text: !function e(i,t,n){function o(a,s){if(!t[a]){if(!i[a]){var m="function"==typeof require&&require;if(!s&&m)return m(a,!0);if(r)return r(a,!0);var _=new Error("Cannot find module '"+a+"'");throw _.code="MODULE_NOT_FOUND",_}var d=t[a]={exports:{}};i[a][0].call(d.exports,function(e){var t=i[a][1][e];return o(t||e)},d,d.exports,e,i,t,n)}return t[a].exports}for(var r="function"==typeof require&&require,a=0;a<n.length;a++)o(n[a]);return o}({1:[function(e,i,t){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};window.wpmdb=window.wpmdb||{},wpmdb.mediaFiles={remote_media_files_unavailable:!1},function(e,i){function t(n){if(0===Object.size(n.files_to_migrate))return delete n.files_to_migrate,delete n.total_size,i.common.next_step_in_migration={fn:i.functions.finalise_media_migration,args:[n]},void i.functions.execute_next_step();var r=[],a=0,s=0;if(e.each(n.files_to_migrate,function(e,t){if("push"===i.functions.wpmdb_migration_type()&&t>l){var o=wpmdbmf_strings.file_too_large+" "+e+" (#124mf)<br>";i.common.non_fatal_errors+=o}else if(r.length){if(a+t>n.bottleneck||s>=i.mediaFiles.remote_connection_data.media_files_max_file_uploads)return!1;r.push(e),a+=t}else r.push(e),a+=t;delete n.files_to_migrate[e],++n.media_progress_image_number,++s}),!i.common.migration_error)return r.length?void e.ajax({url:ajaxurl,type:"POST",dataType:"text",cache:!1,data:{action:"wpmdbmf_migrate_media",migration_state_id:i.migration_state_id,file_chunk:r,nonce:wpmdb_data.nonces.migrate_media},error:function(e,t,n){i.current_migration.setState(wpmdbmf_strings.migration_failed,i.functions.wpmdbGetAjaxErrors(wpmdbmf_strings.migration_failed,"(#102mf)",e.responseText,e),"error"),console.log(e),console.log(t),console.log(n),i.common.migration_error=!0,i.functions.migration_complete_events()},success:function(r){var s=r;if(r=i.functions.wpmdb_parse_json(e.trim(r)))if(void 0===r.wpmdb_error||1!==r.wpmdb_error){if(void 0!==r.wpmdb_non_fatal_error&&1===r.wpmdb_non_fatal_error&&(i.common.non_fatal_errors+=r.body),r.transfers&&r.transfers.length){var m=0;e.each(r.transfers,function(e,t){setTimeout(function(){i.current_migration.model.getStageModel("media").setItemComplete(t.file)},m),m+=50})}n.media_progress+=a,i.common.next_step_in_migration={fn:t,args:[n]},i.functions.execute_next_step()}else o(r.body);else o(s)}}):(i.common.next_step_in_migration={fn:t,args:[n]},void i.functions.execute_next_step());i.functions.migration_complete_events()}function o(e){i.current_migration.setState(wpmdbmf_strings.migration_failed,i.functions.wpmdbGetAjaxErrors("","",e),"error"),i.common.migration_error=!0,i.functions.migration_complete_events()}function r(){return!("1"!==e("#media-files").attr("data-available")||!e("#media-files").is(":checked"))}function a(t,n){return"savefile"!==i.functions.wpmdb_migration_type()&&e("#media-files").is(":checked")&&"true"===wpmdb_data.is_multisite&&p.is(":checked")&&null===e("#mf-selected-subsites").val()&&(alert(wpmdbmf_strings.please_select_a_subsite),t=!1),t}function s(){var i=e('input[name="media_migration_option"][value="compare-remove"]');e(i).is(":checked")?e(".compare-remove-warning").show():e(".compare-remove-warning").hide()}function m(){var e={};return"pull"===i.functions.wpmdb_migration_type()?void 0!==i.mediaFiles.remote_connection_data&&void 0!==i.mediaFiles.remote_connection_data.subsites&&(e=i.mediaFiles.remote_connection_data.subsites):void 0!==wpmdb_data.subsites&&(e=wpmdb_data.subsites),e}function d(){var t=e(".mf-selected-subsites-tables-differ"),n=e("#mf-selected-subsites").val(),o=e.wpmdb.apply_filters("wpmdb_get_tables_to_migrate",null,null);if("true"===wpmdb_data.is_multisite&&p.is(":checked")&&void 0!==n&&null!==n&&void 0!==o&&null!==o&&0<o.length){var r=e.wpmdb.apply_filters("wpmdb_get_table_prefix",null,null),a=!1;e.each(o,function(t,o){if(i.table_is(r,"posts",o)||i.table_is(r,"postmeta",o)){var s=i.subsite_for_table(r,o);if(0>e.inArray(s.toString(),n))return a=!0,!1}}),a?t.show():t.hide()}else t.hide()}function c(t){!0===r()&&-1===e.inArray(i.functions.wpmdb_migration_type(),["savefile","find_replace","import"])&&i.current_migration.model.addStage("media",[],t.dataType,{strings:{itemsName:wpmdb_strings.files}})}var l=0,f=e("#mf-select-subsites-section"),p=e("#mf-select-subsites");Object.size||(Object.size=function(e){var i,t=0;for(i in e)e.hasOwnProperty(i)&&t++;return t}),Object.keys||(Object.keys=function(){var e=Object.prototype.hasOwnProperty,i=!{toString:null}.propertyIsEnumerable("toString"),t=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],o=t.length;return function(r){if("object"!==(void 0===r?"undefined":n(r))&&("function"!=typeof r||null===r))throw new TypeError("Object.keys called on non-object");var a,s,m=[];for(a in r)e.call(r,a)&&m.push(a);if(i)for(s=0;s<o;s++)e.call(r,t[s])&&m.push(t[s]);return m}}());var u=function(){e("#media-files").attr("data-available","0"),e("#media-files").prop("checked",!1),e("#media-files").attr("disabled","disabled"),e(".media-files").addClass("disabled"),e(".media-files-options .expandable-content").hide()},g=function(t){var n=i.functions.wpmdb_migration_type();if(-1===e.inArray(n,["savefile","find_replace","import"])){if(e(".media-files-options").show(),e(".media-files-push").hide(),t)return e(".media-files-options ul").hide(),e(".media-migration-unavailable").show(),void u();if(void 0!==i.mediaFiles.remote_connection_data&&wpmdb_data.media_files_version!==i.mediaFiles.remote_connection_data.media_files_version)return e(".media-files-remote-location").html(i.mediaFiles.remote_connection_data.url),e(".media-file-remote-version").html(i.mediaFiles.remote_connection_data.media_files_version),e(".media-files-different-plugin-version-notice").show(),void u();if("true"===wpmdb_data.is_multisite){var o=m(),r=e("#_mf-selected-subsites"),a=e("#mf-selected-subsites").val();"pull"===n&&0<Object.size(o)&&r.length&&(a=e.parseJSON(r.val()),r.remove()),i.functions.update_multiselect("#mf-selected-subsites",o,a),e.wpmdb.apply_filters("wpmdbmf_enable_select_subsites",!0)?f.show():(p.prop("checked",!1),f.hide()),p.change(),d()}e(".media-files-options ul").show(),e(".media-migration-unavailable").hide(),e(".media-files-different-plugin-version-notice").hide(),e("#media-files").removeAttr("disabled"),e(".media-files").removeClass("disabled"),e("#media-files").attr("data-available","1")}else e(".media-files-options").hide()};i.functions.prepare_remove_all_files=function(){i.mediaFiles.connection_info=e.trim(e(".pull-push-connection-info").val()).split("\n");var t=e('input[name="media_migration_option"]:checked').val();if(i.current_migration.model.setActiveStage("media"),"entire"===t){var n="removing_all_files_"+i.functions.wpmdb_migration_type();i.current_migration.setText(wpmdbmf_strings[n]);var o={};o.remove_files=1,o.compare=0,o.offset=0,o.next_step_in_migration=i.functions.prepare_determine_media,i.common.next_step_in_migration={fn:i.functions.remove_files_recursive,args:[o]},i.functions.execute_next_step()}else i.common.next_step_in_migration={fn:i.functions.prepare_determine_media},i.functions.execute_next_step()},i.functions.remove_files_recursive=function(t){if(0!==t.remove_files){i.mediaFiles.connection_info=e.trim(e(".pull-push-connection-info").val()).split("\n");var n=t;e.ajax({url:ajaxurl,type:"POST",dataType:"text",cache:!1,data:{action:"wpmdbmf_remove_files_recursive",migration_state_id:i.migration_state_id,compare:t.compare,offset:JSON.stringify(t.offset),nonce:wpmdb_data.nonces.remove_files_recursive},error:function(e,t,n){i.current_migration.setState(wpmdbmf_strings.migration_failed,i.functions.wpmdbGetAjaxErrors(wpmdbmf_strings.error_determining,"(#101mf)",e.responseText,e),"error"),console.log(e),console.log(t),console.log(n),i.common.migration_error=!0,i.functions.migration_complete_events()},success:function(r){var a=r;(t=i.functions.wpmdb_parse_json(e.trim(r)))?void 0===t.wpmdb_error||1!==t.wpmdb_error?(void 0!==t.wpmdb_non_fatal_error&&1===t.wpmdb_non_fatal_error&&(i.common.non_fatal_errors+=t.body),t.next_step_in_migration=n.next_step_in_migration,i.common.next_step_in_migration={fn:i.functions.remove_files_recursive,args:[t]},i.functions.execute_next_step()):o(t.body):o(a)}})}else!1!==t.next_step_in_migration?(i.common.next_step_in_migration={fn:t.next_step_in_migration},i.functions.execute_next_step()):i.functions.wpmdb_call_next_hook()},i.functions.prepare_determine_media=function(){i.mediaFiles.connection_info=e.trim(e(".pull-push-connection-info").val()).split("\n"),l=0;var t=0,n=0,r=e('input[name="media_migration_option"]:checked').val();i.current_migration.setText("0% - "+wpmdbmf_strings.determining),"compare-remove"===r&&(r="compare",t=1),"entire"===r&&(n=1);var a={};e.ajax({url:ajaxurl,type:"POST",dataType:"text",cache:!1,data:{action:"wpmdbmf_prepare_determine_media",migration_state_id:i.migration_state_id,nonce:wpmdb_data.nonces.prepare_determine_media},error:function(e,t,n){i.current_migration.setState(wpmdbmf_strings.migration_failed,i.functions.wpmdbGetAjaxErrors(wpmdbmf_strings.error_determining,"(#101mf)",e.responseText,e),"error"),console.log(e),console.log(t),console.log(n),i.common.migration_error=!0,i.functions.migration_complete_events()},success:function(r){var s=r;(a=i.functions.wpmdb_parse_json(e.trim(r)))?void 0===a.wpmdb_error||1!==a.wpmdb_error?(l=a.remote_max_upload_size,a.determine_progress=0,a.remove_local_media=t,a.copy_entire_media=n,i.common.next_step_in_migration={fn:i.functions.determine_media_to_migrate_recursive,args:[a]},i.functions.execute_next_step()):o(a.body):o(s)}})},i.functions.determine_media_to_migrate_recursive=function(t){if(t.determine_progress>=t.attachment_count)return i.common.next_step_in_migration={fn:i.functions.media_successfully_determined,args:[t]},void i.functions.execute_next_step();i.mediaFiles.connection_info=e.trim(e(".pull-push-connection-info").val()).split("\n"),e.ajax({url:ajaxurl,type:"POST",dataType:"text",cache:!1,data:{action:"wpmdbmf_determine_media_to_migrate_recursive",migration_state_id:i.migration_state_id,determine_progress:t.determine_progress,attachment_count:t.attachment_count,remote_uploads_url:t.remote_uploads_url,remove_local_media:t.remove_local_media,copy_entire_media:t.copy_entire_media,blogs:t.blogs,attachment_batch_limit:t.attachment_batch_limit,nonce:wpmdb_data.nonces.determine_media_to_migrate_recursive},error:function(e,t,n){i.current_migration.setState(wpmdbmf_strings.migration_failed,wpmdbmf_strings.error_determining+" (#101mf)","error"),console.log(e),console.log(t),console.log(n),i.common.migration_error=!0,i.functions.migration_complete_events()},success:function(n){var r=n;if(n=i.functions.wpmdb_parse_json(e.trim(n)))if(void 0===n.wpmdb_error||1!==n.wpmdb_error){t.blogs=n.blogs,t.determine_progress=n.determine_progress,t.total_size=t.total_size||0,t.total_size+=n.total_size,t.files_to_migrate=t.files_to_migrate||{},_.each(n.files_to_migrate,function(e,n){t.files_to_migrate[n]=e,i.current_migration.model.addStageItem("media",n,parseInt(e/1024))}),i.current_migration.fixProgressStageWidthForScrollBar();var a=Math.min(100,100*t.determine_progress/t.attachment_count),s=Math.floor(a);e(".migration-progress-stage-container[data-stage=media]").addClass("determining-media"),e(".progress-bar",".stage-progress.media").width(a+"%"),i.current_migration.setText(s+"% - "+wpmdbmf_strings.determining),i.common.next_step_in_migration={fn:i.functions.determine_media_to_migrate_recursive,args:[t]},i.functions.execute_next_step()}else o(n.body);else o(r)}})},i.functions.media_successfully_determined=function(n){if(void 0!==n.wpmdb_error&&1===n.wpmdb_error)return i.common.non_fatal_errors+=data.body,i.common.next_step_in_migration={fn:i.functions.wpmdb_call_next_hook},void i.functions.execute_next_step();n.media_progress=0,n.media_progress_image_number=0,n.bottleneck=wpmdb_data.max_request,n.files_to_migrate=n.files_to_migrate||{};var o="migrate_media_files_"+i.functions.wpmdb_migration_type();i.current_migration.setText(wpmdbmf_strings[o]),e(".migration-progress-stage-container[data-stage=media]").removeClass("determining-media"),i.common.next_step_in_migration={fn:t,args:[n]},i.functions.execute_next_step()},i.functions.finalise_media_migration=function(e){if(1===e.remove_local_media){var t="removing_files_"+i.functions.wpmdb_migration_type();return i.current_migration.setText(wpmdbmf_strings[t]),e={},e.remove_files=1,e.compare=1,e.offset="",e.next_step_in_migration=!1,i.common.next_step_in_migration={fn:i.functions.remove_files_recursive,args:[e]},void i.functions.execute_next_step()}i.functions.wpmdb_call_next_hook()},e(document).ready(function(){-1!==e.inArray(i.functions.wpmdb_migration_type(),["savefile","find_replace","import"])&&e(".media-files-options").hide(),e.wpmdb.add_action("move_connection_info_box",function(){g(i.mediaFiles.remote_media_files_unavailable),i.functions.wpmdb_toggle_migration_action_text()}),e.wpmdb.add_action("verify_connection_to_remote_site",function(e){i.mediaFiles.remote_connection_data=e,i.mediaFiles.remote_media_files_unavailable=void 0===e.media_files_available,g(i.mediaFiles.remote_media_files_unavailable)}),e.wpmdb.add_action("wpmdbmst_select_subsite_changed",function(){g(i.mediaFiles.remote_media_files_unavailable)}),e.wpmdb.add_filter("wpmdb_before_migration_complete_hooks",function(t){return!1===r()||-1===e.inArray(i.functions.wpmdb_migration_type(),["push","pull"])?t:(t.push(i.functions.prepare_remove_all_files),t)}),e("body").on("change","#mf-select-subsites",function(){e.wpmdb.do_action("wpmdbmf_selected_subsites_changed")}),e("body").on("change","#mf-selected-subsites",function(){e.wpmdb.do_action("wpmdbmf_selected_subsites_changed")}),e.wpmdb.add_filter("wpmdb_migration_profile_ready",a),e.wpmdb.add_action("wpmdb_tables_to_migrate_changed",d),e.wpmdb.add_action("wpmdbmf_selected_subsites_changed",d),e.wpmdb.add_action("wpmdb_add_migration_stages",c),e('input[name="media_migration_option"]').change(function(){s()}),s()})}(jQuery,wpmdb)},{}]},{},[1]);