summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/modules')
-rw-r--r--plugins/jetpack/modules/after-the-deadline/config-unignore.php2
-rw-r--r--plugins/jetpack/modules/after-the-deadline/proxy.php4
-rw-r--r--plugins/jetpack/modules/comments/comments.php5
-rw-r--r--plugins/jetpack/modules/contact-form/admin.php2
-rw-r--r--plugins/jetpack/modules/contact-form/grunion-contact-form.php33
-rw-r--r--plugins/jetpack/modules/custom-css/csstidy/data.inc.php7
-rw-r--r--plugins/jetpack/modules/custom-css/custom-css/js/codemirror.min.js2
-rw-r--r--plugins/jetpack/modules/custom-post-types/js/nova-drag-drop.js5
-rw-r--r--plugins/jetpack/modules/markdown/easy-markdown.php2
-rw-r--r--plugins/jetpack/modules/masterbar/masterbar.php12
-rw-r--r--plugins/jetpack/modules/masterbar/overrides.css8
-rw-r--r--plugins/jetpack/modules/module-headings.php5
-rw-r--r--plugins/jetpack/modules/omnisearch/omnisearch-core.php14
-rw-r--r--plugins/jetpack/modules/omnisearch/omnisearch-jetpack-rtl.css11
-rw-r--r--plugins/jetpack/modules/omnisearch/omnisearch-jetpack-rtl.min.css1
-rw-r--r--plugins/jetpack/modules/omnisearch/omnisearch-jetpack.css10
-rw-r--r--plugins/jetpack/modules/omnisearch/omnisearch-jetpack.min.css2
-rw-r--r--plugins/jetpack/modules/omnisearch/rtl/omnisearch-jetpack-rtl.css11
-rw-r--r--plugins/jetpack/modules/omnisearch/rtl/omnisearch-rtl.css132
-rw-r--r--plugins/jetpack/modules/publicize/publicize-jetpack.php29
-rw-r--r--plugins/jetpack/modules/publicize/publicize.php2
-rw-r--r--plugins/jetpack/modules/search.php16
-rw-r--r--plugins/jetpack/modules/search/class.jetpack-search-widget-filters.php126
-rw-r--r--plugins/jetpack/modules/search/class.jetpack-search.php1313
-rw-r--r--plugins/jetpack/modules/seo-tools.php16
-rw-r--r--plugins/jetpack/modules/seo-tools/jetpack-seo-utils.php13
-rw-r--r--plugins/jetpack/modules/seo-tools/jetpack-seo.php51
-rw-r--r--plugins/jetpack/modules/shortcodes/js/jmpress.js2
-rw-r--r--plugins/jetpack/modules/shortcodes/recipe.php203
-rw-r--r--plugins/jetpack/modules/sitemaps/sitemap-builder.php42
-rw-r--r--plugins/jetpack/modules/stats.php2
-rw-r--r--plugins/jetpack/modules/theme-tools/featured-content.php13
-rw-r--r--plugins/jetpack/modules/theme-tools/social-links.php2
-rw-r--r--plugins/jetpack/modules/theme-tools/social-menu/icon-functions.php16
-rw-r--r--plugins/jetpack/modules/theme-tools/social-menu/social-menu.svg12
-rw-r--r--plugins/jetpack/modules/videopress/class.jetpack-videopress.php24
-rw-r--r--plugins/jetpack/modules/videopress/editor-media-view.php10
-rw-r--r--plugins/jetpack/modules/videopress/js/media-video-widget-extensions.js45
-rw-r--r--plugins/jetpack/modules/videopress/shortcode.php5
-rw-r--r--plugins/jetpack/modules/widgets.php2
-rw-r--r--plugins/jetpack/modules/widgets/contact-info.php2
-rw-r--r--plugins/jetpack/modules/widgets/eu-cookie-law/eu-cookie-law.js2
-rw-r--r--plugins/jetpack/modules/widgets/eu-cookie-law/style.css2
-rw-r--r--plugins/jetpack/modules/widgets/flickr.php18
-rw-r--r--plugins/jetpack/modules/widgets/flickr/form.php61
-rw-r--r--plugins/jetpack/modules/widgets/image-widget.php5
-rw-r--r--plugins/jetpack/modules/widgets/migrate-to-core/image-widget.php130
-rw-r--r--plugins/jetpack/modules/wordads/wordads.php4
48 files changed, 2059 insertions, 377 deletions
diff --git a/plugins/jetpack/modules/after-the-deadline/config-unignore.php b/plugins/jetpack/modules/after-the-deadline/config-unignore.php
index 9a7b9217..95088646 100644
--- a/plugins/jetpack/modules/after-the-deadline/config-unignore.php
+++ b/plugins/jetpack/modules/after-the-deadline/config-unignore.php
@@ -132,7 +132,7 @@ else
<p><?php _e( 'Identify words and phrases to ignore while proofreading your posts and pages:', 'jetpack' ); ?></p>
- <p><input type="text" id="AtD_add_ignore" name="AtD_add_ignore"> <input type="button" value="<?php _e( 'Add', 'jetpack' ); ?>" onclick="javascript:atd_ignore()"></p>
+ <p><input type="text" id="AtD_add_ignore" name="AtD_add_ignore"> <input type="button" value="<?php esc_attr_e( 'Add', 'jetpack' ); ?>" onclick="javascript:atd_ignore()"></p>
<div class="tagchecklist" id="atd_ignores"></div>
diff --git a/plugins/jetpack/modules/after-the-deadline/proxy.php b/plugins/jetpack/modules/after-the-deadline/proxy.php
index 08630235..d9bddfc8 100644
--- a/plugins/jetpack/modules/after-the-deadline/proxy.php
+++ b/plugins/jetpack/modules/after-the-deadline/proxy.php
@@ -87,8 +87,8 @@ function AtD_redirect_call() {
$atd_lang = get_locale();
// If we're on WPCOM, this function should be available.
- if ( function_exists( 'get_user_lang_code' ) ) {
- $atd_lang = get_user_lang_code( $user->ID );
+ if ( function_exists( 'get_user_locale' ) ) {
+ $atd_lang = get_user_locale( $user->ID );
}
if ( ! empty( $atd_lang ) ) {
diff --git a/plugins/jetpack/modules/comments/comments.php b/plugins/jetpack/modules/comments/comments.php
index ab00d491..1f17ec80 100644
--- a/plugins/jetpack/modules/comments/comments.php
+++ b/plugins/jetpack/modules/comments/comments.php
@@ -275,7 +275,8 @@ class Jetpack_Comments extends Highlander_Comments_Base {
}
$params['sig'] = $signature;
- $url = "https://jetpack.wordpress.com/jetpack-comment/?" . http_build_query( $params );
+ $url_origin = set_url_scheme( 'http://jetpack.wordpress.com' );
+ $url = "{$url_origin}/jetpack-comment/?" . http_build_query( $params );
$url = "{$url}#parent=" . urlencode( set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ) );
$this->signed_url = $url;
$height = $params['comment_registration'] || is_user_logged_in() ? '315' : '430'; // Iframe can be shorter if we're not allowing guest commenting
@@ -332,7 +333,7 @@ class Jetpack_Comments extends Highlander_Comments_Base {
* @since JetpackComments (1.4)
*/
public function watch_comment_parent() {
- $url_origin = 'https://jetpack.wordpress.com';
+ $url_origin = set_url_scheme( 'http://jetpack.wordpress.com' );
?>
<!--[if IE]>
diff --git a/plugins/jetpack/modules/contact-form/admin.php b/plugins/jetpack/modules/contact-form/admin.php
index b6667204..062a2c72 100644
--- a/plugins/jetpack/modules/contact-form/admin.php
+++ b/plugins/jetpack/modules/contact-form/admin.php
@@ -696,7 +696,7 @@ function grunion_ajax_spam() {
*/
$subject = apply_filters( 'contact_form_subject', $content_fields['_feedback_subject'], $content_fields['_feedback_all_fields'] );
- wp_mail( $to, $subject, $message, $headers );
+ Grunion_Contact_Form::wp_mail( $to, $subject, $message, $headers );
}
} elseif( $_POST['make_it'] == 'publish' ) {
if ( ! current_user_can($post_type_object->cap->delete_post, $post_id) ) {
diff --git a/plugins/jetpack/modules/contact-form/grunion-contact-form.php b/plugins/jetpack/modules/contact-form/grunion-contact-form.php
index 9c858a4e..d0f06856 100644
--- a/plugins/jetpack/modules/contact-form/grunion-contact-form.php
+++ b/plugins/jetpack/modules/contact-form/grunion-contact-form.php
@@ -938,7 +938,7 @@ class Grunion_Contact_Form_Plugin {
*
* @return string
*/
- function esc_csv( $field ) {
+ public function esc_csv( $field ) {
$active_content_triggers = array( '=', '+', '-', '@' );
if ( in_array( mb_substr( $field, 0, 1 ), $active_content_triggers, true ) ) {
@@ -2150,8 +2150,6 @@ class Grunion_Contact_Form extends Crunion_Contact_Form_Shortcode {
wp_schedule_event( time() + 250, 'daily', 'grunion_scheduled_delete' );
}
- add_filter( 'wp_mail_content_type', __CLASS__ . '::get_mail_content_type' );
- add_action( 'phpmailer_init', __CLASS__ . '::add_plain_text_alternative' );
if (
$is_spam !== true &&
/**
@@ -2166,7 +2164,7 @@ class Grunion_Contact_Form extends Crunion_Contact_Form_Shortcode {
*/
true === apply_filters( 'grunion_should_send_email', true, $post_id )
) {
- wp_mail( $to, "{$spam}{$subject}", $message, $headers );
+ self::wp_mail( $to, "{$spam}{$subject}", $message, $headers );
} elseif (
true === $is_spam &&
/**
@@ -2180,10 +2178,8 @@ class Grunion_Contact_Form extends Crunion_Contact_Form_Shortcode {
*/
apply_filters( 'grunion_still_email_spam', false ) == true
) { // don't send spam by default. Filterable.
- wp_mail( $to, "{$spam}{$subject}", $message, $headers );
+ self::wp_mail( $to, "{$spam}{$subject}", $message, $headers );
}
- remove_filter( 'wp_mail_content_type', __CLASS__ . '::get_mail_content_type' );
- remove_action( 'phpmailer_init', __CLASS__ . '::add_plain_text_alternative' );
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
return self::success_message( $post_id, $this );
@@ -2218,6 +2214,29 @@ class Grunion_Contact_Form extends Crunion_Contact_Form_Shortcode {
}
/**
+ * Wrapper for wp_mail() that enables HTML messages with text alternatives
+ *
+ * @param string|array $to Array or comma-separated list of email addresses to send message.
+ * @param string $subject Email subject.
+ * @param string $message Message contents.
+ * @param string|array $headers Optional. Additional headers.
+ * @param string|array $attachments Optional. Files to attach.
+ *
+ * @return bool Whether the email contents were sent successfully.
+ */
+ public static function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() ) {
+ add_filter( 'wp_mail_content_type', __CLASS__ . '::get_mail_content_type' );
+ add_action( 'phpmailer_init', __CLASS__ . '::add_plain_text_alternative' );
+
+ $result = wp_mail( $to, $subject, $message, $headers, $attachments );
+
+ remove_filter( 'wp_mail_content_type', __CLASS__ . '::get_mail_content_type' );
+ remove_action( 'phpmailer_init', __CLASS__ . '::add_plain_text_alternative' );
+
+ return $result;
+ }
+
+ /**
* Add a display name part to an email address
*
* SpamAssassin doesn't like addresses in HTML messages that are missing display names (e.g., `foo@bar.org`
diff --git a/plugins/jetpack/modules/custom-css/csstidy/data.inc.php b/plugins/jetpack/modules/custom-css/csstidy/data.inc.php
index 9b604417..f65869a6 100644
--- a/plugins/jetpack/modules/custom-css/csstidy/data.inc.php
+++ b/plugins/jetpack/modules/custom-css/csstidy/data.inc.php
@@ -302,6 +302,7 @@ $GLOBALS['csstidy']['all_properties']['animation'] = 'CSS3.0';
$GLOBALS['csstidy']['all_properties']['animation-delay'] = 'CSS3.0';
$GLOBALS['csstidy']['all_properties']['animation-direction'] = 'CSS3.0';
$GLOBALS['csstidy']['all_properties']['animation-duration'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['animation-fill-mode'] = 'CSS3.0';
$GLOBALS['csstidy']['all_properties']['animation-iteration-count'] = 'CSS3.0';
$GLOBALS['csstidy']['all_properties']['animation-name'] = 'CSS3.0';
$GLOBALS['csstidy']['all_properties']['animation-play-state'] = 'CSS3.0';
@@ -399,6 +400,7 @@ $GLOBALS['csstidy']['all_properties']['drop-initial-size'] = 'CSS3.0';
$GLOBALS['csstidy']['all_properties']['drop-initial-value'] = 'CSS3.0';
$GLOBALS['csstidy']['all_properties']['elevation'] = 'CSS2.0,CSS2.1,CSS3.0';
$GLOBALS['csstidy']['all_properties']['empty-cells'] = 'CSS2.0,CSS2.1,CSS3.0';
+$GLOBALS['csstidy']['all_properties']['fill'] = 'CSS3.0';
$GLOBALS['csstidy']['all_properties']['fit'] = 'CSS3.0';
$GLOBALS['csstidy']['all_properties']['fit-position'] = 'CSS3.0';
$GLOBALS['csstidy']['all_properties']['flex'] = 'CSS3.0';
@@ -530,6 +532,7 @@ $GLOBALS['csstidy']['all_properties']['speech-rate'] = 'CSS2.0,CSS2.1,CSS3.0';
$GLOBALS['csstidy']['all_properties']['src'] = 'CSS3.0';
$GLOBALS['csstidy']['all_properties']['stress'] = 'CSS2.0,CSS2.1,CSS3.0';
$GLOBALS['csstidy']['all_properties']['string-set'] = 'CSS3.0';
+$GLOBALS['csstidy']['all_properties']['stroke'] = 'CSS3.0';
$GLOBALS['csstidy']['all_properties']['tab-size'] = 'CSS3.0';
$GLOBALS['csstidy']['all_properties']['table-layout'] = 'CSS2.0,CSS2.1,CSS3.0';
$GLOBALS['csstidy']['all_properties']['target'] = 'CSS3.0';
@@ -667,6 +670,4 @@ $GLOBALS['csstidy']['predefined_templates']['low_compression'][] = '<span class=
$GLOBALS['csstidy']['predefined_templates']['low_compression'][] = '</span>'."\n"; // after comment
$GLOBALS['csstidy']['predefined_templates']['low_compression'][] = "\n";
-require dirname( __FILE__ ) . '/data-wp.inc.php';
-
-?>
+require dirname( __FILE__ ) . '/data-wp.inc.php'; \ No newline at end of file
diff --git a/plugins/jetpack/modules/custom-css/custom-css/js/codemirror.min.js b/plugins/jetpack/modules/custom-css/custom-css/js/codemirror.min.js
index bc7757c8..efc8a0fb 100644
--- a/plugins/jetpack/modules/custom-css/custom-css/js/codemirror.min.js
+++ b/plugins/jetpack/modules/custom-css/custom-css/js/codemirror.min.js
@@ -7,5 +7,5 @@
window.CodeMirror=function(){"use strict";function x(a,c){if(!(this instanceof x))return new x(a,c);this.options=c=c||{};for(var d in _c)!c.hasOwnProperty(d)&&_c.hasOwnProperty(d)&&(c[d]=_c[d]);J(c);var e="string"==typeof c.value?0:c.value.first,f=this.display=y(a,e);f.wrapper.CodeMirror=this,G(this),c.autofocus&&!p&&Nb(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,focused:!1,suppressEdits:!1,pasteIncoming:!1,draggingText:!1,highlight:new Xe},E(this),c.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap");var g=c.value;"string"==typeof g&&(g=new ge(c.value,c.mode)),Fb(this,ke)(this,g),b&&setTimeout(ff(Mb,this,!0),20),Pb(this);var h;try{h=document.activeElement==f.input}catch(i){}h||c.autofocus&&!p?setTimeout(ff(mc,this),20):nc(this),Fb(this,function(){for(var a in $c)$c.propertyIsEnumerable(a)&&$c[a](this,c[a],bd);for(var b=0;b<fd.length;++b)fd[b](this)})()}function y(a,b){var d={},e=d.input=lf("textarea",null,null,"position: absolute; padding: 0; width: 1px; height: 1em; outline: none; font-size: 4px;");return f?e.style.width="1000px":e.setAttribute("wrap","off"),o&&(e.style.border="1px solid black"),e.setAttribute("autocorrect","off"),e.setAttribute("autocapitalize","off"),e.setAttribute("spellcheck","false"),d.inputDiv=lf("div",[e],null,"overflow: hidden; position: relative; width: 3px; height: 0px;"),d.scrollbarH=lf("div",[lf("div",null,null,"height: 1px")],"CodeMirror-hscrollbar"),d.scrollbarV=lf("div",[lf("div",null,null,"width: 1px")],"CodeMirror-vscrollbar"),d.scrollbarFiller=lf("div",null,"CodeMirror-scrollbar-filler"),d.gutterFiller=lf("div",null,"CodeMirror-gutter-filler"),d.lineDiv=lf("div",null,"CodeMirror-code"),d.selectionDiv=lf("div",null,null,"position: relative; z-index: 1"),d.cursor=lf("div","\xa0","CodeMirror-cursor"),d.otherCursor=lf("div","\xa0","CodeMirror-cursor CodeMirror-secondarycursor"),d.measure=lf("div",null,"CodeMirror-measure"),d.lineSpace=lf("div",[d.measure,d.selectionDiv,d.lineDiv,d.cursor,d.otherCursor],null,"position: relative; outline: none"),d.mover=lf("div",[lf("div",[d.lineSpace],"CodeMirror-lines")],null,"position: relative"),d.sizer=lf("div",[d.mover],"CodeMirror-sizer"),d.heightForcer=lf("div",null,null,"position: absolute; height: "+Ve+"px; width: 1px;"),d.gutters=lf("div",null,"CodeMirror-gutters"),d.lineGutter=null,d.scroller=lf("div",[d.sizer,d.heightForcer,d.gutters],"CodeMirror-scroll"),d.scroller.setAttribute("tabIndex","-1"),d.wrapper=lf("div",[d.inputDiv,d.scrollbarH,d.scrollbarV,d.scrollbarFiller,d.gutterFiller,d.scroller],"CodeMirror"),c&&(d.gutters.style.zIndex=-1,d.scroller.style.paddingRight=0),a.appendChild?a.appendChild(d.wrapper):a(d.wrapper),o&&(e.style.width="0px"),f||(d.scroller.draggable=!0),k?(d.inputDiv.style.height="1px",d.inputDiv.style.position="absolute"):c&&(d.scrollbarH.style.minWidth=d.scrollbarV.style.minWidth="18px"),d.viewOffset=d.lastSizeC=0,d.showingFrom=d.showingTo=b,d.lineNumWidth=d.lineNumInnerWidth=d.lineNumChars=null,d.prevInput="",d.alignWidgets=!1,d.pollingFast=!1,d.poll=new Xe,d.cachedCharWidth=d.cachedTextHeight=null,d.measureLineCache=[],d.measureLineCachePos=0,d.inaccurateSelection=!1,d.maxLine=null,d.maxLineLength=0,d.maxLineChanged=!1,d.wheelDX=d.wheelDY=d.wheelStartX=d.wheelStartY=null,d}function z(a){a.doc.mode=x.getMode(a.options,a.doc.modeOption),a.doc.iter(function(a){a.stateAfter&&(a.stateAfter=null),a.styles&&(a.styles=null)}),a.doc.frontier=a.doc.first,bb(a,100),a.state.modeGen++,a.curOp&&Ib(a)}function A(a){a.options.lineWrapping?(a.display.wrapper.className+=" CodeMirror-wrap",a.display.sizer.style.minWidth=""):(a.display.wrapper.className=a.display.wrapper.className.replace(" CodeMirror-wrap",""),I(a)),C(a),Ib(a),pb(a),setTimeout(function(){K(a)},100)}function B(a){var b=Ab(a.display),c=a.options.lineWrapping,d=c&&Math.max(5,a.display.scroller.clientWidth/Bb(a.display)-3);return function(e){return Gd(a.doc,e)?0:c?(Math.ceil(e.text.length/d)||1)*b:b}}function C(a){var b=a.doc,c=B(a);b.iter(function(a){var b=c(a);b!=a.height&&oe(a,b)})}function D(a){var b=kd[a.options.keyMap],c=b.style;a.display.wrapper.className=a.display.wrapper.className.replace(/\s*cm-keymap-\S+/g,"")+(c?" cm-keymap-"+c:""),a.state.disableInput=b.disableInput}function E(a){a.display.wrapper.className=a.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+a.options.theme.replace(/(^|\s)\s*/g," cm-s-"),pb(a)}function F(a){G(a),Ib(a),setTimeout(function(){M(a)},20)}function G(a){var b=a.display.gutters,c=a.options.gutters;mf(b);for(var d=0;d<c.length;++d){var e=c[d],f=b.appendChild(lf("div",null,"CodeMirror-gutter "+e));"CodeMirror-linenumbers"==e&&(a.display.lineGutter=f,f.style.width=(a.display.lineNumWidth||1)+"px")}b.style.display=d?"":"none"}function H(a,b){if(0==b.height)return 0;for(var d,c=b.text.length,e=b;d=Dd(e);){var f=d.find();e=le(a,f.from.line),c+=f.from.ch-f.to.ch}for(e=b;d=Ed(e);){var f=d.find();c-=e.text.length-f.from.ch,e=le(a,f.to.line),c+=e.text.length-f.to.ch}return c}function I(a){var b=a.display,c=a.doc;b.maxLine=le(c,c.first),b.maxLineLength=H(c,b.maxLine),b.maxLineChanged=!0,c.iter(function(a){var d=H(c,a);d>b.maxLineLength&&(b.maxLineLength=d,b.maxLine=a)})}function J(a){var b=bf(a.gutters,"CodeMirror-linenumbers");-1==b&&a.lineNumbers?a.gutters=a.gutters.concat(["CodeMirror-linenumbers"]):b>-1&&!a.lineNumbers&&(a.gutters=a.gutters.slice(0),a.gutters.splice(b,1))}function K(a){var b=a.display,c=a.doc.height,d=c+gb(b);b.sizer.style.minHeight=b.heightForcer.style.top=d+"px",b.gutters.style.height=Math.max(d,b.scroller.clientHeight-Ve)+"px";var e=Math.max(d,b.scroller.scrollHeight),f=b.scroller.scrollWidth>b.scroller.clientWidth+1,g=e>b.scroller.clientHeight+1;g?(b.scrollbarV.style.display="block",b.scrollbarV.style.bottom=f?tf(b.measure)+"px":"0",b.scrollbarV.firstChild.style.height=e-b.scroller.clientHeight+b.scrollbarV.clientHeight+"px"):(b.scrollbarV.style.display="",b.scrollbarV.firstChild.style.height="0"),f?(b.scrollbarH.style.display="block",b.scrollbarH.style.right=g?tf(b.measure)+"px":"0",b.scrollbarH.firstChild.style.width=b.scroller.scrollWidth-b.scroller.clientWidth+b.scrollbarH.clientWidth+"px"):(b.scrollbarH.style.display="",b.scrollbarH.firstChild.style.width="0"),f&&g?(b.scrollbarFiller.style.display="block",b.scrollbarFiller.style.height=b.scrollbarFiller.style.width=tf(b.measure)+"px"):b.scrollbarFiller.style.display="",f&&a.options.coverGutterNextToScrollbar&&a.options.fixedGutter?(b.gutterFiller.style.display="block",b.gutterFiller.style.height=tf(b.measure)+"px",b.gutterFiller.style.width=b.gutters.offsetWidth+"px"):b.gutterFiller.style.display="",l&&0===tf(b.measure)&&(b.scrollbarV.style.minWidth=b.scrollbarH.style.minHeight=m?"18px":"12px",b.scrollbarV.style.pointerEvents=b.scrollbarH.style.pointerEvents="none")}function L(a,b,c){var d=a.scroller.scrollTop,e=a.wrapper.clientHeight;"number"==typeof c?d=c:c&&(d=c.top,e=c.bottom-c.top),d=Math.floor(d-fb(a));var f=Math.ceil(d+e);return{from:qe(b,d),to:qe(b,f)}}function M(a){var b=a.display;if(b.alignWidgets||b.gutters.firstChild&&a.options.fixedGutter){for(var c=P(b)-b.scroller.scrollLeft+a.doc.scrollLeft,d=b.gutters.offsetWidth,e=c+"px",f=b.lineDiv.firstChild;f;f=f.nextSibling)if(f.alignable)for(var g=0,h=f.alignable;g<h.length;++g)h[g].style.left=e;a.options.fixedGutter&&(b.gutters.style.left=c+d+"px")}}function N(a){if(!a.options.lineNumbers)return!1;var b=a.doc,c=O(a.options,b.first+b.size-1),d=a.display;if(c.length!=d.lineNumChars){var e=d.measure.appendChild(lf("div",[lf("div",c)],"CodeMirror-linenumber CodeMirror-gutter-elt")),f=e.firstChild.offsetWidth,g=e.offsetWidth-f;return d.lineGutter.style.width="",d.lineNumInnerWidth=Math.max(f,d.lineGutter.offsetWidth-g),d.lineNumWidth=d.lineNumInnerWidth+g,d.lineNumChars=d.lineNumInnerWidth?c.length:-1,d.lineGutter.style.width=d.lineNumWidth+"px",!0}return!1}function O(a,b){return String(a.lineNumberFormatter(b+a.firstLineNumber))}function P(a){return pf(a.scroller).left-pf(a.sizer).left}function Q(a,b,c,d){for(var g,e=a.display.showingFrom,f=a.display.showingTo,h=L(a.display,a.doc,c),i=!0;;i=!1){var j=a.display.scroller.clientWidth;if(!R(a,b,h,d))break;if(g=!0,b=[],Z(a),K(a),i&&a.options.lineWrapping&&j!=a.display.scroller.clientWidth)d=!0;else if(d=!1,c&&(c=Math.min(a.display.scroller.scrollHeight-a.display.scroller.clientHeight,"number"==typeof c?c:c.top)),h=L(a.display,a.doc,c),h.from>=a.display.showingFrom&&h.to<=a.display.showingTo)break}return g&&(Qe(a,"update",a),(a.display.showingFrom!=e||a.display.showingTo!=f)&&Qe(a,"viewportChange",a,a.display.showingFrom,a.display.showingTo)),g}function R(a,b,c,d){var e=a.display,f=a.doc;if(!e.wrapper.clientWidth)return e.showingFrom=e.showingTo=f.first,e.viewOffset=0,void 0;if(!(!d&&0==b.length&&c.from>e.showingFrom&&c.to<e.showingTo)){N(a)&&(b=[{from:f.first,to:f.first+f.size}]);var g=e.sizer.style.marginLeft=e.gutters.offsetWidth+"px";e.scrollbarH.style.left=a.options.fixedGutter?g:"0";var h=1/0;if(a.options.lineNumbers)for(var i=0;i<b.length;++i)b[i].diff&&b[i].from<h&&(h=b[i].from);var j=f.first+f.size,k=Math.max(c.from-a.options.viewportMargin,f.first),l=Math.min(j,c.to+a.options.viewportMargin);if(e.showingFrom<k&&k-e.showingFrom<20&&(k=Math.max(f.first,e.showingFrom)),e.showingTo>l&&e.showingTo-l<20&&(l=Math.min(j,e.showingTo)),w)for(k=pe(Fd(f,le(f,k)));j>l&&Gd(f,le(f,l));)++l;var m=[{from:Math.max(e.showingFrom,f.first),to:Math.min(e.showingTo,j)}];if(m=m[0].from>=m[0].to?[]:U(m,b),w)for(var i=0;i<m.length;++i)for(var o,n=m[i];o=Ed(le(f,n.to-1));){var p=o.find().from.line;if(!(p>n.from)){m.splice(i--,1);break}n.to=p}for(var q=0,i=0;i<m.length;++i){var n=m[i];n.from<k&&(n.from=k),n.to>l&&(n.to=l),n.from>=n.to?m.splice(i--,1):q+=n.to-n.from}if(!d&&q==l-k&&k==e.showingFrom&&l==e.showingTo)return T(a),void 0;m.sort(function(a,b){return a.from-b.from});try{var r=document.activeElement}catch(s){}.7*(l-k)>q&&(e.lineDiv.style.display="none"),W(a,k,l,m,h),e.lineDiv.style.display="",r&&document.activeElement!=r&&r.offsetHeight&&r.focus();var t=k!=e.showingFrom||l!=e.showingTo||e.lastSizeC!=e.wrapper.clientHeight;return t&&(e.lastSizeC=e.wrapper.clientHeight,bb(a,400)),e.showingFrom=k,e.showingTo=l,S(a),T(a),!0}}function S(a){for(var f,b=a.display,d=b.lineDiv.offsetTop,e=b.lineDiv.firstChild;e;e=e.nextSibling)if(e.lineObj){if(c){var g=e.offsetTop+e.offsetHeight;f=g-d,d=g}else{var h=pf(e);f=h.bottom-h.top}var i=e.lineObj.height-f;if(2>f&&(f=Ab(b)),i>.001||-.001>i){oe(e.lineObj,f);var j=e.lineObj.widgets;if(j)for(var k=0;k<j.length;++k)j[k].height=j[k].node.offsetHeight}}}function T(a){var b=a.display.viewOffset=re(a,le(a.doc,a.display.showingFrom));a.display.mover.style.top=b+"px"}function U(a,b){for(var c=0,d=b.length||0;d>c;++c){for(var e=b[c],f=[],g=e.diff||0,h=0,i=a.length;i>h;++h){var j=a[h];e.to<=j.from&&e.diff?f.push({from:j.from+g,to:j.to+g}):e.to<=j.from||e.from>=j.to?f.push(j):(e.from>j.from&&f.push({from:j.from,to:e.from}),e.to<j.to&&f.push({from:e.to+g,to:j.to+g}))}a=f}return a}function V(a){for(var b=a.display,c={},d={},e=b.gutters.firstChild,f=0;e;e=e.nextSibling,++f)c[a.options.gutters[f]]=e.offsetLeft,d[a.options.gutters[f]]=e.offsetWidth;return{fixedPos:P(b),gutterTotalWidth:b.gutters.offsetWidth,gutterLeft:c,gutterWidth:d,wrapperWidth:b.wrapper.clientWidth}}function W(a,b,c,d,e){function l(b){var c=b.nextSibling;return f&&q&&a.display.currentWheelTarget==b?(b.style.display="none",b.lineObj=null):b.parentNode.removeChild(b),c}var g=V(a),h=a.display,i=a.options.lineNumbers;d.length||f&&a.display.currentWheelTarget||mf(h.lineDiv);var j=h.lineDiv,k=j.firstChild,m=d.shift(),n=b;for(a.doc.iter(b,c,function(b){if(m&&m.to==n&&(m=d.shift()),Gd(a.doc,b)){if(0!=b.height&&oe(b,0),b.widgets&&k&&k.previousSibling)for(var c=0;c<b.widgets.length;++c){var f=b.widgets[c];if(f.showIfHidden){var h=k.previousSibling;if(/pre/i.test(h.nodeName)){var o=lf("div",null,null,"position: relative");h.parentNode.replaceChild(o,h),o.appendChild(h),h=o}var p=h.appendChild(lf("div",[f.node],"CodeMirror-linewidget"));f.handleMouseEvents||(p.ignoreEvents=!0),Y(f,p,h,g)}}}else if(m&&m.from<=n&&m.to>n){for(;k.lineObj!=b;)k=l(k);i&&n>=e&&k.lineNumber&&of(k.lineNumber,O(a.options,n)),k=k.nextSibling}else{if(b.widgets)for(var s,q=0,r=k;r&&20>q;++q,r=r.nextSibling)if(r.lineObj==b&&/div/i.test(r.nodeName)){s=r;break}var t=X(a,b,n,g,s);if(t!=s)j.insertBefore(t,k);else{for(;k!=s;)k=l(k);k=k.nextSibling}t.lineObj=b}++n});k;)k=l(k)}function X(a,b,d,e,f){var k,g=Xd(a,b),h=g.pre,i=b.gutterMarkers,j=a.display,l=g.bgClass?g.bgClass+" "+(b.bgClass||""):b.bgClass;if(!(a.options.lineNumbers||i||l||b.wrapClass||b.widgets))return h;if(f){f.alignable=null;for(var q,m=!0,n=0,o=null,p=f.firstChild;p;p=q)if(q=p.nextSibling,/\bCodeMirror-linewidget\b/.test(p.className)){for(var r=0;r<b.widgets.length;++r){var s=b.widgets[r];if(s.node==p.firstChild){s.above||o||(o=p),Y(s,p,f,e),++n;break}}if(r==b.widgets.length){m=!1;break}}else f.removeChild(p);f.insertBefore(h,o),m&&n==b.widgets.length&&(k=f,f.className=b.wrapClass||"")}if(k||(k=lf("div",null,b.wrapClass,"position: relative"),k.appendChild(h)),l&&k.insertBefore(lf("div",null,l+" CodeMirror-linebackground"),k.firstChild),a.options.lineNumbers||i){var t=k.insertBefore(lf("div",null,null,"position: absolute; left: "+(a.options.fixedGutter?e.fixedPos:-e.gutterTotalWidth)+"px"),k.firstChild);if(a.options.fixedGutter&&(k.alignable||(k.alignable=[])).push(t),!a.options.lineNumbers||i&&i["CodeMirror-linenumbers"]||(k.lineNumber=t.appendChild(lf("div",O(a.options,d),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+e.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+j.lineNumInnerWidth+"px"))),i)for(var u=0;u<a.options.gutters.length;++u){var v=a.options.gutters[u],w=i.hasOwnProperty(v)&&i[v];w&&t.appendChild(lf("div",[w],"CodeMirror-gutter-elt","left: "+e.gutterLeft[v]+"px; width: "+e.gutterWidth[v]+"px"))}}if(c&&(k.style.zIndex=2),b.widgets&&k!=f)for(var r=0,x=b.widgets;r<x.length;++r){var s=x[r],y=lf("div",[s.node],"CodeMirror-linewidget");s.handleMouseEvents||(y.ignoreEvents=!0),Y(s,y,k,e),s.above?k.insertBefore(y,a.options.lineNumbers&&0!=b.height?t:h):k.appendChild(y),Qe(s,"redraw")}return k}function Y(a,b,c,d){if(a.noHScroll){(c.alignable||(c.alignable=[])).push(b);var e=d.wrapperWidth;b.style.left=d.fixedPos+"px",a.coverGutter||(e-=d.gutterTotalWidth,b.style.paddingLeft=d.gutterTotalWidth+"px"),b.style.width=e+"px"}a.coverGutter&&(b.style.zIndex=5,b.style.position="relative",a.noHScroll||(b.style.marginLeft=-d.gutterTotalWidth+"px"))}function Z(a){var b=a.display,c=Cc(a.doc.sel.from,a.doc.sel.to);if(c||a.options.showCursorWhenSelecting?$(a):b.cursor.style.display=b.otherCursor.style.display="none",c?b.selectionDiv.style.display="none":_(a),a.options.moveInputWithCursor){var d=vb(a,a.doc.sel.head,"div"),e=pf(b.wrapper),f=pf(b.lineDiv);b.inputDiv.style.top=Math.max(0,Math.min(b.wrapper.clientHeight-10,d.top+f.top-e.top))+"px",b.inputDiv.style.left=Math.max(0,Math.min(b.wrapper.clientWidth-10,d.left+f.left-e.left))+"px"}}function $(a){var b=a.display,c=vb(a,a.doc.sel.head,"div");b.cursor.style.left=c.left+"px",b.cursor.style.top=c.top+"px",b.cursor.style.height=Math.max(0,c.bottom-c.top)*a.options.cursorHeight+"px",b.cursor.style.display="",c.other?(b.otherCursor.style.display="",b.otherCursor.style.left=c.other.left+"px",b.otherCursor.style.top=c.other.top+"px",b.otherCursor.style.height=.85*(c.other.bottom-c.other.top)+"px"):b.otherCursor.style.display="none"}function _(a){function h(a,b,c,d){0>b&&(b=0),e.appendChild(lf("div",null,"CodeMirror-selected","position: absolute; left: "+a+"px; top: "+b+"px; width: "+(null==c?f-a:c)+"px; height: "+(d-b)+"px"))}function i(b,d,e){function m(c,d){return ub(a,Bc(b,c),"div",i,d)}var k,l,i=le(c,b),j=i.text.length;return Af(se(i),d||0,null==e?j:e,function(a,b,c){var n,o,p,i=m(a,"left");if(a==b)n=i,o=p=i.left;else{if(n=m(b-1,"right"),"rtl"==c){var q=i;i=n,n=q}o=i.left,p=n.right}null==d&&0==a&&(o=g),n.top-i.top>3&&(h(o,i.top,null,i.bottom),o=g,i.bottom<n.top&&h(o,i.bottom,null,n.top)),null==e&&b==j&&(p=f),(!k||i.top<k.top||i.top==k.top&&i.left<k.left)&&(k=i),(!l||n.bottom>l.bottom||n.bottom==l.bottom&&n.right>l.right)&&(l=n),g+1>o&&(o=g),h(o,n.top,p-o,n.bottom)}),{start:k,end:l}}var b=a.display,c=a.doc,d=a.doc.sel,e=document.createDocumentFragment(),f=b.lineSpace.offsetWidth,g=hb(a.display);if(d.from.line==d.to.line)i(d.from.line,d.from.ch,d.to.ch);else{var j=le(c,d.from.line),k=le(c,d.to.line),l=Fd(c,j)==Fd(c,k),m=i(d.from.line,d.from.ch,l?j.text.length:null).end,n=i(d.to.line,l?0:null,d.to.ch).start;l&&(m.top<n.top-2?(h(m.right,m.top,null,m.bottom),h(g,n.top,n.left,n.bottom)):h(m.right,m.top,n.left-m.right,m.bottom)),m.bottom<n.top&&h(g,m.bottom,null,n.top)}nf(b.selectionDiv,e),b.selectionDiv.style.display=""}function ab(a){if(a.state.focused){var b=a.display;clearInterval(b.blinker);var c=!0;b.cursor.style.visibility=b.otherCursor.style.visibility="",a.options.cursorBlinkRate>0&&(b.blinker=setInterval(function(){b.cursor.style.visibility=b.otherCursor.style.visibility=(c=!c)?"":"hidden"},a.options.cursorBlinkRate))}}function bb(a,b){a.doc.mode.startState&&a.doc.frontier<a.display.showingTo&&a.state.highlight.set(b,ff(cb,a))}function cb(a){var b=a.doc;if(b.frontier<b.first&&(b.frontier=b.first),!(b.frontier>=a.display.showingTo)){var f,c=+new Date+a.options.workTime,d=hd(b.mode,eb(a,b.frontier)),e=[];b.iter(b.frontier,Math.min(b.first+b.size,a.display.showingTo+500),function(g){if(b.frontier>=a.display.showingFrom){var h=g.styles;g.styles=Sd(a,g,d);for(var i=!h||h.length!=g.styles.length,j=0;!i&&j<h.length;++j)i=h[j]!=g.styles[j];i&&(f&&f.end==b.frontier?f.end++:e.push(f={start:b.frontier,end:b.frontier+1})),g.stateAfter=hd(b.mode,d)}else Ud(a,g,d),g.stateAfter=0==b.frontier%5?hd(b.mode,d):null;return++b.frontier,+new Date>c?(bb(a,a.options.workDelay),!0):void 0}),e.length&&Fb(a,function(){for(var a=0;a<e.length;++a)Ib(this,e[a].start,e[a].end)})()}}function db(a,b,c){for(var d,e,f=a.doc,g=c?-1:b-(a.doc.mode.innerMode?1e3:100),h=b;h>g;--h){if(h<=f.first)return f.first;var i=le(f,h-1);if(i.stateAfter&&(!c||h<=f.frontier))return h;var j=Ye(i.text,null,a.options.tabSize);(null==e||d>j)&&(e=h-1,d=j)}return e}function eb(a,b,c){var d=a.doc,e=a.display;if(!d.mode.startState)return!0;var f=db(a,b,c),g=f>d.first&&le(d,f-1).stateAfter;return g=g?hd(d.mode,g):id(d.mode),d.iter(f,b,function(c){Ud(a,c,g);var h=f==b-1||0==f%5||f>=e.showingFrom&&f<e.showingTo;c.stateAfter=h?hd(d.mode,g):null,++f}),c&&(d.frontier=f),g}function fb(a){return a.lineSpace.offsetTop}function gb(a){return a.mover.offsetHeight-a.lineSpace.offsetHeight}function hb(a){var b=nf(a.measure,lf("pre",null,null,"text-align: left")).appendChild(lf("span","x"));return b.offsetLeft}function ib(a,b,c,d,e){var f=-1;if(d=d||lb(a,b),d.crude){var g=d.left+c*d.width;return{left:g,right:g+d.width,top:d.top,bottom:d.bottom}}for(var h=c;;h+=f){var i=d[h];if(i)break;0>f&&0==h&&(f=1)}return e=h>c?"left":c>h?"right":e,"left"==e&&i.leftSide?i=i.leftSide:"right"==e&&i.rightSide&&(i=i.rightSide),{left:c>h?i.right:i.left,right:h>c?i.left:i.right,top:i.top,bottom:i.bottom}}function jb(a,b){for(var c=a.display.measureLineCache,d=0;d<c.length;++d){var e=c[d];if(e.text==b.text&&e.markedSpans==b.markedSpans&&a.display.scroller.clientWidth==e.width&&e.classes==b.textClass+"|"+b.wrapClass)return e}}function kb(a,b){var c=jb(a,b);c&&(c.text=c.measure=c.markedSpans=null)}function lb(a,b){var c=jb(a,b);if(c)return c.measure;var d=mb(a,b),e=a.display.measureLineCache,f={text:b.text,width:a.display.scroller.clientWidth,markedSpans:b.markedSpans,measure:d,classes:b.textClass+"|"+b.wrapClass};return 16==e.length?e[++a.display.measureLineCachePos%16]=f:e.push(f),d}function mb(a,e){function t(a){var b=a.top-p.top,c=a.bottom-p.top;c>s&&(c=s),0>b&&(b=0);for(var d=q.length-2;d>=0;d-=2){var e=q[d],f=q[d+1];if(!(e>c||b>f)&&(b>=e&&f>=c||e>=b&&c>=f||Math.min(c,f)-Math.max(b,e)>=c-b>>1)){q[d]=Math.min(b,e),q[d+1]=Math.max(c,f);break}}return 0>d&&(d=q.length,q.push(b,c)),{left:a.left-p.left,right:a.right-p.left,top:d,bottom:null}}function u(a){a.bottom=q[a.top+1],a.top=q[a.top]}if(!a.options.lineWrapping&&e.text.length>=a.options.crudeMeasuringFrom)return nb(a,e);var f=a.display,g=ef(e.text.length),h=Xd(a,e,g,!0).pre;if(b&&!c&&!a.options.lineWrapping&&h.childNodes.length>100){for(var i=document.createDocumentFragment(),j=10,k=h.childNodes.length,l=0,m=Math.ceil(k/j);m>l;++l){for(var n=lf("div",null,null,"display: inline-block"),o=0;j>o&&k;++o)n.appendChild(h.firstChild),--k;i.appendChild(n)}h.appendChild(i)}nf(f.measure,h);var p=pf(f.lineDiv),q=[],r=ef(e.text.length),s=h.offsetHeight;d&&f.measure.first!=h&&nf(f.measure,h);for(var v,l=0;l<g.length;++l)if(v=g[l]){var w=v,x=null;if(/\bCodeMirror-widget\b/.test(v.className)&&v.getClientRects){1==v.firstChild.nodeType&&(w=v.firstChild);var y=w.getClientRects();y.length>1&&(x=r[l]=t(y[0]),x.rightSide=t(y[y.length-1]))}x||(x=r[l]=t(pf(w))),v.measureRight&&(x.right=pf(v.measureRight).left),v.leftSide&&(x.leftSide=t(pf(v.leftSide)))}mf(a.display.measure);for(var v,l=0;l<r.length;++l)(v=r[l])&&(u(v),v.leftSide&&u(v.leftSide),v.rightSide&&u(v.rightSide));return r}function nb(a,b){var c=new Od(b.text.slice(0,100),null);b.textClass&&(c.textClass=b.textClass);var d=mb(a,c),e=ib(a,c,0,d,"left"),f=ib(a,c,99,d,"right");return{crude:!0,top:e.top,left:e.left,bottom:e.bottom,width:(f.right-e.left)/100}}function ob(a,b){var c=!1;if(b.markedSpans)for(var d=0;d<b.markedSpans;++d){var e=b.markedSpans[d];!e.collapsed||null!=e.to&&e.to!=b.text.length||(c=!0)}var f=!c&&jb(a,b);if(f||b.text.length>=a.options.crudeMeasuringFrom)return ib(a,b,b.text.length,f&&f.measure,"right").right;var g=Xd(a,b,null,!0).pre,h=g.appendChild(vf(a.display.measure));return nf(a.display.measure,g),pf(h).right-pf(a.display.lineDiv).left}function pb(a){a.display.measureLineCache.length=a.display.measureLineCachePos=0,a.display.cachedCharWidth=a.display.cachedTextHeight=null,a.options.lineWrapping||(a.display.maxLineChanged=!0),a.display.lineNumChars=null}function qb(){return window.pageXOffset||(document.documentElement||document.body).scrollLeft}function rb(){return window.pageYOffset||(document.documentElement||document.body).scrollTop}function sb(a,b,c,d){if(b.widgets)for(var e=0;e<b.widgets.length;++e)if(b.widgets[e].above){var f=Md(b.widgets[e]);c.top+=f,c.bottom+=f}if("line"==d)return c;d||(d="local");var g=re(a,b);if("local"==d?g+=fb(a.display):g-=a.display.viewOffset,"page"==d||"window"==d){var h=pf(a.display.lineSpace);g+=h.top+("window"==d?0:rb());var i=h.left+("window"==d?0:qb());c.left+=i,c.right+=i}return c.top+=g,c.bottom+=g,c}function tb(a,b,c){if("div"==c)return b;var d=b.left,e=b.top;if("page"==c)d-=qb(),e-=rb();else if("local"==c||!c){var f=pf(a.display.sizer);d+=f.left,e+=f.top}var g=pf(a.display.lineSpace);return{left:d-g.left,top:e-g.top}}function ub(a,b,c,d,e){return d||(d=le(a.doc,b.line)),sb(a,d,ib(a,d,b.ch,null,e),c)}function vb(a,b,c,d,e){function f(b,f){var g=ib(a,d,b,e,f?"right":"left");return f?g.left=g.right:g.right=g.left,sb(a,d,g,c)}function g(a,b){var c=h[b],d=c.level%2;return a==Bf(c)&&b&&c.level<h[b-1].level?(c=h[--b],a=Cf(c)-(c.level%2?0:1),d=!0):a==Cf(c)&&b<h.length-1&&c.level<h[b+1].level&&(c=h[++b],a=Bf(c)-c.level%2,d=!1),d&&a==c.to&&a>c.from?f(a-1):f(a,d)}d=d||le(a.doc,b.line),e||(e=lb(a,d));var h=se(d),i=b.ch;if(!h)return f(i);var j=Jf(h,i),k=g(i,j);return null!=If&&(k.other=g(i,If)),k}function wb(a,b,c,d){var e=new Bc(a,b);return e.xRel=d,c&&(e.outside=!0),e}function xb(a,b,c){var d=a.doc;if(c+=a.display.viewOffset,0>c)return wb(d.first,0,!0,-1);var e=qe(d,c),f=d.first+d.size-1;if(e>f)return wb(d.first+d.size-1,le(d,f).text.length,!0,1);for(0>b&&(b=0);;){var g=le(d,e),h=yb(a,g,e,b,c),i=Ed(g),j=i&&i.find();if(!i||!(h.ch>j.from.ch||h.ch==j.from.ch&&h.xRel>0))return h;e=j.to.line}}function yb(a,b,c,d,e){function j(d){var e=vb(a,Bc(c,d),"line",b,i);return g=!0,f>e.bottom?e.left-h:f<e.top?e.left+h:(g=!1,e.left)}var f=e-re(a,b),g=!1,h=2*a.display.wrapper.clientWidth,i=lb(a,b),k=se(b),l=b.text.length,m=Df(b),n=Ef(b),o=j(m),p=g,q=j(n),r=g;if(d>q)return wb(c,n,r,1);for(;;){if(k?n==m||n==Lf(b,m,1):1>=n-m){for(var s=o>d||q-d>=d-o?m:n,t=d-(s==m?o:q);kf.test(b.text.charAt(s));)++s;var u=wb(c,s,s==m?p:r,0>t?-1:t?1:0);return u}var v=Math.ceil(l/2),w=m+v;if(k){w=m;for(var x=0;v>x;++x)w=Lf(b,w,1)}var y=j(w);y>d?(n=w,q=y,(r=g)&&(q+=1e3),l=v):(m=w,o=y,p=g,l-=v)}}function Ab(a){if(null!=a.cachedTextHeight)return a.cachedTextHeight;if(null==zb){zb=lf("pre");for(var b=0;49>b;++b)zb.appendChild(document.createTextNode("x")),zb.appendChild(lf("br"));zb.appendChild(document.createTextNode("x"))}nf(a.measure,zb);var c=zb.offsetHeight/50;return c>3&&(a.cachedTextHeight=c),mf(a.measure),c||1}function Bb(a){if(null!=a.cachedCharWidth)return a.cachedCharWidth;var b=lf("span","x"),c=lf("pre",[b]);nf(a.measure,c);var d=b.offsetWidth;return d>2&&(a.cachedCharWidth=d),d||10}function Db(a){a.curOp={changes:[],forceUpdate:!1,updateInput:null,userSelChange:null,textChanged:null,selectionChanged:!1,cursorActivity:!1,updateMaxLine:!1,updateScrollPos:!1,id:++Cb},Pe++||(Oe=[])}function Eb(a){var b=a.curOp,c=a.doc,d=a.display;if(a.curOp=null,b.updateMaxLine&&I(a),d.maxLineChanged&&!a.options.lineWrapping&&d.maxLine){var e=ob(a,d.maxLine);d.sizer.style.minWidth=Math.max(0,e+3+Ve)+"px",d.maxLineChanged=!1;var f=Math.max(0,d.sizer.offsetLeft+d.sizer.offsetWidth-d.scroller.clientWidth);f<c.scrollLeft&&!b.updateScrollPos&&ac(a,Math.min(d.scroller.scrollLeft,f),!0)}var g,h;if(b.updateScrollPos)g=b.updateScrollPos;else if(b.selectionChanged&&d.scroller.clientHeight){var i=vb(a,c.sel.head);g=Rc(a,i.left,i.top,i.left,i.bottom)}(b.changes.length||b.forceUpdate||g&&null!=g.scrollTop)&&(h=Q(a,b.changes,g&&g.scrollTop,b.forceUpdate),a.display.scroller.offsetHeight&&(a.doc.scrollTop=a.display.scroller.scrollTop)),!h&&b.selectionChanged&&Z(a),b.updateScrollPos?(d.scroller.scrollTop=d.scrollbarV.scrollTop=c.scrollTop=g.scrollTop,d.scroller.scrollLeft=d.scrollbarH.scrollLeft=c.scrollLeft=g.scrollLeft,M(a),b.scrollToPos&&Pc(a,Gc(a.doc,b.scrollToPos.from),Gc(a.doc,b.scrollToPos.to),b.scrollToPos.margin)):g&&Oc(a),b.selectionChanged&&ab(a),a.state.focused&&b.updateInput&&Mb(a,b.userSelChange);var j=b.maybeHiddenMarkers,k=b.maybeUnhiddenMarkers;if(j)for(var l=0;l<j.length;++l)j[l].lines.length||Ne(j[l],"hide");if(k)for(var l=0;l<k.length;++l)k[l].lines.length&&Ne(k[l],"unhide");var m;if(--Pe||(m=Oe,Oe=null),b.textChanged&&Ne(a,"change",a,b.textChanged),b.cursorActivity&&Ne(a,"cursorActivity",a),m)for(var l=0;l<m.length;++l)m[l]()}function Fb(a,b){return function(){var c=a||this,d=!c.curOp;d&&Db(c);try{var e=b.apply(c,arguments)}finally{d&&Eb(c)}return e}}function Gb(a){return function(){var c,b=this.cm&&!this.cm.curOp;b&&Db(this.cm);try{c=a.apply(this,arguments)}finally{b&&Eb(this.cm)}return c}}function Hb(a,b){var d,c=!a.curOp;c&&Db(a);try{d=b()}finally{c&&Eb(a)}return d}function Ib(a,b,c,d){null==b&&(b=a.doc.first),null==c&&(c=a.doc.first+a.doc.size),a.curOp.changes.push({from:b,to:c,diff:d})}function Jb(a){a.display.pollingFast||a.display.poll.set(a.options.pollInterval,function(){Lb(a),a.state.focused&&Jb(a)})}function Kb(a){function c(){var d=Lb(a);d||b?(a.display.pollingFast=!1,Jb(a)):(b=!0,a.display.poll.set(60,c))}var b=!1;a.display.pollingFast=!0,a.display.poll.set(20,c)}function Lb(a){var c=a.display.input,e=a.display.prevInput,f=a.doc,g=f.sel;if(!a.state.focused||xf(c)||Ob(a)||a.state.disableInput)return!1;a.state.pasteIncoming&&a.state.fakedLastChar&&(c.value=c.value.substring(0,c.value.length-1),a.state.fakedLastChar=!1);var h=c.value;if(h==e&&Cc(g.from,g.to))return!1;if(b&&!d&&a.display.inputHasSelection===h)return Mb(a,!0),!1;var i=!a.curOp;i&&Db(a),g.shift=!1;for(var j=0,k=Math.min(e.length,h.length);k>j&&e.charCodeAt(j)==h.charCodeAt(j);)++j;var l=g.from,m=g.to;j<e.length?l=Bc(l.line,l.ch-(e.length-j)):a.state.overwrite&&Cc(l,m)&&!a.state.pasteIncoming&&(m=Bc(m.line,Math.min(le(f,m.line).text.length,m.ch+(h.length-j))));var n=a.curOp.updateInput,o={from:l,to:m,text:wf(h.slice(j)),origin:a.state.pasteIncoming?"paste":"+input"};return uc(a.doc,o,"end"),a.curOp.updateInput=n,Qe(a,"inputRead",a,o),h.length>1e3||h.indexOf("\n")>-1?c.value=a.display.prevInput="":a.display.prevInput=h,i&&Eb(a),a.state.pasteIncoming=!1,!0}function Mb(a,c){var e,f,g=a.doc;if(Cc(g.sel.from,g.sel.to))c&&(a.display.prevInput=a.display.input.value="",b&&!d&&(a.display.inputHasSelection=null));else{a.display.prevInput="",e=yf&&(g.sel.to.line-g.sel.from.line>100||(f=a.getSelection()).length>1e3);var h=e?"-":f||a.getSelection();a.display.input.value=h,a.state.focused&&af(a.display.input),b&&!d&&(a.display.inputHasSelection=h)}a.display.inaccurateSelection=e}function Nb(a){"nocursor"==a.options.readOnly||p&&document.activeElement==a.display.input||a.display.input.focus()}function Ob(a){return a.options.readOnly||a.doc.cantEdit}function Pb(a){function e(){a.state.focused&&setTimeout(ff(Nb,a),0)}function h(){null==g&&(g=setTimeout(function(){g=null,c.cachedCharWidth=c.cachedTextHeight=sf=null,pb(a),Hb(a,ff(Ib,a))},100))}function i(){for(var a=c.wrapper.parentNode;a&&a!=document.body;a=a.parentNode);a?setTimeout(i,5e3):Me(window,"resize",h)}function j(b){Re(a,b)||a.options.onDragEvent&&a.options.onDragEvent(a,Ee(b))||Ie(b)}function l(){c.inaccurateSelection&&(c.prevInput="",c.inaccurateSelection=!1,c.input.value=a.getSelection(),af(c.input))}var c=a.display;Le(c.scroller,"mousedown",Fb(a,Ub)),b?Le(c.scroller,"dblclick",Fb(a,function(b){if(!Re(a,b)){var c=Rb(a,b);if(c&&!Xb(a,b)&&!Qb(a.display,b)){Fe(b);var d=Yc(le(a.doc,c.line).text,c);Jc(a.doc,d.from,d.to)}}})):Le(c.scroller,"dblclick",function(b){Re(a,b)||Fe(b)}),Le(c.lineSpace,"selectstart",function(a){Qb(c,a)||Fe(a)}),u||Le(c.scroller,"contextmenu",function(b){pc(a,b)}),Le(c.scroller,"scroll",function(){c.scroller.clientHeight&&(_b(a,c.scroller.scrollTop),ac(a,c.scroller.scrollLeft,!0),Ne(a,"scroll",a))}),Le(c.scrollbarV,"scroll",function(){c.scroller.clientHeight&&_b(a,c.scrollbarV.scrollTop)}),Le(c.scrollbarH,"scroll",function(){c.scroller.clientHeight&&ac(a,c.scrollbarH.scrollLeft)}),Le(c.scroller,"mousewheel",function(b){dc(a,b)}),Le(c.scroller,"DOMMouseScroll",function(b){dc(a,b)}),Le(c.scrollbarH,"mousedown",e),Le(c.scrollbarV,"mousedown",e),Le(c.wrapper,"scroll",function(){c.wrapper.scrollTop=c.wrapper.scrollLeft=0});var g;Le(window,"resize",h),setTimeout(i,5e3),Le(c.input,"keyup",Fb(a,function(b){Re(a,b)||a.options.onKeyEvent&&a.options.onKeyEvent(a,Ee(b))||16==b.keyCode&&(a.doc.sel.shift=!1)})),Le(c.input,"input",function(){b&&!d&&a.display.inputHasSelection&&(a.display.inputHasSelection=null),Kb(a)}),Le(c.input,"keydown",Fb(a,kc)),Le(c.input,"keypress",Fb(a,lc)),Le(c.input,"focus",ff(mc,a)),Le(c.input,"blur",ff(nc,a)),a.options.dragDrop&&(Le(c.scroller,"dragstart",function(b){$b(a,b)}),Le(c.scroller,"dragenter",j),Le(c.scroller,"dragover",j),Le(c.scroller,"drop",Fb(a,Zb))),Le(c.scroller,"paste",function(b){Qb(c,b)||(Nb(a),Kb(a))}),Le(c.input,"paste",function(){if(f&&!a.state.fakedLastChar&&!(new Date-a.state.lastMiddleDown<200)){var b=c.input.selectionStart,d=c.input.selectionEnd;c.input.value+="$",c.input.selectionStart=b,c.input.selectionEnd=d,a.state.fakedLastChar=!0}a.state.pasteIncoming=!0,Kb(a)}),Le(c.input,"cut",l),Le(c.input,"copy",l),k&&Le(c.sizer,"mouseup",function(){document.activeElement==c.input&&c.input.blur(),Nb(a)})}function Qb(a,b){for(var c=Je(b);c!=a.wrapper;c=c.parentNode)if(!c||c.ignoreEvents||c.parentNode==a.sizer&&c!=a.mover)return!0}function Rb(a,b,c){var d=a.display;if(!c){var e=Je(b);if(e==d.scrollbarH||e==d.scrollbarH.firstChild||e==d.scrollbarV||e==d.scrollbarV.firstChild||e==d.scrollbarFiller||e==d.gutterFiller)return null}var f,g,h=pf(d.lineSpace);try{f=b.clientX,g=b.clientY}catch(b){return null}return xb(a,f-h.left,g-h.top)}function Ub(a){function q(a){if(!Cc(p,a)){if(p=a,"single"==j)return Jc(c.doc,Gc(e,h),a),void 0;if(n=Gc(e,n),o=Gc(e,o),"double"==j){var b=Yc(le(e,a.line).text,a);Dc(a,n)?Jc(c.doc,b.from,o):Jc(c.doc,n,b.to)
}else"triple"==j&&(Dc(a,n)?Jc(c.doc,o,Gc(e,Bc(a.line,0))):Jc(c.doc,n,Gc(e,Bc(a.line+1,0))))}}function t(a){var b=++s,f=Rb(c,a,!0);if(f)if(Cc(f,l)){var h=a.clientY<r.top?-20:a.clientY>r.bottom?20:0;h&&setTimeout(Fb(c,function(){s==b&&(d.scroller.scrollTop+=h,t(a))}),50)}else{c.state.focused||mc(c),l=f,q(f);var g=L(d,e);(f.line>=g.to||f.line<g.from)&&setTimeout(Fb(c,function(){s==b&&t(a)}),150)}}function v(a){s=1/0,Fe(a),Nb(c),Me(document,"mousemove",w),Me(document,"mouseup",x)}if(!Re(this,a)){var c=this,d=c.display,e=c.doc,g=e.sel;if(g.shift=a.shiftKey,Qb(d,a))return f||(d.scroller.draggable=!1,setTimeout(function(){d.scroller.draggable=!0},100)),void 0;if(!Xb(c,a)){var h=Rb(c,a);switch(Ke(a)){case 3:return u&&pc.call(c,c,a),void 0;case 2:return f&&(c.state.lastMiddleDown=+new Date),h&&Jc(c.doc,h),setTimeout(ff(Nb,c),20),Fe(a),void 0}if(!h)return Je(a)==d.scroller&&Fe(a),void 0;c.state.focused||mc(c);var i=+new Date,j="single";if(Tb&&Tb.time>i-400&&Cc(Tb.pos,h))j="triple",Fe(a),setTimeout(ff(Nb,c),20),Zc(c,h.line);else if(Sb&&Sb.time>i-400&&Cc(Sb.pos,h)){j="double",Tb={time:i,pos:h},Fe(a);var k=Yc(le(e,h.line).text,h);Jc(c.doc,k.from,k.to)}else Sb={time:i,pos:h};var l=h;if(c.options.dragDrop&&qf&&!Ob(c)&&!Cc(g.from,g.to)&&!Dc(h,g.from)&&!Dc(g.to,h)&&"single"==j){var m=Fb(c,function(b){f&&(d.scroller.draggable=!1),c.state.draggingText=!1,Me(document,"mouseup",m),Me(d.scroller,"drop",m),Math.abs(a.clientX-b.clientX)+Math.abs(a.clientY-b.clientY)<10&&(Fe(b),Jc(c.doc,h),Nb(c))});return f&&(d.scroller.draggable=!0),c.state.draggingText=m,d.scroller.dragDrop&&d.scroller.dragDrop(),Le(document,"mouseup",m),Le(d.scroller,"drop",m),void 0}Fe(a),"single"==j&&Jc(c.doc,Gc(e,h));var n=g.from,o=g.to,p=h,r=pf(d.wrapper),s=0,w=Fb(c,function(a){b||Ke(a)?t(a):v(a)}),x=Fb(c,v);Le(document,"mousemove",w),Le(document,"mouseup",x)}}}function Vb(a,b,c,d,e){try{var f=b.clientX,g=b.clientY}catch(b){return!1}if(f>=Math.floor(pf(a.display.gutters).right))return!1;d&&Fe(b);var h=a.display,i=pf(h.lineDiv);if(g>i.bottom||!Te(a,c))return He(b);g-=i.top-h.viewOffset;for(var j=0;j<a.options.gutters.length;++j){var k=h.gutters.childNodes[j];if(k&&pf(k).right>=f){var l=qe(a.doc,g),m=a.options.gutters[j];return e(a,c,a,l,m,b),He(b)}}}function Wb(a,b){return Te(a,"gutterContextMenu")?Vb(a,b,"gutterContextMenu",!1,Ne):!1}function Xb(a,b){return Vb(a,b,"gutterClick",!0,Qe)}function Zb(a){var c=this;if(!(Re(c,a)||Qb(c.display,a)||c.options.onDragEvent&&c.options.onDragEvent(c,Ee(a)))){Fe(a),b&&(Yb=+new Date);var d=Rb(c,a,!0),e=a.dataTransfer.files;if(d&&!Ob(c))if(e&&e.length&&window.FileReader&&window.File)for(var f=e.length,g=Array(f),h=0,i=function(a,b){var e=new FileReader;e.onload=function(){g[b]=e.result,++h==f&&(d=Gc(c.doc,d),uc(c.doc,{from:d,to:d,text:wf(g.join("\n")),origin:"paste"},"around"))},e.readAsText(a)},j=0;f>j;++j)i(e[j],j);else{if(c.state.draggingText&&!Dc(d,c.doc.sel.from)&&!Dc(c.doc.sel.to,d))return c.state.draggingText(a),setTimeout(ff(Nb,c),20),void 0;try{var g=a.dataTransfer.getData("Text");if(g){var k=c.doc.sel.from,l=c.doc.sel.to;Lc(c.doc,d,d),c.state.draggingText&&Ac(c.doc,"",k,l,"paste"),c.replaceSelection(g,null,"paste"),Nb(c),mc(c)}}catch(a){}}}}function $b(a,c){if(b&&(!a.state.draggingText||+new Date-Yb<100))return Ie(c),void 0;if(!Re(a,c)&&!Qb(a.display,c)){var d=a.getSelection();if(c.dataTransfer.setData("Text",d),c.dataTransfer.setDragImage&&!j){var e=lf("img",null,null,"position: fixed; left: 0; top: 0;");e.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",i&&(e.width=e.height=1,a.display.wrapper.appendChild(e),e._top=e.offsetTop),c.dataTransfer.setDragImage(e,0,0),i&&e.parentNode.removeChild(e)}}}function _b(b,c){Math.abs(b.doc.scrollTop-c)<2||(b.doc.scrollTop=c,a||Q(b,[],c),b.display.scroller.scrollTop!=c&&(b.display.scroller.scrollTop=c),b.display.scrollbarV.scrollTop!=c&&(b.display.scrollbarV.scrollTop=c),a&&Q(b,[]),bb(b,100))}function ac(a,b,c){(c?b==a.doc.scrollLeft:Math.abs(a.doc.scrollLeft-b)<2)||(b=Math.min(b,a.display.scroller.scrollWidth-a.display.scroller.clientWidth),a.doc.scrollLeft=b,M(a),a.display.scroller.scrollLeft!=b&&(a.display.scroller.scrollLeft=b),a.display.scrollbarH.scrollLeft!=b&&(a.display.scrollbarH.scrollLeft=b))}function dc(b,c){var d=c.wheelDeltaX,e=c.wheelDeltaY;null==d&&c.detail&&c.axis==c.HORIZONTAL_AXIS&&(d=c.detail),null==e&&c.detail&&c.axis==c.VERTICAL_AXIS?e=c.detail:null==e&&(e=c.wheelDelta);var g=b.display,h=g.scroller;if(d&&h.scrollWidth>h.clientWidth||e&&h.scrollHeight>h.clientHeight){if(e&&q&&f)for(var j=c.target;j!=h;j=j.parentNode)if(j.lineObj){b.display.currentWheelTarget=j;break}if(d&&!a&&!i&&null!=cc)return e&&_b(b,Math.max(0,Math.min(h.scrollTop+e*cc,h.scrollHeight-h.clientHeight))),ac(b,Math.max(0,Math.min(h.scrollLeft+d*cc,h.scrollWidth-h.clientWidth))),Fe(c),g.wheelStartX=null,void 0;if(e&&null!=cc){var k=e*cc,l=b.doc.scrollTop,m=l+g.wrapper.clientHeight;0>k?l=Math.max(0,l+k-50):m=Math.min(b.doc.height,m+k+50),Q(b,[],{top:l,bottom:m})}20>bc&&(null==g.wheelStartX?(g.wheelStartX=h.scrollLeft,g.wheelStartY=h.scrollTop,g.wheelDX=d,g.wheelDY=e,setTimeout(function(){if(null!=g.wheelStartX){var a=h.scrollLeft-g.wheelStartX,b=h.scrollTop-g.wheelStartY,c=b&&g.wheelDY&&b/g.wheelDY||a&&g.wheelDX&&a/g.wheelDX;g.wheelStartX=g.wheelStartY=null,c&&(cc=(cc*bc+c)/(bc+1),++bc)}},200)):(g.wheelDX+=d,g.wheelDY+=e))}}function ec(a,b,c){if("string"==typeof b&&(b=jd[b],!b))return!1;a.display.pollingFast&&Lb(a)&&(a.display.pollingFast=!1);var d=a.doc,e=d.sel.shift,f=!1;try{Ob(a)&&(a.state.suppressEdits=!0),c&&(d.sel.shift=!1),f=b(a)!=We}finally{d.sel.shift=e,a.state.suppressEdits=!1}return f}function fc(a){var b=a.state.keyMaps.slice(0);return a.options.extraKeys&&b.push(a.options.extraKeys),b.push(a.options.keyMap),b}function hc(a,b){var c=ld(a.options.keyMap),e=c.auto;clearTimeout(gc),e&&!nd(b)&&(gc=setTimeout(function(){ld(a.options.keyMap)==c&&(a.options.keyMap=e.call?e.call(null,a):e,D(a))},50));var f=od(b,!0),g=!1;if(!f)return!1;var h=fc(a);return g=b.shiftKey?md("Shift-"+f,h,function(b){return ec(a,b,!0)})||md(f,h,function(b){return("string"==typeof b?/^go[A-Z]/.test(b):b.motion)?ec(a,b):void 0}):md(f,h,function(b){return ec(a,b)}),g&&(Fe(b),ab(a),d&&(b.oldKeyCode=b.keyCode,b.keyCode=0),Qe(a,"keyHandled",a,f,b)),g}function ic(a,b,c){var d=md("'"+c+"'",fc(a),function(b){return ec(a,b,!0)});return d&&(Fe(b),ab(a),Qe(a,"keyHandled",a,"'"+c+"'",b)),d}function kc(a){var c=this;if(c.state.focused||mc(c),!(Re(c,a)||c.options.onKeyEvent&&c.options.onKeyEvent(c,Ee(a)))){b&&27==a.keyCode&&(a.returnValue=!1);var d=a.keyCode;c.doc.sel.shift=16==d||a.shiftKey;var e=hc(c,a);i&&(jc=e?d:null,!e&&88==d&&!yf&&(q?a.metaKey:a.ctrlKey)&&c.replaceSelection(""))}}function lc(a){var c=this;if(!(Re(c,a)||c.options.onKeyEvent&&c.options.onKeyEvent(c,Ee(a)))){var e=a.keyCode,f=a.charCode;if(i&&e==jc)return jc=null,Fe(a),void 0;if(!(i&&(!a.which||a.which<10)||k)||!hc(c,a)){var g=String.fromCharCode(null==f?e:f);this.options.electricChars&&this.doc.mode.electricChars&&this.options.smartIndent&&!Ob(this)&&this.doc.mode.electricChars.indexOf(g)>-1&&setTimeout(Fb(c,function(){Uc(c,c.doc.sel.to.line,"smart")}),75),ic(c,a,g)||(b&&!d&&(c.display.inputHasSelection=null),Kb(c))}}}function mc(a){"nocursor"!=a.options.readOnly&&(a.state.focused||(Ne(a,"focus",a),a.state.focused=!0,-1==a.display.wrapper.className.search(/\bCodeMirror-focused\b/)&&(a.display.wrapper.className+=" CodeMirror-focused"),a.curOp||(Mb(a,!0),f&&setTimeout(ff(Mb,a,!0),0))),Jb(a),ab(a))}function nc(a){a.state.focused&&(Ne(a,"blur",a),a.state.focused=!1,a.display.wrapper.className=a.display.wrapper.className.replace(" CodeMirror-focused","")),clearInterval(a.display.blinker),setTimeout(function(){a.state.focused||(a.doc.sel.shift=!1)},150)}function pc(a,c){function l(){if(null!=e.input.selectionStart){var a=e.input.value="\u200b"+(Cc(f.from,f.to)?"":e.input.value);e.prevInput="\u200b",e.input.selectionStart=1,e.input.selectionEnd=a.length}}function m(){if(e.inputDiv.style.position="relative",e.input.style.cssText=k,d&&(e.scrollbarV.scrollTop=e.scroller.scrollTop=h),Jb(a),null!=e.input.selectionStart){(!b||d)&&l(),clearTimeout(oc);var c=0,f=function(){" "==e.prevInput&&0==e.input.selectionStart?Fb(a,jd.selectAll)(a):c++<10?oc=setTimeout(f,500):Mb(a)};oc=setTimeout(f,200)}}if(!Re(a,c,"contextmenu")){var e=a.display,f=a.doc.sel;if(!Qb(e,c)&&!Wb(a,c)){var g=Rb(a,c),h=e.scroller.scrollTop;if(g&&!i){var j=a.options.resetSelectionOnContextMenu;j&&(Cc(f.from,f.to)||Dc(g,f.from)||!Dc(g,f.to))&&Fb(a,Lc)(a.doc,g,g);var k=e.input.style.cssText;if(e.inputDiv.style.position="absolute",e.input.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(c.clientY-5)+"px; left: "+(c.clientX-5)+"px; z-index: 1000; background: white; outline: none;"+"border-width: 0; outline: none; overflow: hidden; opacity: .05; -ms-opacity: .05; filter: alpha(opacity=5);",Nb(a),Mb(a,!0),Cc(f.from,f.to)&&(e.input.value=e.prevInput=" "),b&&!d&&l(),u){Ie(c);var n=function(){Me(window,"mouseup",n),setTimeout(m,20)};Le(window,"mouseup",n)}else setTimeout(m,50)}}}}function rc(a,b,c){if(!Dc(b.from,c))return Gc(a,c);var d=b.text.length-1-(b.to.line-b.from.line);if(c.line>b.to.line+d){var e=c.line-d,f=a.first+a.size-1;return e>f?Bc(f,le(a,f).text.length):Hc(c,le(a,e).text.length)}if(c.line==b.to.line+d)return Hc(c,_e(b.text).length+(1==b.text.length?b.from.ch:0)+le(a,b.to.line).text.length-b.to.ch);var g=c.line-b.from.line;return Hc(c,b.text[g].length+(g?0:b.from.ch))}function sc(a,b,c){if(c&&"object"==typeof c)return{anchor:rc(a,b,c.anchor),head:rc(a,b,c.head)};if("start"==c)return{anchor:b.from,head:b.from};var d=qc(b);if("around"==c)return{anchor:b.from,head:d};if("end"==c)return{anchor:d,head:d};var e=function(a){if(Dc(a,b.from))return a;if(!Dc(b.to,a))return d;var c=a.line+b.text.length-(b.to.line-b.from.line)-1,e=a.ch;return a.line==b.to.line&&(e+=d.ch-b.to.ch),Bc(c,e)};return{anchor:e(a.sel.anchor),head:e(a.sel.head)}}function tc(a,b,c){var d={canceled:!1,from:b.from,to:b.to,text:b.text,origin:b.origin,cancel:function(){this.canceled=!0}};return c&&(d.update=function(b,c,d,e){b&&(this.from=Gc(a,b)),c&&(this.to=Gc(a,c)),d&&(this.text=d),void 0!==e&&(this.origin=e)}),Ne(a,"beforeChange",a,d),a.cm&&Ne(a.cm,"beforeChange",a.cm,d),d.canceled?null:{from:d.from,to:d.to,text:d.text,origin:d.origin}}function uc(a,b,c,d){if(a.cm){if(!a.cm.curOp)return Fb(a.cm,uc)(a,b,c,d);if(a.cm.state.suppressEdits)return}if(!(Te(a,"beforeChange")||a.cm&&Te(a.cm,"beforeChange"))||(b=tc(a,b,!0))){var e=v&&!d&&Bd(a,b.from,b.to);if(e){for(var f=e.length-1;f>=1;--f)vc(a,{from:e[f].from,to:e[f].to,text:[""]});e.length&&vc(a,{from:e[0].from,to:e[0].to,text:b.text},c)}else vc(a,b,c)}}function vc(a,b,c){if(1!=b.text.length||""!=b.text[0]||!Cc(b.from,b.to)){var d=sc(a,b,c);we(a,b,d,a.cm?a.cm.curOp.id:0/0),yc(a,b,d,zd(a,b));var e=[];je(a,function(a,c){c||-1!=bf(e,a.history)||(Ce(a.history,b),e.push(a.history)),yc(a,b,null,zd(a,b))})}}function wc(a,b){if(!a.cm||!a.cm.state.suppressEdits){var c=a.history,d=("undo"==b?c.done:c.undone).pop();if(d){var e={changes:[],anchorBefore:d.anchorAfter,headBefore:d.headAfter,anchorAfter:d.anchorBefore,headAfter:d.headBefore,generation:c.generation};("undo"==b?c.undone:c.done).push(e),c.generation=d.generation||++c.maxGeneration;for(var f=Te(a,"beforeChange")||a.cm&&Te(a.cm,"beforeChange"),g=d.changes.length-1;g>=0;--g){var h=d.changes[g];if(h.origin=b,f&&!tc(a,h,!1))return("undo"==b?c.done:c.undone).length=0,void 0;e.changes.push(ve(a,h));var i=g?sc(a,h,null):{anchor:d.anchorBefore,head:d.headBefore};yc(a,h,i,Ad(a,h));var j=[];je(a,function(a,b){b||-1!=bf(j,a.history)||(Ce(a.history,h),j.push(a.history)),yc(a,h,null,Ad(a,h))})}}}}function xc(a,b){function c(a){return Bc(a.line+b,a.ch)}a.first+=b,a.cm&&Ib(a.cm,a.first,a.first,b),a.sel.head=c(a.sel.head),a.sel.anchor=c(a.sel.anchor),a.sel.from=c(a.sel.from),a.sel.to=c(a.sel.to)}function yc(a,b,c,d){if(a.cm&&!a.cm.curOp)return Fb(a.cm,yc)(a,b,c,d);if(b.to.line<a.first)return xc(a,b.text.length-1-(b.to.line-b.from.line)),void 0;if(!(b.from.line>a.lastLine())){if(b.from.line<a.first){var e=b.text.length-1-(a.first-b.from.line);xc(a,e),b={from:Bc(a.first,0),to:Bc(b.to.line+e,b.to.ch),text:[_e(b.text)],origin:b.origin}}var f=a.lastLine();b.to.line>f&&(b={from:b.from,to:Bc(f,le(a,f).text.length),text:[b.text[0]],origin:b.origin}),b.removed=me(a,b.from,b.to),c||(c=sc(a,b,null)),a.cm?zc(a.cm,b,d,c):ce(a,b,d,c)}}function zc(a,b,c,d){var e=a.doc,f=a.display,g=b.from,h=b.to,i=!1,j=g.line;a.options.lineWrapping||(j=pe(Fd(e,le(e,g.line))),e.iter(j,h.line+1,function(a){return a==f.maxLine?(i=!0,!0):void 0})),Dc(e.sel.head,b.from)||Dc(b.to,e.sel.head)||(a.curOp.cursorActivity=!0),ce(e,b,c,d,B(a)),a.options.lineWrapping||(e.iter(j,g.line+b.text.length,function(a){var b=H(e,a);b>f.maxLineLength&&(f.maxLine=a,f.maxLineLength=b,f.maxLineChanged=!0,i=!1)}),i&&(a.curOp.updateMaxLine=!0)),e.frontier=Math.min(e.frontier,g.line),bb(a,400);var k=b.text.length-(h.line-g.line)-1;if(Ib(a,g.line,h.line+1,k),Te(a,"change")){var l={from:g,to:h,text:b.text,removed:b.removed,origin:b.origin};if(a.curOp.textChanged){for(var m=a.curOp.textChanged;m.next;m=m.next);m.next=l}else a.curOp.textChanged=l}}function Ac(a,b,c,d,e){if(d||(d=c),Dc(d,c)){var f=d;d=c,c=f}"string"==typeof b&&(b=wf(b)),uc(a,{from:c,to:d,text:b,origin:e},null)}function Bc(a,b){return this instanceof Bc?(this.line=a,this.ch=b,void 0):new Bc(a,b)}function Cc(a,b){return a.line==b.line&&a.ch==b.ch}function Dc(a,b){return a.line<b.line||a.line==b.line&&a.ch<b.ch}function Ec(a){return Bc(a.line,a.ch)}function Fc(a,b){return Math.max(a.first,Math.min(b,a.first+a.size-1))}function Gc(a,b){if(b.line<a.first)return Bc(a.first,0);var c=a.first+a.size-1;return b.line>c?Bc(c,le(a,c).text.length):Hc(b,le(a,b.line).text.length)}function Hc(a,b){var c=a.ch;return null==c||c>b?Bc(a.line,b):0>c?Bc(a.line,0):a}function Ic(a,b){return b>=a.first&&b<a.first+a.size}function Jc(a,b,c,d){if(a.sel.shift||a.sel.extend){var e=a.sel.anchor;if(c){var f=Dc(b,e);f!=Dc(c,e)?(e=b,b=c):f!=Dc(b,c)&&(b=c)}Lc(a,e,b,d)}else Lc(a,b,c||b,d);a.cm&&(a.cm.curOp.userSelChange=!0)}function Kc(a,b,c){var d={anchor:b,head:c};return Ne(a,"beforeSelectionChange",a,d),a.cm&&Ne(a.cm,"beforeSelectionChange",a.cm,d),d.anchor=Gc(a,d.anchor),d.head=Gc(a,d.head),d}function Lc(a,b,c,d,e){if(!e&&Te(a,"beforeSelectionChange")||a.cm&&Te(a.cm,"beforeSelectionChange")){var f=Kc(a,b,c);c=f.head,b=f.anchor}var g=a.sel;if(g.goalColumn=null,null==d&&(d=Dc(c,g.head)?-1:1),(e||!Cc(b,g.anchor))&&(b=Nc(a,b,d,"push"!=e)),(e||!Cc(c,g.head))&&(c=Nc(a,c,d,"push"!=e)),!Cc(g.anchor,b)||!Cc(g.head,c)){g.anchor=b,g.head=c;var h=Dc(c,b);g.from=h?c:b,g.to=h?b:c,a.cm&&(a.cm.curOp.updateInput=a.cm.curOp.selectionChanged=a.cm.curOp.cursorActivity=!0),Qe(a,"cursorActivity",a)}}function Mc(a){Lc(a.doc,a.doc.sel.from,a.doc.sel.to,null,"push")}function Nc(a,b,c,d){var e=!1,f=b,g=c||1;a.cantEdit=!1;a:for(;;){var h=le(a,f.line);if(h.markedSpans)for(var i=0;i<h.markedSpans.length;++i){var j=h.markedSpans[i],k=j.marker;if((null==j.from||(k.inclusiveLeft?j.from<=f.ch:j.from<f.ch))&&(null==j.to||(k.inclusiveRight?j.to>=f.ch:j.to>f.ch))){if(d&&(Ne(k,"beforeCursorEnter"),k.explicitlyCleared)){if(h.markedSpans){--i;continue}break}if(!k.atomic)continue;var l=k.find()[0>g?"from":"to"];if(Cc(l,f)&&(l.ch+=g,l.ch<0?l=l.line>a.first?Gc(a,Bc(l.line-1)):null:l.ch>h.text.length&&(l=l.line<a.first+a.size-1?Bc(l.line+1,0):null),!l)){if(e)return d?(a.cantEdit=!0,Bc(a.first,0)):Nc(a,b,c,!0);e=!0,l=b,g=-g}f=l;continue a}}return f}}function Oc(a){var b=Pc(a,a.doc.sel.head,null,a.options.cursorScrollMargin);if(a.state.focused){var c=a.display,d=pf(c.sizer),e=null;if(b.top+d.top<0?e=!0:b.bottom+d.top>(window.innerHeight||document.documentElement.clientHeight)&&(e=!1),null!=e&&!n){var f="none"==c.cursor.style.display;f&&(c.cursor.style.display="",c.cursor.style.left=b.left+"px",c.cursor.style.top=b.top-c.viewOffset+"px"),c.cursor.scrollIntoView(e),f&&(c.cursor.style.display="none")}}}function Pc(a,b,c,d){for(null==d&&(d=0);;){var e=!1,f=vb(a,b),g=c&&c!=b?vb(a,c):f,h=Rc(a,Math.min(f.left,g.left),Math.min(f.top,g.top)-d,Math.max(f.left,g.left),Math.max(f.bottom,g.bottom)+d),i=a.doc.scrollTop,j=a.doc.scrollLeft;if(null!=h.scrollTop&&(_b(a,h.scrollTop),Math.abs(a.doc.scrollTop-i)>1&&(e=!0)),null!=h.scrollLeft&&(ac(a,h.scrollLeft),Math.abs(a.doc.scrollLeft-j)>1&&(e=!0)),!e)return f}}function Qc(a,b,c,d,e){var f=Rc(a,b,c,d,e);null!=f.scrollTop&&_b(a,f.scrollTop),null!=f.scrollLeft&&ac(a,f.scrollLeft)}function Rc(a,b,c,d,e){var f=a.display,g=Ab(a.display);0>c&&(c=0);var h=f.scroller.clientHeight-Ve,i=f.scroller.scrollTop,j={},k=a.doc.height+gb(f),l=g>c,m=e>k-g;if(i>c)j.scrollTop=l?0:c;else if(e>i+h){var n=Math.min(c,(m?k:e)-h);n!=i&&(j.scrollTop=n)}var o=f.scroller.clientWidth-Ve,p=f.scroller.scrollLeft;b+=f.gutters.offsetWidth,d+=f.gutters.offsetWidth;var q=f.gutters.offsetWidth,r=q+10>b;return p+q>b||r?(r&&(b=0),j.scrollLeft=Math.max(0,b-10-q)):d>o+p-3&&(j.scrollLeft=d+10-o),j}function Sc(a,b,c){a.curOp.updateScrollPos={scrollLeft:null==b?a.doc.scrollLeft:b,scrollTop:null==c?a.doc.scrollTop:c}}function Tc(a,b,c){var d=a.curOp.updateScrollPos||(a.curOp.updateScrollPos={scrollLeft:a.doc.scrollLeft,scrollTop:a.doc.scrollTop}),e=a.display.scroller;d.scrollTop=Math.max(0,Math.min(e.scrollHeight-e.clientHeight,d.scrollTop+c)),d.scrollLeft=Math.max(0,Math.min(e.scrollWidth-e.clientWidth,d.scrollLeft+b))}function Uc(a,b,c,d){var e=a.doc;if(null==c&&(c="add"),"smart"==c)if(a.doc.mode.indent)var f=eb(a,b);else c="prev";var k,g=a.options.tabSize,h=le(e,b),i=Ye(h.text,null,g),j=h.text.match(/^\s*/)[0];if("smart"==c&&(k=a.doc.mode.indent(f,h.text.slice(j.length),h.text),k==We)){if(!d)return;c="prev"}"prev"==c?k=b>e.first?Ye(le(e,b-1).text,null,g):0:"add"==c?k=i+a.options.indentUnit:"subtract"==c?k=i-a.options.indentUnit:"number"==typeof c&&(k=i+c),k=Math.max(0,k);var l="",m=0;if(a.options.indentWithTabs)for(var n=Math.floor(k/g);n;--n)m+=g,l+=" ";k>m&&(l+=$e(k-m)),l!=j?Ac(a.doc,l,Bc(b,0),Bc(b,j.length),"+input"):e.sel.head.line==b&&e.sel.head.ch<j.length&&Lc(e,Bc(b,j.length),Bc(b,j.length),1),h.stateAfter=null}function Vc(a,b,c){var d=b,e=b,f=a.doc;return"number"==typeof b?e=le(f,Fc(f,b)):d=pe(b),null==d?null:c(e,d)?(Ib(a,d,d+1),e):null}function Wc(a,b,c,d,e){function k(){var b=f+c;return b<a.first||b>=a.first+a.size?j=!1:(f=b,i=le(a,b))}function l(a){var b=(e?Lf:Mf)(i,g,c,!0);if(null==b){if(a||!k())return j=!1;g=e?(0>c?Ef:Df)(i):0>c?i.text.length:0}else g=b;return!0}var f=b.line,g=b.ch,h=c,i=le(a,f),j=!0;if("char"==d)l();else if("column"==d)l(!0);else if("word"==d||"group"==d)for(var m=null,n="group"==d,o=!0;!(0>c)||l(!o);o=!1){var p=i.text.charAt(g)||"\n",q=hf(p)?"w":n?/\s/.test(p)?null:"p":null;if(m&&m!=q){0>c&&(c=1,l());break}if(q&&(m=q),c>0&&!l(!o))break}var r=Nc(a,Bc(f,g),h,!0);return j||(r.hitSide=!0),r}function Xc(a,b,c,d){var g,e=a.doc,f=b.left;if("page"==d){var h=Math.min(a.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight);g=b.top+c*(h-(0>c?1.5:.5)*Ab(a.display))}else"line"==d&&(g=c>0?b.bottom+3:b.top-3);for(;;){var i=xb(a,f,g);if(!i.outside)break;if(0>c?0>=g:g>=e.height){i.hitSide=!0;break}g+=5*c}return i}function Yc(a,b){var c=b.ch,d=b.ch;if(a){(b.xRel<0||d==a.length)&&c?--c:++d;for(var e=a.charAt(c),f=hf(e)?hf:/\s/.test(e)?function(a){return/\s/.test(a)}:function(a){return!/\s/.test(a)&&!hf(a)};c>0&&f(a.charAt(c-1));)--c;for(;d<a.length&&f(a.charAt(d));)++d}return{from:Bc(b.line,c),to:Bc(b.line,d)}}function Zc(a,b){Jc(a.doc,Bc(b,0),Gc(a.doc,Bc(b+1,0)))}function ad(a,b,c,d){x.defaults[a]=b,c&&($c[a]=d?function(a,b,d){d!=bd&&c(a,b,d)}:c)}function hd(a,b){if(b===!0)return b;if(a.copyState)return a.copyState(b);var c={};for(var d in b){var e=b[d];e instanceof Array&&(e=e.concat([])),c[d]=e}return c}function id(a,b,c){return a.startState?a.startState(b,c):!0}function ld(a){return"string"==typeof a?kd[a]:a}function md(a,b,c){function d(b){b=ld(b);var e=b[a];if(e===!1)return"stop";if(null!=e&&c(e))return!0;if(b.nofallthrough)return"stop";var f=b.fallthrough;if(null==f)return!1;if("[object Array]"!=Object.prototype.toString.call(f))return d(f);for(var g=0,h=f.length;h>g;++g){var i=d(f[g]);if(i)return i}return!1}for(var e=0;e<b.length;++e){var f=d(b[e]);if(f)return"stop"!=f}}function nd(a){var b=zf[a.keyCode];return"Ctrl"==b||"Alt"==b||"Shift"==b||"Mod"==b}function od(a,b){if(i&&34==a.keyCode&&a["char"])return!1;var c=zf[a.keyCode];return null==c||a.altGraphKey?!1:(a.altKey&&(c="Alt-"+c),(t?a.metaKey:a.ctrlKey)&&(c="Ctrl-"+c),(t?a.ctrlKey:a.metaKey)&&(c="Cmd-"+c),!b&&a.shiftKey&&(c="Shift-"+c),c)}function pd(a,b){this.pos=this.start=0,this.string=a,this.tabSize=b||8,this.lastColumnPos=this.lastColumnValue=0}function qd(a,b){this.lines=[],this.type=b,this.doc=a}function rd(a,b,c,d,e){if(d&&d.shared)return td(a,b,c,d,e);if(a.cm&&!a.cm.curOp)return Fb(a.cm,rd)(a,b,c,d,e);var f=new qd(a,e);if(Dc(c,b)||Cc(b,c)&&"range"==e&&(!d.inclusiveLeft||!d.inclusiveRight))return f;d&&df(d,f),f.replacedWith&&(f.collapsed=!0,f.replacedWith=lf("span",[f.replacedWith],"CodeMirror-widget"),d.handleMouseEvents||(f.replacedWith.ignoreEvents=!0)),f.collapsed&&(w=!0),f.addToHistory&&we(a,{from:b,to:c,origin:"markText"},{head:a.sel.head,anchor:a.sel.anchor},0/0);var i,j,l,g=b.line,h=0,k=a.cm;if(a.iter(g,c.line+1,function(d){k&&f.collapsed&&!k.options.lineWrapping&&Fd(a,d)==k.display.maxLine&&(l=!0);var e={from:null,to:null,marker:f};h+=d.text.length,g==b.line&&(e.from=b.ch,h-=b.ch),g==c.line&&(e.to=c.ch,h-=d.text.length-c.ch),f.collapsed&&(g==c.line&&(j=Cd(d,c.ch)),g==b.line?i=Cd(d,b.ch):oe(d,0)),wd(d,e),++g}),f.collapsed&&a.iter(b.line,c.line+1,function(b){Gd(a,b)&&oe(b,0)}),f.clearOnEnter&&Le(f,"beforeCursorEnter",function(){f.clear()}),f.readOnly&&(v=!0,(a.history.done.length||a.history.undone.length)&&a.clearHistory()),f.collapsed){if(i!=j)throw new Error("Inserting collapsed marker overlapping an existing one");f.size=h,f.atomic=!0}return k&&(l&&(k.curOp.updateMaxLine=!0),(f.className||f.title||f.startStyle||f.endStyle||f.collapsed)&&Ib(k,b.line,c.line+1),f.atomic&&Mc(k)),f}function sd(a,b){this.markers=a,this.primary=b;for(var c=0,d=this;c<a.length;++c)a[c].parent=this,Le(a[c],"clear",function(){d.clear()})}function td(a,b,c,d,e){d=df(d),d.shared=!1;var f=[rd(a,b,c,d,e)],g=f[0],h=d.replacedWith;return je(a,function(a){h&&(d.replacedWith=h.cloneNode(!0)),f.push(rd(a,Gc(a,b),Gc(a,c),d,e));for(var i=0;i<a.linked.length;++i)if(a.linked[i].isParent)return;g=_e(f)}),new sd(f,g)}function ud(a,b){if(a)for(var c=0;c<a.length;++c){var d=a[c];if(d.marker==b)return d}}function vd(a,b){for(var c,d=0;d<a.length;++d)a[d]!=b&&(c||(c=[])).push(a[d]);return c}function wd(a,b){a.markedSpans=a.markedSpans?a.markedSpans.concat([b]):[b],b.marker.attachLine(a)}function xd(a,b,c){if(a)for(var e,d=0;d<a.length;++d){var f=a[d],g=f.marker,h=null==f.from||(g.inclusiveLeft?f.from<=b:f.from<b);if(h||(g.inclusiveLeft&&g.inclusiveRight||"bookmark"==g.type)&&f.from==b&&(!c||!f.marker.insertLeft)){var i=null==f.to||(g.inclusiveRight?f.to>=b:f.to>b);(e||(e=[])).push({from:f.from,to:i?null:f.to,marker:g})}}return e}function yd(a,b,c){if(a)for(var e,d=0;d<a.length;++d){var f=a[d],g=f.marker,h=null==f.to||(g.inclusiveRight?f.to>=b:f.to>b);if(h||"bookmark"==g.type&&f.from==b&&(!c||f.marker.insertLeft)){var i=null==f.from||(g.inclusiveLeft?f.from<=b:f.from<b);(e||(e=[])).push({from:i?null:f.from-b,to:null==f.to?null:f.to-b,marker:g})}}return e}function zd(a,b){var c=Ic(a,b.from.line)&&le(a,b.from.line).markedSpans,d=Ic(a,b.to.line)&&le(a,b.to.line).markedSpans;if(!c&&!d)return null;var e=b.from.ch,f=b.to.ch,g=Cc(b.from,b.to),h=xd(c,e,g),i=yd(d,f,g),j=1==b.text.length,k=_e(b.text).length+(j?e:0);if(h)for(var l=0;l<h.length;++l){var m=h[l];if(null==m.to){var n=ud(i,m.marker);n?j&&(m.to=null==n.to?null:n.to+k):m.to=e}}if(i)for(var l=0;l<i.length;++l){var m=i[l];if(null!=m.to&&(m.to+=k),null==m.from){var n=ud(h,m.marker);n||(m.from=k,j&&(h||(h=[])).push(m))}else m.from+=k,j&&(h||(h=[])).push(m)}if(j&&h){for(var l=0;l<h.length;++l)null!=h[l].from&&h[l].from==h[l].to&&"bookmark"!=h[l].marker.type&&h.splice(l--,1);h.length||(h=null)}var o=[h];if(!j){var q,p=b.text.length-2;if(p>0&&h)for(var l=0;l<h.length;++l)null==h[l].to&&(q||(q=[])).push({from:null,to:null,marker:h[l].marker});for(var l=0;p>l;++l)o.push(q);o.push(i)}return o}function Ad(a,b){var c=ye(a,b),d=zd(a,b);if(!c)return d;if(!d)return c;for(var e=0;e<c.length;++e){var f=c[e],g=d[e];if(f&&g)a:for(var h=0;h<g.length;++h){for(var i=g[h],j=0;j<f.length;++j)if(f[j].marker==i.marker)continue a;f.push(i)}else g&&(c[e]=g)}return c}function Bd(a,b,c){var d=null;if(a.iter(b.line,c.line+1,function(a){if(a.markedSpans)for(var b=0;b<a.markedSpans.length;++b){var c=a.markedSpans[b].marker;!c.readOnly||d&&-1!=bf(d,c)||(d||(d=[])).push(c)}}),!d)return null;for(var e=[{from:b,to:c}],f=0;f<d.length;++f)for(var g=d[f],h=g.find(),i=0;i<e.length;++i){var j=e[i];if(!Dc(j.to,h.from)&&!Dc(h.to,j.from)){var k=[i,1];(Dc(j.from,h.from)||!g.inclusiveLeft&&Cc(j.from,h.from))&&k.push({from:j.from,to:h.from}),(Dc(h.to,j.to)||!g.inclusiveRight&&Cc(j.to,h.to))&&k.push({from:h.to,to:j.to}),e.splice.apply(e,k),i+=k.length-1}}return e}function Cd(a,b){var d,c=w&&a.markedSpans;if(c)for(var e,f=0;f<c.length;++f)e=c[f],e.marker.collapsed&&(null==e.from||e.from<b)&&(null==e.to||e.to>b)&&(!d||d.width<e.marker.width)&&(d=e.marker);return d}function Dd(a){return Cd(a,-1)}function Ed(a){return Cd(a,a.text.length+1)}function Fd(a,b){for(var c;c=Dd(b);)b=le(a,c.find().from.line);return b}function Gd(a,b){var c=w&&b.markedSpans;if(c)for(var d,e=0;e<c.length;++e)if(d=c[e],d.marker.collapsed){if(null==d.from)return!0;if(!d.marker.replacedWith&&0==d.from&&d.marker.inclusiveLeft&&Hd(a,b,d))return!0}}function Hd(a,b,c){if(null==c.to){var d=c.marker.find().to,e=le(a,d.line);return Hd(a,e,ud(e.markedSpans,c.marker))}if(c.marker.inclusiveRight&&c.to==b.text.length)return!0;for(var f,g=0;g<b.markedSpans.length;++g)if(f=b.markedSpans[g],f.marker.collapsed&&!f.marker.replacedWith&&f.from==c.to&&(f.marker.inclusiveLeft||c.marker.inclusiveRight)&&Hd(a,b,f))return!0}function Id(a){var b=a.markedSpans;if(b){for(var c=0;c<b.length;++c)b[c].marker.detachLine(a);a.markedSpans=null}}function Jd(a,b){if(b){for(var c=0;c<b.length;++c)b[c].marker.attachLine(a);a.markedSpans=b}}function Ld(a){return function(){var b=!this.cm.curOp;b&&Db(this.cm);try{var c=a.apply(this,arguments)}finally{b&&Eb(this.cm)}return c}}function Md(a){return null!=a.height?a.height:(a.node.parentNode&&1==a.node.parentNode.nodeType||nf(a.cm.display.measure,lf("div",[a.node],null,"position: relative")),a.height=a.node.offsetHeight)}function Nd(a,b,c,d){var e=new Kd(a,c,d);return e.noHScroll&&(a.display.alignWidgets=!0),Vc(a,b,function(b){var c=b.widgets||(b.widgets=[]);if(null==e.insertAt?c.push(e):c.splice(Math.min(c.length-1,Math.max(0,e.insertAt)),0,e),e.line=b,!Gd(a.doc,b)||e.showIfHidden){var d=re(a,b)<a.doc.scrollTop;oe(b,b.height+Md(e)),d&&Tc(a,0,e.height)}return!0}),e}function Pd(a,b,c,d){a.text=b,a.stateAfter&&(a.stateAfter=null),a.styles&&(a.styles=null),null!=a.order&&(a.order=null),Id(a),Jd(a,c);var e=d?d(a):1;e!=a.height&&oe(a,e)}function Qd(a){a.parent=null,Id(a)}function Rd(a,b,c,d,e){var f=c.flattenSpans;null==f&&(f=a.options.flattenSpans);var j,g=0,h=null,i=new pd(b,a.options.tabSize);for(""==b&&c.blankLine&&c.blankLine(d);!i.eol();)i.pos>a.options.maxHighlightLength?(f=!1,i.pos=b.length,j=null):j=c.token(i,d),f&&h==j||(g<i.start&&e(i.start,h),g=i.start,h=j),i.start=i.pos;for(;g<i.pos;){var k=Math.min(i.pos,g+5e4);e(k,h),g=k}}function Sd(a,b,c){var d=[a.state.modeGen];Rd(a,b.text,a.doc.mode,c,function(a,b){d.push(a,b)});for(var e=0;e<a.state.overlays.length;++e){var f=a.state.overlays[e],g=1,h=0;Rd(a,b.text,f.mode,!0,function(a,b){for(var c=g;a>h;){var e=d[g];e>a&&d.splice(g,1,a,d[g+1],e),g+=2,h=Math.min(a,e)}if(b)if(f.opaque)d.splice(c,g-c,a,b),g=c+2;else for(;g>c;c+=2){var i=d[c+1];d[c+1]=i?i+" "+b:b}})}return d}function Td(a,b){return b.styles&&b.styles[0]==a.state.modeGen||(b.styles=Sd(a,b,b.stateAfter=eb(a,pe(b)))),b.styles}function Ud(a,b,c){var d=a.doc.mode,e=new pd(b.text,a.options.tabSize);for(""==b.text&&d.blankLine&&d.blankLine(c);!e.eol()&&e.pos<=a.options.maxHighlightLength;)d.token(e,c),e.start=e.pos}function Wd(a,b){if(!a)return null;for(;;){var c=a.match(/(?:^|\s)line-(background-)?(\S+)/);if(!c)break;a=a.slice(0,c.index)+a.slice(c.index+c[0].length);var d=c[1]?"bgClass":"textClass";null==b[d]?b[d]=c[2]:new RegExp("(?:^|s)"+c[2]+"(?:$|s)").test(b[d])||(b[d]+=" "+c[2])}return Vd[a]||(Vd[a]="cm-"+a.replace(/ +/g," cm-"))}function Xd(a,c,d,g){for(var h,i=c,j=!0;h=Dd(i);)i=le(a.doc,h.find().from.line);var k={pre:lf("pre"),col:0,pos:0,measure:null,measuredSomething:!1,cm:a,copyWidgets:g};do{i.text&&(j=!1),k.measure=i==c&&d,k.pos=0,k.addToken=k.measure?$d:Zd,(b||f)&&a.getOption("lineWrapping")&&(k.addToken=_d(k.addToken));var l=be(i,k,Td(a,i));d&&i==c&&!k.measuredSomething&&(d[0]=k.pre.appendChild(vf(a.display.measure)),k.measuredSomething=!0),l&&(i=le(a.doc,l.to.line))}while(l);!d||k.measuredSomething||d[0]||(d[0]=k.pre.appendChild(j?lf("span","\xa0"):vf(a.display.measure))),k.pre.firstChild||Gd(a.doc,c)||k.pre.appendChild(document.createTextNode("\xa0"));var m;if(d&&(b||e)&&(m=se(i))){var n=m.length-1;m[n].from==m[n].to&&--n;var o=m[n],p=m[n-1];if(o.from+1==o.to&&p&&o.level<p.level){var q=d[k.pos-1];q&&q.parentNode.insertBefore(q.measureRight=vf(a.display.measure),q.nextSibling)}}var r=k.textClass?k.textClass+" "+(c.textClass||""):c.textClass;return r&&(k.pre.className=r),Ne(a,"renderLine",a,c,k.pre),k}function Zd(a,b,c,d,e,f){if(b){if(Yd.test(b))for(var g=document.createDocumentFragment(),h=0;;){Yd.lastIndex=h;var i=Yd.exec(b),j=i?i.index-h:b.length-h;if(j&&(g.appendChild(document.createTextNode(b.slice(h,h+j))),a.col+=j),!i)break;if(h+=j+1," "==i[0]){var k=a.cm.options.tabSize,l=k-a.col%k;g.appendChild(lf("span",$e(l),"cm-tab")),a.col+=l}else{var m=lf("span","\u2022","cm-invalidchar");m.title="\\u"+i[0].charCodeAt(0).toString(16),g.appendChild(m),a.col+=1}}else{a.col+=b.length;var g=document.createTextNode(b)}if(c||d||e||a.measure){var n=c||"";d&&(n+=d),e&&(n+=e);var m=lf("span",[g],n);return f&&(m.title=f),a.pre.appendChild(m)}a.pre.appendChild(g)}}function $d(a,c,d,e,f){for(var g=a.cm.options.lineWrapping,h=0;h<c.length;++h){var i=c.charAt(h),j=0==h;i>="\ud800"&&"\udbff">i&&h<c.length-1?(i=c.slice(h,h+2),++h):h&&g&&rf(c,h)&&a.pre.appendChild(lf("wbr"));var k=a.measure[a.pos],l=a.measure[a.pos]=Zd(a,i,d,j&&e,h==c.length-1&&f);k&&(l.leftSide=k.leftSide||k),b&&g&&" "==i&&h&&!/\s/.test(c.charAt(h-1))&&h<c.length-1&&!/\s/.test(c.charAt(h+1))&&(l.style.whiteSpace="normal"),a.pos+=i.length}c.length&&(a.measuredSomething=!0)}function _d(a){function b(a){for(var b=" ",c=0;c<a.length-2;++c)b+=c%2?" ":"\xa0";return b+=" "}return function(c,d,e,f,g,h){return a(c,d.replace(/ {3,}/g,b),e,f,g,h)}}function ae(a,b,c,d){var e=!d&&c.replacedWith;if(e&&(a.copyWidgets&&(e=e.cloneNode(!0)),a.pre.appendChild(e),a.measure)){if(b)a.measure[a.pos]=e;else{var f=vf(a.cm.display.measure);if("bookmark"!=c.type||c.insertLeft){if(a.measure[a.pos])return;a.measure[a.pos]=a.pre.insertBefore(f,e)}else a.measure[a.pos]=a.pre.appendChild(f)}a.measuredSomething=!0}a.pos+=b}function be(a,b,c){var d=a.markedSpans,e=a.text,f=0;if(d)for(var k,m,n,o,p,q,h=e.length,i=0,g=1,j="",l=0;;){if(l==i){m=n=o=p="",q=null,l=1/0;for(var r=[],s=0;s<d.length;++s){var t=d[s],u=t.marker;t.from<=i&&(null==t.to||t.to>i)?(null!=t.to&&l>t.to&&(l=t.to,n=""),u.className&&(m+=" "+u.className),u.startStyle&&t.from==i&&(o+=" "+u.startStyle),u.endStyle&&t.to==l&&(n+=" "+u.endStyle),u.title&&!p&&(p=u.title),u.collapsed&&(!q||q.marker.size<u.size)&&(q=t)):t.from>i&&l>t.from&&(l=t.from),"bookmark"==u.type&&t.from==i&&u.replacedWith&&r.push(u)}if(q&&(q.from||0)==i&&(ae(b,(null==q.to?h:q.to)-i,q.marker,null==q.from),null==q.to))return q.marker.find();if(!q&&r.length)for(var s=0;s<r.length;++s)ae(b,0,r[s])
}if(i>=h)break;for(var v=Math.min(h,l);;){if(j){var w=i+j.length;if(!q){var x=w>v?j.slice(0,v-i):j;b.addToken(b,x,k?k+m:m,o,i+x.length==l?n:"",p)}if(w>=v){j=j.slice(v-i),i=v;break}i=w,o=""}j=e.slice(f,f=c[g++]),k=Wd(c[g++],b)}}else for(var g=1;g<c.length;g+=2)b.addToken(b,e.slice(f,f=c[g]),Wd(c[g+1],b))}function ce(a,b,c,d,e){function f(a){return c?c[a]:null}function g(a,c,d){Pd(a,c,d,e),Qe(a,"change",a,b)}var h=b.from,i=b.to,j=b.text,k=le(a,h.line),l=le(a,i.line),m=_e(j),n=f(j.length-1),o=i.line-h.line;if(0==h.ch&&0==i.ch&&""==m){for(var p=0,q=j.length-1,r=[];q>p;++p)r.push(new Od(j[p],f(p),e));g(l,l.text,n),o&&a.remove(h.line,o),r.length&&a.insert(h.line,r)}else if(k==l)if(1==j.length)g(k,k.text.slice(0,h.ch)+m+k.text.slice(i.ch),n);else{for(var r=[],p=1,q=j.length-1;q>p;++p)r.push(new Od(j[p],f(p),e));r.push(new Od(m+k.text.slice(i.ch),n,e)),g(k,k.text.slice(0,h.ch)+j[0],f(0)),a.insert(h.line+1,r)}else if(1==j.length)g(k,k.text.slice(0,h.ch)+j[0]+l.text.slice(i.ch),f(0)),a.remove(h.line+1,o);else{g(k,k.text.slice(0,h.ch)+j[0],f(0)),g(l,m+l.text.slice(i.ch),n);for(var p=1,q=j.length-1,r=[];q>p;++p)r.push(new Od(j[p],f(p),e));o>1&&a.remove(h.line+1,o-1),a.insert(h.line+1,r)}Qe(a,"change",a,b),Lc(a,d.anchor,d.head,null,!0)}function de(a){this.lines=a,this.parent=null;for(var b=0,c=a.length,d=0;c>b;++b)a[b].parent=this,d+=a[b].height;this.height=d}function ee(a){this.children=a;for(var b=0,c=0,d=0,e=a.length;e>d;++d){var f=a[d];b+=f.chunkSize(),c+=f.height,f.parent=this}this.size=b,this.height=c,this.parent=null}function je(a,b,c){function d(a,e,f){if(a.linked)for(var g=0;g<a.linked.length;++g){var h=a.linked[g];if(h.doc!=e){var i=f&&h.sharedHist;(!c||i)&&(b(h.doc,i),d(h.doc,a,i))}}}d(a,null,!0)}function ke(a,b){if(b.cm)throw new Error("This document is already in use.");a.doc=b,b.cm=a,C(a),z(a),a.options.lineWrapping||I(a),a.options.mode=b.modeOption,Ib(a)}function le(a,b){for(b-=a.first;!a.lines;)for(var c=0;;++c){var d=a.children[c],e=d.chunkSize();if(e>b){a=d;break}b-=e}return a.lines[b]}function me(a,b,c){var d=[],e=b.line;return a.iter(b.line,c.line+1,function(a){var f=a.text;e==c.line&&(f=f.slice(0,c.ch)),e==b.line&&(f=f.slice(b.ch)),d.push(f),++e}),d}function ne(a,b,c){var d=[];return a.iter(b,c,function(a){d.push(a.text)}),d}function oe(a,b){for(var c=b-a.height,d=a;d;d=d.parent)d.height+=c}function pe(a){if(null==a.parent)return null;for(var b=a.parent,c=bf(b.lines,a),d=b.parent;d;b=d,d=d.parent)for(var e=0;d.children[e]!=b;++e)c+=d.children[e].chunkSize();return c+b.first}function qe(a,b){var c=a.first;a:do{for(var d=0,e=a.children.length;e>d;++d){var f=a.children[d],g=f.height;if(g>b){a=f;continue a}b-=g,c+=f.chunkSize()}return c}while(!a.lines);for(var d=0,e=a.lines.length;e>d;++d){var h=a.lines[d],i=h.height;if(i>b)break;b-=i}return c+d}function re(a,b){b=Fd(a.doc,b);for(var c=0,d=b.parent,e=0;e<d.lines.length;++e){var f=d.lines[e];if(f==b)break;c+=f.height}for(var g=d.parent;g;d=g,g=d.parent)for(var e=0;e<g.children.length;++e){var h=g.children[e];if(h==d)break;c+=h.height}return c}function se(a){var b=a.order;return null==b&&(b=a.order=Nf(a.text)),b}function te(a){return{done:[],undone:[],undoDepth:1/0,lastTime:0,lastOp:null,lastOrigin:null,generation:a||1,maxGeneration:a||1}}function ue(a,b,c,d){var e=b["spans_"+a.id],f=0;a.iter(Math.max(a.first,c),Math.min(a.first+a.size,d),function(c){c.markedSpans&&((e||(e=b["spans_"+a.id]={}))[f]=c.markedSpans),++f})}function ve(a,b){var c={line:b.from.line,ch:b.from.ch},d={from:c,to:qc(b),text:me(a,b.from,b.to)};return ue(a,d,b.from.line,b.to.line+1),je(a,function(a){ue(a,d,b.from.line,b.to.line+1)},!0),d}function we(a,b,c,d){var e=a.history;e.undone.length=0;var f=+new Date,g=_e(e.done);if(g&&(e.lastOp==d||e.lastOrigin==b.origin&&b.origin&&("+"==b.origin.charAt(0)&&a.cm&&e.lastTime>f-a.cm.options.historyEventDelay||"*"==b.origin.charAt(0)))){var h=_e(g.changes);Cc(b.from,b.to)&&Cc(b.from,h.to)?h.to=qc(b):g.changes.push(ve(a,b)),g.anchorAfter=c.anchor,g.headAfter=c.head}else for(g={changes:[ve(a,b)],generation:e.generation,anchorBefore:a.sel.anchor,headBefore:a.sel.head,anchorAfter:c.anchor,headAfter:c.head},e.done.push(g),e.generation=++e.maxGeneration;e.done.length>e.undoDepth;)e.done.shift();e.lastTime=f,e.lastOp=d,e.lastOrigin=b.origin}function xe(a){if(!a)return null;for(var c,b=0;b<a.length;++b)a[b].marker.explicitlyCleared?c||(c=a.slice(0,b)):c&&c.push(a[b]);return c?c.length?c:null:a}function ye(a,b){var c=b["spans_"+a.id];if(!c)return null;for(var d=0,e=[];d<b.text.length;++d)e.push(xe(c[d]));return e}function ze(a,b){for(var c=0,d=[];c<a.length;++c){var e=a[c],f=e.changes,g=[];d.push({changes:g,anchorBefore:e.anchorBefore,headBefore:e.headBefore,anchorAfter:e.anchorAfter,headAfter:e.headAfter});for(var h=0;h<f.length;++h){var j,i=f[h];if(g.push({from:i.from,to:i.to,text:i.text}),b)for(var k in i)(j=k.match(/^spans_(\d+)$/))&&bf(b,Number(j[1]))>-1&&(_e(g)[k]=i[k],delete i[k])}}return d}function Ae(a,b,c,d){c<a.line?a.line+=d:b<a.line&&(a.line=b,a.ch=0)}function Be(a,b,c,d){for(var e=0;e<a.length;++e){for(var f=a[e],g=!0,h=0;h<f.changes.length;++h){var i=f.changes[h];if(f.copied||(i.from=Ec(i.from),i.to=Ec(i.to)),c<i.from.line)i.from.line+=d,i.to.line+=d;else if(b<=i.to.line){g=!1;break}}f.copied||(f.anchorBefore=Ec(f.anchorBefore),f.headBefore=Ec(f.headBefore),f.anchorAfter=Ec(f.anchorAfter),f.readAfter=Ec(f.headAfter),f.copied=!0),g?(Ae(f.anchorBefore),Ae(f.headBefore),Ae(f.anchorAfter),Ae(f.headAfter)):(a.splice(0,e+1),e=0)}}function Ce(a,b){var c=b.from.line,d=b.to.line,e=b.text.length-(d-c)-1;Be(a.done,c,d,e),Be(a.undone,c,d,e)}function De(){Ie(this)}function Ee(a){return a.stop||(a.stop=De),a}function Fe(a){a.preventDefault?a.preventDefault():a.returnValue=!1}function Ge(a){a.stopPropagation?a.stopPropagation():a.cancelBubble=!0}function He(a){return null!=a.defaultPrevented?a.defaultPrevented:0==a.returnValue}function Ie(a){Fe(a),Ge(a)}function Je(a){return a.target||a.srcElement}function Ke(a){var b=a.which;return null==b&&(1&a.button?b=1:2&a.button?b=3:4&a.button&&(b=2)),q&&a.ctrlKey&&1==b&&(b=3),b}function Le(a,b,c){if(a.addEventListener)a.addEventListener(b,c,!1);else if(a.attachEvent)a.attachEvent("on"+b,c);else{var d=a._handlers||(a._handlers={}),e=d[b]||(d[b]=[]);e.push(c)}}function Me(a,b,c){if(a.removeEventListener)a.removeEventListener(b,c,!1);else if(a.detachEvent)a.detachEvent("on"+b,c);else{var d=a._handlers&&a._handlers[b];if(!d)return;for(var e=0;e<d.length;++e)if(d[e]==c){d.splice(e,1);break}}}function Ne(a,b){var c=a._handlers&&a._handlers[b];if(c)for(var d=Array.prototype.slice.call(arguments,2),e=0;e<c.length;++e)c[e].apply(null,d)}function Qe(a,b){function e(a){return function(){a.apply(null,d)}}var c=a._handlers&&a._handlers[b];if(c){var d=Array.prototype.slice.call(arguments,2);Oe||(++Pe,Oe=[],setTimeout(Se,0));for(var f=0;f<c.length;++f)Oe.push(e(c[f]))}}function Re(a,b,c){return Ne(a,c||b.type,a,b),He(b)||b.codemirrorIgnore}function Se(){--Pe;var a=Oe;Oe=null;for(var b=0;b<a.length;++b)a[b]()}function Te(a,b){var c=a._handlers&&a._handlers[b];return c&&c.length>0}function Ue(a){a.prototype.on=function(a,b){Le(this,a,b)},a.prototype.off=function(a,b){Me(this,a,b)}}function Xe(){this.id=null}function Ye(a,b,c,d,e){null==b&&(b=a.search(/[^\s\u00a0]/),-1==b&&(b=a.length));for(var f=d||0,g=e||0;b>f;++f)" "==a.charAt(f)?g+=c-g%c:++g;return g}function $e(a){for(;Ze.length<=a;)Ze.push(_e(Ze)+" ");return Ze[a]}function _e(a){return a[a.length-1]}function af(a){if(o)a.selectionStart=0,a.selectionEnd=a.value.length;else try{a.select()}catch(b){}}function bf(a,b){if(a.indexOf)return a.indexOf(b);for(var c=0,d=a.length;d>c;++c)if(a[c]==b)return c;return-1}function cf(a,b){function c(){}c.prototype=a;var d=new c;return b&&df(b,d),d}function df(a,b){b||(b={});for(var c in a)a.hasOwnProperty(c)&&(b[c]=a[c]);return b}function ef(a){for(var b=[],c=0;a>c;++c)b.push(void 0);return b}function ff(a){var b=Array.prototype.slice.call(arguments,1);return function(){return a.apply(null,b)}}function hf(a){return/\w/.test(a)||a>"\x80"&&(a.toUpperCase()!=a.toLowerCase()||gf.test(a))}function jf(a){for(var b in a)if(a.hasOwnProperty(b)&&a[b])return!1;return!0}function lf(a,b,c,d){var e=document.createElement(a);if(c&&(e.className=c),d&&(e.style.cssText=d),"string"==typeof b)of(e,b);else if(b)for(var f=0;f<b.length;++f)e.appendChild(b[f]);return e}function mf(a){for(var b=a.childNodes.length;b>0;--b)a.removeChild(a.firstChild);return a}function nf(a,b){return mf(a).appendChild(b)}function of(a,b){d?(a.innerHTML="",a.appendChild(document.createTextNode(b))):a.textContent=b}function pf(a){return a.getBoundingClientRect()}function rf(){return!1}function tf(a){if(null!=sf)return sf;var b=lf("div",null,null,"width: 50px; height: 50px; overflow-x: scroll");return nf(a,b),b.offsetWidth&&(sf=b.offsetHeight-b.clientHeight),sf||0}function vf(a){if(null==uf){var b=lf("span","\u200b");nf(a,lf("span",[b,document.createTextNode("x")])),0!=a.firstChild.offsetHeight&&(uf=b.offsetWidth<=1&&b.offsetHeight>2&&!c)}return uf?lf("span","\u200b"):lf("span","\xa0",null,"display: inline-block; width: 1px; margin-right: -1px")}function Af(a,b,c,d){if(!a)return d(b,c,"ltr");for(var e=!1,f=0;f<a.length;++f){var g=a[f];(g.from<c&&g.to>b||b==c&&g.to==b)&&(d(Math.max(g.from,b),Math.min(g.to,c),1==g.level?"rtl":"ltr"),e=!0)}e||d(b,c,"ltr")}function Bf(a){return a.level%2?a.to:a.from}function Cf(a){return a.level%2?a.from:a.to}function Df(a){var b=se(a);return b?Bf(b[0]):0}function Ef(a){var b=se(a);return b?Cf(_e(b)):a.text.length}function Ff(a,b){var c=le(a.doc,b),d=Fd(a.doc,c);d!=c&&(b=pe(d));var e=se(d),f=e?e[0].level%2?Ef(d):Df(d):0;return Bc(b,f)}function Gf(a,b){for(var c,d;c=Ed(d=le(a.doc,b));)b=c.find().to.line;var e=se(d),f=e?e[0].level%2?Df(d):Ef(d):d.text.length;return Bc(b,f)}function Hf(a,b,c){var d=a[0].level;return b==d?!0:c==d?!1:c>b}function Jf(a,b){for(var d,c=0;c<a.length;++c){var e=a[c];if(e.from<b&&e.to>b)return If=null,c;if(e.from==b||e.to==b){if(null!=d)return Hf(a,e.level,a[d].level)?(If=d,c):(If=c,d);d=c}}return If=null,d}function Kf(a,b,c,d){if(!d)return b+c;do b+=c;while(b>0&&kf.test(a.text.charAt(b)));return b}function Lf(a,b,c,d){var e=se(a);if(!e)return Mf(a,b,c,d);for(var f=Jf(e,b),g=e[f],h=Kf(a,b,g.level%2?-c:c,d);;){if(h>g.from&&h<g.to)return h;if(h==g.from||h==g.to)return Jf(e,h)==f?h:(g=e[f+=c],c>0==g.level%2?g.to:g.from);if(g=e[f+=c],!g)return null;h=c>0==g.level%2?Kf(a,g.to,-1,d):Kf(a,g.from,1,d)}}function Mf(a,b,c,d){var e=b+c;if(d)for(;e>0&&kf.test(a.text.charAt(e));)e+=c;return 0>e||e>a.text.length?null:e}var a=/gecko\/\d/i.test(navigator.userAgent),b=/MSIE \d/.test(navigator.userAgent),c=b&&(null==document.documentMode||document.documentMode<8),d=b&&(null==document.documentMode||document.documentMode<9),e=/Trident\/([7-9]|\d{2,})\./,f=/WebKit\//.test(navigator.userAgent),g=f&&/Qt\/\d+\.\d+/.test(navigator.userAgent),h=/Chrome\//.test(navigator.userAgent),i=/Opera\//.test(navigator.userAgent),j=/Apple Computer/.test(navigator.vendor),k=/KHTML\//.test(navigator.userAgent),l=/Mac OS X 1\d\D([7-9]|\d\d)\D/.test(navigator.userAgent),m=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent),n=/PhantomJS/.test(navigator.userAgent),o=/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),p=o||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent),q=o||/Mac/.test(navigator.platform),r=/win/i.test(navigator.platform),s=i&&navigator.userAgent.match(/Version\/(\d*\.\d*)/);s&&(s=Number(s[1])),s&&s>=15&&(i=!1,f=!0);var zb,Sb,Tb,t=q&&(g||i&&(null==s||12.11>s)),u=a||b&&!d,v=!1,w=!1,Cb=0,Yb=0,bc=0,cc=null;b?cc=-.53:a?cc=15:h?cc=-.7:j&&(cc=-1/3);var gc,oc,jc=null,qc=x.changeEnd=function(a){return a.text?Bc(a.from.line+a.text.length-1,_e(a.text).length+(1==a.text.length?a.from.ch:0)):a.to};x.Pos=Bc,x.prototype={constructor:x,focus:function(){window.focus(),Nb(this),mc(this),Kb(this)},setOption:function(a,b){var c=this.options,d=c[a];(c[a]!=b||"mode"==a)&&(c[a]=b,$c.hasOwnProperty(a)&&Fb(this,$c[a])(this,b,d))},getOption:function(a){return this.options[a]},getDoc:function(){return this.doc},addKeyMap:function(a,b){this.state.keyMaps[b?"push":"unshift"](a)},removeKeyMap:function(a){for(var b=this.state.keyMaps,c=0;c<b.length;++c)if(b[c]==a||"string"!=typeof b[c]&&b[c].name==a)return b.splice(c,1),!0},addOverlay:Fb(null,function(a,b){var c=a.token?a:x.getMode(this.options,a);if(c.startState)throw new Error("Overlays may not be stateful.");this.state.overlays.push({mode:c,modeSpec:a,opaque:b&&b.opaque}),this.state.modeGen++,Ib(this)}),removeOverlay:Fb(null,function(a){for(var b=this.state.overlays,c=0;c<b.length;++c){var d=b[c].modeSpec;if(d==a||"string"==typeof a&&d.name==a)return b.splice(c,1),this.state.modeGen++,Ib(this),void 0}}),indentLine:Fb(null,function(a,b,c){"string"!=typeof b&&"number"!=typeof b&&(b=null==b?this.options.smartIndent?"smart":"prev":b?"add":"subtract"),Ic(this.doc,a)&&Uc(this,a,b,c)}),indentSelection:Fb(null,function(a){var b=this.doc.sel;if(Cc(b.from,b.to))return Uc(this,b.from.line,a);for(var c=b.to.line-(b.to.ch?0:1),d=b.from.line;c>=d;++d)Uc(this,d,a)}),getTokenAt:function(a,b){var c=this.doc;a=Gc(c,a);for(var d=eb(this,a.line,b),e=this.doc.mode,f=le(c,a.line),g=new pd(f.text,this.options.tabSize);g.pos<a.ch&&!g.eol();){g.start=g.pos;var h=e.token(g,d)}return{start:g.start,end:g.pos,string:g.current(),className:h||null,type:h||null,state:d}},getTokenTypeAt:function(a){a=Gc(this.doc,a);var b=Td(this,le(this.doc,a.line)),c=0,d=(b.length-1)/2,e=a.ch;if(0==e)return b[2];for(;;){var f=c+d>>1;if((f?b[2*f-1]:0)>=e)d=f;else{if(!(b[2*f+1]<e))return b[2*f+2];c=f+1}}},getModeAt:function(a){var b=this.doc.mode;return b.innerMode?x.innerMode(b,this.getTokenAt(a).state).mode:b},getHelper:function(a,b){if(gd.hasOwnProperty(b)){var c=gd[b],d=this.getModeAt(a);return d[b]&&c[d[b]]||d.helperType&&c[d.helperType]||c[d.name]}},getStateAfter:function(a,b){var c=this.doc;return a=Fc(c,null==a?c.first+c.size-1:a),eb(this,a+1,b)},cursorCoords:function(a,b){var c,d=this.doc.sel;return c=null==a?d.head:"object"==typeof a?Gc(this.doc,a):a?d.from:d.to,vb(this,c,b||"page")},charCoords:function(a,b){return ub(this,Gc(this.doc,a),b||"page")},coordsChar:function(a,b){return a=tb(this,a,b||"page"),xb(this,a.left,a.top)},lineAtHeight:function(a,b){return a=tb(this,{top:a,left:0},b||"page").top,qe(this.doc,a+this.display.viewOffset)},heightAtLine:function(a,b){var c=!1,d=this.doc.first+this.doc.size-1;a<this.doc.first?a=this.doc.first:a>d&&(a=d,c=!0);var e=le(this.doc,a);return sb(this,le(this.doc,a),{top:0,left:0},b||"page").top+(c?e.height:0)},defaultTextHeight:function(){return Ab(this.display)},defaultCharWidth:function(){return Bb(this.display)},setGutterMarker:Fb(null,function(a,b,c){return Vc(this,a,function(a){var d=a.gutterMarkers||(a.gutterMarkers={});return d[b]=c,!c&&jf(d)&&(a.gutterMarkers=null),!0})}),clearGutter:Fb(null,function(a){var b=this,c=b.doc,d=c.first;c.iter(function(c){c.gutterMarkers&&c.gutterMarkers[a]&&(c.gutterMarkers[a]=null,Ib(b,d,d+1),jf(c.gutterMarkers)&&(c.gutterMarkers=null)),++d})}),addLineClass:Fb(null,function(a,b,c){return Vc(this,a,function(a){var d="text"==b?"textClass":"background"==b?"bgClass":"wrapClass";if(a[d]){if(new RegExp("(?:^|\\s)"+c+"(?:$|\\s)").test(a[d]))return!1;a[d]+=" "+c}else a[d]=c;return!0})}),removeLineClass:Fb(null,function(a,b,c){return Vc(this,a,function(a){var d="text"==b?"textClass":"background"==b?"bgClass":"wrapClass",e=a[d];if(!e)return!1;if(null==c)a[d]=null;else{var f=e.match(new RegExp("(?:^|\\s+)"+c+"(?:$|\\s+)"));if(!f)return!1;var g=f.index+f[0].length;a[d]=e.slice(0,f.index)+(f.index&&g!=e.length?" ":"")+e.slice(g)||null}return!0})}),addLineWidget:Fb(null,function(a,b,c){return Nd(this,a,b,c)}),removeLineWidget:function(a){a.clear()},lineInfo:function(a){if("number"==typeof a){if(!Ic(this.doc,a))return null;var b=a;if(a=le(this.doc,a),!a)return null}else{var b=pe(a);if(null==b)return null}return{line:b,handle:a,text:a.text,gutterMarkers:a.gutterMarkers,textClass:a.textClass,bgClass:a.bgClass,wrapClass:a.wrapClass,widgets:a.widgets}},getViewport:function(){return{from:this.display.showingFrom,to:this.display.showingTo}},addWidget:function(a,b,c,d,e){var f=this.display;a=vb(this,Gc(this.doc,a));var g=a.bottom,h=a.left;if(b.style.position="absolute",f.sizer.appendChild(b),"over"==d)g=a.top;else if("above"==d||"near"==d){var i=Math.max(f.wrapper.clientHeight,this.doc.height),j=Math.max(f.sizer.clientWidth,f.lineSpace.clientWidth);("above"==d||a.bottom+b.offsetHeight>i)&&a.top>b.offsetHeight?g=a.top-b.offsetHeight:a.bottom+b.offsetHeight<=i&&(g=a.bottom),h+b.offsetWidth>j&&(h=j-b.offsetWidth)}b.style.top=g+"px",b.style.left=b.style.right="","right"==e?(h=f.sizer.clientWidth-b.offsetWidth,b.style.right="0px"):("left"==e?h=0:"middle"==e&&(h=(f.sizer.clientWidth-b.offsetWidth)/2),b.style.left=h+"px"),c&&Qc(this,h,g,h+b.offsetWidth,g+b.offsetHeight)},triggerOnKeyDown:Fb(null,kc),execCommand:function(a){return jd[a](this)},findPosH:function(a,b,c,d){var e=1;0>b&&(e=-1,b=-b);for(var f=0,g=Gc(this.doc,a);b>f&&(g=Wc(this.doc,g,e,c,d),!g.hitSide);++f);return g},moveH:Fb(null,function(a,b){var d,c=this.doc.sel;d=c.shift||c.extend||Cc(c.from,c.to)?Wc(this.doc,c.head,a,b,this.options.rtlMoveVisually):0>a?c.from:c.to,Jc(this.doc,d,d,a)}),deleteH:Fb(null,function(a,b){var c=this.doc.sel;Cc(c.from,c.to)?Ac(this.doc,"",c.from,Wc(this.doc,c.head,a,b,!1),"+delete"):Ac(this.doc,"",c.from,c.to,"+delete"),this.curOp.userSelChange=!0}),findPosV:function(a,b,c,d){var e=1,f=d;0>b&&(e=-1,b=-b);for(var g=0,h=Gc(this.doc,a);b>g;++g){var i=vb(this,h,"div");if(null==f?f=i.left:i.left=f,h=Xc(this,i,e,c),h.hitSide)break}return h},moveV:Fb(null,function(a,b){var c=this.doc.sel,d=vb(this,c.head,"div");null!=c.goalColumn&&(d.left=c.goalColumn);var e=Xc(this,d,a,b);"page"==b&&Tc(this,0,ub(this,e,"div").top-d.top),Jc(this.doc,e,e,a),c.goalColumn=d.left}),toggleOverwrite:function(a){(null==a||a!=this.state.overwrite)&&((this.state.overwrite=!this.state.overwrite)?this.display.cursor.className+=" CodeMirror-overwrite":this.display.cursor.className=this.display.cursor.className.replace(" CodeMirror-overwrite",""))},hasFocus:function(){return this.state.focused},scrollTo:Fb(null,function(a,b){Sc(this,a,b)}),getScrollInfo:function(){var a=this.display.scroller,b=Ve;return{left:a.scrollLeft,top:a.scrollTop,height:a.scrollHeight-b,width:a.scrollWidth-b,clientHeight:a.clientHeight-b,clientWidth:a.clientWidth-b}},scrollIntoView:Fb(null,function(a,b){null==a?a={from:this.doc.sel.head,to:null}:"number"==typeof a?a={from:Bc(a,0),to:null}:null==a.from&&(a={from:a,to:null}),a.to||(a.to=a.from),b||(b=0);var c=a;null!=a.from.line&&(this.curOp.scrollToPos={from:a.from,to:a.to,margin:b},c={from:vb(this,a.from),to:vb(this,a.to)});var d=Rc(this,Math.min(c.from.left,c.to.left),Math.min(c.from.top,c.to.top)-b,Math.max(c.from.right,c.to.right),Math.max(c.from.bottom,c.to.bottom)+b);Sc(this,d.scrollLeft,d.scrollTop)}),setSize:Fb(null,function(a,b){function c(a){return"number"==typeof a||/^\d+$/.test(String(a))?a+"px":a}null!=a&&(this.display.wrapper.style.width=c(a)),null!=b&&(this.display.wrapper.style.height=c(b)),this.options.lineWrapping&&(this.display.measureLineCache.length=this.display.measureLineCachePos=0),this.curOp.forceUpdate=!0}),operation:function(a){return Hb(this,a)},refresh:Fb(null,function(){var a=null==this.display.cachedTextHeight;pb(this),Sc(this,this.doc.scrollLeft,this.doc.scrollTop),Ib(this),a&&C(this)}),swapDoc:Fb(null,function(a){var b=this.doc;return b.cm=null,ke(this,a),pb(this),Mb(this,!0),Sc(this,a.scrollLeft,a.scrollTop),Qe(this,"swapDoc",this,b),b}),getInputField:function(){return this.display.input},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},Ue(x);var $c=x.optionHandlers={},_c=x.defaults={},bd=x.Init={toString:function(){return"CodeMirror.Init"}};ad("value","",function(a,b){a.setValue(b)},!0),ad("mode",null,function(a,b){a.doc.modeOption=b,z(a)},!0),ad("indentUnit",2,z,!0),ad("indentWithTabs",!1),ad("smartIndent",!0),ad("tabSize",4,function(a){z(a),pb(a),Ib(a)},!0),ad("electricChars",!0),ad("rtlMoveVisually",!r),ad("theme","default",function(a){E(a),F(a)},!0),ad("keyMap","default",D),ad("extraKeys",null),ad("onKeyEvent",null),ad("onDragEvent",null),ad("lineWrapping",!1,A,!0),ad("gutters",[],function(a){J(a.options),F(a)},!0),ad("fixedGutter",!0,function(a,b){a.display.gutters.style.left=b?P(a.display)+"px":"0",a.refresh()},!0),ad("coverGutterNextToScrollbar",!1,K,!0),ad("lineNumbers",!1,function(a){J(a.options),F(a)},!0),ad("firstLineNumber",1,F,!0),ad("lineNumberFormatter",function(a){return a},F,!0),ad("showCursorWhenSelecting",!1,Z,!0),ad("resetSelectionOnContextMenu",!0),ad("readOnly",!1,function(a,b){"nocursor"==b?(nc(a),a.display.input.blur(),a.display.disabled=!0):(a.display.disabled=!1,b||Mb(a,!0))}),ad("dragDrop",!0),ad("cursorBlinkRate",530),ad("cursorScrollMargin",0),ad("cursorHeight",1),ad("workTime",100),ad("workDelay",100),ad("flattenSpans",!0),ad("pollInterval",100),ad("undoDepth",40,function(a,b){a.doc.history.undoDepth=b}),ad("historyEventDelay",500),ad("viewportMargin",10,function(a){a.refresh()},!0),ad("maxHighlightLength",1e4,function(a){z(a),a.refresh()},!0),ad("crudeMeasuringFrom",1e4),ad("moveInputWithCursor",!0,function(a,b){b||(a.display.inputDiv.style.top=a.display.inputDiv.style.left=0)}),ad("tabindex",null,function(a,b){a.display.input.tabIndex=b||""}),ad("autofocus",null);var cd=x.modes={},dd=x.mimeModes={};x.defineMode=function(a,b){if(x.defaults.mode||"null"==a||(x.defaults.mode=a),arguments.length>2){b.dependencies=[];for(var c=2;c<arguments.length;++c)b.dependencies.push(arguments[c])}cd[a]=b},x.defineMIME=function(a,b){dd[a]=b},x.resolveMode=function(a){if("string"==typeof a&&dd.hasOwnProperty(a))a=dd[a];else if(a&&"string"==typeof a.name&&dd.hasOwnProperty(a.name)){var b=dd[a.name];a=cf(b,a),a.name=b.name}else if("string"==typeof a&&/^[\w\-]+\/[\w\-]+\+xml$/.test(a))return x.resolveMode("application/xml");return"string"==typeof a?{name:a}:a||{name:"null"}},x.getMode=function(a,b){var b=x.resolveMode(b),c=cd[b.name];if(!c)return x.getMode(a,"text/plain");var d=c(a,b);if(ed.hasOwnProperty(b.name)){var e=ed[b.name];for(var f in e)e.hasOwnProperty(f)&&(d.hasOwnProperty(f)&&(d["_"+f]=d[f]),d[f]=e[f])}return d.name=b.name,d},x.defineMode("null",function(){return{token:function(a){a.skipToEnd()}}}),x.defineMIME("text/plain","null");var ed=x.modeExtensions={};x.extendMode=function(a,b){var c=ed.hasOwnProperty(a)?ed[a]:ed[a]={};df(b,c)},x.defineExtension=function(a,b){x.prototype[a]=b},x.defineDocExtension=function(a,b){ge.prototype[a]=b},x.defineOption=ad;var fd=[];x.defineInitHook=function(a){fd.push(a)};var gd=x.helpers={};x.registerHelper=function(a,b,c){gd.hasOwnProperty(a)||(gd[a]=x[a]={}),gd[a][b]=c},x.isWordChar=hf,x.copyState=hd,x.startState=id,x.innerMode=function(a,b){for(;a.innerMode;){var c=a.innerMode(b);if(!c||c.mode==a)break;b=c.state,a=c.mode}return c||{mode:a,state:b}};var jd=x.commands={selectAll:function(a){a.setSelection(Bc(a.firstLine(),0),Bc(a.lastLine()))},killLine:function(a){var b=a.getCursor(!0),c=a.getCursor(!1),d=!Cc(b,c);d||a.getLine(b.line).length!=b.ch?a.replaceRange("",b,d?c:Bc(b.line),"+delete"):a.replaceRange("",b,Bc(b.line+1,0),"+delete")},deleteLine:function(a){var b=a.getCursor().line;a.replaceRange("",Bc(b,0),Bc(b),"+delete")},delLineLeft:function(a){var b=a.getCursor();a.replaceRange("",Bc(b.line,0),b,"+delete")},undo:function(a){a.undo()},redo:function(a){a.redo()},goDocStart:function(a){a.extendSelection(Bc(a.firstLine(),0))},goDocEnd:function(a){a.extendSelection(Bc(a.lastLine()))},goLineStart:function(a){a.extendSelection(Ff(a,a.getCursor().line))},goLineStartSmart:function(a){var b=a.getCursor(),c=Ff(a,b.line),d=a.getLineHandle(c.line),e=se(d);if(e&&0!=e[0].level)a.extendSelection(c);else{var f=Math.max(0,d.text.search(/\S/)),g=b.line==c.line&&b.ch<=f&&b.ch;a.extendSelection(Bc(c.line,g?0:f))}},goLineEnd:function(a){a.extendSelection(Gf(a,a.getCursor().line))},goLineRight:function(a){var b=a.charCoords(a.getCursor(),"div").top+5;a.extendSelection(a.coordsChar({left:a.display.lineDiv.offsetWidth+100,top:b},"div"))},goLineLeft:function(a){var b=a.charCoords(a.getCursor(),"div").top+5;a.extendSelection(a.coordsChar({left:0,top:b},"div"))},goLineUp:function(a){a.moveV(-1,"line")},goLineDown:function(a){a.moveV(1,"line")},goPageUp:function(a){a.moveV(-1,"page")},goPageDown:function(a){a.moveV(1,"page")},goCharLeft:function(a){a.moveH(-1,"char")},goCharRight:function(a){a.moveH(1,"char")},goColumnLeft:function(a){a.moveH(-1,"column")},goColumnRight:function(a){a.moveH(1,"column")},goWordLeft:function(a){a.moveH(-1,"word")},goGroupRight:function(a){a.moveH(1,"group")},goGroupLeft:function(a){a.moveH(-1,"group")},goWordRight:function(a){a.moveH(1,"word")},delCharBefore:function(a){a.deleteH(-1,"char")},delCharAfter:function(a){a.deleteH(1,"char")},delWordBefore:function(a){a.deleteH(-1,"word")},delWordAfter:function(a){a.deleteH(1,"word")},delGroupBefore:function(a){a.deleteH(-1,"group")},delGroupAfter:function(a){a.deleteH(1,"group")},indentAuto:function(a){a.indentSelection("smart")},indentMore:function(a){a.indentSelection("add")},indentLess:function(a){a.indentSelection("subtract")},insertTab:function(a){a.replaceSelection(" ","end","+input")},defaultTab:function(a){a.somethingSelected()?a.indentSelection("add"):a.replaceSelection(" ","end","+input")},transposeChars:function(a){var b=a.getCursor(),c=a.getLine(b.line);b.ch>0&&b.ch<c.length-1&&a.replaceRange(c.charAt(b.ch)+c.charAt(b.ch-1),Bc(b.line,b.ch-1),Bc(b.line,b.ch+1))},newlineAndIndent:function(a){Fb(a,function(){a.replaceSelection("\n","end","+input"),a.indentLine(a.getCursor().line,null,!0)})()},toggleOverwrite:function(a){a.toggleOverwrite()}},kd=x.keyMap={};kd.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite"},kd.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Alt-Up":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Down":"goDocEnd","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore",fallthrough:"basic"},kd.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineStart","Cmd-Right":"goLineEnd","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delLineLeft",fallthrough:["basic","emacsy"]},kd["default"]=q?kd.macDefault:kd.pcDefault,kd.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars"},x.lookupKey=md,x.isModifierKey=nd,x.keyName=od,x.fromTextArea=function(a,b){function e(){a.value=i.getValue()}if(b||(b={}),b.value=a.value,!b.tabindex&&a.tabindex&&(b.tabindex=a.tabindex),!b.placeholder&&a.placeholder&&(b.placeholder=a.placeholder),null==b.autofocus){var c=document.body;try{c=document.activeElement}catch(d){}b.autofocus=c==a||null!=a.getAttribute("autofocus")&&c==document.body}if(a.form&&(Le(a.form,"submit",e),!b.leaveSubmitMethodAlone)){var f=a.form,g=f.submit;try{var h=f.submit=function(){e(),f.submit=g,f.submit(),f.submit=h}}catch(d){}}a.style.display="none";var i=x(function(b){a.parentNode.insertBefore(b,a.nextSibling)},b);return i.save=e,i.getTextArea=function(){return a},i.toTextArea=function(){e(),a.parentNode.removeChild(i.getWrapperElement()),a.style.display="",a.form&&(Me(a.form,"submit",e),"function"==typeof a.form.submit&&(a.form.submit=g))},i},pd.prototype={eol:function(){return this.pos>=this.string.length},sol:function(){return 0==this.pos},peek:function(){return this.string.charAt(this.pos)||void 0},next:function(){return this.pos<this.string.length?this.string.charAt(this.pos++):void 0},eat:function(a){var b=this.string.charAt(this.pos);if("string"==typeof a)var c=b==a;else var c=b&&(a.test?a.test(b):a(b));return c?(++this.pos,b):void 0},eatWhile:function(a){for(var b=this.pos;this.eat(a););return this.pos>b},eatSpace:function(){for(var a=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>a},skipToEnd:function(){this.pos=this.string.length},skipTo:function(a){var b=this.string.indexOf(a,this.pos);return b>-1?(this.pos=b,!0):void 0},backUp:function(a){this.pos-=a},column:function(){return this.lastColumnPos<this.start&&(this.lastColumnValue=Ye(this.string,this.start,this.tabSize,this.lastColumnPos,this.lastColumnValue),this.lastColumnPos=this.start),this.lastColumnValue},indentation:function(){return Ye(this.string,null,this.tabSize)},match:function(a,b,c){if("string"!=typeof a){var f=this.string.slice(this.pos).match(a);return f&&f.index>0?null:(f&&b!==!1&&(this.pos+=f[0].length),f)}var d=function(a){return c?a.toLowerCase():a},e=this.string.substr(this.pos,a.length);return d(e)==d(a)?(b!==!1&&(this.pos+=a.length),!0):void 0},current:function(){return this.string.slice(this.start,this.pos)}},x.StringStream=pd,x.TextMarker=qd,Ue(qd),qd.prototype.clear=function(){if(!this.explicitlyCleared){var a=this.doc.cm,b=a&&!a.curOp;if(b&&Db(a),Te(this,"clear")){var c=this.find();c&&Qe(this,"clear",c.from,c.to)}for(var d=null,e=null,f=0;f<this.lines.length;++f){var g=this.lines[f],h=ud(g.markedSpans,this);null!=h.to&&(e=pe(g)),g.markedSpans=vd(g.markedSpans,h),null!=h.from?d=pe(g):this.collapsed&&!Gd(this.doc,g)&&a&&oe(g,Ab(a.display))}if(a&&this.collapsed&&!a.options.lineWrapping)for(var f=0;f<this.lines.length;++f){var i=Fd(a.doc,this.lines[f]),j=H(a.doc,i);j>a.display.maxLineLength&&(a.display.maxLine=i,a.display.maxLineLength=j,a.display.maxLineChanged=!0)}null!=d&&a&&Ib(a,d,e+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,a&&Mc(a)),b&&Eb(a)}},qd.prototype.find=function(){for(var a,b,c=0;c<this.lines.length;++c){var d=this.lines[c],e=ud(d.markedSpans,this);if(null!=e.from||null!=e.to){var f=pe(d);null!=e.from&&(a=Bc(f,e.from)),null!=e.to&&(b=Bc(f,e.to))}}return"bookmark"==this.type?a:a&&{from:a,to:b}},qd.prototype.changed=function(){var a=this.find(),b=this.doc.cm;if(a&&b){"bookmark"!=this.type&&(a=a.from);var c=le(this.doc,a.line);if(kb(b,c),a.line>=b.display.showingFrom&&a.line<b.display.showingTo){for(var d=b.display.lineDiv.firstChild;d;d=d.nextSibling)if(d.lineObj==c){d.offsetHeight!=c.height&&oe(c,d.offsetHeight);break}Hb(b,function(){b.curOp.selectionChanged=b.curOp.forceUpdate=b.curOp.updateMaxLine=!0})}}},qd.prototype.attachLine=function(a){if(!this.lines.length&&this.doc.cm){var b=this.doc.cm.curOp;b.maybeHiddenMarkers&&-1!=bf(b.maybeHiddenMarkers,this)||(b.maybeUnhiddenMarkers||(b.maybeUnhiddenMarkers=[])).push(this)}this.lines.push(a)},qd.prototype.detachLine=function(a){if(this.lines.splice(bf(this.lines,a),1),!this.lines.length&&this.doc.cm){var b=this.doc.cm.curOp;
-(b.maybeHiddenMarkers||(b.maybeHiddenMarkers=[])).push(this)}},x.SharedTextMarker=sd,Ue(sd),sd.prototype.clear=function(){if(!this.explicitlyCleared){this.explicitlyCleared=!0;for(var a=0;a<this.markers.length;++a)this.markers[a].clear();Qe(this,"clear")}},sd.prototype.find=function(){return this.primary.find()};var Kd=x.LineWidget=function(a,b,c){if(c)for(var d in c)c.hasOwnProperty(d)&&(this[d]=c[d]);this.cm=a,this.node=b};Ue(Kd),Kd.prototype.clear=Ld(function(){var a=this.line.widgets,b=pe(this.line);if(null!=b&&a){for(var c=0;c<a.length;++c)a[c]==this&&a.splice(c--,1);a.length||(this.line.widgets=null);var d=re(this.cm,this.line)<this.cm.doc.scrollTop;oe(this.line,Math.max(0,this.line.height-Md(this))),d&&Tc(this.cm,0,-this.height),Ib(this.cm,b,b+1)}}),Kd.prototype.changed=Ld(function(){var a=this.height;this.height=null;var b=Md(this)-a;if(b){oe(this.line,this.line.height+b);var c=pe(this.line);Ib(this.cm,c,c+1)}});var Od=x.Line=function(a,b,c){this.text=a,Jd(this,b),this.height=c?c(this):1};Ue(Od);var Vd={},Yd=/[\t\u0000-\u0019\u00ad\u200b\u2028\u2029\uFEFF]/g;de.prototype={chunkSize:function(){return this.lines.length},removeInner:function(a,b){for(var c=a,d=a+b;d>c;++c){var e=this.lines[c];this.height-=e.height,Qd(e),Qe(e,"delete")}this.lines.splice(a,b)},collapse:function(a){a.splice.apply(a,[a.length,0].concat(this.lines))},insertInner:function(a,b,c){this.height+=c,this.lines=this.lines.slice(0,a).concat(b).concat(this.lines.slice(a));for(var d=0,e=b.length;e>d;++d)b[d].parent=this},iterN:function(a,b,c){for(var d=a+b;d>a;++a)if(c(this.lines[a]))return!0}},ee.prototype={chunkSize:function(){return this.size},removeInner:function(a,b){this.size-=b;for(var c=0;c<this.children.length;++c){var d=this.children[c],e=d.chunkSize();if(e>a){var f=Math.min(b,e-a),g=d.height;if(d.removeInner(a,f),this.height-=g-d.height,e==f&&(this.children.splice(c--,1),d.parent=null),0==(b-=f))break;a=0}else a-=e}if(this.size-b<25){var h=[];this.collapse(h),this.children=[new de(h)],this.children[0].parent=this}},collapse:function(a){for(var b=0,c=this.children.length;c>b;++b)this.children[b].collapse(a)},insertInner:function(a,b,c){this.size+=b.length,this.height+=c;for(var d=0,e=this.children.length;e>d;++d){var f=this.children[d],g=f.chunkSize();if(g>=a){if(f.insertInner(a,b,c),f.lines&&f.lines.length>50){for(;f.lines.length>50;){var h=f.lines.splice(f.lines.length-25,25),i=new de(h);f.height-=i.height,this.children.splice(d+1,0,i),i.parent=this}this.maybeSpill()}break}a-=g}},maybeSpill:function(){if(!(this.children.length<=10)){var a=this;do{var b=a.children.splice(a.children.length-5,5),c=new ee(b);if(a.parent){a.size-=c.size,a.height-=c.height;var e=bf(a.parent.children,a);a.parent.children.splice(e+1,0,c)}else{var d=new ee(a.children);d.parent=a,a.children=[d,c],a=d}c.parent=a.parent}while(a.children.length>10);a.parent.maybeSpill()}},iterN:function(a,b,c){for(var d=0,e=this.children.length;e>d;++d){var f=this.children[d],g=f.chunkSize();if(g>a){var h=Math.min(b,g-a);if(f.iterN(a,h,c))return!0;if(0==(b-=h))break;a=0}else a-=g}}};var fe=0,ge=x.Doc=function(a,b,c){if(!(this instanceof ge))return new ge(a,b,c);null==c&&(c=0),ee.call(this,[new de([new Od("",null)])]),this.first=c,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.history=te(),this.cleanGeneration=1,this.frontier=c;var d=Bc(c,0);this.sel={from:d,to:d,head:d,anchor:d,shift:!1,extend:!1,goalColumn:null},this.id=++fe,this.modeOption=b,"string"==typeof a&&(a=wf(a)),ce(this,{from:d,to:d,text:a},null,{head:d,anchor:d})};ge.prototype=cf(ee.prototype,{constructor:ge,iter:function(a,b,c){c?this.iterN(a-this.first,b-a,c):this.iterN(this.first,this.first+this.size,a)},insert:function(a,b){for(var c=0,d=0,e=b.length;e>d;++d)c+=b[d].height;this.insertInner(a-this.first,b,c)},remove:function(a,b){this.removeInner(a-this.first,b)},getValue:function(a){var b=ne(this,this.first,this.first+this.size);return a===!1?b:b.join(a||"\n")},setValue:function(a){var b=Bc(this.first,0),c=this.first+this.size-1;uc(this,{from:b,to:Bc(c,le(this,c).text.length),text:wf(a),origin:"setValue"},{head:b,anchor:b},!0)},replaceRange:function(a,b,c,d){b=Gc(this,b),c=c?Gc(this,c):b,Ac(this,a,b,c,d)},getRange:function(a,b,c){var d=me(this,Gc(this,a),Gc(this,b));return c===!1?d:d.join(c||"\n")},getLine:function(a){var b=this.getLineHandle(a);return b&&b.text},setLine:function(a,b){Ic(this,a)&&Ac(this,b,Bc(a,0),Gc(this,Bc(a)))},removeLine:function(a){a?Ac(this,"",Gc(this,Bc(a-1)),Gc(this,Bc(a))):Ac(this,"",Bc(0,0),Gc(this,Bc(1,0)))},getLineHandle:function(a){return Ic(this,a)?le(this,a):void 0},getLineNumber:function(a){return pe(a)},getLineHandleVisualStart:function(a){return"number"==typeof a&&(a=le(this,a)),Fd(this,a)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(a){return Gc(this,a)},getCursor:function(a){var c,b=this.sel;return c=null==a||"head"==a?b.head:"anchor"==a?b.anchor:"end"==a||a===!1?b.to:b.from,Ec(c)},somethingSelected:function(){return!Cc(this.sel.head,this.sel.anchor)},setCursor:Gb(function(a,b,c){var d=Gc(this,"number"==typeof a?Bc(a,b||0):a);c?Jc(this,d):Lc(this,d,d)}),setSelection:Gb(function(a,b,c){Lc(this,Gc(this,a),Gc(this,b||a),c)}),extendSelection:Gb(function(a,b,c){Jc(this,Gc(this,a),b&&Gc(this,b),c)}),getSelection:function(a){return this.getRange(this.sel.from,this.sel.to,a)},replaceSelection:function(a,b,c){uc(this,{from:this.sel.from,to:this.sel.to,text:wf(a),origin:c},b||"around")},undo:Gb(function(){wc(this,"undo")}),redo:Gb(function(){wc(this,"redo")}),setExtending:function(a){this.sel.extend=a},historySize:function(){var a=this.history;return{undo:a.done.length,redo:a.undone.length}},clearHistory:function(){this.history=te(this.history.maxGeneration)},markClean:function(){this.cleanGeneration=this.changeGeneration()},changeGeneration:function(){return this.history.lastOp=this.history.lastOrigin=null,this.history.generation},isClean:function(a){return this.history.generation==(a||this.cleanGeneration)},getHistory:function(){return{done:ze(this.history.done),undone:ze(this.history.undone)}},setHistory:function(a){var b=this.history=te(this.history.maxGeneration);b.done=a.done.slice(0),b.undone=a.undone.slice(0)},markText:function(a,b,c){return rd(this,Gc(this,a),Gc(this,b),c,"range")},setBookmark:function(a,b){var c={replacedWith:b&&(null==b.nodeType?b.widget:b),insertLeft:b&&b.insertLeft};return a=Gc(this,a),rd(this,a,a,c,"bookmark")},findMarksAt:function(a){a=Gc(this,a);var b=[],c=le(this,a.line).markedSpans;if(c)for(var d=0;d<c.length;++d){var e=c[d];(null==e.from||e.from<=a.ch)&&(null==e.to||e.to>=a.ch)&&b.push(e.marker.parent||e.marker)}return b},getAllMarks:function(){var a=[];return this.iter(function(b){var c=b.markedSpans;if(c)for(var d=0;d<c.length;++d)null!=c[d].from&&a.push(c[d].marker)}),a},posFromIndex:function(a){var b,c=this.first;return this.iter(function(d){var e=d.text.length+1;return e>a?(b=a,!0):(a-=e,++c,void 0)}),Gc(this,Bc(c,b))},indexFromPos:function(a){a=Gc(this,a);var b=a.ch;return a.line<this.first||a.ch<0?0:(this.iter(this.first,a.line,function(a){b+=a.text.length+1}),b)},copy:function(a){var b=new ge(ne(this,this.first,this.first+this.size),this.modeOption,this.first);return b.scrollTop=this.scrollTop,b.scrollLeft=this.scrollLeft,b.sel={from:this.sel.from,to:this.sel.to,head:this.sel.head,anchor:this.sel.anchor,shift:this.sel.shift,extend:!1,goalColumn:this.sel.goalColumn},a&&(b.history.undoDepth=this.history.undoDepth,b.setHistory(this.getHistory())),b},linkedDoc:function(a){a||(a={});var b=this.first,c=this.first+this.size;null!=a.from&&a.from>b&&(b=a.from),null!=a.to&&a.to<c&&(c=a.to);var d=new ge(ne(this,b,c),a.mode||this.modeOption,b);return a.sharedHist&&(d.history=this.history),(this.linked||(this.linked=[])).push({doc:d,sharedHist:a.sharedHist}),d.linked=[{doc:this,isParent:!0,sharedHist:a.sharedHist}],d},unlinkDoc:function(a){if(a instanceof x&&(a=a.doc),this.linked)for(var b=0;b<this.linked.length;++b){var c=this.linked[b];if(c.doc==a){this.linked.splice(b,1),a.unlinkDoc(this);break}}if(a.history==this.history){var d=[a.id];je(a,function(a){d.push(a.id)},!0),a.history=te(),a.history.done=ze(this.history.done,d),a.history.undone=ze(this.history.undone,d)}},iterLinkedDocs:function(a){je(this,a)},getMode:function(){return this.mode},getEditor:function(){return this.cm}}),ge.prototype.eachLine=ge.prototype.iter;var he="iter insert remove copy getEditor".split(" ");for(var ie in ge.prototype)ge.prototype.hasOwnProperty(ie)&&bf(he,ie)<0&&(x.prototype[ie]=function(a){return function(){return a.apply(this.doc,arguments)}}(ge.prototype[ie]));Ue(ge),x.e_stop=Ie,x.e_preventDefault=Fe,x.e_stopPropagation=Ge;var Oe,Pe=0;x.on=Le,x.off=Me,x.signal=Ne;var Ve=30,We=x.Pass={toString:function(){return"CodeMirror.Pass"}};Xe.prototype={set:function(a,b){clearTimeout(this.id),this.id=setTimeout(b,a)}},x.countColumn=Ye;var Ze=[""],gf=/[\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,kf=/[\u0300-\u036F\u0483-\u0487\u0488-\u0489\u0591-\u05BD\u05BF\u05C1-\u05C2\u05C4-\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7-\u06E8\u06EA-\u06ED\uA66F\uA670-\uA672\uA674-\uA67D\uA69F\udc00-\udfff]/;x.replaceGetRect=function(a){pf=a};var qf=function(){if(d)return!1;var a=lf("div");return"draggable"in a||"dragDrop"in a}();a?rf=function(a,b){return 36==a.charCodeAt(b-1)&&39==a.charCodeAt(b)}:j&&!/Version\/([6-9]|\d\d)\b/.test(navigator.userAgent)?rf=function(a,b){return/\-[^ \-?]|\?[^ !\'\"\),.\-\/:;\?\]\}]/.test(a.slice(b-1,b+1))}:f&&/Chrome\/(?:29|[3-9]\d|\d\d\d)\./.test(navigator.userAgent)?rf=function(a,b){var c=a.charCodeAt(b-1);return c>=8208&&8212>=c}:f&&(rf=function(a,b){if(b>1&&45==a.charCodeAt(b-1)){if(/\w/.test(a.charAt(b-2))&&/[^\-?\.]/.test(a.charAt(b)))return!0;if(b>2&&/[\d\.,]/.test(a.charAt(b-2))&&/[\d\.,]/.test(a.charAt(b)))return!1}return/[~!#%&*)=+}\]\\|\"\.>,:;][({[<]|-[^\-?\.\u2010-\u201f\u2026]|\?[\w~`@#$%\^&*(_=+{[|><]|\u2026[\w~`@#$%\^&*(_=+{[><]/.test(a.slice(b-1,b+1))});var sf,uf,wf=3!="\n\nb".split(/\n/).length?function(a){for(var b=0,c=[],d=a.length;d>=b;){var e=a.indexOf("\n",b);-1==e&&(e=a.length);var f=a.slice(b,"\r"==a.charAt(e-1)?e-1:e),g=f.indexOf("\r");-1!=g?(c.push(f.slice(0,g)),b+=g+1):(c.push(f),b=e+1)}return c}:function(a){return a.split(/\r\n?|\n/)};x.splitLines=wf;var xf=window.getSelection?function(a){try{return a.selectionStart!=a.selectionEnd}catch(b){return!1}}:function(a){try{var b=a.ownerDocument.selection.createRange()}catch(c){}return b&&b.parentElement()==a?0!=b.compareEndPoints("StartToEnd",b):!1},yf=function(){var a=lf("div");return"oncopy"in a?!0:(a.setAttribute("oncopy","return;"),"function"==typeof a.oncopy)}(),zf={3:"Enter",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",91:"Mod",92:"Mod",93:"Mod",109:"-",107:"=",127:"Delete",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63276:"PageUp",63277:"PageDown",63275:"End",63273:"Home",63234:"Left",63232:"Up",63235:"Right",63233:"Down",63302:"Insert",63272:"Delete"};x.keyNames=zf,function(){for(var a=0;10>a;a++)zf[a+48]=String(a);for(var a=65;90>=a;a++)zf[a]=String.fromCharCode(a);for(var a=1;12>=a;a++)zf[a+111]=zf[a+63235]="F"+a}();var If,Nf=function(){function c(c){return 255>=c?a.charAt(c):c>=1424&&1524>=c?"R":c>=1536&&1791>=c?b.charAt(c-1536):c>=1792&&2220>=c?"r":"L"}var a="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLL",b="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmmrrrrrrrrrrrrrrrrrr",d=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,e=/[stwN]/,f=/[LRr]/,g=/[Lb1n]/,h=/[1n]/,i="L";return function(a){if(!d.test(a))return!1;for(var l,b=a.length,j=[],k=0;b>k;++k)j.push(l=c(a.charCodeAt(k)));for(var k=0,m=i;b>k;++k){var l=j[k];"m"==l?j[k]=m:m=l}for(var k=0,n=i;b>k;++k){var l=j[k];"1"==l&&"r"==n?j[k]="n":f.test(l)&&(n=l,"r"==l&&(j[k]="R"))}for(var k=1,m=j[0];b-1>k;++k){var l=j[k];"+"==l&&"1"==m&&"1"==j[k+1]?j[k]="1":","!=l||m!=j[k+1]||"1"!=m&&"n"!=m||(j[k]=m),m=l}for(var k=0;b>k;++k){var l=j[k];if(","==l)j[k]="N";else if("%"==l){for(var o=k+1;b>o&&"%"==j[o];++o);for(var p=k&&"!"==j[k-1]||b-1>o&&"1"==j[o]?"1":"N",q=k;o>q;++q)j[q]=p;k=o-1}}for(var k=0,n=i;b>k;++k){var l=j[k];"L"==n&&"1"==l?j[k]="L":f.test(l)&&(n=l)}for(var k=0;b>k;++k)if(e.test(j[k])){for(var o=k+1;b>o&&e.test(j[o]);++o);for(var r="L"==(k?j[k-1]:i),s="L"==(b-1>o?j[o]:i),p=r||s?"L":"R",q=k;o>q;++q)j[q]=p;k=o-1}for(var u,t=[],k=0;b>k;)if(g.test(j[k])){var v=k;for(++k;b>k&&g.test(j[k]);++k);t.push({from:v,to:k,level:0})}else{var w=k,x=t.length;for(++k;b>k&&"L"!=j[k];++k);for(var q=w;k>q;)if(h.test(j[q])){q>w&&t.splice(x,0,{from:w,to:q,level:1});var y=q;for(++q;k>q&&h.test(j[q]);++q);t.splice(x,0,{from:y,to:q,level:2}),w=q}else++q;k>w&&t.splice(x,0,{from:w,to:k,level:1})}return 1==t[0].level&&(u=a.match(/^\s+/))&&(t[0].from=u[0].length,t.unshift({from:0,to:u[0].length,level:0})),1==_e(t).level&&(u=a.match(/\s+$/))&&(_e(t).to-=u[0].length,t.push({from:b-u[0].length,to:b,level:0})),t[0].level!=_e(t).level&&t.push({from:b,to:b,level:t[0].level}),t}}();return x.version="3.19.1",x}(),CodeMirror.defineMode("css",function(a,b){"use strict";function l(a,b){return k=b,a}function m(a,b){var c=a.next();if(d[c]){var e=d[c](a,b);if(e!==!1)return e}if("@"==c)return a.eatWhile(/[\w\\\-]/),l("def",a.current());if("="==c)l(null,"compare");else{if(("~"==c||"|"==c)&&a.eat("="))return l(null,"compare");if('"'==c||"'"==c)return b.tokenize=n(c),b.tokenize(a,b);if("#"==c)return a.eatWhile(/[\w\\\-]/),l("atom","hash");if("!"==c)return a.match(/^\s*\w*/),l("keyword","important");if(/\d/.test(c)||"."==c&&a.eat(/\d/))return a.eatWhile(/[\w.%]/),l("number","unit");if("-"!==c)return/[,+>*\/]/.test(c)?l(null,"select-op"):"."==c&&a.match(/^-?[_a-z][_a-z0-9-]*/i)?l("qualifier","qualifier"):":"==c?l("operator",c):/[;{}\[\]\(\)]/.test(c)?l(null,c):"u"==c&&a.match("rl(")?(a.backUp(1),b.tokenize=o,l("property","variable")):(a.eatWhile(/[\w\\\-]/),l("property","variable"));if(/\d/.test(a.peek()))return a.eatWhile(/[\w.%]/),l("number","unit");if(a.match(/^[^-]+-/))return l("meta","meta")}}function n(a,b){return function(c,d){for(var f,e=!1;null!=(f=c.next())&&(f!=a||e);)e=!e&&"\\"==f;return e||(b&&c.backUp(1),d.tokenize=m),l("string","string")}}function o(a,b){return a.next(),b.tokenize=a.match(/\s*[\"\']/,!1)?m:n(")",!0),l(null,"(")}b.propertyKeywords||(b=CodeMirror.resolveMode("text/css"));var c=a.indentUnit||a.tabSize||2,d=b.hooks||{},e=b.atMediaTypes||{},f=b.atMediaFeatures||{},g=b.propertyKeywords||{},h=b.colorKeywords||{},i=b.valueKeywords||{},j=!!b.allowNested,k=null;return{startState:function(a){return{tokenize:m,baseIndent:a||0,stack:[],lastToken:null}},token:function(a,b){if(b.tokenize=b.tokenize||m,b.tokenize==m&&a.eatSpace())return null;var c=b.tokenize(a,b);c&&"string"!=typeof c&&(c=l(c[0],c[1]));var d=b.stack[b.stack.length-1];if("variable"==c)return"variable-definition"==k&&b.stack.push("propertyValue"),b.lastToken="variable-2";if("property"==c){var n=a.current().toLowerCase();"propertyValue"==d?c=i.hasOwnProperty(n)?"string-2":h.hasOwnProperty(n)?"keyword":"variable-2":"rule"==d?g.hasOwnProperty(n)||(c+=" error"):"block"==d?c=g.hasOwnProperty(n)?"property":h.hasOwnProperty(n)?"keyword":i.hasOwnProperty(n)?"string-2":"tag":d&&"@media{"!=d?"@media"==d?c=e[a.current()]?"attribute":/^(only|not)$/.test(n)?"keyword":"and"==n?"error":f.hasOwnProperty(n)?"error":"attribute error":"@mediaType"==d?c=e.hasOwnProperty(n)?"attribute":"and"==n?"operator":/^(only|not)$/.test(n)?"error":"error":"@mediaType("==d?g.hasOwnProperty(n)||(e.hasOwnProperty(n)?c="error":"and"==n?c="operator":/^(only|not)$/.test(n)?c="error":c+=" error"):c="@import"==d?"tag":"error":c="tag"}else"atom"==c?d&&"@media{"!=d&&"block"!=d?"propertyValue"==d?/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(a.current())||(c+=" error"):c="error":c="builtin":"@media"==d&&"{"==k&&(c="error");if("{"==k)if("@media"==d||"@mediaType"==d)b.stack[b.stack.length-1]="@media{";else{var o=j?"block":"rule";b.stack.push(o)}else if("}"==k)for("interpolation"==d&&(c="operator");b.stack.length;){var p=b.stack.pop();if(p.indexOf("{")>-1)break}else if("interpolation"==k)b.stack.push("interpolation");else if("@media"==k)b.stack.push("@media");else if("@import"==k)b.stack.push("@import");else if("@media"==d&&/\b(keyword|attribute)\b/.test(c))b.stack[b.stack.length-1]="@mediaType";else if("@mediaType"==d&&","==a.current())b.stack[b.stack.length-1]="@media";else if("("==k)"@media"==d||"@mediaType"==d?(b.stack[b.stack.length-1]="@mediaType",b.stack.push("@mediaType(")):b.stack.push("(");else if(")"==k)for(;b.stack.length;){var p=b.stack.pop();if(p.indexOf("(")>-1)break}else":"==k&&"property"==b.lastToken?b.stack.push("propertyValue"):"propertyValue"==d&&";"==k?b.stack.pop():"@import"==d&&";"==k&&b.stack.pop();return b.lastToken=c},indent:function(a,b){var d=a.stack.length;return/^\}/.test(b)&&(d-="propertyValue"==a.stack[d-1]?2:1),a.baseIndent+d*c},electricChars:"}",blockCommentStart:"/*",blockCommentEnd:"*/",fold:"brace"}}),function(){function a(a){for(var b={},c=0;c<a.length;++c)b[a[c]]=!0;return b}function g(a,b){for(var d,c=!1;null!=(d=a.next());){if(c&&"/"==d){b.tokenize=null;break}c="*"==d}return["comment","comment"]}var b=a(["all","aural","braille","handheld","print","projection","screen","tty","tv","embossed"]),c=a(["width","min-width","max-width","height","min-height","max-height","device-width","min-device-width","max-device-width","device-height","min-device-height","max-device-height","aspect-ratio","min-aspect-ratio","max-aspect-ratio","device-aspect-ratio","min-device-aspect-ratio","max-device-aspect-ratio","color","min-color","max-color","color-index","min-color-index","max-color-index","monochrome","min-monochrome","max-monochrome","resolution","min-resolution","max-resolution","scan","grid"]),d=a(["align-content","align-items","align-self","alignment-adjust","alignment-baseline","anchor-point","animation","animation-delay","animation-direction","animation-duration","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","appearance","azimuth","backface-visibility","background","background-attachment","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","baseline-shift","binding","bleed","bookmark-label","bookmark-level","bookmark-state","bookmark-target","border","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","clear","clip","color","color-profile","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","content","counter-increment","counter-reset","crop","cue","cue-after","cue-before","cursor","direction","display","dominant-baseline","drop-initial-after-adjust","drop-initial-after-align","drop-initial-before-adjust","drop-initial-before-align","drop-initial-size","drop-initial-value","elevation","empty-cells","fit","fit-position","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","float-offset","flow-from","flow-into","font","font-feature-settings","font-family","font-kerning","font-language-override","font-size","font-size-adjust","font-stretch","font-style","font-synthesis","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-ligatures","font-variant-numeric","font-variant-position","font-weight","grid-cell","grid-column","grid-column-align","grid-column-sizing","grid-column-span","grid-columns","grid-flow","grid-row","grid-row-align","grid-row-sizing","grid-row-span","grid-rows","grid-template","hanging-punctuation","height","hyphens","icon","image-orientation","image-rendering","image-resolution","inline-box-align","justify-content","left","letter-spacing","line-break","line-height","line-stacking","line-stacking-ruby","line-stacking-shift","line-stacking-strategy","list-style","list-style-image","list-style-position","list-style-type","margin","margin-bottom","margin-left","margin-right","margin-top","marker-offset","marks","marquee-direction","marquee-loop","marquee-play-count","marquee-speed","marquee-style","max-height","max-width","min-height","min-width","move-to","nav-down","nav-index","nav-left","nav-right","nav-up","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-style","overflow-wrap","overflow-x","overflow-y","padding","padding-bottom","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","page-policy","pause","pause-after","pause-before","perspective","perspective-origin","pitch","pitch-range","play-during","position","presentation-level","punctuation-trim","quotes","region-break-after","region-break-before","region-break-inside","region-fragment","rendering-intent","resize","rest","rest-after","rest-before","richness","right","rotation","rotation-point","ruby-align","ruby-overhang","ruby-position","ruby-span","shape-inside","shape-outside","size","speak","speak-as","speak-header","speak-numeral","speak-punctuation","speech-rate","stress","string-set","tab-size","table-layout","target","target-name","target-new","target-position","text-align","text-align-last","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-style","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-height","text-indent","text-justify","text-outline","text-overflow","text-shadow","text-size-adjust","text-space-collapse","text-transform","text-underline-position","text-wrap","top","transform","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","vertical-align","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","volume","white-space","widows","width","word-break","word-spacing","word-wrap","z-index","zoom","clip-path","clip-rule","mask","enable-background","filter","flood-color","flood-opacity","lighting-color","stop-color","stop-opacity","pointer-events","color-interpolation","color-interpolation-filters","color-profile","color-rendering","fill","fill-opacity","fill-rule","image-rendering","marker","marker-end","marker-mid","marker-start","shape-rendering","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-rendering","baseline-shift","dominant-baseline","glyph-orientation-horizontal","glyph-orientation-vertical","kerning","text-anchor","writing-mode"]),e=a(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]),f=a(["above","absolute","activeborder","activecaption","afar","after-white-space","ahead","alias","all","all-scroll","alternate","always","amharic","amharic-abegede","antialiased","appworkspace","arabic-indic","armenian","asterisks","auto","avoid","avoid-column","avoid-page","avoid-region","background","backwards","baseline","below","bidi-override","binary","bengali","blink","block","block-axis","bold","bolder","border","border-box","both","bottom","break","break-all","break-word","button","button-bevel","buttonface","buttonhighlight","buttonshadow","buttontext","cambodian","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","cjk-earthly-branch","cjk-heavenly-stem","cjk-ideographic","clear","clip","close-quote","col-resize","collapse","column","compact","condensed","contain","content","content-box","context-menu","continuous","copy","cover","crop","cross","crosshair","currentcolor","cursive","dashed","decimal","decimal-leading-zero","default","default-button","destination-atop","destination-in","destination-out","destination-over","devanagari","disc","discard","document","dot-dash","dot-dot-dash","dotted","double","down","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipse","ellipsis","embed","end","ethiopic","ethiopic-abegede","ethiopic-abegede-am-et","ethiopic-abegede-gez","ethiopic-abegede-ti-er","ethiopic-abegede-ti-et","ethiopic-halehame-aa-er","ethiopic-halehame-aa-et","ethiopic-halehame-am-et","ethiopic-halehame-gez","ethiopic-halehame-om-et","ethiopic-halehame-sid-et","ethiopic-halehame-so-et","ethiopic-halehame-ti-er","ethiopic-halehame-ti-et","ethiopic-halehame-tig","ew-resize","expanded","extra-condensed","extra-expanded","fantasy","fast","fill","fixed","flat","footnotes","forwards","from","geometricPrecision","georgian","graytext","groove","gujarati","gurmukhi","hand","hangul","hangul-consonant","hebrew","help","hidden","hide","higher","highlight","highlighttext","hiragana","hiragana-iroha","horizontal","hsl","hsla","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-table","inset","inside","intrinsic","invert","italic","justify","kannada","katakana","katakana-iroha","keep-all","khmer","landscape","lao","large","larger","left","level","lighter","line-through","linear","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-alpha","lower-armenian","lower-greek","lower-hexadecimal","lower-latin","lower-norwegian","lower-roman","lowercase","ltr","malayalam","match","media-controls-background","media-current-time-display","media-fullscreen-button","media-mute-button","media-play-button","media-return-to-realtime-button","media-rewind-button","media-seek-back-button","media-seek-forward-button","media-slider","media-sliderthumb","media-time-remaining-display","media-volume-slider","media-volume-slider-container","media-volume-sliderthumb","medium","menu","menulist","menulist-button","menulist-text","menulist-textfield","menutext","message-box","middle","min-intrinsic","mix","mongolian","monospace","move","multiple","myanmar","n-resize","narrower","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","nw-resize","nwse-resize","oblique","octal","open-quote","optimizeLegibility","optimizeSpeed","oriya","oromo","outset","outside","outside-shape","overlay","overline","padding","padding-box","painted","page","paused","persian","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","round","row-resize","rtl","run-in","running","s-resize","sans-serif","scroll","scrollbar","se-resize","searchfield","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","semi-condensed","semi-expanded","separate","serif","show","sidama","single","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small","small-caps","small-caption","smaller","solid","somali","source-atop","source-in","source-out","source-over","space","square","square-button","start","static","status-bar","stretch","stroke","sub","subpixel-antialiased","super","sw-resize","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","telugu","text","text-bottom","text-top","textarea","textfield","thai","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","tibetan","tigre","tigrinya-er","tigrinya-er-abegede","tigrinya-et","tigrinya-et-abegede","to","top","transparent","ultra-condensed","ultra-expanded","underline","up","upper-alpha","upper-armenian","upper-greek","upper-hexadecimal","upper-latin","upper-norwegian","upper-roman","uppercase","urdu","url","vertical","vertical-text","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","x-large","x-small","xor","xx-large","xx-small"]);CodeMirror.defineMIME("text/css",{atMediaTypes:b,atMediaFeatures:c,propertyKeywords:d,colorKeywords:e,valueKeywords:f,hooks:{"<":function(a,b){function c(a,b){for(var d,c=0;null!=(d=a.next());){if(c>=2&&">"==d){b.tokenize=null;break}c="-"==d?c+1:0}return["comment","comment"]}return a.eat("!")?(b.tokenize=c,c(a,b)):void 0},"/":function(a,b){return a.eat("*")?(b.tokenize=g,g(a,b)):!1}},name:"css"}),CodeMirror.defineMIME("text/x-scss",{atMediaTypes:b,atMediaFeatures:c,propertyKeywords:d,colorKeywords:e,valueKeywords:f,allowNested:!0,hooks:{":":function(a){return a.match(/\s*{/)?[null,"{"]:!1},$:function(a){return a.match(/^[\w-]+/),":"==a.peek()?["variable","variable-definition"]:["variable","variable"]},",":function(a,b){return"propertyValue"==b.stack[b.stack.length-1]?["operator",";"]:void 0},"/":function(a,b){return a.eat("/")?(a.skipToEnd(),["comment","comment"]):a.eat("*")?(b.tokenize=g,g(a,b)):["operator","operator"]
+(b.maybeHiddenMarkers||(b.maybeHiddenMarkers=[])).push(this)}},x.SharedTextMarker=sd,Ue(sd),sd.prototype.clear=function(){if(!this.explicitlyCleared){this.explicitlyCleared=!0;for(var a=0;a<this.markers.length;++a)this.markers[a].clear();Qe(this,"clear")}},sd.prototype.find=function(){return this.primary.find()};var Kd=x.LineWidget=function(a,b,c){if(c)for(var d in c)c.hasOwnProperty(d)&&(this[d]=c[d]);this.cm=a,this.node=b};Ue(Kd),Kd.prototype.clear=Ld(function(){var a=this.line.widgets,b=pe(this.line);if(null!=b&&a){for(var c=0;c<a.length;++c)a[c]==this&&a.splice(c--,1);a.length||(this.line.widgets=null);var d=re(this.cm,this.line)<this.cm.doc.scrollTop;oe(this.line,Math.max(0,this.line.height-Md(this))),d&&Tc(this.cm,0,-this.height),Ib(this.cm,b,b+1)}}),Kd.prototype.changed=Ld(function(){var a=this.height;this.height=null;var b=Md(this)-a;if(b){oe(this.line,this.line.height+b);var c=pe(this.line);Ib(this.cm,c,c+1)}});var Od=x.Line=function(a,b,c){this.text=a,Jd(this,b),this.height=c?c(this):1};Ue(Od);var Vd={},Yd=/[\t\u0000-\u0019\u00ad\u200b\u2028\u2029\uFEFF]/g;de.prototype={chunkSize:function(){return this.lines.length},removeInner:function(a,b){for(var c=a,d=a+b;d>c;++c){var e=this.lines[c];this.height-=e.height,Qd(e),Qe(e,"delete")}this.lines.splice(a,b)},collapse:function(a){a.splice.apply(a,[a.length,0].concat(this.lines))},insertInner:function(a,b,c){this.height+=c,this.lines=this.lines.slice(0,a).concat(b).concat(this.lines.slice(a));for(var d=0,e=b.length;e>d;++d)b[d].parent=this},iterN:function(a,b,c){for(var d=a+b;d>a;++a)if(c(this.lines[a]))return!0}},ee.prototype={chunkSize:function(){return this.size},removeInner:function(a,b){this.size-=b;for(var c=0;c<this.children.length;++c){var d=this.children[c],e=d.chunkSize();if(e>a){var f=Math.min(b,e-a),g=d.height;if(d.removeInner(a,f),this.height-=g-d.height,e==f&&(this.children.splice(c--,1),d.parent=null),0==(b-=f))break;a=0}else a-=e}if(this.size-b<25){var h=[];this.collapse(h),this.children=[new de(h)],this.children[0].parent=this}},collapse:function(a){for(var b=0,c=this.children.length;c>b;++b)this.children[b].collapse(a)},insertInner:function(a,b,c){this.size+=b.length,this.height+=c;for(var d=0,e=this.children.length;e>d;++d){var f=this.children[d],g=f.chunkSize();if(g>=a){if(f.insertInner(a,b,c),f.lines&&f.lines.length>50){for(;f.lines.length>50;){var h=f.lines.splice(f.lines.length-25,25),i=new de(h);f.height-=i.height,this.children.splice(d+1,0,i),i.parent=this}this.maybeSpill()}break}a-=g}},maybeSpill:function(){if(!(this.children.length<=10)){var a=this;do{var b=a.children.splice(a.children.length-5,5),c=new ee(b);if(a.parent){a.size-=c.size,a.height-=c.height;var e=bf(a.parent.children,a);a.parent.children.splice(e+1,0,c)}else{var d=new ee(a.children);d.parent=a,a.children=[d,c],a=d}c.parent=a.parent}while(a.children.length>10);a.parent.maybeSpill()}},iterN:function(a,b,c){for(var d=0,e=this.children.length;e>d;++d){var f=this.children[d],g=f.chunkSize();if(g>a){var h=Math.min(b,g-a);if(f.iterN(a,h,c))return!0;if(0==(b-=h))break;a=0}else a-=g}}};var fe=0,ge=x.Doc=function(a,b,c){if(!(this instanceof ge))return new ge(a,b,c);null==c&&(c=0),ee.call(this,[new de([new Od("",null)])]),this.first=c,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.history=te(),this.cleanGeneration=1,this.frontier=c;var d=Bc(c,0);this.sel={from:d,to:d,head:d,anchor:d,shift:!1,extend:!1,goalColumn:null},this.id=++fe,this.modeOption=b,"string"==typeof a&&(a=wf(a)),ce(this,{from:d,to:d,text:a},null,{head:d,anchor:d})};ge.prototype=cf(ee.prototype,{constructor:ge,iter:function(a,b,c){c?this.iterN(a-this.first,b-a,c):this.iterN(this.first,this.first+this.size,a)},insert:function(a,b){for(var c=0,d=0,e=b.length;e>d;++d)c+=b[d].height;this.insertInner(a-this.first,b,c)},remove:function(a,b){this.removeInner(a-this.first,b)},getValue:function(a){var b=ne(this,this.first,this.first+this.size);return a===!1?b:b.join(a||"\n")},setValue:function(a){var b=Bc(this.first,0),c=this.first+this.size-1;uc(this,{from:b,to:Bc(c,le(this,c).text.length),text:wf(a),origin:"setValue"},{head:b,anchor:b},!0)},replaceRange:function(a,b,c,d){b=Gc(this,b),c=c?Gc(this,c):b,Ac(this,a,b,c,d)},getRange:function(a,b,c){var d=me(this,Gc(this,a),Gc(this,b));return c===!1?d:d.join(c||"\n")},getLine:function(a){var b=this.getLineHandle(a);return b&&b.text},setLine:function(a,b){Ic(this,a)&&Ac(this,b,Bc(a,0),Gc(this,Bc(a)))},removeLine:function(a){a?Ac(this,"",Gc(this,Bc(a-1)),Gc(this,Bc(a))):Ac(this,"",Bc(0,0),Gc(this,Bc(1,0)))},getLineHandle:function(a){return Ic(this,a)?le(this,a):void 0},getLineNumber:function(a){return pe(a)},getLineHandleVisualStart:function(a){return"number"==typeof a&&(a=le(this,a)),Fd(this,a)},lineCount:function(){return this.size},firstLine:function(){return this.first},lastLine:function(){return this.first+this.size-1},clipPos:function(a){return Gc(this,a)},getCursor:function(a){var c,b=this.sel;return c=null==a||"head"==a?b.head:"anchor"==a?b.anchor:"end"==a||a===!1?b.to:b.from,Ec(c)},somethingSelected:function(){return!Cc(this.sel.head,this.sel.anchor)},setCursor:Gb(function(a,b,c){var d=Gc(this,"number"==typeof a?Bc(a,b||0):a);c?Jc(this,d):Lc(this,d,d)}),setSelection:Gb(function(a,b,c){Lc(this,Gc(this,a),Gc(this,b||a),c)}),extendSelection:Gb(function(a,b,c){Jc(this,Gc(this,a),b&&Gc(this,b),c)}),getSelection:function(a){return this.getRange(this.sel.from,this.sel.to,a)},replaceSelection:function(a,b,c){uc(this,{from:this.sel.from,to:this.sel.to,text:wf(a),origin:c},b||"around")},undo:Gb(function(){wc(this,"undo")}),redo:Gb(function(){wc(this,"redo")}),setExtending:function(a){this.sel.extend=a},historySize:function(){var a=this.history;return{undo:a.done.length,redo:a.undone.length}},clearHistory:function(){this.history=te(this.history.maxGeneration)},markClean:function(){this.cleanGeneration=this.changeGeneration()},changeGeneration:function(){return this.history.lastOp=this.history.lastOrigin=null,this.history.generation},isClean:function(a){return this.history.generation==(a||this.cleanGeneration)},getHistory:function(){return{done:ze(this.history.done),undone:ze(this.history.undone)}},setHistory:function(a){var b=this.history=te(this.history.maxGeneration);b.done=a.done.slice(0),b.undone=a.undone.slice(0)},markText:function(a,b,c){return rd(this,Gc(this,a),Gc(this,b),c,"range")},setBookmark:function(a,b){var c={replacedWith:b&&(null==b.nodeType?b.widget:b),insertLeft:b&&b.insertLeft};return a=Gc(this,a),rd(this,a,a,c,"bookmark")},findMarksAt:function(a){a=Gc(this,a);var b=[],c=le(this,a.line).markedSpans;if(c)for(var d=0;d<c.length;++d){var e=c[d];(null==e.from||e.from<=a.ch)&&(null==e.to||e.to>=a.ch)&&b.push(e.marker.parent||e.marker)}return b},getAllMarks:function(){var a=[];return this.iter(function(b){var c=b.markedSpans;if(c)for(var d=0;d<c.length;++d)null!=c[d].from&&a.push(c[d].marker)}),a},posFromIndex:function(a){var b,c=this.first;return this.iter(function(d){var e=d.text.length+1;return e>a?(b=a,!0):(a-=e,++c,void 0)}),Gc(this,Bc(c,b))},indexFromPos:function(a){a=Gc(this,a);var b=a.ch;return a.line<this.first||a.ch<0?0:(this.iter(this.first,a.line,function(a){b+=a.text.length+1}),b)},copy:function(a){var b=new ge(ne(this,this.first,this.first+this.size),this.modeOption,this.first);return b.scrollTop=this.scrollTop,b.scrollLeft=this.scrollLeft,b.sel={from:this.sel.from,to:this.sel.to,head:this.sel.head,anchor:this.sel.anchor,shift:this.sel.shift,extend:!1,goalColumn:this.sel.goalColumn},a&&(b.history.undoDepth=this.history.undoDepth,b.setHistory(this.getHistory())),b},linkedDoc:function(a){a||(a={});var b=this.first,c=this.first+this.size;null!=a.from&&a.from>b&&(b=a.from),null!=a.to&&a.to<c&&(c=a.to);var d=new ge(ne(this,b,c),a.mode||this.modeOption,b);return a.sharedHist&&(d.history=this.history),(this.linked||(this.linked=[])).push({doc:d,sharedHist:a.sharedHist}),d.linked=[{doc:this,isParent:!0,sharedHist:a.sharedHist}],d},unlinkDoc:function(a){if(a instanceof x&&(a=a.doc),this.linked)for(var b=0;b<this.linked.length;++b){var c=this.linked[b];if(c.doc==a){this.linked.splice(b,1),a.unlinkDoc(this);break}}if(a.history==this.history){var d=[a.id];je(a,function(a){d.push(a.id)},!0),a.history=te(),a.history.done=ze(this.history.done,d),a.history.undone=ze(this.history.undone,d)}},iterLinkedDocs:function(a){je(this,a)},getMode:function(){return this.mode},getEditor:function(){return this.cm}}),ge.prototype.eachLine=ge.prototype.iter;var he="iter insert remove copy getEditor".split(" ");for(var ie in ge.prototype)ge.prototype.hasOwnProperty(ie)&&bf(he,ie)<0&&(x.prototype[ie]=function(a){return function(){return a.apply(this.doc,arguments)}}(ge.prototype[ie]));Ue(ge),x.e_stop=Ie,x.e_preventDefault=Fe,x.e_stopPropagation=Ge;var Oe,Pe=0;x.on=Le,x.off=Me,x.signal=Ne;var Ve=30,We=x.Pass={toString:function(){return"CodeMirror.Pass"}};Xe.prototype={set:function(a,b){clearTimeout(this.id),this.id=setTimeout(b,a)}},x.countColumn=Ye;var Ze=[""],gf=/[\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,kf=/[\u0300-\u036F\u0483-\u0487\u0488-\u0489\u0591-\u05BD\u05BF\u05C1-\u05C2\u05C4-\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7-\u06E8\u06EA-\u06ED\uA66F\uA670-\uA672\uA674-\uA67D\uA69F\udc00-\udfff]/;x.replaceGetRect=function(a){pf=a};var qf=function(){if(d)return!1;var a=lf("div");return"draggable"in a||"dragDrop"in a}();a?rf=function(a,b){return 36==a.charCodeAt(b-1)&&39==a.charCodeAt(b)}:j&&!/Version\/([6-9]|\d\d)\b/.test(navigator.userAgent)?rf=function(a,b){return/\-[^ \-?]|\?[^ !\'\"\),.\-\/:;\?\]\}]/.test(a.slice(b-1,b+1))}:f&&/Chrome\/(?:29|[3-9]\d|\d\d\d)\./.test(navigator.userAgent)?rf=function(a,b){var c=a.charCodeAt(b-1);return c>=8208&&8212>=c}:f&&(rf=function(a,b){if(b>1&&45==a.charCodeAt(b-1)){if(/\w/.test(a.charAt(b-2))&&/[^\-?\.]/.test(a.charAt(b)))return!0;if(b>2&&/[\d\.,]/.test(a.charAt(b-2))&&/[\d\.,]/.test(a.charAt(b)))return!1}return/[~!#%&*)=+}\]\\|\"\.>,:;][({[<]|-[^\-?\.\u2010-\u201f\u2026]|\?[\w~`@#$%\^&*(_=+{[|><]|\u2026[\w~`@#$%\^&*(_=+{[><]/.test(a.slice(b-1,b+1))});var sf,uf,wf=3!="\n\nb".split(/\n/).length?function(a){for(var b=0,c=[],d=a.length;d>=b;){var e=a.indexOf("\n",b);-1==e&&(e=a.length);var f=a.slice(b,"\r"==a.charAt(e-1)?e-1:e),g=f.indexOf("\r");-1!=g?(c.push(f.slice(0,g)),b+=g+1):(c.push(f),b=e+1)}return c}:function(a){return a.split(/\r\n?|\n/)};x.splitLines=wf;var xf=window.getSelection?function(a){try{return a.selectionStart!=a.selectionEnd}catch(b){return!1}}:function(a){try{var b=a.ownerDocument.selection.createRange()}catch(c){}return b&&b.parentElement()==a?0!=b.compareEndPoints("StartToEnd",b):!1},yf=function(){var a=lf("div");return"oncopy"in a?!0:(a.setAttribute("oncopy","return;"),"function"==typeof a.oncopy)}(),zf={3:"Enter",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",91:"Mod",92:"Mod",93:"Mod",109:"-",107:"=",127:"Delete",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63276:"PageUp",63277:"PageDown",63275:"End",63273:"Home",63234:"Left",63232:"Up",63235:"Right",63233:"Down",63302:"Insert",63272:"Delete"};x.keyNames=zf,function(){for(var a=0;10>a;a++)zf[a+48]=String(a);for(var a=65;90>=a;a++)zf[a]=String.fromCharCode(a);for(var a=1;12>=a;a++)zf[a+111]=zf[a+63235]="F"+a}();var If,Nf=function(){function c(c){return 255>=c?a.charAt(c):c>=1424&&1524>=c?"R":c>=1536&&1791>=c?b.charAt(c-1536):c>=1792&&2220>=c?"r":"L"}var a="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLL",b="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmmrrrrrrrrrrrrrrrrrr",d=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,e=/[stwN]/,f=/[LRr]/,g=/[Lb1n]/,h=/[1n]/,i="L";return function(a){if(!d.test(a))return!1;for(var l,b=a.length,j=[],k=0;b>k;++k)j.push(l=c(a.charCodeAt(k)));for(var k=0,m=i;b>k;++k){var l=j[k];"m"==l?j[k]=m:m=l}for(var k=0,n=i;b>k;++k){var l=j[k];"1"==l&&"r"==n?j[k]="n":f.test(l)&&(n=l,"r"==l&&(j[k]="R"))}for(var k=1,m=j[0];b-1>k;++k){var l=j[k];"+"==l&&"1"==m&&"1"==j[k+1]?j[k]="1":","!=l||m!=j[k+1]||"1"!=m&&"n"!=m||(j[k]=m),m=l}for(var k=0;b>k;++k){var l=j[k];if(","==l)j[k]="N";else if("%"==l){for(var o=k+1;b>o&&"%"==j[o];++o);for(var p=k&&"!"==j[k-1]||b-1>o&&"1"==j[o]?"1":"N",q=k;o>q;++q)j[q]=p;k=o-1}}for(var k=0,n=i;b>k;++k){var l=j[k];"L"==n&&"1"==l?j[k]="L":f.test(l)&&(n=l)}for(var k=0;b>k;++k)if(e.test(j[k])){for(var o=k+1;b>o&&e.test(j[o]);++o);for(var r="L"==(k?j[k-1]:i),s="L"==(b-1>o?j[o]:i),p=r||s?"L":"R",q=k;o>q;++q)j[q]=p;k=o-1}for(var u,t=[],k=0;b>k;)if(g.test(j[k])){var v=k;for(++k;b>k&&g.test(j[k]);++k);t.push({from:v,to:k,level:0})}else{var w=k,x=t.length;for(++k;b>k&&"L"!=j[k];++k);for(var q=w;k>q;)if(h.test(j[q])){q>w&&t.splice(x,0,{from:w,to:q,level:1});var y=q;for(++q;k>q&&h.test(j[q]);++q);t.splice(x,0,{from:y,to:q,level:2}),w=q}else++q;k>w&&t.splice(x,0,{from:w,to:k,level:1})}return 1==t[0].level&&(u=a.match(/^\s+/))&&(t[0].from=u[0].length,t.unshift({from:0,to:u[0].length,level:0})),1==_e(t).level&&(u=a.match(/\s+$/))&&(_e(t).to-=u[0].length,t.push({from:b-u[0].length,to:b,level:0})),t[0].level!=_e(t).level&&t.push({from:b,to:b,level:t[0].level}),t}}();return x.version="3.19.1",x}(),CodeMirror.defineMode("css",function(a,b){"use strict";function l(a,b){return k=b,a}function m(a,b){var c=a.next();if(d[c]){var e=d[c](a,b);if(e!==!1)return e}if("@"==c)return a.eatWhile(/[\w\\\-]/),l("def",a.current());if("="==c)l(null,"compare");else{if(("~"==c||"|"==c)&&a.eat("="))return l(null,"compare");if('"'==c||"'"==c)return b.tokenize=n(c),b.tokenize(a,b);if("#"==c)return a.eatWhile(/[\w\\\-]/),l("atom","hash");if("!"==c)return a.match(/^\s*\w*/),l("keyword","important");if(/\d/.test(c)||"."==c&&a.eat(/\d/))return a.eatWhile(/[\w.%]/),l("number","unit");if("-"!==c)return/[,+>*\/]/.test(c)?l(null,"select-op"):"."==c&&a.match(/^-?[_a-z][_a-z0-9-]*/i)?l("qualifier","qualifier"):":"==c?l("operator",c):/[;{}\[\]\(\)]/.test(c)?l(null,c):"u"==c&&a.match("rl(")?(a.backUp(1),b.tokenize=o,l("property","variable")):(a.eatWhile(/[\w\\\-]/),l("property","variable"));if(/\d/.test(a.peek()))return a.eatWhile(/[\w.%]/),l("number","unit");if(a.match(/^[^-]+-/))return l("meta","meta")}}function n(a,b){return function(c,d){for(var f,e=!1;null!=(f=c.next())&&(f!=a||e);)e=!e&&"\\"==f;return e||(b&&c.backUp(1),d.tokenize=m),l("string","string")}}function o(a,b){return a.next(),b.tokenize=a.match(/\s*[\"\']/,!1)?m:n(")",!0),l(null,"(")}b.propertyKeywords||(b=CodeMirror.resolveMode("text/css"));var c=a.indentUnit||a.tabSize||2,d=b.hooks||{},e=b.atMediaTypes||{},f=b.atMediaFeatures||{},g=b.propertyKeywords||{},h=b.colorKeywords||{},i=b.valueKeywords||{},j=!!b.allowNested,k=null;return{startState:function(a){return{tokenize:m,baseIndent:a||0,stack:[],lastToken:null}},token:function(a,b){if(b.tokenize=b.tokenize||m,b.tokenize==m&&a.eatSpace())return null;var c=b.tokenize(a,b);c&&"string"!=typeof c&&(c=l(c[0],c[1]));var d=b.stack[b.stack.length-1];if("variable"==c)return"variable-definition"==k&&b.stack.push("propertyValue"),b.lastToken="variable-2";if("property"==c){var n=a.current().toLowerCase();"propertyValue"==d?c=i.hasOwnProperty(n)?"string-2":h.hasOwnProperty(n)?"keyword":"variable-2":"rule"==d?g.hasOwnProperty(n)||(c+=" error"):"block"==d?c=g.hasOwnProperty(n)?"property":h.hasOwnProperty(n)?"keyword":i.hasOwnProperty(n)?"string-2":"tag":d&&"@media{"!=d?"@media"==d?c=e[a.current()]?"attribute":/^(only|not)$/.test(n)?"keyword":"and"==n?"error":f.hasOwnProperty(n)?"error":"attribute error":"@mediaType"==d?c=e.hasOwnProperty(n)?"attribute":"and"==n?"operator":/^(only|not)$/.test(n)?"error":"error":"@mediaType("==d?g.hasOwnProperty(n)||(e.hasOwnProperty(n)?c="error":"and"==n?c="operator":/^(only|not)$/.test(n)?c="error":c+=" error"):c="@import"==d?"tag":"error":c="tag"}else"atom"==c?d&&"@media{"!=d&&"block"!=d?"propertyValue"==d?/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(a.current())||(c+=" error"):c="error":c="builtin":"@media"==d&&"{"==k&&(c="error");if("{"==k)if("@media"==d||"@mediaType"==d)b.stack[b.stack.length-1]="@media{";else{var o=j?"block":"rule";b.stack.push(o)}else if("}"==k)for("interpolation"==d&&(c="operator");b.stack.length;){var p=b.stack.pop();if(p.indexOf("{")>-1)break}else if("interpolation"==k)b.stack.push("interpolation");else if("@media"==k)b.stack.push("@media");else if("@import"==k)b.stack.push("@import");else if("@media"==d&&/\b(keyword|attribute)\b/.test(c))b.stack[b.stack.length-1]="@mediaType";else if("@mediaType"==d&&","==a.current())b.stack[b.stack.length-1]="@media";else if("("==k)"@media"==d||"@mediaType"==d?(b.stack[b.stack.length-1]="@mediaType",b.stack.push("@mediaType(")):b.stack.push("(");else if(")"==k)for(;b.stack.length;){var p=b.stack.pop();if(p.indexOf("(")>-1)break}else":"==k&&"property"==b.lastToken?b.stack.push("propertyValue"):"propertyValue"==d&&";"==k?b.stack.pop():"@import"==d&&";"==k&&b.stack.pop();return b.lastToken=c},indent:function(a,b){var d=a.stack.length;return/^\}/.test(b)&&(d-="propertyValue"==a.stack[d-1]?2:1),a.baseIndent+d*c},electricChars:"}",blockCommentStart:"/*",blockCommentEnd:"*/",fold:"brace"}}),function(){function a(a){for(var b={},c=0;c<a.length;++c)b[a[c]]=!0;return b}function g(a,b){for(var d,c=!1;null!=(d=a.next());){if(c&&"/"==d){b.tokenize=null;break}c="*"==d}return["comment","comment"]}var b=a(["all","aural","braille","handheld","print","projection","screen","tty","tv","embossed"]),c=a(["width","min-width","max-width","height","min-height","max-height","device-width","min-device-width","max-device-width","device-height","min-device-height","max-device-height","aspect-ratio","min-aspect-ratio","max-aspect-ratio","device-aspect-ratio","min-device-aspect-ratio","max-device-aspect-ratio","color","min-color","max-color","color-index","min-color-index","max-color-index","monochrome","min-monochrome","max-monochrome","resolution","min-resolution","max-resolution","scan","grid"]),d=a(["align-content","align-items","align-self","alignment-adjust","alignment-baseline","anchor-point","animation","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","appearance","azimuth","backface-visibility","background","background-attachment","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","baseline-shift","binding","bleed","bookmark-label","bookmark-level","bookmark-state","bookmark-target","border","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","clear","clip","color","color-profile","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","content","counter-increment","counter-reset","crop","cue","cue-after","cue-before","cursor","direction","display","dominant-baseline","drop-initial-after-adjust","drop-initial-after-align","drop-initial-before-adjust","drop-initial-before-align","drop-initial-size","drop-initial-value","elevation","empty-cells","fit","fit-position","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","float-offset","flow-from","flow-into","font","font-feature-settings","font-family","font-kerning","font-language-override","font-size","font-size-adjust","font-stretch","font-style","font-synthesis","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-ligatures","font-variant-numeric","font-variant-position","font-weight","grid-cell","grid-column","grid-column-align","grid-column-sizing","grid-column-span","grid-columns","grid-flow","grid-row","grid-row-align","grid-row-sizing","grid-row-span","grid-rows","grid-template","hanging-punctuation","height","hyphens","icon","image-orientation","image-rendering","image-resolution","inline-box-align","justify-content","left","letter-spacing","line-break","line-height","line-stacking","line-stacking-ruby","line-stacking-shift","line-stacking-strategy","list-style","list-style-image","list-style-position","list-style-type","margin","margin-bottom","margin-left","margin-right","margin-top","marker-offset","marks","marquee-direction","marquee-loop","marquee-play-count","marquee-speed","marquee-style","max-height","max-width","min-height","min-width","move-to","nav-down","nav-index","nav-left","nav-right","nav-up","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-style","overflow-wrap","overflow-x","overflow-y","padding","padding-bottom","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","page-policy","pause","pause-after","pause-before","perspective","perspective-origin","pitch","pitch-range","play-during","position","presentation-level","punctuation-trim","quotes","region-break-after","region-break-before","region-break-inside","region-fragment","rendering-intent","resize","rest","rest-after","rest-before","richness","right","rotation","rotation-point","ruby-align","ruby-overhang","ruby-position","ruby-span","shape-inside","shape-outside","size","speak","speak-as","speak-header","speak-numeral","speak-punctuation","speech-rate","stress","string-set","tab-size","table-layout","target","target-name","target-new","target-position","text-align","text-align-last","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-style","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-height","text-indent","text-justify","text-outline","text-overflow","text-shadow","text-size-adjust","text-space-collapse","text-transform","text-underline-position","text-wrap","top","transform","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","vertical-align","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","volume","white-space","widows","width","word-break","word-spacing","word-wrap","z-index","zoom","clip-path","clip-rule","mask","enable-background","filter","flood-color","flood-opacity","lighting-color","stop-color","stop-opacity","pointer-events","color-interpolation","color-interpolation-filters","color-profile","color-rendering","fill","fill-opacity","fill-rule","image-rendering","marker","marker-end","marker-mid","marker-start","shape-rendering","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-rendering","baseline-shift","dominant-baseline","glyph-orientation-horizontal","glyph-orientation-vertical","kerning","text-anchor","writing-mode"]),e=a(["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]),f=a(["above","absolute","activeborder","activecaption","afar","after-white-space","ahead","alias","all","all-scroll","alternate","always","amharic","amharic-abegede","antialiased","appworkspace","arabic-indic","armenian","asterisks","auto","avoid","avoid-column","avoid-page","avoid-region","background","backwards","baseline","below","bidi-override","binary","bengali","blink","block","block-axis","bold","bolder","border","border-box","both","bottom","break","break-all","break-word","button","button-bevel","buttonface","buttonhighlight","buttonshadow","buttontext","cambodian","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","cjk-earthly-branch","cjk-heavenly-stem","cjk-ideographic","clear","clip","close-quote","col-resize","collapse","column","compact","condensed","contain","content","content-box","context-menu","continuous","copy","cover","crop","cross","crosshair","currentcolor","cursive","dashed","decimal","decimal-leading-zero","default","default-button","destination-atop","destination-in","destination-out","destination-over","devanagari","disc","discard","document","dot-dash","dot-dot-dash","dotted","double","down","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipse","ellipsis","embed","end","ethiopic","ethiopic-abegede","ethiopic-abegede-am-et","ethiopic-abegede-gez","ethiopic-abegede-ti-er","ethiopic-abegede-ti-et","ethiopic-halehame-aa-er","ethiopic-halehame-aa-et","ethiopic-halehame-am-et","ethiopic-halehame-gez","ethiopic-halehame-om-et","ethiopic-halehame-sid-et","ethiopic-halehame-so-et","ethiopic-halehame-ti-er","ethiopic-halehame-ti-et","ethiopic-halehame-tig","ew-resize","expanded","extra-condensed","extra-expanded","fantasy","fast","fill","fixed","flat","footnotes","forwards","from","geometricPrecision","georgian","graytext","groove","gujarati","gurmukhi","hand","hangul","hangul-consonant","hebrew","help","hidden","hide","higher","highlight","highlighttext","hiragana","hiragana-iroha","horizontal","hsl","hsla","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-table","inset","inside","intrinsic","invert","italic","justify","kannada","katakana","katakana-iroha","keep-all","khmer","landscape","lao","large","larger","left","level","lighter","line-through","linear","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-alpha","lower-armenian","lower-greek","lower-hexadecimal","lower-latin","lower-norwegian","lower-roman","lowercase","ltr","malayalam","match","media-controls-background","media-current-time-display","media-fullscreen-button","media-mute-button","media-play-button","media-return-to-realtime-button","media-rewind-button","media-seek-back-button","media-seek-forward-button","media-slider","media-sliderthumb","media-time-remaining-display","media-volume-slider","media-volume-slider-container","media-volume-sliderthumb","medium","menu","menulist","menulist-button","menulist-text","menulist-textfield","menutext","message-box","middle","min-intrinsic","mix","mongolian","monospace","move","multiple","myanmar","n-resize","narrower","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","nw-resize","nwse-resize","oblique","octal","open-quote","optimizeLegibility","optimizeSpeed","oriya","oromo","outset","outside","outside-shape","overlay","overline","padding","padding-box","painted","page","paused","persian","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","round","row-resize","rtl","run-in","running","s-resize","sans-serif","scroll","scrollbar","se-resize","searchfield","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","semi-condensed","semi-expanded","separate","serif","show","sidama","single","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small","small-caps","small-caption","smaller","solid","somali","source-atop","source-in","source-out","source-over","space","square","square-button","start","static","status-bar","stretch","stroke","sub","subpixel-antialiased","super","sw-resize","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","telugu","text","text-bottom","text-top","textarea","textfield","thai","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","tibetan","tigre","tigrinya-er","tigrinya-er-abegede","tigrinya-et","tigrinya-et-abegede","to","top","transparent","ultra-condensed","ultra-expanded","underline","up","upper-alpha","upper-armenian","upper-greek","upper-hexadecimal","upper-latin","upper-norwegian","upper-roman","uppercase","urdu","url","vertical","vertical-text","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","x-large","x-small","xor","xx-large","xx-small"]);CodeMirror.defineMIME("text/css",{atMediaTypes:b,atMediaFeatures:c,propertyKeywords:d,colorKeywords:e,valueKeywords:f,hooks:{"<":function(a,b){function c(a,b){for(var d,c=0;null!=(d=a.next());){if(c>=2&&">"==d){b.tokenize=null;break}c="-"==d?c+1:0}return["comment","comment"]}return a.eat("!")?(b.tokenize=c,c(a,b)):void 0},"/":function(a,b){return a.eat("*")?(b.tokenize=g,g(a,b)):!1}},name:"css"}),CodeMirror.defineMIME("text/x-scss",{atMediaTypes:b,atMediaFeatures:c,propertyKeywords:d,colorKeywords:e,valueKeywords:f,allowNested:!0,hooks:{":":function(a){return a.match(/\s*{/)?[null,"{"]:!1},$:function(a){return a.match(/^[\w-]+/),":"==a.peek()?["variable","variable-definition"]:["variable","variable"]},",":function(a,b){return"propertyValue"==b.stack[b.stack.length-1]?["operator",";"]:void 0},"/":function(a,b){return a.eat("/")?(a.skipToEnd(),["comment","comment"]):a.eat("*")?(b.tokenize=g,g(a,b)):["operator","operator"]
},"#":function(a){return a.eat("{")?["operator","interpolation"]:(a.eatWhile(/[\w\\\-]/),["atom","hash"])}},name:"css"})}(),CodeMirror.defineMode("less",function(a){function d(a,b){return c=b,a}function f(a,b){var f=a.next();if("@"==f)return a.eatWhile(/[\w\-]/),d("meta",a.current());if("/"==f&&a.eat("*"))return b.tokenize=h,h(a,b);if("<"==f&&a.eat("!"))return b.tokenize=i,i(a,b);if("="==f)d(null,"compare");else{if("|"==f&&a.eat("="))return d(null,"compare");if('"'==f||"'"==f)return b.tokenize=j(f),b.tokenize(a,b);if("/"==f){if(a.eat("/"))return b.tokenize=g,g(a,b);if("string"==c||"("==c)return d("string","string");if(void 0!==b.stack[b.stack.length-1])return d(null,f);if(a.eatWhile(/[\a-zA-Z0-9\-_.\s]/),/\/|\)|#/.test(a.peek()||a.eatSpace()&&")"===a.peek())||a.eol())return d("string","string")}else{if("!"==f)return a.match(/^\s*\w*/),d("keyword","important");if(/\d/.test(f))return a.eatWhile(/[\w.%]/),d("number","unit");if(/[,+<>*\/]/.test(f))return"="==a.peek()||"a"==c?d("string","string"):","===f?d(null,f):d(null,"select-op");if(/[;{}:\[\]()~\|]/.test(f)){if(":"==f)return a.eatWhile(/[a-z\\\-]/),e.test(a.current())?d("tag","tag"):":"==a.peek()?(a.next(),a.eatWhile(/[a-z\\\-]/),a.current().match(/\:\:\-(o|ms|moz|webkit)\-/)?d("string","string"):e.test(a.current().substring(1))?d("tag","tag"):d(null,f)):d(null,f);if("~"!=f)return d(null,f);if("r"==c)return d("string","string")}else{if("."==f)return"("==c?d("string","string"):(a.eatWhile(/[\a-zA-Z0-9\-_]/)," "===a.peek()&&a.eatSpace(),")"===a.peek()||":"===c?d("number","unit"):a.current().length>1&&"rule"===b.stack[b.stack.length-1]&&null===a.peek().match(/{|,|\+|\(/)?d("number","unit"):d("tag","tag"));if("#"==f)return a.eatWhile(/[A-Za-z0-9]/),4==a.current().length||7==a.current().length?null!=a.current().match(/[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}/,!1)?a.current().substring(1)!=a.current().match(/[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}/,!1)?d("atom","tag"):(a.eatSpace(),/[\/<>.(){!$%^&*_\-\\?=+\|#'~`]/.test(a.peek())?"select-op"===c?d("number","unit"):d("atom","tag"):"}"==a.peek()?d("number","unit"):/[a-zA-Z\\]/.test(a.peek())?d("atom","tag"):a.eol()?d("atom","tag"):d("number","unit")):(a.eatWhile(/[\w\\\-]/),d("atom",a.current())):(a.eatWhile(/[\w\\\-]/),"rule"===b.stack[b.stack.length-1]?d("atom",a.current()):d("atom",a.current()));if("&"==f)return a.eatWhile(/[\w\-]/),d(null,f);if(a.eatWhile(/[\w\\\-_%.{]/),null===a.current().match(/\\/)){if("string"==c)return"{"===b.stack[b.stack.length-1]&&":"===a.peek()?d("variable","variable"):("/"===a.peek()&&a.eatWhile(/[\w\\\-_%.{:\/]/),d(c,a.current()));if(null!=a.current().match(/(^http$|^https$)/))return a.eatWhile(/[\w\\\-_%.{:\/]/),"/"===a.peek()&&a.eatWhile(/[\w\\\-_%.{:\/]/),d("string","string");if("<"==a.peek()||">"==a.peek()||"+"==a.peek())return"("!==c||"n"!==a.current()&&"-n"!==a.current()?d("tag","tag"):d("string",a.current());if(/\(/.test(a.peek()))return"when"===a.current()?d("variable","variable"):"@media"===b.stack[b.stack.length-1]&&"and"===a.current()?d("variable",a.current()):d(null,f);if("/"==a.peek()&&void 0!==b.stack[b.stack.length-1])return"/"===a.peek()&&a.eatWhile(/[\w\\\-_%.{:\/]/),d("string",a.current());if(a.current().match(/\-\d|\-.\d/))return d("number","unit");if(/\/|[\s\)]/.test(a.peek()||a.eol()||a.eatSpace()&&"/"==a.peek())&&-1!==a.current().indexOf("."))return"{"==a.current().substring(a.current().length-1,a.current().length)?(a.backUp(1),d("tag","tag")):(a.eatSpace(),/[{<>.a-zA-Z\/]/.test(a.peek())||a.eol()?d("tag","tag"):d("string","string"));if(a.eol()||"["==a.peek()||"#"==a.peek()||"tag"==c){if("{"==a.current().substring(a.current().length-1,a.current().length))a.backUp(1);else{if("border-color"===b.stack[b.stack.length-1]||"background-position"===b.stack[b.stack.length-1]||"font-family"===b.stack[b.stack.length-1])return d(null,a.current());if("tag"===c)return d("tag","tag");if((":"===c||"unit"===c)&&"rule"===b.stack[b.stack.length-1])return d(null,a.current());if("rule"===b.stack[b.stack.length-1]&&"tag"===c)return d("string",a.current());if(";"===b.stack[b.stack.length-1]&&":"===c)return d(null,a.current());if("#"===a.peek()&&void 0!==c&&null===c.match(/\+|,|tag|select\-op|}|{|;/g))return d("string",a.current());if("variable"===c)return d(null,a.current());if("{"===b.stack[b.stack.length-1]&&"comment"===c)return d("variable",a.current());if(0===b.stack.length&&(";"===c||"comment"===c))return d("tag",a.current());if(("{"===b.stack[b.stack.length-1]||";"===c)&&"@media{"!==b.stack[b.stack.length-1])return d("variable",a.current());if("{"===b.stack[b.stack.length-2]&&";"===b.stack[b.stack.length-1])return d("variable",a.current())}return d("tag","tag")}if("compare"==c||"a"==c||"("==c)return d("string","string");if("|"==c||"-"==a.current()||"["==c)return"|"==c&&null!==a.peek().match(/\]|=|\~/)?d("number",a.current()):"|"==c?d("tag","tag"):"["==c?(a.eatWhile(/\w\-/),d("number",a.current())):d(null,f);if(":"==a.peek()||a.eatSpace()&&":"==a.peek()){a.next();var k=":"==a.peek()?!0:!1;if(k)a.backUp(1);else{var l=a.pos,m=a.current().length;a.eatWhile(/[a-z\\\-]/);var n=a.pos;if(null!=a.current().substring(m-1).match(e))return a.backUp(n-(l-1)),d("tag","tag");a.backUp(n-(l-1))}return k?d("tag","tag"):d("variable","variable")}return"font-family"===b.stack[b.stack.length-1]||"background-position"===b.stack[b.stack.length-1]||"border-color"===b.stack[b.stack.length-1]?d(null,null):null===b.stack[b.stack.length-1]&&":"===c?d(null,a.current()):/\^|\$/.test(a.current())&&null!==a.peek().match(/\~|=/)?d("string","string"):"unit"===c&&"rule"===b.stack[b.stack.length-1]?d(null,"unit"):"unit"===c&&";"===b.stack[b.stack.length-1]?d(null,"unit"):")"===c&&"rule"===b.stack[b.stack.length-1]?d(null,"unit"):c&&null!==c.match("@")&&"rule"===b.stack[b.stack.length-1]?d(null,"unit"):";"!==c&&"}"!==c&&","!==c||";"!==b.stack[b.stack.length-1]?";"===c&&void 0!==a.peek()&&null===a.peek().match(/{|./)||";"===c&&a.eatSpace()&&null===a.peek().match(/{|./)?d("variable",a.current()):"@media"===c&&"@media"===b.stack[b.stack.length-1]||"@namespace"===c?d("tag",a.current()):"{"===c&&";"===b.stack[b.stack.length-1]&&"{"===a.peek()?d("tag","tag"):"{"!==c&&":"!==c||";"!==b.stack[b.stack.length-1]?"{"===b.stack[b.stack.length-1]&&a.eatSpace()&&null===a.peek().match(/.|#/)||"select-op"===c||"rule"===b.stack[b.stack.length-1]&&","===c?d("tag","tag"):"variable"===c&&"rule"===b.stack[b.stack.length-1]?d("tag","tag"):a.eatSpace()&&"{"===a.peek()||a.eol()||"{"===a.peek()?d("tag","tag"):")"!==c||"and"!=a.current()&&"and "!=a.current()?")"!==c||"when"!=a.current()&&"when "!=a.current()?")"===c||"comment"===c||"{"===c?d("tag","tag"):a.sol()?d("tag","tag"):a.eatSpace()&&"#"===a.peek()||"#"===a.peek()?d("tag","tag"):0===b.stack.length?d("tag","tag"):";"===c&&void 0!==a.peek()&&null!==a.peek().match(/^[.|\#]/g)?d("tag","tag"):":"===c?(a.eatSpace(),d(null,a.current())):"and "===a.current()||"and"===a.current()?d("variable",a.current()):";"===c&&"{"===b.stack[b.stack.length-1]?d("variable",a.current()):"rule"===b.stack[b.stack.length-1]?d(null,a.current()):d("tag",a.current()):d("variable","variable"):d("variable","variable"):d(null,a.current()):d("tag",a.current())}if("\\"===a.current().charAt(a.current().length-1)){for(a.eat(/\'|\"|\)|\(/);a.eatWhile(/[\w\\\-_%.{]/);)a.eat(/\'|\"|\)|\(/);return d("string",a.current())}}}}}function g(a,b){return a.skipToEnd(),b.tokenize=f,d("comment","comment")}function h(a,b){for(var e,c=!1;null!=(e=a.next());){if(c&&"/"==e){b.tokenize=f;break}c="*"==e}return d("comment","comment")}function i(a,b){for(var e,c=0;null!=(e=a.next());){if(c>=2&&">"==e){b.tokenize=f;break}c="-"==e?c+1:0}return d("comment","comment")}function j(a){return function(b,c){for(var g,e=!1;null!=(g=b.next())&&(g!=a||e);)e=!e&&"\\"==g;return e||(c.tokenize=f),d("string","string")}}var c,b=a.indentUnit,e=/(^\:root$|^\:nth\-child$|^\:nth\-last\-child$|^\:nth\-of\-type$|^\:nth\-last\-of\-type$|^\:first\-child$|^\:last\-child$|^\:first\-of\-type$|^\:last\-of\-type$|^\:only\-child$|^\:only\-of\-type$|^\:empty$|^\:link|^\:visited$|^\:active$|^\:hover$|^\:focus$|^\:target$|^\:lang$|^\:enabled^\:disabled$|^\:checked$|^\:first\-line$|^\:first\-letter$|^\:before$|^\:after$|^\:not$|^\:required$|^\:invalid$)/;return{startState:function(a){return{tokenize:f,baseIndent:a||0,stack:[]}},token:function(a,b){if(a.eatSpace())return null;var e=b.tokenize(a,b),f=b.stack[b.stack.length-1];if("hash"==c&&"rule"==f?e="atom":"variable"==e&&("rule"==f?e=null:f&&"@media{"!=f||(e="when"==a.current()?"variable":/[\s,|\s\)|\s]/.test(a.peek())?"tag":c)),"rule"==f&&/^[\{\};]$/.test(c)&&b.stack.pop(),"{"==c?"@media"==f?b.stack[b.stack.length-1]="@media{":b.stack.push("{"):"}"==c?b.stack.pop():"@media"==c?b.stack.push("@media"):"font-family"===a.current()?b.stack[b.stack.length-1]="font-family":"background-position"===a.current()?b.stack[b.stack.length-1]="background-position":"border-color"===a.current()?b.stack[b.stack.length-1]="border-color":"{"==f&&"comment"!=c&&"tag"!==c?b.stack.push("rule"):":"===a.peek()&&null===a.current().match(/@|#/)&&(e=c),";"!==c||"font-family"!=b.stack[b.stack.length-1]&&"background-position"!=b.stack[b.stack.length-1]&&"border-color"!=b.stack[b.stack.length-1]){if("tag"===c&&")"===a.peek()&&null===a.current().match(/\:/))c=null,e=null;else if("variable"===c&&")"===a.peek()||"variable"===c&&a.eatSpace()&&")"===a.peek())return d(null,a.current())}else b.stack[b.stack.length-1]=a.current();return e},indent:function(a,c){var d=a.stack.length;return/^\}/.test(c)?d-="rule"===a.stack[a.stack.length-1]?2:1:"{"===a.stack[a.stack.length-2]&&(d-="rule"===a.stack[a.stack.length-1]?1:0),a.baseIndent+d*b},electricChars:"}",blockCommentStart:"/*",blockCommentEnd:"*/",lineComment:"//"}}),CodeMirror.defineMIME("text/x-less","less"),CodeMirror.mimeModes.hasOwnProperty("text/css")||CodeMirror.defineMIME("text/css","less"); \ No newline at end of file
diff --git a/plugins/jetpack/modules/custom-post-types/js/nova-drag-drop.js b/plugins/jetpack/modules/custom-post-types/js/nova-drag-drop.js
index 6feadd47..558d4651 100644
--- a/plugins/jetpack/modules/custom-post-types/js/nova-drag-drop.js
+++ b/plugins/jetpack/modules/custom-post-types/js/nova-drag-drop.js
@@ -9,6 +9,7 @@
dragMenus();
addNonce();
addSubmitButton();
+ changeToPost();
}
function dragMenus() {
@@ -43,6 +44,10 @@
$('#posts-filter').append('<input type="hidden" name="' + _novaDragDrop.nonceName + '" value="' + _novaDragDrop.nonce + '" />');
}
+ function changeToPost() {
+ $( '#posts-filter' ).attr( 'method', 'post' );
+ }
+
// do it
$(document).ready(init);
})(jQuery);
diff --git a/plugins/jetpack/modules/markdown/easy-markdown.php b/plugins/jetpack/modules/markdown/easy-markdown.php
index f3870ce0..824be5e9 100644
--- a/plugins/jetpack/modules/markdown/easy-markdown.php
+++ b/plugins/jetpack/modules/markdown/easy-markdown.php
@@ -455,6 +455,8 @@ class WPCom_Markdown {
$post_data['post_content'] = apply_filters( 'content_save_pre', $post_data['post_content'] );
} elseif ( 0 === strpos( $post_data['post_name'], $post_data['post_parent'] . '-autosave' ) ) {
// autosaves for previews are weird
+ /** This filter is already documented in modules/markdown/easy-markdown.php */
+ $post_data['post_content_filtered'] = apply_filters( 'wpcom_untransformed_content', $post_data['post_content'] );
$post_data['post_content'] = $this->transform( $post_data['post_content'], array( 'id' => $post_data['post_parent'] ) );
/** This filter is already documented in core/wp-includes/default-filters.php */
$post_data['post_content'] = apply_filters( 'content_save_pre', $post_data['post_content'] );
diff --git a/plugins/jetpack/modules/masterbar/masterbar.php b/plugins/jetpack/modules/masterbar/masterbar.php
index e462d38e..25346274 100644
--- a/plugins/jetpack/modules/masterbar/masterbar.php
+++ b/plugins/jetpack/modules/masterbar/masterbar.php
@@ -802,18 +802,6 @@ class A8C_WPCOM_Masterbar {
'href' => $href,
'meta' => $meta
) );
-
- if ( current_theme_supports( 'menus' ) ) {
- $wp_admin_bar->add_menu( array(
- 'parent' => 'look-and-feel',
- 'id' => 'menus',
- 'title' => __( 'Menus', 'jetpack' ),
- 'href' => 'https://wordpress.com/menus/' . esc_attr( $this->primary_site_slug ),
- 'meta' => array(
- 'class' => 'mb-icon',
- ),
- ) );
- }
}
if ( current_user_can( 'manage_options' ) ) {
diff --git a/plugins/jetpack/modules/masterbar/overrides.css b/plugins/jetpack/modules/masterbar/overrides.css
index 510bae3f..4a75261b 100644
--- a/plugins/jetpack/modules/masterbar/overrides.css
+++ b/plugins/jetpack/modules/masterbar/overrides.css
@@ -49,14 +49,6 @@
#wpadminbar li#wp-admin-bar-newdash.menupop > .ab-sub-wrapper, /* Reader */
#wpadminbar li#wp-admin-bar-my-account.menupop > .ab-sub-wrapper, /* Me */
#wpadminbar li#wp-admin-bar-notes.menupop > #wpnt-notes-panel2 { /* Notifications */
- display: none !important;
-}
-
-/* Show the panels when the item is active */
-#wpadminbar li#wp-admin-bar-blog.menupop.ab-active > .ab-sub-wrapper, /* My Sites */
-#wpadminbar li#wp-admin-bar-newdash.menupop.ab-active > .ab-sub-wrapper, /* Reader */
-#wpadminbar li#wp-admin-bar-my-account.menupop.ab-active > .ab-sub-wrapper, /* Me */
-#wpadminbar li#wp-admin-bar-notes.menupop.wpnt-show > #wpnt-notes-panel2 { /* Notifications */
display: block !important;
}
diff --git a/plugins/jetpack/modules/module-headings.php b/plugins/jetpack/modules/module-headings.php
index 8deca9bb..cfd630e1 100644
--- a/plugins/jetpack/modules/module-headings.php
+++ b/plugins/jetpack/modules/module-headings.php
@@ -143,6 +143,11 @@ function jetpack_get_module_i18n( $key ) {
'recommended description' => _x( 'Keep visitors engaged on your blog by highlighting relevant and new content at the bottom of each published post.', 'Jumpstart Description', 'jetpack' ),
),
+ 'search' => array(
+ 'name' => _x( 'Search', 'Module Name', 'jetpack' ),
+ 'description' => _x( 'Enhanced search, powered by Elasticsearch', 'Module Description', 'jetpack' ),
+ ),
+
'seo-tools' => array(
'name' => _x( 'SEO Tools', 'Module Name', 'jetpack' ),
'description' => _x( 'Better results on search engines and social media.', 'Module Description', 'jetpack' ),
diff --git a/plugins/jetpack/modules/omnisearch/omnisearch-core.php b/plugins/jetpack/modules/omnisearch/omnisearch-core.php
index 4ed2ab66..ee70473a 100644
--- a/plugins/jetpack/modules/omnisearch/omnisearch-core.php
+++ b/plugins/jetpack/modules/omnisearch/omnisearch-core.php
@@ -58,18 +58,15 @@ class Jetpack_Omnisearch {
if ( wp_style_is( 'genericons', 'registered' ) ) {
$deps = array( 'genericons' );
}
- if( is_rtl() ) {
- wp_register_style( 'omnisearch-admin', plugins_url( 'rtl/omnisearch-rtl.css', __FILE__ ), $deps );
- } else {
- wp_register_style( 'omnisearch-admin', plugins_url( 'omnisearch.css', __FILE__ ), $deps );
- }
+ wp_register_style( 'omnisearch-admin', plugins_url( 'omnisearch.css', __FILE__ ), $deps );
+ wp_style_add_data( 'omnisearch-admin', 'rtl', 'replace' );
}
function jetpack_admin_menu() {
remove_submenu_page( 'index.php', 'omnisearch' );
$this->slug = add_submenu_page( null, __( 'Omnisearch', 'jetpack' ), __( 'Omnisearch', 'jetpack' ), 'edit_posts', 'omnisearch', array( $this, 'omnisearch_page' ) );
- add_action( "admin_print_styles-{$this->slug}", array( $this, 'admin_print_styles_jetpack' ) );
+ add_action( "admin_print_styles-{$this->slug}", array( $this, 'admin_print_styles' ) );
}
function admin_menu() {
@@ -81,11 +78,6 @@ class Jetpack_Omnisearch {
wp_enqueue_style( 'omnisearch-admin' );
}
- function admin_print_styles_jetpack() {
- wp_enqueue_style( 'omnisearch-admin' );
- wp_enqueue_style( 'omnisearch-jetpack' );
- }
-
function omnisearch_page() {
$results = array();
$s = isset( $_GET['s'] ) ? $_GET['s'] : '';
diff --git a/plugins/jetpack/modules/omnisearch/omnisearch-jetpack-rtl.css b/plugins/jetpack/modules/omnisearch/omnisearch-jetpack-rtl.css
deleted file mode 100644
index f7a91b80..00000000
--- a/plugins/jetpack/modules/omnisearch/omnisearch-jetpack-rtl.css
+++ /dev/null
@@ -1,11 +0,0 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
-
-ul#adminmenu a.wp-has-current-submenu:after,
-ul#adminmenu > li.current > a.current:after {
- border-left-color:#8da94c;
- display: none;
-}
-
-.omnisearch-results > li:first-child > h2 {
- text-shadow: none;
-}
diff --git a/plugins/jetpack/modules/omnisearch/omnisearch-jetpack-rtl.min.css b/plugins/jetpack/modules/omnisearch/omnisearch-jetpack-rtl.min.css
deleted file mode 100644
index 1e1a9f76..00000000
--- a/plugins/jetpack/modules/omnisearch/omnisearch-jetpack-rtl.min.css
+++ /dev/null
@@ -1 +0,0 @@
-ul#adminmenu a.wp-has-current-submenu:after,ul#adminmenu>li.current>a.current:after{border-left-color:#8da94c;display:none}.omnisearch-results>li:first-child>h2{text-shadow:none} \ No newline at end of file
diff --git a/plugins/jetpack/modules/omnisearch/omnisearch-jetpack.css b/plugins/jetpack/modules/omnisearch/omnisearch-jetpack.css
deleted file mode 100644
index fdf4f401..00000000
--- a/plugins/jetpack/modules/omnisearch/omnisearch-jetpack.css
+++ /dev/null
@@ -1,10 +0,0 @@
-
-ul#adminmenu a.wp-has-current-submenu:after,
-ul#adminmenu > li.current > a.current:after {
- border-right-color:#8da94c;
- display: none;
-}
-
-.omnisearch-results > li:first-child > h2 {
- text-shadow: none;
-}
diff --git a/plugins/jetpack/modules/omnisearch/omnisearch-jetpack.min.css b/plugins/jetpack/modules/omnisearch/omnisearch-jetpack.min.css
deleted file mode 100644
index f404038e..00000000
--- a/plugins/jetpack/modules/omnisearch/omnisearch-jetpack.min.css
+++ /dev/null
@@ -1,2 +0,0 @@
-/* Do not modify this file directly. It is concatenated from individual module CSS files. */
-ul#adminmenu a.wp-has-current-submenu:after,ul#adminmenu>li.current>a.current:after{border-right-color:#8da94c;display:none}.omnisearch-results>li:first-child>h2{text-shadow:none} \ No newline at end of file
diff --git a/plugins/jetpack/modules/omnisearch/rtl/omnisearch-jetpack-rtl.css b/plugins/jetpack/modules/omnisearch/rtl/omnisearch-jetpack-rtl.css
deleted file mode 100644
index e714cb67..00000000
--- a/plugins/jetpack/modules/omnisearch/rtl/omnisearch-jetpack-rtl.css
+++ /dev/null
@@ -1,11 +0,0 @@
-/* This file was automatically generated on Sep 29 2014 23:28:15 */
-
-ul#adminmenu a.wp-has-current-submenu:after,
-ul#adminmenu > li.current > a.current:after {
- border-left-color:#8da94c;
- display: none;
-}
-
-.omnisearch-results > li:first-child > h2 {
- text-shadow: none;
-}
diff --git a/plugins/jetpack/modules/omnisearch/rtl/omnisearch-rtl.css b/plugins/jetpack/modules/omnisearch/rtl/omnisearch-rtl.css
deleted file mode 100644
index 18ce9833..00000000
--- a/plugins/jetpack/modules/omnisearch/rtl/omnisearch-rtl.css
+++ /dev/null
@@ -1,132 +0,0 @@
-/* This file was automatically generated on Sep 29 2014 23:28:15 */
-
-
-h2.page-title small {
- font-size: 0.6em;
- font-weight: 300;
- font-style: italic;
- opacity: 0.6;
- margin-right: 0.5em;
-}
-
-form.omnisearch-form {
- position: relative;
-}
-
-input.omnisearch {
- border-radius: 0.25em;
- font-size: 2.2em;
- line-height: 1.35;
- padding: 0.25em 0.5em 0.25em 2em;
- width: 100%;
-}
-
-input.omnisearch::-webkit-search-cancel-button {
- display: none;
-}
-
-button.omnisearch-submit {
- background: transparent;
- border: 0;
- cursor: pointer;
- display: block;
- font-size: 2.45em;
- padding: 0.3em 0.5em 0.1em;
- text-align: center;
- position: absolute;
- left: 0;
- bottom: 0;
-}
-
-button.omnisearch-submit::before {
- font-family: 'Genericons', Noticons;
- content: '\f400';
-}
-
-button.omnisearch-submit span {
- display: none;
-}
-
-#results-title,
-.jump-to {
- font-size: 1.2em;
- line-height: 1.5;
- float: right;
- margin-top: 0;
- padding-top: 2em;
-}
-
-#results-title,
-.jump-to strong {
- font-weight: 600;
-}
-
-.jump-to {
- float: left;
- text-align: left;
-}
-
-.jump-to strong,
-.jump-to a {
- color: inherit;
- margin-right: 0.5em;
- text-decoration: none;
-}
-
-.jump-to a:hover {
- text-decoration: underline;
-}
-
-.back-to-top {
- display: block;
- float: left;
- margin-top: 2.5em;
-}
-
-.omnisearch-results {
-
-}
-
-.omnisearch-results > li {
- padding-top: 2.5em;
-}
-
-.omnisearch-results > li:first-child {
- padding-top: 0;
-}
-
-.omnisearch-results .add-new-h2 {
- display: inline;
-}
-
-.wp-list-table .column-snippet {
- width: 65%;
-}
-
-.wp-list-table .column-date {
- width: 15%;
-}
-
-.wp-list-table.comments .column-author {
- width: 20%;
-}
-
-.wp-list-table.media th {
- white-space: nowrap;
-}
-
-.wp-list-table.media .column-parent {
- width: 15%;
-}
-
-.wp-list-table.media .column-comments span.vers {
- display: block;
-}
-
-.tablenav {
- height: 0;
-}
-
-.omnisearch-results .tablenav.top {
- margin: 5px 0;
-}
diff --git a/plugins/jetpack/modules/publicize/publicize-jetpack.php b/plugins/jetpack/modules/publicize/publicize-jetpack.php
index 38999cee..2c8c3967 100644
--- a/plugins/jetpack/modules/publicize/publicize-jetpack.php
+++ b/plugins/jetpack/modules/publicize/publicize-jetpack.php
@@ -159,8 +159,8 @@ class Publicize extends Publicize_Base {
check_admin_referer( 'keyring-request', 'kr_nonce' );
check_admin_referer( "keyring-request-$service_name", 'nonce' );
- $verification = Jetpack::create_nonce( 'publicize' );
- if ( is_wp_error( $verification ) ) {
+ $verification = Jetpack::generate_secrets( 'publicize' );
+ if ( ! $verification ) {
$url = Jetpack::admin_url( 'jetpack#/settings' );
wp_die( sprintf( __( "Jetpack is not connected. Please connect Jetpack by visiting <a href='%s'>Settings</a>.", 'jetpack' ), $url ) );
@@ -180,7 +180,7 @@ class Publicize extends Publicize_Base {
'blog_id' => $wpcom_blog_id,
'secret_1' => $verification['secret_1'],
'secret_2' => $verification['secret_2'],
- 'eol' => $verification['eol'],
+ 'eol' => $verification['exp'],
) ) );
wp_redirect( $redirect );
exit;
@@ -354,11 +354,16 @@ class Publicize extends Publicize_Base {
), menu_page_url( 'sharing', false ) );
}
- function get_services( $filter ) {
- if ( ! in_array( $filter, array( 'all', 'connected' ) ) ) {
- $filter = 'all';
- }
-
+ /**
+ * Get social networks, either all available or only those that the site is connected to.
+ *
+ * @since 2.0
+ *
+ * @param string $filter Select the list of services that will be returned. Defaults to 'all', accepts 'connected'.
+ *
+ * @return array List of social networks.
+ */
+ function get_services( $filter = 'all' ) {
$services = array(
'facebook' => array(),
'twitter' => array(),
@@ -378,7 +383,6 @@ class Publicize extends Publicize_Base {
$connected_services[ $service ] = $connections;
}
}
-
return $connected_services;
}
}
@@ -452,7 +456,10 @@ class Publicize extends Publicize_Base {
* Save a flag locally to indicate that this post has already been Publicized via the selected
* connections.
*/
- function save_publicized( $post_ID, $post, $update ) {
+ function save_publicized( $post_ID, $post = null, $update = null ) {
+ if ( is_null( $post ) ) {
+ return;
+ }
// Only do this when a post transitions to being published
if ( get_post_meta( $post->ID, $this->PENDING ) && $this->post_type_is_publicizeable( $post->post_type ) ) {
$connected_services = Jetpack_Options::get_option( 'publicize_connections' );
@@ -512,7 +519,7 @@ class Publicize extends Publicize_Base {
if ( ! empty( $connection['connection_data']['meta']['facebook_page'] ) ) {
$found = false;
- if ( is_array( $pages->data ) ) {
+ if ( $pages && is_array( $pages->data ) ) {
foreach ( $pages->data as $page ) {
if ( $page->id == $connection['connection_data']['meta']['facebook_page'] ) {
$found = true;
diff --git a/plugins/jetpack/modules/publicize/publicize.php b/plugins/jetpack/modules/publicize/publicize.php
index 1b807a89..75c9333e 100644
--- a/plugins/jetpack/modules/publicize/publicize.php
+++ b/plugins/jetpack/modules/publicize/publicize.php
@@ -119,7 +119,7 @@ abstract class Publicize_Base {
abstract function connect_url( $service_name );
abstract function disconnect_url( $service_name, $id );
abstract function get_connection_meta( $connection );
- abstract function get_services( $filter );
+ abstract function get_services( $filter = 'all' );
abstract function get_connections( $service, $_blog_id = false, $_user_id = false );
abstract function get_connection( $service, $id, $_blog_id = false, $_user_id = false );
abstract function flag_post_for_publicize( $new_status, $old_status, $post );
diff --git a/plugins/jetpack/modules/search.php b/plugins/jetpack/modules/search.php
new file mode 100644
index 00000000..82a71c4c
--- /dev/null
+++ b/plugins/jetpack/modules/search.php
@@ -0,0 +1,16 @@
+<?php
+
+/**
+ * Module Name: Search
+ * Module Description: Enhanced search, powered by Elasticsearch
+ * First Introduced: 5.0
+ * Free: false
+ * Requires Connection: Yes
+ * Auto Activate: No
+ * Feature: Search
+ * Additional Search Queries: search
+ */
+
+require_once( dirname( __FILE__ ) . '/search/class.jetpack-search.php' );
+
+Jetpack_Search::instance();
diff --git a/plugins/jetpack/modules/search/class.jetpack-search-widget-filters.php b/plugins/jetpack/modules/search/class.jetpack-search-widget-filters.php
new file mode 100644
index 00000000..7de39e10
--- /dev/null
+++ b/plugins/jetpack/modules/search/class.jetpack-search-widget-filters.php
@@ -0,0 +1,126 @@
+<?php
+
+
+/**
+ * Provides a widget to show available/selected filters on searches
+ */
+class Jetpack_Search_Widget_Filters extends WP_Widget {
+
+ function __construct() {
+ if ( ! class_exists( 'Jetpack_Search' ) ) {
+ return;
+ }
+
+ parent::__construct(
+ 'jetpack-search-filters',
+ /** This filter is documented in modules/widgets/facebook-likebox.php */
+ apply_filters( 'jetpack_widget_name', esc_html__( 'Search Filters', 'jetpack' ) ),
+ array(
+ 'classname' => 'jetpack-filters',
+ 'description' => __( 'Displays search result filters when viewing search results.', 'jetpack' ),
+ )
+ );
+ }
+
+ function widget( $args, $instance ) {
+ if ( ! class_exists( 'Jetpack_Search' ) || ! is_search() ) {
+ return;
+ }
+
+ $search = Jetpack_Search::instance();
+
+ $filters = $search->get_filters();
+
+ $active_buckets = $search->get_active_filter_buckets();
+
+ if ( empty( $filters ) && empty( $active_buckets ) ) {
+ return;
+ }
+
+ $buckets_found = false;
+
+ foreach ( $filters as $filter ) {
+ if ( isset( $filter['buckets'] ) && count( $filter['buckets'] ) > 1 ) {
+ $buckets_found = true;
+
+ break;
+ }
+ }
+
+ if ( ! $buckets_found && empty( $active_buckets ) ) {
+ return;
+ }
+
+ $title = $instance['title'];
+
+ if ( empty( $title ) ) {
+ $title = __( 'Filter By', 'jetpack' );
+ }
+
+ /** This filter is documented in core/src/wp-includes/default-widgets.php */
+ $title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
+
+ echo $args['before_widget'];
+
+ echo $args['before_title'] . esc_html( $title ) . $args['after_title'];
+
+ if ( ! empty( $active_buckets ) ) {
+ echo '<h3>' . esc_html__( 'Current Filters', 'jetpack' ) . '</h3>';
+
+ echo '<ul>';
+
+ foreach ( $active_buckets as $item ) {
+ echo '<li><a href="' . esc_url( $item['remove_url'] ) . '">' . sprintf( _x( '(X) %1$s: %2$s', 'aggregation widget: active filter type and name', 'jetpack' ), esc_html( $item['type_label'] ), esc_html( $item['name'] ) ) . '</a></li>';
+ }
+
+ if ( count( $active_buckets ) > 1 ) {
+ echo '<li><a href="' . esc_url( add_query_arg( 's', get_query_var( 's' ), home_url() ) ) . '">' . esc_html__( 'Remove All Filters', 'jetpack' ) . '</a></li>';
+ }
+
+ echo '</ul>';
+ }
+
+ foreach ( $filters as $label => $filter ) {
+ if ( count( $filter['buckets'] ) < 2 ) {
+ continue;
+ }
+
+ echo '<h3>' . esc_html( $label ) . '</h3>';
+
+ echo '<ul>';
+
+ foreach ( $filter['buckets'] as $item ) {
+ if ( $item['active'] ) {
+ continue;
+ }
+
+ echo '<li><a href="' . esc_url( $item['url'] ) . '">' . esc_html( $item['name'] ) . '</a> (' . number_format_i18n( absint( $item['count'] ) ) . ')</li>';
+ }
+
+ echo '</ul>';
+ }
+
+ echo $args['after_widget'];
+ }
+
+ function update( $new_instance, $old_instance ) {
+ $instance = array();
+
+ $instance['title'] = sanitize_text_field( $new_instance['title'] );
+
+ return $instance;
+ }
+
+ function form( $instance ) {
+ $instance = wp_parse_args( (array) $instance, array(
+ 'title' => '',
+ ) );
+
+ $title = strip_tags( $instance['title'] );
+
+ ?>
+ <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'jetpack' ); ?></label>
+ <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></p>
+ <?php
+ }
+}
diff --git a/plugins/jetpack/modules/search/class.jetpack-search.php b/plugins/jetpack/modules/search/class.jetpack-search.php
new file mode 100644
index 00000000..cdd10504
--- /dev/null
+++ b/plugins/jetpack/modules/search/class.jetpack-search.php
@@ -0,0 +1,1313 @@
+<?php
+
+class Jetpack_Search {
+
+ protected $found_posts = 0;
+
+ /**
+ * The maximum offset ('from' param), since deep pages get exponentially slower.
+ *
+ * @see https://www.elastic.co/guide/en/elasticsearch/guide/current/pagination.html
+ */
+ protected $max_offset = 200;
+
+ protected $search_result;
+
+ protected $original_blog_id;
+ protected $jetpack_blog_id;
+
+ protected $aggregations = array();
+ protected $max_aggregations_count = 100;
+
+ protected static $instance;
+
+ //Languages with custom analyzers, other languages are supported,
+ // but are analyzed with the default analyzer.
+ public static $analyzed_langs = array( 'ar', 'bg', 'ca', 'cs', 'da', 'de', 'el', 'en', 'es', 'eu', 'fa', 'fi', 'fr', 'he', 'hi', 'hu', 'hy', 'id', 'it', 'ja', 'ko', 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr', 'zh' );
+
+ protected function __construct() {
+ /* Don't do anything, needs to be initialized via instance() method */
+ }
+
+ public function __clone() {
+ wp_die( "Please don't __clone Jetpack_Search" );
+ }
+
+ public function __wakeup() {
+ wp_die( "Please don't __wakeup Jetpack_Search" );
+ }
+
+ /**
+ * Get singleton instance of Jetpack_Search
+ *
+ * Instantiates and sets up a new instance if needed, or returns the singleton
+ *
+ * @module search
+ *
+ * @return Jetpack_Search The Jetpack_Search singleton
+ */
+ public static function instance() {
+ if ( ! isset( self::$instance ) ) {
+ self::$instance = new Jetpack_Search();
+
+ self::$instance->setup();
+ }
+
+ return self::$instance;
+ }
+
+ /**
+ * Perform various setup tasks for the class
+ *
+ * Checks various pre-requisites and adds hooks
+ *
+ * @module search
+ */
+ public function setup() {
+ if ( ! Jetpack::is_active() ) {
+ return;
+ }
+
+ $this->jetpack_blog_id = Jetpack::get_option( 'id' );
+
+ if ( ! $this->jetpack_blog_id ) {
+ return;
+ }
+
+ $this->init_hooks();
+ }
+
+ /**
+ * Setup the various hooks needed for the plugin to take over Search duties
+ *
+ * @module search
+ */
+ public function init_hooks() {
+ add_action( 'widgets_init', array( $this, 'action__widgets_init' ) );
+
+ if ( ! is_admin() ) {
+ add_filter( 'posts_pre_query', array( $this, 'filter__posts_pre_query' ), 10, 2 );
+
+ add_filter( 'jetpack_search_es_wp_query_args', array( $this, 'filter__add_date_filter_to_query' ), 10, 2 );
+ }
+ }
+
+ /*
+ * Run a search on the WP.com public API.
+ *
+ * @module search
+ *
+ * @param array $es_args Args conforming to the WP.com /sites/<blog_id>/search endpoint
+ *
+ * @return object|WP_Error The response from the public api, or a WP_Error
+ */
+ public function search( array $es_args ) {
+ $service_url = 'https://public-api.wordpress.com/rest/v1/sites/' . $this->jetpack_blog_id . '/search';
+
+ $start_time = microtime( true );
+
+ $request = wp_remote_post( $service_url, array(
+ 'headers' => array(
+ 'Content-Type' => 'application/json',
+ ),
+ 'timeout' => 10,
+ 'user-agent' => 'jetpack_search',
+ 'body' => json_encode( $es_args ),
+ ) );
+
+ $end_time = microtime( true );
+
+ if ( is_wp_error( $request ) ) {
+ return $request;
+ }
+ $response_code = wp_remote_retrieve_response_code( $request );
+
+ if ( ! $response_code || $response_code < 200 || $response_code >= 300 ) {
+ return new WP_Error( 'invalid_search_api_response', 'Invalid response from API - ' . $response_code );
+ }
+
+ $response = json_decode( wp_remote_retrieve_body( $request ), true );
+
+ $took = is_array( $response ) && $response['took'] ? $response['took'] : null;
+
+ $query = array(
+ 'args' => $es_args,
+ 'response' => $response,
+ 'response_code' => $response_code,
+ 'elapsed_time' => ( $end_time - $start_time ) * 1000, // Convert from float seconds to ms
+ 'es_time' => $took,
+ 'url' => $service_url,
+ );
+
+ /**
+ * Fires after a search request has been performed
+ *
+ * Includes the following info in the $query parameter:
+ *
+ * array args Array of Elasticsearch arguments for the search
+ * array response Raw API response, JSON decoded
+ * int response_code HTTP response code of the request
+ * float elapsed_time Roundtrip time of the search request, in milliseconds
+ * float es_time Amount of time Elasticsearch spent running the request, in milliseconds
+ * string url API url that was queried
+ *
+ * @since 5.0
+ *
+ * @param array $query Array of information about the query performed
+ */
+ do_action( 'did_jetpack_search_query', $query );
+
+ return $response;
+ }
+
+ /**
+ * Bypass the normal Search query and offload it to Jetpack servers
+ *
+ * This is the main hook of the plugin and is responsible for returning the posts that match the search query
+ *
+ * @module search
+ *
+ * @param array $posts Current array of posts (still pre-query)
+ * @param WP_Query $query The WP_Query being filtered
+ *
+ * @return array Array of matching posts
+ */
+ public function filter__posts_pre_query( $posts, $query ) {
+ if ( ! $query->is_main_query() || ! $query->is_search() ) {
+ return $posts;
+ }
+
+ $this->do_search( $query );
+
+ if ( ! is_array( $this->search_result ) ) {
+ return $posts;
+ }
+
+ // If no results, nothing to do
+ if ( ! count( $this->search_result['results']['hits'] ) ) {
+ return array();
+ }
+
+ $post_ids = array();
+
+ foreach ( $this->search_result['results']['hits'] as $result ) {
+ $post_ids[] = (int) $result['fields']['post_id'];
+ }
+
+ // Query all posts now
+ $args = array(
+ 'post__in' => $post_ids,
+ 'perm' => 'readable',
+ 'post_type' => 'any',
+ );
+
+ $posts_query = new WP_Query( $args );
+
+ // WP Core doesn't call the set_found_posts and its filters when filtering posts_pre_query like we do, so need to
+ // do these manually
+ $query->found_posts = $this->found_posts;
+ $query->max_num_pages = ceil( $this->found_posts / $query->get( 'posts_per_page' ) );
+
+ return $posts_query->posts;
+ }
+
+ /**
+ * Build up the search, then run it against the Jetpack servers
+ *
+ * @param WP_Query $query The original WP_Query to use for the parameters of our search
+ */
+ public function do_search( WP_Query $query ) {
+ if ( ! $query->is_main_query() || ! $query->is_search() ) {
+ return;
+ }
+
+ $page = ( $query->get( 'paged' ) ) ? absint( $query->get( 'paged' ) ) : 1;
+
+ $posts_per_page = $query->get( 'posts_per_page' );
+
+ // ES API does not allow more than 15 results at a time
+ if ( $posts_per_page > 15 ) {
+ $posts_per_page = 15;
+ }
+
+ // Start building the WP-style search query args
+ // They'll be translated to ES format args later
+ $es_wp_query_args = array(
+ 'query' => $query->get( 's' ),
+ 'posts_per_page' => $posts_per_page,
+ 'paged' => $page,
+ 'orderby' => $query->get( 'orderby' ),
+ 'order' => $query->get( 'order' ),
+ );
+
+ if ( ! empty( $this->aggregations ) ) {
+ $es_wp_query_args['aggregations'] = $this->aggregations;
+ }
+
+ // Did we query for authors?
+ if ( $query->get( 'author_name' ) ) {
+ $es_wp_query_args['author_name'] = $query->get( 'author_name' );
+ }
+
+ $es_wp_query_args['post_type'] = $this->get_es_wp_query_post_type_for_query( $query );
+
+ $es_wp_query_args['terms'] = $this->get_es_wp_query_terms_for_query( $query );
+
+
+ /**
+ * Modify the search query parameters, such as controlling the post_type.
+ *
+ * These arguments are in the format of WP_Query arguments
+ *
+ * @module search
+ *
+ * @since 5.0.0
+ *
+ * @param array $es_wp_query_args The current query args, in WP_Query format
+ * @param WP_Query $query The original query object
+ */
+ $es_wp_query_args = apply_filters( 'jetpack_search_es_wp_query_args', $es_wp_query_args, $query );
+
+ // If page * posts_per_page is greater than our max offset, send a 404. This is necessary because the offset is
+ // capped at $this->max_offset, so a high page would always return the last page of results otherwise
+ if ( ( $es_wp_query_args['paged'] * $es_wp_query_args['posts_per_page'] ) > $this->max_offset ) {
+ $query->set_404();
+
+ return;
+ }
+
+ // If there were no post types returned, then 404 to avoid querying against non-public post types, which could
+ // happen if we don't add the post type restriction to the ES query
+ if ( empty( $es_wp_query_args['post_type'] ) ) {
+ $query->set_404();
+
+ return;
+ }
+
+ // Convert the WP-style args into ES args
+ $es_query_args = $this->convert_wp_es_to_es_args( $es_wp_query_args );
+
+ //Only trust ES to give us IDs, not the content since it is a mirror
+ $es_query_args['fields'] = array(
+ 'post_id',
+ );
+
+ /**
+ * Modify the underlying ES query that is passed to the search endpoint. The returned args must represent a valid ES query
+ *
+ * This filter is harder to use if you're unfamiliar with ES, but allows complete control over the query
+ *
+ * @module search
+ *
+ * @since 5.0.0
+ *
+ * @param array $es_query_args The raw ES query args
+ * @param WP_Query $query The original query object
+ */
+ $es_query_args = apply_filters( 'jetpack_search_es_query_args', $es_query_args, $query );
+
+ // Do the actual search query!
+ $this->search_result = $this->search( $es_query_args );
+
+ if ( is_wp_error( $this->search_result ) || ! is_array( $this->search_result ) || empty( $this->search_result['results'] ) || empty( $this->search_result['results']['hits'] ) ) {
+ $this->found_posts = 0;
+
+ return;
+ }
+
+ // Total number of results for paging purposes. Capped at $this->>max_offset + $posts_per_page, as deep paging
+ // gets quite expensive
+ $this->found_posts = min( $this->search_result['results']['total'], $this->max_offset + $posts_per_page );
+
+ return;
+ }
+
+ /**
+ * Given a WP_Query, convert its WP_Tax_Query (if present) into the WP-style ES term arguments for the search
+ *
+ * @module search
+ *
+ * @param WP_Query $query The original WP_Query object for which to parse the taxonomy query
+ *
+ * @return array The new WP-style ES arguments (that will be converted into 'real' ES arguments)
+ */
+ public function get_es_wp_query_terms_for_query( WP_Query $query ) {
+ $args = array();
+
+ $the_tax_query = $query->tax_query;
+
+ if ( ! $the_tax_query ) {
+ return $args;
+ }
+
+
+ if ( ! $the_tax_query instanceof WP_Tax_Query || empty( $the_tax_query->queried_terms ) || ! is_array( $the_tax_query->queried_terms ) ) {
+ return $args;
+ }
+
+ $args = array();
+
+ foreach ( $the_tax_query->queries as $tax_query ) {
+ // Right now we only support slugs...see note above
+ if ( 'slug' !== $tax_query['field'] ) {
+ continue;
+ }
+
+ $taxonomy = $tax_query['taxonomy'];
+
+ if ( ! isset( $args[ $taxonomy ] ) || ! is_array( $args[ $taxonomy ] ) ) {
+ $args[ $taxonomy ] = array();
+ }
+
+ $args[ $taxonomy ] = array_merge( $args[ $taxonomy ], $tax_query['terms'] );
+ }
+
+ return $args;
+ }
+
+ /**
+ * Parse out the post type from a WP_Query
+ *
+ * Only allows post types that are not marked as 'exclude_from_search'
+ *
+ * @module search
+ *
+ * @param WP_Query $query Original WP_Query object
+ *
+ * @return array Array of searchable post types corresponding to the original query
+ */
+ public function get_es_wp_query_post_type_for_query( WP_Query $query ) {
+ $post_types = $query->get( 'post_type' );
+
+ // If we're searching 'any', we want to only pass searchable post types to ES
+ if ( 'any' === $post_types ) {
+ $post_types = array_values( get_post_types( array(
+ 'exclude_from_search' => false,
+ ) ) );
+ }
+
+ if ( ! is_array( $post_types ) ) {
+ $post_types = array( $post_types );
+ }
+
+ $post_types = array_unique( $post_types );
+
+ $sanitized_post_types = array();
+
+ // Make sure the post types are queryable
+ foreach ( $post_types as $post_type ) {
+ if ( ! $post_type ) {
+ continue;
+ }
+
+ $post_type_object = get_post_type_object( $post_type );
+
+ if ( ! $post_type_object || $post_type_object->exclude_from_search ) {
+ continue;
+ }
+
+ $sanitized_post_types[] = $post_type;
+ }
+
+ return $sanitized_post_types;
+ }
+
+ /**
+ * Initialze widgets for the Search module
+ *
+ * @module search
+ */
+ public function action__widgets_init() {
+ require_once( dirname( __FILE__ ) . '/class.jetpack-search-widget-filters.php' );
+
+ register_widget( 'Jetpack_Search_Widget_Filters' );
+ }
+
+ /**
+ * Get the Elasticsearch result
+ *
+ * @module search
+ *
+ * @param bool $raw If true, does not check for WP_Error or return the 'results' array - the JSON decoded HTTP response
+ *
+ * @return array|bool The search results, or false if there was a failure
+ */
+ public function get_search_result( $raw = false ) {
+ if ( $raw ) {
+ return $this->search_result;
+ }
+
+ return ( ! empty( $this->search_result ) && ! is_wp_error( $this->search_result ) && is_array( $this->search_result ) && ! empty( $this->search_result['results'] ) ) ? $this->search_result['results'] : false;
+ }
+
+ /**
+ * Add the date portion of a WP_Query onto the query args
+ *
+ * @param array $es_wp_query_args
+ * @param WP_Query $query The original WP_Query
+ *
+ * @return array The es wp query args, with date filters added (as needed)
+ */
+ public function filter__add_date_filter_to_query( array $es_wp_query_args, WP_Query $query ) {
+ if ( $query->get( 'year' ) ) {
+ if ( $query->get( 'monthnum' ) ) {
+ // Padding
+ $date_monthnum = sprintf( '%02d', $query->get( 'monthnum' ) );
+
+ if ( $query->get( 'day' ) ) {
+ // Padding
+ $date_day = sprintf( '%02d', $query->get( 'day' ) );
+
+ $date_start = $query->get( 'year' ) . '-' . $date_monthnum . '-' . $date_day . ' 00:00:00';
+ $date_end = $query->get( 'year' ) . '-' . $date_monthnum . '-' . $date_day . ' 23:59:59';
+ } else {
+ $days_in_month = date( 't', mktime( 0, 0, 0, $query->get( 'monthnum' ), 14, $query->get( 'year' ) ) ); // 14 = middle of the month so no chance of DST issues
+
+ $date_start = $query->get( 'year' ) . '-' . $date_monthnum . '-01 00:00:00';
+ $date_end = $query->get( 'year' ) . '-' . $date_monthnum . '-' . $days_in_month . ' 23:59:59';
+ }
+ } else {
+ $date_start = $query->get( 'year' ) . '-01-01 00:00:00';
+ $date_end = $query->get( 'year' ) . '-12-31 23:59:59';
+ }
+
+ $es_wp_query_args['date_range'] = array(
+ 'field' => 'date',
+ 'gte' => $date_start,
+ 'lte' => $date_end,
+ );
+ }
+
+ return $es_wp_query_args;
+ }
+
+ /**
+ * Converts WP_Query style args to ES args
+ *
+ * @module search
+ *
+ * @param array $args Array of WP_Query style arguments
+ *
+ * @return array Array of ES style query arguments
+ */
+ function convert_wp_es_to_es_args( array $args ) {
+ jetpack_require_lib( 'jetpack-wpes-query-builder' );
+
+ $builder = new Jetpack_WPES_Query_Builder();
+
+ $defaults = array(
+ 'blog_id' => get_current_blog_id(),
+
+ 'query' => null, // Search phrase
+ 'query_fields' => array( 'title', 'content', 'author', 'tag', 'category' ),
+
+ 'post_type' => null, // string or an array
+ 'terms' => array(), // ex: array( 'taxonomy-1' => array( 'slug' ), 'taxonomy-2' => array( 'slug-a', 'slug-b' ) )
+
+ 'author' => null, // id or an array of ids
+ 'author_name' => array(), // string or an array
+
+ 'date_range' => null, // array( 'field' => 'date', 'gt' => 'YYYY-MM-dd', 'lte' => 'YYYY-MM-dd' ); date formats: 'YYYY-MM-dd' or 'YYYY-MM-dd HH:MM:SS'
+
+ 'orderby' => null, // Defaults to 'relevance' if query is set, otherwise 'date'. Pass an array for multiple orders.
+ 'order' => 'DESC',
+
+ 'posts_per_page' => 10,
+
+ 'offset' => null,
+ 'paged' => null,
+
+ /**
+ * Aggregations. Examples:
+ * array(
+ * 'Tag' => array( 'type' => 'taxonomy', 'taxonomy' => 'post_tag', 'count' => 10 ) ),
+ * 'Post Type' => array( 'type' => 'post_type', 'count' => 10 ) ),
+ * );
+ */
+ 'aggregations' => null,
+ );
+
+ $args = wp_parse_args( $args, $defaults );
+
+ $es_query_args = array(
+ 'blog_id' => absint( $args['blog_id'] ),
+ 'size' => absint( $args['posts_per_page'] ),
+ );
+
+ // ES "from" arg (offset)
+ if ( $args['offset'] ) {
+ $es_query_args['from'] = absint( $args['offset'] );
+ } elseif ( $args['paged'] ) {
+ $es_query_args['from'] = max( 0, ( absint( $args['paged'] ) - 1 ) * $es_query_args['size'] );
+ }
+
+ // Limit the offset to $this->max_offset posts, as deep pages get exponentially slower
+ // See https://www.elastic.co/guide/en/elasticsearch/guide/current/pagination.html
+ $es_query_args['from'] = min( $es_query_args['from'], $this->max_offset );
+
+ if ( ! is_array( $args['author_name'] ) ) {
+ $args['author_name'] = array( $args['author_name'] );
+ }
+
+ // ES stores usernames, not IDs, so transform
+ if ( ! empty( $args['author'] ) ) {
+ if ( ! is_array( $args['author'] ) ) {
+ $args['author'] = array( $args['author'] );
+ }
+
+ foreach ( $args['author'] as $author ) {
+ $user = get_user_by( 'id', $author );
+
+ if ( $user && ! empty( $user->user_login ) ) {
+ $args['author_name'][] = $user->user_login;
+ }
+ }
+ }
+
+ //////////////////////////////////////////////////
+ // Build the filters from the query elements.
+ // Filters rock because they are cached from one query to the next
+ // but they are cached as individual filters, rather than all combined together.
+ // May get performance boost by also caching the top level boolean filter too.
+ $filters = array();
+
+ if ( $args['post_type'] ) {
+ if ( ! is_array( $args['post_type'] ) ) {
+ $args['post_type'] = array( $args['post_type'] );
+ }
+
+ $filters[] = array(
+ 'terms' => array(
+ 'post_type' => $args['post_type'],
+ ),
+ );
+ }
+
+ if ( $args['author_name'] ) {
+ $filters[] = array(
+ 'terms' => array(
+ 'author_login' => $args['author_name'],
+ ),
+ );
+ }
+
+ if ( ! empty( $args['date_range'] ) && isset( $args['date_range']['field'] ) ) {
+ $field = $args['date_range']['field'];
+
+ unset( $args['date_range']['field'] );
+
+ $filters[] = array(
+ 'range' => array(
+ $field => $args['date_range'],
+ ),
+ );
+ }
+
+ if ( is_array( $args['terms'] ) ) {
+ foreach ( $args['terms'] as $tax => $terms ) {
+ $terms = (array) $terms;
+
+ if ( count( $terms ) && mb_strlen( $tax ) ) {
+ switch ( $tax ) {
+ case 'post_tag':
+ $tax_fld = 'tag.slug';
+
+ break;
+
+ case 'category':
+ $tax_fld = 'category.slug';
+
+ break;
+
+ default:
+ $tax_fld = 'taxonomy.' . $tax . '.slug';
+
+ break;
+ }
+
+ foreach ( $terms as $term ) {
+ $filters[] = array(
+ 'term' => array(
+ $tax_fld => $term,
+ ),
+ );
+ }
+ }
+ }
+ }
+
+ if ( $args['query'] ) {
+ $query = array(
+ 'multi_match' => array(
+ 'query' => $args['query'],
+ 'fields' => $args['query_fields'],
+ 'operator' => 'and',
+ 'type' => 'cross_fields',
+ ),
+ );
+
+ $builder->add_query( $query );
+
+ Jetpack_Search::score_query_by_recency( $builder );
+
+ if ( ! $args['orderby'] ) {
+ $args['orderby'] = array( 'relevance' );
+ }
+ } else {
+ if ( ! $args['orderby'] ) {
+ $args['orderby'] = array( 'date' );
+ }
+ }
+
+ // Validate the "order" field
+ switch ( strtolower( $args['order'] ) ) {
+ case 'asc':
+ $args['order'] = 'asc';
+ break;
+
+ case 'desc':
+ default:
+ $args['order'] = 'desc';
+ break;
+ }
+
+ $es_query_args['sort'] = array();
+
+ foreach ( (array) $args['orderby'] as $orderby ) {
+ // Translate orderby from WP field to ES field
+ switch ( $orderby ) {
+ case 'relevance' :
+ //never order by score ascending
+ $es_query_args['sort'][] = array(
+ '_score' => array(
+ 'order' => 'desc',
+ ),
+ );
+
+ break;
+
+ case 'date' :
+ $es_query_args['sort'][] = array(
+ 'date' => array(
+ 'order' => $args['order'],
+ ),
+ );
+
+ break;
+
+ case 'ID' :
+ $es_query_args['sort'][] = array(
+ 'id' => array(
+ 'order' => $args['order'],
+ ),
+ );
+
+ break;
+
+ case 'author' :
+ $es_query_args['sort'][] = array(
+ 'author.raw' => array(
+ 'order' => $args['order'],
+ ),
+ );
+
+ break;
+ } // End switch().
+ } // End foreach().
+
+ if ( empty( $es_query_args['sort'] ) ) {
+ unset( $es_query_args['sort'] );
+ }
+
+ if ( ! empty( $filters ) && is_array( $filters ) ) {
+ foreach ( $filters as $filter ) {
+ $builder->add_filter( $filter );
+ }
+
+ $es_query_args['filter'] = $builder->build_filter();
+ }
+
+ $es_query_args['query'] = $builder->build_query();
+
+ // Aggregations
+ if ( ! empty( $args['aggregations'] ) ) {
+ $this->add_aggregations_to_es_query_builder( $args['aggregations'], $builder );
+
+ $es_query_args['aggregations'] = $builder->build_aggregation();
+ }
+
+ return $es_query_args;
+ }
+
+ /**
+ * Given an array of aggregations, parse and add them onto the Jetpack_WPES_Query_Builder object for use in ES
+ *
+ * @module search
+ *
+ * @param array $aggregations Array of Aggregations (filters) to add to the Jetpack_WPES_Query_Builder
+ *
+ * @param Jetpack_WPES_Query_Builder $builder The builder instance that is creating the ES query
+ */
+ public function add_aggregations_to_es_query_builder( array $aggregations, Jetpack_WPES_Query_Builder $builder ) {
+ foreach ( $aggregations as $label => $aggregation ) {
+ switch ( $aggregation['type'] ) {
+ case 'taxonomy':
+ $this->add_taxonomy_aggregation_to_es_query_builder( $aggregation, $label, $builder );
+
+ break;
+
+ case 'post_type':
+ $this->add_post_type_aggregation_to_es_query_builder( $aggregation, $label, $builder );
+
+ break;
+
+ case 'date_histogram':
+ $this->add_date_histogram_aggregation_to_es_query_builder( $aggregation, $label, $builder );
+
+ break;
+ }
+ }
+ }
+
+ /**
+ * Given an individual taxonomy aggregation, add it to the Jetpack_WPES_Query_Builder object for use in ES
+ *
+ * @module search
+ *
+ * @param array $aggregation The aggregation to add to the query builder
+ * @param string $label The 'label' (unique id) for this aggregation
+ * @param Jetpack_WPES_Query_Builder $builder The builder instance that is creating the ES query
+ */
+ public function add_taxonomy_aggregation_to_es_query_builder( array $aggregation, $label, Jetpack_WPES_Query_Builder $builder ) {
+ $field = null;
+
+ switch ( $aggregation['taxonomy'] ) {
+ case 'post_tag':
+ $field = 'tag';
+ break;
+
+ case 'category':
+ $field = 'category';
+ break;
+
+ default:
+ $field = 'taxonomy.' . $aggregation['taxonomy'];
+ break;
+ }
+
+ $builder->add_aggs( $label, array(
+ 'terms' => array(
+ 'field' => $field . '.slug',
+ 'size' => min( (int) $aggregation['count'], $this->max_aggregations_count ),
+ ),
+ ));
+ }
+
+ /**
+ * Given an individual post_type aggregation, add it to the Jetpack_WPES_Query_Builder object for use in ES
+ *
+ * @module search
+ *
+ * @param array $aggregation The aggregation to add to the query builder
+ * @param string $label The 'label' (unique id) for this aggregation
+ * @param Jetpack_WPES_Query_Builder $builder The builder instance that is creating the ES query
+ */
+ public function add_post_type_aggregation_to_es_query_builder( array $aggregation, $label, Jetpack_WPES_Query_Builder $builder ) {
+ $builder->add_aggs( $label, array(
+ 'terms' => array(
+ 'field' => 'post_type',
+ 'size' => min( (int) $aggregation['count'], $this->max_aggregations_count ),
+ ),
+ ));
+ }
+
+ /**
+ * Given an individual date_histogram aggregation, add it to the Jetpack_WPES_Query_Builder object for use in ES
+ *
+ * @module search
+ *
+ * @param array $aggregation The aggregation to add to the query builder
+ * @param string $label The 'label' (unique id) for this aggregation
+ * @param Jetpack_WPES_Query_Builder $builder The builder instance that is creating the ES query
+ */
+ public function add_date_histogram_aggregation_to_es_query_builder( array $aggregation, $label, Jetpack_WPES_Query_Builder $builder ) {
+ $builder->add_aggs( $label, array(
+ 'date_histogram' => array(
+ 'interval' => $aggregation['interval'],
+ 'field' => ( ! empty( $aggregation['field'] ) && 'post_date_gmt' == $aggregation['field'] ) ? 'date_gmt' : 'date',
+ ),
+ ));
+ }
+
+ /**
+ * And an existing filter object with a list of additional filters.
+ *
+ * Attempts to optimize the filters somewhat.
+ *
+ * @module search
+ *
+ * @param array $curr_filter The existing filters to build upon
+ * @param array $filters The new filters to add
+ *
+ * @return array The resulting merged filters
+ */
+ public static function and_es_filters( array $curr_filter, array $filters ) {
+ if ( ! is_array( $curr_filter ) || isset( $curr_filter['match_all'] ) ) {
+ if ( 1 === count( $filters ) ) {
+ return $filters[0];
+ }
+
+ return array(
+ 'and' => $filters,
+ );
+ }
+
+ return array(
+ 'and' => array_merge( array( $curr_filter ), $filters ),
+ );
+ }
+
+ /**
+ * Add a recency score to a given Jetpack_WPES_Query_Builder object, for emphasizing newer posts in results
+ *
+ * Internally uses a gauss decay function
+ *
+ * @module search
+ *
+ * @param Jetpack_WPES_Query_Builder $builder The Jetpack_WPES_Query_Builder to add the recency score to
+ *
+ * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html#function-decay
+ */
+ public static function score_query_by_recency( Jetpack_WPES_Query_Builder &$builder ) {
+ //Newer content gets weighted slightly higher
+ $date_scale = '360d';
+ $date_decay = 0.9;
+ $date_origin = date( 'Y-m-d' );
+
+ $builder->add_decay( 'gauss', array(
+ 'date_gmt' => array(
+ 'origin' => $date_origin,
+ 'scale' => $date_scale,
+ 'decay' => $date_decay,
+ ),
+ ));
+ }
+
+ /**
+ * Set the available filters for the search
+ *
+ * These get rendered via the Jetpack_Search_Widget_Filters() widget
+ *
+ * Behind the scenes, these are implemented using Elasticsearch Aggregations.
+ *
+ * If you do not require counts of how many documents match each filter, please consider using regular WP Query
+ * arguments instead, such as via the jetpack_search_es_wp_query_args filter
+ *
+ * @module search
+ *
+ * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations.html
+ *
+ * @param array $aggregations Array of filters (aggregations) to apply to the search
+ */
+ public function set_filters( array $aggregations ) {
+ $this->aggregations = $aggregations;
+ }
+
+ /**
+ * Set the search's facets (deprecated)
+ *
+ * @module search
+ *
+ * @deprecated 5.0 Please use Jetpack_Search::set_filters() instead
+ *
+ * @see Jetpack_Search::set_filters()
+ *
+ * @param array $facets Array of facets to apply to the search
+ */
+ public function set_facets( array $facets ) {
+ _deprecated_function( __METHOD__, 'jetpack-5.0', 'Jetpack_Search::set_filters()' );
+
+ $this->set_filters( $facets );
+ }
+
+ /**
+ * Get the raw Aggregation results from the ES response
+ *
+ * @module search
+ *
+ * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations.html
+ *
+ * @return array Array of Aggregations performed on the search
+ */
+ public function get_search_aggregations_results() {
+ $aggregations = array();
+
+ $search_result = $this->get_search_result();
+
+ if ( ! empty( $search_result ) && ! empty( $search_result['aggregations'] ) ) {
+ $aggregations = $search_result['aggregations'];
+ }
+
+ return $aggregations;
+ }
+
+ /**
+ * Get the raw Facet results from the ES response
+ *
+ * @module search
+ *
+ * @deprecated 5.0 Please use Jetpack_Search::get_search_aggregations_results() instead
+ *
+ * @see Jetpack_Search::get_search_aggregations_results()
+ *
+ * @return array Array of Facets performed on the search
+ */
+ public function get_search_facets() {
+ _deprecated_function( __METHOD__, 'jetpack-5.0', 'Jetpack_Search::get_search_aggregations_results()' );
+
+ return $this->get_search_aggregations_results();
+ }
+
+ /**
+ * Get the results of the Filters performed, including the number of matching documents
+ *
+ * Returns an array of Filters (keyed by $label, as passed to Jetpack_Search::set_filters()), containing the Filter and all resulting
+ * matching buckets, the url for applying/removing each bucket, etc.
+ *
+ * NOTE - if this is called before the search is performed, an empty array will be returned. Use the $aggregations class
+ * member if you need to access the raw filters set in Jetpack_Search::set_filters()
+ *
+ * @module search
+ *
+ * @param WP_Query $query The optional original WP_Query to use for determining which filters are active. Defaults to the main query
+ *
+ * @return array Array of Filters applied and info about them
+ */
+ public function get_filters( WP_Query $query = null ) {
+ if ( ! $query instanceof WP_Query ) {
+ global $wp_query;
+
+ $query = $wp_query;
+ }
+
+ $aggregation_data = $this->aggregations;
+
+ if ( empty( $aggregation_data ) ) {
+ return $aggregation_data;
+ }
+
+ $aggregation_results = $this->get_search_aggregations_results();
+
+ if ( ! $aggregation_results ) {
+ return $aggregation_data;
+ }
+
+ // NOTE - Looping over the _results_, not the original configured aggregations, so we get the 'real' data from ES
+ foreach ( $aggregation_results as $label => $aggregation ) {
+ if ( empty( $aggregation ) ) {
+ continue;
+ }
+
+ $type = $this->aggregations[ $label ]['type'];
+
+ $aggregation_data[ $label ]['buckets'] = array();
+
+ $existing_term_slugs = array();
+
+ $tax_query_var = null;
+
+ // Figure out which terms are active in the query, for this taxonomy
+ if ( 'taxonomy' === $this->aggregations[ $label ]['type'] ) {
+ $tax_query_var = $this->get_taxonomy_query_var( $this->aggregations[ $label ]['taxonomy'] );
+
+ if ( ! empty( $query->tax_query ) && ! empty( $query->tax_query->queries ) && is_array( $query->tax_query->queries ) ) {
+ foreach( $query->tax_query->queries as $tax_query ) {
+ if ( $this->aggregations[ $label ]['taxonomy'] === $tax_query['taxonomy'] &&
+ 'slug' === $tax_query['field'] &&
+ is_array( $tax_query['terms'] ) ) {
+ $existing_term_slugs = array_merge( $existing_term_slugs, $tax_query['terms'] );
+ }
+ }
+ }
+ }
+
+ // Now take the resulting found aggregation items and generate the additional info about them, such as
+ // activation/deactivation url, name, count, etc
+ $buckets = array();
+
+ if ( ! empty( $aggregation['buckets'] ) ) {
+ $buckets = (array) $aggregation['buckets'];
+ }
+
+ // Some aggregation types like date_histogram don't support the max results parameter
+ if ( is_int( $this->aggregations[ $label ]['count'] ) && count( $buckets ) > $this->aggregations[ $label ]['count'] ) {
+ $buckets = array_slice( $buckets, 0, $this->aggregations[ $label ]['count'] );
+ }
+
+ foreach ( $buckets as $item ) {
+ $query_vars = array();
+ $active = false;
+ $remove_url = null;
+ $name = '';
+
+ // What type was the original aggregation?
+ switch ( $type ) {
+ case 'taxonomy':
+ $taxonomy = $this->aggregations[ $label ]['taxonomy'];
+
+ $term = get_term_by( 'slug', $item['key'], $taxonomy );
+
+ if ( ! $term || ! $tax_query_var ) {
+ continue 2; // switch() is considered a looping structure
+ }
+
+ $query_vars = array(
+ $tax_query_var => implode( '+', array_merge( $existing_term_slugs, array( $term->slug ) ) ),
+ );
+
+ $name = $term->name;
+
+ // Let's determine if this term is active or not
+
+ if ( in_array( $item['key'], $existing_term_slugs, true ) ) {
+ $active = true;
+
+ $slug_count = count( $existing_term_slugs );
+
+ if ( $slug_count > 1 ) {
+ $remove_url = add_query_arg( $tax_query_var, urlencode( implode( '+', array_diff( $existing_term_slugs, array( $item['key'] ) ) ) ) );
+ } else {
+ $remove_url = remove_query_arg( $tax_query_var );
+ }
+ }
+
+ break;
+
+ case 'post_type':
+ $post_type = get_post_type_object( $item['key'] );
+
+ if ( ! $post_type || $post_type->exclude_from_search ) {
+ continue 2; // switch() is considered a looping structure
+ }
+
+ $query_vars = array(
+ 'post_type' => $item['key'],
+ );
+
+ $name = $post_type->labels->singular_name;
+
+ // Is this post type active on this search?
+ $post_types = $query->get( 'post_type' );
+
+ if ( ! is_array( $post_types ) ) {
+ $post_types = array( $post_types );
+ }
+
+ if ( in_array( $item['key'], $post_types ) ) {
+ $active = true;
+
+ $post_type_count = count( $post_types );
+
+ // For the right 'remove filter' url, we need to remove the post type from the array, or remove the param entirely if it's the only one
+ if ( $post_type_count > 1 ) {
+ $remove_url = add_query_arg( 'post_type', urlencode_deep( array_diff( $post_types, array( $item['key'] ) ) ) );
+ } else {
+ $remove_url = remove_query_arg( 'post_type' );
+ }
+ }
+
+ break;
+
+ case 'date_histogram':
+ $timestamp = $item['key'] / 1000;
+
+ $current_year = $query->get( 'year' );
+ $current_month = $query->get( 'monthnum' );
+ $current_day = $query->get( 'day' );
+
+ switch ( $this->aggregations[ $label ]['interval'] ) {
+ case 'year':
+ $year = (int) date( 'Y', $timestamp );
+
+ $query_vars = array(
+ 'year' => $year,
+ 'monthnum' => false,
+ 'day' => false,
+ );
+
+ $name = $year;
+
+ // Is this year currently selected?
+ if ( ! empty( $current_year ) && (int) $current_year === $year ) {
+ $active = true;
+
+ $remove_url = remove_query_arg( array( 'year', 'monthnum', 'day' ) );
+ }
+
+ break;
+
+ case 'month':
+ $year = (int) date( 'Y', $timestamp );
+ $month = (int) date( 'n', $timestamp );
+
+ $query_vars = array(
+ 'year' => $year,
+ 'monthnum' => $month,
+ 'day' => false,
+ );
+
+ $name = date( 'F Y', $timestamp );
+
+ // Is this month currently selected?
+ if ( ! empty( $current_year ) && (int) $current_year === $year &&
+ ! empty( $current_month ) && (int) $current_month === $month ) {
+ $active = true;
+
+ $remove_url = remove_query_arg( array( 'monthnum', 'day' ) );
+ }
+
+ break;
+
+ case 'day':
+ $year = (int) date( 'Y', $timestamp );
+ $month = (int) date( 'n', $timestamp );
+ $day = (int) date( 'j', $timestamp );
+
+ $query_vars = array(
+ 'year' => $year,
+ 'monthnum' => $month,
+ 'day' => $day,
+ );
+
+ $name = date( 'F jS, Y', $timestamp );
+
+ // Is this day currently selected?
+ if ( ! empty( $current_year ) && (int) $current_year === $year &&
+ ! empty( $current_month ) && (int) $current_month === $month &&
+ ! empty( $current_day ) && (int) $current_day === $day ) {
+ $active = true;
+
+ $remove_url = remove_query_arg( array( 'day' ) );
+ }
+
+ break;
+
+ default:
+ continue 3; // switch() is considered a looping structure
+ } // End switch().
+
+ break;
+
+ default:
+ //continue 2; // switch() is considered a looping structure
+ } // End switch().
+
+ // Need to urlencode param values since add_query_arg doesn't
+ $url_params = urlencode_deep( $query_vars );
+
+ $aggregation_data[ $label ]['buckets'][] = array(
+ 'url' => add_query_arg( $url_params ),
+ 'query_vars' => $query_vars,
+ 'name' => $name,
+ 'count' => $item['doc_count'],
+ 'active' => $active,
+ 'remove_url' => $remove_url,
+ 'type' => $type,
+ 'type_label' => $label,
+ );
+ } // End foreach().
+ } // End foreach().
+
+ return $aggregation_data;
+ }
+
+ /**
+ * Get the results of the Facets performed
+ *
+ * @module search
+ *
+ * @deprecated 5.0 Please use Jetpack_Search::get_filters() instead
+ *
+ * @see Jetpack_Search::get_filters()
+ *
+ * @return array $facets Array of Facets applied and info about them
+ */
+ public function get_search_facet_data() {
+ _deprecated_function( __METHOD__, 'jetpack-5.0', 'Jetpack_Search::get_filters()' );
+
+ return $this->get_filters();
+ }
+
+ /**
+ * Get the Filters that are currently applied to this search
+ *
+ * @module search
+ *
+ * @return array Array if Filters that were applied
+ */
+ public function get_active_filter_buckets() {
+ $active_buckets = array();
+
+ $filters = $this->get_filters();
+
+ if ( ! is_array( $filters ) ) {
+ return $active_buckets;
+ }
+
+ foreach( $filters as $filter ) {
+ if ( isset( $filters['buckets'] ) && is_array( $filter['buckets'] ) ) {
+ foreach( $filter['buckets'] as $item ) {
+ if ( isset( $item['active'] ) && $item['active'] ) {
+ $active_buckets[] = $item;
+ }
+ }
+ }
+ }
+
+ return $active_buckets;
+ }
+
+ /**
+ * Get the Filters that are currently applied to this search
+ *
+ * @module search
+ *
+ * @return array Array if Filters that were applied
+ */
+ public function get_current_filters() {
+ _deprecated_function( __METHOD__, 'jetpack-5.0', 'Jetpack_Search::get_active_filter_buckets()' );
+
+ return $this->get_active_filter_buckets();
+ }
+
+ /**
+ * Calculate the right query var to use for a given taxonomy
+ *
+ * Allows custom code to modify the GET var that is used to represent a given taxonomy, via the jetpack_search_taxonomy_query_var filter
+ *
+ * @module search
+ *
+ * @param string $taxonomy_name The name of the taxonomy for which to get the query var
+ *
+ * @return bool|string The query var to use for this taxonomy, or false if none found
+ */
+ public function get_taxonomy_query_var( $taxonomy_name ) {
+ $taxonomy = get_taxonomy( $taxonomy_name );
+
+ if ( ! $taxonomy || is_wp_error( $taxonomy ) ) {
+ return false;
+ }
+
+ /**
+ * Modify the query var to use for a given taxonomy
+ *
+ * @module search
+ *
+ * @since 5.0.0
+ *
+ * @param string $query_var The current query_var for the taxonomy
+ * @param string $taxonomy_name The taxonomy name
+ */
+ return apply_filters( 'jetpack_search_taxonomy_query_var', $taxonomy->query_var, $taxonomy_name );
+ }
+}
diff --git a/plugins/jetpack/modules/seo-tools.php b/plugins/jetpack/modules/seo-tools.php
index 4003e3fc..ae48885f 100644
--- a/plugins/jetpack/modules/seo-tools.php
+++ b/plugins/jetpack/modules/seo-tools.php
@@ -14,5 +14,21 @@
*/
include dirname( __FILE__ ) . '/seo-tools/jetpack-seo.php';
+include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
+
+// Suppress SEO Tools output if any of the following plugins is active.
+$jetpack_seo_conflicting_plugins = array(
+ 'wordpress-seo/wp-seo.php',
+ 'wordpress-seo-premium/wp-seo-premium.php',
+ 'all-in-one-seo-pack/all_in_one_seo_pack.php',
+ 'all-in-one-seo-pack-pro/all_in_one_seo_pack.php',
+);
+
+foreach( $jetpack_seo_conflicting_plugins as $seo_plugin ) {
+ if ( Jetpack::is_plugin_active( $seo_plugin ) ) {
+ add_filter( 'jetpack_disable_seo_tools', '__return_true' );
+ break;
+ }
+}
new Jetpack_SEO;
diff --git a/plugins/jetpack/modules/seo-tools/jetpack-seo-utils.php b/plugins/jetpack/modules/seo-tools/jetpack-seo-utils.php
index a804dcf4..d6b6474f 100644
--- a/plugins/jetpack/modules/seo-tools/jetpack-seo-utils.php
+++ b/plugins/jetpack/modules/seo-tools/jetpack-seo-utils.php
@@ -22,6 +22,19 @@ class Jetpack_SEO_Utils {
* @return bool True if SEO tools are enabled, false otherwise.
*/
public static function is_enabled_jetpack_seo( $site_id = 0 ) {
+ /**
+ * Can be used by SEO plugin authors to disable the conflicting output of SEO Tools.
+ *
+ * @module seo-tools
+ *
+ * @since 5.0.0
+ *
+ * @param bool True if SEO Tools should be disabled, false otherwise.
+ */
+ if ( apply_filters( 'jetpack_disable_seo_tools', false ) ) {
+ return false;
+ }
+
if ( function_exists( 'has_blog_sticker' ) ) {
// For WPCOM sites
if ( empty( $site_id ) ) {
diff --git a/plugins/jetpack/modules/seo-tools/jetpack-seo.php b/plugins/jetpack/modules/seo-tools/jetpack-seo.php
index fdc8543a..d8bccd46 100644
--- a/plugins/jetpack/modules/seo-tools/jetpack-seo.php
+++ b/plugins/jetpack/modules/seo-tools/jetpack-seo.php
@@ -105,39 +105,12 @@ class Jetpack_SEO {
return;
}
- /**
- * Can be used to insert custom site host that will used for meta title.
- *
- * @module seo-tools
- *
- * @since 4.4.0
- *
- * @param string Name of the site host. Defaults to empty string.
- */
- $site_host = apply_filters( 'jetpack_seo_site_host', '' );
-
- $meta['title'] = sprintf( _x( '%1$s', 'Site Title', 'jetpack' ), get_bloginfo( 'title' ) );
-
- if ( ! empty( $site_host ) ) {
- $meta['title'] = sprintf(
- _x( '%1$s on %2$s', 'Site Title on WordPress', 'jetpack' ),
- get_bloginfo( 'title' ),
- $site_host
- );
- }
-
$front_page_meta = Jetpack_SEO_Utils::get_front_page_meta_description();
$description = $front_page_meta ? $front_page_meta : get_bloginfo( 'description' );
$meta['description'] = trim( $description );
// Try to target things if we're on a "specific" page of any kind.
if ( is_singular() ) {
- $meta['title'] = sprintf(
- _x( '%1$s | %2$s', 'Post Title | Site Title on WordPress', 'jetpack' ),
- get_the_title(),
- $meta['title']
- );
-
// Business users can overwrite the description.
if ( ! ( is_front_page() && Jetpack_SEO_Utils::get_front_page_meta_description() ) ) {
$description = Jetpack_SEO_Posts::get_post_description( get_post() );
@@ -151,12 +124,6 @@ class Jetpack_SEO {
} elseif ( is_author() ) {
$obj = get_queried_object();
- $meta['title'] = sprintf(
- _x( 'Posts by %1$s | %2$s', 'Posts by Author Name | Blog Title on WordPress', 'jetpack' ),
- $obj->display_name,
- $meta['title']
- );
-
$meta['description'] = sprintf(
_x( 'Read all of the posts by %1$s on %2$s', 'Read all of the posts by Author Name on Blog Title', 'jetpack' ),
$obj->display_name,
@@ -165,12 +132,6 @@ class Jetpack_SEO {
} elseif ( is_tag() || is_category() || is_tax() ) {
$obj = get_queried_object();
- $meta['title'] = sprintf(
- _x( 'Posts about %1$s on %2$s', 'Posts about Category on Blog Title', 'jetpack' ),
- single_term_title( '', false ),
- get_bloginfo( 'title' )
- );
-
$description = get_term_field( 'description', $obj->term_id, $obj->taxonomy, 'raw' );
if ( ! is_wp_error( $description ) && '' != $description ) {
@@ -220,22 +181,10 @@ class Jetpack_SEO {
);
}
- $meta['title'] = sprintf(
- _x( 'Posts from %1$s on %2$s', 'Posts from May 2012 on Blog Title', 'jetpack' ),
- $period,
- get_bloginfo( 'title' )
- );
-
$authors = $this->get_authors();
$meta['description'] = wp_sprintf( $template, count( $wp_query->posts ), $authors, $period );
}
- $custom_title = Jetpack_SEO_Titles::get_custom_title();
-
- if ( ! empty( $custom_title ) ) {
- $meta['title'] = $custom_title;
- }
-
/**
* Can be used to edit the default SEO tools meta tags.
*
diff --git a/plugins/jetpack/modules/shortcodes/js/jmpress.js b/plugins/jetpack/modules/shortcodes/js/jmpress.js
index b84bd0ef..429531fa 100644
--- a/plugins/jetpack/modules/shortcodes/js/jmpress.js
+++ b/plugins/jetpack/modules/shortcodes/js/jmpress.js
@@ -1438,7 +1438,7 @@
'use strict';
var $jmpress = $.jmpress,
- hashLink = "a[href^=#]";
+ hashLink = "a[href^='#']";
/* FUNCTIONS */
function randomString() {
diff --git a/plugins/jetpack/modules/shortcodes/recipe.php b/plugins/jetpack/modules/shortcodes/recipe.php
index d0d1a47b..317e3acc 100644
--- a/plugins/jetpack/modules/shortcodes/recipe.php
+++ b/plugins/jetpack/modules/shortcodes/recipe.php
@@ -16,19 +16,73 @@ class Jetpack_Recipes {
function __construct() {
add_action( 'init', array( $this, 'action_init' ) );
- // Add itemprop to allowed tags for wp_kses_post, so we can use it for better Schema compliance.
- global $allowedposttags;
- $tags = array( 'li', 'ol', 'img' );
- foreach ( $tags as $tag ) {
- if ( ! is_array( $allowedposttags[ $tag ] ) ) {
- $allowedposttags[ $tag ] = array();
+ add_filter( 'wp_kses_allowed_html', array( $this, 'add_recipes_kses_rules' ), 10, 2 );
+ }
+
+ /**
+ * Add Schema-specific attributes to our allowed tags in wp_kses,
+ * so we can have better Schema.org compliance.
+ *
+ * @param array $allowedtags Array of allowed HTML tags in recipes.
+ * @param array $context Context to judge allowed tags by.
+ */
+ function add_recipes_kses_rules( $allowedtags, $context ) {
+ if ( in_array( $context, array( '', 'post', 'data' ) ) ) :
+ // Create an array of all the tags we'd like to add the itemprop attribute to.
+ $tags = array( 'li', 'ol', 'ul', 'img', 'p', 'h3', 'time' );
+ foreach ( $tags as $tag ) {
+ $allowedtags = $this->add_kses_rule(
+ $allowedtags,
+ $tag,
+ array(
+ 'class' => array(),
+ 'itemprop' => array(),
+ 'datetime' => array(),
+ )
+ );
}
- $allowedposttags[ $tag ]['itemprop'] = array();
+
+ // Allow itemscope and itemtype for divs.
+ $allowedtags = $this->add_kses_rule(
+ $allowedtags,
+ 'div',
+ array(
+ 'class' => array(),
+ 'itemscope' => array(),
+ 'itemtype' => array(),
+ )
+ );
+ endif;
+
+ return $allowedtags;
+ }
+
+ /**
+ * Function to add a new property rule to our kses array.
+ * Used by add_recipe_kses_rules() above.
+ *
+ * @param array $all_tags Array of allowed HTML tags in recipes.
+ * @param string $tag New HTML tag to add to the array of allowed HTML.
+ * @param array $rules Array of allowed attributes for that HTML tag.
+ */
+ private function add_kses_rule( $all_tags, $tag, $rules ) {
+
+ // If the tag doesn't already exist, add it.
+ if ( ! isset( $all_tags[ $tag ] ) ) {
+ $all_tags[ $tag ] = array();
}
+
+ // Merge the new tags with existing tags.
+ $all_tags[ $tag ] = array_merge( $all_tags[ $tag ], $rules );
+
+ return $all_tags;
}
+ /**
+ * Register our shortcode and enqueue necessary files.
+ */
function action_init() {
- // Enqueue styles if [recipe] exists
+ // Enqueue styles if [recipe] exists.
add_action( 'wp_head', array( $this, 'add_scripts' ), 1 );
// Render [recipe], along with other shortcodes that can be nested within.
@@ -63,7 +117,8 @@ class Jetpack_Recipes {
wp_enqueue_style( 'jetpack-recipes-style', plugins_url( '/css/recipes.css', __FILE__ ), array(), '20130919' );
}
- wp_add_inline_style( 'jetpack-recipes-style', self::themecolor_styles() ); // add $themecolors-defined styles
+ // add $themecolors-defined styles.
+ wp_add_inline_style( 'jetpack-recipes-style', self::themecolor_styles() );
wp_enqueue_script( 'jetpack-recipes-printthis', plugins_url( '/js/recipes-printthis.js', __FILE__ ), array( 'jquery' ), '20170202' );
wp_enqueue_script( 'jetpack-recipes-js', plugins_url( '/js/recipes.js', __FILE__ ), array( 'jquery', 'jetpack-recipes-printthis' ), '20131230' );
@@ -71,25 +126,37 @@ class Jetpack_Recipes {
$title_var = wp_title( '|', false, 'right' );
$print_css_var = plugins_url( '/css/recipes-print.css', __FILE__ );
- wp_localize_script( 'jetpack-recipes-js', 'jetpack_recipes_vars', array( 'pageTitle' => $title_var, 'loadCSS' => $print_css_var ) );
+ wp_localize_script(
+ 'jetpack-recipes-js',
+ 'jetpack_recipes_vars',
+ array(
+ 'pageTitle' => $title_var,
+ 'loadCSS' => $print_css_var,
+ )
+ );
}
/**
* Our [recipe] shortcode.
* Prints recipe data styled to look good on *any* theme.
*
+ * @param array $atts Array of shortcode attributes.
+ * @param string $content Post content.
+ *
* @return string HTML for recipe shortcode.
*/
static function recipe_shortcode( $atts, $content = '' ) {
$atts = shortcode_atts(
array(
- 'title' => '', //string
- 'servings' => '', //intval
- 'time' => '', //string
- 'difficulty' => '', //string
- 'print' => '', //string
- 'image' => '', //string
- 'description' => '', //string
+ 'title' => '', // string.
+ 'servings' => '', // intval.
+ 'time' => '', // string.
+ 'difficulty' => '', // string.
+ 'print' => '', // string.
+ 'source' => '', // string.
+ 'sourceurl' => '', // string.
+ 'image' => '', // string.
+ 'description' => '', // string.
), $atts, 'recipe'
);
@@ -99,21 +166,21 @@ class Jetpack_Recipes {
/**
* The recipe output
*
+ * @param array $atts Array of shortcode attributes.
+ * @param string $content Post content.
+ *
* @return string HTML output
*/
static function recipe_shortcode_html( $atts, $content = '' ) {
- // Add itemprop to allowed tags for wp_kses_post, so we can use it for better Schema compliance.
- global $allowedtags;
- $allowedtags['li'] = array( 'itemprop' => array () );
$html = '<div class="hrecipe jetpack-recipe" itemscope itemtype="https://schema.org/Recipe">';
- // Print the recipe title if exists
+ // Print the recipe title if exists.
if ( '' !== $atts['title'] ) {
$html .= '<h3 class="jetpack-recipe-title" itemprop="name">' . esc_html( $atts['title'] ) . '</h3>';
}
- // Print the recipe meta if exists
+ // Print the recipe meta if exists.
if ( '' !== $atts['servings'] || '' != $atts['time'] || '' != $atts['difficulty'] || '' != $atts['print'] ) {
$html .= '<ul class="jetpack-recipe-meta">';
@@ -126,10 +193,20 @@ class Jetpack_Recipes {
}
if ( '' !== $atts['time'] ) {
+ // Get a time that's supported by Schema.org.
+ $duration = WPCOM_JSON_API_Date::format_duration( $atts['time'] );
+ // If no duration can be calculated, let's output what the user provided.
+ if ( empty( $duration ) ) {
+ $duration = $atts['time'];
+ }
+
$html .= sprintf(
- '<li class="jetpack-recipe-time" itemprop="totalTime"><strong>%1$s: </strong>%2$s</li>',
+ '<li class="jetpack-recipe-time">
+ <time itemprop="totalTime" datetime="%3$s"><strong>%1$s: </strong>%2$s</time>
+ </li>',
esc_html_x( 'Time', 'recipe', 'jetpack' ),
- esc_html( $atts['time'] )
+ esc_html( $atts['time'] ),
+ esc_attr( $duration )
);
}
@@ -141,6 +218,30 @@ class Jetpack_Recipes {
);
}
+ if ( '' !== $atts['source'] ) {
+ $html .= sprintf(
+ '<li class="jetpack-recipe-source"><strong>%1$s: </strong>',
+ esc_html_x( 'Source', 'recipe', 'jetpack' )
+ );
+
+ if ( '' !== $atts['sourceurl'] ) :
+ // Show the link if we have one.
+ $html .= sprintf(
+ '<a href="%2$s">%1$s</a>',
+ esc_html( $atts['source'] ),
+ esc_url( $atts['sourceurl'] )
+ );
+ else :
+ // Skip the link.
+ $html .= sprintf(
+ '%1$s',
+ esc_html( $atts['source'] )
+ );
+ endif;
+
+ $html .= '</li>';
+ }
+
if ( 'false' !== $atts['print'] ) {
$html .= sprintf(
'<li class="jetpack-recipe-print"><a href="#">%1$s</a></li>',
@@ -149,12 +250,12 @@ class Jetpack_Recipes {
}
$html .= '</ul>';
- }
+ } // End if().
// Output the image, if we have one.
if ( '' !== $atts['image'] ) {
$html .= sprintf(
- '<img class="jetpack-recipe-image" itemprop="thumbnailUrl" src="%1$s" />',
+ '<img class="jetpack-recipe-image" itemprop="image" src="%1$s" />',
esc_url( $atts['image'] )
);
}
@@ -162,41 +263,44 @@ class Jetpack_Recipes {
// Output the description, if we have one.
if ( '' !== $atts['description'] ) {
$html .= sprintf(
- '<p class="jetpack-recipe-description">%1$s</p>',
+ '<p class="jetpack-recipe-description" itemprop="description">%1$s</p>',
esc_html( $atts['description'] )
);
}
- // Print content between codes
+ // Print content between codes.
$html .= '<div class="jetpack-recipe-content">' . do_shortcode( $content ) . '</div>';
- // Close it up
+ // Close it up.
$html .= '</div>';
- // If there is a recipe within a recipe, remove the shortcode
+ // If there is a recipe within a recipe, remove the shortcode.
if ( has_shortcode( $html, 'recipe' ) ) {
remove_shortcode( 'recipe' );
}
- // Sanitize html
+ // Sanitize html.
$html = wp_kses_post( $html );
- // Return the HTML block
+ // Return the HTML block.
return $html;
}
/**
* Our [recipe-notes] shortcode.
- * Outputs notes, styled in a div.
+ * Outputs ingredients, styled in a div.
+ *
+ * @param array $atts Array of shortcode attributes.
+ * @param string $content Post content.
*
* @return string HTML for recipe notes shortcode.
*/
static function recipe_notes_shortcode( $atts, $content = '' ) {
$atts = shortcode_atts( array(
- 'title' => '', //string
+ 'title' => '', // string.
), $atts, 'recipe-notes' );
- $html ='';
+ $html = '';
// Print a title if one exists.
if ( '' !== $atts['title'] ) {
@@ -221,11 +325,14 @@ class Jetpack_Recipes {
* Our [recipe-ingredients] shortcode.
* Outputs notes, styled in a div.
*
+ * @param array $atts Array of shortcode attributes.
+ * @param string $content Post content.
+ *
* @return string HTML for recipe ingredients shortcode.
*/
static function recipe_ingredients_shortcode( $atts, $content = '' ) {
$atts = shortcode_atts( array(
- 'title' => esc_html_x( 'Ingredients', 'recipe', 'jetpack' ), //string
+ 'title' => esc_html_x( 'Ingredients', 'recipe', 'jetpack' ), // string.
), $atts, 'recipe-ingredients' );
$html = '<div class="jetpack-recipe-ingredients">';
@@ -256,10 +363,13 @@ class Jetpack_Recipes {
* And we'll magically convert it to a list. This has the added benefit
* of including itemprops for the recipe schema.
*
+ * @param string $content HTML content.
+ * @param string $type Type of list.
+ *
* @return string content formatted as a list item
*/
static function output_list_content( $content, $type ) {
- $html ='';
+ $html = '';
switch ( $type ) {
case 'directions' :
@@ -268,8 +378,8 @@ class Jetpack_Recipes {
$listtype = 'ol';
break;
case 'ingredients' :
- $list_item_replacement = '<li class="jetpack-recipe-ingredient">${1}</li>';
- $itemprop = ' itemprop="recipeIngredient"';
+ $list_item_replacement = '<li class="jetpack-recipe-ingredient" itemprop="recipeIngredient">${1}</li>';
+ $itemprop = '';
$listtype = 'ul';
break;
default:
@@ -285,11 +395,11 @@ class Jetpack_Recipes {
strpos( $content, '-' ) !== false ||
strpos( $content, '*' ) !== false ||
strpos( $content, '#' ) !== false ||
- strpos( $content, '–' ) !== false || // ndash
- strpos( $content, '—' ) !== false || // mdash
+ strpos( $content, '–' ) !== false || // ndash.
+ strpos( $content, '—' ) !== false || // mdash.
preg_match( '/\d+\.\s/', $content )
) {
- // Remove breaks and extra whitespace
+ // Remove breaks and extra whitespace.
$content = str_replace( "<br />\n", "\n", $content );
$content = trim( $content );
@@ -328,13 +438,16 @@ class Jetpack_Recipes {
/**
* Our [recipe-directions] shortcode.
- * Outputs notes, styled in a div.
+ * Outputs directions, styled in a div.
*
- * @return string HTML for recipe notes shortcode.
+ * @param array $atts Array of shortcode attributes.
+ * @param string $content Post content.
+ *
+ * @return string HTML for recipe directions shortcode.
*/
static function recipe_directions_shortcode( $atts, $content = '' ) {
$atts = shortcode_atts( array(
- 'title' => esc_html_x( 'Directions', 'recipe', 'jetpack' ), //string
+ 'title' => esc_html_x( 'Directions', 'recipe', 'jetpack' ), // string.
), $atts, 'recipe-directions' );
$html = '<div class="jetpack-recipe-directions">';
diff --git a/plugins/jetpack/modules/sitemaps/sitemap-builder.php b/plugins/jetpack/modules/sitemaps/sitemap-builder.php
index c6cb1315..cfd7b9a1 100644
--- a/plugins/jetpack/modules/sitemaps/sitemap-builder.php
+++ b/plugins/jetpack/modules/sitemaps/sitemap-builder.php
@@ -1159,7 +1159,7 @@ FOOTER
);
}
- $url = get_permalink( $post );
+ $url = esc_url( get_permalink( $post ) );
/*
* Spec requires the URL to be <=2048 bytes.
@@ -1236,11 +1236,11 @@ FOOTER
);
}
- $url = wp_get_attachment_url( $post->ID );
+ $url = esc_url( wp_get_attachment_url( $post->ID ) );
- $parent_url = get_permalink( get_post( $post->post_parent ) );
+ $parent_url = esc_url( get_permalink( get_post( $post->post_parent ) ) );
if ( '' == $parent_url ) { // WPCS: loose comparison ok.
- $parent_url = get_permalink( $post );
+ $parent_url = esc_url( get_permalink( $post ) );
}
$item_array = array(
@@ -1252,15 +1252,15 @@ FOOTER
),
),
);
-
- $title = esc_html( $post->post_title );
+ /** This filter is already documented in core/wp-includes/feed.php */
+ $title = apply_filters( 'the_title_rss', $post->post_title );
if ( '' !== $title ) {
- $item_array['url']['image:image']['image:title'] = $title;
+ $item_array['url']['image:image']['image:title'] = htmlentities( $title );
}
-
- $caption = esc_html( $post->post_excerpt );
+ /** This filter is already documented in core/wp-includes/feed.php */
+ $caption = apply_filters( 'the_excerpt_rss', $post->post_excerpt );
if ( '' !== $caption ) {
- $item_array['url']['image:image']['image:caption'] = $caption;
+ $item_array['url']['image:image']['image:caption'] = "<![CDATA[" . $caption . "]]>";
}
/**
@@ -1318,20 +1318,29 @@ FOOTER
);
}
- $parent_url = get_permalink( get_post( $post->post_parent ) );
+ $parent_url = esc_url( get_permalink( get_post( $post->post_parent ) ) );
if ( '' == $parent_url ) { // WPCS: loose comparison ok.
- $parent_url = get_permalink( $post );
+ $parent_url = esc_url( get_permalink( $post ) );
}
+ // Prepare the content like get_the_content_feed()
+ $content = $post->post_content;
+ /** This filter is already documented in core/wp-includes/post-template.php */
+ $content = apply_filters( 'the_content', $content );
+ $content = str_replace(']]>', ']]&gt;', $content);
+ /** This filter is already documented in core/wp-includes/feed.php */
+ $content = apply_filters( 'the_content_feed', $content, 'rss2' );
+
$item_array = array(
'url' => array(
'loc' => $parent_url,
'lastmod' => jp_sitemap_datetime( $post->post_modified_gmt ),
'video:video' => array(
- 'video:title' => esc_html( $post->post_title ),
+ /** This filter is already documented in core/wp-includes/feed.php */
+ 'video:title' => apply_filters( 'the_title_rss', $post->post_title ),
'video:thumbnail_loc' => '',
- 'video:description' => esc_html( $post->post_content ),
- 'video:content_loc' => wp_get_attachment_url( $post->ID ),
+ 'video:description' => '<![CDATA[' . $content . ']]>',
+ 'video:content_loc' => esc_url( wp_get_attachment_url( $post->ID ) ),
),
),
);
@@ -1424,7 +1433,8 @@ FOOTER
'news:name' => esc_html( get_bloginfo( 'name' ) ),
'news:language' => $language,
),
- 'news:title' => esc_html( $post->post_title ),
+ /** This filter is already documented in core/wp-includes/feed.php */
+ 'news:title' => apply_filters( 'the_title_rss', $post->post_title ),
'news:publication_date' => jp_sitemap_datetime( $post->post_date_gmt ),
'news:genres' => 'Blog',
),
diff --git a/plugins/jetpack/modules/stats.php b/plugins/jetpack/modules/stats.php
index ebfa5326..cb56ef7d 100644
--- a/plugins/jetpack/modules/stats.php
+++ b/plugins/jetpack/modules/stats.php
@@ -151,7 +151,7 @@ function stats_template_redirect() {
// Should we be counting this user's views?
if ( ! empty( $current_user->ID ) ) {
$count_roles = stats_get_option( 'count_roles' );
- if ( ! array_intersect( $current_user->roles, $count_roles ) ) {
+ if ( ! is_array( $count_roles ) || ! array_intersect( $current_user->roles, $count_roles ) ) {
return;
}
}
diff --git a/plugins/jetpack/modules/theme-tools/featured-content.php b/plugins/jetpack/modules/theme-tools/featured-content.php
index 58986835..7fdfa70c 100644
--- a/plugins/jetpack/modules/theme-tools/featured-content.php
+++ b/plugins/jetpack/modules/theme-tools/featured-content.php
@@ -641,4 +641,17 @@ class Featured_Content {
Featured_Content::setup();
+/**
+ * Adds the featured content plugin to the set of files for which action
+ * handlers should be copied when the theme context is loaded by the REST API.
+ *
+ * @param array $copy_dirs Copy paths with actions to be copied
+ * @return array Copy paths with featured content plugin
+ */
+function wpcom_rest_api_featured_content_copy_plugin_actions( $copy_dirs ) {
+ $copy_dirs[] = __FILE__;
+ return $copy_dirs;
+}
+add_action( 'restapi_theme_action_copy_dirs', 'wpcom_rest_api_featured_content_copy_plugin_actions' );
+
} // end if ( ! class_exists( 'Featured_Content' ) && isset( $GLOBALS['pagenow'] ) && 'plugins.php' !== $GLOBALS['pagenow'] ) {
diff --git a/plugins/jetpack/modules/theme-tools/social-links.php b/plugins/jetpack/modules/theme-tools/social-links.php
index 90cf0258..5f477cd8 100644
--- a/plugins/jetpack/modules/theme-tools/social-links.php
+++ b/plugins/jetpack/modules/theme-tools/social-links.php
@@ -122,7 +122,7 @@ class Social_Links {
'priority' => 35,
) );
- foreach ( array_keys( $this->publicize->get_services() ) as $service ) {
+ foreach ( array_keys( $this->publicize->get_services( 'all' ) ) as $service ) {
$choices = $this->get_customize_select( $service );
if ( empty( $choices ) ) {
diff --git a/plugins/jetpack/modules/theme-tools/social-menu/icon-functions.php b/plugins/jetpack/modules/theme-tools/social-menu/icon-functions.php
index 45cf95e3..f19e1884 100644
--- a/plugins/jetpack/modules/theme-tools/social-menu/icon-functions.php
+++ b/plugins/jetpack/modules/theme-tools/social-menu/icon-functions.php
@@ -3,6 +3,7 @@
* SVG icons related functions and filters
*/
+if ( ! function_exists( 'jetpack_social_menu_include_svg_icons' ) ) :
/**
* Add SVG definitions to the footer.
*/
@@ -16,7 +17,9 @@ function jetpack_social_menu_include_svg_icons() {
}
}
add_action( 'wp_footer', 'jetpack_social_menu_include_svg_icons', 9999 );
+endif;
+if ( ! function_exists( 'jetpack_social_menu_get_svg' ) ) :
/**
* Return SVG markup.
*
@@ -40,8 +43,8 @@ function jetpack_social_menu_get_svg( $args = array() ) {
// Set defaults.
$defaults = array(
- 'icon' => '',
- 'fallback' => false,
+ 'icon' => '',
+ 'fallback' => false,
);
// Parse args.
@@ -71,7 +74,9 @@ function jetpack_social_menu_get_svg( $args = array() ) {
return $svg;
}
+endif;
+if ( ! function_exists( 'jetpack_social_menu_nav_menu_social_icons' ) ) :
/**
* Display SVG icons in social links menu.
*
@@ -97,7 +102,9 @@ function jetpack_social_menu_nav_menu_social_icons( $item_output, $item, $depth,
return $item_output;
}
add_filter( 'walker_nav_menu_start_el', 'jetpack_social_menu_nav_menu_social_icons', 10, 4 );
+endif;
+if ( ! function_exists( 'jetpack_social_menu_social_links_icons' ) ) :
/**
* Returns an array of supported social links (URL and icon name).
*
@@ -106,6 +113,7 @@ add_filter( 'walker_nav_menu_start_el', 'jetpack_social_menu_nav_menu_social_ico
function jetpack_social_menu_social_links_icons() {
// Supported social links icons.
$social_links_icons = array(
+ '500px.com' => '500px',
'amazon.cn' => 'amazon',
'amazon.in' => 'amazon',
'amazon.fr' => 'amazon',
@@ -125,16 +133,19 @@ function jetpack_social_menu_social_links_icons() {
'digg.com' => 'digg',
'dribbble.com' => 'dribbble',
'dropbox.com' => 'dropbox',
+ 'etsy.com' => 'etsy',
'facebook.com' => 'facebook',
'/feed/' => 'feed',
'flickr.com' => 'flickr',
'foursquare.com' => 'foursquare',
+ 'goodreads.com' => 'goodreads',
'plus.google.com' => 'google-plus',
'google.com' => 'google',
'github.com' => 'github',
'instagram.com' => 'instagram',
'linkedin.com' => 'linkedin',
'mailto:' => 'mail',
+ 'meetup.com' => 'meetup',
'medium.com' => 'medium',
'pinterest.com' => 'pinterest',
'getpocket.com' => 'pocket',
@@ -159,3 +170,4 @@ function jetpack_social_menu_social_links_icons() {
return $social_links_icons;
}
+endif;
diff --git a/plugins/jetpack/modules/theme-tools/social-menu/social-menu.svg b/plugins/jetpack/modules/theme-tools/social-menu/social-menu.svg
index 5dc956e1..2cc0da95 100644
--- a/plugins/jetpack/modules/theme-tools/social-menu/social-menu.svg
+++ b/plugins/jetpack/modules/theme-tools/social-menu/social-menu.svg
@@ -1,5 +1,8 @@
<svg style="position: absolute; width: 0; height: 0; overflow: hidden;" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
+<symbol id="icon-500px" viewBox="0 0 24 24">
+<path d="M6.94026,15.1412c.00437.01213.108.29862.168.44064a6.55008,6.55008,0,1,0,6.03191-9.09557,6.68654,6.68654,0,0,0-2.58357.51467A8.53914,8.53914,0,0,0,8.21268,8.61344L8.209,8.61725V3.22948l9.0504-.00008c.32934-.0036.32934-.46353.32934-.61466s0-.61091-.33035-.61467L7.47248,2a.43.43,0,0,0-.43131.42692v7.58355c0,.24466.30476.42131.58793.4819.553.11812.68074-.05864.81617-.2457l.018-.02481A10.52673,10.52673,0,0,1,9.32258,9.258a5.35268,5.35268,0,1,1,7.58985,7.54976,5.417,5.417,0,0,1-3.80867,1.56365,5.17483,5.17483,0,0,1-2.69822-.74478l.00342-4.61111a2.79372,2.79372,0,0,1,.71372-1.78792,2.61611,2.61611,0,0,1,1.98282-.89477,2.75683,2.75683,0,0,1,1.95525.79477,2.66867,2.66867,0,0,1,.79656,1.909,2.724,2.724,0,0,1-2.75849,2.748,4.94651,4.94651,0,0,1-.86254-.13719c-.31234-.093-.44519.34058-.48892.48349-.16811.54966.08453.65862.13687.67489a3.75751,3.75751,0,0,0,1.25234.18375,3.94634,3.94634,0,1,0-2.82444-6.742,3.67478,3.67478,0,0,0-1.13028,2.584l-.00041.02323c-.0035.11667-.00579,2.881-.00644,3.78811l-.00407-.00451a6.18521,6.18521,0,0,1-1.0851-1.86092c-.10544-.27856-.34358-.22925-.66857-.12917-.14192.04372-.57386.17677-.47833.489Zm4.65165-1.08338a.51346.51346,0,0,0,.19513.31818l.02276.022a.52945.52945,0,0,0,.3517.18416.24242.24242,0,0,0,.16577-.0611c.05473-.05082.67382-.67812.73287-.738l.69041.68819a.28978.28978,0,0,0,.21437.11032.53239.53239,0,0,0,.35708-.19486c.29792-.30419.14885-.46821.07676-.54751l-.69954-.69975.72952-.73469c.16-.17311.01874-.35708-.12218-.498-.20461-.20461-.402-.25742-.52855-.14083l-.7254.72665-.73354-.73375a.20128.20128,0,0,0-.14179-.05695.54135.54135,0,0,0-.34379.19648c-.22561.22555-.274.38149-.15656.5059l.73374.7315-.72942.73072A.26589.26589,0,0,0,11.59191,14.05782Zm1.59866-9.915A8.86081,8.86081,0,0,0,9.854,4.776a.26169.26169,0,0,0-.16938.22759.92978.92978,0,0,0,.08619.42094c.05682.14524.20779.531.50006.41955a8.40969,8.40969,0,0,1,2.91968-.55484,7.87875,7.87875,0,0,1,3.086.62286,8.61817,8.61817,0,0,1,2.30562,1.49315.2781.2781,0,0,0,.18318.07586c.15529,0,.30425-.15253.43167-.29551.21268-.23861.35873-.4369.1492-.63538a8.50425,8.50425,0,0,0-2.62312-1.694A9.0177,9.0177,0,0,0,13.19058,4.14283ZM19.50945,18.6236h0a.93171.93171,0,0,0-.36642-.25406.26589.26589,0,0,0-.27613.06613l-.06943.06929A7.90606,7.90606,0,0,1,7.60639,18.505a7.57284,7.57284,0,0,1-1.696-2.51537,8.58715,8.58715,0,0,1-.5147-1.77754l-.00871-.04864c-.04939-.25873-.28755-.27684-.62981-.22448-.14234.02178-.5755.088-.53426.39969l.001.00712a9.08807,9.08807,0,0,0,15.406,4.99094c.00193-.00192.04753-.04718.0725-.07436C19.79425,19.16234,19.87422,18.98728,19.50945,18.6236Z"/>
+</symbol>
<symbol id="icon-amazon" viewBox="0 0 24 24">
<path d="M13.582,8.182C11.934,8.367,9.78,8.49,8.238,9.166c-1.781,0.769-3.03,2.337-3.03,4.644 c0,2.953,1.86,4.429,4.253,4.429c2.02,0,3.125-0.477,4.685-2.065c0.516,0.747,0.685,1.109,1.629,1.894 c0.212,0.114,0.483,0.103,0.672-0.066l0.006,0.006c0.567-0.505,1.599-1.401,2.18-1.888c0.231-0.188,0.19-0.496,0.009-0.754 c-0.52-0.718-1.072-1.303-1.072-2.634V8.305c0-1.876,0.133-3.599-1.249-4.891C15.23,2.369,13.422,2,12.04,2 C9.336,2,6.318,3.01,5.686,6.351C5.618,6.706,5.877,6.893,6.109,6.945l2.754,0.298C9.121,7.23,9.308,6.977,9.357,6.72 c0.236-1.151,1.2-1.706,2.284-1.706c0.584,0,1.249,0.215,1.595,0.738c0.398,0.584,0.346,1.384,0.346,2.061V8.182z M13.049,14.088 c-0.451,0.8-1.169,1.291-1.967,1.291c-1.09,0-1.728-0.83-1.728-2.061c0-2.42,2.171-2.86,4.227-2.86v0.615 C13.582,12.181,13.608,13.104,13.049,14.088z M20.683,19.339C18.329,21.076,14.917,22,11.979,22c-4.118,0-7.826-1.522-10.632-4.057 c-0.22-0.199-0.024-0.471,0.241-0.317c3.027,1.762,6.771,2.823,10.639,2.823c2.608,0,5.476-0.541,8.115-1.66 C20.739,18.62,21.072,19.051,20.683,19.339z M21.336,21.043c-0.194,0.163-0.379,0.076-0.293-0.139 c0.284-0.71,0.92-2.298,0.619-2.684c-0.301-0.386-1.99-0.183-2.749-0.092c-0.23,0.027-0.266-0.173-0.059-0.319 c1.348-0.946,3.555-0.673,3.811-0.356C22.925,17.773,22.599,19.986,21.336,21.043z"/>
</symbol>
@@ -30,6 +33,9 @@
<symbol id="icon-dropbox" viewBox="0 0 24 24">
<path d="M12,6.134L6.069,9.797L2,6.54l5.883-3.843L12,6.134z M2,13.054l5.883,3.843L12,13.459L6.069,9.797L2,13.054z M12,13.459 l4.116,3.439L22,13.054l-4.069-3.257L12,13.459z M22,6.54l-5.884-3.843L12,6.134l5.931,3.663L22,6.54z M12.011,14.2l-4.129,3.426 l-1.767-1.153v1.291l5.896,3.539l5.897-3.539v-1.291l-1.769,1.153L12.011,14.2z"/>
</symbol>
+<symbol id="icon-etsy" viewBox="0 0 24 24">
+<path d="M9.16033,4.038c0-.27174.02717-.43478.48913-.43478h6.22283c1.087,0,1.68478.92391,2.11957,2.663l.35326,1.38587h1.05978C19.59511,3.712,19.75815,2,19.75815,2s-2.663.29891-4.23913.29891h-7.962L3.29076,2.163v1.1413L4.731,3.57609c1.00543.19022,1.25.40761,1.33152,1.33152,0,0,.08152,2.71739.08152,7.20109s-.08152,7.17391-.08152,7.17391c0,.81522-.32609,1.11413-1.33152,1.30435l-1.44022.27174V22l4.2663-.13587h7.11957c1.60326,0,5.32609.13587,5.32609.13587.08152-.97826.625-5.40761.70652-5.89674H19.7038L18.644,18.52174c-.84239,1.90217-2.06522,2.038-3.42391,2.038H11.1712c-1.3587,0-2.01087-.54348-2.01087-1.712V12.65217s3.0163,0,3.99457.08152c.76087.05435,1.22283.27174,1.46739,1.33152l.32609,1.413h1.16848l-.08152-3.55978.163-3.587H15.02989l-.38043,1.57609c-.24457,1.03261-.40761,1.22283-1.46739,1.33152-1.38587.13587-4.02174.1087-4.02174.1087Z"/>
+</symbol>
<symbol id="icon-facebook" viewBox="0 0 24 24">
<path d="M20.007,3H3.993C3.445,3,3,3.445,3,3.993v16.013C3,20.555,3.445,21,3.993,21h8.621v-6.971h-2.346v-2.717h2.346V9.31 c0-2.325,1.42-3.591,3.494-3.591c0.993,0,1.847,0.074,2.096,0.107v2.43l-1.438,0.001c-1.128,0-1.346,0.536-1.346,1.323v1.734h2.69 l-0.35,2.717h-2.34V21h4.587C20.555,21,21,20.555,21,20.007V3.993C21,3.445,20.555,3,20.007,3z"/>
</symbol>
@@ -42,6 +48,9 @@
<symbol id="icon-foursquare" viewBox="0 0 24 24">
<path d="M17.573,2c0,0-9.197,0-10.668,0S5,3.107,5,3.805s0,16.948,0,16.948c0,0.785,0.422,1.077,0.66,1.172 c0.238,0.097,0.892,0.177,1.285-0.275c0,0,5.035-5.843,5.122-5.93c0.132-0.132,0.132-0.132,0.262-0.132h3.26 c1.368,0,1.588-0.977,1.732-1.552c0.078-0.318,0.692-3.428,1.225-6.122l0.675-3.368C19.56,2.893,19.14,2,17.573,2z M16.495,7.22 c-0.053,0.252-0.372,0.518-0.665,0.518c-0.293,0-4.157,0-4.157,0c-0.467,0-0.802,0.318-0.802,0.787v0.508 c0,0.467,0.337,0.798,0.805,0.798c0,0,3.197,0,3.528,0s0.655,0.362,0.583,0.715c-0.072,0.353-0.407,2.102-0.448,2.295 c-0.04,0.193-0.262,0.523-0.655,0.523c-0.33,0-2.88,0-2.88,0c-0.523,0-0.683,0.068-1.033,0.503 c-0.35,0.437-3.505,4.223-3.505,4.223c-0.032,0.035-0.063,0.027-0.063-0.015V4.852c0-0.298,0.26-0.648,0.648-0.648 c0,0,8.228,0,8.562,0c0.315,0,0.61,0.297,0.528,0.683L16.495,7.22z"/>
</symbol>
+<symbol id="icon-goodreads" viewBox="0 0 24 24">
+<path d="M17.3,17.5c-0.2,0.8-0.5,1.4-1,1.9c-0.4,0.5-1,0.9-1.7,1.2C13.9,20.9,13.1,21,12,21c-0.6,0-1.3-0.1-1.9-0.2 c-0.6-0.1-1.1-0.4-1.6-0.7c-0.5-0.3-0.9-0.7-1.2-1.2c-0.3-0.5-0.5-1.1-0.5-1.7h1.5c0.1,0.5,0.2,0.9,0.5,1.2 c0.2,0.3,0.5,0.6,0.9,0.8c0.3,0.2,0.7,0.3,1.1,0.4c0.4,0.1,0.8,0.1,1.2,0.1c1.4,0,2.5-0.4,3.1-1.2c0.6-0.8,1-2,1-3.5v-1.7h0 c-0.4,0.8-0.9,1.4-1.6,1.9c-0.7,0.5-1.5,0.7-2.4,0.7c-1,0-1.9-0.2-2.6-0.5C8.7,15,8.1,14.5,7.7,14c-0.5-0.6-0.8-1.3-1-2.1 c-0.2-0.8-0.3-1.6-0.3-2.5c0-0.9,0.1-1.7,0.4-2.5c0.3-0.8,0.6-1.5,1.1-2c0.5-0.6,1.1-1,1.8-1.4C10.3,3.2,11.1,3,12,3 c0.5,0,0.9,0.1,1.3,0.2c0.4,0.1,0.8,0.3,1.1,0.5c0.3,0.2,0.6,0.5,0.9,0.8c0.3,0.3,0.5,0.6,0.6,1h0V3.4h1.5V15 C17.6,15.9,17.5,16.7,17.3,17.5z M13.8,14.1c0.5-0.3,0.9-0.7,1.3-1.1c0.3-0.5,0.6-1,0.8-1.6c0.2-0.6,0.3-1.2,0.3-1.9 c0-0.6-0.1-1.2-0.2-1.9c-0.1-0.6-0.4-1.2-0.7-1.7c-0.3-0.5-0.7-0.9-1.3-1.2c-0.5-0.3-1.1-0.5-1.9-0.5s-1.4,0.2-1.9,0.5 c-0.5,0.3-1,0.7-1.3,1.2C8.5,6.4,8.3,7,8.1,7.6C8,8.2,7.9,8.9,7.9,9.5c0,0.6,0.1,1.3,0.2,1.9C8.3,12,8.6,12.5,8.9,13 c0.3,0.5,0.8,0.8,1.3,1.1c0.5,0.3,1.1,0.4,1.9,0.4C12.7,14.5,13.3,14.4,13.8,14.1z"/>
+</symbol>
<symbol id="icon-google-plus" viewBox="0 0 24 24">
<path d="M8,11h6.61c0.06,0.35,0.11,0.7,0.11,1.16c0,4-2.68,6.84-6.72,6.84c-3.87,0-7-3.13-7-7s3.13-7,7-7 c1.89,0,3.47,0.69,4.69,1.83l-1.9,1.83C10.27,8.16,9.36,7.58,8,7.58c-2.39,0-4.34,1.98-4.34,4.42S5.61,16.42,8,16.42 c2.77,0,3.81-1.99,3.97-3.02H8V11L8,11z M23,11h-2V9h-2v2h-2v2h2v2h2v-2h2"/>
</symbol>
@@ -61,6 +70,9 @@ c0.091-0.647,0.349-1.086,0.635-1.337c-2.22-0.251-4.555-1.111-4.555-4.943c0-1.091
<symbol id="icon-mail" viewBox="0 0 24 24">
<path d="M20,4H4C2.895,4,2,4.895,2,6v12c0,1.105,0.895,2,2,2h16c1.105,0,2-0.895,2-2V6C22,4.895,21.105,4,20,4z M20,8.236l-8,4.882 L4,8.236V6h16V8.236z"/>
</symbol>
+<symbol id="icon-meetup" viewBox="0 0 24 24">
+<path d="M19.24775,14.722a3.57032,3.57032,0,0,1-2.94457,3.52073,3.61886,3.61886,0,0,1-.64652.05634c-.07314-.0008-.10187.02846-.12507.09547A2.38881,2.38881,0,0,1,13.49453,20.094a2.33092,2.33092,0,0,1-1.827-.50716.13635.13635,0,0,0-.19878-.00408,3.191,3.191,0,0,1-2.104.60248,3.26309,3.26309,0,0,1-3.00324-2.71993,2.19076,2.19076,0,0,1-.03512-.30865c-.00156-.08579-.03413-.1189-.11608-.13493a2.86421,2.86421,0,0,1-1.23189-.56111,2.945,2.945,0,0,1-1.166-2.05749,2.97484,2.97484,0,0,1,.87524-2.50774.112.112,0,0,0,.02091-.16107,2.7213,2.7213,0,0,1-.36648-1.48A2.81256,2.81256,0,0,1,6.57673,7.58838a.35764.35764,0,0,0,.28869-.22819,4.2208,4.2208,0,0,1,6.02892-1.90111.25161.25161,0,0,0,.22023.0243,3.65608,3.65608,0,0,1,3.76031.90678A3.57244,3.57244,0,0,1,17.95918,8.626a2.97339,2.97339,0,0,1,.01829.57356.10637.10637,0,0,0,.0853.12792,1.97669,1.97669,0,0,1,1.27939,1.33733,2.00266,2.00266,0,0,1-.57112,2.12652c-.05284.05166-.04168.08328-.01173.13489A3.51189,3.51189,0,0,1,19.24775,14.722Zm-6.35959-.27836a1.6984,1.6984,0,0,0,1.14556,1.61113,3.82039,3.82039,0,0,0,1.036.17935,1.46888,1.46888,0,0,0,.73509-.12255.44082.44082,0,0,0,.26057-.44274.45312.45312,0,0,0-.29211-.43375.97191.97191,0,0,0-.20678-.063c-.21326-.03806-.42754-.0701-.63973-.11215a.54787.54787,0,0,1-.50172-.60926,2.75864,2.75864,0,0,1,.1773-.901c.1763-.535.414-1.045.64183-1.55913A12.686,12.686,0,0,0,15.85,10.47863a1.58461,1.58461,0,0,0,.04861-.87208,1.04531,1.04531,0,0,0-.85432-.83981,1.60658,1.60658,0,0,0-1.23654.16594.27593.27593,0,0,1-.36286-.03413c-.085-.0747-.16594-.15379-.24918-.23055a.98682.98682,0,0,0-1.33577-.04933,6.1468,6.1468,0,0,1-.4989.41615.47762.47762,0,0,1-.51535.03566c-.17448-.09307-.35512-.175-.53531-.25665a1.74949,1.74949,0,0,0-.56476-.2016,1.69943,1.69943,0,0,0-1.61654.91787,8.05815,8.05815,0,0,0-.32952.80126c-.45471,1.2557-.82507,2.53825-1.20838,3.81639a1.24151,1.24151,0,0,0,.51532,1.44389,1.42659,1.42659,0,0,0,1.22008.17166,1.09728,1.09728,0,0,0,.66994-.69764c.44145-1.04111.839-2.09989,1.25981-3.14926.11581-.28876.22792-.57874.35078-.86438a.44548.44548,0,0,1,.69189-.19539.50521.50521,0,0,1,.15044.43836,1.75625,1.75625,0,0,1-.14731.50453c-.27379.69219-.55265,1.38236-.82766,2.074a2.0836,2.0836,0,0,0-.14038.42876.50719.50719,0,0,0,.27082.57722.87236.87236,0,0,0,.66145.02739.99137.99137,0,0,0,.53406-.532q.61571-1.20914,1.228-2.42031.28423-.55863.57585-1.1133a.87189.87189,0,0,1,.29055-.35253.34987.34987,0,0,1,.37634-.01265.30291.30291,0,0,1,.12434.31459.56716.56716,0,0,1-.04655.1915c-.05318.12739-.10286.25669-.16183.38156-.34118.71775-.68754,1.43273-1.02568,2.152A2.00213,2.00213,0,0,0,12.88816,14.44366Zm4.78568,5.28972a.88573.88573,0,0,0-1.77139.00465.8857.8857,0,0,0,1.77139-.00465Zm-14.83838-7.296a.84329.84329,0,1,0,.00827-1.68655.8433.8433,0,0,0-.00827,1.68655Zm10.366-9.43673a.83506.83506,0,1,0-.0091,1.67.83505.83505,0,0,0,.0091-1.67Zm6.85014,5.22a.71651.71651,0,0,0-1.433.0093.71656.71656,0,0,0,1.433-.0093ZM5.37528,6.17908A.63823.63823,0,1,0,6.015,5.54483.62292.62292,0,0,0,5.37528,6.17908Zm6.68214,14.80843a.54949.54949,0,1,0-.55052.541A.54556.54556,0,0,0,12.05742,20.98752Zm8.53235-8.49689a.54777.54777,0,0,0-.54027.54023.53327.53327,0,0,0,.532.52293.51548.51548,0,0,0,.53272-.5237A.53187.53187,0,0,0,20.58977,12.49063ZM7.82846,2.4715a.44927.44927,0,1,0,.44484.44766A.43821.43821,0,0,0,7.82846,2.4715Zm13.775,7.60492a.41186.41186,0,0,0-.40065.39623.40178.40178,0,0,0,.40168.40168A.38994.38994,0,0,0,22,10.48172.39946.39946,0,0,0,21.60349,10.07642ZM5.79193,17.96207a.40469.40469,0,0,0-.397-.39646.399.399,0,0,0-.396.405.39234.39234,0,0,0,.39939.389A.39857.39857,0,0,0,5.79193,17.96207Z"/>
+</symbol>
<symbol id="icon-medium" viewBox="0 0 24 24">
<path d="M20.962,7.257l-5.457,8.867l-3.923-6.375l3.126-5.08c0.112-0.182,0.319-0.286,0.527-0.286c0.05,0,0.1,0.008,0.149,0.02 c0.039,0.01,0.078,0.023,0.114,0.041l5.43,2.715l0.006,0.003c0.004,0.002,0.007,0.006,0.011,0.008 C20.971,7.191,20.98,7.227,20.962,7.257z M9.86,8.592v5.783l5.14,2.57L9.86,8.592z M15.772,17.331l4.231,2.115 C20.554,19.721,21,19.529,21,19.016V8.835L15.772,17.331z M8.968,7.178L3.665,4.527C3.569,4.479,3.478,4.456,3.395,4.456 C3.163,4.456,3,4.636,3,4.938v11.45c0,0.306,0.224,0.669,0.498,0.806l4.671,2.335c0.12,0.06,0.234,0.088,0.337,0.088 c0.29,0,0.494-0.225,0.494-0.602V7.231C9,7.208,8.988,7.188,8.968,7.178z"/>
</symbol>
diff --git a/plugins/jetpack/modules/videopress/class.jetpack-videopress.php b/plugins/jetpack/modules/videopress/class.jetpack-videopress.php
index c765d37a..46c12a28 100644
--- a/plugins/jetpack/modules/videopress/class.jetpack-videopress.php
+++ b/plugins/jetpack/modules/videopress/class.jetpack-videopress.php
@@ -52,6 +52,8 @@ class Jetpack_VideoPress {
add_filter( 'wp_mime_type_icon', array( $this, 'wp_mime_type_icon' ), 10, 3 );
+ add_filter( 'wp_video_extensions', array( $this, 'add_videopress_extenstion' ) );
+
$this->add_media_new_notice();
VideoPress_Scheduler::init();
@@ -162,6 +164,14 @@ class Jetpack_VideoPress {
),
$this->version
);
+
+ wp_enqueue_script(
+ 'media-video-widget-extensions',
+ plugins_url( 'js/media-video-widget-extensions.js', __FILE__ ),
+ array(),
+ $this->version,
+ true
+ );
}
/**
@@ -296,6 +306,9 @@ class Jetpack_VideoPress {
$existing_mimes[ $key ] = $value;
}
+ // Make sure that videopress mimes are considered videos.
+ $existing_mimes['videopress'] = 'video/videopress';
+
return $existing_mimes;
}
@@ -330,6 +343,17 @@ class Jetpack_VideoPress {
return 'https://wordpress.com/wp-content/mu-plugins/videopress/images/media-video-processing-icon.png';
}
+
+ /**
+ * @param array $extensions
+ *
+ * @return array
+ */
+ public function add_videopress_extenstion( $extensions ) {
+ $extensions[] = 'videopress';
+
+ return $extensions;
+ }
}
// Initialize the module.
diff --git a/plugins/jetpack/modules/videopress/editor-media-view.php b/plugins/jetpack/modules/videopress/editor-media-view.php
index a4727deb..427c3552 100644
--- a/plugins/jetpack/modules/videopress/editor-media-view.php
+++ b/plugins/jetpack/modules/videopress/editor-media-view.php
@@ -101,6 +101,14 @@ function videopress_ajax_query_attachments_args( $args ) {
*/
add_action( 'pre_get_posts', 'videopress_media_list_table_query' );
function videopress_media_list_table_query( $query ) {
+
+ if (
+ ! function_exists( 'get_current_screen' )
+ || is_null( get_current_screen() )
+ ) {
+ return;
+ }
+
if ( is_admin() && $query->is_main_query() && ( 'upload' === get_current_screen()->id ) ) {
$meta_query = array(
array(
@@ -212,4 +220,4 @@ function videopress_media_send_to_editor( $html, $id, $attachment ) {
$html = sprintf( '[videopress postid=%d]', $id );
}
return $html;
-} \ No newline at end of file
+}
diff --git a/plugins/jetpack/modules/videopress/js/media-video-widget-extensions.js b/plugins/jetpack/modules/videopress/js/media-video-widget-extensions.js
new file mode 100644
index 00000000..2fa8c93b
--- /dev/null
+++ b/plugins/jetpack/modules/videopress/js/media-video-widget-extensions.js
@@ -0,0 +1,45 @@
+window.wp = window.wp || {};
+
+( function( wp ) {
+ if ( wp.mediaWidgets ) {
+
+ // Over-ride core media_video#mapMediaToModelProps to set the url based upon videopress_guid if it exists.
+ wp.mediaWidgets.controlConstructors.media_video.prototype.mapMediaToModelProps = ( function( originalMapMediaToModelProps ) {
+ return function( mediaFrameProps ) {
+ var newProps, originalProps, videoPressGuid;
+ originalProps = originalMapMediaToModelProps.call( this, mediaFrameProps );
+ newProps = _.extend( {}, originalProps );
+
+ // API response on new media will have the guid at videopress.guid.
+ if ( mediaFrameProps.videopress && mediaFrameProps.videopress.guid ) {
+ videoPressGuid = mediaFrameProps.videopress.guid;
+ }
+
+ // Selecting an existing VideoPress file will have the guid at .videopress_guid[ 0 ].
+ if ( ! videoPressGuid && mediaFrameProps.videopress_guid && mediaFrameProps.videopress_guid.length ) {
+ videoPressGuid = mediaFrameProps.videopress_guid[ 0 ];
+ }
+
+ if ( videoPressGuid ) {
+ newProps = _.extend( {}, originalProps, {
+ url: 'https://videopress.com/v/' + videoPressGuid,
+ attachment_id: 0
+ });
+ }
+ return newProps;
+ };
+ }( wp.mediaWidgets.controlConstructors.media_video.prototype.mapMediaToModelProps ));
+
+ // Over-ride core media_video#isHostedVideo() to add support for videopress oembed urls.
+ wp.mediaWidgets.controlConstructors.media_video.prototype.isHostedVideo = (function( originalIsHostedVideo ) {
+ return function( url ) {
+ var parsedUrl = document.createElement( 'a' );
+ parsedUrl.href = url;
+ if ( 'videopress.com' === parsedUrl.hostname ) {
+ return true;
+ }
+ return originalIsHostedVideo.call( this, url );
+ };
+ }( wp.mediaWidgets.controlConstructors.media_video.prototype.isHostedVideo ));
+ }
+} )( window.wp );
diff --git a/plugins/jetpack/modules/videopress/shortcode.php b/plugins/jetpack/modules/videopress/shortcode.php
index dd041dbb..3e185bbb 100644
--- a/plugins/jetpack/modules/videopress/shortcode.php
+++ b/plugins/jetpack/modules/videopress/shortcode.php
@@ -184,6 +184,11 @@ class VideoPress_Shortcode {
$videopress_guid = $matches[2];
}
+ // Also test for videopress oembed url, which is used by the Video Media Widget.
+ if ( ! $videopress_guid && preg_match( '@https://videopress.com/v/([a-z0-9]{8})@i', $url, $matches ) ) {
+ $videopress_guid = $matches[1];
+ }
+
break;
}
}
diff --git a/plugins/jetpack/modules/widgets.php b/plugins/jetpack/modules/widgets.php
index adf8929c..de31236f 100644
--- a/plugins/jetpack/modules/widgets.php
+++ b/plugins/jetpack/modules/widgets.php
@@ -31,6 +31,8 @@ function jetpack_load_widgets() {
foreach( $widgets_include as $include ) {
include $include;
}
+
+ include_once dirname( __FILE__ ) . '/widgets/migrate-to-core/image-widget.php';
}
add_action( 'jetpack_modules_loaded', 'jetpack_widgets_loaded' );
diff --git a/plugins/jetpack/modules/widgets/contact-info.php b/plugins/jetpack/modules/widgets/contact-info.php
index 2a164faa..aa0d2f1b 100644
--- a/plugins/jetpack/modules/widgets/contact-info.php
+++ b/plugins/jetpack/modules/widgets/contact-info.php
@@ -124,7 +124,7 @@ if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) {
}
}
- if ( is_email( $instance['email'] ) ) {
+ if ( is_email( trim( $instance['email'] ) ) ) {
printf(
'<div class="confit-email"><a href="mailto:%1$s">%1$s</a></div>',
esc_html( $instance['email'] )
diff --git a/plugins/jetpack/modules/widgets/eu-cookie-law/eu-cookie-law.js b/plugins/jetpack/modules/widgets/eu-cookie-law/eu-cookie-law.js
index 344bddbb..e567e14b 100644
--- a/plugins/jetpack/modules/widgets/eu-cookie-law/eu-cookie-law.js
+++ b/plugins/jetpack/modules/widgets/eu-cookie-law/eu-cookie-law.js
@@ -1,4 +1,6 @@
( function( $ ) {
+ $( '.widget_eu_cookie_law_widget' ).appendTo( 'body' );
+
var overlay = $( '#eu-cookie-law' ), initialScrollPosition, scrollFunction;
overlay.find( 'form' ).on( 'submit', accept );
diff --git a/plugins/jetpack/modules/widgets/eu-cookie-law/style.css b/plugins/jetpack/modules/widgets/eu-cookie-law/style.css
index 684e7b97..41cdaba0 100644
--- a/plugins/jetpack/modules/widgets/eu-cookie-law/style.css
+++ b/plugins/jetpack/modules/widgets/eu-cookie-law/style.css
@@ -5,6 +5,7 @@
padding: 0;
position: fixed;
right: 1em;
+ width: auto;
z-index: 50001;
}
@@ -16,6 +17,7 @@
line-height: 1.5;
overflow: hidden;
padding: 6px 6px 6px 15px;
+ position: relative;
}
#eu-cookie-law a,
diff --git a/plugins/jetpack/modules/widgets/flickr.php b/plugins/jetpack/modules/widgets/flickr.php
index 14fd73d1..aac364af 100644
--- a/plugins/jetpack/modules/widgets/flickr.php
+++ b/plugins/jetpack/modules/widgets/flickr.php
@@ -116,11 +116,17 @@ if ( ! class_exists( 'Jetpack_Flickr_Widget' ) ) {
$photos = '';
if ( ! is_wp_error( $rss ) ) {
foreach ( $rss->get_items( 0, $instance['items'] ) as $photo ) {
- if ( $enclosure = $photo->get_enclosure() ) {
- $src = str_replace( '_s.jpg', $image_size_string, $enclosure->get_thumbnail() );
- } else {
- $src = preg_match( '/src="(.*?)"/i', $photo->get_description(), $p );
- $src = str_replace( '_m.jpg', $image_size_string, $p[1] );
+ switch ( $instance['flickr_image_size'] ) {
+ case 'thumbnail':
+ $src = $photo->get_enclosure()->get_thumbnail();
+ break;
+ case 'small':
+ $src = preg_match( '/src="(.*?)"/i', $photo->get_description(), $p );
+ $src = $p[1];
+ break;
+ case 'large':
+ $src = $photo->get_enclosure()->get_link();
+ break;
}
$photos .= '<a href="' . esc_url( $photo->get_permalink(), array( 'http', 'https' ) ) . '">';
@@ -186,7 +192,7 @@ if ( ! class_exists( 'Jetpack_Flickr_Widget' ) ) {
if (
isset( $new_instance['flickr_image_size'] ) &&
- in_array( $new_instance['flickr_image_size'], array( 'thumbnail', 'small' ) )
+ in_array( $new_instance['flickr_image_size'], array( 'thumbnail', 'small', 'large' ) )
) {
$instance['flickr_image_size'] = $new_instance['flickr_image_size'];
} else {
diff --git a/plugins/jetpack/modules/widgets/flickr/form.php b/plugins/jetpack/modules/widgets/flickr/form.php
index 5b862da1..4ba4956b 100644
--- a/plugins/jetpack/modules/widgets/flickr/form.php
+++ b/plugins/jetpack/modules/widgets/flickr/form.php
@@ -52,29 +52,42 @@
</p>
<p>
- <label>
+ <div>
<?php esc_html_e( 'What size photos would you like to display?', 'jetpack' ); ?>
- </label>
- <select name="<?php echo esc_attr( $this->get_field_name( 'flickr_image_size' ) ); ?>">
- <?php
- $flickr_sizes = array(
- array(
- 'size' => 'thumbnail',
- 'text' => esc_html__( 'Thumbnail', 'jetpack' ),
- ),
- array(
- 'size' => 'small',
- 'text' => esc_html__( 'Small', 'jetpack' ),
- ),
- );
- foreach( $flickr_sizes as $flickr_size ) { ?>
- <option
- <?php selected( $instance['flickr_image_size'], $flickr_size['size'] ); ?>
- value="<?php echo esc_attr( $flickr_size['size'] ); ?>"
- >
- <?php esc_html_e( $flickr_size['text'] ); ?>
- </option>
- <?php }
- ?>
- </select>
+ </div>
+ <ul>
+ <li>
+ <label>
+ <input
+ <?php checked( $instance['flickr_image_size'], 'thumbnail' ); ?>
+ name="<?php echo esc_attr( $this->get_field_name( 'flickr_image_size' ) ); ?>"
+ type="radio"
+ value="thumbnail"
+ />
+ <?php esc_html_e( 'Thumbnail', 'jetpack' ); ?>
+ </label>
+ </li>
+ <li>
+ <label>
+ <input
+ <?php checked( $instance['flickr_image_size'], 'small' ); ?>
+ name="<?php echo esc_attr( $this->get_field_name( 'flickr_image_size' ) ); ?>"
+ type="radio"
+ value="small"
+ />
+ <?php esc_html_e( 'Medium', 'jetpack' ); ?>
+ </label>
+ </li>
+ <li>
+ <label>
+ <input
+ <?php checked( $instance['flickr_image_size'], 'large' ); ?>
+ name="<?php echo esc_attr( $this->get_field_name( 'flickr_image_size' ) ); ?>"
+ type="radio"
+ value="large"
+ />
+ <?php esc_html_e( 'Large', 'jetpack' ); ?>
+ </label>
+ </li>
+ </ul>
</p>
diff --git a/plugins/jetpack/modules/widgets/image-widget.php b/plugins/jetpack/modules/widgets/image-widget.php
index 10ba8ccd..aabbb43f 100644
--- a/plugins/jetpack/modules/widgets/image-widget.php
+++ b/plugins/jetpack/modules/widgets/image-widget.php
@@ -9,8 +9,11 @@
/**
* Register the widget for use in Appearance -> Widgets
*/
-add_action( 'widgets_init', 'jetpack_image_widget_init' );
+add_action( 'widgets_init', 'jetpack_image_widget_init', 11 );
function jetpack_image_widget_init() {
+ if ( class_exists( 'WP_Widget_Media_Image' ) && Jetpack_Options::get_option( 'image_widget_migration' ) ) {
+ return;
+ }
register_widget( 'Jetpack_Image_Widget' );
}
diff --git a/plugins/jetpack/modules/widgets/migrate-to-core/image-widget.php b/plugins/jetpack/modules/widgets/migrate-to-core/image-widget.php
new file mode 100644
index 00000000..a441608b
--- /dev/null
+++ b/plugins/jetpack/modules/widgets/migrate-to-core/image-widget.php
@@ -0,0 +1,130 @@
+<?php
+/**
+ * Migration from Jetpack's Image Widget to WordPress' Core Image Widget.
+ *
+ * @since 4.9
+ *
+ * @package Jetpack
+ */
+
+/**
+ * Migrates all active instances of Jetpack's image widget to Core's media image widget.
+ */
+function jetpack_migrate_image_widget() {
+ // Only trigger the migration from wp-admin
+ if ( ! is_admin() ) {
+ return;
+ }
+ // Only migrate if the new widget is available and we haven't yet migrated
+ if ( ! class_exists( 'WP_Widget_Media_Image' ) || Jetpack_Options::get_option( 'image_widget_migration' ) ) {
+ return;
+ }
+
+ $default_data = array(
+ 'attachment_id' => 0,
+ 'url' => '',
+ 'title' => '',
+ 'size' => 'full',
+ 'width' => 0,
+ 'height' => 0,
+ 'align' => 'none',
+ 'caption' => '',
+ 'alt' => '',
+ 'link_type' => '',
+ 'link_url' => '',
+ 'image_classes' => '',
+ 'link_classes' => '',
+ 'link_rel' => '',
+ 'image_title' => '',
+ 'link_target_blank' => false,
+ );
+
+ $media_image = get_option( 'widget_media_image' );
+ $sidebars_widgets = wp_get_sidebars_widgets();
+
+ foreach ( get_option( 'widget_image', array() ) as $id => $widget ) {
+ if ( is_string( $id ) ) {
+ continue;
+ }
+
+ $media_image[ $id ] = array_merge( $default_data, array_intersect_key( $widget, $default_data ), array(
+ 'alt' => $widget['alt_text'],
+ 'height' => $widget['img_height'],
+ 'image_classes' => ! empty( $widget['align'] ) ? 'align' . $widget['align'] : '',
+ 'image_title' => $widget['img_title'],
+ 'link_url' => $widget['link'],
+ 'url' => $widget['img_url'],
+ 'width' => $widget['img_width'],
+ ) );
+
+ // Check if the image is in the media library.
+ $image_basename = basename( $widget['img_url'] );
+ $attachment_ids = get_posts( array(
+ 'fields' => 'ids',
+ 'meta_query' => array(
+ array(
+ 'value' => basename( $image_basename ),
+ 'compare' => 'LIKE',
+ 'key' => '_wp_attachment_metadata',
+ ),
+ ),
+ 'post_status' => 'inherit',
+ 'post_type' => 'attachment',
+ ) );
+
+ foreach ( (array) $attachment_ids as $attachment_id ) {
+ $image_meta = wp_get_attachment_metadata( $attachment_id );
+
+ // Is it a full size image?
+ $image_path_pieces = explode( '/', $image_meta['file'] );
+ if ( $image_basename === array_pop( $image_path_pieces ) ) {
+ $media_image[ $id ]['attachment_id'] = $attachment_id;
+ $media_image[ $id ]['width'] = $image_meta['width'];
+ $media_image[ $id ]['height'] = $image_meta['height'];
+ break;
+ }
+
+ // Is it a down-sized image?
+ foreach ( $image_meta['sizes'] as $size => $image ) {
+ if ( false !== array_search( $image_basename, $image ) ) {
+ $media_image[ $id ]['attachment_id'] = $attachment_id;
+ $media_image[ $id ]['size'] = $size;
+ $media_image[ $id ]['width'] = $image['width'];
+ $media_image[ $id ]['height'] = $image['height'];
+ break 2;
+ }
+ }
+ }
+
+ if ( ! empty( $widget['link'] ) ) {
+ $media_image[ $id ]['link_type'] = $widget['link'] === $widget['img_url'] ? 'file' : 'custom';
+ }
+
+ foreach ( $sidebars_widgets as $sidebar => $widgets ) {
+ if ( false !== ( $key = array_search( "image-{$id}", $widgets, true ) ) ) {
+ $sidebars_widgets[ $sidebar ][ $key ] = "media_image-{$id}";
+ }
+ }
+
+ wp_unregister_sidebar_widget( "image-{$id}" );
+ $media_image_widget = new WP_Widget_Media_Image();
+ $media_image_widget->_set( $id );
+ $media_image_widget->_register_one( $id );
+ }
+
+ update_option( 'widget_media_image', $media_image );
+ delete_option( 'widget_image' );
+ wp_set_sidebars_widgets( $sidebars_widgets );
+
+ Jetpack_Options::update_option( 'image_widget_migration', true );
+
+ // We need to refresh on widgets page for changes to take effect.
+ add_action( 'current_screen', 'jetpack_refresh_on_widget_page' );
+}
+add_action( 'widgets_init', 'jetpack_migrate_image_widget' );
+
+function jetpack_refresh_on_widget_page( $current ) {
+ if ( 'widgets' === $current->base ) {
+ wp_safe_redirect( admin_url( 'widgets.php' ) );
+ }
+}
diff --git a/plugins/jetpack/modules/wordads/wordads.php b/plugins/jetpack/modules/wordads/wordads.php
index 884f92af..c8748e18 100644
--- a/plugins/jetpack/modules/wordads/wordads.php
+++ b/plugins/jetpack/modules/wordads/wordads.php
@@ -190,6 +190,10 @@ HTML;
* @since 4.5.0
*/
function insert_ad( $content ) {
+ // Ad JS won't work in XML feeds.
+ if ( is_feed() ) {
+ return $content;
+ }
/**
* Allow third-party tools to disable the display of in post ads.
*