From ea449a335c29f5eea71fe7cdbc392497b2a90ab1 Mon Sep 17 00:00:00 2001 From: alexandergull Date: Mon, 10 Mar 2025 13:19:00 +0500 Subject: [PATCH 01/23] Version: 2.153.99-fix --- security-malware-firewall.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security-malware-firewall.php b/security-malware-firewall.php index 9986fbcbb..67f3d5f67 100644 --- a/security-malware-firewall.php +++ b/security-malware-firewall.php @@ -5,7 +5,7 @@ Plugin URI: https://wordpress.org/plugins/security-malware-firewall/ Description: Security & Malware scan by CleanTalk to protect your website from online threats and viruses. IP/Country FireWall, Web application FireWall. Detailed stats and logs to have full control. Author: CleanTalk Security -Version: 2.153 +Version: 2.153.99-fix Author URI: https://cleantalk.org Text Domain: security-malware-firewall Domain Path: /i18n From 9a9a07bc2c145c65579f978fdc59081bf05d9721 Mon Sep 17 00:00:00 2001 From: alexandergull Date: Thu, 20 Mar 2025 15:25:44 +0500 Subject: [PATCH 02/23] New. Scanner. Heuristic. Entropy analysis updated to find suspicious array key calls. --- .../HeuristicAnalyser/HeuristicAnalyser.php | 12 +- .../HeuristicAnalyser/Modules/Entropy.php | 365 ++++++++++++++++-- 2 files changed, 340 insertions(+), 37 deletions(-) diff --git a/lib/CleantalkSP/Common/Scanner/HeuristicAnalyser/HeuristicAnalyser.php b/lib/CleantalkSP/Common/Scanner/HeuristicAnalyser/HeuristicAnalyser.php index 7b918c4ed..9f8178f64 100644 --- a/lib/CleantalkSP/Common/Scanner/HeuristicAnalyser/HeuristicAnalyser.php +++ b/lib/CleantalkSP/Common/Scanner/HeuristicAnalyser/HeuristicAnalyser.php @@ -33,6 +33,10 @@ class HeuristicAnalyser { // Constants const HEURISTIC_SCAN_MAX_FILE_SIZE = 524288; // 512 KB + /** + * Maximum number of keys to return in the entropy verdict. This is to prevent the verdict from being too large. + */ + const HEURISTIC_MAX_ENTROPY_VERDICT_KEYS = 10; // Current file attributes /** @@ -234,7 +238,7 @@ public function __construct($input, $self = null) $currentMemoryLimitBytes = $this->convertToBytes($currentMemoryLimit); $compareValueBytes = $this->convertToBytes('256M'); - if ($currentMemoryLimitBytes >= $compareValueBytes) { + if ($currentMemoryLimit === '-1' || $currentMemoryLimitBytes >= $compareValueBytes) { if ( isset($input['path']) && version_compare(PHP_VERSION, '8.1', '>=') && extension_loaded('mbstring') ) { // Do not run entropy analysis on included constructs $this->entropyAnalyser = new Entropy($input['path']); @@ -434,7 +438,7 @@ public function processContent() // Detecting bad variables $this->variables->detectBad(); if ( $this->entropyAnalyser ) { - $this->entropyAnalyser->analyse($this->variables); + $this->entropyAnalyser->extractSuspiciousVariables($this->variables); } /** Gather the results of scanning */ @@ -549,8 +553,8 @@ public function makeVerdict() } } - if ( $this->entropyAnalyser && $this->entropyAnalyser->getVerdict() ) { - $this->verdict['SUSPICIOUS'] = $this->entropyAnalyser->getVerdict(); + if ( $this->entropyAnalyser && $this->entropyAnalyser->getEntropyVerdict(static::HEURISTIC_MAX_ENTROPY_VERDICT_KEYS) ) { + $this->verdict['SUSPICIOUS'] = $this->entropyAnalyser->getEntropyVerdict(static::HEURISTIC_MAX_ENTROPY_VERDICT_KEYS); } // Detecting JavaScript injection in HTML diff --git a/lib/CleantalkSP/Common/Scanner/HeuristicAnalyser/Modules/Entropy.php b/lib/CleantalkSP/Common/Scanner/HeuristicAnalyser/Modules/Entropy.php index e3b7b7acb..30bb5b7de 100644 --- a/lib/CleantalkSP/Common/Scanner/HeuristicAnalyser/Modules/Entropy.php +++ b/lib/CleantalkSP/Common/Scanner/HeuristicAnalyser/Modules/Entropy.php @@ -6,16 +6,61 @@ class Entropy { + /** + * Min length of variable to be suspicious + */ + const SUSPICIOUS_VARIABLES_MIN_LENGTH = 3; + /** + * Threshold for variable tokenization, less is suspicious + */ + const SUSPICIOUS_VARIABLES_THRESHOLD = 2; + /** + * Min length of array key to be suspicious + */ + const SUSPICIOUS_ARRAY_KEYS_MIN_LENGTH = 2; + /** + * Threshold for array keys tokenization, less is suspicious + */ + const SUSPICIOUS_ARRAY_KEYS_THRESHOLD = 3; + /** + * How to reduce array keys tokenization before check to show in the verdict + */ + const SUSPICIOUS_ARRAY_KEYS_VERDICT_SHOWN_MULTIPLIER = 0.5; + /** + * MIn length of int key to be suspicious + */ + const SUSPICIOUS_ARRAY_KEYS_MIN_INT_KEY_LENGTH = 3; + /** + * Threshold for long int keys in array, more is suspicious + */ + const SUSPICIOUS_ARRAY_KEYS_LONGINT_THRESHOLD = 0.3; + + /** + * Verdict name of long integer in array key + */ + const ENTROPY_VERDICT_ARRAY_KEYS_LONGINT_NAME = 'Long integer in array key'; + /** + * Verdict name of high entropy in array key + */ + const ENTROPY_VERDICT_ARRAY_KEYS_HIGH_ENTROPY_NAME = 'High entropy in array key'; /** * @var array|null */ - private $verdict; + private $entropy_verdict; /** * Flag - is need to check variables separately * @var bool */ private $is_file_suspicious; + /** + * @var bool + */ + private $has_suspicious_variables; + /** + * @var array + */ + private $suspicious_array_calls = []; /** * @param string $path @@ -31,41 +76,48 @@ public function __construct($path) * @param Variables $variables * @return void */ - public function analyse(Variables $variables) + public function extractSuspiciousVariables(Variables $variables) { if ( !$this->is_file_suspicious ) { return; } - $variables_obj = $variables->variables; - $variable_names = array_keys($variables->variables); + $encoder = new Encoder(); - if ( !count($variable_names) ) { - return; - } + if ( $this->has_suspicious_variables ) { + $variables_obj = $variables->variables; + $variable_names = array_keys($variables->variables); - $encoder = new Encoder(); - $detected_unreadable_variables = []; - foreach ( $variable_names as $variable ) { - // do not change empty state! this change is from heur package! - if ( empty($variables_obj[$variable]) ) { - continue; + if ( !count($variable_names) ) { + return; } - if ( strpos($variable, '_') === 0 || strlen($variable) < 5 ) { - continue; - } - $num_tokens = count($encoder->encode($variable)); - if ( ! $num_tokens ) { - continue; + + $detected_unreadable_variables = []; + foreach ( $variable_names as $variable ) { + // do not change empty state! this change is from heur package! + if ( empty($variables_obj[$variable]) ) { + continue; + } + if ( strpos($variable, '_') === 0 || strlen($variable) < 5 ) { + continue; + } + $num_tokens = count($encoder->encode($variable)); + if ( ! $num_tokens ) { + continue; + } + $res = strlen($variable) / $num_tokens; + if ( $res < static::SUSPICIOUS_VARIABLES_THRESHOLD && isset($variables_obj[$variable][0][2]) ) { + $detected_unreadable_variables[$variables_obj[$variable][0][2]] = [$variable]; + } } - $res = strlen($variable) / $num_tokens; - if ( $res < 2 && isset($variables_obj[$variable][0][2]) ) { - $detected_unreadable_variables[$variables_obj[$variable][0][2]] = [$variable]; + + if ( count($detected_unreadable_variables) ) { + $this->entropy_verdict = $detected_unreadable_variables; } } - if ( count($detected_unreadable_variables) ) { - $this->verdict = $detected_unreadable_variables; + if ( empty($this->entropy_verdict) && !empty($this->suspicious_array_calls)) { + $this->entropy_verdict = $this->suspicious_array_calls; } } @@ -77,17 +129,33 @@ public function analyse(Variables $variables) */ private function analyseFile($path) { - $variable_names = $this->extractVariableNames($path); + $this->has_suspicious_variables = $this->analyseVariableCalls($path); + if ( !$this->has_suspicious_variables ) { + $this->suspicious_array_calls = $this->analyseArrayKeyCalls($path); + } + return $this->has_suspicious_variables || !empty($this->suspicious_array_calls); + } + + /** + * Analysing average unreadable variable score for the full file + * + * @param $path + * @return bool + */ + private function analyseVariableCalls($path) + { + $variable_names = static::extractVariableNames($path); $filtered_names = []; + foreach ( $variable_names as $variable_name ) { - if ( strpos($variable_name, '_') !== 0 && strlen($variable_name) >= 5 ) { + if ( strpos($variable_name, '_') !== 0 && strlen($variable_name) >= static::SUSPICIOUS_VARIABLES_MIN_LENGTH ) { $filtered_names[] = $variable_name; } } $filtered_names = array_unique($filtered_names); - if ( count($filtered_names) > 3 ) { + if ( count($filtered_names) > static::SUSPICIOUS_VARIABLES_MIN_LENGTH ) { $encoder = new Encoder(); $sum = 0; @@ -102,7 +170,7 @@ private function analyseFile($path) $average_tokenization = $sum / count($filtered_names); - if ( $average_tokenization < 2 ) { + if ( $average_tokenization < static::SUSPICIOUS_VARIABLES_THRESHOLD ) { return true; } } @@ -110,21 +178,252 @@ private function analyseFile($path) } /** + * Analysing average unreadable variable score for the full file + * + * @param $path + * + * @return array + */ + private function analyseArrayKeyCalls($path) + { + //perform entropy analysis for array keys + $suspicious_calls = $this->analyzeArrayKeysEntropy($path); + + if (empty($suspicious_calls)) { + //if nothing found perform long int count analysis + $suspicious_calls = $this->analyzeArrayKeysLongInt($path); + } + + return $suspicious_calls; + } + + /** + * Analysing average unreadable array keys score for the full file + * @param $path + * + * @return array + */ + private function analyzeArrayKeysEntropy($path) + { + $output = []; + $array_keys_calls = static::extractArrayKeysWordLike($path); + $filtered_keys = []; + + foreach ( $array_keys_calls as $key ) { + if ( strlen($key) >= static::SUSPICIOUS_ARRAY_KEYS_MIN_LENGTH ) { + $filtered_keys[] = $key; + } + } + + $filtered_keys = array_unique($filtered_keys); + if ( count($filtered_keys) > 3 ) { + $encoder = new Encoder(); + $sum = 0; + + foreach ( $filtered_keys as $key ) { + $num_tokens = count($encoder->encode($key)); + if ( ! $num_tokens ) { + continue; + } + $res = strlen($key) / $num_tokens; + $sum += $res; + } + + $average_array_key_tokenization = $sum / count($filtered_keys); + if ( $average_array_key_tokenization < static::SUSPICIOUS_ARRAY_KEYS_THRESHOLD ) { + foreach ( $filtered_keys as $key ) { + $num_tokens = count($encoder->encode($key)); + if ( ! $num_tokens ) { + continue; + } + $res = strlen($key) / $num_tokens; + if ( $res < static::SUSPICIOUS_ARRAY_KEYS_THRESHOLD * static::SUSPICIOUS_ARRAY_KEYS_VERDICT_SHOWN_MULTIPLIER ) { + $found_on_lines = static::findRowsNumWithPattern($path, '/\[\'' . $key . '\'\]/'); + foreach ( $found_on_lines as $line_num ) { + $output[$line_num] = [static::ENTROPY_VERDICT_ARRAY_KEYS_HIGH_ENTROPY_NAME]; + } + } + } + } + } + return $output; + } + + /** + * Analysing average long int in array call score for the full file + * @param $path + * + * @return array + */ + private function analyzeArrayKeysLongInt($path) + { + $output = []; + $array_keys_int = static::extractArrayKeysIntLike($path); + $total_int_keys_calls = count($array_keys_int); + $probably_long_int = []; + foreach ($array_keys_int as $int) { + if (strlen($int) >= static::SUSPICIOUS_ARRAY_KEYS_MIN_INT_KEY_LENGTH) { + $found_on_lines = static::findRowsNumWithPattern($path, '/\[' . $int . '\]/'); + foreach ($found_on_lines as $line_num) { + $probably_long_int[$line_num] = [static::ENTROPY_VERDICT_ARRAY_KEYS_LONGINT_NAME]; + } + } + } + if ( + count($probably_long_int) && + $total_int_keys_calls / count($probably_long_int) > static::SUSPICIOUS_ARRAY_KEYS_LONGINT_THRESHOLD + ) { + $output = $probably_long_int; + } + return $output; + } + + /** + * Extract variable names from the file + * @param $path + * @return string[] + */ + private static function extractVariableNames($path) + { + $pattern = '/\$([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)/'; + return static::extractFileDataByRegexp($path, $pattern); + } + + /** + * Extract int-like array keys from the file * @param $path * @return string[] */ - private function extractVariableNames($path) + private static function extractArrayKeysWordLike($path) + { + $pattern = '/\[\'([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)\'\]/'; + return static::extractFileDataByRegexp($path, $pattern); + } + + /** + * Extract word-like array keys from the file + * @param $path + * @return string[] + */ + private static function extractArrayKeysIntLike($path) + { + $pattern = '/\[(\d+)]/'; + return static::extractFileDataByRegexp($path, $pattern); + } + + /** + * @param $path + * @param $pattern + * + * @return array|string[] + */ + private static function extractFileDataByRegexp($path, $pattern) { $content = file_get_contents($path); - preg_match_all('/\$([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)/', $content, $matches); - return $matches[1]; + preg_match_all($pattern, $content, $matches); + return isset($matches[1]) ? $matches[1] : []; + } + + /** + * Find each row in a file that matches a specified regular expression. + * + * @param string $filePath The path to the file. + * @param string $pattern The regular expression pattern to search for. + * @return array An array of lines that match the regular expression. + */ + private static function findRowsNumWithPattern($filePath, $pattern) + { + $result = []; + if (!class_exists('\SplFileObject')) { + return array(); + } + $file = new \SplFileObject($filePath); + $line_num = 0; + + while (!$file->eof()) { + $line_num++; + $line = $file->fgets(); + if (preg_match($pattern, $line)) { + $result[] = $line_num; + } + } + + return $result; } /** * @return array|null */ - public function getVerdict() + public function getEntropyVerdict($max_keys_number = 0) + { + if ( + $max_keys_number !== 0 + && is_array($this->entropy_verdict) + && count($this->entropy_verdict) > $max_keys_number + ) { + return static::reduceVerdict($this->entropy_verdict, $max_keys_number); + } + return $this->entropy_verdict; + } + + /** + * Reduce verdict to max keys number + * @param $verdict + * @param $max_keys + * + * @return array + */ + private static function reduceVerdict($verdict, $max_keys) + { + $verdict_of_array_checks = []; + $verdict_other = []; + // we need to separate array checks from other checks + foreach ($verdict as $line => $value) { + if (is_array($value)) { + if ( + $value[0] === static::ENTROPY_VERDICT_ARRAY_KEYS_HIGH_ENTROPY_NAME || + $value[0] === static::ENTROPY_VERDICT_ARRAY_KEYS_LONGINT_NAME + ) { + $verdict_of_array_checks[$line] = $value; + } else { + $verdict_other[$line] = $value; + } + } + } + if (count($verdict_other) + count($verdict_of_array_checks) !== count($verdict)) { + throw new \RuntimeException('Verdict reduction error'); + } + //first, if we have found array checks - reduce them + if (count($verdict_of_array_checks) > 2 && count($verdict_other) <= $max_keys) { + $verdict_of_array_checks = static::halfVerdictArray($verdict_of_array_checks, $max_keys - count($verdict_other)); + return count($verdict_other) // if other checks found - merge them + ? array_merge($verdict_other, $verdict_of_array_checks) + : $verdict_of_array_checks; + } + //if we have no array checks - reduce other checks by limit + return array_slice($verdict, 0, $max_keys); + } + + /** + * Reduce verdict to max keys number deleting every second key. + * @param $array + * @param $max_keys + * + * @return array + */ + private static function halfVerdictArray($array, $max_keys) { - return $this->verdict; + $counter = 3; //save first elem always + $halfed = []; + foreach ($array as $index => $value) { + $counter++; + if ($counter % 2 == 1) { + $halfed[$index] = $value; + } + } + unset($array); + return count($halfed) > $max_keys + ? static::halfVerdictArray($halfed, $max_keys) + : $halfed; } } From cd5890df1628803fdbc30aacc5eafc532c22f6b5 Mon Sep 17 00:00:00 2001 From: AntonV1211 Date: Thu, 20 Mar 2025 19:05:15 +0700 Subject: [PATCH 03/23] Fix. SettingsPage. Textdomain fix --- security-malware-firewall.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/security-malware-firewall.php b/security-malware-firewall.php index 67f3d5f67..65ba38334 100644 --- a/security-malware-firewall.php +++ b/security-malware-firewall.php @@ -375,7 +375,9 @@ function spbc_change_author_name($link, $_author_id, $_author_nicename) add_filter('script_loader_tag', 'spbc_admin_add_script_attribute', 10, 3); include_once SPBC_PLUGIN_DIR . 'inc/spbc-admin.php'; - include_once SPBC_PLUGIN_DIR . 'templates/spbc_settings_main.php'; // Templates for settings pgae + add_action('init', function () { + include_once SPBC_PLUGIN_DIR . 'templates/spbc_settings_main.php'; // Templates for settings pgae + }); add_action('admin_init', array('CleantalkSP\SpbctWP\Activator', 'redirectAfterActivation'), 1); // Redirect after activation add_action('admin_init', 'spbc_admin_init', 1, 1); // Main admin hook From 6b150bc0b80fba5a6eee7f3f68ef8b512879d1be Mon Sep 17 00:00:00 2001 From: alexandergull Date: Sun, 23 Mar 2025 19:08:21 +0500 Subject: [PATCH 04/23] Fix. HTTP. Get DNS records. False result handled. --- lib/CleantalkSP/SpbctWP/Helpers/HTTP.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/CleantalkSP/SpbctWP/Helpers/HTTP.php b/lib/CleantalkSP/SpbctWP/Helpers/HTTP.php index 05d6c810a..e0c6ea6f5 100644 --- a/lib/CleantalkSP/SpbctWP/Helpers/HTTP.php +++ b/lib/CleantalkSP/SpbctWP/Helpers/HTTP.php @@ -25,7 +25,10 @@ class HTTP extends \CleantalkSP\Common\Helpers\HTTP public static function getCleantalksAPIServersFromDNS() { $servers = []; - $dns_records = dns_get_record('api.cleantalk.org', DNS_A); + $dns_records = @dns_get_record('api.cleantalk.org', DNS_A); + if (false === $dns_records) { + $dns_records = array(); + } foreach ($dns_records as $record) { if (isset($record['ip'])) { From a96f6b0b67cd6c9bbedc2733a2ee48148e966421 Mon Sep 17 00:00:00 2001 From: alexandergull Date: Sat, 22 Mar 2025 13:58:08 +0500 Subject: [PATCH 05/23] Ref. Admin page. CSS styles and JS scripts enqueuing refactored. --- inc/spbc-admin.php | 294 -------------------- js/jquery-ui.min.js | 6 - lib/CleantalkSP/SpbctWP/SpbcEnqueue.php | 352 ++++++++++++++++++++++++ security-malware-firewall.php | 9 +- 4 files changed, 356 insertions(+), 305 deletions(-) delete mode 100644 js/jquery-ui.min.js diff --git a/inc/spbc-admin.php b/inc/spbc-admin.php index c847704d4..3345bf8cf 100644 --- a/inc/spbc-admin.php +++ b/inc/spbc-admin.php @@ -4,7 +4,6 @@ use CleantalkSP\SpbctWP\CleantalkSettingsTemplates; use CleantalkSP\SpbctWP\Cron; use CleantalkSP\SpbctWP\Escape; -use CleantalkSP\SpbctWP\SpbcEnqueue; use CleantalkSP\SpbctWP\VulnerabilityAlarm\Dto\PluginReport; use CleantalkSP\SpbctWP\VulnerabilityAlarm\Dto\ThemeReport; use CleantalkSP\SpbctWP\VulnerabilityAlarm\VulnerabilityAlarmService; @@ -472,299 +471,6 @@ function changedPluginName(){ return $meta; } -/** - * Register stylesheet and scripts. - * @psalm-suppress InvalidArgument - */ -function spbc_enqueue_scripts($hook) -{ - // If the user is not admin - if ( ! current_user_can('upload_files')) { - return; - } - - global $spbc; - - // For ALL admin pages - SpbcEnqueue::getInstance()->css('spbc-admin.css'); - SpbcEnqueue::getInstance()->css('spbc-icons.css'); - SpbcEnqueue::getInstance()->js('spbc-common.js', array('jquery')); - SpbcEnqueue::getInstance()->js('spbc-admin.js', array('jquery')); - SpbcEnqueue::getInstance()->js('spbc-react-bundle.js', array('wp-i18n'), ['in_footer']); - wp_set_script_translations('spbc-react-bundle-js', 'security-malware-firewall'); - - $vulnerability_show_install = ( - isset($spbc->settings['vulnerability_check__test_before_install']) && - $spbc->settings['vulnerability_check__test_before_install'] == true - ); - - $vulnerability_show_list = ( - isset($spbc->settings['vulnerability_check__enable_cron'], $spbc->settings['vulnerability_check__warn_on_modules_pages']) && - $spbc->settings['vulnerability_check__enable_cron'] == true && - $spbc->settings['vulnerability_check__warn_on_modules_pages'] == true - ); - wp_localize_script('spbc-common-js', 'spbcSettings', array( - 'wpms' => (int) is_multisite(), - 'is_main_site' => (int) is_main_site(), - 'img_path' => SPBC_PATH . '/images', - 'key_is_ok' => $spbc->key_is_ok, - 'critical' => $spbc->data['display_scanner_warnings']['critical'], - 'secfw_enabled' => $spbc->settings['secfw__enabled'], - 'ajax_nonce' => wp_create_nonce("spbc_secret_nonce"), - 'ajaxurl' => admin_url('admin-ajax.php', 'relative'), - //'debug' => !empty($debug) ? 1 : 0, - 'key_changed' => ! empty($spbc->data['key_changed']), - 'admin_bar__admins_online_counter' => $spbc->settings['admin_bar__admins_online_counter'] ? 1 : 0, - 'needToWhitelist' => ! Cookie::get('spbc_secfw_ip_wl'), - 'frontendAnalysisAmount' => (defined('SPBCT_ALLOW_CURL_SINGLE') && SPBCT_ALLOW_CURL_SINGLE) ? 2 : 20, - 'spbctNoticeDismissSuccess' => \CleantalkSP\SpbctWP\AdminBannersModule\AdminBannersHandler::getJSONOfPostNotices(), - 'vulnerabilityShowInstall' => $vulnerability_show_install, - 'vulnerabilityShowList' => $vulnerability_show_list, - 'spbcSpinner' => array ( - 'imgSource' => SPBC_PATH . '/images/preloader2.gif', - 'altText' => esc_html__('Loading...', 'security-malware-firewall') - ), - 'wl_mode_enabled' => $spbc->data['wl_mode_enabled'], - 'wl_company_name' => $spbc->data['wl_company_name'], - 'wl_support_url' => $spbc->data['wl_support_url'], - 'default_wl_support_url' => $spbc->default_data['wl_support_url'], - )); - - SpbcEnqueue::getInstance()->js('spbc-cookie.js', array('jquery')); - - wp_localize_script( - 'spbc-cookie-js', - 'spbcPublic', - array ( - '_ajax_nonce' => wp_create_nonce('ct_secret_stuff'), - '_rest_nonce' => wp_create_nonce('wp_rest'), - '_ajax_url' => admin_url('admin-ajax.php', 'relative'), - '_rest_url' => esc_url(get_rest_url()), - // '_apbct_ajax_url' => APBCT_URL_PATH . '/lib/Cleantalk/ApbctWP/Ajax.php', - 'data__set_cookies' => $spbc->settings['data__set_cookies'], - 'data__set_cookies__alt_sessions_type' => $spbc->settings['data__set_cookies__alt_sessions_type'], - 'no_confirm_row_actions' => spbc_get_no_confirm_row_actions(), - ) - ); - - if ($spbc->settings['upload_checker__file_check'] && in_array($hook, array('upload.php', 'media-new.php'))) { - SpbcEnqueue::getInstance()->js('spbc-upload.js', array('jquery')); - } - - // Load UI (modal window) for profile pages - if ($hook === 'profile.php' || $hook === 'user-edit.php') { - SpbcEnqueue::getInstance()->custom( - 'jquery-ui', - SPBC_PATH . '/css/jquery-ui.min.css', - array(), - '1.12.1', - null, - 'all' - ); - wp_enqueue_script('jquery-ui-dialog'); - } - - // For settings page - if ($hook === 'settings_page_spbc') { - $button_template = ''; - - $button_template_send = sprintf($button_template, '', 'send', __('Send for analysys', 'security-malware-firewall')); - $button_template_delete = sprintf($button_template, '', 'delete', __('Delete', 'security-malware-firewall')); - $button_template_approve = sprintf($button_template, '', 'approve', __('Approve', 'security-malware-firewall')); - $button_template_view = sprintf($button_template, '', 'view', __('View', 'security-malware-firewall')); - $button_template_view_bad = sprintf($button_template, '', 'view_bad', __('View suspicious code', 'security-malware-firewall')); - $button_template_replace = sprintf($button_template, '', 'replace', __('Replace with original', 'security-malware-firewall')); - $button_template_compare = sprintf($button_template, '', 'compare', __('Show difference', 'security-malware-firewall')); - $actions_unknown = $button_template_send . $button_template_delete . $button_template_approve . $button_template_view; - $actions_modified = $button_template_approve . $button_template_replace . $button_template_compare . $button_template_view_bad; - - // CSS - SpbcEnqueue::getInstance()->css('spbc-settings.css'); - SpbcEnqueue::getInstance()->css('spbc-settings-media.css'); - SpbcEnqueue::getInstance()->css('spbc-table.css'); - wp_deregister_style('jquery-ui-style'); - SpbcEnqueue::getInstance()->custom( - 'jquery-ui', - SPBC_PATH . '/css/jquery-ui.min.css', - array(), - '1.12.1', - null, - 'all' - ); - // JS - SpbcEnqueue::getInstance()->custom( - 'jquery-ui', - SPBC_PATH . '/js/jquery-ui.min.js', - array('jquery'), - '1.13.1', - true, - null - ); - SpbcEnqueue::getInstance()->js('spbc-settings.js', array('jquery'), true); - SpbcEnqueue::getInstance()->js('spbc-table.js', array('jquery'), true); - SpbcEnqueue::getInstance()->js('spbc-scanner-plugin.js', array('jquery'), true); - - wp_localize_script('spbc-table-js', 'spbcTableLocalize', array( - 'scannerIsActive' => esc_html__('Scanner is active for now. Try later.', 'security-malware-firewall'), - )); - - SpbcEnqueue::getInstance()->js('spbc-modal.js', array('jquery'), true); - - wp_localize_script('spbc-settings-js', 'spbcSettingsSecLogs', array( - 'amount' => SPBC_LAST_ACTIONS_TO_VIEW, - 'clicks' => 0, - )); - - wp_localize_script('spbc-settings-js', 'spbcSettingsFWLogs', array( - 'moderate' => $spbc->moderate ? 1 : 0, - 'amount' => SPBC_LAST_ACTIONS_TO_VIEW, - 'clicks' => 0, - )); - - wp_localize_script('spbc-settings-js', 'spbcTable', array( - 'warning_bulk' => __('Are sure you want to perform these actions?', 'security-malware-firewall'), - - 'warning_default' => __('Do you want to proceed?', 'security-malware-firewall'), - - 'warning_h_approve' => __('Do you want to approve this file?', 'security-malware-firewall'), - 'warning_t_approve' => __('If you agree, this file will be approved.', 'security-malware-firewall'), - - 'warning_h_send' => __('Do you want to proceed?', 'security-malware-firewall'), - 'warning_t_send' => __('This file will be sent to the Cloud to analyze for a malware, usually processing takes up to 1 minute. The result will be shown in the Analysis log.', 'security-malware-firewall'), - - 'warning_h_delete' => __('This can\'t be undone and could damage your website. Are you sure?', 'security-malware-firewall'), - 'warning_t_delete' => __('If you agree, this file will be deleted.', 'security-malware-firewall'), - - 'warning_h_replace' => __('This can\'t be undone. Are you sure?', 'security-malware-firewall'), - 'warning_t_replace' => __('If you agree, this file will be replaced.', 'security-malware-firewall'), - - 'warning_h_quarantine' => __('This could damage your website, but you will have an option to restore the file.', 'security-malware-firewall'), - 'warning_t_quarantine' => __('If you agree, this file will be quarantined.', 'security-malware-firewall'), - )); - - // Getting scanner settings - $scanner_settings = array_filter( - (array) $spbc->settings, - function ($key) { - return strpos($key, 'scanner') === 0; - }, - ARRAY_FILTER_USE_KEY - ); - - wp_localize_script('spbc-settings-js', 'spbcScaner', array( - - // PARAMS - 'settings' => $scanner_settings, - 'states' => ScannerQueue::$stages, - 'timezone_shift' => $spbc->data['site_utc_offset_in_seconds'] ?: false, - - // Settings / Statuses - 'scaner_enabled' => $spbc->scaner_enabled ? 1 : 0, - 'check_links' => $spbc->settings['scanner__outbound_links'] ? 1 : 0, - 'check_heuristic' => $spbc->settings['scanner__heuristic_analysis'] ? 1 : 0, - 'check_signature' => $spbc->settings['scanner__signature_analysis'] ? 1 : 0, - 'auto_cure' => $spbc->settings['scanner__auto_cure'] ? 1 : 0, - 'check_frontend' => $spbc->settings['scanner__frontend_analysis'] ? 1 : 0, - 'check_listing' => $spbc->settings['scanner__important_files_listing'] ? 1 : 0, - 'wp_content_dir' => realpath(WP_CONTENT_DIR), - 'wp_root_dir' => realpath(ABSPATH), - - // Templates - 'row_template' => '%s%s%s%s%s', - 'row_template_links' => '%s%s%s', - 'actions_unknown' => $actions_unknown, - 'actions_modified' => $actions_modified, - 'page_selector_template' => '', - - //TRANSLATIONS - - //Confirmation - 'scan_modified_confiramation' => __('There is more than 30 modified files and this could take time. Do you want to proceed?', 'security-malware-firewall'), - 'warning_about_cancel' => __('Scan will be performed in the background mode soon.', 'security-malware-firewall'), - 'delete_warning' => __('Are you sure you want to delete the file? It can not be undone.'), - // Buttons - 'button_scan_perform' => __('Perform Scan', 'security-malware-firewall'), - 'button_scan_pause' => __('Pause scan', 'security-malware-firewall'), - 'button_scan_resume' => __('Resume scan', 'security-malware-firewall'), - // Progress bar - 'progressbar_get_cms_hashes' => __('Receiving hashes', 'security-malware-firewall'), - 'progressbar_get_modules_hashes' => __('Receiving plugins hashes', 'security-malware-firewall'), - 'progressbar_get_approved_hashes' => __('Updating statuses for the approved files', 'security-malware-firewall'), - 'progressbar_get_denied_hashes' => __('Updating statuses for the denied files', 'security-malware-firewall'), - 'progressbar_clean_results' => __('Preparing', 'security-malware-firewall'), - // Scanning core - 'progressbar_file_system_analysis' => __('Scanning for modifications', 'security-malware-firewall'), - 'progressbar_heuristic_analysis' => __('Heuristic analysis', 'security-malware-firewall'), - 'progressbar_schedule_send_heuristic_suspicious_files' => __('Schedule suspicious files to be automatically sent for analysis', 'security-malware-firewall'), - 'progressbar_signature_analysis' => __('Searching for signatures', 'security-malware-firewall'), - //Cure - 'progressbar_auto_cure_backup' => __('Creating a backup', 'security-malware-firewall'), - 'progressbar_auto_cure' => __('Cure', 'security-malware-firewall'), - // Links - 'progressbar_outbound_links' => __('Scanning links', 'security-malware-firewall'), - // Frontend - 'progressbar_frontend_analysis' => __('Scanning pages', 'security-malware-firewall'), - // Other - 'progressbar_important_files_listing' => __('Check pages for listing', 'security-malware-firewall'), - 'progressbar_send_results' => __('Sending results', 'security-malware-firewall'), - // Warnings - 'result_text_bad_template' => __('Recommend to scan all (%s) of the found files to make sure the website is secure.', 'security-malware-firewall'), - 'result_text_good_template' => __('No threats are found.', 'security-malware-firewall'), - //Misc - 'look_below_for_scan_res' => __('Look below for scan results.', 'security-malware-firewall'), - 'view_all_results' => sprintf( - __('
%sView all scan results for this website%s', 'security-malware-firewall'), - '', - '' - ), - 'last_scan_was_just_now' => __('The last scan of this website happened just now. Files scanned: %s.', 'security-malware-firewall'), - 'last_scan_was_just_now_links' => __('The last scan of this website happened just now. Files scanned: %s. Outbound links found: %s.', 'security-malware-firewall'), - 'copy_log_to_clipboard_hint' => __('Copied!', 'security-malware-firewall'), - 'copy_log_to_clipboard_hint_failed' => __('Failed to copy!', 'security-malware-firewall'), - 'copy_log_to_clipboard_hint_unsupported' => __('Clipboard API not supported in local environment', 'security-malware-firewall'), - )); - - wp_localize_script('spbc-settings-js', 'spbcDescriptions', array( - 'waf__enabled' => __('Bla bla', 'security-malware-firewall'), - 'waf__xss_check' => __('Cross-Site Scripting (XSS) — prevents malicious code to be executed/sent to any user. As a result malicious scripts can not get access to the cookie files, session tokens and any other confidential information browsers use and store. Such scripts can even overwrite content of HTML pages. CleanTalk WAF monitors for patterns of these parameters and block them.', 'security-malware-firewall'), - 'waf__sql_check' => __('SQL Injection — one of the most popular ways to hack websites and programs that work with databases. It is based on injection of a custom SQL code into database queries. It could transmit data through GET, POST requests or cookie files in an SQL code. If a website is vulnerable and execute such injections then it would allow attackers to apply changes to the website\'s MySQL database.', 'security-malware-firewall'), - 'upload_checker__file_check' => __('The option checks each uploaded file to a website for malicious code. If it\'s possible for visitors to upload files to a website, for instance a work resume, then attackers could abuse it and upload an infected file to execute it later and get access to your website.', 'security-malware-firewall'), - 'traffic_control__enabled' => __('It analyzes quantity of requests towards website from any IP address for a certain period of time. For example, for an ordinary visitor it\'s impossible to generate 2000 requests within 1 hour. Big amount of requests towards website from the same IP address indicates that there is a high chance of presence of a malicious program.', 'security-malware-firewall'), - 'scanner__outbound_links' => __('This option allows you to know the number of outgoing links on your website and website addresses they lead to. The option\'s purpose is to check your website and find hidden, forgotten and spam links. You should always remember if you have links to other websites which have a bad reputation, it could affect your visitors\' trust and your SEO.', 'security-malware-firewall'), - 'scanner__heuristic_analysis' => __('Often, authors of malicious code disguise their code which makes it difficult to identify it by their signatures. The malicious code itself can be placed anywhere on the site, for example the obfuscated PHP-code in the "logo.png" file, and the code itself is called by one inconspicuous line in "index.php". Therefore, the usage of plugins to search for malicious code is preferable. Heuristic analysis can indicate suspicious PHP constructions in a file that you should pay attention to.', 'security-malware-firewall'), - 'scanner__signature_analysis' => __('Code signatures — it\'s a code sequence a malicious program consists of. Signatures are being added to the database after analysis of the infected files. Search for such malicious code sequences is performed in scanning by signatures. If any part of code matches a virus code from the database, such files would be marked as critical.', 'security-malware-firewall'), - 'scanner__auto_cure' => __('It cures infected files automatically if the scanner knows cure methods for these specific cases. If the option is disabled then when the scanning process ends you will be presented with several actions you can do to the found files: Cure. Malicious code will be removed from the file. Replace. The file will be replaced with the original file. Delete. The file will be put in quarantine. Do nothing. Before any action is chosen, backups of the files will be created and if the cure is unsuccessful it\'s possible to restore each file.', 'security-malware-firewall'), - 'misc__backend_logs_enable' => __('To control appearing errors you have to check log file of your hosting account regularly. It\'s inconvenient and just a few webmasters pay attention to it. Also, errors could appear for a short period of time and only when one specific function is running, they can\'t be spotted in other circumstances so it\'s hard to catch them. PHP errors tell you that some of your website functionality doesn\'t work correctly, furthermore hackers may use these errors to get access to your website. The CleanTalk Scanner will check your website backend once per hour. Statistics of errors is available in your CleanTalk Dashboard.', 'security-malware-firewall'), - 'data__set_cookies' => __('Part of the CleanTalk FireWall functions depend on cookie files, so disabling this option could lead to deceleration of the firewall work. It will affect user identification who are logged in right now. Traffic Control will not be able to determine authorized users and they could be blocked when the request limit is reached. We do not recommend to disable this option without serious reasons. However, you should disable this option is you\'re using Varnish.', 'security-malware-firewall'), - '2fa__enable' => __('Two-Factor Authentication for WordPress admin accounts will improve your website security and make it safer, if not impossible, for hackers to breach your WordPress account. Two-Factor Authentication works via e-mail. Authentication code will be sent to your admin email. When authorizing, a one-time code will be sent to your email. While entering the code, make sure that it does not contain spaces. With your first authorization, the CleanTalk Security plugin remembers your browser and you won’t have to input your authorization code every time anymore. However, if you started to use a new device or a new browser then you are required to input your authorization code. The plugin will remember your browser for 30 days.', 'security-malware-firewall'), - )); - } -} - -function spbc_admin_add_script_attribute($tag, $handle) -{ - $async_scripts = array( - //'jquery-ui', - //'spbc-common-js', - 'spbc-scannerplugin-js', - 'spbc-scaner-events-js', - 'spbc-scaner-callbacks-js', - ); - - $defer_scripts = array( - 'spbc-settings-js', - 'spbc-scaner-js', - ); - - if (in_array($handle, $async_scripts)) { - return str_replace(' src', ' async="async" src', $tag); - } elseif (in_array($handle, $defer_scripts)) { - return str_replace(' src', ' defer="defer" src', $tag); - } else { - return $tag; - } -} - /* * Logging admin action */ diff --git a/js/jquery-ui.min.js b/js/jquery-ui.min.js deleted file mode 100644 index 9583d4757..000000000 --- a/js/jquery-ui.min.js +++ /dev/null @@ -1,6 +0,0 @@ -/*! jQuery UI - v1.13.1 - 2022-03-17 -* http://jqueryui.com -* Includes: widget.js, position.js, data.js, disable-selection.js, focusable.js, form-reset-mixin.js, jquery-patch.js, keycode.js, labels.js, scroll-parent.js, tabbable.js, unique-id.js, widgets/draggable.js, widgets/droppable.js, widgets/resizable.js, widgets/selectable.js, widgets/sortable.js, widgets/accordion.js, widgets/autocomplete.js, widgets/button.js, widgets/checkboxradio.js, widgets/controlgroup.js, widgets/datepicker.js, widgets/dialog.js, widgets/menu.js, widgets/mouse.js, widgets/progressbar.js, widgets/selectmenu.js, widgets/slider.js, widgets/spinner.js, widgets/tabs.js, widgets/tooltip.js, effect.js, effects/effect-blind.js, effects/effect-bounce.js, effects/effect-clip.js, effects/effect-drop.js, effects/effect-explode.js, effects/effect-fade.js, effects/effect-fold.js, effects/effect-highlight.js, effects/effect-puff.js, effects/effect-pulsate.js, effects/effect-scale.js, effects/effect-shake.js, effects/effect-size.js, effects/effect-slide.js, effects/effect-transfer.js -* Copyright jQuery Foundation and other contributors; Licensed MIT */ - -!function(t){"use strict";"function"==typeof define&&define.amd?define(["jquery"],t):t(jQuery)}(function(V){"use strict";V.ui=V.ui||{};V.ui.version="1.13.1";var n,i=0,a=Array.prototype.hasOwnProperty,r=Array.prototype.slice;V.cleanData=(n=V.cleanData,function(t){for(var e,i,s=0;null!=(i=t[s]);s++)(e=V._data(i,"events"))&&e.remove&&V(i).triggerHandler("remove");n(t)}),V.widget=function(t,i,e){var s,n,o,a={},r=t.split(".")[0],l=r+"-"+(t=t.split(".")[1]);return e||(e=i,i=V.Widget),Array.isArray(e)&&(e=V.extend.apply(null,[{}].concat(e))),V.expr.pseudos[l.toLowerCase()]=function(t){return!!V.data(t,l)},V[r]=V[r]||{},s=V[r][t],n=V[r][t]=function(t,e){if(!this||!this._createWidget)return new n(t,e);arguments.length&&this._createWidget(t,e)},V.extend(n,s,{version:e.version,_proto:V.extend({},e),_childConstructors:[]}),(o=new i).options=V.widget.extend({},o.options),V.each(e,function(e,s){function n(){return i.prototype[e].apply(this,arguments)}function o(t){return i.prototype[e].apply(this,t)}a[e]="function"==typeof s?function(){var t,e=this._super,i=this._superApply;return this._super=n,this._superApply=o,t=s.apply(this,arguments),this._super=e,this._superApply=i,t}:s}),n.prototype=V.widget.extend(o,{widgetEventPrefix:s&&o.widgetEventPrefix||t},a,{constructor:n,namespace:r,widgetName:t,widgetFullName:l}),s?(V.each(s._childConstructors,function(t,e){var i=e.prototype;V.widget(i.namespace+"."+i.widgetName,n,e._proto)}),delete s._childConstructors):i._childConstructors.push(n),V.widget.bridge(t,n),n},V.widget.extend=function(t){for(var e,i,s=r.call(arguments,1),n=0,o=s.length;n",options:{classes:{},disabled:!1,create:null},_createWidget:function(t,e){e=V(e||this.defaultElement||this)[0],this.element=V(e),this.uuid=i++,this.eventNamespace="."+this.widgetName+this.uuid,this.bindings=V(),this.hoverable=V(),this.focusable=V(),this.classesElementLookup={},e!==this&&(V.data(e,this.widgetFullName,this),this._on(!0,this.element,{remove:function(t){t.target===e&&this.destroy()}}),this.document=V(e.style?e.ownerDocument:e.document||e),this.window=V(this.document[0].defaultView||this.document[0].parentWindow)),this.options=V.widget.extend({},this.options,this._getCreateOptions(),t),this._create(),this.options.disabled&&this._setOptionDisabled(this.options.disabled),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:function(){return{}},_getCreateEventData:V.noop,_create:V.noop,_init:V.noop,destroy:function(){var i=this;this._destroy(),V.each(this.classesElementLookup,function(t,e){i._removeClass(e,t)}),this.element.off(this.eventNamespace).removeData(this.widgetFullName),this.widget().off(this.eventNamespace).removeAttr("aria-disabled"),this.bindings.off(this.eventNamespace)},_destroy:V.noop,widget:function(){return this.element},option:function(t,e){var i,s,n,o=t;if(0===arguments.length)return V.widget.extend({},this.options);if("string"==typeof t)if(o={},t=(i=t.split(".")).shift(),i.length){for(s=o[t]=V.widget.extend({},this.options[t]),n=0;n
"),i=e.children()[0];return V("body").append(e),t=i.offsetWidth,e.css("overflow","scroll"),t===(i=i.offsetWidth)&&(i=e[0].clientWidth),e.remove(),s=t-i},getScrollInfo:function(t){var e=t.isWindow||t.isDocument?"":t.element.css("overflow-x"),i=t.isWindow||t.isDocument?"":t.element.css("overflow-y"),e="scroll"===e||"auto"===e&&t.widthx(k(s),k(n))?o.important="horizontal":o.important="vertical",u.using.call(this,t,o)}),a.offset(V.extend(h,{using:t}))})},V.ui.position={fit:{left:function(t,e){var i=e.within,s=i.isWindow?i.scrollLeft:i.offset.left,n=i.width,o=t.left-e.collisionPosition.marginLeft,a=s-o,r=o+e.collisionWidth-n-s;e.collisionWidth>n?0n?0=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return!0}}),V.ui.plugin={add:function(t,e,i){var s,n=V.ui[t].prototype;for(s in i)n.plugins[s]=n.plugins[s]||[],n.plugins[s].push([e,i[s]])},call:function(t,e,i,s){var n,o=t.plugins[e];if(o&&(s||t.element[0].parentNode&&11!==t.element[0].parentNode.nodeType))for(n=0;n").css("position","absolute").appendTo(t.parent()).outerWidth(t.outerWidth()).outerHeight(t.outerHeight()).offset(t.offset())[0]})},_unblockFrames:function(){this.iframeBlocks&&(this.iframeBlocks.remove(),delete this.iframeBlocks)},_blurActiveElement:function(t){var e=V.ui.safeActiveElement(this.document[0]);V(t.target).closest(e).length||V.ui.safeBlur(e)},_mouseStart:function(t){var e=this.options;return this.helper=this._createHelper(t),this._addClass(this.helper,"ui-draggable-dragging"),this._cacheHelperProportions(),V.ui.ddmanager&&(V.ui.ddmanager.current=this),this._cacheMargins(),this.cssPosition=this.helper.css("position"),this.scrollParent=this.helper.scrollParent(!0),this.offsetParent=this.helper.offsetParent(),this.hasFixedAncestor=0i[2]&&(o=i[2]+this.offset.click.left),t.pageY-this.offset.click.top>i[3]&&(a=i[3]+this.offset.click.top)),s.grid&&(t=s.grid[1]?this.originalPageY+Math.round((a-this.originalPageY)/s.grid[1])*s.grid[1]:this.originalPageY,a=!i||t-this.offset.click.top>=i[1]||t-this.offset.click.top>i[3]?t:t-this.offset.click.top>=i[1]?t-s.grid[1]:t+s.grid[1],t=s.grid[0]?this.originalPageX+Math.round((o-this.originalPageX)/s.grid[0])*s.grid[0]:this.originalPageX,o=!i||t-this.offset.click.left>=i[0]||t-this.offset.click.left>i[2]?t:t-this.offset.click.left>=i[0]?t-s.grid[0]:t+s.grid[0]),"y"===s.axis&&(o=this.originalPageX),"x"===s.axis&&(a=this.originalPageY)),{top:a-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.offset.scroll.top:n?0:this.offset.scroll.top),left:o-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.offset.scroll.left:n?0:this.offset.scroll.left)}},_clear:function(){this._removeClass(this.helper,"ui-draggable-dragging"),this.helper[0]===this.element[0]||this.cancelHelperRemoval||this.helper.remove(),this.helper=null,this.cancelHelperRemoval=!1,this.destroyOnClear&&this.destroy()},_trigger:function(t,e,i){return i=i||this._uiHash(),V.ui.plugin.call(this,t,[e,i,this],!0),/^(drag|start|stop)/.test(t)&&(this.positionAbs=this._convertPositionTo("absolute"),i.offset=this.positionAbs),V.Widget.prototype._trigger.call(this,t,e,i)},plugins:{},_uiHash:function(){return{helper:this.helper,position:this.position,originalPosition:this.originalPosition,offset:this.positionAbs}}}),V.ui.plugin.add("draggable","connectToSortable",{start:function(e,t,i){var s=V.extend({},t,{item:i.element});i.sortables=[],V(i.options.connectToSortable).each(function(){var t=V(this).sortable("instance");t&&!t.options.disabled&&(i.sortables.push(t),t.refreshPositions(),t._trigger("activate",e,s))})},stop:function(e,t,i){var s=V.extend({},t,{item:i.element});i.cancelHelperRemoval=!1,V.each(i.sortables,function(){var t=this;t.isOver?(t.isOver=0,i.cancelHelperRemoval=!0,t.cancelHelperRemoval=!1,t._storedCSS={position:t.placeholder.css("position"),top:t.placeholder.css("top"),left:t.placeholder.css("left")},t._mouseStop(e),t.options.helper=t.options._helper):(t.cancelHelperRemoval=!0,t._trigger("deactivate",e,s))})},drag:function(i,s,n){V.each(n.sortables,function(){var t=!1,e=this;e.positionAbs=n.positionAbs,e.helperProportions=n.helperProportions,e.offset.click=n.offset.click,e._intersectsWith(e.containerCache)&&(t=!0,V.each(n.sortables,function(){return this.positionAbs=n.positionAbs,this.helperProportions=n.helperProportions,this.offset.click=n.offset.click,t=this!==e&&this._intersectsWith(this.containerCache)&&V.contains(e.element[0],this.element[0])?!1:t})),t?(e.isOver||(e.isOver=1,n._parent=s.helper.parent(),e.currentItem=s.helper.appendTo(e.element).data("ui-sortable-item",!0),e.options._helper=e.options.helper,e.options.helper=function(){return s.helper[0]},i.target=e.currentItem[0],e._mouseCapture(i,!0),e._mouseStart(i,!0,!0),e.offset.click.top=n.offset.click.top,e.offset.click.left=n.offset.click.left,e.offset.parent.left-=n.offset.parent.left-e.offset.parent.left,e.offset.parent.top-=n.offset.parent.top-e.offset.parent.top,n._trigger("toSortable",i),n.dropped=e.element,V.each(n.sortables,function(){this.refreshPositions()}),n.currentItem=n.element,e.fromOutside=n),e.currentItem&&(e._mouseDrag(i),s.position=e.position)):e.isOver&&(e.isOver=0,e.cancelHelperRemoval=!0,e.options._revert=e.options.revert,e.options.revert=!1,e._trigger("out",i,e._uiHash(e)),e._mouseStop(i,!0),e.options.revert=e.options._revert,e.options.helper=e.options._helper,e.placeholder&&e.placeholder.remove(),s.helper.appendTo(n._parent),n._refreshOffsets(i),s.position=n._generatePosition(i,!0),n._trigger("fromSortable",i),n.dropped=!1,V.each(n.sortables,function(){this.refreshPositions()}))})}}),V.ui.plugin.add("draggable","cursor",{start:function(t,e,i){var s=V("body"),i=i.options;s.css("cursor")&&(i._cursor=s.css("cursor")),s.css("cursor",i.cursor)},stop:function(t,e,i){i=i.options;i._cursor&&V("body").css("cursor",i._cursor)}}),V.ui.plugin.add("draggable","opacity",{start:function(t,e,i){e=V(e.helper),i=i.options;e.css("opacity")&&(i._opacity=e.css("opacity")),e.css("opacity",i.opacity)},stop:function(t,e,i){i=i.options;i._opacity&&V(e.helper).css("opacity",i._opacity)}}),V.ui.plugin.add("draggable","scroll",{start:function(t,e,i){i.scrollParentNotHidden||(i.scrollParentNotHidden=i.helper.scrollParent(!1)),i.scrollParentNotHidden[0]!==i.document[0]&&"HTML"!==i.scrollParentNotHidden[0].tagName&&(i.overflowOffset=i.scrollParentNotHidden.offset())},drag:function(t,e,i){var s=i.options,n=!1,o=i.scrollParentNotHidden[0],a=i.document[0];o!==a&&"HTML"!==o.tagName?(s.axis&&"x"===s.axis||(i.overflowOffset.top+o.offsetHeight-t.pageY").css({overflow:"hidden",position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),top:this.element.css("top"),left:this.element.css("left")})),this.element=this.element.parent().data("ui-resizable",this.element.resizable("instance")),this.elementIsWrapper=!0,t={marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom"),marginLeft:this.originalElement.css("marginLeft")},this.element.css(t),this.originalElement.css("margin",0),this.originalResizeStyle=this.originalElement.css("resize"),this.originalElement.css("resize","none"),this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"})),this.originalElement.css(t),this._proportionallyResize()),this._setupHandles(),e.autoHide&&V(this.element).on("mouseenter",function(){e.disabled||(i._removeClass("ui-resizable-autohide"),i._handles.show())}).on("mouseleave",function(){e.disabled||i.resizing||(i._addClass("ui-resizable-autohide"),i._handles.hide())}),this._mouseInit()},_destroy:function(){this._mouseDestroy(),this._addedHandles.remove();function t(t){V(t).removeData("resizable").removeData("ui-resizable").off(".resizable")}var e;return this.elementIsWrapper&&(t(this.element),e=this.element,this.originalElement.css({position:e.css("position"),width:e.outerWidth(),height:e.outerHeight(),top:e.css("top"),left:e.css("left")}).insertAfter(e),e.remove()),this.originalElement.css("resize",this.originalResizeStyle),t(this.originalElement),this},_setOption:function(t,e){switch(this._super(t,e),t){case"handles":this._removeHandles(),this._setupHandles();break;case"aspectRatio":this._aspectRatio=!!e}},_setupHandles:function(){var t,e,i,s,n,o=this.options,a=this;if(this.handles=o.handles||(V(".ui-resizable-handle",this.element).length?{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",nw:".ui-resizable-nw"}:"e,s,se"),this._handles=V(),this._addedHandles=V(),this.handles.constructor===String)for("all"===this.handles&&(this.handles="n,e,s,w,se,sw,ne,nw"),i=this.handles.split(","),this.handles={},e=0;e"),this._addClass(n,"ui-resizable-handle "+s),n.css({zIndex:o.zIndex}),this.handles[t]=".ui-resizable-"+t,this.element.children(this.handles[t]).length||(this.element.append(n),this._addedHandles=this._addedHandles.add(n));this._renderAxis=function(t){var e,i,s;for(e in t=t||this.element,this.handles)this.handles[e].constructor===String?this.handles[e]=this.element.children(this.handles[e]).first().show():(this.handles[e].jquery||this.handles[e].nodeType)&&(this.handles[e]=V(this.handles[e]),this._on(this.handles[e],{mousedown:a._mouseDown})),this.elementIsWrapper&&this.originalElement[0].nodeName.match(/^(textarea|input|select|button)$/i)&&(i=V(this.handles[e],this.element),s=/sw|ne|nw|se|n|s/.test(e)?i.outerHeight():i.outerWidth(),i=["padding",/ne|nw|n/.test(e)?"Top":/se|sw|s/.test(e)?"Bottom":/^e$/.test(e)?"Right":"Left"].join(""),t.css(i,s),this._proportionallyResize()),this._handles=this._handles.add(this.handles[e])},this._renderAxis(this.element),this._handles=this._handles.add(this.element.find(".ui-resizable-handle")),this._handles.disableSelection(),this._handles.on("mouseover",function(){a.resizing||(this.className&&(n=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i)),a.axis=n&&n[1]?n[1]:"se")}),o.autoHide&&(this._handles.hide(),this._addClass("ui-resizable-autohide"))},_removeHandles:function(){this._addedHandles.remove()},_mouseCapture:function(t){var e,i,s=!1;for(e in this.handles)(i=V(this.handles[e])[0])!==t.target&&!V.contains(i,t.target)||(s=!0);return!this.options.disabled&&s},_mouseStart:function(t){var e,i,s=this.options,n=this.element;return this.resizing=!0,this._renderProxy(),e=this._num(this.helper.css("left")),i=this._num(this.helper.css("top")),s.containment&&(e+=V(s.containment).scrollLeft()||0,i+=V(s.containment).scrollTop()||0),this.offset=this.helper.offset(),this.position={left:e,top:i},this.size=this._helper?{width:this.helper.width(),height:this.helper.height()}:{width:n.width(),height:n.height()},this.originalSize=this._helper?{width:n.outerWidth(),height:n.outerHeight()}:{width:n.width(),height:n.height()},this.sizeDiff={width:n.outerWidth()-n.width(),height:n.outerHeight()-n.height()},this.originalPosition={left:e,top:i},this.originalMousePosition={left:t.pageX,top:t.pageY},this.aspectRatio="number"==typeof s.aspectRatio?s.aspectRatio:this.originalSize.width/this.originalSize.height||1,s=V(".ui-resizable-"+this.axis).css("cursor"),V("body").css("cursor","auto"===s?this.axis+"-resize":s),this._addClass("ui-resizable-resizing"),this._propagate("start",t),!0},_mouseDrag:function(t){var e=this.originalMousePosition,i=this.axis,s=t.pageX-e.left||0,e=t.pageY-e.top||0,i=this._change[i];return this._updatePrevProperties(),i&&(e=i.apply(this,[t,s,e]),this._updateVirtualBoundaries(t.shiftKey),(this._aspectRatio||t.shiftKey)&&(e=this._updateRatio(e,t)),e=this._respectSize(e,t),this._updateCache(e),this._propagate("resize",t),e=this._applyChanges(),!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize(),V.isEmptyObject(e)||(this._updatePrevProperties(),this._trigger("resize",t,this.ui()),this._applyChanges())),!1},_mouseStop:function(t){this.resizing=!1;var e,i,s,n=this.options,o=this;return this._helper&&(s=(e=(i=this._proportionallyResizeElements).length&&/textarea/i.test(i[0].nodeName))&&this._hasScroll(i[0],"left")?0:o.sizeDiff.height,i=e?0:o.sizeDiff.width,e={width:o.helper.width()-i,height:o.helper.height()-s},i=parseFloat(o.element.css("left"))+(o.position.left-o.originalPosition.left)||null,s=parseFloat(o.element.css("top"))+(o.position.top-o.originalPosition.top)||null,n.animate||this.element.css(V.extend(e,{top:s,left:i})),o.helper.height(o.size.height),o.helper.width(o.size.width),this._helper&&!n.animate&&this._proportionallyResize()),V("body").css("cursor","auto"),this._removeClass("ui-resizable-resizing"),this._propagate("stop",t),this._helper&&this.helper.remove(),!1},_updatePrevProperties:function(){this.prevPosition={top:this.position.top,left:this.position.left},this.prevSize={width:this.size.width,height:this.size.height}},_applyChanges:function(){var t={};return this.position.top!==this.prevPosition.top&&(t.top=this.position.top+"px"),this.position.left!==this.prevPosition.left&&(t.left=this.position.left+"px"),this.size.width!==this.prevSize.width&&(t.width=this.size.width+"px"),this.size.height!==this.prevSize.height&&(t.height=this.size.height+"px"),this.helper.css(t),t},_updateVirtualBoundaries:function(t){var e,i,s=this.options,n={minWidth:this._isNumber(s.minWidth)?s.minWidth:0,maxWidth:this._isNumber(s.maxWidth)?s.maxWidth:1/0,minHeight:this._isNumber(s.minHeight)?s.minHeight:0,maxHeight:this._isNumber(s.maxHeight)?s.maxHeight:1/0};(this._aspectRatio||t)&&(e=n.minHeight*this.aspectRatio,i=n.minWidth/this.aspectRatio,s=n.maxHeight*this.aspectRatio,t=n.maxWidth/this.aspectRatio,e>n.minWidth&&(n.minWidth=e),i>n.minHeight&&(n.minHeight=i),st.width,a=this._isNumber(t.height)&&e.minHeight&&e.minHeight>t.height,r=this.originalPosition.left+this.originalSize.width,l=this.originalPosition.top+this.originalSize.height,h=/sw|nw|w/.test(i),i=/nw|ne|n/.test(i);return o&&(t.width=e.minWidth),a&&(t.height=e.minHeight),s&&(t.width=e.maxWidth),n&&(t.height=e.maxHeight),o&&h&&(t.left=r-e.minWidth),s&&h&&(t.left=r-e.maxWidth),a&&i&&(t.top=l-e.minHeight),n&&i&&(t.top=l-e.maxHeight),t.width||t.height||t.left||!t.top?t.width||t.height||t.top||!t.left||(t.left=null):t.top=null,t},_getPaddingPlusBorderDimensions:function(t){for(var e=0,i=[],s=[t.css("borderTopWidth"),t.css("borderRightWidth"),t.css("borderBottomWidth"),t.css("borderLeftWidth")],n=[t.css("paddingTop"),t.css("paddingRight"),t.css("paddingBottom"),t.css("paddingLeft")];e<4;e++)i[e]=parseFloat(s[e])||0,i[e]+=parseFloat(n[e])||0;return{height:i[0]+i[2],width:i[1]+i[3]}},_proportionallyResize:function(){if(this._proportionallyResizeElements.length)for(var t,e=0,i=this.helper||this.element;e").css({overflow:"hidden"}),this._addClass(this.helper,this._helper),this.helper.css({width:this.element.outerWidth(),height:this.element.outerHeight(),position:"absolute",left:this.elementOffset.left+"px",top:this.elementOffset.top+"px",zIndex:++e.zIndex}),this.helper.appendTo("body").disableSelection()):this.helper=this.element},_change:{e:function(t,e){return{width:this.originalSize.width+e}},w:function(t,e){var i=this.originalSize;return{left:this.originalPosition.left+e,width:i.width-e}},n:function(t,e,i){var s=this.originalSize;return{top:this.originalPosition.top+i,height:s.height-i}},s:function(t,e,i){return{height:this.originalSize.height+i}},se:function(t,e,i){return V.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[t,e,i]))},sw:function(t,e,i){return V.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[t,e,i]))},ne:function(t,e,i){return V.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[t,e,i]))},nw:function(t,e,i){return V.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[t,e,i]))}},_propagate:function(t,e){V.ui.plugin.call(this,t,[e,this.ui()]),"resize"!==t&&this._trigger(t,e,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}}),V.ui.plugin.add("resizable","animate",{stop:function(e){var i=V(this).resizable("instance"),t=i.options,s=i._proportionallyResizeElements,n=s.length&&/textarea/i.test(s[0].nodeName),o=n&&i._hasScroll(s[0],"left")?0:i.sizeDiff.height,a=n?0:i.sizeDiff.width,n={width:i.size.width-a,height:i.size.height-o},a=parseFloat(i.element.css("left"))+(i.position.left-i.originalPosition.left)||null,o=parseFloat(i.element.css("top"))+(i.position.top-i.originalPosition.top)||null;i.element.animate(V.extend(n,o&&a?{top:o,left:a}:{}),{duration:t.animateDuration,easing:t.animateEasing,step:function(){var t={width:parseFloat(i.element.css("width")),height:parseFloat(i.element.css("height")),top:parseFloat(i.element.css("top")),left:parseFloat(i.element.css("left"))};s&&s.length&&V(s[0]).css({width:t.width,height:t.height}),i._updateCache(t),i._propagate("resize",e)}})}}),V.ui.plugin.add("resizable","containment",{start:function(){var i,s,n=V(this).resizable("instance"),t=n.options,e=n.element,o=t.containment,a=o instanceof V?o.get(0):/parent/.test(o)?e.parent().get(0):o;a&&(n.containerElement=V(a),/document/.test(o)||o===document?(n.containerOffset={left:0,top:0},n.containerPosition={left:0,top:0},n.parentData={element:V(document),left:0,top:0,width:V(document).width(),height:V(document).height()||document.body.parentNode.scrollHeight}):(i=V(a),s=[],V(["Top","Right","Left","Bottom"]).each(function(t,e){s[t]=n._num(i.css("padding"+e))}),n.containerOffset=i.offset(),n.containerPosition=i.position(),n.containerSize={height:i.innerHeight()-s[3],width:i.innerWidth()-s[1]},t=n.containerOffset,e=n.containerSize.height,o=n.containerSize.width,o=n._hasScroll(a,"left")?a.scrollWidth:o,e=n._hasScroll(a)?a.scrollHeight:e,n.parentData={element:a,left:t.left,top:t.top,width:o,height:e}))},resize:function(t){var e=V(this).resizable("instance"),i=e.options,s=e.containerOffset,n=e.position,o=e._aspectRatio||t.shiftKey,a={top:0,left:0},r=e.containerElement,t=!0;r[0]!==document&&/static/.test(r.css("position"))&&(a=s),n.left<(e._helper?s.left:0)&&(e.size.width=e.size.width+(e._helper?e.position.left-s.left:e.position.left-a.left),o&&(e.size.height=e.size.width/e.aspectRatio,t=!1),e.position.left=i.helper?s.left:0),n.top<(e._helper?s.top:0)&&(e.size.height=e.size.height+(e._helper?e.position.top-s.top:e.position.top),o&&(e.size.width=e.size.height*e.aspectRatio,t=!1),e.position.top=e._helper?s.top:0),i=e.containerElement.get(0)===e.element.parent().get(0),n=/relative|absolute/.test(e.containerElement.css("position")),i&&n?(e.offset.left=e.parentData.left+e.position.left,e.offset.top=e.parentData.top+e.position.top):(e.offset.left=e.element.offset().left,e.offset.top=e.element.offset().top),n=Math.abs(e.sizeDiff.width+(e._helper?e.offset.left-a.left:e.offset.left-s.left)),s=Math.abs(e.sizeDiff.height+(e._helper?e.offset.top-a.top:e.offset.top-s.top)),n+e.size.width>=e.parentData.width&&(e.size.width=e.parentData.width-n,o&&(e.size.height=e.size.width/e.aspectRatio,t=!1)),s+e.size.height>=e.parentData.height&&(e.size.height=e.parentData.height-s,o&&(e.size.width=e.size.height*e.aspectRatio,t=!1)),t||(e.position.left=e.prevPosition.left,e.position.top=e.prevPosition.top,e.size.width=e.prevSize.width,e.size.height=e.prevSize.height)},stop:function(){var t=V(this).resizable("instance"),e=t.options,i=t.containerOffset,s=t.containerPosition,n=t.containerElement,o=V(t.helper),a=o.offset(),r=o.outerWidth()-t.sizeDiff.width,o=o.outerHeight()-t.sizeDiff.height;t._helper&&!e.animate&&/relative/.test(n.css("position"))&&V(this).css({left:a.left-s.left-i.left,width:r,height:o}),t._helper&&!e.animate&&/static/.test(n.css("position"))&&V(this).css({left:a.left-s.left-i.left,width:r,height:o})}}),V.ui.plugin.add("resizable","alsoResize",{start:function(){var t=V(this).resizable("instance").options;V(t.alsoResize).each(function(){var t=V(this);t.data("ui-resizable-alsoresize",{width:parseFloat(t.width()),height:parseFloat(t.height()),left:parseFloat(t.css("left")),top:parseFloat(t.css("top"))})})},resize:function(t,i){var e=V(this).resizable("instance"),s=e.options,n=e.originalSize,o=e.originalPosition,a={height:e.size.height-n.height||0,width:e.size.width-n.width||0,top:e.position.top-o.top||0,left:e.position.left-o.left||0};V(s.alsoResize).each(function(){var t=V(this),s=V(this).data("ui-resizable-alsoresize"),n={},e=t.parents(i.originalElement[0]).length?["width","height"]:["width","height","top","left"];V.each(e,function(t,e){var i=(s[e]||0)+(a[e]||0);i&&0<=i&&(n[e]=i||null)}),t.css(n)})},stop:function(){V(this).removeData("ui-resizable-alsoresize")}}),V.ui.plugin.add("resizable","ghost",{start:function(){var t=V(this).resizable("instance"),e=t.size;t.ghost=t.originalElement.clone(),t.ghost.css({opacity:.25,display:"block",position:"relative",height:e.height,width:e.width,margin:0,left:0,top:0}),t._addClass(t.ghost,"ui-resizable-ghost"),!1!==V.uiBackCompat&&"string"==typeof t.options.ghost&&t.ghost.addClass(this.options.ghost),t.ghost.appendTo(t.helper)},resize:function(){var t=V(this).resizable("instance");t.ghost&&t.ghost.css({position:"relative",height:t.size.height,width:t.size.width})},stop:function(){var t=V(this).resizable("instance");t.ghost&&t.helper&&t.helper.get(0).removeChild(t.ghost.get(0))}}),V.ui.plugin.add("resizable","grid",{resize:function(){var t,e=V(this).resizable("instance"),i=e.options,s=e.size,n=e.originalSize,o=e.originalPosition,a=e.axis,r="number"==typeof i.grid?[i.grid,i.grid]:i.grid,l=r[0]||1,h=r[1]||1,c=Math.round((s.width-n.width)/l)*l,u=Math.round((s.height-n.height)/h)*h,d=n.width+c,p=n.height+u,f=i.maxWidth&&i.maxWidthd,s=i.minHeight&&i.minHeight>p;i.grid=r,m&&(d+=l),s&&(p+=h),f&&(d-=l),g&&(p-=h),/^(se|s|e)$/.test(a)?(e.size.width=d,e.size.height=p):/^(ne)$/.test(a)?(e.size.width=d,e.size.height=p,e.position.top=o.top-u):/^(sw)$/.test(a)?(e.size.width=d,e.size.height=p,e.position.left=o.left-c):((p-h<=0||d-l<=0)&&(t=e._getPaddingPlusBorderDimensions(this)),0"),this._addClass(this.helper,"ui-selectable-helper")},_destroy:function(){this.selectees.removeData("selectable-item"),this._mouseDestroy()},_mouseStart:function(i){var s=this,t=this.options;this.opos=[i.pageX,i.pageY],this.elementPos=V(this.element[0]).offset(),this.options.disabled||(this.selectees=V(t.filter,this.element[0]),this._trigger("start",i),V(t.appendTo).append(this.helper),this.helper.css({left:i.pageX,top:i.pageY,width:0,height:0}),t.autoRefresh&&this.refresh(),this.selectees.filter(".ui-selected").each(function(){var t=V.data(this,"selectable-item");t.startselected=!0,i.metaKey||i.ctrlKey||(s._removeClass(t.$element,"ui-selected"),t.selected=!1,s._addClass(t.$element,"ui-unselecting"),t.unselecting=!0,s._trigger("unselecting",i,{unselecting:t.element}))}),V(i.target).parents().addBack().each(function(){var t,e=V.data(this,"selectable-item");if(e)return t=!i.metaKey&&!i.ctrlKey||!e.$element.hasClass("ui-selected"),s._removeClass(e.$element,t?"ui-unselecting":"ui-selected")._addClass(e.$element,t?"ui-selecting":"ui-unselecting"),e.unselecting=!t,e.selecting=t,(e.selected=t)?s._trigger("selecting",i,{selecting:e.element}):s._trigger("unselecting",i,{unselecting:e.element}),!1}))},_mouseDrag:function(s){if(this.dragged=!0,!this.options.disabled){var t,n=this,o=this.options,a=this.opos[0],r=this.opos[1],l=s.pageX,h=s.pageY;return ll||i.righth||i.bottoma&&i.rightr&&i.bottom *",opacity:!1,placeholder:!1,revert:!1,scroll:!0,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1e3,activate:null,beforeStop:null,change:null,deactivate:null,out:null,over:null,receive:null,remove:null,sort:null,start:null,stop:null,update:null},_isOverAxis:function(t,e,i){return e<=t&&t*{ cursor: "+o.cursor+" !important; }").appendTo(n)),o.zIndex&&(this.helper.css("zIndex")&&(this._storedZIndex=this.helper.css("zIndex")),this.helper.css("zIndex",o.zIndex)),o.opacity&&(this.helper.css("opacity")&&(this._storedOpacity=this.helper.css("opacity")),this.helper.css("opacity",o.opacity)),this.scrollParent[0]!==this.document[0]&&"HTML"!==this.scrollParent[0].tagName&&(this.overflowOffset=this.scrollParent.offset()),this._trigger("start",t,this._uiHash()),this._preserveHelperProportions||this._cacheHelperProportions(),!i)for(s=this.containers.length-1;0<=s;s--)this.containers[s]._trigger("activate",t,this._uiHash(this));return V.ui.ddmanager&&(V.ui.ddmanager.current=this),V.ui.ddmanager&&!o.dropBehaviour&&V.ui.ddmanager.prepareOffsets(this,t),this.dragging=!0,this._addClass(this.helper,"ui-sortable-helper"),this.helper.parent().is(this.appendTo)||(this.helper.detach().appendTo(this.appendTo),this.offset.parent=this._getParentOffset()),this.position=this.originalPosition=this._generatePosition(t),this.originalPageX=t.pageX,this.originalPageY=t.pageY,this.lastPositionAbs=this.positionAbs=this._convertPositionTo("absolute"),this._mouseDrag(t),!0},_scroll:function(t){var e=this.options,i=!1;return this.scrollParent[0]!==this.document[0]&&"HTML"!==this.scrollParent[0].tagName?(this.overflowOffset.top+this.scrollParent[0].offsetHeight-t.pageYt[this.floating?"width":"height"]?h&&c:o",i.document[0]);return i._addClass(t,"ui-sortable-placeholder",s||i.currentItem[0].className)._removeClass(t,"ui-sortable-helper"),"tbody"===n?i._createTrPlaceholder(i.currentItem.find("tr").eq(0),V("",i.document[0]).appendTo(t)):"tr"===n?i._createTrPlaceholder(i.currentItem,t):"img"===n&&t.attr("src",i.currentItem.attr("src")),s||t.css("visibility","hidden"),t},update:function(t,e){s&&!o.forcePlaceholderSize||(e.height()&&(!o.forcePlaceholderSize||"tbody"!==n&&"tr"!==n)||e.height(i.currentItem.innerHeight()-parseInt(i.currentItem.css("paddingTop")||0,10)-parseInt(i.currentItem.css("paddingBottom")||0,10)),e.width()||e.width(i.currentItem.innerWidth()-parseInt(i.currentItem.css("paddingLeft")||0,10)-parseInt(i.currentItem.css("paddingRight")||0,10)))}}),i.placeholder=V(o.placeholder.element.call(i.element,i.currentItem)),i.currentItem.after(i.placeholder),o.placeholder.update(i,i.placeholder)},_createTrPlaceholder:function(t,e){var i=this;t.children().each(function(){V(" ",i.document[0]).attr("colspan",V(this).attr("colspan")||1).appendTo(e)})},_contactContainers:function(t){for(var e,i,s,n,o,a,r,l,h,c=null,u=null,d=this.containers.length-1;0<=d;d--)V.contains(this.currentItem[0],this.containers[d].element[0])||(this._intersectsWith(this.containers[d].containerCache)?c&&V.contains(this.containers[d].element[0],c.element[0])||(c=this.containers[d],u=d):this.containers[d].containerCache.over&&(this.containers[d]._trigger("out",t,this._uiHash(this)),this.containers[d].containerCache.over=0));if(c)if(1===this.containers.length)this.containers[u].containerCache.over||(this.containers[u]._trigger("over",t,this._uiHash(this)),this.containers[u].containerCache.over=1);else{for(i=1e4,s=null,n=(l=c.floating||this._isFloating(this.currentItem))?"left":"top",o=l?"width":"height",h=l?"pageX":"pageY",e=this.items.length-1;0<=e;e--)V.contains(this.containers[u].element[0],this.items[e].item[0])&&this.items[e].item[0]!==this.currentItem[0]&&(a=this.items[e].item.offset()[n],r=!1,t[h]-a>this.items[e][o]/2&&(r=!0),Math.abs(t[h]-a)this.containment[2]&&(i=this.containment[2]+this.offset.click.left),t.pageY-this.offset.click.top>this.containment[3]&&(s=this.containment[3]+this.offset.click.top)),e.grid&&(t=this.originalPageY+Math.round((s-this.originalPageY)/e.grid[1])*e.grid[1],s=!this.containment||t-this.offset.click.top>=this.containment[1]&&t-this.offset.click.top<=this.containment[3]?t:t-this.offset.click.top>=this.containment[1]?t-e.grid[1]:t+e.grid[1],t=this.originalPageX+Math.round((i-this.originalPageX)/e.grid[0])*e.grid[0],i=!this.containment||t-this.offset.click.left>=this.containment[0]&&t-this.offset.click.left<=this.containment[2]?t:t-this.offset.click.left>=this.containment[0]?t-e.grid[0]:t+e.grid[0])),{top:s-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.scrollParent.scrollTop():o?0:n.scrollTop()),left:i-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():o?0:n.scrollLeft())}},_rearrange:function(t,e,i,s){i?i[0].appendChild(this.placeholder[0]):e.item[0].parentNode.insertBefore(this.placeholder[0],"down"===this.direction?e.item[0]:e.item[0].nextSibling),this.counter=this.counter?++this.counter:1;var n=this.counter;this._delay(function(){n===this.counter&&this.refreshPositions(!s)})},_clear:function(t,e){this.reverting=!1;var i,s=[];if(!this._noFinalSort&&this.currentItem.parent().length&&this.placeholder.before(this.currentItem),this._noFinalSort=null,this.helper[0]===this.currentItem[0]){for(i in this._storedCSS)"auto"!==this._storedCSS[i]&&"static"!==this._storedCSS[i]||(this._storedCSS[i]="");this.currentItem.css(this._storedCSS),this._removeClass(this.currentItem,"ui-sortable-helper")}else this.currentItem.show();function n(e,i,s){return function(t){s._trigger(e,t,i._uiHash(i))}}for(this.fromOutside&&!e&&s.push(function(t){this._trigger("receive",t,this._uiHash(this.fromOutside))}),!this.fromOutside&&this.domPosition.prev===this.currentItem.prev().not(".ui-sortable-helper")[0]&&this.domPosition.parent===this.currentItem.parent()[0]||e||s.push(function(t){this._trigger("update",t,this._uiHash())}),this!==this.currentContainer&&(e||(s.push(function(t){this._trigger("remove",t,this._uiHash())}),s.push(function(e){return function(t){e._trigger("receive",t,this._uiHash(this))}}.call(this,this.currentContainer)),s.push(function(e){return function(t){e._trigger("update",t,this._uiHash(this))}}.call(this,this.currentContainer)))),i=this.containers.length-1;0<=i;i--)e||s.push(n("deactivate",this,this.containers[i])),this.containers[i].containerCache.over&&(s.push(n("out",this,this.containers[i])),this.containers[i].containerCache.over=0);if(this.storedCursor&&(this.document.find("body").css("cursor",this.storedCursor),this.storedStylesheet.remove()),this._storedOpacity&&this.helper.css("opacity",this._storedOpacity),this._storedZIndex&&this.helper.css("zIndex","auto"===this._storedZIndex?"":this._storedZIndex),this.dragging=!1,e||this._trigger("beforeStop",t,this._uiHash()),this.placeholder[0].parentNode.removeChild(this.placeholder[0]),this.cancelHelperRemoval||(this.helper[0]!==this.currentItem[0]&&this.helper.remove(),this.helper=null),!e){for(i=0;i li > :first-child").add(t.find("> :not(li)").even())},heightStyle:"auto",icons:{activeHeader:"ui-icon-triangle-1-s",header:"ui-icon-triangle-1-e"},activate:null,beforeActivate:null},hideProps:{borderTopWidth:"hide",borderBottomWidth:"hide",paddingTop:"hide",paddingBottom:"hide",height:"hide"},showProps:{borderTopWidth:"show",borderBottomWidth:"show",paddingTop:"show",paddingBottom:"show",height:"show"},_create:function(){var t=this.options;this.prevShow=this.prevHide=V(),this._addClass("ui-accordion","ui-widget ui-helper-reset"),this.element.attr("role","tablist"),t.collapsible||!1!==t.active&&null!=t.active||(t.active=0),this._processPanels(),t.active<0&&(t.active+=this.headers.length),this._refresh()},_getCreateEventData:function(){return{header:this.active,panel:this.active.length?this.active.next():V()}},_createIcons:function(){var t,e=this.options.icons;e&&(t=V(""),this._addClass(t,"ui-accordion-header-icon","ui-icon "+e.header),t.prependTo(this.headers),t=this.active.children(".ui-accordion-header-icon"),this._removeClass(t,e.header)._addClass(t,null,e.activeHeader)._addClass(this.headers,"ui-accordion-icons"))},_destroyIcons:function(){this._removeClass(this.headers,"ui-accordion-icons"),this.headers.children(".ui-accordion-header-icon").remove()},_destroy:function(){var t;this.element.removeAttr("role"),this.headers.removeAttr("role aria-expanded aria-selected aria-controls tabIndex").removeUniqueId(),this._destroyIcons(),t=this.headers.next().css("display","").removeAttr("role aria-hidden aria-labelledby").removeUniqueId(),"content"!==this.options.heightStyle&&t.css("height","")},_setOption:function(t,e){"active"!==t?("event"===t&&(this.options.event&&this._off(this.headers,this.options.event),this._setupEvents(e)),this._super(t,e),"collapsible"!==t||e||!1!==this.options.active||this._activate(0),"icons"===t&&(this._destroyIcons(),e&&this._createIcons())):this._activate(e)},_setOptionDisabled:function(t){this._super(t),this.element.attr("aria-disabled",t),this._toggleClass(null,"ui-state-disabled",!!t),this._toggleClass(this.headers.add(this.headers.next()),null,"ui-state-disabled",!!t)},_keydown:function(t){if(!t.altKey&&!t.ctrlKey){var e=V.ui.keyCode,i=this.headers.length,s=this.headers.index(t.target),n=!1;switch(t.keyCode){case e.RIGHT:case e.DOWN:n=this.headers[(s+1)%i];break;case e.LEFT:case e.UP:n=this.headers[(s-1+i)%i];break;case e.SPACE:case e.ENTER:this._eventHandler(t);break;case e.HOME:n=this.headers[0];break;case e.END:n=this.headers[i-1]}n&&(V(t.target).attr("tabIndex",-1),V(n).attr("tabIndex",0),V(n).trigger("focus"),t.preventDefault())}},_panelKeyDown:function(t){t.keyCode===V.ui.keyCode.UP&&t.ctrlKey&&V(t.currentTarget).prev().trigger("focus")},refresh:function(){var t=this.options;this._processPanels(),!1===t.active&&!0===t.collapsible||!this.headers.length?(t.active=!1,this.active=V()):!1===t.active?this._activate(0):this.active.length&&!V.contains(this.element[0],this.active[0])?this.headers.length===this.headers.find(".ui-state-disabled").length?(t.active=!1,this.active=V()):this._activate(Math.max(0,t.active-1)):t.active=this.headers.index(this.active),this._destroyIcons(),this._refresh()},_processPanels:function(){var t=this.headers,e=this.panels;"function"==typeof this.options.header?this.headers=this.options.header(this.element):this.headers=this.element.find(this.options.header),this._addClass(this.headers,"ui-accordion-header ui-accordion-header-collapsed","ui-state-default"),this.panels=this.headers.next().filter(":not(.ui-accordion-content-active)").hide(),this._addClass(this.panels,"ui-accordion-content","ui-helper-reset ui-widget-content"),e&&(this._off(t.not(this.headers)),this._off(e.not(this.panels)))},_refresh:function(){var i,t=this.options,e=t.heightStyle,s=this.element.parent();this.active=this._findActive(t.active),this._addClass(this.active,"ui-accordion-header-active","ui-state-active")._removeClass(this.active,"ui-accordion-header-collapsed"),this._addClass(this.active.next(),"ui-accordion-content-active"),this.active.next().show(),this.headers.attr("role","tab").each(function(){var t=V(this),e=t.uniqueId().attr("id"),i=t.next(),s=i.uniqueId().attr("id");t.attr("aria-controls",s),i.attr("aria-labelledby",e)}).next().attr("role","tabpanel"),this.headers.not(this.active).attr({"aria-selected":"false","aria-expanded":"false",tabIndex:-1}).next().attr({"aria-hidden":"true"}).hide(),this.active.length?this.active.attr({"aria-selected":"true","aria-expanded":"true",tabIndex:0}).next().attr({"aria-hidden":"false"}):this.headers.eq(0).attr("tabIndex",0),this._createIcons(),this._setupEvents(t.event),"fill"===e?(i=s.height(),this.element.siblings(":visible").each(function(){var t=V(this),e=t.css("position");"absolute"!==e&&"fixed"!==e&&(i-=t.outerHeight(!0))}),this.headers.each(function(){i-=V(this).outerHeight(!0)}),this.headers.next().each(function(){V(this).height(Math.max(0,i-V(this).innerHeight()+V(this).height()))}).css("overflow","auto")):"auto"===e&&(i=0,this.headers.next().each(function(){var t=V(this).is(":visible");t||V(this).show(),i=Math.max(i,V(this).css("height","").height()),t||V(this).hide()}).height(i))},_activate:function(t){t=this._findActive(t)[0];t!==this.active[0]&&(t=t||this.active[0],this._eventHandler({target:t,currentTarget:t,preventDefault:V.noop}))},_findActive:function(t){return"number"==typeof t?this.headers.eq(t):V()},_setupEvents:function(t){var i={keydown:"_keydown"};t&&V.each(t.split(" "),function(t,e){i[e]="_eventHandler"}),this._off(this.headers.add(this.headers.next())),this._on(this.headers,i),this._on(this.headers.next(),{keydown:"_panelKeyDown"}),this._hoverable(this.headers),this._focusable(this.headers)},_eventHandler:function(t){var e=this.options,i=this.active,s=V(t.currentTarget),n=s[0]===i[0],o=n&&e.collapsible,a=o?V():s.next(),r=i.next(),a={oldHeader:i,oldPanel:r,newHeader:o?V():s,newPanel:a};t.preventDefault(),n&&!e.collapsible||!1===this._trigger("beforeActivate",t,a)||(e.active=!o&&this.headers.index(s),this.active=n?V():s,this._toggle(a),this._removeClass(i,"ui-accordion-header-active","ui-state-active"),e.icons&&(i=i.children(".ui-accordion-header-icon"),this._removeClass(i,null,e.icons.activeHeader)._addClass(i,null,e.icons.header)),n||(this._removeClass(s,"ui-accordion-header-collapsed")._addClass(s,"ui-accordion-header-active","ui-state-active"),e.icons&&(n=s.children(".ui-accordion-header-icon"),this._removeClass(n,null,e.icons.header)._addClass(n,null,e.icons.activeHeader)),this._addClass(s.next(),"ui-accordion-content-active")))},_toggle:function(t){var e=t.newPanel,i=this.prevShow.length?this.prevShow:t.oldPanel;this.prevShow.add(this.prevHide).stop(!0,!0),this.prevShow=e,this.prevHide=i,this.options.animate?this._animate(e,i,t):(i.hide(),e.show(),this._toggleComplete(t)),i.attr({"aria-hidden":"true"}),i.prev().attr({"aria-selected":"false","aria-expanded":"false"}),e.length&&i.length?i.prev().attr({tabIndex:-1,"aria-expanded":"false"}):e.length&&this.headers.filter(function(){return 0===parseInt(V(this).attr("tabIndex"),10)}).attr("tabIndex",-1),e.attr("aria-hidden","false").prev().attr({"aria-selected":"true","aria-expanded":"true",tabIndex:0})},_animate:function(t,i,e){var s,n,o,a=this,r=0,l=t.css("box-sizing"),h=t.length&&(!i.length||t.index()",delay:300,options:{icons:{submenu:"ui-icon-caret-1-e"},items:"> *",menus:"ul",position:{my:"left top",at:"right top"},role:"menu",blur:null,focus:null,select:null},_create:function(){this.activeMenu=this.element,this.mouseHandled=!1,this.lastMousePosition={x:null,y:null},this.element.uniqueId().attr({role:this.options.role,tabIndex:0}),this._addClass("ui-menu","ui-widget ui-widget-content"),this._on({"mousedown .ui-menu-item":function(t){t.preventDefault(),this._activateItem(t)},"click .ui-menu-item":function(t){var e=V(t.target),i=V(V.ui.safeActiveElement(this.document[0]));!this.mouseHandled&&e.not(".ui-state-disabled").length&&(this.select(t),t.isPropagationStopped()||(this.mouseHandled=!0),e.has(".ui-menu").length?this.expand(t):!this.element.is(":focus")&&i.closest(".ui-menu").length&&(this.element.trigger("focus",[!0]),this.active&&1===this.active.parents(".ui-menu").length&&clearTimeout(this.timer)))},"mouseenter .ui-menu-item":"_activateItem","mousemove .ui-menu-item":"_activateItem",mouseleave:"collapseAll","mouseleave .ui-menu":"collapseAll",focus:function(t,e){var i=this.active||this._menuItems().first();e||this.focus(t,i)},blur:function(t){this._delay(function(){V.contains(this.element[0],V.ui.safeActiveElement(this.document[0]))||this.collapseAll(t)})},keydown:"_keydown"}),this.refresh(),this._on(this.document,{click:function(t){this._closeOnDocumentClick(t)&&this.collapseAll(t,!0),this.mouseHandled=!1}})},_activateItem:function(t){var e,i;this.previousFilter||t.clientX===this.lastMousePosition.x&&t.clientY===this.lastMousePosition.y||(this.lastMousePosition={x:t.clientX,y:t.clientY},e=V(t.target).closest(".ui-menu-item"),i=V(t.currentTarget),e[0]===i[0]&&(i.is(".ui-state-active")||(this._removeClass(i.siblings().children(".ui-state-active"),null,"ui-state-active"),this.focus(t,i))))},_destroy:function(){var t=this.element.find(".ui-menu-item").removeAttr("role aria-disabled").children(".ui-menu-item-wrapper").removeUniqueId().removeAttr("tabIndex role aria-haspopup");this.element.removeAttr("aria-activedescendant").find(".ui-menu").addBack().removeAttr("role aria-labelledby aria-expanded aria-hidden aria-disabled tabIndex").removeUniqueId().show(),t.children().each(function(){var t=V(this);t.data("ui-menu-submenu-caret")&&t.remove()})},_keydown:function(t){var e,i,s,n=!0;switch(t.keyCode){case V.ui.keyCode.PAGE_UP:this.previousPage(t);break;case V.ui.keyCode.PAGE_DOWN:this.nextPage(t);break;case V.ui.keyCode.HOME:this._move("first","first",t);break;case V.ui.keyCode.END:this._move("last","last",t);break;case V.ui.keyCode.UP:this.previous(t);break;case V.ui.keyCode.DOWN:this.next(t);break;case V.ui.keyCode.LEFT:this.collapse(t);break;case V.ui.keyCode.RIGHT:this.active&&!this.active.is(".ui-state-disabled")&&this.expand(t);break;case V.ui.keyCode.ENTER:case V.ui.keyCode.SPACE:this._activate(t);break;case V.ui.keyCode.ESCAPE:this.collapse(t);break;default:e=this.previousFilter||"",s=n=!1,i=96<=t.keyCode&&t.keyCode<=105?(t.keyCode-96).toString():String.fromCharCode(t.keyCode),clearTimeout(this.filterTimer),i===e?s=!0:i=e+i,e=this._filterMenuItems(i),(e=s&&-1!==e.index(this.active.next())?this.active.nextAll(".ui-menu-item"):e).length||(i=String.fromCharCode(t.keyCode),e=this._filterMenuItems(i)),e.length?(this.focus(t,e),this.previousFilter=i,this.filterTimer=this._delay(function(){delete this.previousFilter},1e3)):delete this.previousFilter}n&&t.preventDefault()},_activate:function(t){this.active&&!this.active.is(".ui-state-disabled")&&(this.active.children("[aria-haspopup='true']").length?this.expand(t):this.select(t))},refresh:function(){var t,e,s=this,n=this.options.icons.submenu,i=this.element.find(this.options.menus);this._toggleClass("ui-menu-icons",null,!!this.element.find(".ui-icon").length),e=i.filter(":not(.ui-menu)").hide().attr({role:this.options.role,"aria-hidden":"true","aria-expanded":"false"}).each(function(){var t=V(this),e=t.prev(),i=V("").data("ui-menu-submenu-caret",!0);s._addClass(i,"ui-menu-icon","ui-icon "+n),e.attr("aria-haspopup","true").prepend(i),t.attr("aria-labelledby",e.attr("id"))}),this._addClass(e,"ui-menu","ui-widget ui-widget-content ui-front"),(t=i.add(this.element).find(this.options.items)).not(".ui-menu-item").each(function(){var t=V(this);s._isDivider(t)&&s._addClass(t,"ui-menu-divider","ui-widget-content")}),i=(e=t.not(".ui-menu-item, .ui-menu-divider")).children().not(".ui-menu").uniqueId().attr({tabIndex:-1,role:this._itemRole()}),this._addClass(e,"ui-menu-item")._addClass(i,"ui-menu-item-wrapper"),t.filter(".ui-state-disabled").attr("aria-disabled","true"),this.active&&!V.contains(this.element[0],this.active[0])&&this.blur()},_itemRole:function(){return{menu:"menuitem",listbox:"option"}[this.options.role]},_setOption:function(t,e){var i;"icons"===t&&(i=this.element.find(".ui-menu-icon"),this._removeClass(i,null,this.options.icons.submenu)._addClass(i,null,e.submenu)),this._super(t,e)},_setOptionDisabled:function(t){this._super(t),this.element.attr("aria-disabled",String(t)),this._toggleClass(null,"ui-state-disabled",!!t)},focus:function(t,e){var i;this.blur(t,t&&"focus"===t.type),this._scrollIntoView(e),this.active=e.first(),i=this.active.children(".ui-menu-item-wrapper"),this._addClass(i,null,"ui-state-active"),this.options.role&&this.element.attr("aria-activedescendant",i.attr("id")),i=this.active.parent().closest(".ui-menu-item").children(".ui-menu-item-wrapper"),this._addClass(i,null,"ui-state-active"),t&&"keydown"===t.type?this._close():this.timer=this._delay(function(){this._close()},this.delay),(i=e.children(".ui-menu")).length&&t&&/^mouse/.test(t.type)&&this._startOpening(i),this.activeMenu=e.parent(),this._trigger("focus",t,{item:e})},_scrollIntoView:function(t){var e,i,s;this._hasScroll()&&(i=parseFloat(V.css(this.activeMenu[0],"borderTopWidth"))||0,s=parseFloat(V.css(this.activeMenu[0],"paddingTop"))||0,e=t.offset().top-this.activeMenu.offset().top-i-s,i=this.activeMenu.scrollTop(),s=this.activeMenu.height(),t=t.outerHeight(),e<0?this.activeMenu.scrollTop(i+e):s",options:{appendTo:null,autoFocus:!1,delay:300,minLength:1,position:{my:"left top",at:"left bottom",collision:"none"},source:null,change:null,close:null,focus:null,open:null,response:null,search:null,select:null},requestIndex:0,pending:0,liveRegionTimer:null,_create:function(){var i,s,n,t=this.element[0].nodeName.toLowerCase(),e="textarea"===t,t="input"===t;this.isMultiLine=e||!t&&this._isContentEditable(this.element),this.valueMethod=this.element[e||t?"val":"text"],this.isNewMenu=!0,this._addClass("ui-autocomplete-input"),this.element.attr("autocomplete","off"),this._on(this.element,{keydown:function(t){if(this.element.prop("readOnly"))s=n=i=!0;else{s=n=i=!1;var e=V.ui.keyCode;switch(t.keyCode){case e.PAGE_UP:i=!0,this._move("previousPage",t);break;case e.PAGE_DOWN:i=!0,this._move("nextPage",t);break;case e.UP:i=!0,this._keyEvent("previous",t);break;case e.DOWN:i=!0,this._keyEvent("next",t);break;case e.ENTER:this.menu.active&&(i=!0,t.preventDefault(),this.menu.select(t));break;case e.TAB:this.menu.active&&this.menu.select(t);break;case e.ESCAPE:this.menu.element.is(":visible")&&(this.isMultiLine||this._value(this.term),this.close(t),t.preventDefault());break;default:s=!0,this._searchTimeout(t)}}},keypress:function(t){if(i)return i=!1,void(this.isMultiLine&&!this.menu.element.is(":visible")||t.preventDefault());if(!s){var e=V.ui.keyCode;switch(t.keyCode){case e.PAGE_UP:this._move("previousPage",t);break;case e.PAGE_DOWN:this._move("nextPage",t);break;case e.UP:this._keyEvent("previous",t);break;case e.DOWN:this._keyEvent("next",t)}}},input:function(t){if(n)return n=!1,void t.preventDefault();this._searchTimeout(t)},focus:function(){this.selectedItem=null,this.previous=this._value()},blur:function(t){clearTimeout(this.searching),this.close(t),this._change(t)}}),this._initSource(),this.menu=V("