var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.arrayIteratorImpl=function(a){var b=0;return function(){return b<a.length?{done:!1,value:a[b++]}:{done:!0}}};$jscomp.arrayIterator=function(a){return{next:$jscomp.arrayIteratorImpl(a)}};$jscomp.makeIterator=function(a){var b="undefined"!=typeof Symbol&&Symbol.iterator&&a[Symbol.iterator];return b?b.call(a):$jscomp.arrayIterator(a)};$jscomp.arrayFromIterator=function(a){for(var b,c=[];!(b=a.next()).done;)c.push(b.value);return c};
$jscomp.arrayFromIterable=function(a){return a instanceof Array?a:$jscomp.arrayFromIterator($jscomp.makeIterator(a))};$jscomp.findInternal=function(a,b,c){a instanceof String&&(a=String(a));for(var d=a.length,f=0;f<d;f++){var e=a[f];if(b.call(c,e,f,a))return{i:f,v:e}}return{i:-1,v:void 0}};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.SIMPLE_FROUND_POLYFILL=!1;
$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){a!=Array.prototype&&a!=Object.prototype&&(a[b]=c.value)};$jscomp.getGlobal=function(a){a=["object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global,a];for(var b=0;b<a.length;++b){var c=a[b];if(c&&c.Math==Math)return c}throw Error("Cannot find global object");};$jscomp.global=$jscomp.getGlobal(this);
$jscomp.polyfill=function(a,b,c,d){if(b){c=$jscomp.global;a=a.split(".");for(d=0;d<a.length-1;d++){var f=a[d];f in c||(c[f]={});c=c[f]}a=a[a.length-1];d=c[a];b=b(d);b!=d&&null!=b&&$jscomp.defineProperty(c,a,{configurable:!0,writable:!0,value:b})}};$jscomp.polyfill("Array.prototype.find",function(a){return a?a:function(a,c){return $jscomp.findInternal(this,a,c).v}},"es6","es3");$jscomp.polyfill("Object.is",function(a){return a?a:function(a,c){return a===c?0!==a||1/a===1/c:a!==a&&c!==c}},"es6","es3");
$jscomp.polyfill("Array.prototype.includes",function(a){return a?a:function(a,c){var b=this;b instanceof String&&(b=String(b));var f=b.length;c=c||0;for(0>c&&(c=Math.max(c+f,0));c<f;c++){var e=b[c];if(e===a||Object.is(e,a))return!0}return!1}},"es7","es3");
$jscomp.checkStringArgs=function(a,b,c){if(null==a)throw new TypeError("The 'this' value for String.prototype."+c+" must not be null or undefined");if(b instanceof RegExp)throw new TypeError("First argument to String.prototype."+c+" must not be a regular expression");return a+""};$jscomp.polyfill("String.prototype.includes",function(a){return a?a:function(a,c){return-1!==$jscomp.checkStringArgs(this,a,"includes").indexOf(a,c||0)}},"es6","es3");
$jscomp.polyfill("String.prototype.startsWith",function(a){return a?a:function(a,c){var b=$jscomp.checkStringArgs(this,a,"startsWith");a+="";var f=b.length,e=a.length;c=Math.max(0,Math.min(c|0,b.length));for(var g=0;g<e&&c<f;)if(b[c++]!=a[g++])return!1;return g>=e}},"es6","es3");$jscomp.checkEs6ConformanceViaProxy=function(){try{var a={},b=Object.create(new $jscomp.global.Proxy(a,{get:function(c,d,f){return c==a&&"q"==d&&f==b}}));return!0===b.q}catch(c){return!1}};
$jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS=!1;$jscomp.ES6_CONFORMANCE=$jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS&&$jscomp.checkEs6ConformanceViaProxy();$jscomp.SYMBOL_PREFIX="jscomp_symbol_";$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};$jscomp.SymbolClass=function(a,b){this.$jscomp$symbol$id_=a;$jscomp.defineProperty(this,"description",{configurable:!0,writable:!0,value:b})};
$jscomp.SymbolClass.prototype.toString=function(){return this.$jscomp$symbol$id_};$jscomp.Symbol=function(){function a(c){if(this instanceof a)throw new TypeError("Symbol is not a constructor");return new $jscomp.SymbolClass($jscomp.SYMBOL_PREFIX+(c||"")+"_"+b++,c)}var b=0;return a}();
$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var a=$jscomp.global.Symbol.iterator;a||(a=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("Symbol.iterator"));"function"!=typeof Array.prototype[a]&&$jscomp.defineProperty(Array.prototype,a,{configurable:!0,writable:!0,value:function(){return $jscomp.iteratorPrototype($jscomp.arrayIteratorImpl(this))}});$jscomp.initSymbolIterator=function(){}};
$jscomp.initSymbolAsyncIterator=function(){$jscomp.initSymbol();var a=$jscomp.global.Symbol.asyncIterator;a||(a=$jscomp.global.Symbol.asyncIterator=$jscomp.global.Symbol("Symbol.asyncIterator"));$jscomp.initSymbolAsyncIterator=function(){}};$jscomp.iteratorPrototype=function(a){$jscomp.initSymbolIterator();a={next:a};a[$jscomp.global.Symbol.iterator]=function(){return this};return a};$jscomp.owns=function(a,b){return Object.prototype.hasOwnProperty.call(a,b)};
$jscomp.polyfill("WeakMap",function(a){function b(){if(!a||!Object.seal)return!1;try{var b=Object.seal({}),d=Object.seal({}),c=new a([[b,2],[d,3]]);if(2!=c.get(b)||3!=c.get(d))return!1;c.delete(b);c.set(d,4);return!c.has(b)&&4==c.get(d)}catch(q){return!1}}function c(){}function d(a){var b=typeof a;return"object"===b&&null!==a||"function"===b}function f(a){if(!$jscomp.owns(a,g)){var b=new c;$jscomp.defineProperty(a,g,{value:b})}}function e(a){var b=Object[a];b&&(Object[a]=function(a){if(a instanceof
c)return a;f(a);return b(a)})}if($jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS){if(a&&$jscomp.ES6_CONFORMANCE)return a}else if(b())return a;var g="$jscomp_hidden_"+Math.random();e("freeze");e("preventExtensions");e("seal");var h=0,l=function(a){this.id_=(h+=Math.random()+1).toString();if(a){a=$jscomp.makeIterator(a);for(var b;!(b=a.next()).done;)b=b.value,this.set(b[0],b[1])}};l.prototype.set=function(a,b){if(!d(a))throw Error("Invalid WeakMap key");f(a);if(!$jscomp.owns(a,g))throw Error("WeakMap key fail: "+
a);a[g][this.id_]=b;return this};l.prototype.get=function(a){return d(a)&&$jscomp.owns(a,g)?a[g][this.id_]:void 0};l.prototype.has=function(a){return d(a)&&$jscomp.owns(a,g)&&$jscomp.owns(a[g],this.id_)};l.prototype.delete=function(a){return d(a)&&$jscomp.owns(a,g)&&$jscomp.owns(a[g],this.id_)?delete a[g][this.id_]:!1};return l},"es6","es3");$jscomp.MapEntry=function(){};
$jscomp.polyfill("Map",function(a){function b(){if($jscomp.ASSUME_NO_NATIVE_MAP||!a||"function"!=typeof a||!a.prototype.entries||"function"!=typeof Object.seal)return!1;try{var b=Object.seal({x:4}),d=new a($jscomp.makeIterator([[b,"s"]]));if("s"!=d.get(b)||1!=d.size||d.get({x:4})||d.set({x:4},"t")!=d||2!=d.size)return!1;var c=d.entries(),f=c.next();if(f.done||f.value[0]!=b||"s"!=f.value[1])return!1;f=c.next();return f.done||4!=f.value[0].x||"t"!=f.value[1]||!c.next().done?!1:!0}catch(q){return!1}}
if($jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS){if(a&&$jscomp.ES6_CONFORMANCE)return a}else if(b())return a;$jscomp.initSymbolIterator();var c=new WeakMap,d=function(a){this.data_={};this.head_=g();this.size=0;if(a){a=$jscomp.makeIterator(a);for(var b;!(b=a.next()).done;)b=b.value,this.set(b[0],b[1])}};d.prototype.set=function(a,b){a=0===a?0:a;var d=f(this,a);d.list||(d.list=this.data_[d.id]=[]);d.entry?d.entry.value=b:(d.entry={next:this.head_,previous:this.head_.previous,head:this.head_,key:a,
value:b},d.list.push(d.entry),this.head_.previous.next=d.entry,this.head_.previous=d.entry,this.size++);return this};d.prototype.delete=function(a){a=f(this,a);return a.entry&&a.list?(a.list.splice(a.index,1),a.list.length||delete this.data_[a.id],a.entry.previous.next=a.entry.next,a.entry.next.previous=a.entry.previous,a.entry.head=null,this.size--,!0):!1};d.prototype.clear=function(){this.data_={};this.head_=this.head_.previous=g();this.size=0};d.prototype.has=function(a){return!!f(this,a).entry};
d.prototype.get=function(a){return(a=f(this,a).entry)&&a.value};d.prototype.entries=function(){return e(this,function(a){return[a.key,a.value]})};d.prototype.keys=function(){return e(this,function(a){return a.key})};d.prototype.values=function(){return e(this,function(a){return a.value})};d.prototype.forEach=function(a,b){for(var d=this.entries(),c;!(c=d.next()).done;)c=c.value,a.call(b,c[1],c[0],this)};d.prototype[Symbol.iterator]=d.prototype.entries;var f=function(a,b){var d=b&&typeof b;"object"==
d||"function"==d?c.has(b)?d=c.get(b):(d=""+ ++h,c.set(b,d)):d="p_"+b;var f=a.data_[d];if(f&&$jscomp.owns(a.data_,d))for(a=0;a<f.length;a++){var e=f[a];if(b!==b&&e.key!==e.key||b===e.key)return{id:d,list:f,index:a,entry:e}}return{id:d,list:f,index:-1,entry:void 0}},e=function(a,b){var d=a.head_;return $jscomp.iteratorPrototype(function(){if(d){for(;d.head!=a.head_;)d=d.previous;for(;d.next!=d.head;)return d=d.next,{done:!1,value:b(d)};d=null}return{done:!0,value:void 0}})},g=function(){var a={};return a.previous=
a.next=a.head=a},h=0;return d},"es6","es3");
$jscomp.polyfill("Set",function(a){function b(){if($jscomp.ASSUME_NO_NATIVE_SET||!a||"function"!=typeof a||!a.prototype.entries||"function"!=typeof Object.seal)return!1;try{var b=Object.seal({x:4}),c=new a($jscomp.makeIterator([b]));if(!c.has(b)||1!=c.size||c.add(b)!=c||1!=c.size||c.add({x:4})!=c||2!=c.size)return!1;var e=c.entries(),g=e.next();if(g.done||g.value[0]!=b||g.value[1]!=b)return!1;g=e.next();return g.done||g.value[0]==b||4!=g.value[0].x||g.value[1]!=g.value[0]?!1:e.next().done}catch(h){return!1}}
if($jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS){if(a&&$jscomp.ES6_CONFORMANCE)return a}else if(b())return a;$jscomp.initSymbolIterator();var c=function(a){this.map_=new Map;if(a){a=$jscomp.makeIterator(a);for(var b;!(b=a.next()).done;)this.add(b.value)}this.size=this.map_.size};c.prototype.add=function(a){a=0===a?0:a;this.map_.set(a,a);this.size=this.map_.size;return this};c.prototype.delete=function(a){a=this.map_.delete(a);this.size=this.map_.size;return a};c.prototype.clear=function(){this.map_.clear();
this.size=0};c.prototype.has=function(a){return this.map_.has(a)};c.prototype.entries=function(){return this.map_.entries()};c.prototype.values=function(){return this.map_.values()};c.prototype.keys=c.prototype.values;c.prototype[Symbol.iterator]=c.prototype.values;c.prototype.forEach=function(a,b){var d=this;this.map_.forEach(function(c){return a.call(b,c,c,d)})};return c},"es6","es3");
$jscomp.iteratorFromArray=function(a,b){$jscomp.initSymbolIterator();a instanceof String&&(a+="");var c=0,d={next:function(){if(c<a.length){var f=c++;return{value:b(f,a[f]),done:!1}}d.next=function(){return{done:!0,value:void 0}};return d.next()}};d[Symbol.iterator]=function(){return d};return d};$jscomp.polyfill("Array.prototype.keys",function(a){return a?a:function(){return $jscomp.iteratorFromArray(this,function(a){return a})}},"es6","es3");$jscomp.FORCE_POLYFILL_PROMISE=!1;
$jscomp.polyfill("Promise",function(a){function b(){this.batch_=null}function c(a){return a instanceof f?a:new f(function(b,d){b(a)})}if(a&&!$jscomp.FORCE_POLYFILL_PROMISE)return a;b.prototype.asyncExecute=function(a){if(null==this.batch_){this.batch_=[];var b=this;this.asyncExecuteFunction(function(){b.executeBatch_()})}this.batch_.push(a)};var d=$jscomp.global.setTimeout;b.prototype.asyncExecuteFunction=function(a){d(a,0)};b.prototype.executeBatch_=function(){for(;this.batch_&&this.batch_.length;){var a=
this.batch_;this.batch_=[];for(var b=0;b<a.length;++b){var d=a[b];a[b]=null;try{d()}catch(k){this.asyncThrow_(k)}}}this.batch_=null};b.prototype.asyncThrow_=function(a){this.asyncExecuteFunction(function(){throw a;})};var f=function(a){this.state_=0;this.result_=void 0;this.onSettledCallbacks_=[];var b=this.createResolveAndReject_();try{a(b.resolve,b.reject)}catch(l){b.reject(l)}};f.prototype.createResolveAndReject_=function(){function a(a){return function(c){d||(d=!0,a.call(b,c))}}var b=this,d=!1;
return{resolve:a(this.resolveTo_),reject:a(this.reject_)}};f.prototype.resolveTo_=function(a){if(a===this)this.reject_(new TypeError("A Promise cannot resolve to itself"));else if(a instanceof f)this.settleSameAsPromise_(a);else{a:switch(typeof a){case "object":var b=null!=a;break a;case "function":b=!0;break a;default:b=!1}b?this.resolveToNonPromiseObj_(a):this.fulfill_(a)}};f.prototype.resolveToNonPromiseObj_=function(a){var b=void 0;try{b=a.then}catch(l){this.reject_(l);return}"function"==typeof b?
this.settleSameAsThenable_(b,a):this.fulfill_(a)};f.prototype.reject_=function(a){this.settle_(2,a)};f.prototype.fulfill_=function(a){this.settle_(1,a)};f.prototype.settle_=function(a,b){if(0!=this.state_)throw Error("Cannot settle("+a+", "+b+"): Promise already settled in state"+this.state_);this.state_=a;this.result_=b;this.executeOnSettledCallbacks_()};f.prototype.executeOnSettledCallbacks_=function(){if(null!=this.onSettledCallbacks_){for(var a=0;a<this.onSettledCallbacks_.length;++a)e.asyncExecute(this.onSettledCallbacks_[a]);
this.onSettledCallbacks_=null}};var e=new b;f.prototype.settleSameAsPromise_=function(a){var b=this.createResolveAndReject_();a.callWhenSettled_(b.resolve,b.reject)};f.prototype.settleSameAsThenable_=function(a,b){var d=this.createResolveAndReject_();try{a.call(b,d.resolve,d.reject)}catch(k){d.reject(k)}};f.prototype.then=function(a,b){function d(a,b){return"function"==typeof a?function(b){try{c(a(b))}catch(w){e(w)}}:b}var c,e,g=new f(function(a,b){c=a;e=b});this.callWhenSettled_(d(a,c),d(b,e));return g};
f.prototype.catch=function(a){return this.then(void 0,a)};f.prototype.callWhenSettled_=function(a,b){function d(){switch(c.state_){case 1:a(c.result_);break;case 2:b(c.result_);break;default:throw Error("Unexpected state: "+c.state_);}}var c=this;null==this.onSettledCallbacks_?e.asyncExecute(d):this.onSettledCallbacks_.push(d)};f.resolve=c;f.reject=function(a){return new f(function(b,d){d(a)})};f.race=function(a){return new f(function(b,d){for(var f=$jscomp.makeIterator(a),e=f.next();!e.done;e=f.next())c(e.value).callWhenSettled_(b,
d)})};f.all=function(a){var b=$jscomp.makeIterator(a),d=b.next();return d.done?c([]):new f(function(a,f){function e(b){return function(d){g[b]=d;h--;0==h&&a(g)}}var g=[],h=0;do g.push(void 0),h++,c(d.value).callWhenSettled_(e(g.length-1),f),d=b.next();while(!d.done)})};return f},"es6","es3");
$jscomp.polyfill("Array.from",function(a){return a?a:function(a,c,d){c=null!=c?c:function(a){return a};var b=[],e="undefined"!=typeof Symbol&&Symbol.iterator&&a[Symbol.iterator];if("function"==typeof e){a=e.call(a);for(var g=0;!(e=a.next()).done;)b.push(c.call(d,e.value,g++))}else for(e=a.length,g=0;g<e;g++)b.push(c.call(d,a[g],g));return b}},"es6","es3");$jscomp.polyfill("Array.of",function(a){return a?a:function(a){return Array.from(arguments)}},"es6","es3");
$jscomp.polyfill("Object.values",function(a){return a?a:function(a){var b=[],d;for(d in a)$jscomp.owns(a,d)&&b.push(a[d]);return b}},"es8","es3");$jscomp.polyfill("Array.prototype.findIndex",function(a){return a?a:function(a,c){return $jscomp.findInternal(this,a,c).i}},"es6","es3");$jscomp.polyfill("Array.prototype.flatMap",function(a){return a?a:function(a,c){for(var b=[],f=0;f<this.length;f++){var e=a.call(c,this[f],f,this);Array.isArray(e)?b.push.apply(b,e):b.push(e)}return b}},"es9","es5");
$jscomp.assign="function"==typeof Object.assign?Object.assign:function(a,b){for(var c=1;c<arguments.length;c++){var d=arguments[c];if(d)for(var f in d)$jscomp.owns(d,f)&&(a[f]=d[f])}return a};$jscomp.polyfill("Object.assign",function(a){return a||$jscomp.assign},"es6","es3");
$jscomp.polyfill("String.prototype.repeat",function(a){return a?a:function(a){var b=$jscomp.checkStringArgs(this,null,"repeat");if(0>a||1342177279<a)throw new RangeError("Invalid count value");a|=0;for(var d="";a;)if(a&1&&(d+=b),a>>>=1)b+=b;return d}},"es6","es3");$jscomp.stringPadding=function(a,b){a=void 0!==a?String(a):" ";return 0<b&&a?a.repeat(Math.ceil(b/a.length)).substring(0,b):""};
$jscomp.polyfill("String.prototype.padStart",function(a){return a?a:function(a,c){var b=$jscomp.checkStringArgs(this,null,"padStart");return $jscomp.stringPadding(c,a-b.length)+b}},"es8","es3");$jscomp.polyfill("Array.prototype.values",function(a){return a?a:function(){return $jscomp.iteratorFromArray(this,function(a,c){return c})}},"es8","es3");$jscomp.polyfill("Number.isFinite",function(a){return a?a:function(a){return"number"!==typeof a?!1:!isNaN(a)&&Infinity!==a&&-Infinity!==a}},"es6","es3");
$jscomp.polyfill("Number.isInteger",function(a){return a?a:function(a){return Number.isFinite(a)?a===Math.floor(a):!1}},"es6","es3");var functions;
function NS_functions(){this.operationWaitingPollingInterval=3E3;this.operationWaitingNumberRetries=2;this.currentRetry=0;this.serviceFreeAmountCatalog={};this.updatePrices=function(){var a=this,b=0;$(".table_container").each(function(){var c=0,d=0;$(this).find("tr").each(function(){var b=0,e=!0;var g=$('td.quantity select, td.quantity input[type="text"], td.quantity input[type="number"], td.quantity input[type="hidden"][name$="\\.quantity"], td.item_room input[type="hidden"][name$="\\.quantity"]',this);
0<g.length&&(e=a.validateQuantityInputField(g));var h=$(this).find(".unit_price .amount:not(.resale_min, .resale_max)").last();var l=$(this).find('.subscription input[type="checkbox"]');if(0<g.length&&e&&(0===l.length||l.is(":checked"))){e="true"===g.siblings('input[name$="\\.isFreeAmount"]').val();l=g.parents(".quantity").siblings(".unit_price").find('input[name$="\\.unitPrice"]');var k=g.parents(".quantity").siblings(".item").find('input[name$="\\.itemId"][type="hidden"]').val();if(!e||l&&a.validatePrice(0!==
l.val().length,l,null,a.serviceFreeAmountCatalog[k]))b=parseInt($(g).val(),10);h=h.data("amount")||0;e&&0!==b&&0!==h&&(g=g.parents(".quantity").find("[name*=audienceSubCategory]").val(),h+=a.calculateChargeThenUpdateMaxChargeInstruction(h,g,this,".table_container"));g=b*h;$(this).find(".subtotal .amount").html(functions.generateAmount(g));c+=g;d+=b}else $(this).find(".subtotal .amount").html(functions.generateAmount(0))});$(this).find("tr.subtotal td.reservation_amount .amount").html(functions.generateAmount(c));
b+=c;"undefined"!==typeof selectedProductPlural&&selectedProductPlural&&a.updateSelectedQuantityIndicator(d,this);a.alertTotalTicketAmount($(".subtotal.with_submit_button .reservation_amount"))});return b};this.updateSelectedQuantityIndicator=function(a,b){var c=selectedProductPlural;b=$(b).find("tr.subtotal .quantity");0<a?(1===a&&(c=selectedProductSingular),b.show()):b.hide();b.html(a+" "+c)};this.addCardNumberSeparators=function(a){return a.split("-").join("").match(/.{1,4}/g).join("-")};this.handleFormSubmit=
function(a,b,c,d,f){if(!(d&&secutix.date&&secutix.date.picker&&secutix.date.picker.check&&secutix.date.picker.check.isDatepickerSetToToday(d))){$("#notification").hide();$("#noTPEConnected").hide();b=$(b).parents("form:first");if(a)b.one("submit",function(){var a;var b=function(){$(this).attr("disabled","disabled").addClass("submit-form-disabled")};var d=function(){""===$(this).val()&&$(this).attr("disabled","disabled").addClass("submit-form-disabled")};var l=0;for(a=c.length;l<a;l++){var k=c[l].split(".")[0];
$(this).find('[name^="'+k+'"]').each(b);$(this).find('[name^="preferredAreas"]').each(d)}f&&$(this).find('input[type="hidden"][id="checkout"]').each(function(a,b){$(b).val(!0)});return!0});b.submit()}};this.validateQuantities=function(a,b,c,d,f,e){var g=this,h=!1,l=!0,k=!0,m,p;b=b||".table_container";$("#emptyMemberCard").hasClass("hidden")||$("#emptyMemberCard").addClass("hidden");g.hideAllFreeAmountErrorMess();$(".main_content_notification:has(.error)").not(".hidden").addClass("hidden");var q=!1;
var r=[];$(b).each(function(){$('td.quantity select, td.quantity input[type="text"], td.quantity input[type="number"], td.unit_price input[type="hidden"][name$="\\.quantity"]',this).each(function(){g.validateQuantityInputField($(this))?0<parseInt($(this).val(),10)?q=!0:r.push($(this).attr("name")):h=!0})});h||"undefined"===typeof conditionalRatesMessage||"function"!==typeof conditionalRatesMessage.validateContionalQuantities||(h=!conditionalRatesMessage.validateContionalQuantities());h?f&&f(!1):($('.unit_price input[type="text"], input[name$="\\.unitPrice"]').each(function(){var a=
$(this).parents(".package_line_item_selector");0!==a.length?a.parent().hasClass("disabled")||(l&=packages.validatePrice(!0,$(this))):(m=$(this).parents(".unit_price").siblings(".quantity").find('select[name$="\\.quantity"],input:visible[name$="\\.quantity"]'),p=$(this).parents(".unit_price").siblings(".item").find('input[name$="\\.itemId"][type="hidden"]').val(),0!==m.length&&0<parseInt(m.val(),10)&&(l=l&&g.validatePrice(!0,$(this),null,g.serviceFreeAmountCatalog[p])),0===m.length&&0!==$(this).val().length&&
(q=!0,l=l&&g.validatePrice(!0,$(this),null,g.serviceFreeAmountCatalog[p])))}),q&&l&&"undefined"!==typeof audSubCatVerification?audSubCatVerification.validateAllQuantities(c,!1,function(c){c?g.handleFormSubmit(a,b,r,d,e):k=!1;f&&f(k)}):(audSubCatVerification||g.handleFormSubmit(a,b,r,d,e),q||(k=!1,$(".main_content_notification:has(.error)").not(".hidden").addClass("hidden"),$("#notification.hidden").removeClass("hidden"),window.scrollTo(0,0)),f&&f(k)))};this.validateQuantityInputField=function(a){var b=
[{rule:validation.numericRule(!0)},{rule:validation.numericBoundsRule(a.data("minQuantity"),a.data("maxQuantity"),!0,!0)}];return validation.validateField(a,b,null,!0)};this.validateQuantityInputFieldAndHideTooltipIfOk=function(a){var b=[{rule:validation.numericRule(!0)},{rule:validation.numericBoundsRule(a.data("minQuantity"),a.data("maxQuantity"),!0,!0)}];return validation.validateFieldAndHandleTooltip(!0,a,b,null,!0)};this.validateUnitPriceInputField=function(a){var b=a.attr("name").split("[")[1].split("]")[0];
b=0===parseInt($('[name="serviceFormData['+b+'].quantity"]').val(),10)||0>=a.data("minQuantity");var c=[{rule:validation.numericBoundsRule(a.data("minQuantity"),a.data("maxQuantity"),b,!1,void 0,function(a){return 1E3*a}),errorId:"freeAmountRange"}];a.parent().removeClass("error");c=validation.validateField(a,c,null,!0,!0);c||(a.removeClass("error"),a.parent().addClass("error"));b||0!==a.val().length||(c=!1,a.parent().addClass("error"));void 0!==preventFormSubmit&&preventFormSubmit&&(c=!1);return c};
this.updateOrderAmount=function(a){var b=parseInt($("#saleAmountValue").val(),10)+a;0===b?($(".button.pay").hide(),$(".button.not_paying").show()):($(".button.pay").show(),$(".button.not_paying").hide());$("#final_amount").html(functions.generateAmount(b));$(".main_content_summary_delivery .subtotal .amount").html(functions.generateAmount(a))};this.conditionsAccepted=function(a){if(!$("#conditionsAccepted1").is(":checked"))return $(".main_content_group.hidden").removeClass("hidden"),window.scrollTo(0,
0),!1;$("#notification").hide();$("#noTPEConnected").hide();tools.form.submitWithProcessing($("form:first"))};this.getIntPartFromAmount=function(a){var b="0",c=/(\d+)(\d{3})/;if(a.length<secutixAmountDecimalSize+1)return b;b=a.substring(0,a.length-secutixAmountDecimalSize);if(1===priceSeparator.length&&0<b.length)for(;c.test(b);)b=b.replace(c,"$1"+priceSeparator+"$2");return b};this.getDoublePartFromAmount=function(a){var b;var c="1";for(b=1;b<=secutixAmountDecimalSize;b++)c+="0";return a/parseInt(c,
10)};this.getMantissaFromAmount=function(a){var b,c="";if(0===currencyFractionDigit)return"";for(b=a.length;b<secutixAmountDecimalSize;b++)a="0"+a;a=a.substring(Math.max(a.length-secutixAmountDecimalSize,0),a.length-secutixAmountDecimalSize+currencyFractionDigit);for(b=0;b<currencyFractionDigit;b++)c+="0";return a===c?zeroCentLabel:a};this.generateAmount=function(a){var b="";if(void 0!==a&&null!==a){a=a.toString();var c=functions.getMantissaFromAmount(a);c===zeroCentLabel&&(b="zeroCentMantissa");
a='<span class="int_part">'+functions.getIntPartFromAmount(a)+"</span>";c='<span class="mantissa '+b+'">'+c+"</span>";var d='<span class="currency currency_code">'+currencyCode+"</span>";var f='<span class="currency currency_symbol">'+currencySymbol+"</span>";b='<span class="decimal_separator '+b+'">'+amountDecimalSeaparator+"</span>";var e=amountFormat;e=e.replace("{amountIntPart}",a);e=e.replace("{amountMantissa}",c);e=e.replace("{currencyCode}",d);e=e.replace("{currencySymbol}",f);return e=e.replace("{decimalSeparator}",
b)}};this.stringToStxAmount=function(a){var b=a.indexOf("."),c=0;-1!==b&&(c=Math.min(a.length-b-1,secutixAmountDecimalSize),a=a.substring(0,b)+a.substring(b+1,b+1+c));for(b=c;b<secutixAmountDecimalSize;b++)a+="0";return parseInt(a,10)};this.hideAllFreeAmountErrorMess=function(){$("#freeAmountRange").hide();$("#nonIntUnitPriceError").hide();$("#noAmount").hide();$(".main_content_notification:has(.error)").not(".hidden").addClass("hidden")};this.validatePrice=function(a,b,c,d){var f=!b.data("previousEntry")||
b.data("previousEntry")!=b.val();b.parent().removeClass("error");functions.hideAllFreeAmountErrorMess();preventFormSubmit=!1;if(f&&c){var e=0;c.html(functions.generateAmount(e));c.data("amount",e);b.data("previousEntry",b.val())}if(0===b.val().length)return a&&(b.parent().addClass("error"),$("#noAmount").show(),preventFormSubmit=!0),!1;if(!$.isNumeric(b.val())||10<b.val().length)return a&&(b.parent().addClass("error"),d&&d.nonInt&&($("#nonIntUnitPriceError").find("#nonInt").html(d.nonInt),$("#nonIntUnitPriceError").show()),
preventFormSubmit=!0),!1;e=functions.stringToStxAmount(b.val());d&&"DONATION"===d.productType||(e-=e%1E3);if(e<parseInt(b.data("minQuantity"),10)||e>parseInt(b.data("maxQuantity"),10)||e<parseInt(b.attr("minquantity"),10)||e>parseInt(b.attr("maxquantity"),10))return a&&(b.parent().addClass("error"),d&&d.noMatchError&&($("#freeAmountRange").find("#freeAmountRangeErrorMess").html(d.noMatchError),$("#freeAmountRange").show()),preventFormSubmit=!0),!1;f&&c&&(c.html(functions.generateAmount(e)),c.data("amount",
e),b.data("previousEntry",b.val()));return!0};this.checkCrossSell=function(a,b){if(window.location&&window.location.protocol==="file:"){return false;}var c=void 0!==b?b:"confirmationDialog_"+a;$.ajax({type:"POST",url:contextPath+"/ajax/cart/cancelOperations/checkCrossSell",cache:!1,data:{operationIds:a},success:function(a){""!==a?($("#"+c).attr("title",crossSellDialogTitle),$("#"+c).find(".dialog-message").html(a),$("#"+c).find(".dialog-button-ok").find(".text").html(crossSellDialogRemove),$("#"+c).find(".dialog-button-cancel").find(".text").html(crossSellDialogCancel),
tools.dialog.showDialog(c,!0,!1,!1,"cross-sell-dialog")):tools.dialog.showDialog(c,!0,!0,!1,"cancel_message_dialog")},error:function(){tools.dialog.showDialog("ajaxErrorDialog",!0)}})};this.cancelOperations=function(a,b){this.genericAjaxPost(contextPath+"/ajax/cart/cancelOperations",{operationIds:b},function(a){util.storeSession.removeSessionStorage();isNaN(a)?tools.dialog.showDialog("concurrencyDialog",!0,!0):-1==a?tools.dialog.showDialog("removeMainOwnerTicketError",!0,!0):window.location.reload()})};
this.cancelMovement=function(a){this.genericAjaxPost(contextPath+"/ajax/cart/cancelMovement",{movementId:a},function(a){switch(a.status){case "ERR_DEGRESSIVE_RATE_NOT_SUPPORT":functions.showToastMessage({message:SecuTixLabels.cancelMovement.degressiveTariffNotSupported});break;case "ERR_CONDITIONAL_TARIFF_NOT_SUPPORT":functions.showToastMessage({message:SecuTixLabels.cancelMovement.conditionalTariffNotSupported});break;case "ERR_MIN_QUANTITY_TARIFF_EXCEED":functions.showToastMessage({message:SecuTixLabels.cancelMovement.minQuantityTariffExceeded});
break;case "ERR_CONDITIONAL_XSELL_NOT_SUPPORT":functions.showToastMessage({message:SecuTixLabels.cancelMovement.conditionalXSellNotSupported});break;case "ERR_GROUP_VISIT_NOT_SUPPORT":functions.showToastMessage({message:SecuTixLabels.cancelMovement.groupVisitNotSupported});break;default:window.location.reload()}},!0)};this.updateColleagueDistribution=function(a,b){tools.dialog.showWaitingPopup("requestProcessingDialog",!0);$.ajax({type:"POST",url:contextPath+"/ajax/account/distribution/colleague",
cache:!1,data:{colleagueContactNumber:a},success:function(){window.location.href=b?b:contextPath+"/pro/account/distribution/distributionPortal?loadFirstMobileIfETicketsIsEmpty=true"},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}})};this.clearSessionStoreByKey=function(a){sessionStorage.removeItem(a)};this.showToastMessage=function(a){var b=void 0===a.title?"":a.title,c=void 0===a.message?"":a.message,d=void 0===a.type?"info":a.type,f=void 0===
a.duration?3E3:a.duration;setTimeout(function(){var a=document.getElementById("toastMessage");if(a){var g=document.createElement("div"),h=setTimeout(function(){a.removeChild(g)},f+1E3);g.onclick=function(b){b.target.closest(".toast__close")&&(a.removeChild(g),clearTimeout(h))};var l=(f/1E3).toFixed(2);g.classList.add("toast","toast--"+d);g.style.animation="slideInLeft ease-in-out .3s forwards, fadeOut ease-in-out .3s forwards "+l+"s";l='<div class="toast__icon"></div><div class="toast__body">';b&&
""!==b.trim()&&(l+='<h3 class="toast__title">'+b+"</h3>");l+='<p class="toast__msg">'+c+"</p></h3>";g.innerHTML=l+'</div><i class="toast__close"></i>';g.setAttribute("role","alert");a.appendChild(g)}},50)};this.genericAjaxPost=function(a,b,c,d){tools.dialog.showWaitingPopup("loadingDialog",!0);$.ajax({type:"POST",url:a,cache:!1,data:b,success:function(a){tools.dialog.hideDialog("loadingDialog");c(a)},error:function(){tools.dialog.hideDialog("loadingDialog");d?tools.dialog.showDialog("ajaxErrorDialogReload",
!0,!0):tools.dialog.showDialog("ajaxErrorDialog",!0)}})};this.interruptCheckout=function(){tools.dialog.showWaitingPopup("loadingDialog",!0);$.ajax({type:"GET",url:contextPath+"/ajax/checkout/interruptCheckout",cache:!1,success:function(a){location.reload()},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}})};this.cancelCheckout=function(){tools.dialog.showWaitingPopup("loadingDialog",!0);$.ajax({type:"GET",url:contextPath+"/ajax/checkout/cancelCheckout",
cache:!1,success:function(a){location.reload()},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}})};this.toggleTableView=function(a,b){b=b?$("#table_"+b):$(a).closest(".seat_category_section").find("table");functions.toggleElementViewStatus(b,a)};this.toggleElementViewStatus=function(a,b){a.toggle(0,function(){var a=compactCheckoutViewShow;$(this).is(":visible")?(a=compactCheckoutViewHide,$(b).parent().removeClass("plus"),$(b).parent().addClass("less"),
$(b).parent().attr("aria-expanded","true")):($(b).parent().removeClass("less"),$(b).parent().addClass("plus"),$(b).parent().attr("aria-expanded","false"));$(b).find(".text").html(a)})};this.resetEnclosingForm=function(a,b){$(a).closest("form")[0].reset();!0!==b&&$(a).closest("form").find("table").each(function(){$(this).find("input[type='radio']").each(function(){if(!$(this).is(":disabled"))return $(this).prop("checked",!0),!1})})};this.waitForOperationCompletion=function(){tools.dialog.showWaitingPopup("operationOnGoingDialog",
!0,null);jQuery.ajax({type:"GET",url:contextPath+"/ajax/orderModificationOnGoing",cache:!1,success:function(a){!0===a?functions.currentRetry<functions.operationWaitingNumberRetries?(functions.currentRetry++,setTimeout(functions.waitForOperationCompletion,functions.operationWaitingPollingInterval)):(tools.dialog.hideDialog("operationOnGoingDialog"),tools.dialog.showDialog("ajaxErrorDialogReload",!0,!0)):location.reload()},error:function(){tools.dialog.hideDialog("operationOnGoingDialog");tools.dialog.showDialog("ajaxErrorDialogReload",
!0,!0)}})};this.setSoldOutDivInTable=function(){var a,b=null;$(".table_container .category_unavailable_overlay").each(function(){var c=$(this).attr("data-seat-cat-id");c&&$('tr[class*="'+c+'"]').each(function(){$(this).addClass("seat_category_sold_out")});a=$(this).parent().parent();a.hasClass("seat_category_end")?b=a:(b=a.nextAll("tr.v2-seatcat_"+$(this).data("seatCatId")+":visible").last(),b.length||(b=null));null!==b&&($(this).css(a.position()),$(this).css("height",b.position().top-a.position().top+
b.height()-1+"px"),$(this).css("width",a.width()+"px"),$(this).css("display","block"),$(this).parent().siblings(".quantity").find(".buy_unavailable,.no_quantity").each(function(){$(this).css("visibility","hidden")}))})};this.initAudienceSubCategoryDescription=function(){var a=$(".audience-subcat-desc"),b,c;a.hasClass("mobile")||a.hasClass("tablet")?a.click(function(a){c=$(a.target);b=$("#audience-subcat-desc-popup");0===b.length?b=$("<div></div>",{id:"audience-subcat-desc-popup",title:c.parent().clone().children().remove().end().text(),
"class":"dialog-content",html:c.html()}).appendTo($(document.body)):b.html(c.html());tools.dialog.showDialog("audience-subcat-desc-popup",!0,!1)}):a.hover(function(){$(this).tipsy("show")},function(){$(this).tipsy("hide")})};this.toggleProductDescriptionDetails=function(a){var b=$(a).attr("id");a=$(a).closest(".truncatable_buttons_container");b=b.substring(b.indexOf("_")+1);$(a).prev("#prod_"+b).toggleClass("truncated");$(a).find(".show_more, .show_less").toggle()};this.collapseProductDescriptionDetails=
function(a){$("#prod_"+(a||"")).toggleClass("truncated")};this.printQuote=function(a){a=$(a).parents(".main_content").find(".title_container");0===a.find(".quoteTitle").length&&a.append('<span class="quoteTitle hidden">'+quoteTitle+"</span>");window.print()};this.isWebGLSupport=function(){var a=document.createElement("canvas");return(a=a.getContext("webgl")||a.getContext("experimental-webgl"))&&a instanceof WebGLRenderingContext?((a=a.getExtension("WEBGL_lose_context"))&&a.loseContext(),!0):!1};this.minusQtyButtonClicked=
function(a,b){var c=$(a).closest(".touch_friendly_qty_selection");a=$(c).find(".number input");var d=parseInt($(a).val(),10),f=$(c).find(".button.plus");c=$(c).find(".button.minus");$(c).hasClass("disabled")||(d>b?d--:d===b&&(d=0),a.val(d),a.change(),$(f).hasClass("disabled")&&$(f).removeClass("disabled"),b=0===d,$(c).toggleClass("disabled",b))};this.plusQtyButtonClicked=function(a,b,c){var d=$(a).closest(".touch_friendly_qty_selection");a=$(d).find(".number input");var f=parseInt($(a).val(),10),
e=$(d).find(".button.minus");d=$(d).find(".button.plus");$(d).hasClass("disabled")||(0===f?f=b:f<c&&f++,a.val(f),a.change(),$(e).hasClass("disabled")&&$(e).removeClass("disabled"),b=f===c,$(d).toggleClass("disabled",b))};this.getWindowInnerHeight=function(){var a=jQuery(window).height()||window.innerHeight;a&&0!=a||(a="100%");return a};this.deviceOrientation=function(){var a=functions.getWindowInnerHeight();jQuery("html").css("height",a);jQuery("body").css("height","100.30%");200<$(".pano-thumbnail > iframe").height()?
($(".pano-thumbnail > iframe").height(a),window.scroll(0,0)):$(".pano-thumbnail > iframe").height("100%")};this.stripHtml=function(a){var b=document.createElement("div");b.innerHTML=a;return b.textContent||b.innerText||""};this.handleFallbackImage=function(a,b){var c=this;a&&(b?(a.src=b.shift(),a.onerror=function(){if(b&&b.length)return c.handleFallbackImage(a,b);$(a).hide();return null}):$(a).hide())};this.calculateChargeThenUpdateMaxChargeInstruction=function(a,b,c,d){var f=0;if(0===a||!b||"undefined"===
typeof audienceSubCat2ChargeMap)return 0;(b=audienceSubCat2ChargeMap[b])&&(!b.threshold||a>=Number(b.threshold))&&(b.amount?f=parseFloat(b.amount):b.slope&&(f=a*(parseFloat(b.slope)/100)));if(0===f)return f;a=$(c).parents(d).find(".merge_charges_instruction .amount");if(!a)return f;c=a.data("amount");f>c&&a.html(functions.generateAmount(f));return f};this.detectCapslockOnOff=function(a){a=$("#password, #old_password, #new_password, #password_confirm");var b=function(a){$(a).parent().siblings(".notice_cap_lock_on").remove()},
c=function(a){a=a.originalEvent&&"function"===typeof a.originalEvent.getModifierState&&a.originalEvent.getModifierState("CapsLock");var d=$("<p/>",{"class":"notice_cap_lock_on"});b(this);a&&($(d).html(noticeCapsLockOnMess),$(this).parent().after(d))};a.on("keyup",c);a.on("mousedown",c);a.on("focusout",function(){b(this)})};this.callSampUrl=function(a){a&&$.ajax({type:"GET",url:a,data:{isNeedResponse:!1}}).always(function(){return!1})};this.handleClickWatchStreamContent=function(a,b,c){b&&(this.callSampUrl(c),
b.toLowerCase().includes("<iframe")?($("#"+a).html(b),tools.dialog.showDialog(a,!0,!1,function(){$("#"+a).empty()},"watchStreamButtonContent")):window.open(b))};this.accessibilityVisuallyHiddenSpan=function(a){return $('<span class="accessibility-visually-hidden"></span>').text(a)};this.accessibilityVisuallyHiddenSpanWithID=function(a,b){return $("<span id = "+b+' class="accessibility-visually-hidden"></span>').text(a)};this.accessibilityVisuallyHiddenColWithID=function(a,b){return $('<td class="accessibility-visually-hidden"></td>').text(functions.accessibilityVisuallyHiddenSpanWithID(a,
b).text())};this.addVisuallyHiddenTextForPerformanceSelection=function(){var a=this;$(".performances_group_container .performance").each(function(){var b=$(this).find(".date_time_venue").text(),c=$(this).find(".perf_name_location_container").text(),d=$(this).find(".tariff_availability_container .tariff ").text(),f=$(this).find(".button_container .button a");$(f).append(a.accessibilityVisuallyHiddenSpan(c+b+d))})};this.addVisuallyHiddenTextForTimeSlotSelection=function(){var a=this,b=$("#timeSlotsContainer").find(".timeslot_time.header").text(),
c=$("#timeSlotsContainer").find(".timeslot_from_price.header").text(),d=$("#timeSlotsContainer").find(".timeslot_theme.header").text(),f=$("#timeSlotsContainer").find(".timeslot_language.header").text();$("#timeSlotsContainer .timeslot_simple_container.available").each(function(){var e=$(this).find(".button_container .button a"),g=b+$(this).find(".timeslot_time").text(),h=c+$(this).find(".timeslot_from_price").text(),l=d+$(this).find(".timeslot_theme.theme_language_column ").text(),k=f+$(this).find(".timeslot_language.theme_language_column").text();
$(e).append(a.accessibilityVisuallyHiddenSpan(g+l+k+h))})};this.handleExchangePrefillForUnitRate=function(a){$(".table_container td.quantity").each(function(){var b=$(this).find(".button.minus"),c=$("[name*='audienceSubCategoryId']",this).val(),d=$("[name*='priceLevelId']",this).val(),f=$("[name*='advantageId']",this).val(),e=a.filter(function(a){return c===a.audSubCatId&&d===a.priceLevelId&&f===a.advantageId});if(0<e.length){e=e[0];if(0<$("select",this).length){var g=$("select",this);b=g;g=$.map(g.find("option"),
function(a){return a.value});if(Math.max.apply(Math,$jscomp.arrayFromIterable(g))<e.quantity)return}else b.length&&$(b).removeClass("disabled"),b=$('input[name$="quantity"]',this);b.val(e.quantity);conditionalRatesMessage.updateAppearanceState(b)}})};this.processExchangePrefillValues=function(a,b){b?(b=$("#flat_rate_table .flat_rate_selection_row .tariff select"),0<b.length&&(a=a[0],null!=a&&b.val(a.audSubCatId))):this.handleExchangePrefillForUnitRate(a);this.updatePrices()};this.isFreeAmount=function(){var a=
0!==$("#main_content_cart").length?$("#total .amount").text():$(".reservation_amount .amount")&&$(".reservation_amount .amount").text();return a?0==parseFloat(a.split(" ")[0].replace(/,/g,"")):!1};this.formatLongLocalDateTime=function(a,b){return(new Intl.DateTimeFormat(b,{weekday:"long",month:"long",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1})).format(new Date(a))};this.formatShortLocalDateTime=function(a,b){return(new Intl.DateTimeFormat(b,{month:"long",day:"2-digit",hour:"2-digit",
minute:"2-digit",hour12:!1})).format(new Date(a))};this.debounce=function(a,b){var c;return function(d){for(var f=[],e=0;e<arguments.length;++e)f[e-0]=arguments[e];var g=this;clearTimeout(c);c=setTimeout(function(){a.apply(g,f)},b)}};this.alertMessage=function(a){var b=$('<span role="alert" class="accessibility-visually-hidden">'+a+"</span>");$("body").append(b);setTimeout(function(){b.remove()},1E3)};this.debounceAlertMessage=this.debounce(this.alertMessage,300);this.alertTotalTicketAmount=function(a){var b=
a.find(".reservation_text").text().trim(),c=a.find(".reservation_selected_quantity").text().trim();a=a.find(".amount").text().trim();this.debounceAlertMessage(b+" "+c+" "+a)}}functions=new NS_functions;$(function(){functions.initAudienceSubCategoryDescription();functions.detectCapslockOnOff();"true"==isIOS&&0<$("#seat-map").length&&(window.onresize=function(a){functions.deviceOrientation()},setTimeout(function(){functions.deviceOrientation()},10))});
var tools;
function NS_tools(){var a,b;$(function(){$(document).on("click","input[type=radio]",function(){$(this).focus()});$(document).on("keydown",".add_keyboard_support:focus",function(a){"Enter"===a.key&&$(this).click()});$(document).on("keydown","[aria-expanded=true]",function(a){"Escape"===a.key&&$(this).click()});$(document.body).focusin(function(b){a=b.target});$(document.body).focusout(function(b){a=null});b=$.fn.html;$.fn.html=function(){var d;try{a&&0<this.length&&$.contains(this[0],a)&&(d=finder(a))}catch(e){console.error(e)}var c=
b.apply(this,arguments);0<arguments.length&&d&&$(d).focus();return c}});this.log="undefined"!==typeof console&&"undefined"!==typeof console.log?function(a){console.log(a)}:function(){};this.isInteger=function(a){return/^\d+$/.test(a)};var c=function(){var a=$(this);tools.isInteger(a.val())||a.val("")};this.registerAsIntegerInput=function(a){$("."+a).each(function(a,b){$(this).on("keyup",c).on("change",c)})};this.preventFormAutoSubmit=function(a){$("#"+a).bind("keypress keydown keyup",function(a){if(13==
a.keyCode)return a.preventDefault(),!1})};this.logFeatureIssue=function(a,b){$.ajax({url:contextPath+"/ajax/error/feature",type:"POST",cache:!1,data:{feature:a,description:b},error:function(a){},success:function(a){},complete:function(){}})};this.registerGlobalHandlerAjaxFragmentResponse=function(){$.ajaxSetup({dataFilter:function(a,b){return"string"===$.type(a)&&-1!=a.indexOf("login_form")?(location.reload(!0),""):a}})};this.registerAsToggleLink=function(a,b,c){$("."+a).click(function(a){var d=$(this).parent();
a.preventDefault();$(this).hasClass("less")?($(this).removeClass("less").addClass("plus"),d.removeClass(b),d.parent().find(c).slideUp("slow")):($(this).removeClass("plus").addClass("less"),d.addClass(b),d.parent().find(c).slideDown("slow"))})};this.registerSpecificSupportOfTabKeyForTipsy=function(a,b){b.attr("tabindex",-1);a.bind("focus",function(){b.tipsy("show")}).bind("blur",function(){b.tipsy("hide")})};this.makePath=function(a,b){a=a.split(".");var d=a.length,c;b=b||window;for(c=0;c<d-1;c++){var f=
a[c];b[f]||(b[f]={});b=b[f]}return{scope:b,key:a[d-1]}};this.module=function(a,b,c,g){c=this.makePath(a,c);a=c.key;c=c.scope;if(!("object"===typeof g&&g.hasOwnProperty("loadOnce")&&g.loadOnce&&c.hasOwnProperty(a))){if("function"===typeof b)try{b=b()}catch(h){setTimeout(function(){throw h;},10)}c[a]=b}};this.scrollToElementBottom=function(a,b,c){$("html, body").animate({scrollTop:$(a).offset().top-($(window).height()-$(a).height())+c},b)};this.saveFocusState=function(a){a=a?a.attr("id"):void 0;localStorage.setItem("focused_"+
a,"true")};this.loadFocusState=function(a){localStorage.getItem("focused_"+a)&&($("#"+a).focus(),localStorage.removeItem("focused_"+a))};this.scrollElementInViewport=function(a,b,c){$(a).offset().top+$(a).height()-$(window).scrollTop()>window.innerHeight&&this.scrollToElementBottom(a,b,c)};this.displayLazyImages=function(){var a=setInterval(function(){$("img.lazy").length&&($('img.lazy:not(".image_loaded")').lazyload({effect:"fadeIn",failure_limit:10,threshold:500,skip_invisible:!1,load:function(){$(this).addClass("image_loaded")}}),
clearInterval(a))},100);setTimeout(function(){clearInterval(a)},1E4)};this.makeTooltipAccessible=function(a){var b=setInterval(function(){var d=$(a);if(d&&0===d.length)return!1;clearInterval(b);d.each(function(){var a=$(this);$(this).on("keydown",function(b){"Escape"===b.key&&(0===$(".tipsy").length?a.tipsy("show"):a.tipsy("hide"))})})},1E3);return null};this.dialog=new function(){this.buttons={};this.timeouts={};this.showDialog=function(a,b,c,g,h,l){h=h||"";var d=this,e=null;displayDialogEffects&&
(e="fade");$("body > .tipsy").remove();$("#"+a).dialog({buttons:this.buttons[a]||null,closeText:l?dialogCloseText:null,draggable:!1,closeOnEscape:!0!==c,open:function(b,e){d.forceButtonDisplay();$("#"+a).closest(".ui-dialog").find(".ui-dialog-title").addClass("semantic-no-styling-no-display");isNewTicketShop&&c&&$("#"+a).closest(".ui-dialog").find(".ui-dialog-title").each(function(){$(this).text().trim()||$(this).addClass("no-title-no-close-button")});b=$("#"+a).closest(".ui-dialog").find(".ui-dialog-titlebar-close");
c?b.hide():($(".ui-widget-overlay").bind("click",function(){$("#"+a).dialog("close")}),d._LABEL_CLOSE_DIALOG&&b.attr("aria-label",d._LABEL_CLOSE_DIALOG));tools.isFirefox()&&$(".ui-widget-overlay").css("height",$(document).height()+"px")},close:g,modal:b,width:"auto",resizable:!1,show:e,hide:e,minWidth:50,minHeight:50,dialogClass:h})};this.showDialogWithoutTooltip=function(a,b){tools.dialog.showDialog(a,b,null,null,null,!1)};this.showWaitingPopup=function(a,b,c){tools.dialog.showDialog(a,!0,b,c,"pleaseWaitDialog")};
this.showWaitingPopupDelayed=function(a,b,c,g){var d=this;this.timeouts[a]=setTimeout(function(){delete d.timeouts[a];d.showWaitingPopup(a,b,c)},g)};this.hideDialog=function(a){var b=$("#"+a);this.timeouts.hasOwnProperty(a)&&(clearTimeout(this.timeouts[a]),delete this.timeouts[a]);b.hasClass("ui-dialog-content")&&b.dialog("close")};this.hideDialogAndDestroy=function(a){var b=$("#"+a);this.hideDialog(a);null!=b.dialog("instance")&&b.dialog("destroy")};this.hideDialogAndDelete=function(a){this.hideDialogAndDestroy(a);
$("#"+a).remove()};this.addButton=function(a,b,c){this.buttons[a]||(this.buttons[a]={});this.buttons[a][b]=c};this.hasButtons=function(a){return void 0!==this.buttons[a]};this.forceButtonDisplay=function(){if($("body").hasClass("ie_lte_8")){var a=$(".alternative_button",".ui-dialog-content");var b=$(".button",".ui-dialog-content");b.removeClass("button");a.removeClass("alternative_button");setTimeout(function(){b.addClass("button");a.addClass("alternative_button");a=b=null},0)}}};this.message=new function(){this.show=
function(a,b){a=a||"";b=b||"";$("#message_title").html(a);$("#message_content").html(b);$("#message_container").is(":hidden")||$("#message_container").fadeTo(0,0,function(){$("#message_container").fadeTo(200,1)});$("#message_container").slideDown(200)};this.hide=function(){$("#message_title").html("");$("#message_content").html("");$("#message_container").slideUp(200)}};this.countdown=new function(){var a=null,b=null,c="",g="",h="",l="",k="",m="",p=!1,q=!0,r=!1;this.sessionExpirationTime=this.expirationTime=
0;var t=function(a){var b=new Date;b.setSeconds(b.getSeconds()+a);tools.countdown.expirationTime=b.getTime()};var w=function(){var a,c=null,d=Math.floor((tools.countdown.sessionExpirationTime-(new Date).getTime())/1E3);if(0<d){if(59===d&&tools.dialog.showDialog("expirationExtendDialog",!0,!0,!1,"expiration_dialog"),a=$(".session_countdown_seconds"))c=x(a,d),m!==c&&(m=c,a.each(function(){$(this).html(c);z(a)}))}else tools.dialog.hideDialog("expirationExtendDialog"),tools.dialog.showDialog("sessionUserExpiredDialog",
!0,!0,function(){return window.location.reload()},"session_expire_dialog"),clearInterval(b);return null};this.computeSessionCountdown=function(){var a=util.contact.getContact();a&&a.expires&&(tools.countdown.sessionExpirationTime=Date.parse(a.expires),b=setInterval(w,1E3))};this.setConfig=function(a){c=a.hours;g=a.minutes;h=a.seconds;l=a.and;p=a.isWRCountdown;q=a.isCartEmpty;r=a.hasQueue;t(a.countdownSeconds)};this.updateTimer=function(){$.ajax({type:"GET",url:contextPath+"/ajax/countdown/update",
success:function(a){!1===a.basketEmpty&&a.countdown&&(p=a.countDownWR||!1,t(parseInt(a.countdown,10)))}})};this.reload=function(){location.reload()};var y=function(a){a.addClass("highlight")};var z=function(a){a.removeClass("highlight")};var x=function(a,b){var d=[],e=0,f=0,k=0;if(0<b&&b<=checkoutCountdownThresholdSeconds)return y(a),f=Math.floor(b/60),k=b-60*f,10>f&&(f="0"+f),10>k&&(k="0"+k),d.push(f+":"+k),"00"===f?d.push("&nbsp;"+h):d.push("&nbsp;"+g),d.join("");0<b&&(e=Math.floor(b/3600),f=Math.floor((b-
3600*e)/60),k=b-3600*e-60*f);0<e?d.push(e+" "+c+" "+l+" "+f+" "+g):0<f&&d.push(f+"&nbsp;"+g);0===e&&0===f&&d.push(k+"&nbsp;"+h);return d.join("")};var A=function(){var b,c,d=Math.floor((tools.countdown.expirationTime-(new Date).getTime())/1E3);if(0<d){if(b=$(".countdown_seconds")){var e=x(b,d);k!==e&&(k=e,b.each(function(){d<=checkoutCountdownThresholdSeconds&&(b.closest("#content_countdown").attr("aria-live","off"),b.closest("p").attr("aria-live","off"));$(this).html(e)}))}}else clearTimeout(a),
!1===p?($.ajax({type:"GET",url:contextPath+"/ajax/cart/cartExpiredDataLayer",success:function(a){a&&a.dataLayerInfo&&(c=JSON.parse(a.dataLayerInfo),dataLayer&&c&&a.orderId!==localStorage.getItem("lastOrderId")&&(dataLayer.push(c),localStorage.setItem("lastOrderId",a.orderId)));util.storeSession.removeSessionStorage()}}),tools.dialog.showDialog("expirationDialog",!0,!0,!1,"expiration_dialog")):$.ajax({type:"GET",url:contextPath+"/ajax/wr/status",success:function(a){setTimeout(function(){$.ajax({type:"GET",
url:contextPath+"/ajax/wr/timeout"}).then(function(){a?(tools.dialog.showDialog("timeoutWRExpirationDialog",!0,!0),setTimeout(function(){$("#buttonExpiration").removeAttr("style");$("#timeoutWRExpirationDialog .please_wait").attr("style","display:none")},5E3)):window.location.reload()})},1E3)}})};var C=function(){r?($(".wrCountdownMsg").show(),$(".countdownMsg").hide()):(q?($("#secondary_content_countdown").hide(),$(".flat-cart").hide(),$(".countdownMsg").hide()):$(".countdownMsg").show(),$(".wrCountdownMsg").hide())};
this.startCountdown=function(){C();a||(A(),a=setInterval(A,1E3))};this.stopCountdown=function(){p||clearTimeout(a)}};this.date=new function(){this.DatePicker=function(a,b,c,g){var d=this;this.calendarConfiguration=a;this.isVisitSpecialCalendar=!1;this.preComputedDates={};this.alreadyLoadedMonths={};this.LEGEND_TYPE_NONE=0;this.LEGEND_TYPE_AVAILABILITY=1;this.LEGEND_TYPE_RATE=2;this.LEGEND_TYPE_AVAILABILITY_TABLE=3;this.LEGEND_TYPE_AVAILABILITY_OVER=4;this.tourId=this.crossSellId=this.baseProductId=
this.advantageId=this.productId=void 0;this.dateUpdateUrl=void 0!==g?g:c?"/ajax/selection/package/date/range":"/ajax/event/date/range";this.isPackage=c;this.packageLineId=null;this.rateTypes=[];this.singularText=datePickerConfig.singularText;this.pluralText=datePickerConfig.pluralText;this.legendFree=datePickerConfig.legendFree;this.legendLimited=datePickerConfig.legendLimited;this.legendFull=datePickerConfig.legendFull;this.legendAdvantage=datePickerConfig.legendAdvantage;this.legendToday=datePickerConfig.legendToday;
this.dateFormat=datePickerConfig.dateFormat;this.isAllowHideAvailabilityLegend=datePickerConfig.isAllowHideAvailabilityLegend;this.isAvailabilitiesAreGood=!1;this.cssLegendFree="datepicker_legend_free";this.cssLegendLimited="datepicker_legend_limited";this.cssLegendFull="datepicker_legend_full";this.cssLegendAdvantage="datepicker_legend_advantage";this.cssLegendToday="datepicker_legend_today";this.cssLegendRate="datepicker_legend_rate_";this.legendContainer=".datepicker_legend";this.AVAILABILITY_STATUS=
{AVAILABLE:"available",LIMITED:"limited",SOLD_OUT:"soldOut"};this.availabilityFilter={available:!0,limited:!0,soldOut:!0};this.selectedDateText=this.maxDate=this.minDate=null;this.requirePerformances=b;this.legendType=this.LEGEND_TYPE_NONE;this.showAccessibilityIndicator=this.showAdvantageLegend=!1;this.parseDate=function(a){return $.datepicker.parseDate(this.dateFormat,a)};this.getPerformanceForDate=function(a){return this.getCalendarConfigForDate(a).performances};this.getCalendarConfigForDate=function(a){var b=
0;for(b in this.calendarConfiguration)if(this.calendarConfiguration[b].performanceDate===a)return this.calendarConfiguration[b]};this.getMinDate=function(a){var b;var c=0;for(b=d.calendarConfiguration.length;c<b;c++)if(a=this.parseDate(d.calendarConfiguration[c].performanceDate),void 0===this.minDate||this.minDate>a)this.minDate=a;return this.minDate};this.getMinDateWithAvailability=function(){var a;var b=0;for(a=d.calendarConfiguration.length;b<a;b++)if("NONE"!=d.calendarConfiguration[b].availability){var c=
this.parseDate(d.calendarConfiguration[b].performanceDate);if(void 0===e||e>c)var e=c}return e};this.setMaxDate=function(a){this.maxDate=this.parseDate(a)};this.setMinDate=function(a){this.minDate=this.parseDate(a)};this.preComputeDates=function(a){var b="",c,e;d.isAvailabilitiesAreGood=!0;var f=0;for(e=a.length;f<e;f++){"GOOD"!==a[f].availability&&(d.isAvailabilitiesAreGood=!1);var g=this.parseDate(a[f].performanceDate);if(void 0===this.preComputedDates[g]){0<a[f].numPerformances&&(b=1===a[f].numPerformances?
"1 "+this.singularText:a[f].numPerformances+" "+d.pluralText);var h="datepicker_selectable";if(d.legendType===d.LEGEND_TYPE_AVAILABILITY||d.legendType===d.LEGEND_TYPE_AVAILABILITY_TABLE)"NONE"===a[f].availability?h=d.isPackage?"datepicker_full":h+" datepicker_full":(a[f].advantage&&(h+=" advantage"),"GOOD"===a[f].availability?h+=" datepicker_free":"LIMITED"===a[f].availability&&(h+=" datepicker_limited"));else if(d.legendType===d.LEGEND_TYPE_AVAILABILITY_OVER)b+="\n","NONE"===a[f].availability?(b+=
d.legendFull,h=d.isPackage?"datepicker_full":h+" datepicker_full"):(a[f].advantage&&(b=this.legendAdvantage+", ",h+=" advantage"),"GOOD"===a[f].availability?(b+=d.legendFree,h+=" datepicker_free"):"LIMITED"===a[f].availability&&(b+=d.legendLimited,h+=" datepicker_limited"));else if(d.legendType===d.LEGEND_TYPE_RATE)if(a[f].advantage)h+=" advantage",b=this.legendAdvantage;else for(h+=" datepicker_rate datepicker_rate_"+a[f].rateTypeId,c=0;c<d.rateTypes.length;c++){if(parseInt(d.rateTypes[c].id,10)===
parseInt(a[f].rateTypeId,10)){b=datePickerConfig.legendRate.replace("{0}",d.rateTypes[c].description);break}}else h+=" datepicker_existing_performances";this.preComputedDates[g]={text:b,cssClass:h}}}};this.handleLegendAvailabilityFilter=function(a){$(".datepicker_legend_checkbox").each(function(){var b=this,c=$(this).parent().attr("class");if(isNewTicketShop){var e=$("<label _ts15_label></label>");$(b).after(e);$(e).on("click",function(){$(b).prop("checked",!$(b).prop("checked")).trigger("change")})}var f=
c.includes("free")?d.AVAILABILITY_STATUS.AVAILABLE:c.includes("limited")?d.AVAILABILITY_STATUS.LIMITED:d.AVAILABILITY_STATUS.SOLD_OUT;b.checked=d.availabilityFilter[f];$(this).on("change",function(){d.availabilityFilter[f]=b.checked;d.refreshDatePicker(a)})})};this.refreshDatePicker=function(a){$(a).datepicker("refresh");this.updateRenderedDomOfDatePicker()};this.resetAvailabilityFilter=function(a){d.availabilityFilter.available=!0;d.availabilityFilter.limited=!0;d.availabilityFilter.soldOut=!0;d.refreshDatePicker(a)};
this.showDatePicker=function(a,b){var c;if(null===this.minDate){var e=0;for(c=this.calendarConfiguration.length;e<c;e++){var f=this.parseDate(this.calendarConfiguration[e].performanceDate);if(null===this.minDate||this.minDate>f)this.minDate=f}}null===this.selectedDateText&&(this.selectedDateText=$.datepicker.formatDate(this.dateFormat,this.minDate));e=this.parseDate(this.selectedDateText);this.preComputeDates(this.calendarConfiguration);e=String(e.getFullYear())+(e.getMonth()+1);d.alreadyLoadedMonths[e]=
!0;tools.date.makeDatePicker(a,{minDate:this.minDate,maxDate:this.maxDate,beforeShowDay:this.checkDatesToShow,onSelect:function(c,e){c!==d.selectedDateText?(d.selectedDateText=c,b.apply(this,[c,e,d.getCalendarConfigForDate(c)])):$(a).dialog&&$(a).hasClass("ui-dialog-content")&&$(a).dialog("close");d.updateRenderedDomOfDatePicker()},onChangeMonthYear:this.updateCalendarConfiguration,dateFormat:this.dateFormat,defaultDate:this.isPackage?this.getMinDateWithAvailability():this.selectedDateText,closeOnEscape:!0,
firstDay:1,showOtherMonths:!1,hideIfNoPrevNext:!0});this.checkMonthToShowLinkedSeasonProductBtn(this.parseDate(d.selectedDateText).getFullYear(),this.parseDate(d.selectedDateText).getMonth()+1);this.legendType>this.LEGEND_TYPE_NONE&&this.createLegend(a);this.updateRenderedDomOfDatePicker()};this.updateRenderedDomOfDatePicker=function(){var a=this.showAccessibilityIndicator;setTimeout(function(){$(".ui-datepicker td.ui-datepicker-current-day").append('<span class="accessibility-visually-hidden">'+
datepickerSelectedDay+"</span>");$(".ui-datepicker-header a.ui-datepicker-next:not([href]):not([tabIndex])").attr("title",nextMonth);$(".ui-datepicker-header a.ui-datepicker-prev:not([href]):not([tabIndex])").attr("title",previousMonth);$(".ui-datepicker-header a.ui-datepicker-next:not([href]):not([tabIndex])").attr("aria-label",nextMonth);$(".ui-datepicker-header a.ui-datepicker-prev:not([href]):not([tabIndex])").attr("aria-label",previousMonth);$(".ui-datepicker-header a:not([href]):not([tabIndex])").attr("tabIndex",
"0").addClass("add_keyboard_support");a&&($(".ui-datepicker .datepicker_free").each(function(){$(this).append('<div class="datepicker_legend_accessibility_container"><span class="datepicker_legend_accessibility_free"></span><span class="datepicker_legend_accessibility_free"></span><span class="datepicker_legend_accessibility_free"></span></div>')}),$(".ui-datepicker .datepicker_limited").each(function(){$(this).append('<div class="datepicker_legend_accessibility_container"><span class="datepicker_legend_accessibility_limited"></span><span class="datepicker_legend_accessibility_limited"></span></div>')}),
$(".ui-datepicker .datepicker_full").each(function(){$(this).append('<div class="datepicker_legend_accessibility_container"><span class="datepicker_legend_accessibility_full"></span></div>')}));$(".ui-datepicker .ui-datepicker-title:not(:has(> .datepicker_accessibility_current_month))").each(function(){$(this).prepend('<span class="datepicker_accessibility_current_month accessibility-visually-hidden">'+currentMonth+"</span>")});$(".ui-datepicker .datepicker_free > a:not(:has(> .datepicker_legend_accessibility_free))").each(function(){$(this).append('<span class="datepicker_legend_accessibility_free accessibility-visually-hidden">'+
legendFree+"</span>")});$(".ui-datepicker .datepicker_limited > a:not(:has(> .datepicker_legend_accessibility_limited))").each(function(){$(this).append('<span class="datepicker_legend_accessibility_limited accessibility-visually-hidden">'+legendLimited+"</span>")});$(".ui-datepicker .datepicker_full > a:not(:has(> .datepicker_legend_accessibility_full))").each(function(){$(this).append('<span class="datepicker_legend_accessibility_full accessibility-visually-hidden">'+legendFull+"</span>")});$('.ui-datepicker [class*="datepicker_"].advantage > a:not(:has(> .datepicker_legend_accessibility_advantage))').each(function(){$(this).append('<span class="datepicker_legend_accessibility_advantage accessibility-visually-hidden">'+
advantageAccessibilityText+"</span>")});$('.ui-datepicker [class*="ui-state-disabled"] > .ui-state-default:not(:has(> .datepicker_legend_accessibility_inactive))').each(function(){$(this).append('<span class="datepicker_legend_accessibility_inactive accessibility-visually-hidden">'+inactiveAccessibilityText+"</span>")})},0)};this.createLegend=function(a){var b;var d=(d=$(this.legendContainer+" legend")[0])?d.outerHTML:"";if(!0===this.isAllowHideAvailabilityLegend&&!0===this.isAvailabilitiesAreGood)$(this.legendContainer).html(d);
else{switch(this.legendType){case this.LEGEND_TYPE_AVAILABILITY:d+=this.createLegendItem(this.legendFree,this.cssLegendFree);d+=this.createLegendItem(this.legendLimited,this.cssLegendLimited);d+=this.createLegendItem(this.legendFull,this.cssLegendFull);this.showAdvantageLegend&&(d+=this.createLegendItem(this.legendAdvantage,this.cssLegendAdvantage));break;case this.LEGEND_TYPE_AVAILABILITY_TABLE:d=d+"<table><tr><td>"+this.createLegendItem(this.legendFree,this.cssLegendFree);d+=this.createLegendItem(this.legendLimited,
this.cssLegendLimited);d+=this.createLegendItem(this.legendFull,this.cssLegendFull);d+="</td><td>";this.showAdvantageLegend&&(d+=this.createLegendItem(this.legendAdvantage,this.cssLegendAdvantage));d+="</td></tr></table>";break;case this.LEGEND_TYPE_RATE:for(b=0;b<this.rateTypes.length;b++)d+=this.createLegendItem(this.rateTypes[b].description,this.cssLegendRate+this.rateTypes[b].id);this.showAdvantageLegend&&(d+=this.createLegendItem(this.legendAdvantage,this.cssLegendAdvantage))}$(this.legendContainer).html(d);
this.handleLegendAvailabilityFilter(a)}};this.createLegendItem=function(a,b){var d='<label class="datepicker_legend_item '+b+'">';b.includes("advantage")||(d+='<input type="checkbox" class="datepicker_legend_checkbox" />');d+='<span class="datepicker_legend_color_box"></span>';if(this.showAccessibilityIndicator)switch(a){case this.legendFree:for(b=1;3>=b;b++)d+='<span class="datepicker_legend_accessibility_free"></span>';break;case this.legendLimited:for(b=1;2>=b;b++)d+='<span class="datepicker_legend_accessibility_limited"></span>';
break;case this.legendFull:d+='<span class="datepicker_legend_accessibility_full"></span>'}return d+('<span class="datepicker_legend_text">'+a+"</span></label>")};this.checkMonthToShowLinkedSeasonProductBtn=function(a,b){var c=d.minDate.getMonth()+1,e=d.minDate.getFullYear(),f=d.maxDate.getMonth()+1,g=d.maxDate.getFullYear(),k=$(".prevBtn.linkedProductBtn"),h=$(".nextBtn.linkedProductBtn");k.hide();h.hide();c==b&&e==a&&0!==k.length&&k.show();f==b&&g==a&&0!==h.length&&h.show()};this.updateCalendarConfiguration=
function(a,b,c){function e(){setTimeout(function(){var a=$(".ui-datepicker-header .ui-datepicker-next"),b=$(".ui-datepicker-header .ui-datepicker-prev");g&&0<a.length?a.focus():b.focus()},0)}var f=this,g=$(document.activeElement).hasClass("ui-datepicker-next");d.checkMonthToShowLinkedSeasonProductBtn(a,b);if(!0===d.alreadyLoadedMonths[String(a)+b])d.updateRenderedDomOfDatePicker(),e();else{var k={tourId:d.tourId,productId:d.productId,advantageId:d.advantageId,ppid:d.baseProductId,crossSellId:d.crossSellId,
reservationIdx:d.reservationIdx,month:b,year:a,requirePerformances:d.requirePerformances,visitExtendedInfo:d.isVisitSpecialCalendar};!0===d.isPackage&&(k.packageLineId=d.packageLineId);tools.dialog.showWaitingPopup("loadingDialog",!0);$.ajax({type:"GET",async:void 0===c?!0:c,url:contextPath+d.dateUpdateUrl,data:k,success:function(c){d.calendarConfiguration=d.calendarConfiguration.concat(c);d.preComputeDates(c);d.legendType>d.LEGEND_TYPE_NONE&&d.createLegend(f);d.alreadyLoadedMonths[String(a)+b]=!0;
$(f).datepicker("refresh");d.updateRenderedDomOfDatePicker();e();tools.dialog.hideDialog("loadingDialog")},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}})}};this.getDateAvailability=function(a){return a.cssClass.includes("free")?d.AVAILABILITY_STATUS.AVAILABLE:a.cssClass.includes("limited")?d.AVAILABILITY_STATUS.LIMITED:d.AVAILABILITY_STATUS.SOLD_OUT};this.isDateMatchAvailabilityFilter=function(a){return d.availabilityFilter[d.getDateAvailability(a)]};
this.checkDatesToShow=function(a){a=d.preComputedDates[a];var b=!0;return void 0!==a&&d.isDateMatchAvailabilityFilter(a)?(d.isPackage&&"datepicker_full"===a.cssClass&&(b=!1),[b,a.cssClass,a.text]):[!1,"",""]}};this.isTodayDate=function(a){return this.isSameDate(new Date,a)};this.isSameDate=function(a,b){return a.getDate()===b.getDate()&&a.getMonth()===b.getMonth()&&a.getYear()===b.getYear()};this.makeDatePicker=function(a,b){b=b||{};b.selectOtherMonths=!1!==b.selectOtherMonths;b.dateFormat=b.dateFormat||
datePickerConfig.dateFormat;b.dayNames=datePickerConfig.dayNames;b.dayNamesShort=datePickerConfig.dayNamesShort;b.dayNamesMin=datePickerConfig.dayNamesShort;b.monthNames=datePickerConfig.monthNames;b.monthNamesShort=datePickerConfig.monthNamesShort;b.hideIfNoPrevNext=!0;b.firstDay=1;return $(a).datepicker(b)};this.fromJodaDateTime=function(a){return 6===a.length?new Date(a[0],a[1]-1,a[2],a[3],a[4],a[5]):new Date(a[0],a[1]-1,a[2])};this.toggleClassToday=function(a,b){a=a instanceof jQuery?a:$(a);a=
a.hasClass("datepicker_element")?a:a.closest(".datepicker_element");tools.date.isTodayDate(b)?a.addClass("today"):a.removeClass("today")}};this.isStorageAvailable=function(){try{return void 0!==sessionStorage&&void 0!==JSON&&sessionStorage&&JSON?(sessionStorage.setItem("storageCheck",""),!0):!1}catch(d){return!1}};this.storage=this.isStorageAvailable()?{setItem:function(a,b){sessionStorage.setItem(a,JSON.stringify(b))},getItem:function(a){try{return JSON.parse(sessionStorage.getItem(a))}catch(f){return null}},
removeItem:function(a){sessionStorage.removeItem(a)},clear:function(){sessionStorage.clear()}}:{setItem:function(){},getItem:function(){},removeItem:function(){},clear:function(){}};this.form={submitWithProcessing:function(a){setTimeout(function(){a.submit();a=null},100);tools.dialog.showWaitingPopup("requestProcessingDialog",!0)},focusFirstEmptyField:function(a){a.find('input:visible[value=""], select:visible[value="0"]').not("disabled").first().focus()}};this.hasClick={};this.preventFormSpam=function(){var a=
this;$(document).on("submit","form",function(b){var d=$(this).attr("id")||"no_id";a.hasClick[d]?b.preventDefault():(a.hasClick[d]=!0,$(".button",this).addClass("disabled"))})};this.preventButtonSpam=function(a,b){var d=this;$(document).on("click",a,function(c){var e=$(this).attr("id")||"no_id";d.hasClick[e]?c.preventDefault():(d.hasClick[e]=!0,$(a).parent().addClass("disabled"),b&&tools.dialog.showWaitingPopup("requestProcessingDialog",!0))})};this.disableLink=function(a){a=$(a.target||a.srcElement);
var b=/MSIE|Trident/gi.test(window.navigator.userAgent);a.length&&(a.attr("onclick",""),a.click(function(a){b||a.preventDefault();b=!1}))};this.fireFancybox=function(a){var b=function(){this.title='<a href="'+this.href+'" target="_blank" id="openInNewWindow">'+openInNewWindowLabel+"</a> "+this.title};displayFancyboxInNewTab||$(a).filter(function(a,b){a=$(b).attr("href");b=!1;var c=window.location.hostname;void 0!==a&&(b=a.startsWith("/")||0<a.indexOf(c));return b&&"_blank"!==tools.getParameterFromUrl("target",
a)}).data("fancybox-type","iframe").fancybox({width:"85%",height:"90%",helpers:{title:{type:"inside",position:"top"}},iframe:{preload:!1},afterLoad:b})};this.cookie={setItem:function(a,b,c,g){var d=new Date;d.setDate(d.getDate()+c);b=encodeURIComponent(b)+(null===c?"":"; expires="+d.toUTCString());document.cookie=a+"="+(b+(g?"; path="+g:""))},getItem:function(a){var b;try{var c=document.cookie.split(";");for(b=0;b<c.length;b++){var d=c[b].substr(0,c[b].indexOf("="));var h=c[b].substr(c[b].indexOf("=")+
1);d=d.replace(/^\s+|\s+$/g,"");if(d==a)return decodeURIComponent(h)}return null}catch(l){return null}}};this.getBrowserInfo=function(){var a=navigator.userAgent;var b=a.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i)||[];if(0<b.length){if(/trident/i.test(b[1])){var c=/\brv[ :]+(\d+)/g.exec(a)||[];return{name:"MSIE",version:c[1]||""}}if(/Edge\/\d./i.test(navigator.userAgent))return c=/\bEdge[ /]+(\d+\.?\d+)/g.exec(a)||[],{name:"Edge",version:c[1]||""};if("Chrome"===b[1]&&(c=
a.match(/\bOPR\/(\d+)/)))return{name:"Opera",version:c[1]};var g=b[1];b=b[2];(c=a.match(/version\/(\d+)/i))&&(b=c[1])}else g=navigator.appName,b=navigator.appVersion;return{name:g,version:b}};this.checkUnsupportedBrowserPrinter=function(a){var b=tools.getBrowserInfo(),c={Firefox:["65","66"],Edge:["14.14393","15.15063"]};c[b.name]&&c[b.name].includes(b.version)?tools.dialog.showDialog("unsupportedBrowserPrinterCheck",!0,!0,a,"unsupported_browser_print_checker_dialog"):a()};this.isFirefox=function(){return/firefox/gi.test(window.navigator.userAgent)};
this.isSafari=function(){var a=tools.getBrowserInfo();return a&&"Safari"===a.name};this.keyBoardSubmit=function(a,b){var c=tools.isFirefox()?"input[type=text]:last":"input";$(c,a).on("keypress",function(a){13===a.which&&$(b).click()})};this.toggleGroup=function(a,b,c){var d=a.find(".group_content"),e=a.find("> .group_main_title");b=!1!==b;void 0===c&&a.hasClass("group_open")||void 0!==c&&!c?(a.removeClass("group_open").addClass("group_closed"),e.removeClass("open").addClass("closed").find(".group_count").removeClass("hidden"),
b?d.slideUp():d.hide()):(a.removeClass("group_closed").addClass("group_open"),e.removeClass("closed").addClass("open").find(".group_count").addClass("hidden"),b?d.slideDown():d.show())};this.panel=new function(){this.toggle=function(a,b,c){var d=a.parents(".panel_header").siblings(".panel_content");c&&d.slideToggle();d.attr("aria-hidden",!b);a.attr("aria-expanded",b)};this.initPanelToggle=function(){var a=this;$(".toggle_panel_button").off("click").click(function(b){var c="true"===$(this).find('> [role="button"]').attr("aria-expanded");
a.toggle($(this),!c,!0);b.preventDefault()}).each(function(){var b="true"===$(this).find('> [role="button"]').attr("aria-expanded");a.toggle($(this),b,!1)})}};this.addSelectWrapper=function(){/iPhone/i.test(navigator.userAgent)&&jQuery.each($("form select"),function(a,b){50<$("option",$(b)).length&&!$(b).parent().is("form")&&$(b).wrap("<form class='select_wrapper'></form>")})};this.removeSelectWrapper=function(){jQuery.each($("form select"),function(a,b){50<$("option",$(b)).length&&$(b).parent().is("form")&&
$(b).unwrap()})};this.bindGroups=function(){$(".group.group_foldable > .group_main_title").on("click",function(a){a.preventDefault();tools.toggleGroup($(this).parent());tools.triggerLazyImagesRefresh();$(this).find("[role=button]").attr("aria-expanded",$(this).parent().hasClass("group_open"))})};this.triggerLazyImagesRefresh=function(){try{$(window).trigger("scroll")}catch(d){}};this.getAmount=function(a){var b=$(a+" .mantissa").text();a=parseInt($(a+" .int_part").text().replace(/\D/g,""),10);var c=
Math.max(secutixAmountDecimalSize-currencyFractionDigit,0),d;for(d=0;d<currencyFractionDigit;d++)a*=10;$.isNumeric(b)&&(a+=parseInt(b,10));if(!isNaN(a)){for(d=0;d<c;d++)a*=10;return a}return null};this.parsePanoURL=function(a){a=a.split(/^(tk3d|krpano|pacifa):\/\//);var b=a[1],c=a[2];b||(c=a[0]);return{protocol:b,url:c}};this.initCollapsibleSection=function(){$(".collapsibleDummyCheckbox").each(function(){$(this).parent().find(".collapsibleLabel").click(this.click.bind(this))}).change(function(){var a=
!$(this).prop("checked");a&&tools.triggerLazyImagesRefresh();$(this).parent().find(".collapsible_title [role=button]").attr("aria-expanded",a)})};this.setParameterToUrl=function(a,b,c,g){var d=tools.getParameterFromUrl(b,a);if(g&&""!==d)return a;c=b+"="+c;""!==d?(a=a.replace("?"+b+"="+d,"?"+c),a=a.replace("&"+b+"="+d,"&"+c)):a=0<=a.indexOf("?")?a+("&"+c):a+("?"+c);return a};this.padStart=function(a,b,c){for(;a.length<c;)a=b+a;return a};this.scrollToElement=function(a,b){$("html, body").animate({scrollTop:$(a).offset().top},
b)};this.getParameterFromUrl=function(a,b){a=a.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");a=(new RegExp("[\\?&]"+a+"=([^&#]*)")).exec(b);return null===a?"":decodeURIComponent(a[1])};this.isIOSDevice=function(){return"iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document};this.fixFooterForIOSDevices=function(){return tools.isIOSDevice()&&$("html").addClass("iOS_footer")};this.bindResetFilter=
function(a){$(window).on("pageshow",function(){var b=$("#"+a+" option");0<b.length&&(b[0].selected=!0)})};this.replaceJSPArgument=function(a,b,c){var d=a.html();d=d.replace(b,c);a.html(d)};this.initDragHandler=function(a){a||$(document).ready(function(){var a=$("#seat-map-sub-container").width()-$("#seat-map").width(),b=$("#seat-details"),c=$("#drag-handler"),d=!1,l,k,m=0;c.css({right:b.width()+15});var p=function(a,c){b.find(a+" .name").each(function(a,b){$(b).css({width:c})})},q=function(a){var d=
$(".price-range");d.css({width:""});d.each(function(){var a=$(this).width();a>m&&(m=a)});d.css({width:m+5});$(".seat_selection").length?(p(".categories_table .category",a-d.width()-50-15),p(".seat-info-content .seat-description .seat-info-category",a-50),p("#seat-selected-info-content .distribution-seat-description .seat-info-category",a-50),p("#selection-summary-container .summary-content .seat-cat-title",a-$(".count-per-cat").width()-30)):300>a?(p(".seat-info-category",250),p(".seat-info-category-legend .category",
180)):(p(".seat-info-category",a-50),p(".seat-info-category-legend .category",a-d.width()-50-15));b.css({width:a});c.css({right:a+15});c.css({right:b.width()+15})};q(a);c.mousedown(function(c){d=!0;l=b.width();k=c.clientX;$(document).mousemove(function(b){d&&(b=Math.round(l-(b.clientX-k)),b<a||600<b||q(b))});$(document).mouseup(function(){d=!1;$(document).off("mousemove");$(document).off("mouseup")})});$(document).mousemove(function(a){d&&a.preventDefault()})})};this.initAfterMustacheRender=function(){tools.panel.initPanelToggle()};
this.userAborted=function(a){return!a.getAllResponseHeaders()}}tools||(tools=new NS_tools,$(function(){tools.registerGlobalHandlerAjaxFragmentResponse();tools.fireFancybox("a.iframe[href^='https://'], a.iframe[href^='/']");tools.preventFormSpam();tools.displayLazyImages();tools.bindGroups();tools.initCollapsibleSection();tools.fixFooterForIOSDevices();tools.panel.initPanelToggle()}));
tools.module("viewer",{openSeatViewDialog:function(a){$("#scene_photo_dialog").dialog({modal:!0,width:"auto",resizable:!1,show:"fade",hide:"fade",title:a})},seatViewInit:function(){$("#scene_photo").attr("src","")},seatView:function(a,b){var c=$("#scene_photo");viewer.seatViewInit();c.on("load",function(){viewer.openSeatViewDialog(b)});c.attr("src",a)}});
function Performances(a,b,c,d,f){var e=this,g=!0,h=function(a){$("#performance_container").html(a);$("#performanceSelectedDate").html($("#newPerformanceDate").html());$("#newPerformanceDate").remove();tools.displayLazyImages()};this.productId=a;this.advantageId=b;this.baseProductId=c;this.crossSellId=d;this.reservationIdx=f;this.cachedPerformances={};this.datePickers={};$(function(){var a=function(){var a=$("#min_quantity").val();if(/^\d*$/.test(a))return a&&"0"!==a||(a=null),util.url.updateUrlAndReload({minQuantity:a},
!0),!1};$("#min_quantity_submit").on("click",a);$("select#min_quantity").on("change",a);$("#min_quantity").on("keydown",function(b){if(13==b.keyCode)return a()});$("#min_quantity_reset").on("click",function(){$("#min_quantity").val("");return a()})});this.cacheFirstPerformance=function(a){a=$.datepicker.parseDate(datePickerConfig.dateFormat,a);e.cachedPerformances[a]=[{language:"all",rateType:"all",content:$("#performance_container").html()}]};this.updatePerformances=function(a,b,c){b=$(".date_filter");
var d=null,f=null,g=!0;a instanceof Object||(a=$.datepicker.parseDate(datePickerConfig.dateFormat,a));b&&(d=$("#performanceLanguageFilter").val(),f=$("#performanceRateTypeFilter").val(),b.find(".date").html($.datepicker.formatDate(dateShortPattern,a)));c&&(g=c.advantage);e.getPerformances(a,d,f,e.minQuantity,g)};this.updateAllPerformances=function(){var a=$("#performanceLanguageFilter").val(),b=$("#performanceRateTypeFilter").val();this.getPerformances(null,a,b,this.minQuantity)};this.getPerformances=
function(a,b,c,d,f){var g,k=a,l;var m=b;var p=c;""===m&&(m="all");p||(p="all");if(l=this.cachedPerformances[a])for(g in l)if(!(!l.hasOwnProperty(g)||m&&l[g].language!==m||p&&l[g].rateType!==p)){h(l[g].content);return}tools.dialog.showWaitingPopupDelayed("loadingDialog",!0,!1,300);null!==a?(a instanceof Object||(a=$.datepicker.parseDate(datePickerConfig.dateFormat,a)),a={year:a.getFullYear(),month:a.getMonth()+1,day:a.getDate()},c&&(a.rateType=c)):a={};a.productId=e.productId;if(void 0===f||!0===f)a.advantageId=
e.advantageId;a.language=b;a.ppid=e.baseProductId;a.crossSellId=e.crossSellId;a.reservationIdx=e.reservationIdx;c&&(a.rateType=c);d&&(a.minQuantity=d);$.ajax({type:"GET",url:contextPath+"/ajax/event/date/performances",cache:!1,data:a,success:function(a){h(a);e.cachedPerformances[k]||(e.cachedPerformances[k]=[]);e.cachedPerformances[k].push({content:a,language:m,rateType:p});tools.dialog.hideDialog("loadingDialog")},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",
!0)}})};this.togglePerformancesGroup=function(a,b){a=$(b);b=a.siblings(".performances_group_container");a.hasClass("open")?(b.slideUp(),a.removeClass("open"),a.addClass("closed"),a.attr("aria-expanded","false")):(b.slideDown(),a.removeClass("closed"),a.addClass("open"),a.attr("aria-expanded","true"))};this.bindFilters=function(){performances.bindVenueFilter();performances.bindTeamFilter();performances.bindToggleUnavailableMatchFilter()};this.bindVenueFilter=function(){var a=$("#venue"),b=a.parent().find("label .alternative_button.filter_reset");
a.change(performances.applyFilters);b.hide();b.click(function(){a.val("");performances.applyFilters();return!1})};this.bindTeamFilter=function(){var a=$("#team"),b=a.parent().find("label .alternative_button.filter_reset");a.change(performances.applyFilters);b.hide();b.click(function(){a.val("");performances.applyFilters();return!1})};this.bindToggleUnavailableMatchFilter=function(){$("#toggle_unavailable_matches").click(performances.applyFilters)};this.clickToggleUnavailableMatchesCheckbox=function(){var a=
$("#toggle_unavailable_matches");g=!1;a.prop("checked",!0);a.triggerHandler("click")};this.filterVenue=function(){var a=$("#venue").val(),b=$("#venue").parent().find("label .alternative_button.filter_reset"),c;if(void 0!==a&&""!==a)for(b.show(),b=e.getVisiblePerformances($("#performance_container")),c=0;c<b.length;c++){var d=b[c];$(d).toggle(a===$(d).attr("data-venue-id"))}performances.togglePerformanceContainerHeading()};this.filterTeam=function(){var a=$("#team").val(),b=$("#team").parent().find("label .alternative_button.filter_reset"),
c;if(void 0!==a&&""!==a)for(b.show(),b=e.getVisiblePerformances($("#performance_container")),c=0;c<b.length;c++){var d=b[c];$(d).toggle(a===String($(d).attr("data-host-team-id"))||a===String($(d).attr("data-opposing-team-id")))}performances.togglePerformanceContainerHeading()};this.filterUnavailableMatches=function(){var a=$("#toggle_unavailable_matches");0<a.length&&($("#performance_container .performance.sold_out").each(function(){"none"!==$(this).css("display")&&$(this).toggle(!$(a).is(":checked"))}),
performances.togglePerformanceContainerHeading())};this.announceChange=function(){var a=$("#venue"),b=$("#team"),c=$("#toggle_unavailable_matches"),d="";if(a.length&&a.val()){var e=$('label[for="venue"]')[0].innerText;d+=e+": "+a[0].options[a[0].selectedIndex].text+". "}b.length&&b.val()&&(a=$('label[for="team"]')[0].innerText,d+=a+": "+b[0].options[b[0].selectedIndex].text+". ");c.length&&c.is(":checked")&&(b=$('label[for="toggle_unavailable_matches"]')[0].textContent,d+=b+".");var f=0;$("#performance_container li.performance").each(function(){"none"!==
$(this).css("display")&&f++});b=1>=f?filterResultSingular:filterResultPlural;$("#filter_announcement").html(filterApplied+". "+d+"\n"+f+" "+b)};this.applyFilters=function(){var a=$("#team").parent().find("label .alternative_button.filter_reset"),b=$("#venue").parent().find("label .alternative_button.filter_reset");performances.initBeforeFiltering();a.hide();b.hide();performances.filterVenue();performances.filterTeam();performances.filterUnavailableMatches();g?setTimeout(performances.announceChange,
500):g=!0;tools.triggerLazyImagesRefresh()};this.togglePerformanceContainerHeading=function(){var a=$("#performance_container");$(".group_sub_title",a).each(function(){var a=$(this),b=e.hasVisiblePerformances(a.next());a.toggle(b);a.next().toggle(b)});$(".group_main_title",a).each(function(){var a=$(this);a.parent().toggle(e.hasVisiblePerformances(a.next()))})};this.hasVisiblePerformances=function(a){var b=!1;$(".performance",a).each(function(){if("none"!==$(this).css("display"))return b=!0});return b};
this.getVisiblePerformances=function(a){var b=[];$(".performance",a).each(function(){"none"!==$(this).css("display")&&b.push(this)});return b};this.initBeforeFiltering=function(){var a=$("#performance_container");$(".performances_sub_group_container",a).show();$(".performances_group_container",a).show();$(".group_main_title",a).show();$(".group_sub_title",a).show();$(".performance",a).css("display","flex")};this.addDatePicker=function(a,b){this.datePickers[a]=b};this.getDatePicker=function(a){return this.datePickers[a]};
this.showDatePickerPopup=function(a,b,c,d){var f="#"+b+" .datepicker_content";if($(c).hasClass("disabled"))return!1;a.showDatePicker(f,function(f){var g=a.getPerformanceForDate(f);f=$(c).siblings(".time_selection");$(c).find("input").val(g[0].performanceDate);f=e.updateTimeOptions(f,g,a.advantageId);tools.dialog.hideDialog(b);e.performanceChanged(f,a.advantageId,d)});tools.dialog.showDialog(b,!0,!1,function(){a.resetAvailabilityFilter(f)},"date_picker_popup")};this.updateTimeOptions=function(a,b,
c){c=0;var d=$(a).parent();if(1<b.length){if($(a).is("select"))$(a).find("option").remove();else{var e=$(a).find("input").attr("id");var f=$(a).find("input").attr("name");$(a).remove();$("<select class='time_selection' id='"+e+"' name='"+f+"'>").insertAfter(d.find(".datepicker_element"));a=d.find(".time_selection")}for(c in b)if(b.hasOwnProperty(c)){var g=b[c].performanceName?"&nbsp;- "+b[c].performanceName:"";$(a).append("<option "+("NONE"===b[c].availabilityLevel?"disabled":"")+" value='"+b[c].performanceId+
"'>"+b[c].performanceTime+g+"</option>")}$(a).children("option:enabled").first().prop("selected",!0)}else g=b[0].performanceName?"&nbsp;- "+b[0].performanceName:"",$(a).is("select")?(e=$(a).attr("id"),f=$(a).attr("name"),$(a).remove(),$("<span class='time_selection'>"+b[0].performanceTime+g+"<input type='hidden' id='"+e+"' name='"+f+"' value='"+b[0].performanceId+"'></span>").insertAfter(d.find(".datepicker_element")),d.find(".time_selection")):(e=$(a).find("input").attr("id"),f=$(a).find("input").attr("name"),
$(a).html(b[0].performanceTime+g+"<input type='hidden' id='"+e+"' name='"+f+"' value='"+b[0].performanceId+"'>"),a.toggleClass("single",!g));return b[0].performanceId};this.buildUrlForSelectedPerformance=function(a,b,c){a=contextPath+("/selection/event/seat?perfId="+a+"&productId="+this.productId);b&&(a+="&advantageId="+b);c&&(a+="&tourId="+c);return a};this.buildUrlForSelectedPerformanceWithCrossSell=function(a,b){a=new URL(a.toString());a.searchParams.set("perfId",b);return a.toString()};this.performanceChanged=
function(a,b,c){var d=new URL(window.location.href);d.searchParams.has("crossSellId")?window.location.replace(this.buildUrlForSelectedPerformanceWithCrossSell(d,a)):window.location.replace(this.buildUrlForSelectedPerformance(a,b,c))}}
;var proceed2AddAccommodationToCart={addAccommodationToCart:function(a,b,c){$.ajax({url:"/ajax/selection/service/accommodation?ridx="+a+"&id="+b+"&price="+c,type:"POST",cache:!1,dataType:"json",contentType:"application/json",success:function(a){!0===a.error?(tools.dialog.hideDialog("requestProcessingDialog"),tools.dialog.showDialog("ajaxErrorDialog",!0)):window.location.replace(a.dataLayerInfo)},error:function(a){tools.dialog.hideDialog("requestProcessingDialog");tools.dialog.showDialog("ajaxErrorDialog",
!0)}})}};
tools.module("account.accountKit",function(){var a="";var b=function(b){if("PARTIALLY_AUTHENTICATED"===b.status)$("#"+a+"code").val(b.code),$('input[name="_csrf"]').val(b.state),$("#"+a+"accountKitForm").submit();else{if("NOT_AUTHENTICATED"===b.status||"BAD_PARAMS"===b.status)throw Error(b.status);throw Error("Unknown error occured when authenticate with Account Kit");}};return{init:function(b,d){a=d;AccountKit.init({appId:b,state:$('input[name="_csrf"]').val(),version:"v1.0"})},loginWithPhoneNumber:function(){AccountKit.login("PHONE",
{},b)}}});
tools.module("account.addToCalendar",function(){var a=null,b=null,c=function(a,b){var c=null;for(c in b)b.hasOwnProperty(c)&&(a=a.split(c).join(b[c]));return a},d=function(a){var d=a.data("date-start").replace(/\D/g," ").split(" ");d[1]--;d=new Date(Date.UTC(d[0],d[1],d[2],d[3],d[4]));var e=a.data("duration");e=""===e?3600:e;var f=a.data("address");a=a.data("name");var g=$("html").attr("lang"),l=h(d,[{weekday:"long"},{day:"numeric"},{month:"long"},{year:"numeric"}],g," ");g=h(d,[{hour:"2-digit",minute:"2-digit",
hour12:!1}],g);d={title:a,start:d,startTimeStr:g,startDateStr:l,duration:e,address:f};d.description=c(b.descriptionTemplate,{"{name}":d.title,"{location}":d.address,"{date}":d.startDateStr,"{time}":d.startTimeStr,"{url}":document.URL,"{homeUrl}":b.homeUrl});b.toEmail&&(d.to=b.toEmail);return d},f=function(a,b){var c=function(a){a=String(a);1===a.length&&(a="0"+a);return a};var d=b?a.getFullYear():a.getUTCFullYear();d+="-"+c((b?a.getMonth():a.getUTCMonth())+1);d+="-"+c(b?a.getDate():a.getUTCDate());
d+="T"+c(b?a.getHours():a.getUTCHours());d+=":"+c(b?a.getMinutes():a.getUTCMinutes());d+=":"+c(b?a.getSeconds():a.getUTCSeconds());d+="."+String(((b?a.getMilliseconds():a.getUTCMilliseconds())/1E3).toFixed(3)).slice(2,5);return(d+"Z").replace(/-|:|\.\d+/g,"")},e=function(a){var b=a.start.getTime();return a.end?f(a.end):f(new Date(b+1E3*a.duration))},g=function(b){var g=$(this),h=d(g),l={google:function(a){var b=f(a.start),c=e(a);return encodeURI(["https://www.google.com/calendar/render?action=TEMPLATE",
"&text="+(a.title||""),"&dates="+(b||""),"/"+(c||""),"&details="+(a.description||""),"&location="+(a.address||""),"&sprop=&sprop=name:"].join(""))},yahoo:function(a){var b=a.end?(a.end.getTime()-a.start.getTime())/6E4:a.duration/60;b=(600>b?"0"+Math.floor(b/60):String(Math.floor(b/60)))+(10>b%60?"0"+b%60:String(b%60));var c=f(new Date(a.start),!0)||"";return encodeURI(["http://calendar.yahoo.com/?v=60&view=d&type=20","&title="+(a.title||""),"&st="+c,"&dur="+(b||""),"&desc="+(a.description||""),"&in_loc="+
(a.address||"")].join(""))},ics:function(a,b,c){b=f(a.start);c=e(a);a=["BEGIN:VCALENDAR","VERSION:2.0","BEGIN:VEVENT","URL:"+document.URL,"DTSTART:"+(b||""),"DTEND:"+(c||""),"SUMMARY:"+(a.title||""),"DESCRIPTION:"+(a.description.replace(/\n/g,"\\n")||""),"LOCATION:"+(a.address||""),"END:VEVENT","END:VCALENDAR"];for(b=a.length;b;)b--,a[b]||a.splice(b,1);return encodeURI("data:text/calendar;charset=utf8,"+a.join("\n"))},ical:function(a){return this.ics(a,"icon-ical","iCal")},outlook:function(a){return this.ics(a,
"icon-outlook","Outlook")}};g=g.parents(".product, .product_right_img");var q=g.find(".alternative_button.show_map"),r=g.find(".button_separator");b=c(a,{"{rowIndex}":b,"{google}":l.google(h),"{yahoo}":l.yahoo(h),"{ical}":l.ical(h),"{outlook}":l.outlook(h),"{addToCalendarDescription}":h.title});b=$(b);var t=b.last();h=b.first();t.hide();0<q.length?(h.insertBefore(r),t.insertAfter(q)):g.first().append(b);$("a",b.first()).on("click",function(a){var b=$(this).parents(".product, .product_right_img"),
c=b.find(".map_panel"),d=$(this).parent().find(".triangle");a.preventDefault();c.is(":visible")&&account.venueMap.closeMap(b);d.is(":visible")?d.removeClass("visible"):d.addClass("visible");t.slideToggle(200)});$("a",t).on("click",function(a){$(this).parents(".product, .product_right_img").find(".add-to-calendar .triangle").removeClass("visible");t.slideUp(200)})},h=function(a,b,c,d){return b.map(function(b){return(new Intl.DateTimeFormat(c,b)).format(a)}).join(d)};return{supportAccessibilityDropdown:function(a){var b=
$(".add-to-calendar-links"),c=b.find('[role="option"]'),d=$(a);d.on("click",function(){"true"===d.attr("aria-expanded")&&c[0].focus()});c.each(function(a,e){e.addEventListener("keydown",function(f){"ArrowDown"===f.key?(f.preventDefault(),c[(a+1)%c.length].focus()):"ArrowUp"===f.key?(f.preventDefault(),c[(a-1+c.length)%c.length].focus()):"Escape"===f.key?(d.attr("aria-expanded","false"),b.hidden=!0,d.focus()):"Enter"===f.key&&(d.innerText=e.innerText,c[a].querySelector("a").click(),d.attr("aria-expanded",
"false"),b.hidden=!0)})})},init:function(c){b=c;c=b.homeUrl;/^http/.test(c)||(b.homeUrl=window.location.protocol+"//"+window.location.host+c);a=$("#addToCalendarTpl").html();$('[type="performance/js-date"]').each(g)}}});
tools.module("account.autoSubscriptions",function(){var a,b,c=function(a,b){$(a).prop("checked",b);$(a).val(b);!0===b?$(a).closest("li").find(".subscription_item").removeClass("disabled"):$(a).closest("li").find(".subscription_item").addClass("disabled")},d=function(d,e){var f;var h=String($(e).data("contactnumber"));var l=$(e).data("criterioncode");a:{for(f=0;f<a.length;f++)if(a[f].contactNumber===h){f=a[f];break a}f=null}var k=null!==f.defaultEpcPaymentAlias;l=f.subscriptionEntries[l];b=e.id;if(e.checked&&
!1===l)return tools.dialog.showDialog("warning_subscribe_again_"+h,!0,!0,null,"scheme_subscription_dialog"),c(e,!1),d.preventDefault(),!1;if(e.checked||!0!==l){if(e.checked&&!1===f.subscriber)return tools.dialog.showDialog("warning_not_a_subscriber_"+h,!0,!0,null,"scheme_subscription_dialog"),c(e,!1),d.preventDefault(),!1;if(e.checked&&!k)return tools.dialog.showDialog("warning_missing_valid_card_"+h,!0,!0,null,"scheme_subscription_dialog"),c(e,!1),d.preventDefault(),!1}else return tools.dialog.showDialog("warning_unsubcribe_subscription_"+
h,!0,!0,null,"scheme_subscription_dialog"),c(e,!0),d.preventDefault(),!1;c(e,e.checked);return!0};return{init:function(b){a=b.subscriptionContactDatas;$("input:checkbox","#auto_subscription_form").change(function(a){d(a,a.target)});$("#saveSubscriptionsButton").click(function(){$("#auto_subscription_form").submit()})},confirmUnsubscribe:function(){c($('input[id="'+b+'"]'),!1)}}});
tools.module("account.bankAccount",function(){var a=[],b=null,c=function(a,b){a=".field"+a;var c=a+" .additional_errorText";$(a).removeClass("error");$(c).addClass("hidden");$(b).hide()},d=function(a,b,d){var e=".field"+b,f=e+" .additional_errorText";a?c(b,d):($(e).addClass("error"),$(d).show(),$(f).removeClass("hidden"))},f=function(){var b=!1;0<(a||[]).length&&$("#ibanNumber")&&2<$.trim($("#ibanNumber").val()).length&&0<=a.indexOf($.trim($("#ibanNumber").val()).substr(0,2).toUpperCase())&&(b=!0);
return b},e=function(a){"ORDER_SUMMARY"===b&&(f()?$("span.mandatory","#field_bicNumber").text(""):$("span.mandatory","#field_bicNumber").text("*"),a&&0===$.trim($("#bicNumber").val()).length&&c("#field_bicNumber","#notification_validate_bic_number"))},g=function(a,b){if(0===$.trim($(a).val()).length)return account.register.addMandatoryErrorField(b),$(b).addClass("error"),!0;$(b).remove("error");return!1};return{isMissingIbanNumberMandatoryField:function(){return g("#ibanNumber","#field_ibanNumber")},
isMissingBicNumberMandatoryField:function(){return g("#bicNumber","#field_bicNumber")},ibanNumberValidator:function(a){if(!$("#ibanNumber"))return c("#field_ibanNumber","#notification_validate_iban_number"),!0;var b=$.trim($("#ibanNumber").val());if(0===b.length&&!a)return c("#field_ibanNumber","#notification_validate_iban_number"),!0;if(0===b.length&&a)return d(!1,"#field_ibanNumber","#notification_validate_iban_number"),!1;a=ibanTools.electronicFormatIBAN($("#ibanNumber").val());a=ibanTools.isValidIBAN(a);
d(a,"#field_ibanNumber","#notification_validate_iban_number");return a},bicNumberValidator:function(a){if(!$("#bicNumber"))return c("#field_bicNumber","#notification_validate_bic_number"),!0;var b=f(),e=$.trim($("#bicNumber").val());if(0===e.length&&(!a||b))return c("#field_bicNumber","#notification_validate_bic_number"),!0;if(0===e.length&&a&&!b)return d(!1,"#field_bicNumber","#notification_validate_bic_number"),!1;a=ibanTools.isValidBIC($("#bicNumber").val().toUpperCase());d(a,"#field_bicNumber",
"#notification_validate_bic_number");return a},init:function(c){var d="ORDER_SUMMARY"===c.screenOrigin;b=c.screenOrigin;c.optionalBicCountryCodes&&(a=c.optionalBicCountryCodes.split(","));e(!1);$("#ibanNumber").blur(function(){account.bankAccount.ibanNumberValidator(d);e(!0)});$("#bicNumber").blur(function(){account.bankAccount.bicNumberValidator(d)});account.bankAccount.addUseExistingBankAccountCheckboxEvent()},addUseExistingBankAccountCheckboxEvent:function(){$("#field_maskedIbanNumber").length&&
$("#field_ibanNumber").hide();$("#field_maskedBicNumber").length&&$("#field_bicNumber").hide();$("#useExistingBankAccount").on("click",function(){this.checked?($("#field_ibanNumber").hide(),$("#field_bicNumber").hide(),$("#field_maskedIbanNumber").show(),$("#field_maskedBicNumber").show()):($("#field_maskedIbanNumber").hide(),$("#field_maskedBicNumber").hide(),$("#field_ibanNumber").show(),$("#field_bicNumber").show())})}}});
tools.makePath("account.beneficiary.Questionnaire");
account.beneficiary.Questionnaire=function(a,b){this.REUSE_ANSWERS_CONTAINER_SELECTOR="#beneficiary_save_checkbox_container";this.REUSE_ANSWERS_CHECKBOX_SELECTOR="#beneficiary_save_checkbox";this.FORM_HIDDEN_INPUT_ID_SELECTOR="#input_beneficiary_questionnaire_id";this.FORM_SELECTOR_ADDRESS_LINE1='input[id$="_line1"]';this.FORM_SELECTOR_ADDRESS_LINE2='input[id$="_line2"]';this.FORM_SELECTOR_ADDRESS_LINE3='input[id$="_line3"]';this.FORM_SELECTOR_ADDRESS_COUNTRY=".beneficiary_address_country select";
this.FORM_SELECTOR_ADDRESS_ZIP_CODE='input[id$="_zipcode"]';this.FORM_SELECTOR_ADDRESS_CITY='input[id$="_city"]';this.GET_QUESTIONNAIRE_ANSWERS_URL="/ajax/account/order/questionnaireAnswers";this.BENEFICIARY_NAMES_CONTAINER="#beneficiary_names_container";this.BENEFICIARY_NAMES_OUTSIDE_QUESTIONNAIRES_CONTAINER="#beneficiary_names_outside_questionnaires_container";this.BENEFICIARY_NAMES_INSIDE_QUESTIONNAIRE_CONTAINER=".beneficiary_names_inside_questionnaire_container";this.$currentContainer=this.answerQustnnrMapKey=
this.currentId=null;this.defaultAnswersValues=a;this.hasMandatoryFields=!1;this.savedAnswersValues={};this.alreadySetAnswersValues=b;this.isUpdateBeneficiary=this.hasMultipleTicketsOnPage=!1;this.additionalConfig={}};
account.beneficiary.Questionnaire.prototype.initNewQuestionnaire=function(a,b,c,d,f,e,g){this.currentId=a;this.additionalConfig=e||{};this.answerQustnnrMapKey=f&&(c in this.savedAnswersValues||c in this.alreadySetAnswersValues)?c:c||b;this.isUpdateBeneficiary=f;this.hasMultipleTicketsOnPage=d;g||$(".beneficiary_questionnaire").hide();this.currentId?($(this.FORM_HIDDEN_INPUT_ID_SELECTOR).val(a),this.$currentContainer=$("#beneficiary_questionnaire_"+this.currentId),1===this.$currentContainer.find(this.BENEFICIARY_NAMES_INSIDE_QUESTIONNAIRE_CONTAINER).length?
$(this.BENEFICIARY_NAMES_CONTAINER).detach().appendTo(this.$currentContainer.find(this.BENEFICIARY_NAMES_INSIDE_QUESTIONNAIRE_CONTAINER)):$(this.BENEFICIARY_NAMES_CONTAINER).detach().appendTo(this.BENEFICIARY_NAMES_OUTSIDE_QUESTIONNAIRES_CONTAINER),this.$currentContainer.show(),this.hasMandatoryFields=this.$currentContainer.length?0<this.$currentContainer.find(".mandatory").length:!1):($(this.FORM_HIDDEN_INPUT_ID_SELECTOR).val(""),this.$currentContainer=null,this.hasMandatoryFields=!1,$(this.BENEFICIARY_NAMES_CONTAINER).detach().appendTo(this.BENEFICIARY_NAMES_OUTSIDE_QUESTIONNAIRES_CONTAINER));
$(this.REUSE_ANSWERS_CHECKBOX_SELECTOR).prop("checked",!1);this.$currentContainer&&this.$currentContainer.length&&this.hasMultipleTicketsOnPage&&0<this.$currentContainer.find(".copyAllowed").length?$(this.REUSE_ANSWERS_CONTAINER_SELECTOR).show():$(this.REUSE_ANSWERS_CONTAINER_SELECTOR).hide();this.additionalConfig&&!0===this.additionalConfig.isTransfer&&$(this.REUSE_ANSWERS_CONTAINER_SELECTOR).hide();this.$currentContainer&&this.$currentContainer.length&&this.$currentContainer.find(".beneficiary_question").each(function(a){var b=
$(this);$.each(".beneficiary_boolean .beneficiary_number .beneficiary_date .beneficiary_phone .beneficiary_email .beneficiary_text .beneficiary_single .beneficiary_multi .beneficiary_address_line_1 .beneficiary_address_line_2 .beneficiary_address_line_3 .beneficiary_address_country .beneficiary_address_zip_city .beneficiary_address_existing".split(" "),function(a,c){account.beneficiary.validation.cleanContainerFromError(b.find(c))})});this.$currentContainer&&this.$currentContainer.length&&this.$currentContainer.find(".beneficiary_address_existing").each(function(a){var b=
$(this);b.find(".beneficiary_address_existing_item").hide();b.find("select").val("");b.find("select").on("change",function(){b.find(".beneficiary_address_existing_item").hide();b.find("#beneficiary_existing_address_"+$(this).val()).show()})});this.applyDefaultValues()};
account.beneficiary.Questionnaire.prototype.applyDefaultValues=function(){var a=this;this.$currentContainer&&this.$currentContainer.length&&this.$currentContainer.find(".beneficiary_question").each(function(b){b=$(this);var c=b.attr("data-id"),d=c in a.defaultAnswersValues,f=a.getSavedAnswer(c),e=a.answerQustnnrMapKey in(a.savedAnswersValues||{})&&c in(a.savedAnswersValues[a.answerQustnnrMapKey]||{}),g=a.answerQustnnrMapKey in(a.alreadySetAnswersValues||{})&&c in(a.alreadySetAnswersValues[a.answerQustnnrMapKey]||
{}),h=d||!!f||e||g,l="",k="0",m="0",p="0",q={},r=0,t=[];r=!1;e?(l=a.savedAnswersValues[a.answerQustnnrMapKey][c],r=!0):g?(l=a.alreadySetAnswersValues[a.answerQustnnrMapKey][c],r=!0):f?l=f:d&&(l=a.defaultAnswersValues[c]);r&&b.addClass("is-defined");if(b.find(".beneficiary_boolean").length)b.find('input[type="radio"]').each(function(){$(this).prop("checked",!1)}),h&&b.find('input:radio[value="'+l+'"]').prop("checked",!0);else if(b.find(".beneficiary_number").length||b.find(".beneficiary_phone").length||
b.find(".beneficiary_email").length||b.find(".beneficiary_text").length)b.find('input[type="number"], input[type="text"], input[type="email"]').val(h?l:"");else if(b.find(".beneficiary_date").length)h&&(c=l.split("-"),3===c.length&&(p=c[0],m=parseInt(c[1],10).toString(),k=parseInt(c[2],10).toString())),b.find('select[id$="_day"]').val(k),b.find('select[id$="_month"]').val(m),b.find('select[id$="_year"]').val(p);else if(b.find(".beneficiary_single").length)b.find("select").val(h?l:"");else if(b.find(".beneficiary_address_existing").length)b.find("select").val(h?
l:""),h&&l.length&&(b.find(".beneficiary_address_existing_item").hide(),b.find("#beneficiary_existing_address_"+l).show());else if(b.find(".beneficiary_multi").length){if(b.find("option:selected").removeAttr("selected"),h)for(t=l.split(","),r=0;r<t.length;r++)t[r].length&&b.find('option[value="'+t[r]+'"]').attr("selected",!0)}else b.find(".beneficiary_address").length&&(l.length&&(q=JSON.parse(l)),b.find(a.FORM_SELECTOR_ADDRESS_LINE1).val(h&&"addressLine1"in q?q.addressLine1:""),b.find(a.FORM_SELECTOR_ADDRESS_LINE2).val(h&&
"addressLine2"in q?q.addressLine2:""),b.find(a.FORM_SELECTOR_ADDRESS_LINE3).val(h&&"addressLine3"in q?q.addressLine3:""),b.find(a.FORM_SELECTOR_ADDRESS_COUNTRY).val(h&&"addressCountry"in q?q.addressCountry:""),b.find(a.FORM_SELECTOR_ADDRESS_ZIP_CODE).val(h&&"addressZipCode"in q?q.addressZipCode:""),b.find(a.FORM_SELECTOR_ADDRESS_CITY).val(h&&"addressCity"in q?q.addressCity:""))});a.isUpdateBeneficiary?$("#beneficiary_save_checkbox").attr("disabled","disabled"):$("#beneficiary_save_checkbox").prop("disabled",
!1)};
account.beneficiary.Questionnaire.prototype.save=function(){var a=this,b=$(this.REUSE_ANSWERS_CHECKBOX_SELECTOR).is(":checked");this.$currentContainer&&this.$currentContainer.length&&this.$currentContainer.find(".beneficiary_question").each(function(c){var d=$(this);c=d.attr("data-id");var f=d.hasClass("copyAllowed"),e="",g=a.answerQustnnrMapKey in a.savedAnswersValues;if(d.find(".beneficiary_boolean").length)d=d.find('input[type="radio"]:checked'),d.length&&(e=d.val());else if(d.find(".beneficiary_number").length||d.find(".beneficiary_phone").length||
d.find(".beneficiary_email").length||d.find(".beneficiary_text").length)d=d.find('input[type="number"], input[type="text"], input[type="email"]'),1===d.length&&(e=d.val());else if(d.find(".beneficiary_date").length){var h=d.find('select[id$="_day"]');var l=d.find('select[id$="_month"]');d=d.find('select[id$="_year"]');1===h.length&&1===l.length&&1===d.length&&"0"!==h.val()&&"0"!==l.val()&&"0"!==d.val()&&(e=d.val()+"-"+l.val()+"-"+h.val())}else if(d.find(".beneficiary_single").length||d.find(".beneficiary_address_existing").length)d=
d.find("select"),null!==d.val()&&d.val().length&&(e=d.val());else if(d.find(".beneficiary_multi").length)d=d.find("select"),null!==d.val()&&d.val().length&&(e=d.val().toString());else if(d.find(".beneficiary_address")){h=d.find(a.FORM_SELECTOR_ADDRESS_LINE1);l=d.find(a.FORM_SELECTOR_ADDRESS_LINE2);var k=d.find(a.FORM_SELECTOR_ADDRESS_LINE3);var m=d.find(a.FORM_SELECTOR_ADDRESS_COUNTRY);var p=d.find(a.FORM_SELECTOR_ADDRESS_ZIP_CODE);d=d.find(a.FORM_SELECTOR_ADDRESS_CITY);if(h.length&&h.val().length||
l.length&&l.val().length||k.length&&k.val().length||m.length&&m.val().length||p.length&&p.val().length||d.length&&d.val().length)e=JSON.stringify({addressLine1:h.val(),addressLine2:l.val(),addressLine3:k.val(),addressZipCode:p.val(),addressCity:d.val(),addressCountry:m.val()})}b&&f&&a.saveAnswer(c,e);g||(a.savedAnswersValues[a.answerQustnnrMapKey]={});a.savedAnswersValues[a.answerQustnnrMapKey][c]=e})};
account.beneficiary.Questionnaire.prototype.fillEmails=function(){this.$currentContainer&&this.$currentContainer.length&&this.$currentContainer.find(".beneficiary_question .beneficiary_email input").each(function(a){$(this).val(contactName.email)})};account.beneficiary.Questionnaire.prototype.propagate=function(a,b){var c=this.savedAnswersValues,d={};c[a]&&($.extend(!0,d,c[a]),c[b]=d)};
account.beneficiary.Questionnaire.prototype.getQuestionnaire=function(a,b){return $.extend(!0,{},this.savedAnswersValues[a]||this.savedAnswersValues[b]||this.alreadySetAnswersValues[a]||this.alreadySetAnswersValues[b])};account.beneficiary.Questionnaire.prototype.setQuestionnaire=function(a,b,c){this.savedAnswersValues[a]=c;this.alreadySetAnswersValues[a]=c;this.alreadySetAnswersValues[b]=c};
account.beneficiary.Questionnaire.prototype.saveAnswer=function(a,b){this.getSavedAnswer(a);var c=this.savedAnswersValuesForReuse;c[a]=b;tools.isStorageAvailable()&&tools.storage.setItem("questionnaire_saved_"+this.currentId,c)};
account.beneficiary.Questionnaire.prototype.getSavedAnswer=function(a){var b=this.savedAnswersValuesForReuse;!b&&tools.isStorageAvailable()&&(this.savedAnswersValuesForReuse=b=tools.storage.getItem("questionnaire_saved_"+this.currentId));b||(this.savedAnswersValuesForReuse=b={});return b[a]};
account.beneficiary.Questionnaire.prototype.getAllAnswerByKey=function(){var a,b={},c,d={};$(".beneficiary_question").each(function(a,c){a=$(c).find("input").get(0)||{};b[$(c).attr("data-id")]=a.value});for(a in this.alreadySetAnswersValues){var f=this.alreadySetAnswersValues[a];var e={};for(c in f)e[b[c]]=f[c];d[a]=e}return d};
tools.module("account.beneficiary.form",function(){var a=null,b=null,c=!1,d={},f=null,e={},g,h={},l=!1,k=!1,m=null,p=!1,q="",r="",t="",w="",y="",z="",x="",A=!1,C=!1,u=!1,v=!1,D=!1,E=!1,F=!1,B="",G="",L="",K="",H="",M="",Q="",S="",V="",N=null,I,O,R=[],X={},T={},Z={},ba={ERR_WRONG_RFID_CARD_NUMBER:"#beneficiary_form .message.error.rfid_wrong_card_from_server",ERR_UNKNOWN_LOADING_RFID:"#beneficiary_form .message.error.rfid_server_error",ERR_ALREADY_USED_RFID_CARD_NUMBER:"#beneficiary_form .message.error.rfid_already_used_card_from_server",
ERR_SAME_DATE_TICKET_EXISTS_ON_RFID_CARD:"#beneficiary_form .message.error.rfid_same_date_ticket_exists_on_card_from_server",ERR_WRONG_RFID_CARD_NUMBER_OR_POSTCODE:"#beneficiary_form .message.error.rfid_wrong_card_or_postcode_from_server"},U=!1,P=!1,Y=!1,da=!1,aa=!1,W="";isPOENotAllowed=function(a){return a.hasAttachment&&!a.isAllowPOEUpdate};buildFirstNameAsFormatted=function(a){return null!==a&&void 0!==a&&Y?a.toLowerCase().replace(/^([a-z])|([\s\-'])([a-z])/g,function(a){return a.toUpperCase()}):
a};buildLastNameAsFormatted=function(a){return null!==a&&void 0!==a&&Y?a.toUpperCase():a};displayRFIDCardInfos=function(a,b,c){var d=function(){var a=arguments[0],b;for(b=1;b<arguments.length;b++){var c=new RegExp("\\{"+(b-1)+"\\}","gm");a=a.replace(c,arguments[b])}return a};var e=function(a,b,c,e){var f=a.cardNumber.replace(/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g,"\\$&");b='<div class="rfid_card_selection"><label class="rfid_card_lb"><img src="'+(b[a.cardTypeData.cardTypeId].url||c)+'" alt="rfid img info"/><div class="rfid_card"><input type="radio" name="containerId" value ="{0}" id="card{0}""/><label class="rfid_card_number" for="{0}">{0}</label></label></div></div>';
$("#existing_rfid_card").append(d(b,a.cardNumber));"function"===typeof $("#card"+f).change&&$("#card"+f).change(function(){$("#rfid_card_number").focus();$("#rfid_card_number").val($(this).val()).prop("readonly",!0)});e&&$("#card"+f).prop("checked",e).change()};var f='<label><img src="'+b+'" alt="rfid img info"/><div><input type="radio" name="containerId" value ="" id="new" /><label for="new">'+B+"</label></label></div>";$("#rfid_card_info").html("");$("#rfid_card_info").append(f);F?($("#new").prop("checked",
!0),$("#rfid_card_number").focus(),$("#new").change(function(){$("#rfid_card_number").val("").prop("readonly",!1);$("#rfid_card_number").focus()})):$.ajax({url:contextPath+"/ajax/account/order/getListCardNumber?contactReference="+c,type:"GET",cache:!1,success:function(c){$("#existing_rfid_card").html("");c=c.filter(function(b){return a[b.cardTypeData.cardTypeId]});(c||[]).forEach(function(c,d){e(c,a,b,0===d)});0===c.length&&($("#new").prop("checked",!0),$("#rfid_card_number").focus());$("#new").change(function(){$("#rfid_card_number").val("").prop("readonly",
!1);$("#rfid_card_number").focus()})},error:function(a){tools.dialog.hideDialog("loadingDialog");403!==a.status&&tools.dialog.showDialog("ajaxErrorDialog",!0)}})};openForm=function(){var b=$("#beneficiary_form").addClass("open"),c=$(a).addClass("open"),d=c.parents(".print_button_container_for_expand_panel"),e=c.parents(".ticket_additional_container").addClass("beneficiary_expanded");c=c.parents(".print, .print_options").find(".questionnaire_answers");c.length&&c.is(":visible")&&c.find(".close_expand_panel").trigger("click");
b.detach().appendTo(e);d.addClass("beneficiary_expanded").find(".triangle_expand_panel").show();b.slideDown(150);$("#beneficiary_form").find("#beneficiary_first_name").focus();$("#beneficiary_form").find("#beneficiary_last_name").focus();tools.form.focusFirstEmptyField($("#beneficiary_form"));b.find("select[multiple='multiple']").each(function(a,b){var c=[];$("#"+b.id+" option[selected='selected']").each(function(a,b){c.push(b.value)});$(b).val(c)})};slideToAndOpenForm=function(){$("body, html").animate({scrollTop:$(a).offset().top-
60},400,function(){openForm()})};hideModifyingStatus=function(a){a=$(a).closest(".ticket_additional_container");var b=$(".printed_status",a);$(".current_edit_beneficiary",a).remove();$(".already_printed_status",b).show()};handleHide=function(a){var b=$(a).removeClass("open");b.parents(".print_button_container_for_expand_panel").removeClass("beneficiary_expanded").find(".triangle_expand_panel").hide();b.parents(".ticket_additional_container").removeClass("beneficiary_expanded");$("#beneficiary_form").removeClass("open");
hideModifyingStatus(a)};resetQuestionnaireFieldsAttr=function(){var a=$("#beneficiary_first_name");$("#beneficiary_last_name").prop("disabled",!1);a.prop("disabled",!1);f.$currentContainer&&f.$currentContainer.length&&f.$currentContainer.find(".beneficiary_question").each(function(a){a=$(this);if(a.find(".beneficiary_date").length){var b=a.find('select[id$="_day"]');var c=a.find('select[id$="_month"]');a=a.find('select[id$="_year"]');b.prop("disabled",!1);c.prop("disabled",!1);a.prop("disabled",!1)}else a.find(".beneficiary_single").length||
a.find(".beneficiary_multi").length||a.find(".beneficiary_address_existing").length?(b=a.find("select"),b.prop("disabled",!1),a.find(".manage_address_book").length&&a.find(".manage_address_book").addClass("show")):a.find(".beneficiary_text").length||a.find(".beneficiary_phone").length?(b=a.find('input[type="text"]'),b.prop("disabled",!1)):a.find(".beneficiary_email").length?(b=a.find('input[type="email"]'),b.prop("disabled",!1)):a.find(".beneficiary_number").length?(b=a.find('input[type="number"]'),
b.prop("disabled",!1)):a.find(".beneficiary_boolean").length&&(b=a.find('input[type="radio"]:disabled'),b.prop("disabled",!1))})};hideForm=function(){var b=a;$("#beneficiary_form").slideUp(150,function(){handleHide(b)})};hideFormAndOpenNext=function(){$("#beneficiary_form").slideUp(150,function(){handleHide(b);slideToAndOpenForm()})};hideFormAndOpenNextWithoutAnimation=function(){handleHide(b);slideToAndOpenForm()};hideAnswers=function(a){a.slideUp(150,function(){a.find(".triangle_expand_panel").hide()})};
openAnswers=function(a){var b=a.parents(".print, .print_options").find("#beneficiary_form");b.length&&b.is(":visible")&&b.find(".close_expand_panel").trigger("click");a.slideDown(150);a.find(".close_expand_panel").click(function(){hideAnswers(a);return!1});a.find(".triangle_expand_panel").show()};slideToAndOpenAnswers=function(a){a.length&&$("body,html").animate({scrollTop:a.parents(".print, .print_options").offset().top-60},400,function(){openAnswers(a)})};getConfigurationInternal=function(a,b,c){var d=
a;b&&(d+="_"+b);var e=c[d];if(void 0!==e)return e;$.each(c,function(b,c){c.id===a&&(e=c)});return e};getConfiguration=function(a,b){return getConfigurationInternal(a,b,e)};getOriginalConfiguration=function(a,b){return getConfigurationInternal(a,b,h)};getMembershipByMovement=function(a){return T[a]?(X[T[a]]=X[T[a]]||{},X[T[a]]):{}};scrollFormToView=function(a){var b=$(window).height(),c=$(document).scrollTop();b=c+b;a=$(a).offset();(a.top<c||a.top>b)&&$("body,html").animate({scrollTop:$("#beneficiary_form").offset().top-
50},400)};submitBeneficiaryAndLoadOntoCard=function(a,b,c){var d=getConfiguration(a,b),g=$("#beneficiary_form .message.error.generic_mandatory_msg"),h=$("#beneficiary_form .message.error.membership_number_msg");var k=account.beneficiary.validation.checkBeneficiaryForm(d,"#beneficiary_first_name","#beneficiary_last_name",f,E,G,R,getMembershipByMovement(d.movementId),null,m,U,P,e);$("#beneficiary_form .message.error.rfid_wrong_card").hide();""===$.trim($("#rfid_card_number").val())?(k.mandatory=!0,
g=$("#beneficiary_form .message.error.rfid_wrong_card_from_server"),$("#rfid_card_number").addClass("wrong"),$("#rfid_card_number").one("focus",function(){$("#rfid_card_number").removeClass("wrong")})):$("#beneficiary_form .message.error.rfid_wrong_card_from_server").hide();!k.mandatory&&0<$("#rfidClaimerAccepted").length&&!$("#rfidClaimerAccepted").is(":checked")&&(k.mandatory=!0,g=$("#beneficiary_form .message.error.rfid_not_accept_swisspass_condition"));k.mandatory?(g.show(),scrollFormToView(g)):
k.membership?(h.show(),scrollFormToView(h)):(tools.dialog.showWaitingPopup("LoadingRFIDDialog",!0),f.save(),k=$("#beneficiary_form form").serialize(),$.ajax({url:contextPath+"/ajax/account/order/loadTicketOntoCard",type:"POST",cache:!1,data:k,success:function(e,f,g){$("#beneficiary_form .message.error.rfid_wrong_card_from_server").hide();$("#beneficiary_form .message.error.rfid_wrong_card_or_postcode_from_server").hide();$("#beneficiary_form .message.error.rfid_server_error").hide();$("#beneficiary_form .message.error.rfid_already_used_card_from_server").hide();
$("#beneficiary_form .message.error.rfid_checkbox_not_checked").hide();$("#input_rfid_card_zipcode").val("");e.success?null!==e.parameters&&e.parameters.requireZipCode?($("#cancel_card_verification").unbind("click").on("click",function(){tools.dialog.hideDialog("card_verification_popup");tools.dialog.hideDialog("LoadingRFIDDialog");return!1}),$("#process_card_verification").unbind("click").on("click",function(){if(""===$("#field_rfid_card_zip_code").val())return!1;$("#input_rfid_card_zipcode").val($("#field_rfid_card_zip_code").val());
tools.dialog.hideDialog("card_verification_popup");submitBeneficiaryAndLoadOntoCard(a,b,c);return!1}),$("#field_rfid_card_zip_code").unbind("keyup").on("keyup",function(){""===$("#field_rfid_card_zip_code").val()?$("#process_card_verification").parent().addClass("disabled"):$("#process_card_verification").parent().removeClass("disabled")}),$("#field_rfid_card_zip_code").val(""),$("#process_card_verification").parent().addClass("disabled"),tools.dialog.showDialog("card_verification_popup",!0,!0),N&&
N(d,$("#beneficiary_form form").serializeArray())):window.location.reload():ba[e.status]?(tools.dialog.hideDialog("LoadingRFIDDialog"),$(ba[e.status]).show(),$("#rfid_card_number").addClass("wrong"),$("#rfid_card_number").one("focus",function(){$("#rfid_card_number").removeClass("wrong")})):(tools.dialog.hideDialog("LoadingRFIDDialog"),hideForm(),tools.dialog.showDialog("ajaxErrorDialog",!0))},error:function(){tools.dialog.hideDialog("LoadingRFIDDialog");hideForm();tools.dialog.showDialog("ajaxErrorDialog",
!0)}}))};updatePrintButtons=function(a){var b=a.ticketId,c=contextPath+"/account/order/generateTicket?id="+b+"&ticketName="+encodeURIComponent(a.ticketFileName)+"&printed=true";$("#print_"+b+"_MOBILE").unbind("click").attr("target","_blank").attr("href",c+"&support=MOBILE");$("#print_"+b+"_ETICKET").unbind("click").attr("target","_blank").attr("href",c+"&support=ETICKET");a.isTabletOrMobile||$("#print_"+b+"_ETICKET .text").text(W);$("#print_"+b+"_PASSBOOK").unbind("click").attr("target","_blank").attr("href",
c+"&support=PASSBOOK")};normalizeFileName=function(a){var b=a.lastName||"";a=a.ticketFileName.replace("FIRSTNAME_PLACEHOLDER",a.firstName||"").replace("LASTNAME_PLACEHOLDER",b);return diacritics.removeDiacritics(a).replace(/\s+/g,"-").replace(/[^A-Za-z0-9_\-.{}]/g,"")};finalSubmitBeneficiaryAndPrint=function(a,b,c,d,e){var f;tools.dialog.showWaitingPopup("beneficiaryProcessingDialog",!0);resetQuestionnaireFieldsAttr();var g=d.serializeArray();(f=window.open(contextPath+"/account/file/generateTicket",
"Ticket"+b))?$.ajax({url:contextPath+"/ajax/account/order/generateTicketWithAnswers"+(e?"?isUpdateBeneficiary=true":""),method:"POST",data:d.serialize()}).then(function(d){var e="";tools.dialog.hideDialog("beneficiaryProcessingDialog");if("SESSION_EXPIRED"===d.status)return tools.dialog.showDialog("sessionExpiredWhileGeneratingTicketDialog",!0,!0),f.close(),!1;if("OK"!==d.status)return tools.dialog.showDialog("ajaxErrorDialog",!0),f.close(),!1;try{e=f.location.href}catch(pa){}f.location.href=contextPath+
"/account/order/ticket/"+encodeURIComponent(normalizeFileName(a))+"?id="+d.ticketId+"&support="+c+"&isUpdateBeneficiary=true";try{f.account.beneficiary.general.checkDownloaded(e)}catch(pa){}f.focus();(d.ticketId!=b||p)&&window.location.reload();N&&N(a,g)},function(){tools.dialog.hideDialog("beneficiaryProcessingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}):(tools.dialog.hideDialog("beneficiaryProcessingDialog"),tools.dialog.showDialog("unsupportedBrowserTicketDialog"))};propagateBeneficiary=
function(a,b,c){var d=getConfiguration(a,b),g=d.ticketId||d.movementId,h,k=d&&d.associatedMovements;k&&k.length&&$.each(e,function(){0>$.inArray(this.movementId,k)||(this.firstName=d.firstName,this.lastName=d.lastName,c&&c(this),h=this.ticketId||this.movementId,g&&h&&f.propagate(g,h))})};updateConfiguration=function(a){a.firstName=$("#beneficiary_first_name").val();a.lastName=$("#beneficiary_last_name").val();a.ticketFileNameLabel&&(a.ticketFileNameLabel.includes("{0}")?a.ticketFileName=a.ticketFileNameLabel.replace("{0}",
a.firstName).replace("{1}",a.lastName):a.ticketFileName=a.ticketFileNameLabel.replace("{1}",a.firstName).replace("{2}",a.lastName));a.ticketFileName=normalizeFileName(a)};hidePrintButton=function(a,b){"MOBILE"===a?$("#print_"+b+"_ETICKET").parent().parent().hide():"ETICKET"===a&&$("#print_"+b+"_MOBILE").parent().parent().hide()};submitBeneficiaryAndPrint=function(a,b,c,d){var g=getConfiguration(a,b),h=g.isTabletOrMobile,k=g.containsRFIDSupport,l=g.shipmentMode||[],p=l.typeRFID,A=l.typeElectronic,
x=l.typeMobile,u=account.beneficiary.validation.checkBeneficiaryForm(g,"#beneficiary_first_name","#beneficiary_last_name",f,E,G,R,getMembershipByMovement(g.movementId),null,m,U,P,e),C=$("#beneficiary_first_name").val(),q=$("#beneficiary_last_name").val(),J=$("#beneficiary_form .message.error.generic_mandatory_msg"),B=$("#beneficiary_form .message.error.membership_number_msg"),r=null,t=account.beneficiary.form.setPrintedStatus;(p&&k||!0===d)&&!$("#field_rfid_checkbox").is(":checked")&&(u.mandatory=
!0,J=$("#beneficiary_form .message.error.rfid_checkbox_not_checked"));if(u.mandatory)J.show(),scrollFormToView(J);else if(u.membership)B.show(),scrollFormToView(B);else return f.save(),$("#beneficiary_first_name").val()===contactName.firstName&&$("#beneficiary_last_name").val()===contactName.lastName&&(v=!0),r=function(d){g.ticketFileName=d;updatePrintButtons(g);p&&($("#print_"+a+"_RFID").parents(".print_button_container_for_expand_panel").hide(),$("#print_"+a+"_RFID").parent().parent().parent().find(".support_separator").hide(),
$("#print_"+a+"_DEMAT_BADGE").parents(".print_button_container_for_expand_panel").hide(),$("#print_"+a+"_DEMAT_BADGE").parent().parent().parent().find(".support_separator").hide());c?t(g.movementId,C,q,h,A,x,f.currentId,!1,g.allowUpdateTicketInfo):t(a,C,q,h,A,x,f.currentId,!1,g.allowUpdateTicketInfo);propagateBeneficiary(a,b,function(a){var b=a.shipmentMode||[];a.ticketFileName=normalizeFileName(a);updatePrintButtons(a);a.nonPrintableBeneficiaryModifiable&&$('select[data-movement-id="'+a.movementId+
'"]').attr("disabled","disabled");t(a.ticketId,a.firstName,a.lastName,a.isTabletOrMobile,b.isShipmentModeTypeElectronic,b.isShipmentModeTypeMobile,a.questionnaireId,!0,a.allowUpdateTicketInfo)});g.nonPrintableBeneficiaryModifiable&&$('select[data-movement-id="'+g.movementId+'"]').attr("disabled","disabled");tools.dialog.hideDialog("beneficiaryProcessingDialog")},updateConfiguration(g),r(g.ticketFileName),$("#input_beneficiary_fileName").val(g.ticketFileName),hideForm(),l.typeMobile&&aa&&hidePrintButton(b,
a),tools.dialog.showWaitingPopup("beneficiaryProcessingDialog",!0),finalSubmitBeneficiaryAndPrint(g,a,b,$("#beneficiary_form form"),c)};updateDisplay=function(a){var b=a.ticketId,c=a.movementId,d=b||c,e="",f=a.firstName&&a.lastName?x+": "+a.firstName+" "+a.lastName:q;a.questionnaireId&&!a.noAlreadyPrintedStatus&&(e=" with_answers");a.nonPrintableBeneficiaryModifiable||U?$("#set_beneficiary_"+b).find(".text").html(r):$("#set_beneficiary_"+b).hide();changeMatchButtonsLabels(d);beneficiaries.isBeneficiarySelectorEnabled()||
(c=$("#printed_status_"+d+" .beneficiary_selector_label"),$(c).hasClass("beneficiary_selector_hidden")||(q===f?$("#not_printed_status_"+d).html('<span class="not_printed_status beneficiary_selector_label'+e+'"></span>').find("span").text(f):$("#printed_status_"+d).html('<span class="already_printed_status beneficiary_selector_label'+e+'"></span>').find("span").text(f)));if(a.questionnaireId&&!a.noAlreadyPrintedStatus)$("#printed_status_"+d+" .beneficiary_selector_label,#not_printed_status_"+d+" .beneficiary_selector_label").unbind().on("click",
function(){account.beneficiary.form.showAnswers(this,b,a.movementId);return!1});!a.nonPrintableBeneficiaryModifiable&&a.firstName&&a.lastName&&(U&&$("#printed_status_"+d).parent().find(".print_button_container_for_expand_panel").html('<span class="cannot_modify_beneficiary_info">'+t+"</span>"),$("#printed_status_"+d+" .beneficiary_selector").attr("disabled","disabled"))};updateDisplayedData=function(a,b){$("#beneficiary_first_name").val()===contactName.firstName&&$("#beneficiary_last_name").val()===
contactName.lastName&&(v=!0);updateConfiguration(b);updateDisplay(b);propagateBeneficiary(a,null,updateDisplay);tools.dialog.hideDialog("beneficiaryProcessingDialog");hideForm();N&&N(b,d[a])};serializeAllArray=function(a){var b=a.find(":input:disabled").prop("disabled",!1);a=a.serializeArray();b.attr("disabled","disabled");return a};prepareFormDataToSubmit=function(a){if(U||P)var b=a.find(":input:disabled").prop("disabled",!1);a=a.serializeArray();null!=b&&b.attr("disabled","disabled");return a};
submitBeneficiary=function(a,b){var g=getConfiguration(a),h=getMembershipByMovement(g.movementId);h[g.movementId]=null;b=account.beneficiary.validation.checkBeneficiaryForm(g,"#beneficiary_first_name","#beneficiary_last_name",f,E,G,R,h,b,m,U,P,e);if(b.mandatory)return $("#beneficiary_form .message.error.generic_mandatory_msg").show(),scrollFormToView("#beneficiary_form .message.error.generic_mandatory_msg"),!1;if(b.membership)return $("#beneficiary_form .message.error.membership_number_msg").show(),
scrollFormToView("#beneficiary_form .message.error.membership_number_msg"),!1;if(b.isPeselError)return $("#beneficiary_form .message.error.invalid_pesel").show(),scrollFormToView("#beneficiary_form .message.error.invalid_pesel"),!1;if(b.isAllowedCharacterError)return $("#beneficiary_form .message.error.not_allowed_character").show(),scrollFormToView("#beneficiary_form .message.error.not_allowed_character"),!1;if(b.isNotUniqueBeneficiary)return $("#beneficiary_form .message.error.duplicated_main_ticket").show(),
scrollFormToView("#beneficiary_form .message.error.duplicated_main_ticket"),!1;f.save();d[a]=serializeAllArray($("#beneficiary_form form"));c?updateDisplayedData(a,g):(tools.dialog.showWaitingPopup("beneficiaryProcessingDialog",!0),$.ajax({url:contextPath+"/ajax/account/order/setBeneficiaryOnMovement",type:"POST",cache:!1,data:serializeAllArray($("#beneficiary_form form")),success:function(b,c,d){b.success?updateDisplayedData(a,g):ba[b.status]?(tools.dialog.hideDialog("beneficiaryProcessingDialog"),
tools.dialog.showDialog("ajaxErrorDialog",!0)):"ERR_NOT_UNIQUE_BENEFICIARY"===b.status?(tools.dialog.hideDialog("beneficiaryProcessingDialog"),$("#beneficiary_form .message.error.duplicated_main_ticket").show(),scrollFormToView("#beneficiary_form .message.error.duplicated_main_ticket")):"ERR_MANDATORY_DATA_MISSING"===b.status&&(tools.dialog.hideDialog("beneficiaryProcessingDialog"),$("#beneficiary_form .message.error.generic_mandatory_msg").show(),scrollFormToView("#beneficiary_form .message.error.generic_mandatory_msg"))},
error:function(){tools.dialog.hideDialog("beneficiaryProcessingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}}));return!0};getAllowUpdateTicketInfoConfigurations=function(a,b){var c=[];$.each(e,function(){(this.ticketId===a.toString()||this.movementId===b)&&this.allowUpdateTicketInfo&&0<=["MOBILE","ETICKET"].indexOf(this.support)&&c.push(this)});return c};showModifyingStatus=function(a,b){a=$("#print_"+a+"_MOBILE, #print_"+a+"_ETICKET, #print_"+a+", #print_"+b+"_MOBILE, #print_"+b+"_ETICKET, #print_"+
b);a=$(".printed_status",a.closest(".ticket_additional_container"));b=$("<span></span>").addClass("current_edit_beneficiary").text(currentEditBeneficiary);$(".current_edit_beneficiary",a).remove();$(".already_printed_status",a).hide();a.append(b)};getQuestionBaseName=function(a){a=$("input[value='"+a+"']").map(function(){return-1===$(this).parent().parent().attr("style").indexOf("none")?$(this).attr("name"):""}).filter(function(a){return""!==this.valueOf()});1===a.length&&(a=a.get(0));return 0!==
a.length?a.substr(0,a.lastIndexOf(".")):null};handleMandatoryQuestion=function(a,b){a&&(a=$("[name='"+getQuestionBaseName(a)+".answer']").parents(".beneficiary_question").find(".field_label"),b?0===a.find(".mandatory").length&&a.append('<span class="mandatory">*</span>'):a.find(".mandatory").remove())};handleMembershipContingents=function(a){var b;var c=$("input[name='"+getQuestionBaseName(M)+".answer']").parents(".beneficiary_question");c.removeClass("hidden");if(b=c.find('input[type="text"]').get(0))b.onchange=
function(){$(b).val($.trim($(b).val()))};if(L){var d=$("input[value='"+L+"']");d.parent().find("select").each(function(a,b){b.onchange=function(){R=[]}})}-1<O.indexOf(Number(a))?(c.addClass("mandatory"),handleMandatoryQuestion(M,!0)):(c.removeClass("mandatory"),handleMandatoryQuestion(M,!1))};handleCityProvinceMandatoryForItaly=function(a,b,c,d,e){var f;var g=$("[name='"+getQuestionBaseName(a)+".answer']").parents(".beneficiary_question");var h=$("input[name='"+getQuestionBaseName(b)+".answer']").parents(".beneficiary_question");
K&&(f=$("select[name='"+getQuestionBaseName(K)+".answer']").parents(".beneficiary_question"));"true"===c&&("IT"===d?(g.addClass("mandatory"),handleMandatoryQuestion(a,!0),g.removeClass("hidden"),e?(a=g.find("select"),a.get(0)&&(a.replaceWith('<input type="text" id="'+a.get(0).id+'" name="'+a.get(0).name+'" />'),g.removeClass("beneficiary_single"),g.addClass("beneficiary_text"),g=g.find(".beneficiary_single"),g.removeClass("beneficiary_single"),g.addClass("beneficiary_text"))):(h.addClass("mandatory"),
handleMandatoryQuestion(b,!0),h.removeClass("hidden")),f&&(f.addClass("mandatory"),handleMandatoryQuestion(K,!0))):(e||(h.removeClass("mandatory"),handleMandatoryQuestion(b,!1),$("input[name='"+getQuestionBaseName(b)+".answer']").val(""),h.addClass("hidden")),g.removeClass("mandatory"),handleMandatoryQuestion(a,!1),$("[name='"+getQuestionBaseName(a)+".answer']").val(""),g.addClass("hidden"),f&&(f.removeClass("mandatory"),handleMandatoryQuestion(K,!1))))};isBeneficiaryMandatory=function(a){return a.isPerformance?
a.forceBeneficiaryMandatory?!0:a.mandatoryBeneficiary:!1};handledBeneficiaryMandatory=function(a,b){var c=a.isPerformance;A&&account.beneficiary.validation.addMandatory2Label("#beneficiary_form","#field_first_name",!0);C&&account.beneficiary.validation.addMandatory2Label("#beneficiary_form","#field_last_name",!0);$(".beneficiary_question.mandatory").filter(function(a,b){return $(b).data("id")&&0>Number($(b).data("id"))}).find(".field_label").each(function(a,b){0===$(b).find(".mandatory").length&&
$(b).append('<span class="mandatory">*</span>')});if(c){var d=isBeneficiaryMandatory(a);b.find('label[for="beneficiary_first_name"] .mandatory').remove();b.find('label[for="beneficiary_last_name"] .mandatory').remove();d&&(account.beneficiary.validation.addMandatory2Label("#beneficiary_form","#field_first_name",!0),account.beneficiary.validation.addMandatory2Label("#beneficiary_form","#field_last_name",!0));$(".beneficiary_question.mandatory").filter(function(a,b){return $(b).data("id")&&0>Number($(b).data("id"))}).find(".field_label").each(function(a,
b){$(b).find(".mandatory").remove();d&&$(b).append('<span class="mandatory">*</span>')})}};isTicketHolderNameMandatory=function(a){return a.isPerformance?a.forceBeneficiaryMandatory||a.mandatoryBeneficiary:A||C};fillConfigurationWithQuestionnaire=function(a,b){var c,d,e;for(c in a){var f=a[c];if((d=b[f.ticketId]||b[f.movementId])&&f)for(e in d)switch(e){case "QU_EXB_BD":if(d[e]&&d[e].split){var g=d[e].split("-");f.birthdayYear=g[0];f.birthdayMonth=g[1];f.birthdayDay=g[2]}break;case "QU_EXB_NA":f.countryCode=
d[e];break;case "QU_EXB_ID":f.idNumber=d[e];break;case "QU_EXB_BP":f.birthPlace=d[e];break;case "QU_EXB_BR":f.birthRegion=d[e];break;case "Title":f.title=d[e];break;case "Country":f.residenceCountry=d[e]}}};resetConfiguration=function(a){a.firstName="";a.lastName="";a.birthdayYear=null;a.birthdayMonth=null;a.birthdayDay=null;a.countryCode=null;a.idNumber=null;a.birthPlace=null;a.birthRegion=null;a.title=null;a.residenceCountry=null;a.isHistoryContact=!1;a.readOnlyBeneficiary=!1};resetContactConfiguration=
function(){isAnyMainOwnerSetted()||$.each(e,function(){this.contactTitle=g.contactTitle;this.contactResidenceCountry=g.contactResidenceCountry;this.contactBirthPlace=g.contactBirthPlace;this.contactBirthRegion=g.contactBirthRegion;this.contactFirstName=g.contactFirstName;this.contactLastName=g.contactLastName;this.contactIdNumber=g.contactIdNumber;this.contactCountryCode=g.contactCountryCode;this.contactBirthdayYear=g.contactBirthdayYear;this.contactBirthdayMonth=g.contactBirthdayMonth;this.contactBirthdayDay=
g.contactBirthdayDay})};isAnyMainOwnerSetted=function(){var a=!1;$.each(e,function(){a=a||isMainOwner(this)});return a};changeMatchButtonsLabels=function(a,b){var c=!1,d;$.each(getMatchTicketIdsFromTicketId(a,b),function(a,e){d=getConfiguration(e,b);isMainOwner(d)&&(U||P)?(c=!0,isPOENotAllowed(d)?($("#set_beneficiary_"+e).hide(),$("#message_not_allow_update_"+e).removeClass("hidden")):changeButtonLabel(w,e)):(isPOENotAllowed(d)&&d.firstName&&d.lastName&&$("#printed_status_"+e+" .beneficiary_selector").attr("disabled",
"disabled"),d.firstName?changeButtonLabel(r,e):changeButtonLabel(z,e))});$.each(getCurrentMatchTicketIdsFromTicketId(a,b),function(a,b){c||!U&&!P?beneficiaries.isBeneficiarySelectorEnabled()&&$("#printed_status_"+b+" .beneficiary_selector").hasClass("beneficiary_selector_hidden")&&($("#printed_status_"+b+" .beneficiary_selector_label").addClass("beneficiary_selector_hidden"),$("#printed_status_"+b+" .beneficiary_selector").removeClass("beneficiary_selector_hidden"),$("#printed_status_"+b).css("order",
"-1")):(a=getConfiguration(b),(!isPOENotAllowed(a)||""===a.firstName&&""===a.lastName)&&changeButtonLabel(y,b),isPOENotAllowed(d)&&d.firstName&&d.lastName&&$("#printed_status_"+b+" .beneficiary_selector").attr("disabled","disabled"))})};changeButtonLabel=function(a,b){if(b=$("#set_beneficiary_"+b))b.find(".text").html(a),b.parent().removeClass("setAsMainTicket"),a===y&&b.parent().addClass("setAsMainTicket")};getCurrentMatchTicketIdsFromTicketId=function(a,b){var c=getConfiguration(a,b),d=[];$.each(h,
function(a,b){c.performanceId&&c.performanceId!==b.performanceId||b.isHistoryContact||b.isTicketHolderDeadlinePassed||d.push(b.ticketId||b.movementId)});return[].concat($jscomp.arrayFromIterable(new Set(d)))};getMatchTicketIdsFromTicketId=function(a,b){return(a=getConfiguration(a,b))?getMatchTicketIdsFromPerformanceId(a.performanceId):[]};getMatchTicketIdsFromPerformanceId=function(a){var b=[];$.each(e,function(c,d){a&&a!==d.performanceId||b.push(d.ticketId||d.movementId)});return[].concat($jscomp.arrayFromIterable(new Set(b)))};
getPerformancesIds=function(){var a=[];$.each(h,function(b,c){a.includes(c.performanceId)||a.push(c.performanceId)});return[].concat($jscomp.arrayFromIterable(new Set(a)))};isMainOwner=function(a){var b=(""===a.contactBirthdayYear||void 0===a.contactBirthdayYear)&&(""===a.contactBirthdayMonth||void 0===a.contactBirthdayMonth)&&(""===a.contactBirthdayDay||void 0===a.contactBirthdayDay)||(""===a.birthdayYear||void 0===a.birthdayYear)&&(""===a.birthdayMonth||void 0===a.birthdayMonth)&&(""===a.birthdayDay||
void 0===a.birthdayDay),c=a.contactBirthdayYear+"/"+a.contactBirthdayMonth+"/"+a.contactBirthdayDay;return a.firstName.toLowerCase()===a.contactFirstName.toLowerCase()&&a.lastName.toLowerCase()===a.contactLastName.toLowerCase()&&(b||datesEqual(c,getBirthday(a)))&&(null===a.contactIdNumber||""===a.contactIdNumber||null===a.idNumber||""===a.idNumber||a.contactIdNumber===a.idNumber)};getBirthday=function(a){return a.birthdayYear+"/"+a.birthdayMonth+"/"+a.birthdayDay};datesEqual=function(a,b){return(new Date(a)).getTime()===
(new Date(b)).getTime()};initConfigurationBirthday=function(a){a.birthdayYear=a.contactBirthdayYear;a.birthdayMonth=a.contactBirthdayMonth;a.birthdayDay=a.contactBirthdayDay};clearConfigurations=function(a){var b;(U||P)&&$.each(getCurrentMatchTicketIdsFromTicketId(a),function(c,d){b=getConfiguration(d);a==d||isPOENotAllowed(b)?b.firstName===contactName.firstName&&b.lastName===contactName.lastName&&resetConfiguration(b):resetConfiguration(b)})};resetTicketHolder=function(a){var b,c=getMatchMovementIdsFromTicketId(a);
hideForm();tools.dialog.showWaitingPopup("beneficiaryProcessingDialog",!0);$.ajax({url:contextPath+"/ajax/account/order/resetBeneficiaryOnMovement",type:"POST",cache:!1,data:{movementIds:c.toString()},success:function(c,d,e){var f=beneficiaries.isBeneficiarySelectorEnabled(),g;$('.beneficiary_selector option[value!="-1"]').remove();$.each(getCurrentMatchTicketIdsFromTicketId(a),function(a,c){b=getConfiguration(c);g=$("#printed_status_"+c+" .beneficiary_selector_label");isPOENotAllowed(b)||!U&&!P?
""===b.firstName&&""===b.lastName?changeButtonLabel(y,c):g.removeClass("beneficiary_selector_hidden"):(resetConfiguration(b),changeButtonLabel(y,c));f?($("#printed_status_"+c).css("order","initial"),$("#printed_status_"+c+" .beneficiary_selector").addClass("beneficiary_selector_hidden").prop("disabled",!1).val(-1),inCheckout&&P&&(g.removeClass().addClass("beneficiary_selector_label not_printable_status"),g.html(q))):isPOENotAllowed(b)||(g.html(""),g.removeClass().addClass("beneficiary_selector_label not_printable_status"))});
b=getConfiguration(a);beneficiaries.resetBeneficiariesByPerformance(b);resetContactConfiguration();tools.dialog.hideDialog("beneficiaryProcessingDialog")},error:function(){tools.dialog.hideDialog("beneficiaryProcessingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}})};getMatchMovementIdsFromTicketId=function(a){a=getCurrentMatchTicketIdsFromTicketId(a);var b=[];$.each(a,function(a,c){a=e[c];isPOENotAllowed(a)||b.push(a.movementId)});return b};disableAllNotEmptyFields=function(){A&&""!=$("#beneficiary_first_name").val()&&
$("#beneficiary_first_name").attr("disabled","disabled");C&&""!=$("#beneficiary_last_name").val()&&$("#beneficiary_last_name").attr("disabled","disabled");disableQuestionnaireFields()};disableQuestionnaireFields=function(){f.$currentContainer&&f.$currentContainer.length&&f.$currentContainer.find(".beneficiary_question").each(function(a){a=$(this);if(a.hasClass("is-defined"))if(a.find(".beneficiary_date").length){var b=a.find('select[id$="_day"]');var c=a.find('select[id$="_month"]');a=a.find('select[id$="_year"]');
1!==b.length||1!==c.length||1!==a.length||"0"===b.val()&&"0"===c.val()&&"0"===a.val()||(b.attr("disabled","disabled"),c.attr("disabled","disabled"),a.attr("disabled","disabled"))}else a.find(".beneficiary_single").length||a.find(".beneficiary_multi").length||a.find(".beneficiary_address_existing").length?(b=a.find("select"),1===b.length&&null!==b.val()&&0<b.val().length&&b.attr("disabled","disabled"),a.find(".manage_address_book").length&&(a=a.find(".manage_address_book"),1===b.length&&null!==b.val()&&
0<b.val().length?a.hide():a.addClass("show"))):a.find(".beneficiary_text").length||a.find(".beneficiary_phone").length?(b=a.find('input[type="text"]'),1===b.length&&0<b.val().length&&b.attr("disabled","disabled")):a.find(".beneficiary_email").length?(b=a.find('input[type="email"]'),1===b.length&&0<b.val().length&&b.attr("disabled","disabled")):a.find(".beneficiary_number").length?(b=a.find('input[type="number"]'),1===b.length&&0<b.val().length&&b.attr("disabled","disabled")):a.find(".beneficiary_boolean").length&&
(b=a.find('input[type="radio"]').not(":checked"),1===b.length&&0<b.val().length&&b.attr("disabled","disabled"))})};return{init:function(a,b,d){var g=$("#beneficiary_form .beneficiary_question > .beneficiary_date"),h=this;r=d.newButtonBeneficiaryLabel;t=d.newCannotModifyBeneficiaryLabel;x=d.newIntroBeneficiaryLabel;q=d.newNoBeneficiaryLabel;u=d.nonPrintableGuestDataActivated;G=d.newIdQuestionCode;L=d.newBirthdayQuestionCode;K=d.newNationalityQuestionCode;H=d.newBirthRegionCode;M=d.newBirthPlaceCode;
Q=d.newTitleQuestionCode;S=d.newResidenceCountryQuestionCode;V=d.newIsCityProvinceMandatoryForItaly;c=d.newStoreBeneficiaryDataInsteadOfImmediateSubmit;F=d.isGuestSessionOrNull;B=d.newAddRFIDCheckboxLabel;A=d.isFirstNameMandatoryOrNot;C=d.isLastNameMandatoryOrNot;I=d.isMembershipContingentsParam;O=d.membershipContingentsMovMandatoryListParam;T=d.perfByMovementParam;Z=d.siteByMovParam;k=d.peselCheckForPolandParam;m=d.allowedFieldCharactersParam;p=d.isBarCodeSupportedParam;w=d.newResetMainTicketLabel;
z=d.newSetBeneficiaryLabel;y=d.newSetAsMainTicketLabel;U=d.newForcePurchaserToOneTicketPerMatch;P=d.newForcePurchaserToOneTicketPerMatchDuringSales&&inCheckout;Y=d.isNameShouldReformat;aa=d.isForbidSwitchMTicketToPrintAtHome;W=d.reprintStatus;g.each(function(a){a=$(this).find('select[id$="_day"]');var b=$(this).find('select[id$="_month"]'),c=$(this).find('select[id$="_year"]');a.length&&b.length&&c.length&&(secutix.date.combos.populateCombosDatepicker(a.attr("id"),b.attr("id"),c.attr("id"),datePickerConfig.monthNames),
secutix.date.combos.dynamizeDateCombos(a.attr("id"),b.attr("id"),c.attr("id")))});f=new account.beneficiary.Questionnaire(a,b);a=f.getAllAnswerByKey();fillConfigurationWithQuestionnaire(e,a);$('[id^="print_"], [id^="set_beneficiary_"], [id^="transfer_"]').on("click",function(a,b){a=$(this);var c=a.attr("id").replace("print_","").replace("set_beneficiary_","").replace("transfer_",""),d=e[c],f={},g=a.parent().hasClass("disabled");if((!inCheckout||P)&&a.find(".text").html()===w)return tools.dialog.showDialog("warning_reset_main_ticket",
!0),$("#warning_reset_main_ticket .button a").attr("onclick","tools.dialog.hideDialog('warning_reset_main_ticket'); account.beneficiary.form.resetTicketHolder("+c+");"),!1;if(g)return!1;f.isSubmitBeneficiary=b;if(d&&(b="true"===d.beneficiariesAlwaysModifiable,0===a.attr("id").lastIndexOf("transfer_",0)&&(b=!0,f.isTransfer=!0),!d.isPrinted||!d.firstName&&!d.isTicketHolderDeadlinePassed||a.is('[id^="transfer_"]')))return h.show(a,d.ticketId,d.movementId,d.support,b,void 0,f),!1});$("#beneficiary_form form").submit(function(a){return!1});
$('[id^="toggle_questionnaire_btn_"]').on("click",function(){var a=this.id.replace("toggle_questionnaire_btn_","");if(isNaN(parseInt(a,10)))return!1;var b=$(this).parent();b.hasClass("plus")?(b.switchClass("plus","less",0),$(b).find(".plus").addClass("hidden"),$(b).find(".less").removeClass("hidden")):(b.switchClass("less","plus",0),$(b).find(".less").addClass("hidden"),$(b).find(".plus").removeClass("hidden"));$("#questionnaire_table_"+a).slideToggle();return!1});D=1<$(".ticket_formats_container .formats").length;
P?($.each(e,function(a,b){b.isHistoryContact||changeMatchButtonsLabels(b.ticketId||b.movementId,b.support)}),v=!0):U&&$.each(e,function(a,b){changeMatchButtonsLabels(b.ticketId||b.movementId,b.support);v=!0})},populateQuestionnaireAnswers:function(a,b,c,d,e){f=new account.beneficiary.Questionnaire(a,b);D=1<$(".ticket_formats_container .formats").length;f.initNewQuestionnaire(e,d,c,D,!0,null,!0)},show:function(d,e,g,h,k,m,p){var A=null,x=null,C=null,q=null,B=$("#beneficiary_first_name"),r=$("#beneficiary_last_name"),
t=$("#beneficiary_form"),y=e||g,J=getConfiguration(y,h),w=getOriginalConfiguration(y,h),E=J.contactReference,la=J.firstName,ha=J.lastName;var W=J.idNumber;var Y=J.birthPlace;var sa=J.birthRegion;var ka=J.countryCode;var ja=J.title;var ca=J.residenceCountry;var ea=J.containsRFIDSupport,aa=J.cardTypes,ma={},O=J.isParking;var fa=J.isFlatRate;var Ia=p&&!0===p.isSubmitBeneficiary,Ja=(J.shipmentMode||[]).typeRFID,Ka=J.isB2BOrB2B2C,La=J.hasAttachment,R=J.isAllowPOEUpdate;if(U||P)$(d).parent().hasClass("setAsMainTicket")?
(initConfigurationBirthday(J),clearConfigurations(e),la=J.contactFirstName,ha=J.contactLastName,W=J.contactIdNumber,J.idNumber=J.contactIdNumber,ka=J.contactCountryCode,ja=J.contactTitle,ca=J.contactResidenceCountry,Y=J.contactBirthPlace,sa=J.contactBirthRegion,J.readOnlyBeneficiary=!0,v=J.isHistoryContact=!0):J.readOnlyBeneficiary=w.readOnlyBeneficiary;if($(d).hasClass("open")&&!da)return!1;$("#input_beneficiary_ticketId").val(y);$("#input_beneficiary_support").val(h);$("#input_beneficiary_movement_id").val(J.movementId);
$("#input_beneficiary_file_id").val(J.fileId);$("#input_beneficiary_hospitalityProductType").val(J.isHospitalityProductType);f.initNewQuestionnaire(J.questionnaireId,e,J.movementId,D,m,p,!1);b=a;a=d;$("#beneficiary_mandatory").hide();$("#beneficiary_generic_mandatory").hide();$("#beneficiary_optional").hide();$("#beneficiary_already_set").hide();$("#message_not_allow_update").hide();$("#input_hospitality_questionnaire").hide();$("#first_beneficiary_not_changeable").hide();$("#group_contact_mandatory").hide();
$("#group_contact_generic_mandatory").hide();$("#group_contact_optional").hide();$("#group_contact_already_set").hide();$("#beneficiary_form .message.error.generic_mandatory_msg").hide();$("#beneficiary_form .message.error.membership_number_msg").hide();$("#beneficiary_form .message.error.rfid_wrong_card").hide();$("#beneficiary_form .message.error.rfid_wrong_card_from_server").hide();$("#beneficiary_form .message.error.rfid_wrong_card_or_postcode_from_server").hide();$("#beneficiary_form .message.error.rfid_already_used_card_from_server").hide();
$("#beneficiary_form .message.error.rfid_server_error").hide();$("#beneficiary_form .message.error.rfid_checkbox_not_checked").hide();$("#beneficiary_form .message.error.invalid_pesel").hide();$("#beneficiary_form .message.error.rfid_same_date_ticket_exists_on_card_from_server").hide();$("#beneficiary_form .message.error.rfid_not_accept_swisspass_condition").hide();$("#beneficiary_form .message.error.not_allowed_character").hide();$("#beneficiary_form .message.error.duplicated_main_ticket").hide();
resetQuestionnaireFieldsAttr();$("#mandatory_info_description").hide();$("#rfidClaimerAccepted").prop("checked",!1);la&&ha?(r.val(ha),B.val(la)):v||Ka||F?(r.val(""),B.val("")):(r.val(contactName.lastName),B.val(contactName.firstName),f.fillEmails());if(la&&ha&&(!u&&!k&&!m||J.readOnlyBeneficiary)){J.readOnlyBeneficiary&&!P?$("#first_beneficiary_not_changeable").show():fa?$("#group_contact_already_set").show():$("#beneficiary_already_set").show();fa=$(d).parents(".formats_container").find("select.beneficiary_selector");
if(0===fa.length||-1===Number(fa.val())||fa.is(":disabled")||(U||P)&&$(d).parent().hasClass("setAsMainTicket"))r.attr("disabled","disabled"),B.attr("disabled","disabled");inCheckout&&!P||disableQuestionnaireFields()}else isTicketHolderNameMandatory(J)?fa?$("#group_contact_mandatory").show():$("#beneficiary_mandatory").show():k?($("#beneficiary_generic_mandatory").hide(),$("#input_hospitality_questionnaire").show()):f.hasMandatoryFields?fa?$("#group_contact_generic_mandatory").show():$("#beneficiary_generic_mandatory").show():
fa?$("#group_contact_optional").show():$("#beneficiary_optional").show();G&&(fa=getQuestionBaseName(G))&&($("input[name='"+fa+".answer']").val(W?W:""),J.readOnlyBeneficiary&&W&&(!inCheckout||w.idNumber||P)?$("input[name='"+fa+".answer']").attr("disabled","disabled"):$("input[name='"+fa+".answer']").prop("disabled",!1));K&&(W=getQuestionBaseName(K),fa="select[name='"+W+".answer']",W&&($(fa).val(ka?ka:""),$(fa).change(function(){account.beneficiary.form.nationalityChanged(this)}),J.readOnlyBeneficiary&&
ka&&(!inCheckout||w.countryCode||P)?$(fa).attr("disabled","disabled"):$(fa).prop("disabled",!1),account.beneficiary.form.nationalityChanged(fa)));if(Q&&(W=getQuestionBaseName(Q),ka="select[name='"+W+".answer']",W)){W=!1;for(fa=0;fa<$(ka+" option").length;fa++)if(ja&&""!=$(ka+" option")[fa].value&&ja.toUpperCase()==$(ka+" option")[fa].value.toUpperCase()){W=$(ka+" option")[fa].selected=!0;J.readOnlyBeneficiary&&(!inCheckout||w.title||P)?$(ka).attr("disabled","disabled"):$(ka).prop("disabled",!1);break}else $(ka).val("");
W||$(ka).prop("disabled",!1)}S&&(W=!1,ja=getQuestionBaseName(S),ka="select[name='"+ja+".answer']",ja&&ca&&0<$(ka+" option[value="+ca+"]").length?($(ka).val(ca),W=!0,J.readOnlyBeneficiary&&(!inCheckout||w.residenceCountry||P)?$(ka).attr("disabled","disabled"):$(ka).prop("disabled",!1)):$(ka).val(""),W||$(ka).prop("disabled",!1));L&&(ca=getQuestionBaseName(L))&&(parseInt(J.birthdayYear)&&parseInt(J.birthdayMonth)&&parseInt(J.birthdayDay)?($("select[name='"+ca+".year']").val(parseInt(J.birthdayYear)),
$("select[name='"+ca+".month']").val(parseInt(J.birthdayMonth)),$("select[name='"+ca+".day']").val(parseInt(J.birthdayDay))):($("select[name='"+ca+".year']").val(0),$("select[name='"+ca+".month']").val(0),$("select[name='"+ca+".day']").val(0)),J.readOnlyBeneficiary&&J.birthdayYear&&J.birthdayMonth&&J.birthdayDay&&(!inCheckout||w.birthdayYear||P)?($("select[name='"+ca+".year']").attr("disabled","disabled"),$("select[name='"+ca+".month']").attr("disabled","disabled"),$("select[name='"+ca+".day']").attr("disabled",
"disabled")):u&&($("select[name='"+ca+".year']").prop("disabled",!1),$("select[name='"+ca+".month']").prop("disabled",!1),$("select[name='"+ca+".day']").prop("disabled",!1)));M&&(ca=getQuestionBaseName(M))&&($("input[name='"+ca+".answer']").val(Y?Y:""),J.readOnlyBeneficiary&&Y&&(!inCheckout||w.birthPlace||P)?$("input[name='"+ca+".answer']").attr("disabled","disabled"):$("input[name='"+ca+".answer']").prop("disabled",!1));H&&(Y=getQuestionBaseName(H))&&($("input[name='"+Y+".answer']").val(sa?sa:""),
J.readOnlyBeneficiary&&sa&&(!inCheckout||w.birthRegion||P)?$("input[name='"+Y+".answer']").attr("disabled","disabled"):$("input[name='"+Y+".answer']").prop("disabled",!1));I&&M&&handleMembershipContingents(g);H&&M&&(g=Z[g],handleCityProvinceMandatoryForItaly(H,M,V,g,I));O?($("#beneficiary_form #field_first_name label").html($("#number_plate_label").html()),$("#beneficiary_form #field_last_name label").html($("#last_name_if_plate_label").html()),!inCheckout&&la||B.val(""),ha?r.val(ha):v||r.val(contactName.firstName+
" "+contactName.lastName)):$("#beneficiary_form #field_first_name label").html($("#first_name_label").html());handledBeneficiaryMandatory(J,t);(isTicketHolderNameMandatory(J)||k||f.hasMandatoryFields)&&$("#mandatory_info_description").show();account.beneficiary.validation.setNeededCardTypesInstance($.extend(!0,[],aa));$("#rfid_checkbox_container").hide();$("#card_number_available").hide();$("#field_rfid_checkbox").prop("checked",!1);$("#rfid_card_number").val("");$("#input_rfid_card_zipcode").val("");
$("#beneficiary_form .content").removeClass("rfid");Ja&&ea&&("RFID"!==h&&"DEMAT_BADGE"!==h?($("#rfid_checkbox_container").show(),$("#beneficiary_form label.for-eticket").show(),$("#beneficiary_form label.for-rfid").hide()):($("#beneficiary_form label.for-eticket").hide(),$("#beneficiary_form label.for-rfid").show(),$("#beneficiary_form .content").addClass("rfid")));if("RFID"!==h&&"DEMAT_BADGE"!==h)$(".rfid_card_desc").hide(),$("#rfid_card_number").parent().hide(),$("#beneficiary_form .message.info").show(),
$("#rfid_card_info").hide(),$("#existing_rfid_card").hide(),$("#rfid_disclaimer_agreement").hide();else{$("#rfid_disclaimer_agreement").show();$("#rfid_card_info").show();$("#existing_rfid_card").show();$(".rfid_card_desc").show();$("#rfid_card_number").parent().show();$("#beneficiary_form .message.info").hide();for(k=0;k<aa.length;k++){if(aa[k].cardNumber||aa[k].cardNumberProposal)A=aa[k].cardNumber,C=aa[k].beneficiary,x=aa[k].cardNumberProposal;ma[aa[k].id]=aa[k]}x&&($("#rfid_card_number").val(x),
B.val(C.firstName),r.val(C.lastName));A&&($("#card_number_available").show(),$("#card_number_fill").unbind("click"),$("#card_number_fill").click(function(){$("#rfid_card_number").val(A);B.val(C.firstName);r.val(C.lastName);account.beneficiary.validation.checkInput(null,$("#rfid_card_number")[0]);return!1}));displayRFIDCardInfos(ma,J.multipleCardTypesUrl,E)}r.removeClass("error");r.parent().removeClass("error");B.removeClass("error");B.parent().removeClass("error");$("#rfid_card_number").removeClass("wrong").removeClass("valid");
x&&account.beneficiary.validation.checkInput(null,$("#rfid_card_number")[0]);"RFID"===h?$("#beneficiary_form .button.print a").html($("#beneficiaryPopupContinueRFIDLabel").val()):"DEMAT_BADGE"===h?$("#beneficiary_form .button.print a").html($("#beneficiaryPopupContinueBadgeLabel").val()):$("#beneficiary_form .button.print a").html($("#beneficiaryPopupContinuePrintLabel").val());q=function(){var a=getConfiguration(y,"ETICKET"),b=getConfiguration(y,"MOBILE"),c=p&&!0===p;tools.removeSelectWrapper();
h?"RFID"!==h&&"DEMAT_BADGE"!==h?(submitBeneficiaryAndPrint(e,h,m,c),a&&(a.isPrinted=!0),b&&(b.isPrinted=!0)):($("#beneficiary_form .message.error.rfid_wrong_card").hide(),$("#beneficiary_form .message.error.rfid_wrong_card_from_server").hide(),$("#beneficiary_form .message.error.rfid_wrong_card_or_postcode_from_server").hide(),$("#beneficiary_form .message.error.rfid_server_error").hide(),$("#beneficiary_form .message.error.rfid_already_used_card_from_server").hide(),$("#beneficiary_form .message.error.rfid_same_date_ticket_exists_on_card_from_server").hide(),
submitBeneficiaryAndLoadOntoCard(e,h,aa)):submitBeneficiary(y,!1);(U||P)&&changeMatchButtonsLabels(y,h);return!1};$("#beneficiary_form .button.print a").unbind().on("click",q);$("#beneficiary_form input").unbind().keypress(function(a){if(13===a.which)return q()});$("#beneficiary_form input").unbind().focus(function(){$(this).removeClass("error")});$("#beneficiary_form .close_expand_panel").unbind().click(function(){hideForm();P&&($("#printed_status_"+e+" .beneficiary_selector").val(-1),$("#printed_status_"+
e+" .beneficiary_selector").trigger("change"),resetConfiguration(J),changeMatchButtonsLabels(e));return!1});(!0===Ia&&J.readOnlyBeneficiary&&c&&N||l)&&submitBeneficiary(y,!0);if(!J.isPrinted&&la&&ha&&J.isTicketHolderDeadlinePassed)return q(),!1;t.hasClass("open")&&da?hideFormAndOpenNextWithoutAnimation():hideFormAndOpenNext();$("#beneficiary_first_name").on("focusout",function(){$(this).val(buildFirstNameAsFormatted($(this).val()))});$("#beneficiary_last_name").on("focusout",function(){$(this).val(buildLastNameAsFormatted($(this).val()))});
La&&!R?!la||!ha||la===J.contactFirstName&&ha===J.contactLastName&&$(d).parent().hasClass("setAsMainTicket")||$("#set_beneficiary_"+e).find(".text").html()==z||(disableAllNotEmptyFields(),$("#message_not_allow_update").show(),fa=$(d).parents(".formats_container").find("select.beneficiary_selector"),fa.attr("disabled","disabled")):$("#message_not_allow_update").hide();return!1},showAnswersFromBeneficiarySelector:function(a,b,c){a=$("#questionnaire_answers_"+b);a.length&&a.remove();var d=[];$.each(e,
function(){this.ticketId!==b.toString()&&this.movementId!==c||!this.allowUpdateTicketInfo||d.push(this)});if(0<d.length){a=d[0];var f=$('[id^="set_beneficiary_'+a.movementId+'"]:first');0===f.length&&(f=$('[id^="set_beneficiary_'+a.ticketId+'"]:first'));0<f.length&&(da=!0,this.show(f,a.ticketId,a.movementId,a.support,"true"===a.beneficiariesAlwaysModifiable,!1),da=!1,showModifyingStatus(a.ticketId,a.movementId))}},showAnswers:function(a,b,c,d){var e=$("#questionnaire_answers_"+b);var g=$(a).parents(".ticket_additional_container");
e.length&&e.remove();a=getAllowUpdateTicketInfoConfigurations(b,c);if(0<a.length){var h=a[0];if("-1"===h.questionnaireId&&(a=$('[id^="print_'+h.movementId+'"]:first'),0===a.length&&(a=$('[id^="print_'+h.ticketId+'"]:first')),0<a.length))return this.show(a,h.ticketId,h.movementId,h.support,"true"===h.beneficiariesAlwaysModifiable,!0),showModifyingStatus(h.ticketId,h.movementId),!1}h=getConfiguration(b,"ETICKET")||getConfiguration(b,"MOBILE")||getConfiguration(b,null);tools.dialog.showWaitingPopup("beneficiaryProcessingDialog",
!0);$.ajax({type:"GET",url:contextPath+f.GET_QUESTIONNAIRE_ANSWERS_URL,cache:!1,data:{ticketId:b,movementId:d?d:c,allowUpdateTicketInfo:h?h.allowUpdateTicketInfo:!1},success:function(a){$(".questionnaire_answers",g).remove();g.append(a);h&&h.isPrinted&&("ETICKET"===h.support||"MOBILE"===h.support)||$("#modify_"+b,g).remove();slideToAndOpenAnswers($("#questionnaire_answers_"+b));tools.dialog.hideDialog("beneficiaryProcessingDialog")},error:function(){tools.dialog.hideDialog("beneficiaryProcessingDialog");
tools.dialog.showDialog("ajaxErrorDialog",!0)}})},modifyTicketHolders:function(a){a=getAllowUpdateTicketInfoConfigurations(a);if(0<a.length){a=a[0];var b=$('[id^="print_'+a.movementId+'"]:first');0===b.length&&(b=$('[id^="print_'+a.ticketId+'"]:first'));0<b.length&&(this.show(b,a.ticketId,a.movementId,a.support,"true"===a.beneficiariesAlwaysModifiable,!0),showModifyingStatus(a.ticketId,a.movementId))}},setPrintedStatus:function(a,b,c,d,e,f,g,h,k){var l="";var m=$("#print_"+a+"_MOBILE, #print_"+a+
"_ETICKET, #print_"+a);var p=m.parent().parent().parent().parent().find(".printed_status .beneficiary_selector_label.not_printed_status, .printed_status .beneficiary_selector_label.already_printed_status");var A=m.parent().parent().parent().parent().find("select.beneficiary_selector");l=f||d&&e;var x=p.hasClass("not_printed_status");h=h&&x;$(".current_edit_beneficiary",m.closest(".ticket_additional_container")).remove();k||A.attr("disabled","disabled");if(x||h)""!==b&&""!==c?(l=h?l?notDownloadedBeneficiary:
notPrintedBeneficiary:l?alreadyDownloadedBeneficiary:alreadyPrintedBeneficiary,p.text(l.replace("{0}",b+" "+c))):f||d&&e?p.html(alreadyDownloaded):p.html(alreadyPrinted),g&&g.length&&(void 0!==p.attr("onclick")&&null!=p.attr("onclick")||p.unbind().click(function(){k?account.beneficiary.form.showAnswers(this,a,a):account.beneficiary.form.showAnswers(this,a);return!1}),p.addClass("with_answers"),k&&(p.html(p.html()+" "+editLabel),p.attr("tabindex","0"),p.attr("role","button"),p.attr("aria-label",[p.text(),
openBtnLabel,beneficiaryFormLabel].join(" ")))),h||(p.removeClass("not_printed_status").addClass("already_printed_status"),$("#printed_tickets, .printed_ticket").html(Number($("#printed_tickets").html())+1),p=parseInt($("#printed_tickets").html(),10)/parseInt($(".total_ticket",".printed_ticket_status").html(),10),$(".mask.full, .fill",".printed_ticket_status").css("transform","rotate("+180*p+"deg)"),$(".fill.fix",".printed_ticket_status").css("transform","rotate("+360*p+"deg)"),$("#beneficiary_"+
a).html("")),A.is(":visible")&&!h&&($(".beneficiary_selector_printed_"+a).removeClass("beneficiary_selector_hidden"),$(".beneficiary_selector_not_printed_"+a).addClass("beneficiary_selector_hidden")),x&&h&&m.unbind().click(function(){account.beneficiary.form.setPrintedStatus(a,b,c,d,e,f,g,!1,k)})},register:function(a){var b=a.ticketId||a.movementId;a.firstName&&(a.firstName=a.firstName.replace(/\\/g,""));a.lastName&&(a.lastName=a.lastName.replace(/\\/g,""));a.contactFirstName=buildFirstNameAsFormatted(a.contactFirstName.replace(/\\/g,
""));a.contactLastName=buildLastNameAsFormatted(a.contactLastName.replace(/\\/g,""));a.contactTitle=void 0===a.contactTitle?null:a.contactTitle;a.contactResidenceCountry=void 0===a.contactResidenceCountry?null:a.contactResidenceCountry;a.contactBirthPlace=void 0===a.contactBirthPlace?null:a.contactBirthPlace;a.contactBirthRegion=void 0===a.contactBirthRegion?null:a.contactBirthRegion;a.title=void 0===a.title?null:a.title;a.residenceCountry=void 0===a.residenceCountry?null:a.residenceCountry;a.birthPlace=
void 0===a.birthPlace?null:a.birthPlace;a.birthRegion=void 0===a.birthRegion?null:a.birthRegion;a.id=b;a.support&&(b+="_"+a.support);e[b]=a;h[b]=$.extend({},a);a.readOnlyBeneficiary&&(v=!0);g||(g=$.extend({},a))},nationalityChanged:function(a){k&&pesel.needsPeselValidation($(a).val())?($(".idNumberLabel").hide(),$(".idNumberLabelPl").show(),E=!0):($(".idNumberLabelPl").hide(),$(".idNumberLabel").show(),E=!1)},setSuccessfulBeneficiarySetCallback:function(a){N=a},getStoredBeneficiaryData:function(){return d},
updateContactInfo:function(a){isMainOwner(a)&&$.each(account.beneficiary.form.getMovementDefinitions(),function(){this.contactTitle=a.title;this.contactResidenceCountry=a.residenceCountry;this.contactBirthdayDay="0"===a.birthdayDay?"":a.birthdayDay;this.contactBirthdayMonth="0"===a.birthdayMonth?"":a.birthdayMonth;this.contactBirthdayYear="0"===a.birthdayYear?"":a.birthdayYear;this.contactBirthPlace=a.birthPlace;this.contactBirthRegion=a.birthRegion})},getMovementDefinitions:function(){return e},
updateInvalidMembershipNumber:function(a,b){R=R.concat(a);l=b},setBeneficiary:function(a,b,c,d){var e=getConfiguration(b||a);var g=getConfiguration(b,"ETICKET");var h=getConfiguration(b,"MOBILE");c?(c.ticketId=void 0,$.extend(e,c),$.extend(g,c),$.extend(h,c),account.beneficiary.form.showAnswersFromBeneficiarySelector(this,b,a)):(e&&resetConfiguration(e),g&&resetConfiguration(g),h&&resetConfiguration(h),f.setQuestionnaire(a,b,[]),!e&&0<$(d.target).parents(".beneficiary_expanded").length&&($("#beneficiary_first_name").val(""),
$("#beneficiary_last_name").val(""),$("#beneficiary_last_name").prop("disabled",!1),$("#beneficiary_first_name").prop("disabled",!1)),$("#set_beneficiary_"+b||a).trigger("click"))},getQuestionnaire:function(a,b){return f.getQuestionnaire(a,b)},setQuestionnaire:function(a,b,c){return c.setQuestionnaire(a,b,c)},updateBeneficiary:function(a,b){var c=f.getQuestionnaire(a,null);f.setQuestionnaire(a,null,c);a=getConfiguration(a,void 0);b=getConfiguration(b,void 0);b=$.extend({},b,a);$.extend(a,b)},resetTicketHolder:function(a){resetTicketHolder(a)},
isLabelInHistory:function(a,b){var c;for(c in e){var d=e[c];var f=d.firstName+" "+d.lastName;if(d.isHistoryContact&&d.performanceId==b&&f===a)return!0}return!1},updateDisplayDatas:function(){$.each(e,function(a,b){b.ticketId&&b.performanceId&&updateDisplay(b)})}}});
tools.module("account.beneficiary.general",{generateTicketAndShow:function(a,b,c,d,f,e,g,h,l,k){var m="",p=contextPath+"/ajax/account/order/generateTicket";tools.isStorageAvailable()&&(m=tools.storage.getItem("beneficiary"+a));!m&&k&&setTimeout(function(){throw"Expected data in sessionStorage, found none";},10);null===m||!m.length||l&&!h?m={id:a,movementId:b?parseInt(b,10):"",fileId:c?parseInt(c,10):"",firstName:d,lastName:f,support:g}:p=contextPath+"/ajax/account/order/generateTicketWithAnswers";
h&&(p+="?isUpdateBeneficiary="+h);jQuery.ajax({url:p,type:"POST",cache:!1,data:m,success:function(b){var c=window.location.href;tools.dialog.hideDialog("ticketProcessingDialog");if("SESSION_EXPIRED"===b.status)return tools.dialog.showDialog("sessionExpiredWhileGeneratingTicketDialog",!0,!0),!1;if("OK"!==b.status)return tools.dialog.showDialog("ajaxErrorDialog",!0),!1;window.location.replace(contextPath+"/account/order/ticket/"+e+"?id="+b.ticketId+"&support="+g+(h?"&isUpdateBeneficiary=true":""));
account.beneficiary.general.checkDownloaded(c);b.ticketId!==a&&window.opener.location.reload(!0)},error:function(){tools.dialog.hideDialog("ticketProcessingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}})},switchToTnMCTickets:function(){window.location.href="http://tnmc.secutix.com/switchToTickets"},checkDownloaded:function(a){setTimeout(function(){a===window.location.href&&tools.dialog.showDialog("no_redirection_dialog",!0)},100)}});
tools.module("account.beneficiary.validation",function(){var a=[],b=!1,c=function(){var b=null,c;for(c=0;c<a.length;c++)$("#field_rfid_card_type").val()===a[c].id&&(b={format:a[c].codeCheck,autocomplete:a[c].enableAutoComplete,autoUppercase:a[c].enableAutoUppercase});return b},d=function(a,b){var c,e=0,f=/[a-zA-Z0-9]/,g=/[0-9]/,h=/[a-fA-F0-9]/;for(c=0;c<a.length;c++){var k=b.charAt(e);var l=a.charAt(c);if("x"===k){if(!f.test(l))return!1;e++}else if("h"===k){if(!h.test(l))return!1;e++}else if("n"===
k){if(!g.test(l))return!1;e++}else if("["===k){e++;for(k=e;k<b.length&&"]"!==b.charAt(k);k++);if(k===b.length-1&&"]"!==b.charAt(k))return!1;l=c+(k-e);d(a.substring(c,l),b.substring(e,k))?c=l-1:c--;e=k+1}else if("]"!==k&&k===l)e++;else return!1}return c===a.length&&e===b.length},f=function(a,b){return"undefined"!==typeof a.keyCode&&0<a.keyCode&&-1!==String.fromCharCode(a.keyCode).search(b)||"undefined"!==typeof a.charCode&&0<a.charCode&&-1!==String.fromCharCode(a.charCode).search(b)||"undefined"!==
typeof a.charCode&&a.charCode===a.keyCode&&"undefined"!==typeof a.keyCode&&-1!==a.keyCode.toString().search(/^(8|9|13)$/)?!0:!1},e=function(a){if(a.selectionStart)return a.selectionStart;if(document.selection){a.focus();var b=document.selection.createRange();b.moveStart("character",-a.value.length);return b.text.length}return a.value.length},g=function(a,b){a.addClass("error");a.one("focus click",function(){a.removeClass("error");b&&$.each(b,function(a,b){b.removeClass("error")})})},h=function(a,
b,c,d){var e=a.find(".beneficiary_address_country"),f=a.find(".beneficiary_address_zip_city");a=function(){g(f)};c=validation.checkZipCodeValues(b,c,function(){g(e)},a,a);d.length||(g(f),c=!1);b.length||(g(e),c=!1);return c},l=function(a,b,c,d,e){""!==a&&validation.validateField($(b),[{rule:c}],null,!1,!1)||(a&&d&&!d.test(a)?e.isAllowedCharacterError=!0:e.mandatory=!0,g($(b).parent()))};equalsBeneficiary=function(a,b){return equalsStringValues(a.firstName,b.firstName)&&equalsStringValues(a.lastName,
b.lastName)&&equalsOrEmptyStringValues(a.idNumber,b.idNumber)&&equalsOrEmptyStringValues(a.countryCode,b.countryCode)&&equalsOrEmptyStringValues(a.birthPlace,b.birthPlace)&&equalsOrEmptyStringValues(a.birthRegion,b.birthRegion)&&equalsOrEmptyBirthdayField(a.birthdayYear,b.birthdayYear)&&equalsOrEmptyBirthdayField(a.birthdayMonth,b.birthdayMonth)&&equalsOrEmptyBirthdayField(a.birthdayDay,b.birthdayDay)&&equalsOrEmptyStringValues(a.isHistoryContact,b.isHistoryContact)};equalsOrEmptyStringValues=function(a,
b){return!a||!b||equalsStringValues(a,b)};equalsStringValues=function(a,b){return a==b||"string"===typeof a&&"string"===typeof b&&a.toLowerCase()===b.toLowerCase()};equalsOrEmptyBirthdayField=function(a,b){var c=!a||!b;c||(a=parseInt(a,10),b=parseInt(b,10),c=0===a||0===b||a===b);return c};isNotUniqueBeneficiary=function(a,b){var c=Object.keys(b),d=!1,e;for(e=0;e<c.length;e++){var f=b[c[e]];if(a.performanceId===f.performanceId&&a.ticketId!==f.ticketId&&equalsBeneficiary(a,f)){d=!0;break}}return d};
return{setNeededCardTypesInstance:function(b){a=b},isCorrectFormat:function(a,b,c){var e,f=a.replace(/[\s|\-|/]/g,""),g;var h=c?-1!==b.indexOf("x")?/[^a-zA-Z0-9]/:-1!==b.indexOf("h")?/[^g-zG-Z]/:/[^0-9]/:/[^a-zA-Z0-9\-.]/;var k=c?b.replace(/[\s|\-|/]/g,""):b;h=!c||!h.test(f);var l=[];for(g=0;g<b.length;g++)if("["===b.charAt(g))for(e=g+1;e<b.length;e++)if("]"===b.charAt(e)){l.push({start:g,stop:e,length:e-g+1,cleanedLength:b.substring(g+1,e).replace(/[\s|\-|/]/g,"").length});g+=e-g;break}if(0<l.length)for(e=
c?b.replace(/[\s|\-|/]/g,"").length:b.length,e-=2*l.length,k=e===f.length,g=0;!k&&g<l.length;g++)e-=l[g].cleanedLength,k=e===f.length;else k=k.length===f.length;return(c||d(a,b))&&h&&k},formatCardNumber:function(a,b){var d=c(),e="",f=0,g;if(null!==d){var h=a.value.replace(/[\s|\-|/]/g,"");var k=d.format;var l=d.autocomplete;d=d.autoUppercase;if(l)for(g=0;g<k.length&&f!==h.length;g++)"x"===k.charAt(g)||"h"===k.charAt(g)||"n"===k.charAt(g)?(e+=h.charAt(f),f++):"["!==k.charAt(g)&&"]"!==k.charAt(g)&&
(e+=k.charAt(g));account.beneficiary.validation.isCorrectFormat(a.value,k,l)?$(a).addClass("valid"):$(a).removeClass("valid");if(l){if(f<h.length)for(g=f;g<h.length;g++)e+=h.charAt(g);a.value=e;b&&(" "!=e.charAt(b)&&"-"!=e.charAt(b)&&"/"!=e.charAt(b)||b++,a.setSelectionRange?a.setSelectionRange(b,b):a.createTextRange&&(k=a.createTextRange(),k.collapse(!0),k.moveEnd("character",b),k.moveStart("character",b),k.select()))}d&&(a.value=a.value.toUpperCase())}},checkKey:function(a,d){var e=a?a:window.event,
g=c();if(null===g)return!0;var h=g.format;g=g.autocomplete?-1!==h.indexOf("h")?/[^a-fA-F0-9]/:-1!==h.indexOf("x")?/[a-zA-Z0-9]/:/[0-9]/:/[a-zA-Z0-9\-.]/;a=a?a:window.event;h=!1;!a.ctrlKey||99!==a.charCode&&118!==a.charCode?!b||67!==a.keyCode&&86!==a.keyCode||(h=!0):h=!0;b=17===a.keyCode;a=h||f(e,g);!a&&d&&48<e.keyCode&&(a=f({keyCode:e.keyCode-48},g));d=9===e.keyCode||8===e.keyCode||35===e.keyCode||36===e.keyCode||37===e.keyCode||39===e.keyCode||46===e.keyCode||12===e.keyCode;return a||d},checkInput:function(a,
b){a=!a||account.beneficiary.validation.checkKey(a,!0);if(a){var c=e(b);c!==b.value.length?account.beneficiary.validation.formatCardNumber(b,e(b)):account.beneficiary.validation.formatCardNumber(b)}return a},addMandatory2Label:function(a,b,c){a=$(a+" "+b+" "+(c?"label":".label"));0===a.find(".mandatory").length&&a.append('<span class="mandatory">*</span>')},cleanContainerFromError:function(a){a.length&&a.removeClass("error")},checkBeneficiaryForm:function(a,b,c,d,e,f,w,y,z,x,A,C,u){var k={},m,p=a.movementId,
q=a.ticketId,B=a.isHistoryContact,r=a.performanceId;a=a.isParking;var t=!1,K,H=$.trim($(b).val()),M=$.trim($(c).val()),Q=0<$(b).siblings('label[for="beneficiary_first_name"]').find(".mandatory").length,S=0<$(c).siblings('label[for="beneficiary_last_name"]').find(".mandatory").length,V="",N="",I="",O="",R="",X="",T=new RegExp(x);validation.rules.firstname.regExp=T;validation.rules.lastname.regExp=T;if(Q||S||(""===H&&""!==M||""!==H&&""!==M||""!==H&&""===M)&&!a)l(H,b,validation.rules.firstname,T,k),
l(M,c,validation.rules.lastname,T,k);d.$currentContainer&&d.$currentContainer.length&&d.$currentContainer.find(".beneficiary_question").each(function(a){a=$(this);var b=0<a.find(".mandatory"+(z?"":":visible")).length;if(a.find(".beneficiary_boolean").length&&b&&!a.find('input[type="radio"]:checked').length)g(a.find(".beneficiary_boolean")),k.mandatory=!0;else if(a.find(".beneficiary_number").length){var c=a.find('input[type="number"]');1!==c.length||!b&&!c.val().length||validation.validateFieldAndHandleTooltip(!1,
c.attr("id"),[{rule:validation.numericRule(!1)}],null,!1,!1,!1)||(g(a.find(".beneficiary_number")),k.mandatory=!0)}else if(a.find(".beneficiary_date").length){c=a.find('select[id$="_day"]');var d=a.find('select[id$="_month"]');var e=a.find('select[id$="_year"]');1!==c.length||1!==d.length||1!==e.length||!b&&"0"===c.val()&&"0"===d.val()&&"0"===e.val()||("0"===c.val()||"0"===d.val()||"0"===e.val()?(g(a.find(".beneficiary_date")),k.mandatory=!0):(O=e.val(),R=d.val(),X=c.val()))}else if(a.find(".beneficiary_phone").length)c=
a.find('input[type="text"]'),1!==c.length||!b&&!c.val().length||validation.validateFieldAndHandleTooltip(!1,c.attr("id"),[{rule:validation.rules.singleFieldPhone}],null,!1,!1,!1)||(g(a.find(".beneficiary_phone")),k.mandatory=!0);else if(a.find(".beneficiary_email").length)c=a.find('input[type="email"]'),1!==c.length||!b&&!c.val().length||validation.validateFieldAndHandleTooltip(!1,c.attr("id"),[{rule:validation.rules.email}],null,!1,!1,!1)||(g(a.find(".beneficiary_email")),k.mandatory=!0);else if(a.find(".beneficiary_text").length){if(c=
a.find('input[type="text"]'),1===c.length)if(0<$.trim(c.val()).length)if((b=c.val())&&T&&!T.test(b))g(a.find(".beneficiary_text")),k.isAllowedCharacterError=!0;else if(a.find('input[value="QU_EXB_BP"]').length){K=c.val().replace(/\s/g,"");for(m in y)y.hasOwnProperty(m)&&(t=t||y[m]===K);-1<w.indexOf(K)||t?(g(a.find(".beneficiary_text")),k.membership=!0):I=c.val()}else a.find('input[value="QU_EXB_ID"]').length&&(V=c.val());else b&&(g(a.find(".beneficiary_text")),k.mandatory=!0)}else if(a.find(".beneficiary_single").length)c=
a.find("select"),!b||null!==c.val()&&c.val().length?a.find('input[value="QU_EXB_NA"]').length&&(N=c.val()):(g(a.find(".beneficiary_single")),k.mandatory=!0);else if(a.find(".beneficiary_multi").length)c=a.find("select"),!b||null!==c.val()&&c.val().length||(g(a.find(".beneficiary_multi")),k.mandatory=!0);else if(a.find(".beneficiary_address").length){var f=a.find('input[id$="_line1"]').val().length,l=a.find('input[id$="_line2"]').val().length,p=a.find('input[id$="_line3"]').val().length;c=a.find(".beneficiary_address_country select").val();
d=a.find('.beneficiary_address_zip_city input[id$="_zipcode"]').val();e=a.find('.beneficiary_address_zip_city input[id$="_city"]').val();var A=f||l||p||c.length||d.length||e.length;if(A||b){var x=f||l||p,u=a.find(".beneficiary_address_line_1"),C=a.find(".beneficiary_address_line_2"),q=a.find(".beneficiary_address_line_3");x||(f||g(u,[C,q]),l||g(C,[u,q]),p||g(q,[u,C]));f=x}else f=!0;a=A||b?h(a,c,d,e):!0;f&&a||(k.mandatory=!0)}else a.find(".beneficiary_address_existing").length&&(c=a.find("select"),
!b||null!==c.val()&&c.val().length||(g(a.find(".beneficiary_address_existing")),k.mandatory=!0))});k.mandatory||k.membership||!A&&!C||(k.isNotUniqueBeneficiary=isNotUniqueBeneficiary({performanceId:r,ticketId:q,firstName:H,lastName:M,idNumber:V,countryCode:N,birthPlace:I,birthdayYear:O,birthdayMonth:R,birthdayDay:X,isHistoryContact:B},u));e&&f&&(b=$("input[value='"+f+"']").attr("name"),b=b.substr(0,b.lastIndexOf("."))+".answer",pesel.isValidPesel($("input[name='"+b+"']").val())||(g($("input[name='"+
b+"']").parent()),k.isPeselError=!0,$("input[name='"+b+"']").prop("disabled",!1)));k.mandatory||k.membership||t||k.isNotUniqueBeneficiary||(y[p]=K);return k}}});
tools.module("dashboard",function(){var a=null,b=null,c=null,d=null,f=null,e=null,g=null,h=null;return{init:function(){a=$("#tab_late_payments");b=$("#tab_offers");c=$("#tab_quotes");d=$("#tab_requests");f=$("#tab_content_late_payments");e=$("#tab_content_offers");g=$("#tab_content_quotes");h=$("#tab_content_requests");a.hasClass("highlight")||f.hide();b.hasClass("highlight")||e.hide();c.hasClass("highlight")||g.hide();d.hasClass("highlight")||h.hide();a.hasClass("disabled")||a.click(function(){f.show();
a.addClass("highlight");e.hide();b.removeClass("highlight");g.hide();c.removeClass("highlight");h.hide();d.removeClass("highlight")});b.hasClass("disabled")||b.click(function(){f.hide();a.removeClass("highlight");e.show();b.addClass("highlight");g.hide();c.removeClass("highlight");h.hide();d.removeClass("highlight")});c.hasClass("disabled")||c.click(function(){f.hide();a.removeClass("highlight");e.hide();b.removeClass("highlight");g.show();c.addClass("highlight");h.hide();d.removeClass("highlight")});
d.hasClass("disabled")||d.click(function(){f.hide();a.removeClass("highlight");e.hide();b.removeClass("highlight");g.hide();c.removeClass("highlight");h.show();d.addClass("highlight")})}}});
tools.module("account.edit.aliasManagement",function(){var a=null,b=null,c=null,d=null,f=null,e=null,g=null,h=null,l=null,k=null,m=null,p=null,q=function(a,b){var c=$(b).find(".payment_method_label .code"),d=$(b).find(".payment_method_label .cardNumber"),e;$(b).removeClass();$(c).html("");$(d).html("");if(a){if(e=a.paymentMethod.code)$(b).addClass("payment_method"),$(b).addClass("payment_method_"+e),$(c).html(e);if(a=a.cardNumber.value)a=(isNewTicketShop?"****-":"XXXX-")+a.substring(a.length-4),$(d).html(a)}},
r=function(){$(k).closest(".button").addClass("disabled")},t=function(a){m=a;$(f).val("");$(e).val($(e).find("option:first").val());$(g).val($(g).find("option:first").val());$(l).removeClass("error");$(h).html("");r();if(a){q(a,c);var b=a.cardHolder.name;var d=a.cardHolder.value;var k=a.cardHolder.editable;b&&($(f).attr("name",b),d&&$(f).val(d),k?($(f).prop("readonly",!1),$(f).removeClass("disabled")):($(f).prop("readonly",!0),$(f).addClass("disabled")));$(f).blur();b=a.cardExpMonth.name;var p=a.cardExpMonth.value;
d=a.cardExpMonth.editable;b&&($(e).attr("name",b),p&&$.each($(e).find("option"),function(){$(this).text()===p&&$(e).val($(this).val())}),d?$(e).prop("disabled",!1):$(e).prop("disabled",!0));b=a.cardExpYear.name;d=a.cardExpYear.value;a=a.cardExpYear.editable;b&&($(g).attr("name",b),d&&$(g).val(d),a?$(e).prop("disabled",!1):$(e).prop("disabled",!0))}},w=function(){$(k).closest(".button").removeClass("disabled")},y=function(a,c){tools.dialog.showWaitingPopup("pleaseWaitDialog",!0);c=$(c);$(c).html(Mustache.render(b,
a));$("#alias_mgt_form").submit()},z=function(){var a={},b,c,d;m&&(a.url=m.url,a.hiddenFields=[],(b=m.hiddenFields)&&$.each(b,function(d){c=b[d];a.hiddenFields.push({name:c.name,value:c.value})}),(d=m.cardNumber)&&a.hiddenFields.push({name:d.name,value:d.value}),(d=m.cardHolder)&&a.hiddenFields.push({name:d.name,value:$(f).val()}),(d=m.cardExpMonth)&&a.hiddenFields.push({name:d.name,value:$(e).val()}),(d=m.cardExpYear)&&a.hiddenFields.push({name:d.name,value:$(g).val()}),y(a,$("#aliasEditFormContainer")))},
x=function(b){b&&a[b]&&(tools.dialog.showWaitingPopup("pleaseWaitDialog",!0),b={aliasId:b},$.ajax({type:"POST",url:contextPath+"/ajax/account/updateAliasData",data:b,dataType:"json",success:function(a){tools.dialog.hideDialog("pleaseWaitDialog");"OK"===a.status?(t(a.epcAliasPaymentDetails),tools.dialog.showDialog("edit_payment_method_popup",!0)):"ERR_UPDATE_OR_REMOVE_ALIAS_DATA"===a.status&&tools.dialog.showDialog("genericAjaxErrorDialog",!0)}}))},A=function(b){if(b&&a[b]){tools.dialog.showWaitingPopup("pleaseWaitDialog",
!0);var c={aliasId:b};$.ajax({type:"POST",url:contextPath+"/ajax/account/removeAliasData",data:c,dataType:"json",success:function(c){tools.dialog.hideDialog("pleaseWaitDialog");"OK"===c.status?(p=c.removeAliasData,(c=a[b])&&q(c,d),tools.dialog.showDialog("remove_payment_method_popup",!0)):"ERR_UPDATE_OR_REMOVE_ALIAS_DATA"===c.status&&tools.dialog.showDialog("genericAjaxErrorDialog",!0)}})}},C=function(){var a={},b,c;p&&(a.url=p.postUrl,a.hiddenFields=[],(b=p.hiddenFields)&&$.each(b,function(d){c=
b[d];a.hiddenFields.push({name:c.name,value:c.value})}),y(a,$("#aliasRemoveFormContainer")))};return{init:function(m){a=m.aliasById;c=$("#edit_alias_payment_method_placeholder");d=$("#remove_alias_payment_method_placeholder");f=$("#card_holder");e=$("#card_expiration_date_month");g=$("#card_expiration_date_year");k=$("#confirmEditAliasButton");h=$("#card_expiration_field_error");l=$("#card_expiration_field");b=$("#aliasManagementFormTpl").html();$(".payment_method .alternative_button.edit").click(function(a){var b=
$(this).find("a").attr("id").substring(10);a.preventDefault();x(b)});$(".payment_method .alternative_button.delete").click(function(a){var b=$(this).find("a").attr("id").substring(12);a.preventDefault();A(b)});$("#cancelEditAliasButton").click(function(a){a.preventDefault();tools.dialog.hideDialog("edit_payment_method_popup")});$(k).click(function(a){a.preventDefault();$(k).closest(".button").hasClass("disabled")||z()});$(f).change(function(a){a.preventDefault();a=$(f).val()?!0:!1;a?w():r()});$([e,
g]).each(function(){$(this).change(function(a){a.preventDefault();a=new Date;if($(e).find(":selected").val()&&$(g).find(":selected").val()){var b=$(e).val();var c=$(g).val();a=parseInt(c,10)>a.getFullYear()||parseInt(c,10)===a.getFullYear()&&parseInt(b,10)>=a.getMonth()+1;$(l).toggleClass("error",!a);a?$(h).html(""):$(h).html(account.edit.aliasManagement._MSG_EXP_DATE_ERROR)}else $(l).removeClass("error"),$(h).html(""),a=!1;a?w():r()})});$("#cancelRemoveAliasButton").click(function(a){a.preventDefault();
tools.dialog.hideDialog("remove_payment_method_popup")});$("#confirmRemoveAliasButton").click(function(a){a.preventDefault();$(confirmRemoveAliasButton).closest(".button").hasClass("disabled")||C()})}}});
tools.module("account.edit.password",function(){var a=function(a){$(".field.error").removeClass("error");var b=["old_password","new_password","password_confirm"];b=a?["old_password","new_password","password_confirm"]:["new_password","password_confirm"];account.register.getEmptyFields(b).forEach(function(a){account.register.addMandatoryErrorField(a)});return account.register.checkFields(b)},b=function(b){account.register.hideNotifications();account.register.removeMandatoryErrorFields();if(!a(b))return $("#notification_mandatory").show().attr("role",
"alert"),!1;if(!account.register.checkPassword($("#new_password").val()))return $("#notification_password_invalid").show().attr("role","alert"),!1;if(b){b=$("#old_password").val();var c=$("#new_password").val();if(b===c)return $("#notification_password_identical").show().attr("role","alert"),!1}if(!account.register.checkConfirmPassword())return $("#notification_password_confirmation").show().attr("role","alert"),!1;account.register.validateField(account.register.validationRules.password,"new_password")?
b=!0:($("#notification_validate_password").show().attr("role","alert"),$("#field_password").addClass("error"),b=!1);return b?!0:!1};return{submitEditForm:function(a){b(a)?$("#edit_password_request_form").submit():(window.scrollTo(0,0),account.register.focusOnFirstFailedElement())}}});
tools.module("account.edit.personalDetails",function(){var a=function(a,b,e){$(".field.error").removeClass("error");var d=!0;var f=["login","login_confirm","firstname","lastname"];account.register.checkFields(f)||(account.register.getEmptyFields(f).forEach(function(a){return account.register.addMandatoryErrorField(a)}),d=!1);"undefined"!=typeof e&&"undefined"!=typeof e.civility&&e.civility&&$("#field_title").length&&"undefined"===typeof $("input[name=title]:checked").val()&&("undefined"===typeof $("select[id=title]").val()||
""===$("select[id=title]").val())&&(account.register.addMandatoryErrorField("field_title"),$("#field_title").addClass("error"),d=!1);f=$("#day").val();var l=$("#month").val();var k=$("#year").val();if("undefined"!=typeof e&&"undefined"!=typeof e.birthdate&&e.birthdate){if("0"===f||"0"===l||"0"===k)account.register.addMandatoryErrorField("field_birthdate"),$("#field_birthdate").addClass("error"),d=!1}else"0"===f&&"0"===l&&"0"===k||"0"!==f&&"0"!==l&&"0"!==k||($("#field_birthdate").addClass("error"),
d=!1);if(a||b||account.register.enableContactAddress)account.register.checkContactAddressMandatoryFields(e)||(d=!1),account.register.checkPhoneFields(e,!0)||(d=!1);account.register.checkIbanField()||(d=!1);account.register.checkSwitfField()||(d=!1);c(e,"custom_nationality")&&""===$("#nationality").val()&&(account.register.addMandatoryErrorField("field_nationality"),$("#field_nationality").addClass("error"),d=!1);c(e,"id_number")&&!account.register.checkFields(["passport"])&&(account.register.addMandatoryErrorField("passport"),
d=!1);c(e,"id_type")&&!account.register.checkFields(["id_type"])&&(account.register.addMandatoryErrorField("id_type"),d=!1);account.register.checkPobFields(e,d)||(d=!1);c(e,"contact_image")&&""===$("#individualPhotoData").val()&&"false"===$("#isContactImageSet").val()&&(account.register.addMandatoryErrorField("field_contact_image"),$("#field_contact_image .profile_img_section > img").addClass("error"),d=!1);$("#useExistingBankAccount").is(":checked")||(c(e,"bank_IBAN")&&account.bankAccount.isMissingIbanNumberMandatoryField()&&
(d=!1),c(e,"bank_BIC")&&account.bankAccount.isMissingBicNumberMandatoryField()&&(d=!1));(a||b)&&c(e,"function")&&""===$('input[id="function"]').val()&&($("#field_function").addClass("error"),account.register.addMandatoryErrorField("field_function"),d=!1);return d},b=function(){if(!account.register.validateField(account.register.validationRules.email,"login"))return $("#notification_validate_login").show().attr("role","alert"),$("#field_login").addClass("error"),!1;if(!account.register.validateField(account.register.validationRules.firstname,
"firstname"))return $("#notification_validate_firstname").show().attr("role","alert"),$("#field_firstname").addClass("error"),!1;if(!account.register.validateField(account.register.validationRules.lastname,"lastname"))return $("#notification_validate_lastname").show().attr("role","alert"),$("#field_lastname").addClass("error"),!1;if("PL"===$("#nationality").val()){if(0!==$("#passport").length&&!pesel.isValidPesel($("#passport").val()))return $("#notification_validate_pesel").show().attr("role","alert"),
$("#field_passport").addClass("error"),!1}else if(!account.register.validateField(account.register.validationRules.passport,"passport"))return $("#notification_validate_passport").show().attr("role","alert"),$("#field_passport").addClass("error"),!1;return account.register.validateAllowedCharacters()&&account.register.validatePhoneNumbers()?!0:!1},c=function(a,b){return"undefined"!=typeof a&&"undefined"!=typeof a[b]&&a[b]};return{init:function(){var a=$(".fieldset_container.address input"),b=$(".fieldset_container.address select");
$([a,b]).each(function(){$(this).change(function(){$("#notification_addressModification").show()})});account.register.registerContactCriteriaHandler()},submitEditForm:function(c,f,e,g){tools.removeSelectWrapper();account.register.filterPhoneMobileFax();account.register.validationRules.addressLine.maxLength=g;g=!0;account.register.hideNotifications();account.register.removeMandatoryErrorFields();a(c,f,e)||($("#notification_mandatory").show().attr("role","alert"),g=!1);account.register.checkConfirmEmail()||
($("#notification_email_confirmation").show().attr("role","alert"),g=!1);"undefined"==typeof e||"undefined"==typeof e.birthdate||!e.birthdate||account.register.checkBirthdate()&&account.register.checkBirthdayInThePast()||($("#notification_invalid_birthdate").show().attr("role","alert"),g=!1);account.register.checkMandatoryContactAuthorizations()||($("#notification_mandatory").show().attr("role","alert"),g=!1);account.register.checkMandatoryContactCriteria()||($("#notification_mandatory").show().attr("role",
"alert"),g=!1);account.register.checkZipCode()||(g=!1);account.register.enableContactAddress&&!account.register.checkAddressLinesLength()&&(g=!1);b()||(g=!1);$("#useExistingBankAccount").is(":checked")||(account.bankAccount&&!account.bankAccount.ibanNumberValidator()&&(g=!1),account.bankAccount&&!account.bankAccount.bicNumberValidator()&&(g=!1));g?$("#edit_personal_details_form").submit():(window.scrollTo(0,0),account.register.focusOnFirstFailedElement())},resetRemoveAccountPopup:function(){$('#remove_account_popup input[type="password"]').val("");
$("#btn_remove_account").hasClass("disabled")||$("#btn_remove_account").addClass("disabled");$("#remove_account_msg_invalid_password").hide()},showRemoveAccountPopup:function(a){account.edit.personalDetails.resetRemoveAccountPopup();tools.dialog.showDialog("remove_account_popup",!0);a&&($("#remove_account_msg_instruction").hide(),$("#remove_account_msg_invalid_password").hide(),$("#remove_account_password_label").hide(),$('#remove_account_popup input[type="password"]').hide())},hideRemoveAccountPopup:function(){tools.dialog.hideDialog("remove_account_popup")},
removeAccount:function(a){tools.dialog.showWaitingPopup("loadingDialog",!0);$.ajax({type:"POST",url:contextPath+"/ajax/account/remove",cache:!1,data:{password:$('#remove_account_popup input[type="password"]').val()},success:function(b){tools.dialog.hideDialog("loadingDialog");b.success?window.location.replace(contextPath+"/account/logout"):"ERR_CONTACT_INVALID_PASSWORD"!==b.status||a?"ERR_CONTACT_NOT_DELETABLE"===b.status?($("#remove_account_not_allowed_popup .error_message").hide(),$("#remove_account_not_allowed_popup #error_message_generic").show().attr("role",
"alert"),tools.dialog.hideDialog("remove_account_popup"),tools.dialog.showDialog("remove_account_not_allowed_popup",!0)):"ERR_CONTACT_NOT_DELETABLE_BALANCE"===b.status?($("#remove_account_not_allowed_popup .error_message").hide(),$("#remove_account_not_allowed_popup #error_message_balance").show().attr("role","alert"),tools.dialog.hideDialog("remove_account_popup"),tools.dialog.showDialog("remove_account_not_allowed_popup",!0)):"ERR_CONTACT_NOT_DELETABLE_OPEN_ORDER"===b.status?($("#remove_account_not_allowed_popup .error_message").hide(),
$("#remove_account_not_allowed_popup #error_message_open_order").show().attr("role","alert"),tools.dialog.hideDialog("remove_account_popup"),tools.dialog.showDialog("remove_account_not_allowed_popup",!0)):tools.dialog.showDialog("ajaxErrorDialog",!0):$("#remove_account_msg_invalid_password").show().attr("role","alert")},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}})}}});
tools.module("account.exchange.exchangeTariffs",function(){var a={},b=function(){var a=[];$("select.tariff_option option:selected[data-verificationId!='']","#exchange_tariff_form").each(function(b,c){a.push({name:$(c).attr("data-audSubCatName"),id:$(c).attr("data-audSubCatId"),verificationId:$(c).attr("data-verificationId")})});return a},c=function(){var a=!0;$("select.tariff_option","#exchange_tariff_form").each(function(b,c){""!==$("option:selected",$(c)).attr("data-verificationId")&&$(".new.member_card_elem").is(":visible")&&
(a=!1)});return a},d=function(){var a=!0;$("select.tariff_option","#exchange_tariff_form").each(function(b,c){0===$("option:selected",$(c)).length&&(a=!1)});return a},f=function(b){$("#btnAddToExchangeCart").tipsy({className:"tipsy-hover",delayIn:200,gravity:"s",title:function(){return d()?c()?"":a.pleaseEnterMemberCards:a.pleaseSelectTariffs}});tools.makeTooltipAccessible("#btnAddToExchangeCart")},e=function(){return $(".tariff_verification_container")},g=function(){if(0<$("#exchange_tariff_form option[data-verificationId!='']").length){var a=
b(),c=[].concat($jscomp.arrayFromIterable(new Set(a.map(function(a){return a.id})))),d=c.map(function(b){return a.filter(function(a){return b===a.id})[0]}),f=d.map(function(a){return a.name}),g=d.map(function(a){return a.verificationId}),h=[];d.forEach(function(b){var c=0;a.forEach(function(a){a.id===b.id&&c++});h.push(c)});tools.dialog.showWaitingPopup("loadingDialog",!0);$.ajax({type:"GET",url:contextPath+"/ajax/selection/showMultiMemberCardList"+window.location.search,data:{verificationIds:g,audSubCatIds:c,
audSubCatNames:f,quantities:h}}).done(function(a){$.trim(a)?e().html(a):e().html("")}).always(function(){tools.dialog.hideDialog("loadingDialog")})}},h=function(){var a=0;$(".exchange_tariff_item").each(function(b,c){b=$('input[name="oldAmount"]',c).val();c=$("option:selected",c);0<c.length&&(c=c.attr("data-amount"),a+=Math.max(Number(c)-Number(b),0))});$("#tariffExchangeSubTotalAmount").html(functions.generateAmount(a))};return{init:function(b){a=b.labels;h();f();g()},handleTariffChanged:function(a){var b=
$("option:selected",$(a)).attr("data-pricelevelId");h();g();a=$(a).closest(".exchange_tariff_item");$('input[type="hidden"][name$="priceLevelId"]',a).val(b)},submit:function(){c()&&d()&&$("#exchange_tariff_form").submit()}}});
tools.module("account.exchange.exchangeTickets",function(){var a={},b=0,c=!1,d=[],f=!1,e=0,g=function(a){return $(a).find('input[type="checkbox"][id^="exchange_"]:checked').length},h=function(a){var c=g(a);$("#notification_maxNbTickets_exceeded").hide();if(0===c)return!1;if(c>b)return $("#notification_maxNbTickets_exceeded").show(),tools.scrollToElement($("#notification_maxNbTickets_exceeded"),"fast"),!1;$(".ticket",a).each(function(a,b){0===$(b).find('input[type="checkbox"][id^="exchange_"]:checked').length&&
$("input",$(b)).remove()});return!0},l=function(b){$(b).find(".exchange_button").each(function(c,d){$(d).hasClass("disabled")||($("a",d).tipsy({className:"tipsy-validation",delayIn:200,gravity:"s",title:function(){return 0===g(b)?a.pleaseSelectTickets:""}}),tools.makeTooltipAccessible("a"),tools.makeTooltipAccessible(d))})},k=function(){var a=$(".main_content_exchange_tickets").find('input[type="checkbox"][id^="exchange_"]:checked'),b=a.closest(".product_container").find("form").attr("data-producttype");
c=0!==a.length&&"undefined"!==typeof b&&!1!==b;$("#exchange_ticket_button").toggleClass("disabled",!c)},m=function(a){if(0!==d.length&&a){var b=a.find(".exchange_button"),c=a.attr("data-productId");0!==b.length&&c&&(a=d.filter(function(a){return a.productId===c}).map(function(a){return a.infoId}),a=0===a.length||1===(new Set(a)).size,$(b).toggleClass("disabled",!a))}},p=function(a){var b=a.closest(".product_container").find("form").attr("data-producttype"),c=[];if("PASS"===b)return a.parent().find('input[name$="ticketId"]').each(function(){c.push($(this).val())}),
{ticketIds:c,ticketInfo:a.siblings('input[name$="timeslotId"]').val()+"_"+a.siblings('input[name$="productId"]').val()+"_"+a.siblings('input[name$="visitGroupId"]').val(),ticketType:b,ticketState:a.siblings('input[name="allTicketsState"]').val()};c.push(a.siblings('input[name$="ticketId"]').val());return{ticketIds:c,ticketInfo:a.siblings('input[name$="productId"]').val()+"_"+a.siblings('input[name$="performanceId"]').val(),ticketType:b,ticketState:a.siblings('input[name="allTicketsState"]').val()}},
q=function(a){var b=a.siblings('input[name$="timeslotId"]').val(),c=a.siblings('input[name$="productId"]').val(),d=a.siblings('input[name$="visitGroupId"]').val()||"";a=a.data("index");var e=c+"_"+d+"_"+b;return{id:e+"_"+a,infoId:e,timeslotId:b,visitGroupId:d,productId:c}},r=function(){if(0===d.length)return!1;var a=d[0];return 0===d.filter(function(b){return a.ticketInfo!==b.ticketInfo}).length},t=function(a){$(".exchange_button").each(function(b,c){"EVENT"!==a||0===$(c).find("#exchange_tariff").length&&
0===$(c).find("#exchange_seat").length&&0===$(c).find("#exchange_date").length?"PASS"===a&&0!==$(c).find("#exchange_pass").length&&$(c).removeClass("disabled"):$(c).removeClass("disabled")})},w=function(){$(".exchange_ticket_form").each(function(a,b){var c=$(b).find(".ticket_barcode").length,d=e-1;c>e&&$(".load_more_button_"+a).show();$(b).find(".ticket_barcode").closest(".ticket:gt("+d+")").hide()})},y=function(a){return 0===g(a)||0<$(a).find(".exchange_button.disabled").length},z=function(a,b){if(a&&
b){if(a.checked)d.push(q($(a)));else{var c=q($(a));d=d.filter(function(a){return a.id!==c.id})}m(b)}},x=function(){$(".exchange_button").each(function(a,b){$(b).addClass("disabled")})};return{init:function(c){var g={};a=c.labels;b=c.maxNbTicketsAllowed;f=c.isForMobileOperator;e=c.limitedDisplayTickets;$('a[id$="_seat"]',".button.disabled").tipsy({className:"tipsy-validation",delayIn:200,gravity:"s",title:function(){return a.changeSeatDisabled}});tools.makeTooltipAccessible('a[id$="_seat"]');tools.makeTooltipAccessible(".button.disabled");
$('a[id$="_date"]',".button.disabled").tipsy({className:"tipsy-validation",delayIn:200,gravity:"s",title:function(){return a.changeDateDisabled}});tools.makeTooltipAccessible('a[id$="_date"]');$('a[id$="_tariff"]',".button.disabled").tipsy({className:"tipsy-validation",delayIn:200,gravity:"s",title:function(){return a.changeTariffDisabled}});tools.makeTooltipAccessible('a[id$="_tariff"]');$('input[type="checkbox"][id^="exchange_"]').on("change",function(){var a=$(this).closest("form");l(a);f||"PASS"!==
a.attr("data-productType")?(k(),this.checked?d.push(p($(this))):(g=p($(this)),d=d.filter(function(a){return g.ticketIds[0]!==a.ticketIds[0]}))):z(this,a)});$(".exchange_ticket_form").each(function(a,b){l(b)});f&&(w(),x(),$("#action_selector_container").on("dialogclose",function(a,b){x()}))},handleClickChangeTicket:function(a){var b=this.getExchangeTicketsForm(a);y(b)||$(a).closest(".exchange_actions_btn").find(".exchange_actions_btn_wrapper").show()},handleClickCancel:function(a){$(a).closest(".exchange_actions_btn").find(".exchange_actions_btn_wrapper").hide()},
handleChangeProduct:function(a){a=this.getExchangeTicketsForm(a);h(a)&&(a.attr("action",contextPath+"/account/tickets/exchange/product"),a.submit())},handleChangeTariffs:function(a){a=this.getExchangeTicketsForm(a);!y(a)&&h(a)&&(a.attr("action",contextPath+"/account/tickets/exchange/tariff"),a.submit())},handleChangeSeats:function(a){a=this.getExchangeTicketsForm(a);!y(a)&&h(a)&&(a.attr("action",contextPath+"/account/tickets/exchange/seat"),a.submit())},handleChangeDate:function(a){a=this.getExchangeTicketsForm(a);
!y(a)&&h(a)&&(a.attr("action",contextPath+"/account/tickets/exchange/date"),a.submit())},handleExchangeVisitPass:function(a){a=this.getExchangeTicketsForm(a);!y(a)&&h(a)&&(a.attr("action",contextPath+"/account/tickets/exchange/pass"),a.submit())},handleExchangeButton:function(){r()?($(".invalid_selected_exchange_tickets").hide(),$("#exchange_ticket_button").hasClass("disabled")||(t(d[0].ticketType),$("#action_selector_container").dialog("open"))):($(".invalid_selected_exchange_tickets").show(),$(".missing_criteria_error").hide(),
$(".invalid_selected_print_tickets").hide(),window.scrollTo(0,0))},loadMoreTicket:function(a){var b=$(a).closest(".exchange_ticket_form").find(".ticket:visible").length+e;$(a).closest(".exchange_ticket_form").find(".ticket:lt("+b+")").show();0===$(a).closest(".exchange_ticket_form").find(".ticket").filter(":hidden").length&&$(a).hide()},getExchangeTicketsForm:function(a){return $(a).closest("form.exchange_ticket_form")},isGroupUnitTicketSameState:function(){return 1===d.length&&"null"===d[0].ticketState?
!1:!0},isSelectedTicketsSameState:function(){if(0===d.length)return!1;var a=d[0];if(!this.isGroupUnitTicketSameState())return $(".invalid_selected_print_tickets").text($(".invalid_selected_print_tickets_for_group").text().replace(/\\/g,"")),!1;$(".invalid_selected_print_tickets").text($(".invalid_selected_print_tickets_for_all").text().replace(/\\/g,""));return 0===d.filter(function(b){return a.ticketState!==b.ticketState}).length},getTicketStateToHandlePrintOrRePrint:function(){return this.isSelectedTicketsSameState()?
0!==d.length?d[0].ticketState:null:null},getSelectedTicketsId:function(){var a=[];if(0===d.length)return[];d.forEach(function(b){return a.push(b.ticketIds)});return a},clearSelectedTickets:function(){d=[]}}});
tools.module("exportCustomerInfo",function(){var a={},b=null,c=function(){exportCustomerInfo.generateReport();return!1},d=function(){$([a.includeVoucherCode,a.includeInvitation]).each(function(b){$(this).change(function(){a.includeVoucherCode.is(":checked")||a.includeInvitation.is(":checked")?(a.exportButton.parent(".button").removeClass("disabled"),a.exportButton.off("click").on("click",c),$("#criteria_required").slideUp("hidden")):(a.exportButton.parent(".button").addClass("disabled"),a.exportButton.off("click"),
$("#criteria_required").slideDown("hidden"))})});a.exportButton.on("click",c)};return{init:function(c){b=c.reportUrl;a.season=$("#season");a.includeVoucherCode=$("#includeVoucherCode");a.includeInvitation=$("#includeInvitation");a.exportButton=$("#btn_generate");d()},generateReport:function(){var c=a.includeVoucherCode.is(":checked")?"true":"false";var d=a.includeInvitation.is(":checked")?"true":"false";var g=a.season.val()||"";window.open(b+"&seasonId="+g+"&includeVoucherCode="+c+"&includeInvitation="+
d+"&exportType=CSV")}}});
tools.module("file",function(){var a=null,b,c,d,f,e,g,h,l,k,m=!1,p,q;var r=function(){b=$("#filter_type");c=$("#status");d=$("#date_from");f=$("#date_to");e=$("#buyer");g=$("#order_file_id");h=$("#btn_submit_search");l=$("#toggle_cancelled_files_id");k=$("#fileContact")};var t=function(){$([b,c,d,f,e,l]).each(function(){$(this).focus(function(){g.val("")})});c.on("change",submitFilterInternal);e.on("change",submitFilterInternal);k.on("change",submitFilterInternal);$(".filterToolReset").on("click",
function(){$(this).hide().parents(".criteria").find("input, select").val("");submitFilterInternal()});b.change(function(){C();("ALL"!==c.val()||""!==e.val()||""!==d.val()||""!==f.val()||m)&&submitFilterInternal()});g.bind("change keydown keyup",function(a){v()&&$(this).tipsy("hide");13===a.which&&h.click()});$([d,f]).each(function(){$(this).keydown(function(a){$(this).datepicker("hide");13===a.which&&(u($(this))||a.preventDefault())})});l.on("click",submitFilterInternal)};var w=function(){$("input[name=cancelledFiles]").val(l.is(":checked"))};
var y=function(){submitFilterInternal()};var z=function(){$("#date_criteria").show();d.prop("disabled",!1);f.prop("disabled",!1);$("#status_criteria, #buyer_criteria").hide();c.prop("disabled",!0);e.prop("disabled",!0)};var x=function(){$("#status_criteria").show();$("#status").prop("disabled",!1);$("#date_criteria, #buyer_criteria").hide();d.prop("disabled",!0);f.prop("disabled",!0);e.prop("disabled",!0);$("#hide_cancelled_files_criteria").hide();l.prop("checked",!1)};var A=function(){$("#buyer_criteria").show();
e.prop("disabled",!1);$("#date_criteria, #status_criteria").hide();d.prop("disabled",!0);f.prop("disabled",!0);c.prop("disabled",!0)};var C=function(){"date"===b.val()?z():"status"===b.val()?x():"buyer"===b.val()&&A()};var u=function(b){try{var c=$.datepicker.parseDate(datePickerConfig.dateFormat,d.val());var e=$.datepicker.parseDate(datePickerConfig.dateFormat,f.val());if(null!==c&&null!==e&&c>e)return validation.showErrorTooltip(b,a.startDateEndDate),!1}catch(K){return b.val(""),!1}return!0};var v=
function(){return!g.val()||validation.validateField(g,[{rule:validation.numericRule(!0)}],null,!0,!1)};submitFilterInternal=function(){("date"!==b.val()||u(d))&&v()&&(w(),tools.saveFocusState(l),$("#file_filter_form").submit())};var D=function(){$("#file_cancel_error_remark").hide();$("#file_cancel_error_options").hide();$("#file_cancel_error_checkbox").hide()};var E=function(){$("#file_cancel_form_reason").val("");$("#file_cancel_form_checkbox").prop("checked",!1);0<$("input[type=radio]").length&&
$("input[type=radio]").prop("checked",!1)};var F=function(a){a.placeholder();a.datepicker(datePickerConfig);a.datepicker("option","maxDate",new Date)};return{completeMissingInfo:function(a){$.ajax({type:"GET",url:contextPath+"/ajax/account/file/dynamicInfo",cache:!1,data:{fileId:a},success:function(b){var c=b;0<$(b).filter("#fileErrorMessage").length?(c=$(b).filter("#fileErrorMessage").text(),$("#file_"+a+" .file_content_type_waiting").addClass("hidden"),$("#file_"+a+" .file_content_has_error").removeClass("hidden"),
$("#file_"+a+" .label_value.file_status .value").html(c),$("#file_"+a+" .label_value.last_update_date .value").html(c),$("#file_"+a+" .label_value.file_amount .value").removeClass("loading"),$("#file_"+a+" .label_value.file_amount .value").html(c)):($("#file_"+a+" .label_value.file_amount").remove(),$("#file_"+a+" .label_value.last_update_date").remove(),$("#file_"+a+" .label_value.file_status").remove(),$("#file_"+a+" .fields_container").append(c))}})},initFileList:function(b,c){a=b;datePickerConfig.onSelect=
y;datePickerConfig.dayNamesMin=datePickerConfig.dayNamesShort;r();t();C();F(d);F(f);m=c},submitFilter:function(){submitFilterInternal()},deleteDocument:function(a,b,c,d,e,f){tools.dialog.showWaitingPopup("loadingDialog",!0);$.ajax({type:"POST",url:a,cache:!1,data:{documentId:b,fileId:c,contactNumber:d,isCheckoutProcess:!1},success:function(a){var c=parseInt($("#main_content_file_documents .sub_section_quantity").html(),10);tools.dialog.hideDialog("loadingDialog");-1!==a.indexOf(b)?($("#document_"+
b).hide(),c--,c+$(".upload_file_name:visible").length<f&&1>$(".browse_file:visible").length&&(addUploadField(),updateAddBtnState()),0===c?($("#message_upload_no_file").show(),$("#main_content_file_documents .sub_section.document_list").hide()):(1===c&&$("#main_content_file_documents .sub_section_txt").html(e),$("#main_content_file_documents .sub_section_quantity").html(c.toString()),$("#main_content_file_documents .sub_section_separator").hide(),$("#main_content_file_documents .sub_section_last_date").hide())):
tools.dialog.showDialog("ajaxErrorDialog",!0)},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}})},cancelFormSubmit:function(){D();""===$("#file_cancel_form_reason").val()?$("#file_cancel_error_remark").show():4===$("input[type=radio]").length&&2!==$("input[type=radio]:checked").length?$("#file_cancel_error_options").show():$("#file_cancel_form_checkbox").is(":checked")?""!==$("#file_cancel_form_fileid").val()&&$("#file_cancel_form").submit():
$("#file_cancel_error_checkbox").show()},checkAllCancel:function(){var a=$("input[type=radio]:checked");2===a.length&&"false"===a[0].value&&"false"===a[1].value?$("#cancelNowButton").addClass("disabled"):$("#cancelNowButton").removeClass("disabled")},showCancelForm:function(){D();E();tools.dialog.showDialog("cancel_file_popup",!0)},hideCancelForm:function(){tools.dialog.hideDialog("cancel_file_popup",!0);D();E()},showFullRemark:function(a){var b=$("#fullExternalRemark_"+a).html();$("#externalRemark_"+
a).html(b);$("#showMore_"+a).hide()},displayRemark:function(a,b){a=a.html();for(var c=$("#externalRemark_"+b),d=a.split("<br>"),e="",f=0;200>e.length&&0<d.length;){var g=d.shift();200<e.length+g.length?e+=g.substring(0,200-e.length):(e+=g,0<d.length&&(e+="<br>",f++))}a.length>200+4*f?(c.html(e+"â€¦"),$("#showMore_"+b).show()):c.html(a);c.removeClass("hidden")},checkPaymentOngoing:function(a,b,c,d){var e=contextPath+"/account/file/pay?fileId="+a+"&orderId="+b+"&amount="+c+"&contactNumber="+d;tools.dialog.showWaitingPopup("loadingDialog",
!0);$.ajax({type:"GET",url:contextPath+"/ajax/account/file/checkPaymentPossible",cache:!1,success:function(a){!0===a?window.location.href=e:(tools.dialog.hideDialog("loadingDialog"),$("#paymentAlreadyOngoingDialog #continue-payment").attr("href",e),tools.dialog.showDialog("paymentAlreadyOngoingDialog",!0,!1,null,"message_dialog message_warning"))},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}})},initLinkFilesForSeating:function(a){$(".linkFileResult, .link_file_container hr").hide();
p=a.contextPath;q=a.fileId;file.buildLinkedFileInfo(a.parentGroupInfo,a.childGroupInfo);$("#parentFileId").on("input",function(){$("#parentFileId").val($("#parentFileId").val().replace(/\s+/g,""));isNaN($("#parentFileId").val())?($(".parentFileIdError").show(),$(".button.linkFilesBtn").addClass("disabled")):($(".button.linkFilesBtn").removeClass("disabled"),$(".parentFileIdError").hide())});$("#parentFileId").on("keypress",function(a){if(13===a.which)file.onClickLinkFileForSeating(a)});$("#linkFilesBtn").on("click",
function(a){file.onClickLinkFileForSeating(a)});var b=a.parentGroupInfo||a.childGroupInfo;file.initViewForSuggestedFileNumber(a.suggestedFileNumber&&!b,a.suggestedFileNumber)},initViewForSuggestedFileNumber:function(a,b){a?($(".instruction").hide(),$("#parentFileId").val(b),$(".button.linkFilesBtn").removeClass("disabled")):$(".seat_with_suggestion").hide()},onClickLinkFileForSeating:function(a){a.preventDefault();isNaN($("#parentFileId").val())||!file||$(".button.linkFilesBtn").hasClass("disabled")||
file.linkFilesForSeating()},buildLinkedFileInfo:function(a,b){a&&b&&($(".linkFileResult, .link_file_container hr").show(),$(".linkFileResult").html("<p>"+a+"</p><p>"+b+"</p>"))},linkFilesForSeating:function(){var a=p+"/ajax/account/file/linkFile",b=$("#parentFileId").val();0<$.trim(b).length&&(tools.dialog.showWaitingPopup("loadingDialog",!0),$(".button.linkFilesBtn").addClass("disabled"),$(".linkFileResult").removeClass("error"),$.ajax({type:"POST",url:a,cache:!1,data:{fileId:q,parentFileId:b}}).done(function(a){tools.dialog.hideDialog("loadingDialog");
$(".linkFileResult, .link_file_container hr").show();a.success?($(".seat_with_suggestion").hide(),$(".auto_link_message").hide(),$("#parentFileId").val(""),file.buildLinkedFileInfo(a.parameters.parentGroupInfo,a.parameters.childGroupInfo)):"ERR_LINK_FILES_FOR_SEATING_FAIL"===a.status&&($(".linkFileResult").addClass("error"),$(".linkFileResult").html("<p>"+a.parameters.linkFileFail+"</p>"))}).fail(function(){$(".linkFileResult, .link_file_container hr").hide();tools.dialog.hideDialog("loadingDialog");
tools.dialog.showDialog("ajaxErrorDialog",!0)}).always(function(){$(".button.linkFilesBtn").removeClass("disabled")}))}}});
tools.module("file.history",{showFileHistory:function(a){tools.dialog.showWaitingPopup("loadingDialog",!0);$.ajax({type:"GET",url:contextPath+"/ajax/account/file/history",cache:!1,data:{fileId:a},success:function(a){tools.dialog.hideDialog("loadingDialog");$(a).dialog({draggable:!1,modal:!0,resizable:!1,width:"auto",close:function(){$("#fileHistoryDialog").dialog("destroy").remove()}})},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}})}});
tools.module("loginAndReset",function(){var a=function(){$("#guest_login_button").click(function(a){a.preventDefault();$("#main_content_login").hide();$("#guest_login_box_content").show();$(".groupBtnRegisterAndGuestLogin").hide()});$("#cancel_guest_login_button").click(function(a){a.preventDefault();$("#main_content_login").show();$("#guest_login_box_content").hide();$(".groupBtnRegisterAndGuestLogin").show()});tools.keyBoardSubmit("#guest_login_form","#confirm_guest_login_button");onCaptchaGuestButton=
function(){$("#guest_login_form").submit()};$("#confirm_guest_login_button_no_captcha").click(function(a){a.preventDefault();$("#guest_login_form").submit()});$("#guest_login_form").submit(function(a){$("#guestLogin").removeClass("error");$("#guestConfirmedEmail").removeClass("error");$("#guestFirstName").removeClass("error");$("#guestLastName").removeClass("error");$(".main_content_login_register .error.message").hide();account.register.removeMandatoryErrorFields();var b=account.register.checkMandatoryContactCriteria();
b||$("#notification_mandatory").show().attr("role","alert");(a=(a=validation.validateFields([{fieldId:"guestLogin",rules:[{rule:validation.rules.mandatory,errorId:"guestLoginIncorrectEmail"},{rule:validation.rules.email,errorId:"guestLoginIncorrectEmail"}]},{fieldId:"guestConfirmedEmail",rules:[{rule:validation.rules.mandatory,errorId:"guestLoginIncorrectConfirmedEmail"},{rule:validation.rules.email,errorId:"guestLoginIncorrectConfirmedEmail"}]},{fieldId:"guestFirstName",rules:[{rule:validation.rules.mandatory,
errorId:"guestFirstNameMandatory"}]},{fieldId:"guestLastName",rules:[{rule:validation.rules.mandatory,errorId:"guestLastNameMandatory"}]},{fieldId:$("[name=g-recaptcha-response]"),rules:validation.rules.mandatory,defaultErrorId:"notification_captcha"}]))&&b)&&0<$("#guestConfirmedEmail").length&&(a=$("#guestConfirmedEmail").val()===$("#guestLogin").val(),a||($("#guestConfirmedEmail").addClass("error"),$("#guestLoginEmailNotMatchConfirmedEmail").show()));a&&loginAndReset.storeGuestLoginFields();return a})};
return{init:function(){$("#sendNewPassword").submit(function(){var a;$("#sendNewPassword").prevAll().hide();$("#email_address").removeClass("error");(a=validation.validateFields([{fieldId:"email_adress",rules:[{rule:validation.rules.mandatory,errorId:"notification_mandatory"},{rule:validation.rules.email,errorId:"notification_validate_email"}]},{fieldId:"captcha_response_field",rules:validation.rules.mandatory,defaultErrorId:"notification_mandatory"},{fieldId:$("[name=g-recaptcha-response]"),rules:validation.rules.mandatory,
defaultErrorId:"notification_captcha"}]))&&loginAndReset.storeResetFields();return a});$("#resetSubmitInvisibleCaptcha")[0]&&tools.keyBoardSubmit("#sendNewPassword","#resetSubmitInvisibleCaptcha");onCaptchaButtonResetReady=function(){$("#sendNewPassword").submit()};$("#resetSubmit").click(function(a){a.preventDefault();onCaptchaButtonResetReady()});a()},storeLoginFields:function(){tools.storage.setItem("loginUsername",$("#login").val())},storeResetFields:function(){tools.storage.setItem("loginUsername",
$("#email_adress").val())},storeLoginFromRegister:function(){tools.storage.setItem("loginUsername",$("#login").val())},storeGuestLoginFields:function(){tools.storage.setItem("loginUsername",$("#guestLogin").val())},restoreLoginFields:function(){var a=tools.storage.getItem("loginUsername");null!==a&&""===$("#login").val()&&$("#login").val(a)},restoreResetFields:function(){var a=tools.storage.getItem("loginUsername");null!==a&&""===$("#email_adress").val()&&$("#email_adress").val(a)}}});
tools.module("account.massPrinting",function(){var a=null,b=null,c=0,d=function(){var a=h();null!=a&&"DONE"===a.state?(document.cookie=l()+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;",tools.dialog.showDialog("massPrintingFinishedDialog",!0,!0,null,"pleaseWaitDialog massPrintingFinishedDialog"),tools.dialog.hideDialog("requestProcessingDialog")):setTimeout(function(){d()},2E3)},f=function(c){var f="tickets_"+Math.random().toString().replace(".","");b.find(".useCulturalContact").val(a);var g=
b.find("form");g.attr("action",g.attr("action")+f+".pdf");g.attr("target","_"+f);!0!==c&&e()||(g[0].submit(),d())},e=function(){if(!0===tools.storage.getItem("alreadyCheckedPopupBlocker"))return!1;var a=window.open("dummy","dummy","width=1, height=1");if(!a||a.closed||"undefined"==typeof a.closed)return tools.dialog.showDialog("popupBlockerDlg",!0,!1,null,""),!0;a.close();tools.storage.setItem("alreadyCheckedPopupBlocker",!0);return!1},g=function(a,b,d){var e=!1,g=!1;c=0;tools.dialog.showWaitingPopup("requestProcessingDialog",
!0);$.ajax({type:"POST",url:contextPath+"/ajax/account/order/massPrintingCheck",data:{orderId:b,fileId:a,movementIds:d}}).done(function(a){0<=a.indexOf("BENEFICIARY_MANDATORY_MISSING")?tools.dialog.showDialog("massPrintingDlg_mandatory_beneficiaries",!0,!1,null,""):0<=a.indexOf("BENEFICIARY_OPTIONAL_MISSING")&&!(0<=a.indexOf("QUESTIONNAIRE_MANDATORY_MISSING"))?(c++,tools.dialog.showDialog("massPrintingDlg_optional_beneficiaries",!0,!1,null,"")):e=!0;0<=a.indexOf("QUESTIONNAIRE_MANDATORY_MISSING")?
tools.dialog.showDialog("massPrintingDlg_mandatory_questionnaire",!0,!1,null,""):0<=a.indexOf("QUESTIONNAIRE_OPTIONAL_MISSING")&&!(0<=a.indexOf("BENEFICIARY_MANDATORY_MISSING"))?(tools.dialog.showDialog("massPrintingDlg_optional_questionnaire",!0,!1,null,""),c++):g=!0;e&&g?f(!1):tools.dialog.hideDialog("requestProcessingDialog")}).fail(function(){tools.dialog.hideDialog("requestProcessingDialog")})},h=function(){var a=Date.now(),b=tools.cookie.getItem(l());return b&&(b=JSON.parse(b),(new Date(b.expires)).getTime()>
a)?(a=b,a.fileName=decodeURIComponent(a.fileName.replace(/\+/g," ")),a.expires=decodeURIComponent(a.expires.replace(/\+/g," ")),a.state=decodeURIComponent(a.state.replace(/\+/g," ")),a):null},l=function(){return"stx_MASSPRINTING_"+SecuTixConfig.institCode+"_"+SecuTixConfig.salesChannelCode};return{handleGenerateTicketWarningMess:function(a,b){"true"===a?tools.dialog.showDialog("massPrintingDlg_mandatory_beneficiaries",!0,!1,null,""):"true"===b&&tools.dialog.showDialog("massPrintingDlg_mandatory_questionnaire",
!0,!1,null,"")},checkBeforePrint:function(a){tools.checkUnsupportedBrowserPrinter(function(){var c=$(a).parents(".massPrintingWidget"),d=c.find("[name=orderId]").val(),e=c.find("[name=fileId]").val(),f=c.find(".movementIds").val();b=c;g(e,d,f)})},doPrintWithPopupBlocker:function(){tools.dialog.hideDialog("popupBlockerDlg");f(!0)},doPrint:function(b){"undefined"!==typeof b&&(a=b);0>=--c&&f(!0)}}});
if("undefined"===typeof menuModule){var menuModule$11=function(){var a=null;showOffCanvasMenu=function(){$('[id^="page_"]').addClass("slide_right");$("#secondary_content_navigation").addClass("slide_right").attr("role","dialog");$('[id^="page_"] #footer_wrapper').addClass("slide_right");a=$("body").css("overflow-y");$("body").css("overflow","hidden");$("#close_menu_overlay").show();$("#account_account_mobile a").attr("aria-expanded","true");$("#secondary_content_navigation .account_info a").focus();
$("#close-dialog-button").focus()};hideOffCanvasMenu=function(){$('[id^="page_"]').removeClass("slide_right");$("#secondary_content_navigation").removeClass("slide_right").removeAttr("role");$('[id^="page_"] #footer_wrapper').removeClass("slide_right");null!==a&&"undefined"!==typeof a?$("body").css("overflow-y",a):$("body").css("overflow-y","visible");$("#close_menu_overlay").hide();$("#account_account_mobile a").attr("aria-expanded","false").focus()};return{init:function(a){var b,d=$("#secondary_content_navigation .last_menu_product_category .nav_title"),
f=$("#secondary_content_navigation .last_item_link a"),e=$(".tickets_menu_logout a");d=$(d[0]);f=$(f[0]);var g=$("#logIn"),h=$("#signUp"),l=$("#close-dialog-button"),k=$("#account_account_mobile a");a&&(b=e&&0<e.length?e:f&&0<f.length?f:d&&0<d.length?d:h&&0<h.length?h:g);$("#secondary_content_navigation .openable").on("click",function(a){return!1});k.on("click",function(a){showOffCanvasMenu();return!1});k.on("keydown",function(a){if(13===a.which)return showOffCanvasMenu(),a.preventDefault()});l.on("click",
function(){hideOffCanvasMenu()});$("#close_menu_overlay").on("click",function(){hideOffCanvasMenu()});$("#secondary_content_navigation .content_title .menu_close_button").on("click",function(){hideOffCanvasMenu()});$("#secondary_content_navigation").on("keydown",function(a){27===a.which&&hideOffCanvasMenu()});if(b)b.on("keydown",function(a){if(!a.shiftKey&&9===a.which)return l.focus(),a.preventDefault()});l.on("keydown",function(a){if(a.shiftKey&&9===a.which)return b.focus(),a.preventDefault()});
"undefined"!==typeof Hammer&&((new Hammer(document.getElementById("close_menu_overlay"))).on("swipeleft",function(){hideOffCanvasMenu()}),(new Hammer(document.getElementById("secondary_content_navigation"))).on("swipeleft",function(){hideOffCanvasMenu()}));a=util.contact.getContact();!a&&"undefined"!==typeof contactName&&contactName&&(a={individualFirstName:contactName.firstName,individualLastname:contactName.lastName});a?($("#secutix_static_menu_name").text(a.individualFirstName+" "+a.individualLastname),
$("#secondary_content_navigation").addClass("state-user-logged")):$("#secondary_content_navigation").addClass("state-user-not-logged")},toggle:function(a){!0!==a&&!1!==a&&(a=!$('[id^="page_"]').hasClass("slide_right"));a?showOffCanvasMenu():hideOffCanvasMenu()}}};"undefined"!==typeof tools&&tools instanceof NS_tools?tools.module("account.menu",menuModule$11()):(window.account=window.account||{},window.account.menu=menuModule$11())}
;if("undefined"===typeof menuLiteModule){var menuLiteModule$12=function(){var a=function(a){if(a){for(;a.firstChild;)a.parentNode.insertBefore(a.firstChild,a);a.remove()}},b=function(b,d,f,e){d=void 0===d?!1:d;(f=f.getElementsByClassName(e))&&0<f.length&&(b?d&&a(f[0]):f[0].remove())};return{loadMenuData:function(c,d,f,e,g,h){$.ajax({type:"GET",url:contextPath+"/ajax/secure/menuBox",dataType:"html",cache:!0,success:function(l){if(l){l=(new DOMParser).parseFromString(l,"text/html");var k=d?["productMenuTop",
"productMenuBottom"]:["productMenuBottom","productMenuTop"],m=l.getElementById(k[0]);k=l.getElementById(k[1]);m&&m.remove();a(k);b(c,!0,l,"menu_list_account_logged_in");b(f,!1,l,"tickets_menu_account_automatic_subscriptions");b(e,!1,l,"tickets_menu_add_products_mobile");b(e,!0,l,"tickets_menu_add_products_contains");b(h,!1,l,"first_level_subgrouping_management");(m=l.getElementsByName(g))&&0<m.length&&(m[0].classList.add("selected"),m[0].querySelector("a").setAttribute("aria-current","page"));(m=
$("#liteModeMenu"))&&m.html(l.body.innerHTML)}}})}}};"undefined"!==typeof tools&&tools instanceof NS_tools?tools.module("account.menuLiteMode",menuLiteModule$12()):(window.account=window.account||{},window.account.menuLiteMode=menuLiteModule$12())}
;tools.module("ongoingOrder",function(){var a,b,c;return{submit:function(d,f,e){a=d;b=f;c=e;tools.dialog.showWaitingPopup("loadingDialog",!0);$.ajax({type:"GET",url:contextPath+"/ajax/account/cartEmpty",cache:!1,data:void 0,success:function(a){a.success?$.ajax({type:"GET",url:contextPath+"/ajax/request/cartEmpty",cache:!1,data:{isRequestCart:!1},success:function(a){a.success?d?$(d).submit():"function"===typeof b?(tools.dialog.hideDialog("loadingDialog"),b()):tools.dialog.hideDialog("loadingDialog"):
(tools.dialog.hideDialog("loadingDialog"),tools.dialog.showDialog("clear_request_basket_dialog",!0,!0))},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}}):(tools.dialog.hideDialog("loadingDialog"),tools.dialog.showDialog("clear_basket_dialog",!0,!0))},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}})},previewRequest:function(a,b,c,g,h){this.checkIfCartIsEmptyAndSubmit({submitForm:!1,contextPathSuffix:a,
fileId:b,quotaDistribution:c,viewType:g,isRequestTransferSeatCat:h})},checkIfCartIsEmptyAndSubmit:function(a){tools.dialog.showWaitingPopup("loadingDialog",!0);$.ajax({type:"GET",url:contextPath+"/ajax/request/cartEmpty",cache:!1,data:{isRequestCart:!0,fileId:a.fileId},success:function(b){b.success?$.ajax({type:"GET",url:contextPath+"/ajax/account/cartEmpty",cache:!1,success:function(b){b.success?a.submitForm?a.isTransferSeatCat?optionReview.submitTransferSeatCatForm(a.checkoutUrl,a.fileId,a.timeout,
a.finalizationCheckoutUrl):optionReview.submitForm(a.checkoutUrl,a.fileId,a.isQuotaDistribution,a.timeout,a.finalizationCheckoutUrl):(b=""+contextPath+a.contextPathSuffix+"/request/summary?fileId="+a.fileId+(a.quotaDistribution?"&quotaDistribution=yes":""),a.viewType&&(b+="&viewType="+a.viewType),a.isRequestTransferSeatCat&&(b+="&transferSeatCat="+a.isRequestTransferSeatCat),window.location.href=b):a.submitForm?ongoingOrder.finalizeCart():(tools.dialog.hideDialog("loadingDialog"),tools.dialog.showDialog("clear_basket_dialog",
!0,!0))},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}}):(tools.dialog.hideDialog("loadingDialog"),tools.dialog.showDialog("clear_request_basket_dialog",!0,!0))},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}})},registerAdvantageClick:function(a){$("#adv_promo_box .perf_link").click(function(){analytics.onClickAdvantagePromotion(a,$(this).attr("id"))})},clearCartAndSubmit:function(d){var f=
c?{newOrderType:c}:{};d&&(f.isAbandonOrder=!0);tools.dialog.showWaitingPopup("loadingDialog",!0);tools.dialog.hideDialog("clear_basket_dialog");$.ajax({type:"GET",url:contextPath+"/ajax/account/clearShoppingCart",data:f,cache:!1,success:function(c){a?$(a).submit():"function"===typeof b?(tools.dialog.hideDialog("loadingDialog"),b()):tools.dialog.hideDialog("loadingDialog");window.location.reload()},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",
!0)}})},clearRequestCartAndSubmit:function(){var d=c?{newOrderType:c}:{};tools.dialog.showWaitingPopup("loadingDialog",!0);tools.dialog.hideDialog("clear_request_basket_dialog");$.ajax({type:"GET",url:contextPath+"/ajax/request/clearCart",data:d,cache:!1,success:function(c){a?$(a).submit():"function"===typeof b?(tools.dialog.hideDialog("loadingDialog"),b()):tools.dialog.hideDialog("loadingDialog");window.location.reload()},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",
!0)}})},submitRequest:function(a){window.location.href=contextPath+a+"/request/summary"},finalizeCart:function(){window.location.href=contextPath+"/cart/shoppingCart"},validateBeforeSubmit:function(a,b,c){a?tools.dialog.showDialog(c,!0):this.submit(b,null,null)}}});
tools.module("orders",function(){var a=null,b={},c=function(){$([b.filterType,b.status,b.dateFrom,b.dateTo]).each(function(){$(this).focus(function(){b.orderId.val("")})});b.status.on("change",h);b.buyer.on("change",h);$(".filterToolReset").on("click",function(){$(this).hide().parents(".criteria").find("input, select").val("");h()});b.filterType.change(function(){f();h()});b.orderId.bind("change keydown keyup",function(a){g()&&$(this).tipsy("hide");13===a.which&&b.orderIdButton.click()});$([b.dateFrom,
b.dateTo]).each(function(){$(this).keydown(function(a){$(this).datepicker("hide");13===a.which&&(e($(this))||a.preventDefault())})})},d=function(){h()},f=function(){"purchase_date"===b.filterType.val()?($("#purchase_date_criteria").show(),b.dateFrom.prop("disabled",!1),b.dateTo.prop("disabled",!1),$("#status_criteria, #buyer_criteria").hide(),b.status.prop("disabled",!0),b.buyer.prop("disabled",!0)):"status"===b.filterType.val()?($("#status_criteria").show(),b.status.prop("disabled",!1),$("#purchase_date_criteria, #buyer_criteria").hide(),
b.dateFrom.prop("disabled",!0),b.dateTo.prop("disabled",!0),b.buyer.prop("disabled",!0)):"buyer"===b.filterType.val()&&($("#buyer_criteria").show(),b.buyer.prop("disabled",!1),$("#purchase_date_criteria, #status_criteria").hide(),b.dateFrom.prop("disabled",!0),b.dateTo.prop("disabled",!0),b.status.prop("disabled",!0))},e=function(c){try{var d=$.datepicker.parseDate(datePickerConfig.dateFormat,b.dateFrom.val());var e=$.datepicker.parseDate(datePickerConfig.dateFormat,b.dateTo.val());if(null!==d&&null!==
e&&d>e)return validation.showErrorTooltip(c,a.startDateEndDate),!1}catch(p){return c.val(""),!1}return!0},g=function(){return!b.orderId.val()||validation.validateField(b.orderId,[{rule:validation.numericRule(!0)}],null,!0,!1)},h=function(){("purchase_date"!==b.filterType.val()||e(b.dateFrom))&&g()&&$("#order_filter_form").submit()};return{initOrderList:function(e){a=e;datePickerConfig.onSelect=d;datePickerConfig.dayNamesMin=datePickerConfig.dayNamesShort;b.filterType=$("#filter_type");b.status=$("#status");
b.dateFrom=$("#date_from");b.dateTo=$("#date_to");b.orderId=$("#order_id");b.buyer=$("#buyer");b.orderIdButton=$("#btn_submit_search");b.dateFrom.placeholder();b.dateTo.placeholder();c();f();b.dateFrom.datepicker(datePickerConfig);b.dateTo.datepicker(datePickerConfig)},submitFilter:function(){h()}}});
tools.module("pendingTransfer",function(){var a=function(){var a=[];$(".ticket_pending_transfer_container .pending_transfer_line").each(function(b,c){b=$(c).find("input[id^=pending_transfer_ticket_checkbox]");b.length&&b.is(":checked")&&(b=b.data("movementids"))&&a.push.apply(a,$jscomp.arrayFromIterable(String(b).split(",").map(function(a){return a.trim()})))});return a.join(",")},b=function(){var a=$(".ticket_pending_transfer_container .pending_transfer_line input:checked"),b=$("#main_content_account_home_pending_transfer_ticket");
a.parent().remove();b.find(".pending_transfer_line").length?1===b.find(".pending_transfer_line").length&&(a=$(".ticket_pending_transfer_container .pending_transfer_line input"),a.prop("checked",!0),a.hide()):b.remove()};return{acceptTransfer:function(){tools.dialog.showWaitingPopup("loadingDialog",!0);$.ajax({type:"POST",url:contextPath+"/ajax/account/resaleManagement/acceptTransferTickets",data:a(),contentType:"application/json",success:function(a){tools.dialog.hideDialog("loadingDialog");"OK"===
a.status?($("#accept_transfer_message_success").show(),b()):"ERR_ACCEPT_TRANSFER"===a.status&&$("#accept_transfer_message_failure").show()},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}})},rejectTransfer:function(){tools.dialog.showWaitingPopup("loadingDialog",!0);$.ajax({type:"POST",url:contextPath+"/ajax/account/resaleManagement/rejectTransferTickets",data:a(),contentType:"application/json",success:function(a){tools.dialog.hideDialog("loadingDialog");
"OK"===a.status?($("#reject_transfer_message_success").show(),b()):"ERR_REJECT_TRANSFER"===a.status&&$("#reject_transfer_message_failure").show()},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}})}}});
tools.module("profileAvatar",function(){var a={},b="jpeg jpg png gif bmp jpe".split(" ");updateStateContactImageChange=function(){$("#isContactImageChange").val("true")};onClickProfileAvatar=function(){$("#individualPhotoData").focus().trigger("click")};clearProfileAvatarInp=function(){$(".profile_img_section .alternative_button.delete").addClass("hidden");$("#individualPhotoData").val("");$("#profile-avatar-preview").attr("src",a.defaultProfileAvatar);$("#isContactImageSet").val("false");updateStateContactImageChange()};
onProfileAvatarInpChange=function(c){var d=$("#individualPhotoData").val();$(".profile_img_section .alternative_button.delete").addClass("hidden");c.files&&c.files[0]&&($("#field_contact_image .profile_img_section > img").removeClass("error"),c.files[0].size<=parseInt(a.avatarMaxSize,10)&&-1!==$.inArray(d.split(".").pop().toLowerCase(),b)?(d=new FileReader,d.onload=function(a){updateStateContactImageChange();cropPhoto("#profile-avatar-preview",a.target.result,c.files[0].type)},d.readAsDataURL(c.files[0]),
$(".profile_img_section .alternative_button.delete").removeClass("hidden")):(clearProfileAvatarInp(),$("#profile_avatar_confirm_popup  p.content").html(a.errorLabel.maxSizeFile),tools.dialog.showDialog("profile_avatar_confirm_popup",!0)))};cropPhoto=function(a,b,f){var c=new Image;c.src=b;c.onload=function(){var b=Math.min(c.width,c.height)/2;var d=c.height/2;var e=c.width/2;var k=d-b;var m=e-b;e+=b;b=d+b;d=document.createElement("canvas");d.width=e-m;d.height=b-k;d.getContext("2d").drawImage(c,-m,
-k);$(a).attr("src",d.toDataURL(f,1))}};return{init:function(b){a=b}}});
var punch;
function NS_punch(){var a;this.alertMessage=this.lastStatusClass="";this.switchToNeutralTimeout=1E3;$(function(){$("#ticket_number").focus();$("#ticket_number").bind("keypress",function(a){13===(a.keyCode||a.which)&&(punch.punchTicket(),$("#ticket_number").val(""))})});this.accessibilityPunchStatusSwitch=function(a){"ON_GOING"!==a?$("#ticket_punching_message_container").removeAttr("role"):$("#ticket_punching_message_container").attr("role","alert");"SUCCESS"!==a?$("#ticket_punch_successful_message_container").removeAttr("role"):$("#ticket_punch_successful_message_container").attr("role",
"alert");"FAIL"!==a?$("#ticket_punch_failed_message_container").removeAttr("role"):$("#ticket_punch_failed_message_container").attr("role","alert")};this.punchTicket=function(){var b=$("#ticket_number").val();$("#ticket_number").val("");if(!punch.isTicketNumberValid(b))return $("#instruction_message_container").hide(),$("#error_message_container").hide(),$("#notification_missing_ticket_number").show().attr("role","alert"),$("#ticket_number").focus(),!1;clearTimeout(a);this.accessibilityPunchStatusSwitch("ON_GOING");
$.ajax({url:contextPath+"/pro/ajax/account/punchTicket",type:"POST",data:{ticketNumber:b},cache:!1,beforeSend:function(){$("#ticket_number").attr("disabled","disabled")},success:function(a){$("#error_message_container").hide();$("#notification_missing_ticket_number").hide();$("#instruction_message_container").show();$(".table_container").html(a);a=$("#h_ticket_status").val();punch.setTicketStatus(a);$("#ticket_number").prop("disabled",!1);$("#ticket_number").focus();punch.accessibilityPunchStatusSwitch(a)},
error:function(a){$("#error_message_container").hide();$("#notification_missing_ticket_number").hide();$("#instruction_message_container").show();$("#ticket_number").prop("disabled",!1);$("#ticket_number").focus()}})};this.setTicketStatus=function(a){""!==punch.lastStatusClass&&$(".image_result").removeClass(punch.lastStatusClass);"ERROR"===a?($("#instruction_message_container").hide(),$("#error_message_container").show().attr("role","alert"),$("#error_message").html('<div class="icon" aria-hidden="true"></div>'+
$("#h_error_message").val())):("SUCCESS"===a?punch.setSuccessStatus():"FAIL"===a&&punch.setFailStatus(),$(".ticket_number").html($("#h_ticket_number").val()))};this.setSuccessStatus=function(){$(".image_result").addClass("success");punch.lastStatusClass="success";a=setTimeout(function(){$(".image_result").removeClass("success");$(".image_result").addClass("success_neutral");punch.lastStatusClass="success_neutral"},punch.switchToNeutralTimeout)};this.setFailStatus=function(){$(".image_result").addClass("fail");
punch.lastStatusClass="fail";a=setTimeout(function(){$(".image_result").removeClass("fail");$(".image_result").addClass("fail_neutral");punch.lastStatusClass="fail_neutral"},punch.switchToNeutralTimeout)};this.isTicketNumberValid=function(a){return""!==a}}punch=new NS_punch;
tools.module("account.refund",function(){var a="",b="",c="",d="",f=function(a){$(a).removeClass("error");$(a).find(".format_error").remove()},e=function(e,h,l,k){f(h);e||($(h).addClass("error"),e='<span class="format_error">',e=l&&k?e+c:l&&!k?e+a:!l&&k?e+d:e+b,e+="</span>",$(h).append(e))};return{submitForm:function(a){$(a).parent().addClass("disabled");if($("#useExistingBankAccount").is(":checked"))var b=!0;else{b=account.refund.ibanNumberValidator();var c=account.refund.bicNumberValidator();b=b&&
c?!0:!1}if(b)$("#refund_credit_form").submit();else return $(a).parent().removeClass("disabled"),!1},toUpperCase:function(a){$(a).val($(a).val().toUpperCase())},ibanNumberValidator:function(){if(!$("#ibanNumber")||0===$.trim($("#ibanNumber").val()).length)return e(!1,"#field_ibanNumber",!0,!0),!1;var a=ibanTools.electronicFormatIBAN($("#ibanNumber").val());a=ibanTools.isValidIBAN(a);e(a,"#field_ibanNumber",!0,!1);return a},bicNumberValidator:function(){if(!$("#bicNumber")||0===$.trim($("#bicNumber").val()).length)return e(!1,
"#field_bicNumber",!1,!0),!1;var a=ibanTools.isValidBIC($("#bicNumber").val().toUpperCase());e(a,"#field_bicNumber",!1,!1);return a},init:function(e,f,l,k){a=e;b=f;c=l;d=k;$("#ibanNumber").blur(function(){account.refund.toUpperCase("#ibanNumber");account.refund.ibanNumberValidator()});$("#bicNumber").blur(function(){account.refund.toUpperCase("#bicNumber");account.refund.bicNumberValidator()});account.bankAccount.addUseExistingBankAccountCheckboxEvent()},resetForm:function(){$("#refund_credit_form")[0].reset();
f("#field_ibanNumber");f("#field_bicNumber")}}});
tools.module("account.register",function(){var a=["address_lookup","old_password","new_password","password_confirm"],b="ACCHADDR ACCHCITY ACCHCOUN ACCHPC BANKADDR BANKCITY BANKCOUN BANKKEY BANKNAME ACCHNAME".split(" "),c=["title","firstname","lastname","password","emailAddress"],d={},f,e=function(a,b,c,d,e,f){if(!account.register.validateField(account.register.validationRules.email,"login"))return $("#notification_validate_login").show().attr("role","alert"),$("#field_login").addClass("error").removeClass("filled_by_social").parents(".fieldset_container.filled_by_social").removeClass("filled_by_social"),
!1;if(!d&&!e&&!account.register.validateField(account.register.validationRules.password,"new_password"))return $("#notification_validate_password").show(),$("#field_password").addClass("error"),!1;if(!account.register.validateField(account.register.validationRules.firstname,"firstname"))return $("#notification_validate_firstname").show(),$("#field_firstname").addClass("error").removeClass("filled_by_social"),!1;if(!account.register.validateField(account.register.validationRules.lastname,"lastname"))return $("#notification_validate_lastname").show(),
$("#field_lastname").addClass("error").removeClass("filled_by_social"),!1;if("PL"===$("#nationality").val()){if(0!==$("#passport").length&&!pesel.isValidPesel($("#passport").val()))return $("#notification_validate_pesel").show(),$("#field_passport").addClass("error").removeClass("filled_by_social"),!1}else if(!account.register.validateField(account.register.validationRules.passport,"passport"))return $("#notification_validate_passport").show(),$("#field_passport").addClass("error").removeClass("filled_by_social"),
!1;if((a||b)&&"new_structure_yes"===$("input[name=isNewStructure]:checked").attr("id")||c){if(!account.register.validateField(account.register.validationRules.addressLine,"structure_name"))return $("#notification_validate_address_line_too_long").show(),$("#field_structure_name").addClass("error"),!1;if(p(f,"siret_code")&&0<$("#siret_code").length&&!account.register.validateField(account.register.validationRules.siretCode,"siret_code"))return $("#notification_validate_siret_code").show(),$("#field_siret_code").addClass("error"),
!1}return account.register.validateAllowedCharacters()&&account.register.validatePhoneNumbers()?!0:!1},g=function(a,b){account.register.hideNotifications();account.register.removeMandatoryErrorFields();$(".field.error").removeClass("error");if(!account.register.checkContactAddressMandatoryFields(a))return $("#notification_mandatory").show().attr("role","alert"),!1;if(60<$("#address_name").val().length){$("#field_address_name").addClass("error");var c=!1}else c=!0;return c?account.register.checkZipCode()?
b&&!account.register.validateAddressStatus()?($("#notification_address_status").show().attr("role","alert"),!1):account.register.validateAllowedCharacters()?account.register.enableContactAddress?account.register.checkAddressLinesLength():account.register.checkPhoneFields(a,!1)&&account.register.validatePhoneNumbers()?!0:!1:!1:!1:($("#notification_address_name").show().attr("role","alert"),!1)},h=function(a,b,c,d,f,g,h){c=c&&$("#account_type_company").is(":checked");account.register.hideNotifications();
var k=!0;$(".field.error").removeClass("error");var m=!0;var x=d?["login","login_confirm","firstname","lastname"]:f?["login","login_confirm","firstname","lastname","captcha_response_field"]:"login login_confirm new_password password_confirm firstname lastname captcha_response_field".split(" ");if(!account.register.checkFields(x)){m=account.register.getEmptyFields(x);for(x=0;x<m.length;x++)account.register.addMandatoryErrorField(m[x]);m=!1}p(g,"civility")&&$("#field_title").length&&!$("#field_title").find(".field_locked").length&&
"undefined"===typeof $("input[name=title]:checked").val()&&"undefined"===typeof $("select[id=title]").val()&&(account.register.addMandatoryErrorField("field_title"),$("#field_title").addClass("error").removeClass("filled_by_social"),m=!1);x=$("#day").val();var A=$("#month").val();var C=$("#year").val();if(p(g,"birthdate")){if("0"===x||"0"===A||"0"===C)account.register.addMandatoryErrorField("field_birthdate"),$("#field_birthdate").addClass("error"),m=!1}else isAnyFieldValid="0"!==x||"0"!==A||"0"!==
C,isAnyFieldInvalid="0"===x||"0"===A||"0"===C,isAnyFieldValid&&isAnyFieldInvalid&&($("#field_birthdate").addClass("error"),m=!1);m||(k=!1);p(g,"prefered_language")&&!account.register.checkFields(["language"])&&(account.register.addMandatoryErrorField("language"),k=!1);p(g,"civility")&&0<$('select[id="title"]').length&&""===$('select[id="title"]').val()&&(account.register.addMandatoryErrorField("field_title"),$("#field_title").addClass("error"),k=!1);p(g,"contact_image")&&""===$("#individualPhotoData").val()&&
"false"===$("#isContactImageSet").val()&&(account.register.addMandatoryErrorField("field_contact_image"),$("#field_contact_image .profile_img_section > img").addClass("error"),k=!1);p(g,"id_type")&&!account.register.checkFields(["id_type"])&&(account.register.addMandatoryErrorField("id_type"),k=!1);p(g,"id_number")&&!account.register.checkFields(["passport"])&&(account.register.addMandatoryErrorField("passport"),k=!1);p(g,"custom_nationality")&&""===$("#nationality").val()&&(account.register.addMandatoryErrorField("field_nationality"),
$("#field_nationality").addClass("error"),k=!1);l(g,k)||(k=!1);if(a||b||c||h){p(g,"function")&&""===$('input[id="function"]').val()&&($("#field_function").addClass("error"),account.register.addMandatoryErrorField("field_function"),k=!1);m=!0;if("new_structure_yes"===$("input[name=isNewStructure]:checked").attr("id")||c){p(g,"official_name")&&(x=$("#official_name").val(),""===x&&(account.register.addMandatoryErrorField("field_official_name"),$("#field_official_name").addClass("error"),m=!1));p(g,"type")&&
(x=$("#structure_type").val(),"0"===x&&(account.register.addMandatoryErrorField("field_structure_type"),$("#field_structure_type").addClass("error"),m=!1));if(p(g,"headcount"))if(x=parseInt($("#number_of_employees").val(),10),""!==$("#number_of_employees").val()&&isNaN(x))account.register.addMandatoryErrorField("field_number_of_employees_numeric"),$("#field_number_of_employees").addClass("error"),m=!1;else if(isNaN(x)||2147483647<x||0>x)account.register.addMandatoryErrorField("field_number_of_employees"),
$("#field_number_of_employees").addClass("error"),m=!1;p(g,"siret_code")&&0<$("#siret_code").length&&(siretCode=$("#siret_code").val(),""===siretCode&&(account.register.addMandatoryErrorField("field_siret_code"),$("#field_siret_code").addClass("error"),m=!1))}else 0<$("#structure_code").length&&""===$("#structure_code").val()&&($("#field_structure_code").addClass("error"),m=!1);m||(k=!1)}account.register.enableContactAddress&&!account.register.checkContactAddressMandatoryFields(g)&&(k=!1);(a||b||
account.register.enableContactAddress)&&!account.register.checkPhoneFields(g,!0)&&(k=!1);account.register.checkMandatoryContactAuthorizations()||(k=!1);account.register.checkMandatoryContactCriteria()||(k=!1);if("new_structure_yes"===$("input[name=isNewStructure]:checked").attr("id")||c)account.register.checkMandatoryStructureAuthorizations()||(k=!1),account.register.checkMandatoryStructureCriteria()||(k=!1);account.register.checkIbanField()||(k=!1);account.register.checkSwitfField()||(k=!1);$("#useExistingBankAccount").is(":checked")||
(p(g,"bank_IBAN")&&account.bankAccount.isMissingIbanNumberMandatoryField()&&(k=!1),p(g,"bank_BIC")&&account.bankAccount.isMissingBicNumberMandatoryField()&&(k=!1));if(!k)return $("#notification_mandatory").show().attr("role","alert"),!1;if(k=!d&&$("#field_captcha").hasClass("field_mandatory"))k=$("#field_captcha"),m=$("[name=g-recaptcha-response]"),m.length&&!m.val()?(k.addClass("error"),$("#notification_captcha").show().attr("role","alert"),k=!1):(k.removeClass("error"),$("#notification_captcha").hide(),
k=!0),k=!k;if(k)return!1;if(!account.register.checkConfirmEmail()&&!h)return $("#notification_email_confirmation").show().attr("role","alert"),$("#field_login").parents(".fieldset_container.filled_by_social").removeClass("filled_by_social"),!1;if(p(g,"birthdate")&&!account.register.checkBirthdate()||!account.register.checkBirthdayInThePast())return $("#notification_invalid_birthdate").show().attr("role","alert"),!1;if(!d&&!f&&!h){if(!account.register.checkPassword($("#new_password").val()))return $("#notification_password_invalid").show().attr("role",
"alert"),!1;if(!account.register.checkConfirmPassword())return $("#notification_password_confirmation").show().attr("role","alert"),!1}return account.register.enableContactAddress&&(!account.register.checkAddressLinesLength()||!account.register.checkZipCode())||!e(a,b,c,d,f,g)||!$("#useExistingBankAccount").is(":checked")&&(account.bankAccount&&!account.bankAccount.ibanNumberValidator()||account.bankAccount&&!account.bankAccount.bicNumberValidator())?!1:!0},l=function(a,b){p(a,"pob_country")?(""===
$("#pob_country").val()&&(account.register.addMandatoryErrorField("field_pob_country"),$("#field_pob_country").addClass("error"),b=!1),account.register.validateLocalityFields("field_pob_locality_criteria")||(b=!1)):q(a,"pob_country")&&""!==$("#pob_country").val()&&(account.register.validateLocalityFields("field_pob_locality_criteria")||(b=!1));p(a,"pob_town")&&!account.register.checkFields(["pob_town"])&&(account.register.addMandatoryErrorField("pob_town"),b=!1);if(p(a,"pob_town")||q(a,"pob_town")){a=
!b;$("#notification_validate_address_line_too_long").hide();var c=$("#pob_town").val(),d=!0;c&&c.length>account.register.validationRules.addressLine.maxLength?($("#notification_validate_address_line_too_long").show().attr("role","alert"),$("#pob_town").removeClass("valid"),$("#field_pob_zipcode_town").addClass("error"),d=!1):a||($("#pob_town").addClass("valid"),$("#field_pob_zipcode_town").removeClass("error"));account.register.toggleMaxLengthError("#field_pob_zipcode_town .field.field_address_zipcode_town",
d);d||(b=!1)}return b},k=function(a){var b={},c=!0;$("input[name^="+a+"]").each(function(){$(this).data("mandatory")&&(b[$(this).data("authorizationCode")]=!0)});jQuery.each(b,function(b,d){"undefined"===jQuery.type($("input[name="+a+"\\["+b+"\\]]:checked").val())&&(b=$("input[name="+a+"\\["+b+"\\]]").parent().parent(),b.addClass("error"),b=b.attr("id"),account.register.addMandatoryErrorField(b),c=!1)});return c},m=function(a){var b={},c={},d=!0,e;$('input[name^="'+a+'"], select[name^="'+a+'"]').each(function(){$(this).data("mandatory")&&
(b[$(this).data("criterionIdCode")]=!0,c[$(this).data("criterionIdCode")]=$(this).data("list"))});jQuery.each(b,function(b,f){if(c[b]){e=$("input[type='checkbox'][name="+a+"\\["+b+"\\]\\.values]");if(0<e.length&&0===$("input[type='checkbox'][name="+a+"\\["+b+"\\]\\.values]:checked").length){f=$(e).closest(".field");var g=f.attr("id");account.register.addMandatoryErrorField(g);f.addClass("error");d=!1}e=$("input[type='radio'][name="+a+"\\["+b+"\\]\\.values]");0<e.length&&0===$("input[type='radio'][name="+
a+"\\["+b+"\\]\\.values]:checked").length&&(f=$(e).closest(".field"),g=f.attr("id"),account.register.addMandatoryErrorField(g),f.addClass("error"),d=!1);e=$("select[name="+a+"\\["+b+"\\]\\.values]");0<e.length&&(!$(e).val()||0===$(e).val().length)&&(b=$(e).closest(".field"),f=b.attr("id"),account.register.addMandatoryErrorField(f),b.addClass("error"),d=!1)}else e=$("input[type='radio'][name="+a+"\\["+b+"\\]\\.values\\[0\\]]"),0<e.length&&"undefined"===jQuery.type($("input[type='radio'][name="+a+"\\["+
b+"\\]\\.values\\[0\\]]:checked").val())&&(f=e.parent().parent(),g=f.attr("id"),account.register.addMandatoryErrorField(g),f.addClass("error"),d=!1),e=$("[name="+a+"\\["+b+"\\]\\.values\\[0\\]]"),0===e.val().length?(b=e.parent(),f=b.attr("id"),account.register.addMandatoryErrorField(f),b.addClass("error"),d=!1):(e=$("[type='checkbox'][name="+a+"\\["+b+"\\]\\.values\\[0\\]]"),0<e.length&&e.is(":visible")&&0==e[0].checked?(b=$(e).closest(".field"),f=b.attr("id"),account.register.addMandatoryErrorField(f),
b.addClass("error"),d=!1):e.is(":hidden")&&(e.val(!1),e[0].checked=!1))});return d},p=function(a,b){return void 0!==a&&void 0!==a[b]&&a[b]},q=function(a,b){return void 0!==a&&void 0!==a[b]&&!a[b]},r=function(){0<$("#privacyPolicyAccepted").length&&$("#saveButton").toggleClass("disabled",!$("#privacyPolicyAccepted").is(":checked"))},t=function(){$(c).each(function(a,b){d[b]=$("input[name="+b+"]").val()})},w=function(){var a=!1;$(c).each(function(b,c){d[c]!==$("input[name="+c+"]").val()&&(a=!0)});return a},
y=function(a){var b=$("#official_name"),c=$("#structure_name"),d=$(".alert_max_address_length"),e=function(){c.data("dirty",!0)};d.hide();b.on("change",function(){c.length&&!c.data("dirty")&&(c.val(b.val().substring(0,a)),b.val().length>a?d.show():d.hide())});c.on("keydown",e);c.val()&&e()},z=function(a,b,c){$(".read_only_field").each(function(){var d=$(this).find(a);if(d.length){var e=b(d);d.remove();(d=$(this).find('[id="'+c(d)+'_content"]'))&&d.text(e)}})};return{enableContactAddress:!1,countryCodes:[],
countryNames:[],mandatoryErrorMessages:{},isZipCodeOptional:function(){return account.register.address.isZipCodeOptional},getZipCodeFieldContainerName:function(){return account.register.address.oneLineZipAndCity?"field_address_zipcode_town":"field_address_zipcode"},getZipCodeFieldName:function(){return account.register.address.oneLineZipAndCity?"address_zipcode":"address_zipcode_standalone"},getCityFieldName:function(){return account.register.address.oneLineZipAndCity?"address_town":"address_town_standalone"},
getCityFieldContainerName:function(){return account.register.address.oneLineZipAndCity?"field_address_zipcode_town":"field_address_town"},validationRules:{email:{minLength:1,maxLength:200,regExp:/^[a-z0-9\_\-\+\$\']+(\.[a-z0-9\_\-\+\$\']+)*@[a-z0-9\-]+(\.[a-z0-9\-]+)*\.[a-z]+$/i},password:{minLength:8,maxLength:40,regExp:void 0},firstname:{minLength:1,maxLength:100,regExp:void 0},lastname:{minLength:1,maxLength:100,regExp:void 0},passport:{minLength:0,maxLength:100,regExp:void 0},addressLine:{minLength:0,
maxLength:100,regExp:void 0},phone:{regExp:/^[0-9]*$/},siretCode:{minLength:1,maxLength:14,regExp:void 0}},validateField:function(a,b){if(0===$("#"+b).length)return!0;var c=$("#"+b).val();return void 0!==a.minLength&&c.length<a.minLength||void 0!==a.maxLength&&c.length>a.maxLength||void 0!==a.regExp&&!a.regExp.test(c)?($("#"+b).addClass("error"),!1):!0},validateCompletingAccountForm:function(a,b,c,d,e,f,g){return h(a,b,c,d,e,f,g)},submitRegisterForm:function(a,b,d,e,f,g,k,l){tools.removeSelectWrapper();
account.register.filterPhoneMobileFax();account.register.validationRules.addressLine.maxLength=k;account.register.checkPrivacyPolicy()&&(account.register.removeMandatoryErrorFields(),h(a,b,d,e,f,g)?(loginAndReset.storeLoginFromRegister(),a="true"===$("input[name=isShippingContactForm]").val(),d="true"===$("input[name=isAccountShippingContactForm]").val(),b="true"===$("input[name=isBillingContactForm]").val(),(a||d||b)&&!w()&&(e=$("#register_request_form").attr("action"),$(c).each(function(a,b){$("input[name="+
b+"]").attr("disabled","disabled")}),a&&(e=e.replace("checkout/shippingContact/contactForm","checkout/deliveryModes/newAddress")),d&&(e=e.replace("account/shippingContact/contactForm","account/editDelivery/newAddress")),b&&(e=e.replace("checkout/billingContact/contactForm","checkout/billingContact/newAddress")),$("#register_request_form").attr("action",e)),$("#register_request_form").submit()):(window.scrollTo(0,0),this.focusOnFirstFailedElement(),"undefined"===typeof grecaptcha||null===grecaptcha||
l||grecaptcha.reset()))},submitAddressForm:function(a,b,c,d){tools.removeSelectWrapper();account.register.filterPhoneMobileFax();account.register.validationRules.addressLine.maxLength=b;c&&!$("#is_delivery_address").prop("checked")?tools.dialog.showWaitingPopup("confirmationDialog_removeDelivery",!0):g(a,d)?$("#address_form").submit():(window.scrollTo(0,0),this.focusOnFirstFailedElement())},hideNotifications:function(){$("#backend_error_notification").hide();$("#notification_mandatory").hide();$("#notification_email_confirmation").hide();
$("#notification_password_invalid").hide();$("#notification_password_identical").hide();$("#notification_password_confirmation").hide();$("#notification_validate_login").hide();$("#notification_validate_password").hide();$("#notification_validate_firstname").hide();$("#notification_validate_lastname").hide();$("#backend_error_notification_container").hide();$("#notification_validate_address_line_too_long").hide();$("#notification_validate_siret_code").hide();$("[id^='allowedChars_error_']").hide();
$("#notification_address_status").hide();$("#notification_validate_zipcode").hide();$("#notification_validate_zipcode_too_long").hide();$("#notification_validate_zipcode_invalid").hide();$("#field_address_line_1 input").removeClass("error");$("#notification_address_name").hide();$("#notification_validate_passport").hide();$("#notification_validate_pesel").hide();$("#notification_validate_iban_number").hide();$("#notification_validate_bic_number").hide()},validateAllowedCharacters:function(b){var c=
new RegExp(account.register.allowedFieldCharacters),d,e=!0;b=void 0!==b?$("input[type='text']:enabled",b):$("input[type='text']:enabled");$(".field.error").removeClass("error");$(".field.error .additional_errorText").hide();for(d=0;d<b.length;d++)""!==$(b[d]).val()&&0>a.indexOf($(b[d]).attr("id"))&&!c.test($(b[d]).val())&&(e=$(b[d]).closest(".field"),account.register.showErrorMsgBelowTheField(e),$(e).addClass("error"),e=!1);return e},showErrorMsgBelowTheField:function(a){var b=$(a).attr("id");if(void 0!==
b&&0<b.length){var c=b.replace(/([[\]])/g,"_");var d="field_address_line_1"===b?"multiFields":"singleField";b=$("#allowedChars_error_"+c);0===$(b).length&&(b=$("#notification_"+d+"_allowedChars_error").clone().attr("id","allowedChars_error_"+c),b.removeClass("hidden"),b.insertAfter(a),b.css("color","red"));$(b).show().attr("role","alert")}},scrollToErrorMessage:function(){if(0<$("[id^='allowedChars_error_']:visible").length){var a=$("[id^='allowedChars_error_']:visible").first().closest(".fieldset_container");
0<$(a).length?$("html, body").animate({scrollTop:$(a).offset().top},0):window.scrollTo(0,0)}else window.scrollTo(0,0)},focusOnFirstFailedElement:function(){var a=$("#mandatory_error_fields li").first().find("a");0<a.length?a.focus():$(".field.error").first().find("input,select").not(".valid").first().focus()},showTooltipErrorMessage:function(a,b){$(a.parent()).data("title",b);$(a.parent()).hover(function(){$(this).tipsy({className:"tipsy-hover",delayIn:0,gravity:"sw",title:function(){return $(this).hasClass("error")?
$(this).data("title"):""}})})},validateAddressStatus:function(){var a=$("#is_delivery_address").is(":checked")||$("#is_billing_address").is(":checked");a?($("#field_is_delivery_address").removeClass("error"),$("#field_is_billing_address").removeClass("error")):($("#field_is_delivery_address").addClass("error"),$("#field_is_billing_address").addClass("error"));return a},validatePhoneNumbers:function(){return 0<$("#phone_number").length&&!account.register.validateField(account.register.validationRules.phone,
"phone_number")?(account.register.showErrorMsgBelowTheField($("#field_phone")),$("#field_phone").addClass("error"),!1):0<$("#mobile_number").length&&!account.register.validateField(account.register.validationRules.phone,"mobile_number")?(account.register.showErrorMsgBelowTheField($("#field_mobile")),$("#field_mobile").addClass("error"),!1):0<$("#fax_number").length&&!account.register.validateField(account.register.validationRules.phone,"fax_number")?(account.register.showErrorMsgBelowTheField($("#field_fax")),
$("#field_fax").addClass("error"),!1):!0},checkPhoneFields:function(a,b){var c=!0;p(a,"phone_group_mandatory")?b?""!==$("#phone_number").val()&&""!==$("#phone_prefix").val()||""!==$("#mobile_prefix").val()&&""!==$("#mobile_number").val()||""!==$("#fax_prefix").val()&&""!==$("#fax_number").val()?c=!0:(["field_phone","field_mobile","field_fax"].forEach(function(a){account.register.addMandatoryErrorField(a)}),$("#field_phone").addClass("error"),$("#field_mobile").addClass("error"),$("#field_fax").addClass("error"),
c=!1):""!==$("#phone_number").val()&&""!==$("#phone_prefix").val()||""!==$("#fax_prefix").val()&&""!==$("#fax_number").val()?c=!0:(["field_phone","field_fax"].forEach(function(a){account.register.addMandatoryErrorField(a)}),$("#field_phone").addClass("error"),$("#field_fax").addClass("error"),c=!1):(p(a,"fix_phone")?""!==$("#phone_number").val()?""===$("#phone_prefix").val()&&(account.register.addMandatoryErrorField("field_phone"),$("#field_phone").addClass("error"),c=!1):(account.register.addMandatoryErrorField("field_phone"),
$("#field_phone").addClass("error"),c=!1):""!==$("#phone_number").val()&&""===$("#phone_prefix").val()&&($("#field_phone").addClass("error"),c=!1),p(a,"mobile_phone")?""!==$("#mobile_number").val()?""===$("#mobile_prefix").val()&&(account.register.addMandatoryErrorField("field_mobile"),$("#field_mobile").addClass("error"),c=!1):($("#field_mobile").addClass("error"),account.register.addMandatoryErrorField("field_mobile"),c=!1):""!==$("#mobile_number").val()&&""===$("#mobile_prefix").val()&&($("#field_mobile").addClass("error"),
c=!1),p(a,"fax_phone")?""!==$("#fax_number").val()?""===$("#fax_prefix").val()&&(account.register.addMandatoryErrorField("fax_prefix"),$("#field_fax").addClass("error"),c=!1):(account.register.addMandatoryErrorField("fax_prefix"),$("#field_fax").addClass("error"),c=!1):""!==$("#fax_number").val()&&""===$("#fax_prefix").val()&&($("#field_fax").addClass("error"),c=!1));return c},checkContactAddressMandatoryFields:function(a){var b=$("#"+this.getZipCodeFieldName());var c=["address_name"];"new_structure_yes"===
$("input[name=isNewStructure]:checked").attr("id")&&c.push("structure_name");var d=account.register.validateFieldsByTargetIds(c);if(!account.register.checkFields(c)){d=account.register.getEmptyFields(c);for(c=0;c<d.length;c++)account.register.addMandatoryErrorField(d[c]);d=!1}c=this.getCityFieldName();p(a,"town")&&!account.register.checkValue($("#"+c).val(),c)&&(account.register.addMandatoryErrorField(c),d=!1);p(a,"zip_code")&&b.length&&!account.register.checkValue(validation.getFilteredZipCode(b.val()),
this.getZipCodeFieldName())&&(account.register.addMandatoryErrorField(this.getZipCodeFieldName()),d=!1);p(a,"address")&&(b=["address_line_1","address_line_2","address_line_3"],account.register.checkOneMandatoryFields(b)&&account.register.checkAddressLinesLength(!d)||((d=account.register.getEmptyFields(b))&&d.length===b.length&&account.register.addMandatoryErrorField(d[0]),d=!1));b=$("#address_country").val();p(a,"country")&&""===b&&($("#field_address_country").addClass("error"),account.register.addMandatoryErrorField("field_address_country"),
d=!1);return account.register.validateLocalityFields()&&d},validateLocalityFields:function(a){var b=[];$("select","#"+(void 0===a?"field_locality_criteria":a)).each(function(){b.push($(this).attr("id"))});return account.register.validateFieldsByTargetIds(b)},validateFieldsByTargetIds:function(a){var b=!0;if(!account.register.checkFields(a)){a=account.register.getEmptyFields(a);for(b=0;b<a.length;b++)account.register.addMandatoryErrorField(a[b]);b=!1}return b},checkMandatoryContactAuthorizations:function(){return k("contactAuthorizations")},
checkMandatoryStructureAuthorizations:function(){return k("structureAuthorizations")},checkMandatoryContactCriteria:function(){return m("contactCriteria")},checkMandatoryStructureCriteria:function(){return m("structureCriteria")},checkFields:function(a){var b;var c=!0;var d=0;for(b=a.length;d<b;d++)account.register.checkValue($("#"+a[d]).val(),a[d])||(c=!1);return c},checkPobFields:function(a,b){return l(a,b)},getEmptyFields:function(a){var b=[];a.forEach(function(a){account.register.checkValue($("#"+
a).val(),a)||b.push(a)});return b},checkValue:function(a,b){var c="#"+b;if(0!==$(c).length&&0===$.trim(a).length)return $(c).closest(".field").addClass("error").removeClass("filled_by_social").parents(".fieldset_container.filled_by_social").removeClass("filled_by_social"),"captcha_response_field"===b&&$("#field_captcha").addClass("error"),$(c).removeClass("valid"),!1;"address_zipcode"!==b&&"address_town"!==b||$(c).addClass("valid");return!0},getMandatoryErrorMessage:function(a){var b=account.register.mandatoryErrorMessages;
return b&&b[a]||"Field with id: "+a},addMandatoryErrorField:function(a){var b=$("#mandatory_error_fields"),c=b.find("li a"),d=account.register.getMandatoryErrorMessage(a);"#"===a.substring(0,1)&&(a=a.replace("#",""));if(0!==$("#notification_mandatory .content").find('a[href="#'+a+'"]').length)return!1;0===c.length&&$("#"+a).focus();b.append('\n        <li>\n          <a href="#'+a+'" class="error"> '+d+" </a>\n        </li>")},removeMandatoryErrorFields:function(){$("#mandatory_error_fields").empty()},
checkOneMandatoryFields:function(a){var b;for(b=0;b<a.length;b++)if(""!==$("#"+a[b]).val())return!0;for(b=0;b<a.length;b++)$("#"+a[b]).removeClass("valid");$("#"+a[0]).closest(".field").addClass("error");return!1},checkConfirmEmail:function(){return $("#login").val()!==$("#login_confirm").val()?($("#field_login_confirm").addClass("error"),!1):!0},checkSwitfField:function(a,b){a=a?$('input[id*="structureCriteria[BANKSWIF]"]'):$('input[id*="contactCriteria[BANKSWIF]"]');var c=/^[A-Z]{6}[0-9A-Z]{2}([0-9A-Z]{3})?$/,
d=!0,e="";if(0===a.length)return!0;void 0!==a.val()&&(e=a.val().toUpperCase());if(""!==e&&!1===c.test(e))return a.parent().addClass("error"),account.register.showTooltipErrorMessage(a,account.register.errorSwiftNumberFormat),!1;""===e&&b&&(account.register.addMandatoryErrorField(a),a.parent().addClass("error"),account.register.showTooltipErrorMessage(a,account.register.errorMandatoryField),d=!1);d&&a.parent().removeClass("error");return d},checkIbanField:function(a,b){var c=account.register.countriesValidate,
d=/^([A-Z]{2})([\d]{2})[a-zA-Z0-9]*$/,e=a?$('input[id*="structureCriteria[ACCNUMB]"]'):$('input[id*="contactCriteria[ACCNUMB]"]'),f=a?$('select[id*="structureCriteriaBANKCOUN"]'):$('select[id*="contactCriteriaBANKCOUN"]');a=e.val();var g=!0;f=f.val();if(0===e.length)return!0;f&&(f=f.toUpperCase());a&&(a=a.toUpperCase());if(""!==a&&(!f||-1<c.indexOf(f))){if(34<a.length)return e.parent().addClass("error"),account.register.showTooltipErrorMessage(e,account.register.errorIbanNumberFormat),!1;e.parent().removeClass("error");
if(!1===d.test(a))return e.parent().addClass("error"),account.register.showTooltipErrorMessage(e,account.register.errorIbanNumberFormat),!1;e.parent().removeClass("error");if(!account.register.checkIbanCheckSum(a))return e.parent().addClass("error"),account.register.showTooltipErrorMessage(e,account.register.errorIbanNumberFormat),!1;e.parent().removeClass("error")}""===a&&b&&(e.parent().addClass("error"),account.register.showTooltipErrorMessage(e,account.register.errorMandatoryField),g=!1);g&&e.parent().removeClass("error");
return g},checkIbanCheckSum:function(a){var b,c=9;a=a.substr(4)+a.substr(0,4);for(b=0;b<a.length;b++)65<=a.charCodeAt(b)&&90>=a.charCodeAt(b)&&(a=a.substr(0,b)+(a.charCodeAt(b)-55)+a.substr(b+1));for(b=Number(a.substr(0,9))%97;c<a.length;)b=Number(b+a.substr(c,7))%97,c+=7;return 1===b},checkZipCode:function(){var a=$("#address_country").val(),b=$("#"+this.getZipCodeFieldName()),c=$("#"+this.getZipCodeFieldContainerName());if(!b.length)return!0;var d=validation.getFilteredZipCode(b.val());(a=validation.checkZipCodeValues(a,
d,function(){c.addClass("error");b.removeClass("valid");$("#notification_validate_zipcode").show().attr("role","alert")},function(){c.addClass("error");b.removeClass("valid");$("#notification_validate_zipcode_too_long").show().attr("role","alert")},function(){c.addClass("error");b.removeClass("valid");$("#notification_validate_zipcode_invalid").show().attr("role","alert")}))?($("#"+account.register.getZipCodeFieldName()).addClass("valid"),$("#"+account.register.getCityFieldContainerName()).removeClass("error")):
($("#"+account.register.getZipCodeFieldName()).removeClass("valid"),$("#"+account.register.getCityFieldContainerName()).addClass("error"));return a},checkBirthdate:function(){var a=$("#day").val();var b=$("#month").val();var c=$("#year").val();if(void 0===a||void 0===b||void 0===c)return!0;var d=parseInt(a,10);var e=parseInt(b,10);var f=parseInt(c,10);a=new Date(c,b-1,a);return d===a.getDate()&&e===a.getMonth()+1&&f===a.getFullYear()},checkBirthdayInThePast:function(){var a=$("#day").val(),b=$("#month").val(),
c=$("#year").val();return void 0===a||void 0===b||void 0===c?!0:new Date(c,b-1,a)<new Date},checkConfirmPassword:function(){return $("#new_password").val()!==$("#password_confirm").val()?($("#field_password_confirm").addClass("error"),!1):!0},checkPassword:function(a){var b,c,d,e;if(8>a.length)return $("#field_password").addClass("error"),!1;var f=e=d=c=0;for(b=a.length;f<b;f++){var g=a.charCodeAt(f);48<=g&&57>=g?e++:65<=g&&90>=g?d++:97<=g&&122>=g&&c++}return 1>e||1>c||1>d?($("#field_password").addClass("error"),
!1):!0},checkAddressLinesLength:function(a){$("#notification_validate_address_line_too_long").hide();var b=account.register.checkAddressFieldMaxLength("address_line_1")&&account.register.checkAddressFieldMaxLength("address_line_2")&&account.register.checkAddressFieldMaxLength("address_line_3");a=account.register.checkCityFieldName(a);account.register.toggleMaxLengthError(".field.address",b);account.register.toggleMaxLengthError(":is(#field_address_zipcode_town,#anti_fraud_form) .field.field_address_zipcode_town",
a);return b&&a},toggleMaxLengthError:function(a,b){b?($(a).removeClass("error"),$(a+" .additional_hint").show(),$(a+" .additional_errorText").addClass("hidden")):($(a).addClass("error"),$(a+" .additional_hint").hide(),$(a+" .additional_errorText").removeClass("hidden"))},checkCityFieldName:function(a){var b=$("#"+account.register.getCityFieldName()).val(),c=!0;b&&b.length>account.register.validationRules.addressLine.maxLength?($("#notification_validate_address_line_too_long").show().attr("role","alert"),
$("#"+account.register.getCityFieldName()).removeClass("valid"),$("#"+account.register.getCityFieldContainerName()).addClass("error"),c=!1):a||($("#"+account.register.getCityFieldName()).addClass("valid"),$("#"+account.register.getCityFieldContainerName()).removeClass("error"));return c},checkAddressFieldMaxLength:function(a){var b=!0,c=$("#"+a);account.register.validateField(account.register.validationRules.addressLine,a)?c.addClass("valid"):($("#notification_validate_address_line_too_long").show().attr("role",
"alert"),c.removeClass("valid"),b=!1);return b},filterPhoneMobileFax:function(){0<$("#phone_number").length&&$("#phone_number").val($("#phone_number").val().replace(/ /g,""));0<$("#mobile_number").length&&$("#mobile_number").val($("#mobile_number").val().replace(/ /g,""));0<$("#fax_number").length&&$("#fax_number").val($("#fax_number").val().replace(/ /g,""))},showFieldsFilledBySocial:function(){$(".filled_by_social:hidden").each(function(){$(this).slideToggle("fast")});$(".fields_obtained_from_social").slideToggle("fast");
return!1},populateSelects:function(){var a;if(0<$("#nationality").length){$("#nationality").append('<option value="">--</option>');var b=0;for(a=account.register.countryCodes.length;b<a;b++)$("#nationality").append('<option value="'+account.register.countryCodes[b]+'">'+account.register.countryNames[b]+"</option>")}},checkPrivacyPolicy:function(){return 0>=$("#privacyPolicyAccepted").length||$("#privacyPolicyAccepted").is(":checked")},registerContactCriteriaHandler:function(){var a=$('input[id*="contactCriteria[BANKSWIF]"]'),
c=$('input[id*="contactCriteria[ACCNUMB]"]'),d=$('input[id*="structureCriteria[BANKSWIF]"]'),e=$('input[id*="structureCriteria[ACCNUMB]"]');$(a).blur(function(){account.register.checkSwitfField();account.register.checkIbanField()}).keydown(function(){account.register.checkSwitfField()}).keyup(function(a){account.register.checkSwitfField()});$(c).blur(function(){account.register.checkIbanField();account.register.checkSwitfField()}).keydown(function(){account.register.checkIbanField()}).keyup(function(a){account.register.checkIbanField()});
$(d).blur(function(){account.register.checkSwitfField(!0);account.register.checkIbanField(!0)}).keydown(function(){account.register.checkSwitfField(!0)}).keyup(function(a){account.register.checkSwitfField(!0)});$(e).blur(function(){account.register.checkIbanField(!0);account.register.checkSwitfField(!0)}).keydown(function(){account.register.checkIbanField(!0)}).keyup(function(a){account.register.checkIbanField(!0)});b.forEach(function(b){$('input[id*="contactCriteria['+b+']"], select[id*="contactCriteria'+
b+'"]').on("change",function(){a.parent().removeClass("error");c.parent().removeClass("error");account.register.checkSwitfField();account.register.checkIbanField()});$('input[id*="structureCriteria['+b+']"], select[id*="structureCriteria'+b+'"]').on("change",function(){e.parent().removeClass("error");d.parent().removeClass("error");account.register.checkSwitfField(!0);account.register.checkIbanField(!0)})})},changeSearchStructureBtnState:function(a){a?$("#searchStructureButton").removeClass("disabled"):
$("#searchStructureButton").addClass("disabled")},changeStructure:function(){$("#structure_code_search").val("");$("#structure_code").val("");$("#structure_info").text("");$("#search_error").text("");$("#field_structure_code input").show();$("#searchStructureButton").show();account.register.changeSearchStructureBtnState(!1);$("#structure_info_container").hide();$("#field_structure_code input").focus()},searchStructure:function(){if(""===$("#structure_code_search").val()||$("#searchStructureButton").hasClass("disabled"))return!1;
if(isNaN($("#structure_code_search").val())&&3>$("#structure_code_search").val().length)return $("#search_error").text(account.register.errorStructureNameTooShort),$("#field_structure_code input").focus(),!1;tools.dialog.showWaitingPopup("loadingDialog",!0);$("#search_error").text("");$.ajax({type:"GET",url:contextPath+"/ajax/account/register/searchStructure",data:{structureNameOrNumber:$("#structure_code_search").val(),parentStructureContactNumber:f},success:function(a){tools.dialog.hideDialog("loadingDialog");
0===a.length?($("#search_error").text(account.register.errorStructureNotFound),$("#field_structure_code input").focus()):1<a.length?($("#search_error").text(account.register.errorStructureManyFound),$("#field_structure_code input").focus()):($("#structure_info").text(a[0].contactNumber+" - "+a[0].structureOfficialName),$("#structure_code").val(a[0].contactNumber),$("#field_structure_code input").hide(),$("#searchStructureButton").hide(),$("#field_structure_code").removeClass("error"),$("#structure_info_container").show());
return!1},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0);return!1}})},initCheckAddressLineMaxLength:function(a){account.register.validationRules.addressLine.maxLength=a;account.register.checkAddressLinesLength();$("#address_line_1, #address_line_2, #address_line_3, #address_town").on("change",account.register.checkAddressLinesLength)},initValidationRuleFieldMaxLength:function(a){["firstname","lastname"].forEach(function(b){account.register.validationRules[b].maxLength=
a||100})},initContentAndHandlingForPeselAndPassportLabel:function(a,b){var c=0<$('label[for="passport"]').find(".mandatory").length?'&nbsp;<span class="mandatory">*</span>':"";0<$("#nationality").length&&"PL"===$("#nationality").val()&&$('label[for="passport"]').html(b+c);$('select[name$="nationality"]').on("change",function(d){var e=d.target.value;d.preventDefault();"PL"===e?$('label[for="passport"]').html(b+c):$('label[for="passport"]').html(a+c)})},addLanguageAttributeForSelector:function(){$('#language[name="preferredLanguage"] > option').each(function(){this.setAttribute("lang",
this.value)})},init:function(a,b,c){y(a);f=c;account.register.initCheckAddressLineMaxLength(a);account.register.initValidationRuleFieldMaxLength(b);t();account.register.registerContactCriteriaHandler();account.register.populateSelects();r();$("#privacyPolicyAccepted").on("change",r);$("#structure_code_search").unbind("keypress keydown keyup").on("keypress keydown keyup",function(a){account.register.changeSearchStructureBtnState(""!==$(this).val());if(13==a.keyCode)return a.preventDefault(),account.register.searchStructure(),
!1;""===$(this).val()&&$("#search_error").text("")});$("#structure_info_container").hide();account.register.changeSearchStructureBtnState(!1);$("#save").tipsy({className:"tipsy-hover",delayIn:200,gravity:"ne",title:function(){return account.register.checkPrivacyPolicy()?"":account.register.errorPrivacyPolicy}});tools.makeTooltipAccessible("#save")},removeReadOnlyContactCriteriaWithEmptyValue:function(){$(".read_only_field").each(function(){$(this).find(".read_only_content").text()||$(this).remove()})},
assignSingleValueContactCriteria:function(){z("input[type=text]",function(a){return a.val()},function(a){return a.attr("id")});z("input[type=radio]:checked",function(a){return a.next("label").text()},function(a){a=a.attr("id");return a.substring(0,a.lastIndexOf("."))})},assignMultipleValueContactCriteria:function(){z("select",function(a){return a.find("option:selected").toArray().map(function(a){return a.text}).join(" | ")},function(a){return a.attr("id")})},onPobCountryUpdated:function(){account.register.address.refreshLocalityCriteriaFields("pob_country",
"field_pob_locality_criteria","pobLocalityCriteriaTpl",!1,"#pob_locality_",function(){return account.register.address.defaultPobLocalityCriterionValues})}}});
tools.module("account.register.address",{prefixCodes:[],prefixNumbers:[],prefixLookupTable:[],countryCodes:[],countryNames:[],defaultLocalityCriterionValues:{},defaultLocalityCriterionNames:{},defaultPobLocalityCriterionValues:{},localityCriteriaCache:{},oneLineZipAndCity:!0,populateSelects:function(a){var b;var c="#"+(a||"address_country");$(c).append('<option value="">--</option>');a=0;for(b=account.register.address.countryCodes.length;a<b;a++)$(c).append('<option value="'+account.register.address.countryCodes[a]+
'">'+account.register.address.countryNames[a]+"</option>")},populatePhone:function(a,b,c){var d,f=[];a="#"+(a||"phone_prefix");b="#"+(b||"mobile_prefix");var e="#"+(c||"fax_prefix");$(a).empty();$(b).empty();$(e).empty();$(a).append('<option value="">--</option>');$(b).append('<option value="">--</option>');$(e).append('<option value="">--</option>');c=0;for(d=account.register.address.prefixCodes.length;c<d;c++){var g=account.register.address.prefixNumbers[c];account.register.address.prefixLookupTable[account.register.address.prefixCodes[c]]=
g;-1==$.inArray(g,f)&&(f.push(g),g='<option value="'+g+'">+'+g+"</option>",$(a).append(g),$(b).append(g),$(e).append(g))}},setPrefix:function(a,b,c){a="#"+(a||"phone_prefix");c="#"+(c||"address_country");""===$("#"+(b||"phone_number")).val()&&(b=$(c+" option:selected").val(),b=account.register.address.prefixLookupTable[b],$(a).val(b))},setMobilePrefix:function(){if(""===$("#mobile_number").val()){var a=$("#address_country option:selected").val();a=account.register.address.prefixLookupTable[a];$("#mobile_prefix").val(a)}},
setFaxPrefix:function(){if(""===$("#fax_number").val()){var a=$("#address_country option:selected").val();a=account.register.address.prefixLookupTable[a];$("#fax_prefix").val(a)}},refreshLocalityCriteriaFields:function(a,b,c,d,f,e){b=void 0===b?"field_locality_criteria":b;c=void 0===c?"localityCriteriaTpl":c;d=void 0===d?!1:d;f=void 0===f?"#locality_":f;e=void 0===e?function(){return account.register.address.defaultLocalityCriterionValues}:e;a=$("#"+(void 0===a?"address_country":a)+" option:selected").val();
e=e();var g;a=account.register.address.localityCriteriaCache[a]||[];Array.isArray(a)&&0<a.length&&a.forEach(function(a,b){a.index=b});if(Mustache&&0<$("#"+c).length&&0<$("#"+b).length){$("#"+b).html(Mustache.render($("#"+c).html(),{items:a}));for(c=0;c<a.length;c++)(g=e[a[c].localityCriterionCode])&&$(f+a[c].localityCriterionCode).val(g);d&&$("#"+b+" select").attr("disabled",!0)}},isTwoLinesOfZipAndCity:function(a){return["US","GB","IE"].includes(a)},setVisibleZipCityVariant:function(){var a=$("#address_country option:selected").val();
this.isTwoLinesOfZipAndCity(a)?(this.oneLineZipAndCity&&($("#address_town_standalone").val($("#address_town").val()),$("#address_zipcode_standalone").val($("#address_zipcode").val())),$("#field_address_town input").prop("disabled",!1),$("#field_address_zipcode input").prop("disabled",!1),$("#field_address_zipcode_town input").prop("disabled",!0),$("#field_address_town").css("display","block"),$("#field_address_zipcode").css("display","block"),$("#field_address_zipcode_town").hide(),this.oneLineZipAndCity=
!1):(this.oneLineZipAndCity||($("#address_town").val($("#address_town_standalone").val()),$("#address_zipcode").val($("#address_zipcode_standalone").val())),$("#field_address_zipcode_town").show(),$("#field_address_town").hide(),$("#field_address_zipcode").hide(),$("#field_address_town input").prop("disabled",!0),$("#field_address_zipcode input").prop("disabled",!0),$("#field_address_zipcode_town input").prop("disabled",!1),this.oneLineZipAndCity=!0);addressAutoComplete.updateCityAndZipCodeFields()},
updateFields:function(){this.refreshLocalityCriteriaFields();this.setPrefix();this.setMobilePrefix();this.setFaxPrefix();this.setVisibleZipCityVariant();addressAutoComplete.updateCityAndZipCodeFields()},checkCityAndZipCodeFields:function(){var a=$("#anti_address_country option:selected").val();this.isTwoLinesOfZipAndCity(a)?$("#field_address_zipcode_town").addClass("two-lines"):$("#field_address_zipcode_town").removeClass("two-lines")},updateFieldsAntifraud:function(a,b,c,d,f,e){this.refreshLocalityCriteriaFields(c,
d,f,e,"#locality_",function(){return account.register.address.defaultLocalityCriterionNames});this.setPrefix(a,b,c);this.checkCityAndZipCodeFields()}});
tools.module("account.register.addressConfirmation",{showOriginalAddress:function(){$("#address_confirmation_seized").show("blind","slow");$("#button_rewrite_address").show("blind","slow");$("#button_incorrect_address").hide("blind","slow");$("#button_accept_proposed_address").addClass("aligned");return!1},confirmProposedAddress:function(){$("#address_confirmation_form input[name=action]").val("confirmProposedAddress");$("#address_confirmation_form").submit();return!1},keepOriginalAddress:function(){$("#address_confirmation_form input[name=action]").val("keepOriginalAddress");
$("#address_confirmation_form").submit();return!1}});
tools.module("salesReports",function(){var a=null,b={},c,d,f=function(){$(".filterToolReset").on("click",function(){$(this).hide().parents(".criteria").find("input, select").val("");$(this).hide().parents(".criteria").find('input[type="checkbox"]').prop("checked",!1)});$([b.relay,b.decomposedProduct,b.ticketDetail,b.dateTo]).each(function(){$(this).closest(".criteria").find(".filterToolReset").hide()});$([b.relay,b.dateFrom,b.dateTo]).each(function(){$(this).change(function(){""!==$(this).val()?$(this).closest(".criteria").find(".filterToolReset").show():
$(this).closest(".criteria").find(".filterToolReset").hide()})});$([b.decomposedProduct,b.ticketDetail]).each(function(){$(this).change(function(){b.decomposedProduct.is(":checked")||b.ticketDetail.is(":checked")?$(this).closest(".criteria").find(".filterToolReset").show():$(this).closest(".criteria").find(".filterToolReset").hide()})});$([b.dateFrom,b.dateTo]).each(function(){$(this).keydown(function(c){$(this).datepicker("hide");if(13===c.which){a:{var d=$(this);try{var e=$.datepicker.parseDate(datePickerConfig.dateFormat,
b.dateFrom.val());var f=$.datepicker.parseDate(datePickerConfig.dateFormat,b.dateTo.val());if(null!==e&&null!==f&&e>f){validation.showErrorTooltip(d,a.startDateEndDate);var k=!1;break a}}catch(m){d.val("");k=!1;break a}k=!0}k||c.preventDefault()}})})};return{init:function(e){a=e.messages;c=e.reportUrl;d=e.loginContactNumber;b.relay=$("#relay");b.dateFrom=$("#date_from");b.dateTo=$("#date_to");b.decomposedProduct=$("#decomposedProduct");b.ticketDetail=$("#ticketDetail");b.reportVariantsSel=$("#reportVariantSel");
b.dateFrom.placeholder();b.dateTo.placeholder();f();b.dateFrom.datepicker(datePickerConfig);b.dateTo.datepicker(datePickerConfig);b.dateFrom.datepicker("setDate",new Date)},generateReport:function(){var a=b.decomposedProduct.is(":checked")?"T":"F";var f=b.ticketDetail.is(":checked")?"T":"F";var h=b.relay.val()?b.relay.val():"";0<b.reportVariantsSel.length&&(c=b.reportVariantsSel.val()+d);window.open(c+"&relayNumber="+h+"&fromDate="+b.dateFrom.val()+"&toDate="+b.dateTo.val()+"&decomposedByProduct="+
a+"&ticketDetail="+f)}}});
tools.module("socialLink",function(){$(function(){$("#social_login_link_question_yes").click(function(a){a.preventDefault();$("#social_link_instruction").slideToggle("fast");$("#social_link_question_container").slideToggle("fast");$("#social_login_form_container").slideToggle("fast")})})});
tools.module("subgrouping_relay",function(){var a=function(){var a,d=contextPath+"/ajax/account/subgrouping/relay/save_or_update",f=contextPath+"/account/subgrouping/management";tools.dialog.showWaitingPopup("loadingDialog",!0);jQuery.ajax({url:d,type:"POST",processData:!1,cache:!1,dataType:"json",data:$("#relay_request_form").serialize(),success:function(c){a=c&&c.status;if("OK"===a)window.location.href=f+b(c.parameters.redirect);else{if("ERR_CREATE_RELAY"===a)if(c.message){c=c.message;tools.dialog.hideDialog("loadingDialog");
switch(c){case "error.contact.loginAlreadyUsed":$("#notification_login_already_used").show();break;case "error.contact.invalidEmail":$("#notification_invalid_email").show();break;case "error.contact.updatingNonExistentStructure":$("#notification_non_existent_structure").show();break;case "error.contingent.permission":$("#subgrouping_message_no_permission").show();break;case "error.contact.missingIndividualIdNumber":$("#notification_missing_individual_id_number").show();break;case "error.call.invalid_parameter":$("#notification_invalid_country_code").show();
break;case "error.contact.wrongLocalityCriterion":$("#notification_wrong_locality_criteria").show();break;case "error.contact.validatedMobilePhoneByAnotherContact":$("#notification_validated_by_another_contact").show()}account.register.scrollToErrorMessage()}else tools.dialog.showDialog("ajaxErrorDialog",!0);tools.dialog.hideDialog("loadingDialog")}},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}})},b=function(a){switch(a){case "newSubStructure":return"?newContactAndSubStructureCreatedMessage=true";
case "existingSubStructure":return"?newContactCreatedMessage=true";case "updated":return"?contactUpdated=true";default:return""}};return{submitCreateRelay:function(b,d,f,e){$("#notification_login_already_used").hide();$("#subgrouping_message_no_permission").hide();tools.removeSelectWrapper();account.register.validationRules.addressLine.maxLength=e;account.register.removeMandatoryErrorFields();account.register.validateCompletingAccountForm(b,d,!0,!1,!1,f,!0)?b=!0:(account.register.scrollToErrorMessage(),
b=!1);b&&a()},initExistingSubStructure:function(a,b){a&&b&&($("#structure_code_search").val(a),$("#searchStructureButton").removeClass("disabled"),$("#structure_info").text(a+" - "+b),$("#structure_code").val(a),$("#field_structure_code input").hide(),$("#searchStructureButton").hide(),$("#structure_info_container").show());$("#field_contactCriteria-ATBBHR").hide();$('input[id^="structureCriteriaSSTYPE.values"]').each(function(a,b){b.onclick="GRPSLS"===b.value?function(a){$("#field_contactCriteria-ATBBHR").hide();
$("#contactCriteria\\[ATBBHR\\]").prop("checked",!1)}:function(a){$("#field_contactCriteria-ATBBHR").show()}})}}});
tools.module("account.ticketFilter",function(){var a={},b,c,d="",f="",e="",g="";bindFilterEvents=function(){$(".seat_cat_show_hide").click(function(a){a.preventDefault();void 0==this.state||0==this.state?(this.state=1,$(this).removeClass("plus"),$(this).addClass("less"),$(this).find(".text").text(f),$(this).find('[role="button"]').attr("aria-expanded",!0),$(this).parent().find(".seat_category_tickets").slideDown(),$(this).parent().find(".product_tickets").slideDown()):(this.state=0,$(this).removeClass("less"),
$(this).addClass("plus"),$(this).find(".text").text(e),$(this).find('[role="button"]').attr("aria-expanded",!1),$(this).parent().find(".seat_category_tickets").slideUp(),$(this).parent().find(".product_tickets").slideUp())});$("#toggle_show_past_tickets_id").on("click",function(){$(this).prop("disabled",!0);$("#toggle_show_resold_cancelled_tickets_id").prop("disabled",!0);$("input[name=showPastTickets]").val($("#toggle_show_past_tickets_id").is(":checked"));$("input[name=showResoldCancelledTickets]").val($("#toggle_show_resold_cancelled_tickets_id").is(":checked"));
tools.saveFocusState($("#toggle_show_past_tickets_id"));$("#ticket_filter_form").submit()});$("#toggle_show_resold_cancelled_tickets_id").on("click",function(){$(this).prop("disabled",!0);$("#toggle_show_past_tickets_id").prop("disabled",!0);$("input[name=showPastTickets]").val($("#toggle_show_past_tickets_id").is(":checked"));$("input[name=showResoldCancelledTickets]").val($("#toggle_show_resold_cancelled_tickets_id").is(":checked"));tools.saveFocusState($("#toggle_show_resold_cancelled_tickets_id"));
$("#ticket_filter_form").submit()});$("#fileContact").on("change",function(){$("input[name=showPastTickets]").val($("#toggle_show_past_tickets_id").is(":checked"));$("input[name=showResoldCancelledTickets]").val($("#toggle_show_resold_cancelled_tickets_id").is(":checked"));$("#ticket_filter_form").submit()});$("#ticket_product_id").change(function(){var b=this.value;var e=a[b]||[];$("input[name=filterProductId]").val(b);$("#ticket_performance_id").html("");$("input[name=filterPerformanceId]").val("");
$("#ticket_performance_id").prop("disabled",!1);$("#ticket_performance_id").append('<option value="">'+d+"</option>");for(b=0;b<e.length;b++)$("#ticket_performance_id").append('<option value="'+e[b].id+'">'+e[b].text+"</option>");c&&""!==c&&$("#ticket_performance_id").find(":selected").val()!==c&&($('option[value="'+c+'"]',"#ticket_performance_id").prop("selected",!0),$("#ticket_performance_id").change(),c="");$("#ticket_performance_id").prop("disabled",0===e.length);1===e.length&&($('option[value="'+
e[0].id+'"]',"#ticket_performance_id").prop("selected",!0),$("#ticket_performance_id").change())});$("#ticket_performance_id").change(function(){$("input[name=filterPerformanceId]").val(this.value);c=this.value});b&&""!==b?$("#ticket_product_id").find(":selected").val()!==b&&($('option[value="'+b+'"]',"#ticket_product_id").prop("selected",!0),$("#ticket_product_id").change(),b=""):$("#ticket_performance_id").prop("disabled",!0);$("#submitTicketFilterBtn").tipsy({className:"tipsy-hover",delayIn:200,
gravity:"s",title:function(){return isMissingFilter()?g:""}});tools.makeTooltipAccessible("#submitTicketFilterBtn")};isMissingFilter=function(){return""===$("input[name=filterPerformanceId]").val()&&!$("#ticket_performance_id").prop("disabled")||" "===$("input[name=filterProductId]").val()&&!$("#ticket_product_id").prop("disabled")};submitFiltersInternal=function(){if(isMissingFilter())return!1;$("input[name=showPastTickets]").val($("#toggle_show_past_tickets_id").is(":checked"));$("input[name=showResoldCancelledTickets]").val($("#toggle_show_resold_cancelled_tickets_id").is(":checked"));
$("#ticket_filter_form").submit()};return{init:function(h){a=h.performanceItemsMap||{};b=h.selectedProductId||void 0;c=h.selectedPerformanceId||void 0;f=h.hideDetailsLabel||"";e=h.showDetailsLabel||"";d=h.pleaseSelectLabel||"";g=h.missingFilterLabel||"";bindFilterEvents()},submitFilters:function(){submitFiltersInternal()}}});
tools.module("upload",function(){var a={},b="jpeg jpg png gif bmp jpe pdf doc docx dot csv".split(" "),c=["xls","xlsx"];onInputFileChange=function(d){var f=$("#browse_file_"+d),e=$("#upload_file_name_"+d),g=$("#file_name_"+d),h=$("#btn_delete_file_"+d);var l=$("#input_upload_hidden_"+d).val();var k=document.getElementById("input_upload_hidden_"+d),m="true"===a.isSupportExcelFileOnly?c:b;$(".main_content_notification:has(.error)").not(".hidden").addClass("hidden");""!==l&&100>=l.length?(l=l.split("\\"),
l=l[l.length-1],-1==$.inArray(l.split(".").pop().toLowerCase(),m)?handleErrorMessage(d,a.errLabel.invalidFileTypeErr):k.files&&k.files[0].size>a.maxSizePerFile?handleErrorMessage(d,a.errLabel.maxSizeFile.replace("{0}",l)):(g.html(l),h.attr("aria-label",h.attr("aria-label")+" "+l),f.hide(),e.show(),functions.alertMessage(a.infoLabel.fileUploaded+" "+l))):100<l.length&&handleErrorMessage(d,a.errLabel.tooLongFileName);updateAddBtnState()};handleErrorMessage=function(a,b){$(".main_content_notification:has(.success)").not(".hidden").addClass("hidden");
$("#input_upload_hidden_"+a).val("");$("#mess_error").text(b);$("#msg_long_file_name").removeClass("hidden");$(window).scrollTop(0)};onClickBrowseBtn=function(a){$("#input_upload_hidden_"+a).focus().trigger("click")};addUploadField=function(b){b=0===$(a.fieldUploadGroup).length?0:a.currentIndex;var c=$(a.uploadedFile).length,d=$(a.fileWaitting4Upload).length;$(a.uploadedDocument).length+c+d<a.maxFileAttachment&&$("#group_file").append(Mustache.render(a.inputUploadTpl,{index:b}));a.currentIndex++};
deleteUploadField=function(b){var c=$(a.fieldUploadGroup).length,d=$("#file_name_"+b)[0].innerText;$("#field_upload_group_"+b).remove();functions.alertMessage(a.infoLabel.fileDeleted+" "+d);1>=c&&addUploadField();updateAddBtnState()};updateAddBtnState=function(){var b=$(a.fieldUploadGroup).length,c=$(a.uploadedFile).length,e=$(a.fileWaitting4Upload).length,g=$(a.uploadedDocument).length,h=a.maxFileAttachment-(c+g);1<=e&&b<h?a.addProofBtn.show():a.addProofBtn.hide();0<e+c?(a.submitButton.removeClass("disabled"),
a.submitButtonLink.attr("aria-disabled","false")):(a.submitButton.addClass("disabled"),a.submitButtonLink.attr("aria-disabled","true"));g===a.maxFileAttachment&&0<a.uploadDocumentContainer.length?a.uploadDocumentContainer.hide():a.uploadDocumentContainer.show()};deleteFileAttachment=function(b,c,e,g){tools.dialog.showWaitingPopup("loadingDialog",!0);var d=$(a.fieldUploadGroup).length;$.ajax({type:"POST",url:b,cache:!1,data:{documentId:c,fileId:e,contactNumber:g,isCheckoutProcess:!0},success:function(b){tools.dialog.hideDialog("loadingDialog");
-1!==b.indexOf(c)?(b=$("#uploaded_file_name_"+c+" .file_name.uploaded")[0].innerText,$("#uploaded_file_name_"+c).remove(),functions.alertMessage(a.infoLabel.fileDeleted+" "+b),1>d&&addUploadField(),updateAddBtnState()):tools.dialog.showDialog("ajaxErrorDialog",!0)},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}})};return{init:function(b){a.currentIndex=0;a.errLabel=b.errorLabel;a.infoLabel=b.infoLabel;a.inputUploadTpl=$("#inputUploadTpl").html();
a.fieldUploadGroup=".field_upload_group";a.uploadedFile=".file_name.uploaded";a.fileWaitting4Upload=".upload_file_name:visible";a.uploadedDocument=".file_documents_container .file_document:visible";a.uploadDocumentContainer=$(".upload_document_container");a.maxSizePerFile=b.maxSizePerFile;a.maxFileAttachment=b.maxFileAttachment;a.isSupportExcelFileOnly=b.isSupportExcelFileOnly;addUploadField();a.submitButton=$(".button.upload");a.submitButtonLink=a.submitButton.children('a[role="button"]');a.fileNoticeMess=
$(".notice_message");a.form=$("#file_upload_form");a.fileUploadFormInput=$(".input_upload_hidden");a.addProofBtn=$(".alternative_button.add");updateAddBtnState();b.ajaxAction&&a.form.submit(b.ajaxAction);b.isIElte10?a.fileNoticeMess.hide():a.fileUploadFormInput.hide();a.submitButton.click(function(){a.submitButton.hasClass("disabled")||a.form.submit()})}}});
tools.module("account.venueMap",function(){var a=null,b=null,c=!1;return{init:function(d){var f,e,g,h,l,k,m=$(".alternative_button.show_map");a=d.showMapButtonLabel;b=d.closeMapButtonLabel;c=d.isMobile;if(m)m.on("click",function(a){c||(a.preventDefault(),f=$(this).parents(".product, .product_right_img"),e=f.find(".add-to-calendar-links"),g=f.find(".add-to-calendar"),h=$(this).find(".text"),l=$(this).find(".triangle"),k=f.find(".map_panel"),k.is(":visible")?account.venueMap.closeMap(f):(h.text(b),
e.is(":visible")&&(e.hide(),g.find(".triangle").removeClass("visible")),l.addClass("visible"),k.slideDown(200)))})},closeMap:function(b){var c=b.find(".map_panel"),d=b.find(".alternative_button.show_map");b=d.find(".text");d=d.find(".triangle");b.text(a);d.removeClass("visible");c.slideUp(200)}}});
tools.module("account.voucherCodes",function(){return{initDashboard:function(){$("#filter_season").change(function(){$("#file_filter_form").submit()})}}});
tools.module("voucherCodesReports",function(){var a;return{init:function(b){a=b.reportUrl;$(".btn_export_voucher_code").off("click");$(".btn_export_voucher_code").on("click",this.generateReport)},generateReport:function(b){b=$(b.currentTarget).data("advantage-id");window.open(a+"advantageIds="+b+"&exportType=CSV")}}});
tools.module("addressAutoComplete",function(){var a,b;var c=function(a){return a};var d={countryCode:["country"],line1:null,line2:null,line3:["neighborhood","locality"],line4:["locality"],town:["postal_town","locality","administrative_area_level_2"],zipCode:["postal_code"]};var f={street_number:"short_name",route:"long_name",locality:"long_name",administrative_area_level_1:"long_name",administrative_area_level_2:"long_name",country:"short_name",postal_code:"short_name"};var e={state:{highlightedRow:0,
currentResults:[],countryCode:"",isSuggestionsShown:!1},triggerState:{timerRef:null,keyCount:0},fields:{$lookupField:null,$line1:null,$line2:null,$line3:null,$town:null,$zipCode:null,$country:null,$gpsLatitude:null,$gpsLongitude:null,$gpsLocationType:null},pcaControl:null,init:function(c,d){var e=[],f={},g;f=d;d=$('[id^="address_line_"]');this.fields.$lookupField=$("#address_lookup");this.fields.$formattedAddress=$("#formatted_address");this.fields.$line1=$(d[0]);this.fields.$line2=$(d[1]);this.fields.$line3=
$(d[2]);this.fields.$town=$("#"+account.register.getCityFieldName());this.fields.$zipCode=$("#"+account.register.getZipCodeFieldName());this.fields.$country=$("#address_country");this.fields.$gpsLatitude=$("#gps_latitude");this.fields.$gpsLongitude=$("#gps_longitude");this.fields.$gpsLocationType=$("#gps_location_type");this.state.countryCode=this.fields.$country.val();this.fields.$lookupField.attr("role","combobox");if(c){var h=this;this.fields.$lookupField.on("focus",function(){h.state.countryCode=
h.fields.$country.val();null!==h.pcaControl&&h.pcaControl.setCountry(h.state.countryCode)});this.fields.$lookupField.keydown(function(a){var b;13===a.which?a.preventDefault():(38===a.which||40===a.which)&&setTimeout(function(){b=$(".pcaselected");0<b.length&&$("#address_lookup_accessibility_info").text($(b).text())},200)});d=[{element:this.fields.$lookupField[0],field:"",mode:pca.fieldMode.SEARCH}];c={bar:{visible:!1},key:c};c=new pca.Address(d,c);c.listen("populate",function(a,b){b=a.Line3?[a.Line1,
a.Line2,a.Line3]:[a.Company,a.Line1,a.Line2];b=b.filter(function(a){return a});this.fillAddressValues({province:this.getDataByField(a,["Province","ProvinceCode","ProvinceName"]),adminArea:this.getDataByField(a,["AdminArea","AdminAreaCode","AdminAreaName"]),line1:b.shift(),line2:b.shift(),line3:b.shift(),town:a.City,zipCode:a.PostalCode});this.fields.$formattedAddress.val(a.Label);this.fields.$gpsLocationType.val("ROOFTOP")}.bind(this));c.listen("show",function(){g=f.numberOfResultsMsg.replace("{0}",
e.length);this.fields.$lookupField.attr("aria-expanded","true");$(".pcalist").attr("role","listbox");$(".pcaitem",".pcalist").attr("role","option");$(".pcalist").prepend('<div class="pcaitem pcaitem_total" role="alert" aria-label="'+g+'">'+g+"</div>")}.bind(this));c.listen("hide",function(){this.fields.$lookupField.attr("aria-expanded","false")}.bind(this));c.listen("results",function(a,b){e=a||[];$("#address_lookup_accessibility_info").text(f.numberOfResultsMsg.replace("{0}",e.length))}.bind(this));
c.listen("noresults",function(){$("#address_lookup_accessibility_info").text(f.noResultsMsg)}.bind(this));c.listen("select",function(a){this.fields.$lookupField.val(a.Text)}.bind(this));this.pcaControl=c}else a=new google.maps.places.AutocompleteService,b=new google.maps.Geocoder,this.fields.$lookupField.keydown(this.keyPressHandler.bind(this)),this.fields.$lookupField.focusin(function(a){a.target.select();this.state.countryCode=this.fields.$country.val()}.bind(this))},keyPressHandler:function(a){var b=
$(a.target);if(this.state.isSuggestionsShown){if(38===a.which){0<this.state.highlightedRow&&(this.state.highlightedRow--,this.drawSuggestion());return}if(40===a.which){this.state.highlightedRow<this.state.currentResults.length-1&&(this.state.highlightedRow++,this.drawSuggestion());return}if(13===a.which){a.preventDefault();this.onAddressSelected(this.state.currentResults[this.state.highlightedRow].description,this.state.currentResults[this.state.highlightedRow].place_id);return}}6<b.val().length?
3===++this.triggerState.keyCount&&this.getPredictions():0===b.val().length&&this.removeSuggestions();this.triggerState.timerRef&&(clearTimeout(this.triggerState.timerRef),this.triggerState.timerRef=null);this.triggerState.timerRef=setTimeout(function(){6<b.val().length&&this.getPredictions()}.bind(this),250)},getPredictions:function(){this.triggerState.keyCount=0;var b={input:this.fields.$lookupField.val(),types:["geocode","establishment"],componentRestrictions:{country:this.state.countryCode}};a.getPredictions(b,
function(a,b){"OK"===b&&this.popSuggestions(a)}.bind(this))},popSuggestions:function(a){this.state.highlightedRow=0;this.state.currentResults=a;this.drawSuggestion()},drawSuggestion:function(){var a;this.removeSuggestions();for(a=0;a<this.state.currentResults.length;a++)this.state.currentResults[a].selected=a===this.state.highlightedRow;a={suggestions:this.state.currentResults};this.getSuggestionContainer().html(Mustache.render('<div class="address_autocomplete_suggestions" role="alert">{{#suggestions}}<div data-place-id="{{place_id}}" class="single_item {{#selected}}highlighted{{/selected}}">{{description}}</div>{{/suggestions}}</div>',
a));a=this.fields.$lookupField.offset();a.top+=this.fields.$lookupField.outerHeight();this.getSuggestionContainer().offset(a);$(document.body).one("click",this.removeSuggestions.bind(this));this.state.isSuggestionsShown=!0},onAddressSelected:function(a,c){this.fields.$lookupField.val(a);this.fields.$formattedAddress.val(a);this.fields.$lookupField.blur();b.geocode({placeId:c},function(a,b){this.removeSuggestions();"OK"===b&&(this.fireAddressAutocompleted(a[0]),this.fillGpsValues(a[0]))}.bind(this))},
fireAddressAutocompleted:function(a){var b;var d={};var e=[];var f="town line1 line2 line3 line4 zipCode countryCode".split(" ");var g=a.address_components;for(b=0;b<f.length;b++)if(a=f[b],"line1"===a){var q=[];q.push(this.extractAddressComponent("room",g,e));q.push(this.extractAddressComponent("floor",g,e));q.push(this.extractAddressComponent("establishment",g,e));d[a]=q.filter(c).join(" ")}else"line2"===a?(q=[],q.push(this.extractAddressComponent("street_number",g,e)),q.push(this.extractAddressComponent(["route",
"street_address"],g,e)),d[a]=q.filter(c).join(" ")):d[a]=this.extractAddressLine(a,g,e);d=this.shiftLinesIfEmpty(d);this.fillAddressValues(d)},getDataByField:function(a,b){return b.map(function(b){return a[b]}).filter(function(a){return a})},fillAddressValues:function(a){var b=this;var c=a.province;var d=a.adminArea;var e=$("#address_country option:selected").val();var f=account.register.address.localityCriteriaCache[e]||[];if(0<f.length)switch(e){case "FR":b.tryToFillValues(c,f.find(function(a){return"REGION"===
a.localityCriterionCode}));b.tryToFillValues(d,f.find(function(a){return"DEPT"===a.localityCriterionCode}));break;default:b.tryToFillValues(c,f[0])}["line1","line2","line3","town","zipCode"].forEach(function(c){var d=b.fields["$"+c];d.val(a[c]);d.one("change",function(){b.removeGpsValues()})})},tryToFillValues:function(a,b){a=a.map(function(a){return a.trim().replace(/\s|-/g,"")}).filter(function(a){return a});var c=$("#locality_"+b.localityCriterionCode);b=$("#locality_"+b.localityCriterionCode+
" option");c&&a.length&&b.each(function(b,d){b=$(d).val();d=$(d).text().trim().replace(/\s|-/g,"");if(a.includes(d)||a.includes(b))return c.val(b),!1;c.val("")})},fillGpsValues:function(a){var b=a.geometry.location;a=a.geometry.location_type;b?(this.fields.$gpsLatitude.val(b.lat()),this.fields.$gpsLongitude.val(b.lng()),this.fields.$gpsLocationType.val(a)):this.removeGpsValues()},removeGpsValues:function(){this.fields.$gpsLatitude.val("");this.fields.$gpsLongitude.val("");this.fields.$gpsLocationType.val("")},
removeSuggestions:function(){this.getSuggestionContainer().html("");this.state.isSuggestionsShown=!1},getSuggestionContainer:function(){var a=$("#address_suggestions");0===a.length&&($(document.body).append('<div id="address_suggestions"/>'),a=$("#address_suggestions"),a.delegate(".single_item","click",function(a){var b=$(a.target);a=b.data("place-id");b=b.html();this.onAddressSelected(b,a)}.bind(this)));return a},extractAddressLine:function(a,b,c){return this.extractAddressComponent(d[a],b,c)},extractAddressComponent:function(a,
b,c){var d,e;a instanceof Array||(a=[a]);for(d=0;d<a.length;d++){var g=a[d];for(e=0;e<b.length;e++){var h=b[e];if(0<=h.types.indexOf(g)&&0>c.indexOf(g))return c.push(g),h[f[g]||"long_name"]}}return null},shiftLinesIfEmpty:function(a){var b,c;for(b=1;2>=b;b++)for(c=b;4>=c&&!a["line"+c];c++)a["line"+c]=a["line"+(c+1)],a["line"+(c+1)]=null;return a}};return{init:function(a,b,c,d,f,p,q){var g=p?"https://maps.googleapis.com/maps/api/js":"http://maps.google.cn/maps/api/js";window.google||window.pca?e.init(f,
q):(window.stx_initAddressAutoComplete=function(){e.init(f,q)},p=document.createElement("script"),p.setAttribute("async",""),f?(p.setAttribute("src",contextPath+"/resources/js/lib/address.min.js"),p.onload=window.stx_initAddressAutoComplete,a=document.createElement("link"),a.setAttribute("rel","stylesheet"),a.setAttribute("type","text/css"),a.setAttribute("href",contextPath+"/resources/css/address.min.css"),document.head.appendChild(a)):b?(p.setAttribute("id","googleMapsAPI"),p.setAttribute("defer",
!0),p.setAttribute("src",g+"?v=3.25&client="+b+"&channel="+c+"&libraries=places&callback=stx_initAddressAutoComplete&language="+d)):(p.setAttribute("id","googleMapsAPI"),p.setAttribute("defer",!0),p.setAttribute("src",g+"?v=3.25&key="+a+"&libraries=places&callback=stx_initAddressAutoComplete&language="+d)),document.head.appendChild(p))},updateCityAndZipCodeFields:function(){e.fields.$town=$("#"+account.register.getCityFieldName());e.fields.$zipCode=$("#"+account.register.getZipCodeFieldName())},getAddressLookUpEngineFields:function(){return e.fields}}});
tools.module("advantages",{specialOfferFormSubmit:function(a,b){a=a.find("input");a.val(a.val().substring(0,20));return 0<a.val().length},specialOfferFormClick:function(a,b){b.preventDefault();return a.submit()},toggleAdvantageTouchBloc:function(){$(this).parent().find(".advantage_container").toggle(0,function(){$(this).parent().hasClass("advantage_open")?$(this).parent().removeClass("advantage_open"):$(this).parent().addClass("advantage_open")})}});
$(function(){$("#seatMapSpecialOfferForm").add($("#specialOfferForm")).submit(function(a){return advantages.specialOfferFormSubmit($(this),a)}).find(".button").click(function(a){return advantages.specialOfferFormClick($(this).parent(),a)});$("#seatMapSpecialOfferTrigger").click(function(){$(this).hide();$("#seatMapSpecialOfferForm").removeClass("hidden")})});
tools.module("analytics",{onClickAdvantagePromotion:function(a,b){window.dataLayer||(dataLayer=[]);dataLayer.push({event:"onClickAdvantagePromotion",currentPerfId:a,promotionPerfId:b})}});
tools.module("SecuTixAPI",{getContact:function(){var a=util.contact.getContact();return a?{lang:a.lang,firstName:a.individualFirstName,lastName:a.individualLastname,title:a.individualTitle,structureName:a.structureOfficialName}:null},getUrls:function(){var a=SecuTixConfig.urls;return{account:a.account,cart:a.cart,logout:a.logout,continueShopping:a.continueShopping,langs:a.langs}},toggleSecutixMobileMenu:function(a){account.menu.toggle(a)},getCart:function(){var a=util.cart.getCart();return a?{nbItems:a.nbItems,
amount:a.amount,currency:a.currency}:null},accessibilityZoomIn:function(){util.accessibility.zoomIn()},accessibilityZoomOut:function(){util.accessibility.zoomOut()},toggleContrastMode:function(){util.accessibility.highContrastHandler()},initAccessibilityMode:function(){util.accessibility.initAccessibilityMode()}});
tools.module("audSubCatVerification",function(){var a=null,b=null,c=null,d=null,f=[],e=[],g=function(a){var b=a.find("td.tariff,th.tariff").index(),c=a.find("td.area"),d=a.find("td.subtotal").index(),e=$("#tpl_external_membership").text();e=$(e);0<$("#season_ticket_subscribers_table").length?(e.children().last().attr("colspan",2),e.children().first().remove()):(c.length&&!c.is(":visible")&&b--,e.children().first().attr("colspan",b),e.children().last().attr("colspan",d-b+1).attr("width",1));a.hasClass("v2-alternative_bg_even")?
e.addClass("v2-alternative_bg_even"):a.hasClass("v2-alternative_bg_odd")&&e.addClass("v2-alternative_bg_odd");if(b=a.attr("class"))b=b.split(" ").find(function(a){return a.includes("v2-seatcat_")}),e.addClass(b);return e.insertAfter(a)},h=function(a){var b=a.next(".external_membership");b.hasClass("group_end")&&b.hasClass("seat_category_end")&&a.addClass("group_end").addClass("seat_category_end");b.remove()},l=function(a){var b=parseInt(a.val(),10),c=a.parent().parent(),d=0,e=null;0<b?(e=f.index(a),
f.slice(0,e).each(function(){$(this).attr("data-verificationId")===$(a).attr("data-verificationId")&&(d+=parseInt($(this).val(),10))}),tools.dialog.showWaitingPopup("loadingDialog",!0),$.ajax({type:"GET",url:contextPath+"/ajax/selection/showMemberCardList"+window.location.search,data:{verificationId:a.attr("data-verificationId"),audSubCatId:a.attr("data-audSubCatId"),quantityIndex:e,quantity:b,totalPreviousQuantity:d}}).done(function(a){if($.trim(a)){var b=c.next(".external_membership").children().last();
b.length||(b=g(c).children().last());c.hasClass("group_end")&&c.hasClass("seat_category_end")&&(c.removeClass("group_end").removeClass("seat_category_end"),c.next(".external_membership").addClass("group_end").addClass("seat_category_end"));b.html(a)}else h(c);tools.dialog.hideDialog("loadingDialog")}).fail(function(){a.val("0");tools.dialog.hideDialog("loadingDialog")})):h(c)},k=function(a){$.each(a.find("input"),function(a,b){$(b).keypress(function(a){13===a.keyCode&&$(b).parent().find("a").trigger("click")})})},
m=function(a){var b=$(this);a=f.index(b);l(b);f.slice(a+1).each(function(){$(this).attr("data-verificationId")===$(b).attr("data-verificationId")&&l($(this))})};return{initMessages:function(e){a=e.lblNote;b=e.lblErrInvalidCard;c=e.lblErrAreadyUsedCard;d=e.lblErrNotEnoughCards},init:function(b){b&&this.initMessages(b);f=$(".quantity_to_verify");e=[];f.each(function(){var a=$(this).attr("data-verificationId");0>$.inArray(a,e)&&e.push(a)});e.length&&(tools.dialog.showWaitingPopup("loadingDialog",!0),
$.ajax({type:"GET",url:contextPath+"/ajax/selection/getAudSubCatVerification",data:{verificationIds:e}}).done(function(b){$("#external_membership_secondary_content").removeClass("hidden").find(".content").html(b);f.each(function(b){var c=$(this),d=c.attr("data-verificationId"),e=c.parent().parent();d=$.trim($("#external_membership_"+d+" .name").text())+": "+a;e.find(".tariff").prepend('<span class="external_membership_icon"></span>').attr("title",d);b||$("#membershipLegend").html('<span class="external_membership_icon"></span>'+
a).parents(".legend").removeClass("hidden");l(c);c.bind("change",m)});tools.dialog.hideDialog("loadingDialog")}).fail(function(){tools.dialog.hideDialog("loadingDialog")}))},getVerificationDescriptor:function(a){var b=[],c=[],d=[],e;for(e in a)if(a.hasOwnProperty(e)){var f=e.split("_")[1];var g=a[e];var h=g.externalVerification;h=h.id;var k=d.indexOf(h);-1===k?(d.push(h),b.push(f),c.push(g.count)):c[k]+=g.count}return{verificationIds:d,quantities:c,audSubCatIds:b}},initVerificationDialog:function(a,
b){var c=[],d=[],e=[];c={};var f=b?$("#verification_container_mobile"):$("#external_verification_block");membershipVerificationCommon.init(b);c=audSubCatVerification.getVerificationDescriptor(a);e=c.verificationIds;d=c.quantities;c=c.audSubCatIds;tools.dialog.showWaitingPopup("loadingDialog",!0);$.ajax({type:"GET",url:contextPath+"/ajax/selection/showMultiMemberCardList"+window.location.search,contentType:"application/json",data:{verificationIds:e,audSubCatIds:c,quantities:d}}).done(function(a){tools.dialog.hideDialog("loadingDialog");
$.trim(a)?(f.html(a),k(f),membershipVerificationCommon.handleKeyUp(f),membershipVerificationCommon.showVerificationDialog(b)):tools.dialog.showDialog("ajaxErrorDialog",!0)}).fail(function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)})},verify:function(a,d,e,f){var g=$("#card_number_"+e),h=$("#pin_code_"+e),k=$("#member_card_"+e+" .new"),l=$("#member_card_"+e+" .existing"),m=$("#existing_card_number_"+e);$.trim(g.val())?(f.parent().removeClass("continue").addClass("working").parent().addClass("validating"),
$.ajax({type:"POST",dataType:"json",url:contextPath+"/ajax/selection/verifyMemberCard",data:{verificationId:a,audSubCatId:d,cardNumber:g.val(),pinCode:h.val()}}).done(function(a){switch(a){case "INVALID":validation.showErrorTooltip(f,b);break;case "ALREADY_USED":validation.showErrorTooltip(f,c);break;default:m.val(g.val()),k.hide(),l.show()}f.parent().removeClass("working").addClass("continue").parent().removeClass("validating")}).fail(function(){f.parent().removeClass("working").addClass("continue").parent().removeClass("validating")})):
validation.showErrorTooltip(f,validationErrors.mandatory)},remove:function(a,b,c,d){var e=$("#member_card_"+c+" .new"),f=$("#member_card_"+c+" .existing"),g=$("#card_number_"+c),h=$("#pin_code_"+c);d.parent().removeClass("delete").addClass("working").parent().addClass("validating");$.ajax({type:"POST",dataType:"json",url:contextPath+"/ajax/selection/removeMemberCard",data:{verificationId:a,cardNumber:b}}).done(function(a){g.val("");h.val("");f.hide();e.show();$(".button.addWithValidation").addClass("disabled");
d.parent().removeClass("working").addClass("delete").parent().removeClass("validating")}).fail(function(){d.parent().removeClass("working").addClass("delete").parent().removeClass("validating")})},validateAllQuantities:function(a,b,c){var e=!0,g=b?$(".external_verification_container .card_number"):$(".external_membership .card_number"),h,k,m,p,q=[],u=[],r=[],D=[];$(".new.member_card_elem:visible").each(function(){h=$(this).attr("data-verificationId");k=$(this).attr("data-audsubcatid");m=$(this).find(".card_number").val();
p=$(this).find(".pin_code").val();if(""===m||""===p)return e=!1;q.push(h);u.push(k);r.push(m);D.push(p)});e?0<q.length?(tools.dialog.showWaitingPopup("requestProcessingDialog",!0),$.ajax({type:"GET",contentType:"application/json",url:contextPath+"/ajax/selection/validate"+window.location.search,data:{verificationIds:q,audSubCatIds:u,cardNumbers:r,pinCodes:D}}).done(function(h){tools.dialog.hideDialog("requestProcessingDialog");h||(e=h,b||f.each(function(){l($(this))}),a&&validation.showErrorTooltip(a,
d.replace("{0}",g.filter(":enabled").length)));c&&c(e)}).fail(function(){tools.dialog.hideDialog("requestProcessingDialog");c&&c(!1)})):c&&c(!0):(a&&validation.showErrorTooltip(a,d.replace("{0}",g.filter(":enabled").length)),c&&c(!1))}}});
tools.module("authorization",function(){return{init:function(){"visible"===document.visibilityState&&0!==window.innerWidth&&0!==window.innerHeight&&($("#loadingMessage").show(),setTimeout(function(){var a={};$("#confirmOptinForm").serializeArray().forEach(function(b){"authorizationCodes"===b.name||"producerNumbers"===b.name?(a[b.name]||(a[b.name]=[]),b.value&&a[b.name].push.apply(a[b.name],$jscomp.arrayFromIterable(b.value.split(",")))):a[b.name]=b.value});$.ajax({url:contextPath+"/ajax/authorization/opt-in/confirm",
type:"POST",contentType:"application/json",data:JSON.stringify(a),processData:!1,success:function(a){$("#loadingMessage").hide();"SUCCESS"===a.status?($("#successMessage").show(),$("#errorMessage").hide()):"ALREADY"===a.status?($("#alreadyMessage").show(),$("#errorMessage").hide()):"FAILED"===a.status&&$("#errorMessage").show()},error:function(){$("#loadingMessage").hide();$("#errorMessage").show()}})},2E3))}}});
tools.module("beneficiaries",function(){function a(){return D&&(D.forcePurchaserToOneTicketPerMatchDuringSales||D.activateBeneficiarySelector)}function b(a,b){var d;if((a=a.membership)&&a.length){for(d in b)if(-1<a.indexOf(String(b[d]).replace(/\s/g,""))){var e=d.split(".");e.splice(-1,1,"code");if("QU_EXB_BP"===b[e.join(".")]){e=b[[e[0],"movementId"].join(".")];x[e]=!1;c(!1);var f=f||e}}f&&$(function(){$("#set_beneficiary_"+f).trigger("click",!0)})}}function c(a){a?A.removeClass("disabled"):A.addClass("disabled");
u!==a&&(u=a)}function d(a,b){var c;for(c in a){var d=a[c];var f=b[c];if(!e(d)&&!e(f)&&("string"!==typeof d&&"string"!==typeof f&&d!==f||"string"===typeof d&&"string"===typeof f&&d.toLowerCase()!==f.toLowerCase()))return!1}return!0}function f(a,b,c){var d;for(d in a)if(!c||!c.includes(d)){var f=a[d];var g=b[d];if(!e(f)&&!e(g)&&(e(f)&&!e(g)||!e(g)&&e(f)||f!==g||"string"===typeof f&&"string"===typeof g&&f.toLowerCase()!==g.toLowerCase()))return!1}return!0}function e(a){return null===a||void 0===a||""===
a}function g(a){return{firstName:a.firstName,lastName:a.lastName,birthdayYear:a.birthdayYear||"0",birthdayMonth:h(a.birthdayMonth),birthdayDay:h(a.birthdayDay),countryCode:a.countryCode,idNumber:a.idNumber,birthPlace:a.birthPlace,birthRegion:a.birthRegion,title:a.title,residenceCountry:a.residenceCountry,isHistoryContact:a.isHistoryContact,ticketId:a.ticketId}}function h(a){if(a&&"0"!=a)for(;"0"===a.charAt(0);)a=a.substring(1);else a="0";return a}function l(a,b){$("select.beneficiary_selector").each(function(c,
d){c=d.attributes["data-movement-id"].value;Number($(d).val())===b&&account.beneficiary.form.updateBeneficiary(c,a)})}function k(b){var c,e="",h;var k=isMainOwner(b);if(!b.firstName&&!b.lastName)return-1;v[b.performanceId]||(v[b.performanceId]=[]);var m=v[b.performanceId];var p=g(b);var q=m.length;for(c=0;c<q;c++)if(d(m[c],p)||f(m[c],p,["isHistoryContact","ticketId"])){k=m[c];for(h in v)m=v[h],m[c]=$.extend({},m[c],p);inCheckout&&!a()&&(f(p,k,[])||l(b.movementId,c,p));if(a()){var A=[k.firstName,k.lastName].join(" ");
e=[p.firstName,p.lastName].join(" ");$('select.beneficiary_selector[data-ticket-id="'+b.ticketId+'"]').each(function(a,b){$(b).html($(b).html().replace(A,e))})}return c+1}c=getPerformancesIds();e=p.firstName+" "+p.lastName+(k?" ("+D.mainLabel+")":"");for(h in c){k=c[h];var C=k==b.performanceId?' disabled="disabled"':"";v[k]||(v[k]=[]);m=v[k];m[q]=p;a()&&$.each(getMatchTicketIdsFromPerformanceId(k),function(a,b){$("#printed_status_"+b+" .beneficiary_selector").append('<option value="'+(q+1)+'"'+C+
">"+e+"</option>")})}return q+1}function m(a,b,c){var d,e={},f={};var g=b.length;for(d=0;d<g;d++){var h=b[d];var l=h.name.split(".");if(3===l.length){var m=$('input[name="'+h.name+'"], select[name="'+h.name+'"]').parents(".beneficiary_questionnaire");m&&0!==m.length&&"none"===m.css("display")||(m=[l[0],l[1]].join("."),"code"===l[2]&&"QU_EXB_BD"!==h.value?e[h.value]=m:"answer"===l[2]?f[m]=h.value:"month"===l[2]?a.birthdayMonth=h.value:"day"===l[2]?a.birthdayDay=h.value:"year"===l[2]&&(a.birthdayYear=
h.value))}else-1!==["firstName","lastName"].indexOf(h.name)&&(a[h.name]=h.value)}if(b=f[e.QU_EXB_NA])a.countryCode=b;if(b=f[e.QU_EXB_ID])a.idNumber=b;if(b=f[e.QU_EXB_BP])a.birthPlace=b;if(b=f[e.QU_EXB_BR])a.birthRegion=b;if(b=f[e.Title])a.title=b;if(e=f[e.Country])a.residenceCountry=e;if(!0!==c)return a.isHistoryContact=!1,k(a)}function p(a){var b=$('select[data-movement-id="'+a+'"]').parents(".seat_category_section").parent().find("select.beneficiary_selector");0===b.length&&(b=$('select[data-movement-id="'+
a+'"]').parents(".seat_category_container").parent().find("select.beneficiary_selector"));return b}function q(b,c){var d,e=[],f=account.beneficiary.form.getMovementDefinitions();$.each(f,function(){this.performanceId!==c||this.isHistoryContact||(d=d&&0<d.length?d.add(p(this.movementId)):p(this.movementId))});void 0===d&&(d=p(b));a()&&d.each(function(a,b){$(b).find("option").each(function(a,b){b=$(b);a=b.html();b=b.val();a=(a=a&&-1!==a.indexOf(" - ")?a.substring(a.indexOf(" - "),0):a)&&-1!==a.indexOf(" ("+
D.mainLabel)?a.substring(a.indexOf(" ("+D.mainLabel),0):a;-1<b&&account.beneficiary.form.isLabelInHistory(a,c)&&e.push(b)})});d.each(function(a,b){a=$(b);a[0].value&&e.push(a[0].value)});d.each(function(a,b){a=$(b);var c=a[0].value;b=getConfiguration(b.getAttribute("data-ticket-id"));isMainOwner(b)&&"-1"!=a.val()?a.attr("disabled","disabled"):isPOENotAllowed(b)||b.firstName===b.contactFirstName||b.lastName===b.contactLastName?!b.hasAttachment&&b.isAllowPOEUpdate||""!==b.firstName||a.prop("disabled",
!1):a.prop("disabled",!1);a.find("option").each(function(a,b){a=$(b);b=a.html();var d=a.val();-1<d&&c!==d&&-1<e.indexOf(d)?(a.attr("disabled","disabled"),-1===b.indexOf(" - "+D.selectedLabel)&&a.html(b+" - "+D.selectedLabel)):(a.prop("disabled",!1),-1!==b.indexOf(" - "+D.selectedLabel)&&a.html(b.substring(b.indexOf(" - "+D.selectedLabel),0)))})})}function r(a){var b=a.target;var d=b.attributes["data-movement-id"].value;var e=b.attributes["data-ticket-id"].value;var f=account.beneficiary.form.getMovementDefinitions()[e||
d];var g=v[f.performanceId]?v[f.performanceId][$(b).val()-1]:void 0;account.beneficiary.form.setBeneficiary(d,e,g,a);b.value&&-1!==Number(b.value)||($(b).val(-1),x[d]=!1,q(d,f.performanceId),A&&(A.find("a").unbind().on("click",function(){return!1}),c(!1)));y(f,b.value)}function t(){var b=account.beneficiary.form.getMovementDefinitions(),c;if(a()){for(c in b){var e=b[c];if(!e.isHistoryContact){var f=$('select[data-movement-id="'+e.movementId+'"]');if(isMainOwner(e)||!e.allowUpdateTicketInfo||e.readOnlyBeneficiary||
e.isPrinted&&e.nonPrintableBeneficiaryModifiable||e.associatedMovements&&e.firstName&&e.lastName){if($('select[data-movement-id="'+e.movementId+'"]').attr("disabled","disabled"),!x[e.movementId]&&e.firstName&&e.lastName){var h=g(e);a:{var k,l=h,m=v[e.performanceId];var p=m.length;for(k=0;k<p;k++)if(h=m[k],d(l,h)){h=k+1;break a}h=void 0}0<=h&&(f.val(h),q(e.movementId,e.performanceId))}}else $('[id^="print_'+e.ticketId+'"').attr("onClick","").attr("href",""),$('[id^="print_'+e.movementId+'"').attr("onClick",
"").attr("href","");0<$("[data-movement-id="+e.ticketId+"] .printed_status .beneficiary_selector_label").not(".beneficiary_selector_hidden").filter(".not_printed_status,.already_printed_status").length||(e.isPrinted?$(".beneficiary_selector_printed_"+e.ticketId).removeClass("beneficiary_selector_hidden"):$(".beneficiary_selector_not_printed_"+e.ticketId).removeClass("beneficiary_selector_hidden"))}}$(".printed_status").css("margin-right","1em").css("min-width","unset");$("select.beneficiary_selector:not(.printed_without_owner)").on("change",
r)}}function w(a,b){var c=account.beneficiary.form.getMovementDefinitions();!0===a.readOnlyBeneficiary&&$.each(c,function(c,d){d.id===a.id||!0!==d.readOnlyBeneficiary||isPOENotAllowed(d)||m(d,b,!0)})}function y(a,b){var c=account.beneficiary.form.getMovementDefinitions(),d=a&&a.associatedMovements;-1!==b&&d&&d.length&&$.each(c,function(){0>$.inArray(this.movementId,d)||($('select[data-movement-id="'+this.movementId+'"]').val(b),q(this.movementId))})}function z(){var b=account.beneficiary.form.getMovementDefinitions(),
c;if(a()){for(c in b){var d=b[c];var e=getOriginalConfiguration(d.ticketId);d.firstName&&d.lastName&&(d.firstName=buildFirstNameAsFormatted(d.firstName),d.lastName=buildLastNameAsFormatted(d.lastName));var f=k(d);!e.isHistoryContact&&-1<f&&$('select[data-movement-id="'+d.movementId+'"]').val(f)}for(c in b)d=b[c],e=getOriginalConfiguration(d.ticketId),e.isHistoryContact||q(d.movementId,d.performanceId)}}var x={},A=null,C=[],u=!1,v={},D,E=function(){var a=null;$.each(C,function(b,c){if(null!==a)return!1;
x[c]||(a=c)});return a},F=function(){var a={},c=0;u&&($.each(account.beneficiary.form.getStoredBeneficiaryData(),function(b,d){$.each(d,function(b,d){b="ticketBeneficiaryFormModels["+c+"]."+d.name;"_csrf"===d.name?a[d.name]=d.value:jQuery.isEmptyObject(a[b])?a[b]=d.value:a[b]+=","+d.value});c++}),tools.dialog.showWaitingPopup("beneficiaryProcessingDialog",!0),$.ajax({url:contextPath+"/checkout/beneficiaries",type:"POST",cache:!1,data:a,success:function(c,d,e){c.success?window.location=contextPath+
"/checkout/deliveryModes":(tools.dialog.hideDialog("beneficiaryProcessingDialog"),"ERR_INVALID_MEMBERSHIP_NUMBER"===c.status?(c=c&&c.message&&c.message.split(",")||[],account.beneficiary.form.updateInvalidMembershipNumber(c,!0),b({membership:c},a)):tools.dialog.showDialog("ajaxErrorDialog",!0))},error:function(){tools.dialog.hideDialog("beneficiaryProcessingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}}))};return{init:function(a,b,d){D=d||{};x=a||{};A=b||$(" ");account.beneficiary.form.setSuccessfulBeneficiarySetCallback(beneficiaries.beneficiarySeized);
$(".ticket_formats_container[data-movement-id]").each(function(){C[C.length]=$(this).attr("data-movement-id")});var e=E();D.soldTickets||(null!==e?(A.find("a").unbind().on("click",function(){return!1}),D.forcePurchaserToOneTicketPerMatchDuringSales||$(function(){$("#set_beneficiary_"+e).trigger("click",!0)}),c(!1)):(c(!0),A.find("a").unbind().on("click",function(){window.location.href=contextPath+"/checkout/deliveryModes";return!1})));z();t();account.beneficiary.form.updateDisplayDatas()},beneficiarySeized:function(a,
b){var d=m(a,b);$('select[data-movement-id="'+a.movementId+'"]').val(d);account.beneficiary.form.updateContactInfo(a);w(a,b);q(a.movementId,a.performanceId);y(a,d);x[a.movementId]=!0;b=E();null===b||D.soldTickets?(c(!0),A.find("a").unbind().on("click",function(){F();return!1}),$("#set_beneficiary_"+a.movementId).offset()&&$("body,html").animate({scrollTop:$("#set_beneficiary_"+a.movementId).offset().top-50},400)):(c(!1),$("#set_beneficiary_"+b).trigger("click",inCheckout&&!D.forcePurchaserToOneTicketPerMatchDuringSales))},
refreshBeneficiarySelectors:q,isBeneficiarySelectorEnabled:a,resetBeneficiariesByPerformance:function(b){a()&&(v=[],$.each(getMatchTicketIdsFromPerformanceId(b.performanceId),function(a,b){x[b]=!1}));z();t()}}});
var buyer={lastTilte:"",remove:function(a,b){tools.dialog.showWaitingPopup("loadingDialog",!0);$.ajax({type:"POST",url:contextPath+"/pro/ajax/removeBuyer",data:{},success:function(c){b&&($("#buy_order").attr("href",a),$("#buyNow").attr("href",a),"undefined"!==typeof proceed2CheckoutFromCart&&proceed2CheckoutFromCart.forceNextPageUri(a));tools.dialog.hideDialog("loadingDialog");$("#main_content_buyer_box").hide()},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",
!0)}})},showContactOrStructureTag:function(){$("#buyer_box_infos").hide();$("#buyer_box_buttons").hide();$("#add_buyer_box_buttons").show();$(".contact_structure_selection").removeClass("hidden");this.lastTilte=$("#main_content_buyer_box > .content_title > .title > .title_text").html();this.changeTitle(buyerTitleChange)},showContactOrStructureTagFromCheckout:function(){$("#buyer_box_infos").hide();$("#buyer_box_buttons").hide();$(".contact_structure_selection").removeClass("hidden");$("#btn_cancel_add_buyer").parent().show();
$("#btn_continue").parent().addClass("disabled")},hideContactOrStructureTag:function(){orderContactSelection.cancelContact();orderContactSelection.return2ContactSearch();$("#add_buyer_box_buttons").hide();$(".contact_structure_selection").addClass("hidden");$("#buyer_box_infos").show();$("#buyer_box_buttons").show();$("#btn_add_buyer").parent().addClass("disabled");this.changeTitle(this.lastTilte)},hideContactOrStructureTagFromCheckout:function(){orderContactSelection.cancelContact();orderContactSelection.return2ContactSearch();
$(".contact_structure_selection").addClass("hidden");$("#buyer_box_infos").show();$("#buyer_box_buttons").show();$("#btn_cancel_add_buyer").parent().hide()},changeTitle:function(a){$("#main_content_buyer_box > .content_title > .title > .title_text").html(a)},updateBuyerDetailedInfo:function(a,b,c,d,f){$("#buyer_info_name_structure").html(a+" "+b+(null!==d?" / "+d:""));$("#buyer_info_email").html(c);$("#buyer_info_number").html(f)},changeBuyer:function(){$.ajax({type:"POST",url:contextPath+"/pro/ajax/buyer",
data:{contactNumber:$("#selected_contact").val(),email:$("#selected_email").val(),firstName:$("#selected_first_name").val(),lastName:$("#selected_last_name").val(),structureName:$("#selected_structureName").val()},success:function(a){tools.dialog.hideDialog("loadingDialog");buyer.hideContactOrStructureTag();buyer.changeTitle(buyerTitleSellingTo+" "+$("#selected_first_name").val()+" "+$("#selected_last_name").val());buyer.updateBuyerDetailedInfo($("#selected_first_name").val(),$("#selected_last_name").val(),
$("#selected_email").val(),$("#selected_structureName").val(),$("#selected_contact").val())},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}})},checkoutBuyerFormSubmit:function(){$("#buyer_form").submit()},checkoutBillingContactFormSubmit:function(){$("#billing_contact_form").submit()},addBuyer:function(a,b,c){$("#btn_continue").parent().hasClass("disabled")||this.checkoutBuyerFormSubmit()},addBillingContact:function(a){$("#btn_continue").parent().hasClass("disabled")||
this.checkoutBillingContactFormSubmit()},proceedWithNoUpdate:function(a){window.location.replace(a)},redirect2FilteredOrders:function(a){window.location.replace(a+"/account/orders?filter_type=buyer&buyer="+$("#buyer_info_number").html())},redirect2FilteredFiles:function(a){window.location.replace(a+"/account/files?filter_type=buyer&buyer="+$("#buyer_info_number").html())}};
tools.module("cached.cart",{init:function(){var a=util.cart.getCart();a?($("#cart_number_items").text(a.nbItems),$("#cart_total").text(a.amount+" "+a.currency),1<a.nbItems?$("#cart_several_items").removeClass("hidden"):$("#cart_single_item").removeClass("hidden"),$("#cart_with_items").removeClass("hidden")):$("#empty_cart").removeClass("hidden")}});
tools.module("cached.countdown",function(){var a=Date.now(),b="stx_WR_"+SecuTixConfig.institCode+"_"+SecuTixConfig.salesChannelCode,c=SecuTixLabels.countdown.hours,d=SecuTixLabels.countdown.minutes,f=SecuTixLabels.countdown.seconds,e=SecuTixLabels.countdown.and,g=!1,h=!0;return{init:function(){var l=tools.cookie.getItem(b);if(l){l=decodeURIComponent(l).split("|");var k=(new Date(l[0])).getTime();g="true"===l[1];h="true"===l[2];k>a&&(tools.countdown.setConfig({hours:c,minutes:d,seconds:f,and:e,countdownSeconds:(k-
a)/1E3,isWRCountdown:!0,isCartEmpty:h,hasQueue:g}),tools.countdown.startCountdown(),jQuery("#secondary_content_countdown").removeClass("hidden"))}}}});
tools.module("cached.event",{init:function(a){util.form.acquireCsrfToken("#event_form");util.form.linkAjaxPost({form:"#event_form",ajaxUrl:"/ajax/selection/event/submit?lang="+$("html").attr("lang"),securedUrl:"/secured/selection/event/submit",baseData:{preferredAreas:{}},processData:function(a){var b=a.eventFormData;delete a.crossSellFormModel;delete a._csrf;delete a.productId;for(a=0;a<b.length;a++)b[a]||b.splice(a--,1)},notificationHandler:function(a){jQuery("#event_form .submit-form-disabled").removeClass("submit-form-disabled").prop("disabled",
!1);"undefined"!==typeof conditionalRatesMessage&&conditionalRatesMessage.refreshConditionalRatesConfiguration();a&&setTimeout(function(){window.scrollTo(0,0)},10)},withCaptcha:a.withCaptcha})}});
tools.module("cached.header",{init:function(){var a=util.contact.getContact(),b=$("#account_account");a?(b.text(a.individualFirstName+" "+a.individualLastname),b.parent().removeClass("hidden"),$("#contact_name").removeClass("hidden"),$("#header_disconnect").removeClass("hidden"),$("#account_disconnect_separator").removeClass("hidden")):($("#account_account_signIn").parent().removeClass("hidden"),$("#account_account_register").parent().removeClass("hidden"))}});
tools.module("cached.pass",{init:function(a){util.form.acquireCsrfToken("#pass_form");util.form.linkAjaxPost({form:"#pass_form",ajaxUrl:"/ajax/selection/pass/submit",securedUrl:"/secured/selection/pass/submit",processData:function(a){var b;delete a.crossSellFormModel;delete a._csrf;a=a.passFormDatas;for(b=0;b<a.length;b++)a[b]||a.splice(b--,1)},notificationHandler:function(a){jQuery("#pass_form .submit-form-disabled").removeClass("submit-form-disabled").prop("disabled",!1);a&&setTimeout(function(){window.scrollTo(0,
0)},10)},withCaptcha:a.withCaptcha})}});
tools.module("catalog.goods.controller",function(){return{init:function(){var a=new catalog.goods.model.Catalog,b=new catalog.goods.model.Filters,c=new catalog.goods.view.View,d=function(a){return function(b){b.preventDefault();a.call(this,b)}},f=function(a){$("#goods_left_column, #goods_central_column").toggleClass("goods-choose-category",a)},e=function(a){$(".goods-search-form .search").toggle(!a);$(".goods-search-form .delete").toggle(a)},g=function(){$("#goods_filters").removeClass("show")},h=
null;$("#goods_back_to_top").hide();a.fetch().then(function(){var d;try{var e=/familyId=(.*)/.exec(History.getState().url);(d=a.families._map[e[1]])?b.familyId=d.id:History.replaceState({familyId:null},null,"?")}catch(m){}c.render(a,b);$(".goods-loading").removeClass("goods-loading");$("#goods_loading_indicator").hide()});$("#main_content_list_products_GOODS").on("click",".goods-family, .goods-breadcrumb-child",d(function(){var a=$(this).data("family-id");b.familyId=a;b.topicId=null;f(!1);History.pushState({familyId:b.familyId},
null,"?familyId="+a)}));$("#goods_breadcrumb .goods-breadcrumb-home, #goods_filters_back a").on("click",d(function(){b.familyId=null;b.topicId=null;History.pushState({familyId:null},null,"?")}));$("#goods_filters_sort").on("change",function(){b.sort=$(this).val();g();c.itemsView.render(a,b)});$("#goods_pagination .page.previous").on("click",d(function(){b.pagination.page--;c.itemsView.render(a,b);window.scrollTo(0,0)}));$("#goods_pagination").on("click",".page.page-link",d(function(){b.pagination.page=
$(this).data("page");c.itemsView.render(a,b);window.scrollTo(0,0)}));$("#goods_pagination .page.next").on("click",d(function(){b.pagination.page++;c.itemsView.render(a,b);window.scrollTo(0,0)}));$("#goods_back_to_top").on("click",d(function(){window.scrollTo(0,0)}));h=d(function(){var d=null;$(".goods-search-form input").each(function(){var a=$(this).val();a&&(d=a)});b.searchValue=d;b.search=diacritics.removeDiacritics(d).toUpperCase();e(!0);g();c.render(a,b)});$(".goods-search-form").on("submit",
h);$(".goods-search-form .search a").on("click",h);$(".goods-search-form, #goods_search_notification").find(".delete a").on("click",d(function(){b.searchValue=null;b.search=null;e(!1);$(".goods-search-form input").val("");g();c.render(a,b)}));$("#goods_filters_topic").on("change",function(){b.topicId=$(this).val();g();c.render(a,b);$("#goods_filters_topic_container .delete").toggleClass("show",!!b.topicId)});$("#goods_filters_topic_container .delete").on("click",d(function(){b.topicId=null;g();c.render(a,
b);$("#goods_filters_topic_container .delete").removeClass("show")}));$(".goods-category-general-title, .goods-category-general-subtitle").on("click",d(function(){f(!0);g()}));$("#goods_filters_mobile a").on("click",d(function(){$("#goods_filters").toggleClass("show")}));$("#goods_close_categories a").on("click",d(function(){f(!1)}));$("#goods_search_mobile input").on("keydown, keyup, change",function(){$("#goods_search input").val("")});$("#goods_search input").on("keydown, keyup, change",function(){$("#goods_search_mobile input").val("")});
$(window).on("resize",function(){g()}).on("scroll",function(){var a=!1,b=$("#goods_back_to_top");return function(){var c=1E3<$(this).scrollTop();c!==a&&((a=c)?b.stop().fadeIn():b.stop().fadeOut())}}());History.Adapter.bind(window,"statechange",function(){var d=History.getState();b.familyId=d.data.familyId;c.render(a,b)})}}});
tools.module("catalog.goods.model",function(){var a=jQuery.get,b=function(a,b){return a.rank!==b.rank?a.rank>b.rank?1:-1:a.name>b.name?1:a.name===b.name?0:-1},c=function(a,b){a.forEach(function(a){var d=a.childs;b.push(a);d&&c(d,b)});return b},d=function(a,d){d._map||(d._map={});Object.keys(a).forEach(function(c){var e=a[c],f=e.parent?a[e.parent]:null;e.id=parseInt(c,10);d._map[e.id]=e;f?(c=f.childs,c||(c=[],f.childs=c),c.push(e),c.sort(b),e.parent=f):d.push(e);d.sort(b)});d._flat=c(d,[])},f=function(a){var b=
functions.generateAmount;a.forEach(function(a){var c=a.minPrice,d=a.minPriceWithoutAdvantage;null!==d&&(a.viewMinPrice=b(d),d>c&&(a.viewMinPriceWithAdvantage=b(c)));a._searchName=diacritics.removeDiacritics(a.name).toUpperCase()})},e=function(a,b){if(!b)return null;b=a[b];a=[b.id];(b=b.childs)&&(a=a.concat(b.map(function(a){return a.id})));return a};var g=function(){this.topics=this.families=this.products=null};g.prototype.fetch=function(b){b=function(a){this.products=a.items;this.families=[];this.topics=
[];d(a.families,this.families);d(a.topics,this.topics);f(this.products)}.bind(this);return a(contextPath+"/ajax/list/goods").then(b,function(){tools.dialog.showDialog("ajaxErrorDialogReload",!0,!0)})};var h=function(){this.searchValue=this.search=this.familyId=this.topicId=null;this.sort="ALPHABET";this.pagination={page:1,displayWindow:2,nbPerPage:99}};h.prototype.getFilteredProducts=function(a,b){var c=e(a.families._map,this.familyId),d=this.search;b=!!b;return this._getSortedProducts(a.products.filter(function(a){return a.isStoreFrontProduct!==
b||c&&-1===c.indexOf(a.familyId)||d&&-1===a._searchName.indexOf(d)?!1:!0}))};h.prototype._getSortedProducts=function(a){return a.sort(function(a,c){return"PRICE_UP"===this.sort?a.minPrice-c.minPrice:"PRICE_DOWN"===this.sort?c.minPrice-a.minPrice:b(a,c)}.bind(this))};h.prototype.getTopics=function(a,b){var c=a.reduce(function(a,b){b=b.topicId;-1===a.indexOf(b)&&a.push(b);return a},[]);a=0;var d=c.length,e;if(1>=d)return null;for(a=0;a<d;a++)(e=b.topics._map[c[a]])&&e.parent&&(c.push(e.parent.id),d++);
return b.topics._flat.slice(0).filter(function(a){return-1!==c.indexOf(a.id)})};h.prototype.getTopicFilteredProducts=function(a,b){var c=e(b.topics._map,this.topicId);return c?a.filter(function(a){return-1!==c.indexOf(a.topicId)}):a};return{Catalog:g,Filters:h}});
tools.module("catalog.goods.view",function(){var a=null,b=null,c=null,d=null,f=null,e=function(a,b,c){a=Mustache.render(a,b,{});c&&$(c).html(a);return a};var g=function(){this.familiesView=new h;this.itemsView=new l};g.prototype.render=function(a,b){this.familiesView.render(a,b);this.itemsView.render(a,b)};var h=function(){};h.prototype.render=function(a,b){var c,g=b.familyId,h=$("#goods_breadcrumb");this.initialized||(this.initialized=!0,e(d,a,"#goods_families"));h.find(".goods-breadcrumb-child").remove();
$(".goods-family-highlight").removeClass("goods-family-highlight");$("#goods_category_title").toggleClass("goods-with-category",!!g);$("#goods_category_title, #goods_search_notification").toggleClass("goods-with-search",!!b.searchValue);$(".goods-category-title").text("");g?(a=a.families._map[g],(c=a.parent)&&h.append($(e(f,c))),h.append($(e(f,a))),$(".goods-family[data-family-id="+g+"]").addClass("goods-family-highlight"),g=a.name):g=$(".goods-breadcrumb-home").text();b.searchValue?$(".goods-category-search").text(b.searchValue):
$(".goods-category-search").text("");$(".goods-category-text").text(g)};var l=function(){};l.prototype.render=function(a,d){var f=d.getFilteredProducts(a),g=d.getTopics(f,a),h=d.getTopicFilteredProducts(f,a),k=$("#goods_list"),l=$("#goods_empty_list"),m=$("#goods_filters"),z=$(".goods-total-products"),x=$("#goods_filters_topic"),A=null;1===f.length?z.text(b.LABEL_PRODUCT_COUNT_SINGULAR):1<f.length?($("#goods_empty_list").hide(),z.text(b.LABEL_PRODUCT_COUNT_PLURAL.replace("{0}",f.length))):z.html("&nbsp;");
l.toggle(!h.length);m.toggleClass("hide",!h.length);k.html("");A=pagination.paginate(h,d.pagination);A.list.forEach(function(a){k.append($(e(c,a)))});pagination.updatePaginationWidget("#goods_pagination",A.view);$("#goods_filters_topic_container").toggle(!!g);g&&($("option",x).each(function(){var a=$(this);a.val()&&a.remove()}),g.forEach(function(a){var b=$(document.createElement("option")),c=a.id;b.text((a.parent?"- ":"")+a.name);b.val(c);String(d.topicId)===String(c)&&b.prop("selected",!0);x.append(b)}));
this.renderStoreFront(a,d);$(".goods-product-image").lazyload().one("appear",function(){var a=$(this);a.css("background-image","url('"+a.data("image")+"')")});setTimeout(function(){$(window).trigger("resize")},10)};l.prototype.renderStoreFront=function(a,b){a=b.getFilteredProducts(a,!0);var d=$("#goods_storefront_list");$("#goods_storefront").toggle(0<a.length);d.html("");a.forEach(function(a){d.append($(e(c,a)))})};return{init:function(e){a=e;b=a.labels;c=$("#goodsItemTpl").html();d=$("#goodsFamiliesTpl").html();
f=$("#goodsBreadcrumbElementTpl").html();e=b.LABEL_PRODUCT_SEARCH.replace("{1}","<span class='goods-category-text'></span>");e=e.replace("{0}","<span class='goods-category-search'></span>");$(".goods-category-title-extended").html(e)},View:g,FamiliesView:h}});
tools.module("communityTickets",function(){var a=!1,b=0,c=function(){var a=0;$('input[type="checkbox"]:checked',"#form_reservation_tickets").each(function(b,c){a+=Number($(c).data("amount"))});$("#totalAmount_amount").html(functions.generateAmount(a))},d=function(){var a=0;$(".table_container").each(function(){$(this).find("table tr","#form_reservation_tickets").each(function(){$(this).find('input[type="checkbox"]:checked').each(function(){a+=Number($(this).data("amount"))})});$(this).find("#subTotalAmount_amount").html(functions.generateAmount(a));
a=0})};return{init:function(b){a=b.isPartialPayPage;c();a&&d()},updateButtonState:function(){0<$('input[type="checkbox"]:checked',"#form_reservation_tickets").length?$("#submitTickets").closest(".button").removeClass("disabled"):$("#submitTickets").closest(".button").addClass("disabled");c();a&&d()},submitForm:function(){if($("#submitTickets").closest(".button").hasClass("disabled"))return!1;tools.form.submitWithProcessing($("#form_reservation_tickets"))},openPartialPayPopup:function(f){$(document).ready(function(){f?
($("#unable_partial_pay").show(),window.scrollTo(0,0)):(tools.dialog.showDialog("payTicketPartiallyDialog",!0,!1,communityTickets.closePartialPayDialog),b=$("#payTicketPartiallyDialog").width(),c(),a&&d())})},resetForm:function(){$('input[type="checkbox"]:checked',"#form_reservation_tickets").each(function(a,b){$(b).prop("checked",!1)})},toggleDisplaySubProducts:function(a,c){functions.toggleElementViewStatus(a,c);$("#payTicketPartiallyDialog").width()<b&&$("#payTicketPartiallyDialog").width(b)},
closePartialPayDialog:function(){var a;tools.dialog.hideDialog("payTicketPartiallyDialog");$("#payTicketPartiallyDialog .product_composition_container").each(function(){$(this).is(":visible")||($(this).show(),a=$(this).closest(".reserved_product").find(".subscribers_header .alternative_button"),a.removeClass("plus"),a.addClass("less"),a.attr("aria-expanded","true"))});$('input[type="checkbox"]:checked',"#form_reservation_tickets").each(function(a,b){$(b).prop("checked",!1)})}}});
tools.module("conditionalRatesMessage",function(){var a=null,b=null,c={},d={},f=function(a){var b,d;if(a){var e=Object.keys(a);var f=e.length;for(b=0;b<f;b++){var g=a[e[b]];for(d=0;d<g.requiredRateAudSubCatIds.length;d++){var h=c&&c[g.requiredRateAudSubCatIds[d]];h||(c[g.requiredRateAudSubCatIds[d]]={required:[]},h=c[g.requiredRateAudSubCatIds[d]]);-1===h.required.indexOf(e[b])&&h.required.push(e[b])}}}},e=function(a,c,d,e){var f;var g=$(".quantity",a).find('input[type="number"],input[type="text"],select');
var h=$(".quantity",a).find(".touch_friendly_qty_selection .button.minus");a=$(".quantity",a).find(".touch_friendly_qty_selection .button.plus");c&&r(g,"0");$(g).prop("disabled",c);if(b.preselectMaxQuantityAcrossCategories){var k=g.closest("tr").attr("data-conditionalrateid");var l=this.conditionalRatesData.find(function(a){return a.id===k});e&&!g.prop("disabled")&&l&&l.preselectMaxQuantity&&0<d&&(new Promise(function(a,b){a(g.change())})).then(function(){f=g.children().filter(function(){return"none"!==
$(this).css("display")});f.length&&r(g,f.last().val())})}0<a.length&&($(a).toggleClass("disabled",c),c&&$(h).addClass("disabled"))},g=function(a){var b,c=a.requiredRateAudSubCatIds.length,d,e,f={total:0,bySeatCategory:{}};for(b=0;b<c;b++){var g=a.crossSeatCategory?'[data-conditionalrateid$="_'+a.requiredRateAudSubCatIds[b]+'"]':'[data-conditionalrateid="'+a.prefixId+a.requiredRateAudSubCatIds[b]+'"]';$(".quantity",g).find('input[type="number"],input[type="text"],select').each(function(a,b){""!==$(b).val()&&
(d=Number($(b).val()),e=h($(b).closest("tr").attr("data-conditionalrateid")),f.total+=d,void 0===f.bySeatCategory[e]&&(f.bySeatCategory[e]=0),f.bySeatCategory[e]+=d)})}return f},h=function(a){a=a.split("_");return 3===a.length?a[0]:""},l=function(a,b){var c,d,e,f=a.requiredRateAudSubCatIds.length;for(c=0;c<f;c++)$("[data-conditionalrateid]").each(function(f,g){d=h($(g).attr("data-conditionalrateid"));-1!==$(g).attr("data-conditionalrateid").indexOf(a.requiredRateAudSubCatIds[c])&&$(".quantity",g).find('input[type="number"],input[type="text"],select').each(function(a,
c){""!==$(c).val()&&(e=Number($(c).val()),b.total+=e,void 0===b.bySeatCategory[d]&&(b.bySeatCategory[d]=0),b.bySeatCategory[d]+=e)})})},k=function(a,b){var c=0;$("[data-conditionalrateid]").each(function(d,e){(void 0!==b&&$(e).attr("data-conditionalrateid")===b||void 0===b&&-1!==$(e).attr("data-conditionalrateid").indexOf(a))&&$(".quantity",e).find('input[type="number"],input[type="text"],select').each(function(a,b){""!==$(b).val()&&(c+=Number($(b).val()))})});return c},m=function(a){var b=null,c;
$('tr[data-conditionalrateid^="'+a.prefixId+'"]').each(function(a,d){c=$("td.category",d);0<c.length&&""!==$(c).text().replace(/\s+/g,"")&&(b=$(c).text().replace(/\s+/g,""))});return b},p=function(){null!==b&&(a=b.conditionalRatesDataParam,f(b.crossSeatCategoryRates),conditionalRatesMessage.initStateSpecialRates(),d=b.messages,$(".quantity").find('select,input[type="number"],input[type="text"]').on("change",function(){var b=$(this).closest("tr");var d=$(b).data("conditionalrateid");if(c&&d&&c[d.split("_")[2]]){var f=
c[d.split("_")[2]];var g=f.required.length;for(d=0;d<g;d++){var k,m,p=f.required[d],u=[],r=a.length,D={total:0,bySeatCategory:{}};for(m=0;m<r;m++)-1!==a[m].id.indexOf(p)&&-1===u.indexOf(p)&&(u.push(p),l(a[m],D));for(m=0;m<r;m++)if(u=a[m],-1!==u.id.indexOf(p)){var E=u.specialAudSubCatIdsWithTriggerQuantities.length;for(k=0;k<E;k++){var F=u.specialAudSubCatIdsWithTriggerQuantities[k];var B=h(u.prefixId+F.audienceSubCatId);B=F.crossSeatCategory?D.total:D.bySeatCategory[B]||0;var G='[data-conditionalrateid="'+
u.prefixId+F.audienceSubCatId+'"]';e($(G),B<F.triggerQuantity,B,!0);B>=F.triggerQuantity&&(B=Math.floor(B/F.parentThreshold)*F.childRatio,q($(G),B))}}}}b.hasClass("conditional_group")&&conditionalRatesMessage.updateAppearanceState(this);conditionalRatesMessage.validateContionalQuantities(this)}),$(".dismiss_button").on("click",function(){$(".commercial_banner").slideUp()}),"true"===b.showCommercialBanner&&$(".commercial_banner").removeClass("hidden"),$(".banner_instruction",".commercial_banner").text(b.commercialMsg))},
q=function(a,b){a=$(".quantity.conditional_dependent_max_qty",a).find('input[type="number"],input[type="text"],select');0<a.length&&(b<parseInt(a.val(),10)&&r(a,b),a.children("option").each(function(a,c){$(c).show();parseInt($(c).val(),10)>b&&$(c).hide()}))},r=function(a,c){a.val(c);switch(b.productType){case "PACKAGE":packages.updatePrices();break;default:functions.updatePrices()}};return{init:function(a){b=a;$(function(){p()})},refreshConditionalRatesConfiguration:function(){p()},updateAppearanceState:function(b){var c=
a.length;b=$(b).closest("tr");var d=$(b).data("conditionalrateid");$("#proportionalQuantityError").remove();for(b=0;b<c;b++){var f=a[b];if(String(f.id)===String(d)){var k,l=f;var m=g(l);var p=l.specialAudSubCatIdsWithTriggerQuantities.length;for(k=0;k<p;k++){var r=l.specialAudSubCatIdsWithTriggerQuantities[k];f='[data-conditionalrateid="'+l.prefixId+r.audienceSubCatId+'"]';var t=h(l.prefixId+r.audienceSubCatId);t=r.crossSeatCategory?m.total:m.bySeatCategory[t]||0;e($(f),t<r.triggerQuantity,t,!1);
t>=r.triggerQuantity&&(t=Math.floor(t/r.parentThreshold)*r.childRatio,q($(f),t))}}}},validateContionalQuantities:function(c){var e,f;if(!a)return!0;var h=!0;$("#proportionalQuantityError").remove();var l={};var p=0;for(e=a.length;p<e;l={$jscomp$loop$prop$quantityFieldInPromise$36:l.$jscomp$loop$prop$quantityFieldInPromise$36},p++){var q=a[p];var u=$('tr[data-conditionalrateid="'+q.id+'"]');if(0!==u.length){u=$(u[0]);var v=$(".quantity.conditional_dependent_max_qty",u).find('input[type="number"],input[type="text"],select');
if(0!==v.length){var t=q.crossSeatCategory?k(q.subCatId):k(q.subCatId,q.id);var E=g(q);var F=Math.floor(E.total/q.specialAudSubCatIdsWithTriggerQuantities[0].parentThreshold);F*=q.specialAudSubCatIdsWithTriggerQuantities[0].childRatio;if(!b.preselectMaxQuantityAcrossCategories){var B=v.closest("tr").attr("data-conditionalrateid");B=$("tbody").find("[data-conditionalrateid^='"+B+"']").prevAll(".conditional_group_start")[0];var G=void 0;switch(b.productType){case "EVENT":case "SPORTING_EVENT":G="eventFormData";
break;case "PACKAGE":G="packageQuantities";break;default:G=""}B=$(B).find('input[type="number"],input[type="text"],select[id^=\''+G+"']");B.length&&c&&c.id===B[0].id&&!v.prop("disabled")&&q.preselectMaxQuantity&&0<B.val()&&(l.$jscomp$loop$prop$quantityFieldInPromise$36=v,(new Promise(function(a){return function(b,c){b(a.$jscomp$loop$prop$quantityFieldInPromise$36.change())}}(l))).then(function(a){return function(){f=a.$jscomp$loop$prop$quantityFieldInPromise$36.children().filter(function(){return"none"!==
$(this).css("display")});f.length&&r(a.$jscomp$loop$prop$quantityFieldInPromise$36,f.last().val())}}(l)))}0<F&&t>F&&($(".table_container #proportionalQuantityError").length&&$(".table_container #proportionalQuantityError").remove(),v=$("#notification").clone().attr("id","proportionalQuantityError").removeClass("hidden"),t=m(q),E=1===E.total?q.crossSeatCategory||null===t?d.proportionalMaxQuantityWithoutSeatCatSingle:d.proportionalMaxQuantityWithSeatCatSingle:q.crossSeatCategory||null===t?d.proportionalMaxQuantityWithoutSeatCatPlural:
d.proportionalMaxQuantityWithSeatCatPlural,E=E.replace("{0}",F),E=E.replace("{1}",$(".audience-subcat-name",u).text()),E=E.replace("{2}",t),$(".message .content",v).text(E),$(u).closest(".table_container").prepend(v),h=!1)}}}return h},initStateSpecialRates:function(){$(".quantity",".promotion_rate").find('input[type="number"],input[type="text"],select').each(function(a,b){conditionalRatesMessage.updateAppearanceState(b)})}}}());
tools.module("confirmation",function(){var a=null,b=function(c){$.ajax({type:"GET",url:contextPath+"/ajax/checkout/isOrderClosed",cache:!1,success:function(d){var e=function(a,b){a.removeAttr("role");b.attr("role","alert");a.fadeOut("fast",function(){b.fadeIn("fast")})};if(!0===d){d=$("#confirmation_polling");var f=$("#confirmation_order_closed");var l=$("#confirmation_generating_tickets");l.removeAttr("role");e(d,f)}else c<a.length-1?setTimeout(function(){b(c+1)},a[c+1]):(d=$("#confirmation_polling"),
f=$("#confirmation_polling_stop"),e(d,f));util.storeSession.removeSessionStorage()}})},c=function(){var a=$("#confirmation_generating_tickets");0<a.length&&(a.attr("role","alert"),$("#confirmation_processing_order").fadeOut("fast",function(){a.fadeIn("fast")}))},d=function(){var a=$("#confirmation_three_points");setTimeout(function(){d()},300);switch(a.text().length){case 1:a.html(". .");break;case 3:a.html(". . .");break;case 5:a.html("");break;default:a.html(".")}};return{initBookingTag:function(a){$("<iframe>",
{src:a,frameBorder:0,width:1,height:1,style:"display:none"}).prependTo("body")},initPolls:function(f){a=f;setTimeout(function(){b(0)},a[0]);setTimeout(function(){c()},2500);d()},ejectFromTS:function(){$.ajax({type:"GET",url:contextPath+"/ajax/wr/eject"})},logOutAndRedirect:function(a){$.ajax({url:contextPath+"/ajax/checkout/logOutAndRedirect",type:"POST",cache:!1,async:!1,indexValue:a,success:function(){window.location.replace(contextPath+("/account/reset?emailAndRedirectToLoginPage="+this.indexValue))},
error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}})}}});
var contact;
function NS_contact(){this.delivery=new function(){var a,b,c;var d=["BY_MAIL","BY_RECOMMANDED_MAIL","DHL","FEDEX"];this.orderSummaryLocked=this.isHackShipmentMode=this.deliveryModesScreen=!1;this.contactAddresses={};this.isRevertVatAvailable=!1;this.lastHackDeliveryMode=this.lastGoodsDeliveryMode=this.lastDeliveryMode=this.contactEmail=this.editLink="";this.submitDeliveryModeForm=function(){$("#notification_delivery_address").hide();$("#notification_missing_shipment_mode_selection").hide();$("#notification_invalid_collection_date").hide();
$("#notification_collection_date_out_of_range").hide();$("#notification_collection_time_out_of_range").hide();0<$('input[type="radio"][name="shipmentModeId"]').length&&0===$('input[type="radio"][name="shipmentModeId"]:checked').length||0<$('input[type="radio"][name="goodsShipmentModeId"]').length&&0===$('input[type="radio"][name="goodsShipmentModeId"]:checked').length||0<$('input[type="radio"][name="hackShipmentModeId"]').length&&0===$('input[type="radio"][name="hackShipmentModeId"]:checked').length?
($("#notification_missing_shipment_mode_selection").show(),window.scrollTo(0,0)):(0<$('input[name="goodsShipmentModeId"]:checked').length&&(contact.delivery.lastDeliveryMode=$('input[name="goodsShipmentModeId"]:checked').attr("attr-type"),$("#goodsShipmentModeType").val(contact.delivery.lastDeliveryMode)),0<$('input[name="hackShipmentModeId"]:checked').length&&(contact.delivery.lastHackDeliveryMode=$('input[name="hackShipmentModeId"]:checked').attr("attr-type"),$("#hackShipmentModeType").val(contact.delivery.lastHackDeliveryMode)),
0<=$.inArray(contact.delivery.lastDeliveryMode,d)&&"undefined"===typeof contact.delivery.getSelectedContactId()||0<=$.inArray(contact.delivery.lastGoodsDeliveryMode,d)&&""===this.getSelectedGoodsContactAddress()||0<=$.inArray(contact.delivery.lastHackDeliveryMode,d)&&""===this.getSelectedHackContactAddress()?($("#notification_delivery_address").show(),window.scrollTo(0,0)):validateCollectionDate()?0<$(".pickup_person_block").length&&("HANDED_POSTPONED"===contact.delivery.lastDeliveryMode||"LEFT_AT_CONTROL"===
contact.delivery.lastDeliveryMode)?editPickupPerson.savePickupPerson($("#delivery_modes_form")):$("#delivery_modes_form").submit():window.scrollTo(0,0))};validateCollectionDate=function(){var b=$("#collection-date_"+a);var c=$("#collection-time_"+a);if(b&&c&&0<b.length&&0<c.length){var d=b[0].required||c[0].required;var e=""===b[0].value||""===c[0].value;var f=""!==b[0].value||""!==c[0].value;if(d&&e||!d&&e&&f)return $("#notification_invalid_collection_date").show(),!1;e=b[0].value.split("-");d=b[0].min.split("-");
f=b[0].max.split("-");e=new Date(Date.UTC(e[0],e[1],e[2]));d=new Date(Date.UTC(d[0],d[1],d[2]));f=new Date(Date.UTC(f[0],f[1],f[2]));if(e<d||e>f)return $("#notification_collection_date_out_of_range").show(),!1;f=c[0].value.split(":");var p=c[0].min.split(":");d=c[0].max.split(":");e=new Date;f=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDay(),f[0],f[1]));p=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDay(),p[0],p[1]));e=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDay(),d[0],
d[1]));if(f<p||f>e)return $("#notification_collection_time_out_of_range").show(),!1;e=$(".collectionDate");e.val(b[0].value);b=$(".collectionTime");b.val(c[0].value)}return!0};this.getSelectedContactId=function(){return $("select.cc01 option:selected").val()};this.getSelectedGoodsContactAddress=function(){return $("#goodsContactAddressId")?$("#goodsContactAddressId").val():""};this.getSelectedHackContactAddress=function(){return $("#hackContactAddressId")?$("#hackContactAddressId").val():""};var f=
function(a,b){b=$(".delivery_address-"+b);b.find(".address").html(a.formattedAddress);a.formattedContact?(b.find(".shipping_contact_info").html(a.formattedContact),b.addClass("with_contact_info")):(b.find(".shipping_contact_info").html(""),b.removeClass("with_contact_info"))};var e=function(a){var b=$(".delivery_address-"+a);b.find(".cc01").show();$("select",b).prop("disabled",!0);contact.delivery.orderSummaryLocked||b.find(".cc01").prop("disabled",!1);b.find(".shipping_address").show();b.find(".button_container").show();
b.find(".shipping_contact_email").hide();contact.delivery.setCurrentAddress(a)};this.showContainer=function(a){$(".delivery_address-"+a).show()};this.recomputeVat=function(){this.isRevertVatAvailable&&(window.location.href=contact.delivery.checkoutSummaryUrl+"?billingAddressId="+$(".cc01").val())};this.setCurrentAddress=function(a){var d=this.contactAddresses[a];shipment_mode_id=a;if(!(void 0===d||0>=d.length)){var e=$(".delivery_address-"+a).find(".cc01")[0].selectedIndex;e=d[e];f(e,a);edit_contact_address_id=
e.addressId;$("#"+a+"_shipmentContactNumber,#billingContactNumber").val(e.shipmentContactNumber);b="";0<$('input[name="goodsShipmentModeId"]:checked').length&&(b=$('input[name="goodsShipmentModeId"]:checked').val(),Number(b)===a&&$("#goodsContactAddressId").val(e.addressId));c="";0<$('input[name="hackShipmentModeId"]:checked').length&&(c=$('input[name="hackShipmentModeId"]:checked').val(),Number(c)===a&&$("#hackContactAddressId").val(e.addressId))}};this.showShippingAddressForm=function(f,h,l,k){a=
$('input[name="shipmentModeId"]:checked').val();b="";0<$('input[name="goodsShipmentModeId"]:checked').length&&(b=$('input[name="goodsShipmentModeId"]:checked').val());c="";0<$('input[name="hackShipmentModeId"]:checked').length&&(c=$('input[name="hackShipmentModeId"]:checked').val());$(".delivery_address").filter(function(d,e){return!$(e).hasClass("delivery_address-"+a)&&!$(e).hasClass("delivery_address-"+b)&&!$(e).hasClass("delivery_address-"+c)}).each(function(a,b){$("select",b).prop("disabled",
!0);$(b).hide()});0<=$.inArray(f,d)?(this.showContainer(h),e(h),l&&$("#goodsContactAddressId").val($(".cc01",".delivery_address-"+h).val()),k&&$("#hackContactAddressId").val($(".cc01",".delivery_address-"+h).val())):(shipment_mode_id=h,edit_contact_address_id="",l&&$("#goodsContactAddressId").val(""),k&&$("#hackContactAddressId").val(""))};this.updateGoodsShipmentModes=function(b,c,d){var e=!1;d||$('input[name="goodsShipmentModeId"]').each(function(d,f){0<=$.inArray(Number($(f).val()),b)?($(f).prop("disabled",
!1),$(f).parent().removeClass("disabled"),$(f).val()!==a||c||($(f).prop("checked",!0),contact.delivery.setGoodsDeliveryMode($(f).attr("attr-type"),$(f).val()),e=!0)):($(f).attr("disabled","disable"),$(f).parent().addClass("disabled"))});e||c||((d=$('input[name="goodsShipmentModeId"]').filter(function(a,b){return!$(b).is(":disabled")&&"true"===$(b).attr("attr-externalProvider")}).first())&&0!==d.length||(d=$('input[name="goodsShipmentModeId"]').filter(function(a,b){return!$(b).is(":disabled")}).first()),
$(d).prop("checked",!0),contact.delivery.setGoodsDeliveryMode($(d).attr("attr-type"),$(d).val()))};this.setDeliveryMode=function(a,b,c,d){contact.delivery.lastDeliveryMode=a;this.showShippingAddressForm(a,b);$("#shipmentModeType").val(a);this.handlePickupPersonForm(a,b);$('input[name="shipmentModeId"]').each(function(a,c){$(c).val()===String(b)&&$(c).prop("checked",!0)});0<$("#goodsShipmentModeType").length&&this.deliveryModesScreen&&!this.isHackShipmentMode&&contact.delivery.ajax.showGoodsShipmentModes(b,
a,c,this.updateGoodsShipmentModes,d)};this.setGoodsDeliveryMode=function(a,b,c){contact.delivery.lastGoodsDeliveryMode=a;this.showShippingAddressForm(a,b,!0);$("#goodsShipmentModeType").val(a);c&&$('input[name="goodsShipmentModeId"]').each(function(a,c){$(c).val()===String(b)&&$(c).prop("checked",!0)})};this.setHackDeliveryMode=function(a,b){contact.delivery.lastHackDeliveryMode=a;this.showShippingAddressForm(a,b,!0);$("#hackShipmentModeType").val(a);$('input[name="hackShipmentModeId"]').each(function(a,
c){$(c).val()===String(b)&&$(c).prop("checked",!0)})};this.handlePickupPersonForm=function(a,b){var c=$(".pickup_person_block");0<c.length&&("HANDED_POSTPONED"===a||"LEFT_AT_CONTROL"===a?(a=$(".delivery_mode_description_"+b),0===a.find(".pickup_person_block").length&&c.detach().appendTo(a),c.removeClass("hidden")):c.addClass("hidden"))};this.lockScreen=function(){$("select").attr("disabled","disabled");$("input:not([name='_csrf'])").attr("disabled","disabled");$("form").each(function(){this.reset()})};
this.editContactAddress=function(a,b){a+="&shipmentModeId="+shipment_mode_id;window.location.href=this.buildAddtionalAddressUrlParameters(a+"&edit=true",b)};this.newContactAddress=function(a,b){a+="&shipmentModeId="+shipment_mode_id;window.location.href=this.buildAddtionalAddressUrlParameters(a,b)};this.buildAddtionalAddressUrlParameters=function(d,e){a=$('input[name="shipmentModeId"]:checked').val();b="";0<$('input[name="goodsShipmentModeId"]:checked').length&&(b=$('input[name="goodsShipmentModeId"]:checked').val());
c="";0<$('input[name="hackShipmentModeId"]:checked').length&&(c=$('input[name="hackShipmentModeId"]:checked').val());var f=0<$("#newShippingContact_contactNumber_"+e).length?$("#newShippingContact_contactNumber_"+e):$("#"+e+"_shipmentContactNumber");0<f.length&&(d+="&shipmentContactNumber="+f.val());f=$("#billingContactNumber");0<f.length&&(d+="&billingContactNumber="+f.val());d+="&contactAddressId="+edit_contact_address_id;0<e&&(e===a&&(d+="&ticketingShipmentAddress=true"),e===b&&(d+="&goodsShipmentAddress=true"),
e===c&&(d+="&hackShipmentAddress=true"));return d};this.ajax=new function(){var a=function(a,b,c){"abort"!==c&&tools.dialog.showDialog("ajaxErrorDialog",!0)};this.showGoodsShipmentModes=function(b,c,d,e,f){$.ajax({url:contextPath+"/ajax/checkout/deliveryModes/getGoodsShipmentModes",type:"POST",data:{ticketingShipmentModeId:b,ticketingShipmentModeType:c},cache:!1}).done(function(a){return e(a,d,f)}).fail(a)}}}}contact=new NS_contact;
tools.module("contact.addFriendOrFamily",function(){var a,b,c,d,f=!1,e=function(a){0<$(a).length&&$(a).val("")},g=function(){a?($("#cancelExistingButton").parent().addClass("disabled"),$("#saveExistingButton").parent().addClass("disabled"),$("#cancelNewButton").parent().removeClass("disabled"),$("#saveNewButton").parent().removeClass("disabled")):($("#cancelNewButton").parent().addClass("disabled"),$("#saveNewButton").parent().addClass("disabled"),$("#cancelExistingButton").parent().removeClass("disabled"),
$("#saveExistingButton").parent().removeClass("disabled"))},h=function(){$("#notification_save_error").hide();$("#notification_validate_mandatory_field_empty").hide();$("#notification_validate_email_invalid").hide();$("#notification_email_required_for_account").hide();$("#notification_invalid_birthdate").hide();$("#notification_validate_zipcode").hide();$("#notification_validate_zipcode_too_long").hide();$("#notification_validate_zipcode_invalid").hide();$("#notification_validate_address_line_too_long").hide();
$("#notification_not_accept_privacy").hide();$("#existingContactForm").find(".field, input").removeClass("error");$("#newContactForm").find(".field, input").removeClass("error");$("#existingContactForm").find(".allowed_chars_error").remove();$("#newContactForm").find(".allowed_chars_error").remove()},l=function(){$("#existingContactForm").find(".field, input").removeClass("error");$("#existingContactForm")[0].reset()},k=function(){$("#newContactForm").find(".field, input").removeClass("error");$("#newContactForm")[0].reset();
e("#address_country");e("#phone_prefix");e("#mobile_prefix")},m=function(b){if(!0!==a||!0===b)a=!0,l(),h(),g(),$("#view_new_form").closest(".navigator").removeClass("show"),$("#new_contact_form").removeClass("hide"),$("#new_contact_form_button_container").removeClass("hide"),$("#view_existing_form").closest(".navigator").removeClass("hide"),$("#existing_contact_form").removeClass("show"),$("#existing_contact_form_button_container").removeClass("show"),$("#view_new_form").closest(".navigator").addClass("hide"),
$("#new_contact_form").addClass("show"),$("#new_contact_form_button_container").addClass("show"),$("#view_existing_form").closest(".navigator").addClass("show"),$("#existing_contact_form").addClass("hide"),$("#existing_contact_form_button_container").addClass("hide")},p=function(b){if(!1!==a||!0===b)a=!1,k(),h(),g(),$("#view_new_form").closest(".navigator").removeClass("hide"),$("#new_contact_form").removeClass("show"),$("#new_contact_form_button_container").removeClass("show"),$("#view_existing_form").closest(".navigator").removeClass("show"),
$("#existing_contact_form").removeClass("hide"),$("#existing_contact_form_button_container").removeClass("hide"),$("#view_new_form").closest(".navigator").addClass("show"),$("#new_contact_form").addClass("hide"),$("#new_contact_form_button_container").addClass("hide"),$("#view_existing_form").closest(".navigator").addClass("hide"),$("#existing_contact_form").addClass("show"),$("#existing_contact_form_button_container").addClass("show")},q=function(a,b){return void 0!==a&&void 0!==a[b]&&a[b]},r=function(){var b,
c={};if(a){var d=$("#newContactForm").serializeArray();for(b=0;b<d.length;b++){var e=d[b];c[e.name]=e.value}c.isCreateAccount=$("#isCreateAccount").is(":checked");c.country=$("#address_country").val();c.phonePrefix=$("#phone_prefix").val();c.mobilePrefix=$("#mobile_prefix").val();return c}return{contactNumber:$("#existingContactNumber").val(),lastname:$("#existingLastName").val(),isCreateAccount:!1,token:$("#registerFormModel").find("input[name=_csrf]").val()}},t=function(){var a=r(),d;tools.dialog.showWaitingPopup("loadingDialog",
!0);$.ajax({type:"POST",url:contextPath+b,data:a,success:function(b){tools.dialog.hideDialog("loadingDialog");b.errorMessage?($("#notification_save_error","#add_family_contact_form").find(".error_message").html(b.errorMessage),$("#notification_save_error").show(),g(),window.scrollTo(0,0)):b.contact?(tools.dialog.hideDialogAndDestroy("add_family_contact_form"),"function"===typeof c&&(d=void 0!==$("#distribute_ticket_fileId").val()?$("#distribute_ticket_fileId").val():"",c(b.contact,d,a))):tools.dialog.showDialog("sessionExpiredDialog",
!0)},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0);g()}})};return{init:function(e){b=e.saveUrl;c=e.saveCallback;d=e.screenConfigMap;f=e.enableContactAddress;$("input","#existingContactForm").bind("focus",function(){p()});$("input","#newContactForm").bind("focus",function(){m()});$("#isCreateAccount").on("click",function(){$("#isCreateAccount").is(":checked")?$("#purchaserDuty").hide(50):$("#purchaserDuty").show(50)});$("#cancelExistingButton, #cancelNewButton").unbind("click").bind("click",
function(a){a.preventDefault();$(this).parent().hasClass("disabled")||tools.dialog.hideDialogAndDestroy("add_family_contact_form")});$("#saveNewButton, #saveExistingButton").unbind("click").bind("click",function(b){b.preventDefault();if(!$(this).parent().hasClass("disabled")){$("#cancelNewButton").parent().addClass("disabled");$("#saveNewButton").parent().addClass("disabled");$("#cancelExistingButton").parent().addClass("disabled");$("#saveExistingButton").parent().addClass("disabled");var c={rule:validation.rules.mandatory,
errorId:"notification_validate_mandatory_field_empty"};h();if(a){b=validation.validateFields([{fieldId:"newFirstName",rules:[c]},{fieldId:"newLastName",rules:[c]}],!0);q(d,"email")&&(b=validation.validateFields([{fieldId:"newEmail",rules:[c]}],!0)&&b);b&&$("#isCreateAccount").is(":checked")&&(b=validation.validateFields([{fieldId:"newEmail",rules:[{rule:validation.rules.mandatory,errorId:"notification_email_required_for_account"}]}],!0));q(d,"civility")&&"undefined"===typeof $("input[name=title]:checked").val()&&
"undefined"===typeof $("select[id=title]").val()&&($("#field_title").addClass("error"),$("#notification_validate_mandatory_field_empty").show(),b=!1);b&&void 0!==d&&void 0!==d.email&&""!==$("#newEmail").val()&&(b=validation.validateFields([{fieldId:"newEmail",rules:[{rule:validation.rules.email,errorId:"notification_validate_email_invalid"}]}],!0));var e=!0;c=$("#day").val();var k=$("#month").val();var l=$("#year").val();q(d,"birthdate")?"0"===c||"0"===k||"0"===l?($("#field_birthdate").addClass("error"),
e=!1):account.register.checkBirthdate()&&account.register.checkBirthdayInThePast()||($("#notification_invalid_birthdate").show(),e=!1):"0"===c&&"0"===k&&"0"===l||"0"!==c&&"0"!==k&&"0"!==l&&account.register.checkBirthdayInThePast()||($("#field_birthdate").addClass("error"),$("#notification_invalid_birthdate").show(),e=!1);b=e&&b;f&&(account.register.checkContactAddressMandatoryFields(d)?(b=account.register.checkAddressLinesLength()&&b,b=account.register.checkZipCode()&&b):(b=!1,$("#notification_validate_mandatory_field_empty").show()));
account.register.checkPhoneFields(d,!1)?b=account.register.validatePhoneNumbers()&&b:(b=!1,$("#notification_validate_mandatory_field_empty").show());0<$("#privacyPolicyAccepted").length&&!$("#privacyPolicyAccepted").is(":checked")&&(b=!1,$("#notification_not_accept_privacy").show());b&&((b=account.register.validateAllowedCharacters("#newContactForm"))||account.register.scrollToErrorMessage())}else b=validation.validateFields([{fieldId:"existingContactNumber",rules:[c]},{fieldId:"existingLastName",
rules:[c]}],!0);account.register.checkPobFields(d,b)||(b=!1);b?t():g()}});$("#address_country, #phone_prefix, #mobile_prefix, #day, #month, #year").bind("focus",function(){m()});$("#view_new_form").unbind("click").bind("click",function(a){a.preventDefault();m(!0)});$("#view_existing_form").unbind("click").bind("click",function(a){a.preventDefault();p(!0)})},showForm:function(){h();k();l();tools.dialog.showDialog("add_family_contact_form",!0,!0);p(!0)}}});
tools.module("contact.contactList",function(){var a,b=!1,c,d,f,e;removeContactAjax=function(a,b){tools.dialog.showWaitingPopup("loadingDialog",!0);$.ajax({type:"POST",url:contextPath+b,data:a,success:function(a){handleResponseMessage(a.status,a.statusCode)},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}})};updateWarningRemoveMemberMessage=function(a){var b=$("#warning-remove-member-message > .content > .icon");a=d.replace("{0}",a.email).replace("{1}",
a.structureOfficialName);$("#warning-remove-member-message > .content").empty().append(b).append(a);$("#subgrouping_message_relay_has_order").hide()};handleResponseMessage=function(a,b){var c=!0;switch(b?b:a){case "success":$("#searchCriteria").submit();break;case "error.contact.wrongContactNumber":tools.dialog.showDialog("error_remove_member_wrong_number",!0);break;case "OK":c=!1;window.location.href=tools.setParameterToUrl(window.location.href,"relayRemovedMessage","true",!1);break;case "ERR_RELAY_HAS_ORDER":$("#subgrouping_message_relay_has_order").show();
break;case "ERR_RELAY_NO_PERMISSION":$("#subgrouping_message_no_permission").show();break;default:tools.dialog.showDialog("ajaxErrorDialog",!0)}c&&tools.dialog.hideDialog("loadingDialog")};clearInfoMessages=function(){b&&($("#subgrouping_message_contact_created").hide(),$("#subgrouping_message_contact_substructure_created").hide(),$("#subgrouping_message_relay_removed").hide(),$("#subgrouping_message_relay_has_order").hide(),$("#subgrouping_message_contact_updated").hide(),$("#subgrouping_message_no_permission").hide())};
validateMinLengthField=function(a){return $("#"+a).val()?validation.validateField(a,[{rule:$.extend({tooltipError:$("#notification_validate_length_min_two > .content").html()},validation.rules.minLength2)}],null,!0):!0};requestConsentAjax=function(a,b){$.ajax({type:"POST",url:contextPath+b,data:a,success:function(a){handleResponseMessage(a.status,a.statusCode)},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}})};return{init:function(a){b=a.isSubGrouping;
c=a.contactList;d=a.customRemoveMessage;f=a.validateMinLength},showEditContactForm:function(a,d){if(b)tools.dialog.showWaitingPopup("loadingDialog",!0),window.location.href=contextPath+d+"?contactNumber="+c[a].contactNumber;else{clearInfoMessages();if(void 0!==a){d=$("#firstName-"+a).val();var e=$("#lastName-"+a).val();var f=$("#email-"+a).val()}else d=$("#fNameCriteria").val(),e=$("#lNameCriteria").val(),f=$("#emailCriteria").val();a=$("#contactNumber-"+a).val();contact.editContactCommon.showEditContactForm({firstName:d,
lastName:e,email:f,contactNumber:a})}},search:function(){var a=[];clearInfoMessages();$("#emailCriteria").val()&&a.push(validation.validateField("emailCriteria",[{rule:$.extend({tooltipError:$("#notification_validate_email_invalid > .content").html()},validation.rules.email)}],null,!0));f&&(a.push(validateMinLengthField("subStructureCriteria")),a.push(validateMinLengthField("fNameCriteria")),a.push(validateMinLengthField("lNameCriteria")));a.filter(function(a){return!a}).length||(tools.dialog.showWaitingPopup("loadingDialog",
!0),$("#searchCriteria").submit())},showDeleteContactPopup:function(d){a=d;b&&updateWarningRemoveMemberMessage(c[d]);tools.dialog.showDialog("warning_remove_member",!0)},deleteContact:function(d){var e=b?{contactNumber:c[a].contactNumber,subStructureNumber:c[a].subStructureNumber}:{contactNumber:$("#contactNumber-"+a).val()};removeContactAjax(e,d)},redirectToNewContact:function(a){window.location.href=contextPath+a},showResentConsentEmailPopup:function(a){e=a;tools.dialog.showDialog("warning_resend_consent_email",
!0)},requestConsent:function(a){var b={contactNumber:$("#contactNumber-"+e).val(),contactConnectionId:$("#request-consent-contact-connection-id-"+e).val()};requestConsentAjax(b,a)}}});
tools.module("contact.editContactCommon",function(){var a=function(){$("#notification_save_error").hide();$("#notification_validate_mandatory_field_empty").hide();$("#notification_validate_email_invalid").hide();$("#edit_structure_member_form").find(".field, input").removeClass("error")},b=function(a,b,f){tools.dialog.showWaitingPopup("loadingDialog",!0);$.ajax({type:"POST",url:contextPath+b,data:{firstName:a.firstName,lastName:a.lastName,email:a.email,contactNumber:a.contactNumber,isMemberOfStructure:a.isAddToMember,
_csrf:a.token},success:function(b){tools.dialog.hideDialog("loadingDialog");b.errorMessage?($("#notification_save_error").find(".error_message").html(b.errorMessage),$("#notification_save_error").show()):b.contact?(tools.dialog.hideDialog("edit_structure_member_form"),b.contact.isAssignSTGToContact=b.assignSTGToPublicContacts,"function"==typeof f&&f(b.contact,a)):tools.dialog.showDialog("sessionExpiredDialog",!0)},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",
!0)}})};return{showEditContactForm:function(b,d){a();$("#edit_structure_member_form").find("span").removeClass("error");$("#editFirstName").val(b.firstName);$("#editLastName").val(b.lastName);$("#editEmail").val(b.email);$("#contactNumber").val(b.contactNumber);tools.dialog.showDialog("edit_structure_member_form",!0,!0)},hideEditContactForm:function(){tools.dialog.hideDialog("edit_structure_member_form")},validateAndSubmit:function(c,d,f){var e={rule:validation.rules.mandatory,errorId:"notification_validate_mandatory_field_empty"};
a();if(validation.validateFields([{fieldId:"editEmail",rules:[e,{rule:validation.rules.email,errorId:"notification_validate_email_invalid"}]},{fieldId:"editFirstName",rules:[e]},{fieldId:"editLastName",rules:[e]}],!0))return e=$("#addToMemberCheckBox"),b({firstName:$("#editFirstName").val(),lastName:$("#editLastName").val(),email:$("#editEmail").val(),contactNumber:$("#contactNumber").val(),isAddToMember:f?!1:0===e.length?!0:e.is(":checked"),token:$("#memberData").find("input[name=_csrf]").val()},
c,d),!0}}});
tools.module("contactOrStructureSelection",{DIST_SEARCH_MIN_LENGTH:3,saveButtonSelector:"",listContactsUrl:"",hasBasicForm:!1,labels:{},listContacts:[],ignoreNameCheck:!1,isB2C:!1,isDistributionSeatMap:!1,isDistributionSeatMapWidget:!1,mode:"distribution",searchContactAjax:function(a,b){var c=contactOrStructureSelection.mode;tools.dialog.showWaitingPopup("loadingDialog",!0);$.ajax({type:"GET",url:contextPath+"/pro/ajax/contactSearch",data:{searchText:a,from:b},success:function(a){tools.dialog.hideDialog("loadingDialog");
$("#"+c+"_contact_lookup_result").append(a);0<$(".contact_result_item").length?($("#"+c+"_contact_create").hide(),$("#"+c+"_reset_lookup").hide()):($("#"+c+"_contact_create").show(),$("#"+c+"_contact_lookup_text").focus().select())},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}})},loadContacts:function(){var a,b=this,c=$('[id$="contact_list"]');$(".contact_list_waiting").hide();""!==b.listContactsUrl?($('[id$="contact_basic_form"]').show(),
$('[id$="contact_advanced_form"]').hide(),$(".contact_list_waiting").show(),c.attr("disabled","disabled"),$.ajax({type:"GET",url:contextPath+b.listContactsUrl,data:{},success:function(d){var f;b.listContacts=d;$(".contact_list_waiting").hide();c.prop("disabled",!1);if(0<d.length)for(f in c.append('<option value="-1">'+b.labels.chooseBusinessPartner+"</option>"),d)d.hasOwnProperty(f)&&(a=d[f],c.append('<option value="'+a.contactId+'">'+a.structureOfficialName+" | "+a.individualLastname+", "+a.individualFirstname+
"</option>"));else b.completelyHideBasicForm()},error:function(){$(".contact_list_waiting").hide();c.prop("disabled",!1);b.completelyHideBasicForm()}})):b.completelyHideBasicForm()},completelyHideBasicForm:function(){this.hasBasicForm&&(this.listContacts=[],$('[id$="contact_basic_form"]').hide(),$('[id$="contact_advanced_form"]').show())},toggleAdvancedLink:function(){var a=this;$("#"+a.mode+"_contact_advanced_form").slideToggle(200,function(){$("#"+a.mode+"_show_advanced_contact_form_btn").text($(this).is(":visible")?
a.labels.hideAdvancedLinkText:a.labels.advancedLinkText);($(this).is(":visible")||"-1"===$("#"+a.mode+"_contact_list").val())&&a.cancelContact()})},registerBasicContactFormActions:function(){var a,b=this;b.hasBasicForm&&(b.loadContacts(),$('[id$="show_advanced_contact_form_btn"]').unbind("click").on("click",function(){b.toggleAdvancedLink();return!1}),$('[id$="contact_list"]').on("change",function(){var c,d=b.listContacts;for(c in d)if(d.hasOwnProperty(c)){a=d[c];if(a.contactId===Number($(this).val())){b.selectStructure(a);
$("#"+b.mode+"_contact_advanced_form").is(":visible")&&b.toggleAdvancedLink();break}$("#"+b.mode+"_contact_selection").hide();b.enableSaveButton(!1)}}))},enableSaveButton:function(a){null!==contactOrStructureSelection.saveButtonSelector&&(a?$(contactOrStructureSelection.saveButtonSelector).parent().removeClass("disabled"):$(contactOrStructureSelection.saveButtonSelector).parent().addClass("disabled"))},searchStructureAjax:function(){var a=contactOrStructureSelection.mode;tools.dialog.showWaitingPopup("loadingDialog",
!0);$.ajax({type:"GET",url:contextPath+"/pro/ajax/structureSearch",data:{email:$("#"+a+"_search_relay_email").val(),structurecode:$("#"+a+"_search_relay_code").val()},success:function(b){void 0!==b.contactNumber&&void 0!==b.individualFirstname&&void 0!==b.individualLastname&&void 0!==b.email&&void 0!==b.structureOfficialName?($(contactOrStructureSelection.saveButtonSelector).parent().removeClass("disabled"),contactOrStructureSelection.isDistributionSeatMapWidget?distribution.seatmap.seatList.handleSelectContactSuccessWidget():
contactOrStructureSelection.isDistributionSeatMap&&distribution.seatmap.switchShipmentHandler.handleSelectContactSuccess(),contactOrStructureSelection.selectStructure(b),tools.dialog.hideDialog("loadingDialog")):(tools.dialog.hideDialog("loadingDialog"),$("#"+a+"_structure_create").show(),$("#"+a+"_search_relay_email").focus().select(),$(contactOrStructureSelection.saveButtonSelector).parent().addClass("disabled"))},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",
!0);return!1}})},reset:function(){this.enableSearch(!1,!1);this.enableSearch(!1,!0);$('[id$="contact_lookup_text"]').val("");$('[id$="contact_lookup_result"]').empty();$('[id$="reset_lookup"]').hide();$('[id$="contact_create"]').hide();$('[id$="structure_create"]').hide();$('[id$="search_relay_email"]').val("");$('[id$="search_relay_code"]').val("")},checkContactName:function(a,b){this.ignoreNameCheck||a&&b&&(a.firstName.toUpperCase()!==b.firstName.toUpperCase()||a.lastName.toUpperCase()!==b.lastName.toUpperCase())&&
tools.dialog.showDialog("warning_contact_existed",!0)},selectStructure:function(a){var b=contactOrStructureSelection.mode,c=$("#"+b+"_contact_selection");$("#selected_contact").val(a.contactNumber);$("#selected_first_name").val(a.individualFirstname);$("#selected_last_name").val(a.individualLastname);$("#selected_email").val(a.email);$("#selected_structureName").val(a.structureOfficialName);c.find(".contact_first_name").html(a.individualFirstname);c.find(".contact_last_name").html(a.individualLastname);
c.find(".contact_email").html(a.email);c.find(".contact_structure").html(a.structureOfficialName).show();$("#"+b+"_structure_search").hide();$("#"+b+"_structure_create").hide();c.show();null!==contactOrStructureSelection.saveButtonSelector&&($(contactOrStructureSelection.saveButtonSelector).parent().removeClass("disabled"),contactOrStructureSelection.isDistributionSeatMapWidget?distribution.seatmap.seatList.handleSelectContactSuccessWidget():contactOrStructureSelection.isDistributionSeatMap&&distribution.seatmap.switchShipmentHandler.handleSelectContactSuccess());
contactOrStructureSelection.reset()},selectContact:function(a,b){var c=contactOrStructureSelection.mode,d=$("#"+c+"_contact_selection");contactOrStructureSelection.checkContactName(a,b);$("#selected_contact").val(a.contactNumber);$("#selected_first_name").val(a.firstName);$("#selected_last_name").val(a.lastName);$("#selected_email").val(a.email);$("#selected_structureName").val(a.structureName);"RELAY"!==a.role?$(".contact_info",d).removeClass("relay_contact"):$(".contact_info",d).addClass("relay_contact");
a.isAssignSTGToContact&&$(".invite_recipient").show();d.find(".contact_first_name").html(a.firstName);d.find(".contact_last_name").html(a.lastName);d.find(".contact_email").html(a.email);d.find(".contact_structure").html(a.structureName).hide();$("#"+c+"_contact_search").hide();$("#"+c+"_contact_create").hide();$("#"+c+"_structure_create").hide();d.show();null!==contactOrStructureSelection.saveButtonSelector&&($(contactOrStructureSelection.saveButtonSelector).parent().removeClass("disabled"),contactOrStructureSelection.isDistributionSeatMapWidget?
distribution.seatmap.seatList.handleSelectContactSuccessWidget():contactOrStructureSelection.isDistributionSeatMap&&distribution.seatmap.switchShipmentHandler.handleSelectContactSuccess());contactOrStructureSelection.reset()},enableSearch:function(a,b){var c=b?$("#"+this.mode+"_lookup_structure"):$("#"+this.mode+"_lookup_members");if(!c.hasClass("disabled")!==a)if(a)if(c.removeClass("disabled"),c.parent().removeClass("disabled"),b)$("#distribution_lookup_structure, #redistribution_lookup_structure").on("click",
function(){contactOrStructureSelection.searchStructure()});else $("#distribution_lookup_members, #redistribution_lookup_members").on("click",function(){contactOrStructureSelection.search()});else c.addClass("disabled"),c.parent().addClass("disabled"),b?$("#distribution_lookup_structure, #redistribution_lookup_structure").off("click"):$("#distribution_lookup_members, #redistribution_lookup_members").off("click")},handleTypeChangeForContact:function(){var a=contactOrStructureSelection.mode;$("#"+a+
"_structure_search").hide();$("#"+a+"_contact_selection").hide();$("#"+a+"_structure_create").hide();$("#"+a+"_contact_search").show();$("#"+a+"_contact_create").show();contactOrStructureSelection.reset();null!==contactOrStructureSelection.saveButtonSelector&&$(contactOrStructureSelection.saveButtonSelector).parent().addClass("disabled")},handleTypeChangeForStructure:function(){var a=contactOrStructureSelection.mode;$("#"+a+"_contact_search").hide();$("#"+a+"_contact_create").hide();$("#"+a+"_contact_selection").hide();
$("#"+a+"_structure_search").show();$("#"+a+"_structure_create").show();contactOrStructureSelection.reset();null!==contactOrStructureSelection.saveButtonSelector&&$(contactOrStructureSelection.saveButtonSelector).parent().addClass("disabled")},handleChangeInStructureInputs:function(){var a=contactOrStructureSelection.mode;null!==contactOrStructureSelection.saveButtonSelector&&null!==$("#"+a+"_search_relay_email").val()&&null!==$("#"+a+"_search_relay_code").val()&&$("#"+a+"_search_relay_email").val().length>
contactOrStructureSelection.DIST_SEARCH_MIN_LENGTH&&0<$("#"+a+"_search_relay_code").val().length?contactOrStructureSelection.enableSearch(!0,!0):contactOrStructureSelection.enableSearch(!1,!0)},init:function(a,b){var c=this;null!==a&&(c.saveButtonSelector=a);b&&(c.hasBasicForm=b.hasBasicForm,c.listContactsUrl=b.listContactsUrl,c.labels=b.labels,c.ignoreNameCheck=b.ignoreNameCheck,c.isB2C=b.isB2C,c.isDistributionSeatMap=b.isDistributionSeatMap,c.isDistributionSeatMapWidget=b.isDistributionSeatMapWidget,
c.mode=b.mode,c.registerBasicContactFormActions());$('[id$="invite_recipient_checkbox"]').on({change:function(){$(this).is(":checked")?($("#"+c.mode+"_notify_recipient_checkbox").prop("disabled",!0),$("#"+c.mode+"_notify_recipient_checkbox").prop("checked",!0)):($("#"+c.mode+"_notify_recipient_checkbox").prop("disabled",!1),$("#"+c.mode+"_notify_recipient_checkbox").prop("checked",!1))}});c.enableSaveButton(!1);$('[id$="contact_lookup_text"]').on({keyup:function(){contactOrStructureSelection.enableSearch($(this).val().length>=
contactOrStructureSelection.DIST_SEARCH_MIN_LENGTH,!1)},keypress:function(a){13===a.keyCode&&$("#"+c.mode+"_lookup_members").click()}});$('[id$="search_relay_email"]').on({keypress:function(a){13===a.keyCode&&$("#"+c.mode+"_search_relay_email").val().length>=contactOrStructureSelection.DIST_SEARCH_MIN_LENGTH&&0<=$("#"+c.mode+"_search_relay_code").val().length&&$("#"+c.mode+"_lookup_relays").click()}});$('[id$="search_relay_code"]').on({keypress:function(a){13===a.keyCode&&$("#"+c.mode+"_search_relay_email").val().length>=
contactOrStructureSelection.DIST_SEARCH_MIN_LENGTH&&0<=$("#"+c.mode+"_search_relay_code").val().length&&$("#"+c.mode+"_lookup_relays").click()}});$('[id$="contact_search_radio_container"] input:radio').on({change:function(){"contact"===$(this).val()?(contactOrStructureSelection.handleTypeChangeForContact(),$("#"+c.mode+"_info_message_contact").show(),$("#"+c.mode+"_info_message_structure").hide(),$("#"+c.mode+"_contact_lookup_text").focus()):"structure"===$(this).val()&&(contactOrStructureSelection.handleTypeChangeForStructure(),
$("#"+c.mode+"_info_message_contact").hide(),$("#"+c.mode+"_info_message_structure").show(),$("#"+c.mode+"_search_relay_email").focus())}});$('[id$="search_relay_email"]').keyup(this.handleChangeInStructureInputs);$('[id$="search_relay_code"]').keyup(this.handleChangeInStructureInputs);this.reset()},search:function(a){var b=$("#"+this.mode+"_contact_lookup_text").val();a||$("#"+this.mode+"_contact_lookup_result").empty();$("#show_more").detach();this.searchContactAjax(b,a)},searchStructure:function(){this.searchStructureAjax()},
selectContactFromList:function(a,b){this.selectContact({contactNumber:a,firstName:$.trim($("#result_first_name_"+a).text()),lastName:$.trim($("#result_last_name_"+a).text()),email:$.trim($("#result_email_"+a).text()),structureName:$.trim($("#result_structure_"+a).text()),role:$.trim($("#result_role_"+a).text()),isAssignSTGToContact:b})},cancelContact:function(){var a="contact"===$("#"+this.mode+"_contact_search_radio_container input:radio:checked").val()||this.isB2C,b="structure"===$("#"+this.mode+
"_contact_search_radio_container input:radio:checked").val();null!==this.saveButtonSelector&&$(this.saveButtonSelector).parent().addClass("disabled");contactOrStructureSelection.reset();$("#"+this.mode+"_contact_selection").hide();a?($("#"+this.mode+"_contact_search").show(),$("#"+this.mode+"_contact_selection").hide(),$("#"+this.mode+"_selected_contact").val(""),$("#"+this.mode+"_contact_lookup_text").focus()):b&&($("#"+this.mode+"_structure_search").show(),$("#"+this.mode+"_search_relay_email").focus());
this.hasBasicForm&&($("#"+this.mode+"_contact_list").val(-1),$("#"+this.mode+"_contact_list option:first-child").prop("selected",!0))},return2ContactSearch:function(){$("#"+this.mode+"_search_type_contact_radio").prop("checked",!0);$("#"+this.mode+"_info_message_contact").show();$("#"+this.mode+"_info_message_structure").hide();this.handleTypeChangeForContact()},showEditContactForm:function(){contact.editContactCommon.showEditContactForm({email:$("#"+this.mode+"_contact_lookup_text").val()})},validateContact:function(a){var b=
$("#selected_contact").val();b||validation.showErrorTooltip($(a),$("#contact-selection-msg .content").html());return b},updateDistributionMode:function(a){$("#"+this.mode+"_contact_selection_panel").is(":visible")&&$(".close_expand_panel").trigger("click");this.reset();this.mode=a}});
tools.module("contactQuickSearch",function(){var a=function(){var a=$(".remove_contact_criteria");a.css("display","none");$("#contact_criteria").on("input",function(){""!==$(this).val()?a.show():a.hide()})},b=function(){$("#buy_actions #EXT").addClass("disabled");$("#buy_actions #AVR").addClass("disabled");$("#buy_actions #EXT").css("pointer-events","none");$("#buy_actions #AVR").css("pointer-events","none")},c=function(){var a=/^.*?\[[^\d]*(\d+)[^\d]*\].*$/,c=/paymentMethodId\=(\d+)/,e,g,h;$("#contact_criteria").on("focusout",
function(){(e=a.exec($(this).val()))&&0!==e.length?(g="&buyerContactNumber="+e[1],$("#buy_actions .button a").attr("onclick",function(a,b){h=c.exec(b);return"window.location = 'checkout/deliveryModes?paymentMethodId="+h[1]+g+"'"}),$("#buy_actions #EXT").removeClass("disabled"),$("#buy_actions #AVR").removeClass("disabled"),$("#buy_actions #EXT").css("pointer-events",""),$("#buy_actions #AVR").css("pointer-events","")):($("#buy_actions #NUM a").attr("onclick",function(a,b){h=c.exec(b);return"window.location = 'checkout/deliveryModes?paymentMethodId="+
h[1]+"'"}),b())})};return{init:function(d){this.getAndMakeSuggestListContact(d);c();a();$(".remove_contact_criteria").on("click",function(){$("#contact_criteria").val("");$("#contact_criteria").focus();$(".remove_contact_criteria").hide()});b()},getAndMakeSuggestListContact:function(a){var b=3,c=500,d;a&&(b=3,c=500,d={my:"center bottom",at:"center top"});$("#contact_criteria").autocomplete({source:function(a,b){$.ajax({url:"/ajax/ticketManagement/getContactList",type:"POST",dataType:"json",data:{contactNumberOrName:a.term},
success:function(a){b(a)},error:function(){tools.dialog.showDialog("ajaxErrorDialog",!0)}})},minLength:b,delay:c,position:d})}}});
tools.module("creditNote",function(){var a=[];prefix=function(a,c){return"string"===typeof a?a.replace("#","#"+c):a};getDueAmount=function(){return tools.getAmount("#final_amount")};updateDueAmount=function(a){var b=getDueAmount();a?this.$credit_note_amount_text.removeClass("hidden"):this.$credit_note_amount_text.addClass("hidden");null!==b&&(a?this.setCreditNotePaymentAmount(this.$credit_note_amount_value.val()):this.setCreditNotePaymentAmount(0))};updatePayAmountForAllInstances=function(b){a.forEach(function(a){var c=
a.widgetIdPrefix.replace("_",""),f=b[c+"Amount"],e=null!==f&&0<f?f:0;null!==f&&("loyalty"===c?(c=""!==a.$credit_note_amount_integer.val()?a.$credit_note_amount_integer.val():0,e=Math.min(e,functions.stringToStxAmount(c)),a.$credit_note_amount_text.html("-"+functions.generateAmount(e)),a.$credit_note_amount_value.val(e),a.$credit_note_amount_integer.val(functions.getDoublePartFromAmount(String(e))),0===f&&a.$useCreditNote.prop("checked",!1)):0<f&&(a.$credit_note_amount_value.val(f),a.$credit_note_amount_text.html("-"+
functions.generateAmount(f))))})};setCreditNotePaymentAmount=function(a){var b=this.widgetIdPrefix.replace("_","");var d=$('input[name="paymentMethodId"]:checked');var f=this.compulsoryCreditUse||this.$useCreditNote.is(":checked");d=d&&0<d.length?$(d[0]).val():creditNote.ccPaymentMethodId;a={paymentMethodId:this.paymentMethodId,mainPaymentMethodId:d,paymentType:b,selected:f,amount:a};tools.dialog.showWaitingPopup("loadingDialog",!0);return $.ajax({url:contextPath+"/ajax/checkout/setCreditNotePaymentAmount",
type:"POST",data:a,cache:!1,success:function(a){tools.dialog.hideDialog("loadingDialog");"OK"===a.splitPayment?($("#notification_split_payment, #notification_split_payment_finish").hide(),$("#warning_credit_note_split_payment").hide(),waitingAccount.enableWaitingAccountButtons()):("KO"===a.splitPayment?($("#notification_split_payment").show(),$("#notification_split_payment_finish").hide(),$("#warning_credit_note_split_payment").hide()):($("#notification_split_payment").hide(),$("#warning_credit_note_split_payment").hide(),
waitingAccount.isWaitingAccountSelected()&&creditNote.isCreditNoteInstanceSelected()?($("#warning_credit_note_split_payment").toggle(creditNote.isCreditNoteInstanceSelected()),waitingAccount.disableWaitingAccountButtons(),$("#notification_split_payment_finish").hide()):($("#notification_split_payment_finish").show(),waitingAccount.enableWaitingAccountButtons(),window.scrollTo(0,0))),waitingAccount.isWaitingAccountSelected()||$("#warning_prepayment_satisfied").is(":visible")||window.scrollTo(0,0));
updatePayAmountForAllInstances(a);$("#final_amount").html(functions.generateAmount(a.dueAmount));orderSummary.updatePaymentAntifraudForm();orderSummary.changeProceedPrepaymentState(!orderSummary.isDisablePrepaymentButton());orderSummary.changeProceedButtonState();orderSummary.updatePaymentMethodForm(a.dueAmount,a.paymentFeeAmount)},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}})};getCreditNotAmount=function(a){var b=Number(a.$credit_note_balance.val());
var d=getDueAmount(),f=a.widgetIdPrefix.replace("_","");a=a.$credit_note_amount_integer.val();if(null!==d)return b=d<=b?"loyalty"===f?"0"!==a?functions.stringToStxAmount(a):d:d:b};updateCreditNoteAmountInternal=function(){var a=getCreditNotAmount(this);null!==a&&(this.$credit_note_amount_value.val(a),this.$credit_note_amount_text.html(functions.generateAmount(-a)),this.updateDueAmount(this.isCreditNoteSelected(),!1),0<a||this.isCreditNoteSelected()?this.$main_content_credit_note.removeClass("hidden"):
this.$main_content_credit_note.addClass("hidden"))};formatAmount=function(a){var b=Number(this.$credit_note_balance.val());var d=functions.stringToStxAmount(a.val());0>d&&(d=0);d>b&&(d=b);d=functions.getDoublePartFromAmount(String(d));a.val(d);return functions.stringToStxAmount(String(d))};return{ccPaymentMethodId:null,updateCreditNoteAmount:function(){a.forEach(function(a){a.creditNoteAvailable&&a.updateCreditNoteAmountInternal()})},isCreditNoteInstanceSelected:function(){var b=!1;a.forEach(function(a){"creditNote_"===
a.widgetIdPrefix&&a.isCreditNoteSelected()&&(b=!0)});return b},getInstance:function(){var b={compulsoryCreditUse:!1,useCreditByDefault:!1,widgetIdPrefix:"",paymentMethodId:null,$useCreditNote:null,$credit_note_amount_text:null,$main_content_credit_note:null,$credit_note_amount_value:null,$credit_note_balance:null,creditNoteAvailable:null,updateCreditNoteAmountInternal:updateCreditNoteAmountInternal,updateDueAmount:updateDueAmount,setCreditNotePaymentAmount:setCreditNotePaymentAmount,formatAmount:formatAmount,
isCreditNoteSelected:function(){return this.$useCreditNote.is(":checked")||this.compulsoryCreditUse},init:function(a){var c=a.widgetIdPrefix;this.compulsoryCreditUse=a.compulsoryCreditUse;this.useCreditByDefault=a.useCreditByDefault;this.paymentMethodId=a.paymentMethodId;this.$useCreditNote=$(prefix("#useCreditNote",c));this.$credit_note_amount_text=$(prefix("#credit_note_amount_text",c));this.$main_content_credit_note=$(prefix("#main_content_credit_note",c));this.$credit_note_amount_value=$(prefix("#credit_note_amount_value",
c));this.$credit_note_amount_integer=$(prefix("#credit_note_amount_integer",c));this.$credit_note_balance=$(prefix("#credit_note_balance",c));this.creditNoteAvailable=a.creditNoteAvailable;this.widgetIdPrefix=c;this.creditNoteAvailable&&((this.compulsoryCreditUse||this.useCreditByDefault)&&this.updateDueAmount(!0,!0),this.compulsoryCreditUse||(this.$useCreditNote.on("click",function(){b.updateDueAmount(this.checked,!0)}),$(prefix("#useCreditNote",c)).is(":checked")||this.$credit_note_amount_text.addClass("hidden")),
a=function(){this.$credit_note_amount_value.val(this.formatAmount(this.$credit_note_amount_integer));this.$useCreditNote.prop("checked",!0);this.updateDueAmount(!0)}.bind(this),this.$credit_note_amount_integer.change(a),this.$credit_note_amount_integer.val(functions.getDoublePartFromAmount(this.$credit_note_amount_value.val())),orderSummary.changeProceedPrepaymentState(!orderSummary.isDisablePrepaymentButton()),orderSummary.changeProceedButtonState())}};a.push(b);return b}}});
tools.module("culturalContacts",function(){var a=[],b,c,d,f,e,g,h,l,k=function(b){var c;for(c=0;c<a.length;c++)if(a[c].contact.contactNumber===b)return a[c]},m=function(a,b){var c=$(a).data("movementid"),e="";!0===b&&(e=d);void 0!==f&&(b=k(f[c]),h&&(l=h[c]),void 0!==b&&(e=b.contact.contactNumber),f[c]=void 0);""===e&&void 0!==$(a).data("contactreference")&&""!==$(a).data("contactreference")&&(e=$(a).data("contactreference")+"");b=k(e);return void 0!==b&&b.authorizedOperationIds.includes($(a).data("operationid"))?
e:""},p=function(a,b){a=k(a);var c=$(b).data("movementid");if(void 0!==a){c=$("td.beneficiary_"+c);$('input[name$=".firstName"]',c).val(a.contact.firstName);$('input[name$=".lastName"]',c).val(a.contact.lastName);var d=a.contact.email;"PENDING"===a.contact.connectionStatus&&g&&(d="");$('input[name$=".email"]',c).val(d);$(b).closest(".beneficiary_input").removeClass("error")}},q=function(a,b){b=m(a,b);l&&!$(a).hasClass("required_beneficiary")&&$(a).find("option").filter(function(){return""===$(this).attr("value")}).remove();
$(a).val(b);p(b,a)},r=function(b){a=a.filter(function(a){return a.contact.contactNumber!==b.contact.contactNumber});a.push(b);$('select[name$=".contactNumber"]').each(function(a,c){a=$(c).data("operationid");a=0<=b.authorizedOperationIds.indexOf(a);var d=$(c).data("movementid");var f=$("<option>");void 0!==e&&e.hasOwnProperty(d)||(f.val(b.contact.contactNumber),d=b.contact.contactNumber+" - "+b.contact.firstName+" "+b.contact.lastName,a||(f.attr("disabled","disabled"),d+=" (*)"),f.text(d),$(c).find("option").each(function(a,
c){return"-1"===$(c).val()||Number(b.contact.contactNumber)<Number($(c).val())?(f.insertBefore($(c)),!1):!0}))})},t=function(a,c){tools.dialog.showWaitingPopup("loadingDialog",!0);$.ajax({type:"POST",url:contextPath+"/ajax/checkout/getCulturalContact",data:{contactNumber:a,fileId:c},success:function(c){tools.dialog.hideDialog("loadingDialog");r(c);0<=c.authorizedOperationIds.indexOf($(b).data("operationid"))&&($(b).val(a),p(a,b))},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",
!0)}})},w=function(a){var b=$("td.beneficiary_"+$(a).data("movementid"));$(a).val("");$('input[name$=".firstName"]',b).val("");$('input[name$=".lastName"]',b).val("");$('input[name$=".email"]',b).val("")};return{init:function(k){a=k.culturalContacts;d=k.defaultContactNumber;f=k.defaultMovementContactMap;e=k.unmodifiableMovementContactMap;c=k.isDistributeTicket;g=k.isApplyStrictGdprForFnf;h=k.movementTicketAssignedMap;$('select[name$=".contactNumber"]').unbind("change").on("change",function(a){var c=
a.target.value;a.preventDefault();"-1"===c?(w(a.target),contact.addFriendOrFamily.showForm(),b=a.target):""===c?w(a.target):p(c,a.target)});$('select[name$=".contactNumber"]').each(function(a,b){"true"===c?q(b,!0):q(b,0===a);$(b).closest(".seat_category_section").find(".purchase_on_behalf_note").removeClass("hidden")})},checkCulturalContacts:function(){var a=!0;void 0!==e&&$('select[name$=".contactNumber"]').each(function(b,c){b=$(c).data("movementid");e.hasOwnProperty(b)&&e[b]!==$(c).val()&&($(c).closest(".beneficiary_input").addClass("error"),
a=!1)});return a},addNewContact:function(a,b){t(a.contactNumber,b)}}});
tools.module("secutix.date.picker.check",function(){var a=!1,b=null,c=function(a){var b=new Date,c=!1;b.setHours(0,0,0,0);$.datepicker&&$.datepicker.parseDate&&datePickerConfig&&datePickerConfig.dateFormat&&($(".datepicker_element input").each(function(a){$.datepicker.parseDate(datePickerConfig.dateFormat,$(this).val()).getTime()===b.getTime()&&(c=!0)}),a&&(a=$.datepicker.parseDate(datePickerConfig.dateFormat,a),a.getTime()===b.getTime()&&(c=!0)));return c};return{setIsEnable:function(b){a=b},checkToday:function(d,
f){b=d;a&&c(f)?tools.dialog.showWaitingPopup("confirmationDialog_check_popup",!0):this.submit()},isDatepickerSetToToday:function(d,f){var e=!1;b=d;a&&c(f)&&(tools.dialog.showWaitingPopup("confirmationDialog_check_popup",!0),e=!0);return e},submit:function(){b&&b()}}});
tools.module("secutix.date.combos",function(){var a="0 1 3 5 7 8 10 12".split(" "),b="0 1 3 4 5 6 7 8 9 10 11 12".split(" "),c=function(a){$("#"+a+" option").each(function(){$(this).prop("disabled",!1)})},d=function(a,b){$("#"+a+" option").each(function(){-1===$.inArray($(this).val(),b)?$(this).attr("disabled","disabled"):$(this).prop("disabled",!1)})},f=function(a){return 0===a%400||0!==a%100&&0===a%4?!0:!1},e=function(a){$("#"+a+" option").each(function(){f(parseInt($(this).val(),10))?$(this).prop("disabled",
!1):$(this).attr("disabled","disabled")})},g=function(g,h,l,q){q&&(c(h),c(l));g=$("#"+g).val();q=$("#"+h).val();var k=$("#"+l).val();"31"===g?d(h,a):"30"===g||"29"===g&&!f(parseInt(k,10))?d(h,b):c(h);"29"===g&&"2"===q?e(l):c(l)},h=function(b,d,g,h){h&&(c(b),c(g));h=$("#"+b).val();d=$("#"+d).val();var k=$("#"+g).val();-1===$.inArray(d,a)&&$("#"+b+' option[value="31"]').attr("disabled","disabled");"2"===d&&($("#"+b+' option[value="30"]').attr("disabled","disabled"),f(parseInt(k,10))||$("#"+b+' option[value="29"]').attr("disabled",
"disabled"));"29"===h&&"2"===d?e(g):c(g)},l=function(e,g,h,l){l&&(c(e),c(g));l=$("#"+e).val();var k=$("#"+g).val();h=$("#"+h).val();"31"===l?d(g,a):"30"===l||"29"===l&&!f(parseInt(h,10))?d(g,b):c(g);"2"===k&&($("#"+e+' option[value="31"]').attr("disabled","disabled"),$("#"+e+' option[value="30"]').attr("disabled","disabled"),f(parseInt(h,10))||$("#"+e+' option[value="29"]').attr("disabled","disabled"))};return{populateCombosDatepicker:function(a,b,c,d,e){var f;if(!0!==$("#"+a).prop("initialized")){var g=
1;for(f=31;g<=f;g++)$("#"+a+" option:last").val(g),$("#"+a+" option:last").html(g),31!==g&&$("#"+a).append($("#"+a+" option:last").clone());$("#"+a).prop("initialized",!0)}if(!0!==$("#"+b).prop("initialized")){g=0;for(f=12;g<f;g++)$("#"+b+" option:last").val(g+1),$("#"+b+" option:last").html(d[g]),11!==g&&$("#"+b).append($("#"+b+" option:last").clone());$("#"+b).prop("initialized",!0)}a=(new Date).getFullYear();f=100;e&&(a-=Number(e),f-=Number(e));f=a-f;if(!0!==$("#"+c).prop("initialized")){for(g=
a;g>=f;g--)$("#"+c+" option:last").val(g),$("#"+c+" option:last").html(g),g!==f&&$("#"+c).append($("#"+c+" option:last").clone());$("#"+c).prop("initialized",!0)}},dynamizeDateCombos:function(a,b,c){$("#"+a).change(function(){g(a,b,c,!0)});$("#"+b).change(function(){h(a,b,c,!0)});$("#"+c).change(function(){l(a,b,c,!0)});g(a,b,c,!1);h(a,b,c,!1);l(a,b,c,!1)},resetDateCombosValues:function(a,b,d){$("#"+a).val(0);$("#"+b).val(0);$("#"+d).val(0);c(a);c(b);c(d)}}});
tools.module("degressiveRates",function(){var a={},b,c=null,d=function(){$(".audience-subcat-desc").tipsy({className:"tipsy-advantage tipsy-hover tipsy-aud-subcat",opacity:1,gravity:"s",html:!0,trigger:"hover",title:function(){return $(this).html().replace(/\n/g,"<br />")}});tools.makeTooltipAccessible(".audience-subcat-desc")},f=function(a,c){var e=$(".tariff",c),f=$("<div/>",{"class":"audience-subcat-desc"}),g=$(e).find(".audience-subcat-desc");a.audienceSubCategory&&a.audienceSubCategory.externalDescription?
($(g).remove(),$(f).html(a.audienceSubCategory.externalDescription),$(e).append(f),d()):$(g).remove();e=$(".tariff",c);f=$("<div/>",{"class":"audience-subcat-requireAttachment"});g=$(e).find(".audience-subcat-requireAttachment");a.audienceSubCategory&&a.audienceSubCategory.requireAttachment?($(g).remove(),$(f).html(b),$(e).append(f)):$(g).remove();$("td.unit_price > .amount",c).html(functions.generateAmount(a.amount));$("td.unit_price > .amount",c).data("amount",a.amount);$('input[id$=".audienceSubCategoryId"]',
c).val(a.audienceSubCategory.id);$('input[id$=".audienceSubCategory"]',c).val(a.audienceSubCategory.id);$('input[id$=".priceLevelId"]',c).val(a.priceLevelId);void 0!==a.advantage?$('input[id$=".advantageId"]',c).val(a.advantage.advantageId):$('input[id$=".advantageId"]',c).val("")},e=function(a,b,d){var e=a[0],g=$(".vp_flat_rate_combo",b).val();var h={};a&&0<a.length&&(h.key=d,1===a.length?(h.isSingleRate=!0,d=a[0],h.price=d,h.hasPriceLevelId=d.priceLevelId,h.hasPriceLevelCode=d.priceLevelCode,h.hasAdvantage=
d.advantage,h.audienceSubCategoryDesc=d.audienceSubCategory.externalDescription):h.matchingRates=a);d=$(".audience-subcat-name",b);var l=c;$(d).html(Mustache.render(l,h,void 0));for(h=0;h<a.length;h++)if(a[h].audienceSubCategory.id===g){e=a[h];$('.vp_flat_rate_combo option[value="'+g+'"]',b).prop("selected",!0);$(".vp_flat_rate_combo",b).change();break}f(e,b)};return{init:function(a){c=$("#degressiveRateTariffTpl").html();b=a.requireAttachmentText},onMatchingDegressiveRatesComboChange:function(b,
c){var d,e=a[c];if(e){var g=$(b).closest("tr.degressive_rate");c=$(b).val();for(d=0;d<e.children.length;d++){var h=e.children[d];if(h.audienceSubCategory.id===c){f(h,g);c=$(b).find("option:selected").hasClass("with_advantage");$(b).toggleClass("with_advantage",c);break}}functions.updatePrices()}},updatePrices:function(b,c){var d=a[c];if(d){var f=Number($(b).val())||Number($(b).closest(".touch_friendly_qty_selection").find(".number input").val());b=$(b).closest("tr.degressive_rate");var g=[],h=d.children;
var q=Number(d.parent.maxQuantity);if(!(0<q&&q<f))for(q=0;q<h.length;q++){var r=h[q];var t=Number(r.minQuantity);var w=Number(r.maxQuantity);if(t>f)break;(f<=w||""===r.maxQuantity)&&g.push(r)}0<g.length?e(g,b,c):e([d.parent],b,c)}},addDegressiveRates:function(b,c,d){a[b]={parent:c,children:d}}}}());
tools.module("addressBookWidget",{saveButtonSelector:"",isDistributionSeatMap:"",selectAddressBook:function(a){null!=a&&($("#addressBook_id").val(a.id),$("#addressBook_ownerContactNumber").val(a.ownerContactNumber),$("#addressBook_firstName").val(a.firstName),$("#addressBook_lastName").val(a.lastName),$("#addressBook_email").val(a.email),$("#addressBook_company").val(a.company),$("#addressBook_targetContactNumber").val(a.targetContactNumber),null!==this.saveButtonSelector&&($(this.saveButtonSelector).parent().removeClass("disabled"),
this.isDistributionSeatMap&&distribution.seatmap.switchShipmentHandler.handleSelectContactSuccess()))},unselectAddressBook:function(){null!==this.saveButtonSelector&&$(this.saveButtonSelector).parent().addClass("disabled");$("#addressBook_id").val("");$("#addressBook_ownerContactNumber").val("");$("#addressBook_firstName").val("");$("#addressBook_lastName").val("");$("#addressBook_email").val("");$("#addressBook_company").val("");$("#addressBook_targetContactNumber").val("");$("#selected_contact").val("");
$("#selected_first_name").val("");$("#selected_last_name").val("");$("#selected_email").val("")},toggleNotifyReceipt:function(a){$("#notify_recipient").val(a)},addressBookHandler:function(a,b){switch(a){case "AB_SELECTED":addressBookWidget.selectAddressBook(b);break;case "AB_UNSELECTED":addressBookWidget.unselectAddressBook();break;case "TOGGLE_NOTIFY_RECEIPT":addressBookWidget.toggleNotifyReceipt(b)}},init:function(a,b){null!==a&&(this.saveButtonSelector=a);null!=b&&(this.isDistributionSeatMap=b.isDistributionSeatMap)}});
tools.module("distribution.detail",function(){var a=0,b,c,d,f,e,g,h,l=!1,k=!1,m=function(a,b){var c=!1,d=!0,e=validation.numericRule();("object"!==typeof a?$("."+a):$(a)).each(function(){var a=[{rule:e},{rule:validation.numericBoundsRule(1,parseInt($(this).attr("data-maxQuantity"),10),!1,!0,!0)}];$(this).val()&&0<parseInt($(this).val(),10)&&(c=!0,validation.validateField(this.id,a,null,!0)||(d=!1),g=$(this).attr("data-product-id"),h=$(this).attr("data-ticket-support"))});b&&!c&&(d=!1,validation.showErrorTooltip($(b),
$("#quantity-selection-msg .content").html()));return d},p=function(){var a=0,b;$(".product_family").each(function(c,d){var e=0;$('input.distribution_quantity[type="number"]',d).each(function(a,b){""!==$(b).val()&&(e+=Number($(b).val()),g=b.getAttribute("data-product-id"),h=b.getAttribute("data-ticket-support"))});$(".product_group_selected .selected_quantity",d).text(e);0<e?$(".selection_info",d).show():$(".selection_info",d).hide();"PACKAGE"===$(d).attr("data-product-type")?(b=Number($(".composition-info",
d).attr("attr-total-line-quantity")),a+=e*b,$(".product_group_selected .selected_package_quantity",d).text(e),$(".product_group_selected .selected_quantity",d).text(e*b)):a+=e;r(e,e*b,d)});$("#nb_tickets_selected").text(a);q(a)},q=function(a){0>a||(1>=a?($("#distribution_selected_summary").find(".totalOneTicket").removeClass("hidden"),$("#distribution_selected_summary").find(".totalMultiTicket").addClass("hidden")):1<a&&($("#distribution_selected_summary").find(".totalMultiTicket").removeClass("hidden"),
$("#distribution_selected_summary").find(".totalOneTicket").addClass("hidden")))},r=function(a,b,c){var d=a;0!=a&&("PACKAGE"===$(c).attr("data-product-type")&&(1==a?($(".selection_info",c).find(".onePackage").removeClass("hidden"),$(".selection_info",c).find(".multiPackage").addClass("hidden")):($(".selection_info",c).find(".multiPackage").removeClass("hidden"),$(".selection_info",c).find(".onePackage").addClass("hidden")),d=b),1==d?($(".selection_info",c).find(".oneTicket").removeClass("hidden"),
$(".selection_info",c).find(".multiTicket").addClass("hidden")):($(".selection_info",c).find(".multiTicket").removeClass("hidden"),$(".selection_info",c).find(".oneTicket").addClass("hidden")))},t=function(){var a=!0;$("#distribute_multiple_supports_error").hide();$("#print_multiple_supports_error").hide();$("#print_exceed_max_count_error").hide();$('[id^="easy_switch_shipment_multiple_supports_error_"]').hide();$('.product_family input.distribution_quantity[type="number"]').each(function(b,c){""!==
$(c).val()&&(""!==h&&h!==$(c).attr("data-ticket-support")&&(a=!1),h=$(c).attr("data-ticket-support"),g=$(c).attr("data-product-id"))});return a},w=function(){var a=!1,b=$(".ticket_holder_reach_deadline_to_update_error"),c=b.find(".error-info");b.hide();b.html();var d=A();0<d.size&&(a=!0,d=y(d),c.html(d),b.show(),b[0].scrollIntoView({behavior:"smooth",block:"end",inline:"nearest"}));return a},y=function(a){var b=[];a.forEach(function(a,c){var d=z(c);0<a.size&&a.forEach(function(a,e){e=x(c,e);a=u(d,
e,a);b.push(a)})});return b},z=function(a){var b=$("#prod_"+a),c=0<$("#mutltiple_distribution_product_detail_container").length,d=0<$(".tickets_distribution_seat_map").length;return c?$("#distribution_detail_product_"+a+" > .distribution_product_name").html():d&&("SPORTING_EVENT"===b.attr("data-product-type")||b.hasClass("not_on_sales"))?b.find(".subtitle").html():$("#prod_title_"+a+" > p.title").html()},x=function(a,b){a=$("#prod_"+a);b=$("#perf_line_"+b);var c=0<$(".tickets_distribution_seat_map").length,
d=0<b.find(".all_match_info .match_info").length;return c?"SPORTING_EVENT"===a.attr("data-product-type")?Array.of(a.find(".round_kind > .round").html(),a.find("p.title").html()).join(" - "):a.find("p.date").html():d?b.find(".all_match_info .match_info").html():b.find(".title > div").html()},A=function(){var a=new Map;$('input.distribution_quantity[type="number"]').each(function(b,c){if(""!==$(c).val()){var d=$(c).siblings('input[name$=".ticketHolderDeadlinePassed"]');if("true"===d.val())if(c=d.attr("data-product-id"),
b=d.attr("data-performance-id"),d=d.attr("data-seat-cat-name"),a.has(c))c=a.get(c),c.has(b)?c.get(b).add(d):c.set(b,(new Set).add(d));else{var e=new Map;e.set(b,(new Set).add(d));a.set(c,e)}}});return a},C=function(){var a=!1,b=Object.values(distribution.seatmap.seatList.getSelectedSeats()),c=$(".ticket_holder_reach_deadline_to_update_error"),d=c.find(".error-info");c.hide();c.html();if(0<b.length){var e=new Set;b.forEach(function(a){a.distributionTicketResult&&a.distributionTicketResult.ticketHolderDeadlinePassed&&
e.add(a.seatCategory)});0<e.size&&(a=!0,b=z(SeatMap.productId),b=u(b,x(SeatMap.productId),e),d.html(b),c.show(),c[0].scrollIntoView({behavior:"smooth",block:"end",inline:"nearest"}))}return a},u=function(a,b,c){return'<li><span class="invalid-performance">'+Array.of(a,b,Array.from(c).join(", ")).join(" - ").replace(/[\r\n\t]+/gm,"")+"</span></li>"},v=null,D={},E={},F={},B={},G={},L={},K={},H={},M=null,Q=null,S=null,V=!1,N=function(a,b){a=a.find("input.toogle_all_seats");b?a.prop("checked",!0):a.removeProp("checked")},
I=function(){return $("#distribution_form")},O=function(){var a=0;I().find("input.distribution_quantity").each(function(){var b=0<parseInt($(this).val(),10),c=$(this).parent().find("input");b?(c.each(function(){var b=$(this).attr("name");b&&($(this).val()?$(this).attr("name",b.replace("[]","["+a+"]")):$(this).removeAttr("name"))}),a++):c.removeAttr("name")})},R=function(a,b){var c=$(b).closest("[id^=tickets_list_]");b=$(c).find(".ticketsList");c=$(c).attr("id").substring(13).split("_");distribution.detail.showPaginatedSeatSelection(c[0],
c[1],c[2],a,!0,b)},X=function(){$(".seat_cat_show_hide").click(function(a){var b=$(this).closest("[id^=select_seat_popup_]"),c=$(b).find(".seat_cat_show_hide"),d=$(this).closest(".seatCat_tickets_container").find(".ticketsList"),e=$(this).find(".text"),f=$(this).find("a").attr("id");a.preventDefault();$(this).hasClass("plus")?($(b).find(".ticketsList").addClass("close"),$(c).removeClass("less").addClass("plus"),$(c).find(".text").text(M),$(this).removeClass("plus"),$(this).addClass("less"),$(e).text(Q),
$(d).removeClass("close"),a=f.substring(15),d=a.split("_"),a=d[0],c=d[1],d=d[2],f=a+"_"+c+"_"+d,e=$("#tickets_list_"+f+" table"),f=$("#tickets_list_"+f+" .ticketsList"),0===$(e).length&&distribution.detail.showPaginatedSeatSelection(a,c,d,1,!1,f)):($(this).removeClass("less"),$(this).addClass("plus"),$(e).text(M),$(d).addClass("close"));tools.dialog.showDialog($(b).attr("id"),!0)})},T=function(a){var b=$("#tickets_list_"+a),c=$(b).find("input.toogle_all_seats"),d=$(b).find("input.selected_seat");
$(d).change(function(){var a=$(this).val(),e=$(b).find(".seatCat_summary .counter"),f=parseInt($(e).text(),10);B[a]=$(this).prop("checked");f=B[a]?f+1:f-1;e.html(f);$(c).is(":checked")?B[a]||$(c).prop("checked",!1):U(c,d)});$(c).change(function(){var a=$(b).find("input.selected_seat:checked"),c=$(b).find(".seatCat_summary .counter"),e=parseInt($(c).text(),10);$(this).is(":checked")?($(d).prop("checked",!0),e+=d.length-a.length):($(d).prop("checked",!1),e-=a.length);$(d).each(function(){var a=$(this).val();
B[a]=$(this).prop("checked")});c.html(e)})},Z=function(a){$("#select_seat_popup_"+a+" .seatCat_tickets_container").each(function(){var a=$(this).find("input.toogle_all_seats"),b=$(this).find("input.selected_seat");$(b).each(function(){var a=$(this).val();B[a]?$(this).prop("checked",!0):$(this).prop("checked",!1)});U(a,b)})},ba=function(a){$("#select_seat_popup_"+a+" .seatCat_tickets_container").each(function(){var a=$(this).attr("id").substring(13);a=H[a];var b=$(this).find(".seatCat_summary .counter");
void 0!==a?b.html(a):b.html("0")})},U=function(a,b){var c=!0;$(b).each(function(){var a=$(this).val();if(!B[a])return c=!1});c?$(a).prop("checked",!0):$(a).prop("checked",!1)},P=function(a){a=$("#tickets_list_"+a);a=$(a).find("input.selected_seat");$(a).each(function(){var a=$(this).val();L[a]=$(this).attr("data-opId")})},Y=function(){$(".close_expand_panel").on("click",function(){$(this).closest(".expand_panel").slideUp(function(){$(".triangle_tip").hide()});$(".stx-ab-clear-button:visible").click()})},
da=function(a,b){$(b).html(Mustache.render(v,a))},aa=function(a){var b=$("#available_tickets_filter");"true"===a&&b.prop("checked",!0);if(0<b.length&&b.is(":checked")){if(a=$(".has_availability_line .toogle_button").first(),0<a.length){var c=a.closest(".distribution_perf_line");$(".no_availability_line .toogle_button.less").click();var d=c.offset().top-100;$(".distribution_perf_line .toogle_button").closest(".distribution_perf_line").find(".toggle_content").each(function(){$(this).is(":visible")&&
(d-=$(this).height());return $(this).closest(".distribution_perf_line").attr("id")!==c.attr("id")});a.hasClass("plus")&&a.click();$("html, body").animate({scrollTop:d},"slow")}}else 0<b.length&&($(".distribution_perf_line .toogle_button.less").click(),$(".toogle_button").first().click());$("input[name=showOnlyAvailableTicketsLines]").val(b.is(":checked"))};return{events:$({}),init:function(g){a=g.maxAllowedTicketCount;b=g.actionForSplitAndDistribute;c=g.actionForDistribute;d=g.actionForEasySwitchShipmentAndDistribute;
f=g.actionForRedistribute;e=g.actionForEasySwitchShipmentAndRedistribute;l="true"===g.isDistributionSeatMap;k="true"===g.distributionForAddressBookEnabled;$(function(){tools.preventFormAutoSubmit("distribution_form");tools.registerAsToggleLink("toogle_button","expanded_box",".toggle_content");tools.registerAsIntegerInput("distribution_quantity");$(".toogle_button").slice(1).click();v=$("#ticketsListTpl").html();l||(distribution.pagination.setPaginationConfiguration({displayWindow:2,nbPerPage:g.ticketsPageSize}),
distribution.pagination.onPageChange(R));M=g.showDetails;Q=g.hideDetails;S=g.autoChoosingSeatsText;V=g.isB2C;X();Y();$("#available_tickets_filter").unbind("change").bind("change",function(){aa()});var a=setInterval(function(){"complete"===document.readyState&&(clearInterval(a),aa(g.showOnlyAvailableTicketsLines))},100)})},checkPrintingStatus:function(){$.ajax({url:contextPath+"/pro/account/distribution/event/getCompleteStatus",dataType:"json"}).done(function(a){!0===a&&window.location.reload(!0)})},
validateQuantity:function(a,b){return m(a,b)},showPaginatedSeatSelection:function(a,b,c,d,e,f){var g=a+"_"+b+"_"+c,h=g+"_"+d;a={productId:a,perfId:b,seatCatId:c,ticketSupport:K[b],page:d};var k=function(){return function(a,b){return b(functions.generateAmount(this.price))}};void 0===F[h]?(distribution.pagination.doPaginate(a,D[g],d),da(a,f),e&&tools.dialog.showDialog("select_seat_popup_"+b,!0),$.ajax({type:"POST",url:contextPath+"/ajax/pro/account/distribution/event/detail/tickets",data:a,dataType:"json",
success:function(a){a.success&&(a.displayTickets=!0,a.generateAmount=k,distribution.pagination.doPaginate(a,D[g],d),da(a,f),$("#tickets_list_"+g).find('input[type="checkbox"]').first().focus(),T(g),P(g),F[h]=a,$("#select_seat_popup_"+b).is(":visible")&&tools.dialog.showDialog("select_seat_popup_"+b,!0))}})):(da(F[h],f),T(g),Z(b),e&&tools.dialog.showDialog("select_seat_popup_"+b,!0));void 0===E[g]&&(distribution.pagination.init(f),E[g]=!0);$("#tickets_list_"+g).find('input[type="checkbox"]').first().focus()},
showSeatSelection:function(a){var b={},c=$("#select_seat_popup_"+a),d=!0;c.find("input.selected_seat").each(function(){var a=$(this).attr("data-opId"),c=$(this).val(),e=$("[id^=distrib_quantity_"+a+"]"),f=e.attr("data-explicitlyInputPath");b[a]||(b[a]=[],e.nextAll('input:hidden[name^="'+f+'"]').each(function(){b[a].push($(this).val())}));0<=$.inArray(c,b[a])?$(this).prop("checked",!0):($(this).removeProp("checked"),d=!1)});N(c,d);tools.dialog.showDialog("select_seat_popup_"+a,!0)},updateSelectedQuantity:function(){p()},
confirmSeatSelection:function(a){var b={};a="select_seat_popup_"+a;$.each(B,function(a,c){var d=L[a];void 0!==d&&(b[d]||(b[d]=[]),c&&b[d].push(a))});$.each(b,function(a,b){var c=$("[id^=distrib_quantity_"+a+"]"),d=c.attr("data-explicitlyInputPath");c.nextAll('input:hidden[name^="'+d+'"]').remove();b.length?(c.val(b.length),c.attr("disabled",!0),$.each(b,function(a,b){$("<input>").attr({type:"hidden",name:d+"["+a+"]",value:b}).insertAfter(c)})):(c.val(""),c.prop("disabled",!1));p()});G=$.extend(!0,
{},B);$("#"+a+" .seatCat_tickets_container").each(function(){var a=$(this).attr("id").substring(13),b=parseInt($(this).find(".seatCat_summary .counter").text(),10);H[a]=b});tools.dialog.hideDialog(a)},toggleAllSeats:function(a,b){a=$("#select_seat_popup_"+a).find("input.selected_seat");b?a.prop("checked",!0):a.removeProp("checked")},updateToggleAllCheckBox:function(a,b){a=$("#select_seat_popup_"+a);b=!(b||a.find("input.selected_seat").is(":not(:checked)"));N(a,b)},cancelSeatSelection:function(a){tools.dialog.hideDialog("select_seat_popup_"+
a)},distributionFormSubmit:function(a){tools.dialog.showWaitingPopup("requestProcessingDialog",!0);$("#is_automatic_distribution").val(!0);if(!k){var b=$("#"+a+"_invite_recipient_checkbox").is(":checked");a=$("#"+a+"_notify_recipient_checkbox").is(":checked");$("#isAssignSTGToContact").val(b);$("#notify_recipient").val(a)}I().submit()},proceedWithNoContactChange:function(){tools.dialog.showWaitingPopup("requestProcessingDialog",!0);O();$("#is_automatic_distribution").val(!0);$("#selected_contact").val("");
$("#selected_first_name").val("");$("#selected_last_name").val("");$("#selected_email").val("");I().submit()},doSelectDeliveryMode:function(a){null!=g&&null!=h&&(b=contextPath+"/account/distribution/deliveryModes?productId="+g+"&ticketSupport="+h);I().attr("action",b);this.doDistributeInternal(a,"#btn_splitAndDistribute")},doDistribute:function(a){null!=g&&null!=h&&(c=contextPath+"/pro/account/distribution/listDistributionProducts?productId="+g+"&ticketSupport="+h);I().attr("action",c);this.doDistributeInternal(a,
"#btn_distribute")},doRedistribute:function(a){I().attr("action",f+"&view="+distribution.seatmap.seatViews.getSelectedView());this.doRedistributeInternal(a,"#btn_redistribute")},doDistributeAndEasySwitchShipment:function(a,b,c,e){e=encodeURIComponent(e);e="&srcShipmentModeId="+b+"&targetShipmentModeId="+c+"&easySwitchShipmentActionName="+e+"&isDistribute=true";null!=g&&null!=h&&(d=contextPath+("/pro/account/distribution/easySwitchShipmentAndDistribute?productId="+g+"&ticketSupport="+h));I().attr("action",
d+e);this.doDistributeInternal(a,"#btn_distribute_and_easy_switch_shipment_"+b+"_"+c)},doRedistributeAndEasySwitchShipment:function(a,b,c,d){d=encodeURIComponent(d);d="&srcShipmentModeId="+b+"&targetShipmentModeId="+c+"&easySwitchShipmentActionName="+d;I().attr("action",e+d+"&view="+distribution.seatmap.seatViews.getSelectedView());this.doRedistributeInternal(a,"#btn_redistribute_and_easy_switch_shipment_"+b+"_"+c)},returnDistribute:function(){$("#return_distribution_form").submit()},distributionWithAddressBook:function(a,
b){b={id:$("#addressBook_id").val(),ownerContactNumber:$("#addressBook_ownerContactNumber").val(),firstName:$("#addressBook_firstName").val(),lastName:$("#addressBook_lastName").val(),email:$("#addressBook_email").val(),company:$("#addressBook_company").val(),targetContactNumber:$("#addressBook_targetContactNumber").val()};tools.dialog.showWaitingPopup("requestProcessingDialog",!0);$.ajax({type:"POST",url:contextPath+"/ajax/distribution/linkAddressBook",data:JSON.stringify(b),contentType:"application/json",
dataType:"json",success:function(b){b&&"OK"===b.status&&b.contactInfo?(b=b.contactInfo,$("#selected_contact").val(b.contactNumber),$("#selected_first_name").val(b.firstName),$("#selected_last_name").val(b.lastName),$("#selected_email").val(b.email),O(),distribution.detail.distributionFormSubmit(a)):(tools.dialog.hideDialog("requestProcessingDialog"),tools.dialog.showDialog("ajaxErrorDialog",!0))},error:function(){tools.dialog.hideDialog("requestProcessingDialog");tools.dialog.showDialog("ajaxErrorDialog",
!0)}})},doDistributeInternal:function(a,b){if(!t())$("#distribute_multiple_supports_error").show(),0<$("#distribute_multiple_supports_error").length&&($("#main_content_distribution_product_detail_info").show(),$("#distribute_multiple_supports_error")[0].scrollIntoView({behavior:"smooth",block:"end",inline:"nearest"}));else if(!$(b).parent().hasClass("disabled")&&(this.events.trigger("onBeforeDistributionFormSubmit"),m("distribution_quantity",a)))if(k)this.distributionWithAddressBook("distribution",
a);else{b="contact"===$("#distribution_contact_search_radio_container input:radio:checked").val()||V;var c="structure"===$("#distribution_contact_search_radio_container input:radio:checked").val();b&&!$("#selected_contact").val()||c&&(""===$("#selected_email").val()||""===$("#selected_contact").val())?null!==$("#buyer_info_number").html()&&this.proceedWithNoContactChange():(O(),(b&&contactOrStructureSelection.validateContact(a)||c)&&this.distributionFormSubmit("distribution"))}},doRedistributeInternal:function(a,
b){if(!$(b).parent().hasClass("disabled"))if(b=distribution.seatmap.seatList.getMovementIdsFromSeatList(),this.events.trigger("onBeforeDistributionFormSubmit"),$("#movementIds","#distribution_form").val(b),k)this.distributionWithAddressBook("redistribution",a);else{b="contact"===$("#redistribution_contact_search_radio_container input:radio:checked").val()||V;var c="structure"===$("#redistribution_contact_search_radio_container input:radio:checked").val();O();b&&contactOrStructureSelection.validateContact(a)?
this.distributionFormSubmit("redistribution"):c&&this.distributionFormSubmit("redistribution")}},doImmediatelyPrint:function(b){var c=!1;t()?0<a&&Number($("#nb_tickets_selected").text())>a?($("#print_exceed_max_count_error").show(),0<$("#print_multiple_supports_error").length&&($("#main_content_distribution_product_detail_info").show(),$("#print_exceed_max_count_error")[0].scrollIntoView({behavior:"smooth",block:"end",inline:"nearest"}))):(l?C():w())||$("#btn_immediate_print").parent().hasClass("disabled")||
(this.events.trigger("onBeforeDistributionFormSubmit"),m("distribution_quantity",b)&&(O(),$(".printing-item-info").prop("disabled",!1),tools.dialog.showWaitingPopup("requestProcessingDialog",!0),$(".distribution_quantity").each(function(){!$(this).prop("disabled")&&0<$(this).val()&&(c=!0)}),c&&void 0!==S&&setTimeout(function(){$("#requestProcessingDialog > p").html(S)},2E3),$("#is_automatic_distribution").attr("disabled","disabled"),b=I().attr("action"),0<b.indexOf("?")?null!=g&&null!=h?I().attr("action",
contextPath+"/pro/account/distribution/immediatePrintDetails?productId="+g+"&ticketSupport="+h):I().attr("action",contextPath+"/pro/account/distribution/immediatePrintDetails"+this.getUrlParams(b)):I().attr("action",contextPath+"/pro/account/distribution/immediatePrintDetails"),I().submit())):($("#print_multiple_supports_error").show(),0<$("#print_multiple_supports_error").length&&($("#main_content_distribution_product_detail_info").show(),$("#print_multiple_supports_error")[0].scrollIntoView({behavior:"smooth",
block:"end",inline:"nearest"})))},doEasySwitchShipment:function(a,b,c,d){t()?$("#btn_easy_switch_shipment_"+b+"_"+c).parent().hasClass("disabled")||(this.events.trigger("onBeforeDistributionFormSubmit"),m("distribution_quantity",a)&&(O(),a=I().attr("action"),d=encodeURIComponent(d),0<a.indexOf("?")?null!=g&&null!=h?I().attr("action",contextPath+("/pro/account/distribution/easySwitchShipmentAndDistribute?productId="+g+"&ticketSupport="+h)+("&srcShipmentModeId="+b+"&targetShipmentModeId="+c+"&easySwitchShipmentActionName="+
d)):I().attr("action",contextPath+"/pro/account/distribution/easySwitchShipmentAndDistribute"+this.getUrlParams(a)+("&srcShipmentModeId="+b+"&targetShipmentModeId="+c+"&easySwitchShipmentActionName="+d)):I().attr("action",contextPath+"/pro/account/distribution/easySwitchShipmentAndDistribute?srcShipmentModeId="+(b+"&targetShipmentModeId="+c+"&easySwitchShipmentActionName="+d)),I().submit())):(b="#easy_switch_shipment_multiple_supports_error_"+b+"_"+c,$(b).show(),0<$(b).length&&($("#main_content_distribution_product_detail_info").show(),
$(b)[0].scrollIntoView({behavior:"smooth",block:"end",inline:"nearest"})))},doEasySwitchShipmentOnSeatMap:function(a,b,c){if(!$("#btn_easy_switch_shipment_"+a+"_"+b).parent().hasClass("disabled")){tools.dialog.showWaitingPopup("requestProcessingDialog",!0);this.events.trigger("onBeforeEasySwitchShipmentFormSubmit",[a,b]);var d=I().attr("action");c=encodeURIComponent(c);I().attr("action",contextPath+"/pro/account/distribution/easySwitchShipment"+this.getUrlParams(d)+("&srcShipmentModeId="+a+"&targetShipmentModeId="+
b+"&easySwitchShipmentActionName="+c)+"&view="+distribution.seatmap.seatViews.getSelectedView());I().submit()}},getUrlParams:function(a){return a.substring(a.indexOf("?"))},openPanel:function(a,b){if(!$(a).parent().hasClass("disabled")){var c=$("."+b+"_action_buttons_container .triangle_tip");b=$("."+b+"_contact_selection_panel");c.css({left:$(a).offset().left-$(a).parent().parent().offset().left+$(a).outerWidth()/2});c.show();b.slideDown();$("body,html").animate({scrollTop:$("#main_content_distribution_product_detail_step2").offset().top-
12});V&&contactOrStructureSelection.return2ContactSearch()}},showContactOrStructureTag:function(){$("#buyer_box_infos").hide();$("#buyer_box_buttons").hide();$("#contact_distribution").removeClass("hidden");$("#contact_redistribution").removeClass("hidden");$("#btn_distribute").parent().addClass("disabled");$("#btn_splitAndDistribute").parent().addClass("disabled")},setPerfIdSeatCatIdToTicketsNbMap:function(a,b){D[a]=b},showSelectSeatPopup:function(a,b,c,d){a=$("#toggle_details_"+(a+"_"+b+"_"+c)).closest(".seat_cat_show_hide");
K[b]=d;$(a).hasClass("plus")?a.trigger("click"):tools.dialog.showDialog("select_seat_popup_"+b,!0);B=$.extend(!0,{},G);Z(b);ba(b)}}});
tools.module("distribution.disableF5",{doDisableF5:function(a){116===(a.which||a.keyCode)&&a.preventDefault()}});
tools.module("distribute.ticket",function(){var a,b,c,d=contextPath+"/ajax/account/file/distribute/ticket",f=function(){$("#distribute_ticket_continue_button").parent().addClass("disabled")},e=function(){$("#distribute_ticket_continue_button").parent().removeClass("disabled")},g=function(){$("#error_missing_beneficiary").hide();$("#error_distribute_ticket_missing_email").hide();$("#error_distribute_ticket").hide();$('select[name$=".contactNumber"]',"#distribute_ticket_form").each(function(a,b){$(b).closest(".beneficiary_input").removeClass("error")})},
h=function(){var f=!1;g();$('select.required_beneficiary[name$=".contactNumber"]',"#distribute_ticket_form").each(function(a,b){""===$(b).val()&&(f=!0,$(b).closest(".beneficiary_input").addClass("error"))});culturalContacts&&"function"===typeof culturalContacts.checkCulturalContacts&&!1===culturalContacts.checkCulturalContacts()&&(f=!0);if(f)$("#error_missing_beneficiary").show(),$("#distributeTicketTitle").hide(),window.scrollTo(0,0),e();else if(!f){b=$("#distribute_ticket_form");var h=b.find('select[name$=".contactNumber"]').filter(function(){return""===
$(this).val()});h.prop("disabled",!0);a=$("#distribute_ticket_fileId").val();c=contextPath+"?fileId="+a;$.ajax({type:"POST",url:d,dataType:"JSON",data:b.serialize(),success:function(a){"OK"!=a.status?("ERR_CON_CONTACT_MISSING_LOGIN"===a.status?($("#error_distribute_ticket_missing_email").show(),$("#mess_error_missing_email").html(a.parameters.messageMissingLogin),$('select[name$=".contactNumber"]',"#distribute_ticket_form").each(function(b,c){$(c).val()===a.parameters.contactNumberMissingLogin&&$(c).closest(".beneficiary_input").addClass("error")})):
"ERR_MOVEMENT_WITHOUT_TICKET"===a.status?$("#error_distribute_ticket_movement_without_ticket").show():$("#error_distribute_ticket").show(),$("#distributeTicketTitle").hide(),window.scrollTo(0,0),e(),h.prop("disabled",!1)):window.location.href=c}})}};return{getAllDistributableTicket:function(a){e();tools.dialog.showWaitingPopup("loadingDialog",!0);$.ajax({type:"GET",url:d,dataType:"html",data:{fileId:a},success:function(a){a&&$("#distribute_ticket_form_content").append(a);tools.dialog.showDialog("distribute_ticket_dialog",
!0,!0,!1,!1);tools.dialog.hideDialog("loadingDialog")}})},initBindingEventDistributeTicketForm:function(){$("#distribute_ticket_continue_button").unbind().on("click",function(){f();h()})},resetForm:function(){$("#distribute_ticket_form_content").html("");$(".distribute_ticket_error").hide();$("#distributeTicketTitle").show()},disableDistributeAction:function(){f()}}});
tools.module("distribution.guest.main",function(){var a=null,b=null,c=function(){if(a)return a();var b=$('#list_all_guests input[name="ck_guestId"]:checked'),c=[],d;for(d=0;d<b.length;d++)c.push(b[d].value);return c.join(",")},d=function(a){var c={tickets:[]};c.tickets=a.tickets;0<c.tickets.length&&distribution.guest.pagination.doPaginate(c);distribution.guest.view.render(c,b)},f=function(a){$("#editGuestButton").toggleClass("disabled",!a);$("#deleteGuestButton").toggleClass("disabled",!a)},e=function(a){if(!$("#deleteGuestButton").hasClass("disabled")){var b=
c();var d=$("#list_all_guests").find("tr.row_data_guest").length;var e=window.location.search;tools.dialog.showWaitingPopup("requestProcessingDialog",!0);tools.dialog.hideDialog("delete_guests_popup");$.ajax({type:"POST",url:contextPath+"/ajax/account/distribution/event/tickets/remove",cache:!1,data:{movementId:b},success:function(a){a.success?d===b.split(",").length?window.location.href=$(".bottom_navigation_toolbar").find(".back a").attr("href"):0<=e.indexOf("SAVE_SUCCESS")?window.location.href=
e.replace("SAVE_SUCCESS","DELETE_SUCCESS"):0<=e.indexOf("DELETE_SUCCESS")?window.location.reload():window.location.href=e+"&statusModifyGuest=DELETE_SUCCESS":"ERR_DELETE_TICKET_DIRECT_GUEST_INPUT"===a.status&&$(".delete_guest_msg_error").show()},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}})}};return{init:function(a,c,e){b=$("#list_all_guests");distribution.guest.pagination.init("#list_all_guests",a.tickets);d(a);distribution.guest.pagination.onPageChange(d);
distribution.guest.main.initButtonControllers(b,e)},addHoverButtonHandler:function(){$(".editGuest, .deleteGuest, .cannotModified").hover(function(){$(this).tipsy({className:"tipsy-hover",delayIn:0,gravity:"sw",title:function(){if($(this).hasClass("disabled")){if($(this).hasClass("editGuest"))return messageOnToolTipWhenHover.selectEditGuestsConditions;if($(this).hasClass("deleteGuest"))return messageOnToolTipWhenHover.selectDeleteGuestsConditions;if($(this).hasClass("cannotModified"))return messageOnToolTipWhenHover.cannotModified}return""}})})},
initButtonControllers:function(b,d,f){a=f;$(b).on("click","#deleteGuest",function(a){a.preventDefault();if(!$("#deleteGuestButton").hasClass("disabled"))return tools.dialog.showDialog("delete_guests_popup",!0,!1),a=c().split(",").length,a=1===a?$("#delete_guests_info p.infos_singular").text().replace("{0}",a):$("#delete_guests_info p.infos").text().replace("{0}",a),$("#delete_guests_popup .content").html(a),!1});$("#btn_cancel_delete_guest").on("click",function(a){tools.dialog.hideDialog("delete_guests_popup");
return!1});$("#btn_confirm_delete_guest").on("click",function(a){tools.dialog.hideDialog("delete_guests_popup");e();"undefined"!==typeof distribution.seatmap&&"undefined"!==typeof distribution.seatmap.seatDetails&&distribution.seatmap.seatDetails.saveLastZoomedInfoInSession();return!1});$(b).on("click","#editGuest",function(a){a.preventDefault();$("#editGuestButton").hasClass("disabled")||(tools.dialog.showWaitingPopup("requestProcessingDialog",!0),"undefined"!==typeof distribution.seatmap&&"undefined"!==
typeof distribution.seatmap.seatDetails&&distribution.seatmap.seatDetails.saveLastZoomedInfoInSession(),a=c(),a=contextPath+"/pro/account/distribution/event/tickets/detail?"+d+"&movementId="+a,window.location.href=a)})},checkAll:function(a){$("tr."+a.parentElement.parentElement.className+' input[type="checkbox"]').each(function(){this.checked=a.checked?!0:!1});var b=$('#list_all_guests input[name="ck_guestId"]:checked').length;f(0<b)},checkGuests:function(a){$("#ck_all_guestId").prop("checked",!1);
a=$('#list_all_guests input[name="ck_guestId"]:checked').length;f(0<a)}}});
tools.module("distribution.guest.pagination",function(){var a=1,b=$.Callbacks(),c=function(c,d){a!==c&&(a=c,b.fire({tickets:d}))},d=function(b,d){b.on("click",".pagination .page",function(b){$(this).hasClass("current")||($(this).hasClass("previous")?c(a-1,d):$(this).hasClass("next")?c(a+1,d):c(parseInt($(this).text(),10),d));b.preventDefault()})};return{init:function(a,b){a=$(a);d(a,b)},onPageChange:function(a){b.add(a)},doPaginate:function(b,c){var d=[],e=b.tickets[0].numberOfTicketPerPage,f;c=a;
if(b.tickets.length>e){var k=Math.floor(b.tickets.length/e);k!==b.tickets.length/e&&k++;1>c?c=1:c>k&&(c=k);a=c;var m=Math.max(1,Math.min(c-4,k-8));var p=Math.min(k,Math.max(c+4,m+8));for(f=m;f<=p;f++)d.push({index:f,selected:f===c});d={nbPages:k,page:c,pages:d,hasPages:0!==d.length,hasPrevious:1!==c,hasNext:c!==k,remainBefore:1!==m,remainAfter:p!==k};c=(c-1)*e;e=b.tickets.slice(c,c+e);e[0].isHeader=!0;b.tickets=e}else d={nbPages:0<b.tickets.length?1:0,pages:[],hasPages:!1};b.pagination=d}}});
tools.module("distribution.guest.view",function(){var a=200,b=function(b,d){d.fadeTo(a,0,function(){d.html(Mustache.render($("#ticketListOfProductItemTpl").html(),b,{ticketListOfProductItemTpl:$("#ticketListOfProductItemTpl").html()}));d.fadeTo(a,1,function(){a=200;distribution.guest.main.addHoverButtonHandler()})})};return{render:function(a,d){b(a,d)},setFadeDuration:function(b){a=b}}});
tools.module("distribution.immediatePrint",function(){var a=!1,b="",c=function(c,f){var d=!0;("object"!=typeof c?$("."+c).find(".field"):$(c)).each(function(){var a=$(this).find("input, select");$(this).removeClass("error");a.removeClass("error");if($(this).hasClass("beneficiary_boolean"))return 1>$(this).find('input[type="radio"]:checked').length&&(d=!1,$(this).addClass("error")),!0;a.each(function(){validation.validateField($(this),validation.mandatoryRule(),null,!1,f)||(d=!1)})});d&&$(".beneficiary_container, .beneficiary_questionnaire").each(function(){var c=
{method:function(a){return pesel.isValidPesel(a)},tooltipError:b};a&&pesel.needsPeselValidation($(this).find("select.country").val())&&!validation.validateField($(this).find(".id_number input"),c,null,!0,f)&&(d=!1)});return d};return{validateBeneficiary:function(a,b){c(a,b)},copyBeneficiary:function(a){var b,c;if($("#chk_copy_beneficiary_"+a).is(":checked")){var d=function(a,b){var c=2===arguments.length;var d=$(a).data("type");if("TEXT"===d||"PHONE"===d||"EMAIL"===d||"NUMBER"===d){var e=$(a).find('input:not([type="hidden"])');
if(c){e.val(b);return}return e.val()}if("LIST_SINGLE"===d||"ADDRESS"===d||"LIST_MULTI"===d||"COUNTRY"===d){e=$(a).find("select");if(c){e.val(b);"ADDRESS"===d&&e.change();return}return e.val()}if("DATE"===d)if(b=b||[],e=$(a).find("select"),c&&b.length===e.length)e.each(function(a,c){$(c).val(b[a])});else return e.map(function(){return $(this).val()}).get()};beneficiaryContainerSelector=".beneficiary_container";a&&(beneficiaryContainerSelector+="."+a);var h=$(beneficiaryContainerSelector);h.first().find(".beneficiary_question").each(function(a,
e){b=d(e);h.slice(1).each(function(){d($(this).find(".beneficiary_question").eq(a),b);"BOOLEAN"===$(e).data("type")&&(c=$(e).find('input[type="radio"]:checked'),0<c.length&&$(this).find(".beneficiary_question").eq(a).find('input[type="radio"][id*="_yes_"]').prop("checked",!0))})})}},setBeneficiary:function(a){var b="";tools.removeSelectWrapper();c("mandatory",!0)&&(a&&(b+="?questionnaireId="+a),tools.dialog.showWaitingPopup("loadingDialog",!0),a=$("#immediate_print_form"),$.ajax({type:"POST",url:contextPath+
"/ajax/pro/account/distribution/setBeneficiary"+b,cache:!1,data:a.serialize(),dataType:"json",success:function(a){window.location.href=$(".buttons_container").find(".cancel a").attr("href")+"&statusModifyGuest=SAVE_SUCCESS"},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}}))},doPrint:function(){tools.removeSelectWrapper();if(c("mandatory",!0)){var a=$("#immediate_print_form");var b="tickets"+Math.random().toString().replace(".","");window.open("",
"_"+b);a.attr("action",a.attr("action")+"print/"+b+".pdf");a.attr("target","_"+b);a.submit();$(".tickets_beneficiary").hide();$("#btn_print").hide();$("#download_ticket_info").show()}},init:function(c,f,e,g){var d=$(".beneficiary_questionnaire");b=g||"";0<d.length&&d.find(".beneficiary_address_existing").each(function(a){var b=$(this);b.find(".beneficiary_address_existing_item").hide();b.find("select").val("");b.find("select").on("change",function(){b.find(".beneficiary_address_existing_item").hide();
b.find("#beneficiary_existing_address_"+$(this).val()).show()})});a=e;distribution.immediatePrint.initDate(c,f);tools.registerAsToggleLink("toggle_button","",".beneficiary_container .toggle_content");$(c).each(function(){var a=$(this);a.find('input[name$="firstName"], input[name$="lastName"]').focus(function(b){b.preventDefault();a.find(".toggle_content").is(":hidden")&&a.find(".toggle_button").trigger("click")})})},initDate:function(a,b){$(".beneficiary_date",a).each(function(a){var c=$(this);a=
$(c).find('select[id*="_day_"]');var d=$(c).find('select[id*="_month_"]');c=$(c).find('select[id*="_year_"]');a.length&&d.length&&c.length&&(secutix.date.combos.populateCombosDatepicker(a.attr("id"),d.attr("id"),c.attr("id"),b),secutix.date.combos.dynamizeDateCombos(a.attr("id"),d.attr("id"),c.attr("id")))})},nationalityChanged:function(a){a=$(a);var b=a.parent().parent().parent();pesel.needsPeselValidation(a.val())?(b.find(".idNumberLabel").hide(),b.find(".idNumberLabelPl").show(),checkPesel=!0):
(b.find(".idNumberLabelPl").hide(),b.find(".idNumberLabel").show(),checkPesel=!1)}}});
tools.module("distribution.pagination",function(){var a={displayWindow:2,nbPerPage:10},b=$.Callbacks(),c=function(a){a=$(a).siblings(".page.current");return 0===a.length?1:parseInt($(a).text(),10)},d=function(a){$(a).on("click",".pagination .page",function(a){var d=$(this),e=c(this);d.hasClass("current")||(d=d.hasClass("previous")?e-1:d.hasClass("next")?e+1:parseInt(d.text(),10),c(this)!==d&&b.fire(d,this));a.preventDefault()})};return{init:function(a){d(a)},setPaginationConfiguration:function(b){a=
b},onPageChange:function(a){b.add(a)},doPaginate:function(b,c,d){var e=[],f=a.displayWindow,g=a.nbPerPage;if(c>g){c=Math.ceil(c/g);1>d?d=1:d>c&&(d=c);g=Math.max(1,Math.min(d-f,c-2*f));var m=Math.min(c,Math.max(d+f,g+2*f));for(f=g;f<=m;f++)e.push({index:f,selected:f===d});d={nbPages:c,page:d,pages:e,hasPages:0!==e.length,hasPrevious:1!==d,hasNext:d!==c,remainBefore:1!==g,remainAfter:m!==c};b.pagination=d}}}});
tools.module("distribution.productList",function(){var a=function(){$("#btnSubmitSearch").parent().removeClass("hidden");$("#btnClearSearch").parent().addClass("hidden")},b=function(){$("#btnSubmitSearch").parent().addClass("hidden");$("#btnClearSearch").parent().removeClass("hidden")};return{addToggleButtonHandler:function(a){$(a).click(function(a){a.preventDefault();void 0===this.state||0===this.state?(this.state=1,$(this).removeClass("less"),$(this).addClass("plus"),$(this).parent().siblings().slideUp()):
(this.state=0,$(this).removeClass("plus"),$(this).addClass("less"),$(this).parent().siblings().slideDown())})},expiredShownClicked:function(a){$("#expiredShown").val($(a).is(":checked"));this.submitFilter()},submitFilter:function(){$("#filterCriteria").submit();b()},clearFilter:function(){$("#searchProductName").val("");this.submitFilter();a()},chooseProperSearchButton:function(){""===$("#searchProductName").val()?a():b()},addSearchBoxHandler:function(){$("#searchProductName").blur(function(b){""===
$(this).val().trim()&&""!==this.defaultValue&&($("#filterCriteria").submit(),a())})}}});
tools.module("distribution.seatmap.lasso",function(){var a=null,b=!1,c=!0,d=null,f=!0,e=!1,g=null,h=0,l=!1,k=!1,m=!1,p=function(){var c=[new OpenLayers.Rule({filter:new OpenLayers.Filter.Function({evaluate:function(a){return l}}),symbolizer:{externalGraphic:contextPath+"/resources/images/buttons-icons/lassoPointerEnd.svg",graphicWidth:35,graphicHeight:25,graphicOpacity:1}}),new OpenLayers.Rule({filter:new OpenLayers.Filter.Function({evaluate:function(a){return b&&!l}}),symbolizer:{externalGraphic:contextPath+
"/resources/images/buttons-icons/lassoPointerMinus.svg",graphicWidth:35,graphicHeight:25,graphicOpacity:1}}),new OpenLayers.Rule({filter:new OpenLayers.Filter.Function({evaluate:function(a){return!b&&!l}}),symbolizer:{graphicName:"circle"}})];c=new OpenLayers.Style({strokeWidth:2,pointRadius:5,fillColor:"#83D5D5",fillOpacity:.3,strokeColor:"#83D5D5"},{rules:c});a=new OpenLayers.Layer.Vector("lasso",{renderers:OpenLayers.Layer.Vector.prototype.renderers,styleMap:new OpenLayers.StyleMap({temporary:c})});
d={lassoPolygon:new OpenLayers.Control.DrawFeature(a,OpenLayers.Handler.Polygon,{callbacks:{point:q}})};SeatMap.map.addLayer(a);SeatMap.map.addControl(d.lassoPolygon);a.events.on({featureadded:function(c){var d,e,f,g=SeatMap.getCurrentViewLayer().features,h=c.feature,l=h.geometry;m||(k=!1,m=!0,setTimeout(function(){try{for(d in g){if(k)break;g.hasOwnProperty(d)&&(e=g[d],f=e.data?e.data.id:e.attributes.id,l.intersects(e.geometry)&&!e.attributes.unselectable&&(b?distribution.seatmap.seatList.getSeat(f)&&
SeatMap.selectControl.unselect(e):distribution.seatmap.seatList.getSeat(f)||SeatMap.selectControl.select(e)))}distribution.seatmap.seatDetails.hideSeatDetails();a.removeFeatures(h);y()}finally{m=!1}},400))}});r()},q=function(a,b){h++;1===h?g=jQuery.extend(!0,{},a):2===h?e=!0:l&&d.lassoPolygon.drawFeature(b)},r=function(){var a=new OpenLayers.Control;(new OpenLayers.Handler.Keyboard(a,{keydown:function(a){(a.altKey||a.ctrlKey||a.metaKey)&&!SeatMap.isFreeSeatsCallsInProgress()&&(b=a.altKey,null!==d&&
(a=d.lassoPolygon,!a.active&&f&&(a.activate(),SeatMap.selectControl.deactivate())))},keyup:function(a){SeatMap.isFreeSeatsCallsInProgress()||(b=!1,y())}})).activate();SeatMap.map.addControl(a)},t=function(){w(SeatMap.map.getResolution());SeatMap.map.events.on({zoomend:function(a){a=this.getResolution();w(a)},mousemove:function(a){if(null!==d){var b=d.lassoPolygon;var c=SeatMap.map.getLonLatFromPixel(a.xy);var f=c.lon;c=c.lat;var k=new OpenLayers.Geometry.Point(f,c);e?l=18>=k.distanceTo(g)?!0:!1:0===
h&&(a.altKey||a.ctrlKey||a.metaKey)&&(b.insertXY(f,c),q(k))}}})},w=function(a){c&&(a>SeatMap.getCurrentViewLayer().maxResolution?(y(),f=!1):f=!0)},y=function(){if(null!==d){var a=d.lassoPolygon;a.deactivate();e=!1;g=null;h=0;l=!1;SeatMap.selectControl&&SeatMap.selectControl.activate()}};return{init:function(a){c=a.hasBlocks;SeatMap.events.on("initSeatsLayerDone",p);SeatMap.events.on("mapLoaded",t);util.dom.onDomBlur(y)},cancelAddingFeatures:function(){k=!0}}});
tools.module("distribution.seatmap.modifyGuestsFilters",function(){var a=null,b=null,c=null,d=function(a){var b=["modify-guests-filter-no-details","modify-guests-filter-partial-details","modify-guests-filter-full-details"],c=a.prop("id"),d=a.is(":checked");a=SeatMap.modifyGuestSeatsLayer.features.filter(function(a){var d=distribution.seatmap.seatDetails.isBeneficiaryFullySet(a.data.distributionTicketResult);a=distribution.seatmap.seatDetails.isAtLeastOneBeneficiaryInfoSet(a.data.distributionTicketResult);
return c===b[2]&&d||c===b[1]&&!d&&a||c===b[0]&&!d&&!a});$.each(a,function(a,b){b.attributes.filtered=!d;SeatMap.modifyGuestSeatsLayer.drawFeature(b,"filtered")})};return{init:function(){a=$("#modify-guests-filter-no-details");b=$("#modify-guests-filter-partial-details");c=$("#modify-guests-filter-full-details");a.change(function(){d($(this))});b.change(function(){d($(this))});c.change(function(){d($(this))})},isNoGuestDetailsFilterChecked:function(){return a.prop("checked")},isPartialGuestDetailsFilterChecked:function(){return b.prop("checked")},
isFullGuestDetailsFilterChecked:function(){return c.prop("checked")},getModifyGuestsFiltersContainer:function(){return $("#modifiable-guests-filters-container")}}});
tools.module("distribution.seatmap.seatDetails",function(){var a=null,b=[],c=null,d=null,f={},e=null,g=null,h=null,l=null,k=null,m=null,p=null,q=null,r=null,t=!0,w=null,y=null,z=null,x=null,A=null,C=null,u=null,v=null,D=!1,E=function(){$(r).hasClass("fullscreen")&&$(q).hide()},F=function(){var a=$("#toggle-fullscreen-button");$(q).click(function(b){b.preventDefault();$(r).hasClass("fullscreen")&&($(a).trigger("click",[!0]),tools.scrollToElement($("#main_content_distribution_product_detail_step2"),
2E3))});$(a).click(function(a){$(r).hasClass("fullscreen")&&$(q).is(":visible")?$(q).hide():0<distribution.seatmap.seatList.getSelectedSeatsSize()&&$(q).show()})},B=function(){var b=a?tools.storage.getItem("distributionSeatMap_lastZoomInfo_"+a):null;b&&SeatMap.map.setCenter(new OpenLayers.LonLat(b.center.lon,b.center.lat),b.zoomLevel);G(SeatMap.map.getResolution(),!0);SeatMap.map.events.on({zoomend:function(a){a=this.getResolution();G(a,!1)}})},G=function(a,b){if(t){$(m).hide();var c=distribution.seatmap.seatList.getSelectedSeatsSize();
a>SeatMap.getCurrentViewLayer().maxResolution?($(e).show(),0===c&&U(),$(l).hide(),$(modifyGuestsFiltersContainer).addClass("block-level"),$(modifyGuestsFiltersContainer).find("input").attr("disabled",!0)):($(e).hide(),0===c&&$(l).show(),$(modifyGuestsFiltersContainer).removeClass("block-level"),$(modifyGuestsFiltersContainer).find("input").prop("disabled",!1))}b&&!t&&$(l).show()},L=function(){var a=new OpenLayers.Control.SelectFeature(SeatMap.blocksLayer,{hover:!0,highlightOnly:!0,eventListeners:{featurehighlighted:T,
featureunhighlighted:Z}});SeatMap.map.addControl(a);a.activate();SeatMap.blocksLayer.events.on({beforefeatureadded:function(a){var b=SeatMap.additionalBlockInfo[a.feature.data.id];return b?(a.feature.attributes.fillColor="url(#"+b.gradientIdentifier+")",!0):!1},featureselected:function(a){SeatMap.selectControl.unselect(a.feature)}})},K=function(a){a=new OpenLayers.Control.SelectFeature(a,{hover:!0,highlightOnly:!0,eventListeners:{featurehighlighted:X,featureunhighlighted:O}});SeatMap.map.addControl(a);
a.activate()},H=function(b,c,d){var e=b.feature.data.id,g=a+"_"+e,h=b.feature.data.distributionTicketResult.audienceCatComplimentary;c=c.call(this,b);var k=!1;b.feature.attributes.isComplimentary=h;b.feature.attributes.unselectable=c;d&&(k=d.call(this,b.feature.data.distributionTicketResult,c));b.feature.attributes.filtered=k;null!==b.feature.data.distributionTicketResult.distributionTicket&&null!==b.feature.data.distributionTicketResult.distributionTicket.seatDefinition&&(b.feature.attributes.rotation=
b.feature.data.distributionTicketResult.distributionTicket.seatDefinition.rotation);f[g]||(f[g]=b.feature.data);distribution.seatmap.seatList.getSeat(e)&&(SeatMap.selectControl.select(b.feature),distribution.seatmap.seatDetails.hideSeatDetails());b=b.feature.data.distributionTicketResult.distributionTicket;b.shipmentModeData=u[b.ticketId]},M=function(a){return null==v?!0:Array.isArray(a.selectedFeatures)&&a.selectedFeatures.length>=v?(tools.dialog.showDialog("seatSelectionLimitExceededDialog",!0,
!0,null,"message_dialog message_warning"),distribution.seatmap.lasso.cancelAddingFeatures(),distribution.seatmap.seatDetails.hideSeatDetails(),!1):!0},Q=function(c,d){var e={data:f[a+"_"+c.feature.data.id]};if(d.call(this,c))SeatMap.selectControl.unselect(c.feature);else{distribution.seatmap.seatList.addSeat(e);d=c.feature.data.id;b.unshift(d);if(d=f[a+"_"+d])distribution.seatmap.seatDetails.displaySeatDetails(c,d,"selected"),$(p).hide(),$(modifyGuestsFiltersContainer).hide();R();$(r).hasClass("fullscreen")&&
!$(q).is(":visible")&&$(q).show()}},S=function(c,d){var e={data:f[a+"_"+c.feature.data.id]},g=c.feature.attributes.currentPage;g=g?g:1;d.call(this,c)||(distribution.seatmap.seatList.deleteSeat(e,g),d=b.indexOf(c.feature.data.id),b.splice(d,1),distribution.seatmap.seatDetails.hideSelectedSeatDetails(),U(),b.length&&(d=f[a+"_"+b[0]],$(p).hide(),$(modifyGuestsFiltersContainer).hide(),distribution.seatmap.seatDetails.displaySeatDetails(c,d,"selected")))},V=function(){K(SeatMap.seatsLayer);SeatMap.seatsLayer.events.on({beforefeatureadded:function(a){H(a,
function(a){return a.feature.data.distributionTicketResult.distributed});return!0},beforefeatureselected:function(){return M(SeatMap.seatsLayer)},featureselected:function(a){Q(a,function(a){return a.feature.data.distributionTicketResult.distributed&&!x})},featureunselected:function(a){S(a,function(a){return a.feature.data.distributionTicketResult.distributed&&!x})}})},N=function(){K(SeatMap.takeBackSeatsLayer);var a=function(a){return!a.feature.data.distributionTicketResult.canTakeBack};SeatMap.takeBackSeatsLayer.events.on({beforefeatureadded:function(b){H(b,
a);return!0},beforefeatureselected:function(){return M(SeatMap.takeBackSeatsLayer)},featureselected:function(b){Q(b,a)},featureunselected:function(b){S(b,a)}})},I=function(){K(SeatMap.modifyGuestSeatsLayer);var a=function(a){return!a.feature.data.distributionTicketResult.canModifyGuest};SeatMap.modifyGuestSeatsLayer.events.on({beforefeatureadded:function(b){H(b,a,aa);return!0},beforefeatureselected:function(){return M(SeatMap.modifyGuestSeatsLayer)},featureselected:function(b){Q(b,a)},featureunselected:function(b){S(b,
a)}})},O=function(a){R()},R=function(){c=setTimeout(function(){distribution.seatmap.seatDetails.hideHoveredSeatDetails()},10)},X=function(d){var e=d.feature.data.id;window.clearTimeout(c);0<=b.indexOf(e)||(e=f[a+"_"+e])&&distribution.seatmap.seatDetails.displaySeatDetails(d,e,"hover")},T=function(a){window.clearTimeout(d);(a=SeatMap.additionalBlockInfo[a.feature.data.id])&&Y(a)},Z=function(a){d=setTimeout(function(){$(h).hide();$(g).show()},10)},ba=function(a,b){$(b).html(Mustache.render(C,a))},U=
function(){$(p).show();distribution.seatmap.seatViews.getSelectedView()===SeatMap.MODIFY_GUEST_SEATS&&$(modifyGuestsFiltersContainer).show()},P=function(a){var b=SeatMap.getCurrentViewLayer();return b.id===SeatMap.seatsLayer.id?a.nbOfDistributableTickets:b.id===SeatMap.takeBackSeatsLayer.id?a.nbOfCanTakeBackTickets:b.id===SeatMap.modifyGuestSeatsLayer.id?a.nbOfCanModifyGuestTickets:0},Y=function(a){var b={},c=[],d=a.seatCatAvailabilityById,e=0,f=0;for(seatCatId in d)if(d.hasOwnProperty(seatCatId)){var k=
d[seatCatId];e+=P(k);f+=k.nbOfTotalTickets;k.hashSign||(k.hashSign="#",k.isSingular=1===k.nbOfTotalTickets);k.totalAvailableInContext=function(a){return function(){return P(a)}}(k);c.push(k)}b.seatCategory=c;b.availability=e;b.totalNumber=f;b.isSingular=1===f;b.blockName=a.blockName;b.showTotal=1<c.length;ba(b,h);$(h).show();$(g).hide()},da=function(a){a=String(a);1===a.length&&(a="0"+a);return a},aa=function(a,b){if(!a.distributionTicket)return!1;b=distribution.seatmap.seatDetails.isBeneficiaryFullySet(a);
a=distribution.seatmap.seatDetails.isAtLeastOneBeneficiaryInfoSet(a);return!distribution.seatmap.modifyGuestsFilters.isNoGuestDetailsFilterChecked()&&!a||!distribution.seatmap.modifyGuestsFilters.isPartialGuestDetailsFilterChecked()&&a&&!b||!distribution.seatmap.modifyGuestsFilters.isFullGuestDetailsFilterChecked()&&b},W=function(a){var b=[];b.push(a.beneficiaryFirstName);b.push(a.beneficiaryLastName);y.displayBirthdayQuestion&&b.push(a.beneficiaryBirthdate);y.displayIdNumberQuestion&&b.push(a.beneficiaryIdNumber);
y.displayNationalityQuestion&&b.push(a.beneficiaryCountry);return b};return{init:function(b){a=b.performanceId;t=b.hasBlocks;w=b.countriesByCode;y=b.beneficiaryFormConfig;z=b.displayTicketHolderToAllRelays;x=b.fromAccountSeatMap;A=b.contactName;u=b.shipmentModeByTicketId||{};v=b.seatSelectionLimit;D=b.isDistributionSeatMapWidget||!1;if(!D){g=$("#seat-details .seat_info_instruction.block");e=$("#seat-details .block_instructions_details_container");h=$("#seat-details .seat_info_block_details");l=$("#seat-details .seat-info-placeholder");
k=$("#seat-details #seat_info_instructions_container");m=$(".seat-info-content");p=$("#seat-details .remaining_tickets_container");q=$("#distribution-fullscreen-continue-button");r=$(".main_content.seat_selection");modifyGuestsFiltersContainer=distribution.seatmap.modifyGuestsFilters.getModifyGuestsFiltersContainer();F();C=$("#blockAvailabilityInfoTpl").html();SeatMap.events.on("initSeatsLayerDone",V);SeatMap.events.on("initTakeBackSeatsLayerDone",N);SeatMap.events.on("initModifyGuestSeatsLayerDone",
I);SeatMap.events.on("initBlocksLayerDone",L);SeatMap.events.on("mapLoaded",B);SeatMap.events.on("afterSwitchingViewLayer",E);if(distribution.detail)distribution.detail.events.on("onBeforeDistributionFormSubmit",distribution.seatmap.seatDetails.saveLastZoomedInfoInSession);b=$("body");(b.hasClass("ie_lte_8")||b.hasClass("ie_lte_9"))&&tools.log("GTM does not work well with VML. Please be aware that 'Click Listener' and 'Form Submit Listener' in GTM should not be enabled on this page for IE8/9. \nOtherwise it will cause an 'Attribute only valid on v:image' error.")}},
displaySeatDetails:function(a,b,c){if(!b.seatId){var d=a.feature;var e=d.data;b.seatId=e.id;b.color=b.color?b.color:e.color;b.row=e.row;b.number=e.number;b.mapId=d.layer.map.eventsDiv.id;b.geometryId=d.geometry.id;b.seatCentroid=d.geometry.getCentroid();d=e.distributionTicketResult.distributionTicket;b.block=d.block;b.blockName=d.blockName;b.area=d.area;b.fileNumber=d.fileNumber;b.culturalContact=d.culturalContact;b.invoiceNumber=d.invoiceNumber;b.invoiceContact=d.invoiceContact;b.ticketState=d.ticketState}b.geometryId=
a.feature.geometry.id;a="seat-"+c;var f=b.distributionTicketResult,g=f.audienceSubCategory,h=f.audienceCatComplimentary,p=f.distributed,q=f.ticketHolderSetByCurrentContact;d=f.distributionContactInfo;e=$("#"+a+"-distributed-to-contact-info-container");var u=$(e).find(".name"),A=$(e).find(".structure-info"),C=$(e).find(".not-yet-distributed"),x=$("#"+a+"-distributed-to-guest-info-container"),r=$(x).find(".name"),v=$(x).find(".birthday"),B=$(x).find(".passport"),t=$(x).find(".country"),D=$("#"+a+"-cannot-view-guest-info-container"),
E=null,F=$("#"+a+"-info-complement-container .seat-info-distributedTo-container");$("#"+a+"-info-category .color").css("background-color","#"+b.color);$("#"+a+"-info-category .name").html(b.seatCategory);$("#"+a+"-info-areaname").html(b.area);b.blockName?$("#"+a+"-info-blockname").html(" - "+distribution.seatmap.seatDetails._LABEL_SEAT_BLOCK+" "+b.blockName):$("#"+a+"-info-blockname").html("");b.row?$("#"+a+"-info-rowname").html(distribution.seatmap.seatDetails._LABEL_SEAT_RANK+" "+b.row):$("#"+a+
"-info-rowname").html("");var G=$("#"+a+"-info-seat-container");if(b.number){var P=$("#"+a+"-info-text"),H=$("#"+a+"-info-seat");b.row?(P.html(distribution.seatmap.seatDetails._LABEL_SEAT_NUMBER),P.addClass("with_row")):(P.html(distribution.seatmap.seatDetails._LABEL_SEAT_NUMBER),P.removeClass("with_row"));H.html(b.number);G.show()}else G.hide();b.fileNumber?($("#"+a+"-info-ticket-file-number-value").html(" "+b.fileNumber),$("#"+a+"-info-ticket-file-number-container").show()):$("#"+a+"-info-ticket-file-number-container").hide();
b.invoiceNumber?($("#"+a+"-info-ticket-invoice-number-value").html(" "+b.invoiceNumber),$("#"+a+"-info-ticket-invoice-number-container").show()):$("#"+a+"-info-ticket-invoice-number-container").hide();b.culturalContact.structureContact?b.culturalContact.structureName&&b.culturalContact.structureName?($("#"+a+"-info-ticket-contact-name-value").html(" "+b.culturalContact.structureName+" ("+b.culturalContact.contactNumber+")"),$("#"+a+"-info-ticket-contact-name-container").show()):$("#"+a+"-info-ticket-contact-name-container").hide():
b.culturalContact.firstName&&b.culturalContact.lastName&&b.culturalContact.contactNumber?($("#"+a+"-info-ticket-contact-name-value").html(" "+b.culturalContact.firstName+" "+b.culturalContact.lastName+" ("+b.culturalContact.contactNumber+")"),$("#"+a+"-info-ticket-contact-name-container").show()):$("#"+a+"-info-ticket-contact-name-container").hide();b.culturalContact.email?($("#"+a+"-info-ticket-email-address-value").html(" "+b.culturalContact.email),$("#"+a+"-info-ticket-email-address-container").show()):
$("#"+a+"-info-ticket-email-address-container").hide();b.ticketState?(G=b.ticketState.trim().replace("_"," ").toLowerCase(),G=G.charAt(0).toUpperCase()+G.slice(1),$("#"+a+"-info-ticket-ticket-status-value").html(" "+G),$("#"+a+"-info-ticket-ticket-status-container").show()):$("#"+a+"-info-ticket-ticket-status-container").hide();f&&(h?$("#"+a+"-info-is-complimentary").html(g):$("#"+a+"-info-is-complimentary").html(""),p||q?(q=(g=!q&&(f.distributionTicket&&f.distributionTicket.culturalContact?null!==
f.distributionTicket.culturalContact.structureId||null!==f.distributionTicket.culturalContact.contactNumber:!1))&&z||q,h=distribution.seatmap.seatDetails.isAtLeastOneBeneficiaryInfoSet(f),f=f.distributionTicket,q&&h?(q=f.beneficiaryFirstName,h=f.beneficiaryLastName,$(r).html(""),$(r).show(),q&&$(r).append(q+" "),h&&$(r).append(h),q||h||$(r).hide(),(r=f.beneficiaryBirthdate)&&y.displayBirthdayQuestion?(E=new Date(r),$(v).html(da(E.getDate())+"."+da(E.getMonth()+1)+"."+E.getFullYear())):$(v).html(""),
(v=f.beneficiaryIdNumber)&&y.displayIdNumberQuestion?(null!==E&&(v="- "+v),$(B).html(v)):$(B).html(""),B=f.beneficiaryCountry,w&&w[B]&&y.displayNationalityQuestion?$(t).html(w[B]):$(t).html(""),$(D).hide(),$(x).show()):(!z&&g&&h?$(D).show():$(D).hide(),$(x).hide()),g?(f.distributed?($(u).html(d[0]),d[1]?$(A).html(d[1]):$(A).html(""),$(C).hide(),$(u).show(),$(A).show()):($(u).hide(),$(A).hide(),$(C).show()),$(e).show()):$(e).hide(),$(F).show()):$(F).hide());c&&"hover"===c&&(d=$("#seat-hover-info-content"),
d.css("visibility")?null:d.css("visibility","hidden"),d.css("display","block"),d=d[0].getBoundingClientRect(),e=$(("#"+b.mapId).replaceAll(".","\\."))[0].getBoundingClientRect(),u=$(("#"+b.geometryId).replaceAll(".","\\."))[0].getBoundingClientRect(),A=Math.abs(u.y-e.y),C=Math.abs(e.y+e.height-u.y),b=u.x-e.x+(Math.abs(u.x-e.x-20)>=d.width?-d.width-20:u.width+20),d=u.y-e.y+(A>=d.height/2&&C>=d.height/2?-d.height/2:A>=d.height?-d.height+u.height:C>=d.height?0:-d.height/2),a=$("#"+a+"-info-content"),
a.css("top",d+"px"),a.css("left",b+"px"),m.css("visibility","visible"));m=$("#seat-"+c+"-info-content");$(m).show();c&&"selected"===c&&($(l).hide(),$(k).hide())},buildShopSeatDataForWidget:function(a){a=JSON.parse(JSON.stringify(a));a.seatId=a.id;var b=a.distributionTicketResult.distributionTicket;a.blockName=b.blockName;a.fileNumber=b.fileNumber;a.culturalContact=b.culturalContact;a.invoiceNumber=b.invoiceNumber;a.invoiceContact=b.invoiceContact;a.ticketState=b.ticketState;return a},hideSelectedSeatDetails:function(){m=
$("#seat-selected-info-content");$(m).hide();$(k).show();$(e).is(":visible")||$(l).show()},hideHoveredSeatDetails:function(){m=$("#seat-hover-info-content");$(m).hide()},hideSeatDetails:function(){this.hideHoveredSeatDetails();this.hideSelectedSeatDetails()},isFromAccountSeatMap:function(){return x},getContactName:function(){return A},saveLastZoomedInfoInSession:function(){D||a&&tools.storage.setItem("distributionSeatMap_lastZoomInfo_"+a,{zoomLevel:SeatMap.map.getZoom(),center:SeatMap.map.getCenter()})},
isAtLeastOneBeneficiaryInfoSet:function(a){a=a.distributionTicket;if(!a)return!1;a=W(a);a=$jscomp.makeIterator(a);for(var b=a.next();!b.done;b=a.next())if(null!==b.value)return!0;return!1},isBeneficiaryFullySet:function(a){a=a.distributionTicket;if(!a)return!1;a=W(a);a=$jscomp.makeIterator(a);for(var b=a.next();!b.done;b=a.next())if(null===b.value)return!1;return!0},seatSelectedWidget:function(b){distribution.seatmap.seatList.addSeatWidget({data:f[a+"_"+b]})},seatUnselectedWidget:function(b){distribution.seatmap.seatList.deleteSeatWidget({data:f[a+
"_"+b]})}}});
tools.module("distribution.seatmap.seatList",function(){var a={},b={},c={},d=null,f=null,e=null,g=null,h=null,l,k,m=null,p=null,q=null,r,t={},w=function(a){$(h).html(Mustache.render(m,a,q));distribution.seatmap.seatList.setSeatCatColor(h,".seatCat_summary");$(".seatCat_text").css({width:$(".seatCat_header").width()-$(".toggle_details_button_container").width()-$(".counter").width()-$(".tickets").width()-40})},y=function(a,c){var e={},f=function(){return function(a,b){return b(functions.generateAmount(this.price))}};
var h=a.seatCategoryId;var k=a.distributionTicketResult;var l=SeatMap.getCurrentViewLayer().id===SeatMap.takeBackSeatsLayer.id;var m=SeatMap.getCurrentViewLayer().id===SeatMap.modifyGuestSeatsLayer.id;c&&(b[h]?b[h].totalDistributableTickets.unshift(k):(e.performanceId=d,e.seatCategoryId=h,e.seatCategory=a.seatCategory,e.audienceSubCategory=k.audienceSubCategory,e.displayTickets=!0,e.generateAmount=f,e.totalDistributableTickets=[k],e.isSeatMap=!0,e.takeBackView=l,e.modifyGuestView=m,e.displayDistributedToColumn=
l||m||k.distributed&&distribution.seatmap.seatDetails.isFromAccountSeatMap(),e.contactName=distribution.seatmap.seatDetails.getContactName(),e.isMobileTicket="MOBILE"===g,b[h]=e))},z=function(a,c,d){var e,f=[],g=20*(c-1),h=g+20;for(e in b)b.hasOwnProperty(e)&&f.push(b[e]);a.hasSelection=0<f.length;a.selectedSeatCat=f;for(e in a.selectedSeatCat)if(a.selectedSeatCat.hasOwnProperty(e)){f=a.selectedSeatCat[e];var k=f.seatCategoryId;f.counter=f.totalDistributableTickets.length;f.isSingleSelection=1===
f.counter;k===d?(k=f.totalDistributableTickets.length,0>g&&(g=0),h>k&&(h=k),g>=k&&(g-=20,h=g+20),f.distributableTickets=f.totalDistributableTickets.slice(g,h),distribution.pagination.doPaginate(f,f.counter,c),f.closeClass=null):(k=$("#toggle_details_"+k).closest(".seat_cat_show_hide"),k.hasClass("plus")?f.closeClass="close":f.closeClass=null)}},x=function(c,d,e,f){var g={},h=d.seatCategoryId;void 0===a[c]&&(y(d,e),z(g,f,h),w(g),distribution.seatmap.selectionSummary.updateSummary(b))},A=function(a,
b){b=$(b).closest("[id^=ticketsList_]");b=$(b).attr("id").substring(12);b=parseInt(b,10);var c={};z(c,a,b);w(c)},C=function(){var b={};$.each(a,function(a,c){c=c.distributionTicketResult;a=c.operationKey;c=c.distributionTicket.ticketId;void 0!==a&&(b[a]||(b[a]=[]),b[a].push(c))});Object.keys(a).length>r?($("#notification_maxDistributableTickets_exceeded").show(),tools.scrollToElement($("#notification_maxDistributableTickets_exceeded"),"fast")):$.each(b,function(a,b){var c=$("#hidden-fields-container"),
h=$("#distrib_quantity_"+a);0===h.length&&(h=$("<input>").attr({type:"hidden",id:"distrib_quantity_"+a,name:"quantities[].quantity"}),h.addClass("distribution_quantity"),h.appendTo(c),h.wrap("<div class='distrib_seat_map_hidden_inputs'></div>"),$("<input>").attr({type:"hidden",name:"quantities[].targetItems[0].performanceId",value:d}).insertAfter(h),$("<input>").attr({type:"hidden",name:"quantities[].productId",value:e}).insertAfter(h),$("<input>").attr({type:"hidden",name:"quantities[].productType",
value:f}).insertAfter(h),$("<input>").attr({type:"hidden",name:"quantities[].distributableTicketSupport",value:g}).insertAfter(h),$("<input>").attr({type:"hidden",name:"quantities[].targetItems[0].requestItemKey",value:a}).insertAfter(h));h.nextAll('input:hidden[name^="quantities[].explicitlySelectedTickets"]').remove();b.length?(h.val(b.length),$.each(b,function(a,b){$("<input>").attr({type:"hidden",name:"quantities[].explicitlySelectedTickets["+a+"]",value:b}).insertAfter(h)})):h.val("")})},u=function(){$(h).on("click",
".seat_cat_show_hide",function(a){var b=$(this).find("[id^=toggle_details_]");b=$(b).attr("id").substring(15);b=$(h).find("#ticketsList_"+b);var c=$(this).find(".text");a.preventDefault();$(this).hasClass("plus")?($(this).removeClass("plus"),$(this).addClass("less"),$(c).text(l),$(b).slideDown().removeClass("close")):($(this).removeClass("less"),$(this).addClass("plus"),$(c).text(k),$(b).slideUp())})},v=function(){$(h).on("click",".remove_row_button",function(b){var c=!1;b=$(this).attr("id");var e=
parseInt(b.substring(11),10),f=distribution.seatmap.seatList.getSeatFeature(e),g={data:a[e]};b=$(this).closest("tr");var k=$(b).find("td");if(a[e]){e=a[e].seatCategoryId;e=$(h).find("#ticketsList_"+e+" .page.current");var l=0===e.length?1:parseInt($(e).text(),10)}$(k).wrapInner('<div style="display: block;" />');$(b).find("td > div").fadeOut("slow",function(){c||(f?(f.attributes.currentPage=l,SeatMap.selectControl.unselect(f),f.attributes.currentPage=null):(SeatSessionStorage.removeStoredSeat(d,g),
distribution.seatmap.seatList.deleteSeat(g,l)),distribution.seatmap.seatDetails.hideSeatDetails(),c=!0)})})},D=function(){SeatMap.seatsLayer.events.on({beforefeatureadded:function(a){var b=a.feature.data;a=b.seatCategoryId;b=b.color;c[a]||b&&(c[a]=b)}})},E=function(){SeatMap.takeBackSeatsLayer.events.on({beforefeatureadded:function(a){var b=a.feature.data;a=b.seatCategoryId;b=b.color;c[a]||b&&(c[a]=b)}})},F=function(b,c,d){var e={},g=0;$.each(a,function(a,b){var f=b.distributionTicketResult.distributionTicket;
a=f.shipmentModeData;b=b.culturalContact;f=f.ticketId;void 0!==b&&a&&a.id===c&&a.easySwitchTargetShipmentModeData&&a.easySwitchTargetShipmentModeData.targetShipmentModeId===d&&(a=b.contactNumber+"|"+b.email,e[a]||(e[a]=[]),e[a].push(f))});Object.keys(a).length>r?($("#notification_maxDistributableTickets_exceeded").show(),tools.scrollToElement($("#notification_maxDistributableTickets_exceeded"),"fast")):$.each(e,function(a,b){a=a.split("|");var c=$("#hidden-fields-container"),d=$("<input>").attr({type:"hidden",
name:"productType",value:f});d.appendTo(c);d.wrap("<div class='distrib_seat_map_hidden_inputs'></div>");$("<input>").attr({type:"hidden",name:"contactsWithTickets["+g+"].contact.contactNumber",value:a[0]}).insertBefore(d);$("<input>").attr({type:"hidden",name:"contactsWithTickets["+g+"].contact.email",value:a[1]}).insertBefore(d);$.each(b,function(a,b){$("<input>").attr({type:"hidden",name:"contactsWithTickets["+g+"].ticketIds["+a+"]",value:b}).insertBefore(d)});g++})};return{init:function(a){d=a.performanceId;
f=a.productType;e=a.productId;g=a.ticketSupport;r=a.maxDistributableTickets;m=$("#selectedTicketsListTpl").html();p=distribution.seatmap.seatDetails.isFromAccountSeatMap()?$("#ticketsListAccountSeatMapTpl").html():$("#ticketsListTpl").html();q={ticketsListTpl:p};h=$("#seat-list-container");k=a.showDetails;l=a.hideDetails;distribution.pagination.setPaginationConfiguration({displayWindow:4,nbPerPage:20});distribution.pagination.onPageChange(A);distribution.pagination.init(h);distribution.detail&&(distribution.detail.events.on("onBeforeDistributionFormSubmit",
C),distribution.detail.events.on("onBeforeEasySwitchShipmentFormSubmit",F));u();v();SeatMap.events.on("initSeatsLayerDone",D);SeatMap.events.on("initTakeBackSeatsLayerDone",E)},setSeatCatColor:function(a,b){a.find(b).each(function(){var a=parseInt($(this).attr("data-seatcatid"),10);(a=c[a])?$(this).find(".color").css("background-color","#"+a):$(this).find(".color").hide()})},getSeat:function(b){return a[b]},getSelectedSeats:function(){return a},getSelectedSeatsSize:function(){var b=0,c;for(c in a)a.hasOwnProperty(c)&&
b++;return b},getSeatFeature:function(a){var b,c=SeatMap.getCurrentViewLayer().features;for(b in c)if(c.hasOwnProperty(b)){var d=c[b];if(a===d.data.id)return d}return null},addSeat:function(b){var c=b.data.id;x(c,b.data,!0,1);void 0===a[c]&&(a[c]=b.data,this.hasShipmentModeData(b)&&distribution.seatmap.switchShipmentHandler.handleSelectTicket(b))},clearSelectedSeatsWidget:function(){var b=this;Object.values(a).forEach(function(a){b.deleteSeatWidget(a)})},applySeatListWidget:function(b){var c=this;
Array.isArray(b)&&(a&&0!==a.length?(this.clearSelectedSeatsWidget(),b.forEach(function(a){c.addSeatWidget(a)}),this.updateButtonsState()):b.forEach(function(a){c.addSeatWidget(a)}))},updateButtonsState:function(){null===t||$.isEmptyObject(t)?($("#btn_distribute_tickets, #btn_immediate_print, #btn_redistribute_tickets").parent().addClass("disabled"),$("[id^=btn_easy_switch_shipment]").parent().addClass("disabled"),$("#btn_distribute, #btn_splitAndDistribute, #btn_redistribute").parent().addClass("disabled"),
$("[id^=btn_distribute_and_easy_switch_shipment], [id^=btn_redistribute_and_easy_switch_shipment]").parent().addClass("disabled")):($("#btn_distribute_tickets, #btn_immediate_print, #btn_redistribute_tickets").parent().removeClass("disabled"),this.updateSwitchShipmentButtonsStateWidget("[id^=btn_easy_switch_shipment]"),this.isSwitchShipmentAndDistributeBtnEnableWidget()&&($("#btn_distribute, #btn_splitAndDistribute, #btn_redistribute").parent().removeClass("disabled"),this.updateSwitchShipmentButtonsStateWidget("[id^=btn_distribute_and_easy_switch_shipment], [id^=btn_redistribute_and_easy_switch_shipment]")))},
addSeatWidget:function(b){b=distribution.seatmap.seatDetails.buildShopSeatDataForWidget(b);var c=b.id;void 0===a[c]&&(a[c]=b,this.hasShipmentModeDataWidget(b)&&(b=b.distributionTicketResult.distributionTicket.shipmentModeData.id,t[b]=(t[b]||0)+1))},handleSelectContactSuccessWidget:function(){this.isSwitchShipmentAndDistributeBtnEnableWidget()&&!$("[id^=btn_distribute_and_easy_switch_shipment], [id^=btn_redistribute_and_easy_switch_shipment]").parent().hasClass("disabled")&&(null===t||$.isEmptyObject(t)?
($("#btn_distribute, #btn_splitAndDistribute, #btn_redistribute").parent().addClass("disabled"),$("[id^=btn_distribute_and_easy_switch_shipment], [id^=btn_redistribute_and_easy_switch_shipment]").parent().addClass("disabled")):this.updateSwitchShipmentButtonsStateWidget("[id^=btn_distribute_and_easy_switch_shipment], [id^=btn_redistribute_and_easy_switch_shipment]"))},updateSwitchShipmentButtonsStateWidget:function(a){$(a).each(function(){var a=$(this).find("input.source_shipment").val();t.hasOwnProperty(a)?
$(this).parent().removeClass("disabled"):$(this).parent().addClass("disabled")})},isSwitchShipmentAndDistributeBtnEnableWidget:function(){return $("#distribution_contact_selection, #redistribution_contact_selection").is(":visible")},deleteSeat:function(c,d){if(c){var e=c.data.id;var f=c.data;var g=f.seatCategoryId;var h=b[g].totalDistributableTickets;a[e]&&delete a[e];a:{var k=f.distributionTicketResult;var l;for(l in h)if(h.hasOwnProperty(l)){var m=h[l];if(m.distributionTicket.ticketId===k.distributionTicket.ticketId){k=
l;break a}}k=-1}-1<k&&(h.splice(k,1),b[g].pagination=null,0===h.length&&delete b[g]);x(e,f,!1,d);this.hasShipmentModeData(c)&&distribution.seatmap.switchShipmentHandler.handleUnselectTicket(c)}},deleteSeatWidget:function(b){if(b){var c=b.id;a[c]&&delete a[c];this.hasShipmentModeDataWidget(b)&&(b=b.distributionTicketResult.distributionTicket.shipmentModeData.id,t[b]&&(t[b]--,0===t[b]&&delete t[b]))}},getMovementIdsFromSeatList:function(){var b=[],c,d;$.each(a,function(a,e){(c=e.distributionTicketResult)&&
(d=c.distributionTicket)&&b.push(d.movementId)});return b.join(",")},hasShipmentModeData:function(a){return"undefined"!==typeof distribution.seatmap.switchShipmentHandler&&a.data.distributionTicketResult.distributionTicket.shipmentModeData&&a.data.distributionTicketResult.distributionTicket.shipmentModeData.id},hasShipmentModeDataWidget:function(a){return a.distributionTicketResult.distributionTicket.shipmentModeData&&a.distributionTicketResult.distributionTicket.shipmentModeData.id}}});
tools.module("distribution.seatmap.seatViews",function(){var a=null,b=null,c=null,d=void 0,f=null,e=null,g=null,h=null,l=null,k=null,m=null,p=null,q=null,r=null,t=null,w=null,y=null,z=null,x=null,A=null,C=null,u=null,v=null,D=null,E=null,F=null,B=null,G=null,L=!1,K=function(a,b){$(G).html(a);$(B).html(b);$(F).show()},H=function(a){e.hide();g.hide();d=SeatMap.ASSIGN_SEATS;T();R();f.show();a||SeatMap.switchSeatsLayer(SeatMap.ASSIGN_SEATS);h.hide();K(A,C);contactOrStructureSelection.updateDistributionMode("distribution")},
M=function(a){f.hide();g.hide();d=SeatMap.TAKE_BACK_SEATS;T();R();e.show();a||SeatMap.switchSeatsLayer(SeatMap.TAKE_BACK_SEATS);h.hide();K(u,v);contactOrStructureSelection.updateDistributionMode("redistribution")},Q=function(a){f.hide();e.hide();d=SeatMap.MODIFY_GUEST_SEATS;T();R();X();g.show();a||SeatMap.switchSeatsLayer(SeatMap.MODIFY_GUEST_SEATS);h.show();K(D,E);contactOrStructureSelection.updateDistributionMode("distribution")},S=function(){d!==SeatMap.TAKE_BACK_SEATS&&d!==SeatMap.MODIFY_GUEST_SEATS&&
ba(a)},V=function(){SeatMap.takeBackSeatsLayer.events.on({featureselected:function(a){R()},featureunselected:function(a){R()}});d===SeatMap.TAKE_BACK_SEATS&&ba(b)},N=function(){SeatMap.modifyGuestSeatsLayer.events.on({featureselected:function(a){X()},featureunselected:function(a){X()}});d===SeatMap.MODIFY_GUEST_SEATS&&ba(c)},I=function(){return Object.keys(distribution.seatmap.seatList.getSelectedSeats()).length},O=function(a){var b=distribution.seatmap.seatList.getSelectedSeats(),c=0;SeatMap.getCurrentViewLayer()&&
SeatMap.getCurrentViewLayer().id===a&&(c=Object.keys(b).length);return c},R=function(){var a=O(SeatMap.takeBackSeatsLayer.id);1<a?$(".content","#takeback-tickets-instruction-message").html(m.replace("{0}",a)):1===a?$(".content","#takeback-tickets-instruction-message").html(k.replace("{0}",a)):$(".content","#takeback-tickets-instruction-message").html(l);0<a?$("#btn_take_back").parent().removeClass("disabled"):$("#btn_take_back").parent().addClass("disabled")},X=function(){var a=O(SeatMap.modifyGuestSeatsLayer.id),
b=$(".content","#modify-guests-instruction-message");1<a?$(b).html(w.replace("{0}",a)):1===a?$(b).html(t.replace("{0}",a)):$(b).html(r);$("#modify_guests_action_buttons .button").toggleClass("disabled",0>=a)},T=function(){d===SeatMap.TAKE_BACK_SEATS?$("#main_content_distribution_product_detail_step2").find(".main_title").html(z):d===SeatMap.MODIFY_GUEST_SEATS?$("#main_content_distribution_product_detail_step2").find(".main_title").html(x):$("#main_content_distribution_product_detail_step2").find(".main_title").html(y)},
Z=function(){$(".view_link_container").unbind("click").on("click",function(){$(this).hasClass("selected")||ba(this)});$("#btn_take_back").unbind("click").on("click",function(a){$(this).parent().hasClass("disabled")||(a=L?I():O(SeatMap.takeBackSeatsLayer.id),1<a?$(".content","#takeback_confirm_dialog").html(q.replace("{0}",a)):$(".content","#takeback_confirm_dialog").html(p.replace("{0}",a)),tools.dialog.showDialog("takeback_confirm_dialog",!0,!1));return!1});$("#btn_cancel_takeback").unbind("click").on("click",
function(a){tools.dialog.hideDialog("takeback_confirm_dialog");return!1});$("#btn_confirm_takeback").unbind("click").on("click",function(a){tools.dialog.hideDialog("takeback_confirm_dialog");a=$("#takeback_form");var b=distribution.seatmap.seatList.getMovementIdsFromSeatList();$("#movementIds","#takeback_form").val(b);0===b.length||$("#btn_take_back").parent().hasClass("disabled")||(void 0!==d&&(b=a.attr("action"),b=b+"&view="+d,a.attr("action",b)),tools.form.submitWithProcessing(a));distribution.seatmap.seatDetails.saveLastZoomedInfoInSession();
return!1})},ba=function(d,e){e=void 0===e?!1:e;$(".view_link_container").removeClass("selected");$(d).addClass("selected");e||$.isEmptyObject(SeatMap.hiddenSeats)||SeatMap.hiddenSeats[SeatMap.getCurrentViewLayer().id].forEach(function(a,b){b.attributes.unselectable=!1});a.hasClass("selected")?H(e):b.hasClass("selected")?M(e):c.hasClass("selected")&&Q(e)};return{init:function(H){l=H.takeBackInstructionNoSelected;k=H.takeBackInstructionSingle;m=H.takeBackInstructionPlural;p=H.takeBackConfirmationMsgSingle;
q=H.takeBackConfirmationMsgPlural;r=H.modifyGuestsInstructionNoSelected;t=H.modifyGuestsInstructionSingle;w=H.modifyGuestsInstructionPlural;y=H.step2SectionTitle;z=H.step2TakeBackSectionTitle;x=H.step2ModifyGuestsSectionTitle;A=H.distributableTicketsNum;C=H.distributableTicketsLabel;u=H.cancelableTicketsNum;v=H.cancelableTicketsLabel;D=H.modifiableTicketsNum;E=H.modifiableTicketsLabel;F=$("#seat-details .remaining_tickets_container");B=$("#seat-details .remaining_tickets_container .remaining_text");
G=$("#seat-details .remaining_tickets_container .remaining_number");d=H.selectedView;a=$("#view-assign-seats-link");b=$("#view-take-back-seats-link");c=$("#view-modify-guests-link");h=distribution.seatmap.modifyGuestsFilters.getModifyGuestsFiltersContainer();f=$("#main_content_distribution_step2_assign_seats");e=$("#main_content_distribution_step2_take_back_tickets");g=$("#main_content_distribution_step2_modify_guests");f.hide();e.hide();g.hide();Z();H.editGuestParams&&distribution.guest.main.initButtonControllers($("#modify_guests_action_buttons"),
H.editGuestParams,distribution.seatmap.seatList.getMovementIdsFromSeatList);L=H.isDistributionSeatMapWidget||!1;L||(SeatMap.events.on("initSeatsLayerDone",S),SeatMap.events.on("initTakeBackSeatsLayerDone",V),SeatMap.events.on("initModifyGuestSeatsLayerDone",N),SeatMap.events.on("beforeSwitchingViewLayer",function(){distribution.seatmap.selectionSummary.resetSummary()}),SeatMap.events.on("afterSwitchingViewLayer",function(){distribution.seatmap.selectionSummary.resetSummary()}))},getSelectedView:function(){return d},
updateNumberOfTickets:function(a,b,c,d){A=b;u=c;D=d;ba(a,!0)},changeSeatViewWidget:function(a){distribution.seatmap.seatList.clearSelectedSeatsWidget();a===SeatMap.ASSIGN_SEATS?(d=SeatMap.ASSIGN_SEATS,e.hide(),g.hide(),f.show(),T(),contactOrStructureSelection.updateDistributionMode("distribution")):a===SeatMap.TAKE_BACK_SEATS?(d=SeatMap.TAKE_BACK_SEATS,f.hide(),g.hide(),e.show(),T(),contactOrStructureSelection.updateDistributionMode("redistribution")):a===SeatMap.MODIFY_GUEST_SEATS&&(d=SeatMap.MODIFY_GUEST_SEATS,
f.hide(),e.hide(),g.show(),T(),contactOrStructureSelection.updateDistributionMode("distribution"))},updateSeatViewsAfterSeatSelectionChanged:function(){if(d===SeatMap.TAKE_BACK_SEATS){if(d===SeatMap.TAKE_BACK_SEATS){var a=I();1<a?$(".content","#takeback-tickets-instruction-message").html(m.replace("{0}",a)):1===a?$(".content","#takeback-tickets-instruction-message").html(k.replace("{0}",a)):$(".content","#takeback-tickets-instruction-message").html(l);0<a?$("#btn_take_back").parent().removeClass("disabled"):
$("#btn_take_back").parent().addClass("disabled")}}else if(d===SeatMap.MODIFY_GUEST_SEATS&&d===SeatMap.MODIFY_GUEST_SEATS){a=I();var b=$(".content","#modify-guests-instruction-message");1<a?$(b).html(w.replace("{0}",a)):1===a?$(b).html(t.replace("{0}",a)):$(b).html(r);$("#modify_guests_action_buttons .button").toggleClass("disabled",0>=a)}}}});
tools.module("distribution.seatmap.selectionSummary",function(){var a=null,b=null,c=null,d=null;return{init:function(f){c=f.performanceId;a=$("#selection-summary-container");b=$("#selectionSummaryTpl").html();d=f.seatCatSummaryMap;a.on("click",".seat-info-sub-title",function(b){b=$(this).find(".collapse");var c=$(this).find(".expand");a.find(".summary-content").toggle("blind",{direction:"up"});b.hasClass("hidden")?(b.removeClass("hidden"),c.addClass("hidden")):(b.addClass("hidden"),c.removeClass("hidden"))});
a.on("click","#remove_all_selection",function(a){distribution.seatmap.selectionSummary.resetSummary()})},resetSummary:function(){var a=distribution.seatmap.seatList.getSelectedSeats(),b;for(b in a)if(a.hasOwnProperty(b)){var d=parseInt(b,10);d=distribution.seatmap.seatList.getSeatFeature(d);var h={data:a[b]};d?SeatMap.selectControl.unselect(d):distribution.seatmap.seatList.deleteSeat(h,1)}SeatSessionStorage.clearEvent(c);distribution.seatmap.seatDetails.hideSeatDetails()},updateSummary:function(c){var e=
{};e=[];var f={},h=!jQuery.isEmptyObject(c),l=0,k,m;if(h)for(k in d)if(d.hasOwnProperty(k)){var p=0;var q=d[k];f=c[k];var r={};for(m in q)if(q.hasOwnProperty(m)){var t=q[m];var w=t.audienceSubCategoryId;var y={audSubCatId:w,audSubCat:t.audienceSubCategory,isComplimentary:t.audienceCatComplimentary,countByAudSubCat:0};r[w]=y;y=t.seatCategory}f&&($.each(f.totalDistributableTickets,function(a,b){r[b.audienceSubCategoryId].countByAudSubCat+=1}),p=f.counter);for(tempAudSubCatId in r)r[tempAudSubCatId].hideAudSubCat=
0===r[tempAudSubCatId].countByAudSubCat?!0:!1;f=$.map(r,function(a){return a});f={seatCategoryId:k,seatCategory:y,countBySeatCat:p,hideSeatCat:0===p?!0:!1,audSubCats:f};e.push(f);l+=p}e={hasSelection:h,seatCats:e,totalSeatCount:l};a.html(Mustache.render(b,e));distribution.seatmap.seatList.setSeatCatColor(a,".seat-cat");$(".seat-cat-title .name").css({width:$("#seat-details").width()-$(".count-per-cat").width()-30})}}});
tools.module("distribution.seatmap.switchShipmentHandler",function(){var a={},b=function(b){$(b).each(function(){var b=$(this).find("input.source_shipment").val();var c=$(this).is("[id^=btn_easy_switch_shipment]");b=a.hasOwnProperty(b)?c?a[b].switchShipmentPossibleTickets:a[b].totalTickets:0;c=$(this);0<b?c.parent().removeClass("disabled"):c.parent().addClass("disabled")})},c=function(){null===a||$.isEmptyObject(a)?($("#btn_distribute_tickets, #btn_immediate_print, #btn_redistribute_tickets").parent().addClass("disabled"),
$("[id^=btn_easy_switch_shipment]").parent().addClass("disabled"),$("#btn_distribute, #btn_splitAndDistribute, #btn_redistribute").parent().addClass("disabled"),$("[id^=btn_distribute_and_easy_switch_shipment], [id^=btn_redistribute_and_easy_switch_shipment]").parent().addClass("disabled")):($("#btn_distribute_tickets, #btn_immediate_print, #btn_redistribute_tickets").parent().removeClass("disabled"),b("[id^=btn_easy_switch_shipment]"),$("#distribution_contact_selection, #redistribution_contact_selection").is(":visible")&&
($("#btn_distribute, #btn_splitAndDistribute, #btn_redistribute").parent().removeClass("disabled"),b("[id^=btn_distribute_and_easy_switch_shipment], [id^=btn_redistribute_and_easy_switch_shipment]")))},d=function(a,b){return{totalTickets:a,switchShipmentPossibleTickets:b}},f=function(b,c,f){var e=a[b]||d(0,0),g=e.totalTickets;e=e.switchShipmentPossibleTickets;g+=f;c&&(e+=f);if(e>g)throw Error("Switch shipment possible tickets should never be larger than total tickets, \n        switchShipmentPossibleTickets = "+
e+", totalTickets = "+g);0>=g?delete a[b]:a[b]=d(g,e)};return{init:function(){$("#btn_distribute_tickets, #btn_immediate_print, #btn_redistribute_tickets").parent().addClass("disabled");$("[id^=btn_easy_switch_shipment]").parent().addClass("disabled")},handleSelectTicket:function(a){f(a.data.distributionTicketResult.distributionTicket.shipmentModeData.id,a.data.distributionTicketResult.distributionTicket.switchShipmentPossible,1);c()},handleUnselectTicket:function(a){f(a.data.distributionTicketResult.distributionTicket.shipmentModeData.id,
a.data.distributionTicketResult.distributionTicket.switchShipmentPossible,-1);c()},handleSelectContactSuccess:function(){$("#distribution_contact_selection, #redistribution_contact_selection").is(":visible")&&!$("[id^=btn_distribute_and_easy_switch_shipment], [id^=btn_redistribute_and_easy_switch_shipment]").parent().hasClass("disabled")&&(null===a||$.isEmptyObject(a)?($("#btn_distribute, #btn_splitAndDistribute, #btn_redistribute").parent().addClass("disabled"),$("[id^=btn_distribute_and_easy_switch_shipment], [id^=btn_redistribute_and_easy_switch_shipment]").parent().addClass("disabled")):
b("[id^=btn_distribute_and_easy_switch_shipment], [id^=btn_redistribute_and_easy_switch_shipment]"))}}});
tools.module("distribution.ticketDistribution",function(){var a={elResultLoading:".result_loading",elResultText:".result_text",elResultData:".result_data",ajaxLoading:!1,isDistributeSuccessful:!1},b=function(a){$("#exportTicketButton").toggleClass("disabled",!a)},c=function(a){var b=[],c={ERROR:"error",WARNING:"warning",INFO:"info"},d;for(d in a)a.hasOwnProperty(d)&&b.push('<span class="log_line_result '+c[a[d].messageSeverity]+'">'+a[d].internalMessage+"</span>");return b.join("</br>")+"</br>"},
d=function(b){var c=$("#importTicketDetail_result"),d=$("#importTicketDetail_container");$(a.elResultText).html("");$(a.elResultData).html("");b?(c.show(),d.hide()):(c.hide(),d.show(),$(a.elResultLoading).hide())},f=function(){deleteUploadField(0);tools.dialog.showDialog("ajaxErrorDialog",!0)},e=function(b){$(".importBtnCls").addClass("disabled");d(!0);$(a.elResultText).html(b);$(a.elResultText).show();$(a.elResultLoading).show()};return{addHoverButtonHandler:function(a){$("#exportTicketButton").hover(function(){$(this).tipsy({className:"tipsy-hover",
delayIn:0,gravity:"sw",title:function(){return $(this).hasClass("disabled")?a.message.selectExportTicketConditions:""}})})},checkAll:function(a){var c=document.getElementsByName("ck_distribution_item_id"),d=!1,e;var f=0;for(e=c.length;f<e;f++)c[f].checked=a.checked;a.checked&&(d=!0);b(d)},checkDistributionItem:function(){var a=document.getElementsByName("ck_distribution_item_id"),c=!1;$("#ck_all_distribution_item").prop("checked",!1);var d=0;for(n=a.length;d<n;d++)if(a[d].checked){c=!0;break}b(c)},
exportTicketDetail:function(a,b,c,d,e){if(!$("#exportTicket").parent().hasClass("disabled")){var f=$('.dashboard input[name="ck_distribution_item_id"]:checked');var g=[],h;for(h=0;h<f.length;h++)g.push(f[h].value);f=g.join(",");a=a+"/report/generate/ExportTicketDistributionDetail?productIds="+b+"&ticketSupport="+c+"&exportType="+d;if(f)switch(e){case "EVENT":case "SPORTING_EVENT":a+="&performanceIds="+f;break;case "VISIT_PASS":case "TIMESLOT_PASS":a+="&timeslotIds="+f;break;case "SERVICE":case "VOUCHER":case "PASS":a+=
"&itemIds="+f}window.open(a)}},closeImportTicketPopupFunction:function(){tools.dialog.hideDialog("distribution_import_ticket_details_popup");a.isDistributeSuccessful&&location.reload()},importTicketDetail:function(){tools.dialog.showDialog("distribution_import_ticket_details_popup",!0,!1,distribution.ticketDistribution.closeAndSwitchToImportTicketDetailField,"");a.currentExecutionId&&!a.ajaxLoading&&(e(a.labels.importInprogress),distribution.ticketDistribution.callToGetExecutionResult(null))},callImportTicketDetail:function(b){var c=
new FormData(document.forms[0]),d=$("#notify_recipient").is(":checked");b.preventDefault();c.append("file",$(".input_upload_hidden")[0].files[0]);c.append("productId",a.productId);c.append("ticketSupport",a.ticketSupport);c.append("notifyRecipient",d);a.ajaxLoading=!0;e(a.labels.importStart);$.ajax({url:$("#file_upload_form").attr("action"),type:"POST",data:c,cache:!1,contentType:!1,processData:!1,success:function(b){a.ajaxLoading=!1;b.success?(a.currentExecutionId=b.parameters.currentExecutionId,
distribution.ticketDistribution.callToGetExecutionResult(null)):"TICKET_DISTRIBUTION_INVALID_UPLOAD_FILE"===b.status?(handleErrorMessage(0,a.labels.errorInvalidFileType),distribution.ticketDistribution.switchToImportTicketDetailField()):"TICKET_DISTRIBUTION_UPLOAD_FAIL"===b.status&&(distribution.ticketDistribution.closeImportTicketPopupFunction(),f())},error:function(a){tools.userAborted(a)||(distribution.ticketDistribution.closeImportTicketPopupFunction(),f())}})},closeAndSwitchToImportTicketDetailField:function(){distribution.ticketDistribution.closeImportTicketPopupFunction();
a.ajaxLoading||distribution.ticketDistribution.switchToImportTicketDetailField()},switchToImportTicketDetailField:function(){deleteUploadField(0);d(!1)},callToGetExecutionResult:function(b){var e=a.contextPath+"/ajax/pro/account/distribution/dashboard/import/executionResult";null!==b&&(e+="?lastExportDate="+b);a.ajaxLoading=!0;$.ajax({type:"GET",url:e,success:function(e){e.success?($(a.elResultText).hide(),e.logLinesDtos&&0<e.logLinesDtos.length&&(null==b&&""!==$(a.elResultData).html().trim()&&$(a.elResultData).html(""),
$(a.elResultData).append(c(e.logLinesDtos)),a.isDistributeSuccessful=!0),e.executionOver?""===$(a.elResultData).html().trim()?distribution.ticketDistribution.callToGetExecutionResult(null):(a.currentExecutionId=null,a.ajaxLoading=!1,$(".importBtnCls").removeClass("disabled"),$(a.elResultLoading).hide()):setTimeout(function(){distribution.ticketDistribution.callToGetExecutionResult(e.parameters.lastExportDate?e.parameters.lastExportDate:null)},5E3)):(d(!1),f(),distribution.ticketDistribution.closeImportTicketPopupFunction())},
error:function(a){tools.userAborted(a)||(d(!1),f(),distribution.ticketDistribution.closeImportTicketPopupFunction())}})},initExcelExportMessage:function(){$("#export_excel_button").on("click",function(){var a=0,b="";$(".export-excel-notification").hide();var c=function(){var b=$(this).text();/\s*\d+\s*/.test(b)&&(a+=parseInt(b,10))};var d=$(".dashboard .total_row .total.number");d.length?d.each(c):$("#main_content_distribution_tickets_list td.number").each(c);2E3<a?b="_huge":100<a&&(b="_large");$("#export_excel_button_notification"+
b).fadeIn("fast")})},initImportTicketDetail:function(b){a.productId=b.productId;a.ticketSupport=b.ticketSupport;a.currentExecutionId=b.currentExecutionId;a.labels=b.labels;a.contextPath=b.contextPath;$(".import_ticket_details_button_container #importBtn").on("click",function(a){$(".importBtnCls").hasClass("disabled")||distribution.ticketDistribution.switchToImportTicketDetailField();a.preventDefault()})}}});
tools.module("distributionPortal.addressBook",function(){var a,b=null,c=function(){a=null;$("#selectAddressBookPopup .stx-ab-clear-button").click()},d=function(a,b){var c=distributionPortal.distributionCart.getCartData();return c&&c.cartItems&&0!==c.cartItems.length?a&&c.cartItems.find(function(b){return b.targetAddressBookId===a})||b&&c.cartItems.find(function(a){return a.targetrContactNumber===b})?(tools.dialog.hideDialog("selectAddressBookPopup"),!0):!1:!1};return{saveSelectedAddressBookHandler:function(){if(a&&
a.id){var c=distributionPortal.distributionCart,e=c.getCartData();if(void 0===b||null==b){if(!d(a.id,null)){var g={targetAddressBookId:a.id,firstName:a.firstName,lastName:a.lastName,isTempItem:!0,totalTickets:0};if(e&&e.cartItems&&0<e.cartItems.length){if(e.cartItems.length>=e.ticketLimit.maxRecipients){distributionPortal.commonMessageHandler.displayStatus("WARN_MAX_RECIPIENTS",{ticketLimit:{maxRecipients:e.ticketLimit.maxRecipients}});return}e.cartItems.push(g)}else e.cartItems=[g];c.setCartItemSelectedKey(c.buildItemKey({targetAddressBookId:a.id}));
c.setCartData(e);tools.dialog.hideDialog("selectAddressBookPopup")}}else if(g=e.cartItems.findIndex(function(a){return a.key===b}),-1!==g){if(e.cartItems[g].targetAddressBookId!==a.id)if(e.cartItems[g].isTempItem){if(d(a.id,null))return;e.cartItems[g].targetAddressBookId=a.id;e.cartItems[g].firstName=a.firstName;e.cartItems[g].lastName=a.lastName;c.setCartItemSelectedKey(c.buildItemKey({targetAddressBookId:a.id}));c.setCartData(e)}else c.setCartItemSelectedKey(c.buildItemKey({targetAddressBookId:a.id})),
c.switchTarget(e.cartItems[g],a.id);tools.dialog.hideDialog("selectAddressBookPopup")}}else tools.dialog.hideDialog("selectAddressBookPopup")},cancelSelectedAddressBookHandler:function(){tools.dialog.hideDialog("selectAddressBookPopup")},selectedAddressBookHandler:function(b,c){switch(b){case "AB_SELECTED":a=c;break;case "AB_UNSELECTED":a=null}},openSelectAddressBookPopup:function(a,d){d&&(d.preventDefault(),d.stopPropagation());b=a;tools.dialog.showDialog("selectAddressBookPopup",!0,!1,c)}}});
tools.module("distributionPortal.api",function(){var a=contextPath+"/account/distribution/distributionPortal",b=contextPath+"/ajax/account/distribution/distributionPortal",c=function(a,b,c,d,e,f,g){g||(tools.dialog.hideDialog("requestProcessingDialog"),tools.dialog.hideDialog("loadingDialog"));a.success?(f&&functions.showToastMessage({title:e||"",message:f,type:"success",duration:3E3}),"function"===typeof c&&c(a,b)):"function"===typeof d&&d(a,b)},d=function(a,b,c,d){d||(tools.dialog.hideDialog("requestProcessingDialog"),
tools.dialog.hideDialog("loadingDialog"));"function"===typeof c&&c(a,b)},f=function(a,b,c,d,e,f,g){e=void 0===e?"success":e;g||(tools.dialog.hideDialog("requestProcessingDialog"),tools.dialog.hideDialog("loadingDialog"));d&&functions.showToastMessage({title:c||"",message:d,type:e,duration:3E3});"function"===typeof f&&f(a)},e=function(a){return a.map(function(a){return a.then(function(a){return{success:!0,value:a}},function(a){return{success:!1,value:a}})})},g=function(a,e,f){return $.ajax({type:"POST",
url:b+"/distributeTickets",cache:!1,contentType:"application/json",data:JSON.stringify(a)}).then(function(b){var c=$.Deferred();b.success?c.resolve({params:a,response:b}):c.reject({params:a,response:b});return c.promise()}).done(function(b){c(b.response,a,e,f,null,null,!0)}).fail(function(b){d(b.response,a,f,!0)})},h=function(a,b,e){return $.ajax({type:"POST",url:"/ajax/distributionPortal/linkAddressBook",cache:!1,contentType:"application/json",data:JSON.stringify(a)}).then(function(b){var c=$.Deferred();
b.success?c.resolve({params:a,response:b}):c.reject({params:a,response:b});return c.promise()}).done(function(d){c(d.response,a,b,e,null,null,!0)}).fail(function(b){d(b.response,a,e,!0)})},l=function(a,b,c){return a?h(a,b,c):(a=$.Deferred(),a.resolve(),a.promise())};return{loadDistributionProductData:function(b,e,f){$.ajax({type:"GET",url:a+"/listProducts.json",dataType:"json",data:b,success:function(a){c(a,b,e,f)},error:function(a){d(a,b,f)}})},loadConfirmDistributionData:function(b,e,f){tools.dialog.showWaitingPopup("loadingDialog",
!0);$.ajax({type:"GET",url:a+"/confirmation/cartData.json",dataType:"json",data:b,success:function(a){c(a,b,e,f,null,null,!1)},error:function(a){d(a,b,f,!1)}})},addToDistributionCart:function(a,e,f,g){g=void 0===g?!0:g;return $.ajax({type:"POST",url:b+"/addToCart",cache:!1,contentType:"application/json",data:JSON.stringify(a),success:function(b){$("#distributionCartAjaxDialog .add-to-cart-ok .number-tickets").html(b.data.numberOfSuccessTicket);if(g){var d=$("#distributionCartAjaxDialog .add-to-cart-ok .content").text().trim();
c(b,a,e,f,null,d)}return b},error:function(b){d(b,a,f)}})},loadCartSummaryData:function(b,e,f){$.ajax({type:"GET",url:a+"/cartData.json",dataType:"json",success:function(a){c(a,b,e,f,null,null,!0)},error:function(a){d(a,b,f,!0)}})},switchTarget:function(a,e,f){$.ajax({type:"POST",url:b+"/switchTarget",cache:!1,contentType:"application/json",data:JSON.stringify(a),success:function(b){var d=$("#distributionCartAjaxDialog .switch-target-ok .content").text().trim();c(b,a,e,f,null,d)},error:function(b){d(b,
a,f)}})},deleteTickets:function(a,e,f){$.ajax({type:"POST",url:b+"/deleteTickets",cache:!1,contentType:"application/json",data:JSON.stringify(a),success:function(b){var d=$("#distributionCartAjaxDialog .remove-from-cart-ok .content").text().trim();c(b,a,e,f,null,d)},error:function(b){d(b,a,f)}})},deletePerformance:function(a,e,f){$.ajax({type:"POST",url:b+"/deletePerformance",cache:!1,contentType:"application/json",data:JSON.stringify(a),success:function(b){var d=$("#distributionCartAjaxDialog .remove-from-cart-ok .content").text().trim();
c(b,a,e,f,null,d)},error:function(b){d(b,a,f)}})},deletePackage:function(a,e,f){$.ajax({type:"POST",url:b+"/deletePackage",cache:!1,contentType:"application/json",data:JSON.stringify(a),success:function(b){var d=$("#distributionCartAjaxDialog .remove-from-cart-ok .content").text().trim();c(b,a,e,f,null,d)},error:function(b){d(b,a,f)}})},discardAllTickets:function(a,e,f){tools.dialog.showWaitingPopup("requestProcessingDialog",!0);$.ajax({type:"POST",url:b+"/discardAll",cache:!1,contentType:"application/json",
data:JSON.stringify(a),success:function(b){var d=$("#distributionCartAjaxDialog .discard-all-tickets-ok .content").text().trim();c(b,a,e,f,null,d)},error:function(b){d(b,a,f)}})},distributeTickets:function(a,b,c,d,h,t){tools.dialog.showWaitingPopup("requestProcessingDialog",!0);var k=a.map(function(a){return l(a.linkAddressBookParams,b,c).then(function(){return g(a.distributeParams,d,h)}).then(function(b){var c=$.Deferred();b.response.success?c.resolve({params:a,distributionResponse:b.response}):
c.reject({params:a,distributionResponse:b.response});return c.promise()})});$.when.apply($,$jscomp.arrayFromIterable(e(k))).done(function(b){for(var c=[],d=0;d<arguments.length;++d)c[d-0]=arguments[d];d=c.map(function(a){return a.value}).flatMap(function(a){return a.params}).map(function(a){return a.additionalDataForCallback}).map(function(a){return a.totalRequestedTickets}).reduce(function(a,b){return a+b},0);var e=c.filter(function(a){return a.success}).map(function(a){return a.value}).map(function(a){return a.distributionResponse}).map(function(a){return a.data}).flatMap(function(a){var b=
a.distributedMovementIds;a=a.takenBackMovementIds;Array.isArray(b)&&b.length||(b=[]);Array.isArray(a)&&a.length||(a=[]);return b.concat(a)}).length;d===e?(d=$("#distributionCartAjaxDialog .distribute-tickets-ok .content").text().trim(),e="success"):e?(d=$("#distributionCartAjaxDialog .distribute-tickets-partial-success .content").text().trim(),e="warning"):(d=$("#distributionCartAjaxDialog .distribute-tickets-error .content").text().trim(),e="error");f(c,a,null,d,e,t,!1)})},loadTicketsDetails:function(a,
e,f){tools.dialog.showWaitingPopup("requestProcessingDialog",!0);$.ajax({type:"GET",url:b+"/ticketsDetails.json",data:a,dataType:"json",success:function(b){c(b,a,e,f)},error:function(b){d(b,a,f)}})}}});
tools.module("distributionPortal.commonMessageHandler",function(){var a,b=function(a){if(isNaN(a))return"";var b=$("html").attr("lang");return(new Intl.NumberFormat(b)).format(a)},c=function(a,c){switch(a){case "WARN_ADD_TO_DISTRIBUTION_CART":return $("#distributionCartAjaxDialog .add-to-cart-ko .number-tickets").html(b(c.numberOfFailureTicket)),"add-to-cart-ko";case "ERR_NOT_SHARE_STRUCTURE":return"not-share-structure";case "ERR_CONTACT_NOT_EXIST":return"contact-not-exist";case "ERR_ADDBOOK_NOT_EXIST":return"addbook-not-exist";
case "ERR_POS_NOT_EXIST":return"pos-not-exist";case "ERR_DELETE_TICKET":return"delete-ticket-error";case "ERR_DELETE_PERFORMANCE":return"delete-performance-error";case "ERR_DISCARD_ALL":return"discard-all-error";case "WARN_MAX_TICKETS":return $("#distributionCartAjaxDialog .max-tickets .number-tickets").html(b(c.ticketLimit.maxTickets)),"max-tickets";case "WARN_MAX_TICKETS_PER_REQUEST":return $("#distributionCartAjaxDialog .max-tickets-per-request .number-tickets").html(b(c.ticketLimit.maxTicketsPerRequest)),
"max-tickets-per-request";case "WARN_MAX_TICKETS_PER_TARGET":return $("#distributionCartAjaxDialog .max-tickets-per-target .number-tickets").html(b(c.ticketLimit.maxTicketsPerTarget)),"max-tickets-per-target";case "WARN_MAX_RECIPIENTS":return $("#distributionCartAjaxDialog .max-recipients .number-tickets").html(b(c.ticketLimit.maxRecipients)),"max-recipients";default:return"generic"}};return{display:function(a){$("#distributionCartAjaxDialog .message").hide();$("#distributionCartAjaxDialog ."+a).show();
tools.dialog.showDialog("distributionCartAjaxDialog",!0,!0,!1,"cancel_message_dialog")},displayStatus:function(a,b){$("#distributionCartAjaxDialog .message").hide();a=c(a,b);$("#distributionCartAjaxDialog ."+a).show();tools.dialog.showDialog("distributionCartAjaxDialog",!0,!0,!1,"cancel_message_dialog")},setSelectedRelay:function(b){a=b},changeRelay:function(b){a=b&&""!==b?b:a;functions.updateColleagueDistribution(a)},cancelChangeRelay:function(a){a&&distributionPortal.productList.filterHandler.cancelChangeRelay()}}});
tools.module("distributionPortal.confirmDistribution.actionHandler.main",function(){return{afterRender:function(){distributionPortal.confirmDistribution.actionHandler.distributeTicketsHandler.afterRender();distributionPortal.confirmDistribution.actionHandler.discardTicketsHandler.afterRender()}}});
tools.module("distributionPortal.confirmDistribution.actionHandler.discardTicketsHandler",function(){return{afterRender:function(){$('#discard_button a[role="button"]').off("click").on("click",function(){if($(this).parent().hasClass("disabled"))return!1;tools.dialog.showWaitingPopup("confirmationDialog_confirmDiscardAll",!0);return!1})},onDiscardAll:function(a){a&&a.preventDefault();tools.dialog.hideDialog("confirmationDialog_confirmDiscardAll");distributionPortal.api.discardAllTickets({},function(){distributionPortal.confirmDistribution.state.clearState();
var a=distributionPortal.confirmDistribution.state.getCurrentState();distributionPortal.confirmDistribution.renderer.stateDependentRenderer.renderFull(a)},function(a){distributionPortal.commonMessageHandler.displayStatus(a.status,a.data)})}}});
tools.module("distributionPortal.confirmDistribution.actionHandler.distributeTicketsHandler",function(){var a=function(){return distributionPortal.confirmDistribution.state.getCurrentState().recipientItems.filter(function(a){return a.selected}).map(function(a){var b=a.recipientContact.addressBookId?{id:a.recipientContact.addressBookId,ownerContactNumber:a.recipientContact.addressBookOwnerContactNumber,firstName:a.recipientContact.firstName,lastName:a.recipientContact.lastName,email:a.recipientContact.email,
company:a.recipientContact.company||null,targetContactNumber:null}:null;var d={targetContactNumber:a.recipientContact.contactNumber,targetAddressBookId:a.recipientContact.addressBookId,notifyRecipient:!!a.notifyRecipient},f=distributionPortal.confirmDistribution.state.getTotalTicketsOfRecipientItem(a.recipientItemId);return{linkAddressBookParams:b,distributeParams:d,additionalDataForCallback:{recipientItemId:a.recipientItemId,totalRequestedTickets:f}}})};return{afterRender:function(){$("#distribute_button a").off("click").on("click",
function(){if($(this).parent().hasClass("disabled"))return!1;tools.dialog.showWaitingPopup("confirmationDialog_confirmDistributeTickets",!0);return!1})},distributeTickets:function(b){b&&b.preventDefault();b=a();if(!b||!b.length)return!1;distributionPortal.api.distributeTickets(b,null,null,null,null,function(a){a.forEach(function(a){if(a.success){var b=a.value.params;a=a.value.distributionResponse.data;var c=[];Array.isArray(a.takenBackMovementIds)&&a.takenBackMovementIds.length&&(c=c.concat(a.takenBackMovementIds));
Array.isArray(a.distributedMovementIds)&&a.distributedMovementIds.length&&(c=c.concat(a.distributedMovementIds));distributionPortal.confirmDistribution.state.deleteMovementIdsFromRecipientItem(b.additionalDataForCallback.recipientItemId,c)}});a=distributionPortal.confirmDistribution.state.getCurrentState();distributionPortal.confirmDistribution.renderer.stateDependentRenderer.renderFull(a)})}}});
tools.module("distributionPortal.confirmDistribution.addressBookHandler",function(){var a,b=null,c=null,d=null,f=function(){tools.dialog.hideDialog("selectAddressBookPopup")},e=function(){a=null;$("#selectAddressBookPopup .stx-ab-clear-button").click()};return{saveSelectedAddressBookHandler:function(){if(a&&a.id){var e=distributionPortal.confirmDistribution.state.findRecipientItemByContact(a.id);if(e&&!distributionPortal.confirmDistribution.state.extIsMergeRecipientItemPossible(b,e.recipientItemId))f();
else{var h=e?distributionPortal.confirmDistribution.state.getTotalTicketsOfRecipientItem(e.recipientItemId):0;var l=distributionPortal.confirmDistribution.state.getTotalTicketsOfRecipientItem(b);if(h+l>distributionPortal.confirmDistribution.constants.getMaxTicketsPerTarget())distributionPortal.commonMessageHandler.displayStatus("WARN_MAX_TICKETS_PER_TARGET",{ticketLimit:{maxTicketsPerTarget:distributionPortal.confirmDistribution.constants.getMaxTicketsPerTarget()}});else{var k=a.id,m=a.firstName,
p=a.lastName,q=a.email,r=a.company,t=a.ownerContactNumber;h=e?function(){distributionPortal.confirmDistribution.state.mergeRecipientItem(b,e.recipientItemId);var a=distributionPortal.confirmDistribution.state.getCurrentState();distributionPortal.confirmDistribution.renderer.stateDependentRenderer.renderFull(a)}:function(){var a=distributionPortal.confirmDistribution.state.extUpdateRecipientItemState(b,k,m,p,q,r,t);distributionPortal.confirmDistribution.renderer.stateDependentRenderer.renderRecipientItem("#"+
b,a)};tools.dialog.showWaitingPopup("requestProcessingDialog",!0);distributionPortal.api.switchTarget({oldTargetContactNumber:c||null,oldTargetAddressBookId:d||null,newTargetContactNumber:null,newTargetAddressBookId:a.id||null},h,function(a){distributionPortal.commonMessageHandler.displayStatus(a.status,a.data)});f()}}}else f()},cancelSelectedAddressBookHandler:function(){f()},selectedAddressBookHandler:function(b,c){switch(b){case "AB_SELECTED":a=c;break;case "AB_UNSELECTED":a=null}},openSelectAddressBookPopup:function(a,
f,l,k){k&&k.preventDefault();tools.dialog.showDialog("selectAddressBookPopup",!0,!1,e);b=a;c=f;d=l}}});
tools.module("distributionPortal.confirmDistribution.main",function(){var a;return{init:function(b){distributionPortal.confirmDistribution.constants.init(b.maxTicketsPerTarget);distributionPortal.confirmDistribution.renderer.main.init();a=b.redirectToDistributionPortalUrl;distributionPortal.api.loadConfirmDistributionData(null,function(b){b=distributionPortal.confirmDistribution.state.extLoadState(b.data);distributionPortal.confirmDistribution.state.isCurrentStateValid()||window.location.replace(a);
distributionPortal.confirmDistribution.renderer.stateDependentRenderer.renderFull(b);distributionPortal.confirmDistribution.itemHandler.main.onFirstTimeRender()},null)}}});
tools.module("distributionPortal.confirmDistribution.state",function(){var a,b={},c={},d={},f={},e={},g={},h={},l=0,k=function(a){if(null!=a)return structuredClone(a)},m=function(a,b){b.productItemId=a+"_"+b.productData.productId+"_prod_"+(b.productData.productDateData&&b.productData.productDateData.productDateISO8601)+"_productDate_"+(b.performanceData&&b.performanceData.performanceId)+"_perf";var c=b.productItemId;b.tariffItems.forEach(function(a){a.tariffItemId=c+"_"+(a.seatCategoryData&&a.seatCategoryData.logicalSeatCatId)+
"_"+a.tariffData.tariffId+"_"+(a.dateTimeData&&a.dateTimeData.epochTimestamp)+"_"+(a.itemData&&a.itemData.itemId)+"_tariff";var b=a.tariffItemId;a.ticketItems.forEach(function(a){a.ticketItemId=b+"_"+a.movementId+"_ticket"})})},p=function(a,b){b.recipientItemId=a+"_"+b.recipientContact.contactNumber+"_"+b.recipientContact.addressBookId+"_recipient";var c=b.recipientItemId;b.productItems.forEach(function(a){m(c,a)});b.packageItems.forEach(function(a){a.packageItemId=c+"_"+a.productData.productId+"_pack";
a.packageLineItems.forEach(function(b){var c=b.productItem;m(a.packageItemId,c);b.packageLineItemId=c.productItemId+"_packageLine"})})},q=function(b){var c=a.ownerContactNumber;b?p(c,b):a.recipientItems.forEach(function(a){p(c,a)})},r=function(){b={};c={};d={};f={};e={};g={};var k=function(a){c[a.productItemId]=a;a.tariffItems.forEach(function(a){e[a.tariffItemId]=a;a.ticketItems.forEach(function(a){g[a.ticketItemId]=a;h[a.movementId]=a.ticketItemId})})};a.recipientItems.forEach(function(a){b[a.recipientItemId]=
a;a.productItems.forEach(function(a){k(a)});a.packageItems.forEach(function(a){d[a.packageItemId]=a;a.packageLineItems.forEach(function(a){f[a.packageLineItemId]=a;k(a.productItem)})})})},t=function(a){a.totalTickets=a.tariffItems.reduce(function(a,b){return a+b.totalTickets},0)},w=function(a){a.totalTickets=a.packageLineItems.reduce(function(a,b){t(b.productItem);return a+b.productItem.totalTickets},0)},y=function(a){var b=function(a){return a.tariffItems.forEach(function(a){a.totalTickets=a.ticketItems.length})};
a.productItems.forEach(function(a){b(a);t(a)});a.packageItems.forEach(function(a){a.packageLineItems.forEach(function(a){b(a.productItem)});w(a)})},z=function(b){b?y(b):a.recipientItems.forEach(function(a){y(a)})},x=function(){a.recipientItems.forEach(function(a){var b=a.recipientContact;a.productItems.forEach(function(c){c.dependencies={recipientContact:b,recipientItemId:a.recipientItemId};c.tariffItems.forEach(function(a){a.ticketItems.forEach(function(c){c.dependencies={recipientContact:b,tariffItemId:a.tariffItemId}})})});
a.packageItems.forEach(function(c){c.dependencies={recipientContact:b,recipientItemId:a.recipientItemId};c.packageLineItems.forEach(function(a){a.productItem.tariffItems.forEach(function(a){a.ticketItems.forEach(function(c){c.dependencies={recipientContact:b,tariffItemId:a.tariffItemId}})})})})})},A=function(a,b){var c=((a.seatCategoryData||0)&&a.seatCategoryData.seatCatRank)-((b.seatCategoryData||0)&&b.seatCategoryData.seatCatRank);if(0!==c)return c;c=a.tariffData.tariffRank-b.tariffData.tariffRank;
if(0!==c)return c;a=a.tariffData.advantage?a.tariffData.advantage.advantageName:"";b=b.tariffData.advantage?b.tariffData.advantage.advantageName:"";c=a.localeCompare(b);return 0!==c?a&&b?c:-1*c:0},C=function(a,b){var c=a.productData.productDateData?(new Date(a.productData.productDateData.productDateISO8601)).setHours(0,0,0):Infinity,d=b.productData.productDateData?(new Date(b.productData.productDateData.productDateISO8601)).setHours(0,0,0):Infinity;c-=d;if(0!==c)return c;c=(a.performanceData&&a.performanceData.matchInfo?
a.performanceData.matchInfo.roundRank:-1)-(b.performanceData&&b.performanceData.matchInfo?b.performanceData.matchInfo.roundRank:-1);return 0!==c?c:a.productData.productCode.localeCompare(b.productData.productCode,void 0,{numeric:!0})},u=function(a,b){return C(a.productItem,b.productItem)},v=function(a,b){var c=a.recipientContact.lastName.localeCompare(b.recipientContact.lastName);return 0!==c?c:a.recipientContact.firstName.localeCompare(b.recipientContact.firstName)},D=function(a,b){var c="",d="",
e="",f="",g="",h="",k="",l="";a.seatData&&(c=a.seatData.seatArea||"",d=a.seatData.seatBlock||"",e=a.seatData.seatRow||"",f=a.seatData.seatNumber||"");b.seatData&&(g=b.seatData.seatArea||"",h=b.seatData.seatBlock||"",k=b.seatData.seatRow||"",l=b.seatData.seatNumber||"");a=c.localeCompare(g,void 0,{numeric:!0});if(0!==a)return a;d=d.localeCompare(h,void 0,{numeric:!0});if(0!==d)return d;e=e.localeCompare(k,void 0,{numeric:!0});return 0!==e?e:f.localeCompare(l,void 0,{numeric:!0})},E=function(){var b=
function(a){a.sort(A);a.forEach(function(a){a.ticketItems.sort(D)})},c=function(a){a.sort(C);a.forEach(function(a){return b(a.tariffItems)})},d=function(a){a.sort(u);a.forEach(function(a){return b(a.productItem.tariffItems)})},e=function(a){a.forEach(function(a){return d(a.packageLineItems)})};(function(a){a.sort(v);a.forEach(function(a){c(a.productItems);e(a.packageItems)})})(a.recipientItems)},F=function(a,b,d){if((b||0===b)&&(d||0===d))throw Error("When delete tariff item, only tariff item id or tariff item index should be specified.");
var f=c[a];if(!d&&0!==d&&(d=f.tariffItems.findIndex(function(a){return a.tariffItemId.toString()===b.toString()}),-1===d))throw Error("Index cannot be found for productItemId = "+a+", tariffItemId = "+b);a=f.tariffItems.splice(d,1)[0];b||0===b||(b=a.tariffItemId);delete e[b];t(f)},B=function(a){for(var b=[],c=0;c<a.tariffItems.length;++c)a.tariffItems[c].totalTickets||b.push(c);a=a.productItemId;b=b.sort().reverse();b=$jscomp.makeIterator(b);for(c=b.next();!c.done;c=b.next())F(a,null,c.value)},G=
function(a,b,d){if((b||0===b)&&(d||0===d))throw Error("When delete product item, only product item id or product item index should be specified.");var e=Array.isArray(a.productItems)&&a.productItems.length;if(!e&&!b)throw Error("When delete product item without it attaching to a list, an product item id must be provided.");if(e){if(!d&&0!==d&&(d=a.productItems.findIndex(function(a){return a.productItemId.toString()===b.toString()}),-1===d))throw Error("Index cannot be found for parentItem = "+JSON.stringify(a)+
", productItemId = "+b);a=a.productItems.splice(d,1)[0];b||0===b||(b=a.productItemId)}delete c[b]},L=function(a,b,c){if((b||0===b)&&(c||0===c))throw Error("When delete package line item, only package line item id or package line item index should be specified.");if(!c&&0!==c){var d=a.packageLineItems.findIndex(function(a){return a.packageLineItemId.toString()===b.toString()});if(-1===d)throw Error("Index cannot be found for parentItem = "+JSON.stringify(a)+", \n          packageLineItemId = "+b+", packageLineItemIdx = "+
c);c=d}a=a.packageLineItems.splice(c,1)[0];b||0===b||(b=a.packageLineItemId);delete f[b]},K=function(a,b,c){if((b||0===b)&&(c||0===c))throw Error("When delete product item, only product item id or product item index should be specified.");if(!c&&0!==c&&(c=a.packageItems.findIndex(function(a){return a.packageItemId.toString()===b.toString()}),-1===c))throw Error("Index cannot be found for recipientItemId = "+a.recipientItemId+", \n          packageItemId = "+b);a=a.packageItems.splice(c,1)[0];b||0===
b||(b=a.productItemId);delete d[b]},H=function(a){for(var b=a.productItems,c=[],d=0;d<b.length;++d){var e=b[d];e.totalTickets||c.push(d);B(e)}b=c.sort().reverse();b=$jscomp.makeIterator(b);for(c=b.next();!c.done;c=b.next())G(a,null,c.value);b=a.packageItems;c=[];for(d=0;d<b.length;++d){e=b[d];e.totalTickets||c.push(d);for(var f=[],g=0;g<e.packageLineItems.length;++g){var h=e.packageLineItems[g];h.productItem.totalTickets||f.push(g);B(h.productItem)}f=f.sort().reverse();f=$jscomp.makeIterator(f);for(g=
f.next();!g.done;g=f.next())g=g.value,h=e.packageLineItems[g],G(h,h.productItem.productItemId,null),L(e,null,g)}b=c.sort().reverse();b=$jscomp.makeIterator(b);for(c=b.next();!c.done;c=b.next())K(a,null,c.value)},M=function(c){var d=a.recipientItems[c];a.recipientItems.splice(c,1);delete b[d.recipientItemId]},Q=function(b){var c=a.recipientItems.findIndex(function(a){return a.recipientItemId.toString()===b.toString()});if(-1===c)throw Error("Index cannot be found for recipientItemId = "+b);M(c)},S=
function(a){return 0===a.productItems.length&&0===a.packageItems.length&&0===a.productItems.length},V=function(b){b?(H(b),S(b)&&Q(b.recipientItemId)):a.recipientItems.forEach(function(a){H(a);S(a)&&Q(a.recipientItemId)})},N=function(){l=a.recipientItems.reduce(function(a,b){return b.selected?a+1:a},0)},I=function(a){q(a);r();z(a);x();E();V(a);N()},O=function(b,c){if(!c&&!b)return null;c=parseInt(c);if(b&&"string"!==typeof b)throw Error("Only string target contact number is supported.");if(c)var d=
function(a){return a.recipientContact.addressBookId===c};else if(b)d=function(a){return a.recipientContact.contactNumber===b};else throw Error("Either targetAddressBookId or targetContactNumber must not be null");return a.recipientItems.find(function(a){if(d(a))return a})},R=function(a,b,c,d,e,f,g,h){a=a.recipientContact;a.addressBookId=b;a.contactNumber=null;a.email=f;a.firstName=d;a.lastName=e;a.company=g;a.addressBookOwnerContactNumber=h},X=function(a,b){a.tariffItems.forEach(function(a){a.ticketItems=
a.ticketItems.filter(function(a){return!b.has(a.movementId)})})},T=function(a,b){a.ticketItems.forEach(function(a){if(g[a.ticketItemId])throw Error("Ticket item cannot be assigned to two target contact at the same time.");b.ticketItems.push(a)})},Z=function(a,b){a.tariffItems.forEach(function(a){var c=e[a.tariffItemId];c?T(a,c):b.tariffItems.push(a)})},ba=function(a,b){a.productItems.forEach(function(a){var d=c[a.productItemId];d?Z(a,d):b.productItems.push(a)})},U=function(a,b){a.packageLineItems.forEach(function(a){var c=
f[a.packageLineItemId];c?Z(a.productItem,c.productItem):b.packageLineItems.push(a)})};return{extLoadState:function(b){k(a);a=k(b);I();return k(a)},clearState:function(){a={}},isCurrentStateValid:function(){for(var b=$jscomp.makeIterator(a.recipientItems),c=b.next();!c.done;c=b.next())if(c=(c=c.value.recipientContact)?c.addressBookId||c.contactNumber:!1,!c)return!1;return!0},getCurrentState:function(){return k(a)},getOwnerContactNumber:function(){return a.ownerContactNumber},mergeRecipientItem:function(c,
e){if(c!==e){k(a);var f=k(b[c]),g=b[e];Q(c);R(f,g.recipientContact.addressBookId,g.recipientContact.contactNumber,g.recipientContact.firstName,g.recipientContact.lastName,g.recipientContact.email,g.recipientContact.company);p(a.ownerContactNumber,f);ba(f,g);f.packageItems.forEach(function(a){var b=d[a.packageItemId];b?U(a,b):g.packageItems.push(a)});I(g)}},extIsMergeRecipientItemPossible:function(a,b){return a!==b},findRecipientItemByContact:function(a){a=O(null,a);return null==a?null:k(a)},extUpdateRecipientItemState:function(c,
d,e,f,g,h,l){k(a);c=b[c];R(c,d,null,e,f,g,h,l);I(c);return k(c)},extDeleteTicketFromTariffItem:function(a,b){var c=e[a],d=c.ticketItems.findIndex(function(a){return a.ticketItemId.toString()===b.toString()});if(-1===d)throw Error("Index cannot be found for tariffItemId = "+a+", ticketItemId = "+b);c.ticketItems.splice(d,1);a=g[b].movementId;delete g[b];delete h[a];c.totalTickets=c.ticketItems.length;I()},isTariffItemExists:function(a){return!!e[a]},findTariffItem:function(a){return k(e[a])},updateTicketNumberForProductItem:function(a){t(c[a.toString()])},
findProductItem:function(a){return k(c[a])},findPackageItem:function(a){return k(d[a])},isProductItemExists:function(a){return!!c[a]},extDeleteProductItemFromRecipientItem:function(a,c,d){a=b[a];G(a,c,d);I(a)},extDeletePackageItemFromRecipientItem:function(a,c,d){a=b[a];K(a,c,d);I(a)},isRecipientItemExists:function(a){return!!b[a]},findRecipientItem:function(a){return k(b[a])},deleteRecipientItem:Q,deleteRecipientItemByContactNumberAndAddressBookId:function(b,c){var d=a.recipientItems.findIndex(function(a){return a.recipientContact.contactNumber===
b&&a.recipientContact.addressBookId===c});if(-1===d)throw Error("Recipient item index cannot be found for contactNumber = "+b+", addressBookId = "+c);M(d)},deleteMovementIdsFromRecipientItem:function(a,c){a=b[a];var d=new Set(c);a.productItems.forEach(function(a){X(a,d)});a.packageItems.forEach(function(a){a.packageLineItems.forEach(function(a){X(a.productItem,d)})});c=$jscomp.makeIterator(c);for(var e=c.next();!e.done;e=c.next()){e=e.value;var f=h[e];delete h[e];delete g[f]}I(a)},getTicketItem:function(a){return k(g[a])},
toggleTicketItemListDisplay:function(a){a=e[a];a.ticketItemListDisplayed=!a.ticketItemListDisplayed},toggleProductItemListDisplay:function(a){a=b[a];a.productItemListDisplayed=!a.productItemListDisplayed},getProductItem:function(a){return k(c[a])},findMovementIdsOfProductItem:function(a){return c[a].tariffItems.flatMap(function(a){return a.ticketItems}).map(function(a){return a.movementId})},findMovementIdsOfPackageItem:function(a){return d[a].packageLineItems.flatMap(function(a){a=a.productItem.tariffItems.flatMap(function(a){return a.ticketItems}).map(function(a){return a.parentMovementId});
return[].concat($jscomp.arrayFromIterable(new Set(a)))})},getTotalTicketsOfRecipientItem:function(a){var c=b[a];a=c.productItems.reduce(function(a,b){return a+b.totalTickets},0);c=c.packageItems.reduce(function(a,b){return a+b.totalTickets},0);return a+c},toggleRecipientItemSelected:function(a,c){a=b[a];!!a.selected!==c&&(a.selected=c,a.selected?++l:--l)},toggleRecipientItemNotify:function(a){a=b[a];a.notifyRecipient=!a.notifyRecipient},getRecipientItemSelectedState:function(a){return!!b[a].selected},
getRecipientItemNotifyState:function(a){return!!b[a].notifyRecipient},getNumberOfSelectedRecipientItem:function(){return l}}});
tools.module("distributionPortal.confirmDistribution.constants",function(){var a;return{init:function(b){a=b},getMaxTicketsPerTarget:function(){return a}}});
tools.module("distributionPortal.confirmDistribution.itemHandler.main",function(){return{onFirstTimeRender:function(){distributionPortal.confirmDistribution.itemHandler.recipientItem.onFirstTimeRender()},afterRender:function(){distributionPortal.confirmDistribution.itemHandler.recipientItem.afterRender();distributionPortal.confirmDistribution.itemHandler.recipientItemList.afterRender();distributionPortal.confirmDistribution.itemHandler.productPanel.afterRender();distributionPortal.confirmDistribution.itemHandler.packageItem.afterRender();
distributionPortal.confirmDistribution.itemHandler.tariffItem.afterRender();distributionPortal.confirmDistribution.itemHandler.ticketItem.afterRender()}}});
tools.module("distributionPortal.confirmDistribution.itemHandler.packageItem",function(){return{onRemovePackageClicked:function(a,b,c){distributionPortal.confirmDistribution.renderer.stateIndependentRenderer.renderConfirmPackageDeleteDialogAfterRemoveBtn(a,{recipientItemId:b,packageItemId:c});tools.dialog.showWaitingPopup("confirmationDialog_confirmRemovePackage_"+c)},afterRender:function(){},removePackage:function(a,b,c){c&&c.preventDefault();tools.dialog.showWaitingPopup("requestProcessingDialog",
!0);c=distributionPortal.confirmDistribution.state.findPackageItem(b);var d=distributionPortal.confirmDistribution.state.findMovementIdsOfPackageItem(b);distributionPortal.api.deletePackage({targetContactNumber:c.dependencies.recipientContact.contactNumber,targetAddressBookId:c.dependencies.recipientContact.addressBookId,movementIds:d},function(){distributionPortal.confirmDistribution.state.extDeletePackageItemFromRecipientItem(a,b);$("#"+b).trigger("packageItemDeleted")},function(a){distributionPortal.commonMessageHandler.displayStatus(a.status,
a.data)})}}});
tools.module("distributionPortal.confirmDistribution.itemHandler.productPanel",function(){return{onRemoveProductClicked:function(a,b,c){distributionPortal.confirmDistribution.renderer.stateIndependentRenderer.renderConfirmPerformanceDeleteDialogAfterRemoveBtn(a,{recipientItemId:b,productItemId:c});tools.dialog.showWaitingPopup("confirmationDialog_confirmRemoveProduct_"+c)},afterRender:function(){$(".product_item").off("tariffItemDeleted").on("tariffItemDeleted",function(a){var b=$(a.currentTarget).data("productItemId");
if(!distributionPortal.confirmDistribution.state.isProductItemExists(b))return $(a.currentTarget).trigger("productItemDeleted"),!1;a="#"+$(a.currentTarget).attr("id");b=distributionPortal.confirmDistribution.state.findProductItem(b);distributionPortal.confirmDistribution.renderer.stateDependentRenderer.renderProductItem(a,b)}).off("ticketItemDeleted").on("ticketItemDeleted",function(a){var b=$(a.currentTarget).data("productItemId");distributionPortal.confirmDistribution.state.updateTicketNumberForProductItem(b);
a="#"+b+"_info_container";b=distributionPortal.confirmDistribution.state.findProductItem(b);distributionPortal.confirmDistribution.renderer.stateDependentRenderer.renderProductInfoContainer(a,b)})},removePerformance:function(a,b,c){c&&c.preventDefault();tools.dialog.showWaitingPopup("requestProcessingDialog",!0);c=distributionPortal.confirmDistribution.state.getProductItem(b);var d=distributionPortal.confirmDistribution.state.findMovementIdsOfProductItem(b);distributionPortal.api.deletePerformance({targetContactNumber:c.dependencies.recipientContact.contactNumber,
targetAddressBookId:c.dependencies.recipientContact.addressBookId,movementIds:d},function(){distributionPortal.confirmDistribution.state.extDeleteProductItemFromRecipientItem(a,b);$("#"+b).trigger("productItemDeleted")},function(a){distributionPortal.commonMessageHandler.displayStatus(a.status,a.data)})}}});
tools.module("distributionPortal.confirmDistribution.itemHandler.recipientItem",function(){return{onFirstTimeRender:function(){$(".recipient_input").each(function(){$(this).prop("checked",!0)}).trigger("change")},afterRender:function(){$(".recipient_item").off("productItemDeleted packageItemDeleted").on("productItemDeleted packageItemDeleted",function(a){var b=$(a.currentTarget).data("recipientItemId");if(!distributionPortal.confirmDistribution.state.isRecipientItemExists(b))return $(a.currentTarget).trigger("recipientItemDeleted"),
!1;a="#"+$(a.currentTarget).attr("id");b=distributionPortal.confirmDistribution.state.findRecipientItem(b);distributionPortal.confirmDistribution.renderer.stateDependentRenderer.renderRecipientItem(a,b)});$(".recipient_input").off("change").on("change",function(a){var b=$(this).data("recipientItemId");distributionPortal.confirmDistribution.state.toggleRecipientItemSelected(b,a.currentTarget.checked);0===distributionPortal.confirmDistribution.state.getNumberOfSelectedRecipientItem()?$("#distribute_button span").addClass("disabled"):
$("#distribute_button span").removeClass("disabled")}).each(function(){var a=$(this).data("recipientItemId");$(this).prop("checked",distributionPortal.confirmDistribution.state.getRecipientItemSelectedState(a)).trigger("change")});$(".notify_recipient_input").off("change").on("change",function(){var a=$(this).data("recipientItemId");distributionPortal.confirmDistribution.state.toggleRecipientItemNotify(a)}).each(function(){var a=$(this).data("recipientItemId");$(this).prop("checked",distributionPortal.confirmDistribution.state.getRecipientItemNotifyState(a))})},
onTogglePerformanceListItem:function(a){distributionPortal.confirmDistribution.state.toggleProductItemListDisplay(a)}}});
tools.module("distributionPortal.confirmDistribution.itemHandler.recipientItemList",function(){return{afterRender:function(){$(".recipient_list").off("recipientItemDeleted").on("recipientItemDeleted",function(){var a=distributionPortal.confirmDistribution.state.getCurrentState();distributionPortal.confirmDistribution.renderer.stateDependentRenderer.renderFull(a)})}}});
tools.module("distributionPortal.confirmDistribution.itemHandler.tariffItem",function(){return{afterRender:function(){$(".tariff_item").off("ticketItemDeleted").on("ticketItemDeleted",function(a){var b=$(a.currentTarget).data("tariffItemId");if(!distributionPortal.confirmDistribution.state.isTariffItemExists(b))return $(a.currentTarget).trigger("tariffItemDeleted"),!1;a="#"+$(a.currentTarget).attr("id");b=distributionPortal.confirmDistribution.state.findTariffItem(b);distributionPortal.confirmDistribution.renderer.stateDependentRenderer.renderTariffItem(a,
b)})},onToggleTicketItemListClicked:function(a){distributionPortal.confirmDistribution.state.toggleTicketItemListDisplay(a)}}});
tools.module("distributionPortal.confirmDistribution.itemHandler.ticketItem",function(){return{onRemoveTicketClicked:function(a,b,c){distributionPortal.confirmDistribution.renderer.stateIndependentRenderer.renderConfirmTicketDeleteDialogAfterRemoveBtn(a,{tariffItemId:b,ticketItemId:c});tools.dialog.showWaitingPopup("confirmationDialog_confirmRemoveTicket_"+c)},removeTicket:function(a,b,c){c&&c.preventDefault();if(!b)throw Error("ticketItemId cannot be empty, ticketItemId = "+b);tools.dialog.showWaitingPopup("requestProcessingDialog",
!0);c=distributionPortal.confirmDistribution.state.getTicketItem(b);distributionPortal.api.deleteTickets({targetContactNumber:c.dependencies.recipientContact.contactNumber,targetAddressBookId:c.dependencies.recipientContact.addressBookId,movementIds:[c.movementId]},function(){distributionPortal.confirmDistribution.state.extDeleteTicketFromTariffItem(a,b);$("#"+b).trigger("ticketItemDeleted")},function(a){distributionPortal.commonMessageHandler.displayStatus(a.status,a.data)})},afterRender:function(){}}});
tools.module("distributionPortal.confirmDistribution.renderer.main",function(){return{init:function(){distributionPortal.confirmDistribution.renderer.stateDependentRenderer.init();distributionPortal.confirmDistribution.renderer.stateIndependentRenderer.init()},unescapeHtml:function(a){return a.replaceAll("&gt;",">")}}});
tools.module("distributionPortal.confirmDistribution.renderer.stateDependentRenderer",function(){var a,b,c,d,f,e,g,h,l,k,m=distributionPortal.confirmDistribution.renderer.main.unescapeHtml,p=function(){tools.initAfterMustacheRender();distributionPortal.confirmDistribution.itemHandler.main.afterRender();distributionPortal.confirmDistribution.actionHandler.main.afterRender()};return{init:function(){a=m($("#confirmationDistributionTpl").html());b=m($("#recipientListPartialTpl").html());c=m($("#recipientPanelPartialTpl").html());
d=m($("#tariffPanelPartialTpl").html());f=m($("#productInfoContainerPartialTpl").html());e=m($("#productPanelPartialTpl").html());g=m($("#packagePanelPartialTpl").html());h=m($("#packageInstancePartialTpl").html());l=m($("#packageLinePartialTpl").html());k=m($("#packageLineProductPartialTpl").html());Mustache.parse(a);Mustache.parse(b);Mustache.parse(c);Mustache.parse(d);Mustache.parse(f);Mustache.parse(e);Mustache.parse(g);Mustache.parse(h);Mustache.parse(l);Mustache.parse(k)},renderFull:function(m){$("#confirm_distribution_page .content_element .content").html(Mustache.render(a,
m,{recipientListPartialTpl:b,recipientPanelPartialTpl:c,productPanelPartialTpl:e,packagePanelPartialTpl:g,packageInstancePartialTpl:h,packageLinePartialTpl:l,packageLineProductPartialTpl:k,productInfoContainerPartialTpl:f,tariffPanelPartialTpl:d}));p()},renderRecipientItem:function(a,b){$(a).replaceWith(Mustache.render(c,b,{productPanelPartialTpl:e,packagePanelPartialTpl:g,packageInstancePartialTpl:h,packageLinePartialTpl:l,packageLineProductPartialTpl:k,productInfoContainerPartialTpl:f,tariffPanelPartialTpl:d}));
p()},renderTariffItem:function(a,b){$(a).replaceWith(Mustache.render(d,b,{}));p()},renderProductInfoContainer:function(a,b){$(a).replaceWith(Mustache.render(f,b,{}));p()},renderProductItem:function(a,b){$(a).replaceWith(Mustache.render(e,b,{productInfoContainerPartialTpl:f,tariffPanelPartialTpl:d}));p()}}});
tools.module("distributionPortal.confirmDistribution.renderer.stateIndependentRenderer",function(){var a,b,c,d=distributionPortal.confirmDistribution.renderer.main.unescapeHtml;return{init:function(){a=d($("#confirmTicketDeleteDialogTpl").html());b=d($("#confirmPerformanceDeleteDialogTpl").html());c=d($("#confirmPackageDeleteDialogTpl").html());Mustache.parse(a);Mustache.parse(b);Mustache.parse(c)},renderConfirmTicketDeleteDialogAfterRemoveBtn:function(b,c){$(b).after(Mustache.render(a,c,{}))},renderConfirmPerformanceDeleteDialogAfterRemoveBtn:function(a,
c){$(a).after(Mustache.render(b,c,{}))},renderConfirmPackageDeleteDialogAfterRemoveBtn:function(a,b){$(a).after(Mustache.render(c,b,{}))}}});
tools.module("distributionPortal.distributionCart",function(){var a,b=null,c=null,d=!1,f,e,g,h,l,k,m=function(b,c){var d=a.ticketLimit.maxTicketsPerTarget,e=c&&c.targetAddressBookId?c.targetAddressBookId:null,f=c&&c.targetContactNumber?c.targetContactNumber:null;c=a.cartItems.find(function(a){return a.targetAddressBookId===e&&a.targetContactNumber===f});return c?c.totalTickets+b>d?(g.displayStatus("WARN_MAX_TICKETS_PER_TARGET",{ticketLimit:a.ticketLimit}),!1):!0:!0},p=function(a,b){var c=[];a&&a.cartItems&&
(c=c.concat(a.cartItems.filter(function(a){return a.isTempItem})));0<c.length&&0<b.cartItems.length&&(c=c.filter(function(a){return!b.cartItems.find(function(b){return b.targetAddressBookId&&a.targetAddressBookId===b.targetAddressBookId||b.targetContactNumber&&a.targetContactNumber===b.targetContactNumber})}),b.cartItems=b.cartItems.concat(c));return b},q=function(b){h.loadCartSummaryData(null,function(c){a=p(a,c.data);l&&l.notifyMaxTicketsUpdate();f.renderDistributionCart(a);b&&l.notifyWidgetCartDataUpdate()})},
r=function(a){q(d);d||(e.loadProducts(null,!0,!1,!0),k.updateTicketsAfterRemovedFromCart())},t=function(a){g.displayStatus(a.status,a.data)},w=function(a){g.displayStatus(a.status,a.data)},y=function(a,b,c){b&&b===a.targetAddressBookId||!m(a.totalTickets,{targetAddressBookId:b,targetContactNumber:c})||(tools.dialog.showWaitingPopup("requestProcessingDialog",!0),h.switchTarget({oldTargetContactNumber:a.targetContactNumber,oldTargetAddressBookId:a.targetAddressBookId,newTargetContactNumber:c,newTargetAddressBookId:b},
function(a){x(A({targetContactNumber:c,targetAddressBookId:b}));q(d)},w))},z=function(){return null!==b?a.cartItems.find(function(a){return a.key===b}):{}},x=function(a){b=a;d&&l.notifyWidgetUpdateSelectedTarget(z())},A=function(a){return(a.targetAddressBookId||0)+"_"+(a.targetContactNumber||0)},C=function(){return a&&a.cartItems&&0!==a.cartItems.length?!a.cartItems.some(function(a){return!a.targetAddressBookId&&!a.targetContactNumber||!a.totalTickets||0===a.totalTickets}):!1};return{init:function(a){(d=
a.isSeatMap)?l=distributionPortal.seatMap.main:e=distributionPortal.productList.main;b=A({});h=distributionPortal.api;f=distributionPortal.distributionCartViewHelper;g=distributionPortal.commonMessageHandler;k=distributionPortal.ticketsList;f.init();this.loadCartData()},getCartData:function(){return a},setCartData:function(b){a=b;f.renderDistributionCart(a)},getCartItemSelectedKey:function(){return b},loadCartData:q,deleteCartItem:function(a,b){a.preventDefault();a.stopPropagation();c=b;tools.dialog.showDialog("confirmationDialog_distributionPortalDeleteTicketConfirmDialog",
!0,!0,!1,"cancel_message_dialog")},onSelectCartItem:function(c){b===c?x({}):x(c);f.renderDistributionCart(a)},getTargetDataForAddToCart:z,confirmDeleteCartItem:function(){var b=a.cartItems.findIndex(function(a){return a.key===c});if(-1!==b){var d=a.cartItems[b];0===d.totalTickets?(a.cartItems.splice(b,1),f.renderDistributionCart(a)):(tools.dialog.showWaitingPopup("requestProcessingDialog",!0),h.deleteTickets({targetContactNumber:d.targetContactNumber,targetAddressBookId:d.targetAddressBookId},r,t))}},
buildItemKey:A,setCartItemSelectedKey:x,assignToMe:function(b,c){b.preventDefault();b.stopPropagation();b=a.cartItems.find(function(a){return a.key===c});y(b,null,a.ownerContactNumber)},switchTarget:y,goToConfirmationPage:function(){C()&&(window.location.href=contextPath+"/pro/account/distribution/distributionPortal/confirmation")},isValidToGoToConfirmation:C,isValidQuantity:m}});
tools.module("distributionPortal.distributionCartViewHelper",function(){var a,b,c,d,f=function(a,b,c,d){$(c).html(Mustache.render(a,b,d))},e=function(a){a.cartItems.sort(function(a,b){if(!a.targetAddressBookId&&!a.targetContactNumber)return b.isTempItem?-1:1;if(!b.targetAddressBookId&&!b.targetContactNumber)return a.isTempItem?1:-1;if(!a.isTempItem&&b.isTempItem)return-1;if(a.isTempItem&&!b.isTempItem)return 1;var c=$("html").attr("lang");return((a.lastName||"")+" "+(a.firstName||"")+" "+(a.structureName||
"")).localeCompare((b.lastName||"")+" "+(b.firstName||"")+" "+(b.structureName||""),c)})};return{init:function(){b=$("#distributionCartTpl").html();Mustache.parse(b);c=$("#distributionCartItemTpl").html();Mustache.parse(c);d=distributionPortal.distributionCart},renderDistributionCart:function(g){e(g);a=g;a.isDisableGoToConfirmation=!d.isValidToGoToConfirmation();a.totalTickets=0;var h=d.getCartItemSelectedKey();a.cartItems.forEach(function(b){b.key=d.buildItemKey(b);a.totalTickets+=parseInt(b.totalTickets);
b.selected=h===b.key;b.showAssignToMe=b.totalTickets&&0!==b.totalTickets&&(!b.targetContactNumber||b.targetContactNumber!==g.ownerContactNumber);return b});a.isEmptyTarget=function(){return!this.targetAddressBookId&&!this.targetContactNumber};a.isNoTicket=function(){return!this.totalTickets||0===this.totalTickets};f(b,a,"#distributionCart",{distributionCartItemTpl:c});if(a.isDisableGoToConfirmation){var l=$(".button.disabled #goToConfirmationPage");l.tipsy({gravity:"n",title:function(){return l.attr("data-original-title")}})}}}});
tools.module("distributionPortal.productList.expandHandler",function(){var a=[],b,c;return{init:function(){b=distributionPortal.productList.filterHandler;c=distributionPortal.productList.productListViewHelper},expandAllDetail:function(b,f,e){a=[];b.forEach(function(b){b.isExpand=f;a.push({key:b.key,isExpand:f})});e&&c.renderProductList(b)},handleExpandAll:function(a){$(".panel_header_button_container .expand_button").each(function(b,c){b=c.classList.contains("down");var d=c.classList.contains("up");
(a&&b||!a&&d)&&c.click()})},setExpandStatusAfterReload:function(c){var d=b.getViewAllDetail();c.forEach(function(b){var c=a.find(function(a){return a.key===b.key});b.isExpand=c?c.isExpand:d;"PACKAGE"===b.productType&&b.categories.forEach(function(b){c=a.find(function(a){return a.key===b.key});b.isExpand=c?c.isExpand:d})})},addToggleExpandButtonHandler:function(){$(".panel_header_button_container .expand_button").click(function(b){b.preventDefault();var c=$(this)[0].firstChild.id;b=a.findIndex(function(a){return a.key===
c});var d=$(this).parents(".panel_header").siblings(".panel_content");if($(this)[0].classList.contains("down")){var g=!0;$(this).removeClass("down");$(this).addClass("up");d.slideDown();$(this).find('> [role="button"]').attr("aria-expanded",!0);d.attr("aria-hidden",!1)}else g=!1,$(this).removeClass("up"),$(this).addClass("down"),d.slideUp(),$(this).find('> [role="button"]').attr("aria-expanded",!1),d.attr("aria-hidden",!0);-1!==b?a[b].isExpand=g:a.push({key:c,isExpand:g})})}}});
tools.module("distributionPortal.productList.filterHandler",function(){var a=new Proxy({},{set:function(a,b,c){a[b]=c;sessionStorage.setItem("distributionPortalFilterData",JSON.stringify(a));return!0}}),b,c,d,f,e=function(b){b=void 0===b?!0:b;var e=$("#productFilter").val(),f=$("#performanceFilter");f.find("option:not(#selectAllOptions)").remove();a.performanceIds&&f.trigger("updatePlaceholder",a.performanceIds.length);e&&"-1"!==e?(f.prop("disabled",!1),e=d[e]||[],e.length?(e.forEach(function(a){f.append($("<option>",
{value:a.id,text:a.displayName}))}),f.val(a.performanceIds).trigger("change.select2")):(f.prop("disabled",!0),b&&c.loadProducts(a))):(f.prop("disabled",!0),b&&c.loadProducts(a))},g=function(){$("#sortingCriteria").on("change",function(){a.orderBy=$(this).val();c.filterAndSortProductOnClient(c.getCurrentListProduct(),a,!0)});$("#productState").on("change",function(){a.productState=$(this).val();c.loadProducts(a)});$("#productFilter").on("change",function(){a.productId=$(this).val();a.performanceIds=
[];e()});$("#performanceFilter").on("change",function(){a.performanceIds=$(this).val();c.loadProducts(a)});$("#applyFilterButton").on("click",function(){c.loadProducts(a,!1,!1,!0)})};return{init:function(b,l){b&&"object"===typeof b&&Object.keys(b).forEach(function(c){return a[c]=b[c]});c=distributionPortal.productList.main;f=distributionPortal.productList.expandHandler;d=l;g();e(!1)},getCurrentFilterCriteria:function(){return a},getViewAllDetail:function(){return a.isViewAllDetail},onChangeFilter:function(b,
d){a[b]=d;var e=c.getCurrentListProduct();switch(b){case "dateFrom":$("#dateTo")[0].min=d;c.filterAndSortProductOnClient(e,a,!0);break;case "dateTo":$("#dateFrom")[0].max=d;c.filterAndSortProductOnClient(e,a,!0);break;case "productName":c.filterAndSortProductOnClient(e,a,!0);break;default:c.loadProducts(a)}},onToggleFilter:function(b,d){a[b]=d;switch(b){case "isShowDistributed":a.remainingTickets=d?"NON_AVAILABLE":"AVAILABLE";c.loadProducts(a);break;case "isViewAllDetail":f.handleExpandAll(d)}},onFocusRelaySelection:function(a){b=
a},cancelChangeRelay:function(){b&&($('#colleague > [value="'+b+'"]')[0].selected=!0)},populatePerformanceFilter:e,isDistributionView:function(){return a?"AVAILABLE"===a.remainingTickets:!1}}});
tools.module("distributionPortal.productList.main",function(){var a=[],b,c,d,f,e,g,h,l,k,m=function(a){if(a&&""!==a)return a=a.split("-").map(function(a){return parseInt(a)}),new Date(a[0],a[1],a[2],0,0,0,0)},p=function(a,b,c){c=void 0===c?-1:c;if(!(a&&""!==a||b&&""!==b))return 0;if(!a||""===a)return 1;if(!b||""===b)return-1;a=m(a);b=m(b);return isNaN(a)||isNaN(b)?0:(b-a)*c},q=function(a,b){var c=$("html").attr("lang");return a.localeCompare(b,c)},r=function(a,b){a=parseInt(a);b=parseInt(b);return isNaN(a)&&
isNaN(b)?0:isNaN(a)?-1:isNaN(b)?1:a-b},t=function(a,b,c){var e=function(b){a.filter(function(a){return"PACKAGE"===a.productType&&a.categories}).forEach(function(a){a.categories.forEach(function(a){a.compositionLines&&a.compositionLines.sort(b)})})},f="DATE_ASC"===b?-1:1;switch(b){case "DATE_ASC":case "DATE_DESC":a.sort(function(a,b){var c=p(a.dateFilter,b.dateFilter,f);if(0!==c)return c;c=r(a.matchInfo?a.matchInfo.roundRank:null,b.matchInfo?b.matchInfo.roundRank:null);if(0!==c)return c;c=q(a.productCode,
b.productCode);return 0!==c?c:q(a.productName,b.productName)});e(function(a,b){if(!a.performance&&!b.performance)return 0;if(!a.performance)return 1;if(!b.performance)return-1;var c=p(a.performance.dateFilter,b.performance.dateFilter,f);if(0!==c)return c;c=r(a.performance.matchInfo?a.performance.matchInfo.roundRank:null,b.performance.matchInfo?b.performance.matchInfo.roundRank:null);return 0!==c?c:q(a.productName,b.productName)});break;case "PRODUCT_NAME_ASC":a.sort(function(a,b){var c=a.productName.localeCompare(b.productName);
return 0===c?p(a.dateFilter,b.dateFilter):c}),e(function(a,b){var c=a.productName.localeCompare(b.productName);return 0!==c?c:a.performance||b.performance?a.performance?b.performance?p(a.performance.dateFilter,b.performance.dateFilter):-1:1:0})}c&&d.renderProductList(a)},w=function(a,b,c){var e=b.productName;e&&""!==e&&(a=a.filter(function(a){return a.productName.toLowerCase().includes(e.toLowerCase())}));var f=m(b.dateFrom);b.dateFrom&&!isNaN(f)&&(a=a.filter(function(a){return a.dateFilter&&""!==
a.dateFilter&&m(a.dateFilter)>=f}));var g=m(b.dateTo);b.dateTo&&!isNaN(g)&&(a=a.filter(function(a){return a.dateFilter&&""!==a.dateFilter&&m(a.dateFilter)<=g}));t(a,b.orderBy);c&&d.renderProductList(a);return a},y=function(a){b=a&&""!==a?a:b;window.location.href=b},z=function(){tools.dialog.showDialog("ajaxErrorDialog",!0)},x=function(a){c=a&&""!==a?a:c;window.location.href=c};return{init:function(a,b,c){distributionPortal.distributionCart.init({isSeatMap:!1});l=distributionPortal.api;f=distributionPortal.productList.filterHandler;
f.init(a,b);d=distributionPortal.productList.productListViewHelper;d.init();e=distributionPortal.productList.expandHandler;e.init();g=distributionPortal.productList.quantityHandler;g.init();distributionPortal.stickyBar.init({});h=distributionPortal.ticketsList;h.init();k=c;this.loadProducts(a,!1,!0)},getProducts:function(){return a},setProducts:function(b){return a=b},getCurrentListProduct:function(){return a},loadProducts:function(b,c,g,h){h=void 0===h?!1:h;b||(b=f.getCurrentFilterCriteria());if(h||
!k)c||tools.dialog.showWaitingPopup("loadingDialog",!0),h={remainingTickets:b.remainingTickets,productState:b.productState,productId:"-1"===b.productId?void 0:b.productId,performanceIds:0<b.performanceIds.length?b.performanceIds:void 0},g&&(h.loadFirstMobileIfETicketsIsEmpty=b.loadFirstMobileIfETicketsIsEmpty),l.loadDistributionProductData(h,function(h){var k=b;g&&h.filterCriteria&&h.filterCriteria.productState&&h.filterCriteria.productState!==k.productState&&(f.onChangeFilter("productState",h.filterCriteria.productState),
$("#productState").val(h.filterCriteria.productState).trigger("change.select2"));h=a=h.products;var l=!c;h=w(h,k,!1);l&&e.expandAllDetail(h,f.getViewAllDetail());d.renderProductList(h)},z)},filterAndSortProductOnClient:w,onClickOpenSeatMap:function(a,c){a.preventDefault();g.isNotAnySelected()?y(c):(tools.dialog.showDialog("confirmationDialog_distributionPortalOpenSeatMapConfirmDialog",!0,!0,!1,"cancel_message_dialog"),b=c)},openSeatMap:y,onClickOpenTicketingDashboard:function(a,b){a.preventDefault();
g.isNotAnySelected()?x(b):(tools.dialog.showDialog("confirmationDialog_distributionPortalOpenTicketingDashboardConfirmDialog",!0,!0,!1,"cancel_message_dialog"),c=b)},openTicketingDashboard:x}});
tools.module("distributionPortal.productList.productListViewHelper",function(){var a=[],b,c,d,f,e,g,h,l,k,m,p,q,r,t,w=function(){return function(a,b){switch(b(a).replace(/\s/g,"")){case "PACKAGE":return b("{{> packageCompositionTpl}}");default:return b("{{> categoryTpl}}")}}},y=function(){return function(a,b){if((a=b(a))&&""!==a)return b(0===parseInt(a)?"distributed":"")}},z=function(){return function(a,b){if((a=b(a))&&""!==a)return b(0<parseInt(a)?"quantity-selected":"")}},x=function(){return function(a,
b){if((a=b(a))&&""!==a)return b(0<parseInt(a)?"input-quantity-selected":"")}},A=function(){return function(a,b){switch(b(a)){case "PACKAGE":return b("package_quantity");default:return b("")}}};return{init:function(){c=$("#productListTpl").html();Mustache.parse(c);d=$("#productItemTpl").html();Mustache.parse(d);f=$("#categoryTpl").html();Mustache.parse(f);h=$("#audiSubCatTpl").html();Mustache.parse(h);l=$("#ticketNumberTpl").html();Mustache.parse(l);k=$("#performancePanelTpl").html();Mustache.parse(k);
e=$("#packageCompositionTpl").html();Mustache.parse(e);g=$("#packageCompositionLineTpl").html();Mustache.parse(g);m=$("#stickyBarTpl").html();Mustache.parse(m);p=distributionPortal.productList.expandHandler;q=distributionPortal.productList.quantityHandler;r=distributionPortal.productList.filterHandler;t=distributionPortal.stickyBarViewHelper},getProductsDisplay:function(){return a},getProductsViewModel:function(){return b},getStickyBarViewModel:function(){},renderProductList:function(m){a=m;p.setExpandStatusAfterReload(m);
q.handleSelectedQuantity(m);distributionPortal.ticketsList.setExpandStatusAfterReload(m);b={products:m,mapToCategoryTypeTemplate:w,isDistributedProduct:y,hasQuantity:z,hasInputQuantity:x,ticketIconClass:A,isDistributionView:r.isDistributionView()};m=c;var u=b,C={productItemTpl:d,categoryTpl:f,packageCompositionTpl:e,packageCompositionLineTpl:g,audiSubCatTpl:h,ticketNumberTpl:l,performancePanelTpl:k};$("#distributionProductList").html(Mustache.render(m,u,C));distributionPortal.ticketsList.renderTicketsList(!0);
t.renderStickyBar();p.addToggleExpandButtonHandler(r.getViewAllDetail())}}});
tools.module("distributionPortal.productList.quantityHandler",function(){var a=[],b,c,d,f,e=function(a,b,c){if(isNaN(a)||0>a||a>b)return!1;a=f.getCartData().ticketLimit;b=distributionPortal.stickyBar.getStickyBarData();c+=b.totalTickets;return c>a.maxTicketsPerRequest?(d.displayStatus("WARN_MAX_TICKETS_PER_REQUEST",{ticketLimit:{maxTicketsPerRequest:a.maxTicketsPerRequest}}),!1):c>a.remainingTickets?(d.displayStatus("WARN_MAX_TICKETS",{ticketLimit:{maxTickets:a.maxTickets}}),!1):!0},g=function(d,
f){d=parseInt(d);var g=a.findIndex(function(a){return a.key===f});-1!==g?e(d,a[g].numberOfDistributableTickets,d-a[g].quantity)?a[g].quantity=d:a.splice(g,1):(g=b.getProducts(),g.forEach(function(b){b.categories.forEach(function(b){b.audSubCats.forEach(function(c){c.key===f&&e(d,c.numberOfDistributableTickets,d)&&(c.quantity=d,"PACKAGE"===c.productFamilyType&&(c.compositionLines=b.compositionLines),a.push(c))})})}),b.setProducts(g));c.renderProductList(c.getProductsDisplay())};return{init:function(){c=
distributionPortal.productList.productListViewHelper;b=distributionPortal.productList.main;d=distributionPortal.commonMessageHandler;f=distributionPortal.distributionCart},getCurrentSelected:function(){return a},onChangeQuantity:g,onChangeQuantityDebounceForTab:function(a,b,c,d){"true"===c?functions.debounce(function(){return g(a,b)},d)():g(a,b)},handleSelectedQuantity:function(b){b.forEach(function(b){var c=0;b.categories.forEach(function(b){b.audSubCats.forEach(function(b){var d=a.find(function(a){return b.key===
a.key&&0<a.quantity});d?(b.quantity=d.quantity,c=b.quantityRate?c+parseInt(d.quantity)*parseInt(b.quantityRate):c+parseInt(d.quantity)):b.hasSelectedMovementIds?c+=b.selectedMovementIds.length:b.quantity=0})});b.quantity=c})},isNotAnySelected:function(){return!a||0===a.length},resetSelected:function(b){a=[];b&&c.renderProductList(c.getProductsDisplay())}}});
tools.module("distributionPortal.seatMap.main",function(){var a=[],b={},c,d,f,e=function(){},g=function(){f&&f.getCartData()&&e("MAX_TICKETS_UPDATE",f.getCartData().ticketLimit)};return{init:function(a){b=a;f=distributionPortal.distributionCart;f.init({isSeatMap:!0});c=distributionPortal.stickyBar;c.init({isSeatMap:!0});d=distributionPortal.stickyBarViewHelper;d.init();d.renderStickyBar()},getSeatsSelected:function(){return a},getSeatMapData:function(){return b},resetSelected:function(){a=[]},seatMapCallBack:function(b,
c){"CHANGE_SELECTED_SEATS"===b&&(a=c,d.renderStickyBar())},initUpdateStateToSeatMapWidget:function(a){"function"===typeof a?(e=a,g()):e=function(){console.error("Can't call to widget")}},notifyWidgetAddToCartSuccess:function(){e("ADD_TO_CART_SUCCESS")},notifyWidgetUpdateSelectedTarget:function(a){e("UPDATE_TARGET_SELECTED",a?{targetAddressBookId:a.targetAddressBookId,targetContactNumber:a.targetContactNumber}:{})},notifyWidgetClearAllSelected:function(){e("CLEAR_ALL_SELECTED")},notifyWidgetCartDataUpdate:function(){e("CART_DATA_UPDATE")},
notifyMaxTicketsUpdate:g}});
tools.module("distributionPortal.stickyBar",function(){var a={totalTickets:0,isDisplay:!1},b,c,d,f,e,g,h,l,k,m=function(){var c=0;if(b)c=l.getSeatsSelected().length;else{c=d.getCurrentSelected();var e=k.getSelectedMovementIds();c=c.map(function(a){return a.quantityRate?parseInt(a.quantity)*parseInt(a.quantityRate):parseInt(a.quantity)}).reduce(function(a,b){return a+b},0)+e.length}a={totalTickets:c,isDisplay:0<c}},p=function(a,g){e.setCartItemSelectedKey(e.buildItemKey(g));e.loadCartData();b?(l.resetSelected(),
l.notifyWidgetAddToCartSuccess()):(d.resetSelected(),f.loadProducts(null,!0,!1,!0),k.updateTicketsAfterAddedToCart());c.renderStickyBar()},q=function(a){e.loadCartData(b);g.displayStatus(a.status,a.data)},r=function(a){var b=e.getTargetDataForAddToCart(),c={targetContactNumber:b&&b.targetContactNumber,targetAddressBookId:b&&b.targetAddressBookId,requestProducts:a};tools.dialog.showWaitingPopup("requestProcessingDialog",!0);h.addToDistributionCart(c,function(a){p(a,{targetContactNumber:c.targetContactNumber,
targetAddressBookId:c.targetAddressBookId})},q)},t=function(){var a=l.getSeatsSelected(),b=l.getSeatMapData(),c=a.filter(function(a){return!a.distributionTicketResult.allocated&&!a.distributionTicketResult.distributed}).map(function(a){return a.distributionTicketResult.distributionTicket.movementId});a=a.filter(function(a){return!a.distributionTicketResult.allocated&&a.distributionTicketResult.distributed}).map(function(a){return a.distributionTicketResult.distributionTicket.movementId});var d=[];
0<c.length&&d.push({productId:b.productId,ticketSupport:b.ticketSupport,forDistribute:!0,explicitlySelectedMovementIds:c});0<a.length&&d.push({productId:b.productId,ticketSupport:b.ticketSupport,forDistribute:!1,explicitlySelectedMovementIds:a});r(d)},w=function(a,b){var c=e.getTargetDataForAddToCart(),d=c&&c.targetContactNumber,f=c&&c.targetAddressBookId;c=[];0<a.length&&c.push(h.addToDistributionCart({targetContactNumber:d,targetAddressBookId:f,requestProducts:a},void 0,q,!1));0<b.length&&c.push(h.addToDistributionCart({targetContactNumber:d,
targetAddressBookId:f,requestProducts:b},void 0,q));tools.dialog.showWaitingPopup("requestProcessingDialog",!0);Promise.all(c).then(function(){p(void 0,{targetContactNumber:d,targetAddressBookId:f})})},y=function(){var a=d.getCurrentSelected(),b=k.getSelectedTickets();if(a&&0!==a.length||b&&0!==b.length){var c=[];a.forEach(function(a){var b=[];if("PACKAGE"===a.productFamilyType){a.compositionLines.forEach(function(c){return b.push({compositionId:c.compositionId,itemId:c.itemId,timeSlotId:c.timeSlotId,
performanceId:c.performance?c.performance.performanceId:null,seatCategoryId:c.seatCategoryId,audienceSubCategoryId:c.audienceSubCategoryId,advantageId:a.advantageId,quantity:c.quantity*a.quantity})});var d=null}else b=[{itemId:a.itemId,performanceId:a.performanceId,seatCategoryId:a.seatCategoryId,audienceSubCategoryId:a.audienceSubCategoryId,advantageId:a.advantageId,timeSlotId:a.timeSlotId,quantity:a.quantity}],d=c.find(function(b){return b.productId===a.productId&&b.ticketSupport===a.ticketSupport});
b=b.filter(function(a){return 0<a.quantity});d?d.requestItems=d.requestItems.concat(b):c.push({productId:a.productId,ticketSupport:a.ticketSupport,requestItems:b})});var e=[];b.forEach(function(a){var b=a.productId,c=a.ticketSupport,d=a.isDistribution,f=Array.from(a.movementIds),g=e.find(function(b){return b.productId===a.productId});g?g.explicitlySelectedMovementIds=g.explicitlySelectedMovementIds.concat(f):e.push({productId:b,ticketSupport:c,explicitlySelectedMovementIds:f,forDistribute:d})});w(c,
e)}},z=function(){var a=$("#footer_wrapper"),b=$(".isolated-container"),c;a.length?c=a[0]:b.length&&(c=b[0]);c?(a=c.getBoundingClientRect(),a=Math.max(Math.min(a.bottom,window.innerHeight)-Math.max(a.top,0),0)):a=0;$("#distributionStickyBar").css("bottom",a+20+"px")};return{init:function(a){$(z);$(window).on("scroll",z);b=a.isSeatMap;e=distributionPortal.distributionCart;h=distributionPortal.api;g=distributionPortal.commonMessageHandler;c=distributionPortal.stickyBarViewHelper;c.init();b?l=distributionPortal.seatMap.main:
(d=distributionPortal.productList.quantityHandler,f=distributionPortal.productList.main,k=distributionPortal.ticketsList)},getStickyBarData:function(){m();return a},calculateTotalTickets:m,addToCart:function(c){c.preventDefault();e.isValidQuantity(a.totalTickets,e.getTargetDataForAddToCart())&&(b?t():y())},clearDataOfStickyBar:function(a){a.preventDefault();b?(l.resetSelected(),l.notifyWidgetClearAllSelected()):(d.resetSelected(!0),k.resetSelected());c.renderStickyBar()},isNotAnyTicketsSelected:function(){return!a.totalTickets||
0===a.totalTickets},updateBottomPosition:z}});
tools.module("distributionPortal.stickyBarViewHelper",function(){var a,b,c;return{init:function(){b=$("#stickyBarTpl").html();Mustache.parse(b);c=distributionPortal.stickyBar},renderStickyBar:function(){a=c.getStickyBarData();c.updateBottomPosition();var d=b,f=a;$("#distributionStickyBar").html(Mustache.render(d,f,void 0))}}});
tools.module("distributionPortal.ticketsList",function(){var a={},b,c=[],d=[],f,e,g=function(a,c){$(c).html(Mustache.render(b,a))},h=function(a){return a.tickets.reduce(function(b,c){var d=c.distributionOperationIndex+"_"+a.productId+"_"+a.performanceId+"_"+(null==c.seatCategoryId?"":c.seatCategoryId)+"_"+c.audienceSubCategoryId;b[d]||(b[d]=Object.assign({},a,{index:c.distributionOperationIndex,seatCategoryId:c.seatCategoryId,audienceSubCategoryId:c.audienceSubCategoryId,tickets:[]}));b[d].tickets.push(c);
return b},{})},l=function(a){var b=$(a).parents(".panel_header_button_container").siblings(".distributionTicketsList"),c=$(a).parent(),d=c.hasClass("down");c.toggleClass("down",!d).toggleClass("up",d);b.slideToggle(d);$(a).find('> [role="button"]').attr("aria-expanded",d);b.attr("aria-hidden",!d)},k=function(a){var b=a.checked,d=a.movementId,e=a.productId,g=a.performanceId,h=a.seatCategoryId,k=a.audienceSubCategoryId,l=a.ticketSupport;a=void 0===a.isCheckBoxForAll?!1:a.isCheckBoxForAll;var m=c.find(function(a){return a.productId===
e&&a.performanceId===g&&a.seatCategoryId===h&&a.audienceSubCategoryId===k});b?m?m.movementIds.add(d):(b=new Set([d]),c.push({productId:e,performanceId:g,seatCategoryId:h,audienceSubCategoryId:k,ticketSupport:l,movementIds:b,isDistribution:f.isDistributionView()})):m&&(1<m.movementIds.size&&!a?m.movementIds.delete(d):c.splice(c.indexOf(m),1))},m=function(b){if(void 0===b?0:b)$(".tipsy-disabled-tooltip").remove(),$(".tariff_item .rounded_button.disabled > a").tipsy({gravity:"w",className:"tipsy-disabled-tooltip",
title:function(){return expandDisabledTooltip}});b=Object.values(a);0!==b.length&&b.forEach(function(a){var b=a.tickets.filter(function(a){return"hidden"!==a.isHidden&&(a.distributable||a.canTakeBack)});if(a.isTicketsDetailsExpanded){if(b.length){var d=!0;b.forEach(function(a){c.some(function(b){return b.movementIds.has(a.movementId.toString())})?a.checked="checked":(a.checked="",d=!1)});a.allTicketsChecked=d?"checked":""}else a.isTicketsDetailsExpanded=!1,a.allTicketsChecked=!1;g(a,"#distributionTicketsList_"+
a.index+"_"+a.productId+"_"+a.performanceId+"_"+a.seatCategoryId+"_"+a.audienceSubCategoryId)}})};return{init:function(){a={};c=[];d=[];f=distributionPortal.productList.filterHandler;e=distributionPortal.stickyBarViewHelper;b=$("#distributionPortalTicketsListTpl").html()},getSelectedMovementIds:function(){return c.flatMap(function(a){return Array.from(a.movementIds)})},getSelectedTickets:function(){return c},resetSelected:function(){c=[];m()},onToggleTicketsListClicked:function(b,c,e,f,k,m,z,x){var p=
c+"_"+e+"_"+f+"_"+k+"_"+m;a[p]||d.includes(p)?(e=$("#distributionTicketsList_"+c+"_"+e+"_"+f+"_"+k+"_"+m),0<$(e).find("table.ticket_list").length||g(a[p],e),l(b),a[p]=Object.assign({},a[p],{isTicketsDetailsExpanded:!a[p].isTicketsDetailsExpanded})):(distributionPortal.api.loadTicketsDetails({productId:e,performanceId:f,ticketSupport:z,isDistribution:x},function(d,e){var f=e.productId,p=e.performanceId;e=e.isDistribution;var u=c+"_"+f+"_"+p+"_"+k+"_"+m,q=$("#distributionTicketsList_"+u);Object.assign(a,
h({tickets:d.tickets,productId:f,performanceId:p,ticketSupport:z,isDistribution:e}));a[u].isTicketsDetailsExpanded=!0;g(a[u],q);l(b)}),d.push(p))},selectAll:function(a){var b=$(a).is(":checked");$(a).closest("table").find('tr.ticket_item:not(.hidden) > td.ticket_seat_info input[type="checkbox"]').each(function(){var a=$(this);a.prop("checked",b);k({checked:b,movementId:a.val(),productId:a.data("product-id"),performanceId:a.data("performance-id"),seatCategoryId:a.data("seat-category-id"),audienceSubCategoryId:a.data("audience-sub-category-id"),
ticketSupport:a.data("ticket-support"),isCheckBoxForAll:!0})});e.renderStickyBar()},handleClickOnTicket:function(a){a=$(a);k({checked:a.is(":checked"),movementId:a.val(),productId:a.data("product-id"),performanceId:a.data("performance-id"),seatCategoryId:a.data("seat-category-id"),audienceSubCategoryId:a.data("audience-sub-category-id"),ticketSupport:a.data("ticket-support")});e.renderStickyBar()},renderTicketsList:m,updateTicketsAfterAddedToCart:function(){c=[];Object.values(a).forEach(function(a){a.tickets.forEach(function(a){"checked"===
a.checked&&(a.checked="",a.isHidden="hidden")})});m()},updateTicketsAfterRemovedFromCart:function(){c=[];Object.values(a).forEach(function(a){a.tickets.forEach(function(a){a.isHidden=""})});m()},setExpandStatusAfterReload:function(b){0!==Object.values(a).length&&b.filter(function(a){return"SPORTING_EVENT"===a.productType||"EVENT"===a.productType}).forEach(function(b){b.categories.forEach(function(c){c.audSubCats.forEach(function(c){var d=b.productId+"_"+b.performanceId+"_"+c.seatCategoryId+"_"+c.audienceSubCategoryId;
a[d]&&(c.isTicketsDetailsExpanded=a[d].isTicketsDetailsExpanded||!1)})})})}}});
tools.module("editPickupPerson",function(){var a={},b=function(){$(".field").find("input, select").focus(function(){$("#someone_else").prop("checked",!0)})},c=function(){var a=0,b;$(".field").each(function(){$(this).removeClass("error");b=$(this).find("input, select");b.removeClass("error")});$(".field.mandatory").each(function(){b=$(this).find("input, select");"field_title"===$(this).attr("id")?void 0===$("input[name*=individualTitle]:checked").val()&&($(this).addClass("error"),a=1):b.each(function(){validation.validateField($(this),
validation.mandatoryRule(),null,!1,!0)||(a=1)})});0===a&&(validation.validateField($('input[name*=".firstName"]'),validation.rules.firstname,null,!1,!0)||(a=3));0===a&&(validation.validateField($('input[name*=".lastName"]'),validation.rules.lastname,null,!1,!0)||(a=4));0===a&&(validation.validateField($("input[name*=nationalPhoneNumber]"),validation.rules.phone,null,!1,!0)||(a=5));0===a&&($("#agreement input").is(":checked")||(a=2));return a};return{init:function(c,f,e,g,h){secutix.date.combos.populateCombosDatepicker("day",
"month","year",c);$("#day").val(e);$("#month").val(g);$("#year").val(h);b();a=f},updateMobilePrefix:function(){$("#mobile_prefix").val(a[$("#country option:selected").val()])},savePickupPerson:function(a){var b=$("input[name=pickup_person_type]:checked").val(),d=a.attr("action"),g=-1===d.indexOf("?")?"?":"&";"myself"===b||"someone_from_back_office"===b?(b="myself"===b?$("#current_contact_number").val():$("#back_office_contact_number").val(),a.attr("action",d+(g+"existingContactNumber="+b)),a.submit()):
(d=c(),$(".message.error").hide(),1===d?$("#notification_mandatory").show():3===d?$("#notification_first_name").show():4===d?$("#notification_last_name").show():5===d?$("#notification_mobile_phone").show():2===d?$("#notification_agreement").show():a.submit())}}});
tools.module("fastline",function(){var a=null,b,c,d={SINGLE_CODE_MODE:{maskPattern:"XXXX-XXXX-XXXX-XXXX",codeRule:{minLength:19,maxLength:19,regExp:/^([0-Za-z]{4}-?){3}[0-Za-z]{4}$/}},FREE_MODE:{maskPattern:"?XXXXXXXXXXXXXXXXXXXX",codeRule:{minLength:1,maxLength:20,regExp:/^\w{1,20}$/}}},f=function(){var a=$(".code_line","#codes_list");$(a).each(function(b,c){c=$(".delete_code",c);b===a.length-1?""!==$('input[class="input_text"]',$(c).closest(".code_line")).val()?$(c).show():$(c).hide():$(c).show()})},
e=function(){var a=$("#verify_codes"),b=$("#add_new_code"),d=!1;$(".input_text","#codes_list").each(function(a,b){if(c.regExp.test(b.value))return d=!0,!1});d?a.parent().removeClass("disabled"):a.parent().addClass("disabled");0<$(".input_text","#codes_list").filter(function(a,b){return!c.regExp.test(b.value)}).first().length?b.parent().hide():b.parent().show()},g=function(a,b){a.tipsy({className:"tipsy-validation",delayIn:1E3,html:!0,offset:0,trigger:"manual",gravity:"se",opacity:1,title:function(){return b}}).tipsy("show");
setTimeout(function(){a.tipsy("hide")},5E3)};return{deleteCode:function(a){$(a).closest(".code_line").remove();0===$(".input_text","#codes_list").length&&this.addCodeLine();e()},addCodeLine:function(){var a=$("#base_code_line").clone();if(0<$(".input_text","#codes_list").length){var c=$(".input_text","#codes_list").filter(function(a,b){return""===b.value}).first();if(0<c.length){c.focus();return}}a.removeClass("hidden").removeAttr("id");$(".input_text",a).mask(b).on("keyup",function(){e()}).on("change",
function(){e()});$("#codes_list").append(a);f();e();$(".input_text",a).focus()},init:function(g){a=g.labels;g=g.validationMode;-1===Object.keys(d).indexOf(g)&&(g="SINGLE_CODE_MODE");b=d[g].maskPattern;c=d[g].codeRule;$.mask.definitions.X="[A-Za-z0-9]";"FREE_MODE"===g&&($.mask.placeholder="");0===$(".input_text","#codes_list").length?this.addCodeLine():(f(),$(".input_text","#codes_list").each(function(a,c){$(c).mask(b).on("keyup",function(){e()}).on("change",function(){e()})}));e()},verifyCodes:function(){var b=
0,d=!1,e;$("#hidden_codes_list").empty();if($("#verify_codes").parent().hasClass("disabled"))return!1;$(".input_text","#codes_list").each(function(f,h){(e=validation.validateField($(h),[{rule:c}],null,!1))?0<$('input[value="'+h.value+'"]',"#hidden_codes_list").length?(g($(h),a.duplicatedCode),$(h).focus(),d=!0):(f=$('<input type="hidden"></input>').attr("name","codes["+b+"]").val(h.value),$("#hidden_codes_list").append(f),b++):$(h).removeClass("error")});0<b&&!d?$("#codes_form").submit():0>=b&&g($("#verify_codes"),
a.missingCode)}}});
tools.module("hospitality.session.overlay",function(){var a=null,b=function(b){b.stopPropagation();$(this).tipsy({html:!0,trigger:"manual",gravity:$.fn.tipsy.autoNS,className:"bundle-session-tooltip",opacity:1,title:function(){var b=$(this),c=b.data("session-id"),d=b.data("session-availability"),h={availability:d,session:a[c]};return a[c]?d?Mustache.render('<div class="bundle-session-preview">{{#session}}<div class="name"><strong>{{name}} :</strong></div>{{#hostTeam}}{{#visitTeam}}<div class="teams">{{hostTeam}} vs {{visitTeam}}</div>{{/visitTeam}}{{/hostTeam}}<div>{{site}}</div><div class="date">{{date}}</div><div>{{availabilityLabel}}{{/session}}: {{availability}}</div></div>',
h):Mustache.render('<div class="bundle-session-preview">{{#session}}<div class="name"><strong>{{name}} :</strong></div>{{#hostTeam}}{{#visitTeam}}<div class="teams">{{hostTeam}} vs {{visitTeam}}</div>{{/visitTeam}}{{/hostTeam}}<div>{{site}}</div><div class="date">{{date}}</div>{{/session}}</div>',h):b.attr("data-original-title")||""}});$(this).tipsy("show")},c=function(){$(this).tipsy("hide")};return{init:function(a,f){$(a).on("mouseover",f,b);$(a).on("mouseout",f,c);$(a).on("click",f,b);$(document).on("click",
function(a){$(".tipsy.bundle-session-tooltip").remove()})},addConf:function(b){null===a?a=b:$.extend(a,b)}}});
tools.module("hospitality.lounge",{rooms:{},addToCartWithCaptcha:"false",ignoreAvailability:!1,registerRooms:function(a,b){hospitality.lounge.rooms[a]=b},filterRoomNotEnoughAvailability:function(a){var b=$(a).val();$(".item_room input[type=radio][name*=roomIdBySite]:visible").prop("disabled",!1);$(".item_room input[type=radio][name*=roomIdBySite]:visible").each(function(){!hospitality.lounge.ignoreAvailability&&parseInt($(this).attr("data-room-availability"),10)<b&&($(this).attr("disabled",!0),this.checked=
!1)});hospitality.lounge.reSelectFirstAvailableRoomForeachSite()},disableSite:function(a){a.each(function(){if(!$(this).is(":disabled"))return this.checked=!0,!1})},reSelectFirstAvailableRoomForeachSite:function(){var a,b,c;$(".table_container.siteSection").each(function(){c=$(this).attr("class").split(" ");for(a=0;a<c.length;a++)-1!==c[a].indexOf("siteSection_")&&(b=parseInt(c[a].substring(12),10),hospitality.lounge.disableSite($(".siteSection_"+b+" .item_room input[type=radio][name*=roomIdBySite]:visible")))})},
resetAllQuantities:function(){$(".table_container").each(function(){$(this).find("tr").each(function(){var a=$('td.quantity select, td.quantity input[type="text"], td input[type="hidden"].quantity, td.quantity input[type="number"]',this);0<a.length&&($(a).val("0"),$(a).tipsy("hide"))})});functions.updatePrices(0);$(".item_room input[type=radio][name*=roomIdBySite]:visible:not(.soldout)").each(function(){$(this).prop("disabled",!1)})},checkQuantities:function(){$(".table_container").each(function(){$(this).find("tr").each(function(){var a=
$('td.quantity select, td.quantity input[type="text"], td.quantity input[type="number"]',this);0<a.length&&!0===a.is(":visible")&&functions.validateQuantityInputFieldAndHideTooltipIfOk(a)})})},handleAudSubCatChange:function(a){hospitality.lounge.resetAllQuantities();$(".cat_quantity:not(.audsubcat_"+a+")").hide();$(".cat_quantity.audsubcat_"+a).show();$("#audSubCatId").val(a);hospitality.lounge.filterRoomNotEnoughAvailability($('input[id$=".quantity"], select[id$=".quantity"]',".cat_quantity.audsubcat_"+
a))},validateRooms:function(){var a=!1;if(0<$(".item_room input[type=radio][name*=roomIdBySite]:visible").length){var b=$(".item_room input[type=radio][name*=roomIdBySite]:checked");if(0===b.length||""===$(b).val())a=!0}a||functions.validateQuantities(!0,null,$("#bookLounges"),null,function(a){a||tools.dialog.hideDialog("loadingDialog")})},handleStandartInit:function(){$('#main_content_hospitality_quantity input[name*="quantity"]').bind("input",function(a){hospitality.lounge.checkQuantities();functions.updatePrices(0);
hospitality.lounge.filterRoomNotEnoughAvailability($('#main_content_hospitality_quantity input[name*=".quantity"]'))});$('#main_content_hospitality_quantity input[name*="quantity"]').bind("keypress",function(a){13===a.keyCode&&(a.preventDefault(),hospitality.lounge.validateRooms())});$("#bookLounges #book").attr("onClick","");$("#bookLounges #book").unbind("click").on("click",function(a){a.preventDefault();hospitality.lounge.validateRooms()})},selectionInit:function(a){hospitality.lounge.ignoreAvailability=
a;$("input[type=radio][name=audSubCat]").change(function(){hospitality.lounge.handleAudSubCatChange(this.value);$("tr.item:not(.audsubcat_"+this.value+")").hide();$("tr.item.audsubcat_"+this.value).show();$(".siteSection:not(.audsubcat_"+this.value+")").hide();$(".siteSection.audsubcat_"+this.value).show();hospitality.lounge.reSelectFirstAvailableRoomForeachSite()});hospitality.lounge.handleStandartInit();hospitality.lounge.reSelectFirstAvailableRoomForeachSite();hospitality.lounge.autoAddToCart(!1)},
selectionSimpleProductInit:function(a,b){hospitality.lounge.ignoreAvailability=b;if(!a||hospitality.lounge.ignoreAvailability)$("input[type=radio][name=audSubCat]").change(function(){hospitality.lounge.handleAudSubCatChange(this.value)}),hospitality.lounge.handleStandartInit(),hospitality.lounge.autoAddToCart(!0)},extractRoomAndQuantityParamsFromUrl:function(){var a,b,c;var d=window.location.search.substring(1).split("&");var f=0;for(a=d.length;f<a;f++){var e=d[f].split("=");"roomId"===e[0]&&(b=e[1]);
"quantity"===e[0]&&(c=e[1]);if(b&&c)break}return[b,c]},cleanUpAutoAddingToCart:function(a){hospitality.lounge.resetAllQuantities();$(".multiple-selection-input").remove();$("#"+a).show()},autoAddToCart:function(a){var b=0;var c=0===$(".item_room_data").length;var d=hospitality.lounge.extractRoomAndQuantityParamsFromUrl();var f=d[0];d=d[1];if(f||d){if(c){if(!d){$("#hospitalityIncorrectRoomIdQuantity").show();return}if(!$.isNumeric(d)){$("#hospitalityIncorrectRoomIdQuantity").show();return}var e=parseInt(d,
10);var g=$("[id^='quantityFormData'][id$='.quantity']:visible");if(0===g.length){$("#hospitalityIncorrectRoomIdQuantity").show();return}if(e<g.data("minQuantity")){$("#hospitalityIncorrectRoomIdQuantity").show();return}if(e>g.data("maxQuantity")){$("#hospitalityQuantityError").show();return}g.val(e).trigger("blur")}else{if(!f||!d){$("#hospitalityIncorrectRoomIdQuantity").show();return}f=f.split(",");var h=d.split(",");if(f.length!==h.length){$("#hospitalityIncorrectRoomIdQuantity").show();return}$("[id^='quantityFormData'][id$='.quantity']").each(function(){var a=
this.id.match(/^quantityFormData(\d+)\./)[1];b=Math.max(b,parseInt(a,10))});d=0;for(c=f.length;d<c;d++){var l=f[d];e=h[d];if(!$.isNumeric(l)||!$.isNumeric(e))return hospitality.lounge.cleanUpAutoAddingToCart("hospitalityIncorrectRoomIdQuantity");e=parseInt(e,10);if(a){var k=$(".cat_quantity:not(.hidden) input[name^='quantityFormData'][name$='.roomId']:enabled").filter("[value='"+l+"']");if(0===k.length)return hospitality.lounge.cleanUpAutoAddingToCart("hospitalityIncorrectRoomIdQuantity");g=k.parents("tr.cat_quantity").find("input[name$='.quantity']");
if(0===g.length||e<g.data("minQuantity"))return hospitality.lounge.cleanUpAutoAddingToCart("hospitalityIncorrectRoomIdQuantity");if(e>g.data("maxQuantity"))return hospitality.lounge.cleanUpAutoAddingToCart("hospitalityQuantityError");g.val(e).trigger("blur")}else{k=$("input[type=radio][name^='roomIdBySite']:visible:enabled").filter("#roomIdBySite"+l);g=$("[id^='quantityFormData'][id$='.quantity']:visible");if(0===k.length||0===g.length||e<g.data("minQuantity"))return hospitality.lounge.cleanUpAutoAddingToCart("hospitalityIncorrectRoomIdQuantity");
if(!hospitality.lounge.ignoreAvailability&&(e>g.data("maxQuantity")||e>parseInt(k.attr("data-room-availability"),10)))return hospitality.lounge.cleanUpAutoAddingToCart("hospitalityQuantityError");g.val(e);b+=1;$("<input>",{type:"hidden",name:"quantityFormData["+b+"].quantity",value:e,"class":"multiple-selection-input"}).insertAfter(g);$("<input>",{type:"hidden",name:"quantityFormData["+b+"].roomId",value:l,"class":"multiple-selection-input"}).insertAfter(g);$("<input>",{type:"hidden",name:"quantityFormData["+
b+"].itemAudSubCatId",value:$("#audSubCatId").val(),"class":"multiple-selection-input"}).insertAfter(g)}}a||$("#multipleRoomSelection").val("true")}$("#hospitalityIncorrectRoomIdQuantity").hide();$("#hospitalityQuantityError").hide();"false"===hospitality.lounge.addToCartWithCaptcha?(tools.dialog.showWaitingPopupDelayed("loadingDialog",!0,null,200),$("#bookLounges #book").trigger("click")):$("#bookLounges #bookWithCaptcha").trigger("click")}}});
tools.module("hospitality.skybox",{roomSizeByAudSubCat:{},addToCartWithCaptcha:"false",registerRoomSizeByAudSubCat:function(a,b){hospitality.skybox.roomSizeByAudSubCat[a]=b},renderRoomSizeSelection:function(){var a=hospitality.skybox.roomSizeByAudSubCat[$("#audSubCatId").val()];Mustache&&0<$("#hospRoomSizeSelectionTpl").length&&a&&($("#main_content_hospitality_skybox_areas .title .customSectionRight").html(Mustache.render($("#hospRoomSizeSelectionTpl").html(),{rooms:a,hasRooms:0<a.length})),$("#hospRoomSizeSelection").on("change",
function(){hospitality.skybox.onRoomSizeChange()}),hospitality.skybox.onRoomSizeChange())},onRoomSizeChange:function(){var a=$("#audSubCatId").val(),b=$("#hospRoomSizeSelection").val();""!==b?($(".area:not(.audsubcat_"+a+"roomSize_"+b+")").hide(),$(".area.audsubcat_"+a+".roomSize_"+b).show()):$(".area.audsubcat_"+a).show();hospitality.skybox.resetAllQuantities()},handleSelectRoomChange:function(){hospitality.skybox.updateQuantity();functions.updatePrices();hospitality.skybox.updateSeatsTotal()},updateQuantity:function(){var a=
$('input[type=radio][name*="roomId"]:visible:checked');$('input[type="hidden"][name$="\\.quantity"]').val(0);""!==a.val()&&$('input[type="hidden"][name$="\\.quantity"]',a.closest("td")).val(1)},isHospRoomSelecionModePrivateOrBoth:function(){var a=$("#hospRoomSelectionModel").val();return"PRIVATE"===a||"BOTH"===a},resetAllQuantities:function(){var a=$('td.item_room input[type=radio][name*="roomId"]:visible');$(".table_container").each(function(){$(this).find("tr").each(function(){var a=$('td.quantity select, td.quantity input[type="text"], td input[type="hidden"].quantity, td.quantity input[type="number"], td.item_room input[type="hidden"][name$="\\.quantity"]',
this);0<a.length&&($(a).val("0"),$(a).tipsy("hide"))})});hospitality.skybox.isHospRoomSelecionModePrivateOrBoth()&&0<a.length&&(a.get(0).checked=!0);hospitality.skybox.updateQuantity();functions.updatePrices(0);hospitality.skybox.updateSeatsTotal()},updateSeatsTotal:function(){$(".table_container").each(function(){var a=0;$(this).find("tr").each(function(){var b=!0;var c=$("td.zone",this);if(0<c.length)if(c=parseInt(c.html().match(/\d+/)[0],10),hospitality.skybox.isHospRoomSelecionModePrivateOrBoth())b=
$('td.item_room input[type=radio][name*="roomId"]:visible',this),0<b.length&&$(b).is(":checked")&&(a+=c);else{var d=$('td.quantity select, td.quantity input[type="text"], td input[type="hidden"].quantity, td.quantity input[type="number"]',this);0<d.length&&(b=functions.validateQuantityInputField(d));0<d.length&&b&&(b=parseInt($(d).val(),10),a+=b*c)}});0===a?$(this).find("tr.subtotal td.reservation_amount .custom").hide():$(this).find("tr.subtotal td.reservation_amount .custom").show();$(this).find("tr.subtotal td.reservation_amount .custom_reservation_value").html(a)})},
extractRoomAndQuantityParamsFromUrl:function(){var a,b,c;var d=window.location.search.substring(1).split("&");var f=0;for(a=d.length;f<a;f++){var e=d[f].split("=");"roomId"===e[0]&&(b=e[1]);"quantity"===e[0]&&(c=e[1]);if(b&&c)break}return[b,c]},autoAddToCart:function(){var a=!hospitality.skybox.isHospRoomSelecionModePrivateOrBoth();var b=hospitality.skybox.extractRoomAndQuantityParamsFromUrl();var c=b[0];b=b[1];if(c||b){if(a){if(!b){$("#hospitalityIncorrectRoomIdQuantity").show();return}b=b.split(",");
c=0;for(a=b.length;c<a;c++){var d=b[c];if(!$.isNumeric(d)){hospitality.skybox.resetAllQuantities();$("#hospitalityIncorrectRoomIdQuantity").show();return}d=$("tr.area[class*='audsubcat_']:not(.hidden)").find("input[name$='.areaSeatQuantity'][value="+d+"]");if(0===d.length){hospitality.skybox.resetAllQuantities();$("#hospitalityIncorrectRoomIdQuantity").show();return}d.parents("tr.area").find("td.quantity [name^='skyboxRoomFormData'][name$='.quantity']").val("1").trigger("change")}}else{if(!c){$("#hospitalityIncorrectRoomIdQuantity").show();
return}b=c.split(",");$('input[type="hidden"][name$="\\.quantity"]').val(0);c=0;for(a=b.length;c<a;c++){d=b[c];if(!$.isNumeric(d)){$("#hospitalityIncorrectRoomIdQuantity").show();$('[id^="multiple_room_id"]').val("");hospitality.skybox.updateQuantity();return}var f=$("input[type=radio][name=roomId]:visible:enabled").filter("#room_id_"+d);if(0===f.length){$("#hospitalityIncorrectRoomIdQuantity").show();$('[id^="multiple_room_id"]').val("");hospitality.skybox.updateQuantity();return}$("#multiple_room_id_"+
d).val(d);f.siblings('[name$="\\.quantity"]').val(1)}$("#multipleRoomSelection").val("true")}$("#hospitalityIncorrectRoomIdQuantity").hide();"false"===hospitality.skybox.addToCartWithCaptcha?(tools.dialog.showWaitingPopupDelayed("loadingDialog",!0,null,200),$("#bookSkyboxes #book").trigger("click")):$("#bookSkyboxes #bookWithCaptcha").trigger("click")}},validateRooms:function(){var a=!1;$("tr.audsubcat_"+$("#audSubCatId").val()+' input[name="roomId"]:visible:checked').each(function(b,c){""!==$(c).val()&&
(a=!0)});!a&&hospitality.skybox.isHospRoomSelecionModePrivateOrBoth()?($("#notification_select_room.hidden").removeClass("hidden"),tools.dialog.hideDialog("loadingDialog"),window.scrollTo(0,0)):hospitality.skybox.isHospRoomSelecionModePrivateOrBoth()?functions.handleFormSubmit(!0,"#bookSkyboxes .table_container",[],null):functions.validateQuantities(!0,null,$("#bookSkyboxes"),null,function(a){a||tools.dialog.hideDialog("loadingDialog")})},selectionInit:function(a,b){hospitality.skybox.isHospRoomSelecionModePrivateOrBoth()&&
(hospitality.skybox.renderRoomSizeSelection(),hospitality.skybox.handleSelectRoomChange());if(!a||b)$("input[type=radio][name=audSubCat]").change(function(){$(".area:not(.audsubcat_"+this.value+")").hide();$(".area.audsubcat_"+this.value).show();$("#audSubCatId").val(this.value);hospitality.skybox.isHospRoomSelecionModePrivateOrBoth()&&hospitality.skybox.renderRoomSizeSelection();hospitality.skybox.resetAllQuantities()}),$("#bookSkyboxes #book").on("click",function(a){a.preventDefault();hospitality.skybox.validateRooms()}),
$("#bookSkyboxes").on("keypress",function(a){13===a.keyCode&&(a.preventDefault(),hospitality.skybox.validateRooms())}),$('input[type=radio][name*="roomId"]').on("change",function(){hospitality.skybox.handleSelectRoomChange()}),hospitality.skybox.autoAddToCart()}});
tools.module("insurance",{dif:null,adjustPrice:function(a){var b=parseInt($(".int_part",a).text().replace(/\D/g,""),10),c=parseInt($(".mantissa",a).text().replace(/\D/g,""),10);a.html(functions.generateAmount(1E3*b+10*c+this.dif))},init:function(a,b){var c=[];$(".insurance input").on("change",function(){var b=$(this),f=b.data("amount"),e=b.data("operationid"),g=$(this).parents("table"),h=$(".charges_insurance",g);g=$(".reservation_amount",g);var l=g.data("amount"),k=0,m=c.length;h.toggleClass("cancelled");
if(b.is(":checked"))for(b=f,f=functions.generateAmount(l),k=0;k<m;k++){if(c[k]===e){c.splice(k,1);break}}else b=-f,f=functions.generateAmount(l-f),c.push(e);$(".amount",g).html(f);insurance.dif=b;$(".total .amount").each(function(){insurance.adjustPrice($(this))});a&&$("#cancelInsuranceOperations").val(c.join("_"))});if(!a)$(window).on("beforeunload",function(){c.length&&($.ajax({url:contextPath+"/ajax/cart/cancelInsurances",async:!1,type:"POST",data:{operationIds:c.join("_")}}),c=null)});b&&$(".insurance input").click()}});
tools.module("listOtherProductsFilter",function(){var a={},b=null,c="",d=null,f=null,e=[],g=function(){var b=0;$.each(a,function(a,c){c&&b++});return b},h=function(a,b){return $.trim(a).toUpperCase().localeCompare($.trim(b).toUpperCase())},l=function(a,b){return h($(a).find(".title").text(),$(b).find(".title").text())},k=function(a,b){return-1*h($(a).find(".title").text(),$(b).find(".title").text())},m=function(a,b){a=jQuery.inArray($(a).attr("id"),e);b=jQuery.inArray($(b).attr("id"),e);if(a&&b)return a<
b?-1:1},p=function(){var a=b.find(">.content_element").is(":visible");$(".product_type_container").each(function(){var b=$(this);!b.hasClass("group_closed")&&0===b.find(".product:visible").length&&a&&b.hide()})},q=function(){"TYPE"===c?b.find('[id^="product_type_container_"]').show():b.find(".product").closest("li").show();d.hide();$(".product_type_container").each(function(){tools.toggleGroup($(this),!1,!0)})},r=function(){var a=b.find(".product_type_container:visible .product").length;a+=$("#merged_products_container .product:visible").length;
$("#product_counter").text(1<a?productCountLabelPlural.replace("{0}",a):productCountLabelSingular)},t=function(){var b=$(".filters_activation .selected_product_types"),c="",d=0;$.each(a,function(a,b){if(b)if(7>d)0!==d&&(c+=", "),c+=f[a],d++;else return c+=", ...",!1});0===d&&(c=f["-all-"]);b.html(c)};return{init:function(g,h){var k=[];a=g;b=$("#main_content_list_products_OTHER_PRODUCTS");d=$(".filters .alternative_button.filter_reset, .filters .button_container .cancel");$.each(a,function(b,c){c&&
(k.push(b),a[b]=!1)});b.find(".product").each(function(){e.push($(this).attr("id"))});$("#filter_type_desktop").on("change",function(){listOtherProductsFilter.orderProductsBy(this.value)});$(".button_filter").on("click",function(){listOtherProductsFilter.filterProductType($(this).attr("data-product-type"));return!1});d.on("click",function(){listOtherProductsFilter.resetFilter();return!1});$(".filters_activation").on("click",function(){listOtherProductsFilter.toggleFilterPanel()});$(".filters_activation .alternative_button, .filters .button_container .button").on("click",
function(){listOtherProductsFilter.toggleFilterPanel();return!1});c="TYPE";f=h;listOtherProductsFilter.orderProductsBy(c);$.each(k,function(a,b){listOtherProductsFilter.filterProductType(b)})},filterProductType:function(e){var f=$("#button_product_type_"+e),h=f.find("span.accessibility-visually-hidden"),k=$("#product_type_container_"+e),l=b.find('.product[data-product-type="'+e+'"]').closest("li");f.hasClass("button_filter_off")?(f.removeClass("button_filter_off").addClass("button_filter_on"),h.show(),
tools.toggleGroup(k,!1,!0),0===g()&&("TYPE"===c?b.find('[id^="product_type_container_"]').hide():(b.find(".product").closest("li").hide(),l.show()),d.show()),l.length&&("TYPE"===c?l.first().closest(".group_foldable").show():l.show()),a[e]=!0):(f.removeClass("button_filter_on").addClass("button_filter_off"),h.hide(),1===g()?q():l.length&&("TYPE"===c?l.closest(".group_foldable").hide():l.hide()),a[e]=!1);t();p();r();tools.triggerLazyImagesRefresh()},orderProductsBy:function(a){var d=b.find(".product").toArray();
if(0!==d.length){switch(a){case "TYPE":d.sort(m);break;case "PRODUCT_NAME_AZ":d.sort(l);break;case "PRODUCT_NAME_ZA":d.sort(k);break;default:return}var e={},f=document.createDocumentFragment();$.each(d,function(){var b=$(this),c=b.closest("li")[0];"TYPE"===a?(b.find(".inline_season_addon").hide(),b=b.attr("data-product-type"),"TIMESLOT_PASS"===b&&(b="PASS"),e[b]||(e[b]=document.createDocumentFragment()),e[b].appendChild(c)):(b.find(".inline_season_addon").show(),f.appendChild(c))});"TYPE"===a?($("#merged_products_container").hide(),
$.each(e,function(a,b){$("#product_type_container_"+a).show().find(".group_content ul.semantic-no-styling").append(b)})):$("#merged_products_container").show().find(".group_content ul.semantic-no-styling").append(f);p();tools.triggerLazyImagesRefresh();c=a}},resetFilter:function(){b.find(".filters .button_filter.button_filter_on").removeClass("button_filter_on").addClass("button_filter_off");$.each(a,function(b,c){c&&(a[b]=!1)});t();q();r()},toggleFilterPanel:function(){var a=b.find(".filters"),c=
$(".filters_activation .alternative_button");c.hasClass("plus")?(a.slideDown(),c.removeClass("plus").addClass("less")):(a.slideUp(),c.removeClass("less").addClass("plus"))}}}());
tools.module("productFilter",function(){var a=null,b=[],c={},d=function(a){var b=null,c=[];for(b in a)void 0!==b&&(c=c.concat(a[b]));return c},f=function(a){a=c[a];var b=null,d=[];for(b in a)void 0!==b&&a[b].forEach(function(a){return d=d.concat({eventId:a,topicId:1<b.split("-").length?b.split("-")[0]:null})});return d},e=function(a,b){return null===a&&null===b?null:null===a?b:null===b?a:$.map(a,function(a){return 0>$.inArray(a,b)?null:a})},g=function(a){if(void 0!==b[a.attr("id")]){var d=b[a.attr("id")];
return d(a,c)}},h=function(a){return void 0===c[a.attr("id")]?null:void 0===c[a.attr("id")][a.val()]?d(c[a.attr("id")]):c[a.attr("id")][a.val()]},l=function(){var b,k=[],l=[],r=!0,t=null;for(b=0;b<a.length;b++){var w=a[b];g(w);w=h(w);t=e(t,w)}t=$.unique(t);for(b=0;b<a.length;b++)w=a[b].attr("id"),"topicFilter"===w?l=l.concat(f(w)):k=k.concat(d(c[w]));k=$.unique(k);if(0<k.length)for(b=0;b<k.length;b++)w="#prod_"+k[b],0<=$.inArray(k[b],t)?$(w).removeClass("hidden"):$(w).addClass("hidden");else if(0<
l.length)for(b=0;b<l.length;b++)k=void 0,k=l[b].topicId?"#top_"+l[b].topicId:"#without_topic",w=k+" #prod_"+l[b].eventId,0<=$.inArray(l[b].eventId,t)?$(w).removeClass("hidden"):$(w).addClass("hidden");$(".main_content > .content_element > .content > .group:visible").each(function(){var a=$(this).find(".product");$(a).filter(".hidden").length<a.length?(r=!1,$(this).show()):$(this).hide()});r?$("#filterMsgNoResult").show():$("#filterMsgNoResult").hide()},k=function(){$(a).each(function(a,b){b.change(l)})};
return{init:function(b){a=b;k()},data:function(a,b){c[a]=void 0===c[a]?b:$.extend(c[a],b)},addSpecialHandler:function(a,c){b[a.attr("id")]=c},resetFilter:function(){var b;for(b=0;b<a.length;b++)$(a[b]).prop("selectedIndex",0);l()}}}());
tools.module("contact.lotteryHistory",function(){var a=contextPath+"/ajax/account/lotteryHistory/application";return{getApplicationDetail:function(b){tools.dialog.showWaitingPopup("loadingDialog",!0);$.ajax({type:"POST",url:a,dataType:"html",data:{applicationId:b},success:function(a){a&&$("#application_detail").append(a);tools.dialog.showDialog("contact_lottery_history_detail",!0,!0,!1,!1);tools.dialog.hideDialog("loadingDialog")},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",
!0)}})},resetForm:function(){$("#application_detail").html("")}}});
tools.module("matchInfo",{buildMatchInfo:function(a){$.widget("custom.matchSelectCombo",$.ui.selectmenu,{_renderItem:function(b,c){var d=$('<li class="match_option">'),f=$(c.element),e=$("<div>");c.disabled&&d.addClass("ui-state-disabled");f.data("host-team")?($("<span>",{"class":"team_text",text:f.data("host-team")}).appendTo(e),$("<img>",{"class":"team_logo",src:f.data("host-logo")}).appendTo(e),$("<span>",{"class":"vs_text",text:" "+a+" "}).appendTo(e),$("<img>",{"class":"team_logo",src:f.data("opposing-logo")}).appendTo(e),
$("<span>",{"class":"team_text",text:f.data("opposing-team")}).appendTo(e)):$("<span>",{"class":"team_text",text:f.data("performance-name")}).appendTo(e);$("<span>",{"class":"performance_date",text:f.data("performance-date")}).appendTo(e);$("<span>",{"class":"performance_time",text:f.data("performance-time")}).appendTo(e);$("<span>",{"class":"location",text:f.data("location")}).appendTo(e);b.addClass("match_option_wrapper");return d.append(e).appendTo(b)},_renderButtonItem:function(b){var c=$("<span>",
{"class":"ui-selectmenu-text"});b=$(b.element);b.data("host-team")?($("<span>",{"class":"team_text",text:b.data("host-team")}).appendTo(c),$("<img>",{"class":"team_logo",src:b.data("host-logo")}).appendTo(c),$("<span>",{"class":"vs_text",text:" "+a+" "}).appendTo(c),$("<img>",{"class":"team_logo",src:b.data("opposing-logo")}).appendTo(c),$("<span>",{"class":"team_text",text:b.data("opposing-team")}).appendTo(c)):($("<span>",{"class":"team_text",text:b.data("performance-name")}).appendTo(c),$("<span>",
{"class":"performance_date",text:b.data("performance-date")}).appendTo(c),$("<span>",{"class":"performance_time",text:b.data("performance-time")}).appendTo(c));return c}})}});
tools.module("membershipVerificationCommon",function(){var a=function(a){0===a.filter(function(){return""===$.trim(this.value)&&$(this).is(":visible")}).length?$(".button.addWithValidation").removeClass("disabled"):$(".button.addWithValidation").addClass("disabled")};return{init:function(a){(a?$("#emptyMemberCardMobile"):$("#emptyMemberCard")).addClass("hidden");$("#externalVerificationDialog").on("dialogclose",function(a){$("#add-to-cart").parent().removeClass("disabled")});$("#verification_panel").on("click",
".close_expand_panel",function(a){a.preventDefault();membershipVerificationCommon.hideVerificationDialog(!0)})},getVerificationContainer:function(a){return a?$("#verification_panel"):$("#externalVerificationDialog")},showVerificationDialog:function(b){var c=membershipVerificationCommon.getVerificationContainer(b);b?($("#seat-map-sub-container").slideUp(600),$("#total_button_container").addClass("verification_expanded"),$("#pre-cart").addClass("verification_expanded"),$("#total_button_container .triangle_expand_panel").show(),
$("#verification_panel").slideDown(600)):tools.dialog.showDialog("externalVerificationDialog",!0);a(c.find("input"))},hideVerificationDialog:function(a){a?($("#verification_panel").slideUp(600),$("#total_button_container .triangle_expand_panel").hide(),$("#total_button_container").removeClass("verification_expanded"),$("#pre-cart").removeClass("verification_expanded"),$("#seat-map-sub-container").slideDown(600),$("#add-to-cart").parent().removeClass("disabled")):tools.dialog.hideDialog("externalVerificationDialog")},
handleKeyUp:function(b){var c=b.find("input");c.keyup(function(){a(c)})}}});
tools.module("memberships",function(){var a=null,b=null,c=null,d=null,f=!1,e=function(b){b.hasClass("group_end")&&(b.removeClass("group_end"),c.addClass("group_end"));b.find(".membership_unselected .alternative_button").addClass("disabled");c.insertAfter(b);a.appendTo(c.find("td"));a.slideDown("fast",function(){tools.scrollToElement(b,"fast")})},g=function(b){var d=c.hasClass("group_end"),f=c.prev();d&&c.removeClass("group_end");a.slideUp("fast",function(){c.prev().find(".membership_unselected .alternative_button").removeClass("disabled");
c.detach();void 0!==b&&e(b);d&&f.addClass("group_end")})},h=function(a,c,e){var f=d.find(".membership_unselected"),g=d.find(".membership_selected"),h=d.attr("data-movement-id");$("<input />",{type:"hidden",id:"movementsMembershipsOverride"+h,name:"movementsMembershipsOverride["+h+"]",value:c}).appendTo(b);f.hide();g.find(".membership_name").html(a);g.find(".membership_contact").html(e);g.find(".membership_number").html(c);g.show()},l=function(){$("#validateMembershipsForm2").toggleClass("disabled",
0<$(".membership_unselected:visible").length)};return{init:function(e,g){a=$("#membershipsFormContainer");b=$("#membershipsForm");f=g;c=$("<tr></tr>",{id:"membershipsFormRow"});c.append($("<td></td>",{colspan:$("td.membership").first().siblings().length+1}));$.each(e,function(a,b){d=$(".membership[data-movement-id='"+a+"']");h(b.membershipName,b.membershipNumber,b.contact.individualFirstname+" "+b.contact.individualLastname)});l();memberships.bindEvents()},showForm:function(a){var b=a.parents(".specify_member_btn_container");
d=a.parents(".membership");c.is(":visible")?g(b):e(b)},closeForm:function(){g()},addMembership:function(a,b){a=$.trim(a).replace(/-/g,"");tools.dialog.showWaitingPopupDelayed("membershipsProcessingDialog",!0,null,200);$.ajax({url:contextPath+"/ajax/memberships/addMembership",type:"POST",data:{movementId:d.attr("data-movement-id"),membershipNumber:a},cache:!1,success:function(a){tools.dialog.hideDialog("membershipsProcessingDialog");if("MEMBERSHIP_NUMBER_ALREADY_USED"===a.ajaxStatus)tools.dialog.showDialog("membershipAlreadyEnteredDialog",
!0);else if("MEMBERSHIP_NOT_FOUND"===a.ajaxStatus)tools.dialog.showDialogWithoutTooltip("invalidMembershipCardDialog",!0);else{var c=a.contact.individualFirstname+" "+a.contact.individualLastname;h(a.membershipName,a.membershipNumber,c);if(b&&0===$(".membership_card .membership_number:contains("+a.membershipNumber+")").length){var d=$("#template_membership_card").clone();d.find(".membership_name").html(a.membershipName);d.find(".membership_contact").html(c);d.find(".membership_number").html(a.membershipNumber);
d.find(".selectMembership").click(function(a){a.preventDefault();memberships.addMembership($(this).parents(".membership_card").find(".membership_number").text(),!1)});d.removeClass("hidden").css("display","flex").appendTo($("#template_membership_card").parent());$("#membership_list").not(":visible").show()}$("#newMembershipNumber").val("");g();f&&l()}},error:function(){tools.dialog.hideDialog("membershipsProcessingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}})},deleteMembership:function(a){tools.dialog.showWaitingPopupDelayed("membershipsProcessingDialog",
!0,null,200);$.ajax({url:contextPath+"/ajax/memberships/removeMembership",type:"POST",data:{movementId:d.attr("data-movement-id")},cache:!1,success:function(){tools.dialog.hideDialog("membershipsProcessingDialog");$("#movementsMembershipsOverride"+a.attr("data-movement-id")).remove();a.find(".membership_selected").hide();a.find(".membership_unselected").show();f&&l()},error:function(){tools.dialog.hideDialog("membershipsProcessingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}})},bindEvents:function(){$(".membership_unselected .alternative_button a").click(function(a){a.preventDefault();
a=$(this);a.parent().hasClass("disabled")?memberships.closeForm():memberships.showForm(a)});$(".membership_selected .alternative_button a").click(function(a){a.preventDefault();memberships.deleteMembership($(this).parents(".membership"))});$(".submit_membership_form").click(function(a){a.preventDefault();if($(this).hasClass("disabled")){a=$("#noMembershipWarning");var c=$("#noMembershipError");a.is(":visible")?(tools.scrollToElement(a,"fast"),a.slideUp("fast",function(){c.slideDown("fast")})):tools.scrollToElement(c,
"fast")}else b.submit()});$("#addMembership").click(function(a){a.preventDefault();(a=$("#newMembershipNumber").val())&&memberships.addMembership(a,!0)});$("#newMembershipNumber").bind("enterKey",function(){var a=$("#newMembershipNumber").val();a&&memberships.addMembership(a,!0)}).keypress(function(a){13===a.keyCode&&(a.preventDefault(),$(this).trigger("enterKey"))});$(".selectMembership").click(function(a){a.preventDefault();a=$(this).parents(".membership_card").find(".membership_number").text();
memberships.addMembership(a,!1)});$("#membershipsSeizeOtherCards").click(function(a){a.preventDefault();$("#main_content_memberships").slideDown("fast");$(this).hide();tools.displayLazyImages()});a.find(".close_expand_panel").click(function(){memberships.closeForm()})}}});
tools.module("multiselect",function(){var a=null,b=function(a){return $(a).find(".dropdown .dropdownItem:not(:first-child):not(.hidden)").toArray().filter(function(a){return $(a).children("input").is(":checked")}).length},c=function(a,b){$(a).prop("checked",b);return b},d=function(a,b){var c=$(a).find(".placeHolder > .default");a=$(a).find(".placeHolder > .selectedItems");0===b?(a.hide(),c.show()):(c.hide(),a.find(".number").html(b),a.show())},f=function(a,b){var c=$(a).find("input#selectedValues").val();
void 0===b||c.includes(b)||$(a).find("input#selectedValues").val(""===c?b:c+" "+b)},e=function(a,b){var c=$(a).find("input#selectedValues").val();$(a).find("input#selectedValues").val(c.replace(b,"").trim())},g=function(a){var d=$(a).find(".dropdown .dropdownItem:not(:first-child):not(.noItems)").toArray().length,e=b(a);c($(a).find(".dropdown .selectAll input"),d===e)},h=function(a){var b=$("#input_search").val().trim().replace(/ +/g," ").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase(),
c=$(a).find(".dropdown .dropdownItem:not(.hidden):not(.selectAll):not(.noItems)"),d=0,e=$(a).find(".dropdown .selectAll"),f=$(a).find(".dropdown .noItems");Array.from(c).forEach(function(a){var c=$(a).find(".searchValue").data("search-values").split("|");Array.apply(null,$jscomp.arrayFromIterable(c)).some(function(a){return a.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().includes(b)})?($(a).css({display:"flex"}),$(a).addClass("active"),d++):($(a).css({display:"none"}),$(a).removeClass("active"))});
0===d?(e.hide(),f.show()):(e.show(),f.hide());l(a);g(a)},l=function(a){$(a).find("#input_search").on("keydown",function(b){"Enter"===b.key&&(b=$(a).find(".dropdown .selectAll").find("input"),b.is(":checked")||multiselect.selectAllItems(a,b))})},k=function(){function b(a){var b=$(a).find(".dropdown"),c=b.siblings(".selector");b.width(c.width());$(a).addClass("active");b.is(":hidden")&&$(a).find(".icon").toggleClass("rotate");c=$(a).find("#input_search");if(c.length){var d=$(a).find(".placeHolder");
"hidden"===c.attr("type")&&(c.attr("type","text").focus(),d.hide(),l(a))}b.show();a=b.find(".dropdownItem").map(function(){return $(this).width()}).get();a=Math.max.apply(Math,a);0<a&&b.find(".dropdownItem").width(a)}function c(a,b){$(a).find(".dropdown").hide();$(a).find(".placeHolder").show();g(a);var c=$(a).find("#input_search");c.length&&(c.val(""),c.attr("type","hidden"),SeatMap.initSearchableFilterOutFocus(a));$(b.target).closest(".dropdown").length||($(a).find(".icon").toggleClass("rotate"),
$(a).removeClass("active"))}$(a).each(function(a,d){$(d).on("click",function(a){var e=$(a.target);e.hasClass("icon")&&e.hasClass("rotate")?c(d,a):b(d)});$(document).on("click",function(a){$(d).hasClass("active")&&0===$(a.target).closest(d).length&&c(d,a)})});$(document).find(".culturalContactSelector .dropdown .noItems").hide()};return{init:function(b){a=b;k()},getComboList:function(){return a},selectItem:function(a,h,l){l?c(h,!h.is(":checked")):(c(h,!h.is(":checked")),g(a),h.is(":checked")?f(a,h.prop("id")):
e(a,h.prop("id")),d(a,b(a)))},updateSelectedItemsText:function(a){d(a,b(a))},selectAllItems:function(a,g){var h=c(g,!g.is(":checked"));$(a).find(".dropdown .dropdownItem:not(:first-child):not(.hidden):is(.active)").each(function(b,d){c($(d).children("input"),h);h?f(a,$(d).children("input").prop("id")):e(a,$(d).children("input").prop("id"))});d(a,b(a))},reset:function(a){$(a).find(".dropdown .dropdownItem input").each(function(b,e){b=$(e);c(b,!1);d(a,0)});$(a).find("input#selectedValues").val("")},
getSelectedValues:function(a){return $(a).find("input#selectedValues").val().trim().split(" ").filter(function(a){return a}).filter(function(b){return $(a).find("input[id='"+b+"']").parent(":not(.hidden)").length}).sort()},getListValueBySearch:function(a){h(a)}}});
tools.module("option.event",function(){var a=null,b=null,c=function(){return option.general.isMainPerformanceSelected()?option.general.isAtLeastOneQuantitySelected("seatCategoryQuantityInput")?option.general.isMinGaugeRespected("seatCategoryQuantityInput")?option.general.isMaxGaugeRespected("seatCategoryQuantityInput")?option.general.isMaxLengthRequestRemarkRespected("remark"):!1:(option.general.showNotification("notification-respect_min_gauge_per_seatcat"),option.general.validateQuantity("seatCategoryQuantityInput"),
!1):(option.general.showNotification("notification-select_tickets"),!1):(option.general.showNotification("notification-select_performance"),!1)};return{init:function(c){option.general.setConfig(c);a=c.perfIdToConfigIdMap;b=c.previousConfigId;jQuery(function(){tools.registerAsIntegerInput("seatCategoryQuantityInput")})},checkSubmit:function(){option.general.doSubmitOption(c)},refreshPerformanceData:function(c){a[c]!==b&&(b=a[c],option.general.refreshPerformanceData())}}});
OPT_SELECTOR_REMOVE_FORM="#optionRemoveForm";OPT_SELECTOR_REQUEST_FORM="#optionRequestForm";OPT_SELECTOR_DEPENDENT_LINE=".dependent_line";OPT_SELECTOR_DEPENDENT_PERF=".dependent_performance-";OPT_SELECTOR_PERFORMANCE_SELECT=".select_fallback";OPT_SELECTOR_PERFORMANCE_DATA=".performance_option";OPT_SELECTOR_MIN_GAUGE_CONTAINTER=".min_gauge_container";OPT_SELECTOR_CATEGORIES_TABLE_CONTAINTER=".categories_table_container";OPT_SELECT_NO_VALUE="";OPT_REMARK_MAX_LENGTH=2E3;
tools.module("option.general",function(){var a=void 0,b=void 0,c=void 0,d="",f=null,e=!1,g=function(a){if(0===a.length)var b=0;else if(b=parseInt(a,10),isNaN(b)||!/^[0-9]+$/.test(a))b=-1;return b},h=function(a){a.each(function(){$(this).tipsy("hide");$(this).removeClass("error")})},l=function(a){a||(a=0);return f.find(OPT_SELECTOR_PERFORMANCE_SELECT+"-"+a)},k=function(a){a||(a=0);a=l(a);return(a.length?a.val():OPT_SELECT_NO_VALUE)!==OPT_SELECT_NO_VALUE},m=function(){$(OPT_SELECTOR_PERFORMANCE_DATA).show()},
p=function(a,b){var c=b?function(a,c){return-1===$.inArray($(c).val(),b)}:function(a,b){return 0===a};f.find(OPT_SELECTOR_PERFORMANCE_SELECT+"-"+a+" option").each(function(b){c(b,this)?$(this).prop("disabled",!1):(b=l(a),b.val()==$(this).val()&&b.val(OPT_SELECT_NO_VALUE),$(this).attr("disabled",!0))})},q=function(a,b){tools.dialog.showWaitingPopup("loadingDialog",!0);$.ajax({type:"GET",url:contextPath+"/ajax/option/getPerformanceCategoriesTable",data:{performanceId:a,productId:c},success:function(a){$(OPT_SELECTOR_CATEGORIES_TABLE_CONTAINTER).html(a);
b&&b(a);tools.dialog.hideDialog("loadingDialog")},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}})},r=function(){$(OPT_SELECTOR_DEPENDENT_LINE+"_"+d).each(function(){$(this).find(OPT_SELECTOR_PERFORMANCE_SELECT).each(function(a){a=l(a);(a.length?a.val():OPT_SELECT_NO_VALUE)!==OPT_SELECT_NO_VALUE?($(this).children().hide(),$(this).find(OPT_SELECTOR_DEPENDENT_PERF+a.val()).show(),$(this).parent().show()):$(this).parent().hide()})})};checkMandatoryRemark=
function(){var a=$("#remark");return!e||a.length&&a.val()?!0:($("#field_remark").addClass("error"),option.general.showNotification("notification-mandatory-fields"),!1)};return{setConfig:function(d){void 0!==d.minGauge&&(a=d.minGauge);void 0!==d.maxGauge&&(b=d.maxGauge);void 0!==d.productId&&(c=d.productId);void 0!==d.mandatoryRemark&&(e=d.mandatoryRemark);$(function(){f=$(OPT_SELECTOR_REQUEST_FORM);$(OPT_SELECTOR_MIN_GAUGE_CONTAINTER).html(a)})},setCurrentContainerId:function(a){d=a;f=$(d?"#"+d:OPT_SELECTOR_REQUEST_FORM)},
getCurrentContainer:function(){return f},removeOption:function(){tools.dialog.showWaitingPopup("requestProcessingDialog",!0);$(OPT_SELECTOR_REMOVE_FORM).submit()},doSubmitOption:function(a){$("#field_remark").removeClass("error");$(".main_content_notification").hide();if(a()&&checkMandatoryRemark()){tools.dialog.showWaitingPopup("requestProcessingDialog",!0);a=$(OPT_SELECTOR_REQUEST_FORM);var b=function(){$(this).val()===OPT_SELECT_NO_VALUE&&$(this).removeAttr("name")};a.find("select").each(b);a.find('input[type="hidden"]').each(b);
a.submit()}},isAtLeastOneQuantitySelected:function(a){var b=!1;$("."+a).each(function(){if(0<g($.trim($(this).val())))return b=!0,!1});return b},isMaxLengthRequestRemarkRespected:function(a){return validation.validateField(a,{maxLength:OPT_REMARK_MAX_LENGTH,tooltipError:validationErrors.textTooLong},null,!0)},isMinGaugeRespected:function(b){var c=!0;$("."+b).each(function(){var b=g($.trim($(this).val()));if(0<b&&b<a)return c=!1});return c},isMaxGaugeRespected:function(a){var c=!0;$("."+a).each(function(){var a=
g($.trim($(this).val()));if(0<a&&a>b)return c=!1});return c},validateQuantity:function(c){var d=!0;var e=[{rule:validation.numericRule()},{rule:validation.numericBoundsRule(a,0)},{rule:validation.numericBoundsRule(0,b)}];"object"!=typeof c?(c=$("."+c),h(c)):c=$(c);c.each(function(){0===g($.trim($(this).val()))||validation.validateField(this.id,e,null,!0)||(d=!1)});return d},showNotification:function(a){$("#"+a).show();window.scrollTo(0,0)},isMainPerformanceSelected:function(){return k()},refreshPerformanceData:function(){k()?
q(l().val(),m):$(OPT_SELECTOR_PERFORMANCE_DATA).hide()},selectChanged:function(a,b){var c=0;for(selectedPerfIds=[];c<=b;c++)c>a&&(k(c-1)?p(c,selectedPerfIds):p(c)),k(c)&&selectedPerfIds.push(l(c).val());r()},hideFallbacks:function(a){f.find(".select_fallback_container").slice(a).parent().hide()},showFallbacks:function(a){var b=f.find(".select_fallback_container").slice(1),c=b.length;b.each(function(b){if($(this).parent().is(":hidden"))return $(this).parent().show(),b>=c-1&&$(a).hide(),!1})},getProductId:function(){return c}}});
OPT_SELECTOR_PKG_LINE_CONTENT=".package_line_content";OPT_SELECTOR_ITEM_SELECT=".select_item";OPT_SELECTOR_MAIN_PERF_SELECT=".select_fallback-0";OPT_SELECTOR_QUANTITY_SUMMARY=".total_package_content .value";OPT_QUANTITY_JOIN_CHAR="+";
tools.module("option.pkg",function(){var a={},b=function(a){var b=!0;$(OPT_SELECTOR_PKG_LINE_CONTENT).find(a).each(function(){if($(this).val()===OPT_SELECT_NO_VALUE)return b=!1});return b},c=function(){return b(OPT_SELECTOR_MAIN_PERF_SELECT)&&b(OPT_SELECTOR_ITEM_SELECT)?option.general.isAtLeastOneQuantitySelected("seatCategoryQuantityInput")?option.general.isMinGaugeRespected("seatCategoryQuantityInput")?option.general.isMaxLengthRequestRemarkRespected("remark"):(option.general.showNotification("notification-respect_min_gauge"),
option.general.validateQuantity("seatCategoryQuantityInput"),!1):(option.general.showNotification("notification-select_tickets"),!1):(option.general.showNotification("notification-select_pkg_line_info"),!1)};return{init:function(a){option.general.setConfig(a);$(function(){tools.registerAsIntegerInput("seatCategoryQuantityInput")})},makeQuantitySummary:function(){$(function(){option.pkg.refreshQuantitySummary()})},checkSubmit:function(){option.general.doSubmitOption(c)},addLineQuantityData:function(b,
c,e){c=c+","+e;a[c]||(a[c]=0);a[c]+=b},refreshQuantitySummary:function(){var b=[];$.each(a,function(a,c){a=a.split(",");b.push(c+" "+(1===c?a[0]:a[1]))});$(OPT_SELECTOR_QUANTITY_SUMMARY).text(b.join(" "+OPT_QUANTITY_JOIN_CHAR+" "))}}});
tools.module("requestEdit",function(){var a={},b=function(b,c,d){var e=b.data("maxQuantity");var f=b.data("minQuantity");"undefined"===typeof e&&(e=1E7);"undefined"===typeof f&&(f=0);var g=[{rule:validation.numericRule(!0)}];!a.allowExceedingPreRequestDemand&&$.isNumeric(d)&&parseInt(d)?g.push({rule:validation.requestExceedLimit(f,e,!0,!0)}):g.push({rule:validation.numericBoundsRule(f,e,!0,!0)});return validation.validateFieldAndHandleTooltip(!0,b,g,null,c,!1,!0)},c=!1,d=function(a,b,c){void 0!==
c?f(c,a,b):$(".table_container").each(function(){f(this,a,b)})},f=function(a,c,d){$(a).find("tr").each(function(){var a=$('td.quantity.review_quantity input[type="text"], td.quantity.review_quantity input[type="number"]',this);0<a.length&&($(a).val()?c.validQuantityField&&!d?c.validQuantityField=b(a,!1):d&&b(a,!0):a.val(0),0<parseInt(a.val(),10)&&(c.quantitySelected=!0))})},e=function(){var d=0,e=0;$(".table_container").each(function(){var c=0,f=0,g=!1,h=null,l=null;$(this).find("tr").each(function(k){var m=
!0;var p=$(this).find("input.hidden_initial_quantity");p.length&&(h=$(this).find(".remaining_quantity"));$(this).find(".quota_distribution_remaining_label").length&&(l=$(this).find(".quota_distribution_remaining_label"));var u=$('td.quantity.review_quantity input[type="text"], td.quantity.review_quantity input[type="number"]',this);if(0<u.length){$(u).val()&&(m=b(u,!0,p.length&&p.val()?p.val():0));var x=!1}else if(a.isQuotaDistribution){if(0<$("#distributedColumn",this).length&&$("#distributedColumn",
this)[0].innerText){x=m=!0;var C=parseInt($("#distributedColumn",this)[0].innerText,10)}}else 0<$("#confirmedColumn",this).length&&$("#confirmedColumn",this)[0].innerText?(x=m=!0,C=parseInt($("#confirmedColumn",this)[0].innerText,10)):0<$("#acceptedColumn",this).length&&$("#acceptedColumn",this)[0].innerText?(x=m=!0,C=parseInt($("#acceptedColumn",this)[0].innerText,10)):0<$("#distributedColumn",this).length&&$("#distributedColumn",this)[0].innerText&&(x=m=!0,C=parseInt($("#distributedColumn",this)[0].innerText,
10));var A=$(this).find(".unit_price .amount").last();var r=($(this).parent().find("tr").length-1)/$(this).parent().find(".unit_price .amount").length;k=Math.floor(k/r);!A.length&&a.isQuotaDistribution&&(A=$(this).parent().find(".unit_price .amount").eq(k));(x||0<u.length)&&m?(u=!x&&$(u).val()?parseInt($(u).val(),10):C,isNaN(u)&&(u=0),A=A.data("amount"),A*=u,a.isQuotaDistribution?$(this).find(".quotaDistributionEntryTotalAmount  .amount").html(functions.generateAmount(A)):$(this).find(".subtotal .amount").html(functions.generateAmount(A)),
c+=A,d+=u,f+=u,0<p.length&&(p=Number($(p).val()),A=u-p,m=$("td.other_cat_quantity .wrapper_other_cat_quantity",this),x=$("td.other_cat_quantity input",this),C=$(".max_other_cat_qty",this),prevQty=x.val(),0<A?(m.hasClass("hidden_input")&&m.removeClass("hidden_input"),x.val(Math.min(prevQty,A)),$(C).html(" / "+A)):(m.addClass("hidden_input"),x.val(0)),g||(g=!(isNaN(p)&&0===u)&&p!==u))):a.isQuotaDistribution||$(this).find(".subtotal .amount").html(functions.generateAmount(0));a.isQuotaDistribution&&
!a.isQuotaDistributionReadOnlyMode&&$(this).hasClass("quotaDistributionTotalLine")&&(p=$(this).find("input.hidden_quota_distribution_initial_quantity").val(),$(this).find("td.quotaDistributionTotalQuantity").html(d),$(this).find("td.quotaDistributionTotalAmount").html(functions.generateAmount(c)),e+=d,z(a,p,d,h,l),d=0)});a.isQuotaDistribution||(e=d);$(this).find("tr.subtotal td.reservation_amount .amount").html(functions.generateAmount(c));var k=$(this).parent().siblings().first().find(".tickets");
if(1===k.length){if(g){var m=k.find(".ticket_icon").first();var p=k.find(".ticket_state").first();var u=k.find(".ticket_quantity").first();m.removeClass("inactive");m.addClass("active");p.html("");u.html(f)}else m=k.find(".ticket_icon").first(),p=k.find(".ticket_state").first(),u=k.find(".ticket_quantity").first(),m.removeClass("active"),m.addClass("inactive"),p.html(a.labels.ticketStatePreRequest);a.isQuotaDistribution||(u.html(f),0<f?k.addClass("hasTickets"):k.removeClass("hasTickets"));k=$(this).parent().siblings().first().find(".button");
k.find(".modify_text").toggleClass("hidden",0===f);k.find(".request_text").toggleClass("hidden",0<f)}});var f=e+" "+(1<e?a.labels.ticketPlural:a.labels.ticketSingle);var g;if(g=0<e)g=a.isQuotaDistribution?!t()&&w():!0;g?($("#summary").hasClass("collapsed")?($(".total_ticket").html(f),$("#summary").removeClass("collapsed")):$(".total_ticket").html()!==f&&$(".total_ticket").fadeOut(200,function(){a.isEditingRequest&&!c&&($("#buy_order").attr("onclick",""),$("#buy_order").click(function(a){tools.dialog.showWaitingPopup("confirmationDialog",
!0);a.stopPropagation()}),c=!0);$(".total_ticket").html(f);$(".total_ticket").fadeIn(200)}),$("#addToCartButton").removeClass("disabled"),$(".applyToAllButton").removeClass("disabled"),!0===a.applyToAllClicked&&a.previousQuantity!==e&&$(".applyToAllButton.visible").each(function(){$(this).tipsy("show")})):($(".total_ticket").html(f),$("#addToCartButton").addClass("disabled"),0==e&&$(".applyToAllButton").addClass("disabled"),a.applyToAllClicked=!1);a.previousQuantity=e;m()},g=function(){var b=0;$('.table_transfer_seat_cat tr td.target_quantity_to_transfer_seat_cat > input[type="number"]').each(function(){var a=
Number($(this).val());isNaN(a)||$(this).hasClass("error")||(b+=a)});$(".total_ticket").html(b+" "+(1<b?a.labels.ticketPlural:a.labels.ticketSingle))},h=function(){l()?$("#transferSeatCatButton").removeClass("disabled"):$("#transferSeatCatButton").addClass("disabled")},l=function(){var a=!0,b=0;$(".table_transfer_seat_cat tr.group_seat_cat_body").each(function(){var c=$(this).find("td.target_transfer_seat_cat > select"),d=$(this).find('td.target_quantity_to_transfer_seat_cat > input[type="number"]'),
e=$(this).find("td.remaining_quantity > span"),f=isNaN(d.val())?0:d.val(),g=isNaN(c.val())?0:Number(c.val()),h=0<c.length&&!c.hasClass("error")&&0!==g;e=0<d.length&&!d.hasClass("error")&&0!==f&&Number(e.text())>=f;b+=isNaN(f)||d.hasClass("error")?0:f;0!==g&&h&&0==f?(d.addClass("error"),a=!1):0==g&&e&&0!=f&&(c.addClass("error"),a=!1);0==g&&0==f&&(d.removeClass("error"),c.removeClass("error"))});return a&&0<b},k=function(){if(t()){if(a.showQuotaDistributionConfirmedQuantity)return a.labels.exceedConfirmedLimitQuantity;
if(a.isQuotaDistribution)return a.labels.exceedDistributedLimitQuantity}return a.labels.contentNotChanged},m=function(){a.isQuotaDistribution&&($("#addToCartButton").tipsy({className:"tipsy-validation",delayIn:200,gravity:"s",title:function(){return $("#addToCartButton").hasClass("disabled")&&!$("#addToCartButton").hasClass("clicked")?k():""}}),tools.makeTooltipAccessible("#addToCartButton"))},p=function(a){return $('td.quantity.review_quantity input[type="text"], td.quantity.review_quantity input[type="number"]',
a)},q=function(a,b){b=void 0===b?!0:b;for(var c=0;c<a.length;c++){var d=a[c];if(d.hasClass("hidden")){d.removeClass("hidden");var f=p(d);d=$("input.hidden_initial_distributed_quantity",d).val();f.length&&d&&f.val(d)}}b&&e()},r=function(a,b){b=void 0===b?!0:b;for(var c=0;c<a.length;c++){var d=a[c];d.hasClass("hidden")||(d.addClass("hidden"),d=p(d),0<d.length&&d.val(0))}b&&e()},t=function(){var b=0<$(".remaining_quantity.additional_quantity").length;return a.isQuotaDistribution?a.showQuotaDistributionConfirmedQuantity?
!a.allowExceedingPreRequestDemand&&b:b:!1},w=function(){var b=!0,c=0;$('td.quantity.review_quantity input[type="number"]').each(function(a,d){b=b&&Number($(d).val())===Number($(d).attr("defaultvalue"));c+=Number($(d).attr("defaultvalue"))});return!b||a.showQuotaDistributionConfirmedQuantity&&0<c},y=function(b){var c={},d=a.isQuotaDistribution?".quotaDistribution":".group_seat_cat_body",e=a.isQuotaDistribution?"input[name=hidden_seat_cat_entry_key]":".hidden_seat_cat_sub_cat_key",f,g,h,k;var l=b.closest("table").find(".group_seat_cat_body").first().attr("groupkey").split("_")[0];
b.closest("table").find(d).each(function(){f=$(this).find(e).val();h=p($(this));c[f]=""===h.val()?"0":h.val()});$(".table_container").each(function(){g=$(this).find(".group_seat_cat_body").first().attr("groupkey").split("_")[0];g!==l&&$(this).parent().parent().is(":visible")&&$(this).find(d).each(function(a){f=$(this).find(e).val();if(k=c[f])h=p($(this)),h.val(k)})})},z=function(a,b,c,d,e){d.removeClass("additional_quantity");e&&e.removeClass("additional_quantity");b&&parseInt(b)?(b-=c,0>b?(a=a.isQuotaDistributionReadOnlyMode?
a.labels.additionalQuantity:a.showQuotaDistributionConfirmedQuantity?a.labels.additionalConfirmedQuantity:a.labels.additionalDistributedQuantity,d.addClass("additional_quantity"),d.html("("+Math.abs(b)+")")):(a=a.isQuotaDistributionReadOnlyMode?a.labels.remainingQuantity:a.showQuotaDistributionConfirmedQuantity?a.labels.unConfirmedQuantity:a.labels.unDistributedQuantity,d.html(""+Math.abs(b))),e&&(e.html(a),0>b&&e.addClass("additional_quantity"))):d.html("-")};return{init:function(b){a.labels=b.labels;
a.withPreRequestedQuantity=b.withPreRequestedQuantity;a.isEditingRequest=b.isEditingRequest;a.performanceId=b.performanceId;a.allowExceedingPreRequestDemand=b.allowExceedingPreRequestDemand;a.isQuotaDistribution=b.isQuotaDistribution;a.isQuotaDistributionReadOnlyMode=b.isQuotaDistributionReadOnlyMode;a.showQuotaDistributionConfirmedQuantity=b.showQuotaDistributionConfirmedQuantity;a.applyToAllClicked=!1;a.previousQuantity=0;$(".request_content").hide();requestEdit.bindFilters();$(".applyToAllButton").each(function(){$(this).tipsy({className:"tipsy-information",
delayIn:100,opacity:1,trigger:"manual",gravity:"sw",title:function(){return a.labels.alreadyAppliedToAll}})});$("#applyToAllButton a").on("click",function(b){b.preventDefault();a.applyToAllClicked=!1;!$(this).parent().hasClass("disabled")&&requestEdit.validateQuantities($(this).closest("table"))&&(y($(this)),setTimeout(function(){a.applyToAllClicked=!0;e();$(".applyToAllButton.visible").each(function(){$(this).tipsy("hide")})},200))});$("#addToCartButton a").on("click",function(a){a.preventDefault();
!$(this).parent().hasClass("disabled")&&requestEdit.validateQuantities()&&requestEdit.onFallbackChange()&&(tools.dialog.showWaitingPopup("loadingDialog",!0),$("#addToCartButton").addClass("clicked"),$("#request_edit_form tr.quotaDistribution").each(function(){var a=$(this).find(".quantity input"),b=function(a){a.attr("disabled","disabled");a.addClass("submit-form-disabled")};(function(a,b){return Number(a)!==Number(b)})(a.val(),$(this).find(".quantity input.hidden_initial_review_quantity").val())||
(b(a),b($(this).find('input[name="distributionEntry"]')),b($(this).find('input[name="hidden_seat_cat_entry_key"]')))}),$("#request_edit_form").submit())});var c=function(a){return function(a){var b=$(this).find(".button").not(".applyToAllButton"),c=b.parents(".performance_SPORTING_EVENT").first(),d=0===c.find(".buttons .button.requestDrawerBtn.hidden").length;c.toggleClass("expanded",d);c=b.parents(".request_performance").first();c.toggleClass("expanded",d);c.toggleClass("collapsed",!d);var e=c.find(".applyToAllButton");
e.toggleClass("visible",d);c.hasClass("collapsed")!==d&&(b.siblings(".requestDrawerCloseBtn, .requestDrawerBtn").toggleClass("hidden"),b.toggleClass("hidden"),e.tipsy("hide"));c.find(".request_content").first().slideToggle(400);$.each($(".quantity input"),function(a,b){$(b).tipsy("hide")});if("undefined"!==typeof a.type&&"click"===a.type)return!1}};$(".performance_SPORTING_EVENT").on("click",c());1===$(".request_content").length?($(".matches_toggle").addClass("hidden"),$(".performance_SPORTING_EVENT").trigger("click"),
setTimeout(function(){$(".filters").removeClass("hidden");$("#performance_container").removeClass("hidden")},400)):($(".filters").removeClass("hidden"),$("#performance_container").removeClass("hidden"));$(".toggle_button").on("click",function(){$round=$(this).parents(".round");$round.toggleClass("collapsed");$round.find(".round_content").slideToggle()});$("#toggle_all_matches").on("click",function(){$(this).is(":checked")?$(".round").each(function(){var a=$(this);a.hasClass("collapsed")?(a.removeClass("collapsed"),
$(".round_content",this).slideDown(openPerformances)):$(".request_performance.collapsed",$(a)).each(c())}):$(".round").each(function(){var a=$(this);$(".request_performance.expanded",$(a)).each(c())})});a.performanceId&&$(".request_performance").filter(function(b,c){return $(c).attr("data-performance-id")===a.performanceId}).each(function(a,b){$(b).hasClass("collapsed")&&$(".performance_SPORTING_EVENT",$(b)).click()});0<$("#transferSeatCatButton").length?(g(),h()):a.isQuotaDistributionReadOnlyMode||
e();$("#transferSeatCatButton a").on("click",function(a){a.preventDefault();!$(this).parent().hasClass("disabled")&&l()&&(tools.dialog.showWaitingPopup("loadingDialog",!0),$("#request_seatCat_transfer_form").submit())});a.isQuotaDistributionReadOnlyMode&&$(".additional_quantity").each(function(b,c){b=$(c).closest(".group_seat_cat_body ").attr("groupkey");z(a,$(c).html(),0,$(c),$("th.quantity",'.group_seat_cat_header[groupkey="'+b+'"]'))})},onQuantityChange:function(){e()},onTargetSeatCatQuantityChange:function(a,
b,c){var d=$('input[name="performance2RequestData['+a+"]["+b+'].targetTransferQuantity"]');a=$("#performance_"+a+"_"+b+"_remainingQuantity");b=Number(d.val());c=Number(c);functions.validateQuantityInputField(d)?(d.removeClass("error"),a.html(c-b)):(d.addClass("error"),a.html(c));g();h()},onChangeSeatCategory:function(){h()},validateQuantities:function(b){var c={validQuantityField:!0,quantitySelected:!1};d(c,!1,b);void 0===b&&(c.validQuantityField||($("#notification-reselect_tickets.hidden").removeClass("hidden"),
$(".tipsy:last").remove(),d(c,!0,b)),c.quantitySelected||a.withPreRequestedQuantity||($("#notification-select_tickets.hidden").removeClass("hidden"),c.validQuantityField=!1));return c.validQuantityField},onFallbackChange:function(){var a=!0;$(".table_container").each(function(){$(this).find("tr").each(function(){var b,c;var d=$('td.quantity.review_quantity input[type="text"], td.quantity.review_quantity input[type="number"]',this);0<d.length&&(b=parseInt($(d).val(),10));d=$("input.hidden_initial_quantity",
this);0<d.length&&(c=$(d).val());d=$('td.quantity.other_cat_quantity input[type="text"], td.quantity.other_cat_quantity input[type="number"]',this);0<d.length&&0<=c&&b>c&&(b-=c,0<b&&(b=[{rule:validation.numericRule(!0)},{rule:validation.numericBoundsRule(0,b,!0,!0)}],$(d).val()||d.val(0),a=validation.validateFieldAndHandleTooltip(!0,d,b,null,!0,!1,!0)))});if(!a)return!1});return a},bindFilters:function(){requestEdit.bindVenueFilter();requestEdit.bindTeamFilter()},bindVenueFilter:function(){var a=
$("#venue"),b=a.parent().find(".label .filterToolReset");a.change(requestEdit.applyFilters);b.hide();b.click(function(){a.val("");requestEdit.applyFilters()})},bindTeamFilter:function(){var a=$("#team"),b=a.parent().find(".label .filterToolReset");a.change(requestEdit.applyFilters);b.hide();b.click(function(){a.val("");requestEdit.applyFilters()})},filterVenue:function(){var a=$("#venue").val(),b=$("#venue").parent().find(".label .filterToolReset");void 0!==a&&""!==a&&(b.show(),$("#performance_container .request_performance:visible").each(function(){$(this).toggle(a===
$(this).attr("data-venue-id"))}),requestEdit.togglePerformanceContainerHeading())},filterTeam:function(){var a=$("#team").val(),b=$("#team").parent().find(".label .filterToolReset");void 0!==a&&""!==a&&(b.show(),$("#performance_container .request_performance:visible").each(function(){$(this).toggle(a===String($(this).attr("data-host-team-id"))||a===String($(this).attr("data-opposing-team-id")))}),requestEdit.togglePerformanceContainerHeading())},togglePerformanceContainerHeading:function(){var a=
$("#performance_container");$(".date",a).each(function(){var a=0<$(this).nextUntil(".date",".request_performance:visible").length;$(this).toggle(a)});$(".round",a).each(function(){$(this).toggle(0<$(this).find(".request_performance:visible").length)})},applyFilters:function(){var a=$("#venue").parent().find(".label .filterToolReset"),b=$("#team").parent().find(".label .filterToolReset"),c=$("#performance_container");$(".round",c).show();$(".round_content",c).show();$(".date",c).show();$(".request_performance",
c).show();a.hide();b.hide();requestEdit.filterVenue();requestEdit.filterTeam()},onChangeRelaysSelect:function(a){var b=[],c=[],d=new Set(a);$(".quotaDistribution").map(function(a,e){a=$(e);e=a.children("input[name=distributionEntry]").val();d.has(e)?b.push(a):c.push(a)});q(b,!1);r(c,!1);e()}}});
tools.module("optionReview",function(){var a=function(a,b,f){for(b;b<f;b++)a.options.remove(0)};buttonDisabled=function(a){return 0===$("#"+a).length?!1:$("#"+a).parent().hasClass("disabled")};var b=function(a,b,f){var c=0;for(c;c<=b;c++){var d=document.createElement("option");d.text=c;d.value=c;d.selected=c===f;a.options.add(d)}};return{updateQuantityDelta:function(){$(".table_container").each(function(){$(this).find("tr").each(function(){var c=$('td.quantity select, td.quantity input[type="text"], td.quantity input[type="number"]',
this);var d=$('td.hidden_initial_quantity input[type="hidden"]',this);var f=$("td.other_cat_quantity select",this);var e=void 0!==f[0]?f[0]:null;0<c.length&&0<d.length&&null!==e&&(c=parseInt($(c).val(),10),d=parseInt($(d).val(),10),c-=d,d=parseInt(e.value,10),a(e,0,e.options.length),f.hasClass("hidden_select_box")&&0<c?(f.removeClass("hidden_select_box"),b(e,c,0)):0<c?b(e,c,d>c?c:d):0>=c&&f.addClass("hidden_select_box"))})})},updateTotalAmountOfAllTables:function(a){var b=$(".total .amount");0<b.length&&
b.html(functions.generateAmount(a))},submitForm:function(a,b,f,e,g){tools.dialog.showWaitingPopup("loadingDialog",!0);this.setTimeoutToCheckout(e);$.post(contextPath+"/ajax/request/summary/submit",{preRequestedFileId:b,isQuotaDistribution:f}).done(function(c){switch(c.status){case "ERR_TOO_MANY_TICKETS":var d=$("#tooManyRequestTickets");c.parameters&&($(".message-content",d).html(c.parameters.message),$("#edit_request_btn",d).attr("href",c.parameters.redirectUrl));b?$("#cancel_request_btn",d).attr("href",
contextPath+"/request/summary/cancel"):$("#cancel_request_btn",d).attr("href","");$("#cancel_request_btn",d).unbind("click").on("click",function(){if(!b)return tools.dialog.hideDialog("tooManyRequestTickets"),!1});tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("tooManyRequestTickets",!0,!0);break;case "ERR_AVAILABILITY":tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("dialogAvailabilityError",!0);break;case "INVALID_REQUESTED_QUANTITY":tools.dialog.hideDialog("loadingDialog");
tools.message.show(c.messageTitle,c.message);break;case "ERR_LIMIT_EXCEEDED":tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("quotaDistributionLimitExceededError",!0,!0);break;case "ERR_QUOTA_DISTRIBUTION_CONFIGURATION":tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("quotaDistributionMisconfiguredError",!0,!0);break;default:window.location=c.parameters.updatedCheckoutUrl?contextPath+c.parameters.updatedCheckoutUrl:a}}).fail(function(a){0<e?window.location=g:(tools.dialog.hideDialog("loadingDialog"),
tools.dialog.showDialog("ajaxErrorDialog",!0))})},submitTransferSeatCatForm:function(a,b,f,e){tools.dialog.showWaitingPopup("loadingDialog",!0);this.setTimeoutToCheckout(f);$.post(contextPath+"/ajax/request/transferSeatCat/submit",{preRequestedFileId:b}).done(function(c){switch(c.status){case "ERR_TOO_MANY_TICKETS":var d=$("#tooManyRequestTickets");c.parameters&&($(".message-content",d).html(c.parameters.message),$("#edit_request_btn",d).attr("href",c.parameters.redirectUrl));b?$("#cancel_request_btn",
d).attr("href",contextPath+"/request/summary/cancel"):$("#cancel_request_btn",d).attr("href","");$("#cancel_request_btn",d).unbind("click").on("click",function(){if(!b)return tools.dialog.hideDialog("tooManyRequestTickets"),!1});tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("tooManyRequestTickets",!0,!0);break;case "ERR_AVAILABILITY":tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("dialogAvailabilityError",!0);break;case "INVALID_REQUESTED_QUANTITY":tools.dialog.hideDialog("loadingDialog");
tools.message.show(c.messageTitle,c.message);break;case "ERR_TRANSFER_SEAT_CATEGORY_CONFIGURATION":tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("transferSeatCatMisconfiguredError",!0,!0);break;default:window.location=c.parameters.updatedCheckoutUrl?contextPath+c.parameters.updatedCheckoutUrl:a}}).fail(function(a){0<f?window.location=e:(tools.dialog.hideDialog("loadingDialog"),tools.dialog.showDialog("ajaxErrorDialog",!0))})},setTimeoutToCheckout:function(a){0<a&&$.ajaxSetup({async:!0,
timeout:a})},init:function(a){if(buttonDisabled("submitRequest")||buttonDisabled("buy_order"))$("#submitRequest, #buy_order").tipsy({className:"tipsy-validation",delayIn:200,gravity:"s",title:function(){return a.labels.contentNotChanged}}),tools.makeTooltipAccessible("#submitRequest, #buy_order")},checkAndSubmit:function(a,b,f,e,g,h,l){if(buttonDisabled("submitRequest")||buttonDisabled("buy_order"))return!1;a||"undefined"!==typeof f&&null!==f?ongoingOrder.checkIfCartIsEmptyAndSubmit({submitForm:!0,
checkoutUrl:b,fileId:f,isQuotaDistribution:"true"==e,isTransferSeatCat:"true"==g,timeout:h,finalizationCheckoutUrl:l}):tools.dialog.showDialog("cancel_file_request_popup",!0)}}});
OPT_SELECTOR_SUBJECT_EVENTS_CONTAINTER="#sstk_subject_events_container-";OPT_SELECTOR_OPTIONAL_EVENT=".season_ticket_line_optional";OPT_SELECTOR_LINE_CONTAINTER="#season_ticket_line-";OPT_SELECTOR_ADD_FALLBACK="a[href$=add_choice]";OPT_SELECTOR_REMOVE_FALLBACK="a[href$=remove_choice]";OPT_SELECTOR_ADD_EVENT="a[href$=add_event]";OPT_SELECTOR_MAIN_PERF_SELECT=".select_fallback-0";OPT_SELECTOR_SPECIFY_FALLBACK_DYNAMIC_CLOSED="#specifyFallbackForDynamicClosed";
OPT_SELECTOR_SPECIFY_FALLBACK_DYNAMIC_OPEN="#specifyFallbackForDynamicOpen";OPT_SEASONTICKET_AJAX_COUNT=2;
tools.module("option.seasonTicket",function(){var a=!0,b=null,c=null,d=0,f="",e=null,g={},h=function(a){f=OPT_SELECTOR_LINE_CONTAINTER+a;e=$(f)},l=function(a,b){var c=b?b.id:"",d=b?jQuery.datepicker.formatDate("dd MM yy",b.jsDate,datePickerConfig)+" "+b.time:"";a.find("span").html(d);a.find('input[type="hidden"]').val(c);b?a.parent().show():a.parent().hide()},k=function(a){var b=e.find(OPT_SELECTOR_PERFORMANCE_SELECT).filter(":hidden");b.length&&(l(b.first(),a),1>=b.length&&e.find(OPT_SELECTOR_ADD_FALLBACK).parent().hide())},
m=function(a,b,c){var d=null,f=e.find(OPT_SELECTOR_PERFORMANCE_SELECT).filter(":visible");!c&&1>=f.length?tools.dialog.showWaitingPopup("confirmationDialog_removeSsTkLine_"+a,!0):(f.slice(b).each(function(){if(d){var a=$(this),b=d;b.find("span").html(a.find("span").html());b.find('input[type="hidden"]').val(a.find('input[type="hidden"]').val())}d=$(this)}),l(d,null),e.find(OPT_SELECTOR_ADD_FALLBACK).parent().show())},p=function(){$(OPT_SELECTOR_REQUEST_FORM).parent().find(OPT_SELECTOR_ADD_EVENT).parent().show();
$.each(g,function(a,b){var c=$(a.length?OPT_SELECTOR_SUBJECT_EVENTS_CONTAINTER+a:OPT_SELECTOR_REQUEST_FORM);b=b.maxOptional;var d=c.find(OPT_SELECTOR_OPTIONAL_EVENT).length;c=c.parent().find(OPT_SELECTOR_ADD_EVENT).parent();if(null!==b&&d>=b&&(c.hide(),!a.length))return!1})},q=function(){var a=!0;$(OPT_SELECTOR_REQUEST_FORM).find(OPT_SELECTOR_MAIN_PERF_SELECT+' input[type="hidden"]').each(function(){if($(this).val()===OPT_SELECT_NO_VALUE)return a=!1});return a},r=function(){var a=!0;$.each(g,function(b,
c){var d=$(b.length?OPT_SELECTOR_SUBJECT_EVENTS_CONTAINTER+b:OPT_SELECTOR_REQUEST_FORM);b=c.minOptional;c=c.maxOptional;d=d.find(OPT_SELECTOR_OPTIONAL_EVENT).length;if(null!==b&&d<b||null!==c&&d>c)return a=!1});return a},t=function(){return r()?q()?option.general.isAtLeastOneQuantitySelected("seatCategoryQuantityInput")?option.general.isMinGaugeRespected("seatCategoryQuantityInput")?option.general.isMaxLengthRequestRemarkRespected("remark"):(option.general.showNotification("notification-respect_min_gauge_per_seatcat"),
option.general.validateQuantity("seatCategoryQuantityInput"),!1):(option.general.showNotification("notification-select_tickets"),!1):(option.general.showNotification("notification-select_sstk_line_info"),!1):(option.general.showNotification("notification-select_events"),!1)},w=function(){$("html body").removeClass("disable_scrolling")},y=function(){$("html body").addClass("disable_scrolling");tools.dialog.showDialog("sstk_option_add_event_popup",!0,!1,w,"content_bloc main_content alternative_content");
null!==c?option.seasontickets.performances.prefillSubject(c):b?option.seasontickets.performances.showOnlyEvent(b):option.seasontickets.performances.showAllEvent();b?$("#ui-dialog-title-sstk_option_add_event_popup").html(option.seasontickets.performances.messages.title.addFallBackPerformance):$("#ui-dialog-title-sstk_option_add_event_popup").html(option.seasontickets.performances.messages.title.addAnEvent);1===$("td.showPerformances a.showPerformances").length&&$("td.showPerformances a.showPerformances").click()};
return{init:function(a){option.general.setConfig(a);$(function(){tools.registerAsIntegerInput("seatCategoryQuantityInput");var a=$(OPT_SELECTOR_SPECIFY_FALLBACK_DYNAMIC_OPEN),b=$(OPT_SELECTOR_SPECIFY_FALLBACK_DYNAMIC_CLOSED),c=$(OPT_SELECTOR_REQUEST_FORM);c.find(".hidden").hide();0<c.find(OPT_SELECTOR_ADD_EVENT).filter(":visible").length||0<c.find(OPT_SELECTOR_ADD_FALLBACK).filter(":visible").length||0<c.find(OPT_SELECTOR_REMOVE_FALLBACK).filter(":visible").length?(b.hide(),a.show()):(a.hide(),b.show())})},
addSubjectData:function(a,b,c){g[a]={minOptional:b,maxOptional:c}},checkSubmit:function(){option.general.doSubmitOption(t)},unselectEvent:function(a,b){h(a);e.remove();$("#confirmationDialog_removeSsTkLine_"+a).remove();p()},unselectPerformance:function(a,b,c){h(a);m(a,b,c)},selectPerformance:function(a,b){var c=a.event.subject.code==option.seasontickets.performances.Subject.NO_SUBJECT_CODE?"":a.event.subject.code,d=a.event.id;tools.dialog.hideDialog("sstk_option_add_event_popup");h(b);e.length?k(a):
(tools.dialog.showWaitingPopup("loadingDialog",!0),$.ajax({type:"GET",url:contextPath+"/option/seasonticket/detail/ajax/getNewSeasonTicketLine",data:{productId:option.general.getProductId(),subjectCode:c,seasonTicketLineId:b,eventId:d},success:function(d){$(OPT_SELECTOR_SUBJECT_EVENTS_CONTAINTER+c).append(d);tools.dialog.hideDialog("loadingDialog");h(b);l(e.find(OPT_SELECTOR_PERFORMANCE_SELECT).first(),a);p();tools.displayLazyImages();tools.triggerLazyImagesRefresh()},error:function(){tools.dialog.hideDialog("loadingDialog");
tools.dialog.showDialog("ajaxErrorDialog",!0)}}))},getSelectedPerformances:function(){return $(OPT_SELECTOR_REQUEST_FORM).find(OPT_SELECTOR_PERFORMANCE_SELECT+' input[type="hidden"]').not('[value="'+OPT_SELECT_NO_VALUE+'"]').map(function(){return parseInt($(this).val(),10)})},isFirstChoice:function(a){return 0<$(OPT_SELECTOR_REQUEST_FORM).find(OPT_SELECTOR_MAIN_PERF_SELECT+' input[type="hidden"][value="'+a+'"]').length},isFirstChoiceDefined:function(a){h(a);return e.length&&e.find(OPT_SELECTOR_MAIN_PERF_SELECT+
' input[type="hidden"]').val()!==OPT_SELECT_NO_VALUE},initializeAndShowAddEventDialog:function(d,e){b=e;c=d;a?(option.seasontickets.performances.init(null,!1,option.general.getProductId()),a=!1):y()},dataInitializedCallBack:function(){d++;d===OPT_SEASONTICKET_AJAX_COUNT&&y()}}});
tools.module("option.seasontickets.performances",function(){var a=null,b=null,c=null,d=null,f=null,e=null,g=null,h=null,l=null,k=null,m=null,p=null,q=null,r=null,t=null,w=null,y=null,z=null,x=0,A=!1,C=null,u=null,v=null,D={},E=null,F=null,B=null,G=null,L=null,K=null,H=!1,M=1,Q=function(a,b,c){$(c).html(Mustache.render(a,b,{performanceTpl:u}))},S=function(){K={page:1,displayWindow:2,nbPerPage:5}},V=function(a){a=$(window).height();var b=$("#sstk_option_add_event_popup").parent(),c=b.height();b=b.offset().top;
0!==b&&(a=b-(a-c)/2,$("html,body").animate({scrollTop:a},300))},N=function(a){var b={},c=null;for(c in a)a.hasOwnProperty(c)&&(b[c]={id:String(c),name:a[c]});return b};return{messages:null,init:function(a,b,c){var d=null,e=null,f=this,g=function(){e&&d&&(f.loadEvents(d),f.loadConfiguration(e),f.updatePerformanceList(),H&&(tools.dialog.hideDialog("loadingDialog"),H=!1))},h=seasontickets.performances.errors,k=h.ajaxErrorDialog;H||(tools.dialog.showWaitingPopup("loadingDialog",!0),H=!0);S();$("body").hasClass("ie_lte_9");
fixedPrice=b;Selection=option.seasontickets.performances.Selection;F=seasontickets.performances.Event;B=seasontickets.performances.Performance;G=option.seasontickets.performances.Subject;L=seasontickets.performances.filters;C=$("#performancesListTpl").html();u=$("#performanceTpl").html();this.bindEvents();$.ajax({url:contextPath+"/option/seasonticket/detail/SeasonTicketCatalog.json?productId="+c+(a?"&devCookieHost="+a:""),dataType:"json"}).done(function(a){d=a;g();option.seasonTicket.dataInitializedCallBack()}).fail(k);
$.ajax({url:contextPath+"/option/seasonticket/detail/SeasonTicketConfiguration.json?productId="+c,dataType:"json"}).done(function(a){a&&a.status===h.ERR_INSUFFICIENT_AVAIL_EVENTS?h.cantBookErrorDialog():e=a;g();option.seasonTicket.dataInitializedCallBack()}).fail(k)},bindEvents:function(){var a=this;$("#performances").on("click","#showGroup",function(b){S();E=1;D={};a.updatePerformanceList();b.preventDefault()}).on("click","#showAll",function(b){S();E=0;a.updatePerformanceList();b.preventDefault()}).on("click",
".event_performance .button a",function(b){if(!$(this).parent().hasClass("disabled")){var c=$(b.target).parents(".event_performance");c=c.data("perfid");c=f[c];var d=c.event.subject.getFreeMatch(c);option.seasonTicket.selectPerformance(c,d.seasonTicketLineId);a.updatePerformanceList()}b.preventDefault()}).on("click","a.showPerformances",function(b){var c=String($(this).parents(".event").data("eventid"));D[c]=!D[c];a.updatePerformanceList();D[c]&&(c=$("tr[data-eventid="+c+"]").parents("table").position().top,
$("#performances_and_events").animate({scrollTop:c},300));b.preventDefault()}).on("click","a.seatmap",function(a){var b=$(this).parents(".event_performance").data("perfid");b=" ("+f[b].venue.name+")";viewer.seatView($(this).attr("href"),option.seasontickets.performances.messages.seatMapTitle+b);a.preventDefault()}).on("click",".pagination .page",function(b){var c=$(this);c.hasClass("current")||(c.hasClass("previous")?K.page--:c.hasClass("next")?K.page++:K.page=parseInt(c.text(),10),a.updatePerformanceList());
b.preventDefault()});seasontickets.performances.filters.bind(function(){K.page=1;a.updatePerformanceList()});$(".last .button.disabled").tipsy({live:!0,delayIn:1E3,offset:8,gravity:"se",title:function(){return option.seasontickets.performances.messages.thisPerformanceIsSelected}});tools.makeTooltipAccessible(".last .button.disabled")},loadEvents:function(c){var d=N(c.topicNames),u=c.topicSubTopics,v=c.firstTopicCodes,C;l=N(c.subTopicNames);g={};var t=null;for(t in c.venueNames)c.venueNames.hasOwnProperty(t)&&
(g[t]={id:String(t),name:c.venueNames[t],space:c.spaceNames[t],spaceCode:t.split("_")[1],site:c.siteNames[t],siteCode:t.split("_")[0],showSpace:c.spaceNames[t]!=c.siteNames[t]});h=N(c.subjectNames);r=c.seatCategoryNames;k=c.blockNames;m=c.areaNames;p=c.teamNames;q=c.teamLogos;a={};f={};b=[];e=[];for(t in u)if(u.hasOwnProperty(t)){var A=u[t];for(C=A.length;C--;)l[String(A[C])].topic=d[t]}$.each(c.events,function(){var c=new F(this,l,v);var d=c.id;b.push(c);a[d]=c});$.each(c.performances,function(){var b=
new B(this,a,g,r,k,m,!0,null,null,null,p,q);var c=b.id;e.push(b);f[c]=b})},loadConfiguration:function(c){var d=c.performanceAvailabilities,g=c.maxTicketPerPerformance||1,k=c.maxTicketPerEvent||1,l=c.subjects,m=1===l.length,p=0,u=this.messages.selection;!1===c.success&&(seasontickets.performances.errors.handleError(c.status)||seasontickets.performances.errors.ajaxErrorDialog());var q=c.subscribers;c.orderedSubcribers?y=c.orderedSubcribers:(y=[],$("#secondary_content_seasonticket .quantity_line").each(function(){var a=
$(this).data("audiencesubcategory"),b=q[a];y.push({id:a,quantity:b});p+=b}));1!==p&&(u.chosenPerformancesMultiple.replace("{0}",p),u.chosenPerformanceMultiple.replace("{0}",p));$.each(b,function(){this.available=k;this.noTopics=!m});$.each(e,function(){this.setAvailability(d[this.id],g)});t={};w=[];(z=c.maxOptional)||0===z||(z=null);x=c.minOptional||0;m&&(m=l[0],x&&(m.minOptional=x),z||0===z)&&(m.maxOptional=z);A=!0;$.each(l,function(){var b=new G(this,a,f,h,r);b.allFixed||(allFixed=!1);w.push(b);
t[b.code]=b;A=A&&b.allOptional});1===w.length&&(A=!1);A&&(v=null);$.each(b,function(){this.subject=t[this.subjectCode]})},updatePerformanceList:function(){var f=null,g=null;$(".last .button.disabled").tipsy("hide");$(".buy_unavailable.last span").tipsy("hide");null===E&&(E=c?0:1);var h={showAll:c?!1:!0,showAllSelected:0===E,showGroup:c?!1:!0,showGroupSelected:1===E,canBook:!0,multipleViews:!0,isOptionMode:!0};var k=null!==v?w[v]:null;if(c)f=c,h.eventName=f.name,g=[f],D={},D[f.id]=!0;else if(1===E)for(f in g=
[],a)a.hasOwnProperty(f)&&a[f].subject===d&&g.push(a[f]);c?$(b).each(function(){this.available=1}):$(b).each(function(){var a=this;$(this.subject.selections).each(function(){this.event==a&&(option.seasonTicket.isFirstChoiceDefined(this.seasonTicketLineId)?a.available=0:a.available=1)})});g?(h.multipleEvents=!c,h=$.extend(h,F.getViewFromList(g,k,L,K,D))):(h.allPerformances=!0,h.multipleEvents=!0,h=$.extend(h,B.getViewFromList($(e).filter(function(){return this.event.subject==d}),k,L,K)));1<w.length&&
(h.displaySubjects=!0);h.hasFilterSubjects=!1;h.hasFilters=h.hasFilterSubjects||h.hasFilterTopics||h.hasFilterEvents||h.hasFilterVenue||h.hasFilterDates?!0:!1;Q(C,h,"#performances");h=option.seasonTicket.getSelectedPerformances();this.disableSelectedPerformanceForOption(h);0===M?V():M--},resetFilterAndPagination:function(a){L.filterSubject="undefined"===typeof a?null:a;L.filterEvent=null;L.filterDay=null;L.filterMonth=null;L.filterSubtopic=null;L.filterVenue=null;K.page=1},showOnlyEvent:function(b){c=
a[b];this.resetFilterAndPagination();this.updatePerformanceList()},prefillSubject:function(a){c=null;var b=seasontickets.performances.filters.getId(a);$(w).each(function(){this.name==a&&(d=this)});this.resetFilterAndPagination(b);D={};this.updatePerformanceList()},showAllEvent:function(){c=null;this.resetFilterAndPagination();D={};this.updatePerformanceList()},disableSelectedPerformanceForOption:function(a){$(".event_performance").each(function(){var b=$(this).data("perfid");var c=$("tr[data-perfid="+
b+"]");0<=$.inArray(b,a)?(option.seasonTicket.isFirstChoice(b)?(c.addClass("selected"),c.find(".button").hide(),c.find("td.last .highlighted_text").show()):(c.removeClass("selected"),c.find(".button").show(),c.find("td.last .highlighted_text").hide()),c.find(".button").addClass("disabled")):c.find(".button").removeClass("disabled")})}}});
(function(){tools.makePath("option.seasontickets.performances.Selection");option.seasontickets.performances.Selection=function(a,b,c,d,f){c=a.eventId;this.areaBlockId=this.seatCategory=this.performance=this.event=null;this.seasonTicketLineId=a.seasonTicketLineId;this.fixed=!0===a.fixed;this.booked=!0===a.booked;this.optional=!0===a.optional;this.mandatory=!1!==a.mandatory;this.categoryOnly=!0===a.categoryOnly;this.hasSelection=!this.fixed&&!this.booked||this.categoryOnly;this.selected=this.failed=
this.onGoingBooking=!1;this.price=null;this.subject=f;this.block={name:null,seatCategory:{name:null}};this.index=a.index;c&&(this.event=b[c]);this.modifyPerformance=this.oldSelection=null}})();
tools.makePath("option.seasontickets.performances.Subject");
option.seasontickets.performances.Subject=function(a,b,c,d,f,e){var g=option.seasontickets.performances.Selection,h=[],l=0,k=0,m=this;this.code=a.subjectCode;this.minOptional=a.minOptional||0;this.maxOptional=a.maxOptional;this.selectedIndex=0;this.name=this.code?d[this.code].name:"";this.allFixed=!0;this.cannotBookMessages={};this.undefinedSelections=0;this.canHaveOptional=!0;this.code||(this.code=option.seasontickets.performances.Subject.NO_SUBJECT_CODE);jQuery.each(a.configuration,function(){var a=
new g(this,b,c,f,m,e);a.index=h.length;h.push(a);a.optional?(l++,l>m.minOptional&&(a.mandatory=!1)):k++;a.fixed||(this.allFixed=!1)});this.selections=h;if(0!==this.maxOptional)for(a=this.minOptional?this.minOptional:1;a>l;)if(d=this.minOptional>l,this.addOptionalSelection(d),d)l++;else break;this.included=k;this.optional=l;this.allOptional=0===k};
option.seasontickets.performances.Subject.prototype.getFreeMatch=function(a,b){var c=this.selections.length;if(0===this.undefinedSelections)return null;for(b=0;b<c;b++){var d=this.selections[b];if(!d.seatCategory&&!d.onGoingBooking&&(d.optional&&(d.mandatory||this.canHaveOptional)||d.event&&d.event===a.event))return d}return null};
option.seasontickets.performances.Subject.prototype.addOptionalSelection=function(a){this.undefinedSelections++;this.selections.push(new option.seasontickets.performances.Selection({optional:!0,index:this.selections.length,mandatory:a},null,null,null,this))};option.seasontickets.performances.Subject.prototype.checkCanAdd=function(a){return!0};option.seasontickets.performances.Subject.prototype.sync=function(){};option.seasontickets.performances.Subject.prototype.getMaxAllowedTickets=function(){return null};
option.seasontickets.performances.Subject.NO_SUBJECT_CODE="__NO_SUBJECT__";
tools.module("option.service",function(){var a=function(){return option.general.isAtLeastOneQuantitySelected("itemQuantityInput")?option.general.isMinGaugeRespected("itemQuantityInput")?option.general.isMaxLengthRequestRemarkRespected("remark"):(option.general.showNotification("notification-respect_min_gauge"),option.general.validateQuantity("itemQuantityInput"),!1):(option.general.showNotification("notification-select_items"),!1)};return{init:function(a){option.general.setConfig(a);jQuery(function(){tools.registerAsIntegerInput("itemQuantityInput")})},
checkSubmit:function(){option.general.doSubmitOption(a)}}});
tools.module("option.visit",function(){var a={},b=!1,c=function(a,b){b=a.parseDate(b);a.updateCalendarConfiguration(b.getFullYear(),b.getMonth()+1,!1)},d=function(b,d,e,f){var g=a[b];"undefined"===typeof g&&(tools.dialog.showWaitingPopup("loadingDialog",!0),$.ajax({type:"GET",async:!1,url:contextPath+"/ajax/option/event/calendar",data:{productId:b,packageId:f,packageLineId:e,month:"",year:""},success:function(c){var d="/ajax/option/event/calendar";e&&f&&(d+="?packageLineId="+e+"&packageId="+f);g=
new tools.date.DatePicker(c,!0,!1,d);g.productId=b;c.length&&g.setMaxDate(c[c.length-1].performanceDate);a[b]=g;tools.dialog.hideDialog("loadingDialog")},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}}));d&&c(g,d);return g},f=function(a,b){return $("#"+a.substr(0,a.length-1)+(parseInt(a.substr(-1),10)+b))},e=function(a,b,c,e,f,g){a=d(a,null,f,g).getPerformanceForDate(c);f=$("#time_select-"+b);$("#date_picker_input-"+b).val(c);f.find("option").slice(1).remove();
for(b=0;b<a.length;b++)f.append('<option value="'+a[b].performanceId+'">'+a[b].performanceTime+"</option>"),e!==a[b].performanceId&&0!==b||f.val(a[b].performanceId).trigger("change")},g=function(){return option.general.isMainPerformanceSelected()?option.general.isAtLeastOneQuantitySelected("seatCategoryQuantityInput")?option.general.isMinGaugeRespected("seatCategoryQuantityInput")?option.general.isMaxGaugeRespected("seatCategoryQuantityInput")?option.general.isMaxLengthRequestRemarkRespected("remark"):
!1:(option.general.showNotification("notification-visit-respect_min_gauge_per_seatcat"),option.general.validateQuantity("seatCategoryQuantityInput"),!1):(option.general.showNotification("notification-select_tickets"),!1):(option.general.showNotification("notification-visit-select_performance"),!1)};return{init:function(a){option.general.setConfig(a);b=a.isPerfDataLoaded;$(function(){tools.registerAsIntegerInput("seatCategoryQuantityInput")})},refreshPerformanceData:function(a){b||(b=!0,option.general.refreshPerformanceData())},
checkSubmit:function(){option.general.doSubmitOption(g)},selectChanged:function(a){if(!$("#time_select-"+a).val()){var b=$("#date_picker_input-"+a),c=$("#time_select-"+a),d;for(d=1;b.length&&c.length;d++)b.val(""),c.val("").find("option").slice(1).remove(),b=f("date_picker_input-"+a,d),c=f("time_select-"+a,d)}},setPerformance:function(a,b,c,f,g,q){f=d(a,f,g,q).getPerformanceForDate(f);var h;for(h=0;h<f.length;h++)if(f[h].performanceId===c){$("#date_picker_input-"+b).val(f[h].performanceDate);e(a,
b,f[h].performanceDate,f[h].performanceId,g,q);break}},showDatePickerPopup:function(a,b,c,g,p){var h=f("time_select-"+c,-1),k;if(!h.length||h.val()){h=d(a,null,g,p);tools.dialog.showDialog(b,!0,!1,!1,"date_picker_popup");h.selectedDateText=$("#date_picker_input-"+c).val();if(k=!h.selectedDateText)h.selectedDateText=null;h.showDatePicker("#"+b,function(d){e(a,c,d,null,g,p);tools.dialog.hideDialog(b)});k&&(h.selectedDateText=null)}}}});
tools.module("orderContactSelection",{DIST_SEARCH_MIN_LENGTH:3,saveButtonSelector:"",contactSelectionType:"",searchContactAjax:function(a,b){var c=null;switch(this.contactSelectionType){case "BUYER":c="/pro/ajax/contactSearch/buyerContact";break;case "INVOICING":c="/pro/ajax/contactSearch/billingContact";break;case "SHIPPING":c="/pro/ajax/contactSearch/shippingContact"}tools.dialog.showWaitingPopup("loadingDialog",!0);$.ajax({type:"GET",url:contextPath+c,data:{searchText:a,from:b},success:function(a){tools.dialog.hideDialog("loadingDialog");
$("#contact_lookup_result").append(a)},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}})},reset:function(){this.enableSearch(!1);this.enableContactIdLookup(!1);$("#contact_lookup_text").val("");$("#contact_lookup_result").empty();$("#reset_lookup").hide();$("#contact_create").hide();$("#contact_link").hide();"INVOICING"==this.contactSelectionType&&$(".contact_structure_selection").removeClass("hidden")},checkContactName:function(a,b){a&&b&&
(a.firstName.toUpperCase()!==b.firstName.toUpperCase()||a.lastName.toUpperCase()!==b.lastName.toUpperCase())&&tools.dialog.showDialog("warning_contact_existed",!0)},selectContact:function(a,b){var c=$("#contact_selection");orderContactSelection.checkContactName(a,b);$("#selected_contact").val(a.contactNumber);$("#selected_first_name").val(a.firstName);$("#selected_last_name").val(a.lastName);$("#selected_email").val(a.email);$("#selected_phoneNumbers").val(a.phoneNumbers);$("#selected_structureName").val(a.structureName);
"SHIPPING"===this.contactSelectionType?$("#shipping_contact_form").submit():(c.find(".contact_first_name").html(a.firstName),c.find(".contact_last_name").html(a.lastName),b=a.phoneNumbers&&0<a.phoneNumbers.length?a.email+", ":a.email,c.find(".contact_email").html(b),c.find(".contact_phone_numbers").html(a.phoneNumbers),c.find(".contact_structure").html(a.structureName),""===a.structureName?c.find(".contact_structure").hide():c.find(".contact_structure").show(),$("#contact_search").hide(),$("#contact_create").hide(),
$("#info_message_contact").hide(),c.show(),null!==orderContactSelection.saveButtonSelector&&$(orderContactSelection.saveButtonSelector).parent().removeClass("disabled"),$("#btn_continue").parent().removeClass("disabled"),orderContactSelection.reset())},enableSearch:function(a){var b=$("#lookup_members");!b.hasClass("disabled")!=a&&(a?(b.removeClass("disabled"),b.parent().removeClass("disabled"),b.on("click",function(){orderContactSelection.search()})):(b.addClass("disabled"),b.parent().addClass("disabled"),
b.off("click")))},enableContactIdLookup:function(a){var b=$("#submit_contactId");!b.parent().hasClass("disabled")!=a&&(a?(b.parent().removeClass("disabled"),b.on("click",function(){orderContactSelection.submitContactId()})):(b.parent().addClass("disabled"),b.off("click")))},init:function(a,b){null!==a&&(this.saveButtonSelector=a);this.contactSelectionType=b;$("#contact_lookup_text").on({keyup:function(){orderContactSelection.enableSearch(validation.validateField($(this),[{rule:validation.rules.email}],
null,!1,!1))},keypress:function(a){13===a.keyCode&&$("#lookup_members").click()}});$("#contact_id_text").on({keyup:function(){orderContactSelection.enableContactIdLookup(1<=$(this).val().length)},keypress:function(a){13===a.keyCode&&$("#submit_contactId").click()}});this.reset()},search:function(a){var b=$("#contact_lookup_text").val();a||$("#contact_lookup_result").empty();$("#show_more").detach();this.searchContactAjax(b,a)},afterSearch:function(a){0<$(".contact_result_item").length?($("#contact_create").hide(),
$("#reset_lookup").hide(),$("#contact_link").hide()):a?($("#contact_create").hide(),$("#contact_link").show()):($("#contact_create").show(),$("#contact_link").hide())},submitContactId:function(){var a=null;switch(this.contactSelectionType){case "BUYER":a="/pro/ajax/contactSearch/buyerContactWithNumber";break;case "INVOICING":a="/pro/ajax/contactSearch/billingContactWithNumber";break;case "SHIPPING":a="/pro/ajax/contactSearch/shippingContactWithNumber"}tools.dialog.showWaitingPopup("loadingDialog",
!0);$.ajax({type:"GET",url:contextPath+a,data:{searchText:$("#contact_lookup_text").val(),contactNumber:$("#contact_id_text").val()},success:function(a){tools.dialog.hideDialog("loadingDialog");$("#contact_lookup_message_container").html(a)},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}})},selectContactFromList:function(a){this.selectContact({contactNumber:a,firstName:$.trim($("#result_first_name_"+a).text()),lastName:$.trim($("#result_last_name_"+
a).text()),email:$.trim($("#result_email_"+a).text()),phoneNumbers:$.trim($("#result_phone_numbers_"+a).text()),structureName:$.trim($("#result_structure_"+a).text())})},cancelContact:function(){null!==this.saveButtonSelector&&$(this.saveButtonSelector).parent().addClass("disabled");$("#btn_continue").parent().addClass("disabled");$("#contact_search").show();$("#contact_create").hide();$("#contact_link").hide();$("#contact_selection").hide();$("#selected_contact").val("");$("#contact_id_text").val("");
$("#info_message_contact").show()},return2ContactSearch:function(){jQuery("#search_type_contact_radio").prop("checked",!0);$("#info_message_contact").show();$("#contact_link").hide()},showEditContactForm:function(){contact.editContactCommon.showEditContactForm({email:$("#contact_lookup_text").val()})},validateContact:function(a){var b=$("#selected_contact").val();b||validation.showErrorTooltip($(a),$("#contact-selection-msg .content").html());return b}});
tools.module("orderSummary",function(){var a=!1,b=!1,c=!1,d=!1,f=!1,e=!1,g=!1,h=!1,l=!1,k=!1,m=!1,p=!1,q=!1,r=!0,t=!1,w=null,y=null,z=0,x,A=[],C=null,u=null,v=null,D=!1,E=!1,F=!1,B=!1,G=!1,L=!1,K=!1,H=[],M=!1,Q=!1,S=!0,V=!1,N=!1,I=!1,O=null,R=function(){var a=$("input[name=paymentMethodId]:checked").val();var b=$('input[type="radio"][name="paymentMethodId"]').length;f=$("#unauthorizedOverPaymentNotification").is(":visible");q=$("#warning_prepayment_satisfied").is(":visible");e=$("#notification_split_payment").is(":visible")||
$("#notification_split_payment_finish").is(":visible")||$("#warning_voucher_split_payment").is(":visible")||$("#warning_credit_note_split_payment").is(":visible")||$("#warning_manual_validation_split_payment").is(":visible");g=$("#wa_not_enough").is(":visible");x=!b||!$('input[type="radio"][class*="other_pm_type_PREPAYMENT"]').is(":visible")&&1===b||a;h=$("#conditionsAccepted").is(":checked")||E;l=$(".payment_method_item.enable_contact_mandate").children("input").is(":checked");k=$("#acceptDDebitFromOrgId").is(":checked");
m=l?k?!0:!1:!0;p=!$("#visibility_checkbox").length||$("#visibility_checkbox").is(":checked");waitingAccount&&a&&(b=waitingAccount.isPaymentMethodEnabledMap,r=0===Object.keys(b).length||void 0===b[a]||b[a]);Q=ra();t=G||!f&&!e&&!g&&h&&m&&p&&x&&r&&!q&&!validatedMinBallotTickets&&Q},X=function(a,b){var c;$("#"+a).closest("tbody").find(".beneficiary").each(function(){var a=$(this).find('input[type="checkbox"]');a.is(":checked")&&(c=a.attr("id"))});return c},T=function(){return parseInt($("#cancellation_insurance_amount").val(),
10)},Z=function(a,b){var c=T();a&&"false"!==a||(c=-c);tools.dialog.showWaitingPopup("loadingDialog",!0);$.ajax({url:contextPath+"/ajax/checkout/applyCancellationInsurance",type:"POST",data:{insuranceAmount:c},cache:!1,success:function(a){$("#dueAmount_amount").html(functions.generateAmount(a.orderAmount));tools.dialog.hideDialog("loadingDialog");a&&a.vouchersList&&(a.promotionalCode&&a.vouchersList.push(a.promotionalCode),a.freeShipmentPromotionalCode&&a.vouchersList.push(a.freeShipmentPromotionalCode),
voucher.updateVoucherAmount(a.vouchersList));$.when(creditNote.updateCreditNoteAmount(),orderSummary.updateTotalAmount()).done(function(){b&&b()})},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}})},ba=function(a,b){tools.dialog.showWaitingPopup("loadingDialog",!0);$.ajax({url:contextPath+"/ajax/checkout/setGiftAidContactCriteria",type:"POST",data:{giftAidCriteriaValue:a},cache:!1,async:!1,success:function(){b&&b()},error:function(){tools.dialog.hideDialog("loadingDialog");
tools.dialog.showDialog("ajaxErrorDialog",!0)}})},U=function(){if(C){var a=S?$("#accept_cancins").is(":checked"):$("#accept_cancellation_insurance").is(":checked");var b=localStorage.getItem("skipCanInsPopup");if(!a&&!V&&!0===C.suggestByPopup&&"true"!==b&&0!==T())return window.scrollTo(0,0),tools.dialog.showDialog("subscribe_cansins_popup",!0,!1),!0}return!1},P=function(){if(u){var a=$("#accept_gift_aid").is(":checked");if(!a&&!0===u.suggestByPopup)return window.scrollTo(0,0),tools.dialog.showDialog("subscribe_giftAid_popup",
!0,!1),!0}return!1},Y=function(){var a=0<$("#contactRemark").length?$("#contactRemark").val().length:0;a=z-a;$("#remark_input_length_info").text(y.wordCountInfo.replace("{0}",a).replace("{1}",z))},da=function(a){a&&0!==a.length&&(a=$.escapeSelector($(a).data("payment-method-code")),$("#main_content_payment_method_description").hide(150),$(".payment_method_description_item").hide(),0<$("#payment_method_description_"+a).length&&($("#payment_method_description_"+a).show(),$("#main_content_payment_method_description").show(150)))},
aa=function(a){B&&a&&0!==a.length&&(a=$(a).data("payment-type"),0<tools.getAmount("#final_amount")&&("CB"===a||"CB_WITH_VALIDATION"===a)?$("#anti_fraud_form").slideDown("slow"):$("#anti_fraud_form").slideUp("slow"))},W=function(a){return 0<$(".mandatory",$(a)).length},J=function(){var a=[],b,c,d,e=!0;if(G)return!0;if(0<$("#auti_fraud_configuration_error").length&&$("#auti_fraud_configuration_error").is(":visible"))return!1;if(0===$("#anti_fraud_form").length||!$("#anti_fraud_form").is(":visible"))return!0;
$(".message","#anti_fraud_form").hide();$(".field","#anti_fraud_form").each(function(e,f){$(f).removeClass("error");"field_ADDRESS"===$(f).attr("id")?b=$(f):"field_BIRTHDAY"===$(f).attr("id")?c=$(f):"field_TELEPHONE"===$(f).attr("id")?d=$(f):W(f)&&$(f).find('input[type="text"], input[type="email"], input[type="number"], select').each(function(b,c){a.push($(c).attr("id"))})});account.register.checkFields(a)||($("#anti_fraud_notification_mandatory").show(),e=!1);b&&W(b)&&!account.register.checkOneMandatoryFields(["input_ADDRESS_line1",
"input_ADDRESS_line2","input_ADDRESS_line3"])&&($("#anti_fraud_notification_mandatory").show(),e=!1);d&&W(d)&&!account.register.checkFields(["anti_phone_number","anti_phone_prefix"])&&($("#anti_fraud_notification_mandatory").show(),e=!1);if(c){var f=$("#birthdate_day").val();var g=$("#birthdate_month").val();var h=$("#birthdate_year").val();!W(c)||"0"!==f&&"0"!==g&&"0"!==h||(c.addClass("error"),$("#anti_fraud_notification_mandatory").show(),e=!1);"0"!==f&&"0"!==g&&"0"!==h&&(new Date(h,g-1,f)>new Date?
e&&(c.addClass("error"),$("#anti_fraud_notification_invalid_birthdate").show(),e=!1):$("#input_BIRTHDAY").val(h+"-"+tools.padStart(g,"0",2)+"-"+tools.padStart(f,"0",2)))}e&&!account.register.validateField(account.register.validationRules.email,"input_EMAIL")&&($("#anti_fraud_notification_invalid_email").show(),e=!1);e&&tools.removeSelectWrapper();return e},la=function(){if(!$(".payment_method_item").find("input:checked").parent().hasClass("enable_contact_mandate"))return!0;if(!$("#useExistingBankAccount").is(":checked")){var a=
account.bankAccount&&!account.bankAccount.ibanNumberValidator(!0)?!1:!0;if(!a)return!1;a=account.bankAccount&&!account.bankAccount.bicNumberValidator(!0)?!1:!0;if(!a)return!1}return!0},ja=function(){if(C&&!I){if(C.answerMandatory&&!C.disabled)return!!$('input:radio[name="acceptCancellationInsurance"]:checked').val()}else if(C&&I&&C.answerMandatory&&!C.disabled&&0!==T()&&!N)return!1;return!0},ea=function(a){var b=$("#cancellation_insurance_container");if(b.length){var c=b.find("#error_missing_cancellation_insurance"),
d=b.find(".cancellation_insurance_options");a?(c.addClass("visible").removeClass("hidden"),d.addClass("error"),b.parent()[0].scrollIntoView({behavior:"smooth"})):(c.addClass("hidden").removeClass("visible"),d.removeClass("error"))}},ha=function(b,c){var e,f,g,h={},k,l,m=!1;var p=0<$("#billingAddressRequired").length&&!$("[name=billingAddressId]").val();b&&b.preventDefault();$("#error_same_beneficiary").hide();if(la()){if(!$("#buyNow").parent().hasClass("disabled")&&!$("#buyNowNoDue").parent().hasClass("disabled")){$("#notification_terms_and_conditions").hide();
$("#reduced_visibility_terms_and_conditions_notification").hide();if(p){$("#billing_address_required").show();window.scrollTo(0,0);return}if(d){$("#error_audsubcat_not_satisfied").show();window.scrollTo(0,0);return}if(!J()){0<$("#anti_fraud_form").length&&$("#anti_fraud_form")[0].scrollIntoView({behavior:"smooth",block:"end",inline:"nearest"});return}if(!ja()){ea(!0);return}if(!($("#conditionsAccepted").is(":checked")||E||D||F)){$("#notification_terms_and_conditions").show();window.scrollTo(0,0);
return}if(a&&!$("#visibility_checkbox").is(":checked")){$("#reduced_visibility_terms_and_conditions_notification").show();return}if(window.voucher&&!voucher.canSubmit())return;var u=$("input[name^='beneficiaries']:not([type='hidden'])","#order_validation_form");if(u.length){var r=[];u.each(function(){var a=$(this),b=a.parent();var c=b.parent();var d=a.attr("name"),e=a.val();b.removeClass("error");f=c.attr("class");g=$(this).closest(".product_container").children().first().hasClass("product_PACKAGE")?
$(this).closest(".product_container").children().first().attr("id"):"";21<f.length&&(f=f.substring(f.indexOf("product_")+8,f.length));f+="_"+g;-1!==d.indexOf("email")&&1<=e.length&&0<f.length?(k=[],h[f]?(k=h[f].slice(0),h[f].push(e)):h[f]=[e],r.push({fieldId:a,rules:{maxLength:validation.rules.email.maxLength,regExp:validation.rules.email.regExp,tooltipError:validationErrors.email,blackList:c.find('input[type="checkbox"]').is(":checked")&&c.find('input[type="checkbox"]').is(":visible")?k.slice(0):
[]}})):-1===d.indexOf("createLogin")&&a.hasClass("mandatory_beneficiary")?(a.val($.trim(e)),r.push({fieldId:$(this),rules:validation.mandatoryRule()})):(a=c.find('input[name$="firstName"]'),c=c.find('input[name$="lastName"]'),(-1!==d.indexOf("firstName")&&c.val()||-1!==d.indexOf("lastName")&&a.val())&&r.push({fieldId:$(this),rules:{minLength:1,tooltipError:validationErrors.fullName}}))});if(!validation.validateFields(r,!0,!0)){window.scrollTo(0,0);return}$("td.error","#order_validation_form").removeClass(".error")}u=
{};var q=!1;$("td[class*=product_]","#order_validation_form").each(function(a,b){f=$(b).attr("class");g=$(b).closest(".product_container").children().first().hasClass("product_PACKAGE")?$(b).closest(".product_container").children().first().attr("id"):"";21<f.length&&(f=f.substring(f.indexOf("product_")+8,f.length));f+="_"+g;a=$(b).find('input[name$="firstName"]');var c=$(b).find('input[name$="lastName"]');var d=$(b).find('input[name$="email"]');var h=$(b).find('input[name$="createLogin"]');h=$(h).is(":checked")&&
$(h).is(":visible");b=$(b).find('select[name$="contactNumber"]');$(a).removeClass("error");$(c).removeClass("error");$(d).removeClass("error");if((e=u[f])&&void 0===$(b).val())for(l=0;l<e.length;l++)void 0!==e[l].contactNumber&&(e[l].firstName&&e[l].firstName===$(a).val()&&e[l].lastName&&e[l].lastName===$(c).val()?!1===h?(q=!0,$(a).addClass("error"),$(c).addClass("error"),""!==$(d).val()&&$(d).addClass("error")):!1===e[l].isCreateLogin&&w!==e[l].email&&(q=!0,e[l].firstNameInput.addClass("error"),
e[l].lastNameInput.addClass("error")):e[l].email&&e[l].email===$(d).val()&&e[l].email===w&&(q=!0,$(d).addClass("error")));else e||(e=[]);e.push({contactNumber:$(b).val(),firstName:$(a).val(),lastName:$(c).val(),email:$(d).val(),isCreateLogin:h,contactNumberInput:$(b),firstNameInput:$(a),lastNameInput:$(c),emailInput:$(d)});u[f]=e});if(q){$("#error_same_beneficiary").show();window.scrollTo(0,0);return}b=localStorage.getItem("skipGiftAidCheck");p=localStorage.getItem("skipGiftAidCheckWithOrderId");
var v=localStorage.getItem("orderId");if(!c&&U()||"true"!==b&&p!==v&&P())return;localStorage.removeItem("skipGiftAidCheck");localStorage.removeItem("skipCanInsPopup");$("#accept_gift_aid").is(":checked")&&!$("#accept_gift_aid").is(":disabled")&&ba("true");$('select[name$=".contactNumber"]',"#order_validation_form").each(function(a,b){""===$(b).val()&&H[a]&&(m=!0,$(b).closest(".beneficiary_input").addClass("error"))});culturalContacts&&"function"===typeof culturalContacts.checkCulturalContacts&&!1===
culturalContacts.checkCulturalContacts()&&(m=!0);if(m){$("#error_missing_beneficiary").show();window.scrollTo(0,0);return}if(!ra())return;$('input[type="radio"]:checked').prop("disabled",!1);tools.form.submitWithProcessing($("#order_validation_form"));tools.countdown.stopCountdown()}"undefined"!==typeof FB&&0<$("#fb-messenger-checkbox-connect").length&&$("#fb-messenger-checkbox-connect")[0]&&FB.AppEvents.logEvent("MessengerCheckboxUserConfirmation",null,{app_id:$("#fb-messenger-checkbox-connect")[0].getAttribute("messenger_app_id"),
page_id:$("#fb-messenger-checkbox-connect")[0].getAttribute("page_id"),ref:$("#fb-messenger-checkbox-connect")[0].getAttribute("ref"),user_ref:$("#fb-messenger-checkbox-connect")[0].getAttribute("user_ref")})}else 0<$("#contact_mandate_data").length&&$("#contact_mandate_data")[0].scrollIntoView({behavior:"smooth",block:"end",inline:"nearest"})},ca=function(){R();t&&tools.dialog.showDialog("termsAndConditionsDialog",!0,!1,qa,"terms_and_conditions_dialog");return!1},ma=function(a,b){$("#termsAndConditionsDialogAccept").parent().hasClass("disabled")||
(D=!0,$("#termsAndConditionsDialogLabelRefused").hide(),$("#termsAndConditionsDialogLabelRefused").removeClass("termsAndConditionsDialogLabels"),tools.dialog.hideDialog("termsAndConditionsDialog"),ha(a,b));return!1},oa=function(){$("#termsAndConditionsDialogRefuse").parent().hasClass("disabled")||($("#termsAndConditionsDialogLabelRefused").show(),$("#termsAndConditionsDialogLabelRefused").addClass("termsAndConditionsDialogLabels"),tools.dialog.hideDialog("termsAndConditionsDialog"));return!1},na=
function(){$("#termsAndConditionsDialogAcceptButton").toggleClass("disabled",!1);$("#termsAndConditionsDialogRefuseButton").toggleClass("disabled",!1)},pa=function(){var a,b;v&&((a=document.getElementById("termsAndConditionsDialogIframe"))||a.contentWindow||a.contentWindow.document)&&(a.contentWindow.document.open("text/html","replace"),a.contentWindow.document.onreadystatechange=function(){"interactive"===a.contentWindow.document.readyState&&a.contentWindow.document.write(v)},a.contentWindow.document.close(),
setTimeout(function(){(b=$(a.contentWindow.document).innerHeight())&&b<$(a).height()+1?na():$(a.contentWindow).scroll(function(){$(a.contentWindow).scrollTop()+$(a).height()+1>=$(a.contentWindow.document).innerHeight()&&na()})},1E3))},qa=function(){D||$("#termsAndConditionsDialogRefuse").parent().hasClass("disabled")||F||oa()},ra=function(){return M?I?V:S?$("#accept_cancins").is(":checked"):$("#accept_cancellation_insurance").is(":checked"):!0},ia=function(){var a=tools.getAmount("#final_amount"),
b=tools.getAmount("#payment_overhead_fee .amount");orderSummary.updatePaymentMethodForm(a,b)};return{init:function(k){a=k.containsReducedVisibleSeats;b=k.isAndroidTabletOrMobile;c=k.noPaymentMethodAvailable;d=k.ascDependencyNotSatisfied;C=k.cancellationInsuranceData;u=k.giftAidData;w=k.loginEmail;y=k.message;z=k.remarkLength;A=k.emailsByBillingContactNumbers||[];E=k.showTermsAndConditionsDialog;v=k.termsAndConditionsDialogContent;F=k.repaymentRequired;L=k.hidePrepaymentMethod;K=k.disablePrepaymentMethod;
B=k.cbPaymentHolderRequired;G=k.orderSummaryLocked;var l=k.orderId;var q=k.isShowGiftAid;validatedMinBallotTickets=k.validatedMinBallotTickets;M=k.hasCancellationInsuranceOnly;S=k.isUsingRadioButtonsForCancellationInsurance;I=k.isInsuranceWidgetActive;O=k.insuranceWidgetEvent;R();$("#payment_overhead_fee").hide();localStorage.removeItem("skipGiftAidCheck");localStorage.removeItem("skipCanInsPopup");localStorage.removeItem("skipGiftAidCheckWithOrderId");q||localStorage.setItem("skipGiftAidCheck","true");
localStorage.setItem("orderId",l);localStorage.removeItem("skipGiftAidCheck");localStorage.removeItem("skipCanInsPopup");localStorage.removeItem("skipGiftAidCheckWithOrderId");q||localStorage.setItem("skipGiftAidCheck","true");localStorage.setItem("orderId",l);l=function(){return t?"":validatedMinBallotTickets?k.message.notEnoughBallotTickets:f?k.message.overPayment:e?k.message.splitPayment:g?k.message.waitingAccount:p?h?m?r?"":k.message.selectedWAPaymentNotEnabled:k.message.acceptDirectDebit:k.message.acceptConditions:
k.message.visibility};$("#buyNow").on("click",ha).tipsy({className:"tipsy-hover",delayIn:200,gravity:"ne",title:l});tools.makeTooltipAccessible("#buyNow");$("#visibility_checkbox, #conditionsAccepted, #acceptDDebitFromOrgId").on("click",this.changeProceedButtonState);$("#error_same_contact").is(":visible")&&$(".beneficiary_input").addClass("error");$(".beneficiary_input input").on("change",function(){$(this).parent().removeClass("error")});if(I&&null!==O)document.addEventListener(O,function(a){a.detail&&
(N=!0,V=a.detail.sold,Z(V))});else if(S){if(q=$('input[name="acceptCancellationInsurance"]'))q.on("change",function(){Z(this.value)})}else if(q=$("#accept_cancellation_insurance"),null!==q)q.on("click",function(){Z(this.checked)});ia();q=$("#accept_gift_aid");if(null!==q)q.on("click",function(){orderSummary.changeProceedButtonState()});null!==k.cancellationInsuranceData&&($("#cancel_subscribe_cansins").unbind("click").on("click",function(){tools.dialog.hideDialog("subscribe_cansins_popup");localStorage.setItem("skipCanInsPopup",
"true");ha(null,!0);return!1}),$("#subscribe_cansins").unbind("click").on("click",function(){tools.dialog.hideDialog("subscribe_cansins_popup");localStorage.setItem("skipCanInsPopup","true");Z(!0,function(){S?$("#accept_cancins").prop("checked",!0):$("#accept_cancellation_insurance").prop("checked",!0);ha(null,!0)});return!1}),$('input:radio[name="acceptCancellationInsurance"]').change(function(){ea(!1)}));null!==k.giftAidData&&($("#cancel_subscribe_giftAid").unbind("click").on("click",function(){tools.dialog.hideDialog("subscribe_giftAid_popup");
localStorage.setItem("skipGiftAidCheck","true");localStorage.setItem("skipGiftAidCheckWithOrderId",k.orderId);ha(null,!0);return!1}),$("#subscribe_giftAid").unbind("click").on("click",function(){tools.dialog.hideDialog("subscribe_giftAid_popup");localStorage.setItem("skipGiftAidCheck","true");localStorage.setItem("skipGiftAidCheckWithOrderId",k.orderId);$("#accept_gift_aid").prop("checked",!0);ha(null,!0);return!1}));$("#contactRemark").on("keyup",function(){Y()});Y();$('input[type="radio"][name="paymentMethodId"]').change(function(){da($(this));
aa($(this))});da($('input[type="radio"][name="paymentMethodId"]:checked'));aa($('input[type="radio"][name="paymentMethodId"]:checked'));$("#termsAndConditionsDialogIframe").css("height",.4*$(window).height());$("#termsAndConditionsDialogReviewButton").on("click",ca);$("#termsAndConditionsDialogLabelAlreadyAccepted").on("click",ca);$("#termsAndConditionsDialogAccept").on("click",ma).tipsy({className:"tipsy-hover",delayIn:200,gravity:"ne",title:l});tools.makeTooltipAccessible("#termsAndConditionsDialogAccept");
$("#termsAndConditionsDialogRefuse").on("click",oa);$("#termsAndConditionsDialogIframe").on("load",pa);0!==$(".payment_method_item").find("input").filter(":checked").parent().filter(".enable_contact_mandate").length?orderSummary.showContactMandateForm():orderSummary.hideContactMandateForm()},updateConfirmationEmails:function(){var a=$("#billingContactNumber").val(),b;if(0!==$("#main_content_email_confirmation").length)if(a=A[a],$("#main_content_email_confirmation").html(""),a&&0<a.length){var c=$("#main_content_email_confirmation").attr("data-emailConfirmationLabel");
if(1===a.length)$("#main_content_email_confirmation").append("<span>"+c+"</span> <strong>"+a[0]+"</strong>"),$("#main_content_email_confirmation").append('<input type="hidden" value="'+a[0]+'" name="emailConfirmation" />');else{$("#main_content_email_confirmation").append('<span class="label">'+c+"</span>");c=$('<select name="emailConfirmation" id="emailConfirmation" />');for(b=0;b<a.length;b++)0===b?c.append('<option value="'+a[b]+'" selected>'+a[b]+"</option>"):c.append('<option value="'+a[b]+'">'+
a[b]+"</option>");$("#main_content_email_confirmation").append(c)}$("#main_content_email_confirmation").show()}else $("#main_content_email_confirmation").append('<input type="hidden" value="" name="emailConfirmation" />'),$("#main_content_email_confirmation").hide()},changeProceedButtonState:function(){c||(R(),$("#buyNowButton").toggleClass("disabled",!t),b&&($("#buyNowButton").hide(),$("#buyNowButton").show()))},showWarningMessageForPrepayment:function(){$("#notification_split_payment, #notification_split_payment_finish").hide();
$("#warning_prepayment_satisfied").show()},changeProceedPrepaymentState:function(a){var b=tools.getAmount("#final_amount"),d=$("input[type=radio][name=paymentMethodId]"),e=d.length,f=null;(!c||L||K)&&d.each(function(){$(this).hasClass("other_pm_type_PREPAYMENT")&&($(this).is(":checked")&&!a&&0!==b?($(this).attr("disabled",!0),orderSummary.showWarningMessageForPrepayment()):0===b?($(this).prop("checked",!1),1===e?$("#main_content_summary_payment_methods").hide():$(this).is(":visible")&&($(this).parent().hide(),
f=$(this).parent().parent(),f.find($(d)).each(function(){if($(this).is(":visible"))return $(this).prop("checked",!0),$("#warning_prepayment_satisfied").hide(),!1}))):($("#warning_prepayment_satisfied").hide(),$(this).prop("disabled",!1),$("#main_content_summary_payment_methods").show(),$(this).parent().show()))})},updateTotalAmount:function(a){var b=$('input[name="paymentMethodId"][type="radio"]:checked, input[name="paymentMethodId"][type="hidden"]');if(!(0>=b.length))return $.ajax({url:contextPath+
"/ajax/checkout/getUpdateTotalAmount",type:"POST",data:{paymentMethodId:$(b).val(),repaymentRequired:a?!0:!1},cache:!1,success:function(a){tools.dialog.hideDialog("loadingDialog");if(a){var c=a.paymentFeeAmount;$("#final_amount").html(functions.generateAmount(a.dueAmount));$("#main_content_summary_overheads.main_content_summary > .subtotal > .amount").html(functions.generateAmount(c));$("#main_content_summary_overheads.main_content_summary > .subtotal > .charges_text").text(y.paymentFeeAmountWithName.replace("{0}",
$(b).data("payment-method-name")));var d=$('select[name="localCurrencyAmount"]');d.length&&null!=a.localCurrencyAmounts&&a.localCurrencyAmounts.forEach(function(a){var b=a.currencyCode;a=functions.getIntPartFromAmount(a.amount.toString());var c=d.find('option[value="'+b+'"]');c.length&&c.text(a+" "+b)});orderSummary.updatePaymentAntifraudForm();waitingAccount.updatePaymentMessagesAndOptions(a.splitPayment);orderSummary.changeProceedPrepaymentState(!orderSummary.isDisablePrepaymentButton());orderSummary.changeProceedButtonState();
orderSummary.updatePaymentMethodForm(a.dueAmount,c);orderSummary.updateInstallmentsAmount(a.installmentDatas,$(b).val())}},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}})},handleCreateLoginShowHide:function(a,b,c){var d=X(b,c);a&&1<=a.length&&(!c||a!==c)?($("#"+b).parent().show(),$("#"+b).prop("checked",!1),d===b&&$("#"+b).closest("tbody").find(".beneficiary").each(function(){if($(this).find('input[type="email"]').val()===c){var a=$(this).find('input[type="checkbox"]').attr("id");
$("#"+a).prop("checked",!0);return!1}})):($("#"+b).parent().hide(),a==c&&void 0===d&&$("#"+b).prop("checked",!0))},updatePaymentMethodForm:function(a,b){0<b?$("#payment_overhead_fee").show():$("#payment_overhead_fee").hide();0<a?$("#main_content_summary_payment_methods").show():$("#main_content_summary_payment_methods").hide()},updatePaymentAntifraudForm:function(){aa($('input[type="radio"][name="paymentMethodId"]:checked'))},populatePrefilledDataAntiFraudForm:function(a){G&&$('input[type="text"], input[type="email"], input[type="number"], select',
"#anti_fraud_form").prop("disabled",!1);$("#input_FIRSTNAME","#anti_fraud_form").val(a.firstName);$("#input_LASTNAME","#anti_fraud_form").val(a.lastName);$("#input_EMAIL","#anti_fraud_form").val(a.email);$("#anti_address_country","#anti_fraud_form").val(a.country);null!==a.country&&$("#anti_address_country").trigger("change");$("#anti_address_zipcode","#anti_fraud_form").val(a.zipCode);$("#anti_address_town","#anti_fraud_form").val(a.city);$("#input_ADDRESS_line1","#anti_fraud_form").val(a.addressLine1);
$("#input_ADDRESS_line2","#anti_fraud_form").val(a.addressLine2);$("#input_ADDRESS_line3","#anti_fraud_form").val(a.addressLine3);$("#birthdate_day","#anti_fraud_form").val(a.birthDateDay);$("#birthdate_month","#anti_fraud_form").val(a.birthDateMonth);$("#birthdate_year","#anti_fraud_form").val(a.birthDateYear);null!==a.phonePrefix&&$("#anti_phone_prefix","#anti_fraud_form").val(a.phonePrefix);$("#anti_phone_number","#anti_fraud_form").val(a.phoneNumber);$("#input_DOCUMENTTYPE","#anti_fraud_form").val(a.documentType);
$("#input_DOCUMENTNUMBER","#anti_fraud_form").val(a.documentNumber);G&&$('input[type="text"], input[type="email"], input[type="number"], select',"#anti_fraud_form").attr("disabled",!0);Array.isArray(a.localityCriterionElements)&&a.localityCriterionElements.forEach(function(a){account.register.address.defaultLocalityCriterionNames[a.localityCriterionCode]=a.localityCriterionElementName})},showContactMandateForm:function(){$(".contact_mandate").show();$("#direct_debit_mandate").find("input").not("#acceptDDebitFromOrgId").prop("disabled",
!1);0==$("#direct_debit_mandate").find("#hiddenDirectDebitFromOrgConsent").length&&$("#direct_debit_mandate").find("#acceptDDebitFromOrgId").prop("disabled",!1)},hideContactMandateForm:function(){$(".contact_mandate").hide();$("#direct_debit_mandate").find("input").attr("disabled","disabled")},isDisablePrepaymentButton:function(){return voucher.isVoucherApplied()||creditNote.isCreditNoteInstanceSelected()},unsubscribeGiftAid:function(){ba("false",function(){location.reload()})},addMandatoryCulturalContacts:function(a){H.push.apply(H,
$jscomp.arrayFromIterable(a))},updateInstallmentsAmount:function(a,b){Array.isArray(a)&&0!==a.length&&$("#payment_installments_table_"+b+" .installment_due_amount > .amount").each(function(b,c){(b=a[b])&&$(c).html(functions.generateAmount(b))})}}});
var packages;
function NS_Packages(){this.SELECTION_CHANGE="selectionChange";this.DEFAULT_PRICE_LEVEL_ID=-1;this.mandatorySeatCategory=!1;this.referencePackageLineId=null;this.linesToSync=[];this.mappingTable={};this.priceCatalog={};this.freeAmountCatalog={};this.parentChildRelationship={};this.dummySeatCatForServices="SERVICES";this.dummyTablePrefix="NO_TABLE";this.uniqueLogicalConfiguration=!1;this.packageLines=[];this.originalUnitPrice=new Map;this.chargeDataMap=new Map;this.audienceSubCatChargeMap={};this.currentAudienceSubCatAndPrices=
new Map;this.baseMaxChargeAmount={maxChargeAudienceSubCatId:null,maxChargeAmount:null};this.currentSelectedAudienceSubCats=new Set;this.isCheckingOverlappedTimeslots=!1;this.datePickers={};this.audienceSubCategories={};this.allowedSubCategories=[];this.totalPrices=null;this.dateForId={};this.visitLanguages={};this.performancesForVisit={};this.optionalLineQty={};this.packageLinesToLoad=[];this.previousSelections={};this.duration=1;this.timeslotIsFullLabel=this.showEndTime="";this.typingTimer=0;this.parentSelectedSeatCatChanged=
!1;this.addDatePicker=function(a,b){this.datePickers[a]=b};this.getDatePicker=function(a){return this.datePickers[a]};this.isAudSubCatPriceEqual=function(a,b,c){return a&&b&&Number(a.audienceSubCatId)===Number(b)&&(!c||Number(a.priceLevelId)===Number(c))};this.initAudienceSubCat2ChargeMap=function(a){return this.audienceSubCatChargeMap=a};this.addOriginalPrice=function(a,b){this.originalUnitPrice.set(a,b)};this.addCurrentSelectedAudienceSubCats=function(a){this.currentSelectedAudienceSubCats.add(a)};
this.removeCurrentSelectedAudienceSubCat=function(a){this.currentSelectedAudienceSubCats.delete(a)};this.setBaseMaxChargeAmount=function(a,b){this.baseMaxChargeAmount.maxChargeAudienceSubCatId=a;this.baseMaxChargeAmount.maxChargeAmount=b};this.addPrice=function(a,b,c,d,f,e,g){this.priceCatalog[a]||(this.priceCatalog[a]={});var h=this.priceCatalog[a];if(!h[b]||e)h[b]=[];a:{e=h[b];for(l in e)if(e.hasOwnProperty(l)&&this.isAudSubCatPriceEqual(e[l],c,g)){var l=!0;break a}l=!1}l||h[b].push({audienceSubCatId:c,
priceLevelId:g||this.DEFAULT_PRICE_LEVEL_ID,price:d});this.priceCatalog[a].SERVICES&&1===this.priceCatalog[a].SERVICES.length&&(this.priceCatalog[a].SERVICES[0].price=d);f&&(this.audienceSubCategories[c]=f)};this.storeAudienceSubCatInfo=function(a){for(var b in a)a.hasOwnProperty(b)&&(this.audienceSubCategories[b]=a[b])};this.registerDateForId=function(a,b){this.dateForId[a]=b};this.initSelectedCategories=function(a){var b=$("table[id='"+a+"']").find("input:radio");var c=a.replace("sel_table_","");
var d=0<$("#pl_"+c).find(".package_line_optional_checkbox").length;c=b.filter(function(){return 1===b.length||d?"hidden"!==$(this).css("visibility"):"hidden"!==$(this).css("visibility")&&!$(this).attr("disabled")}).first();0<c.length&&!c.prop("disabled")&&(c.prop("checked",!0),this.categorySelectionChanged(c));this.parentSelectedSeatCatChanged&&(a=$("table[id='"+a+"']").find("input[type='radio']:checked"),this.categorySelectionChanged(a))};this.disableOptionalLines=function(a){var b=this,c;$(".package_line_container").each(function(){c=
$(this).find(".package_line_optional_checkbox input");0<c.length&&b.toggleDisableLine(c,a)})};this.toggleDisableLine=function(a,b){var c=$(a).closest(".package_line_container"),d=c.find(".package_line_content");$(a).is(":checked")?($(d).find("input").prop("disabled",!1),$(d).find(".package_line_item_selector select").prop("disabled",!1),$(d).find(".package_line_performance_selector select").prop("disabled",!1),$(d).removeClass("disabled"),$(d).find("table select").each(function(){var a=$(this);0<
$(this).closest("tr").find("input:checked").length&&a.prop("disabled",!1)}),packages.initSelectedCategoriesForOptionalLine(c),$(d).find(".datepicker_element").removeClass("disabled"),packages.mandatorySeatCategory&&packages.syncMultiLogicConfLines(),c.removeClass("disabled"),c.addClass("enabled")):($(d).find("input").prop("disabled",!0),$(d).find("select").prop("disabled",!0),$(d).find(".datepicker_element").addClass("disabled"),$(d).addClass("disabled"),c.removeClass("enabled"),c.addClass("disabled"),
$(d).find('select[id*="itemOrPerformanceId"]').is(":visible")||$(d).find('select[id*="itemOrPerformanceId"]').prop("disabled",!1));b||packages.toggleTotalPackageContent();packages.updatePrices()};this.initSelectedCategoriesForOptionalLine=function(a){a="sel_table_"+$(a).find("input[id$='packageLineId']").val();$("table[id='"+a+"']").find("input[type='radio']:checked").length||packages.initSelectedCategories(a)};this.categorySelectionChanged=function(a){var b=$(a).closest(".package_line_container").find("input[id*='packageLineId']").val();
this.synchronizeSeatCatTwins($(a).val(),Number(b));$(a).closest("tbody").find("td.area select").each(function(){$(this).attr("disabled","disabled")});$(a).attr("disabled")||$(a).closest("tr").find("td.area select").prop("disabled",!1);!0===this.mandatorySeatCategory&&Number(b)===Number(this.referencePackageLineId)&&this.syncMultiLogicConfLines()};this.updateSubtotalsForSingleTable=function(){var a=0,b=this,c=$("#uc_table"),d=0;c.find("tbody tr").each(function(){var c=$(this).find("td.quantity select"),
g,h;var l=!0;0===c.length&&(c=$(this).find("td.quantity input[type='text']"),0<c.length&&(l=functions.validateQuantityInputField(c)));if(0<c.length&&l){$(this).find("input[type='hidden']").each(function(){-1!==$(this).attr("id").indexOf("logicalSeatCategory")?h=Number($(this).val()):-1!==$(this).attr("id").indexOf("audienceSubCategory")&&(g=Number($(this).val()))});var k=b.getPriceForAudSubCatPrice("uc_table",g,h);k+=b.getFreeInputAmountPrice();$(".package_line_optional_checkbox input:checked").each(function(){var a=
$(this).closest(".package_line_container").find("input[id*='packageLineId']").val(),c=h;a="ulc_opt_"+a;var d=b.priceCatalog[a];!d.hasOwnProperty(c)&&d.hasOwnProperty(b.dummySeatCatForServices)&&(c=b.dummySeatCatForServices);k+=b.getPriceForAudSubCatPrice(a,g,c)});c=Number(c.val());0<c?(l=k*c,d+=c):l=0;f=$(this).find(".unit_price .amount");f.html(functions.generateAmount(k));b.setCurrentAudienceSubCatAndPrices(k,c,g);0<c?b.addCurrentSelectedAudienceSubCats(g):b.currentSelectedAudienceSubCats.has(g)&&
0===c&&b.removeCurrentSelectedAudienceSubCat(g);b.updateChargeAmount(b.calculateMaxChargeToDisplay());f=$(this).find(".subtotal .amount");f.html(functions.generateAmount(l));a+=l}else f=$(this).find(".subtotal .amount"),f.html(functions.generateAmount(0))});var f=c.find("tbody .subtotal .reservation_amount");f=f.find(".amount");f.html(functions.generateAmount(a));functions.updateSelectedQuantityIndicator(d,c);functions.alertTotalTicketAmount($(".subtotal.with_submit_button .reservation_amount"))};
this.getSelectionConfiguration=function(){var a=[],b="",c=this.dummySeatCatForServices;$("th.category, td.category").find("input:radio:checked").each(function(){var b=$(this).closest(".package_line_container").find("input[type='checkbox']");if((0===b.length||$(b).is(":checked"))&&!$(this).attr("disabled")){var c=$(this).val();b=$(this).closest("table").attr("id");a.push({tableId:b,seatCategoryId:Number(c)})}});$(".visit_table").each(function(){var b=$(this).attr("id"),c,e=$(this).closest(".package_line_container").find("input[type='checkbox']");
(0===e.length||$(e).is(":checked"))&&$(this).find("tr input:hidden").each(function(){c=$(this).val();a.push({tableId:b,seatCategoryId:Number(c)})})});$(".services_table").each(function(){var b=$(this).closest(".package_line_container").find("input[type='checkbox']");if(0===b.length||$(b).prop("checked"))b=$(this).attr("id"),a.push({tableId:b,seatCategoryId:c})});for(b in this.priceCatalog)this.priceCatalog.hasOwnProperty(b)&&-1<b.indexOf(this.dummyTablePrefix)&&a.push({tableId:b,seatCategoryId:c});
return a};this.getTotalPrice=function(a,b){var c=0,d=this.getSelectionConfiguration(),f,e=d.length,g=$("#participants_number_text_field");for(f=0;f<e;f++){var h=this.getPriceForAudSubCatPrice(d[f].tableId,a,d[f].seatCategoryId,b);var l=parseInt(d[f].tableId.replace(/[^\d]*(\d+)$/g,"$1"),10);l=packages.getPackageLineByPackageLineId(l);!l.isFlatRate&&packages.hasParentLine(l)&&l.parentLineFlatRate&&0<g.length&&(h*=g.val());c+=h}return c};this.toggleTotalPackageContent=function(){var a=$("#participants_number_text_field"),
b,c={},d;var f=0;for(b=packages.packageLines.length;f<b;f++){var e=packages.packageLines[f];var g=0;if(0===$(".package_line_container[id=pl_"+e.packageLineId+"]").find(".package_line_optional_checkbox input[type='checkbox']").length||$(".package_line_container[id=pl_"+e.packageLineId+"]").find(".package_line_optional_checkbox input[type='checkbox']").is(":checked"))g=!e.isFlatRate&&packages.hasParentLine(e)&&e.parentLineFlatRate&&a?parseInt(a.val(),10):parseInt(e.packageQuantity,10);packages.addQuantityByProductType(c,
e,g)}for(d in c)c.hasOwnProperty(d)&&(f=$(".total_package_content .tpq_"+d),a=$(".total_package_content .tpq_"+d+"_text"),f.text(c[d].quantity),f=1>=c[d].quantity?c[d].singularText:c[d].pluralText,a.text(f))};this.addQuantityByProductType=function(a,b,c){a[b.packageProductType]||(a[b.packageProductType]={quantity:0,pluralText:b.packagePluralText,singularText:b.packageSingularText});a[b.packageProductType].quantity+=c;return a};this.initChargeAmount=function(){var a=this;void 0!==this.currentAudienceSubCatAndPrices&&
this.currentAudienceSubCatAndPrices instanceof Map&&this.currentAudienceSubCatAndPrices.forEach(function(b,c){a.updateChargeMap(b,c)});if(void 0!==this.chargeDataMap){var b=Math.max.apply(Math,$jscomp.arrayFromIterable(Object.values(this.chargeDataMap))),c=Object.keys(this.chargeDataMap).find(function(c){return a.chargeDataMap[c]===b});this.setBaseMaxChargeAmount(c,b)}};this.getChargeAmountFromChargeTable=function(a,b){var c=Math.max(1,b.quantity);b=b.price/c;var d;a.amount&&(d=parseFloat(a.amount));
if(a.slope){var f=Math.pow(10,secutixAmountDecimalSize);d=b*(parseFloat(a.slope)/100);var e=d%currencyMinimumAmount;d=0!==e?Math.abs(e)>=currencyMinimumAmount/2?Math.abs(d)+currencyMinimumAmount-Math.abs(e):d-e:d;if(a.rounding){d+=b;e=(a.rounding/f).toFixed(currencyFractionDigit)*f;var g=d%e;d=(0<g?d-g+e:d)-b}a.ceiling&&d>parseFloat(a.ceiling)&&(d=parseFloat(a.ceiling));a.floor&&d<parseFloat(a.floor)&&(d=parseFloat(a.floor));a.rounding||a.ceiling||a.floor||(d=(d/f).toFixed(currencyFractionDigit)*
f)}d||(d=0);return d*c};this.updateChargeMap=function(a,b){var c=this.audienceSubCatChargeMap[b];void 0!==c&&(this.chargeDataMap[b]=this.getChargeAmountFromChargeTable(c,a))};this.calculateChargeByAudSubCat=function(a,b){b=this.audienceSubCatChargeMap[b];if(void 0!==b)return this.getChargeAmountFromChargeTable(b,a)};this.calculateMaxChargeToDisplay=function(){var a=this;if(0<this.currentSelectedAudienceSubCats.size){var b=Number(0);this.currentSelectedAudienceSubCats.forEach(function(c){isNaN(a.calculateChargeByAudSubCat(a.currentAudienceSubCatAndPrices.get(c),
c))||(b+=a.calculateChargeByAudSubCat(a.currentAudienceSubCatAndPrices.get(c),c))});return b}return this.baseMaxChargeAmount.maxChargeAmount};this.updateChargeAmount=function(a){var b=$("#main_content_package_selection .merge_charges_instruction .amount");void 0===a||isNaN(a)?b.html(functions.generateAmount(Math.max.apply(Math,$jscomp.arrayFromIterable(Object.values(this.chargeDataMap))))):b.html(functions.generateAmount(a))};this.initUnitPriceTableWithChargeAmount=function(){$("#main_content_package_selection .table_container table tbody tr").each(function(){var a=
$(this).find('.quantity input[id*="audienceSubCategory"]').val(),b=$(this).find(".unit_price .amount");void 0!==packages.chargeDataMap&&void 0!==packages.chargeDataMap[a]&&b&&b.html(functions.generateAmount(packages.originalUnitPrice.get(b[0].id)+packages.chargeDataMap[a]))})};this.setCurrentAudienceSubCatAndPrices=function(a,b,c){a={quantity:b,price:a};this.currentAudienceSubCatAndPrices.set(c,a);this.baseMaxChargeAmount.maxChargeAudienceSubCatId===c&&0===b&&this.setBaseMaxChargeAmount(this.baseMaxChargeAmount.maxChargeAudienceSubCatId,
this.calculateChargeByAudSubCat(a,c))};this.updateTotalPrices=function(){var a=this,b=0,c=0;var d=0;var f;if(0===$("#quantity_table").length){var e=this.getSelectionConfiguration();this.selectionConfiguration={};for(f=e.length;d<f;d++){var g=e[d];var h=g.tableId.replace(/[^\d]*(\d+)$/g,"$1");g=g.seatCategoryId==this.dummySeatCatForServices?null:g.seatCategoryId;this.selectionConfiguration[h]=g}this.events.trigger(this.SELECTION_CHANGE)}else $("#quantity_table tbody tr").each(function(){var d=$(this).find('.quantity input[id*="audienceSubCategory"]').val();
var e=$(this).find('.quantity input[id*="priceLevelId"]').val()||a.DEFAULT_PRICE_LEVEL_ID;if(d){e=a.getTotalPrice(d,e);e+=a.getFreeInputAmountPrice();var f=$(this).find(".unit_price .amount");f.html(functions.generateAmount(e));f.data("amount",e);a.addOriginalPrice(f[0].id,e);f=$(this).find(".subtotal .amount");var g=$(this).find(".quantity select");0===g.length?(g=$(this).find(".quantity input"),g=functions.validateQuantityInputField(g)?Number(g.val()):0):g=Number(g.val());f.html(functions.generateAmount(e*
g));f={quantity:g,price:e};a.setCurrentAudienceSubCatAndPrices(0<g?e*g:e,g,d);a.updateChargeMap(f,d);void 0!==a.chargeDataMap[d]&&(e+=a.chargeDataMap[d]);b+=e*g;c+=g;0<g?a.addCurrentSelectedAudienceSubCats(d):a.currentSelectedAudienceSubCats.has(d)&&0===g&&a.removeCurrentSelectedAudienceSubCat(d);void 0!==a.chargeDataMap[d]&&(e=$(this).find(".unit_price .amount"),e.html(functions.generateAmount(e.data("amount")+a.chargeDataMap[d])))}}),d=$("#quantity_table tbody tr.subtotal .reservation_amount .amount"),
d.html(functions.generateAmount(b)),functions.updateSelectedQuantityIndicator(c,"#quantity_table"),packages.updateChargeAmount(a.calculateMaxChargeToDisplay())};this.getFreeInputAmountPrice=function(){var a=$('input[name$="\\.unitPrice"]'),b,c=0,d,f,e;0!==a.length&&a.each(function(){if(0===$(this).closest(".package_line_container").find(".package_line_optional_checkbox input[type='checkbox']").length||$(this).closest(".package_line_container").find(".package_line_optional_checkbox input[type='checkbox']").is(":checked"))b=
$(this),d=b.parents(".package_line_item_selector").find('select[name$="\\.itemOrPerformanceId"], input[type="hidden"][name$="\\.itemOrPerformanceId"]').val(),packages.validatePrice(0<b.val().length,b)&&(f=functions.stringToStxAmount(b.val()),e=packages.freeAmountCatalog[d].packageLineQuantity||1,"DONATION"!==packages.freeAmountCatalog[d].productType&&(f-=f%1E3),c+=f*e)});return c};this.getPriceForAudSubCatPrice=function(a,b,c,d){var f=(a=this.priceCatalog[a][c])?a.length:0,e=0;for(c=0;c<f;c++)if(this.isAudSubCatPriceEqual(a[c],
b,d)||-1===a[c].audienceSubCatId)e+=a[c].price;return e};this.getAudienceSubCat=function(a,b){var c=(a=this.priceCatalog[a][b])?a.length:0,d=[];for(b=0;b<c;b++){var f=a[b].audienceSubCatId;d.push({id:f,name:this.audienceSubCategories[f]})}return d};this.serviceChanged=function(a,b,c,d,f,e){if(this.freeAmountCatalog[$(a).val()]){var g=this.freeAmountCatalog[$(a).val()];$(a).parents(".package_line_item_selector").append(this.generateFreeAmountInput(g.itemMinAmount,g.itemMaxAmount,g.freeAmountContraint,
e))}else e=$(a).parents(".package_line_item_selector").find(".free_Amount_Input_Div"),0!==e.length&&(functions.hideAllFreeAmountErrorMess(),e.remove());this.loadTable(a,"/ajax/selection/package/serviceUpdate",{advantageId:c,ppid:d,crossSellId:f},function(){packages.synchronizeItemTwins($(a).val(),b);packages.storePreviousSelection(b)});void 0!==this.chargeDataMap&&this.updatePrices()};this.generateFreeAmountInput=function(a,b,c,d){d="packageLines["+d+"].unitPrice";return'<div class="free_Amount_Input_Div"><span class="freeAmountInput"><input id="'+
(d+'" name="'+d+'" onkeyup="if (event.keyCode != 13) { packages.typingTimer = setTimeout(packages.formFieldsChangedFromTimeout.bind(null,this), 1000);}" onkeydown="if (event.keyCode != 13) {clearTimeout(this.typingTimer)} else {event.preventDefault();};" type="text" onblur="packages.freeInputFieldChange(this);" value="" minquantity="'+a+'" maxquantity="'+b+'"/></span><span class="currency currency_code">')+(currencyCode+"</span>")+c+"</div>"};this.freeInputFieldChange=function(a){a=$(a);0!==a.length&&
packages.validatePrice(0<a.val().length,a)&&packages.updatePrices();packages.updatePriceForOptionalServiceTable(a,0!==a.length&&packages.validatePrice(0<a.val().length,a))};this.updatePriceForOptionalServiceTable=function(a,b){var c=a.closest(".package_line_container"),d=c.find(".package_line_optional_checkbox input[type='checkbox']"),f,e=a.parents(".package_line_item_selector").find('select[name$="\\.itemOrPerformanceId"], input[type="hidden"][name$="\\.itemOrPerformanceId"]').val();0!==d.length&&
d.is(":checked")&&c.find(".services_table > tbody td.unit_price").each(function(){f=functions.stringToStxAmount(a.val());"DONATION"!==packages.freeAmountCatalog[e].productType&&(f-=f%1E3);$(this).find(".amount").html(b?functions.generateAmount(f):functions.generateAmount(0))})};this.formFieldsChangedFromTimeout=function(a){packages.freeInputFieldChange(a)};this.validatePrice=function(a,b){var c=b.parents(".package_line_item_selector").find('select[name$="\\.itemOrPerformanceId"], input[type="hidden"][name$="\\.itemOrPerformanceId"]').val();
return functions.validatePrice(a,b,null,packages.freeAmountCatalog[c])};this.eventOrTimeslotPassChanged=function(a,b,c,d){var f=$("#reservationIdx").val(),e=$("#crossSellBaseProductId").val(),g=$("#crossSellId").val(),h=$(a).parents(".package_line_performance_selector")[0];a={reservationIdx:f,ppid:e,crossSellId:g,lineNb:b};void 0!==d&&(a.advantageId=d);packages.loadTable(h,"/ajax/selection/package/eventOrTimeslotPassUpdate",a,function(){var a=$(h).closest(".package_line_header").siblings(".table_container").find("table");
a=0<a.length?a.attr("id"):"uc_table";var d=packages.getPackageLineIdFromLineNumber(b);!0===c&&(c=packages.dateForId[$(h).val()]);c&&packages.dates.setCurrentDate(c,a);packages.synchronizePerformanceTwins(d);packages.storePreviousSelection(d);void 0!=packages.parentChildRelationship[d]&&this.resetChildOptionalChoiceAfterParentSelecting(packages.parentChildRelationship[d]);a=$(".package_line_container[id=pl_"+d+"] .stage_preview_container");a.length&&a.remove()})};this.eraseStoredPricesForUpdatedLines=
function(a){var b=packages.parentChildRelationship[a],c=$(".package_line_container[id=pl_"+a+"]").find(".table_container table");0<c.length?delete packages.priceCatalog[c.attr("id")]:delete packages.priceCatalog[packages.dummyTablePrefix+"_"+a];if(b)for(a=0;a<b.length;a++)c=$(".package_line_container[id=pl_"+b[a].packageLineId+"]").find(".table_container table"),0<c.length?delete packages.priceCatalog[c.attr("id")]:delete packages.priceCatalog[packages.dummyTablePrefix+"_"+b[a].packageLineId]};this.updatePackageLineProductHeader=
function(a){a=$(".package_line_container[id=pl_"+a+"]");var b=$("#packageLineProductInfo",a);0<b.length&&($(".package_line_header_product",a).html(b.html()),b.remove())};this.replaceTableContent=function(a,b){var c=$(".package_line_container[id=pl_"+a+"]"),d=c.find(".table_container");0<d.length?d.replaceWith(b):c.append(b);packages.updatePackageLineProductHeader(a)};this.replacePackageLine=function(a,b){$(".package_line_container[id=pl_"+a+"]").replaceWith(b);packages.updatePackageLineProductHeader(a)};
this.performSuccessActions=function(a){var b=null;for(b in a)a[b].updateWholeLine?packages.replacePackageLine(a[b].packageLineId,a[b].updatedContent):(packages.eraseStoredPricesForUpdatedLines(a[b].packageLineId),packages.replaceTableContent(a[b].packageLineId,a[b].updatedContent));packages.disableOptionalLines(!0);tools.displayLazyImages()};this.storePreviousSelection=function(a){var b=$(".package_line_container[id=pl_"+a+"]");0<b.find(".package_line_performance_selector").length?(b=b.find(".package_line_performance_selector"),
b={selectorClass:"package_line_performance_selector",selectedDate:b.find(".datepicker_element input").val(),performanceCombo:b.find(".time_selection").clone(),selectedPerformance:b.find(".time_selection").val(),languageCombo:b.find(".language_selection").clone(),selectedLanguage:b.find(".language_selection").val()},packages.previousSelections[a]=b):packages.previousSelections[a]={selectorClass:"package_line_item_selector",value:b.find(".package_line_item_selector select").val()}};this.restorePreviousSelection=
function(a){var b=packages.previousSelections[a],c=$(".package_line_container[id=pl_"+a+"]").find("."+b.selectorClass);if("package_line_performance_selector"===b.selectorClass){a=c.find(".datepicker_element");0<a.length&&a.find("input[type='hidden']").val(b.selectedDate);a=c.find(".time_selection");if(0<a.length){var d=b.performanceCombo.clone();a.replaceWith(d);b.selectedPerformance&&d.val(b.selectedPerformance)}a=c.find(".language_selection");0<a.length&&(c=b.languageCombo.clone(),a.replaceWith(c),
b.selectedLanguage&&c.val(b.selectedLanguage))}else c.find("select").val(b.value)};this.loadTable=function(a,b,c,d){var f=[];tools.dialog.showWaitingPopup("loadingDialog",!0);$(a).is("select")||$(a).find(".time_selection").children().filter("option").length?c.selectedItem=$(a).find("option:selected").val():c.selectedItem=$(a).find("input[type='hidden']").val();c.productId=$(a).closest("form").find("input[name='productId']").val();c.packageLineId=packages.getClosestPackageLineContainer(a);a=$.map($(".package_element_selector, .time_selection"),
function(a){return $(a).is("select")?$(a).find("option:selected"):$(a).find("input[type='hidden']")});c.selectedItems=$.map(a,function(a){return $(a).val()});c.packageLinesSelectedItems=$.map(a,function(a){return packages.getClosestPackageLineContainer(a)});$.ajax({type:"GET",url:contextPath+b,data:c,success:function(a){var b;f.push({updateWholeLine:!1,packageLineId:c.packageLineId,updatedContent:a});if(packages.parentChildRelationship[c.packageLineId])for(a=packages.parentChildRelationship[c.packageLineId],
b=0;b<a.length;b++){var e=a[b];packages.packageLinesToLoad.push({productId:c.productId,packageLineId:e.packageLineId,parentPackageLineId:c.packageLineId,lineNb:e.lineNb-1,parentItemOrPerformanceId:c.selectedItem,parentYear:0,parentMonth:0,parentDay:0})}packages.performNextStepInTableUpdate(c.productId,c.advantageId,d,f)},error:function(a){tools.dialog.hideDialog("loadingDialog");400===a.status?(packages.restorePreviousSelection(c.packageLineId),tools.dialog.showDialog("plAvailabilityErrorDialog",
!0)):tools.dialog.showDialog("ajaxErrorDialog",!0)}})};this.getClosestPackageLineContainer=function(a){return $(a).closest(".package_line_container").find("input[name$='.packageLineId']").val()};this.performNextStepInTableUpdate=function(a,b,c,d){0<packages.packageLinesToLoad.length?(a=packages.packageLinesToLoad.pop(),packages.loadPackageLine(a.productId,b,a.packageLineId,a.parentPackageLineId,a.lineNb,a.parentItemOrPerformanceId,a.parentYear,a.parentMonth,a.parentDay,c,d)):packages.uniqueLogicalConfiguration||
0!==$("#quantity_table").length?packages.updatePackageQuantityTable(a,b,c,d,packages.uniqueLogicalConfiguration):(c&&c.call(packages),packages.performSuccessActions(d),packages.finalizeLinesUpdateChain())};this.loadPackageLine=function(a,b,c,d,f,e,g,h,l,k,m){var p=$("#crossSellBaseProductId").val(),q=$("#crossSellId").val();this.priceCatalog["sel_table_"+c]=[];$.ajax({type:"GET",url:contextPath+"/ajax/selection/package/lineUpdate",data:{productId:a,advantageId:b,packageLineId:c,ppid:p,crossSellId:q,
lineNb:f,parentItemOrPerformanceId:"undefined"!=typeof e?e:0,year:"undefined"!=typeof g?g:0,month:"undefined"!=typeof h?h:0,day:"undefined"!=typeof l?l:0},success:function(d){m.push({updateWholeLine:!0,packageLineId:c,updatedContent:d});packages.performNextStepInTableUpdate(a,b,k,m)},error:function(a){packages.packageLinesToLoad=[];tools.dialog.hideDialog("loadingDialog");400===a.status?(packages.restorePreviousSelection(d),tools.dialog.showDialog("plAvailabilityErrorDialog",!0)):tools.dialog.showDialog("ajaxErrorDialog",
!0)}})};this.updatePackageQuantityTable=function(a,b,c,d,f){var e={},g,h,l=$("#crossSellBaseProductId").val(),k=$("#crossSellId").val(),m=$("#reservationIdx").val(),p={},q,r={};$(".package_line_container").each(function(){g=$(this).find("input[id*='packageLineId']").val();h=$(this).find("[id*='itemOrPerformanceId']").val();$(this).find("[id*='passSelectedDate']")&&(q=$(this).find("[id*='passSelectedDate']").val());e[g]=h;r[g]=q;p=$(this).find("input[id*='mergedPackageLinesId']");p.each(function(){e[$(this).val()]=
h;r[$(this).val()]=q})});$.ajax({type:"POST",url:contextPath+"/ajax/selection/package/packageTableUpdate",data:{productId:a,advantageId:b,baseProductId:l,crossSellId:k,reservationIdx:m,itemOrPerformancesId:e,passSelectedDayPerPackageLine:r,uniqueLogicalConig:f},success:function(a){f?(packages.priceCatalog.uc_table={},$("#uc_table").closest(".table_container").replaceWith(a)):$("#quantity_table").closest(".table_container").replaceWith(a);packages.updateChargeAmount(packages.calculateMaxChargeToDisplay());
visitGroupDetails.init({});c&&c.call(packages);packages.performSuccessActions(d);packages.finalizeLinesUpdateChain();"undefined"!==typeof conditionalRatesMessage&&conditionalRatesMessage.refreshConditionalRatesConfiguration()},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}});return!1};this.updatePrices=function(){packages.uniqueLogicalConfiguration?packages.updateSubtotalsForSingleTable():packages.updateTotalPrices()};this.finalizeLinesUpdateChain=
function(){packages.mandatorySeatCategory&&!packages.uniqueLogicalConfiguration&&packages.syncMultiLogicConfLines();packages.updatePrices();tools.dialog.hideDialog("loadingDialog")};this.validateTimeSlots=function(a,b,c,d){var f=$("#package_form");util.form.extractFormAsJson(f,null,function(e){e.visitPassFormModel={};$.ajax({url:contextPath+"/ajax/selection/package/validateTimeSlots",method:"POST",data:JSON.stringify(e),processData:!1,contentType:"application/json",success:function(e){"ERR_TIMESLOTS_OVERLAPPED"===
e.status?tools.dialog.showDialog("timeslot_warning_popup",!0,!0,null,"timeslot_warning_popup"):(packages.isCheckingOverlappedTimeslots=!1,packages.validateSubmission(a,b,c,d))},error:function(){tools.dialog.showDialog("ajaxErrorDialog",!0)}})})};this.validateSubmission=function(a,b,c,d,f){var e=!1;0==f&&(packages.isCheckingOverlappedTimeslots=!1);packages.isCheckingOverlappedTimeslots?packages.validateTimeSlots(a,b,c,d,f):($("#error_noProductSelected").addClass("hidden"),$("#error_missingSelection").addClass("hidden"),
f=$("#uc_table"),0===f.length&&(f=$("#quantity_table")),f=$("input[id*='optionalSelected']"),!f.length||$(".package_line_container").length>f.length?e=!0:f.each(function(){$(this).is(":checked")&&(e=!0)}),e?functions.validateQuantities(!0,a,b,c,function(a){a||($("#error_missingSelection.hidden").removeClass("hidden"),packages.isCheckingOverlappedTimeslots="true"===localStorage.getItem("isCheckingOverlappedTimeslots"));e&&a&&$("#notification").addClass("hidden")},d):($("#error_noProductSelected.hidden").removeClass("hidden"),
$("#notification.hidden").removeClass("hidden"),window.scrollTo(0,0)))};this.updateComboOptions=function(a,b,c,d,f,e){var g=0,h=$(a).parent(),l="VISIT_PASS"===$('input[name$="packageLines['+c+'].productType"]').val();if(1<b.length){if($(a).is("select"))$(a).find("option").remove();else{var k=$(a).find("input").attr("id");var m=$(a).find("input").attr("name");$(a).remove();$("<select class='time_selection' id='"+k+"' name='"+m+"' onchange='packages.eventOrTimeslotPassChanged(this, "+c+", "+(!d&&!l)+
", "+(e?""+e:"")+");"+(l?"packages.getThemes("+c+")":"")+" '>").insertAfter(h.find(".datepicker_element"));a=h.find(".time_selection")}for(g in b)b.hasOwnProperty(g)&&(d=b[g].performanceName?"&nbsp;- "+b[g].performanceName:"",c=packages.buildDisplayedTimeslot(b[g]),$(a).append("<option "+(f&&"NONE"===b[g].availabilityLevel?"disabled":"")+" value='"+(f?b[g].id:b[g].performanceId)+"'>"+(f?c:b[g].performanceTime)+d+"</option>"));$(a).children("option:enabled").first().prop("selected",!0)}else d=b[0].performanceName?
"&nbsp;- "+b[0].performanceName:"",c=packages.buildDisplayedTimeslot(b[0]),$(a).is("select")?(k=$(a).attr("id"),m=$(a).attr("name"),$(a).remove(),$("<span class='time_selection'>"+(f?c:b[0].performanceTime)+d+"<input type='hidden' id='"+k+"' name='"+m+"' value='"+(f?b[0].id:b[0].performanceId)+"'></span>").insertAfter(h.find(".datepicker_element")),a=h.find(".time_selection")):(k=$(a).find("input").attr("id"),m=$(a).find("input").attr("name"),$(a).html((f?c:b[0].performanceTime)+d+"<input type='hidden' id='"+
k+"' name='"+m+"' value='"+(f?b[0].id:b[0].performanceId)+"'>"),a.toggleClass("single",!d));return a};this.buildDisplayedTimeslot=function(a){var b=!a.endTime||1<a.durationInDays||!this.showEndTime?a.startTime:a.startTime+"&nbsp;- "+a.endTime;a.availabilityLevel&&"NONE"===a.availabilityLevel&&(b=b+"&nbsp;- "+packages.timeslotIsFullLabel);return b};this.languageChanged=function(a,b,c,d){var f=[],e=0;this.synchronizePerformanceTwins(c);c=packages.performancesForVisit[$(a).closest(".package_line_container").attr("id")];
var g=$(a).val();if("all"!==g)for(e in c)packages.visitLanguages[c[e].performanceLanguageName]===g&&f.push(c[e]);else f=c;a=$(a).siblings(".time_selection");a=packages.updateComboOptions(a,f,b,!0,!1,d);packages.eventOrTimeslotPassChanged(a,b,null,d)};this.showDatePickerPopup=function(a,b,c,d,f){var e=a.parseDate($(c).find("input").val()),g=$("#"+b).datepicker("getDate"),h="#"+b+" .datepicker_content";if($(c).hasClass("disabled"))return!1;g&&e.getTime()!==g.getTime()&&($("#"+b).datepicker("setDate",
e),a.selectedDateText=$.datepicker.formatDate(datePickerConfig.dateFormat,$("#"+b).datepicker("getDate")));a.showDatePicker(h,function(e){if("TIMESLOT_PASS"==f||"VISIT_PASS"==f)packages.getTimeslots(a,c,e,b,d);else if("VISIT"==f)packages.getVisitPerformances(a,c,e,b,d);else{var g=a.getPerformanceForDate(e);var h=$(c).siblings(".time_selection");$(c).find("input").val(g[0].performanceDate);h=packages.updateComboOptions(h,g,d,!1,!1,a.advantageId);tools.dialog.hideDialog(b);packages.eventOrTimeslotPassChanged(h,
d,e,a.advantageId)}});tools.dialog.showDialog(b,!0,!1,function(){a.resetAvailabilityFilter(h)},"date_picker_popup")};this.setAvailableLanguages=function(a,b){var c={},d=[],f=0,e=!1;for(f in b)if(b.hasOwnProperty(f)){var g=b[f].performanceLanguageName;if(-1===$.inArray(g,d)){var h=packages.visitLanguages[g];c[g]=h;d.push(g)}}a=$(a).closest("div").find("select[class='language_selection']");b=a.val();a.find("option[value!='all']").remove();for(f in d)d.hasOwnProperty(f)&&(h=c[d[f]],g="",h===b&&(e=!0,
g='selected = "selected"'),$(a).append('<option value="'+h+'" '+g+">"+visitInLabel.replace("{0}",d[f])+"</option>"));e||(a.find("option[value='all']").prop("selected",!0),b="all");return b};this.getVisitPerformances=function(a,b,c,d,f){var e=a.parseDate(c),g=$("form").find("input[name='productId']").val(),h=$(b).closest(".package_line_container").find("input[name$='.packageLineId']").val(),l,k=$("#crossSellBaseProductId").val(),m=$("#crossSellId").val(),p=[],q,r=0;$.ajax({type:"GET",url:contextPath+
"/ajax/selection/package/visitPerformances",data:{packageProductId:g,advantageId:a.advantageId,packageLineId:h,ppid:k,crossSellId:m,year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()},success:function(e){q=$(b).siblings(".time_selection");packages.performancesForVisit[$(b).closest(".package_line_container").attr("id")]=e;$(b).find("input").val(e[0].performanceDate);l=packages.setAvailableLanguages(b,e);if("all"!==l)for(r in e)packages.visitLanguages[e[r].performanceLanguageName]===l&&p.push(e[r]);
else p=e;q=packages.updateComboOptions(q,p,f,!0,!1,a.advantageId);tools.dialog.hideDialog(d);packages.eventOrTimeslotPassChanged(q,f,c,a.advantageId)},error:function(){tools.dialog.hideDialog(d);tools.dialog.showDialog("ajaxErrorDialog",!0)}})};this.getTimeslots=function(a,b,c,d,f){var e=a.parseDate(c),g=$("form").find("input[name='productId']").val(),h=$("#crossSellBaseProductId").val(),l=$("#crossSellId").val(),k=$(b).closest(".package_line_container"),m=k.find("input[name$='.packageLineId']").val(),
p=k.find("input[name$='.packageLineQuantity']").val(),q,r=k.find("input[name$='.productType']").val();$.ajax({type:"GET",url:contextPath+"/ajax/selection/package/timeslots",data:{packageProductId:g,advantageId:a.advantageId,ppid:h,crossSellId:l,packageLineId:m,packageLineQuantity:p,year:e.getFullYear(),month:e.getMonth()+1,day:e.getDate()},success:function(e){q=$(b).closest(".package_line_performance_selector").find(".time_selection");$(b).find("input").val(e[0].startDate);q=packages.updateComboOptions(q,
e,f,!1,!0,a.advantageId);tools.dialog.hideDialog(d);packages.eventOrTimeslotPassChanged(q,f,c,a.advantageId);"VISIT_PASS"==r&&packages.getThemes(f)},error:function(){tools.dialog.hideDialog(d);tools.dialog.showDialog("ajaxErrorDialog",!0)}})};this.updateStagePreview=function(a,b,c){var d=$(a).closest(".package_line_container").find(".stage_preview img");a=$(a).closest(".package_line_container").find(".dialog-content img");$(d).attr("src",b.source);$(d).attr("width",b.width);$(d).attr("height",b.height);
$(a).attr("src",c.source);$(a).attr("width",c.width);$(a).attr("height",c.height)};this.updatePerformancePicture=function(a,b){a=$(a).closest(".package_line_container").find(".product img");$(a).attr("src",b.source);$(a).attr("width",b.width);$(a).attr("height",b.height)};this.events=$({});this.addParentChildRelationship=function(a,b,c,d){this.parentChildRelationship[a]||(this.parentChildRelationship[a]=[]);this.parentChildRelationship[a].push({packageLineId:b,lineProductId:c,lineNb:d})};this.addPackageLine=
function(a){this.packageLines.push(a)};this.getPackageLineByPackageLineId=function(a){var b;var c=0;for(b=packages.packageLines.length;c<b;c++){var d=packages.packageLines[c];if(d.packageLineId===a)return d}return null};this.getPackageLineByLineProductId=function(a){var b;var c=0;for(b=packages.packageLines.length;c<b;c++){var d=packages.packageLines[c];if(d.lineProductId===a)return d}return null};this.getPackageLineIdFromLineNumber=function(a){return parseInt($('[id="packageLines\\['+a+'\\].packageLineId"]').val(),
10)};this.hasParentLine=function(a){return"undefined"!==typeof a.parentLineId};this.getPackageLineTwinId=function(a){var b;if(!packages.hasParentLine(a))return null;var c=0;for(b=packages.parentChildRelationship[a.parentLineId].length;c<b;c++){var d=packages.parentChildRelationship[a.parentLineId][c];if(d.packageLineId!==a.packageLineId&&d.lineProductId===a.lineProductId)return d.packageLineId}return null};this.synchronizeSeatCatTwins=function(a,b){"undefined"!==typeof b&&(b=packages.getPackageLineByPackageLineId(b),
b=packages.getPackageLineTwinId(b),null!==b&&(b=packages.getPackageLineByPackageLineId(b).packageLineNb-1,$('[id^="packageLines'+(b+'.selectedSeatCategory"]')).each(function(b,d){a===$(this).val()&&($(this).prop("checked",!0),$(this).closest("tbody").find("select").prop("disabled",!0),$(this).attr("disabled")||$(this).closest("tr").find("select").prop("disabled",!1))})))};this.synchronizeItemTwins=function(a,b){b=packages.getPackageLineByPackageLineId(b);b=packages.getPackageLineTwinId(b);null!==
b&&(b=packages.getPackageLineByPackageLineId(b).packageLineNb-1,$('[id="packageLines'+(b+'.itemOrPerformanceId"] option[value="')+a+'"]').prop("selected",!0))};this.synchronizePerformanceTwins=function(a){var b=packages.getPackageLineByPackageLineId(a).packageLineNb-1;var c=$('[id="packageLines'+b+'.itemOrPerformanceId"]').val();if("undefined"!==typeof c)this.synchronizeItemTwins(c,a),this.synchronizeSeatCatTwins($('input[name="packageLines\\['+b+'\\].selectedSeatCategory"]:checked').val(),a);else{b=
$("#pl_"+a+' input[type="text"]').val();c=$("#pl_"+a+' select[class="language_selection"]').val();var d=$("#pl_"+a+' select[class="time_selection"]').val();var f=$("#pl_"+a+' select[class="language_selection"]').html();var e=$("#pl_"+a+' select[class="time_selection"]').html();a=packages.getPackageLineByPackageLineId(a);a=packages.getPackageLineTwinId(a);null!==a&&($("#pl_"+a+' select[class="language_selection"]').html(f),$("#pl_"+a+' select[class="time_selection"]').html(e),$("#pl_"+a+' input[type="text"]').val(b),
$("#pl_"+a+' select[class="language_selection"]').val(c),$("#pl_"+a+' select[class="time_selection"]').val(d))}};this.syncMultiLogicConfLines=function(){var a=$("#pl_"+packages.referencePackageLineId).find("input:radio:checked"),b=a.val(),c=packages.linesToSync,d={},f=0,e=0,g="",h="",l,k=0,m,p="",q=!1,r={};!a.length&&$("#pl_"+packages.referencePackageLineId).hasClass("package_line_container_VISIT")&&(a=$("#pl_"+packages.referencePackageLineId).find("input[name*='selectedSeatCategory']"),b=a.val());
$(".extended_availability_none").removeClass("extended_availability_none");for(f in c)if(c.hasOwnProperty(f))for(p in $("#pl_"+c[f]).find("input[name*='selectedSeatCategory']").each(function(){if("NONE"===$(this).closest("tr").attr("data-availability"))for(g in packages.mappingTable){if(packages.mappingTable.hasOwnProperty(g))for(h in packages.mappingTable[g].logicalSeatCatMapping)if(packages.mappingTable[g].logicalSeatCatMapping[h]===Number($(this).val()))for(l=$("#pl_"+packages.referencePackageLineId).hasClass("package_line_container_VISIT")?
$("#pl_"+packages.referencePackageLineId).find("input[name*='selectedSeatCategory']"):$("#pl_"+packages.referencePackageLineId).find("input:radio"),l=l.filter(function(){return $(this).val()===g||-1<$.inArray(Number($(this).val()),packages.mappingTable[g].logicalSeatCatMapping)}),e=0;e<l.length;e++)p=$(l[e]).attr("id"),r[p]=!1}else{q=!1;for(g in packages.mappingTable)if(packages.mappingTable.hasOwnProperty(g))for(h in packages.mappingTable[g].logicalSeatCatMapping)if(packages.mappingTable[g].logicalSeatCatMapping[h]===
Number($(this).val()))for(l=$("#pl_"+packages.referencePackageLineId).hasClass("package_line_container_VISIT")?$("#pl_"+packages.referencePackageLineId).find("input[name*='selectedSeatCategory']"):$("#pl_"+packages.referencePackageLineId).find("input:radio"),l=l.filter(function(){return $(this).val()===g||-1<$.inArray(Number($(this).val()),packages.mappingTable[g].logicalSeatCatMapping)}),e=0;e<l.length;e++)p=$(l[e]).attr("id"),r[p]=void 0===r[p]?!0:r[p]||!0,q="NONE"===$(l[e]).closest("tr").attr("data-availability")?
q||!1:!0;q?$(this).closest("tr").removeClass("availability_NONE"):$(this).closest("tr").addClass("availability_NONE")}if(packages.matchMappingTable(b,Number($(this).val()))){if(0===$(this).closest(".package_line_container").find(".package_line_optional_checkbox").length||$(this).closest(".package_line_container").find(".package_line_optional_checkbox input[type='checkbox']").is(":checked"))$(this).prop("disabled",!1),d[c[f]]||$(this).parents(".category").siblings(".area").find("select").prop("disabled",
!1);d[c[f]]||($(this).prop("checked",!0),d[c[f]]=!0)}else $(this).attr("disabled","disabled"),$(this).parents(".category").siblings(".area").find("select").attr("disabled","disabled")}),r)if(r.hasOwnProperty(p)&&(!1===r[p]?$('input[id="'+p+'"]').prop("disabled",!0):$('input[id="'+p+'"]').prop("disabled",!1)),r.hasOwnProperty(p)&&!1===r[p]){var t=$('input[id="'+p+'"]').closest("tr");if(0<t.length&&!t.hasClass("extended_availability_none")){t.addClass("extended_availability_none");for(k in packages.mappingTable[g].logicalSeatCatMapping)packages.mappingTable[g].logicalSeatCatMapping.has&&
(m=$("input:radio").filter(function(){return Number($(this).val())===packages.mappingTable[g].logicalSeatCatMapping[k]}).closest("tr")),m&&!m.hasClass("availability_NONE")&&m.addClass("extended_availability_none");"hidden"===a.css("visibility")&&(t=a.closest("#pl_"+packages.referencePackageLineId).find("input:radio").filter(function(){return"hidden"!==$(this).css("visibility")}).first(),t.prop("checked",!0),b=t.val(),this.parentSelectedSeatCatChanged=!0)}}a=packages.mappingTable[b];if(void 0===packages.mappingTable[b])for(h in packages.mappingTable)if(-1<
$.inArray(parseInt(b,10),packages.mappingTable[h].logicalSeatCatMapping)){a=packages.mappingTable[h];break}void 0===a?packages.modifyAvailabilityInQuantityTable("NONE"):($("input").filter(function(){return this.id.match(/packageQuantities\[\d+\].itemId/)}).val(a.packageItemId),$("input").filter(function(){return this.id.match(/packageQuantities\[\d+\].physicalSeatCategory/)}).val(a.institutionSeatCategoryId),packages.modifyAvailabilityInQuantityTable(a.availabilityLevel))};this.matchMappingTable=
function(a,b){var c=0,d;var f=packages.mappingTable[a];if(void 0===f)for(d in packages.mappingTable){if(packages.mappingTable.hasOwnProperty(d)&&(f=packages.mappingTable[d].logicalSeatCatMapping,-1<$.inArray(parseInt(a,10),f)&&-1<$.inArray(b,f)))return!0}else if(f=f.logicalSeatCatMapping,void 0!==f)for(c in f)if(f.hasOwnProperty(c)&&f[c]===b)return!0;return!1};this.registerAllowedSubCategory=function(a,b){this.allowedSubCategories.push({id:a,rank:b})};this.modifyAvailabilityInQuantityTable=function(a){var b=
"available",c="available",d=!0;switch(a){case "GOOD":c="limited";b="available";break;case "LIMITED":c="available";b="limited";break;case "NONE":d=!1}d?($("#quantity_table .availability_bullet").removeClass(c).addClass(b),$("#quantity_table .no_availability").hide(),$("#quantity_table .sufficient_availability").show()):($("#quantity_table .no_availability").show(),$("#quantity_table .sufficient_availability").hide())};this.disableWholeContainer=function(){$("#main_content_container input").attr("disabled",
!0);$("#main_content_container select").attr("disabled",!0);$("#main_content_container .datepicker_element").addClass("disabled");$("#main_content_container .button").addClass("disabled");$("#main_content_container .button a").unbind("click");$("#main_content_container .button a").attr("onclick","return false;");$("#main_content_container .alternative_button").addClass("disabled");$("#main_content_container .alternative_button a").unbind("click");$("#main_content_container .alternative_button").unbind("click");
$("#main_content_container .alternative_button a").attr("onclick","return false;");$("#ticketholders td.rate .alternative_button.delete").hide()};this.getThemes=function(a){var b,c,d=$("form").find('input[name="productId"]').val(),f=$("form").find('input[name="partnerAdvantageId"]').val(),e=$("#crossSellId").val(),g=$('input[name$="packageLines['+a+'].packageLineId"]').closest(".package_line_container"),h=g.find("input[name$='.packageLineId']").val(),l;var k=g.find(".time_selection");var m=g.find(".theme_selection");
k=k.is("select")?k.find("option:selected").val():k.find("input").val();$.ajax({type:"GET",url:contextPath+"/ajax/selection/package/themes",data:{selectedItem:k,packageProductId:d,advantageId:f,crossSellId:e,packageLineId:h},success:function(d){0<d.length?(0===m.length&&(b=c="packageLines["+a+"].themeAndLanguage",$("<select class='theme_selection'id='"+c+"' name='"+b+"'>").insertAfter(g.find(".time_selection"))),l=g.find(".theme_selection"),l=packages.updateThemesComboOptions(l,d),d=g.find(".package_line_optional_checkbox"),
d.length&&l.prop("disabled",!d.is(":checked"))):g.find(".theme_selection").remove()},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}})};this.updateThemesComboOptions=function(a,b){var c=0;var d=a.parent();if(1<b.length){if(a.is("select"))a.find("option").remove();else{c=a.find("input").attr("id");var f=a.find("input").attr("name");a.remove();$("<select class='theme_selection' id='"+c+"' name='"+f+"' onchange=''>").insertAfter(d.find(".time_selection"));
a=d.find(".theme_selection")}c=0;for(d=b.length;c<d;c++)if(b.hasOwnProperty(c)){var e=packages.buildDisplayedThemeAndLanguageInfo([b[c].themeName,b[c].languageName]);a.append("<option value='"+b[c].id+"'>"+e+"</option>")}$(a).children().first().prop("selected",!0)}else e=packages.buildDisplayedThemeAndLanguageInfo([b[c].themeName,b[c].languageName]),a.is("select")?(c=a.attr("id"),f=a.attr("name"),a.remove(),$("<span class='theme_selection'>"+e+"<input type='hidden' id='"+c+"' name='"+f+"' value='"+
b[0].id+"'></span>").insertAfter(d.find(".time_selection")),a=d.find(".theme_selection")):(c=a.find("input").attr("id"),f=a.find("input").attr("name"),a.html(e+"<input type='hidden' id='"+c+"' name='"+f+"' value='"+b[0].id+"'>"),a.toggleClass("single",!e));return a};this.buildDisplayedThemeAndLanguageInfo=function(a){return a.filter(function(a){return a}).join(" - ")};this.resetChildOptionalChoiceAfterParentSelecting=function(a){var b;var c=0;for(b=a.length;c<b;c++){var d=a[c];$(".package_line_container[id=pl_"+
d.packageLineId+"]").find(".package_line_optional_checkbox input[type='checkbox']").prop("checked",!1)}packages.toggleTotalPackageContent()}}packages=new NS_Packages;
tools.module("packages.dates",function(){var a={},b={},c={},d="",f=function(a){return(a=/\d*$/.exec(a))&&a.length?a[0]:"NO_ID"};return{DATE_CHANGE:"dateChange",setCurrentDate:function(b,c){d=f(c);a[d]=$.datepicker.parseDate(datePickerConfig.dateFormat,b);this.events.trigger(this.DATE_CHANGE)},setCurrentValidity:function(a,g,h){d=f(d);b[d]=$.datepicker.parseDate(datePickerConfig.dateFormat,a);c[d]=$.datepicker.parseDate(datePickerConfig.dateFormat,g);this.events.trigger(this.DATE_CHANGE)},getCurrentDate:function(b){return a[b]||
a[d]},getCurrentValidityFrom:function(a){return b[a]||b[d]},getCurrentValidityTo:function(a){return c[a]||c[d]},events:$({})}});
tools.module("packages.flatRate",function(){var a=[],b=null,c=null,d=null,f=null,e=null,g=null,h=null,l=function(b){var c=[],d;if(a&&b)for(d=0;d<a.length;d++){var e=a[d];var f=e.audienceSubCategory.minQuantity;var g=e.audienceSubCategory.maxQuantity;if(f>b)break;b<=g&&c.push(e)}return c},k=function(b){var c=null,d;if(a)for(d=0;d<a.length;d++){var e=a[d];if(b===e.audienceSubCategory.id){c=e;break}}return c},m=function(a,b,c,d){$(a).html(Mustache.render(b,c,d))},p=function(){$(".audience-subcat-desc").tipsy({className:"tipsy-advantage tipsy-hover tipsy-aud-subcat",
opacity:1,gravity:"s",html:!0,trigger:"hover",title:function(){return $(this).html().replace(/\n/g,"<br />")}});tools.makeTooltipAccessible(".audience-subcat-desc")},q=function(a){h&&h!==a.audienceSubCategory.id?($(g).wrapInner('<div style="display: block;" />'),$(g).find("div").fadeOut("600",function(){m(g,c,a);packages.updateTotalPrices();packages.toggleTotalPackageContent()})):(m(g,c,a),packages.updateTotalPrices(),packages.toggleTotalPackageContent());h=a.audienceSubCategory.id},r=function(a,
b){var c=$("<div/>",{"class":"audience-subcat-desc"}),d=$(a).siblings(".audience-subcat-desc"),e=$(a).siblings(".audience-subcat-requireAttachment");b&&b.audienceSubCategory.externalDescription?($(d).remove(),$(c).html(b.audienceSubCategory.externalDescription),$(a).after(c),p()):$(d).remove();b&&b.audienceSubCategory.requireAttachment?e.show():e.hide()},t=function(a){if(a){var b={};a&&(b=k(a.audienceSubCategory.id));q(b)}},w=function(a,b){var c={isAvailable:!1};0<b.length&&a&&$(b).find("option").each(function(b){if(a===
$(this).val())return c.isAvailable=!0,c.foundOption=$(this),!1});return c};return{init:function(){b=$("#packagesFlatRateTariffTpl").html();c=$("#packagesFlatRateUnitPriceTpl").html();f=$("#flat_rate_table");e=$(f).find(".flat_rate_selection_row .tariff");g=$(f).find(".flat_rate_selection_row .unit_price");d=$("#participants_number_text_field");d.on("input",function(){var a=parseInt($(this).val(),10),c=$("#addToCartButtonContainer"),d=!0,f=$(this).closest(".text_field_container"),g=$("#input_out_of_range"),
h=$("#vp_flat_rate_combo");h=0<$(h).length?$(h).val():null;a=l(a);0<a.length&&(d={},a&&0<a.length&&(1===a.length?(d=a[0],d.isSingleRate=!0):d.matchingRates=a),m(e,b,d),1===a.length?(t(a[0]),r($(".price_level_tariff"),a[0])):(d=$("#vp_flat_rate_combo"),h=w(h,d),0<d.length&&(h.isAvailable?$(h.foundOption).prop("selected",!0):d.selectedIndex=0,d.change())),d=!1);d||visitGroupDetails.hasInvalidFields()?$(c).addClass("disabled"):$(c).removeClass("disabled");$(f).toggleClass("error",d);$(g).toggle(d)});
d.trigger("input")},hasInvalidFields:function(){var a=$(d).val();return 0===l(a).length},onMatchingRatesComboChange:function(a){var b=$(a).val();b=k(b);var c=$(a).find("option:selected").hasClass("with_advantage");$(a).toggleClass("with_advantage",c);r(a,b);t(b)},addValidAudSubCatDatas:function(b){a.push(b)},clearValidAudSubCatDatas:function(){a=[]}}}());
tools.module("pagination",{update:function(a,b,c){tools.dialog.showWaitingPopup("loadingDialog",!0);jQuery.ajax({type:"GET",url:contextPath+b,cache:!!c,success:function(b){jQuery(a).closest(".content").html(b);tools.displayLazyImages();tools.triggerLazyImagesRefresh();tools.dialog.hideDialog("loadingDialog")},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}})},paginate:function(a,b){var c=[],d=b.page,f=b.displayWindow,e=b.nbPerPage,g=null;if(a.length>
e){g=Math.floor(a.length/e);g!==a.length/e&&g++;1>d?d=1:d>g&&(d=g);b.page=d;b=Math.max(1,Math.min(d-f,g-2*f));var h=Math.min(g,Math.max(d+f,b+2*f));for(f=b;f<=h;f++)c.push({index:f,selected:f===d});g={pages:c,hasPrevious:1!==d,hasNext:d!==g,remainBefore:1!==b,remainAfter:h!==g};a=a.splice((d-1)*e,e)}return{list:a,view:g}},updatePaginationWidget:function(a,b){b?($(a).show(),$(".page.previous",a).toggle(b.hasPrevious),$(".page.next",a).toggle(b.hasNext),$(".separator-before").toggleClass("remaining",
b.remainBefore),$(".separator-after").toggleClass("remaining",b.remainAfter),$(".page-link",a).remove(),b.pages.forEach(function(b){var c=$('<span class="page page-link"><a href="#">'+b.index+"</a></span>");c.data("page",b.index);b.selected&&c.addClass("current");$(".separator-after",a).before(c)})):$(a).hide()}});
var pass;function NS_pass(){this.passDatePickers=[];this.addPassDatePicker=function(a){this.passDatePickers.push(a)};$(function(){var a;for(a=0;a<pass.passDatePickers.length;a++)pass.passDatePickers[a].addClickListener()})}pass=new NS_pass;
function Pass(){this.datePickerDialog="#datePickerDialog";this.datePicker=void 0;this.isPackage=!1;this.productId=0;this.reservationIdx=this.crossSellId=this.baseProductId=this.advantageId=void 0;this.showAdvantageLegend=!1;this.packageLineId=0;this.calendarConfiguration=this.maxDate=void 0;this.updateUrl="/ajax/selection/pass/update";this.dateUpdateUrl="/ajax/selection/pass/range";this.trigger="#date_picker_trigger";this.container="#pass_selected_date";this.datePickerContainerDiv=".datepicker_content";
this.legendContainerDiv="#datePickerDialog .datepicker_legend";this.initDatePicker=function(){this.datePicker=new tools.date.DatePicker(this.calendarConfiguration,!0,!1);this.datePicker.isPackage=this.isPackage;this.datePicker.packageLineId=this.packageLineId;this.datePicker.productId=this.productId;this.datePicker.advantageId=this.advantageId;this.datePicker.baseProductId=this.baseProductId;this.datePicker.crossSellId=this.crossSellId;this.datePicker.legendType=this.datePicker.LEGEND_TYPE_RATE;this.datePicker.setMaxDate(this.maxDate);
this.datePicker.dateUpdateUrl=this.dateUpdateUrl;this.datePicker.legendContainer=this.legendContainerDiv;this.datePicker.showAdvantageLegend=this.showAdvantageLegend};this.addClickListener=function(){var a=this,b=$(this.trigger);0===b.length&&(b=$(this.trigger));b.click(function(){if($(a.trigger).hasClass("disabled"))return!1;a.datePicker.showDatePicker("#"+a.datePickerDialog+" "+a.datePickerContainerDiv,function(b,d){tools.date.toggleClassToday(a.trigger,new Date(d.selectedYear,d.selectedMonth,d.selectedDay));
tools.dialog.hideDialog(a.datePickerDialog);a.updateTable(b)});tools.dialog.showDialog(a.datePickerDialog,!0,!1,!1,"date_picker_popup");a.lastDate=$("#"+a.datePickerDialog).datepicker("getDate");return!1})};this.updateTable=function(a){var b=this.datePicker.parseDate(a),c=this;tools.dialog.showWaitingPopup("loadingDialog",!0);var d={productId:this.productId,advantageId:this.advantageId,ppid:this.baseProductId,crossSellId:this.crossSellId,reservationIdx:this.reservationIdx,year:b.getFullYear(),month:b.getMonth()+
1,day:b.getDate()};this.isPackage&&(d.packageLineId=this.packageLineId);$.ajax({type:"GET",url:contextPath+this.updateUrl,data:d,success:function(f){var e,g=[],h;if(c.isPackage){if(h=packages.parentChildRelationship[d.packageLineId])for(e=0;e<h.length;e++)childObject=h[e],packages.packageLinesToLoad.push({productId:d.productId,packageLineId:childObject.packageLineId,parentPackageLineId:d.packageLineId,lineNb:childObject.lineNb-1,parentItemOrPerformanceId:0,parentYear:b.getFullYear(),parentMonth:b.getMonth()+
1,parentDay:b.getDate()});packages.performNextStepInTableUpdate(d.productId,d.advantageId,null,g);e=$("#pl_"+c.packageLineId+" .table_container");if(0<e.length)packages.priceCatalog[e.find("table").attr("id")]=[],e.replaceWith(f);else{packages.priceCatalog.uc_table={};packages.priceCatalog[packages.dummyTablePrefix+"_"+c.packageLineId]={};if(h)for(e=0;e<h.length;e++)packages.priceCatalog[packages.dummyTablePrefix+"_"+h[e].packageLineId]={};$("#pl_"+c.packageLineId).append(f)}packages.updateTotalPrices()}else $(".legend").remove(),
$(".table_container").replaceWith(f);tools.triggerLazyImagesRefresh();$(c.trigger).find("input").val(a);c.isPackage&&packages.dates.setCurrentDate(a,c.packageLineId);tools.dialog.hideDialog("loadingDialog");c.lastDate=$("#"+c.datePickerDialog).datepicker("getDate");void 0!==audSubCatVerification&&"function"===typeof audSubCatVerification.init&&audSubCatVerification.init()},error:function(a){tools.dialog.hideDialog("loadingDialog");400===a.status?(tools.dialog.showDialog("plAvailabilityErrorDialog",
!0),$("#"+c.datePickerDialog).datepicker("setDate",c.lastDate)):tools.dialog.showDialog("ajaxErrorDialog",!0)}})}}
;tools.module("performanceSelectionSort",function(){return function(){var a=null,b=$("#performance_container .performances_container"),c={date:1,venue:1,minPrice:1,available:1},d=function(){a||(a=[],$(".performance, .group_sub_title","#performance_container").not(".header").each(function(){var b={id:$(this).attr("id")};$(this).data("date")&&(b.date=new Date($(this).data("date")));$("*",this).each(function(){$(this).data("date")&&(b.date=new Date($(this).data("date")));void 0!==$(this).data("min-price")&&
(b.minPrice=parseInt($(this).data("min-price"),10));void 0!==$(this).data("available")&&(b.available=parseInt($(this).data("available"),10));if($(this).hasClass("location")){var a=$(".space",this).html();var c=$(".site",this).html();b.venue=a+c}});a.push(b)}))},f=function(c,d){c.fadeTo("fast",0,function(){var e;var f=0;for(e=a.length;f<e;f++)c.append($("#"+a[f].id));d?$(".group_sub_title",b).show():$(".group_sub_title",b).hide();c.fadeTo("fast",1)})},e=function(e,h,l,k){d();a.sort(h);f(b,l);c[e]=
-c[e];e=1===c[e];$(".sort","#performance_container").removeClass("asc desc");e?$(k).addClass("asc"):$(k).addClass("desc")};$("#sort_on_date").on("click",function(a){a.preventDefault();e("date",function(a,b){var d=new Date(a.date),e=new Date(b.date),f=d.getMonth(),g=e.getMonth();return f===g&&void 0===a.available?-1:f===g&&void 0===b.available?1:d<e?c.date:-c.date},!0,this)});$("#sort_on_min_price").on("click",function(a){a.preventDefault();e("minPrice",function(a,b){return isNaN(a.minPrice)&&isNaN(b.minPrice)?
0:isNaN(a.minPrice)?1:isNaN(b.minPrice)?-1:c.minPrice*(b.minPrice-a.minPrice)},!1,this)});$("#sort_on_venue").on("click",function(a){a.preventDefault();e("venue",function(a,b){return a.hasOwnProperty("venue")?b.hasOwnProperty("venue")?a.venue<b.venue?c.venue:-c.venue:1:-1},!1,this)});$("#sort_on_available").on("click",function(a){a.preventDefault();e("available",function(a,b){return a.available||b.available?a.available?b.available?c.available*(b.available-a.available):-1:1:0},!1,this)})}});
tools.module("pesel",function(){return{needsPeselValidation:function(a){return"PL"==a},isValidPesel:function(a){var b=[1,3,7,9,1,3,7,9,1,3],c=0,d;a=jQuery.trim(a);if(!/^\d{11}$/.test(a))return!1;a=a.split("");for(d=0;11>d;d++)b[d]&&(c+=parseInt(a[d],10)*b[d]);return(10-c%10)%10==a[10]}}});
tools.module("postSellingListener",function(){return{init:function(a,b){var c=this;$(a+" [id^=main_content_suggestion] a").on("click",function(){var a=$(this).attr("href");/^(\/selection|\/secured\/selection|\/checkout\/summary)/.test(a)&&(a=!!a.includes("/checkout/summary"),c.checkOrderStateAndSetResumeFileValue($(this).attr("href"),b,a));return!1})},checkOrderStateAndSetResumeFileValue:function(a,b,c){var d=!1;tools.dialog.showWaitingPopup("loadingDialog",!0);$.ajax({type:"POST",url:contextPath+
"/ajax/checkout/setPreviousFileId",data:{fileId:b,createEmptyOrder:c},dataType:"json"}).done(function(){window.location.href=""+a}).fail(function(a,b){tools.dialog.hideDialog("loadingDialog");a.responseJSON&&"ERR_ORDER_NOT_CLOSE"===a.responseJSON.status?tools.dialog.showDialog("orderNotCompleted",!0,!0):tools.dialog.showDialog("ajaxErrorDialog",!0);d=!0});return!d}}});
tools.module("quickBooking",function(){var a=function(a,c,d){a=window.location.href.includes("checkout/crossSellingProducts");$.ajax({url:d,type:"GET",context:c,data:{isSeparatedCrossSellPage:a},success:function(a){$("#secondary_content_cart").replaceWith(a);$("#cart_size").text($(a).find("#hidden_cart_size")[0].innerText)},error:function(a,b){$("#crossSellAjaxErrorDialog .message").hide();$("#crossSellAjaxErrorDialog .generic").show();tools.dialog.showDialog("crossSellAjaxErrorDialog",!0)}})};return{externalOnSuccess:function(b,
c,d){a(b,c,d)}}});
var proceed2CheckoutFromCart={nextPageUriForcedByBuyerDelete:"",forceNextPageUri:function(a){nextPageUriForcedByBuyerDelete=String(a)},changeButtonState:function(a){$("#buyNowButton").toggleClass("disabled",!a.checked);$(".buy_order").toggleClass("disabled",!a.checked)},validateCartForReducedVisibilityAgrmnt:function(a,b,c,d,f,e){var g="undefined"!=typeof nextPageUriForcedByBuyerDelete&&""!==nextPageUriForcedByBuyerDelete?nextPageUriForcedByBuyerDelete:String(c);c=d+"/ajax/cart/reservation/visibilityConditionsAgreed";
var h=function(){"function"===typeof e?e():window.location=g};if(f||0===f)c+="?index="+f;b?a&&!$("#visibility_checkbox").is(":checked")?($("#reduced_visibility_terms_and_conditions_notification").show(),window.scrollTo(0,0)):$("#visibility_checkbox").is(":checked")?$.ajax({url:c,type:"POST",cache:!1,dataType:"json",contentType:"application/json",success:function(a,b,c){h()},error:function(a,b,c){tools.dialog.showDialog("ajaxErrorDialog",!0)}}):h():h()},updateMembershipStartValidity:function(a){var b=
a.data("productId"),c=function(a){a="dd"===datePickerConfig.dateFormat.split(".")[0]?new Date(a.split(".").reverse().join("-")):new Date(a);isNaN(a)&&(a=new Date);return $.datepicker.formatDate(datePickerConfig.dateFormat,a)}(a.val());$('input[name="startValidityDate"]').each(function(){$(this).data("productId")==b&&$(this).datepicker("setDate",c)});$.ajax({type:"POST",url:contextPath+"/ajax/cart/reservation/updateMembershipStartValidity",cache:!1,data:{productId:b,startValidity:c},success:function(a){},
error:function(){tools.dialog.showDialog("ajaxErrorDialog",!0)}})}};
function ReportGeneration(){var a=this;this.generateReport=function(b,c,d,f){b=$("#"+b);c=tools.setParameterToUrl(b.val(),"exportType",c,d);if(b.find(":selected").data("supportOrderDateFilter")||b.data("supportOrderDateFilter"))d=a.orderSaleStartSelector.val(),b=a.orderSaleEndSelector.val(),d&&(c=tools.setParameterToUrl(c,"fromDate",d)),b&&(c=tools.setParameterToUrl(c,"toDate",b));window.open(c,f)};this.handleMessageOrderDateIncompatible=function(a){var b=$(a).attr("id");a=$(a).find(":selected").data("supportOrderDateFilter")||
$(this).data("supportOrderDateFilter");$("[data-msg=orderDateIncompatible][data-id="+b+"]").attr("data-visible",!a)};this.handleOrderDateCompatible=function(){$('input[type="hidden"][id^="reportVariantSel"], select.reportVariantSel:not([id$="_byDate"])').each(function(b,c){a.handleMessageOrderDateIncompatible(c)});$('select.reportVariantSel:not([id$="_byDate"])').on("change",function(b){a.handleMessageOrderDateIncompatible(b.target)})};this.handleDateRangePicker=function(a,c,d){var b=$(a);var e=$(c);
var g=b.parent().find("label .alternative_button.filter_reset");var h=e.parent().find("label .alternative_button.filter_reset");var l=function(){var a=b.datepicker("getDate");g.toggle(null!==a);e.datepicker("option","minDate",a);d&&d(a)};var k=function(){var a=e.datepicker("getDate");h.toggle(null!==a);b.datepicker("option","maxDate",a);d&&d(a)};g.click(function(a){a.preventDefault();b.val("");l()});h.click(function(a){a.preventDefault();e.val("");k()});tools.date.makeDatePicker(a,{onSelect:l});tools.date.makeDatePicker(c,
{onSelect:k})};this.init=function(b){b=b||{};a.handleDateRangePicker("#dp_sales_start_date","#dp_sales_end_date",b.orderDateSelectFunction);a.handleDateRangePicker("#dp_product_start_date","#dp_product_end_date",b.productDateSelectFunction);a.orderSaleStartSelector=$("#dp_sales_start_date");a.orderSaleEndSelector=$("#dp_sales_end_date");a.productStartSelector=$("#dp_product_start_date");a.productEndSelector=$("#dp_product_end_date");a.reportByDateDPSelection=$("#report_by_date_section .datepicker");
a.reportByDateRangeSelection=$(".report_management.manage_product_date_range");a.handleOrderDateCompatible()}}
;(function(){var a=null,b=!0,c=[],d=function(){var b=a?a.delayAfter:null;if(b)return a.delayAfter=null,setTimeout(d,b);a=null;f()},f=function(){if(b&&!a&&c.length){var e=c.splice(0,1)[0];e.before&&e.before.call(e);a=e;var f=e.fail;f||(f=seasontickets.performances.errors.ajaxErrorDialog);var h=function(){e.xhr=jQuery.ajax({url:e.url,type:e.method,data:e.data}).fail(f).done(e.done).always(e.always).always(d)};e.delay?setTimeout(h,e.delay):h()}};tools.module("requestQueuing",{addRequest:function(a,b){b?
c.splice(0,0,a):c.push(a);f()},stop:function(){b=!1},start:function(){b=!0;f()}});jQuery(window).on("beforeunload",function(){a&&a.xhr&&(a.xhr.abort(),tools.dialog.showWaitingPopup("loadingDialog",!0))})})();
tools.module("resale.ajax",function(){var a=null,b,c=null,d=null,f=null;jQuery(window).on("beforeunload",function(){f&&f.abort()});return{init:function(){a=$.Callbacks();d=$.Callbacks();b=seasontickets.performances.errors;c=b.ajaxErrorDialog},onCatalogReady:function(b){a.add(b)},onTicketItemsReady:function(a){d.add(a)},loadCatalog:function(){f=$.ajax({url:contextPath+"/list/resale/resaleProductCatalog.json?",dataType:"json"}).done(function(b){a.fire(b)}).fail(c)},loadTicketItems:function(a,b,h){var e=
{};a?e.productId=a:b&&(e.performanceId=b);/[?&]lang=/.test(h)||(e.lang=$("html").attr("lang"));tools.dialog.showWaitingPopup("loadingDialog",!0);f=$.ajax({url:contextPath+h,data:e,dataType:"json"}).done(function(a){d.fire(a)}).fail(c)}}});
tools.module("resale.filter",function(){var a=$.Callbacks(),b=!1,c={},d=null,f=function(a,b){a.val()!==b&&(a.val(b),$(a).parent().find(".filterToolReset").show())},e=function(){b||(b=!0,a.fire({dateFrom:c.dateFrom.val(),dateTo:c.dateTo.val(),searchText:c.searchText.val(),topicKey:c.topic.val()}),b=!1)},g=function(){f(c.dateFrom,resale.history.getParam("dateFrom"));f(c.dateTo,resale.history.getParam("dateTo"));f(c.searchText,resale.history.getParam("searchText"));e()},h=function(){$(".filterToolReset").on("click",
function(){$(this).hide().parents(".criteria").find("input, select").val("");e()});$([c.dateFrom,c.dateTo,c.searchText,c.topic]).each(function(){$(this).parent().find(".filterToolReset").hide();$(this).change(function(){""!==$(this).val()?$(this).closest(".criteria").find(".filterToolReset").show():$(this).closest(".criteria").find(".filterToolReset").hide();e()})});$([c.dateFrom,c.dateTo]).each(function(){$(this).keydown(function(a){$(this).datepicker("hide");13===a.which&&(a.preventDefault(),$(this).trigger("change"))});
$(this).change(function(){var a=$(this);try{var b=$.datepicker.parseDate(datePickerConfig.dateFormat,c.dateFrom.val());var d=$.datepicker.parseDate(datePickerConfig.dateFormat,c.dateTo.val());null!==b&&null!==d&&b>d&&validation.showErrorTooltip(a,resale.messages.startDateEndDate)}catch(v){validation.showErrorTooltip(a,resale.messages.invalidDate),$(a).focus()}})});c.searchText.keyup(function(a){13===a.which&&a.preventDefault();resale.view.showSearchBoxSpinner();clearTimeout(d);resale.view.setFadeDuration(0);
d=setTimeout(e,1E3);""===$(this).val()?$(this).closest(".criteria").find(".filterToolReset").hide():$(this).closest(".criteria").find(".filterToolReset").show()})},l=function(a,b,c){if("OPEN_PASS"===a.productFamilySubType){if("PERIOD"!==a.validityRule)return!0;var d=tools.date.fromJodaDateTime(a.validTo);a=tools.date.fromJodaDateTime(a.validFrom);if((!b||b<=d)&&(!c||c>=a))return!0}else{if(!a.availablePerfDate||0===a.availablePerfDate.length)return!1;for(d=0;d<a.availablePerfDate.length;d++){var e=
tools.date.fromJodaDateTime(a.availablePerfDate[d]);if((null===b||b<=e)&&(null===c||e<=c))return!0}}return!1},k=function(a,b,c){var d=!1,e;if(""===c)d=!0;else if(0<b.topicIds.length)if(e=0<c.indexOf("-")){var f=c.substr(c.indexOf("-"));$.each(b.subTopicIds,function(b,e){if(0<=c.indexOf(a)&&0<=f.indexOf(e))return d=!0,!1})}else d=0<=a.indexOf(c)&&0<=b.topicIds.indexOf(c);else d=!1;return d},m=function(a,b){if(null===b||"undefined"===typeof b)return!0;var c=[decodeURIComponent(b).replace(/\W/g,"")];
for(b=0;b<c.length;b++){var d=a.name.replace(/\W/g,"");if(-1!==d.toLowerCase().indexOf(c[b].toLowerCase())||a.complement&&(d=a.complement.replace(/\W/g,""),-1!==d.toLowerCase().indexOf(c[b].toLowerCase())))return!0}return!1},p=function(){b=!0;g();b=!1},q=function(a,b){return $("<option></option>").val(a).html(b)},r=function(a,b,c,d){return{topicId:a,key:b,name:c,products:d,visible:0<d.length,showHeader:null!==c&&""!==c}},t=function(a){try{return $.datepicker.parseDate(datePickerConfig.dateFormat,
a),!0}catch(C){return!1}},w=function(a){a&&($([c.dateFrom,c.dateTo,c.topic]).each(function(){$(this).val("")}),resale.sliderFilter.reset(),$(c.dateFrom).trigger("change"),$(".filterToolReset").hide())},y=function(){var a=0<$(".filterToolReset:visible").length;$("#search_button").addClass("active");$("#filter_button").removeClass("active");$("#search_box_container").show();$("#filter_container").hide();""===c.searchText.val()?$(c.searchText).closest(".criteria").find(".filterToolReset").hide():$(c.searchText).closest(".criteria").find(".filterToolReset").show();
w(a);$(c.searchText).focus()},z=function(){$("#search_button").removeClass("active");$("#filter_button").addClass("active");$("#search_box_container").hide();$("#filter_container").show();""!==$(c.searchText).val()&&$(c.searchText).val("").trigger("change");$(c.topic).focus()},x=function(a){c.dateFrom=$("#date_from");c.dateTo=$("#date_to");c.searchText=$("#search_text");c.topic=$("#topic");c.dateFrom.placeholder();c.dateTo.placeholder();h();datePickerConfig.onSelect=function(){$(this).trigger("change")};
c.dateFrom.datepicker(datePickerConfig);c.dateTo.datepicker(datePickerConfig);$("#search_button").click(y);$("#filter_button").click(z);z()};return{init:function(){var a=$("#list_all_tickets");x(a);g();resale.history.onHistoryStateChange(p)},initTopics:function(a){var b;var d=0;for(b=a.length;d<b;d++)$("#topic").append(q(a[d].key,a[d].name));""!==resale.history.getParam("topicKey")&&c.topic.find("option").filter(function(){return $(this).val()===resale.history.getParam("topicKey")}).prop("selected",
!0)},doFilter:function(a,b){var d=null,e=null;null!==c.dateFrom.val()&&""!==c.dateFrom.val()&&t(c.dateFrom.val())&&(d=$.datepicker.parseDate(datePickerConfig.dateFormat,c.dateFrom.val()));null!==c.dateTo.val()&&""!==c.dateTo.val()&&t(c.dateTo.val())&&(e=$.datepicker.parseDate(datePickerConfig.dateFormat,c.dateTo.val()));null!==d&&null!==e&&d>e&&(e=d=null);var f=c.searchText.val();var g=c.topic.val();b.topicsWithProducts=[];b.products=[];var h=[];$.each(a,function(a,c){var p,q=$.grep(c.products,function(a,
b){b=l(a,d,e);var h=m(a,f);a=k(c.topicId,a,g);return b&&h&&a});a=0;for(p=q.length;a<p;a++){var u=q[a];var v=$.grep(h,function(a){return u.productId===a.productId});0===v.length&&h.push(u)}0<q.length&&b.topicsWithProducts.push(r(c.topicId,c.key,c.name,q))});b.products=h},doFilterAfterPagination:function(a){var b,c,d=[];for(b=0;b<a.topicsWithProducts.length;b++){var e=a.topicsWithProducts[b];var f=[];for(c=0;c<a.products.length;c++){var g=a.products[c];(0<=g.topicIds.indexOf(e.topicId)||!e.topicId&&
0===g.topicIds.length)&&f.push(g)}0<f.length&&d.push(r(e.topicId,e.key,e.name,f))}a.topicsWithProducts=d},onFilterChange:function(b){a.add(b)}}});
tools.module("resale.history",function(){var a=$.Callbacks(),b=!1,c={},d=!1,f=function(){var a={};var b=window.location.search.substring(1);if(""===b)return a;var c=b.split("&");for(b=0;b<c.length;b++){var d=c[b].split("=");a[decodeURIComponent(d[0])]=decodeURIComponent(d[1]).replace("+"," ")}return a};return{init:function(){c=f();resale.pagination.onPageChange(this.addParamToUrl);History.Adapter.bind(window,"statechange",function(){d||b||(b=!0,a.fire(),b=!1);d=!1})},getParam:function(a){a=(new RegExp("[\\?&]"+
a+"=([^&#]*)")).exec(window.location.href);return null!==a?a[1]:""},addParamToUrl:function(a){var e;c=$.extend(c,a);for(e in c)null!==c[e]&&""!==c[e]||delete c[e];d=!0;b||History.pushState(null,resale.messages.pageTitle,"?"+$.param(c))},onHistoryStateChange:function(b){a.add(b)}}});
tools.module("resale.itemGeneral",function(){var a,b=function(a,b){var c;for(c=0;c<a.length;c++){var d=a[c];if(b===d.companionTicketResaleId)return d}return null};return{SINGLE_ENTRY:"SINGLE_ENTRY",OPEN_PASS:"OPEN_PASS",OPEN_PASS_SHOW_VALIDITY:"OPEN_PASS_SHOW_VALIDITY",UNSPECIFIED_AREA_ID:"unknow",init:function(b){a=b},setTariff:function(a,b){b=a.pricesSelection[b];null!=a.pricesSelection&&a.pricesSelection.forEach(function(a){a.selected=!1});null!=a&&null!=b&&(a.audienceSubCategoryId=b.audienceSubCatId,
a.audienceSubCategory=b.audienceSubCatName,a.audienceSubCategoryRank=b.audienceSubCatRank,a.audienceCategoryKind=b.audienceCatKind,a.price=b.amount,a.isPriceEqualRealPrice=a.price===a.realPrice,b.selected=!0)},updatePrice:function(a,b){a.displayPrice=functions.generateAmount(b?a.price:a.priceWithCharge)},enhencingItems:function(c,d){var f,e;var g=[];for(f=0;f<c.length;f++){var h=c[f];h.companionKey=null;h.selectable=!0;h.frozen=!1;h.orderQuantity=0;h.availilities=[];d&&d.isTicketsGrouped&&(h.availilities.push({quantity:0,
selected:'selected="selected"'}),h.subTotal=functions.generateAmount(0));for(e=0===h.minQuantity?1:h.minQuantity;e<=h.quantity;e++)h.availilities.push({quantity:e});h.isPriceEqualRealPrice=h.price===h.realPrice;this.SINGLE_ENTRY===a&&(h.seatPath=h.block||h.remark?h.block+" - "+h.remark:" - ",e=$.map(h.resaleSeats,function(a,b){return a.seatId}),h.seatIdString=e.join(";"),h.areaId?h.isWithoutSeatTicket=!1:(h.isWithoutSeatTicket=!0,h.areaId=this.UNSPECIFIED_AREA_ID),h.showAudSubCatLine=h.audienceCategoryKind&&
("FULL"!==h.audienceCategoryKind||1!==h.audienceSubCategoryRank),d&&d.isTicketsGrouped&&(0>g.indexOf(h.seatCategoryId)?(g.push(h.seatCategoryId),h.hideSeatCat=!1,c[f-1]&&(c[f-1].lastInSeatCatGroup=!0)):h.hideSeatCat=!0,f==c.length-1&&(h.lastInSeatCatGroup=!0)));this.OPEN_PASS_SHOW_VALIDITY===a&&(h.showDateColumns=!0,h.startValidityDateString=$.datepicker.formatDate(datePickerConfig.dateFormatLong,tools.date.fromJodaDateTime(h.startValidityDate),datePickerConfig),h.endValidityDateString=$.datepicker.formatDate(datePickerConfig.dateFormatLong,
tools.date.fromJodaDateTime(h.endValidityDate),datePickerConfig));d&&d.isTicketsGrouped||(h.key=h.key+"__"+f);h.withCompanion&&null==h.companionTicketResaleId&&(e=b(c,h.ticketResaleId),null!=e&&(e.companionKey=h.key,h.selectable=!1));h.withoutCompanion=h.withoutCompanion||!1;d.seatRelease&&(this.setTariff(h,0),this.setPriceLevelId(h,0));h.displayPrice=functions.generateAmount(d.seatRelease?h.price:h.priceWithCharge);h.displayRealPrice=functions.generateAmount(h.realPrice)}},setPriceLevelId:function(a,
b){a.priceLevelId=$.isEmptyObject(a.pricesSelection)||a.pricesSelection.length<=b?null:a.pricesSelection[b].priceLevelId}}});
tools.module("resale.itemSorter",function(){var a=null,b,c,d=null,f=function(a,b,c){return a===b?0:(a>b?1:-1)*c};return{init:function(c){a=jQuery.Callbacks();b=c},updateModel:function(a){c=a;null!==d&&resale.itemSorter.doSort(d,!1)},getSortColumns:function(){return b},sortColumn:function(a,b,c,d,f,m){return{id:a,sortable:b,cssClass:c,linkCssClass:"sort",linkCssDirectionClass:"",sortFunction:d,sortDirection:f,text:m}},doSort:function(e,f){d=e;for(e=0;e<b.length;e++){var g=b[e];!1!==g.sortable&&(e===
d?(g.sortDirection.sorted=!0,!0===f&&(g.sortDirection.direction=-g.sortDirection.direction),g.linkCssDirectionClass=0<b[d].sortDirection.direction?"asc":"desc"):(g.sortDirection.sorted=!1,g.linkCssDirectionClass=""))}null!==c&&null!=b[d].sortFunction&&(c.sort(b[d].sortFunction),a.fire(c))},defaultSortDirection:function(){return{sorted:!1,direction:1}},zoneSortFunc:function(a,c,h,l){h=f(a.isWithoutSeatTicket?a.seatCatName:a.seatArea,c.isWithoutSeatTicket?c.seatCatName:c.seatArea,h||b[d].sortDirection.direction);
0!==h||l||(h=resale.itemSorter.subCategorySortFunc(a,c,1));0!==h||l||(h=resale.itemSorter.priceSortFunc(a,c,1));0!==h||l||(h=resale.itemSorter.seatPathSortFunc(a,c,1,!0));return h},subCategorySortFunc:function(a,c,h){return f(a.audienceSubCategory,c.audienceSubCategory,h||b[d].sortDirection.direction)},availabilitySortFunc:function(a,c){return(a.quantity-c.quantity)*b[d].sortDirection.direction},seatPathSortFunc:function(a,c,h,l){var e=h||b[d].sortDirection.direction;if(" - "===a.seatPath&&" - "===
c.seatPath)var g=0;else if(" - "===a.seatPath)g=1;else if(" - "===c.seatPath)g=-1;else{var p=a.seatPath.split(" - ");var q=c.seatPath.split(" - ");for(h=g=0;h<p.length;h++)if(!q[h]){g=1;break}else if(q[h]!==p[h]){g=isNaN(p[h])||isNaN(q[h])?f(p[h],q[h],1):Number(p[h])-Number(q[h]);break}}g*=e;0!==g||l||(g=resale.itemSorter.zoneSortFunc(a,c,1,!0));0!==g||l||(g=resale.itemSorter.priceSortFunc(a,c,1));return g},priceSortFunc:function(a,c,f){return(a.price-c.price)*(f||b[d].sortDirection.direction)},startValidityFunc:function(a,
c){a=tools.date.fromJodaDateTime(a.startValidityDate);c=tools.date.fromJodaDateTime(c.startValidityDate);return(a>c?1:-1)*b[d].sortDirection.direction},endValidityFunc:function(a,c){a=tools.date.fromJodaDateTime(a.endValidityDate);c=tools.date.fromJodaDateTime(c.endValidityDate);return(a>c?1:-1)*b[d].sortDirection.direction},registerSortCompletedCallback:function(b){a.add(b)}}});
tools.module("resale.itemView",function(){var a=null,b=null,c=null,d=null;return{init:function(){d=$.Callbacks();$(this);a=$("#itemsTpl").html();b=$("#itemTpl").html();c=$("#seatCategoriesTpl").html()},registerViewRenderedCallbacks:function(a){d.add(a)},render:function(c,e){e.html(Mustache.render(a,c,{itemTpl:b}));d.fire(e)},renderSeatCategory:function(a,b){b.html(Mustache.render(c,a))}}});
tools.module("resale.main",function(){var a=[],b={},c=jQuery.datepicker.formatDate,d=function(){var b={};0<a.length?(resale.filter.doFilter(a,b),resale.pagination.doPaginate(b),resale.filter.doFilterAfterPagination(b),0===b.products.length&&(b.searchResultEmpty=!0)):b.noTicketsOnSales=!0;var c=jQuery("#list_all_tickets");resale.view.render(b,c)};return{init:function(){resale.history.init();resale.filter.onFilterChange(resale.history.addParamToUrl);resale.ajax.init();resale.filter.init();resale.pagination.init("#list_all_tickets",
!0);resale.view.init();resale.ajax.onCatalogReady(function(b){jQuery("#loading_mark").hide();var e=null,f=null,h,l;a=b.topicWithProductsList;for(h=0;h<a.length;h++){var k=a[h];for(l=0;l<k.products.length;l++){var m=k.products[l];var p=m;if(0<p.firstPerformanceDate.length){var q=tools.date.fromJodaDateTime(p.firstPerformanceDate);p.firstPerformanceDate=c(datePickerConfig.dateFormatLong,q,datePickerConfig)}0<p.lastPerformanceDate.length&&(q=tools.date.fromJodaDateTime(p.lastPerformanceDate),p.lastPerformanceDate=
c(datePickerConfig.dateFormatLong,q,datePickerConfig));0<p.validFrom.length&&(q=tools.date.fromJodaDateTime(p.validFrom),p.validFromString=c(datePickerConfig.dateFormatLong,q,datePickerConfig));0<p.validTo.length&&(q=tools.date.fromJodaDateTime(p.validTo),p.validToString=c(datePickerConfig.dateFormatLong,q,datePickerConfig));m.displayMinPrice=functions.generateAmount(m.minPrice);m.singleDatePerformace=m.firstPerformanceDate&&m.lastPerformanceDate&&m.firstPerformanceDate===m.lastPerformanceDate;m.showPassValidity=
"OPEN_PASS"===m.productFamilySubType&&"PERIOD"===m.validityRule;m.singleDatePass=m.validFromString&&m.validToString&&m.validFromString===m.validToString;m.displayPrice=0<m.availableQuantity;m.productFamilyEvent=-1<jQuery.inArray(m.productFamilySubType,["SIMPLE_TICKET","SPORTING_EVENT"]);m.productFamilyNonDatedPass="OPEN_PASS"===m.productFamilySubType}}resale.filter.initTopics(b.topics);b=0;for(l=a.length;b<l;b++)for(k=a[b],h=0;h<k.products.length;h++){m=k.products[h];if(null===e||e>m.minPrice)e=m.minPrice;
if(null===f||f<m.minPrice)f=m.minPrice}d();tools.triggerLazyImagesRefresh()});resale.filter.onFilterChange(d);resale.pagination.onPageChange(d);resale.ajax.loadCatalog()},pushParam:function(a,c){null===c||""===c?delete b[a]:b[a]=c}}});
tools.module("resale.openPass.item",function(){var a=[],b={},c=[],d,f,e,g,h=!1,l={products:null,totalItems:0,totalItemsText:"",totalPrice:0,totalPriceText:functions.generateAmount(0)},k=function(){var a;l.products=c;var b=0;for(a=l.products.length;b<a;b++)l.products[b].odd=0===b%2;resale.pagination.doPaginate(l);l.sortColumns=resale.itemSorter.getSortColumns();b=$("#list_open_pass_ticket_items");resale.itemView.render(l,b)},m=function(b,c){var e,g=null,k=null;c=0;for(e=a.length;c<e;c++){var l=a[c];
l=h?l.price:l.priceWithCharge;if(null===g||g>l)g=l;if(null===k||k<l)k=l}$("#item_price_filter").parents(".criteria").find(".filterToolReset").hide().on("click",function(){$(this).hide();resale.sliderFilter.reset();resale.openPass.item.doFilter({minPrice:g,maxPrice:k,dateFrom:d,dateTo:f})});null!==g&&null!==k&&(resale.sliderFilter.init("#item_price_filter",g,k),resale.sliderFilter.registerSlideCallback(function(a,b){a===g&&b===k||$("#item_price_filter").parents(".criteria").find(".filterToolReset").show();
resale.openPass.item.doFilter({minPrice:a,maxPrice:b,dateFrom:d,dateTo:f})}));g===k&&(b?$("#item_price_filter_container").hide():$("#item_filters").hide())},p=function(a){try{return $.datepicker.parseDate(datePickerConfig.dateFormat,a),!0}catch(u){return!1}},q=function(a){var b=resale.itemSorter.getSortColumns(),c=b.find(function(a){return"sort_on_audience_subCat"===a.id});b=b.find(function(a){return"sort_on_price"===a.id});a.seatRelease&&(r(c),r(b))},r=function(a){a.sortable=!1;a.sortFunction=null;
a.sortDirection=null;a.linkCssClass="no_hover_styling"},t=function(a){c=a;k()},w=function(a){var b=$("#list_open_pass_ticket_items");a?(b.find("input, a").attr("disabled","disabled"),$("#addOtherProducts, #book").attr("disabled","disabled")):(b.find("input, select").prop("disabled",!1),b.find("a").removeAttr("disabled"),$("#addOtherProducts, #book").removeAttr("disabled"))},y=function(){var b;l.totalItems=0;var c=l.totalPrice=0;for(b=a.length;c<b;c++){var d=a[c];0<d.orderQuantity&&(l.totalItems+=
d.orderQuantity,l.totalPrice+=d.orderQuantity*(h?d.price:d.priceWithCharge))}0===l.totalItems?l.totalItemsText="":1===l.totalItems?l.totalItemsText=resale.messages.singularTicket:(l.totalItemsText=resale.messages.pluralTickets,l.totalItemsText=l.totalItemsText.replace("{0}",l.totalItems));l.totalPriceText=functions.generateAmount(l.totalPrice)},z=function(b,c){var d;var e=0;for(d=a.length;e<d;e++){var f=a[e];if(f.key===b){f.orderQuantity=c;f.frozen=0<c;break}}y()},x=function(a,b){var c=$('<input type="hidden"></input>');
c.attr("id",a).attr("name",a);c.val(b);return c},A=function(a){$("#sort_on_audience_subCat").on("click",function(a){a.preventDefault();a.stopImmediatePropagation();resale.itemSorter.doSort(0,!0)});a&&($("#sort_on_valid_from").on("click",function(a){a.preventDefault();a.stopImmediatePropagation();resale.itemSorter.doSort(1,!0)}),$("#sort_on_valid_to").on("click",function(a){a.preventDefault();a.stopImmediatePropagation();resale.itemSorter.doSort(2,!0)}));$("#sort_on_price").on("click",function(b){b.preventDefault();
b.stopImmediatePropagation();resale.itemSorter.doSort(a?3:1,!0)})};return{init:function(b,d,e){resale.history.init();l.showDateColumns=e;resale.itemGeneral.init(e?resale.itemGeneral.OPEN_PASS_SHOW_VALIDITY:resale.itemGeneral.OPEN_PASS);resale.ajax.init();resale.pagination.init("#list_open_pass_ticket_items",!1);resale.pagination.setPaginationConfiguration({page:1,displayWindow:2,nbPerPage:d});resale.pagination.updatePageNumberFromUrl();resale.itemView.init();resale.itemView.registerViewRenderedCallbacks(function(a){A(e)});
resale.ajax.onTicketItemsReady(function(b){tools.dialog.hideDialog("loadingDialog");a=b.resaleItems;h=b.seatRelease;resale.itemGeneral.enhencingItems(a,{seatRelease:b.seatRelease});c=a;resale.itemSorter.updateModel(c);m(e,h);e&&resale.validityFilter.updateFilterValuesFromUrl();0>=a.length&&($("#controls").hide(),$("#list_open_pass_ticket_items").hide(),$("#no_ticket_on_sale").show());q(b);k()});resale.pagination.onPageChange(k);d=[];d.push(resale.itemSorter.sortColumn("sort_on_audience_subCat",!0,
"tariff",resale.itemSorter.subCategorySortFunc,resale.itemSorter.defaultSortDirection(),resale.messages.headers.subCategory));e&&(d.push(resale.itemSorter.sortColumn("sort_on_valid_from",!0,"valid_from",resale.itemSorter.startValidityFunc,resale.itemSorter.defaultSortDirection(),resale.messages.headers.validFrom)),d.push(resale.itemSorter.sortColumn("sort_on_valid_to",!0,"valid_to",resale.itemSorter.endValidityFunc,resale.itemSorter.defaultSortDirection(),resale.messages.headers.validTo)));d.push(resale.itemSorter.sortColumn("sort_on_price",
!0,"unit_price",resale.itemSorter.priceSortFunc,resale.itemSorter.defaultSortDirection(),resale.messages.headers.price));d.push(resale.itemSorter.sortColumn("sort_on_action",!1,"",null,null,""));resale.itemSorter.init(d);resale.itemSorter.registerSortCompletedCallback(t);resale.ajax.loadTicketItems(b,null,"/selection/resale/passResaleItems.json")},pushParam:function(a,c){null===c||""===c?delete b[a]:b[a]=c},selectItem:function(a,b,c){if("disabled"==$(c).attr("disabled"))return!1;c=$(c).closest("tr").find(".hidden-quantity select");
var d=""===c.val()?0:Number(c.val());if(0>=d||d>b)return c.addClass("error"),!1;z(a,d);k();$("#notification").addClass("hidden")},unselectItem:function(a,b){z(a,0);k()},toggleItem:function(a,b){$(b).hasClass("selected")?this.unselectItem(a,$("#"+a).find("a")):this.selectItem(a,1,$("#"+a).find("a"))},updateAfterTariffChanged:function(b,c){c=$(c).prop("selectedIndex");a:{var d;var e=0;for(d=a.length;e<d;e++){var f=a[e];if(f.key===b){b=f;break a}}b=null}resale.itemGeneral.setTariff(b,c);resale.itemGeneral.setPriceLevelId(b,
c);resale.itemGeneral.updatePrice(b,h);y();k()},updateOrderQuantity:function(a,b,c){!0===c&&(a=Number($(a).val()),z(b,a),k())},addToCart:function(b){var c,d=0;w(!0);b=$(b).parents("form:first");var e=0;for(c=a.length;e<c;e++){var f=a[e];if(0<f.orderQuantity){var g=b,h=d++;var k=x("resaleItemData["+h+"].audienceSubCategoryId",f.audienceSubCategoryId);var l=x("resaleItemData["+h+"].itemId",f.itemId);var m=x("resaleItemData["+h+"].quantity",f.orderQuantity);var p=x("resaleItemData["+h+"].unitAmount",
f.price);var q=x("resaleItemData["+h+"].priceLevelId",f.priceLevelId);g.append(k);g.append(l);g.append(m);g.append(p);g.append(q);for(q=0;q<f.movementIds.length;q++)g.append(x("resaleItemData["+h+"].movementIds["+q+"]",f.movementIds[q]))}}0===d?($("#notification.hidden").removeClass("hidden"),w(!1)):b.submit()},getTickets:function(){return a},doFilter:function(b){var h,l=null,m=null;null!==b.dateFrom&&""!==b.dateFrom&&p(b.dateFrom)&&(l=$.datepicker.parseDate(datePickerConfig.dateFormat,b.dateFrom));
null!==b.dateTo&&""!==b.dateTo&&p(b.dateTo)&&(m=$.datepicker.parseDate(datePickerConfig.dateFormat,b.dateTo));null!==l&&null!==m&&l>m?m=l=null:(d=b.dateFrom,f=b.dateTo);b.minPrice&&(e=b.minPrice);b.maxPrice&&(g=b.maxPrice);c=[];b=0;for(h=a.length;b<h;b++){var q=a[b];var r=q;var t=l,x=m;var A=tools.date.fromJodaDateTime(r.startValidityDate);r=tools.date.fromJodaDateTime(r.endValidityDate);A=(!t||t<=r)&&(!x||x>=A)?!0:!1;A&&(A=(!e||q.price>=e)&&(!g||q.price<=g)?!0:!1);A&&c.push(q)}resale.itemSorter.updateModel(c);
k()}}});
tools.module("resale.validityFilter",function(){var a=!1,b=$.Callbacks(),c,d,f,e,g,h,l,k,m=function(){a||(a=!0,b.fire({dateFrom:c.val(),dateTo:g.val()}),a=!1)},p=function(a,b){b.on("click",function(){$(this).hide();a.val("");m()});b.hide();a.change(function(){""!==$(this).val()?b.show():b.hide();a:{var a=$(this);try{var d=$.datepicker.parseDate(datePickerConfig.dateFormat,c.val());var e=$.datepicker.parseDate(datePickerConfig.dateFormat,g.val());if(null!==d&&null!==e&&d>e){validation.showErrorTooltip(a,
resale.messages.startDateEndDate);var f=!1;break a}}catch(C){validation.showErrorTooltip(a,resale.messages.invalidDate);$(a).focus();f=!1;break a}f=!0}f&&m()});a.keydown(function(a){$(this).datepicker("hide");13===a.which&&(a.preventDefault(),$(this).trigger("change"))})},q=function(){var a=c,b=d,f=resale.history.getParam(e);a.val()!==f&&(a.val(f),b.show());a=g;b=h;f=resale.history.getParam(k);a.val()!==f&&(a.val(f),b.show());m()},r=function(){a=!0;q();a=!1};return{init:function(a){resale.validityFilter.onFilterChange(resale.history.addParamToUrl);
resale.validityFilter.onFilterChange(resale.openPass.item.doFilter);resale.history.onHistoryStateChange(r);f=a.validFromId;e=a.validFromParam;l=a.validToId;k=a.validToParam;c=$("#"+f);c.placeholder();d=$("#"+f+"_filterToolReset");g=$("#"+l);g.placeholder();h=$("#"+l+"_filterToolReset");p(c,d);p(g,h);datePickerConfig.onSelect=function(){$(this).trigger("change")};c.datepicker(datePickerConfig);g.datepicker(datePickerConfig)},updateFilterValuesFromUrl:q,onFilterChange:function(a){b.add(a)}}});
tools.module("resale.pagination",function(){var a={page:1,displayWindow:4,nbPerPage:5},b=$.Callbacks(),c=function(c){a.page!==c&&(a.page=c,b.fire({page:1===a.page?null:a.page}))},d=function(b){b.on("click",".pagination .page",function(b){var d=$(this);d.hasClass("current")||(d.hasClass("previous")?c(a.page-1):d.hasClass("next")?c(a.page+1):c(parseInt(d.text(),10)));b.preventDefault()})};return{init:function(a,b){this.updatePageNumberFromUrl();a=$(a);d(a);if(b)resale.filter.onFilterChange(function(){c(1)});
resale.history.onHistoryStateChange(this.updatePageNumberFromUrl)},goToPage:function(a){c(a)},setPaginationConfiguration:function(b){a=b},updatePageNumberFromUrl:function(){var a=resale.history.getParam("page");a=null===a||""===a?1:parseInt(a,10);c(a)},onPageChange:function(a){b.add(a)},doPaginate:function(b){var c=[],d=a.page,f=a.displayWindow,l=a.nbPerPage;if(b.products.length>l){var k=Math.floor(b.products.length/l);k!==b.products.length/l&&k++;1>d?d=1:d>k&&(d=k);a.page=d;var m=Math.max(1,Math.min(d-
f,k-2*f));var p=Math.min(k,Math.max(d+f,m+2*f));for(f=m;f<=p;f++)c.push({index:f,selected:f===d});c={nbPages:k,page:d,pages:c,hasPages:0!==c.length,hasPrevious:1!==d,hasNext:d!==k,remainBefore:1!==m,remainAfter:p!==k};d=(d-1)*l;b.products=b.products.slice(d,d+l)}else c={nbPages:0<b.products.length?1:0,pages:[],hasPages:!1};b.pagination=c}}});
tools.module("resale.resell",function(){var a,b,c,d=!1,f=null,e,g,h,l,k,m,p=function(a){var b=a.indexOf("."),c=0;-1!==b&&(c=Math.min(a.length-b-1,secutixAmountDecimalSize),a=a.substring(0,b)+a.substring(b+1,b+1+c));for(b=c;b<secutixAmountDecimalSize;b++)a+="0";return parseInt(a,10)},q=function(){if($("#useExistingBankAccount").is(":checked"))return!0;var a=0<$("#resale_criteria").length?!$("#useBankAccount").is(":checked")||account.register.checkSwitfField(!1,!0)&&account.register.checkIbanField(!1,
!0):!0,b=0<$("#field_ibanNumber").length?r():!0,c=0<$("#field_bicNumber").length?t():!0;return a&&b&&c},r=function(){if(!$("#useBankAccount").is(":checked"))return!0;if(0<$("#field_ibanNumber").length)if($(h).parent().removeClass("error"),$(h)&&0!==$.trim($(h).val()).length){var a=ibanTools.electronicFormatIBAN($(h).val());(a=ibanTools.isValidIBAN(a))||w($(h),account.register.ibanNumberErrorFormat)}else w($(h),account.register.ibanEmptyError),a=!1;else a=!0;return a},t=function(){if(!$("#useBankAccount").is(":checked"))return!0;
var a;0<$("#field_bicNumber").length?($(l).parent().removeClass("error"),$(l)&&0!==$.trim($(l).val()).length?(a=ibanTools.isValidBIC($(l).val().toUpperCase()))||w($(l),account.register.bicNumberErrorFormat):(w($(l),account.register.bicEmptyError),a=!1)):a=!0;return a},w=function(a,b){a.parent().addClass("error");account.register.showTooltipErrorMessage(a,b)},y=function(a){var b="1";if(!c)return 0;if(c.constant)return c.constant;if(c.slope){a*=c.slope;if(c.ceiling&&a>c.ceiling)return c.ceiling;if(c.floor&&
a<c.floor)return c.floor;for(var d=1;d<=secutixAmountDecimalSize;d++)b+="0";return(a/parseInt(b)).toFixed(currencyFractionDigit)*b}return 0},z=function(a,b){var c=functions.getMantissaFromAmount(b.toString());$.isNumeric(c)||(c="00");a.val(functions.getIntPartFromAmount(b.toString())+(""!==c?amountDecimalSeaparator+c:""))};return{typingTimer:null,init:function(f,p,y,u,v,w,E,F){var B=$('input[id*="contactCriteria[BANKSWIF]"]'),x=$('input[id*="contactCriteria[ACCNUMB]"]');h="#ibanNumber";l="#bicNumber";
d=w;b=p;k=E;m=F;k&&$('input[id^="resale_price_input_"]').each(function(a,b){$(b).blur(function(){resale.resell.formFieldsChanged(!0)}).keydown(function(){clearTimeout(resale.resell.typingTimer)}).keyup(function(a){13!=a.which&&(resale.resell.typingTimer=setTimeout(resale.resell.formFieldsChanged,1E3))});a=$(b).attr("id").replace("resale_price_input_","");a=parseInt($("#purchase_price_"+a).val());z($(b),a)});$(B).blur(function(){account.register.checkSwitfField(!1,!0);account.register.checkIbanField(!1,
!0);resale.resell.formFieldsChanged(!0)}).keydown(function(){account.register.checkSwitfField(!1,!0)}).keyup(function(a){account.register.checkSwitfField(!1,!0)});$(x).blur(function(){account.register.checkIbanField(!1,!0);account.register.checkSwitfField(!1,!0);resale.resell.formFieldsChanged(!0)}).keydown(function(){account.register.checkIbanField(!1,!0)}).keyup(function(a){account.register.checkIbanField(!1,!0)});$(h).blur(function(){$(h).val($(h).val().toUpperCase());r();resale.resell.formFieldsChanged(!0)});
$(l).blur(function(){$(l).val($(l).val().toUpperCase());t();resale.resell.formFieldsChanged(!0)});a=f;c=y?y:null;e=u;g=v;$("#useBankAccount").change(function(){$("#resale_criteria").toggleClass("hidden",!$(this).is(":checked"));$("#resale_bank_account").toggleClass("hidden",!$(this).is(":checked"));resale.resell.formFieldsChanged(!0)});$("#resale_criteria").toggleClass("hidden",!$("#useBankAccount").is(":checked"));$("#resale_bank_account").toggleClass("hidden",!$("#useBankAccount").is(":checked"));
$("#conditionsAccepted").change(function(){resale.resell.formFieldsChanged(!0)});$("#submitButton").click(function(){resale.resell.validateAllPrices(!1)&&resale.resell.validateConditionsCheckbox(!0)&&q()&&$("#resell_tickets_form").submit();return!1});$("#resell_tickets_form").submit(function(){return resale.resell.validateAllPrices(!1)&&resale.resell.validateConditionsCheckbox(!0)&&q()});account.bankAccount.addUseExistingBankAccountCheckboxEvent();this.writeTicket()},formFieldsChanged:function(a){var b=
$("#submitButton");a=resale.resell.validateAllPrices(a||!1)&&resale.resell.validateConditionsCheckbox(!1)&&q();clearTimeout(resale.resell.typingTimer);a?b.removeClass("disabled"):b.addClass("disabled");return a},validateAllPrices:function(a){var b=this;$("#nonIntUnitPriceError").hide();$("#amountOutOfBounds").hide();$("#noAmount").hide();$("#amountLessThanFee").hide();var c=-1===$.map($('input[id^="resale_price_input_"]'),function(c){return b.validateRowPrice($(c),a,!0)}).indexOf(!1);c?resale.resell.writeTicket():
resale.resell.closeTicket();return c},validateRowPrice:function(a,c,f){a.parent().removeClass("error");var h=$(a).attr("id").replace("resale_price_input_","");var k={noAmount:$("#resale_price_error_tooltip_no_amount_"+h),nonInt:$("#resale_price_error_tooltip_non_int_"+h),outOfBounds:$("#resale_price_error_tooltip_out_of_bounds_"+h)};Object.values(k).forEach(function(a){return a.hide()});var l=a.val().replace(new RegExp("\\"+priceSeparator,"g"),"");if(0===l.length)return f&&(a.parent().addClass("error"),
k.noAmount.show()),resale.resell.closeTicket(),!1;f=l.replace(amountDecimalSeaparator,".");if(!$.isNumeric(f)||10<f.length)return a.parent().addClass("error"),k.nonInt.show(),resale.resell.closeTicket(),!1;f=p(f);d||0!==f%currencyMinimumAmount&&(f=currencyMinimumAmount*Math.floor(f/currencyMinimumAmount));c&&z(a,f);if(f<parseInt(b[h].minPrice,10)||f>parseInt(b[h].maxPrice,10))return a.parent().addClass("error"),k.outOfBounds.show(),resale.resell.closeTicket(),!1;$("#resale_price_td_"+h).find('input[id^="resellTicketRowDataMap"]').val(f);
a=parseInt($("#number_tickets_"+h).val());"SEAT"===m&&(f=$("#purchase_price_"+h).val());$("#subtotal_amount_"+h).html(this.generateAmount(f*a,e,g));$("#subtotal_input_"+h).val(f*a);this.writeTicket();return!0},calculateTotalResellerFeeAmount:function(){var a=0;$('td[id^="subtotal_amount_"]').each(function(b,c){c=$(c).attr("id").replace("subtotal_amount_","");b=parseInt($("#number_tickets_"+c).val());c="SEAT"===m?parseInt($("#purchase_price_"+c).val()):parseInt($("#resale_price_td_"+c+" > input").val());
a+=y(c)*b});return a},writeTicket:function(){var b=0,c=$("#resale_summary"),d=$("#main_content_resale_parameters");$('input[id^="subtotal_input_"]').each(function(a,c){a=parseInt($(c).val().replace(new RegExp("\\"+priceSeparator,"g"),""));b+=a});$("#total_all_tickets").html(this.generateAmount(b,e,g));var h=this.calculateTotalResellerFeeAmount();h>b*a&&$("#amountLessThanFee").show();var k=resale.resell.generateAmount(b-h,e,g);$("#you_will_receive_amount_top_amount").html(k);$("#summary_subtotal_price_amount").html(resale.resell.generateAmount(b,
e,g));$("#summary_total_price_amount").html(k);$("#summary_reseller_fee_amount").html(resale.resell.generateAmount(h,e,g));$("#amountPrice").val(k);if(null===f||f!=b)resale.resell.closeTicket(),c.clone().attr("id","resale_summary_clone").css({width:c.width()+"px",height:"auto"}).appendTo($("#resale_summary_container")),h=$("#resale_summary_clone").height(),$("#resale_summary_clone").remove(),isNewTicketShop?c.css({height:"auto"}):c.css({height:h+"px"}),d.addClass("summary_displayed"),f=b},generateAmount:function(a,
b,c){var d="";if(void 0!==a&&null!==a){a=a.toString();a.includes(".")&&(a=a.substring(0,a.lastIndexOf(".")));var e=functions.getMantissaFromAmount(a);e===zeroCentLabel&&(d="zeroCentMantissa");a='<span class="int_part">'+functions.getIntPartFromAmount(a)+"</span>";e='<span class="mantissa '+d+'">'+e+"</span>";b='<span class="currency currency_code">'+b||currencyCode+"</span>";c='<span class="currency currency_symbol">'+c||currencySymbol+"</span>";d='<span class="decimal_separator '+d+'">'+amountDecimalSeaparator+
"</span>";var f=amountFormat;f=f.replace("{amountIntPart}",a);f=f.replace("{amountMantissa}",e);f=f.replace("{currencyCode}",b);f=f.replace("{currencySymbol}",c);return f=f.replace("{decimalSeparator}",d)}},validateConditionsCheckbox:function(a){var b=$("#conditionsAccepted"),c=b.is(":checked");c?(b.parent().removeClass("error"),$("#conditionsCheckboxUnchecked").hide()):a&&(b.parent().addClass("error"),$("#conditionsCheckboxUnchecked").show());return c},closeTicket:function(){var a=$("#resale_summary"),
b=$("#main_content_resale_parameters");b.hasClass("summary_displayed")&&(a.css({height:"0"}),b.removeClass("summary_displayed"),f=null)}}});
tools.module("resale.singleEntry.item",function(){var a=[],b=!1,c={},d=[],f={products:null,totalItems:0,totalItemsText:"",totalPrice:0,totalPriceText:functions.generateAmount(0)},e=[],g=[],h=[],l=function(){f.products=d;var a=[];var b;if(0<g.length||0<h.length){var c=0;for(b=f.products.length;c<b;c++){var e=null===f.products[c].blockId?f.products[c].areaId.toString():f.products[c].blockId.toString();var k=f.products[c].seatCategoryId.toString();(0<g.length&&-1<$.inArray(e,g)||0<h.length&&-1<$.inArray(k,
h))&&a.push(f.products[c])}f.products=a}a=0;for(e=f.products.length;a<e;a++)f.products[a].odd=0===a%2;resale.pagination.doPaginate(f);f.sortColumns=resale.itemSorter.getSortColumns();a=$("#list_ticket_items");resale.itemView.render(f,a)},k=function(a){$(".seat_category_item").each(function(){var b;var c=""!==$(this).attr("data-blockids")?$(this).attr("data-blockids").split(";"):$(this).attr("data-areaids").split(";");var d=$(this).attr("data-catids");var e=$(this).find('input[type="checkbox"]');var f=
!1;if(0<a.length)for(f=!0,b=0;b<c.length;b++)if(0>$.inArray(c[b],a)){f=!1;break}$(e).prop("checked",f);f&&0>h.indexOf(d)&&h.push(d)});0<$("#seat_categories_table").find("input:checked").length?$("#resetSeatCategoryButton").show():$("#resetSeatCategoryButton").hide()},m=function(b){var c=[],d=!0,m;b=jQuery("#seat_categories_table");$(a).each(function(){if(!e[this.seatCategoryId]){var a=this.seatCategoryId,b=this.seatBgColor,c=parseInt(this.seatBgColor.slice(1),16);var d=c>>16;var f=c>>8&255;c&=255;
d="#"+(16777216+65536*(Math.round(.25*(0-d))+d)+256*(Math.round(.25*(0-f))+f)+(Math.round(.25*(0-c))+c)).toString(16).slice(1);e[a]={seatCatColor:b,seatCatBorder:d,seatCatText:this.seatCatName,seatCatTextColor:this.seatCatTextColor,seatCategoryRank:this.seatCategoryRank,seatCatId:this.seatCategoryId,blockIds:[],areaIds:[]}}if(!this.blockId&&!this.areaId)throw"Strange! item has neither blockId nor areaId";this.blockId&&-1===$.inArray(this.blockId,e[this.seatCategoryId].blockIds)?e[this.seatCategoryId].blockIds.push(this.blockId):
this.areaId&&this.seatCategoryId&&-1===$.inArray(this.areaId,e[this.seatCategoryId].areaIds)&&e[this.seatCategoryId].areaIds.push(this.areaId)});for(m in e)e.hasOwnProperty(m)&&(e[m].blockIdsString=e[m].blockIds.join(";"),e[m].areaIdsString=e[m].areaIds.join(";"),c.push(e[m]));f.seatCategories=c;f.seatCatSelectionTitle=resale.messages.seatCatSelectionTitle;resale.itemView.renderSeatCategory(f,b);$(".seat_category_item").each(function(){d&&$(this).addClass("odd");d=!d;$(this).click(function(a){if("INPUT"===
a.target.tagName){g=[];a=$(this).find("input:checked");var b=$(this).attr("data-catids");0===a.length?h=h.filter(function(a){return a!=b}):h.push(b);0<$("#seat_categories_table").find("input:checked").length?$("#resetSeatCategoryButton").show():$("#resetSeatCategoryButton").hide();l()}})});1>=c.length&&($("#seat_categories_table").hide(),$("#seat_categories_table").siblings(".criteria").css("width","100%"));$("#resetSeatCategoryButton").on("click",function(){$(this).closest(".reset_button_wrapper").addClass("invisible");
h=[];k([]);l()}).closest(".reset_button_wrapper").addClass("invisible")},p=function(){var c,e=null,f=null;var g=0;for(c=a.length;g<c;g++){var h=a[g];h=b?h.price:h.priceWithCharge;if(null===e||e>h)e=h;if(null===f||f<h)f=h}$("#item_price_filter").parents(".criteria").find(".filterToolReset").hide().on("click",function(){$(this).hide();resale.sliderFilter.reset();l()});null!==e&&null!==f&&(resale.sliderFilter.init("#item_price_filter",e,f),resale.sliderFilter.registerSlideCallback(function(c,g){var h;
c===e&&g===f||$("#item_price_filter").parents(".criteria").find(".filterToolReset").show();d=[];var k=0;for(h=a.length;k<h;k++){var m=a[k];var p=b?m.price:m.priceWithCharge;p>=c&&p<=g&&d.push(m)}resale.itemSorter.updateModel(d);l()}));e===f&&$("#item_filters").hide()},q=function(a){d=a;l()},r=function(a){var b=$("#list_ticket_items");a?(b.find("input, a, select").attr("disabled","disabled"),$("#addOtherProducts, #book").attr("disabled","disabled")):(b.find("input, select").prop("disabled",!1),b.find("a").removeAttr("disabled"),
$("#addOtherProducts, #book").removeAttr("disabled"))},t=function(){var c;f.totalItems=0;var d=f.totalPrice=0;for(c=a.length;d<c;d++){var e=a[d];0<e.orderQuantity&&(f.totalItems+=e.orderQuantity,f.totalPrice+=e.orderQuantity*(b?e.price:e.priceWithCharge))}0===f.totalItems?f.totalItemsText="":1===f.totalItems?f.totalItemsText=resale.messages.singularTicket:(f.totalItemsText=resale.messages.pluralTickets,f.totalItemsText=f.totalItemsText.replace("{0}",f.totalItems));f.totalPriceText=functions.generateAmount(f.totalPrice)},
w=function(a,b){a=y(a);null!=a&&(a.orderQuantity=b,a.frozen=0<b,null!=a.companionKey&&(a=y(a.companionKey),null!=a&&(a.orderQuantity=b,a.frozen=0<b)));t()},y=function(b){var c;var d=0;for(c=a.length;d<c;d++){var e=a[d];if(e.key===b)return e}return null},z=function(a,b){var c=$('<input type="hidden"></input>');c.attr("id",a).attr("name",a);c.val(b);return c},x=function(a){var b=resale.itemSorter.getSortColumns(),c=b.find(function(a){return"sort_on_audience_subCat"===a.id});b=b.find(function(a){return"sort_on_price"===
a.id});a.seatRelease&&(A(c),A(b))},A=function(a){a.sortable=!1;a.sortFunction=null;a.sortDirection=null;a.linkCssClass="no_hover_styling"},C=function(){$("#sort_on_zone").on("click",function(a){a.preventDefault();a.stopImmediatePropagation();resale.itemSorter.doSort(0,!0)});$("#sort_on_availability").on("click",function(a){a.preventDefault();a.stopImmediatePropagation();resale.itemSorter.doSort(1,!0)});$("#sort_on_seat_path").on("click",function(a){a.preventDefault();a.stopImmediatePropagation();
resale.itemSorter.doSort(2,!0)});$("#sort_on_audience_subCat").on("click",function(a){a.preventDefault();a.stopImmediatePropagation();resale.itemSorter.doSort(3,!0)});$("#sort_on_price").on("click",function(a){a.preventDefault();a.stopImmediatePropagation();resale.itemSorter.doSort(4,!0)})};return{init:function(c,e,f,g){var h=0;resale.history.init(!1);resale.itemGeneral.init(resale.itemGeneral.SINGLE_ENTRY);resale.ajax.init();resale.pagination.init("#list_ticket_items",!1);resale.pagination.setPaginationConfiguration({page:1,
displayWindow:2,nbPerPage:e});resale.pagination.updatePageNumberFromUrl();resale.itemView.init();resale.itemView.registerViewRenderedCallbacks(function(b){C();for(h;h<g.length;h++)w(g[h],1),l();var c;b=0;for(c=a.length;b<c;b++){var d=a[b];0<d.orderQuantity&&$("select[id="+d.key+"]").val(String(d.orderQuantity))}});resale.ajax.onTicketItemsReady(function(c){tools.dialog.hideDialog("loadingDialog");a=c.resaleItems;b=c.seatRelease;resale.itemGeneral.enhencingItems(a,{seatRelease:c.seatRelease});var e=
a,g,h=[];for(g=0;g<e.length;g++){var k=e[g];if(k.selectable&&(h.push(k),null!=k.companionKey)){a:{var q;for(q=0;q<e.length;q++)if(e[q].key===k.companionKey){k=e[q];break a}k=null}null!=k&&h.push(k)}}d=h;resale.itemSorter.updateModel(d);p();0>=a.length&&($("#controls").hide(),$("#list_ticket_items").hide(),$("#msg_max_allowed_seats").hide(),$("#no_ticket_on_sale").show());x(c);l();m(f)});resale.pagination.onPageChange(l);resale.itemSorter.init([resale.itemSorter.sortColumn("sort_on_zone",!0,"category",
resale.itemSorter.zoneSortFunc,resale.itemSorter.defaultSortDirection(),resale.messages.headers.seatCategory),resale.itemSorter.sortColumn("sort_on_availability",!0,"hidden-quantity",resale.itemSorter.availabilitySortFunc,resale.itemSorter.defaultSortDirection(),resale.messages.headers.availability),resale.itemSorter.sortColumn("sort_on_seat_path",!0,"seatPath",resale.itemSorter.seatPathSortFunc,resale.itemSorter.defaultSortDirection(),resale.messages.headers.seat),resale.itemSorter.sortColumn("sort_on_audience_subCat",
!0,"tariff",resale.itemSorter.subCategorySortFunc,resale.itemSorter.defaultSortDirection(),resale.messages.headers.subCategory),resale.itemSorter.sortColumn("sort_on_price",!0,"unit_price",resale.itemSorter.priceSortFunc,resale.itemSorter.defaultSortDirection(),resale.messages.headers.price),resale.itemSorter.sortColumn("sort_on_action",!1,"",null,null,"")]);resale.itemSorter.registerSortCompletedCallback(q);resale.ajax.loadTicketItems(null,c,"/selection/resale/resaleItems.json")},pushParam:function(a,
b){null===b||""===b?delete c[a]:c[a]=b},selectItem:function(a,b,c){if("disabled"==$(c).attr("disabled"))return!1;c=$(c).closest("tr").find(".hidden-quantity select");var d=""===c.val()?0:Number(c.val());if(0>=d||d>b)return c.addClass("error"),!1;w(a,d);l();$("#notification").addClass("hidden")},unselectItem:function(a){w(a,0);l()},toggleItem:function(a,b){$(b).hasClass("selected")?this.unselectItem(a,$("#"+a).find("a")):this.selectItem(a,1,$("#"+a).find("a"))},updateAfterTariffChanged:function(a,
c){c=$(c).prop("selectedIndex");a=y(a);resale.itemGeneral.setTariff(a,c);resale.itemGeneral.setPriceLevelId(a,c);resale.itemGeneral.updatePrice(a,b);t();l()},updateOrderQuantity:function(a,b,c){!0===c&&(a=Number($(a).val()),w(b,a),l())},addToCart:function(b){var c,d=0;r(!0);b=$(b).parents("form:first");var e=0;for(c=a.length;e<c;e++){var f=a[e];if(0<f.orderQuantity){var g=b,h=d++;var k=z("resaleItemData["+h+"].audienceSubCategoryId",f.audienceSubCategoryId);var l=z("resaleItemData["+h+"].seatCategoryId",
f.seatCategoryId);var m=z("resaleItemData["+h+"].quantity",f.orderQuantity);var p=z("resaleItemData["+h+"].unitAmount",f.price);var q=z("resaleItemData["+h+"].key",f.key);var t=z("resaleItemData["+h+"].priceLevelId",f.priceLevelId);g.append(k);g.append(l);g.append(m);g.append(p);g.append(q);g.append(t);for(t=0;t<f.movementIds.length;t++)g.append(z("resaleItemData["+h+"].movementIds["+t+"]",f.movementIds[t]))}}0===d?($("#notification.hidden").removeClass("hidden"),r(!1)):b.submit()},getTickets:function(){return a}}});
tools.module("resale.singleEntry.itemWithoutSeating",function(){var a=[],b=[],c=null,d=!1,f=!1,e={products:null,hasTicketWithReducedTariff:!1,totalItems:0,totalItemsText:"",totalPrice:0,totalPriceText:functions.generateAmount(0)},g=function(){var a;e.products=b;var c=0;for(a=e.products.length;c<a;c++)e.products[c].odd=0===c%2;e.sortColumns=resale.itemSorter.getSortColumns();c=$("#list_ticket_items");resale.itemView.render(e,c)},h=function(){var c,d=null,e=null;var f=0;for(c=a.length;f<c;f++){var h=
a[f];if(null===d||d>h.priceWithCharge)d=h.priceWithCharge;if(null===e||e<h.priceWithCharge)e=h.priceWithCharge}$("#item_price_filter").parents(".criteria").find(".filterToolReset").hide().on("click",function(){$(this).hide();resale.sliderFilter.reset();g()});null!==d&&null!==e&&(resale.sliderFilter.init("#item_price_filter",d,e),resale.sliderFilter.registerSlideCallback(function(c,f){var h;c===d&&f===e||$("#item_price_filter").parents(".criteria").find(".filterToolReset").show();b=[];var k=0;for(h=
a.length;k<h;k++){var l=a[k];l.price>=c&&l.price<=f&&b.push(l)}resale.itemSorter.updateModel(b);g()}));d===e&&$("#item_filters").hide()},l=function(a){var b=$("#list_ticket_items");a?(b.find("input, a, select").attr("disabled","disabled"),$("#addOtherProducts, #book").attr("disabled","disabled")):(b.find("input, select").prop("disabled",!1),b.find("a").removeAttr("disabled"),$("#addOtherProducts, #book").removeAttr("disabled"))},k=function(a,b){var c=$('<input type="hidden"></input>');c.attr("id",
a).attr("name",a);c.val(b);return c},m=function(a,b,c){var d=k("resaleItemData["+c+"].audienceSubCategoryId",a.audienceSubCategoryId);var e=k("resaleItemData["+c+"].seatCategoryId",a.seatCategoryId);var f=k("resaleItemData["+c+"].quantity",a.orderQuantity);var g=k("resaleItemData["+c+"].unitAmount",a.price);b.append(d);b.append(e);b.append(f);b.append(g);for(d=0;d<Math.min(a.movementIds.length,Math.max(10*a.orderQuantity,20));d++)b.append(k("resaleItemData["+c+"].movementIds["+d+"]",a.movementIds[d]))},
p=function(a,b,c){c={audienceSubCategoryId:a.audienceSubCategoryId,seatCategoryId:a.seatCategoryId,quantity:a.orderQuantity,unitAmount:a.price,movementIds:[]};var d;for(d=0;d<Math.min(a.movementIds.length,Math.max(10*a.orderQuantity,20));d++)c.movementIds[d]=a.movementIds[d];b.push(c)},q=function(b,d){var e,g=null,h=0,q={performanceId:c,resaleItemData:[]};l(!0);$("#notification_static_limit, #notification_static_avail, #notification, #notification_advantage_seatcat_limit, #notification_advantage_perf_limit").addClass("hidden");
b=$("#resale_form");var r=0;for(e=a.length;r<e;r++)g=a[r],0<g.orderQuantity&&(f?p(g,q.resaleItemData,h++):m(g,b,h++));d&&(f?q.captcha=d:b.append(k("captcha",d)));0===h?($("#notification.hidden").removeClass("hidden"),l(!1)):f?(tools.dialog.showWaitingPopup("requestProcessingDialog",!0),$.ajax({url:contextPath+"/ajax/selection/resale/item/submit",method:"POST",data:JSON.stringify(q),processData:!1,contentType:"application/json"}).then(function(a){"OK"===a.status?window.location.href=contextPath+a.parameters.redirect:
(l(!1),tools.dialog.hideDialog("requestProcessingDialog"),"DENIED_BY_PKP"===a.status?window.location.href="/":"ERR_TOO_MANY_TICKETS"===a.status?(a=a.parameters.available||1,$("#static_max_quantity").text(a),$("#notification_static_limit").removeClass("hidden")):"ERR_ALREADY_FULL"===a.status?$("#notification_static_avail").removeClass("hidden"):"ERR_SALE_RESTRICTION"===a.status?$("#notification_sale_restriction").removeClass("hidden"):"ERR_NO_PERFORMANCE_AVAILABILITY"===a.status?tools.dialog.showDialog("noPerformanceAvailabilityError",
!0,!0):"ERR_NO_AVAILABLE_SEAT_CATEGORIES"===a.status?tools.dialog.showDialog("noAvailableSeatCategoriesError",!0,!0):tools.dialog.showDialog("ajaxErrorDialogReload",!0,!0))},function(){tools.dialog.hideDialog("requestProcessingDialog");tools.dialog.showDialog("ajaxErrorDialogReload",!0,!0)})):b.submit()};return{init:function(k){c=k.performanceId;f=k.cached;d=k.withCaptcha;resale.history.init(!1);resale.itemGeneral.init(resale.itemGeneral.SINGLE_ENTRY);resale.ajax.init();resale.itemView.init();resale.itemView.registerViewRenderedCallbacks(function(b){var c;
b=0;for(c=a.length;b<c;b++){var d=a[b];0<d.orderQuantity&&$("select[id="+d.key+"]").val(String(d.orderQuantity))}});resale.ajax.onTicketItemsReady(function(c){tools.dialog.hideDialog("loadingDialog");e.hasTicketWithReducedTariff=c.hasTicketWithReducedTariff;a=c.resaleItems;resale.itemGeneral.enhencingItems(a,{isTicketsGrouped:!0});b=a;resale.itemSorter.updateModel(b);h();0>=a.length&&($("#controls").hide(),$("#msg_max_allowed_seats").hide(),$("#list_ticket_items").hide(),$("#no_ticket_on_sale").show());
c=[resale.itemSorter.sortColumn("sort_on_seatCat",!1,"category",null,null,resale.messages.headers.seatCategory),resale.itemSorter.sortColumn("sort_on_quantity",!1,"quantity",null,null,resale.messages.headers.quantity),resale.itemSorter.sortColumn("sort_on_price",!1,"unit_price",null,null,resale.messages.headers.price),resale.itemSorter.sortColumn("sort_on_subtotal",!1,"subtotal",null,null,resale.messages.headers.subtotal)];e.hasTicketWithReducedTariff?c.splice(1,0,resale.itemSorter.sortColumn("sort_on_audience_subCat",
!0,"reducedTariff",resale.itemSorter.subCategorySortFunc,resale.itemSorter.defaultSortDirection(),resale.messages.headers.reducedTariff)):c.splice(1,0,resale.itemSorter.sortColumn("dummy",!0,"dummy",null,null,""));resale.itemSorter.init(c);g()});resale.ajax.loadTicketItems(null,c,"/selection/resale/resaleItemsWithoutSeating.json")},updateOrderQuantity:function(b,c){b=Number($(b).val());var d;var f=0;for(d=a.length;f<d;f++){var h=a[f];if(h.key===c){h.orderQuantity=b;h.subTotal=functions.generateAmount(h.orderQuantity*
h.priceWithCharge);break}}e.totalItems=0;c=e.totalPrice=0;for(b=a.length;c<b;c++)f=a[c],0<f.orderQuantity&&(e.totalItems+=f.orderQuantity,e.totalPrice+=f.orderQuantity*f.priceWithCharge);0===e.totalItems?e.totalItemsText="":1===e.totalItems?e.totalItemsText=resale.messages.singularTicket:(e.totalItemsText=resale.messages.pluralTickets,e.totalItemsText=e.totalItemsText.replace("{0}",e.totalItems));e.totalPriceText=functions.generateAmount(e.totalPrice);g()},addToCart:function(a){d?util.captcha.showPopup(function(b){q(a,
b)}):q(a)}}});
tools.module("resale.sliderFilter",function(){var a,b,c;return{init:function(d,f,e){f=null===f?0:f;e=null===e?0:e;b=$.Callbacks();a=$(".slider_range",d).slider({range:!0,min:f,max:e,values:[f,e],create:function(){$(".ui-slider-handle:first").addClass("handle-left");$(".ui-slider-handle:last").addClass("handle-right");c=$('<div class="tooltip"><div class="tooltip-inner"></div><div class="tooltip-arrow"></div></div>');$(".ui-slider-handle").append(c)},change:function(a,c){b.fire(c.values[0],c.values[1])},
stop:function(a,b){b.values[0]===f&&$(".handle-left > .tooltip").hide();b.values[1]===e&&$(".handle-right > .tooltip").hide()},slide:function(a,b){$(".slider_range").closest(".criteria").find(".filterToolReset").hide();$(".ui-slider-handle.ui-state-active").hasClass("handle-left")?(a=functions.generateAmount(b.values[0]),c=$(".handle-left > .tooltip")):(a=functions.generateAmount(b.values[1]),c=$(".handle-right > .tooltip"));c.children(".tooltip-inner").html(a);c.show()}});a.append($('<div class="slider_info"></div>').append($('<span class="amount min"></span>').html(functions.generateAmount(f))).append($('<span class="amount max"></span>').html(functions.generateAmount(e))))},
isSliderFilterInitialized:function(){return null!=a},getPriceRangeValues:function(){var b=a.slider("values");return{min:b[0],max:b[1]}},setMinMaxSlider:function(b,c){a.slider("option","min",b);a.slider("option","max",c);var d=$(".amount.min").empty();var f=$(".amount.max").empty();d.html(functions.generateAmount(b));f.html(functions.generateAmount(c));$(".ui-slider-handle > .tooltip").hide()},getMinMaxSlider:function(){return{min:a.slider("option","min"),max:a.slider("option","max")}},reset:function(){var b=
this.getMinMaxSlider();a.slider({values:[b.min,b.max]});$(".ui-slider-handle > .tooltip").hide()},registerSlideCallback:function(a){b.add(a)}}});
tools.module("resale.tickets",function(){var a,b,c,d,f,e,g,h,l,k,m,p=null,q,r=function(a,b){return a=a+(""!==a?",":"")+b.substring(22)},t=function(a,b,c,d){1<d?a.html(c.replace("{0}",d)):a.html(b.replace("{0}",d))},w=function(a,b,c,d){var e="",f=!1;p=null;a.find("div[id^=ticket_content]").each(function(a){a=jQuery(this).find("input[id^=field_checkbox_ticket_]");var g=a.attr("id"),h=a.closest(".seat_category_container").find('input[id^="currency_code_label"]').val(),k;if(k=a.is(":checked"))k=b&&c?
a.parent().hasClass("to_resale")&&a.parent().hasClass("to_transfer"):b?a.parent().hasClass("to_resale"):a.parent().hasClass("to_transfer");if(k&&-1!==g.indexOf("field_checkbox_ticket_")&&22<g.length){if(!p)p=h;else if(p!==h&&d){f=!0;return}e=r(e,g)}});return f?null:e},y=function(a){var b=[];a.find(".content.to_transfer").each(function(a){a=jQuery(this).find("input[id^=field_checkbox_ticket_]");a.length&&a.is(":checked")&&(a=a.data("movementid"),void 0!==a&&b.push(a))});return b.join(",")},z=function(a){var b=
"";a.find(".content.to_resale").each(function(a){a=jQuery(this).find("input[id^=field_checkbox_ticket_]");var c=a.attr("id");1==a.parent().find(".beneficiary_label_main_owner").length&&-1!==c.indexOf("field_checkbox_ticket_")&&22<c.length&&(b=r(b,c))});return b},x=function(a){return a&&a.length?a.split(",").length:0},A=function(a,b,c){var d="",e;a.find(".product_container").each(function(a,f){e=$(f).find(".composed_product");0<e.length?e.each(function(a,e){d=C($(e),d,"",b,c)}):d=C($(f),d,"",b,c)});
return d},C=function(a,b,c,d,e){a.find("input[id^=field_checkbox_ticket_]").each(function(a,b){a=$(b).attr("id");-1!==a.indexOf("field_checkbox_ticket_")&&22<a.length&&(c=r(c,a))});return b=u(b,c,d,e)},u=function(a,b,c,d){var e=b.length?b.split(","):[];c=c.length?c.split(","):[];var f=d.length?d.split(","):[];return(d=e.find(function(a){return f.includes(a)}))&&c.includes(d)?a.length?a+","+b:b:a},v=function(a,b){a=a.find(".button.resell");b?a.removeClass("disabled"):a.hasClass("disabled")||a.addClass("disabled")},
D=function(a){var b="";a.find(".beneficiary_label_main_owner").each(function(a){(a=jQuery(this).closest(".ticket"))&&2===a[0].className.split("ticket_").length&&(b+=""!==b?",":"",b+=a[0].className.split("ticket_")[1])});return b};return{init:function(p,q,r,t,v,A,x,y,u,w,z){c=p;d=q;a=r;b=t;f=v;e=A;g=x;h=y;l=u;k=w;m=z},resell:function(a,b,c,d){var e=$(".product_container").parent(),f=w(e,!0,!1,!0);if(null===f&&d)tools.dialog.showDialog("confirmationDialog_differentCurrencies",!0,!0,!1,"cancel_message_dialog");
else{d=z(e);var g=A(e,f,d),h="";!f||f.split(",").length>l||(v(e,!1),b&&(h+="&filterProductId="+b),c&&(h+="&filterPerformanceId="+c),d?(tools.dialog.showWaitingPopup("loadingDialog",!0),$.ajax({type:"GET",url:contextPath+"/ajax/account/resale/validateResellForMainOwnerTickets",data:{selectedTicketsIds:f,mainTicketsIds:d,matchTicketsIds:g},success:function(b){tools.dialog.hideDialog("loadingDialog");b?window.location.href=a+"?ticketIds="+f+h:(v(e,!0),tools.dialog.showDialog("ticketSelectionValidToResellDialog",
!0,!1,null,null))},error:function(a){v(e,!0);tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}})):window.location.href=a+"?ticketIds="+f+h)}},validateCancellation:function(a,b,c,d){a=D(a.closest(".product_container"));var e="",f=b,g=!1;"object"===typeof b&&(b.length>d&&(g=!0,b=b.slice(0,2)),b.forEach(function(a,c){return e+=a+(c===b.length-1?"":",")}),f=(g?"overLimit_":"")+c);tools.dialog.showWaitingPopup("loadingDialog",!0);$.ajax({type:"GET",url:contextPath+
"/ajax/account/resale/validateCancelResellForNoMainOwnerTickets",data:{selectedTicketIds:e||b,mainTicketsIds:a},success:function(a){tools.dialog.hideDialog("loadingDialog");a?tools.dialog.showDialog("confirmationDialog_"+f,!0,!0,!1,"cancel_message_dialog"):tools.dialog.showDialog("ticketValidToCancelResellDialog",!0,!1,null,null)},error:function(a){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}})},handleRequestReturnTicket:function(a){tools.dialog.showWaitingPopup("loadingDialog",
!0);$("form#return_ticket_form_"+a).submit()},handleRequestTransferTicket:function(){var a=$("input#email_address"),b=$(".additional_errorText");void 0===a.val()||""===a.val()?(b.addClass("error"),b.removeClass("hidden"),a.addClass("error")):(a=y($(".product_container").parent()),$("#movementIds").val(a),tools.dialog.showWaitingPopup("loadingDialog",!0),$("form#transfer_ownership_form").submit())},hideErrorMessage:function(){var a=$("input#email_address"),b=$(".additional_errorText");b.removeClass("error");
b.addClass("hidden");a.removeClass("error")},handleResellButton:function(a){a=a.closest(".by_aud_sub_category").parent();var b=w(a,!0,!1,!0);v(a,0<b.length)},updateCheckBox:function(a,b){null!=b&&$("#field_checkbox_ticket_"+b).prop("checked",a.is(":checked"));this.updateBulkResellButton(a)},updateBulkResellButton:function(p){var r=$("#bulk_resell_button"),B=$("#bulk_transfer_ownership_button"),v=$(".footer_content_container .footer_content .ticket_number"),A=$("#bulk_resell_footer"),y=$(".product_container").parent(),
u=w(y,!1,!0,!1);y=w(y,!0,!1,!m);u=x(u);var z=x(y);null===y||z>l||u>k?(p.prop("checked",!1),0===p.attr("id").indexOf("select_all_to_resale_")&&this.toggleAllTicketsInPerformanceForResale(p,q?void 0:l),m?(u>k||z>k)&&tools.dialog.showDialog("confirmationDialog_"+(u>z?"bulkTransfer":"bulkResale"),!0,!0,!1,"cancel_message_dialog"):tools.dialog.showDialog("confirmationDialog_"+(null===y?"differentCurrencies":"bulkResale"),!0,!0,!1,"cancel_message_dialog")):(q&&(q=u>k||z>l),0<u||0<z?(r.parent().removeClass("disabled"),
B.parent().removeClass("disabled"),A.removeClass("collapsed")):(r.parent().addClass("disabled"),B.parent().addClass("disabled"),A.addClass("collapsed")),0===z&&0===u||z===u?(v.show(),r.parent().show(),B.parent().show(),t(v,c,d,z),r.text(a),B.text(b)):0<u&&0===z?(r.parent().hide(),v.hide(),t(B,g,h,u)):(0<z&&0===u?(B.parent().hide(),v.hide()):(v.hide(),r.parent().show(),B.parent().show(),t(B,g,h,u)),t(r,f,e,z)))},closeConfirmationDialogWithId:function(a){tools.dialog.hideDialog("confirmationDialog_"+
a)},toggleAllTicketsInPerformanceForResale:function(a,b){(isNewTicketShop?a.parent().siblings(".seat_category_list").find(".seat_category_container"):a.parent().siblings(".seat_category_container")).each(function(c,d){c=$(d).find("input[id^=field_checkbox_ticket_]");void 0!==b?(q=!0,b>=c.length?b-=c.length:(c.slice(b,c.length).each(function(b,c){c.checked=a.prop("checked")}),b-=c.length-b)):c.each(function(b,c){c.checked=a.prop("checked")})});this.updateBulkResellButton(a)},countAllCheckedNumbers:function(){var a=
w($(".product_container").parent(),!0,!1,!0);return a.length?a.split(","):0},getAllTransferTicketNumbers:function(){var a=w($(".product_container").parent(),!1,!0,!1);return x(a)},setTitleForDialog:function(a,b){1<this.getAllTransferTicketNumbers()?$("#ticketTransferOwnershipDialog").parent().find(".ui-dialog-title").html(b.replace("{0}",this.getAllTransferTicketNumbers())):$("#ticketTransferOwnershipDialog").parent().find(".ui-dialog-title").html(a.replace("{0}",this.getAllTransferTicketNumbers()))}}});
tools.module("resale.view",function(){var a,b,c,d=function(a,b){b?$("#"+a).show():$("#"+a).hide()},f=200,e=function(e,h){h.fadeTo(f,0,function(){h.html(Mustache.render(a,e,{eventTpl:b,nonDatedPassTpl:c}));h.fadeTo(f,1,function(){f=200;$("#search_box_container .spinner").addClass("invisible")})});d("notification_no_ticket_on_sales",e.noTicketsOnSales);d("notification_search_result_empty",e.searchResultEmpty)};return{init:function(){a=$("#productsListTpl").html();b=$("#eventTpl").html();c=$("#nonDatedPassTpl").html()},
render:function(a,b){e(a,b)},setFadeDuration:function(a){f=a},showSearchBoxSpinner:function(){$("#search_box_container .spinner").removeClass("invisible")}}});
$(function(){var a=function(){$.trim($("#search_field").val())&&setTimeout(function(){$("#searchForm").submit()},10);return!1};$("#submitSearch").click(a);$("#search_field").keypress(function(b){if(13===b.keyCode)return a()})});
tools.module("seasontickets.general",{abandonSeasonTicketConfiguration:function(a){tools.dialog.hideDialog("subscriptionConfigOnGoing");tools.dialog.showWaitingPopup("loadingDialog",!0);jQuery.ajax({type:"POST",url:contextPath+"/ajax/subscription/abandon",cache:!1,success:function(){a?location.replace(a):location.reload()},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}})},startAssistantCountdown:function(a){jQuery("#configurationAssistant #continueButton").click(function(){tools.dialog.hideDialog("configurationAssistant")});
setTimeout(function(){$("select").hide();tools.dialog.showDialog("configurationAssistant",!0,!1,null,"");$("select").show()},1E3*a)}});
tools.module("seasontickets.introduction",{showAdditionalEvents:function(a){a=jQuery(a).closest(".events");a.find(".more_events").remove();a.parent().find(".alternative_button.next").remove();a.find(".additional_events").slideToggle()}});
tools.module("seasontickets.performances",function(){var a=null,b=null,c=null,d=null,f=null,e=null,g=null,h=null,l=null,k=null,m=null,p=null,q=null,r=null,t=null,w=!1,y=null,z=null,x=null,A=1E4,C={},u=!0,v=null,D=0,E=!1,F=!0,B=null,G=0,L={},K=null,H=0,M=null,Q=null,S=null,V=null,N=null,I=null,O=null,R=!1,X=!0,T=null,Z=function(){},ba=0,U=null,P=null,Y=null,da=null,aa=!1,W=0,J=0,la={},ja=!1;var ea=function(a){var b=0,c=t.length,d,e=0,f=!1,g=null===G?0:G;E&&!a&&(G=null);for(d=0;d<c;d++)b+=t[d].getNbOptional();
F=null===v||b<v;for(d=g;;){if(d===g){if(1===e)f=F;else if(2===e)break;e++}b=t[d];if(b.getNextSelectIndex(f,F))return E||a?(b.selections[b.selectedIndex].selected=!1,a||(G=null)):G=d,!0;d===c-1?d=0:d++}a||(I.showWaitingDialog(),G=null);return!1};var ha=function(){var a,b;var c=(t||[]).reduce(function(a,b){return a.concat((b.selections||[]).filter(function(a){return a.performance&&a.price&&!a.onGoingBooking}))},[]);return z.some(function(d){var e,f,g,h;b=C[d.id][d.priceLevelId];var k=d.id;var l=d.priceLevelId;
var m=b.parentTariffId;a=Object.keys(C).filter(function(a){e=a;if(!C[a]||!C[a][l])return!1;f=C[a][l].parentTariffId;return c.every(function(a){h=a.price[e]&&(a.price[e][l]||0===a.price[e][l])?a.price[e][l]:null;return null!=h})&&(k===e||m&&f&&m===f||m&&e===m||f&&k===f)}).map(function(a){return C[a][l]});return(g=ca(a,c.length+1))&&Number(g.tariffId)!==Number(d.id)})};var ca=function(a,b){var c=a.filter(function(a){return b>=a.minQuantity&&(!a.maxQuantity&&a.parentTariffId||a.maxQuantity&&b<=a.maxQuantity)});
if(1==c.length)return c[0];if(0===c.length){c=a.filter(function(a){return a.maxQuantity&&a.maxQuantity<b});if(0<c.length)return c.reduce(function(a,b){return b.maxQuantity>a.maxQuantity?b:a},a[0]);for(c=0;c<a.length;c++)if(!a[c].parentTariffId)return a[c]}else return c.reduce(function(a,b){return a?b.minQuantity>a.minQuantity?b:a:b},null)};var ma=function(a,b){var c=!0,d=0;!1!==a&&(B="");$.each(t,function(){c=c&&this.checkCanBook(a);d+=this.getNbOptional();if(!1!==a&&!c&&!B){var b=this.cannotBookMessages;
b.failedRequest?B=seasontickets.performances.messages.failedRequest:b.minimumNotReached?B=1===t.length||this.code===seasontickets.performances.Subject.NO_SUBJECT_CODE?seasontickets.performances.messages.minimumNotReached:seasontickets.performances.messages.minimumNotReachedOnSubject.replace("{0}",this.name):b.missingPerformance?B=seasontickets.performances.messages.missingPerformance:b.missingSeatCategory?B=seasontickets.performances.messages.missingSeatCategory:b.ongoingRequest&&(B=seasontickets.performances.messages.ongoingRequest)}});
c&&!1!==a&&d<D&&(c=!1,B=seasontickets.performances.messages.minimumNotReached);return c};var oa=function(){O={page:1,displayWindow:2,nbPerPage:20};d&&$.each(d,function(){this.selectAreaBlock()})};var na=function(a){var b={},c=null;for(c in a)a.hasOwnProperty(c)&&(b[c]={id:String(c),name:a[c]});return b};var pa=function(){if(null!==G){var a=t[G].getSelection();a.selected=!1}};var qa=function(a){return a.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;").replace(/\//g,
"&#x2F;")};var ra=function(){var a,b=0;if(!v)return null;var c=t.length;for(a=0;a<c;a++){var d=t[a];b+=d.getNbSelections()-d.included}return v-b};var ia=function(a,b,d){var e=c[a],f=b.val(),g=parseInt(f,10),h=$(".additional_seats_audsubcats[data-perfid="+a+"]"),k=null,l=null,m=0;a=$(".event_performance[data-perfid="+a+"]").find("p.add_seats");var p=e.selectedSeatCategoryId;k=ua(e.additionalSeatsPrices,e.selectedSeatCategoryId);p&&0<k.length?(d&&wa(h,k),"0"!==f?(k=h.slice(0,g),k.each(function(a,b){l=
$(b).find("select.additional_seats_audsubcat").val();m=e.getAdditionalSeatPrice(p,l);$(b).find(".price").html(e.getAdditionalPriceDisplay(m));$(b).removeClass("hidden");0===a&&$(b).find(".additional_seats_count").html(g)}),h.slice(g).addClass("hidden"),k.removeClass("hidden")):h.addClass("hidden"),a.removeClass("hidden")):(b.val("0"),h.addClass("hidden"),a.addClass("hidden"))};var ua=function(a,b){return a?jQuery.grep(a,function(a){return a.seatCategoryId===parseInt(b,10)}):[]};var wa=function(a,
b){var c="";jQuery.each(b,function(a,b){c+="<option value="+b.audienceSubCategoryId+">"+b.audienceSubCategory+"</option>"});jQuery.each(a,function(a,d){$(d).find("select.additional_seats_audsubcat").html(c);1<b.length?$(d).find(".audsubcat_select").removeClass("hidden"):$(d).find(".audsubcat_select").addClass("hidden")})};var xa=function(){var a=0,b,d;for(d in c)c.hasOwnProperty(d)&&-1===d.indexOf("/")&&(b=c[d].selectedAdditionalSeats)&&(a+=b.length);return a};var va=function(a){var b,c=W;if(!jQuery.isEmptyObject(la))for(b in la)if(parseInt(b,
10)===a){c=la[b];break}return c};var ta=function(){return E?X&&ea(!0):null!==G};return{messages:null,init:function(a,b,c,d,e,f){var g=null,h=null,k=this,l=qa(window.location.search);seasontickets.performances.errors.init();seasontickets.performances.viewHelper.init();var m=seasontickets.performances.errors;var p=m.ajaxErrorDialog;var q=function(){h&&g&&(k.loadEvents(g),k.loadConfiguration(h),ea(),k.updateConfDisplay(),k.updatePerformanceList(!0),I.scrollToTop(),I.hideWaitingDialog(),ma()&&(k.allowBook(),
!ta()||c))&&(I.showWaitingDialog(),k.finalize())};var r=function(){$.ajax({url:ia,dataType:"json"}).done(function(a){a?a.status===m.ERR_INSUFFICIENT_AVAIL_EVENTS?m.cantBookErrorDialog():a.status===m.ERR_CART_NOT_EMPTY?m.emptyCartDialog():a.status===m.ERR_ALREADY_FULL?m.alreadyFull():a.status===m.ERR_INSUFFICIENT_TICKETS?tools.dialog.showDialog("insufficientTickets",!0,!0):(h=a,q()):m.ajaxErrorDialog()}).fail(p)};M=seasontickets.performances.Selection;Q=seasontickets.performances.Event;S=seasontickets.performances.Performance;
V=seasontickets.performances.Subject;N=seasontickets.performances.filters;I=seasontickets.performances.viewHelper;w=b;M.fixedPrice=w;S.fixedPrice=w;y=d;f.length&&(seasontickets.multiplePerformancesMap=JSON.parse(f));$("#main_content_seasonticket_performances > .fallback_main_title").removeClass("hidden");P=$("#main_content_seasonticket_performances > .content_title > .title");I.showWaitingDialog();oa();T=$("body").hasClass("ie_lte_9");this.bindEvents();d&&(l+="&advantageId="+d);d=w?"fixedPrice/":
"";b=contextPath+"/selection/subscription/"+d+"SeasonTicketCatalog.json";var ia=contextPath+"/selection/subscription/"+d+"SeasonTicketConfiguration.json";ia+=l;ia+="&checkAvailability="+!c;ia+="&forceValidation="+c;$.ajax({url:b+(l+(a?"&devCookieHost="+a:"")),dataType:"json"}).done(function(a){a?(g=a,g.defaultAreaId=e,q(),r()):m.ajaxErrorDialog()}).fail(p);window.addEventListener("orientationchange",function(){setTimeout(function(){I.adjustCursor()},50)},!1);I.initStickyFooter()},bindEvents:function(){var a=
this,b=function(b){var c=$(b).data("scode");b=parseInt($(b).data("index"),10);var d,e=t.length,f=null;pa();a.removeValidationState();for(d=0;d<e;d++){var g=t[d];if(g.code.toString()===c.toString()){G=d;g.selectedIndex=b;f=g.getSelection();f.selected=!0;break}}return f},e=function(b,c,e){var f=ma();ba--;f?a.allowBook():a.preventBook();0<ba?a.preventCancelSubscription():a.allowCancelSubscription();!f||c?(!c&&ma(!1)||I.hideWaitingDialog(),null!==G||E||(G=0,ea())):ta()||a.finalize();e&&0<Object.keys(e)&&
($("#secondary_content_seasonticket .quantity_line").each(function(){var a=$(this).data("audiencesubcategory"),b=$(this).data("pricelevelid"),c=$(this).data("pricelevelcode");e[a]&&e[a][b]&&($(this).data("audiencesubcategory",e[a][b].audienceSubCategoryId),a=e[a][b],$(".rate",this).html(C[a.audienceSubCategoryId][a.priceLevelId].name+" - "+c))}),z=(z||[]).map(function(a){var b=e[a.id]&&e[a.id][a.priceLevelId]?e[a.id][a.priceLevelId].audienceSubCategoryId:null,c=e[a.id]&&e[a.id][a.priceLevelId]?e[a.id][a.priceLevelId].priceLevelId:
null;return b&&c?{id:b,priceLevelId:c,quantity:a.quantity}:a}),$.each(d,function(){this.buildPrices(z)}));a.updatePerformanceList();a.updateConfDisplay();b&&!c&&(c=$("#perf_selection_"+b.id),c.length&&(c.removeClass("ongoing").addClass("selected").find(".button").removeClass("invisible"),c.find(".wait_overlay").remove()),c=$("#selection_"+b.id),c.addClass("defined modify").removeClass("ongoingbooking"),c.find(".wait_overlay").remove(),c.find(".success_overlay").removeClass("hidden").each(function(){var a=
$(this),b=a.parent().outerHeight();a.height(b).css("line-height",b+"px")}),setTimeout(function(){$("#selection_"+b.id).find(".success_overlay").fadeOut("slow");b=null},1E3),b.optional&&c.find("a.remove").removeClass("hidden"));0===$(":focus").length&&b&&b.event&&b.event.uniquePerformance&&$("tr[data-perfid='"+b.event.uniquePerformance+"'] td.last .button a").focus()},f=function(c,d,f){a.confirmRemoval=function(c){a.confirmRemoval=Z;d&&(f=b(d.parents(".event")));f&&(f.mandatory&&a.preventBook(),ba++,
a.preventCancelSubscription(),f.remove(e));ea();a.updateConfDisplay();a.updatePerformanceList();c.preventDefault()};tools.dialog.showWaitingPopup("confirmationDialog_remove",!0);c.stopPropagation();c.preventDefault()};$("#performances").on("click","#showGroup",function(b){oa();K=1;L={};a.updatePerformanceList();I.scrollToTop();b.preventDefault()}).on("click","#showAll",function(b){oa();K=0;a.updatePerformanceList();I.scrollToTop();b.preventDefault()}).on("click",".event_performance .button a",function(b){var d=
$(b.target).parents(".event_performance"),f=d.data("perfid"),g=d.data("topic");d=d.data("selectionindex");var h=c[g&&g!==seasontickets.performances.Subject.NO_SUBJECT_CODE?[f,g].join("/"):f];g=$(".additional_seats_audsubcats[data-perfid="+f+"]:visible");var k=g.length,l=h.getSubscriberQuantity()*J,m=h.selectedAdditionalSeats,p=0,q;if($(this).parent().hasClass("disabled"))b.preventDefault();else if(m&&(p=m.length),0<k&&xa()-p+k>l)seasontickets.performances.errors.additionalSeatsFullDialog("additionalSeatsFullDialog",
l);else{if(d||0===d){if(g=c[f].selections[d],!g.selected){pa();k=g.subject;f=0;for(d=t.length;f<d;f++)t[f]===k&&(G=f);k.selectedIndex=g.index;g.optional&&(F=!0);g.selected=!0;a.updateConfDisplay();a.updatePerformanceList();I.scrollToTop();b.preventDefault();return}}else h.selectedAdditionalSeats=[],0<k&&g.each(function(){q=$(this).find("select.additional_seats_audsubcat").val();h.addSelectedAdditionalSeat(h.selectedSeatCategoryId,q)});ba++;a.bookPerformance(h,e);a.resetPerformancesListQuantity(h);
b.preventDefault()}}).on("change","select.category",function(a){var b=$(a.target),d=b.parents(".event_performance");a=d.data("perfid");var e=b.val(),f=c[a];var g=$(".additional_seats_audsubcats[data-perfid="+a+"]");var h=d.find("p.add_seats").clone();e&&$("select.category").each(function(){var a=$(this);this!==b[0]&&a.val()&&!a.hasClass("single")&&(a.val(""),a.val()||a.change())});f.selectAreaBlock(e);e=f.priceDisplay;d.find(".price").html(e?"<span class='amount'>"+e+"</span>":"").append(h);d=d.find(".button");
h=$(d).find('span[aria-hidden="true"]');var k=$(d).find("span .accessibility-visually-hidden");g=g.find("select.additional_seats_quantity");ia(a,g,!0);f.selectedBlockId&&(w||e)?(d.removeClass("disabled"),h.attr("aria-hidden","false"),k.attr("aria-hidden","true")):(d.addClass("disabled"),h.attr("aria-hidden","true"),k.attr("aria-hidden","false"));T&&d.find("*").hide().show()}).on("change","select.quantity",function(a){var b=$(a.target);a=b.parents(".event_performance").data("perfid");b=parseInt(b.val(),
10);c[a].selectQuantity(b)}).on("click","a.showPerformances",function(b){var c=""+$(this).parents(".event").data("eventid");L[c]=!L[c];a.updatePerformanceList();b.preventDefault()}).on("click","a.seatmap",function(a){var b=$(this).parents(".event_performance").data("perfid");b=" ("+c[b].venue.name+")";viewer.seatView($(this).attr("href"),seasontickets.performances.messages.seatMapTitle+b);a.preventDefault()}).on("click",".pagination .page",function(b){var c=$(this);c.hasClass("current")||(c.hasClass("previous")?
O.page--:c.hasClass("next")?O.page++:O.page=parseInt(c.text(),10),a.updatePerformanceList(),I.scrollToTop());b.preventDefault()}).on("click",".add_seats a",function(a){var b=$(a.target).parents(".event_performance").data("perfid"),c=$(".additional_seats_audsubcats[data-perfid="+b+"]"),d=c.find(".additional_seats_quantity");c.is(":visible")||("0"===d.val()&&d.val("1"),ia(b,d,!0));a.preventDefault()}).on("change","select.additional_seats_quantity",function(a){a=$(a.target);var b=a.parents(".additional_seats_audsubcats").data("perfid");
ia(b,a,!1)}).on("change","select.additional_seats_audsubcat",function(a){var b=$(a.target);a=b.parents(".additional_seats_audsubcats");var d=a.data("perfid");d=c[d];b=b.val();b=d.getAdditionalSeatPrice(d.selectedSeatCategoryId,b);a.find(".price").html(d.getAdditionalPriceDisplay(b))});seasontickets.performances.filters.bind(function(){O.page=1;a.updatePerformanceList();I.scrollToTop()});$("#eventConfiguration").on("click",".event.can_select",function(){oa();b(this);a.updateConfDisplay();a.updatePerformanceList();
I.scrollToTop()}).on("click",".modify, .failed",function(c){oa();var d=$(this);d=d.hasClass("event")?d:d.parents(".event");if(d=b(d))d.optional&&(F=!0),d.selected=!0;a.updateConfDisplay();a.updatePerformanceList();I.scrollToTop();c.preventDefault()}).on("click","a.remove",function(a){var b=$(this);f(a,b)});$("#performances").on("click","a.remove",function(a){var b=null!==G?t[G]:null;b=b?b.getSelection():null;f(a,null,b)});$(".button.validate").tipsy({html:!0,delayIn:200,title:function(){return B}});
$(".last .button.disabled").tipsy({live:!0,delayIn:200,offset:8,gravity:"se",title:function(){return seasontickets.performances.messages.chooseCategory}});$(".buy_unavailable.last div, .showPerformances .buy_unavailable").tipsy({live:!0,delayIn:200,gravity:"se",title:function(){return seasontickets.performances.messages.performanceIsFull}});$("#eventConfiguration .included").tipsy({live:!0,delayIn:200,gravity:"s",title:function(){return seasontickets.performances.messages.included}});$("#eventConfiguration .event .name").tipsy({live:!0,
delayIn:200,gravity:"s",html:!0,title:function(){if(this.offsetWidth>=this.scrollWidth)return"";var a=$(this).parent();var b=$(this).html();a=a.find(".subtitle").html();return"<div class='tipsyName'>"+b+"</div><div>"+a+"</div>"}});[".last .button.disabled",".buy_unavailable.last div, .showPerformances .buy_unavailable","#eventConfiguration .included","#eventConfiguration .event .name"].forEach(function(a){tools.makeTooltipAccessible(a)});$(document).on("click",".button.book a",function(a){$(this).parent().hasClass("disabled")||
($("#addToCartFormSubmitButton").click(),ja||($(".button.book").addClass("disabled"),tools.dialog.showWaitingPopup("requestProcessingDialog",!0)));a.preventDefault()}).on("click",".button.validate a",function(b){$(this).parent().hasClass("disabled")||(I.showWaitingDialog(),a.finalize(!0));b.preventDefault()}).on("click",".step.subscribers a, .step.categories a",function(a){U=$(this).attr("href");tools.dialog.showWaitingPopup("confirmationDialog_edit",!0);a.preventDefault()}).on("click",".step.performances a, #validation_edit_btn",
function(b){var c;if(null===G){var d=0;for(c=t.length;d<c;d++){var e=t[d];var f=e.getSelectionToModifyIndex();if(null!==f){G=d;e.selectedIndex=f;e=e.getSelection();e.selected=!0;break}}}a.removeValidationState();a.updatePerformanceList();b.preventDefault()}).on("click",".validate.mobiValidateBtn",function(){$(".validate.button").is(":visible")?$(".button.validate a").click():$(".button.book a").is(":visible")&&$(".button.book a").click()});$("#cancelSeasonTicket").on("click",function(a){$(this).parent().hasClass("disabled")||
tools.dialog.showWaitingPopup("confirmationDialog_abandon",!0);a.preventDefault()})},confirmRemoval:null,confirmEdit:function(a){window.location=U},bookPerformance:function(a,b){(null!==G?t[G].getSelection():a.subject.getFreeMatch()).book(a,b);this.preventBook();this.preventCancelSubscription();ea();O.target=a;this.updateConfDisplay();this.updatePerformanceList();a=$(".event_performance.new");a.length?a.focus().blur():I.scrollToTop();O.target=null},loadEvents:function(r){var ia=na(r.topicNames),t=
r.topicSubTopics,B;g=na(r.subTopicNames);f={};var v=null;for(v in r.venueNames)r.venueNames.hasOwnProperty(v)&&(f[v]={id:""+v,name:r.venueNames[v],space:r.spaceNames[v],spaceCode:v.split("_")[1],site:r.siteNames[v],siteCode:v.split("_")[0],showSpace:r.spaceNames[v]!=r.siteNames[v]});e=na(r.subjectNames);p=r.seatCategoryNames;h=r.blockNames;l=r.areaNames;q=r.defaultAreaId;aa=r.allowAdditionalSeats;W=r.additionalSeatsMaxQuantityPerPerformance;J=r.additionalSeatsMaxQuantity;la=r.overrrideMaxAdditionalSeatsForSeasonTicketLine;
k=r.teamNames;m=r.teamLogos;a={};c={};b=[];d=[];for(v in t)if(t.hasOwnProperty(v)){var u=t[v];for(B=u.length;B--;)g[""+u[B]].topic=ia[v]}B=0;for(ia=r.events.length;B<ia;B++)v=new Q(r.events[B],g),t=v.id,b.push(v),a[t]=v;B=0;for(ia=r.performances.length;B<ia;B++)v=new S(r.performances[B],a,f,p,h,l,null,aa,va(r.performances[B].eventId),q,k,m),t=v.id,d.push(v),c[t]=v,v.subjectCode.toString()!==seasontickets.performances.Subject.NO_SUBJECT_CODE.toString()&&(c[[t,v.subjectCode].join("/")]=v);H=d.length/
b.length},loadConfiguration:function(f){var g=f.maxTicketPerEvent||1E4,h=f.subjects,k=h?1===h.length:!1,l=0,m=this.messages.selection;x=f.performanceAvailabilities;A=f.maxTicketPerPerformance||1E4;!1===f.success&&(seasontickets.performances.errors.handleError(f.status)||seasontickets.performances.errors.ajaxErrorDialog());var q=f.subscribers;f.orderedSubcribers?z=f.orderedSubcribers:(z=[],C=(f.tariffAndPriceDatas||[]).reduce(function(a,b){a[b.tariffId]||(a[b.tariffId]={});a[b.tariffId][b.priceLevelId]=
b;return a},{}),$("#secondary_content_seasonticket .quantity_line").each(function(){var a=$(this).data("audiencesubcategory"),b=$(this).data("pricelevelid"),c;if(!q[a]||!q[a][b]){for(c=0;c<Object.keys(q).length;c++){var d=Object.keys(q)[c];C[d]&&C[d][b]&&C[d][b].parentTariffId==a&&C[d][b].priceLevelId==b&&(a=d)}$(this).data("audiencesubcategory",a);$(".rate",this).html(C[a][b].name);$("#page_selection_subscription_performances").addClass("degressive_rate_applied")}c=q[a][b];z.push({id:a,priceLevelId:b,
quantity:c});l+=c}));1===l?(Y=m.chosenPerformances,da=m.chosenPerformance):(Y=m.chosenPerformancesMultiple.replace("{1}",l),da=m.chosenPerformanceMultiple.replace("{1}",l));M.setVersion(f.version);$.each(b,function(){this.available=g;this.noTopics=!k});$.each(d,function(){this.buildPrices(z);this.setSubscriberQuantity(l);this.setAvailability(x[this.id],A)});r={};t=[];(v=f.maxOptional)||0===v||(v=null);D=f.minOptional||0;k&&(k=h[0],D&&!k.minOptional&&(k.minOptional=D),!v&&0!==v||k.maxOptional||(k.maxOptional=
v));E=!0;$.each(h,function(b){var d=new V(this,a,c,e,p);d.allFixed||(u=!1);t.push(d);r[d.code]=d;d.index=b;E=E&&d.allOptional});1===t.length&&(E=!1);E&&(G=null);$.each(b,function(){this.subject=r[this.subjectCode]});$.each(d,function(){var a=!1,b;this.subject=r[this.subjectCode];if(this.subjectCode){for(b=0;b<this.event.subjects.length;b++)if(this.event.subjects[b].code.toString()===this.subjectCode.toString()){a=!0;break}!a&&this.subject&&this.event.subjects.push(this.subject)}})},updateConfDisplay:function(){var a=
{subjects:[],allFixed:u},b=!w&&ha();$(".included, .name").each(function(){$(this).tipsy("hide")});$.each(t,function(){a.subjects.push(this.getView(!E,F,R,b))});I.renderConfiguration(a);null!==G?I.adjustCursor():I.hideCursor();this.updatePrice();ma()},updatePerformanceList:function(a){var c,e=null;$(".last .button.disabled, .buy_unavailable.last span").each(function(){$(this).tipsy("hide")});null===K&&(K=3<H?1:0);a=ma(a||!1);var f={showAll:!0,showAllSelected:0===K,showGroup:!0,showGroupSelected:1===
K,canBook:a,multipleViews:!0,categoryOnly:!1,areaOnly:!1};var g=(c=null!==G?t[G]:null)?c.getSelection():null;this.allowedTicketsNumber=ra();if(g||E&&(!E||ea(!0))){if(g&&g.event){var h=g.event;L={};L[h.id]=!0;g.categoryOnly||(f.eventName=h.name,e=[h])}else 1===K&&(e=b.slice(0));g&&g.block&&(f.isModify=!0,f.isRemovable=g.optional,h=g.adjustForModify(),null!==v&&(v+=h));g&&g.event&&g.categoryOnly&&!aa?(f.events=[g.event.getView()],h=f.events[0],h.performances=g.performance.getView(),h.selected=!0,h.singleVenue=
h.performances[0].venue,f.categoryOnly=!0,h.performances[0].singleCategory&&(f.areaOnly=!0),f.available=g.event.available&&g.performance.available):e?(f.multipleEvents=1<e.length,f=$.extend(f,Q.getViewFromList(e,c,N,O,L,f.isModify)),f.multipleEvents||(f.multipleViews=!g||!g.event,f.events&&f.events.length&&(h=f.events[0],h.selected=!0,1===h.performances.length&&(f.categoryOnly=!0,h.performances[0].singleCategory&&(f.areaOnly=!0))))):(f.allPerformances=!0,f.multipleEvents=!0,f=$.extend(f,S.getViewFromList(d,
c,N,O)));E&&1<t.length?f.displaySubjects=!0:f.hasFilterSubjects=!1;f.hasFilters=f.hasFilterSubjects||f.hasFilterTopics||f.hasFilterEvents||f.hasFilterVenue||f.hasFilterDates?!0:!1;f.isModify?f.categoryOnly?f.areaOnly?P.html(this.messages.title.modifyAreas):P.html(this.messages.title.modifySeatCategories):P.html(this.messages.title.modifyPerformances):f.categoryOnly?f.areaOnly?P.html(this.messages.title.areas):P.html(this.messages.title.seatCategories):P.html(this.messages.title.performances);I.renderPerformances(f);
N.hasFiltering(!g||!g.event)||(f.soldout||!f.available?a?(I.showWaitingDialog(),G=null,X=!1,this.finalize()):seasontickets.performances.errors.cantBookErrorDialog():X=!0);g&&g.block&&(h=g.adjustForModify(!0),null!==v&&(v+=h));this.updateFilterResultAccessibility()}else $("#performances").html("")},resetPerformancesListQuantity:function(a){a&&d.forEach(function(b){a.id!==b.id&&(b.selectedQuantity=1)})},allowBook:function(){$(".validate.disabled.button","#secondary_content_seasonticket").removeClass("disabled");
$("a.validate.mobiValidateBtn").removeClass("button");$(".validate.button").each(function(){$(this).tipsy("hide")});T&&$(".validate.button","#secondary_content_seasonticket").find("*").hide().show()},preventBook:function(){$(".validate.button","#secondary_content_seasonticket").addClass("disabled");$("a.validate.mobiValidateBtn").addClass("button");T&&$(".validate.button.disabled","#secondary_content_seasonticket").find("*").hide().show()},allowCancelSubscription:function(){$(".cancel_subscription .cancel").removeClass("disabled")},
preventCancelSubscription:function(){$(".cancel_subscription .cancel").addClass("disabled")},updatePrice:function(){var a=0,b={},c=z.length,d=0,e=$("#secondary_content_seasonticket");if(!w){$.each(t,function(){var e=this.getPrice(z),f;for(f=0;f<c;f++){var g=z[f];var h=g.id;var k=g.priceLevelId;b[h]||(b[h]={});b[h][k]||(b[h][k]=0);g=e[h][k]?e[h][k]*g.quantity:0;b[h][k]+=g;a+=g}a+=this.getTotalAdditionalSeatsPrice();d+=this.getNbSelections()});$(".amount",e).html(functions.generateAmount(a));var f=
d?1===d?da:Y.replace("{0}",d):"";$(".nb-performances",e).html(f);$("#secondary_content_seasonticket .quantity_line").each(function(){var a=$(this).data("audiencesubcategory"),c=$(this).data("pricelevelid");a=b[a]&&b[a][c]?b[a][c]:0;$(".price",this).html(functions.generateAmount(a))})}},finalize:function(a){var b=t.length-1,c=this;if(!(0<ba)||a){for(;b--;)if(t[b].hasFailure())return;a="/ajax/subscription"+(w?"/fixedPrice":"")+"/validation/productHeader";var d;b=qa(window.location.search);y&&(b+="&advantageId="+
y);requestQueuing.addRequest({url:contextPath+a+b,method:"GET",done:function(a){d=a}});requestQueuing.addRequest({url:contextPath+"/ajax/subscription/"+(w?"fixedPrice/":"")+"validation"+qa(window.location.search),method:"GET",done:function(a){c.setValidationState(a,d);tools.displayLazyImages();tools.triggerLazyImagesRefresh();I.hideWaitingDialog()}})}},setValidationState:function(a,b){R||(R=!0,this.updateConfDisplay(),$("#performances").html(""),$(".step.performances").removeClass("current").addClass("done"),
$(".step.validation").addClass("current"),$(".button.book").show(),$(".button.validate").hide(),$(".validate.mobiValidateBtn").hide(),$(".breadcrumb .current .text").html(this.messages.title.validation),$("#main_content_seasonticket_product").html(b),$("#main_content_seasonticket_performances").hide().after(a),$(".button.validate").tipsy("hide"),I.scrollToTop())},removeValidationState:function(){R&&(R=!1,this.updateConfDisplay(),$("#main_content_seasonticket_performances").show(),$("#main_content_seasonticket_validation").remove(),
$(".step.performances").addClass("current").removeClass("done"),$(".step.validation").removeClass("current"),$(".button.book").hide(),$(".button.validate").show(),$(".breadcrumb .current .text").html(this.messages.title.current))},setAddToCartWithCaptcha:function(a){ja=a},updateFilterResultAccessibility:function(){var a=$("#performances_and_events .product"),b=$("#accessibility_filter_result");void 0!==a&&""!==a&&(b.html(""),a.each(function(){$("<div></div>").text($(this).text()).appendTo(b)}))}}});
tools.makePath("seasontickets.performances.Event");
seasontickets.performances.Event=function(a,b,c){var d,f=a.subTopicIds;this.id=String(a.id);this.name=a.name;this.description=a.description;this.logo=a.logo;this.subjectCode=a.subjectCode||seasontickets.performances.Subject.NO_SUBJECT_CODE;this.subtitle=a.subtitle;this.subjects=[];this.multiplePerformances=a.multiplePerformances;this.uniquePerformance=null;this.performanceList=[];this.performances={};this.selectedPerformances=this.available=0;if(f){this.subtopics=[];var e=0;for(d=f.length;e<d;e++)this.subtopics.push(b[f[e]])}this.firstTopicCode=
"undefined"!==typeof c?c[a.id]:null;this.noTopics=!1};seasontickets.performances.Event.prototype.addPerformance=function(a){this.performanceList.push(a);this.performances[a.id]=a};
seasontickets.performances.Event.prototype.getView=function(a,b,c){var d=null;if(a){var f=!0;var e=seasontickets.performances.Performance;e=e.getViewFromList(this.performanceList,b,a,null,!0,c);var g=e.performances;b=0;for(c=g.length;b<c;b++)if(a=g[b].venue,!d)d=a;else if(d.id!==a.id){f=!1;break}e.onePerformance=1===c;f&&(e.singleVenue=d)}else e={};e.name=this.name;e.subtitle=this.subtitle;e.logo=this.logo;e.eventId=this.id;e.available=0<this.available;e.subject=this.subject;e.subjects=this.subjects;
if(this.subtopics&&!this.noTopics)for(e.hasTopics=!0,e.subtopics=[],b=0,c=this.subtopics.length;b<c;b++)e.subtopics.push({name:this.subtopics[b].name,topic:this.subtopics[b].topic,isLast:b===c-1});e.firstTopicCode=this.firstTopicCode;return e};
seasontickets.performances.Event.getViewFromList=function(a,b,c,d,f,e){var g=null,h=[],l=[],k=seasontickets.performances.filters.getName,m=null,p=[],q=[];$.each(a,function(){l=l.concat(this.performanceList)});g=seasontickets.performances.Performance.getViewFromList(l,b,c,null,null,e);delete g.performances;m=c.filterEvent?k(c.filterEvent):null;$.each(a,function(){if(this.subject){var a=this.subject.index;p[a]||(p[a]=[]);var b=p[a];b.push(this);p[a]=b}});Object.keys(p).forEach(function(a){$.merge(q,
p[a])});$.each(q,function(){m&&m!==this.name||b&&this.subject!==b&&this.subjects&&-1===this.subjects.indexOf(b)||(w=this.getView(c,b,e),w.performances&&0<w.performances.length&&(w.soldout&&(w.performances=[]),h.push(w),f[this.id]&&(w.selected=!0)))});if(d){if(d.target){var r=d.target.event.id;var t=d.target.id;a=0;for(k=h.length;a<k;a++){var w=h[a];if(w.eventId===r){d.page=Math.floor(a/d.nbPerPage)+1;d.target=null;w.selected=!0;a=0;for(k=w.performances.length;a<k;a++)if(r=w.performances[a],r.id===
t){r.isTarget=!0;break}break}}d.target&&(d.page=1,d.target=null)}d=seasontickets.performances.filters.paginate(h,d);h=d.list;g.pagination=d.view}g.events=h;f.nbEvents=h.length;return g};
(function(){var a=null,b=function(b,d,f){f||(b.selectedQuantity=1);return{id:b.id,seatMapImage:b.seatMapImage,venue:b.venue,time:b.time,date:b.date,available:!0,defined:!0,logo:b.logo,maxTickets:d,quantity:b.selectedQuantity,multipleTickets:a.fixedPrice,noPriceDisplay:a.fixedPrice,subject:b.subject,match:b.match}};tools.makePath("seasontickets.performances.Performance");seasontickets.performances.Performance=function(b,d,f,e,g,h,l,k,m,p,q,r){var c=b.start,w=new Date(c[0],c[1]-1,c[2],c[3],c[4],c[5]);
c=b.seatCategories;var y=b.allowUpDownSeatCat,z=b.upDownSeatCategories,x=jQuery.datepicker.formatDate,A=seasontickets.performances.SeatCategory;this.isOptionMode=l;this.id=b.id;this.subjectCode=b.subjectCode||seasontickets.performances.Subject.NO_SUBJECT_CODE;this.venue=f[b.venueCode];this.event=d[b.eventId];this.prices=this.getPriceList(!1,b.prices);this.seatMapImage=b.seatMapImage?contextPath+b.seatMapImage:null;this.logo=b.logo;this.jsDate=w;d=w.getHours();f=w.getMinutes();d=10>d?"0"+d:String(d);
f=10>f?"0"+f:String(f);this.time=d+":"+f;this.date=x(datePickerConfig.dateFormatLong,w,datePickerConfig);this.dateShort=x(datePickerConfig.dateFormat,w,datePickerConfig);this.dateMedium=x(seasonTicketPerformanceMediumDatePattern,w,datePickerConfig);b.match&&(this.match=b.match,this.match.hostName=q[b.match.hostId],this.match.opposingName=q[b.match.opposingId],this.match.hostLogo=r[b.match.hostId],this.match.opposingLogo=r[b.match.opposingId]);this.event.addPerformance(this);this.priceDisplay="";this.available=
this.price=0;this.availability=a.AVAIL_GOOD;this.seatCategories=[];this.allblocks=[];this.blocksMap={};this.defaultAreaId=p;this.soldOutSeatCatsName=b.soldOutSeatCatsName;this.upDownGradeSeatCategories=[];this.allowUpDownSeatCat=y;this.soldOutSeatCats=!1;this.selectedBlockId=this.selectedAreaBlockId=this.selectedSeatCategoryId=null;this.selectedQuantity=1;this.selections=[];p=0;for(q=c.length;p<q;p++)r=c[p],r=new A(r.seatCategoryId,r.areas,e,g,h),this.allblocks=this.allblocks.concat(r.allblocks),
this.seatCategories.push(r);if(y)for(p=0,q=z.length;p<q;p++)r=z[p],r=new A(r.seatCategoryId,r.areas,e,g,h),this.allblocks=this.allblocks.concat(r.allblocks),this.upDownGradeSeatCategories.push(r);p=0;for(q=this.allblocks.length;p<q;p++)e=this.allblocks[p],this.blocksMap[e.id]=e;null!==k&&(this.allowAdditionalSeats=k)&&(this.additionalSeatsMaxQuantityPerPerformance=m,this.additionalSeatsPrices=this.getPriceList(!0,b.prices))};a=seasontickets.performances.Performance;a.prototype.buildPrices=function(a){var b=
this.prices;var c=null;if(b){c={};var e=0;for(b=b.length;e<b;e++){var g=this.prices[e];var h=g.audienceSubCategoryId;var l=g.priceLevelId;var k=g.seatCategoryId;c[k]||(c[k]={});c[k][h]||(c[k][h]={});c[g.seatCategoryId][h][l]=g.amount}this.priceMap=c}e=0;for(b=this.seatCategories.length;e<b;e++)this.seatCategories[e].buildPrices(c,a);e=0;for(b=this.upDownGradeSeatCategories.length;e<b;e++)this.upDownGradeSeatCategories[e].buildPrices(c,a);this.selectAreaBlock()};a.prototype.getPriceList=function(a,
b){return null!==b?jQuery.grep(b,function(b,c){return b.additionalSeatPrice===a}):null};a.prototype.setAvailability=function(b,d){var c=b?b.seatCategoryAvailabilities:null,e;this.availability=b?b.availability:seasontickets.performances.Performance.AVAIL_GOOD;this.availability===seasontickets.performances.Performance.AVAIL_NONE?this.available=0:null!==d&&(this.available=d);if(c){d=0;for(e=this.seatCategories.length;d<e;d++)b=this.seatCategories[d],(b.priceDisplay||a.fixedPrice)&&b.setAvailability(c[b.id]);
d=0;for(e=this.upDownGradeSeatCategories.length;d<e;d++)b=this.upDownGradeSeatCategories[d],b.setAvailability(c[b.id])}};a.prototype.selectAreaBlock=function(a){var b,c=null;if(a){var e=this.allblocks.length;a&&(a=a.replace(/_\d+$/gi,""));this.priceDisplay=this.price=this.selectedAreaBlockId=this.selectedSeatCategoryId=this.selectedBlockId=null;for(b=0;b<e;b++){var g=this.allblocks[b];g.id===a&&g.isAvailable?c=g:g.selected=!1}c&&(c.selected=!0,this.selectedBlockId=c.id,this.selectedSeatCategoryId=
c.seatCategoryId,this.selectedAreaBlockId=c.areaBlockId,this.priceDisplay=c.seatCategory.priceDisplay,this.price=this.priceMap?this.priceMap[this.selectedSeatCategoryId]:null)}};a.prototype.selectQuantity=function(a){this.selectedQuantity=a};a.prototype.setBooked=function(a){var b=a.quantity,c=this.event;this.available-=b;c.available-=b;c.selectedPerformances+=b;c.uniquePerformance=this.id;this.selections.push(a);this.selectAreaBlock()};a.prototype.setFree=function(a){var b,c=this.event;for(b=this.selections.length-
1;0<=b;b--){var e=this.selections[b];e===a&&(e=a.quantity,this.available+=e,c.available+=e,c.selectedPerformances-=e,this.selections.splice(b,1))}c.selectedPerformances||(c.uniquePerformance=null);this.selectedQuantity=1};a.prototype.setFailed=function(a){a&&a.seatCategory.setFailed(a)};a.prototype.getSelectedBlock=function(){return this.blocksMap[this.selectedBlockId]};a.prototype.getSelectedQuantity=function(){return this.selectedQuantity};a.prototype.getSubscriberQuantity=function(){return this.subscriberQuantity};
a.prototype.setSubscriberQuantity=function(a){this.subscriberQuantity=a};a.prototype.getAdditionalPriceDisplay=function(a){return"<span class='plus'>+</span>"+functions.generateAmount(a)};a.prototype.getAdditionalSeatPrice=function(a,b){var c,d=null;for(c=0;c<this.additionalSeatsPrices.length;c++){var g=this.additionalSeatsPrices[c];if(g.seatCategoryId===parseInt(a,10)&&g.audienceSubCategoryId===parseInt(b,10)){d=g;break}}return d.amount};a.prototype.getTotalAdditionalSeatsPrice=function(){var a=
0;this.selectedAdditionalSeats&&jQuery.each(this.selectedAdditionalSeats,function(b,c){a+=c.price});return a};a.prototype.addSelectedAdditionalSeat=function(a,b){var c=this.getAdditionalSeatPrice(a,b);this.selectedAdditionalSeats.push({seatCategoryId:a,audienceSubCategoryId:b,price:c})};a.prototype.getView=function(c){var d=this.selections,f=[],e=[],g=[],h=null,l,k=this.event.getView(),m=0,p=!0,q=this.seatCategories.length,r=null,t=seasontickets.performances.viewHelper,w=this.getMaxTickets(),y=0,
z=this.additionalSeatsPrices&&0<this.additionalSeatsPrices.length,x=this.additionalSeatsMaxQuantityPerPerformance&&0<this.additionalSeatsMaxQuantityPerPerformance,A,C;for(m=0;m<q;m++){var u=this.seatCategories[m];u.id===this.selectedSeatCategoryId&&(this.priceDisplay=u.priceDisplay||"");u.block.isAvailable&&g.push(u);e.push(u)}if(0===g.length&&!this.isOptionMode&&this.allowUpDownSeatCat)for(e=[],this.soldOutSeatCats=!0,m=0;m<this.upDownGradeSeatCategories.length;m++)u=this.upDownGradeSeatCategories[m],
u.id===this.selectedSeatCategoryId&&(this.priceDisplay=u.priceDisplay||""),u.block.isAvailable&&g.push(u),e.push(u);m=0;for(q=d.length;m<q;m++){u=d[m];if(u.selected){r=u;break}var v=b(this,w,p||r);v.event=k;v.selection=!0;v.selectionIndex=m;v.selectionId=u.id;v.singleCategory=1===g.length&&!!g[0].getSingleBlock();v.canModify=u.hasSelection&&!u.onGoingBooking;v.onGoingBooking=u.onGoingBooking;v.quantity=u.quantity;v.quantitySingular=1===u.quantity;p=p&&u.booked;if(l=u.block)u=l.seatCategory,v.priceDisplay=
u.priceDisplay,v.singleBlock={id:l.id,seatCategoryName:u.name,blockName:l.areaBlockId?l.name:""},f.push(v)}r&&(f=[],this.selectQuantity(r.quantity),r.block&&this.selectAreaBlock(r.block.id));this.availability===seasontickets.performances.Performance.AVAIL_NONE&&(g=[]);if((!this.event.available||f.length&&!this.available)&&!r||f.length&&1==e.length&&!p)return f;r||1!==g.length||((h=g[0].getSingleBlock())?this.selectAreaBlock(h.id):this.defaultAreaId?this.selectAreaBlock(g[0].id+"#"+this.defaultAreaId):
this.selectAreaBlock(g[0].block.id));m=0;for(q=e.length;m<q;m++)e[m]=e[m].getView();v=b(this,w,r);v.event=k;v.available=0<this.available;v.defined=!!this.selectedBlockId;v.singleBlock=h;v.singleCategory=1===g.length;v.seatCategories=e;v.priceDisplay=this.priceDisplay;v.soldout=0===g.length&&!this.isOptionMode;v.soldOutSeatCats=this.soldOutSeatCats;v.soldOutSeatCatsName=this.soldOutSeatCatsName;v.allowAdditionalSeats=this.allowAdditionalSeats&&x&&z;v.hideButton=c||!a.fixedPrice?!1:!(seasontickets&&
seasontickets.multiplePerformancesMap&&seasontickets.multiplePerformancesMap[this.event.id])&&!!this.event.selectedPerformances;if(v.allowAdditionalSeats){this.selectedAdditionalSeats&&(y=this.selectedAdditionalSeats.length);var D=[];if(C=1===g.length?g[0].id:this.selectedSeatCategoryId)c=jQuery.grep(this.additionalSeatsPrices,function(a){return a.seatCategoryId===parseInt(C,10)}),jQuery.each(c,function(a,b){A={id:b.audienceSubCategoryId,priceLevelId:b.priceLevelId,name:b.audienceSubCategory};D.push(A)});
0<D.length||!C?(v.additionalSeatsInfo=this.getAdditionalSeatsInfo(this.selectedAdditionalSeats,this.additionalSeatsMaxQuantityPerPerformance,this.getSubscriberQuantity(),D,v.defined,C),v.additionalSeatsQuantity=y):v.allowAdditionalSeats=!1}r&&(v.modify=!0,v.selection=!0,v.quantity=r.quantity);v.multipleTickets&&1<v.maxTickets&&(v.quantityStruct=t.getSelectNumberStructure(v.quantity,1,v.maxTickets),v.hasQuantityStruct=!0);(0<e.length||!a.fixedPrice)&&f.push(v);v.quantitySingular=1===v.quantity;return f};
a.prototype.getAdditionalSeatsInfo=function(a,b,f,e,g,h){var c=[],d=0,m,p;a&&(d=a.length);for(m=0;m<b*f;m++){var q="";var r=m<d?!1:!0;var t=d===m+1?!0:!1;var w=[];for(p=0;p<e.length;p++){var y=e[p];var z=a&&m<d&&y.id===parseInt(a[m].audienceSubCategoryId,10)?!0:!1;z={id:y.id,name:y.name,priceLevelId:y.priceLevelId,selected:z&&g};w.push(z)}a&&m<d&&(q=this.getAdditionalPriceDisplay(a[m].price));p=0===m;c.push({quantity:m+1,selected:t&&g,hidden:r||!g,audSubCatOptions:w,showAudSubCatSelect:1<w.length||
!h,price:q,isFirst:p})}return c};a.prototype.getMaxTickets=function(){var b=[this.event.available,this.available,a.MAX_TICKETS],d=this.event.subject?this.event.subject.getMaxAllowedTickets():void 0,f=seasontickets.performances.allowedTicketsNumber;f&&b.push(f);d&&b.push(d);return Math.min.apply(null,b)};a.getViewFromList=function(a,b,f,e,g,h){var c=!0,d;var m=0;for(d=a.length;m<d;m++){var p=a[m].getView(h);if(p.length&&!p[p.length-1].soldout){c=!1;break}}a=f.filterAndExtractPerformances(a,b,g);b=
a.performances;m=0;for(d=b.length;m<d;m++)b[m]=b[m].getView(h);a.soldout=c;b=Array.prototype.concat.apply([],b);c=!1;m=0;for(d=b.length;m<d;m++)if(h=b[m],!h.selection){if(!h.soldout&&h.available){c=!0;break}}else if(h.modify){c=!0;break}a.available=c;if(e){if(e.target){h=e.target.id;m=0;for(d=b.length;m<d;m++)if(b[m].id===h){e.page=Math.floor(m/e.nbPerPage)+1;e.target=null;b[m].isTarget=!0;break}e.target&&(e.page=1,e.target=null)}f=f.paginate(b,e);a.performances=f.list;a.pagination=f.view}else a.performances=
b;return a};a.AVAIL_GOOD="GOOD";a.AVAIL_NONE="NONE";a.AVAIL_LIMITED="LIMITED";a.MAX_TICKETS=20})();
(function(){var a=function(a,b){b&&(a.availability=b,b===seasontickets.performances.Performance.AVAIL_NONE&&(a.isAvailable=!1))},b=function(a,b){return a.name>b.name?1:a.name<b.name?-1:0};tools.makePath("seasontickets.performances.SeatCategory");seasontickets.performances.SeatCategory=function(a,d,f,e,g){e=[];var c=[];this.id=String(a);this.name=f[a];this.allblocks=this.areas=null;this.blocksMap={};var l=this.createBlock("",this.name);c.push(l);this.block=l;f=0;for(a=d.length;f<a;f++){var k=d[f];
l=k.areaId;l=this.createBlock(l,g[k.areaId]);e.push(l);c.push(l);k=[];l.blocks=k}e.sort(b);this.areas=e;this.allblocks=c};seasontickets.performances.SeatCategory.prototype.createBlock=function(a,b){var c=this.id;return{id:a?String(c)+"#"+a:String(c),name:b,selected:!1,seatCategory:this,seatCategoryId:c,areaBlockId:String(a),isAvailable:!0,availability:seasontickets.performances.Performance.AVAIL_GOOD}};seasontickets.performances.SeatCategory.prototype.setAvailability=function(b){var c,f;if(b&&(a(this.block,
b.availability),b=b.areaBlockAvailabilities)){var e=0;for(c=this.areas.length;e<c;e++){var g=this.areas[e];var h=b[g.areaBlockId]||{};a(g,h.areaAvailability);if(h=h.blockAvailabilities){var l=0;for(f=g.blocks.length;l<f;l++){var k=g.blocks[l];a(k,h[k.areaBlockId])}}}}};seasontickets.performances.SeatCategory.prototype.getView=function(){var a=this.areas,b=seasontickets.performances.Performance,f=[],e=null,g;var h=0;for(g=a.length;h<g;h++){var l=a[h];var k=l.availability;if(e&&e.name===l.name){var m=
e.availability;if(m!=b.AVAIL_GOOD&&(k===b.AVAIL_GOOD||m==b.AVAIL_NONE&&k==b.AVAIL_NONE))f[f.length-1]=l;else continue}else f.push(l);e=l}return{id:this.id,name:this.name,areas:f,block:this.block,available:!!this.block.isAvailable}};seasontickets.performances.SeatCategory.prototype.getSingleBlock=function(){var a=null,b;var f=0;for(b=this.areas.length;f<b;f++){var e=this.areas[f];if(e.isAvailable)if(a){a=null;break}else a=e}return a?{id:a.id,seatCategoryName:this.name,blockName:a.name}:null};seasontickets.performances.SeatCategory.prototype.buildPrices=
function(a,b){var c=[],d=0,g,h=b.length;if(a){for(g=0;g<h;g++){var l=b[g];var k=a[this.id][l.id]&&(a[this.id][l.id][l.priceLevelId]||0===a[this.id][l.id][l.priceLevelId])?a[this.id][l.id][l.priceLevelId]:null;d+=l.quantity*k;k=functions.generateAmount(k);c.push(l.quantity+"<span class='multiplicator'>x</span>"+k);if(null==k)break}k?(this.priceDisplay=c.join("<br/>"),this.simplePriceDisplay=functions.generateAmount(d)):this.simplePriceDisplay=this.priceDisplay=""}};seasontickets.performances.SeatCategory.prototype.setFailed=
function(b){var c,f=this.areas.length,e=!1;if(b)for(b.isAvailable=!1,c=0;c<f;c++)if(this.areas[c].isAvailable){e=!0;break}e&&b.areaBlockId||a(this.block,seasontickets.performances.Performance.AVAIL_NONE)}})();
(function(){var a=null,b=0,c=null,d=function(){this.data.version=c},f=new Date(0),e=function(){2E4>new Date-f||(f=new Date,a||(a=0<$(".countdown_box").length),requestQueuing.addRequest({url:contextPath+"/ajax/countdown",method:"GET",delay:1E3,delayAfter:1E3,done:function(b){$.trim(b)&&(b=$(b),a?b.find(".countdown_box").remove():$("#secondary_content_seasonticket .button.validate:first").after(b.find(".countdown_box")),$("#secondary_content_seasonticket").after(b),a=!0)}},!0))};tools.makePath("seasontickets.performances.Selection");
seasontickets.performances.Selection=function(a,c,d,e,f){e=a.eventId;var g=a.performanceId,h;this.id=String(b++);this.areaBlockId=this.seatCategory=this.performance=this.event=null;this.fixed=!0===a.fixed;this.booked=!0===a.booked;this.optional=!0===a.optional;this.mandatory=!1!==a.mandatory;this.categoryOnly=!0===a.categoryOnly;this.hasSelection=!this.fixed&&!this.booked||this.categoryOnly;this.selected=this.failed=this.onGoingBooking=!1;this.price=null;this.subject=f;this.block=null;this.index=
a.index;this.quantity=a.seatQuantity?a.seatQuantity:0;e&&(this.event=c[e]);if(g)if(this.performance=d[g],!this.performance)seasontickets.performances.errors.cantBookErrorDialog();else if(a.seatCategoryId&&this.performance){c=a.areaBlockId?a.seatCategoryId+"#"+a.areaBlockId:String(a.seatCategoryId);this.performance.selectAreaBlock(c);this.performance.selectQuantity(this.quantity);if((c=a.additionalSeatQuantitiesByAudSubCat)&&!jQuery.isEmptyObject(c))for(h in this.performance.selectedAdditionalSeats=
[],c)if(c.hasOwnProperty(h))for(d=0;d<c[h];d++)this.performance.addSelectedAdditionalSeat(a.seatCategoryId,h);this.updateFromPerformance(this.performance);this.performance.setBooked(this)}};var g=seasontickets.performances.Selection;g.prototype.updateFromPerformance=function(a){this.performance=a;this.price=a.price;this.event=a.event;this.quantity=a.getSelectedQuantity();if(this.block=a.getSelectedBlock())this.seatCategory=this.block.seatCategory,this.areaBlockId=this.block.areaBlockId;a.selectedAdditionalSeats&&
(this.selectedAdditionalSeats=a.selectedAdditionalSeats)};g.prototype.setFailed=function(a,b,c){this.oneMorePerf=this.onGoingBooking=!1;this.performance&&(a&&this.performance.setAvailability(a,null),b||this.performance.setFailed(this.block));this.reset(!0);c?(this.performance=c.performance,this.performance.selectAreaBlock(c.block.id),this.performance.selectQuantity(c.quantity),this.updateFromPerformance(this.performance),this.performance.setBooked(this),this.subject.sync()):(this.failed=!0,this.optional&&
this.subject.removeSelection(this))};g.prototype.reset=function(a){this.performance&&this.performance.setFree(this);this.optional&&a&&(this.event=null);!this.categoryOnly&&this.performance&&(this.performance=null);this.price=this.block=this.seatCategory=null;this.failed=!1;this.quantity=0;this.subject.sync()};g.prototype.getView=function(a,b){a={optional:this.optional,selected:this.selected,mandatory:this.mandatory,id:this.id,index:this.index,code:this.subject.code,unlock:!this.selected&&!this.isBooked()&&
!this.failed&&(this.mandatory&&!this.optional||a&&this.subject.checkCanBook(!1)),failed:this.failed,remove:!1,oneMorePerf:b};b=this.performance;var c=1,d;if(1<this.quantity)for(a.quantity=this.quantity,a.tickets=[],d=this.quantity;c<d;c++)a.tickets.push({value:c});this.event&&(a.name=this.event.name,a.subtitle=this.event.subtitle,b&&!this.selected||this.categoryOnly&&null!==b)&&(a.venue=b.venue.name,a.date=b.dateMedium,a.time=b.time,a.fixed=this.fixed,a.booked=this.booked,this.seatCategory&&!this.selected&&
(a.defined=!this.onGoingBooking&&!this.booked,a.category=this.seatCategory.name,a.price=this.seatCategory.simplePriceDisplay,b.selectedAdditionalSeats&&(a.additionalSeatsQuantity=b.selectedAdditionalSeats.length,a.additionalSeatsPrice=functions.generateAmount(b.getTotalAdditionalSeatsPrice()),a.singleAdditionalSeat=1===a.additionalSeatsQuantity)),a.defined&&(this.hasSelection||b.allowAdditionalSeats)&&!this.onGoingBooking&&(a.modify=!0,a.remove=this.optional));a.onGoingBooking=this.onGoingBooking;
return a};g.prototype.getPrice=function(a,b){return this.price?(a=this.price[a]&&this.price[a][b]?this.price[a][b]:0,a*this.quantity):0};g.prototype.book=function(a,b){var f=a.selectedQuantity,h=this,l=a.subject.code||this.subject.code,q={performanceId:a.id,eventId:a.event.id,seatCategoryId:a.selectedSeatCategoryId,areaBlockId:a.selectedAreaBlockId},r=!1,t=null,w=[],y=!1,z=0;l&&l!=seasontickets.performances.Subject.NO_SUBJECT_CODE&&(q.subjectCode=l);1<f&&(q.quantity=f);if(this.selected&&this.block){if(this.performance===
a&&a.getSelectedBlock()===this.block&&this.quantity==f&&this.selectedAdditionalSeats===a.selectedAdditionalSeats){setTimeout(function(){b(h,!1)},10);return}t={performance:this.performance,block:this.block,quantity:this.quantity};this.reset(!0);r=!0}if(r||this.event)q.index=this.index;a.selectedAdditionalSeats&&($.each(a.selectedAdditionalSeats,function(a,b){w.push(b.audienceSubCategoryId)}),q.additionalSeatsAudSubCatIds=w);this.updateFromPerformance(a);this.quantity=f;a.setBooked(this);this.subject.sync();
this.failed=!1;this.onGoingBooking=!0;requestQueuing.addRequest({data:q,url:contextPath+"/ajax/subscription/"+(g.fixedPrice?"fixedPrice/":"")+"createOperation"+window.location.search,method:"POST",done:function(a){a.version&&(c=a.version);if(a.success)e(),h.onGoingBooking=!1,h.failed=!1,$.isEmptyObject(a.updatedTariffs)||$("#page_selection_subscription_performances").addClass("degressive_rate_applied");else if(a.status){if(r&&(t=null),!seasontickets.performances.errors.handleError(a.status))if(a.status===
seasontickets.performances.errors.ERR_AVAILABILITY)z=a.availability-h.performance.subscriberQuantity,h.performance.selectedAdditionalSeats&&0<h.performance.selectedAdditionalSeats.length&&0<z?(y=!0,seasontickets.performances.errors.additionalSeatsFullDialog("additionalSeatsAvailabilityErrorDialog",z)):seasontickets.performances.errors.bookingFailedErrorDialog(h),h.setFailed(a.updatedAvailability,y,t);else{if(a.status===seasontickets.performances.errors.ERR_INSUFFICIENT_TICKETS)tools.dialog.showDialog("insufficientTicketsPerformance",
!0,!0,null,"message_dialog");else if(a.status===seasontickets.performances.errors.ERR_TOTAL_QUANTITY_EXCEEDED){var d=$("#totalQuantityExceededLimit .message.error .content p");tools.replaceJSPArgument(d,"{0}",a.requestedQuantity);tools.replaceJSPArgument(d,"{1}",a.limit);tools.dialog.showDialog("totalQuantityExceededLimit",!0,!0,null,"message_dialog")}else a.status===seasontickets.performances.errors.ERR_ORDER_ITEM_EXCEEDED&&(d=$("#orderItemExceededLimit .message.error .content p"),tools.replaceJSPArgument(d,
"{0}",a.requestedQuantity),tools.replaceJSPArgument(d,"{1}",a.limit),tools.dialog.showDialog("orderItemExceededLimit",!0,!0,null,"message_dialog"));h.setFailed(null,!1,t)}}else if("string"===typeof a)return seasontickets.performances.errors.sessionExpiredErrorDialog();b(h,h.failed,a.updatedTariffs)},fail:function(a){seasontickets.performances.errors.ajaxErrorDialog(a)&&(h.setFailed(),requestQueuing.stop());b(h,!0)},before:d})};g.prototype.remove=function(a){var b=this.subject.code,f={index:this.index};
b===seasontickets.performances.Subject.NO_SUBJECT_CODE&&(b=null);b&&(f.subjectCode=b);this.seatCategory&&(this.seatCategory.available+=this.quantity,this.performance.setFree(this),this.performance.selectedAdditionalSeats&&(this.performance.selectedAdditionalSeats=[]));this.price=null;this.subject.removeSelection(this);requestQueuing.addRequest({data:f,url:contextPath+"/ajax/subscription/"+(g.fixedPrice?"fixedPrice/":"")+"cancelOperation"+window.location.search,method:"POST",done:function(b){b.version&&
(c=b.version);b.success&&(e(),$.isEmptyObject(b.updatedTariffs)||$("#page_selection_subscription_performances").removeClass("degressive_rate_applied"));a(null,null,b.updatedTariffs)},fail:function(b){seasontickets.performances.errors.ajaxErrorDialog(b)&&requestQueuing.stop();a(null,!0)},before:d})};g.prototype.isBooked=function(){return this.block||this.booked};g.prototype.adjustForModify=function(a){if(!this.performance)return 0;var b=a?-this.quantity:this.quantity;var c=this.event;var d=c.subject;
c.available+=b;this.performance.available+=b;this.optional?null!==d.maxOptional&&(d.maxOptional+=b):d.included+=b;a?c.uniquePerformance=this._tempUniquePerformance:(this._tempUniquePerformance=c.uniquePerformance,c.uniquePerformance=null);return b};g.setVersion=function(a){c=a}})();
tools.makePath("seasontickets.performances.Subject");
seasontickets.performances.Subject=function(a,b,c,d,f,e){var g=seasontickets.performances.Selection,h=[],l=0,k=this;this.code=a.subjectCode;this.minOptional=a.minOptional||0;this.maxOptional=a.maxOptional;this.selectedIndex=0;this.name=this.code?d[this.code].name:"";this.allFixed=!0;this.cannotBookMessages={};this.optional=this.index=0;this.canHaveOptional=0!==this.maxOptional;this.code||(this.code=seasontickets.performances.Subject.NO_SUBJECT_CODE);jQuery.each(a.configuration,function(){var a=new g(this,
b,c,f,k,e);a.index=h.length;h.push(a);a.optional||(l+=a.quantity);a.fixed||(this.allFixed=!1)});this.selections=h;this.sync();this.included=l;this.allOptional=0===l};seasontickets.performances.Subject.prototype.getSelection=function(){return this.selections[this.selectedIndex]};
seasontickets.performances.Subject.prototype.getNextSelectIndex=function(a,b){var c=this.selections.length,d,f=this.selections[this.selectedIndex],e=!1,g=!1,h=0;this.canHaveOptional=b=!0===seasontickets.performances.Selection.fixedPrice?b&&(null===this.maxOptional||0<this.maxOptional):b&&0<(this.maxOptional||1);f&&(f.selected=!1);0===c&&0!==this.maxOptional&&(this.addOptionalSelection(!1),c++);for(d=0;d<c;d++){f=this.selections[d];h+=f.quantity;if(d===this.selectedIndex&&g)break;if(!f.isBooked()){if(a||
f.mandatory){e=!0;break}return!1}d===c-1&&(!b||this.maxOptional&&h===this.included+this.maxOptional?(d=-1,g=!0):(this.addOptionalSelection(!1),a?e=!0:(d=-1,g=!0,c++)))}if(!e)return!1;this.selectedIndex=d;return this.selections[this.selectedIndex].selected=!0};
seasontickets.performances.Subject.prototype.getView=function(a,b,c,d){var f={subjectName:this.name,subjectCode:this.code},e=[],g=[],h=[],l=this.selections.length;this.canHaveOptional=b;if(c)f.validation=!0,f.totalSelected=this.getNbSelections(),f.hasOneSelectedEvent=1===f.totalSelected;else{for(var k=0;k<l;k++){c=this.selections[k].getView(a,d);if(c.unlock||c.selected)a=!1;c.name||(d=!1);c.optional?(c.mandatory||b||c.defined||c.onGoingBooking||c.selected)&&h.push(c):c.booked?g.push(c):e.push(c);
f.mandatory=k<this.minOptional}f.bookedEvents=g;f.hasBookedEvents=0<g.length;f.hasOneBookedEvent=1===g.length;f.events=e;f.hasEvents=0<e.length;f.hasOneEvent=1===e.length;f.optionalEvents=h;f.hasOptionalEvents=0<h.length}f.hasMinOnly=!!this.minOptional&&!this.maxOptional;f.hasMaxOnly=!!this.maxOptional&&!this.minOptional;this.minOptional&&this.maxOptional&&(f.isFixed=this.minOptional===this.maxOptional,f.hasMinMax=!f.isFixed);f.noMinNoMax=!this.minOptional&&!this.maxOptional;f.hasMinOnly&&1===this.minOptional&&
(f.hasMinOnly=!1,f.hasMinOnlySingular=!0);f.hasMaxOnly&&1===this.maxOptional&&(f.hasMaxOnly=!1,f.hasMaxOnlySingular=!0);f.isFixed&&1===this.maxOptional&&(f.isFixed=!1,f.isFixedSingular=!0);f.minOptional=this.minOptional;f.maxOptional=this.maxOptional;return f};
seasontickets.performances.Subject.prototype.getPrice=function(a){var b={},c=a.length;$.each(this.selections,function(){var d;for(d=0;d<c;d++){var f=a[d];var e=f.id;f=f.priceLevelId;b[e]||(b[e]={});b[e][f]||(b[e][f]=0);b[e][f]+=this.getPrice(e,f)}});return b};seasontickets.performances.Subject.prototype.getTotalAdditionalSeatsPrice=function(){var a=0,b=null;$.each(this.selections,function(){b=this.performance;null!==b&&(a+=b.getTotalAdditionalSeatsPrice())});return a};
seasontickets.performances.Subject.prototype.checkCanBook=function(a){var b=!0,c={};$.each(this.selections,function(){!1!==a&&this.onGoingBooking&&(c.ongoingRequest=!0,b=!1);this.mandatory&&(this.failed?(c.failedRequest=!0,b=!1):this.isBooked()||this.oldSelection||(this.optional?c.minimumNotReached=!0:this.performance?c.missingSeatCategory=!0:c.missingPerformance=!0,b=!1))});this.cannotBookMessages=c;return b};
seasontickets.performances.Subject.prototype.removeSelection=function(a){var b,c=this.selections.length;for(b=0;b<c;b++){var d=this.selections[b];d===a&&(this.selections.splice(b,1),this.selectedIndex>b&&this.selectedIndex--)}this.sync();a.selected&&(this.selectedIndex=0)};seasontickets.performances.Subject.prototype.checkCanAdd=function(a){return null!==this.getFreeMatch(a,!0)};
seasontickets.performances.Subject.prototype.getFreeMatch=function(a,b){var c=this.selections.length;for(b=0;b<c;b++){var d=this.selections[b];if(!d.isBooked()&&!d.onGoingBooking&&(d.optional&&(d.mandatory||this.canHaveOptional)||d.event&&d.event===a.event))return d}return null};seasontickets.performances.Subject.prototype.addOptionalSelection=function(a){this.selections.push(new seasontickets.performances.Selection({optional:!0,index:this.selections.length,mandatory:a},null,null,null,this))};
seasontickets.performances.Subject.prototype.hasFailure=function(){var a,b=this.selections.length;for(a=0;a<b;a++)if(this.selections[a].failed)return!0;return!1};seasontickets.performances.Subject.prototype.getNbSelections=function(){var a=0,b,c=this.selections.length;for(b=0;b<c;b++)a+=this.selections[b].quantity;return a};seasontickets.performances.Subject.prototype.getNbOptional=function(){return this.optional};
seasontickets.performances.Subject.prototype.getSelectionToModifyIndex=function(){var a,b=this.selections.length;for(a=0;a<b;a++){var c=this.selections[a];if(c.block&&c.hasSelection)return a}return null};
seasontickets.performances.Subject.prototype.sync=function(){for(var a=this.selections,b=a.length,c=0,d=0,f=1,e,g,h=0;h<b;h++)e=a[h],e.index=h,f=e.quantity,e.optional&&((g=c<this.minOptional)?(e.mandatory=!0,c+=f||1,d+=f||1):(d+=f,e.mandatory?e.isBooked()?e.mandatory=!1:(a.splice(h,1),b--,h--):d!=this.maxOptional||f||(a.splice(h,1),b--,h--)));for(;c<this.minOptional;)this.addOptionalSelection(!0),c++,d++,f=0;this.canHaveOptional&&f&&(null===this.maxOptional||d<this.maxOptional)&&this.addOptionalSelection(!1);
this.optional=d};seasontickets.performances.Subject.prototype.getMaxAllowedTickets=function(){return null===this.maxOptional?null:this.maxOptional+this.included-this.getNbSelections()};seasontickets.performances.Subject.NO_SUBJECT_CODE="__NO_SUBJECT__";
tools.module("seasontickets.performances.errors",{ERR_CONCURRENT_MODIFICATION:"ERR_CONCURRENT_MODIFICATION",ERR_CONFIGURATION_NOT_FOUND:"ERR_CONFIGURATION_NOT_FOUND",ERR_INCORRECT_CONFIGURATION:"ERR_INCORRECT_CONFIGURATION",ERR_TOO_MANY_TICKETS:"ERR_TOO_MANY_TICKETS",ERR_TOO_FEW_TICKETS:"ERR_TOO_FEW_TICKETS",ERR_AVAILABILITY:"ERR_AVAILABILITY",ERR_INSUFFICIENT_AVAIL_EVENTS:"ERR_INSUFFICIENT_AVAIL_EVENTS",ERR_CART_NOT_EMPTY:"ERR_CART_NOT_EMPTY",ERR_ALREADY_FULL:"ERR_ALREADY_FULL",ERROR_NOT_ENOUGH_SEAT_SAME_BLOCK:"ERROR_NOT_ENOUGH_SEAT_SAME_BLOCK",
ADVANTAGE_ALREADY_USED_ATTRIBUTE:"ADVANTAGE_ALREADY_USED_ATTRIBUTE",CANNOT_ATTRIBUTE_SEATS_BECAUSE_OF_DISTANCING:"CANNOT_ATTRIBUTE_SEATS_BECAUSE_OF_DISTANCING",ERR_INSUFFICIENT_TICKETS:"ERR_INSUFFICIENT_TICKETS",ERR_TOTAL_QUANTITY_EXCEEDED:"ERR_TOTAL_QUANTITY_EXCEEDED",ERR_ORDER_ITEM_EXCEEDED:"ERR_ORDER_ITEM_EXCEEDED",handleError:function(a){if(a===this.ERR_CONCURRENT_MODIFICATION||a===this.ERR_CONFIGURATION_NOT_FOUND)tools.dialog.showDialog("orderLockError",!0,!0,null,"message_dialog");else if(a===
this.ERR_TOO_MANY_TICKETS)tools.dialog.showDialog("tooManyTickets",!0,!0,null,"message_dialog");else if(a===this.ERR_TOO_FEW_TICKETS)tools.dialog.showDialog("tooFewTickets",!0,!0,null,"message_dialog");else if(a===this.ERR_CART_NOT_EMPTY)this.emptyCartDialog();else if(a===this.ADVANTAGE_ALREADY_USED_ATTRIBUTE)tools.dialog.showDialog("advantageAlreadyUsed",!0,!0,null,"message_dialog");else if(a===this.ERR_INCORRECT_CONFIGURATION)tools.dialog.showDialog("ajaxErrorDialogReload",!0,!0,null,"message_dialog");
else if(a===this.ERROR_NOT_ENOUGH_SEAT_SAME_BLOCK)tools.dialog.showDialog("notEnoughSeatSameBlock",!0,!0,null,"message_dialog");else if(a===this.CANNOT_ATTRIBUTE_SEATS_BECAUSE_OF_DISTANCING)tools.dialog.showDialog("cannotAttributeSeatBecauseOfDistancing",!0,!0,null,"message_dialog");else return!1;return!0},ajaxErrorDialog:function(a){"abort"!==a.statusText&&tools.dialog.showDialog("ajaxErrorDialogReload",!0,!0)},cantBookErrorDialog:function(){tools.dialog.showDialog("cantBookSeasonTicket",!0,!0)},
additionalSeatsFullDialog:function(a,b){var c=$("#"+a).find(".message");tools.replaceJSPArgument(c,"{0}",b);tools.dialog.showDialog(a,!0,!1)},sessionExpiredErrorDialog:function(){tools.dialog.showDialog("sessionExpiredDialog",!0,!0)},bookingFailedErrorDialog:function(a){var b=a.performance;if(b){var c=b.event;$("#bookingFailedDialog .event").html(c.name);$("#bookingFailedDialog .day").html(b.date);$("#bookingFailedDialog .time").html(b.time);$("#bookingFailedDialog .category").html(a.block.name);
tools.dialog.showDialog("bookingFailedDialog",!0,!0)}},emptyCartDialog:function(){tools.dialog.showDialog("emptyCartDialog",!0,!0);$("#emptyCartDialogAbandon").click(function(){tools.dialog.hideDialog("emptyCartDialog");tools.dialog.showWaitingPopup("loadingDialog",!0);$.post(contextPath+"/ajax/subscription/fixedPrice/clearShoppingCart").done(function(){window.location.reload()}).fail(seasontickets.performances.errors.ajaxErrorDialog)});$("#emptyCartDialogFinalize").click(function(){window.location.href=
contextPath+"/cart/shoppingCart"})},alreadyFull:function(){var a=window.location.href;a=a.replace(/selection\/subscription.*performances/,"account/subscription/detail");a=a.replace("movementIds","movementId");a=a.replace("parentOrderId","orderId");window.location.href=a},init:function(){$("#bookingFailedContinue").on("click",function(a){tools.dialog.hideDialog("bookingFailedDialog");a.preventDefault()})}});
tools.module("seasontickets.performances.filters",function(){var a={},b={},c=1,d={},f=function(a,b){a=a.name?a.name.toLowerCase():"";b=b.name?b.name.toLowerCase():"";return a>b?1:a<b?-1:0},e=function(a,b){var c=null,d=[];for(c in a)a.hasOwnProperty(c)&&d.push(b(c,a[c]));return d};return{filterSubtopic:null,filterSubject:null,filterEvent:null,filterVenue:null,filterDay:null,filterMonth:null,reset:function(){this.filterSubject=this.filterMonth=this.filterDay=this.filterVenue=this.filterEvent=this.filterSubtopic=
null},hasFiltering:function(a){var b=this.filterSubtopic||this.filterVenue||this.filterDay||this.filterMonth||this.filterSubject;a&&(b=b||this.filterEvent);return!!b},bind:function(a){var b=this;$("#performances").on("change","#filterEvent",function(){b.filterEvent=$(this).val();a()}).on("change","#filterVenue",function(){b.filterVenue=$(this).val();a()}).on("change","#filterTopic",function(){b.filterSubtopic=$(this).val();a()}).on("change","#filterSubject",function(){b.filterSubject=$(this).val();
a()}).on("change","#filterDate",function(){var c=$(this).val();/^\d+$/.test(c)?(b.filterDay=c,b.filterMonth=null):(b.filterDay=null,b.filterMonth=c);a()}).on("click","#filterEventToolbar .filterToolReset",function(c){b.filterEvent=null;c.preventDefault();a()}).on("click","#filterVenueToolbar .filterToolReset",function(c){b.filterVenue=null;c.preventDefault();a()}).on("click","#filterTopicToolbar .filterToolReset",function(c){b.filterSubtopic=null;c.preventDefault();a()}).on("click","#filterSubjectToolbar .filterToolReset",
function(c){b.filterSubject=null;c.preventDefault();a()}).on("click","#filterDateToolbar .filterToolReset",function(c){b.filterDay=null;b.filterMonth=null;c.preventDefault();a()})},sortPerNames:function(a){return a.sort(f)},getId:function(d){a[d]||(a[d]=c,b[c]=d,c++);return String(a[d])},getName:function(a){return b[a]},paginate:function(a,b){return pagination.paginate(a,b)},filterAndExtractPerformances:function(a,b,c){var f={},g=[],h=datePickerConfig.dayNames,l=this,r=!1,t=null,w,y,z,x,A={},C={},
u={},v={},D={},E={},F={};var B=[];var G=[];B=[];B=[];G=[];B=[];B=[];var L=!1,K=0,H=0;B=0;for(w=a.length;B<w;B++){var M=a[B];var Q=M.event;var S=Q.noTopics?null:Q.subtopics;var V=M.venue;var N=M.jsDate;var I=M.subject||Q.subject;var O=!1;if((x=M.selections)&&x.length)for(y=x.length;y--&&!(O=x[y].selected););if(Q.multiplePerformances||!Q.uniquePerformance||Q.uniquePerformance===M.id){(L=(L=M.availability!==seasontickets.performances.Performance.AVAIL_NONE&&0!==M.available)&&0!==Q.available)&&K++;O||
(K+=M.selections.length);if(!b){if(!I.checkCanAdd(M))continue}else if(I!==b)continue;F[this.getId(I.name)]=I.name;C[this.getId(V.name)]=V.name;u[N.getDay()]=!0;v[N.getMonth()+1+"/"+N.getFullYear()]=N;null===t?t=Q.id:t&&t!==Q.id&&(t=!1);var R=!1;if(S)for(y=0,x=S.length;y<x;y++){var X=S[y];E[X.id]=X;X.id===this.filterSubtopic&&(R=!0)}this.filterSubject&&this.getName(this.filterSubject)!==I.name||this.filterSubtopic&&!R||(A[this.getId(Q.name)]=Q.name,this.filterEvent&&this.getName(this.filterEvent)!==
Q.name||this.filterVenue&&V.name!==this.getName(this.filterVenue)||this.filterDay&&String(N.getDay())!==this.filterDay||this.filterMonth&&N.getMonth()+1+"/"+N.getFullYear()!==this.filterMonth||(L&&H++,O?L||(H+=1):H+=M.selections.length,g.push(M)))}}if(!c&&(!this.filterSubject||this.filterSubject in F||(this.filterSubject=null,r=!0),this.filterSubtopic&&!E[this.filterSubtopic]&&(this.filterSubtopic=null,r=!0),this.filterEvent&&!A[this.filterEvent]&&(this.filterEvent=null,r=!0),this.filterVenue&&!C[this.filterVenue]&&
(this.filterVenue=null,r=!0),this.filterDay&&!u[this.filterDay]&&(this.filterDay=null,r=!0),this.filterMonth&&!v[this.filterMonth]&&(this.filterMonth=null,r=!0),r))return this.filterAndExtractPerformances(a,b,!0);f.performances=g;f.filters=this;f.filteredNbPerformances=H;f.totalNbPerformances=K;f.filterResultCountAll=H===K&&1<H;f.filterResultCountAllOne=H===K&&1===H;f.filterResultCountOne=H!==K&&1===H;f.filterResultCountNone=0===K||0===H;f.filterResultCountSome=!(f.filterResultCountAll||f.filterResultCountAllOne||
f.filterResultCountOne||f.filterResultCountNone);B=e(C,function(a,b){return{name:b,id:a,selected:a===l.filterVenue}});this.sortPerNames(B);f.filterVenues=B;f.hasFilterVenues=1<B.length;f.hasFilterVenue=!!this.filterVenue;if(!1===t){B=e(A,function(a,b){return{name:b,id:a,selected:a===l.filterEvent}});this.sortPerNames(B);f.filterEvents=B;f.hasFilterEvents=1<B.length;f.hasFilterEvent=!!this.filterEvent;B=e(E,function(a,b){return{name:b.name,id:a,topic:b.topic,selected:a===l.filterSubtopic}});this.sortPerNames(B);
$.each(B,function(){var a=this.topic.id;D[a]||(D[a]=[]);D[a].push(this)});for(z in D)D.hasOwnProperty(z)&&G.push({name:D[z][0].topic.name,subtopics:D[z]});this.sortPerNames(G);f.filterTopics=G;f.hasFilterSubtopics=1<B.length;f.hasFilterSubtopic=!!this.filterSubtopic;B=e(F,function(a,b){return{name:b||null,id:a,selected:a===l.filterSubject}});this.sortPerNames(B);f.filterSubjects=B;f.hasFilterSubjects=1<B.length;f.hasFilterSubject=!!this.filterSubject}G=e(u,function(a,b){return{name:h[a],id:a,selected:a===
l.filterDay,dayIndex:parseInt(a,10)}});G.length&&(G.sort(function(a,b){return a.dayIndex>b.dayIndex?1:-1}),G[0].dayIndex||G.push(G.shift()));f.filterDays=G;B=e(v,function(a,b){var c=d[a];c||(c=a.split("/"),c=jQuery.datepicker.formatDate("MM yy",new Date(c[1],c[0]-1,1),datePickerConfig),d[a]=c);return{name:c,id:a,selected:a===l.filterMonth,jsDate:b}});B.sort(function(a,b){return a.jsDate>b.jsDate?1:-1});f.filterMonths=B;f.hasFilterDates=1<G.length||1<B.length;f.hasFilterDate=!!this.filterDay||!!this.filterMonth;
f.hasFilter=f.hasFilterSubjects||f.hasFilterTopics||f.hasFilterEvents||f.hasFilterDates||f.hasFilterVenues;return f}}});
tools.module("seasontickets.performances.viewHelper",function(){var a=!1,b=null,c=null,d=null,f=null,e=null,g=function(a,c,e){$(e).html(Mustache.render(a,c,{performanceTpl:f,selectionTpl:d,eventConfigurationTpl:b}))},h=!1,l=function(){requestAnimationFrame(l);var a=$("#sticky_box").parent().offset().top;var b=$(window).height();var c=$(window).scrollTop();var d=$("#secondary_content_seasonticket > .content_title").height();a<b+c-d?(h=!1,$("#sticky_box").removeClass("scroll_state")):(h=!0,$("#sticky_box").addClass("scroll_state"))};
return{init:function(){b=$("#eventConfigurationTpl").html();c=$("#performancesListTpl").html();d=$("#selectionTpl").html();f=$("#performanceTpl").html();e=$("#seasonticket_cursor")},renderPerformances:function(a){var b;g(c,a,"#performances");$(".performances_container .event_performance").each(function(a){var c=$(this);a=c.parents(".performances_container").first();var d=c.find(".last .button a"),e=c.attr("data-perfid");var f=0<c.closest(".events_container").length?c.find(".event.product").text():
c.find(".title").text()+" "+c.find(".date .day").text()+" "+c.find(".date .time").text();d.append(functions.accessibilityVisuallyHiddenSpan(f));b="TABLE"===a.prop("tagName")?functions.accessibilityVisuallyHiddenColWithID:functions.accessibilityVisuallyHiddenSpanWithID;var g=f+seasontickets.performances.messages.chooseCategory;c.find("select.category").each(function(a){a="cat-"+a+"-"+e;c.append(b(g,a)).attr("aria-labelledby",a)})})},renderConfiguration:function(a){g(b,a,"#eventConfiguration");$(".wait_overlay").each(function(){var a=
$(this),b=a.parent().outerHeight();a.height(b).css("line-height",b+"px")})},showWaitingDialog:function(){a||(tools.dialog.showWaitingPopup("loadingDialog",!0),a=!0)},hideWaitingDialog:function(){a&&(tools.dialog.hideDialog("loadingDialog"),a=!1)},scrollToTop:function(){var a=$(".step.performances, .step.categories");a=a.length?a.offset().top:0;var b=$("#main_content_seasonticket_performances");b=b.length?b.offset().top:0;a=Math.min(a,b);$(window).scrollTop()>a&&$(window).scrollTop(a)},adjustCursor:function(){var a=
$(".event.selected","#eventConfiguration");if(a.length){a.find(".content").append('<span class="accessibility-visually-hidden">'+accessibilityCurrentSelected+"</span>");var b=(a.outerHeight()-a.innerHeight())/2;var c=a.position();c=c.top-(2.5+b)+"px";a=a.outerHeight()+"px";e.is(":visible")?e.stop(!0).animate({top:c,height:a},1E3,"easeInOutExpo"):(e.show().css("top",c),e.css("height",a))}else e.hide()},hideCursor:function(){e.hide()},getSelectNumberStructure:function(a,b,c){for(var d=[];b<=c;b++)d.push({label:b,
value:b,selected:b==a,singular:1==b});return d},initStickyFooter:function(){$("#sticky_box").click(function(){h&&$("html, body").animate({scrollTop:$("#secondary_content_seasonticket .performances").offset().top},500)});Modernizr.requestanimationframe&&requestAnimationFrame(l)}}});
tools.module("seasontickets.subscribers",function(){var a={},b={},c={},d="",f=function(){var a=null,b=$("#main_content_seasonticket_subscribers select");0===b.length&&(b=$("#main_content_seasonticket_subscribers input[type='text']"),this.validateContent=!0);b.each(function(){var b=parseInt($(this).val(),10);0<b&&(a=a?a+",":"",a+=$(this).attr("id").replace("select_rate_","")+"x"+b)});return a},e=function(a,b,c){a=new Option(b+(c?"- "+d:""),a,!1,!1);c&&a.setAttribute("disabled","disabled");return a},
g=function(){var b=f();null!==b&&(b={productId:a.productId,advantageId:a.advantageId,subscribers:b},tools.dialog.showWaitingPopupDelayed("loadingDialog",!0,!1,300),$.ajax({type:"GET",url:contextPath+"/ajax/fragment/selection/seasonTicketCategory",cache:!1,data:b,success:function(a){var b=$("#season_ticket_categories_container");b.length&&b.html(a);tools.dialog.hideDialog("loadingDialog")},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}}))},
h=function(){var a=$("option","select#select_category").filter(function(a,b){return"0"!==String($(this).val())});1===$(a).length&&(a=a[0],$("select#select_category").remove(),$("#field_category").append("<span>"+$(a).text()+"</span>"),$("#field_category").append('<input type="hidden" id="select_category" value="'+$(a).val()+'" />'))};return{init:function(e){a=e;b=a.itemIdMapping;c=a.seat2AreaMapping;d=a.fullAreaLabel;h();this.onSeatCategoryChange()},onSubcriberChange:function(){g()},onSeatCategoryChange:function(){if(c){var a=
$("#select_category").val();var b=$("#select_area");var d=c[Number(a)];b.find("option").not(":first").remove();d&&1<Object.keys(d).length?(b.prop("disabled",!1),Object.keys(d).forEach(function(a){var c=d[a];b.append(e(a,c.name,!c.isAvailable))})):b.attr("disabled","disabled")}},redirectToNextStep:function(a,c,d){var e=contextPath,g=f();e=c?e+"/selection/subscription/performances":e+"/selection/subscription/validation";$("#errorSeatCatSelection").hide();$("#select_category").removeClass("error");$("#errorNumberSubscriber").hide();
$("#main_content_seasonticket_subscribers select").removeClass("error");if($("#select_category").length&&"0"===$("#select_category").val())return $("#errorSeatCatSelection").show(),$("#select_category").focus().attr("aria-describedby","errorSeatCatSelection").addClass("error"),window.scrollTo(0,0),!1;if(0<$("#subscription_tariff_sold_out").length)return!1;if(g)e+="?productId="+a+"&subscribers="+g,d&&(e+="&advantageId="+d),$("#select_category").length&&(e+="&itemId="+b[$("#select_category").val()]),
$("#select_area").length&&"0"!==$("#select_area").val()&&(e+="&areaId="+$("#select_area").val()),$("#select_location").length&&(e+="&preferredBlockId="+$("#select_location").val());else return $("#errorNumberSubscriber.hidden").removeClass("hidden"),$("#main_content_seasonticket_subscribers select").addClass("error"),window.scrollTo(0,0),!1;"undefined"!==typeof audSubCatVerification?audSubCatVerification.validateAllQuantities($("#nextStepButton"),!1,function(a){a&&(window.location=e)}):window.location=
e}}});
tools.module("ChangeSeat",function(){var a=!0,b=null,c=[],d=[],f={},e=!1,g={},h=null,l=null,k=null,m=null,p={},q=!1,r={},t={},w,y=null,z,x,A={},C=0,u=!1,v=function(b,c,d,e,f){e=a?b.data:e;if(!a||b&&e){var g;e.seatId=e.id;a&&b&&b.geometry&&(e.seatCentroid=b.geometry.getCentroid());!e.area&&t[e.areaId]&&(e.area=t[e.areaId]);!e.block&&r[e.blockId]&&(e.block=r[e.blockId].name);if(f)for(g in f)e[g]=f[g];(b=p[c])||!q?(F(e,b),SeatDetails.showSeatDetailsInThePanel(e),B(c,e,d)):(p[c]={},p[c].scenePhotoLink=
e.scenePhotoLink,p[c].scenePanoLink=e.scenePanoLink,F(e,p[c]),m===c&&(SeatDetails.showSeatDetailsInThePanel(e),B(c,e,d)))}},D=function(a,b,c,d){var e=y+"_"+b,f=a?a.data:null;m!==b&&(m=b,!A[e]&&y&&b?(C||($("#seat-info-loading-bg, #seat-info-loading").show(),$(".seat-map-loading-mask").show()),C++,$.ajax({url:k,type:"GET",cache:!1,data:{perfId:y,seatId:b},error:function(a){tools.dialog.showDialog("ajaxErrorDialog",!0)},success:function(g){C--;1>C&&($("#seat-info-loading-bg, #seat-info-loading").hide(),
$(".seat-map-loading-mask").hide());A[e]=g;a&&!a.data&&(a.data=f);v(a,b,c,d,g)}})):v(a,b,c,d,A[e]))},E=function(){var b={featureselected:function(b,c){var d=a?b.feature.data.id:c.id;if(SeatList.isInSeatList(d))var e=!1;else SeatList.getSelectedSeatId()!==d&&l&&l.destroy(),g[SeatList.getSelectedSeatId()]&&(a?(b.feature.attributes.refOperationId=g[SeatList.getSelectedSeatId()].refOperationId,b.feature.attributes.audienceSubCategory=g[SeatList.getSelectedSeatId()].audienceSubCategory,b.feature.attributes.audienceSubCategoryId=
g[SeatList.getSelectedSeatId()].audienceSubCategoryId):(c.refOperationId=g[SeatList.getSelectedSeatId()].refOperationId,c.audienceSubCategory=g[SeatList.getSelectedSeatId()].audienceSubCategory,c.audienceSubCategoryId=g[SeatList.getSelectedSeatId()].audienceSubCategoryId),delete g[SeatList.getSelectedSeatId()]),e=SeatList.getSelectedSeatId(),f[d]=f[e],delete f[e],SeatList.updateSeat(d),e=!0;g[d]?a&&!b.feature.attributes.refOperationId?(b.feature.attributes.refOperationId=g[d].refOperationId,b.feature.attributes.audienceSubCategory=
g[d].audienceSubCategory,b.feature.attributes.audienceSubCategoryId=g[d].audienceSubCategoryId):a||c.refOperationId||(c.refOperationId=g[d].refOperationId,c.audienceSubCategory=g[d].audienceSubCategory,c.audienceSubCategoryId=g[d].audienceSubCategoryId):g[d]=a?b.feature.attributes:c;D(b.feature,d,e,a?null:c)},featureunselected:function(b,c){var d=b.feature;SeatList.isSeatSelected(a?b.feature.data.id:c.id)&&a&&u&&SeatMap.redrawSeat(d.fid,"addedToCart")}};tools.dialog.hideDialog("subscriptionConfigOnGoing");
if(u)if(a)SeatMap.seatsLayer.events.on(b);else seatmap.SeatMapSvg.events.on("onSeatSelected",b.featureselected),seatmap.SeatMapSvg.events.on("onSeatUnSelected",b.featureunselected)},F=function(a,b){b&&(b.scenePhotoLink&&(a.scenePhotoLink=b.scenePhotoLink),b.scenePanoLink&&(a.scenePanoLink=b.scenePanoLink))},B=function(a,b,c){var d={};g[a]&&(d.audienceSubCatName=g[a].audienceSubCategory,d.audienceSubCategoryId=g[a].audienceSubCategoryId);d.data=b;SeatList.getSeat(a)&&parseInt(SeatList.getSelectedSeatId(),
10)!==a&&(l&&l.destroy(),SeatList.selectSeat(d,!1));c&&(SeatList.addOrUpdateSeatInCartToList(d,a,!0),SeatList.selectNextSeat())},G=function(a,b){new OpenLayers.StyleMap({externalGraphic:contextPath+"/resources/images/buttons-icons/locationIndicator.svg",graphicWidth:35,graphicHeight:35,graphicYOffset:-30,graphicOpacity:1});l&&l.destroy();l=new OpenLayers.Layer.Markers("seatIndicator");a=new OpenLayers.Size(40,40);var c=new OpenLayers.Pixel(-(a.w/2),-(a.h-5));a=new OpenLayers.Icon(contextPath+"/resources/images/buttons-icons/locationIndicator.svg",
a,c);l.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(b.geometry.x,b.geometry.y),a));u&&SeatMap.map.addLayer(l);$(a.imageDiv).find("img").css("box-shadow","none");l.setZIndex(900)},L=function(a){var b;for(b=d.length;b--;)if(0>$.inArray(d[b],a))return!0;return!1},K=function(a){var c=[],d=[],e;tools.dialog.showWaitingPopup("savingSeatDialog",!0);for(e in SeatList.getSelectedSeats())if(SeatList.getSelectedSeats().hasOwnProperty(e)){var f=g[e];d.push(f);c.push(e)}L(c)||a?$.ajax({url:contextPath+
"/ajax/changeSeat/changeSeats",type:"POST",cache:!1,data:JSON.stringify({selectedSeatIds:c,seatsData:d,supplement:x,operationIds:b,parentProductId:w,modifyAllSeatsMode:a}),dataType:"json",contentType:"application/json",error:function(a,b,c){tools.dialog.hideDialog("savingSeatDialog");tools.dialog.showDialog("changeSeatAjaxErrorDialog",!0,!0)},success:function(a,b,c){a.error?(tools.dialog.hideDialog("savingSeatDialog"),c={},"RESTRICTED_AREA"===a.status?tools.dialog.showDialog("restrictedAreaError",
!0):"AVAILABILITY"===a.status?tools.dialog.showDialog("noAvailableSameSeats",!0):"ERROR"==a.level&&"SOCIAL_DISTANCING"==a.status?tools.dialog.showDialog("cannotAttributeSeatBecauseOfDistancing",!0):"COMPANION_ALONE"==a.status?tools.dialog.showDialog("aloneCompanionTickets",!0):(c.cartContentUrl=z,c.backButtonText=ChangeSeat.labels.BACK_TO_CART,c.message=a.message,"FATAL"===a.level?(b="changeSeatResponseErrorDialog",c.isErrorFatal=!0):(b="changeSeatResponseWarningDialog",c.isErrorFatal=!1),c.dialogId=
b,"ERROR"==a.level&&"LOCKED"==a.status&&(c.isSeatLocked=!0),$("#"+b).html(Mustache.render(h,c)),tools.dialog.showDialog(b,!0,"FATAL"===a.level))):window.location=z}}):window.location=z};return{labels:{},getSeatsToBeChanged:function(){var b,h=[],k;if(0<c.length){for(k in c)if(c.hasOwnProperty(k)){var l=b=c[k],m={},p={};var r=l.seatInfo;r.seatId=l.seatId;r.color=l.properties.color;r.row=l.properties.row;r.number=l.properties.number;r.noReselect=l.properties.noReselect;r.seatCategory=r.seatCategory||
l.properties.seatCategory;if(a&&u){var t=new OpenLayers.Geometry.Point(l.geometry.coordinates[0],l.geometry.coordinates[1]);OpenLayers.Projection.transform(t,SeatMap.seatProjection,SeatMap.mapProjection);r.seatCentroid=t.getCentroid()}p.data=r;p.priceIdx=l.priceIdx;p.audienceSubCatName=l.audienceSubCatName;m.seatData=p;m.numbered=null!==r.number;t=m;f[b.seatId]=t.seatData.priceIdx;g[b.seatId]=b.properties;g[b.seatId].refOperationId=b.refOperationId;g[b.seatId].audienceSubCategory=b.audienceSubCatName;
g[b.seatId].audienceSubCategoryId=b.audienceSubCategoryId;d.push(b.seatId.toString());!b.seatInfo.scenePhotoLink&&!b.seatInfo.scenePanoLink||q||(q=!0);t&&h.push(t)}e=!0;return h}return null},isSelectedSeatsRestoredOnMap:function(){return e},getSeatPriceIdx:function(a){return 0<=f[a]?f[a]:null},init:function(d){a=d.isOpenLayerSeatMap;null!==d.blockInfo&&(r=d.blockInfo);null!==d.areaInfo&&(t=d.areaInfo);b=d.operationIds;w=d.parentProductId;x=d.isSupplement;c=d.initiallyAddedSeats;z=d.cartContentUrl;
k=d.seatDescriptionUrl;y=d.performanceId;u=d.isShownOldSeatMap;h=$("#changeSeatErrorDialogTpl").html();a&&u?(SeatMap.events.on("initSeatsLayerDone",E),SeatMap.events.on("seatSelectedOnMap",G)):E();$("#cannotAttributeSeatBecauseOfDistancing .button.modify").click(function(){tools.dialog.hideDialog("cannotAttributeSeatBecauseOfDistancing")});$("#validate-selection").click(function(a){a.preventDefault();K(!0)});$("#modify-seat").click(function(a){a.preventDefault();K(!1)})}}});
tools.module("ExclusiveSessionStorage",function(){var a="",b="";return{init:function(c){c&&(a="isExclusiveAvailable-"+c.productId+"-"+c.performanceId,b="isExclusiveSelected-"+c.productId+"-"+c.performanceId,!ExclusiveSessionStorage.getExclusiveAvailable()&&c.isExclusive?(ExclusiveSessionStorage.storeExclusiveAvailable(!0),ExclusiveSessionStorage.getExclusiveSelected()||ExclusiveSessionStorage.storeExclusiveSelected(c.isExclusive)):c.isExclusive||ExclusiveSessionStorage.removeExclusive())},storeExclusiveAvailable:function(b){sessionStorage.setItem(a,
b)},storeExclusiveSelected:function(a){sessionStorage.setItem(b,a)},getExclusiveAvailable:function(){return sessionStorage.getItem(a)},getExclusiveSelected:function(){return sessionStorage.getItem(b)},removeExclusive:function(){sessionStorage.removeItem(a);sessionStorage.removeItem(b)}}});
tools.module("seatmap.seatBlock",function(){var a=!1,b=!1,c=!1,d=!0,f="",e="",g=null,h=[],l={},k,m=[],p=function(a){-1!=a.indexOf("-full")?a=a.replace("-full","-hover"):-1==a.indexOf("-hover")&&(a+="-hover");return a},q=function(){$("#seat_info_filter_categories_input").is(":checked")?($("#venue-preview").hide(),$("#venue-categories").show(),$("#seat_info_filter_categories_table").fadeIn()):($("#venue-categories").hide(),$("#seat_info_filter_categories_table").fadeOut())},r=function(a){var c=a.attr("id"),
d=p(c),e=$("#seat-info-"+d).find(".seat_info_img_preview"),f=e.data("preview-url");e=e.data("pano-config-url");var g=$("#seat-info-"+d),h=$(".comparison-block").not(".last-selected").first(),k=h.attr("data-current-polygon"),m=-1!=c.indexOf("full"),q=$("#seat-map-step-2");$("#seat_info_filters").hide();$(".block-info-content").hide();$("#seat_info_instructions_container").hide();0<q.length&&(q[0].onclick=function(){window.location.href=$("#seat-info-"+d+" .btn_go_step2 a").attr("href")});b?($("#seat-info-"+
d).show(),$('[id^="P"][id$="-hover"]').css("opacity",0),$('[id^="P"].stx_hover').css("opacity","1.0"),-1!=c.indexOf("-hover")?a.css("opacity",l[c]):a.hasClass("stx_hover")&&a.css("opacity","0.8"),0<q.length&&(q[0].onclick=function(){window.location.href=$("#seat-info-"+d+" .btn_go_step2 a").attr("href")})):(k&&k!==c.replace("-hover","")&&$("[id^='"+k+"']").attr("data-selected","no").click(x).hover(v,D).trigger("mouseleave"),h.attr({"data-current-polygon":c.replace("-hover",""),"data-filled":!0}),
E(),t(h,g,e,f,m))},t=function(a,b,c,d,e){var f=a.attr("id").substr(a.attr("id").lastIndexOf("-")+1);e?w(a):(a.find(".polygon_number_tickets_container").html(b.find(".polygon_number_tickets_container").html()),a.find(".seat_info_block_price").html(b.find(".seat_info_block_price").html()),a.find(".categories_table_container").html("").append(b.find(".categories_table_container .seat-info-category").clone()),a.find(".btn_go_step2_container").html(b.find(".btn_go_step2_container").html()).find("> span").removeClass("hidden"));
var g=a.height();$(".comparison-block").finish();$(".comparison-block").not(a).removeClass("last-selected").animate({top:g+20,borderBottomWidth:"0px"},{duration:"slow",start:function(){a.css("visibility","hidden");$("#comparison-instructions").css("top",g)},complete:function(){a.css("visibility","visible")}});a.css({top:"0"}).addClass("last-selected");a.find(".polygon_name_container").html(b.find(".polygon_name_container").html());a.find(".seat_info_block_availability").html(b.find(".seat_info_block_availability").html()).attr("class",
b.find(".seat_info_block_availability").attr("class"));SeatPano.destroyPanel("pano-container-"+f,"pano-thumbnail-"+f);$("#pano-thumbnail-"+f+" > div").hide();z(f,!0);y(c,d,f);b=a.find(".btn_go_step2_container a");b.attr("href",b.attr("href")+"#seat-map-sub-container")},w=function(a){var b=a.attr("id").substr(a.attr("id").lastIndexOf("-")+1),c;a.find(".polygon_name_container").empty();a.find(".seat_info_block_price").empty();a.find(".polygon_number_tickets_container").empty();a.find(".seat_info_block_availability").empty();
a.find(".categories_table_container").empty();a.find(".btn_go_step2_container").empty();SeatPano.destroyPanel("pano-container-"+b,"pano-thumbnail-"+b);a.hasClass("last-selected")&&($(".comparison-block").finish(),a.removeClass("last-selected"),$(".comparison-block").not(a).addClass("last-selected").animate({top:"0"},{duration:"slow",start:function(){$("#comparison-instructions").css("visibility","hidden")},complete:function(){$("#comparison-instructions").css("visibility","visible");c=$(".last-selected").height();
$("#comparison-instructions").css("top",c)}}))},y=function(a,b,c){if(b){var d=tools.parsePanoURL(b);d.protocol?SeatPano.displayPanel(d.protocol,d.url,"pano-container-"+c,"pano-thumbnail-"+c):SeatPano.displayPanel("krpano",a+b,"pano-container-"+c,"pano-thumbnail-"+c);z(c,!0)}else z(c,!1)},z=function(a,b){a=$("#pano-thumbnail-"+a);var c=$(a).closest(".pano-container");b&&functions.isWebGLSupport()?($(a).show(),$(c).removeClass("no_thumbnail")):($(a).hide(),$(c).addClass("no_thumbnail"))},x=function(){var a=
$(this);var e=a.attr("id").replace("-hover","");d?(r(a),b||(c||a.tooltip("close"),$("[id^='"+e+"']").off("click"),$("[id^='"+e+"']").attr("data-selected","yes")),seatMapWithAccessibility&&!e.includes("full")&&(a="#"+e,k||(k=$(e+"-hover").css("fill")),$(a).css("fill",'url("#pattern-selected-block")'),$("#pattern-selected-block .background").css("fill",k))):(e=$(".btn_go_step2_container a","#seat-info-"+e+"-hover"),$(e).attr("href")&&(window.location.href=$(e).attr("href")))},A=function(a){return a.length&&
(-1!=a.attr("id").indexOf("-hover")||a.hasClass("stx_hover"))},C=function(a){var b=[];$("#seat-map svg").length&&(a&&(b=a.split("#")),$('[id^="P"]').each(function(){var a=!1,c=$(this),d=c.attr("id"),e=d,f=!1,g=null,k=a=null,m=null;g=null;var p=0;-1<e.indexOf("-")&&(e=e.split("-")[0]);g=$("#seat-info-"+e+"-hover");g.length?(a=b.some(function(a){return e===a}))?(c.removeAttr("title"),-1<d.indexOf("-hover")||-1==d.indexOf("-full")&&$("#"+e+"-full").length?f=!0:-1!==d.indexOf("-full")||$("#"+e+"-full").length||
c.addClass("stx_full")):(a=g.find(".seat_info_block_price").data("min-price"),k=g.find(".seat_info_block_price").data("max-price"),m=g.find(".seat_info_block_name").text(),p=g.find(".seat_info_block_seat_available").text(),g=g.find(".seat_info_block_available_tariffs").text(),c.attr("title",m+"::"+a+"::"+k+"::"+p+"::"+g),-1<d.indexOf("-full")?f=!0:-1!=d.indexOf("-hover")||$("#"+e+"-hover").length||c.addClass("stx_hover")):f=!0;f?c.hide():c.show();A(c)&&!f&&(l[d]=1,c.css("opacity",0),h.push("#"+d))}))},
u=function(){var a=!1;if($("#venue-preview").length){var b=function(){$("#venue-preview").css("opacity",1).animate({opacity:0},200,function(){$(this).hide()})};setTimeout(function(){a&&b();a=!0},1E3);$("#seat-map").on("mousemove",function(){$("#seat-map").off("mousemove");a?b():a=!0})}},v=function(){var a=$(this);a=p(a.attr("id"));var b=a.split("-")[0];$("#"+a).css("opacity",l[a]);m[b]||(m[b]=$("#"+b).css("fill"));$(".comparison-block").each(function(){$(this).attr("data-current-polygon")===b&&$(this).addClass("hovering")})},
D=function(){var a=p($(this).attr("id")),b=a.split("-")[0];"yes"!==$(this).attr("data-selected")&&($("#"+b).css("fill",m[b]),$("#"+a).css("opacity",0));$(".comparison-block").each(function(){$(this).attr("data-current-polygon")===b&&$(this).removeClass("hovering")})},E=function(){var a=$(".comparison-block[data-filled='true']");switch(a.length){case 0:$(".comparison-block").hide();$("#seat_info_instructions_container").show();$("#seat_info_filters").show();$("#comparison-instructions").hide();break;
case 1:a.show();$(".comparison-block[data-filled='false']").hide();$("#seat_info_instructions_container").hide();$("#seat_info_filters").hide();$("#comparison-instructions").show();break;case 2:a.show(),$("#seat_info_instructions_container").hide(),$("#seat_info_filters").hide(),$("#comparison-instructions").hide()}},F=function(a,b){a=a.split("#");var c=b.split("#");return a.filter(function(a){return!c.includes(a)}).join("#")};return{init:function(h){var k=h.fullPolygonIds;a=h.isMobile||h.isTablet;
b=h.isMobile;c=h.isTablet;d=h.blockComparisonEnabled;ExclusiveSessionStorage.getExclusiveAvailable()&&((g=ExclusiveSessionStorage.getExclusiveSelected()?"true"===ExclusiveSessionStorage.getExclusiveSelected():h.isExclusive)?$("#exclusive-seats-filter").removeClass("inactive"):$("#exclusive-seats-filter").addClass("inactive"),f=[h.fullPolygonIds,h.exclusiveAllSeatPolygonIds].join("#"),e=[h.fullPolygonIds,F(h.availablePolygonIds,h.exclusivePolygonIds)].join("#"),k=g?e:f);C(k);$("#venue-categories").length?
($("#seat_info_filter_categories").removeClass("hidden"),$("#seat_info_filter_categories_input").change(function(){q()})):$("#seat_info_filter_title").hide();b||($('[id^="P"]').hover(v,D),c||$('[id^="P"]').tooltip({track:!0,show:!1,hide:!1,tooltipClass:"zone-selection-tooltip",content:function(){var a,b="";var c=$(this).attr("title").split("::");var d=c[0];var e=c[1];var f=c[2];var g=c[3];5<=c.length&&(a=c[4]);c="<span class='amount'>"+functions.generateAmount(e)+"</span>";f&&e!==f&&(c+=" - <span class='amount'>"+
functions.generateAmount(f)+"</span>");a&&""!==$.trim(a)&&(b='<span class="available_tariffs">'+$.trim(a)+"</span>");return"<span class='name'>"+d+"</span>"+b+"<span class='prices number_of_tickets'>"+g+"</span><span class='prices'>"+c+"</span>"}}),$(".polygon_navigation_container .polygon_arrow").each(function(){$(this).hide()}));$('[id^="P"]').click(x);$(document).on("click",".close-comparison",function(){var a=$(this).closest(".comparison-block");w(a);$("[id^='"+a.attr("data-current-polygon")+
"']").attr("data-selected","no").click(x).hover(v,D).trigger("mouseleave");a.attr({"data-current-polygon":"","data-filled":!1});E()});$(".comparison-block").hover(function(){var a=$(this).attr("data-current-polygon");$("#"+a+"-hover").css("opacity","0.6")},function(){var a=$(this).attr("data-current-polygon")+"-hover";$("#"+a).css("opacity",l[a])});$("#exclusive-seats-filter").click(function(a){isNewTicketShop||a.preventDefault();(g=!g)?($("#exclusive-seats-filter").removeClass("inactive"),C(e),ExclusiveSessionStorage.storeExclusiveSelected(!0)):
($("#exclusive-seats-filter").addClass("inactive"),C(f),ExclusiveSessionStorage.storeExclusiveSelected(!1));SeatDetails.getSeatCatFilter()});a&&$("#venue-categories").length&&($("#seat_info_filter_categories_input").prop("checked",!0),q());h.areaToSelect&&r($(h.areaToSelect));u()},nextArea:function(a){a=h.indexOf(a);a=a==h.length-1?0:a+1;r($(h[a]))},previousArea:function(a){a=(a=h.indexOf(a))?a-1:h.length-1;r($(h[a]))}}});
SeatCache=function(a,b){this.cache=[];this.fromProjection=a;this.toProjection=b};
SeatCache.prototype={_revertYChange:function(a){var b=new OpenLayers.Bounds;b.top=a.bottom;b.bottom=a.top;b.left=a.left;b.right=a.right;return b},clearCache:function(){this.cache=[]},getFromCache:function(a,b){var c=null;b.transform(this.fromProjection,this.toProjection);var d=this._revertYChange(b);for(b=0;b<this.cache.length;b++){var f=this.cache[b];f.bounds.containsBounds(d)&&f.exclusiveMode===a.exclusiveMode&&(c=f)}return c},pushInCache:function(a,b){for(var c=this._revertYChange(b.filter.value),
d=this.cache.length-1;0<=d;){var f=this.cache[d];c.containsBounds(f.bounds)||f.exclusiveMode!==b.exclusiveMode||this.cache.splice(d,1);d--}this.cache.push({bounds:c,olResponse:a,exclusiveMode:b.exclusiveMode})}};
tools.module("SeatDetails",function(){var a=!0,b=null,c=null,d=null,f=null,e=0,g=null,h={},l=null,k=null,m=null,p=null,q={},r=!1,t=null,w=null,y=null,z=null,x=null,A=null,C=null,u=null,v={},D=!1,E=!1,F=!1,B={},G={},L={},K=[],H=!1,M=null,Q,S=function(a,b){return F&&!E&&a!==b?b:a},V=function(){var a=[];$(".nnseat-rate-select").each(function(){a.push($(this).val())});return a},N=function(a){a=parseInt(a,10)||0;return 0>a?"":a+" "+(1<a?SeatDetails._LABEL_NNAREA_SEAT_COUNT_N:SeatDetails._LABEL_NNAREA_SEAT_COUNT_1)},
I=function(a){var b=0;if(a){var c=jQuery("#nn-resale-seat-quantity");c.empty();(K[a]||[]).forEach(function(a){L[a].isBookAvailable&&(b++,c.append("<option value='"+b+"'>"+b+"</option>"))});if(a&&K&&K[a]&&0<K[a].length&&K[a][0]&&L&&L[K[a][0]]&&L[K[a][0]].resaleInfo){var d=L[K[a][0]].resaleInfo;null!=d&&(d=[d.audienceSubCatgory,functions.generateAmount(S(d.amount,d.amountWithCharge)),N(b)],jQuery("#resale_"+a).html(d.join(" - ")),jQuery("#resale_"+a).prop("selected",!0))}}},O=function(a,b){if(E){a=
a.resaleInfo.resaleMovId;var c=$('#nn-resale-seat-select option[value="'+a+'"]'),d=$("#nn-resale-seat-select");a&&L&&L[a]&&L[a].isBookAvailable&&(c.prop("disabled",!1),c.show(),0<d.length&&d[0]&&0>d[0].selectedIndex&&(c.prop("selected",!0),b&&d.trigger("change")),0<$("#nn-resale-seat-select").find("option").not('[style*="display: none"]').not(":disabled").length&&$("#add-selected-seat-to-cart").parent().removeClass("disabled"))}else I(a.groupResaleIndex)},R=function(a,b,c){if(null!==a.externalVerification){var d=
a.externalVerification.name+": "+SeatDetails._LABEL_NOTE;b.attr("title",d);b.show()}else a.isMemberCategory&&null!==a.priceLevelCode?(d=a.audienceSubCategory+" / "+a.priceLevelCode+": "+SeatDetails._LABEL_NOTE,b.attr("title",d),b.show()):b.hide();a.conditionalRateData&&null!==a.conditionalRateData?(c.attr("title",a.conditionalRateData.rateInfo),c.find(".conditional_rate_indicator_intro").html(a.conditionalRateData.rateInfo),c.show()):a.degressivePrices&&0<a.degressivePrices.length?($(".degressive_rate_indicator_intro").removeClass("hidden"),
c.show()):c.hide()},X=function(a){var b=0,c=!1;$(".nnseat-rate-select").each(function(){if($(this).val()===a&&(b++,1<b))return c=!0,!1});return c},T=function(){$(".nnseat-rate-select").length===b.data.prices.length?$("#add-rate").parent().addClass("disabled"):$("#add-rate").parent().removeClass("disabled")},Z=function(a,c,d){var e=b,f=e.data.prices[a],g=e.priceIdx===a,h=functions.generateAmount(f.amount),k=c?"nn":"",l=$("#nnseat-rate-selection-"+d),m=l.find(".nnseat-rate-pre-price"),p=l.find(".nnseat-rate-price");
d=c?l.find(".external_verification_indicator"):$(".external_verification_indicator");l=c?l.find(".conditional_rate_indicator"):$(".conditional_rate_indicator");var q=c?m:$("#seat-info-pre-price");var r=c?p:$("#seat-info-price");var ia=$("#"+k+"seat-info-adv"),t=$("#"+k+"seat-info-price-adv .advantage"),fa=$("#seat-info-adv-availability"),v=$("#"+k+"seat-info-price-adv .advantage_container"),u=$("#"+k+"seat-info-price-adv .advantage .catchword .text");m=$("#"+k+"seat-info-price");a=String(a);r.removeClass("advantage");
ia.html("");t.not(r).hide();fa.hide();q.html("");if(f.advantageId||f.advantage||e.exclusive)f.advantageId?(ia.html(f.advantage),f.amountWithoutAdvantage&&f.amountWithoutAdvantage!=f.amount&&(r=functions.generateAmount(f.amountWithoutAdvantage),null==r?q.html(""):q.html(r)),m.addClass("advantage"),p.addClass("advantage"),t.removeClass("advantage_NONE").addClass("advantage_"+f.advantageType).show(),v.addClass("advantage_"+f.advantageType),u.html(SeatDetails._ADV_LABELS[f.advantageType])):f.advantage&&
(ia.html(f.advantage),fa.addClass("availability_NONE").show(),t.addClass("advantage_"+f.advantageType).addClass("advantage_NONE").show(),v.addClass("advantage_"+f.advantageType),u.html(SeatDetails._ADV_LABELS[f.advantageType]));c?p.html(functions.generateAmount(f.amount)):(m.html(h),g?$("#seat_info_full, #seat_info_price_full").hide():(a=SeatList.checkAddPrice(e,a,1),!0===a?$("#seat_info_full, #seat_info_price_full").hide():($("#seat_info_full").toggle("OVER_GLOBAL_MAX"==a),$("#seat_info_price_full").toggle("OVER_PRICE_MAX"==
a))));f.degressivePrices&&0<f.degressivePrices.length?($("#"+k+"seat-info-price-adv .degressive_rate").show(),m.addClass("advantage")):$("#"+k+"seat-info-price-adv .degressive_rate").hide();R(f,d,l);f.audienceSubCategoryDescription?($(".external_tariff_description").html(f.audienceSubCategoryDescription),$(".external_tariff_description").show()):$(".external_tariff_description").hide()},ba=function(){e||$("#seat-info-loading-bg, #seat-info-loading").show();e++},U=function(){e--;1>e&&$("#seat-info-loading-bg, #seat-info-loading").hide()},
P=function(a){var b=a?"nn":"";$("#"+b+"seat-info-added").show();$("#"+b+"seat-info-added-bg").show();f=setTimeout(function(){$("#"+b+"seat-info-added").fadeOut(function(){$("#"+b+"seat-info-added-bg").hide();$(".seat-booking").addClass("selected")})},500)},Y=function(a,b,c){b||$(".seat-booking").toggleClass("selected",a);c?($("#nndelete-seat").parent().toggle(a),$("#nnseat_info_booking_title").html(SeatDetails[a?"_LABEL_BOOK_EXISTING":"_LABEL_BOOK_NNAREA_CHOOSE"])):($("#delete-seat").parent().toggle(a),
$("#seat_info_booking_title").html(SeatDetails[a?"_LABEL_BOOK_EXISTING":"_LABEL_BOOK_CHOOSE"]))},da=function(a,b,c,d,e){var f;for(f=0;f<a.length;f++){var g=a[f];var h=g.advantageId?" / "+g.advantage:"";var k=g.priceLevelCode?" / "+g.priceLevelCode:"";if(c===f){var l=' selected="selected"';e&&R(g,d.find(".external_verification_indicator"),d.find(".conditional_rate_indicator"))}else l="";var m="";g.conditionalRateData&&(m="opCondRateCls");b.append('<option class = "'+m+'"value="'+f+'"'+l+">"+g.audienceSubCategory+
k+h+"</option>")}},aa=function(a,b,c){var d=$("#nnseat-rate-selection-"+c);c="undefined"!==typeof c?$("#nnseat-rate-selection-"+c+" .nnseat-rate-select"):$("#seat-info-prices");da(a,c,b,d,!0)},W=function(a,b,c){var d=0===c?' selected="selected"':"",e;$("#nnseat-rate-selection-"+a+" .nnseat-rate-quantity option").remove();$("#nnseat-rate-selection-"+a+" .nnseat-rate-quantity").append('<option value="0"'+d+">0</option>");for(e=b.minQuantity;e<=b.maxQuantity;e++)d=c===e?' selected="selected"':"",$("#nnseat-rate-selection-"+
a+" .nnseat-rate-quantity").append('<option value="'+e+'"'+d+">"+e+"</option>")},J=function(a,b,c,d){var e=$("#nnseat-rate-selection-"+d+" .nnseat-rate-price"),f=$("#nnseat-rate-selection-"+d+" .nnseat-rate-pre-price"),g=a[b];aa(a,b,d);W(d,g,c);e.html(functions.generateAmount(g.amount));g.advantageId?(e.addClass("advantage"),g.amountWithoutAdvantage&&g.amountWithoutAdvantage!=g.amount&&(a=functions.generateAmount(g.amountWithoutAdvantage),f.html(a))):(e.removeClass("advantage"),f.html(""))},la=function(a,
b,c){var d=a.filter(":selected"),e=Number(d.attr("ticket-amount"));if(0===d.length||e<b||e>c)a=a.filter(':not([style*="display: none"])').first().val(),M.val(a)},ja=function(a,b){if(a&&b){var c=M.find("option");0<c.length&&c.each(function(c,d){(c=Number(d.getAttribute("ticket-amount")))&&(c<a||c>b)?$(d).hide():$(d).show()});la(c,a,b);M.trigger("change")}},ea=function(a){var b=resale.sliderFilter.getPriceRangeValues();return!a||a.minPrice>b.max||a.maxPrice<b.min},ha=function(){var a=[];var b=".seat-cat-checkbox:checked";
F&&(b+=":visible");$(b).each(function(){a.push(parseInt($(this).val(),10))});return a},ca=function(a){var b=ha();return 0<=$.inArray(parseInt(a,10),b)},ma=function(){var a=[];$(".tariff-checkbox:checked:visible").each(function(){a.push(parseInt($(this).val(),10))});return a},oa=function(a){var b=ma();return ca(a)?!F||E||H?!0:ea(B[a])||(b||[]).every(function(a){return ea(G[a])})?!1:!0:!1},na=function(a){var b=ha();var c=ma();return(a.gradientIdentifier.split("_")||[]).every(function(a){return 0>$.inArray(parseInt(a,
10),b)})?!1:!F||E?!0:(a.tariffIds||[]).every(function(a){return 0>$.inArray(parseInt(a,10),c)})?!1:H?!0:(b||[]).every(function(a){return ea(B[a])})||(c||[]).every(function(a){return ea(G[a])})||ea(a.mmPriceModel)?!1:!0},pa=function(b,c){var d;var e=resale.sliderFilter.getMinMaxSlider();(b&&b!==e.min||c&&c!==e.max)&&$("#item_price_filter").parents(".criteria").find(".filterToolReset").show();ja(b,c);if(a)if(SeatMap.refreshSeatLayer(),b=SeatMap.blocks)for(f in b)b[f]&&(c=SeatMap.additionalBlockInfo[f])&&
(na(c)?SeatMap.showBlock(f):SeatMap.hideBlock(f));else{var f=SeatMap.nnAreas;for(d in f)f.hasOwnProperty(d)&&(b=jQuery.grep(SeatMap.nnAreasInfo,function(a,b){return a.id.toString()===d})[0])&&(oa(b.seatCategoryId)?SeatMap.addArea(b.id.toString()):SeatMap.removeArea(b.id.toString()))}else seatmap.SeatMapSvg.filterSeatByPrice()},qa=function(a){!a||H||E||($("#item_price_filter").parents(".criteria").find(".filterToolReset").hide().on("click",function(){$(this).hide();resale.sliderFilter.reset();pa()}),
isNaN(a.minPrice)||isNaN(a.maxPrice)||(resale.sliderFilter.init("#item_price_filter",a.minPrice,a.maxPrice),resale.sliderFilter.registerSlideCallback(pa),a.minPrice===a.maxPrice?$(".seat-map-price-filter").hide():$(".seat-map-price-filter").show()))},ra=function(a,c){var d=$("<select>",{id:"rs-seat-info-tariff"}),e=0;b&&null!=b.priceIdx&&(d.prop("disabled",!0),e=b.priceIdx);da(c,d,e);d.on("change",function(b){ua(null,a,c,b.currentTarget.selectedIndex)});return d},ia=function(a){var c=!1;isNewTicketShop?
($("#seat-info-category .name").css("color","#"+a.color),$("#seat-info-category .color").css("background-color","#"+a.color),$("#seat-info-category").css("background-color","#"+a.color+"1A")):$("#seat-info-category .color").css("background-color","#"+a.color);isNewTicketShop?($("#seat-info-category .name").html(a.seatCategory).attr("title",a.seatCategory),$("#seat-info-areaname").html(SeatDetails._LABEL_SEAT_AREA+'<span class="value">'+a.area+"</span>")):($("#seat-info-areaname").html(a.area),$("#seat-info-category .name").html(a.seatCategory));
a.block&&null!==a.block?isNewTicketShop?$("#seat-info-blockname").html(SeatDetails.getSeatBlockLabel(a.areaId)+'<span class="value">'+a.block+"</span>"):$("#seat-info-blockname").html(" - "+SeatDetails.getSeatBlockLabel(a.areaId)+" "+a.block):isNewTicketShop?$("#seat-info-blockname").hide():$("#seat-info-blockname").html("");a.row&&null!==a.row?isNewTicketShop?$("#seat-info-rowname").html(SeatDetails.getSeatRankLabel(a.block,a.areaId)+'<span class="value">'+a.row+"</span>"):$("#seat-info-rowname").html(SeatDetails.getSeatRankLabel(a.block,
a.areaId)+" "+a.row):(isNewTicketShop&&$("#seat-info-rowname").hide(),$("#seat-info-rowname").html(""));a.number&&null!==a.number?($("#seat-info-text").html(SeatDetails.getSeatNumberLabel(a.areaId)),a.row&&null!==a.row?$("#seat-info-text").addClass("with_row"):$("#seat-info-text").removeClass("with_row"),$("#seat-info-seat").html(a.number),$("#seat-info-seat-container").show()):$("#seat-info-seat-container").hide();$("#seat_companion_warning").hide();if(F){b?ua(S(a.resaleInfo.amount,a.resaleInfo.amountWithCharge),
a.resaleInfo.realPrice,a.prices,b.priceIdx||0):ua(S(a.resaleInfo.amount,a.resaleInfo.amountWithCharge),a.resaleInfo.realPrice,a.prices,0);if(E&&a.prices){var d=ra(a.resaleInfo.realPrice,a.prices);var e=$("#rs-seat-info-tariff");e.replaceWith(d)}else d=a.resaleInfo.audienceSubCatgory,$("#rs-seat-info-tariff").html(d||"");a.resaleInfo.withCompanion&&($("#seat_companion_warning").html((null==a.resaleInfo.companionTicketResaleId?SeatDetails._LABEL_COMPANION_INFO:SeatDetails._LABEL_ACCESIBLE_INFO)+" ("+
a.resaleInfo.companionInfo+")"),$("#seat_companion_warning").show())}p||(a.externalRemark&&null!==a.externalRemark?($("#seat-info-remark-text").html(a.externalRemark),$("#seat-info-remark").show(),$("#seat-info-titling-vis").hide(),$("#seat-info-titling-vis-invisibility").hide(),$("#seat-info-stage-vis").hide(),$("#seat-info-stage-vis-invisibility").hide(),c=!0):($("#seat-info-remark-text").html(""),$("#seat-info-remark").hide(),a.titlingVisibilityType&&"VISIBLE"!==a.titlingVisibilityType?("INVISIBLE"===
a.titlingVisibilityType?($("#seat-info-titling-vis").hide(),$("#seat-info-titling-vis-invisibility").show()):($("#seat-info-titling-vis").show(),$("#seat-info-titling-vis-invisibility").hide()),c=!0):($("#seat-info-titling-vis").hide(),$("#seat-info-titling-vis-invisibility").hide()),a.stageVisibilityType&&"VISIBLE"!==a.stageVisibilityType?("INVISIBLE"===a.stageVisibilityType?($("#seat-info-stage-vis-invisibility").show(),$("#seat-info-stage-vis").hide()):($("#seat-info-stage-vis").show(),$("#seat-info-stage-vis-invisibility").hide()),
c=!0):($("#seat-info-stage-vis").hide(),$("#seat-info-stage-vis-invisibility").hide())),a.seatQuality&&null!==a.seatQuality&&($("#seat-info-quality").html(a.seatQuality),c=!0),$("#seat-details .seat-info-content .seat-quality-remarks").toggle(c))},ua=function(a,b,c,d){var e;E&&c&&0<c.length&&(d||0===d)?e=c[d].amount:!E&&(a||0===a)&&(e=a);(e||0===e)&&$("#rs-seat-info-price").html(functions.generateAmount(e)||"");if(b||0===b)$("#rs-seat-info-real-price").html(functions.generateAmount(b)||""),e===b?
$("#rs-seat-info-real-price").removeClass("has-cross-line"):$("#rs-seat-info-real-price").addClass("has-cross-line")},wa=function(b,c){var d=$("#nn-resale-seat-select"),e,f,g,h,k,l,m,p;d.find("option").remove().end();var q=[],r=$(".tariff-checkbox:not(:checked):visible");0<r.length&&r.each(function(a,b){q.push(b.value)});if(!a||SeatMap&&ca(SeatMap.getAreaSeatCategory(b.areaId)))E?(b.resaleSeats||[]).forEach(function(a){h=a.resaleInfo.ticketResaleId;k=a.resaleInfo.resaleMovId;a.seatId=k;a.isBookAvailable=
void 0===SeatList.getSelectedSeats()[k];L[k]=a;m=a.isBookAvailable?"":"disabled";p=1<a.prices.length?SeatList._LABEL_TARIFFS_AVAILABLE_N:SeatList._LABEL_TARIFFS_AVAILABLE_1;e=[a.area,a.seatCategory,a.prices.length+" "+p];d.append('<option id="resale_'+h+'" value="'+k+'" '+m+">"+e.join(" - ")+"</option>")}):(b.ticketResaleGroupsResponse||[]).forEach(function(b){f=b.groupResaleSeatInfoResponse.length;if(!q.includes(b.audienceSubCategoryId.toString())){var h=S(b.amount,b.amountWithCharge);g=b.audienceSubCategoryId+
"_"+h;K[g]=[];(b.groupResaleSeatInfoResponse||[]).forEach(function(a){k=a.resaleInfo.resaleMovId;a.seatId=k;void 0===SeatList.getSelectedSeats()[k]?a.isBookAvailable=!0:(a.isBookAvailable=!1,f--);a.groupResaleIndex=g;L[k]=a;K[g].push(a.resaleInfo.resaleMovId)});m=0===f?"disabled":"";e=[b.audienceSubCategory,functions.generateAmount(h),N(f)];d.append('<option id="resale_'+g+'" value="'+g+'" ticket-amount="'+h+'" '+m+">"+e.join(" - ")+"</option>");b.isNonNumbered=!0;b.seatCentroid=a?c.geometry.getCentroid():
null}});$("#seat-details .seat-info-content").show();$("#nn-resale-seat-select").on("change",function(){if(E)l=L[this.value];else a:{var a=K[this.value],b;if(a)for(b=0;b<a.length;b++){var c=a[b];if(L[c].isBookAvailable){l=L[c];break a}}l=void 0}l&&(ia(l),SeatDetails.selectedNonNumSeat={data:l},$("#add-selected-seat-to-cart").parent().removeClass("disabled"),O(l,!1))});$("#nn-resale-seat-select").trigger("change",0)},xa=function(a,b){a=jQuery.grep(a,function(a,c){return a.priceIdx===b});return 0===
a.length?0:a[0].quantity},va=function(a,b,c,d){try{var e=decodeURIComponent(a),f=new URL(e);var g="http:"===f.protocol||"https:"===f.protocol}catch(Ma){g=!1}return g?decodeURIComponent(a):c?b+a+("&qualifier="+c)+d:b+a+d},ta=function(a){var b=!!a.scenePhotoLink,c=!!a.scenePanoLink,d=!1,e=null;$("#seat-info-img").off("click");$("#krpano_seat_description_seat").html(SeatList.getSeatDescriptionFromData(a));if(c&&functions.isWebGLSupport())$("#seat-info-img").hide(),$("#pano-thumbnail").show(),$(".helper-text").show(),
d||(e=tools.parsePanoURL(a.scenePanoLink),e.protocol?SeatPano.displayPanel(e.protocol,e.url,"pano-container","pano-thumbnail"):SeatPano.displayPanel("krpano",u+a.scenePanoLink,"pano-container","pano-thumbnail"),d=!0),$("#seat-info-img").parent().show();else if(b){$("#seat-info-img").show();$("#pano-thumbnail").hide();$(".helper-text").hide();b=null==l?"":"&performanceId="+l;$("#seat-info-img").attr("src",va(a.scenePhotoLink,x,"MEDIUM",b));$("#seat-info-img-full img").attr("src",va(a.scenePhotoLink,
x,null,b));$("#seat-info-img-full img").show();$("#pano_info").hide();$("#krpano").hide();if(isNewTicketShop)$(".seat-info-img-wrapper").on("click",function(a){$(a.target).is(".seat-info-img-wrapper")&&$("#seat-info-img").trigger("click")});$("#seat-info-img").on("click",function(){tools.dialog.showDialog("seat-info-img-full",!0)});$("#seat-info-img").parent().show()}else $(".helper-text").hide(),$("#seat-info-img").parent().hide(),$("#seat-info-img").attr("src","")},Fa=function(b,c){var d=a?c.data:
c;b.seatId=d.id;b.color=b.color?b.color:d.color;b.row=d.row;b.number=d.number;b.seatCentroid=a?c.geometry.getCentroid():null},za=function(b,e,f,k,l){var m=t+"_"+e;var p=h[m];c===e?a||l||seatmap.SeatMapSvg.events.trigger("onSeatUnSelected",p):(c=e,window.clearTimeout(d),p?SeatDetails.initSeatDetails(b,p):(ta(a?b.feature.data:b),ba(),$.ajax({url:f,type:"GET",cache:!1,data:k,error:function(a){tools.dialog.showDialog("ajaxErrorDialog",!0)},success:function(c){var d=!1;"BAD_REQUEST"===c.status&&("RESTRICTED_AREA"===
c.errorCode?tools.dialog.showDialog("restrictedAreaError",!0):"NO_PRICE"===c.errorCode?tools.dialog.showDialog("noPriceError",!0):tools.dialog.showDialog("ajaxErrorDialog",!0),d=!0);var f;if(f=!d){a:{var k=SeatList.getSelectedSeats();for(l in k)if(k.hasOwnProperty(l)&&(f=k[l].data)&&"MANUAL_OR_AUTO"===c.sameBlockRestrictionMode&&c.seatCategoryId===f.seatCategoryId&&(c.areaId!==f.areaId||c.blockId!==f.blockId)){var l=!1;break a}l=!0}f=!l}f&&(tools.dialog.showDialog("restrictedAreaError",!0),d=!0);
d&&(SeatList.deleteSeat(SeatList.getSeat(e)),SeatList.cancelPreselectSeat(e),a?SeatMap.unselectAllSeats():seatmap.SeatMapSvg.removeSeatSelection(e,!1));d?U():(c.number||c.areaId||(c.areaId=a?e:b.areaId),h[m]=c,U(),!a||b.feature&&b.feature.data?SeatDetails.displaySeatDetails(b,c):g=c)}})))},Ga=function(a){var b=ha();if(0>$.inArray(a.seatCategoryId,b)&&!r)return!1;if(!F||E)return!0;b=ma();if(0>$.inArray(a.tariffId,b))return!1;if(H)return!0;b=resale.sliderFilter.getPriceRangeValues();return a.amount>=
b.min&&a.amount<=b.max?!0:!1},Ha=function(){SeatMap.blocksLayer.events.on({beforefeatureadded:function(a){var b=SeatMap.additionalBlockInfo[a.feature.data.id];if(b){var c=na(b);if(!c&&!r)return!1;if(b.available)return a.feature.attributes.fillColor="url(#"+b.gradientIdentifier+")",!0}return!1}})},sa=function(e){if(!r)return function(f,g){f=f.feature;a&&SeatList.isSeatSelected(f.data.id)&&e(f);c=null;d=setTimeout(function(){!g||!g.isNonNumbered&&g.number?($("#seat-details .seat-info-content").hide(),
$("#seat-details .seat-info-placeholder").show()):($("#seat-details .seat-info-content").show(),$("#seat-details .seat-info-placeholder").hide());b=null},10)}},ka=function(){var b={beforefeatureadded:function(a){a=a.feature;var b=a.attributes;b.nnAreaColor=SeatMap.getAreaColor(a.data.id);b.nnAreaInCartColor=util.color.changeColorLuminance(b.nnAreaColor,-.2);return!0},featureselected:function(b,c){var d=a?b.feature.data.id:c.id;b=a?b:c;c={productId:k,perfId:l,areaId:a?d:c.areaId,advantageId:m||"",
seatCategoryId:a?SeatMap.getAreaSeatCategory(d):c.seatCategoryId,ppid:w,reservationIdx:y,crossSellId:z};za(b,d,C,c,!0)},featureunselected:sa(function(a){SeatMap.redrawArea(a.data.id,"addedToCart")})};if(a)SeatMap.nnAreasLayer.events.on(b);else seatmap.SeatMapSvg.events.on("onAreaSelected",b.featureselected),seatmap.SeatMapSvg.events.on("onAreaUnSelected",b.featureunselected)},Aa=function(a,b){ta(b);SeatDetails.displaySeatDetails(a,b)},Ba=function(){var b={beforefeatureadded:function(a){return SeatList.getSeat(a.feature.data.id)?
(a.feature.renderIntent="addedToCart",!0):Ga(a.feature.data)},featureselected:function(b,c){var d;if(!r){var e=a?b.feature.data.id:c.id;if((d=a?!b.feature.ignoreDeselecting:c.enableDeselecting)&&SeatList.isInSeatList(e))SeatList.deleteSeat(SeatList.getSeat(e));else{b=a?b:c;c={productId:k,perfId:l,seatId:e,advantageId:m||"",ppid:w,reservationIdx:y,crossSellId:z};SeatList.isExclusiveAvailable()&&(d=SeatList.getSeat(e),c.filteredExclusive=d?d.exclusive:SeatList.isExclusive());if(F){var f=SeatList.getSelectedSeats();
(Object.keys(f)||[]).forEach(function(b){f[b].data||Number(b)===Number(e)||(SeatList.cancelPreselectSeat(b),a||seatmap.SeatMapSvg.removeSeatSelection(b,!1))})}SeatList.preselectSeat(e);za(b,e,A,c)}}},featureunselected:sa(function(a){SeatMap.redrawSeat(a.fid,"addedToCart")}),featureadded:function(b){c===b.feature.fid&&(a&&SeatMap.selectControl.select(Object.assign({},b.feature,{ignoreDeselecting:!0})),g&&c===g.seatId&&(Aa(b,g),g=null))}};if(a)SeatMap.seatsLayer.events.on(b);else seatmap.SeatMapSvg.events.on("onSeatSelected",
b.featureselected),seatmap.SeatMapSvg.events.on("onSeatUnSelected",b.featureunselected)},Ca=function(a){a?1===$(".nnseat-rate-select option").length?($(".nnseat-rate-select").hide(),$("#add-rate").hide()):($(".nnseat-rate-select").show(),$("#add-rate").show()):1===$("#seat-info-prices option").length?$("#seat-info-prices").hide():$("#seat-info-prices").show()},ya=function(a){var c={priceIdx:a,data:b.data};SeatList.isExclusiveAvailable()&&(c.exclusive=SeatList.isExclusive());b.priceIdx=a;Y(!0,!0,!1);
SeatList.addSeat(c);SeatSessionStorage.storeSelectedSeat(t,c,!0);P(!1);tools.scrollElementInViewport("#pre-cart",400,12);return b},Da=function(){var a=[],c=[],d,e;jQuery.each($("#seat-details .nnseat-rate-select"),function(b,f){e=parseInt($(f).parent().find(".nnseat-rate-quantity").val(),10);0!==e&&(c=jQuery.map(a,function(a,b){return a.priceIdx}),d=jQuery.inArray($(f).val(),c),-1===d?a.push({priceIdx:$(f).val(),quantity:e}):a[d].quantity+=e)});if(0!==a.length||SeatList.isSeatSelected(b.data.seatId)){$("#notification").hide();
b.priceQty=a;Y(!0,!0,!0);var f={priceQty:a,data:b.data};SeatList.addNonNumberedSeat(f);SeatSessionStorage.storeSelectedSeat(t,f,!1);P(!0);tools.scrollElementInViewport("#pre-cart",400,12)}else $("#notification").show()},Ea=function(b){var c,d=b.checked,e=b.value;if(a){var f=SeatMap.getAreasBySeatCategory(e);b=SeatMap.blocks;SeatMap.refreshSeatLayer();jQuery.each(f,function(a,b){d?SeatMap.addArea(b.id.toString()):SeatMap.removeArea(b.id.toString())}.bind(this));if(!d){var g=[];$.each(SeatMap.blocksLayer.features,
function(){var a=this.attributes.fillColor;a="url(#"+a.substring(5,a.length-1).split("_").filter(function(a){return a!==e}).join("_")+")";this.attributes.fillColor!==a&&(g.push(this.id),this.attributes.fillColor=a,SeatMap.blocksLayer.drawFeature(this))});SeatMap.blocksBySeatCatId[e]=g}if(b)for(c in b)b.hasOwnProperty(c)&&(f=SeatMap.additionalBlockInfo[c])&&(na(f)?SeatMap.showBlock(c):SeatMap.hideBlock(c));if(d){var h=Object.keys(SeatMap.blocksBySeatCatId).filter(function(a){return a!==e});$.each(SeatMap.blocksBySeatCatId[e],
function(){var a=this,b=SeatMap.blocksLayer.features.find(function(b){return b.id===a.valueOf()}),c=b.attributes.fillColor;c=c.substring(5,c.length-1).split("_");c.includes(e)||c.push(e);h.length&&(c=c.filter(function(a){return!h.includes(a)}));c="url(#"+c.sort().join("_")+")";b.attributes.fillColor!==c&&(b.attributes.fillColor=c,SeatMap.blocksLayer.drawFeature(b))});delete SeatMap.blocksBySeatCatId[e]}}else seatmap.SeatMapSvg.filterSeatBySeatCat(e)};return{init:function(c){a=c.isOpenLayerSeatMap;
A=c.seatDetailsUrl;l=c.performanceId;k=c.productId;m=c.partnerAdvantageId;w=c.ppid;y=c.reservationIdx;z=c.crossSellId;x=c.seatImageUrl;u=c.panoConfigUrl;C=c.areaDetailsUrl;p=c.isMobile;q=c.areaIsLogeMap;r=c.isChangeSeatMode;t=c.seatSessionStorageEvent;E=c.isSeatRelease;F=c.resaleMode;v=c.polygonData;F&&(H=c.isModifyTariff,G=c.minMaxPriceByTariff,B=c.minMaxPriceByCategory,qa(c.mmPriceSM));Q=$("#seat-details .seat-info-placeholder");M=$("#nn-resale-seat-select");$("#seat-details").on("change","#seat-info-prices",
function(){var a=parseInt($(this).val(),10),c=b.data,d=b.priceIdx,e=SeatList.getSeat(b.data.seatId);e&&SeatList.deleteSeat(b,!0);Z(a,!1);e&&SeatList.addSeat({data:c,priceIdx:d},!0);ya(parseInt($("#seat-details #seat-info-prices").val(),10))}).on("change",".nnseat-rate-select",function(){var a=$(this).parent(),c=parseInt(/\d+/.exec(a.attr("id"))[0],10),d=b.data.prices,e=$(this).val(),f=parseInt(e,10);d=d[f];var g=(e=X(e))?0:parseInt(a.find(".nnseat-rate-quantity").val(),10),h=SeatList.checkAddPrice(b,
f,g);Z(f,!0,c);W(c,d,g);a.find(".nnseat-rate-quantity").prop("disabled",e);a.find(".nnseat_info_rate_exist").toggle(e);!0===h?Da():$("#add-to-cart").parent().addClass("disabled")}).on("click","#delete-seat, #nndelete-seat",function(a){a.preventDefault();$(this).parent().hasClass("disabled")||SeatList.deleteSeat(b)}).on("change",".nnseat-rate-quantity",function(){var a=$(this).parent().parent().siblings(".nnseat-rate-select").val(),c=parseInt(a,10),d=SeatList.getSeat(b.data.seatId),e=parseInt($(this).val(),
10);c=SeatList.checkAddPrice(b,c,e);e=$(this).parent().parent();d&&xa(d.priceQty,a);!0===c?$(".nnseat_info_price_full, .nnseat_info_full").hide():(e.siblings(".nnseat_info_price_full").toggle("OVER_PRICE_MAX"==c),e.siblings(".nnseat_info_full").toggle("OVER_GLOBAL_MAX"==c));!0===c?Da():$("#add-to-cart").parent().addClass("disabled")});$(".tariff-checkbox").on("click",function(){var b;if(D){var c=$("#nn-resale-seat-select").children("[id*=resale_"+this.value+"]");this.checked?c.show():c.hide();c=$("#nn-resale-seat-select")[0];
if(-1!==c.value.indexOf(this.value)){var d=$("#nn-resale-seat-select option:visible");d.val()?c.selectedIndex=-1!==d.val().indexOf(this.value)?0:-1:(d=d.length,c.selectedIndex=0===d?-1:0)}}else if(a){if(SeatMap.refreshSeatLayer(),c=SeatMap.blocks)for(d in c)c[d]&&(b=SeatMap.additionalBlockInfo[d])&&(na(b)?SeatMap.showBlock(d):SeatMap.hideBlock(d))}else F&&seatmap.SeatMapSvg.filterSeatByTariff(this.value)});isNewTicketShop&&$(".seat-cat-checkbox").each(function(){var a=this,b=$("<label _ts15_label></label>");
$(a).after(b);$(b).on("click",function(){$(a).prop("checked",!$(a).prop("checked")).triggerHandler("click")})});$(".seat-cat-checkbox").on("click",function(){Ea(this)});$("#add-rate").on("click",function(){var a;if(!$("#add-rate").parent().hasClass("disabled")){var c=$("<div></div>").addClass("nnseat-rate-selection");var d=$(".nnseat-rate-selection").length;var e=V();for(a=0;a<b.data.prices.length&&-1!==jQuery.inArray(a.toString(),e);a++);a=a.toString();e=b.data.prices[parseInt(a,10)];c.attr("id",
"nnseat-rate-selection-"+d);c.append($("#nnseat-rate-selection-0").html());c.find(".nnseat-rate-select").val(a);$("#nnseat-rate-selection-"+(d-1)).after(c);W(d,e,0);d=$("#nnseat-rate-selection-"+d);a=d.find(".nnseat-rate-price");a.html(functions.generateAmount(e.amount));d.find(".nnseat_info_price_full").hide();d.find(".nnseat_info_rate_exist").hide();c=d.find(".nnseat-rate-pre-price");e.advantageId?(a.addClass("advantage"),e.amountWithoutAdvantage&&e.amountWithoutAdvantage!=e.amount&&(a=functions.generateAmount(e.amountWithoutAdvantage),
c.html(a))):(a.removeClass("advantage"),c.html(""));R(e,d.find(".external_verification_indicator"),d.find(".conditional_rate_indicator"));T()}return!1});a?(SeatMap.events.on("initSeatsLayerDone",Ba),SeatMap.events.on("initnnAreasLayerDone",ka),SeatMap.events.on("initBlocksLayerDone",Ha)):(Ba(),ka());$(window).on("message",function(a){"https://static.pacifa3d.com"===a.originalEvent.origin&&"fullscreen"===a.originalEvent.data&&(a=$("iframe"),"fixed"===a.css("position")?a.css({position:"static",height:"97px"}):
a.css({position:"fixed",top:"0",left:"0",height:"100%",width:"100%","z-index":"99999"}))});var d=function(){var a=document.getElementById("rs-seat-info-tariff");if(b){if(a=null==a.selectedIndex?0:a.selectedIndex,a=ya(a))$("#add-selected-seat-to-cart").parent().addClass("disabled"),$("#rs-seat-info-tariff").prop("disabled",!0),SeatList.selectSeat(a)}else SeatDetails.selectedNonNumSeat.data.isBookAvailable=!1,SeatDetails.selectedNonNumSeat.priceIdx=a.selectedIndex?a.selectedIndex:0,O(SeatDetails.selectedNonNumSeat.data,
!0),SeatSessionStorage.storeSelectedSeat(t,SeatDetails.selectedNonNumSeat,!1),SeatList.addNonNumberedResaleSeat(SeatDetails.selectedNonNumSeat),P(!0)};$("#add-selected-seat-to-cart").on("click",function(a){a.preventDefault();if(!$("#add-selected-seat-to-cart").parent().hasClass("disabled"))if(D){var b=e();for(a=0;a<b;a++)d(),$("#nn-resale-seat-select").trigger("change")}else d()});var e=function(){return E?1:parseInt($("#nn-resale-seat-quantity").val(),10)||0};SeatPano.init({panoSWFUrl:c.panoSwfUrl,
panoJSUrl:c.panoJSUrl,html5Config:"prefer"})},initSeatDetails:Aa,displaySeatDetails:function(c,d){if(!a||c.feature&&c.feature.data||d.seatId){window.clearTimeout(f);$("#seat-info-added, #seat-info-added-bg").hide();d.seatId||Fa(d,a?c.feature:c);var e=d.seatId;var h=SeatList.getSeat(e);D=d.number?!1:!0;if(F){$(Q).show();$(".seat-info-content").addClass("seat-info-with-filter");$(Q).children(".seat-info-intro-container").hide();$("#seat-details .seat-info-content").show();Ca(D);if(D){b=null;wa(d,c.feature);
resale.sliderFilter.isSliderFilterInitialized()&&(d=resale.sliderFilter.getPriceRangeValues(),ja(d.min,d.max));$("#nn-resale-seat-select").show();$("#nn-resale-seat-quantity").show();$(".seat-quantity").show();$(".seat-number").hide();$("#nn-resale-seat-select")[0].selectedIndex&&0>$("#nn-resale-seat-select")[0].selectedIndex&&$("#add-selected-seat-to-cart").parent().addClass("disabled");return}$("#nn-resale-seat-select").hide();$("#nn-resale-seat-quantity").hide();$(".seat-quantity").hide();$(".seat-number").show()}if(!b||
b.data.seatId!==e){c=D?h?parseInt(h.priceQty[0].priceIdx,10):0:h?parseInt(h.priceIdx,10):0;b={};b.data=d;SeatList.isExclusiveAvailable()&&(b.exclusive=h?h.exclusive:SeatList.isExclusive());D||h||F||(Z(c,!1),ya(c)?h=SeatList.getSeat(e):SeatList.cancelPreselectSeat(e));h?(D?b.priceQty=h.priceQty:(b.priceIdx=h.priceIdx,Z(c,!1)),$("#add-selected-seat-to-cart").parent().addClass("disabled")):$("#add-selected-seat-to-cart").parent().removeClass("disabled");D?(F||Z(c,!0,0),$("#nndelete-seat").attr("data-id",
"id--"+e)):$("#delete-seat").attr("data-id","id--"+e);h?(Y(!0,!1,D),SeatList.selectSeat(b)):Y(!1,!1,D);ia(d);if(D){$(".nnseat-rate-select option").remove();var k=$(".nnseat-rate-selection").first();k.find(".nnseat_info_price_full").hide();k.find(".nnseat_info_rate_exist").hide();var l=k.clone();$("#nnseat-rate-selections").empty();h?jQuery.each(h.priceQty,function(a,b){var c=l.clone();c.attr("id","nnseat-rate-selection-"+a);$("#nnseat-rate-selections").append(c);J(h.data.prices,parseInt(b.priceIdx,
10),b.quantity,a)}):(l.attr("id","nnseat-rate-selection-0"),$("#nnseat-rate-selections").append(l),J(d.prices,c,0,0));$("#add-rate").parent().show();T();$("#seat_booking_with_number").hide();$("#seat_booking_no_number").show()}else $("#seat-info-prices option").remove(),aa(d.prices,c),$("#seat_booking_with_number").show(),$("#seat_booking_no_number").hide(),$("#add-rate").parent().hide();$("#seat-details .seat-info-content").show();F||($("#seat-details .seat-info-placeholder").hide(),Ca(D));F&&a&&
SeatList.cancelPreselectSeat(e)}}else g=d},preventCategoryDisplay:function(){c||window.clearTimeout(d)},isAreaKindLoge:function(a){return a&&null!==a&&q[a]},getSeatBlockLabel:function(a){return SeatDetails.isAreaKindLoge(a)?SeatDetails._LABEL_SEAT_LOGE:SeatDetails._LABEL_SEAT_BLOCK},getSeatRankLabel:function(a,b){if(!a||null===a){if(SeatDetails.isAreaKindLoge(b))return SeatDetails._LABEL_SEAT_LOGE}else if(SeatDetails.isAreaKindLoge(b))return"";return SeatDetails._LABEL_SEAT_RANK},getSeatNumberLabel:function(a){return SeatDetails.isAreaKindLoge(a)?
"":SeatDetails._LABEL_SEAT_NUMBER},getResaleNonNumberedMap:function(){return L},showSeatDetailsInThePanel:function(a){ta(a);ia(a);$("#seat-details .seat-info-content").show();$("#seat-details .seat-info-placeholder").hide()},showLoadingIndicatorInThePanel:function(){ba()},hideLoadingIndicatorInThePanel:function(){U()},setDisplayFilterByPolygon:function(a){a=v[a];F&&a&&($(".seat-info-category-legend").hide(),a.seatCatIds.forEach(function(a){$("#seat-cat-filter-"+a).css("display","flex")}),E||($(".tariff-legend").hide(),
(a.tariffIds||[]).forEach(function(a){$("#tariff-filter-"+a).show()}),H||(resale.sliderFilter.setMinMaxSlider(a.minMaxPrice.minPrice,a.minMaxPrice.maxPrice),resale.sliderFilter.reset())))},getSeatCatFilter:function(){$(".seat-cat-checkbox").each(function(){Ea(this)})},getVisibleSeatCategories:function(){return ha()},getVisibleTariff:function(){return ma()},getPriceRangeSlider:function(){return resale.sliderFilter.getPriceRangeValues()},updateSeatInformation:function(a,b){return O(a,b)},getSelectedSeatId:function(){return c}}});
tools.module("SeatList",function(){var a=!0,b={},c={},d=0,f={},e=!1,g=null,h=null,l=null,k=null,m=null,p=null,q=0,r=null,t=null,w=null,y=0,z=0,x=0,A=!1,C=null,u=!1,v=!1,D,E=null,F=null,B=null,G=!1,L=function(){var a=null;for(a in f)if(f.hasOwnProperty(a)){var c=f[a];if(c.count){if(G&&null!==c.advantageId&&null===c.tariffLimit&&null===w&&null!==c.advantageLimit){e=!0;g=null;return}if(null!==c.minQuantity&&c.count<c.minQuantity||null!==c.maxQuantity&&c.count>c.maxQuantity){e=!1;g=c;return}}}e=!0;g=
null;a:{for(var d in b)if(!0===b[d]){a=!0;break a}a=!1}a&&(e=!1)},K=function(){return v?$("#ResaleItemFormModel"):C?$("#FixedPriceSeasonTicketFormModel"):$("#EventFormModel")},H=function(a,b){b||0===b||(b=a.priceIdx);b=a.data.prices[b];var c=b.audienceSubCategoryId,d=a.data.seatCategoryId,e=b.priceLevelId,g=b.advantageId,h=d+"_"+c;e&&(h+="_"+e);g&&(h+="__"+g);f[h]||(f[h]={count:0,minQuantity:b.minQuantity,maxQuantity:b.maxQuantity,audienceSubCategory:b.audienceSubCategory,seatCategory:a.data.seatCategory,
externalVerification:b.externalVerification,isMemberCategory:b.isMemberCategory,priceLevelCode:b.priceLevelCode,audienceSubCategoryId:c,seatCategoryId:d,advantageName:b.advantage,advantageId:b.advantageId,advantageLimit:b.advantageLimit,tariffLimit:b.audienceSubCategoryMaxQuantity,key:h});return f[h]},M=function(a){jQuery.each(a.priceQty,function(b,c){b=parseInt(c.priceIdx,10);c=c.quantity;b=H(a,b);b.count-=c;0>=b.count&&delete f[b.key]})},Q=function(a,b){b&&M(b);jQuery.each(a.priceQty,function(b,
c){b=parseInt(c.priceIdx,10);c=c.quantity;H(a,b).count+=c})},S=function(a){var b={},c=null;for(c in f)if(f.hasOwnProperty(c)){var d=f[c];"EXTERNAL"===a&&null!==d.externalVerification&&0<d.count&&(b[c]=d);"MEMBERSHIP"===a&&d.isMemberCategory&&0<d.count&&(b[c]=d)}return b},V=function(){var a=S("EXTERNAL");jQuery.isEmptyObject(a)?$("#add-to-cart").text(SeatList._LABEL_BUTTON_ADDTOCART):$("#add-to-cart").text(SeatList._LABEL_BUTTON_PROCEED)},N=function(a,b,c){var d=$(document.createElement("input"));
d.prop("type","hidden").attr("name","eventFormData["+a+"]."+b).val(c);$("#EventFormModel").append(d)},I=function(a,b,c,d,e,f){if(C){a=d.prices[b];a=$(".quantity[data-seat-category-id='"+d.seatCategoryId+"']").has("input[id$='audienceSubCategory'][value='"+a.audienceSubCategoryId+"']");f=a.find("input[id$='quantity']");b="seasonTicketData["+a.attr("data-obj-counter")+"].";var g=parseInt(f.val(),10)||0;f.val(g+c);e?a.append($("<input>",{type:"hidden",name:b+"areaId",value:d.areaId})):a.append($("<input>",
{type:"hidden",name:b+"physicalSeatsIds",value:d.seatId}))}else{b=d.prices[b];g=b.advantageId;var h=b.priceLevelId,k=d.seatCategoryId;N(a,"audienceSubCategory",b.audienceSubCategoryId);N(a,"seatCategory",k);N(a,"contingentId",d.contingentId);N(a,"quantity",c);e?N(a,"areaId",d.seatId):(f&&N(a,"physicalSeatId",d.seatId),N(a,"areaId",d.areaId),N(a,"blockId",d.blockId));g&&N(a,"advantageId",g);h&&N(a,"priceLevelId",h)}},O=function(a,b){var c=$('<input type="hidden"></input>');c.attr("id",a).attr("name",
a);c.val(b);return c},R=function(a,b){var c=0,d=[];$(".nnseat-rate-select").each(function(a,b){d.push($(b).val())});jQuery.each(a||[],function(a,e){if(void 0===b||b===Number(e.priceIdx)||0>d.indexOf(e.priceIdx))c+=e.quantity});return c},X=function(a,b){var c=0;jQuery.each(b||[],function(b,d){c+=v?a[d.priceIdx].amountWithCharge:a[d.priceIdx].amount*d.quantity});return c},T=function(a){var b="";a.data.area&&null!==a.data.area&&(b=a.data.area);a.data.block&&null!==a.data.block&&(b+=(b.length?" - ":"")+
SeatDetails.getSeatBlockLabel(a.data.areaId)+" "+a.data.block);return b},Z=function(a,b,c){var d="";a.data.row&&null!==a.data.row&&(d+=(b?" - ":" ")+(c?"<strong>":"")+SeatDetails.getSeatRankLabel(a.data.block,a.data.areaId)+" "+a.data.row+(c?"</strong>":""));return d},ba=function(a,b){var c="";a.data.number&&null!==a.data.number&&(c+=(b?" - ":" ")+"<strong>"+SeatDetails.getSeatNumberLabel(a.data.areaId)+" "+a.data.number+"</strong>");return c},U=function(a){return T(a)+Z(a,!0,!1)+ba(a,!0)},P=function(a,
b,c){if(c){var d=functions.generateAmount(v?c.amountWithCharge:c.amount);var e=U(a);var f=c.audienceSubCategory;var g=c.advantageId?"<div class='advantage advantage_"+c.advantageType+"'><div class='advantage_catchword_container'><span class='catchword'></span></div></div>":"";var h=c.externalVerification||c.isMemberCategory?'<div class="pre-cart-price-ext-ver"><span class="external_membership_icon"></span></div>':"";c=c.conditionalRateData&&c.conditionalRateData.rateInfo?'<div class="pre-cart-price-conditional-rate"><span class="conditional_rate_indicator_icon"></span></div>':
""}else isNaN(a.data.number)&&a.priceQty?(c=parseInt(a.priceQty[0].priceIdx,10),d=functions.generateAmount(X(a.data.prices,a.priceQty)),e=a.data.area,f=R(a.priceQty),f=1<f?f+" "+SeatList._LABEL_NNAREA_SEAT_COUNT_N:f+" "+SeatList._LABEL_NNAREA_SEAT_COUNT_1,g=a.data.prices[c].advantageId?"<div class='advantage advantage_"+a.data.prices[c].advantageType+"'><div class='advantage_catchword_container'><span class='catchword'></span></div></div>":"",h=a.data.prices[c].externalVerification||a.data.prices[c].isMemberCategory?
'<div class="pre-cart-price-ext-ver"><span class="external_membership_icon"></span></div>':"",c=a.data.prices[c].conditionalRateData&&a.data.prices[c].conditionalRateData.rateInfo?'<div class="pre-cart-price-conditional-rate"><span class="conditional_rate_indicator_icon"></span></div>':""):(d="",e=U(a),f=a.audienceSubCatName?a.audienceSubCatName:$("#pre-cart #details-list li:visible .pre-cart-additional-info-wrapper .pre-cart-cat-2").html(),c=h=g="");a=['<div class="seat-details-item-wrapper">',isNewTicketShop?
'<div class="pre-cart-cat" style="background-color: #'+a.data.color+'1A">':'<div class="pre-cart-cat">','<div class="category-color" style="background-color: #'+a.data.color+'"></div>',isNewTicketShop?'<div class="category-name" style="color: #'+a.data.color+'">'+a.data.seatCategory+"</div></div>":a.data.seatCategory+"</div>",'<div class="pre-cart-desc">'+e+"</div>",'<div class="pre-cart-additional-info-wrapper">','<div class="pre-cart-cat-2">'+f+"</div>",'<div class="pre-cart-adv-sub-wrapper">',
!SeatList.isExclusiveAvailable()||a.exclusive?g:"",h,c,'<div class="pre-cart-price">'+d+"</div>","</div>",'<div class="remove_button_wrapper">','<span class="alternative_button remove"><a title="'+SeatList._LABEL_REMOVE_BUTTON+'" href="" id="id--'+b+'"><span class="icon"></span><span class="symbol"></span><span class="text"></span></a></span>',"</div>","</div>",'<div class="clear"></div>',"</div>"];$("#pre-cart li#pre-cart-line--"+b).html(a.join(""))},Y=function(a){a.addClass("clickable");a.removeClass("disabled")},
da=function(a){a.addClass("disabled");a.removeClass("clickable")},aa=function(){$("#left-arrow, #right-arrow").addClass("display-inline")},W=function(){$("#left-arrow, #right-arrow").removeClass("display-inline")},J=function(){return $("#content").width()>=t?$(".main_content.seat_selection").hasClass("fullscreen")?x:y:z},la=function(a){$("#pre-cart #details-list li").hide();$("#pre-cart #details-list").append('<li id="pre-cart-line--'+a+'"></li>');$("#pre-cart #ticket-icon-list ul li").removeClass("selected-ticket");
$("#pre-cart #ticket-icon-list ul").append('<li id="tid--'+a+'" class="selected-ticket"><span class="icon selected_ticket_icon"></span><br/><span class="icon ticket_icon"></span></li>')},ja=function(a){var b=SeatList.getFirstVisibleSeatPos(),c=$("#ticket-icon-list ul"),d=$("li",c).length,e=a?$("#left-arrow"):$("#right-arrow"),f=a?$("#right-arrow"):$("#left-arrow");var g=$("li:first-child",c).width();var h=a?g:-g;var k=J();b=a?d-(b+k):b;0<b&&SeatList.slideSeatList(b,a);d>k?(aa(),Y(e),da(f)):(W(),$("#ticket-icon-list").css("width",
g*d));c.css("width",c.width()+h)},ea=function(){var a="",b=SeatList.getFailingMinimum();var c=$("#add-to-cart").parent();SeatList.canBook()&&SeatList.getNbSelectedSeats()?c.removeClass("disabled"):(c.addClass("disabled"),b&&(c=b.audienceSubCategory,b.advantageName&&(c+=" "+b.advantageName),null!==b.maxQuantity&&b.count>b.maxQuantity?(a=SeatDetails._LABEL_CANT_BOOK_NOTIFICATION_MAX_LIMIT,a=a.replace("{0}",b.maxQuantity)):(a=SeatDetails._LABEL_CANT_BOOK_NOTIFICATION_MIN_LIMIT,a=a.replace("{0}",b.minQuantity)),
a=a.replace("{1}",b.seatCategory),a=a.replace("{2}",c)));$("#cant_book_notification").html(a)},ha=function(b,c){var d=b.data.seatId,e=parseInt(d,10),f=null,g=null,h=b.data.number?!1:!0;var k=b.priceIdx;h?v?(g=b.data.prices[k],f=b.data.prices[k].amountWithCharge):(f=b.priceQty,f=X(b.data.prices,f)):b.data.prices&&(g=b.data.prices[k])&&(f=v?g.amountWithCharge:g.amount);c?($("#pre-cart #num-tickets").html(SeatList._LABEL_YOUR_SELECTION+" ("+SeatList.getNbSelectedSeats()+")"),k=v?b.data.prices[c.priceIdx].amountWithCharge:
h?X(b.data.prices,c.priceQty):b.data.prices[c.priceIdx].amount,q-=k,q+=f):(f&&(q+=f),$("#pre-cart #num-tickets").html(SeatList._LABEL_YOUR_SELECTION+" ("+SeatList.getNbSelectedSeats()+")"),la(d),ja(!0));null!==g?P(b,d,g):P(b,d);$("#pre-cart #total").html(SeatList._LABEL_TOTAL+" "+functions.generateAmount(q));$("#pre-cart #total").show();ea();c||(a?(h?SeatMap.redrawArea(e,"addedToCart"):SeatMap.redrawSeat(e,"addedToCart",!0),SeatMap.selectSeat(d,h)):seatmap.SeatMapSvg.selectSeat(d,h,b.data.areaId))},
ca=function(a){var b=$("#pre-cart #details-list li").first().find("a").attr("id").replace("id--","");SeatList.selectSeat(SeatList.getSeat(b),a)},ma=function(a){var b=$("#pre-cart #details-list li");if(b){b=b.last().find("a").attr("id").replace("id--","");var c=SeatList.getSeat(b);SeatList.isExclusiveChangedForSeat(c)&&a&&SeatList.toggleExclusive();SeatList.selectSeat(SeatList.getSeat(b),!0)}},oa=function(a){var b,c="",d="",e="",f=b=!0,g="",h="",k;for(k in a)if(a.hasOwnProperty(k)){var l=T(a[k]);var m=
Z(a[k],!1,!1);b&&g.length&&(b=l===g);f&&h.length&&(f=m===h);g=l;h=m}if(b&&f)for(c in a)d.length||(d=T(a[c])+Z(a[c],!0,!1)+" -"),e+=(e.length?", ":"")+ba(a[c],!1);else if(b)for(c in a)d.length||(d=T(a[c])+" -"),e+=(e.length?", ":"")+Z(a[c],!1,!0)+ba(a[c],!0);else for(c in a)a.hasOwnProperty(c)&&(e+=(e.length?", ":"")+U(a[c]));return d+e},na=function(a,b){var c="",d=null,e=null,f=0;b=b?SeatList.getNewProposalSeats():SeatList.getSelectedSeats();var g=function(b,c){I(f,parseInt(c.priceIdx,10),c.quantity,
e,!0,a);f++};C&&($(".quantity").find("[name^='seasonTicketData'][name$='\\.quantity']").val(0),$(".quantity").find("[name^='seasonTicketData'][name$='\\.physicalSeatsIds']").remove());for(c in b)b.hasOwnProperty(c)&&(d=b[c])&&(e=d.data,d.priceQty?jQuery.each(d.priceQty,g):(I(f,d.priceIdx,1,e,!1,a),f++))},pa=function(a){var b=SeatList.getSelectedSeats(),d=Object.keys(b),e=[],f=[],g,h;for(g in b)if(b.hasOwnProperty(g)){var k=b[g];for(h=0;h<=a.length-1;h++){var l=a[h];if(k.data.seatCategoryId===l.seatCategory&&
l.hasOwnProperty("physicalSeatId")&&l.hasOwnProperty("seatCategory")&&0>f.indexOf(l.physicalSeatId)){f.push(a[h].physicalSeatId);e.push(a[h]);break}}}c={};$.each(e,function(a,e){var f={};d[a]&&(a=b[d[a]],null!==a&&e.hasOwnProperty("physicalSeatId")&&e.hasOwnProperty("seatCategory")&&e.hasOwnProperty("contingentId")&&e.hasOwnProperty("areaId")&&e.hasOwnProperty("area")&&(f.seatId=e.physicalSeatId,f.seatCategoryId=e.seatCategory,f.contingentId=e.contingentId,f.areaId=e.areaId,f.area=e.area,e.hasOwnProperty("block")&&
e.hasOwnProperty("blockId")&&(f.block=e.block,f.blockId=e.blockId),e.hasOwnProperty("row")&&(f.row=e.row),e.hasOwnProperty("number")&&(f.number=e.number),a.hasOwnProperty("priceIdx")&&a.data.hasOwnProperty("prices")&&(f.prices=a.data.prices,c[e.physicalSeatId]={},c[e.physicalSeatId].data=f,c[e.physicalSeatId].priceIdx=a.priceIdx)))})},qa=function(){SeatMap.seatsLayer.events.on({featureadded:function(a){a=a.feature.data.id;r&&r.data.seatId===a&&(SeatList.selectSeat(r),r=null)}})},ra=function(){var a=
A?ChangeSeat.getSeatsToBeChanged():SeatSessionStorage.getSelectedSeats(k),b,c=[];if(null!==a&&0<a.length){for(b in a)if(a[b].numbered){var d=a[b].seatData.data.seatId;c.push(d)}0<c.length&&!A?(tools.dialog.showWaitingPopup("checkHolesAndAvailabilityDialog",!0),$.ajax({url:contextPath+"/ajax/seatMap/checkHolesAndAvailability",type:"GET",cache:!1,data:{productId:h,performanceId:l,selectedSeatsIds:c,advantageId:p,ppid:E,reservationIdx:F,crossSellId:B},error:function(a){SeatSessionStorage.clearEvent(k);
tools.dialog.hideDialog("checkHolesAndAvailabilityDialog")},success:function(b){b.error&&b.socialDistancingError?(tools.dialog.hideDialog("checkHolesAndAvailabilityDialog"),tools.dialog.showDialog("cannotAttributeSeatBecauseOfDistancing",!0)):b.error?(SeatSessionStorage.clearEvent(k),tools.dialog.hideDialog("checkHolesAndAvailabilityDialog")):b.requestHadAvailabilityProb||0<$("#cannotAttributeSeatsBecauseOfLockingError").length&&$("#cannotAttributeSeatsBecauseOfLockingError").is(":hidden")?(SeatSessionStorage.clearEvent(k),
$("#impossible_selection_avail_message").fadeIn()):SeatList.restoreSelectedSeats(a);tools.dialog.hideDialog("checkHolesAndAvailabilityDialog")}})):SeatList.restoreSelectedSeats(a)}};return{isUpdatingSeat:!1,isResaleMode:function(){return v},isChangeSeatMode:function(){return A},completeAndSubmitResaleForm:function(){var a,b=0,c=K();var d=SeatList.getSelectedSeats();var e="",f={},g={},h=!0;var k=SeatList.getSelectedSeats();for(m in k)if(k[m]&&k[m].data.resaleInfo&&k[m].data.resaleInfo.withCompanion){var l=
k[m].data.resaleInfo.ticketResaleId;f[l]=k[m].data.resaleInfo;null!=k[m].data.resaleInfo.companionTicketResaleId&&(g[k[m].data.resaleInfo.companionTicketResaleId]=l)}if(f){for(l in f){var m=f[l];if(null!=m.companionTicketResaleId){if(!f[m.companionTicketResaleId])if(h){var p=SeatList._LABEL_ACCESIBLE_ALONE;e=m.companionInfo;h=!1}else p=SeatList._LABEL_COMPANION_MULTIPLE,e=e+", "+m.companionInfo}else g[l]||(h?(p=SeatList._LABEL_COMPANION_ALONE,e=m.companionInfo,h=!1):(p=SeatList._LABEL_COMPANION_MULTIPLE,
e=e+", "+m.companionInfo))}h||($("#aloneCompanionTickets_popup_message").text(p+" ("+e+")"),tools.dialog.showDialog("aloneCompanionTickets",!0))}if(h){for(a in d)if(d[a]){p=d[a];l=c;f=b;g=p.data;m=g.prices[p.priceIdx];e=g.resaleInfo;if(u){h=m.audienceSubCategoryId;var q=m.amount}else h=e.audienceSubCategoryId,q=g.prices[0].amount;k=O("resaleItemData["+f+"].audienceSubCategoryId",h);m=O("resaleItemData["+f+"].seatCategoryId",g.seatCategoryId);h=O("resaleItemData["+f+"].quantity",1);var r=O("resaleItemData["+
f+"].unitAmount",q);q=O("resaleItemData["+f+"].key",e.resaleKey);g=O("resaleItemData["+f+"].priceLevelId",g.prices[p.priceIdx].priceLevelId);l.append(k);l.append(m);l.append(h);l.append(r);l.append(q);l.append(g);l.append(O("resaleItemData["+f+"].movementIds[0]",e.resaleMovId));b++}c.submit()}},handleHolesAndAvailability:function(){var a=SeatList.getSortedSelectedSeats(),b=[],c=!1;if(l&&a)if($.each(a,function(a,d){d.priceQty?c=!0:b.push(a)}),b.length&&!C)tools.dialog.showWaitingPopup("checkHolesAndAvailabilityDialog",
!0),$.ajax({url:contextPath+"/ajax/seatMap/checkHolesAndAvailability",type:"GET",cache:!1,data:{productId:h,performanceId:l,selectedSeatsIds:b,advantageId:p,ppid:E,reservationIdx:F,crossSellId:B},error:function(a){tools.dialog.hideDialog("checkHolesAndAvailabilityDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)},success:function(b){if(b.error&&b.socialDistancingError)tools.dialog.hideDialog("checkHolesAndAvailabilityDialog"),tools.dialog.showDialog("cannotAttributeSeatBecauseOfDistancing",!0);
else if(b.error&&b.impossible)tools.dialog.hideDialog("checkHolesAndAvailabilityDialog"),tools.dialog.showDialog("seatAttributionError",!0);else if(b.error)tools.dialog.hideDialog("checkHolesAndAvailabilityDialog"),tools.dialog.showDialog("ajaxErrorDialog",!0);else if(b.impossible||b.newProposal&&(!b.hasOwnProperty("physicalSeats")||b.physicalSeats.length!==SeatList.getNbSelectedSeats()))tools.dialog.hideDialog("checkHolesAndAvailabilityDialog"),b.requestHadAvailabilityProb?tools.dialog.showDialog("impossible_selection_holes_popup",
!0,!0):b.requestHadHoles?tools.dialog.showDialog("impossible_selection_noAvailability_popup",!0,!0):b.requestHadSocialDistancingProb?tools.dialog.showDialog("impossible_selection_socialdistancing_popup",!0,!0):tools.dialog.showDialog("impossible_selection_default_popup",!0,!0);else if(b.newProposal){tools.dialog.hideDialog("checkHolesAndAvailabilityDialog");var c=b.requestHadAvailabilityProb?SeatList._LABEL_EXPLANATION_NOT_AVAILABLE:SeatList._LABEL_EXPLANATION_HOLE;$("#new_selection_popup_explanation").html(c);
4<b.physicalSeats.length?$("#new_selection_popup_previous").hide():($("#new_selection_popup_previous").show(),$("#new_selection_popup_previous .new_selection_popup_values_seats").html(oa(a)));pa(b.physicalSeats);Object.keys(SeatList.getNewProposalSeats()).length!==SeatList.getNbSelectedSeats()?tools.dialog.showDialog("impossible_selection_default_popup",!0,!0):($("#new_selection_popup_new .new_selection_popup_values_seats").html(oa(SeatList.getNewProposalSeats())),tools.dialog.showDialog("new_selection_popup",
!0,!0))}else na(!0,!1),K().submit()}});else if(b.length||c)na(!0,!1),K().submit()},getSeat:function(a){a=b[a];return!0===a?null:a},isSeatSelected:function(a){return b[a]},slideSeatList:function(a,b){a*=$("#ticket-icon-list ul li:first-child").width();b=b?a:-a;$("#ticket-icon-list").animate({scrollLeft:"+="+b},600)},slideInScreen:function(a){var b=$("#ticket-icon-list ul li:first-child").width(),c=$("#ticket-icon-list"),e=c.prop("scrollLeft"),f=c.width(),g=a*b;e=g-e;var h=null;0>e&&(h=g);e>=f&&(h=
g-f+b);null!==h&&(c.stop().animate({scrollLeft:h},600),a?Y($("#left-arrow")):da($("#left-arrow")),a==d-1?da($("#right-arrow")):Y($("#right-arrow")))},deleteSeat:function(c,e){if(c){var f=c.data.number?!1:!0;SeatSessionStorage.removeStoredSeat(k,c);if(c){var g=c.data.seatId;f?v?d--:(M(c),d-=R(c.priceQty)):(f=H(c),f.count--,d--);L();if(!e){V();e=c.data.seatId;f=parseInt(e,10);var h=!c.data.number;if(v){var l=u?c.data.prices[c.priceIdx].amount:c.data.resaleInfo.amount;h&&$("#nn-resale-seat-select").children("option[value^="+
e+"]").show()}else l=h?X(c.data.prices,c.priceQty):c.data.prices[c.priceIdx].amount;$("#pre-cart #details-list #pre-cart-line--"+e).remove();$("#pre-cart #ticket-icon-list #tid--"+e).remove();ja(!1);q-=l;$("#pre-cart #total").html(SeatList._LABEL_TOTAL+" "+functions.generateAmount(q));$("#pre-cart #num-tickets").html(SeatList._LABEL_YOUR_SELECTION+" ("+SeatList.getNbSelectedSeats()+")");a||seatmap.SeatMapSvg.removeSeatSelection(e,h,c.data.areaId);SeatList.getNbSelectedSeats()?(ma(!0),$("#delete-seat").parent().removeClass("disabled")):
(v?$("#seat-details .seat-info-placeholder").show():h&&($("#seat-details .seat-info-placeholder").hide(),$("#seat-details .seat-info-content").show()),$("#total_button_container #total").hide(),a&&SeatMap.unselectAllSeats());ea();a&&(h?SeatMap.redrawArea(e,"default"):SeatMap.redrawSeat(f,"default",!0));c.data.isBookAvailable=!0;SeatDetails.updateSeatInformation(c.data,!0)}delete b[g];r=null}}},addSeat:function(a,c){var e=a.data.seatId,f=H(a),g=this.getSeat(e);g?H(g).count--:d++;b[e]=a;f.count++;L();
c||(V(),ha(a,g))},addOrUpdateSeatInCartToList:function(a,c,e){this.getSeat(c)||d++;b[c]=a;SeatList.updateSeatListWidget(c,a,e)},selectNextSeat:function(){var a=$("#pre-cart #icons-and-arrows li.selected-ticket"),b=$("#pre-cart #icons-and-arrows li");a=$(a).next("li");1<=$(b).length&&(0<$(a).length?(b=$(a).attr("id").replace("tid--",""),SeatList.selectSeat(SeatList.getSeat(b),!1)):ca(!1))},addNonNumberedResaleSeat:function(a){var c=a.data.resaleInfo.resaleMovId,e=this.getSeat(c);e||d++;b[c]=a;L();
V();ha(a,e);u&&(a=$("#nn-resale-seat-select"),c=a.children("option[value^="+c+"]"),c.prop("selected",!1),c.hide(),c=a.children().not('[style*="display: none"]').not(":disabled").first(),0===c.length?(a[0].selectedIndex=-1,$("#add-selected-seat-to-cart").parent().addClass("disabled")):(a.val(c.val()).change(),$("#add-selected-seat-to-cart").parent().removeClass("disabled")))},addNonNumberedSeat:function(a){var c=a.data.seatId,e=this.getSeat(c);if(e){if(0===a.priceQty.length){SeatList.deleteSeat(e);
return}Q(a,e);d-=R(e.priceQty)}else Q(a);d+=R(a.priceQty);b[c]=a;L();V();ha(a,e)},preselectSeat:function(a){b[a]||(b[a]=!0,L(),ea())},cancelPreselectSeat:function(a){!0===b[a]&&(delete b[a],L(),ea())},selectSeat:function(b,c,d){var e=b.data.seatId,f=$("#pre-cart #ticket-icon-list #tid--"+e).index(),g=f+1,h=b.data.seatCentroid,k=b.data.number?!1:!0;$("#pre-cart #details-list li").hide();$("#pre-cart #details-list li:nth-child("+g+")").show();$("#pre-cart #ticket-icon-list ul li").removeClass("selected-ticket");
$("#pre-cart #ticket-icon-list ul li:nth-child("+g+")").addClass("selected-ticket");SeatList.slideInScreen(f);a?(SeatMap.selectSeat(e,k,d),c&&(SeatList.isCheckExclusiveFromSelectedSeat=!0,r=b,h&&SeatMap.panToSeat(h.x,h.y),b.data.number||SeatMap.map.zoomTo(1),SeatDetails.preventCategoryDisplay())):c&&seatmap.SeatMapSvg.selectSeat(e,k,b.data.areaId)},getNewProposalSeats:function(){return c},getSelectedSeats:function(){return b},getNbSelectedSeats:function(){return d},getSortedSelectedSeats:function(){return SeatList.sortSelectedSeats(b)},
sortSelectedSeats:function(a){var b=[];SeatList.getNbSelectedSeats()&&($.each(a,function(a,c){b.push([a,c])}),b.sort(function(a,b){return a[1].data.area===b[1].data.area?a[1].data.block===b[1].data.block?a[1].data.row===b[1].data.row?a[1].data.number.localeCompare(b[1].data.number,void 0,{numeric:!0}):a[1].data.row.localeCompare(b[1].data.row,void 0,{numeric:!0}):a[1].data.block.localeCompare(b[1].data.block,void 0,{numeric:!0}):a[1].data.area.localeCompare(b[1].data.area,void 0,{numeric:!0})}),a=
{},b.forEach(function(b){a[b[0]]=b[1]}));return a},getFirstVisibleSeatPos:function(){var a=$("#ticket-icon-list"),b=$("#ticket-icon-list ul li"),c=0,d=null;jQuery.each(b,function(b,e){d=$(e);if(d.offset().left>=a.offset().left)return c=b,!1});return c},checkAddPrice:function(a,b,c){var e=this.getSeat(a.data.seatId);var f=0;e&&(f=R(e.priceQty,b));if(w&&c+d-f>w)return"OVER_GLOBAL_MAX";a=H(a,b);return null===a.maxQuantity||a.count+c-f<=a.maxQuantity?!0:"OVER_PRICE_MAX"},checkRequiredAudSubCat:function(){var a=
{},b,c=SeatList.getSelectedSeats(),d={},e="",g=$("#conditional_rate_error_message");for(b in f)if(f.hasOwnProperty(b)){var h=f[b];var k=h.seatCategoryId+"_"+h.audienceSubCategoryId;a[k]=a[k]?a[k]+h.count:h.count}for(b in c)if(c.hasOwnProperty(b)){var l=c[b];if(l.priceQty)jQuery.each(l.priceQty,function(b,c){m=l.data.prices[parseInt(c.priceIdx,10)];p=l.data.seatCategoryId;d=SeatList.buildConditionalRateWarningMessage(m,p,a,d)});else{var m=l.data.prices[l.priceIdx];var p=l.data.seatCategoryId;d=SeatList.buildConditionalRateWarningMessage(m,
p,a,d)}}for(b in d)d.hasOwnProperty(b)&&(e+=d[b]+"</br>");g.find(".error_message").html();if(""!==e)return g.find(".error_message").html(e),g.fadeIn(),tools.scrollToElement(g,200),!1;g.fadeOut();return!0},buildConditionalRateWarningMessage:function(a,b,c,d){var e=0,f;if(a.conditionalRateData){var g=a.conditionalRateData;for(f in g.requiredAudienceSubCatIds)if(g.requiredAudienceSubCatIds.hasOwnProperty(f)){var h=b+"_"+g.requiredAudienceSubCatIds[f];e+=c[h]?c[h]:0}h=b+"_"+a.audienceSubCategoryId;e<
g.triggerQuantity&&!d[h]&&(d[h]=g.mappedRateWarning[SecuTixConfig.currentLang])}return d},canBook:function(){return e},canAdd:function(){var a=w&&d>=w?!1:!0;return a},getFailingMinimum:function(){return g},getSeatDescriptionFromData:function(a){return U({data:a})+" "+SeatList._LABEL_NOT_CONTRACTUAL_VIEW},handleValidation:function(a,b){var c=!1,d=b?$("#emptyMemberCardMobile"):$("#emptyMemberCard"),e=b?$("#membership_verification_mobile_block"):$("#membership_verification_block"),f=membershipVerificationCommon.getVerificationContainer(b).find(".button.addWithValidation");
a.preventDefault();f.hasClass("disabled")||(e.find("input").each(function(){0===$(this).val().length?(c=!0,$(this).parent().addClass("error")):$(this).parent().removeClass("error")}),c?d.removeClass("hidden"):audSubCatVerification.validateAllQuantities($(a.target),!0,function(a){a&&(membershipVerificationCommon.hideVerificationDialog(b),SeatList.handleHolesAndAvailability())}))},restoreSelectedSeats:function(b){for(d in b)if(b[d].numbered)if(A){var c=b[d].seatData.data.seatId;SeatList.addOrUpdateSeatInCartToList(b[d].seatData,
c,!1)}else SeatList.addSeat(b[d].seatData);else v?SeatList.addNonNumberedResaleSeat(b[d].seatData):A||SeatList.addNonNumberedSeat(b[d].seatData);if(A)ca(!0);else{this.waitSeatMapInitialized();b=$("#pre-cart #details-list li").last().find("a").attr("id").replace("id--","");var d=SeatList.getSeat(b);b=d.data.areaId;d=d.data.blockId;(!a||!SeatMap.isZoomOnAreaOrBlockRequired()||null!==d&&-1<jQuery.inArray(d.toString(),SeatMap.zoomOnBlockIds)||null!==b&&-1<jQuery.inArray(b.toString(),SeatMap.zoomOnAreaIdArray))&&
ma()}},waitSeatMapInitialized:function(){a&&!SeatMap.mapInitialized&&setTimeout(this.waitSeatMapInitialized,100);return!0},setSelectedSeat:function(a,c){b[a]=c},getSelectedSeatId:function(){var a=$("#pre-cart #icons-and-arrows li.selected-ticket"),b=null;0<a.length&&(b=$(a).attr("id").replace("tid--",""));return b},updateSeat:function(c){var e=SeatList.getSelectedSeatId();if(null!==e){$("#pre-cart #details-list li:visible").attr("id","pre-cart-line--"+c);var f=$("#pre-cart #icons-and-arrows li.selected-ticket");
$(f).attr("id","tid--"+c);$(f).find("a").attr("id","id--"+c);if(c=SeatList.getSeat(e))delete b[e],d--,$("#pre-cart #details-list #pre-cart-line--"+e).remove(),$("#pre-cart #ticket-icon-list #tid--"+e).remove(),ja(!1),$("#pre-cart #num-tickets").html(SeatDetails._LABEL_YOUR_SELECTION+" ("+SeatList.getNbSelectedSeats()+")"),SeatList.getNbSelectedSeats()||($("#seat-details .seat-info-content").hide(),$("#seat-details .seat-info-placeholder").show(),$("#total_button_container #total").hide(),a&&SeatMap.unselectAllSeats()),
a?SeatMap.redrawSeat(parseInt(e,10),"default",!0):seatmap.SeatMapSvg.removeSeatSelection(e,c.data.number?!1:!0)}},isInSeatList:function(a){return 0<$("#pre-cart #icons-and-arrows li#tid--"+a).length},updateSeatListWidget:function(b,c,d){$("#pre-cart #num-tickets").html(SeatDetails._LABEL_YOUR_SELECTION+" ("+SeatList.getNbSelectedSeats()+")");d||la(b);ja(!0);P(c,b);a&&SeatMap.redrawSeat(parseInt(b,10),"addedToCart",!0)},isExclusiveAvailable:function(){return"true"===ExclusiveSessionStorage.getExclusiveAvailable()},
isExclusive:function(){return SeatList.isExclusiveAvailable()&&"true"===ExclusiveSessionStorage.getExclusiveSelected()},isExclusiveChangedForSeat:function(a){return SeatList.isExclusiveAvailable()&&a.exclusive!==SeatList.isExclusive()},toggleExclusive:function(b){a?SeatMap.toggleExclusive(b):seatmap.SeatMapSvg.toggleExclusive(b)},init:function(b){var c={};a=b.isOpenLayerSeatMap;h=b.productId;l=b.performanceId;m=b.isMobile;p=b.partnerAdvantageId;A=b.isChangeSeatMode;C=b.isSeasonTicketMode;w=b.maxAllowedSeats;
k=b.seatSessionStorageEvent;u=b.isSeatRelease;v=b.resaleMode;E=b.ppid;F=b.reservationIdx;B=b.crossSellId;G=b.isPurchaseOnBehalfEnabled;if(a)SeatMap.events.on("initSeatsLayerDone",qa);var d=$("#content").width();var e=function(a,b){a=parseInt(a,10);return isNaN(a)?b:a};t=e(b.mainContentWidth,700);y=e(b.maxNumberOfTicketsNonMobile,8);z=e(b.maxNumberOfTicketsMobile,5);D=$("#seat-map-sub-container").parent().outerWidth();x=e(b.maxNumberOfTicketsFullScreen,16);$(window).resize(function(){clearTimeout(c);
c=setTimeout(function(){var a=d,b=$(".main_content.seat_selection").hasClass("fullscreen"),c=$("#seat-map-sub-container").parent().width();b=b?c:$("#content").width();c=J();var e=$("#ticket-icon-list"),f=$("#ticket-icon-list ul"),g=$("li",f).length;f=$("li:first-child",f).width();if((a>=t&&b<t||a>D&&b<=D)&&g>c){aa();var h=J(),k=$("#ticket-icon-list ul li"),l=SeatList.getFirstVisibleSeatPos();0===$(k[l]).prev().length?da($("#left-arrow")):Y($("#left-arrow"));0===$(k[l+h-1]).next()?da($("#right-arrow")):
Y($("#right-arrow"));e.css("width",f*c);$("#ticket-icon-list .selected-ticket").click()}if(a<t&&b>=t||a<=D&&b>D)g<=c?(W(),e.css("width",f*g)):e.css("width",f*c);d=b},100)});$("#impossible_selection_default_popup .button.modify").click(function(){ea();tools.dialog.hideDialog("impossible_selection_default_popup")});$("#impossible_selection_holes_popup .button.modify").click(function(){ea();tools.dialog.hideDialog("impossible_selection_holes_popup")});$("#impossible_selection_holes_popup .button.auto_selection").click(function(){na(!1,
!1);K().submit()});$("#impossible_selection_socialdistancing_popup .button.modify").click(function(){ea();tools.dialog.hideDialog("impossible_selection_socialdistancing_popup")});$("#impossible_selection_socialdistancing_popup .button.auto_selection").click(function(){na(!1,!1);K().submit()});$("#impossible_selection_noAvailability_popup .button.modify").click(function(){window.location.reload()});$("#new_selection_popup .button.modify").click(function(){ea();tools.dialog.hideDialog("new_selection_popup")});
$("#cannotAttributeSeatBecauseOfDistancing .button.modify").click(function(){ea();tools.dialog.hideDialog("cannotAttributeSeatBecauseOfDistancing")});$("#new_selection_popup .button.accept_new").click(function(){tools.dialog.showWaitingPopup("checkHolesAndAvailabilityDialog",!0);na(!0,!0);K().submit()});$("#pre-cart").on("click","#ticket-icon-list ul li",function(){var b=$(this).attr("id").replace("tid--",""),c=SeatList.getSeat(b);$("#delete-seat").parent().removeClass("disabled");a||seatmap.SeatMapSvg.resetDefaultPolygonId();
b=function(){SeatList.selectSeat(c,!0,!0)};SeatList.isExclusiveChangedForSeat(c)?SeatList.toggleExclusive(b):b()}).on("click","#left-arrow, #right-arrow",function(){var a="left-arrow"===this.id?!0:!1,b=$("#ticket-icon-list ul li"),c=a?$("#right-arrow"):$("#left-arrow"),d=$(this),e=J();d.hasClass("clickable")&&(b=a?$(b[SeatList.getFirstVisibleSeatPos()]).prev().prev():$(b[SeatList.getFirstVisibleSeatPos()+e-1]).next().next(),SeatList.slideSeatList(1,!a),Y(c),0===b.length&&da(d))}).on("click","#details-list li .alternative_button a",
function(a){var b=$(this).attr("id");a.preventDefault();SeatList.deleteSeat(SeatList.getSeat(b.replace("id--","")))}).on("click","#add-to-cart",function(a){var b=$(this),c=b.parent();a.preventDefault();c.hasClass("disabled")||!SeatList.isResaleMode()&&!SeatList.checkRequiredAudSubCat()||(c.addClass("disabled"),SeatList.isResaleMode()?SeatList.completeAndSubmitResaleForm():b.text()===SeatList._LABEL_BUTTON_ADDTOCART?SeatList.handleHolesAndAvailability():(a=S("EXTERNAL"),jQuery.isEmptyObject(a)||audSubCatVerification.initVerificationDialog(a,
m)))});$("#exclusive-seats-filter").click(function(a){isNewTicketShop||a.preventDefault();SeatList.toggleExclusive();SeatDetails.getSeatCatFilter()});if(a)SeatMap.events.on("mapLoaded",ra);else seatmap.SeatMapSvg.events.one("onChangedSvgSeatMapOfPolygon",ra);L()}}});
var SeatMap={_LABEL_SEAT_RANK:"",_LABEL_YOUR_SELECTION:"",_LABEL_TOTAL:"",_LABEL_SEAT_BLOCK:"",_LABEL_BUTTON_UPDATE:"",_LABEL_BUTTON_SELECT:"",_LABEL_SEAT_NUMBER:"",ASSIGN_SEATS:"ASSIGN_SEATS",TAKE_BACK_SEATS:"TAKE_BACK_SEATS",MODIFY_GUEST_SEATS:"MODIFY_GUEST_SEATS",_ADV_LABELS:{},TILE_SIZE:512,productId:null,performanceId:null,partnerAdvantageId:null,composedProductId:null,ppid:null,reservationIdx:null,crossSellId:null,resourcesUrl:null,freeSeatsUrl:null,areasUrl:null,mapInitialized:!1,zoomLevels:0,
maxZoomScale:0,resolutions:[],map:null,mapProjection:null,blocks:null,miscProperties:{},seatsCache:null,seatsLayer:null,seatProjection:null,closeUpResolutionIndex:null,blocksLayer:null,freeSeatsStyleMap:null,nnAreas:null,nnAreasLayer:null,selectControl:null,nnAreaStyleMap:null,nnAreasInfo:[],mapLayers:[],switchableViewLayers:[],unSelectedFeatures:[],zoomOnAreaIdArray:[],zoomOnNNAreaIdArray:[],zoomOnBlockIds:[],nnAreaIds:[],numberedAreas:null,areasLayer:null,areaStyleMap:null,isAllowMultipleSelection:!1,
isDistributionSeatMap:!1,isEditGuestsModeEnabled:!1,isChangeSeatMode:!1,operationIds:null,blocksColor:"#0099FF",fallbackBlocksColor:"#0099FF",selectedSeatBorderColor:"#000",distributionSelectedSeatBorderColor:"#000",distributionFilteredSeatColor:"#8d8d8d",tempSelected:null,events:$({}),additionalBlockInfo:{},toBeAdjustedBlockId:null,additionalAreaInfo:{},hiddenBlocks:{},freeSeatsCallInProgress:{},miniMapProperties:{OVERVIEW_SIZE:120,NAVMAP_PATH:"-1/0/0.png"},miniMapFeature:null,freeSeatsStrokeWitdh4Accessibility:3,
filterCriteria:null,hiddenSeats:{},noItemsInFilterLabel:"",blocksBySeatCatId:{},distributionSeatMapInitiated:{},addAccessibilityLayout:function(){$("#pattern-selected-seat")&&$("#pattern-selected-seat #check-background").css("fill",this.selectedSeatBorderColor)},init:function(a){var b=this,c;this.addAccessibilityLayout();var d=(c=seatMapWithAccessibility&&0>=$(".distribution_seat_map_group").length)?"url(#pattern-selected-seat)":"#${color}";OpenLayers.ImgPath=contextPath+"/resources/themes/base/images/visualizer/"+
a.openLayerImagesFolder+"/";var f=util.color.hexColor($("#block_color").css("background-color"));this.blocksColor="transparent"===f?this.fallbackBlocksColor:f;var e={radius:function(a){return Math.max(Math.floor(15/b.map.getResolution()),1)}};var g=[new OpenLayers.Rule({}),new OpenLayers.Rule({filter:new OpenLayers.Filter.Comparison({type:OpenLayers.Filter.Comparison.EQUAL_TO,property:"isComplimentary",value:!0}),symbolizer:{graphicName:"square"}}),new OpenLayers.Rule({filter:new OpenLayers.Filter.Comparison({type:OpenLayers.Filter.Comparison.EQUAL_TO,
property:"unselectable",value:!0}),symbolizer:{fillOpacity:0,strokeColor:"#${color}",strokeWidth:2}}),new OpenLayers.Rule({filter:new OpenLayers.Filter.Comparison({type:OpenLayers.Filter.Comparison.EQUAL_TO,property:"filtered",value:!0}),symbolizer:{fillColor:this.distributionFilteredSeatColor}}),new OpenLayers.Rule({filter:new OpenLayers.Filter.Logical({type:OpenLayers.Filter.Logical.AND,filters:[new OpenLayers.Filter.Comparison({type:OpenLayers.Filter.Comparison.EQUAL_TO,property:"filtered",value:!0}),
new OpenLayers.Filter.Comparison({type:OpenLayers.Filter.Comparison.EQUAL_TO,property:"unselectable",value:!0})]}),symbolizer:{strokeColor:this.distributionFilteredSeatColor}})];var h=[new OpenLayers.Rule({}),new OpenLayers.Rule({minScaleDenominator:50,maxScaleDenominator:105,symbolizer:{strokeWidth:2}}),new OpenLayers.Rule({minScaleDenominator:105,maxScaleDenominator:410,symbolizer:{strokeWidth:1}})];f=new OpenLayers.Style({fillColor:"#${color}",strokeColor:c?this.selectedSeatBorderColor:"",rotation:"${rotation}",
pointRadius:"${radius}",cursor:"pointer",strokeWidth:c?this.freeSeatsStrokeWitdh4Accessibility:0},{rules:g,context:e});var l=new OpenLayers.Style({fillColor:d,strokeColor:this.selectedSeatBorderColor,rotation:"${rotation}",pointRadius:"${radius}",strokeWidth:c?3:4},{rules:h,context:e});c=new OpenLayers.Style({fillColor:c?d:this.selectedSeatBorderColor,strokeColor:"#${color}",rotation:"${rotation}",pointRadius:"${radius}",strokeWidth:seatMapWithAccessibility?3:4},{rules:h,context:e});g=new OpenLayers.Style({fillColor:"#${color}",
strokeColor:this.distributionSelectedSeatBorderColor,rotation:"${rotation}",pointRadius:"${radius}",strokeWidth:2},{rules:g,context:e});this.freeSeatsStyleMap=new OpenLayers.StyleMap({"default":f,select:a.isDistributionSeatMap?g:l,addedToCart:c});g=new OpenLayers.Style({fillColor:"#${nnAreaColor}",fillOpacity:.8,strokeWidth:0,cursor:"pointer"});l=new OpenLayers.Style({fillColor:"#${nnAreaColor}",strokeColor:this.selectedSeatBorderColor,strokeWidth:2,fillOpacity:.8,cursor:"pointer"});f=new OpenLayers.Style({fillColor:"#${nnAreaColor}",
strokeColor:"${nnAreaInCartColor}",strokeWidth:2,fillOpacity:.8,cursor:"pointer"});this.nnAreaStyleMap=new OpenLayers.StyleMap({"default":g,select:l,addedToCart:f});this.areaStyleMap=new OpenLayers.StyleMap(new OpenLayers.Style({fillColor:"none",strokeColor:"none"}));this.zoomInValue=a.zoomInValue;this.resourcesUrl=a.resourcesUrl;this.freeSeatsUrl=a.freeSeatsUrl;this.container=a.container;this.productId=a.productId;this.performanceId=a.performanceId;this.partnerAdvantageId=a.partnerAdvantageId;this.ppid=
a.ppid;this.reservationIdx=a.reservationIdx;this.crossSellId=a.crossSellId;this.areasUrl=a.areasUrl;this.composedProductId=a.composedProductId;null!==a.blockInfo&&(this.additionalBlockInfo=a.blockInfo);null!==a.areaInfo&&(this.additionalAreaInfo=a.areaInfo);this.isAllowMultipleSelection=a.isAllowMultipleSelection;this.isDistributionSeatMap=a.isDistributionSeatMap;this.isEditGuestsModeEnabled=a.isEditGuestsModeEnabled;this.isChangeSeatMode=a.isChangeSeatMode;this.operationIds=a.operationIds;this.noItemsInFilterLabel=
a.noItemsInFilterLabel;this.isExclusiveMode()?$("#exclusive-seats-filter").removeClass("inactive"):$("#exclusive-seats-filter").addClass("inactive");this.freeSeatsParams=this.isChangeSeatMode&&this.operationIds?{operationIds:this.operationIds}:{productId:this.productId,performanceId:this.performanceId,advantageId:this.partnerAdvantageId};OpenLayers.Request.GET({url:a.metadataUrl,callback:function(c){200===c.status&&b.parseMetadata(c.responseText)?(b.initMap(),b.initProjections(),b.initBlocksLayer(),
null===b.nnAreas||b.isDistributionSeatMap||b.isChangeSeatMode||b.initNonNumberAreaLayer(),null===b.numberedAreas||b.isDistributionSeatMap||b.isChangeSeatMode||b.initNumberAreaLayer(),localStorage.setItem("isZoomOnSeat","false"),b.initSeatsLayer(),b.initZoomControls(),b.initSelectControl(),b.initMiniMap(),b.initFullScreenControl(),b.isDistributionSeatMap&&(b.triggerInitialLayerLoad(),b.initDistributionFilterHandler()),b.zoomOnBlockIds=b.getZoomOnBlocksAreas(a.zoomOnBlockIds),b.initZoomOnAreaIds(b.getZoomOnBlocksAreas(a.zoomOnAreaIds)),
0<b.zoomOnAreaIdArray.length&&null!==b.numberedAreas?b.zoomOnAreaIdArray=b.zoomMap(b.zoomOnAreaIdArray,"AREA"):0<b.zoomOnBlockIds.length&&null!==b.blocks&&b.zoomMap(b.zoomOnBlockIds,"BLOCK"),null===b.nnAreas&&b.events.trigger("mapLoaded"),b.mapInitialized=!0):(tools.dialog.showDialog("ajaxErrorDialogContinueShopping",!0,!0),tools.logFeatureIssue("SEATMAP","Unable load meta file: "+a.metadataUrl+" in page "+window.location.href))}});$(document).ready(function(){var a=$("html");a.css("background-attachment",
"scroll");$("#seat-map.seat-map-2D").hover(function(){var b=document.documentElement.scrollTop;a.addClass("no_scroll");0!==b&&(a.css("top",-b),a.css("background-position-y",-b))},function(){var b=parseInt(a.css("top"));a.removeClass("no_scroll");a.css("top",0);a.css("background-position-y",0);window.scrollTo({top:-b})})})},isZoomOnAreaOrBlockRequired:function(){if(this.mapInitialized)return 0<this.zoomOnAreaIdArray.length&&null!==this.numberedAreas||0<this.zoomOnBlockIds.length&&null!==this.blocks},
initZoomOnAreaIds:function(a){var b;for(b in a)if(a.hasOwnProperty(b)){var c=a[b];-1<jQuery.inArray(c,this.nnAreaIds)?this.zoomOnNNAreaIdArray.push(c):this.zoomOnAreaIdArray.push(c)}},getZoomOnBlocksAreas:function(a){var b=[];"null"!==a&&(b=a.split("_"));return b},zoomMap:function(a,b){1===a.length?this.zoomToBlockOrArea(a[0],b):1<a.length&&this.zoomToBlocksOrAreas(a,b);return[]},initSelectControl:function(){this.selectControl=new OpenLayers.Control.SelectFeature(this.mapLayers,{multiple:this.isAllowMultipleSelection,
hover:!1,toggle:!0,clickout:!this.isAllowMultipleSelection});this.map.addControl(this.selectControl);this.selectControl.activate()},updateDataList:function(a,b,c){a=a.split(".");var d=a[1];c||(c={});c[d]||(c[d]={});c[d].linearRings||(c[d].linearRings=[]);!isNaN(a[2])&&-1<$.inArray(a[3],["x","y"])&&(c[d].linearRings[a[2]]||(c[d].linearRings[a[2]]={}),c[d].linearRings[a[2]][a[3]]=b);return c},parseMetadata:function(a){a=a.split(/\n/);var b;for(b=0;b<a.length;b++)if(0<a[b].length&&"#"!=a[b].match("^#")){var c=
a[b].split("=");if(2===c.length){var d=c[0];c=c[1];-1!==d.indexOf("zoom")?(this.zoomLevels++,c>this.maxZoomScale&&(this.maxZoomScale=c)):-1!==d.indexOf("block")?this.blocks=this.updateDataList(d,c,this.blocks):-1===d.indexOf("nnarea")||this.isDistributionSeatMap||this.isChangeSeatMode?-1!=d.indexOf("area")?this.numberedAreas=this.updateDataList(d,c,this.numberedAreas):this.miscProperties[d]=c:(this.nnAreas=this.updateDataList(d,c,this.nnAreas),d=d.split(".")[1],-1===$.inArray(d,this.nnAreaIds)&&this.nnAreaIds.push(d))}}if(0===
this.zoomLevels)return!1;for(b=1;b<=this.zoomLevels;b++)this.resolutions.push(Math.pow(2,this.zoomLevels-b)/this.maxZoomScale);this.blocks?this.closeUpResolutionIndex=this.resolutions.length-2:(this.closeUpResolutionIndex=0,this.areaGradientInfo={});return!0},initZoomControls:function(){var a=this.map;$("#zoom-in").click(function(){a.zoomIn()});$("#zoom-out").click(function(){a.zoomOut()})},initFullScreenControl:function(){var a=this.map,b=$(".main_content.seat_selection"),c=$("<div></div>"),d=$("#toggle-fullscreen-button");
$(d).click(function(f){f.preventDefault();$(b).toggleClass("fullscreen");0< !$("#fullscreen-mode-background-overlay").length&&($(c).attr("id","fullscreen-mode-background-overlay"),$(b).prepend($(c)),$("#fullscreen-mode-background-overlay").click(function(){$(d).trigger("click")}));$(this).toggleClass("selected");$(this).hasClass("selected")?$(this).prop("title",SeatMap._LABEL_EXIT_FULL_SCREEN):$(this).prop("title",SeatMap._LABEL_ENTER_FULL_SCREEN);a.updateSize();$(window).resize()});$(document).keydown(function(a){27==
a.which&&$(b).hasClass("fullscreen")&&$(d).trigger("click")})},initMiniMap:function(){var a=this.TILE_SIZE*Math.pow(2,this.zoomLevels-1)/this.maxZoomScale;a=new OpenLayers.Bounds(0,0,a,a);this.miniMapFeature=new OpenLayers.Layer.Vector("miniBlocks",{styleMap:new OpenLayers.StyleMap(new OpenLayers.Style({fillColor:"#000",strokeWidth:1,strokeColor:"#000"}))});a={size:new OpenLayers.Size(this.miniMapProperties.OVERVIEW_SIZE,this.miniMapProperties.OVERVIEW_SIZE),div:$("#mini-map")[0],layers:[new OpenLayers.Layer.Image("smallOverview",
this.resourcesUrl+this.miniMapProperties.NAVMAP_PATH,a,new OpenLayers.Size(this.miniMapProperties.OVERVIEW_SIZE,this.miniMapProperties.OVERVIEW_SIZE)),this.miniMapFeature],minRectSize:2,mapOptions:{theme:null}};a=new OpenLayers.Control.OverviewMap(a);a.isSuitableOverview=function(){return!0};this.map.addControl(a);$("#toggle-mini-map").click(function(){$(this).toggleClass("selected");$("#mini-map").toggleClass("hidden")})},initMap:function(){var a=this.TILE_SIZE*Math.pow(2,this.zoomLevels-1)/this.maxZoomScale;
a=new OpenLayers.Bounds(0,0,a,a);this.mapProjection=new OpenLayers.Projection("mapCoordinates");this.map=new OpenLayers.Map(this.container,{maxExtent:a,resolutions:this.resolutions,restrictedExtent:a,projection:this.mapProjection,units:"cm",theme:null,controls:[new OpenLayers.Control.Navigation],numZoomLevels:this.zoomLevels,transitionEffect:"resize"});a={type:"png",tileSize:new OpenLayers.Size(this.TILE_SIZE,this.TILE_SIZE),freeSeatsStrokeWitdh4Accessibility:this.freeSeatsStrokeWitdh4Accessibility,
freeSeatsStyleMap:this.freeSeatsStyleMap,getURL:function(a){var b=this.map.getResolution(),d=Math.round((a.left-this.maxExtent.left)/(b*this.tileSize.w));a=Math.round((this.maxExtent.top-a.top)/(b*this.tileSize.h));d=this.map.getZoom()+"/"+d+"/"+a+".png";a=this.url;a instanceof Array&&(a=this.selectUrl(d,a));seatMapWithAccessibility&&(b=[0,1,2].includes(SeatMap.map.getZoom())?0:this.freeSeatsStrokeWitdh4Accessibility,this.freeSeatsStyleMap.styles.default.defaultStyle.strokeWidth=b);return a+d},opacity:1,
styleMap:new OpenLayers.StyleMap(new OpenLayers.Style({fillColor:"none",fillOpacity:0,pointRadius:10,strokeColor:"blue",strokeWidth:1,strokeOpacity:1})),transitionEffect:"resize"};a=new OpenLayers.Layer.TMS("background",this.resourcesUrl,a);this.map.addLayer(a);this.map.setBaseLayer(a);a.setOpacity(.3);this.map.setCenter(this.map.getMaxExtent().getCenterLonLat(),1);this.map.zoomTo(0)},addLayerToMap:function(a,b){this.map.addLayer(a);this.transformToFeatures(b,a,!0);this.mapLayers.push(a)},initNumberAreaLayer:function(){this.areasLayer=
new OpenLayers.Layer.Vector("areas",{projection:this.seatProjection,isFixed:!0,styleMap:this.areaStyleMap});this.addLayerToMap(this.areasLayer,this.numberedAreas)},filterAreasByAvailability:function(a){var b=this;jQuery.each(a,function(a,d){null!==d.seatCategoryId&&null!==d.color&&d.available?b.nnAreasInfo.push(d):delete b.nnAreas[d.id]})},initNonNumberAreaLayer:function(){var a=this,b={productId:a.productId,perfId:a.performanceId,advantageId:a.partnerAdvantageId?a.partnerAdvantageId:"",composedProductId:a.composedProductId,
areaIds:Object.keys(a.nnAreas),ppid:a.ppid,reservationIdx:a.reservationIdx,crossSellId:a.crossSellId};this.showLoadingNotification();$.ajax({url:a.areasUrl,type:"POST",cache:!1,data:b,error:function(b){tools.dialog.showDialog("ajaxErrorDialog",!0);tools.logFeatureIssue("SEATMAP","Unable load non-number areas: "+a.areasUrl+" in page "+window.location.href)},success:function(b){a.filterAreasByAvailability(b.areas);a.transformToFeatures(a.nnAreas,a.nnAreasLayer,!0);0<a.zoomOnNNAreaIdArray.length&&(a.zoomOnNNAreaIdArray=
a.zoomMap(a.zoomOnNNAreaIdArray,"NNAREA"));a.events.trigger("mapLoaded")},complete:function(){a.hideLoadingNotification()}});a.nnAreasLayer=new OpenLayers.Layer.Vector("nnAreas",{projection:a.seatProjection,isFixed:!0,styleMap:a.nnAreaStyleMap});a.map.addLayer(a.nnAreasLayer);a.mapLayers.push(a.nnAreasLayer);a.events.trigger("initnnAreasLayerDone")},getAreaColor:function(a){return jQuery.grep(this.nnAreasInfo,function(b,c){return b.id.toString()===a})[0].color},getAreaSeatCategory:function(a){return jQuery.grep(this.nnAreasInfo,
function(b,c){return b.id.toString()===a})[0].seatCategoryId},getAreasBySeatCategory:function(a){return this.nnAreasInfo?jQuery.grep(this.nnAreasInfo,function(b,c){return b.seatCategoryId.toString()===a}):[]},initBlocksLayer:function(){var a=this,b=this.resolutions[this.closeUpResolutionIndex-1];void 0===b&&(1<this.resolutions.length?(b=this.resolutions[0],this.closeUpResolutionIndex++):b=1E4);this.blocksLayer=new OpenLayers.Layer.Vector("blocks",{projection:this.seatProjection,minResolution:b,styleMap:new OpenLayers.StyleMap(new OpenLayers.Style({fillColor:"${fillColor}",
fillOpacity:.8,strokeWidth:0,cursor:"pointer"}))});this.blocksLayer.events.on({featureselected:function(b){var c=b.feature.data.id,f=a.increaseBounds(b.feature.geometry.bounds);a.zoomToBlockOrArea(c,"BLOCK");a.map.getResolution()>a.getCurrentViewLayer().maxResolution&&(a.map.setCenter(f.getCenterLonLat(),a.closeUpResolutionIndex),a.toBeAdjustedBlockId=parseInt(c,10),a.isFreeSeatsCallsInProgress()||a.adjustMapIfNoSeatsInViewport());a.selectControl.unselect(b.feature)}});this.events.trigger("initBlocksLayerDone");
a.addLayerToMap(a.blocksLayer,a.blocks)},adjustMapIfNoSeatsInViewport:function(){var a=null,b=!0,c;var d=null;if(null!==SeatMap.toBeAdjustedBlockId){SeatMap.isDistributionSeatMap&&(d=distribution.seatmap.seatViews.getSelectedView());switch(d){case SeatMap.ASSIGN_SEATS:d=SeatMap.seatsLayer.features;break;case SeatMap.TAKE_BACK_SEATS:d=SeatMap.takeBackSeatsLayer.features;break;case SeatMap.MODIFY_GUEST_SEATS:d=SeatMap.modifyGuestSeatsLayer.features;break;default:d=SeatMap.seatsLayer.features}for(c in d)if(d.hasOwnProperty(c)){var f=
d[c];if(null!==f.data.blockId&&f.data.blockId===SeatMap.toBeAdjustedBlockId&&(f=f.geometry)&&(null===a&&(a=f.getCentroid()),f.getBounds().intersectsBounds(SeatMap.map.getExtent()))){b=!1;break}}b&&a&&SeatMap.map.setCenter(new OpenLayers.LonLat(a.x,a.y),SeatMap.closeUpResolutionIndex);SeatMap.toBeAdjustedBlockId=null}},isExclusiveMode:function(){return this.isDistributionSeatMap||"undefined"===typeof SeatList?!1:SeatList.isExclusive()},initSeatsLayer:function(){var a=this,b=function(b){return new OpenLayers.Protocol.HTTP({format:new OpenLayers.Format.GeoJSON,
read:function(c){var d;a.freeSeatsCallInProgress[b.key]&&(a.freeSeatsCallInProgress[b.key].priv._object.abort(),a.freeSeatsCallInProgress[b.key]=null);var e=a.isExclusiveMode();c.exclusiveMode=e;(d=a.getSeatsFromCache(c))?this.handleRead(d.olResponse,c):(a.showLoadingNotification(),"undefined"!==typeof SeatList&&SeatList.isCheckExclusiveFromSelectedSeat&&(d=SeatList.getSelectedSeatId())&&(e=SeatList.getSeat(d).exclusive||!1,SeatList.isCheckExclusiveFromSelectedSeat=!1,SeatMap.setExclusiveState(e),
c.exclusiveMode=e),this.options.url=a.freeSeatsUrl+(a.freeSeatsUrl.contains("?")?"&":"?")+"isExclusive="+e,d=OpenLayers.Protocol.HTTP.prototype.read.apply(this,arguments),a.freeSeatsCallInProgress[b.key]=d)},params:$.extend({},a.freeSeatsParams,b),handleRead:function(c,d){var e=c.priv.responseText,f=new OpenLayers.Format.JSON;e&&(e=f.read(e),0<e.features.length&&"true"!==localStorage.getItem("isZoomOnSeat")&&a.zoomInValue>=e.features.length&&(f=e.features[0].geometry,f=new OpenLayers.Geometry.Point(f.coordinates[0],
f.coordinates[1]),OpenLayers.Projection.transform(f,SeatMap.seatProjection,SeatMap.mapProjection),f=f.getCentroid(),SeatMap.panToSeat(f.x,f.y),localStorage.setItem("isZoomOnSeat","true")),a.freeSeatsCallInProgress[b.key]&&(a.hideLoadingNotification(),delete a.freeSeatsCallInProgress[b.key]),e.error?tools.dialog.showDialog("ajaxErrorDialogReload",!0):(c.isCached||(c.isCached=!0,d.exclusiveMode=a.isExclusiveMode(),a.pushSeatsInCache(c,d)),this.handleResponse(c,d),a.adjustMapIfNoSeatsInViewport()))}})},
c=this.getCustomBBOXStrategy(),d=new c({blocks:this.blocks}),f=new c({blocks:this.blocks});c=new c({blocks:this.blocks});this.seatsLayer=new OpenLayers.Layer.Vector("seats",{strategies:[d],projection:this.seatProjection,protocol:b({seatMapMode:this.ASSIGN_SEATS,key:"ASSIGN_SEATS_LAYER"}),styleMap:this.freeSeatsStyleMap,maxResolution:this.resolutions[this.closeUpResolutionIndex],alwaysInRange:!this.blocks,visibility:!this.isDistributionSeatMap});this.takeBackSeatsLayer=new OpenLayers.Layer.Vector("takeBackSeats",
{strategies:[f],projection:this.seatProjection,protocol:b({seatMapMode:this.TAKE_BACK_SEATS,key:"TAKE_BACK_SEATS_LAYER"}),styleMap:this.freeSeatsStyleMap,maxResolution:this.resolutions[this.closeUpResolutionIndex],alwaysInRange:!this.blocks,visibility:!this.isDistributionSeatMap});this.modifyGuestSeatsLayer=new OpenLayers.Layer.Vector("modifyGuestSeats",{strategies:[c],projection:this.seatProjection,protocol:b({seatMapMode:this.MODIFY_GUEST_SEATS,key:"MODIFY_GUEST_SEATS_LAYER"}),styleMap:this.freeSeatsStyleMap,
maxResolution:this.resolutions[this.closeUpResolutionIndex],alwaysInRange:!this.blocks,visibility:!this.isDistributionSeatMap});this.map.addLayer(this.seatsLayer);this.mapLayers.push(this.seatsLayer);this.switchableViewLayers.push({id:this.ASSIGN_SEATS,layer:this.seatsLayer});this.isDistributionSeatMap&&(this.mapLayers.push(this.takeBackSeatsLayer),this.map.addLayer(this.takeBackSeatsLayer),this.switchableViewLayers.push({id:this.TAKE_BACK_SEATS,layer:this.takeBackSeatsLayer}),this.isEditGuestsModeEnabled&&
(this.mapLayers.push(this.modifyGuestSeatsLayer),this.map.addLayer(this.modifyGuestSeatsLayer),this.switchableViewLayers.push({id:this.MODIFY_GUEST_SEATS,layer:this.modifyGuestSeatsLayer})));this.events.trigger("initSeatsLayerDone");this.isDistributionSeatMap&&(this.events.trigger("initTakeBackSeatsLayerDone"),this.isEditGuestsModeEnabled&&this.events.trigger("initModifyGuestSeatsLayerDone"))},initProjections:function(){this.seatProjection=new OpenLayers.Projection("seatsCoordinates");var a=parseFloat(this.miscProperties.xOffset);
var b=parseFloat(this.miscProperties.yOffset);var c=this.map.maxExtent.top;OpenLayers.Projection.addTransform("mapCoordinates","seatsCoordinates",function(d){d.y=Math.floor(c-d.y+b);d.x=Math.floor(d.x+a);return d});OpenLayers.Projection.addTransform("seatsCoordinates","mapCoordinates",function(d){d.y=c-d.y+b;d.x-=a;return d})},transformToFeatures:function(a,b,c){c=0;var d,f;if(a)for(c in a)if(a.hasOwnProperty(c)){var e=a[c];var g=[];for(f=0;f<e.linearRings.length;f++){var h=e.linearRings[f];var l=
h.x.split(",");var k=h.y.split(",");var m=[];for(d=0;d<l.length-1;d++)h=new OpenLayers.Geometry.Point(l[d],k[d]),OpenLayers.Projection.transform(h,this.seatProjection,this.mapProjection),m.push(h.clone());g.push(new OpenLayers.Geometry.LinearRing(m))}e.id=c;e.geometry=new OpenLayers.Geometry.Collection(g);b.addFeatures([new OpenLayers.Feature.Vector(e.geometry,e)])}},panToSeat:function(a,b){this.map.setCenter(new OpenLayers.LonLat(a,b),this.zoomLevels-1)},getFeaturesOfLayer:function(a){switch(a){case "AREA":a=
this.areasLayer.features;break;case "NNAREA":a=this.nnAreasLayer.features;break;default:a=this.blocksLayer.features}return a},zoomToBlockOrArea:function(a,b){var c=0;b=this.getFeaturesOfLayer(b);for(c in b)if(b[c].data.id===a){a=b[c].geometry.bounds;this.map.zoomToExtent(this.increaseBounds(a),!0);break}},zoomToBlocksOrAreas:function(a,b){var c=0,d=0,f=new OpenLayers.Bounds,e=[],g=null,h=null,l=!1;b=this.getFeaturesOfLayer(b);for(c in b)if(b.hasOwnProperty(c)){var k=b[c];var m=k.data.id.toString();
-1<$.inArray(m,a)&&(f.extend(k.geometry.getBounds()),e.push(k.geometry),l=!0)}if(l){a=f.getCenterPixel();for(d;d<e.length;d++)if(c=a.distanceTo(e[d].bounds.getCenterPixel()),null===g||c<g)g=c,h=e[d];null!==h&&this.map.zoomToExtent(this.increaseBounds(h.bounds),!0)}},increaseBounds:function(a){var b=.2*(a.right-a.left),c=.2*(a.top-a.bottom),d=new OpenLayers.Bounds;d.left=a.left-b;d.right=a.right+b;d.top=a.top+c;d.bottom=a.bottom-c;return d},selectSeat:function(a,b,c){a=parseInt(a,10);var d=null;var f=
b?this.nnAreasLayer.features:this.seatsLayer.features;this.selectControl.unselectAll();for(d in f)if(f.hasOwnProperty(d)){var e=f[d];var g=parseInt(b?e.data.id:e.fid,10);if(g===a){this.selectControl.select(Object.assign({},e,{ignoreDeselecting:!0}));c&&this.events.trigger("seatSelectedOnMap",e);break}}},unselectAllSeats:function(){this.selectControl.unselectAll()},getSeatsFromCache:function(a){this.seatsCache||(this.seatsCache=new SeatCache(this.mapProjection,this.seatProjection));return this.seatsCache.getFromCache(a,
this.map.getExtent())},pushSeatsInCache:function(a,b){this.seatsCache||(this.seatsCache=new SeatCache(this.mapProjection,this.seatProjection));return this.seatsCache.pushInCache(a,b)},getCustomBBOXStrategy:function(){return OpenLayers.Class(OpenLayers.Strategy.BBOX,{ratio:1,update:function(a){var b=!1;var c=this.layer.map.getExtent();var d=!1;if(!SeatMap.blocks)b=!0;else for(e in SeatMap.blocks)if(SeatMap.blocks.hasOwnProperty(e)){var f=SeatMap.blocks[e];if(!f.geometry){b=!0;break}f=f.geometry.getBounds();
if(f.intersectsBounds(c)){b=!0;break}}c=this.getMapBounds();a&&a.force&&(this.calculateBounds(c),this.resolution=this.layer.map.getResolution(),this.triggerRead(a),d=!0);var e=SeatMap.isDistributionSeatMap&&SeatMap.distributionSeatMapInitiated[this.layer.id];b&&!d&&null!==c&&(a&&a.force||this.invalidBounds(c))&&!e&&(this.calculateBounds(c),this.resolution=this.layer.map.getResolution(),this.triggerRead(a),SeatMap.distributionSeatMapInitiated[this.layer.id]=!0);this.ratio=1.5}})},redrawSeat:function(a,
b,c){var d,f=null==SeatDetails.getSelectedSeatId()||SeatDetails.getSelectedSeatId()!=a;for(d in this.seatsLayer.features)if(this.seatsLayer.features[d].fid===a){c&&!f||this.seatsLayer.drawFeature(this.seatsLayer.features[d],b);break}},redrawArea:function(a,b){for(var c in this.nnAreasLayer.features)if(this.nnAreasLayer.features[c].data.id===a){this.nnAreasLayer.drawFeature(this.nnAreasLayer.features[c],b);break}},removeArea:function(a,b){var c=this;jQuery.each(this.nnAreasLayer.features,function(b,
f){if(f.data.id===a)return c.unSelectedFeatures.push(f),c.nnAreasLayer.removeFeatures(f),!1})},addArea:function(a){var b=this;jQuery.each(this.unSelectedFeatures,function(c,d){if(d.data.id===a)return b.nnAreasLayer.addFeatures(d),!1})},hideBlock:function(a){var b=this;jQuery.each(this.blocksLayer.features,function(c,d){if(d.data.id===a)return b.hiddenBlocks[a]=d,b.blocksLayer.removeFeatures(d),!1})},showBlock:function(a){var b=this.hiddenBlocks[a];b&&(delete this.hiddenBlocks[a],this.blocksLayer.addFeatures(b))},
refreshSeatLayer:function(){this.refreshLayerWithoutCheckResolution(this.seatsLayer)},refreshLayerWithoutCheckResolution:function(a){null!==this.map&&a.refresh({force:!0,exclusiveMode:this.isExclusiveMode()});0<a.features.length&&this.zoomInValue>=a.features.length&&(a=a.features[0].geometry,SeatMap.panToSeat(a.x,a.y))},refreshLayer:function(a){null!==this.map&&this.map.resolution<=this.resolutions[this.closeUpResolutionIndex]&&a.refresh({force:!0,exclusiveMode:this.isExclusiveMode()})},showLoadingNotification:function(){var a=
$("#seat-map .loading");$(a).is(":visible")||$(a).fadeIn(800)},switchSeatsLayer:function(a){this.events.trigger("beforeSwitchingViewLayer");this.switchableViewLayers.forEach(function(b,c,d){b.layer.setVisibility(b.id===a)});this.events.trigger("afterSwitchingViewLayer")},getCurrentViewLayer:function(){var a=null;this.switchableViewLayers.forEach(function(b,c,d){!0===b.layer.getVisibility()&&(a=b.layer)});return a},isFreeSeatsCallsInProgress:function(){return 0<Object.keys(this.freeSeatsCallInProgress).length},
hideLoadingNotification:function(){$("#seat-map .loading").fadeOut(800)},toggleExclusive:function(a){var b=!this.isExclusiveMode();SeatMap.setExclusiveState(b);a&&a();this.refreshLayerWithoutCheckResolution(this.getCurrentViewLayer())},setExclusiveState:function(a){a?($("#exclusive-seats-filter").removeClass("inactive"),ExclusiveSessionStorage.storeExclusiveSelected(!0)):($("#exclusive-seats-filter").addClass("inactive"),ExclusiveSessionStorage.storeExclusiveSelected(!1))},getFilterCriteria:function(){var a=
multiselect.getComboList(),b={fileNumbers:[],invoices:[],shipmentModes:[],culturalContactNumbers:[]};$(a).each(function(a,d){$(d).hasClass("fileNumberSelector")?b.fileNumbers=multiselect.getSelectedValues(d):$(d).hasClass("invoiceNumberSelector")?b.invoices=multiselect.getSelectedValues(d):$(d).hasClass("shipmentModeSelector")?b.shipmentModes=multiselect.getSelectedValues(d):$(d).hasClass("culturalContactSelector")&&(b.culturalContactNumbers=multiselect.getSelectedValues(d))});return b},validateFilterCriteria:function(a){var b=
!0;a=a.data.distributionTicketResult.distributionTicket;SeatMap.areDistributionFiltersApplied()&&a&&(SeatMap.filterCriteria.fileNumbers.length&&(b&=SeatMap.filterCriteria.fileNumbers.includes(a.fileNumber.toString())),SeatMap.filterCriteria.invoices.length&&(b&=SeatMap.filterCriteria.invoices.includes(a.invoiceNumber)),SeatMap.filterCriteria.shipmentModes.length&&(b="undefined"!==typeof a.shipmentModeData?b&SeatMap.filterCriteria.shipmentModes.includes(a.shipmentModeData.id.toString()):b&0),SeatMap.filterCriteria.culturalContactNumbers.length&&
(b&=SeatMap.filterCriteria.culturalContactNumbers.includes(a.culturalContact.contactNumber)));return b},handleBlockFilter:function(){var a=new Set,b=new Set;SeatMap.hiddenBlocks&&$.each(SeatMap.hiddenBlocks,function(a,b){SeatMap.showBlock(b.data.id)});$.each(SeatMap.getCurrentViewLayer().features,function(b,d){a.add(d.data.blockId.toString())});$.each(SeatMap.blocksLayer.features,function(c,d){a.has(d.data.id)||b.add(d.data.id)});b.forEach(function(a,b){SeatMap.hideBlock(b)})},handleSeatFilter:function(){SeatMap.hiddenSeats&&
$.each(SeatMap.switchableViewLayers,function(a,b){if(a=SeatMap.hiddenSeats[b.layer.id])a.forEach(function(a,d){b.layer.addFeatures(d);b.layer.id!==SeatMap.getCurrentViewLayer().id||d.attributes.unselectable||distribution.seatmap.seatList.getSelectedSeats().hasOwnProperty(d.fid)||b.layer.drawFeature(d,"unselectable")}),delete SeatMap.hiddenSeats[b.layer.id]});$.each(SeatMap.switchableViewLayers,function(a,b){var c=new Set;$.each(b.layer.features,function(a,b){SeatMap.validateFilterCriteria(b)||c.add(b)});
SeatMap.hiddenSeats[b.layer.id]=c});$.each(SeatMap.switchableViewLayers,function(a,b){(a=SeatMap.hiddenSeats[b.layer.id])&&a.forEach(function(a,d){b.layer.removeFeatures(d)})})},updateInformation:function(){var a=0,b=0,c=0,d=0,f={0:0,1:0,2:0},e=SeatMap.getCurrentViewLayer().features,g=$(".remaining_tickets_container > .total_number"),h=$(".modifiable-guests-filters-container"),l=$("#seat-map-views > .selected");e.length&&(a=e.length,$.each(e,function(a,e){e.data.distributionTicketResult.distributed||
b++;e.data.distributionTicketResult.canTakeBack&&c++;e.data.distributionTicketResult.canModifyGuest&&d++;distribution.seatmap.seatDetails.isBeneficiaryFullySet(e.data.distributionTicketResult)?f[2]++:distribution.seatmap.seatDetails.isAtLeastOneBeneficiaryInfoSet(e.data.distributionTicketResult)?f[1]++:f[0]++}));distribution.seatmap.seatViews.updateNumberOfTickets(l,b,c,d);$.each(h.find(".remaining"),function(a,b){$(b).html(f[a])});$.each(h.find(".totalNumber"),function(b,c){$(c).html("/ "+a)});g.html("/ "+
a)},getSelectedFileNumbers:function(a){var b=new Set;$(a).parent().find(".dropdownItem:not(.selectAll)").each(function(a,d){a=$(d).find("input");a.is(":checked")&&b.add(a.prop("id"))});return b},refreshFileSelectorAndDepend:function(){SeatMap.updateFilterDropdownOnFileChange([],".invoiceNumberSelector");SeatMap.updateFilterDropdownOnFileChange([],".shipmentModeSelector");SeatMap.updateFilterDropdownOnFileChange([],".culturalContactSelector")},applyFilters:function(a){a.preventDefault();tools.dialog.showWaitingPopup("loadingDialog",
!0);SeatMap.filterCriteria=SeatMap.getFilterCriteria();SeatMap.areDistributionFiltersApplied()&&(!SeatMap.getCurrentViewLayer().features.length&&$.isEmptyObject(SeatMap.hiddenSeats)||SeatMap.handleSeatFilter(),!SeatMap.blocksLayer.features.length&&$.isEmptyObject(SeatMap.hiddenBlocks)||SeatMap.handleBlockFilter(),SeatMap.updateInformation());tools.dialog.hideDialog("loadingDialog");SeatMap.getCurrentViewLayer().features.length?($(".noFilterResult").hide(),tools.scrollElementInViewport(".main_content.seat_selection",
1E3,12)):$(".noFilterResult").show()},initDistributionFilterHandler:function(){$("#apply_filters").on("click",function(a){SeatMap.applyFilters(a)});$(".fileNumberSelector .dropdown .dropdownItem").on("click",function(){var a=SeatMap.getSelectedFileNumbers(this);SeatMap.updateFilterDropdownOnFileChange([].concat($jscomp.arrayFromIterable(a)),".invoiceNumberSelector");SeatMap.updateFilterDropdownOnFileChange([].concat($jscomp.arrayFromIterable(a)),".shipmentModeSelector");SeatMap.updateFilterDropdownOnFileChange([].concat($jscomp.arrayFromIterable(a)),
".culturalContactSelector")});$(".fileNumberSelector").parent().find(".reset").on("click",function(){SeatMap.refreshFileSelectorAndDepend()});$("#reset_all_filters").on("click",function(a){SeatMap.refreshFileSelectorAndDepend();multiselect.reset(".fileNumberSelector");multiselect.reset(".shipmentModeSelector");multiselect.reset(".invoiceNumberSelector");multiselect.reset(".culturalContactSelector");SeatMap.applyFilters(a)})},areDistributionFiltersApplied:function(){return null!==SeatMap.filterCriteria},
triggerInitialLayerLoad:function(){distribution.seatmap.seatViews.getSelectedView()===SeatMap.ASSIGN_SEATS&&SeatMap.seatsLayer.setVisibility(!0);distribution.seatmap.seatViews.getSelectedView()===SeatMap.TAKE_BACK_SEATS&&SeatMap.takeBackSeatsLayer.setVisibility(!0);distribution.seatmap.seatViews.getSelectedView()===SeatMap.MODIFY_GUEST_SEATS&&SeatMap.modifyGuestSeatsLayer.setVisibility(!0)},updateFilterDropdownOnFileChange:function(a,b){var c=$(b+" .dropdown"),d=c.find(".selectAll");c.find(".noItems").remove();
c.find(".dropdownItem:not(.selectAll)").each(function(c,d){0===a.length?($(d).removeClass("hidden"),$(d).show()):$(d).data("file-numbers").map(String).filter(function(b){return a.includes(b)}).length?($(d).removeClass("hidden"),$(d).show()):($(d).children("input").is(":checked")&&multiselect.selectItem(b,$(d).children("input")),$(d).addClass("hidden"),$(d).hide())});c.find(".dropdownItem:not(.selectAll):not(.hidden)").length?(d.removeClass("hidden"),d.show(),c.find(".noItems").remove(),c.closest(".multi-select-container").removeClass("disabled")):
(d.addClass("hidden"),d.hide(),c.append('<div class="dropdownItem noItems"><div>'+SeatMap.noItemsInFilterLabel+"</div></div>"),c.closest(".multi-select-container").addClass("disabled"));multiselect.updateSelectedItemsText(b)},initSearchableFilterOutFocus:function(a){var b=SeatMap.getSelectedFileNumbers($(".fileNumberSelector .dropdown .dropdownItem"));b.size&&SeatMap.updateFilterDropdownOnFileChange(b,"."+$(a).attr("class"));multiselect.getListValueBySearch($(a));multiselect.updateSelectedItemsText(a)}};
tools.module("seatmap.SeatMapSvg",function(){var a,b=null,c=null,d=null,f=null,e=null,g=null,h=null,l=null,k=null,m={},p={},q="",r={},t=[],w={},y=!1,z=!1,x=!1,A=!1,C="",u="",v,D=!1,E=[],F={},B={},G=function(){a||SeatSessionStorage.storeSelectedSeat(b,{selectedSeatPolygons:p})},L=function(){$("#seat-map .loading").fadeOut(800);D=!1},K=function(){var a=SeatSessionStorage.getNonSeatData(b);null!==a&&$.each(SeatSessionStorage.getSelectedSeats(b),function(b,c){b=c.seatData.data.seatId;p[b]=a.selectedSeatPolygons[b]})},
H=function(a){a&&(H.svgPanZoom=svgPanZoom("#seat-map-content svg",{controlIconsEnabled:!1,fit:!1,contain:!0,center:!0,zoomEnabled:!0,minZoom:1,maxZoom:10,panEnabled:!0,customEventsHandler:{haltEventListeners:["touchstart","touchend","touchmove","touchleave","touchcancel"],init:function(a){var b=a.instance,c=1,d=0,e=0;this.hammer=new Hammer(a.svgElement,{inputClass:Hammer.SUPPORT_POINTER_EVENTS?Hammer.PointerEventInput:Hammer.TouchInput});this.hammer.get("pinch").set({enable:!0});this.hammer.on("doubletap",
function(a){b.zoomIn()});this.hammer.on("panstart panmove",function(a){"panstart"===a.type&&(e=d=0);b.panBy({x:a.deltaX-d,y:a.deltaY-e});d=a.deltaX;e=a.deltaY});this.hammer.on("pinchstart pinchmove",function(a){"pinchstart"===a.type&&(c=b.getZoom(),b.zoom(c*a.scale));b.zoom(c*a.scale)});a.svgElement.addEventListener("touchmove",function(a){a.preventDefault()})},destroy:function(){this.hammer.destroy()}},beforePan:function(a,b){var c=this.getSizes(),d=c.width,e=c.height;a=-(c.viewBox.x+c.viewBox.width)*
c.realZoom+d;d=c.width-d-c.viewBox.x*c.realZoom;var f=-(c.viewBox.y+c.viewBox.height)*c.realZoom+e;c=c.height-e-c.viewBox.y*c.realZoom;a>d&&(e=a,a=d,d=e);f>c&&(e=f,f=c,c=e);return{x:Math.max(a,Math.min(d,b.x)),y:Math.max(f,Math.min(c,b.y))}}}));return H.svgPanZoom},M=function(a){a||(a="#s-[areaId]-[blockId]-[rowNum]-[seatNum]");q=a},Q=function(a){a=q.replace("[areaId]",null===a.areaId?"":a.areaId).replace("[blockId]",null===a.blockId?"":a.blockId).replace("[rowNum]",null===a.row?"":a.row).replace("[seatNum]",
null===a.number?"":a.number);return $(a)},S=function(a,b){"undefined"===typeof b&&(b="-hover");return a=-1!==a.indexOf("-full")?a.replace("-full",b):-1===a.indexOf(b)?a+b:a.replace("-hover",b)},V=function(a,b){var c=Q(a);if(c.length){$("#svg-seats").find("[status=selected]").finish();var d=c.css("opacity");c.css("opacity",1).animate({opacity:0},500).animate({opacity:d},500);N(a);seatmap.SeatMapSvg.events.trigger("onSeatSelected",Object.assign({},a,{enableDeselecting:b}))}},N=function(a){seatMapWithAccessibility&&
(a=Q(a),v||(v=a.css("fill")),$("#pattern-selected-seat")&&(a.css("fill","url(#pattern-selected-seat)"),$("#pattern-selected-seat #check-background").css("fill",v)))},I=function(a){var b=Q(a);b.length&&(b.data("seatId",a.id),b.data("seatCategoryId",a.seatCategoryId),b.data("tariffId",a.tariffId),b.data("amount",a.amount),b.click(function(){var a=$(this),b=a.data("seatId"),c=!SeatList.isChangeSeatMode()&&SeatList.isInSeatList(b);SeatList.canAdd()||c?(a.attr("status","selected"),p[b]=f,G(),a=T(f,b),
V(a,c)):$("#cant_book_notification").html(SeatDetails._LABEL_NOTIFICATION_FULL_SEAT)}).hover(function(){var a=$(this);"visible"===a.attr("status")&&a.attr("status","hovered")},function(){var a=$(this);"hovered"===a.attr("status")&&a.attr("status","visible")}),p[a.id]===f?(b.attr("status","selected"),N(a)):b.attr("status","visible"),r[a.seatCategoryId]=(r[a.seatCategoryId]||[]).concat(b),w[a.tariffId]=(w[a.tariffId]||[]).concat(b),t=(t||[]).concat(b))},O=function(a,b,c){a=X(a,c);m[a]||(m[a]={});m[a][b.id]=
b},R=function(a,b){a=X(a,b);return m[a]?m[a]:void 0},X=function(a,b){null==b&&(b=SeatList.isExclusive());return a+"-"+(b?"exclusive":"normal")},T=function(a,b,c){return R(a,c)?R(a,c)[b]:null},Z=function(a,b,e){var g=B[a];if(a===f){var m=g.seatCatIds||[];$(".seat-map-filter .categories_table .seat-info-category-legend").each(function(){m.includes(Number($(this).find('input[type="checkbox"]').val()))?$(this).css("display","flex"):$(this).hide()});var q=$('[id$="-hover"]').css("fill");$('[id^="P"]').css("opacity",
0);$('[id^="P"]').css("fill","none");$('[id$="-hover"]').css("fill",q);$('[id^="'+a+'"]').css("opacity",F[a+"-hover"]);$("#"+a).css("fill","url(#pattern-selected-block)");$("#seat-map-content").html(g.svgSeatMapImageData);H(!0);M($("#svg-seats").attr("seatlocator"));g.numberedSeat?b&&void 0!==R(a)?($.each(R(a),function(a,b){I(b)}),seatmap.SeatMapSvg.events.trigger("onChangedSvgSeatMapOfPolygon",a),L()):$.ajax({url:e||SeatList.isExclusive()?h+"&isExclusive=true":h,type:"GET",cache:!1,data:{productId:d,
performanceId:c,polygonId:a,advantageId:l}}).done(function(b,c,d){b.error||"OK"!==b.status||a!==f||($.each(b.features,function(b,c){b=c.properties;O(a,b,e||SeatList.isExclusive());I(b)}),seatmap.SeatMapSvg.events.trigger("onChangedSvgSeatMapOfPolygon",a),seatmap.SeatMapSvg.events.trigger("restoreDefaultPolygon",null))}).fail(function(a,b,c){tools.dialog.showDialog("ajaxErrorDialog",!0)}).always(function(){L()}):$.ajax({url:k+g.linkedAreaIds[0],type:"POST",cache:!1}).done(function(b,c,d){b.error||
"OK"!==b.status||a!==f||(b=b.areas[0],b.isNonNumbered=!0,b.areaId=b.id,p[b.id]=a,G(),O(a,b),seatmap.SeatMapSvg.events.trigger("onAreaSelected",b),seatmap.SeatMapSvg.events.trigger("onChangedSvgSeatMapOfPolygon",a))}).fail(function(a,b,c){tools.dialog.showDialog("ajaxErrorDialog",!0);tools.logFeatureIssue("SEATMAP","Unable load polygon: "+k+g.linkedAreaIds[0]+" in page "+window.location.href)}).always(function(){L()})}},ba=function(){var a=$("#seat-map .loading");$(a).is(":visible")||$(a).fadeIn(800)},
U=function(a,b){D||(f=a,ba(),y&&($("#add-selected-seat-to-cart").parent().removeClass("disabled"),SeatDetails.setDisplayFilterByPolygon(a)),"undefined"!==typeof B[a]?Z(a,!0,b):$.ajax({url:g+a,type:"GET",cache:!1}).done(function(c,d,e){c.success&&"OK"===c.status&&(B[a]=c,Z(a,!1,b))}).fail(function(b,c,d){tools.dialog.showDialog("ajaxErrorDialog",!0);L();tools.logFeatureIssue("SEATMAP","Unable load polygon: "+g+a+" in page "+window.location.href)}))},P=function(a,b,c){var d=y&&b?p[c]:p[a];c=T(d,a);
var e=function(){var b=T(d,a);!b||null!=SeatDetails.getSelectedSeatId()&&SeatDetails.getSelectedSeatId()==a||V(b,!1)};d&&(b?U(d):(b=SeatList.getSeat(a),Y(d,f,b,c,e)))},Y=function(a,b,c,d,e){if(a!==b)seatmap.SeatMapSvg.events.one("onChangedSvgSeatMapOfPolygon",e),U(a,c?c.exclusive:void 0);else if(d)e();else seatmap.SeatMapSvg.events.one("onChangedSvgSeatMapOfPolygon",e)},da=function(a,b,c){var d=y&&b?p[c]:p[a];if(d)if(c=SeatList.getSeat(a)?SeatList.getSeat(a).exclusive:void 0,c=T(d,a,c)){if(!b){var e=
Q(c);e.filter("[status=selected]").css("opacity","").attr("status","visible");e.removeAttr("style")}p[a]=void 0;G();b?(seatmap.SeatMapSvg.events.trigger("onAreaUnSelected",c),setTimeout(function(){Z(d)},1E3)):seatmap.SeatMapSvg.events.trigger("onSeatUnSelected",c)}else p[a]=void 0},aa=function(){var a=!0,b=$("#toggle-mini-map"),c=$("#mini-map"),d=c.add(b),e=function(){a=!1},f=1E3*parseFloat(c.css("transition-duration")),g=function(){d.unbind("mouseenter mouseleave",e);a&&(c.addClass("animationStartState"),
setTimeout(function(){b.trigger("click");c.removeClass("animationStartState")},f))};$(function(){d.bind("mouseenter mouseleave",e);c.removeClass("animationStartState");setTimeout(g,f+3E3)});$("#venue-preview").hide();$("#venue-categories").hide();b.click(function(){$(this).toggleClass("selected");$("#mini-map").toggleClass("hidden")}).trigger("click")},W=function(a){return a.length&&(-1!==a.attr("id").indexOf("-hover")||a.hasClass("stx_hover"))},J=function(a){var b=[];$("#seat-map svg").length&&(a&&
(b=a.split("#")),$('[id^="P"]').each(function(){var a=!1,c=$(this),d=c.attr("id"),e=d,f=!1;-1<e.indexOf("-")&&(e=e.split("-")[0]);(a=b.some(function(a){return e===a}))?-1<d.indexOf("-hover")||-1===d.indexOf("-full")&&$("#"+e+"-full").length?f=!0:-1!==d.indexOf("-full")||$("#"+e+"-full").length||c.addClass("stx_full"):-1<d.indexOf("-full")?f=!0:-1!==d.indexOf("-hover")||$("#"+e+"-hover").length||c.addClass("stx_hover");f?c.hide():c.show();W(c)&&!f&&(F[d]=1,c.css("opacity",0),E.push("#"+d))}))},la=
function(a){if(0>(SeatDetails.getVisibleSeatCategories()||[]).indexOf($(a).data("seatCategoryId")))return!1;if(y){if(x)return!0;var b=SeatDetails.getVisibleTariff()||[];if(0>b.indexOf($(a).data("tariffId")))return!1;if(z)return!0;b=$(a).data("amount");a=SeatDetails.getPriceRangeSlider();if(a.min>b||a.max<b)return!1}return!0},ja=function(a){"selected"!==a.attr("status")&&a.attr("status",la(a)?"visible":"")},ea=function(a,b){a=a.split("#");var c=b.split("#");return a.filter(function(a){return!c.includes(a)}).join("#")};
return{events:$({}),filterSeatBySeatCat:function(a){(r[a]||[]).forEach(function(a){ja(a)})},filterSeatByTariff:function(a){(w[a]||[]).forEach(function(a){ja(a)})},filterSeatByPrice:function(){(t||[]).forEach(function(a){ja(a)})},init:function(m){var q=m.isTabletOrMobile,r=m.fullPolygonIds,t=$("#venue").find("image");A=q;a=m.isChangeSeatMode;d=m.productId;c=m.performanceId;b=m.seatSessionStorageEvent;g=m.blockViewSvgLoadUrl;h=m.freeSeatsUrl;k=m.areasUrl;l=m.partnerAdvantageId;y=m.resaleMode;z=m.isModifyTariff;
x=m.isSeatRelease;SeatList.isExclusiveAvailable()&&(SeatList.isExclusive()?$("#exclusive-seats-filter").removeClass("inactive"):$("#exclusive-seats-filter").addClass("inactive"),C=[m.fullPolygonIds,m.exclusivePolygonIds].join("#"),u=[m.fullPolygonIds,ea(m.availablePolygonIds,m.exclusivePolygonIds)].join("#"),r=SeatList.isExclusive()?u:C);m.selectedSeatPolygons?p=m.selectedSeatPolygons:K();0<t.length&&$("<div>").css({position:"absolute",width:"100%",height:"100%",opacity:"0.2","background-size":"100%",
"background-image":"url('"+t.attr("xlink:href").replace(/[\r\n]/g,"")+"')"}).prependTo($("#seat-map"));J(r);m.workingPolygonId&&(U(m.workingPolygonId),D=!0);if((e=m.workingPolygonId)&&!a)seatmap.SeatMapSvg.events.on("restoreDefaultPolygon",function(){e&&e!==f&&(U(e),e=null)});aa();$("#zoom-in").click(function(){H().zoomIn()});$("#zoom-out").click(function(){H().zoomOut()});$("#toggle-fullscreen-button").click(function(a,b){var c=$(".main_content.seat_selection"),d=$("<div></div>"),e=$("#toggle-fullscreen-button");
a.preventDefault();$(c).toggleClass("fullscreen");0< !$("#fullscreen-mode-background-overlay").length&&($(d).attr("id","fullscreen-mode-background-overlay"),$(c).prepend($(d)),$("#fullscreen-mode-background-overlay").click(function(){$(e).trigger("click")}));b||tools.scrollToElement($(c),800);$(this).toggleClass("selected");U(f);$(window).resize()});A||($('[id^="P"]').hover(function(){var a=S($(this).attr("id"));$("#"+a).css("opacity",F[a])},function(){var a=S($(this).attr("id"));a!==f+"-hover"&&
$("#"+a).css("opacity",0)}),$(".polygon_navigation_container .polygon_arrow").each(function(){$(this).hide()}));$('[id^="P"]').click(function(){var a=$(this),b=a.attr("id"),c=S(b,"");if(-1===b.indexOf("-full")||a.hasClass("stx_full"))U(c),e=null,seatmap.SeatMapSvg.events.trigger("onAreaUnSelected",null)})},selectSeat:function(a,b,c){P(a,b,c)},removeSeatSelection:function(a,b,c){da(a,b,c)},toggleExclusive:function(a){var b=!SeatList.isExclusive();b?ExclusiveSessionStorage.storeExclusiveSelected(!0):
ExclusiveSessionStorage.storeExclusiveSelected(!1);a&&a();b?($("#exclusive-seats-filter").removeClass("inactive"),J(u)):($("#exclusive-seats-filter").addClass("inactive"),J(C));Z(f,!0)},resetDefaultPolygonId:function(){e=null}}});
tools.module("SeatPano",function(){var a=null,b=null,c=null,d=function(a,b){var c=$("#"+a+"> #"+b),d=$("#"+a);!c.length&&d.length&&$("#"+a).append("<div id="+b+"></div>")};return{init:function(d){a=d.panoSWFUrl;b=d.panoJSUrl;c=d.html5Config},displayPanel:function(f,e,g,h){var l=$("#"+g+"> #"+h),k,m;l.attr({"data-protocol":f,"data-venue-id":""});switch(f){case "krpano":$("#"+h+" > div").length&&removepano(h);d(g,h);embedpano({swf:a,js:b,xml:e,target:h,html5:c});break;case "tk3d":var p=function(a,b){a||
w.load(m)}.bind(this);$("#"+h).remove();$(".tk3d").remove();var q=h+"-"+(new Date).getTime();d(g,q);$("#"+q).addClass("tk3d pano-thumbnail");l=$("#"+g+"> #"+q);l.attr({"data-protocol":f,"data-venue-id":""});f=e.split("?")[0];e=e.split("?")[1].split("&");g=0;for(h=e.length;g<h;g++){var r=e[g].split("=");"venue_id"===r[0]?k=r[1]:"view_id"===r[0]&&(m=r[1])}l.data("venueId",k);if("undefined"===typeof TICKETING3D)$.ajax({dataType:"script",cache:!0,url:f,success:function(a){t=new TICKETING3D(k);w=t.loadModule("view3d",
q);w.init(p)}});else{var t=new TICKETING3D(k);var w=t.loadModule("view3d",q);w.init(p)}break;case "pacifa":d(g,h),$("#"+g+"> #"+h).html($("<iframe>",{src:e,width:"100%",height:"100%",allowfullscreen:!0,scrolling:"no",frameborder:"0"}))}},destroyPanel:function(a,b){switch($("#"+a+"> #"+b).data("protocol")){case "krpano":$("#"+b+" > div").length&&(removepano(b),d(a,b));break;case "tk3d":case "pacifa":$("#"+a+"> #"+b).empty()}}}});
tools.module("SeatSessionStorage",function(){var a=null,b=function(b,c){tools.storage.setItem("seatMapSelection_"+b,{contactNumber:a,data:c})},c=function(b){return(b=tools.storage.getItem("seatMapSelection_"+b))?null===b.contactNumber||b.contactNumber===a?b.data:null:null};return{init:function(b){b&&(a=b)},storeSelectedSeat:function(a,f,e){var d=c(a),h,l=!1;null===d&&(d={selectedSeats:[],nonSeatData:{}});if(void 0===e)d.nonSeatData=f;else{e={seatData:f,numbered:e};for(h in d.selectedSeats)if(d.selectedSeats[h].seatData.data.seatId===
f.data.seatId){d.selectedSeats[h]=e;l=!0;break}l||d.selectedSeats.push(e)}b(a,d)},getSelectedSeats:function(a){a=c(a);return null!==a?a.selectedSeats:null},removeStoredSeat:function(a,f){var d=c(a),g;if(null!==d)for(g in d.selectedSeats)if(d.selectedSeats[g].seatData.data.seatId===f.data.seatId){d.selectedSeats.splice(g,1);b(a,d);break}},getNonSeatData:function(a){a=c(a);return null!==a?a.nonSeatData:null},clearEvent:function(a){tools.storage.removeItem("seatMapSelection_"+a)}}});
tools.module("tag.select",function(){var a=function(){var a=0,b=[];return{set:function(c){b.push({offset:++a,ptr:c});return b[b.length-1].offset},remove:function(a){var c=b.filter(function(b){return b.offset!=a});b=c.splice(0);c=[]},closeAllButMe:function(a){temp=[];b.forEach(function(b){b.offset!=a&&b.ptr.closeOrder()})}}}(),b=function(b,c){var d=this;this.instanceOffset=a.set(this);this.domSelector=b;this.root=document.querySelector(b);this.main;this.button;this.title;this.multipleSize=(this.isMultiple=
this.root.hasAttribute("multiple"))&&this.root.hasAttribute("size")?parseInt(this.root.getAttribute("size")):-1;this.drop;this.top;this.left;this.options;this.listElements;this.search=this.isDisabled=!1;this.inputBox=this.searchZone=null;this.disabledItems=[];this.ulminWidth=140;this.ulminHeight=25;this.userOptions={maxWidth:500,maxHeight:400,translations:{all:"All",item:"item",items:"items",selectAll:"Select All",clearAll:"Clear All"},search:!1,placeHolder:"",stayOpen:!1,disableSelectAll:!1};this.callBack;
this.selectAllDefault;this.firstExecution=!0;if(c){void 0!=c.maxWidth&&(this.userOptions.maxWidth=c.maxWidth);void 0!=c.maxHeight&&(this.userOptions.maxHeight=c.maxHeight);if(void 0!=c.translations)for(var f in c.translations)c.translations.hasOwnProperty(f)&&this.userOptions.translations[f]&&(this.userOptions.translations[f]=c.translations[f]);void 0!=c.placeHolder&&(this.userOptions.placeHolder=c.placeHolder);void 0!=c.search&&(this.search=c.search);void 0!=c.stayOpen&&(this.userOptions.stayOpen=
c.stayOpen);void 0!=c.disableSelectAll&&(this.userOptions.disableSelectAll=c.disableSelectAll);void 0!=c.selectAllDefault&&(this.selectAllDefault=c.selectAllDefault)}this.closeOrder=function(){d.userOptions.stayOpen||(d.drop.style.display="none",d.search&&(d.inputBox.value="",Array.prototype.slice.call(d.listElements).forEach(function(a){a.classList.remove("hide")})))};this.init=function(){d.root.style.display="none";var b=document.getElementById("btn-group-"+d.domSelector);b&&b.remove();d.main=document.createElement("div");
d.root.parentNode.insertBefore(d.main,d.root.nextSibling);d.main.classList.add("vsb-main");d.main.setAttribute("id","btn-group-"+d.domSelector);d.userOptions.stayOpen&&(d.main.style.minHeight=d.userOptions.maxHeight+10+"px");d.button=document.createElement(d.userOptions.stayOpen?"div":"button");d.button.classList.add("stx_select");d.main.appendChild(d.button);d.title=document.createElement("span");d.button.appendChild(d.title);d.title.classList.add("title");d.userOptions.stayOpen&&(d.title.style.paddingLeft=
"20px",d.title.style.fontStyle="italic",d.title.style.verticalAlign="20%");d.drop=document.createElement("div");d.main.appendChild(d.drop);d.drop.classList.add("vsb-menu");d.drop.style.zIndex=2E3-d.instanceOffset;d.ul=document.createElement("ul");d.drop.appendChild(d.ul);d.ul.style.maxHeight=d.userOptions.maxHeight+"px";d.ul.style.minWidth=d.ulminWidth+"px";d.ul.style.minHeight=d.ulminHeight+"px";d.isMultiple&&(d.ul.classList.add("multi"),d.userOptions.disableSelectAll||(b=document.createElement("option"),
b.setAttribute("value","all"),b.innerText=d.userOptions.translations.selectAll,d.selectAllDefault&&(b.setAttribute("selected","true"),b.innerText=d.userOptions.translations.clearAll),d.root.insertBefore(b,d.root.hasChildNodes()?d.root.childNodes[0]:null)));var c="";d.search&&(d.searchZone=document.createElement("div"),d.ul.appendChild(d.searchZone),d.searchZone.classList.add("vsb-js-search-zone"),d.searchZone.style.zIndex=2001-d.instanceOffset,d.inputBox=document.createElement("input"),d.searchZone.appendChild(d.inputBox),
d.inputBox.setAttribute("type","text"),d.inputBox.setAttribute("id","search_"+d.domSelector),d.ul.addEventListener("scroll",function(a){d.searchZone.parentNode.style.top=this.scrollTop+"px"}));d.options=document.querySelectorAll(d.domSelector+" > option");Array.prototype.slice.call(d.options).forEach(function(a){d.populate(d,a,0,c,"")});null!==document.querySelector(d.domSelector+" optgroup")&&(d.options=document.querySelectorAll(d.domSelector+" option"),b=document.querySelectorAll(d.domSelector+
" optgroup"),Array.prototype.slice.call(b).forEach(function(a){var b=a.querySelectorAll("option"),e=document.createElement("li");e.classList.add("grouped-option");e.appendChild(document.createTextNode(a.label));d.ul.appendChild(e);Array.prototype.slice.call(b).forEach(function(a){this.populate(d,a,0,c,"")})}));-1!==d.multipleSize&&0>d.multipleSize&&(c="0 "+(d.userOptions.translations.items||"items"));d.isMultiple&&(d.title.innerHTML=c);""!==d.userOptions.placeHolder&&""===d.title.textContent&&(d.title.textContent=
d.userOptions.placeHolder);d.listElements=d.drop.querySelectorAll("li:not(.grouped-option)");d.search&&d.inputBox.addEventListener("keyup",function(a){var b=a.target.value.toUpperCase();2>b.length?Array.prototype.slice.call(d.listElements).forEach(function(a){a.classList.remove("hidden-search")}):Array.prototype.slice.call(d.listElements).forEach(function(a){-1===a.getAttribute("data-text").toUpperCase().indexOf(b)&&"all"!==a.getAttribute("data-value")?a.classList.add("hidden-search"):a.classList.remove("hidden-search")})});
d.userOptions.stayOpen?(d.drop.style.display="block",d.drop.style.boxShadow="none",d.drop.style.minHeight=d.userOptions.maxHeight+10+"px",d.drop.style.position="relative",d.drop.style.left="0px",d.drop.style.top="0px",d.button.style.border="none"):d.main.addEventListener("click",function(b){d.isDisabled||(d.drop.style.left=d.left+"px",d.drop.style.top=d.top+"px",d.drop.style.display="block",document.addEventListener("click",docListener),b.preventDefault(),b.stopPropagation(),d.userOptions.stayOpen||
a.closeAllButMe(d.instanceOffset))});d.drop.addEventListener("click",function(a){if(!d.isDisabled)if(a.target.hasAttribute("data-value")){var b=a.target.getAttribute("data-value"),c=a.target.getAttribute("data-text"),e=a.target.getAttribute("class");if("all"===b)if(a.target.hasAttribute("data-selected")&&"true"===a.target.getAttribute("data-selected"))d.setValue([]),a.target.innerText=d.userOptions.translations.selectAll,a.target.setAttribute("data-selected","false");else{var f=[];a.target.innerText=
d.userOptions.translations.clearAll;Array.prototype.slice.call(d.listElements).forEach(function(a){!a.hasAttribute("data-value")||"all"===a.getAttribute("data-value")||a.classList.contains("hidden-search")||a.classList.contains("disabled")||f.push(a.getAttribute("data-value"))});a.target.setAttribute("data-selected","true");d.setValue(f);a.target.classList.add("active")}else if(!e||-1==e.indexOf("disabled")){if(d.isMultiple){c=!1;e&&(c=-1!=e.indexOf("active"));c?a.target.classList.remove("active"):
a.target.classList.add("active");for(var g="",h="",k=e=0,l=0;l<d.options.length;l++)k++,d.options[l].value===b&&(d.options[l].selected=!c),d.options[l].selected&&"all"!==d.options[l].value&&(e++,g+=h+d.options[l].textContent,h=",");k===e?g=d.userOptions.translations.all||"all":-1!=d.multipleSize&&e>d.multipleSize&&(b=d.userOptions.translations.items||"items",1===e&&(b=d.userOptions.translations.item||"item"),g=e+" "+b);d.title.textContent=g;d.privateSendChange()}else d.root.value=b,d.title.textContent=
c,e?d.title.setAttribute("class",e+" title"):d.title.setAttribute("class","title"),Array.prototype.slice.call(d.listElements).forEach(function(a){a.classList.remove("active")}),""!=c&&a.target.classList.add("active"),d.privateSendChange(),d.userOptions.stayOpen||docListener();a.preventDefault();a.stopPropagation();""!=d.userOptions.placeHolder&&""===d.title.textContent&&(d.title.textContent=d.userOptions.placeHolder)}}else a.preventDefault(),a.stopPropagation()});docListener=function(){document.removeEventListener("click",
docListener);d.drop.style.display="none";d.search&&(d.inputBox.value="",Array.prototype.slice.call(d.listElements).forEach(function(a){a.classList.remove("hidden-search")}))}};this.init()};b.prototype.populate=function(a,b,c,g,h){g=b.textContent;h=b.value;var d=b.getAttribute("class");d=d?d.split(" "):[];var e=document.createElement("li");b=b.hasAttribute("selected");a.ul.appendChild(e);e.setAttribute("data-value",h);e.setAttribute("data-text",g);e.setAttribute("data-selected",b);0!==d.length&&d.forEach(function(a){e.classList.add(a)});
b&&"all"!==h&&(c++,e.classList.add("active"),a.isMultiple||(a.title.textContent=g,0!=d.length&&d.forEach(function(b){a.title.classList.add(b)})));e.appendChild(document.createTextNode(g))};b.prototype.disableItems=function(a){var b=[];"string"===c(a)&&(a=a.split(","));"array"===c(a)&&Array.prototype.slice.call(this.options).forEach(function(c){-1!=a.indexOf(c.value)&&(b.push(c.value),c.setAttribute("disabled",""))});Array.prototype.slice.call(this.listElements).forEach(function(a){var c=a.getAttribute("data-value");
-1!=b.indexOf(c)&&a.classList.add("disabled")})};b.prototype.enableItems=function(a){var b=[];"string"===c(a)&&(a=a.split(","));"array"===c(a)&&Array.prototype.slice.call(this.options).forEach(function(c){-1!=a.indexOf(c.value)&&(b.push(c.value),c.removeAttribute("disabled"))});Array.prototype.slice.call(this.listElements).forEach(function(a){-1!=b.indexOf(a.getAttribute("data-value"))&&a.classList.remove("disabled")})};b.prototype.setValue=function(a){var b=this;if(null===a||void 0===a||""===a)this.empty();
else if(this.isMultiple){"string"===c(a)&&("all"===a?(a=[],Array.prototype.slice.call(this.options).forEach(function(b){a.push(b.value)})):a=a.split(","));var d=[];if("array"===c(a)){Array.prototype.slice.call(this.options).forEach(function(b){-1!=a.indexOf(b.value)?(b.selected=!0,d.push(b.value)):b.selected=!1});var g="",h="",l=0,k=0;Array.prototype.slice.call(this.listElements).forEach(function(a){k++;-1!=d.indexOf(a.getAttribute("data-value"))?(b.firstExecution&&a.hasAttribute("data-value")&&"all"===
a.getAttribute("data-value")?b.firstExecution=!1:a.classList.add("active"),l++,g+=h+a.getAttribute("data-text"),h=","):a.classList.remove("active")});if(k===l)g=this.userOptions.translations.all||"all";else if(-1!=this.multipleSize&&l>this.multipleSize){var m=this.userOptions.translations.items||"items";1===l&&(m=this.userOptions.translations.item||"item");g=l+" "+m}this.title.textContent=g;this.privateSendChange()}}else{var p=!1,q="";Array.prototype.slice.call(this.listElements).forEach(function(b){b.getAttribute("data-value")===
a?(b.classList.add("active"),p=!0,q=b.getAttribute("data-text")):b.classList.remove("active")});Array.prototype.slice.call(this.options).forEach(function(b){b.value===a?(b.selected=!0,(className=b.getAttribute("class"))||(className="")):b.selected=!1});p&&(this.title.textContent=q,""!=this.userOptions.placeHolder&&""===this.title.textContent&&(this.title.textContent=this.userOptions.placeHolder),""!=className?this.title.setAttribute("class",className+" title"):this.title.setAttribute("class","title"))}};
b.prototype.privateSendChange=function(){var a=document.createEvent("HTMLEvents");a.initEvent(this.id+"OnChange",!0,!1);this.root.dispatchEvent(a);this.callback&&this.callback(this.getValues())};b.prototype.empty=function(){Array.prototype.slice.call(this.listElements).forEach(function(a){a.classList.remove("active")});Array.prototype.slice.call(this.options).forEach(function(a){a.selected=!1});this.title.textContent="";""!=this.userOptions.placeHolder&&""===this.title.textContent&&(this.title.textContent=
this.userOptions.placeHolder);this.privateSendChange()};b.prototype.destroy=function(){var b=document.getElementById("btn-group-"+this.domSelector);b&&(a.remove(this.instanceOffset),b.remove(),this.root.style.display="inline-block")};b.prototype.disable=function(){var a=document.getElementById("btn-group-"+this.domSelector);a&&((button=a.querySelector("button"))&&button.classList.add("disabled"),this.isDisabled=!0)};b.prototype.enable=function(){var a=document.getElementById("btn-group-"+this.domSelector);
a&&((button=a.querySelector("button"))&&button.classList.remove("disabled"),this.isDisabled=!1)};b.prototype.showOptions=function(){console.log(this.userOptions)};b.prototype.setCallback=function(a){this.callback=a};b.prototype.getValues=function(){var a=[].concat($jscomp.arrayFromIterable(document.querySelectorAll(this.domSelector+" option")));return a&&a.length?a.filter(function(a){return a.selected&&parseInt(a.value)}).map(function(a){return a.value}):[]};"remove"in Element.prototype||(Element.prototype.remove=
function(){this.parentNode&&this.parentNode.removeChild(this)});var c=function(a){return Object.prototype.toString.call(a).replace("[object ","").replace("]","").toLowerCase()};return{init:function(a){var c=new b("#"+a.id,{search:a.searchable,placeHolder:a.placeHolder,stayOpen:a.stayOpen,disableSelectAll:a.disableSelectAll,translations:a.translations,selectAllDefault:a.selectAll});a.selectAll&&c.setValue("all");c.setCallback(a.onChange)}}});
tools.module("services",{init:function(){var a={};$("#bookService #book").on("click",function(a){a.preventDefault();functions.validateQuantities(!0,null,$("#bookService"))});$("#bookService").on("keypress",function(a){13==a.keyCode&&(a.preventDefault(),functions.validateQuantities(!0,null,$("#bookService")))});var b=$(".product_right_img.product_GOODS .product_image_container img, .product-image-extra-image").map(function(b){var c=$(this),f=c.data("img-large"),e=c.data("img-small");a[f]=e;return{href:f,
title:c.attr("title"),dom:this,index:b}});$(".product_right_img.product_GOODS .product_image_container img, .product-image-extra-image").on("click",function(){var c=this,d=$.grep(b,function(a){return a.dom===c})[0].index;$.fancybox.open(b,{openEffect:"elastic",closeEffect:"elastic",index:d,type:"image",wrapCSS:"product-goods-image-popup",maxWidth:800,margin:[20,20,20,20],helpers:{title:{type:"inside",position:"top"},thumbs:{width:50,height:50,source:function(b){return a[b.href]}}}});return!1})}});
tools.module("shoppingCart",function(){var a,b=!1,c=!1,d=function(a,d){$(a).toggleClass("disabled",!b);$(a).find(".text").text(b&&c?d.finish:d.buy)},f="",e={isExchangeProductEnabled:null,exchangeBalanceWarningDialogId:null,isHasExchangeBalanceWarningDialog:null,hasAlertExchangeQuantityElement:null,toManyTicketErrorEle:null,notEnoughSeatAvailabilityErrorEle:null,showExchangeBalanceWarning:null};return{initForVoucherPayment:function(b){this.changeProceedButtonState(b.proceedButtonLabels);a=b.voucherPaymentMethodId},
changeProceedButtonState:function(a){b=!(0<$("#overPaymentIsNotAllowed").length||0<$(".confirm-voucher").length);c=functions.isFreeAmount();0<$("#payNowButtonContainer").length?d("#payNowButtonContainer",a):d("#buyNowButton",a);$("#buyNowButton").css("pointer-events",b?"auto":"none")},getPaymentMethodId:function(){return a},initForExchangeOrder:function(a){e.isExchangeProductEnabled=a.isExchangeProductEnabled;e.exchangeBalanceWarningDialogId=a.exchangeBalanceWarningDialogId;e.isHasExchangeBalanceWarningDialog=
a.isHasExchangeBalanceWarningDialog;e.toManyTicketErrorEle=$("#tooManyTicketsError");e.notEnoughSeatAvailabilityErrorEle=$("#notEnoughSeatAvailabilityError");e.hasAlertExchangeQuantityElement=0<e.toManyTicketErrorEle.length||0<e.notEnoughSeatAvailabilityErrorEle.length;e.showExchangeBalanceWarning=function(){tools.dialog.showDialog(e.exchangeBalanceWarningDialogId,!0,!e.isExchangeProductEnabled,null)};!e.isExchangeProductEnabled&&e.isHasExchangeBalanceWarningDialog&&e.showExchangeBalanceWarning()},
handleSubmitForExchangeOrder:function(){return e.hasAlertExchangeQuantityElement?(e.toManyTicketErrorEle.show(),e.notEnoughSeatAvailabilityErrorEle.show(),window.scrollTo(0,0),!1):e.isExchangeProductEnabled&&e.isHasExchangeBalanceWarningDialog?(e.showExchangeBalanceWarning(),!1):!0},handleExchangeBalanceWarningConfirm:function(){e.isExchangeProductEnabled?window.location=f:tools.dialog.hideDialog(e.exchangeBalanceWarningDialogId)},handleButtonSubmit:function(a){var b=this.handleSubmitForExchangeOrder();
f=a;b&&(window.location=f)}}});
tools.module("social.fb",{imageUrl:contextPath+"/images/",shareProducts:[],institutionUrl:null,isMobile:!1,isTnMCApplication:!1,init:function(a,b,c,d){FB&&FB.init({appId:a,status:!0,cookie:!0,logging:!0});this.institutionUrl=b;this.isMobile=c;this.isTnMCApplication=d}},null,{loadOnce:!0});
tools.module("social.fb.join",{joinButtonId:"join_button",joinButtonClass:"join_button",init:function(){$("[data-stx-event-id]").click(function(){var a=$(this).attr("data-stx-event-id");social.fb.join.joinEvent(a)})},joinEvent:function(a){tools.dialog.showWaitingPopup("loadingDialog",!0);FB.login(function(b){FB.api("/"+a+"/attending","post",function(a){a.error?($("#facebook_join_success_message").hide(),$("#facebook_join_error_message").show()):($("#facebook_join_error_message").hide(),$("#facebook_join_success_message").show());
tools.dialog.hideDialog("loadingDialog")})},{scope:"rsvp_event"})}});
tools.module("social.fb.share",{imageUrl:contextPath+"/images/",tnmcNativeShareURL:"http://tnmc.secutix.com/sharefb",shareProducts:[],init:function(a){var b=$("#main_content_confirmation_facebook .selector_container select"),c=this,d;this.shareProducts=a;for(d=0;d<a.length;d++)b.append("<option value='"+d+"'>"+a[d].productName+"</option>");$("#main_content_confirmation_facebook #share").on("click",function(){c.shareProduct()});$("#main_content_confirmation_facebook .selector_container select").on("change",
function(){c.displayProduct($(this).val())});0<a.length&&this.displayProduct(0)},shareProduct:function(){var a=$("#main_content_confirmation_facebook .selector_container select");a=a.length?a.val():0;a=this.shareProducts[a];$("#display_places").is(":checked")&&a.hasOwnProperty("extendedDescription")&&(a.description=a.extendedDescription);this.shareOnFacebook(a)},displayProduct:function(a){$("#facebook_join_error_message").hide();$("#facebook_join_success_message").hide();a=this.shareProducts[a];var b=
$("#main_content_confirmation_facebook .product_image_container img");a.logoUrl?(b.attr("src",a.logoUrl).attr("alt",a.productName).attr("title",a.productName),b.show()):b.hide();$("#main_content_confirmation_facebook .content .title").html(a.productName);$("#main_content_confirmation_facebook .content .day").html(a.startDate||"");$("#main_content_confirmation_facebook .content .location").html(a.venue||"");a.hasOwnProperty("extendedDescription")?$("#display_places_container").show():$("#display_places_container").hide();
a.socialEventId&&a.socialEventId.hasOwnProperty("FACEBOOK")?($("#join").attr("data-stx-event-id",a.socialEventId.FACEBOOK),$("#join").parent().show()):$("#join").parent().hide()},shareOnFacebookAsync:function(a,b,c){var d=this;a=0<=a.indexOf("_")?a.split("_")[0]:a;var f=$(c.target).parents(".facebook_share");f.addClass("async_button_loading");$.ajax({url:contextPath+"/ajax/account/tickets/fbShareProdData",type:"GET",data:{productId:a,operationId:b},dataType:"json",success:function(a){d.shareOnFacebook(a)},
error:function(){tools.dialog.showDialog("ajaxErrorDialog",!0)},complete:function(){f.removeClass("async_button_loading")}})},shareOnFacebook:function(a){var b=social.fb.isMobile?"touch":"popup";social.fb.isTnMCApplication?window.location.href=this.tnmcNativeShareURL+"?link="+encodeURIComponent(a.productUrl)+"&picture="+encodeURIComponent(a.logoUrl)+"&name="+encodeURIComponent(a.productName)+"&caption="+encodeURIComponent(a.linkCaption)+"&description="+encodeURIComponent(a.description):FB&&FB.ui({method:"feed",
link:a.productUrl,picture:a.logoUrl,name:a.productName,caption:a.linkCaption,description:a.description,display:b},function(b){b&&b.post_id&&$.get(contextPath+"/ajax/share/register",{tracker:a.trackingId})})}});
tools.module("social.popup",{showSocialAccountPopup:function(a,b){var c;window.open(a,"",b);if(/Trident/.test(navigator.userAgent)||/MSIE/.test(navigator.userAgent)||/Edge/.test(navigator.userAgent)){window.localStorage.setItem("forceClosePopup","true");var d=setInterval(function(){(c=window.localStorage.getItem("socialRedirectUrl"))&&"null"!=c&&(clearInterval(d),window.localStorage.removeItem("socialRedirectUrl"),window.location.href=c)},500)}}});
tools.module("ticketBarcode",function(){var a,b,c=function(){$(b).slideUp(150,function(){a.removeClass("open");$(b).removeClass("open")})};return{init:function(){$('[id^="barcodeTicket_"]').on("click",function(d){var f=$(this),e=f.attr("id").replace("barcodeTicket_","");d.preventDefault();a=f;b="#ticket_barcode_"+e;$(b).hasClass("open")?c():(d=$(b).addClass("open"),a.addClass("open"),d.slideDown(150))});$(".ticket_barCode .close_expand_panel").click(function(){var d=$(this).parents(".ticket_barCode"),
f=d.attr("id").replace("ticket_barCode","");a=$("#barcodeTicket_"+f);b=d;c();return!1})}}});
tools.module("ticketManagement",function(){return{init:function(){var a=localStorage.getItem("fileId");a&&($("#file_number_criteria").val(a),localStorage.removeItem("fileId"),this.finalizeSubmit($("#searching_criteria_form").serializeArray()))},finalizeSubmit:function(a){var b={},c=$("#ticket_list_container");a.map(function(a){b[a.name]=a.value});""!==$("#file_number_criteria").val()||""!==$("#order_number_criteria").val()||""!==$("#contact_criteria").val()||""!==$("#ticket_barcode_criteria").val()?
($(".missing_criteria_error").hide(),$(".invalid_selected_exchange_tickets").hide(),tools.dialog.showWaitingPopup("loadingDialog",!0),account.exchange.exchangeTickets.clearSelectedTickets(),$.ajax({url:"/ajax/ticketManagement/search",type:"POST",data:{fileId:b.fileId,orderId:b.orderId,contactInfo:b.contactInfo,ticketBarcode:b.ticketBarcode,ticketState:b.ticketState},success:function(a){c.hide();c.html(a);c.fadeIn()},error:function(){c.html("")},complete:function(){tools.dialog.hideDialog("loadingDialog")}})):
($(".missing_criteria_error").show(),$(".invalid_selected_exchange_tickets").hide(),$(".invalid_selected_print_tickets").hide(),c.html(""))},handlePrintButton:function(){var a=account.exchange.exchangeTickets.isSelectedTicketsSameState(),b=account.exchange.exchangeTickets.getTicketStateToHandlePrintOrRePrint();if(a){$(".invalid_selected_print_tickets").hide();if("PRINTED"===b&&!tools.storage.getItem("confirmPrintWarning"))return $("#reprint_confirmation_container").dialog("open"),!1;this.processPrintOrReprint()}else $(".invalid_selected_print_tickets").show(),
$(".invalid_selected_exchange_tickets").hide(),$(".missing_criteria_error").hide(),window.scrollTo(0,0)},processPrintOrReprint:function(){tools.isStorageAvailable()&&$("#confirmPrintWarning").is(":visible")&&(tools.storage.setItem("confirmPrintWarning",$("#confirmPrintWarning").is(":checked")),$("#reprint_confirmation_container").dialog("close"));tools.cookie.setItem("listPrintTickets",account.exchange.exchangeTickets.getSelectedTicketsId(),null,"/");var a=account.exchange.exchangeTickets.getTicketStateToHandlePrintOrRePrint();
tools.cookie.setItem("ticketsState",a,null,"/");window.location.href=contextPath+"/v1/tickets"}}});
tools.module("ticketSelectionFilter",function(){var a={primaryMarket:!0,secondaryMarket:!0,exclusive:!1,accessible:!1},b=function(a,b){localStorage.getItem("currentPerformanceId")&&localStorage.getItem("currentPerformanceId").toString()===a.toString()||(localStorage.setItem("currentPerformanceId",a),localStorage.removeItem("performanceCurrentFilter"));a=new URL(window.location.href);var c=a.pathname,d="/ticketFilter/"+b;void 0!==localStorage.getItem("performanceCurrentFilter")&&localStorage.getItem("performanceCurrentFilter")===
b.toString()&&c.includes(d)||(localStorage.setItem("performanceCurrentFilter",b),c.includes("/ticketFilter/")?c.includes(d+"/")||(a.pathname=c.replace(/\/ticketFilter\/[^/]+/,d)):a.pathname=c.replace(/\/lang\/[^/]+/,"")+d+"/lang/"+$("html").attr("lang"),window.location.href=a.toString())};return{updateFilterValue:function(c,d,f){var e=$(".table_container"),g=$(".seat_selection"),h=$("#no_ticket_available"),l=$(".legend"),k=c.primaryMarket&&c.secondaryMarket?"STANDARD,RESALE":!c.primaryMarket&&c.secondaryMarket?
"RESALE":c.primaryMarket&&!c.secondaryMarket?"STANDARD":"";a!==c&&(a=c,""===k?(g.addClass("not_include_resale"),l.hide(),h.show(),e.hide()):(g.removeClass("not_include_resale"),l.show(),e.show(),h.hide(),f?b(d,k):$.ajax({type:"POST",url:contextPath+"/ajax/selection/event/updateTicketFilter?performanceId="+d,contentType:"application/json",data:k,success:function(a){"UPDATE_STATUS_SUCCESS"===a&&window.location.reload()},error:function(a){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",
!0)}})))}}});
function TimeSlotPass(a,b,c,d,f){var e={},g,h,l=function(a){if(d)$("#timeslot_rate_container").html(a);else{$("#timeslots_container_id").html(a);$("#timeSlotsPassSelectedDateContent").html($("#newtimeSlotsPassSelectedDate").html());$("#newtimeSlotsPassSelectedDate").remove();a=$("#newTimeSlotsPassTotalNumber");var b=$("#timeslots_quantity_container");var c=$(b).find(".filtered_res_quantity");b=$(b).find(".total_quantity");$(c).html($(a).html());$(b).html($(a).html());$(a).remove()}"undefined"!==typeof audSubCatVerification&&
"function"===typeof audSubCatVerification.init&&audSubCatVerification.init()},k=function(g,k){var m={},p=g,q;if(q=e[g])l(q.content);else{tools.dialog.showWaitingPopupDelayed("loadingDialog",!0,!1,300);null!==g&&(g instanceof Object||(g=$.datepicker.parseDate(datePickerConfig.dateFormat,g)),m={year:g.getFullYear(),month:g.getMonth()+1,day:g.getDate()});m.productId=a;if(void 0===k||!0===k.advantage)m.advantageId=b;m.rateInsteadOfTimeslotsTable=d;m.minQuantity=c||"";m.ppid=f.ppid;m.crossSellId=f.crossSellId;
m.reservationIdx=f.reservationIdx;$.ajax({type:"GET",url:h?h:contextPath+"/ajax/selection/timeslots",cache:!1,data:m,success:function(a){l(a);e[p]||(e[p]={content:a});tools.dialog.hideDialog("loadingDialog")},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}})}},m=function(a){a=$.datepicker.parseDate(datePickerConfig.dateFormat,a);e[a]={content:$("#timeslots_container_id").html()}};this.updateTimeSlots=function(a,b,c){g=a;a instanceof Object||
(a=$.datepicker.parseDate(datePickerConfig.dateFormat,a));k(a,c)};this.init=function(a){d||m(a.date);g=a.date;h=a.getTimeslotsUrl;var b=function(){var a=$("#min_quantity").val();/^\d*$/.test(a)&&(a&&"0"!==a||(a=null),g||(g=null),util.url.updateUrlAndReload({minQuantity:a,date:g},!0));return!1};$("#min_quantity_submit").on("click",b);$("#min_quantity").on("keydown",function(a){if(13==a.keyCode)return b()});$("select#min_quantity").on("change",b);$("#min_quantity_reset").on("click",function(){$("#min_quantity").val("");
return b()})}}
;function Tour(a,b){var c=this;this.filters={date:void 0,product:void 0,space:void 0};this.page=b||1;this.tourId=a;this.init=function(){this.productFilterSelector=$("#tour_product_filter");this.spaceFilterSelector=$("#tour_space_filter");this.datePickerFilterSelector=$("#date_picker");this.productFilterResetSelector=this.productFilterSelector.parent().find("label .alternative_button.filter_reset");this.spaceFilterResetSelector=this.spaceFilterSelector.parent().find("label .alternative_button.filter_reset");
this.datePickerFilterResetSelector=this.datePickerFilterSelector.parent().find("label .alternative_button.filter_reset");c.bindFilters();c.handleParameterFilter()};this.handleParameterFilter=function(){c.filters.product=tools.getParameterFromUrl("productId",location.href)||void 0;c.filters.space=tools.getParameterFromUrl("spaceId",location.href)||void 0;c.filters.date=tools.getParameterFromUrl("date",location.href)||void 0;c.productFilterSelector.val(c.filters.product);c.spaceFilterSelector.val(c.filters.space);
c.filters.date&&c.datePickerFilterSelector.datepicker("setDate",$.datepicker.parseDate(datePickerConfig.dateFormat,c.filters.date));c.filters.product&&c.productFilterResetSelector.show();c.filters.space&&c.spaceFilterResetSelector.show();c.filters.date&&c.datePickerFilterResetSelector.show();c.getTour()};this.dateSelectedHandler=function(a){c.filters.date=a;c.filters.date?c.datePickerFilterResetSelector.show():c.datePickerFilterResetSelector.hide();c.getTour()};this.productFilterSelectedHandler=function(){c.filters.product=
c.productFilterSelector.val();c.filters.product?c.productFilterResetSelector.show():c.productFilterResetSelector.hide();c.getTour()};this.spaceFilterSelectedHandler=function(){c.filters.space=c.spaceFilterSelector.val();c.filters.space?c.spaceFilterResetSelector.show():c.spaceFilterResetSelector.hide();c.getTour()};this.loadMoreHandler=function(){c.page++;c.getTour()};this.getTour=function(){var a=c.filters,b;var e=a.date;tools.dialog.showWaitingPopupDelayed("loadingDialog",!0,!1,300);e?(e instanceof
Object||(b=$.datepicker.parseDate(datePickerConfig.dateFormat,e)),e={year:b.getFullYear(),month:b.getMonth()+1,day:b.getDate()}):e={};e.productId=a.product||void 0;e.spaceId=a.space||void 0;e.tourId=c.tourId;e.page=c.page;$.ajax({type:"GET",url:contextPath+"/ajax/selection/tour",cache:!1,data:e,success:function(a){$("#tour_container").html(a);tools.displayLazyImages();tools.dialog.hideDialog("loadingDialog")},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",
!0)}})};this.bindFilter=function(a,b){var c=a.parent().find("label .alternative_button.filter_reset");a.change(b);c.hide();c.click(function(){a.val("");c.hide();b();return!1})};this.bindFilters=function(){this.bindFilter(this.productFilterSelector,tours.productFilterSelectedHandler);this.bindFilter(this.spaceFilterSelector,tours.spaceFilterSelectedHandler);this.datePickerFilterSelector.datepicker().on("input change",function(a){c.dateSelectedHandler(a.target.value)});this.datePickerFilterResetSelector.hide();
this.datePickerFilterResetSelector.click(function(){c.datePickerFilterSelector.val("");c.datePickerFilterResetSelector.hide();c.dateSelectedHandler();return!1})}}
;tools.module("unsupportedBrowser",function(){var a={Opera:0,Chrome:0,Safari:0,Firefox:0,MSIE:8},b=function(b){var c=a[b.name];return c?parseInt(b.version,10)>=c:!0};var c=function(){var a=window.navigator.userAgent;var b=a.indexOf("Edge/");return 0<b?(a=parseInt(a.substring(b+5,a.indexOf(".",b)),10),17>a):!0};return{init:function(){jQuery("#unsupported_browser .close").click(function(a){a.preventDefault();$("#unsupported_browser").hide()});jQuery("#unsupported_edgeVersionUpper17 .close").click(function(a){a.preventDefault();
$("#unsupported_edgeVersionUpper17").hide()});if(!tools.cookie.getItem("unsupportedBrowserWarningShown")){var a=tools.getBrowserInfo();a=b(a);a||(tools.cookie.setItem("unsupportedBrowserWarningShown",!0,null,"/"),$("#unsupported_browser").show())}tools.cookie.getItem("unsupportedSeatMap4EdgeVersion")||(a=c(),!a&&0<$(".seat-map-3D").length&&(tools.cookie.setItem("unsupportedSeatMap4EdgeVersion",!0,null,"/"),$("#unsupported_edgeVersionUpper17").show()))}}});
tools.module("upsell",{upgradeSeatUrl:null,upgradedEventBookingRequest:null,reservationUrl:null,upSellSeatCategoryId:null,previousReservationIndex:null,refuseOffer:function(){$("#upsell_box").slideUp()},acceptOffer:function(){var a=this;tools.dialog.showWaitingPopup("loadingDialog",!0);$.ajax({url:a.upgradeSeatUrl,type:"POST",data:a.upgradedEventBookingRequest,processData:!1,contentType:"application/json",error:function(a){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",
!0)},success:function(b){0<b?(b=a.reservationUrl+b+"?upgradedSeatCatId="+a.upSellSeatCategoryId+"&previousReservationIndex="+a.previousReservationIndex,window.location.replace(b)):($("#added_message_content").parent().hide(),$("#upgraded_error_message").parent().show(),tools.dialog.hideDialog("loadingDialog"),$("#upsell_box").hide())}})},init:function(a){this.upgradeSeatUrl=a.upgradeSeatUrl;this.upgradedEventBookingRequest=a.upgradedEventBookingRequest;this.reservationUrl=a.reservationUrl;this.upSellSeatCategoryId=
a.upSellSeatCategoryId;this.previousReservationIndex=a.previousReservationIndex}});
tools.module("util.accessibility",function(){var a=function(a){$("body").css("zoom",a+"%")},b=function(){return parseInt(sessionStorage.getItem("zoomRatio"),10)||100},c=function(){var a=sessionStorage.getItem("isHighContrast");return null===a||!1===JSON.parse(a)?!1:!0},d=function(a){$("body").toggleClass("high-contrast",a)};return{initAccessibilityMode:function(){a(b());d(c())},zoomIn:function(){var c=b();200>c&&(c+=10,a(c),sessionStorage.setItem("zoomRatio",c))},zoomOut:function(){var c=b();50<c&&
(c-=10,a(c),sessionStorage.setItem("zoomRatio",c))},highContrastHandler:function(){var a=c();a=a?!1:!0;d(a);sessionStorage.setItem("isHighContrast",a)}}});
tools.module("util.captcha",function(){var a=null,b=!1,c=function(){b=!0;$.widget("ui.dialog",$.ui.dialog,{_allowInteraction:function(a){if(this._super(a)||a.target.ownerDocument!=this.document[0]||$(a.target).closest("iframe").length)return!0}});$("#captcha_dialog_continue").on("click",function(){util.captcha.onCaptchaReady();return!1})};return{showPopup:function(d){a=d;b||c();tools.dialog.showDialog("captcha_dialog",!0,!0)},attachToForm:function(a){var b=$(a),c=!1;b.on("submit",function(){if(c)return!0;
c=!0;util.captcha.showPopup(function(a){var c=$('<input type="hidden" name="captcha"></input>');c.val(a);b.append(c);b.submit()});return!1})},onCaptchaReady:function(){var b=$("[name=g-recaptcha-response]"),c=$("#captcha_response_field"),e=null,g=0<b.length;validation.validateFields([{fieldId:b,rules:validation.rules.mandatory,defaultErrorId:"notification_captcha"},{fieldId:c,rules:validation.rules.mandatory,defaultErrorId:"notification_mandatory"}])&&a&&(tools.dialog.hideDialog("captcha_dialog"),
e=b.val()||c.val(),setTimeout(function(){a(e);g&&grecaptcha.reset()},100))},resetStxCaptchaPopup:function(){return 0<$("#captcha_image").length?($("#captcha_image").attr("src",contextPath+"/captcha?"+(new Date).getTime()),$("#captcha_response_field").val(""),tools.dialog.hideDialog("ajaxErrorDialogReload"),tools.dialog.showDialog("captcha_dialog",!0,!0),!0):!1}}});
tools.module("util.cart",{getCart:function(){var a=Date.now(),b=tools.cookie.getItem("stx_cartSummary_"+SecuTixConfig.institCode+"_"+SecuTixConfig.salesChannelCode);if(b&&(b=decodeURIComponent(b).split("|"),3<b.length)){var c=(new Date(b[3])).getTime();if(c>a&&(a=parseInt(b[0],0)))return{nbItems:parseInt(b[0],0),amount:b[1],currency:b[2],expiration:c}}return null}});
tools.module("util.color",function(){return{invertHexColor:function(a){a=a.substring(1);a=parseInt(a,16);a=(16777215^a).toString(16);a=("000000"+a).slice(-6);return"#"+a},hexColor:function(a){if("#"===a.charAt(0))return a;var b=a.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);if(!b||!b.length)return a;delete b[0];for(a=1;3>=a;++a)b[a]=parseInt(b[a],10).toString(16),1==b[a].length&&(b[a]="0"+b[a]);return"#"+b.join("")},changeColorLuminance:function(a,b){var c="#",d;a=String(a).replace(/[^0-9a-f]/gi,"");
6>a.length&&(a=a[0]+a[0]+a[1]+a[1]+a[2]+a[2]);b=b||0;for(d=0;3>d;d++){var f=parseInt(a.substr(2*d,2),16);f=Math.round(Math.min(Math.max(0,f+f*b),255)).toString(16);c+=("00"+f).substr(f.length)}return c}}});
tools.module("util.contact",function(){return{getContact:function(){var a=tools.cookie.getItem("stx_contact_"+SecuTixConfig.institCode+"_"+SecuTixConfig.salesChannelCode+"_v1"),b=Date.now();return a&&(a=JSON.parse(a),(new Date(a.expires)).getTime()>b)?(a.individualFirstName=decodeURIComponent(a.individualFirstName.replace(/\+/g," ")),a.individualLastname=decodeURIComponent(a.individualLastname.replace(/\+/g," ")),a.structureOfficialName=decodeURIComponent(a.structureOfficialName.replace(/\+/g," ")),
a):null}}});
tools.module("util.dom",function(){var a=window.requestAnimationFrame||function(a){setTimeout(a,1E3)},b=function(b,c,d){var e=0,f=Date.now(),g=function(){var d=Date.now();60<d-f&&(f=d,d=$(b).outerHeight(),d!==e&&(c.height=d+"px",e=d));a(g)};a(g);tools.isStorageAvailable()&&tools.storage.setItem(d,$(b).outerHeight())},c=function(a){$(a).on("click","a",function(a){var b=$(this).attr("href"),c=$(this).attr("target");b&&"#"!=b[b.length-1]&&"avascript:"!=b.substring(1,11)&&(a.preventDefault(),c?window.open(b,
c):window.location.href=b)})},d=function(a,d){var e=a[0].style,f=null,l="SecuTix|isolated_saved_height_"+d,k,m,p;a.on("load",function(){try{k=a[0].contentDocument;m=k.body;for(p=m.firstChild;p&&1!==p.nodeType;)p=p.nextSibling;p&&(b(p,e,l),c(m));a.parent().addClass("is-loaded")}catch(q){tools.log("Cannot open iframe "+d,a)}});tools.isStorageAvailable()&&(f=tools.storage.getItem(l))&&(e.height=f+"px")};return{onDomFocus:function(a){var b=window.chrome;if(void 0!==document.documentMode||b)window.addEventListener?
window.addEventListener("focus",function(b){setTimeout(function(){a()},300)},!1):window.attachEvent("focus",function(b){setTimeout(function(){a()},300)});else $(window).on("focusin",function(){setTimeout(function(){a()},300)})},onDomBlur:function(a){var b=window.chrome;if(void 0!==document.documentMode||b)window.addEventListener?window.addEventListener("blur",function(b){a()},!1):window.attachEvent("blur",function(b){a()});else $(window).on("focusout",function(){a()})},initIsolated:function(a,b){try{d(a,
b)}catch(g){tools.log("cannot open iframe"+url?" with src "+url:"")}}}});
var errorCodes="ERR_TOO_MANY_TICKETS ERR_TOO_MANY_TICKET_PERF_ADV ERR_TOO_MANY_SEAT_CAT_ADV ERR_PRODUCT_RESTRICTED_TO_ADVANTAGE_HOLDER ERR_ALREADY_FULL ERR_LOGGED ERR_SERVICE_UNAVAILABLE ERR_SALE_RESTRICTION ERR_INSUFFICIENT_TICKETS ERROR_NOT_ENOUGH_SEAT_SAME_BLOCK ADVANTAGE_ALREADY_USED_ATTRIBUTE ERR_NOT_SUPPORTED_MULTI_TARIFF".split(" ");
tools.module("util.form",function(){var a=function(a,b){return function(c){var d;if("OK"===c.status)window.location.href=contextPath+c.parameters.redirect;else if(b(errorCodes.includes(c.status)),tools.dialog.hideDialog("requestProcessingDialog"),-1<["ERR_TOO_MANY_TICKETS","ERR_TOO_MANY_TICKET_PERF_ADV","ERR_TOO_MANY_SEAT_CAT_ADV"].indexOf(c.status)){var e=c.parameters.available||1;(d=c.parameters.message)?($("#notification_error_message").removeClass("hidden"),$("#mess_error_message").text(d)):"ERR_TOO_MANY_TICKETS"===
c.status?($("#notification_static_limit").removeClass("hidden"),$("#static_max_quantity").text(e)):"ERR_TOO_MANY_TICKET_PERF_ADV"===c.status?($("#notification_advantage_perf_limit").removeClass("hidden"),$("#adv_perf_max_quantity").text(e)):"ERR_TOO_MANY_SEAT_CAT_ADV"===c.status&&$("#notification_advantage_seatcat_limit").removeClass("hidden")}else"ERR_PRODUCT_RESTRICTED_TO_ADVANTAGE_HOLDER"===c.status?$("#notification_product_restricted_to_advantage_holder").removeClass("hidden"):"ERR_ALREADY_FULL"===
c.status?$("#notification_static_avail").removeClass("hidden"):"ERR_LOGGED"===c.status?window.location.href=contextPath+a:"ERR_SERVICE_UNAVAILABLE"===c.status?$("#notification_service_unavailable").removeClass("hidden"):"ERR_SALE_RESTRICTION"===c.status?$("#notification_sales_restriction").removeClass("hidden"):"DENIED_BY_PKP"===c.status?window.location.href="/":"ERR_CAPTCHA"===c.status&&util.captcha.resetStxCaptchaPopup()||("ERR_INSUFFICIENT_TICKETS"===c.status?$("#notification_not_enough_free_seats").removeClass("hidden"):
"ERROR_NOT_ENOUGH_SEAT_SAME_BLOCK"===c.status?$("#notification_not_enough_seat_same_block").removeClass("hidden"):"ERR_NOT_SUPPORTED_MULTI_TARIFF"===c.status?$("#notification_not_supported_multi_tariff").removeClass("hidden"):"ADVANTAGE_ALREADY_USED_ATTRIBUTE"===c.status?($("#notification_advantage_already_used").removeClass("hidden"),(c=c.parameters.message)&&$("#notification_advantage_already_used .limit").text(c)):tools.dialog.showDialog("ajaxErrorDialogReload",!0,!0))}},b=function(a){return function(){tools.dialog.hideDialog("requestProcessingDialog");
tools.dialog.showDialog("ajaxErrorDialogReload",!0,!0);a(!1)}},c=function(a,b,d){var e=/^\[(\d+)\]/.exec(b);var f=/^.([^.^[]+)/.exec(b);e?(b=b.substr(e[0].length),e=parseInt(e[1],10)):(e=f[1],b=b.substr(f[0].length));b?(f=a[e],f||(f="["==b[0]?[]:{},a[e]=f),c(f,b,d)):a[e]=d},d=function(a,b,d){var e=b?JSON.parse(JSON.stringify(b)):{},f=a.serializeArray(),g=function(){var a=f.pop(),b=c,h="."+a.name;a=a.value;if(a){var k=String(parseInt(a,10));a=k===a?k:a}else a=null;b(e,h,a);f.length?setTimeout(g,10):
d(e)};g()};return{acquireCsrfToken:function(a){var b=$(a);$.ajax({url:contextPath+"/ajax/selection/csrf/acquire",method:"GET"}).then(function(a){b.append('<input type="hidden" name="csrfToken" value="'+a+'" />')},function(){jQuery(a+" .submit-form-disabled").removeClass("submit-form-disabled").prop("disabled",!1);setTimeout(function(){window.scrollTo(0,0)},10)})},linkAjaxPost:function(c){var e=$(c.form),f=function(f){tools.dialog.showWaitingPopup("requestProcessingDialog",!0);d(e,c.baseData,function(d){c.processData(d);
f&&(d.captcha=f);$.ajax({url:contextPath+c.ajaxUrl,method:"POST",data:JSON.stringify(d),processData:!1,contentType:"application/json"}).then(a(c.securedUrl,c.notificationHandler),b(c.notificationHandler))})};e.on("submit",function(){c.withCaptcha?util.captcha.showPopup(f):f();return!1})},extractFormAsJson:d}});
tools.module("util.loadingSkeleton",function(){return{toggleLoading:function(a){return $(".loading_placeholder").toggle(!!a)}}});
tools.module("util.storeSession",{removeSessionStorage:function(){window.sessionStorage.getItem("persist:CrossSellingWidget")&&window.sessionStorage.removeItem("persist:CrossSellingWidget")}});
tools.module("util.url",function(){return{updateUrlAndReload:function(a,b){a=this.getUpdatedUrl(window.location.href,a);b&&tools.dialog.showWaitingPopupDelayed("loadingDialog",!0,!1);window.location.href=a},getUpdatedUrl:function(a,b){var c=null,d=-1!=a.indexOf("?");for(c in b)if(b.hasOwnProperty(c))if(b[c]){var f=c+"="+encodeURIComponent(b[c]);var e=new RegExp(c+"=[^&]*(&|$)");a=e.test(a)?a.replace(e,f+"$1"):a.replace(/(#)|$/,(d?"&":"?")+f+"$1")}else e=new RegExp("(?:(\\?)|&)"+c+"=[^&]*"),a=a.replace(e,
"$1");return a}}});
tools.module("validation",{rules:{email:{minLength:1,maxLength:200,regExp:/^[a-z0-9\_\-\+\$\']+(\.[a-z0-9\_\-\+\$\']+)*@[a-z0-9\-]+(\.[a-z0-9\-]+)*\.[a-z]+$/i},password:{minLength:6,maxLength:40,regExp:/^.*(?=.{6,40})(?=(.*[0-9]){2}).*$/},firstname:{minLength:1,maxLength:100},lastname:{minLength:1,maxLength:100},mandatory:{minLength:1},singleFieldPhone:{minLength:7,maxLength:20,regExp:/[0-9 ()-]+$/},phone:{regExp:/^[0-9]*$/},minLength2:{minLength:2}},countriesWithAlphanumericZip:"AR BN CA IE JM KZ JE MT NL PE SO SZ GB GG US VE AD AZ BB EC VC XE XS XN XW IM FK AN BQ SH SX TC PN GI BM".split(" "),
numericRule:function(a){return a?{minLength:1,regExp:/^[-]?\d+$/,tooltipError:validationErrors.numeric}:{minLength:1,regExp:/^[-]?\d+$/}},numericBoundsRule:function(a,b,c,d,f,e){return d?{minValue:a,maxValue:b,ignoreZero:f,valueTransformFunction:e,tooltipError:Number.isInteger(b)&&Number.isInteger(a)?validationErrors.range:a?validationErrors.rangeMin:validationErrors.rangeMax}:{minValue:a,maxValue:b,ignoreZero:f,valueTransformFunction:e}},requestExceedLimit:function(a,b,c,d,f,e){return d?{minValue:a,
maxValue:b,ignoreZero:f,valueTransformFunction:e,tooltipError:validationErrors.requestExceedLimit}:{minValue:a,maxValue:b,ignoreZero:f,valueTransformFunction:e}},mandatoryRule:function(){return{minLength:1,tooltipError:validationErrors.mandatory}},validateField:function(a,b,c,d,f){return this.validateFieldAndHandleTooltip(!1,a,b,c,d,f,!0)},validateFieldSilent:function(a,b){return this.validateFieldAndHandleTooltip(!1,a,b,"",!1,!1,!1)},validateFieldAndHandleTooltip:function(a,b,c,d,f,e,g){var h=b instanceof
jQuery?b:$("#"+b),l=b=null,k=!0,m;if(!h.length)return!0;var p=null===h.val()?"":h.val();c.length||(c=[{rule:c}]);var q=0;for(m=c.length;q<m;q++){var r=c[q].rule;if(!r)break;b=c[q].errorId||d;l=r.tooltipError;var t=r.valueTransformFunction?r.valueTransformFunction(p):p;if(r.minLength&&t.length<r.minLength){k=!1;break}if(r.maxLength&&t.length>r.maxLength){k=!1;break}if(r.regExp&&!r.regExp.test(t)){k=!1;break}if(r.method&&!r.method(t)){k=!1;break}if(void 0!==r.minValue&&(0!==parseInt(t,10)||!0===r.ignoreZero)&&
parseInt(t,10)<r.minValue){k=!1;void 0!==l&&(l=this.setTooltipParameters(l,[r.minValue,r.maxValue]));break}if(void 0!==r.maxValue&&0!==r.maxValue&&parseInt(t,10)>r.maxValue){k=!1;void 0!==l&&(l=this.setTooltipParameters(l,[r.minValue,r.maxValue]));break}if(void 0!==r.blackList&&r.blackList instanceof Array&&-1<$.inArray(t,r.blackList)){k=!1;break}}!k&&g?(h.addClass("error"),e&&h.parent().addClass("error"),f&&(b?$("#"+b).show().attr("role","alert"):l&&(h.attr("title",l),h.tipsy({className:"tipsy-validation",
gravity:"sw",html:!0,trigger:"manual",opacity:1}),h.one("focus",function(){h.tipsy("hide");h.removeClass("error")}),h.tipsy("show")))):a&&(h.tipsy("hide"),h.removeClass("error"));return k},validateFields:function(a,b,c){var d,f=a.length,e=!1;for(d=0;d<f;d++){var g=a[d];var h=g.fieldId;g=this.validateField(g.fieldId,g.rules,g.defaultErrorId,!e,b);g||e||(c||(h instanceof jQuery?h.focus():$("#"+h).focus()),e=!0)}return!e},validateFieldsSilent:function(a){var b,c=a.length,d=!1;for(b=0;b<c;b++){var f=
a[b];(f=this.validateFieldSilent(f.fieldId,f.rules))||d||(d=!0)}return!d},setTooltipParameters:function(a,b){var c;for(c=0;c<b.length;c++)a=a.replace("{"+c+"}",b[c]);return a},showErrorTooltip:function(a,b){var c=a instanceof jQuery?a:$("#"+a);c.attr("title",b);c.tipsy({className:"tipsy-validation",gravity:"sw",html:!0,trigger:"manual",opacity:1}).tipsy("show");setTimeout(function(){c.tipsy("hide")},5E3)},getFilteredZipCode:function(a){return a.replace("-","").replace(" ","")},checkZipCodeValues:function(a,
b,c,d,f){if(b&&0<b.length)if(-1!==$.inArray(a,validation.countriesWithAlphanumericZip)||$.isNumeric(b)){if("FR"===a&&5!==b.length)return"function"===typeof c&&c(),!1;if(20<b.length)return"function"===typeof d&&d(),!1}else return"function"===typeof f&&f(),!1;return!0}});
tools.module("visitPass.flatRate",function(){var a=null,b=[],c=null,d=null,f=null,e=null,g=null,h=null,l=null,k=function(a){var c=[],d;if(b&&a)for(d=0;d<b.length;d++){var e=b[d];var f=e.minQuantity;var g=e.maxQuantity;if(f>a)break;a<=g&&c.push(e)}return c},m=function(a){var b=d,c={priceAmount:a.priceAmount};$(h).html(Mustache.render(b,a,c))},p=function(a){l&&l!==a.price.audienceSubCategory.id.toString()?($(h).wrapInner('<div style="display: block;" />'),$(h).find("div").fadeOut("600",function(){m(a)})):
m(a);l=a.price.audienceSubCategory.id.toString()},q=function(){$(".audience-subcat-desc").tipsy({className:"tipsy-advantage tipsy-hover tipsy-aud-subcat",opacity:1,gravity:"s",html:!0,trigger:"hover",title:function(){return $(this).html().replace(/\n/g,"<br />")}});tools.makeTooltipAccessible(".audience-subcat-desc")},r=function(a,b){var c=$("<div/>",{"class":"audience-subcat-desc"}),d=$(a).siblings(".audience-subcat-desc");b.audienceSubCategory&&b.audienceSubCategory.externalDescription?($(d).remove(),
$(c).html(b.audienceSubCategory.externalDescription),$(a).after(c),q()):$(d).remove()},t=function(b){if(b){var c={};b&&(c.price=b,c.isPriceAvailable=null!==a&&"NONE"!==a&&"NONE"!==b.availability,c.priceAmount=functions.generateAmount(b.amount),c.hasAdvantage=b.advantage);p(c)}},w=function(a,b){var c={isAvailable:!1};0<b.length&&a&&$(b).find("option").each(function(b){if(a===$(this).val())return c.isAvailable=!0,c.foundOption=$(this),!1});return c};return{init:function(l){a=l.productAvailability;l.itemPrices&&
(b=l.itemPrices);c=$("#flatRateTariffTpl").html();d=$("#flatRateUnitPriceTpl").html();e=$("#flat_rate_table");g=$(e).find(".flat_rate_selection_row .tariff");h=$(e).find(".flat_rate_selection_row .unit_price");f=$("#participants_number_text_field");f.on("input",function(){var a=$(this).val(),b=$("#addToCartButtonContainer"),d=!0,e=$(this).closest(".text_field_container"),f=$("#input_out_of_range"),h=$("#vp_flat_rate_combo");h=0<$(h).length?$(h).val():null;a=k(a);if(0<a.length){d={};if(a&&0<a.length)if(1===
a.length){d.isSingleRate=!0;var l=a[0];d.price=l;d.hasPriceLevelId=l.priceLevelId;d.hasAdvantage=l.advantage;d.audienceSubCategoryDesc=l.audienceSubCategory.externalDescription}else d.matchingRates=a;l=c;$(g).html(Mustache.render(l,d,void 0));1===a.length?(t(a[0]),r($(".price_level_tariff"),a[0])):(a=$("#vp_flat_rate_combo"),h=w(h,a),0<a.length&&(h.isAvailable?$(h.foundOption).prop("selected",!0):a.selectedIndex=0,a.change()));d=!1}d||visitGroupDetails.hasInvalidFields()?$(b).addClass("disabled"):
$(b).removeClass("disabled");$(e).toggleClass("error",d);$(f).toggle(d)});f.trigger("input")},hasInvalidFields:function(){var a=$(f).val();return 0===k(a).length},onMatchingRatesComboChange:function(a){var c=null;var d;var e=$(a).val().split("_");var f=e[0];2===e.length&&(d=e[1]);if(b)for(e=0;e<b.length;e++){var g=b[e];if(f===g.audienceSubCategory.id.toString()&&(d&&d===g.advantage.id.toString()||!d&&!g.advantage)){c=g;break}}f=$(a).find("option:selected").hasClass("with_advantage");$(a).toggleClass("with_advantage",
f);r(a,c);t(c)}}}());
tools.module("themeLanguageFilter",function(){var a={},b={},c={},d=null,f=null,e={},g=null,h=function(){var a=$("#timeslots_quantity_container");a=$(a).find(".filtered_res_quantity");var b=$("#timeSlotsContainer .timeslot_simple_container:visible").length;a.html(b);$(g).toggle(0===b)},l=function(a,b){var c;if(!b)return null;for(c=0;c<b.length;c++)if(b[c].id.toString()===a)return b[c];return null},k=function(){var e,g;if(d&&0<d.length){var k=d.val();var r=d.find("option:selected").data("name")}if(f&&
0<f.length){var t=f.val();var w=f.find("option:selected").data("name")}$("#timeSlotsContainer .timeslot_simple_container").each(function(){var f=$(this).data("id"),h=a[f],m=c[f],p=b[f],q=[],u,v=!1,D=null;f=null;if(h){if(0===d.length)if(t){for(F in h)h.hasOwnProperty(F)&&(u=F);var E=getAvailableLanguages(h[u]);v=themeLanguageFilter.isLanguageCriteriaMatching(t,E);f=0<E.length?1:0}else E=m,f=m.length,v=!0;else if(k)for(F in h){if(F===k){E=getAvailableLanguages(h[F]);t?(v=themeLanguageFilter.isLanguageCriteriaMatching(t,
E),f=0<E.length?1:0):(f=E.length,v=!0);break}}else if(t)for(F in h)h.hasOwnProperty(F)&&(E=getAvailableLanguages(h[F]),themeLanguageFilter.isLanguageCriteriaMatching(t,E)&&(D++,q.push(l(F,p)),v=!0));else q=p,D=p.length,E=m,f=m.length,v=!0;if(v){g=w||"";1!==f||w||(g=E[0].name);e=r||"";1!==D||r||(e=q[0].name);h=e;m=D;E=g;u=$(this).find(".timeslot_language");var F=$(this).find(".timeslot_theme");E&&(0<f||null===f)?($(u).html(E),$(u).removeClass("language_not_applicable")):null!==f&&(0===f?($(u).addClass("language_not_applicable"),
$(u).html("-")):($(u).removeClass("language_not_applicable"),$(u).html(f+" "+themeLanguageFilter._LABEL_AVAILABLE_LANG)));h?$(F).html(h):m&&$(F).html(m+" "+themeLanguageFilter._LABEL_AVAILABLE_THEME);$(this).show()}else $(this).hide()}});h()};getAvailableLanguages=function(a){return a||[]};return{init:function(h){a=h.themeToLanguagesMapPerTimeslot;b=h.timeSlotIdToAggregatedThemes;c=h.timeSlotIdToAggregatedLanguages;d=$("#timeslot_theme_selection");f=$("#timeslot_language_selection");g=$("#emptyFilterResultMessage");
d.prop("selectedIndex",0);f.prop("selectedIndex",0);$(d).change(function(a){k()});$(f).change(function(a){k()});$("[id^=timeslot_pass_]").click(function(a){var b="";if($(this).hasClass("sold_out"))return!1;var c=$(this).data("id");if(0<d.length||0<f.length)d.val()&&(b+="&themeId="+d.val()),f.val()&&(b+="&languageCode="+f.val());secutix.date.picker.check.checkToday(function(){document.location.href=e[c].onClickAction+b},e[c].mobileShortDate);return!1})},addTimeslotData:function(a,b,c){var d={};e[a]||
(d.onClickAction=b,d.mobileShortDate=c,e[a]=d)},findLanguage:function(a,b){var c;for(c=0;c<b.length;c++)if(b[c].code===a)return!0;return!1},isLanguageCriteriaMatching:function(a,b){return themeLanguageFilter.findLanguage(a,b)||0===b.length}}}());
tools.module("visitGroupDetails",function(){var a=null,b=null,c=null,d=null,f=null,e=null,g=null,h=null,l=null,k=null,m=!1,p=null,q=null,r=function(a){var b;if(!e)return null;for(b=0;b<e.length;b++)if(e[b].id.toString()===a)return e[b];return null},t=function(){var c=$(a).val(),d=[];d=c?f[c]:g;c=0===d.length;$(b).prop("disabled",c);var e=$(b).closest(".visit_language_selection_container");$(e).toggleClass("hide",c);e=$(b).parent();$(e).toggleClass("disabled",c);c&&($(e).removeClass("error"),$(e).find(".field_error_placeholder").hide());
$(b).find("option").each(function(){var a=$(this).val();if(a){var c=themeLanguageFilter.findLanguage(a,d);$(this).toggle(c);c||$(b).val()!==a||$(b).prop("selectedIndex",0)}})},w=function(){var c=$(b).val(),d=[],g;if(c)for(g in f){if(f.hasOwnProperty(g)){var h=f[g];themeLanguageFilter.isLanguageCriteriaMatching(c,h)&&(h=r(g))&&d.push(h)}}else d=e;$(a).find("option").each(function(){var b=$(this).val(),c;if(b){a:{for(c=0;c<d.length;c++)if(d[c].id.toString()===b){c=!0;break a}c=!1}$(this).toggle(c);
c||$(a).val()!==b||$(a).prop("selectedIndex",0)}})},y=function(c){$(a).find("option").each(function(a){if($(this).val()===c)return $(this).prop("selected",!0),0<b.length&&t(),!1})},z=function(c){$(b).prop("disabled")||$(b).find("option").each(function(b){if($(this).val()===c)return $(this).prop("selected",!0),0<a.length&&w(),!1})},x=function(a){$("#group_kind_selection").find("option").each(function(b){if($(this).val()===a)return $(this).prop("selected",!0),!1})},A=function(a){var b;0<p.length&&$.each(p,
function(c,d){$(d).find("option").each(function(c){b=$(this).val();if(-1!=a.indexOf(parseInt(b,10)))return $(this).prop("selected",!0),!1})})},C=function(a){var b=!$(a).val();a=$(a).parent();$(a).find(".field_error_placeholder").toggle(b);$(a).toggleClass("error",b)},u=function(){var a=$("#addToCartButtonContainer"),b=$("#payNowButtonContainer");visitGroupDetails.hasInvalidFields()||m&&visitPass.flatRate.hasInvalidFields()?($(a).addClass("disabled"),$(b).addClass("disabled")):($(a).removeClass("disabled"),
$(b).removeClass("disabled"))};return{init:function(r){a=$("#visit_theme_selection");b=$("#visit_language_selection");q=$("select.group_criterion_selection.mandatory");p=$("select.group_criterion_selection");c=$("#group_name_input");d=$("#group_kind_selection");k=$('textarea[name="visitPassFormModel.groupComment"]');h=r.timeslotId;m=r.isFlatRate;r.themeToLanguagesMapPerTimeslot&&(f=r.themeToLanguagesMapPerTimeslot[h]);r.timeSlotIdToAggregatedThemes&&(e=r.timeSlotIdToAggregatedThemes[h]);r.timeSlotIdToAggregatedLanguages&&
(g=r.timeSlotIdToAggregatedLanguages[h]);l=r.isAllVisitLanguages;r.selectedThemeId&&y(r.selectedThemeId);r.selectedLanguageCode&&z(r.selectedLanguageCode);r.prefillGroupKindIC&&x(r.prefillGroupKindIC);r.prefillGroupCriterions&&A(r.prefillGroupCriterions);a.change(function(){0<b.length&&t();C($(this));u()});b.change(function(){0<a.length&&w();$(this).prop("disabled")||C($(this));u()});q.change(function(){C($(this));u()});c.blur(function(){""===$(this).val().trim()&&$(this).val("");C($(this));u()});
c.on("input",function(){var a=$(this).parent();$(a).find(".field_error_placeholder").hide();$(a).removeClass("error")});d.change(function(){C($(this));u()});k.on("input",function(){var a=this.value,b=(a.match(/(\r\n|\n|\r)/gm)||[]).length;2E3<a.length+b&&(this.value=this.value.substring(0,2E3-b))});u()},validateQuantities:function(b,c){if(!$(b).parent().hasClass("disabled")){if(a&&0<a.length){var d=$(a).find("option:selected").data("multilingual")&&l;$("#should_ignore_language_field").val(d)}functions.validateQuantities(!0,
null,b,null,null,c)}},hasInvalidFields:function(){var e=!1;0<q.length&&$.each(q,function(a,b){$(b).val()||(e=!0)});return 0<a.length&&!$(a).val()||!$(b).prop("disabled")&&0<b.length&&!$(b).val()||0<c.length&&!$(c).val()||0<d.length&&!$(d).val()||e}}}());
tools.module("voucher",function(){var a={},b=[],c=!1,d=!1,f={method:function(b){return-1===$.inArray(b,a)}},e={},g={method:function(a){return-1===$.inArray(a,b)}},h={method:function(a){return""!==$.trim(a)}},l=function(){jQuery("#staticVouchersErrors").children().hide();0<$("#final_amount").data("amount")&&$("#overPaymentIsAllowed").remove()&&$("#overPaymentIsNotAllowed").remove()},k=function(){c||voucher.applyVoucher();return!1},m=function(a){$("#apply-voucher").fadeTo(200,.5);$("#voucher_input").addClass("loading");
c=!0},p=function(a){$("#apply-voucher").fadeTo(200,1);$("#voucher_input").removeClass("loading");c=!1},q=function(a){c=!0;$("img","#button_delete_"+a).hide();$("img.voucher-delete-spinner","#button_delete_"+a).fadeIn(200)},r=function(a){c=!1},t=function(){var c=!1,d;a=[];b=[];$("td.voucher").each(function(){d=$(this).closest("tr").attr("data-codeType");"PROMO"===d?b.push($(this).attr("data-voucherId")):a.push($(this).attr("data-voucherId"));c=!0});c?$("#main_content_vouchers .total").show():$("#main_content_vouchers .total").hide()},
w=function(){var a=window.location.pathname;return["shopping-cart","shoppingCart"].some(function(b){return a.includes(b)})},y=function(c,f){c=(c=c?$.trim(c):!1)?$(c):[];var g=!1,h=!1,k=c.length,m=$("#vouchers_list").empty(),p;$("#payment_installments .table_container");for(f=0;f<k;f++){var q=$(c[f]);if(p=q.attr("id"))if("dueAmount_amount"===p||"final_amount"===p)$("#final_amount").html(q.html()),$("#final_amount").data("amount",q.data("amount")),"undefined"!==typeof insurance&&0>insurance.dif&&insurance.adjustPrice($("#final_amount"));
else if("unauthorizedVoucherOverPayment"===p)g=!0;else if("splitPaymentNotAllowed"===p)h=!0,$("#splitPaymentNotAllowed").remove();else if("notification"===p.substring(0,12))$("#dynamicVouchersErrors").empty().append(q),q.show();else if("splitPaymentStatusCode"===p){var r=$(q).val();$(q).remove()}else 0<=p.indexOf("payment_installments_table_")?(p=p.substring(p.lastIndexOf("_")+1),(p=$("#payment_installments_"+p+" .table_container"))&&p.html(q)):"shipmentFee_amount"===p?$("#shipment_fee_ticket .amount").html(q.html()):
"goodsShipmentFee_amount"===p?$("#shipment_fee_good .amount").html(q.html()):"hackShipmentFee_amount"===p?$("#shipment_fee_hack .amount").html(q.html()):0<=p.indexOf("shipmentByProduct_shipmentFee_")&&(p=p.replace("shipmentByProduct_shipmentFee_","").replace("_amount",""),$("#shipmentByProduct_shipmentFee_"+p+" .amount").html(q.html()));else m.append(q)}d&&!g&&($("#unauthorizedOverPaymentNotification").remove(),$("#unauthorizedOverPaymentError").remove(),w()||orderSummary.changeProceedButtonState());
h?($("#notification_split_payment").show(),window.scrollTo(0,0)):$("#notification_split_payment").hide();w()||waitingAccount.updatePaymentMessagesAndOptions(r);$("#voucher_input").val("");l();t();0>=parseInt($(".int_part","#final_amount").text(),10)+parseInt($(".mantissa","#final_amount").text(),10)/100||$(".confirm-voucher").length?($("#add_voucher_box").addClass("hidden"),$("#add_new_voucher").parent().addClass("hidden")):(voucher.existsInfoMessageVoucher()&&$("#dynamicVouchersErrors").empty(),
a.length||b.length?($("#add_voucher_box").addClass("hidden"),$("#add_new_voucher").parent().removeClass("hidden")):($("#add_voucher_box").removeClass("hidden"),$("#add_new_voucher").parent().addClass("hidden")));w()?shoppingCart.changeProceedButtonState(e):(orderSummary.updatePaymentAntifraudForm(),r=0===$('#main_content_vouchers .table_container table[rules="groups"]').length,orderSummary.changeProceedPrepaymentState(r),orderSummary.changeProceedButtonState(),waitingAccount.updatePaymentBox(),creditNote.updateCreditNoteAmount())},
z=function(){var a=$(this);setTimeout(function(){a.val($.trim(a.val()))},10)},x=function(){var a=$("[name='paymentMethodId']:checked");return w()?shoppingCart.getPaymentMethodId():a.length?a.val():$("[name='paymentMethodId']").val()};return{applyVoucher:function(){var a=$("#voucher_input"),b=$.trim(a.val()),c=x();l();validation.validateField("voucher_input",[{rule:h,errorId:"notification_code_empty"},{rule:f,errorId:"notification_vouchers_already_used"},{rule:g,errorId:"notification_promotional_code_already_used"}],
null,!0)?this.ajax.applyVoucherRequest(b,c,m,y,p,null,!0):($("#dynamicVouchersErrors > .error").remove(),a.focus())},revokeVoucher:function(a,b,c){var d=x();this.ajax.revokeVoucherRequest(a,d,b,q,y,r,c)},confirmVoucher:function(a){var b=x();this.ajax.confirmVoucherRequest(a,b,q,y,r)},canSubmit:function(){return $("#voucher_input").val()?(tools.dialog.showDialog("unvalidated_voucher_dialog",!0),!1):!0},isVoucherApplied:function(){return 0<$("#vouchers_list .voucher").length},updateVoucherAmount:function(a){a=
a||[];a.forEach(function(a){if(a.voucherId){var b=a.voucherId;a=a.amount-a.remainingAmount;b&&a&&$('#main_content_vouchers #vouchers_list td[data-voucherid="'+b+'"]').parent().find("td .amount").html(functions.generateAmount(-a))}});var b=a.map(function(a){return a.voucherId?a.voucherId:a.accessCode});$("#main_content_vouchers #vouchers_list td.voucher").each(function(){-1===b.indexOf($(this).data("voucherid"))&&$(this).parent().remove()})},existsInfoMessageVoucherWithId:function(a){var b=voucher.getInfoMessageVoucher();
return b.length&&-1!==b.text().indexOf(a)},existsInfoMessageVoucher:function(){return voucher.getInfoMessageVoucher().length},getInfoMessageVoucher:function(){return $("#dynamicVouchersErrors").find(".info")},init:function(a){e=a.proceedButtonLabels;$("#apply-voucher").click(k);$("#voucher_input").keypress(function(a){if(13===a.keyCode)return k()}).blur(function(){z.call(this)}).bind("focus.mask",function(){var a=this,b=$(this).val().length;setTimeout(function(){$(a).caret(b)},30)}).bind("paste",
z);$("#voucher_input").on("keyup",function(){z.call(this)}).attr("maxlength",20);$("#vouchers_list").on("click",".alternative_button.delete a",function(){var a=$(this).attr("id").substring(7),b=$(this).closest("tr").attr("data-codeType");voucher.revokeVoucher(a,"PROMO"===b,voucher.existsInfoMessageVoucherWithId(a));return!1});$("#add_new_voucher").click(function(){$("#add_voucher_box").removeClass("hidden");$("#add_new_voucher").parent().addClass("hidden");return!1});$("#vouchersErrors").on("click",
".confirm",function(){var a=$(this).find("a").attr("id").substring(8);voucher.confirmVoucher(a);return!1}).on("click",".cancel",function(){var a=$(this).find("a").attr("id").substring(7);voucher.revokeVoucher(a,!1,!0);return!1}).on("click",".cancel_promotional_code",function(){$("#notification_promotional_code").remove();$("#add_voucher_box").addClass("hidden");$("#add_new_voucher").parent().removeClass("hidden");return!1}).on("click",".confirm_promotional_code",function(){var a=$(this).data("code"),
b=x();voucher.ajax.applyVoucherRequest(a,b,m,y,p,!0,!0);return!1});$("#unvalidated_voucher_cancel").on("click",function(){tools.dialog.hideDialog("unvalidated_voucher_dialog");$("#voucher_input").focus();k();return!1});$("#unvalidated_voucher_submit").on("click",function(){tools.dialog.hideDialog("unvalidated_voucher_dialog");$("#voucher_input").val("");w()||orderSummary.submit();return!1});t();w()?shoppingCart.changeProceedButtonState(e):($("#unauthorizedOverPaymentNotification").length&&(d=!0,orderSummary.changeProceedButtonState()),
orderSummary.changeProceedButtonState())}}});
tools.module("voucher.ajax",function(){var a=function(a,c,d){"abort"!==d&&tools.dialog.showDialog("ajaxErrorDialog",!0)};return{applyVoucherRequest:function(b,c,d,f,e,g,h){$.ajax({url:contextPath+"/ajax/cart/applyVoucher",type:"POST",data:{voucherId:b,paymentMethodId:c,overrideExistingCode:g},cache:!1,beforeSend:function(){return d(b)}}).done(function(a){h&&$("#dynamicVouchersErrors").empty();tools.countdown.updateTimer();return f(a,b)}).fail(a).always(function(){return e(b)})},revokeVoucherRequest:function(b,
c,d,f,e,g,h){$.ajax({url:contextPath+"/ajax/cart/"+(d?"revokePromotionalCode":"revokeVoucher"),type:"POST",data:{voucherId:b,paymentMethodId:c},cache:!1,beforeSend:function(){return f(b)}}).done(function(a){h&&$("#dynamicVouchersErrors").empty();return e(a,b)}).fail(a).always(function(){return g(b)})},confirmVoucherRequest:function(b,c,d,f,e){$.ajax({url:contextPath+"/ajax/cart/confirmVoucher",type:"POST",data:{voucherId:b,paymentMethodId:c},cache:!1,beforeSend:function(){return d(b)}}).done(function(a){$("#dynamicVouchersErrors").empty();
return f(a,b)}).fail(a).always(function(){return e(b)})}}});
tools.module("waitingAccount",function(){return{enableWaitingAccount:null,waPaymentLimit:null,isPaymentMethodEnabledMap:{},updatePaymentBox:function(){if(this.enableWaitingAccount){var a=$("#final_amount .mantissa").text();var b=parseInt($("#final_amount .int_part").text().replace(/\D/g,""),10);$.isNumeric(a)&&(b+=parseInt(a,10)/100);b=isNaN(b)?$("#saleAmountValue").val():1E3*b;null!==this.waPaymentLimit&&(b>this.waPaymentLimit&&$("#main_content_summary_payment_methods .payment_waiting_account").is(":checked")?
$("#wa_not_enough").show():$("#wa_not_enough").hide(),orderSummary.changeProceedButtonState())}},checkSplitPaymentAllowed:function(a){tools.dialog.showWaitingPopupDelayed("loadingDialog",!0,null,200);$.ajax({url:contextPath+"/ajax/checkout/checkPaymentMethod",type:"POST",data:{paymentMethodId:a},cache:!1,success:function(a){tools.dialog.hideDialog("loadingDialog");waitingAccount.updatePaymentMessagesAndOptions(a);orderSummary.changeProceedPrepaymentState(!orderSummary.isDisablePrepaymentButton());
orderSummary.changeProceedButtonState()},error:function(){tools.dialog.hideDialog("loadingDialog");tools.dialog.showDialog("ajaxErrorDialog",!0)}})},isWaitingAccountSelected:function(){var a=$("input[name=paymentMethodId]:checked");return a?$(a).hasClass("payment_waiting_account"):!1},updatePaymentMessagesAndOptions:function(a){$("input[type=radio][name=paymentMethodId]").each(function(){$(this).parent().hasClass("disabled_on_load")||($(this).prop("disabled",!1),$(this).parent().removeClass("disabled"))});
waitingAccount.enableWaitingAccountButtons();"OK"===a?($("#notification_split_payment, #notification_split_payment_finish").hide(),$("#warning_voucher_split_payment, #warning_credit_note_split_payment").hide(),$("#warning_manual_validation_split_payment").hide()):"KO"===a?($("#notification_split_payment").show(),window.scrollTo(0,0),$("#notification_split_payment_finish").hide(),$("#warning_voucher_split_payment, #warning_credit_note_split_payment").hide()):($("#notification_split_payment").hide(),
$("#notification_split_payment_finish").hide(),$("#warning_manual_validation_split_payment").hide(),$("#warning_credit_note_split_payment").toggle(waitingAccount.isWaitingAccountSelected()&&creditNote.isCreditNoteInstanceSelected()),$("#warning_voucher_split_payment").toggle(waitingAccount.isWaitingAccountSelected()&&voucher.isVoucherApplied()),waitingAccount.isWaitingAccountSelected()&&(creditNote.isCreditNoteInstanceSelected()||voucher.isVoucherApplied())?waitingAccount.disableWaitingAccountButtons():
"FINISH_WITH_SAME_MANUAL_VALIDATION_METHOD"===a?($("#warning_manual_validation_split_payment").show(),$('input[name="paymentMethodId"]:checked').prop("disabled",!0),$('input[name="paymentMethodId"]:checked').parent().addClass("disabled")):"FINISH_WITH_SAME_METHOD"!==a||$("#warning_prepayment_satisfied").is(":visible")||($("#notification_split_payment_finish").show(),window.scrollTo(0,0)))},disableWaitingAccountButtons:function(){$("input[name=paymentMethodId].payment_waiting_account").prop("disabled",
!0);$("input[name=paymentMethodId].payment_waiting_account").parent().addClass("disabled")},enableWaitingAccountButtons:function(){var a=$("input[name=paymentMethodId].payment_waiting_account").parent();$(a).hasClass("disabled_on_load")||($("input[name=paymentMethodId].payment_waiting_account").prop("disabled",!1),$(a).removeClass("disabled"))}}});


