" )
.addClass( "ui-tooltip-content" )
.appendTo( tooltip );
tooltip.appendTo( this.document[0].body );
if ( $.fn.bgiframe ) {
tooltip.bgiframe();
}
this.tooltips[ id ] = element;
return tooltip;
},
_find: function( target ) {
var id = target.data( "ui-tooltip-id" );
return id ? $( "#" + id ) : $();
},
_removeTooltip: function( tooltip ) {
tooltip.remove();
delete this.tooltips[ tooltip.attr( "id" ) ];
},
_destroy: function() {
var that = this;
// close open tooltips
$.each( this.tooltips, function( id, element ) {
// Delegate to close method to handle common cleanup
var event = $.Event( "blur" );
event.target = event.currentTarget = element[0];
that.close( event, true );
// Remove immediately; destroying an open tooltip doesn't use the
// hide animation
$( "#" + id ).remove();
// Restore the title
if ( element.data( "ui-tooltip-title" ) ) {
element.attr( "title", element.data( "ui-tooltip-title" ) );
element.removeData( "ui-tooltip-title" );
}
});
}
});
}( jQuery ) );
/*
* jQuery UI Autocomplete HTML Extension
*
* Copyright 2010, Scott González (http://scottgonzalez.com)
* Dual licensed under the MIT or GPL Version 2 licenses.
*
* http://github.com/scottgonzalez/jquery-ui-extensions
*/
(function( $ ) {
var proto = $.ui.autocomplete.prototype,
initSource = proto._initSource;
function filter( array, term ) {
var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
return $.grep( array, function(value) {
return matcher.test( $( "
" ).html( value.label || value.value || value ).text() );
});
}
$.extend( proto, {
_initSource: function() {
if ( this.options.html && $.isArray(this.options.source) ) {
this.source = function( request, response ) {
response( filter( this.options.source, request.term ) );
};
} else {
initSource.call( this );
}
},
_renderItem: function( ul, item) {
return $( "
" )
.data( "item.autocomplete", item )
.append( $( "
" )[ this.options.html ? "html" : "text" ]( item.label ) )
.appendTo( ul );
}
});
})( jQuery );
/*!
Autosize 1.18.13
license: MIT
http://www.jacklmoore.com/autosize
*/
(function ($) {
var
defaults = {
className: 'autosizejs',
id: 'autosizejs',
append: '\n',
callback: false,
resizeDelay: 10,
placeholder: true
},
// border:0 is unnecessary, but avoids a bug in Firefox on OSX
copy = '
',
// line-height is conditionally included because IE7/IE8/old Opera do not return the correct value.
typographyStyles = [
'fontFamily',
'fontSize',
'fontWeight',
'fontStyle',
'letterSpacing',
'textTransform',
'wordSpacing',
'textIndent',
'whiteSpace'
],
// to keep track which textarea is being mirrored when adjust() is called.
mirrored,
// the mirror element, which is used to calculate what size the mirrored element should be.
mirror = $(copy).data('autosize', true)[0];
// test that line-height can be accurately copied.
mirror.style.lineHeight = '99px';
if ($(mirror).css('lineHeight') === '99px') {
typographyStyles.push('lineHeight');
}
mirror.style.lineHeight = '';
$.fn.autosize = function (options) {
if (!this.length) {
return this;
}
options = $.extend({}, defaults, options || {});
if (mirror.parentNode !== document.body) {
$(document.body).append(mirror);
}
return this.each(function () {
var
ta = this,
$ta = $(ta),
maxHeight,
minHeight,
boxOffset = 0,
callback = $.isFunction(options.callback),
originalStyles = {
height: ta.style.height,
overflow: ta.style.overflow,
overflowY: ta.style.overflowY,
wordWrap: ta.style.wordWrap,
resize: ta.style.resize
},
timeout,
width = $ta.width(),
taResize = $ta.css('resize');
if ($ta.data('autosize')) {
// exit if autosize has already been applied, or if the textarea is the mirror element.
return;
}
$ta.data('autosize', true);
if ($ta.css('box-sizing') === 'border-box' || $ta.css('-moz-box-sizing') === 'border-box' || $ta.css('-webkit-box-sizing') === 'border-box'){
boxOffset = $ta.outerHeight() - $ta.height();
}
// IE8 and lower return 'auto', which parses to NaN, if no min-height is set.
minHeight = Math.max(parseInt($ta.css('minHeight'), 10) - boxOffset || 0, $ta.height());
$ta.css({
overflow: 'hidden',
overflowY: 'hidden',
wordWrap: 'break-word' // horizontal overflow is hidden, so break-word is necessary for handling words longer than the textarea width
});
if (taResize === 'vertical') {
$ta.css('resize','none');
} else if (taResize === 'both') {
$ta.css('resize', 'horizontal');
}
// The mirror width must exactly match the textarea width, so using getBoundingClientRect because it doesn't round the sub-pixel value.
// window.getComputedStyle, getBoundingClientRect returning a width are unsupported, but also unneeded in IE8 and lower.
function setWidth() {
var width;
var style = window.getComputedStyle ? window.getComputedStyle(ta, null) : false;
if (style) {
width = ta.getBoundingClientRect().width;
if (width === 0 || typeof width !== 'number') {
width = parseInt(style.width,10);
}
$.each(['paddingLeft', 'paddingRight', 'borderLeftWidth', 'borderRightWidth'], function(i,val){
width -= parseInt(style[val],10);
});
} else {
width = $ta.width();
}
mirror.style.width = Math.max(width,0) + 'px';
}
function initMirror() {
var styles = {};
mirrored = ta;
mirror.className = options.className;
mirror.id = options.id;
maxHeight = parseInt($ta.css('maxHeight'), 10);
// mirror is a duplicate textarea located off-screen that
// is automatically updated to contain the same text as the
// original textarea. mirror always has a height of 0.
// This gives a cross-browser supported way getting the actual
// height of the text, through the scrollTop property.
$.each(typographyStyles, function(i,val){
styles[val] = $ta.css(val);
});
$(mirror).css(styles).attr('wrap', $ta.attr('wrap'));
setWidth();
// Chrome-specific fix:
// When the textarea y-overflow is hidden, Chrome doesn't reflow the text to account for the space
// made available by removing the scrollbar. This workaround triggers the reflow for Chrome.
if (window.chrome) {
var width = ta.style.width;
ta.style.width = '0px';
var ignore = ta.offsetWidth;
ta.style.width = width;
}
}
// Using mainly bare JS in this function because it is going
// to fire very often while typing, and needs to very efficient.
function adjust() {
var height, original;
if (mirrored !== ta) {
initMirror();
} else {
setWidth();
}
if (!ta.value && options.placeholder) {
// If the textarea is empty, copy the placeholder text into
// the mirror control and use that for sizing so that we
// don't end up with placeholder getting trimmed.
mirror.value = ($ta.attr("placeholder") || '');
} else {
mirror.value = ta.value;
}
mirror.value += options.append || '';
mirror.style.overflowY = ta.style.overflowY;
original = parseInt(ta.style.height,10);
// Setting scrollTop to zero is needed in IE8 and lower for the next step to be accurately applied
mirror.scrollTop = 0;
mirror.scrollTop = 9e4;
// Using scrollTop rather than scrollHeight because scrollHeight is non-standard and includes padding.
height = mirror.scrollTop;
if (maxHeight && height > maxHeight) {
ta.style.overflowY = 'scroll';
height = maxHeight;
} else {
ta.style.overflowY = 'hidden';
if (height < minHeight) {
height = minHeight;
}
}
height += boxOffset;
if (original !== height) {
ta.style.height = height + 'px';
if (callback) {
options.callback.call(ta,ta);
}
$ta.trigger('autosize.resized');
}
}
function resize () {
clearTimeout(timeout);
timeout = setTimeout(function(){
var newWidth = $ta.width();
if (newWidth !== width) {
width = newWidth;
adjust();
}
}, parseInt(options.resizeDelay,10));
}
if ('onpropertychange' in ta) {
if ('oninput' in ta) {
// Detects IE9. IE9 does not fire onpropertychange or oninput for deletions,
// so binding to onkeyup to catch most of those occasions. There is no way that I
// know of to detect something like 'cut' in IE9.
$ta.on('input.autosize keyup.autosize', adjust);
} else {
// IE7 / IE8
$ta.on('propertychange.autosize', function(){
if(event.propertyName === 'value'){
adjust();
}
});
}
} else {
// Modern Browsers
$ta.on('input.autosize', adjust);
}
// Set options.resizeDelay to false if using fixed-width textarea elements.
// Uses a timeout and width check to reduce the amount of times adjust needs to be called after window resize.
if (options.resizeDelay !== false) {
$(window).on('resize.autosize', resize);
}
// Event for manual triggering if needed.
// Should only be needed when the value of the textarea is changed through JavaScript rather than user input.
$ta.on('autosize.resize', adjust);
// Event for manual triggering that also forces the styles to update as well.
// Should only be needed if one of typography styles of the textarea change, and the textarea is already the target of the adjust method.
$ta.on('autosize.resizeIncludeStyle', function() {
mirrored = null;
adjust();
});
$ta.on('autosize.destroy', function(){
mirrored = null;
clearTimeout(timeout);
$(window).off('resize', resize);
$ta
.off('autosize')
.off('.autosize')
.css(originalStyles)
.removeData('autosize');
});
// Call adjust in case the textarea already contains text.
adjust();
});
};
}(jQuery || $)); // jQuery or jQuery-like library, such as Zepto
/*
* jQuery File Upload Plugin 5.42.3
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2010, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/
/* jshint nomen:false */
/* global define, require, window, document, location, Blob, FormData */
(function (factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module:
define([
'jquery',
'jquery.ui.widget'
], factory);
} else if (typeof exports === 'object') {
// Node/CommonJS:
factory(
require('jquery'),
require('./vendor/jquery.ui.widget')
);
} else {
// Browser globals:
factory(window.jQuery);
}
}(function ($) {
'use strict';
// Detect file input support, based on
// http://viljamis.com/blog/2012/file-upload-support-on-mobile/
$.support.fileInput = !(new RegExp(
// Handle devices which give false positives for the feature detection:
'(Android (1\\.[0156]|2\\.[01]))' +
'|(Windows Phone (OS 7|8\\.0))|(XBLWP)|(ZuneWP)|(WPDesktop)' +
'|(w(eb)?OSBrowser)|(webOS)' +
'|(Kindle/(1\\.0|2\\.[05]|3\\.0))'
).test(window.navigator.userAgent) ||
// Feature detection for all other devices:
$('
').prop('disabled'));
// The FileReader API is not actually used, but works as feature detection,
// as some Safari versions (5?) support XHR file uploads via the FormData API,
// but not non-multipart XHR file uploads.
// window.XMLHttpRequestUpload is not available on IE10, so we check for
// window.ProgressEvent instead to detect XHR2 file upload capability:
$.support.xhrFileUpload = !!(window.ProgressEvent && window.FileReader);
$.support.xhrFormDataFileUpload = !!window.FormData;
// Detect support for Blob slicing (required for chunked uploads):
$.support.blobSlice = window.Blob && (Blob.prototype.slice ||
Blob.prototype.webkitSlice || Blob.prototype.mozSlice);
// Helper function to create drag handlers for dragover/dragenter/dragleave:
function getDragHandler(type) {
var isDragOver = type === 'dragover';
return function (e) {
e.dataTransfer = e.originalEvent && e.originalEvent.dataTransfer;
var dataTransfer = e.dataTransfer;
if (dataTransfer && $.inArray('Files', dataTransfer.types) !== -1 &&
this._trigger(
type,
$.Event(type, {delegatedEvent: e})
) !== false) {
e.preventDefault();
if (isDragOver) {
dataTransfer.dropEffect = 'copy';
}
}
};
}
// The fileupload widget listens for change events on file input fields defined
// via fileInput setting and paste or drop events of the given dropZone.
// In addition to the default jQuery Widget methods, the fileupload widget
// exposes the "add" and "send" methods, to add or directly send files using
// the fileupload API.
// By default, files added via file input selection, paste, drag & drop or
// "add" method are uploaded immediately, but it is possible to override
// the "add" callback option to queue file uploads.
$.widget('blueimp.fileupload', {
options: {
// The drop target element(s), by the default the complete document.
// Set to null to disable drag & drop support:
dropZone: $(document),
// The paste target element(s), by the default undefined.
// Set to a DOM node or jQuery object to enable file pasting:
pasteZone: undefined,
// The file input field(s), that are listened to for change events.
// If undefined, it is set to the file input fields inside
// of the widget element on plugin initialization.
// Set to null to disable the change listener.
fileInput: undefined,
// By default, the file input field is replaced with a clone after
// each input field change event. This is required for iframe transport
// queues and allows change events to be fired for the same file
// selection, but can be disabled by setting the following option to false:
replaceFileInput: true,
// The parameter name for the file form data (the request argument name).
// If undefined or empty, the name property of the file input field is
// used, or "files[]" if the file input name property is also empty,
// can be a string or an array of strings:
paramName: undefined,
// By default, each file of a selection is uploaded using an individual
// request for XHR type uploads. Set to false to upload file
// selections in one request each:
singleFileUploads: true,
// To limit the number of files uploaded with one XHR request,
// set the following option to an integer greater than 0:
limitMultiFileUploads: undefined,
// The following option limits the number of files uploaded with one
// XHR request to keep the request size under or equal to the defined
// limit in bytes:
limitMultiFileUploadSize: undefined,
// Multipart file uploads add a number of bytes to each uploaded file,
// therefore the following option adds an overhead for each file used
// in the limitMultiFileUploadSize configuration:
limitMultiFileUploadSizeOverhead: 512,
// Set the following option to true to issue all file upload requests
// in a sequential order:
sequentialUploads: false,
// To limit the number of concurrent uploads,
// set the following option to an integer greater than 0:
limitConcurrentUploads: undefined,
// Set the following option to true to force iframe transport uploads:
forceIframeTransport: false,
// Set the following option to the location of a redirect url on the
// origin server, for cross-domain iframe transport uploads:
redirect: undefined,
// The parameter name for the redirect url, sent as part of the form
// data and set to 'redirect' if this option is empty:
redirectParamName: undefined,
// Set the following option to the location of a postMessage window,
// to enable postMessage transport uploads:
postMessage: undefined,
// By default, XHR file uploads are sent as multipart/form-data.
// The iframe transport is always using multipart/form-data.
// Set to false to enable non-multipart XHR uploads:
multipart: true,
// To upload large files in smaller chunks, set the following option
// to a preferred maximum chunk size. If set to 0, null or undefined,
// or the browser does not support the required Blob API, files will
// be uploaded as a whole.
maxChunkSize: undefined,
// When a non-multipart upload or a chunked multipart upload has been
// aborted, this option can be used to resume the upload by setting
// it to the size of the already uploaded bytes. This option is most
// useful when modifying the options object inside of the "add" or
// "send" callbacks, as the options are cloned for each file upload.
uploadedBytes: undefined,
// By default, failed (abort or error) file uploads are removed from the
// global progress calculation. Set the following option to false to
// prevent recalculating the global progress data:
recalculateProgress: true,
// Interval in milliseconds to calculate and trigger progress events:
progressInterval: 100,
// Interval in milliseconds to calculate progress bitrate:
bitrateInterval: 500,
// By default, uploads are started automatically when adding files:
autoUpload: true,
// Error and info messages:
messages: {
uploadedBytes: 'Uploaded bytes exceed file size'
},
// Translation function, gets the message key to be translated
// and an object with context specific data as arguments:
i18n: function (message, context) {
message = this.messages[message] || message.toString();
if (context) {
$.each(context, function (key, value) {
message = message.replace('{' + key + '}', value);
});
}
return message;
},
// Additional form data to be sent along with the file uploads can be set
// using this option, which accepts an array of objects with name and
// value properties, a function returning such an array, a FormData
// object (for XHR file uploads), or a simple object.
// The form of the first fileInput is given as parameter to the function:
formData: function (form) {
return form.serializeArray();
},
// The add callback is invoked as soon as files are added to the fileupload
// widget (via file input selection, drag & drop, paste or add API call).
// If the singleFileUploads option is enabled, this callback will be
// called once for each file in the selection for XHR file uploads, else
// once for each file selection.
//
// The upload starts when the submit method is invoked on the data parameter.
// The data object contains a files property holding the added files
// and allows you to override plugin options as well as define ajax settings.
//
// Listeners for this callback can also be bound the following way:
// .bind('fileuploadadd', func);
//
// data.submit() returns a Promise object and allows to attach additional
// handlers using jQuery's Deferred callbacks:
// data.submit().done(func).fail(func).always(func);
add: function (e, data) {
if (e.isDefaultPrevented()) {
return false;
}
if (data.autoUpload || (data.autoUpload !== false &&
$(this).fileupload('option', 'autoUpload'))) {
data.process().done(function () {
data.submit();
});
}
},
// Other callbacks:
// Callback for the submit event of each file upload:
// submit: function (e, data) {}, // .bind('fileuploadsubmit', func);
// Callback for the start of each file upload request:
// send: function (e, data) {}, // .bind('fileuploadsend', func);
// Callback for successful uploads:
// done: function (e, data) {}, // .bind('fileuploaddone', func);
// Callback for failed (abort or error) uploads:
// fail: function (e, data) {}, // .bind('fileuploadfail', func);
// Callback for completed (success, abort or error) requests:
// always: function (e, data) {}, // .bind('fileuploadalways', func);
// Callback for upload progress events:
// progress: function (e, data) {}, // .bind('fileuploadprogress', func);
// Callback for global upload progress events:
// progressall: function (e, data) {}, // .bind('fileuploadprogressall', func);
// Callback for uploads start, equivalent to the global ajaxStart event:
// start: function (e) {}, // .bind('fileuploadstart', func);
// Callback for uploads stop, equivalent to the global ajaxStop event:
// stop: function (e) {}, // .bind('fileuploadstop', func);
// Callback for change events of the fileInput(s):
// change: function (e, data) {}, // .bind('fileuploadchange', func);
// Callback for paste events to the pasteZone(s):
// paste: function (e, data) {}, // .bind('fileuploadpaste', func);
// Callback for drop events of the dropZone(s):
// drop: function (e, data) {}, // .bind('fileuploaddrop', func);
// Callback for dragover events of the dropZone(s):
// dragover: function (e) {}, // .bind('fileuploaddragover', func);
// Callback for the start of each chunk upload request:
// chunksend: function (e, data) {}, // .bind('fileuploadchunksend', func);
// Callback for successful chunk uploads:
// chunkdone: function (e, data) {}, // .bind('fileuploadchunkdone', func);
// Callback for failed (abort or error) chunk uploads:
// chunkfail: function (e, data) {}, // .bind('fileuploadchunkfail', func);
// Callback for completed (success, abort or error) chunk upload requests:
// chunkalways: function (e, data) {}, // .bind('fileuploadchunkalways', func);
// The plugin options are used as settings object for the ajax calls.
// The following are jQuery ajax settings required for the file uploads:
processData: false,
contentType: false,
cache: false,
timeout: 0
},
// A list of options that require reinitializing event listeners and/or
// special initialization code:
_specialOptions: [
'fileInput',
'dropZone',
'pasteZone',
'multipart',
'forceIframeTransport'
],
_blobSlice: $.support.blobSlice && function () {
var slice = this.slice || this.webkitSlice || this.mozSlice;
return slice.apply(this, arguments);
},
_BitrateTimer: function () {
this.timestamp = ((Date.now) ? Date.now() : (new Date()).getTime());
this.loaded = 0;
this.bitrate = 0;
this.getBitrate = function (now, loaded, interval) {
var timeDiff = now - this.timestamp;
if (!this.bitrate || !interval || timeDiff > interval) {
this.bitrate = (loaded - this.loaded) * (1000 / timeDiff) * 8;
this.loaded = loaded;
this.timestamp = now;
}
return this.bitrate;
};
},
_isXHRUpload: function (options) {
return !options.forceIframeTransport &&
((!options.multipart && $.support.xhrFileUpload) ||
$.support.xhrFormDataFileUpload);
},
_getFormData: function (options) {
var formData;
if ($.type(options.formData) === 'function') {
return options.formData(options.form);
}
if ($.isArray(options.formData)) {
return options.formData;
}
if ($.type(options.formData) === 'object') {
formData = [];
$.each(options.formData, function (name, value) {
formData.push({name: name, value: value});
});
return formData;
}
return [];
},
_getTotal: function (files) {
var total = 0;
$.each(files, function (index, file) {
total += file.size || 1;
});
return total;
},
_initProgressObject: function (obj) {
var progress = {
loaded: 0,
total: 0,
bitrate: 0
};
if (obj._progress) {
$.extend(obj._progress, progress);
} else {
obj._progress = progress;
}
},
_initResponseObject: function (obj) {
var prop;
if (obj._response) {
for (prop in obj._response) {
if (obj._response.hasOwnProperty(prop)) {
delete obj._response[prop];
}
}
} else {
obj._response = {};
}
},
_onProgress: function (e, data) {
if (e.lengthComputable) {
var now = ((Date.now) ? Date.now() : (new Date()).getTime()),
loaded;
if (data._time && data.progressInterval &&
(now - data._time < data.progressInterval) &&
e.loaded !== e.total) {
return;
}
data._time = now;
loaded = Math.floor(
e.loaded / e.total * (data.chunkSize || data._progress.total)
) + (data.uploadedBytes || 0);
// Add the difference from the previously loaded state
// to the global loaded counter:
this._progress.loaded += (loaded - data._progress.loaded);
this._progress.bitrate = this._bitrateTimer.getBitrate(
now,
this._progress.loaded,
data.bitrateInterval
);
data._progress.loaded = data.loaded = loaded;
data._progress.bitrate = data.bitrate = data._bitrateTimer.getBitrate(
now,
loaded,
data.bitrateInterval
);
// Trigger a custom progress event with a total data property set
// to the file size(s) of the current upload and a loaded data
// property calculated accordingly:
this._trigger(
'progress',
$.Event('progress', {delegatedEvent: e}),
data
);
// Trigger a global progress event for all current file uploads,
// including ajax calls queued for sequential file uploads:
this._trigger(
'progressall',
$.Event('progressall', {delegatedEvent: e}),
this._progress
);
}
},
_initProgressListener: function (options) {
var that = this,
xhr = options.xhr ? options.xhr() : $.ajaxSettings.xhr();
// Accesss to the native XHR object is required to add event listeners
// for the upload progress event:
if (xhr.upload) {
$(xhr.upload).bind('progress', function (e) {
var oe = e.originalEvent;
// Make sure the progress event properties get copied over:
e.lengthComputable = oe.lengthComputable;
e.loaded = oe.loaded;
e.total = oe.total;
that._onProgress(e, options);
});
options.xhr = function () {
return xhr;
};
}
},
_isInstanceOf: function (type, obj) {
// Cross-frame instanceof check
return Object.prototype.toString.call(obj) === '[object ' + type + ']';
},
_initXHRData: function (options) {
var that = this,
formData,
file = options.files[0],
// Ignore non-multipart setting if not supported:
multipart = options.multipart || !$.support.xhrFileUpload,
paramName = $.type(options.paramName) === 'array' ?
options.paramName[0] : options.paramName;
options.headers = $.extend({}, options.headers);
if (options.contentRange) {
options.headers['Content-Range'] = options.contentRange;
}
if (!multipart || options.blob || !this._isInstanceOf('File', file)) {
options.headers['Content-Disposition'] = 'attachment; filename="' +
encodeURI(file.name) + '"';
}
if (!multipart) {
options.contentType = file.type || 'application/octet-stream';
options.data = options.blob || file;
} else if ($.support.xhrFormDataFileUpload) {
if (options.postMessage) {
// window.postMessage does not allow sending FormData
// objects, so we just add the File/Blob objects to
// the formData array and let the postMessage window
// create the FormData object out of this array:
formData = this._getFormData(options);
if (options.blob) {
formData.push({
name: paramName,
value: options.blob
});
} else {
$.each(options.files, function (index, file) {
formData.push({
name: ($.type(options.paramName) === 'array' &&
options.paramName[index]) || paramName,
value: file
});
});
}
} else {
if (that._isInstanceOf('FormData', options.formData)) {
formData = options.formData;
} else {
formData = new FormData();
$.each(this._getFormData(options), function (index, field) {
formData.append(field.name, field.value);
});
}
if (options.blob) {
formData.append(paramName, options.blob, file.name);
} else {
$.each(options.files, function (index, file) {
// This check allows the tests to run with
// dummy objects:
if (that._isInstanceOf('File', file) ||
that._isInstanceOf('Blob', file)) {
formData.append(
($.type(options.paramName) === 'array' &&
options.paramName[index]) || paramName,
file,
file.uploadName || file.name
);
}
});
}
}
options.data = formData;
}
// Blob reference is not needed anymore, free memory:
options.blob = null;
},
_initIframeSettings: function (options) {
var targetHost = $('
').prop('href', options.url).prop('host');
// Setting the dataType to iframe enables the iframe transport:
options.dataType = 'iframe ' + (options.dataType || '');
// The iframe transport accepts a serialized array as form data:
options.formData = this._getFormData(options);
// Add redirect url to form data on cross-domain uploads:
if (options.redirect && targetHost && targetHost !== location.host) {
options.formData.push({
name: options.redirectParamName || 'redirect',
value: options.redirect
});
}
},
_initDataSettings: function (options) {
if (this._isXHRUpload(options)) {
if (!this._chunkedUpload(options, true)) {
if (!options.data) {
this._initXHRData(options);
}
this._initProgressListener(options);
}
if (options.postMessage) {
// Setting the dataType to postmessage enables the
// postMessage transport:
options.dataType = 'postmessage ' + (options.dataType || '');
}
} else {
this._initIframeSettings(options);
}
},
_getParamName: function (options) {
var fileInput = $(options.fileInput),
paramName = options.paramName;
if (!paramName) {
paramName = [];
fileInput.each(function () {
var input = $(this),
name = input.prop('name') || 'files[]',
i = (input.prop('files') || [1]).length;
while (i) {
paramName.push(name);
i -= 1;
}
});
if (!paramName.length) {
paramName = [fileInput.prop('name') || 'files[]'];
}
} else if (!$.isArray(paramName)) {
paramName = [paramName];
}
return paramName;
},
_initFormSettings: function (options) {
// Retrieve missing options from the input field and the
// associated form, if available:
if (!options.form || !options.form.length) {
options.form = $(options.fileInput.prop('form'));
// If the given file input doesn't have an associated form,
// use the default widget file input's form:
if (!options.form.length) {
options.form = $(this.options.fileInput.prop('form'));
}
}
options.paramName = this._getParamName(options);
if (!options.url) {
options.url = options.form.prop('action') || location.href;
}
// The HTTP request method must be "POST" or "PUT":
options.type = (options.type ||
($.type(options.form.prop('method')) === 'string' &&
options.form.prop('method')) || ''
).toUpperCase();
if (options.type !== 'POST' && options.type !== 'PUT' &&
options.type !== 'PATCH') {
options.type = 'POST';
}
if (!options.formAcceptCharset) {
options.formAcceptCharset = options.form.attr('accept-charset');
}
},
_getAJAXSettings: function (data) {
var options = $.extend({}, this.options, data);
this._initFormSettings(options);
this._initDataSettings(options);
return options;
},
// jQuery 1.6 doesn't provide .state(),
// while jQuery 1.8+ removed .isRejected() and .isResolved():
_getDeferredState: function (deferred) {
if (deferred.state) {
return deferred.state();
}
if (deferred.isResolved()) {
return 'resolved';
}
if (deferred.isRejected()) {
return 'rejected';
}
return 'pending';
},
// Maps jqXHR callbacks to the equivalent
// methods of the given Promise object:
_enhancePromise: function (promise) {
promise.success = promise.done;
promise.error = promise.fail;
promise.complete = promise.always;
return promise;
},
// Creates and returns a Promise object enhanced with
// the jqXHR methods abort, success, error and complete:
_getXHRPromise: function (resolveOrReject, context, args) {
var dfd = $.Deferred(),
promise = dfd.promise();
context = context || this.options.context || promise;
if (resolveOrReject === true) {
dfd.resolveWith(context, args);
} else if (resolveOrReject === false) {
dfd.rejectWith(context, args);
}
promise.abort = dfd.promise;
return this._enhancePromise(promise);
},
// Adds convenience methods to the data callback argument:
_addConvenienceMethods: function (e, data) {
var that = this,
getPromise = function (args) {
return $.Deferred().resolveWith(that, args).promise();
};
data.process = function (resolveFunc, rejectFunc) {
if (resolveFunc || rejectFunc) {
data._processQueue = this._processQueue =
(this._processQueue || getPromise([this])).pipe(
function () {
if (data.errorThrown) {
return $.Deferred()
.rejectWith(that, [data]).promise();
}
return getPromise(arguments);
}
).pipe(resolveFunc, rejectFunc);
}
return this._processQueue || getPromise([this]);
};
data.submit = function () {
if (this.state() !== 'pending') {
data.jqXHR = this.jqXHR =
(that._trigger(
'submit',
$.Event('submit', {delegatedEvent: e}),
this
) !== false) && that._onSend(e, this);
}
return this.jqXHR || that._getXHRPromise();
};
data.abort = function () {
if (this.jqXHR) {
return this.jqXHR.abort();
}
this.errorThrown = 'abort';
that._trigger('fail', null, this);
return that._getXHRPromise(false);
};
data.state = function () {
if (this.jqXHR) {
return that._getDeferredState(this.jqXHR);
}
if (this._processQueue) {
return that._getDeferredState(this._processQueue);
}
};
data.processing = function () {
return !this.jqXHR && this._processQueue && that
._getDeferredState(this._processQueue) === 'pending';
};
data.progress = function () {
return this._progress;
};
data.response = function () {
return this._response;
};
},
// Parses the Range header from the server response
// and returns the uploaded bytes:
_getUploadedBytes: function (jqXHR) {
var range = jqXHR.getResponseHeader('Range'),
parts = range && range.split('-'),
upperBytesPos = parts && parts.length > 1 &&
parseInt(parts[1], 10);
return upperBytesPos && upperBytesPos + 1;
},
// Uploads a file in multiple, sequential requests
// by splitting the file up in multiple blob chunks.
// If the second parameter is true, only tests if the file
// should be uploaded in chunks, but does not invoke any
// upload requests:
_chunkedUpload: function (options, testOnly) {
options.uploadedBytes = options.uploadedBytes || 0;
var that = this,
file = options.files[0],
fs = file.size,
ub = options.uploadedBytes,
mcs = options.maxChunkSize || fs,
slice = this._blobSlice,
dfd = $.Deferred(),
promise = dfd.promise(),
jqXHR,
upload;
if (!(this._isXHRUpload(options) && slice && (ub || mcs < fs)) ||
options.data) {
return false;
}
if (testOnly) {
return true;
}
if (ub >= fs) {
file.error = options.i18n('uploadedBytes');
return this._getXHRPromise(
false,
options.context,
[null, 'error', file.error]
);
}
// The chunk upload method:
upload = function () {
// Clone the options object for each chunk upload:
var o = $.extend({}, options),
currentLoaded = o._progress.loaded;
o.blob = slice.call(
file,
ub,
ub + mcs,
file.type
);
// Store the current chunk size, as the blob itself
// will be dereferenced after data processing:
o.chunkSize = o.blob.size;
// Expose the chunk bytes position range:
o.contentRange = 'bytes ' + ub + '-' +
(ub + o.chunkSize - 1) + '/' + fs;
// Process the upload data (the blob and potential form data):
that._initXHRData(o);
// Add progress listeners for this chunk upload:
that._initProgressListener(o);
jqXHR = ((that._trigger('chunksend', null, o) !== false && $.ajax(o)) ||
that._getXHRPromise(false, o.context))
.done(function (result, textStatus, jqXHR) {
ub = that._getUploadedBytes(jqXHR) ||
(ub + o.chunkSize);
// Create a progress event if no final progress event
// with loaded equaling total has been triggered
// for this chunk:
if (currentLoaded + o.chunkSize - o._progress.loaded) {
that._onProgress($.Event('progress', {
lengthComputable: true,
loaded: ub - o.uploadedBytes,
total: ub - o.uploadedBytes
}), o);
}
options.uploadedBytes = o.uploadedBytes = ub;
o.result = result;
o.textStatus = textStatus;
o.jqXHR = jqXHR;
that._trigger('chunkdone', null, o);
that._trigger('chunkalways', null, o);
if (ub < fs) {
// File upload not yet complete,
// continue with the next chunk:
upload();
} else {
dfd.resolveWith(
o.context,
[result, textStatus, jqXHR]
);
}
})
.fail(function (jqXHR, textStatus, errorThrown) {
o.jqXHR = jqXHR;
o.textStatus = textStatus;
o.errorThrown = errorThrown;
that._trigger('chunkfail', null, o);
that._trigger('chunkalways', null, o);
dfd.rejectWith(
o.context,
[jqXHR, textStatus, errorThrown]
);
});
};
this._enhancePromise(promise);
promise.abort = function () {
return jqXHR.abort();
};
upload();
return promise;
},
_beforeSend: function (e, data) {
if (this._active === 0) {
// the start callback is triggered when an upload starts
// and no other uploads are currently running,
// equivalent to the global ajaxStart event:
this._trigger('start');
// Set timer for global bitrate progress calculation:
this._bitrateTimer = new this._BitrateTimer();
// Reset the global progress values:
this._progress.loaded = this._progress.total = 0;
this._progress.bitrate = 0;
}
// Make sure the container objects for the .response() and
// .progress() methods on the data object are available
// and reset to their initial state:
this._initResponseObject(data);
this._initProgressObject(data);
data._progress.loaded = data.loaded = data.uploadedBytes || 0;
data._progress.total = data.total = this._getTotal(data.files) || 1;
data._progress.bitrate = data.bitrate = 0;
this._active += 1;
// Initialize the global progress values:
this._progress.loaded += data.loaded;
this._progress.total += data.total;
},
_onDone: function (result, textStatus, jqXHR, options) {
var total = options._progress.total,
response = options._response;
if (options._progress.loaded < total) {
// Create a progress event if no final progress event
// with loaded equaling total has been triggered:
this._onProgress($.Event('progress', {
lengthComputable: true,
loaded: total,
total: total
}), options);
}
response.result = options.result = result;
response.textStatus = options.textStatus = textStatus;
response.jqXHR = options.jqXHR = jqXHR;
this._trigger('done', null, options);
},
_onFail: function (jqXHR, textStatus, errorThrown, options) {
var response = options._response;
if (options.recalculateProgress) {
// Remove the failed (error or abort) file upload from
// the global progress calculation:
this._progress.loaded -= options._progress.loaded;
this._progress.total -= options._progress.total;
}
response.jqXHR = options.jqXHR = jqXHR;
response.textStatus = options.textStatus = textStatus;
response.errorThrown = options.errorThrown = errorThrown;
this._trigger('fail', null, options);
},
_onAlways: function (jqXHRorResult, textStatus, jqXHRorError, options) {
// jqXHRorResult, textStatus and jqXHRorError are added to the
// options object via done and fail callbacks
this._trigger('always', null, options);
},
_onSend: function (e, data) {
if (!data.submit) {
this._addConvenienceMethods(e, data);
}
var that = this,
jqXHR,
aborted,
slot,
pipe,
options = that._getAJAXSettings(data),
send = function () {
that._sending += 1;
// Set timer for bitrate progress calculation:
options._bitrateTimer = new that._BitrateTimer();
jqXHR = jqXHR || (
((aborted || that._trigger(
'send',
$.Event('send', {delegatedEvent: e}),
options
) === false) &&
that._getXHRPromise(false, options.context, aborted)) ||
that._chunkedUpload(options) || $.ajax(options)
).done(function (result, textStatus, jqXHR) {
that._onDone(result, textStatus, jqXHR, options);
}).fail(function (jqXHR, textStatus, errorThrown) {
that._onFail(jqXHR, textStatus, errorThrown, options);
}).always(function (jqXHRorResult, textStatus, jqXHRorError) {
that._onAlways(
jqXHRorResult,
textStatus,
jqXHRorError,
options
);
that._sending -= 1;
that._active -= 1;
if (options.limitConcurrentUploads &&
options.limitConcurrentUploads > that._sending) {
// Start the next queued upload,
// that has not been aborted:
var nextSlot = that._slots.shift();
while (nextSlot) {
if (that._getDeferredState(nextSlot) === 'pending') {
nextSlot.resolve();
break;
}
nextSlot = that._slots.shift();
}
}
if (that._active === 0) {
// The stop callback is triggered when all uploads have
// been completed, equivalent to the global ajaxStop event:
that._trigger('stop');
}
});
return jqXHR;
};
this._beforeSend(e, options);
if (this.options.sequentialUploads ||
(this.options.limitConcurrentUploads &&
this.options.limitConcurrentUploads <= this._sending)) {
if (this.options.limitConcurrentUploads > 1) {
slot = $.Deferred();
this._slots.push(slot);
pipe = slot.pipe(send);
} else {
this._sequence = this._sequence.pipe(send, send);
pipe = this._sequence;
}
// Return the piped Promise object, enhanced with an abort method,
// which is delegated to the jqXHR object of the current upload,
// and jqXHR callbacks mapped to the equivalent Promise methods:
pipe.abort = function () {
aborted = [undefined, 'abort', 'abort'];
if (!jqXHR) {
if (slot) {
slot.rejectWith(options.context, aborted);
}
return send();
}
return jqXHR.abort();
};
return this._enhancePromise(pipe);
}
return send();
},
_onAdd: function (e, data) {
var that = this,
result = true,
options = $.extend({}, this.options, data),
files = data.files,
filesLength = files.length,
limit = options.limitMultiFileUploads,
limitSize = options.limitMultiFileUploadSize,
overhead = options.limitMultiFileUploadSizeOverhead,
batchSize = 0,
paramName = this._getParamName(options),
paramNameSet,
paramNameSlice,
fileSet,
i,
j = 0;
if (!filesLength) {
return false;
}
if (limitSize && files[0].size === undefined) {
limitSize = undefined;
}
if (!(options.singleFileUploads || limit || limitSize) ||
!this._isXHRUpload(options)) {
fileSet = [files];
paramNameSet = [paramName];
} else if (!(options.singleFileUploads || limitSize) && limit) {
fileSet = [];
paramNameSet = [];
for (i = 0; i < filesLength; i += limit) {
fileSet.push(files.slice(i, i + limit));
paramNameSlice = paramName.slice(i, i + limit);
if (!paramNameSlice.length) {
paramNameSlice = paramName;
}
paramNameSet.push(paramNameSlice);
}
} else if (!options.singleFileUploads && limitSize) {
fileSet = [];
paramNameSet = [];
for (i = 0; i < filesLength; i = i + 1) {
batchSize += files[i].size + overhead;
if (i + 1 === filesLength ||
((batchSize + files[i + 1].size + overhead) > limitSize) ||
(limit && i + 1 - j >= limit)) {
fileSet.push(files.slice(j, i + 1));
paramNameSlice = paramName.slice(j, i + 1);
if (!paramNameSlice.length) {
paramNameSlice = paramName;
}
paramNameSet.push(paramNameSlice);
j = i + 1;
batchSize = 0;
}
}
} else {
paramNameSet = paramName;
}
data.originalFiles = files;
$.each(fileSet || files, function (index, element) {
var newData = $.extend({}, data);
newData.files = fileSet ? element : [element];
newData.paramName = paramNameSet[index];
that._initResponseObject(newData);
that._initProgressObject(newData);
that._addConvenienceMethods(e, newData);
result = that._trigger(
'add',
$.Event('add', {delegatedEvent: e}),
newData
);
return result;
});
return result;
},
_replaceFileInput: function (data) {
var input = data.fileInput,
inputClone = input.clone(true);
// Add a reference for the new cloned file input to the data argument:
data.fileInputClone = inputClone;
$('
').append(inputClone)[0].reset();
// Detaching allows to insert the fileInput on another form
// without loosing the file input value:
input.after(inputClone).detach();
// Avoid memory leaks with the detached file input:
$.cleanData(input.unbind('remove'));
// Replace the original file input element in the fileInput
// elements set with the clone, which has been copied including
// event handlers:
this.options.fileInput = this.options.fileInput.map(function (i, el) {
if (el === input[0]) {
return inputClone[0];
}
return el;
});
// If the widget has been initialized on the file input itself,
// override this.element with the file input clone:
if (input[0] === this.element[0]) {
this.element = inputClone;
}
},
_handleFileTreeEntry: function (entry, path) {
var that = this,
dfd = $.Deferred(),
errorHandler = function (e) {
if (e && !e.entry) {
e.entry = entry;
}
// Since $.when returns immediately if one
// Deferred is rejected, we use resolve instead.
// This allows valid files and invalid items
// to be returned together in one set:
dfd.resolve([e]);
},
successHandler = function (entries) {
that._handleFileTreeEntries(
entries,
path + entry.name + '/'
).done(function (files) {
dfd.resolve(files);
}).fail(errorHandler);
},
readEntries = function () {
dirReader.readEntries(function (results) {
if (!results.length) {
successHandler(entries);
} else {
entries = entries.concat(results);
readEntries();
}
}, errorHandler);
},
dirReader, entries = [];
path = path || '';
if (entry.isFile) {
if (entry._file) {
// Workaround for Chrome bug #149735
entry._file.relativePath = path;
dfd.resolve(entry._file);
} else {
entry.file(function (file) {
file.relativePath = path;
dfd.resolve(file);
}, errorHandler);
}
} else if (entry.isDirectory) {
dirReader = entry.createReader();
readEntries();
} else {
// Return an empy list for file system items
// other than files or directories:
dfd.resolve([]);
}
return dfd.promise();
},
_handleFileTreeEntries: function (entries, path) {
var that = this;
return $.when.apply(
$,
$.map(entries, function (entry) {
return that._handleFileTreeEntry(entry, path);
})
).pipe(function () {
return Array.prototype.concat.apply(
[],
arguments
);
});
},
_getDroppedFiles: function (dataTransfer) {
dataTransfer = dataTransfer || {};
var items = dataTransfer.items;
if (items && items.length && (items[0].webkitGetAsEntry ||
items[0].getAsEntry)) {
return this._handleFileTreeEntries(
$.map(items, function (item) {
var entry;
if (item.webkitGetAsEntry) {
entry = item.webkitGetAsEntry();
if (entry) {
// Workaround for Chrome bug #149735:
entry._file = item.getAsFile();
}
return entry;
}
return item.getAsEntry();
})
);
}
return $.Deferred().resolve(
$.makeArray(dataTransfer.files)
).promise();
},
_getSingleFileInputFiles: function (fileInput) {
fileInput = $(fileInput);
var entries = fileInput.prop('webkitEntries') ||
fileInput.prop('entries'),
files,
value;
if (entries && entries.length) {
return this._handleFileTreeEntries(entries);
}
files = $.makeArray(fileInput.prop('files'));
if (!files.length) {
value = fileInput.prop('value');
if (!value) {
return $.Deferred().resolve([]).promise();
}
// If the files property is not available, the browser does not
// support the File API and we add a pseudo File object with
// the input value as name with path information removed:
files = [{name: value.replace(/^.*\\/, '')}];
} else if (files[0].name === undefined && files[0].fileName) {
// File normalization for Safari 4 and Firefox 3:
$.each(files, function (index, file) {
file.name = file.fileName;
file.size = file.fileSize;
});
}
return $.Deferred().resolve(files).promise();
},
_getFileInputFiles: function (fileInput) {
if (!(fileInput instanceof $) || fileInput.length === 1) {
return this._getSingleFileInputFiles(fileInput);
}
return $.when.apply(
$,
$.map(fileInput, this._getSingleFileInputFiles)
).pipe(function () {
return Array.prototype.concat.apply(
[],
arguments
);
});
},
_onChange: function (e) {
var that = this,
data = {
fileInput: $(e.target),
form: $(e.target.form)
};
this._getFileInputFiles(data.fileInput).always(function (files) {
data.files = files;
if (that.options.replaceFileInput) {
that._replaceFileInput(data);
}
if (that._trigger(
'change',
$.Event('change', {delegatedEvent: e}),
data
) !== false) {
that._onAdd(e, data);
}
});
},
_onPaste: function (e) {
var items = e.originalEvent && e.originalEvent.clipboardData &&
e.originalEvent.clipboardData.items,
data = {files: []};
if (items && items.length) {
$.each(items, function (index, item) {
var file = item.getAsFile && item.getAsFile();
if (file) {
data.files.push(file);
}
});
if (this._trigger(
'paste',
$.Event('paste', {delegatedEvent: e}),
data
) !== false) {
this._onAdd(e, data);
}
}
},
_onDrop: function (e) {
e.dataTransfer = e.originalEvent && e.originalEvent.dataTransfer;
var that = this,
dataTransfer = e.dataTransfer,
data = {};
if (dataTransfer && dataTransfer.files && dataTransfer.files.length) {
e.preventDefault();
this._getDroppedFiles(dataTransfer).always(function (files) {
data.files = files;
if (that._trigger(
'drop',
$.Event('drop', {delegatedEvent: e}),
data
) !== false) {
that._onAdd(e, data);
}
});
}
},
_onDragOver: getDragHandler('dragover'),
_onDragEnter: getDragHandler('dragenter'),
_onDragLeave: getDragHandler('dragleave'),
_initEventHandlers: function () {
if (this._isXHRUpload(this.options)) {
this._on(this.options.dropZone, {
dragover: this._onDragOver,
drop: this._onDrop,
// event.preventDefault() on dragenter is required for IE10+:
dragenter: this._onDragEnter,
// dragleave is not required, but added for completeness:
dragleave: this._onDragLeave
});
this._on(this.options.pasteZone, {
paste: this._onPaste
});
}
if ($.support.fileInput) {
this._on(this.options.fileInput, {
change: this._onChange
});
}
},
_destroyEventHandlers: function () {
this._off(this.options.dropZone, 'dragenter dragleave dragover drop');
this._off(this.options.pasteZone, 'paste');
this._off(this.options.fileInput, 'change');
},
_setOption: function (key, value) {
var reinit = $.inArray(key, this._specialOptions) !== -1;
if (reinit) {
this._destroyEventHandlers();
}
this._super(key, value);
if (reinit) {
this._initSpecialOptions();
this._initEventHandlers();
}
},
_initSpecialOptions: function () {
var options = this.options;
if (options.fileInput === undefined) {
options.fileInput = this.element.is('input[type="file"]') ?
this.element : this.element.find('input[type="file"]');
} else if (!(options.fileInput instanceof $)) {
options.fileInput = $(options.fileInput);
}
if (!(options.dropZone instanceof $)) {
options.dropZone = $(options.dropZone);
}
if (!(options.pasteZone instanceof $)) {
options.pasteZone = $(options.pasteZone);
}
},
_getRegExp: function (str) {
var parts = str.split('/'),
modifiers = parts.pop();
parts.shift();
return new RegExp(parts.join('/'), modifiers);
},
_isRegExpOption: function (key, value) {
return key !== 'url' && $.type(value) === 'string' &&
/^\/.*\/[igm]{0,3}$/.test(value);
},
_initDataAttributes: function () {
var that = this,
options = this.options,
data = this.element.data();
// Initialize options set via HTML5 data-attributes:
$.each(
this.element[0].attributes,
function (index, attr) {
var key = attr.name.toLowerCase(),
value;
if (/^data-/.test(key)) {
// Convert hyphen-ated key to camelCase:
key = key.slice(5).replace(/-[a-z]/g, function (str) {
return str.charAt(1).toUpperCase();
});
value = data[key];
if (that._isRegExpOption(key, value)) {
value = that._getRegExp(value);
}
options[key] = value;
}
}
);
},
_create: function () {
this._initDataAttributes();
this._initSpecialOptions();
this._slots = [];
this._sequence = this._getXHRPromise(true);
this._sending = this._active = 0;
this._initProgressObject(this);
this._initEventHandlers();
},
// This method is exposed to the widget API and allows to query
// the number of active uploads:
active: function () {
return this._active;
},
// This method is exposed to the widget API and allows to query
// the widget upload progress.
// It returns an object with loaded, total and bitrate properties
// for the running uploads:
progress: function () {
return this._progress;
},
// This method is exposed to the widget API and allows adding files
// using the fileupload API. The data parameter accepts an object which
// must have a files property and can contain additional options:
// .fileupload('add', {files: filesList});
add: function (data) {
var that = this;
if (!data || this.options.disabled) {
return;
}
if (data.fileInput && !data.files) {
this._getFileInputFiles(data.fileInput).always(function (files) {
data.files = files;
that._onAdd(null, data);
});
} else {
data.files = $.makeArray(data.files);
this._onAdd(null, data);
}
},
// This method is exposed to the widget API and allows sending files
// using the fileupload API. The data parameter accepts an object which
// must have a files or fileInput property and can contain additional options:
// .fileupload('send', {files: filesList});
// The method returns a Promise object for the file upload call.
send: function (data) {
if (data && !this.options.disabled) {
if (data.fileInput && !data.files) {
var that = this,
dfd = $.Deferred(),
promise = dfd.promise(),
jqXHR,
aborted;
promise.abort = function () {
aborted = true;
if (jqXHR) {
return jqXHR.abort();
}
dfd.reject(null, 'abort', 'abort');
return promise;
};
this._getFileInputFiles(data.fileInput).always(
function (files) {
if (aborted) {
return;
}
if (!files.length) {
dfd.reject();
return;
}
data.files = files;
jqXHR = that._onSend(null, data);
jqXHR.then(
function (result, textStatus, jqXHR) {
dfd.resolve(result, textStatus, jqXHR);
},
function (jqXHR, textStatus, errorThrown) {
dfd.reject(jqXHR, textStatus, errorThrown);
}
);
}
);
return this._enhancePromise(promise);
}
data.files = $.makeArray(data.files);
if (data.files.length) {
return this._onSend(null, data);
}
}
return this._getXHRPromise(false, data && data.context);
}
});
}));
/*
* jQuery Iframe Transport Plugin 1.6.1
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2011, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/
/*jslint unparam: true, nomen: true */
/*global define, window, document */
(function (factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module:
define(['jquery'], factory);
} else {
// Browser globals:
factory(window.jQuery);
}
}(function ($) {
'use strict';
// Helper variable to create unique names for the transport iframes:
var counter = 0;
// The iframe transport accepts three additional options:
// options.fileInput: a jQuery collection of file input fields
// options.paramName: the parameter name for the file form data,
// overrides the name property of the file input field(s),
// can be a string or an array of strings.
// options.formData: an array of objects with name and value properties,
// equivalent to the return data of .serializeArray(), e.g.:
// [{name: 'a', value: 1}, {name: 'b', value: 2}]
$.ajaxTransport('iframe', function (options) {
if (options.async) {
var form,
iframe,
addParamChar;
return {
send: function (_, completeCallback) {
form = $('
');
form.attr('accept-charset', options.formAcceptCharset);
addParamChar = /\?/.test(options.url) ? '&' : '?';
// XDomainRequest only supports GET and POST:
if (options.type === 'DELETE') {
options.url = options.url + addParamChar + '_method=DELETE';
options.type = 'POST';
} else if (options.type === 'PUT') {
options.url = options.url + addParamChar + '_method=PUT';
options.type = 'POST';
} else if (options.type === 'PATCH') {
options.url = options.url + addParamChar + '_method=PATCH';
options.type = 'POST';
}
// javascript:false as initial iframe src
// prevents warning popups on HTTPS in IE6.
// IE versions below IE8 cannot set the name property of
// elements that have already been added to the DOM,
// so we set the name along with the iframe HTML markup:
iframe = $(
'
'
).bind('load', function () {
var fileInputClones,
paramNames = $.isArray(options.paramName) ?
options.paramName : [options.paramName];
iframe
.unbind('load')
.bind('load', function () {
var response;
// Wrap in a try/catch block to catch exceptions thrown
// when trying to access cross-domain iframe contents:
try {
response = iframe.contents();
// Google Chrome and Firefox do not throw an
// exception when calling iframe.contents() on
// cross-domain requests, so we unify the response:
if (!response.length || !response[0].firstChild) {
throw new Error();
}
} catch (e) {
response = undefined;
}
// The complete callback returns the
// iframe content document as response object:
completeCallback(
200,
'success',
{'iframe': response}
);
// Fix for IE endless progress bar activity bug
// (happens on form submits to iframe targets):
$('
')
.appendTo(form);
form.remove();
});
form
.prop('target', iframe.prop('name'))
.prop('action', options.url)
.prop('method', options.type);
if (options.formData) {
$.each(options.formData, function (index, field) {
$('
')
.prop('name', field.name)
.val(field.value)
.appendTo(form);
});
}
if (options.fileInput && options.fileInput.length &&
options.type === 'POST') {
fileInputClones = options.fileInput.clone();
// Insert a clone for each file input field:
options.fileInput.after(function (index) {
return fileInputClones[index];
});
if (options.paramName) {
options.fileInput.each(function (index) {
$(this).prop(
'name',
paramNames[index] || options.paramName
);
});
}
// Appending the file input fields to the hidden form
// removes them from their original location:
form
.append(options.fileInput)
.prop('enctype', 'multipart/form-data')
// enctype must be set as encoding for IE:
.prop('encoding', 'multipart/form-data');
}
form.submit();
// Insert the file input fields at their original location
// by replacing the clones with the originals:
if (fileInputClones && fileInputClones.length) {
options.fileInput.each(function (index, input) {
var clone = $(fileInputClones[index]);
$(input).prop('name', clone.prop('name'));
clone.replaceWith(input);
});
}
});
form.append(iframe).appendTo(document.body);
},
abort: function () {
if (iframe) {
// javascript:false as iframe src aborts the request
// and prevents warning popups on HTTPS in IE6.
// concat is used to avoid the "Script URL" JSLint error:
iframe
.unbind('load')
.prop('src', 'javascript'.concat(':false;'));
}
if (form) {
form.remove();
}
}
};
}
});
// The iframe transport returns the iframe content document as response.
// The following adds converters from iframe to text, json, html, and script:
$.ajaxSetup({
converters: {
'iframe text': function (iframe) {
return iframe && $(iframe[0].body).text();
},
'iframe json': function (iframe) {
return iframe && $.parseJSON($(iframe[0].body).text());
},
'iframe html': function (iframe) {
return iframe && $(iframe[0].body).html();
},
'iframe script': function (iframe) {
return iframe && $.globalEval($(iframe[0].body).text());
}
}
});
}));
(function($, undefined) {
/**
* Unobtrusive scripting adapter for jQuery
* https://github.com/rails/jquery-ujs
*
* Requires jQuery 1.8.0 or later.
*
* Released under the MIT license
*
*/
// Cut down on the number of issues from people inadvertently including jquery_ujs twice
// by detecting and raising an error when it happens.
if ( $.rails !== undefined ) {
$.error('jquery-ujs has already been loaded!');
}
// Shorthand to make it a little easier to call public rails functions from within rails.js
var rails;
var $document = $(document);
$.rails = rails = {
// Link elements bound by jquery-ujs
linkClickSelector: 'a[data-confirm], a[data-method], a[data-remote], a[data-disable-with], a[data-disable]',
// Button elements bound by jquery-ujs
buttonClickSelector: 'button[data-remote]:not(form button), button[data-confirm]:not(form button)',
// Select elements bound by jquery-ujs
inputChangeSelector: 'select[data-remote], input[data-remote], textarea[data-remote]',
// Form elements bound by jquery-ujs
formSubmitSelector: 'form',
// Form input elements bound by jquery-ujs
formInputClickSelector: 'form input[type=submit], form input[type=image], form button[type=submit], form button:not([type]), input[type=submit][form], input[type=image][form], button[type=submit][form], button[form]:not([type])',
// Form input elements disabled during form submission
disableSelector: 'input[data-disable-with]:enabled, button[data-disable-with]:enabled, textarea[data-disable-with]:enabled, input[data-disable]:enabled, button[data-disable]:enabled, textarea[data-disable]:enabled',
// Form input elements re-enabled after form submission
enableSelector: 'input[data-disable-with]:disabled, button[data-disable-with]:disabled, textarea[data-disable-with]:disabled, input[data-disable]:disabled, button[data-disable]:disabled, textarea[data-disable]:disabled',
// Form required input elements
requiredInputSelector: 'input[name][required]:not([disabled]),textarea[name][required]:not([disabled])',
// Form file input elements
fileInputSelector: 'input[type=file]',
// Link onClick disable selector with possible reenable after remote submission
linkDisableSelector: 'a[data-disable-with], a[data-disable]',
// Button onClick disable selector with possible reenable after remote submission
buttonDisableSelector: 'button[data-remote][data-disable-with], button[data-remote][data-disable]',
// Make sure that every Ajax request sends the CSRF token
CSRFProtection: function(xhr) {
var token = $('meta[name="csrf-token"]').attr('content');
if (token) xhr.setRequestHeader('X-CSRF-Token', token);
},
// making sure that all forms have actual up-to-date token(cached forms contain old one)
refreshCSRFTokens: function(){
var csrfToken = $('meta[name=csrf-token]').attr('content');
var csrfParam = $('meta[name=csrf-param]').attr('content');
$('form input[name="' + csrfParam + '"]').val(csrfToken);
},
// Triggers an event on an element and returns false if the event result is false
fire: function(obj, name, data) {
var event = $.Event(name);
obj.trigger(event, data);
return event.result !== false;
},
// Default confirm dialog, may be overridden with custom confirm dialog in $.rails.confirm
confirm: function(message) {
return confirm(message);
},
// Default ajax function, may be overridden with custom function in $.rails.ajax
ajax: function(options) {
return $.ajax(options);
},
// Default way to get an element's href. May be overridden at $.rails.href.
href: function(element) {
return element.attr('href');
},
// Submits "remote" forms and links with ajax
handleRemote: function(element) {
var method, url, data, elCrossDomain, crossDomain, withCredentials, dataType, options;
if (rails.fire(element, 'ajax:before')) {
elCrossDomain = element.data('cross-domain');
crossDomain = elCrossDomain === undefined ? null : elCrossDomain;
withCredentials = element.data('with-credentials') || null;
dataType = element.data('type') || ($.ajaxSettings && $.ajaxSettings.dataType);
if (element.is('form')) {
method = element.attr('method');
url = element.attr('action');
data = element.serializeArray();
// memoized value from clicked submit button
var button = element.data('ujs:submit-button');
if (button) {
data.push(button);
element.data('ujs:submit-button', null);
}
} else if (element.is(rails.inputChangeSelector)) {
method = element.data('method');
url = element.data('url');
data = element.serialize();
if (element.data('params')) data = data + "&" + element.data('params');
} else if (element.is(rails.buttonClickSelector)) {
method = element.data('method') || 'get';
url = element.data('url');
data = element.serialize();
if (element.data('params')) data = data + "&" + element.data('params');
} else {
method = element.data('method');
url = rails.href(element);
data = element.data('params') || null;
}
options = {
type: method || 'GET', data: data, dataType: dataType,
// stopping the "ajax:beforeSend" event will cancel the ajax request
beforeSend: function(xhr, settings) {
if (settings.dataType === undefined) {
xhr.setRequestHeader('accept', '*/*;q=0.5, ' + settings.accepts.script);
}
if (rails.fire(element, 'ajax:beforeSend', [xhr, settings])) {
element.trigger('ajax:send', xhr);
} else {
return false;
}
},
success: function(data, status, xhr) {
element.trigger('ajax:success', [data, status, xhr]);
},
complete: function(xhr, status) {
element.trigger('ajax:complete', [xhr, status]);
},
error: function(xhr, status, error) {
element.trigger('ajax:error', [xhr, status, error]);
},
crossDomain: crossDomain
};
// There is no withCredentials for IE6-8 when
// "Enable native XMLHTTP support" is disabled
if (withCredentials) {
options.xhrFields = {
withCredentials: withCredentials
};
}
// Only pass url to `ajax` options if not blank
if (url) { options.url = url; }
return rails.ajax(options);
} else {
return false;
}
},
// Handles "data-method" on links such as:
//
Delete
handleMethod: function(link) {
var href = rails.href(link),
method = link.data('method'),
target = link.attr('target'),
csrfToken = $('meta[name=csrf-token]').attr('content'),
csrfParam = $('meta[name=csrf-param]').attr('content'),
form = $('
'),
metadataInput = '
';
if (csrfParam !== undefined && csrfToken !== undefined) {
metadataInput += '
';
}
if (target) { form.attr('target', target); }
form.hide().append(metadataInput).appendTo('body');
form.submit();
},
// Helper function that returns form elements that match the specified CSS selector
// If form is actually a "form" element this will return associated elements outside the from that have
// the html form attribute set
formElements: function(form, selector) {
return form.is('form') ? $(form[0].elements).filter(selector) : form.find(selector);
},
/* Disables form elements:
- Caches element value in 'ujs:enable-with' data store
- Replaces element text with value of 'data-disable-with' attribute
- Sets disabled property to true
*/
disableFormElements: function(form) {
rails.formElements(form, rails.disableSelector).each(function() {
rails.disableFormElement($(this));
});
},
disableFormElement: function(element) {
var method, replacement;
method = element.is('button') ? 'html' : 'val';
replacement = element.data('disable-with');
element.data('ujs:enable-with', element[method]());
if (replacement !== undefined) {
element[method](replacement);
}
element.prop('disabled', true);
},
/* Re-enables disabled form elements:
- Replaces element text with cached value from 'ujs:enable-with' data store (created in `disableFormElements`)
- Sets disabled property to false
*/
enableFormElements: function(form) {
rails.formElements(form, rails.enableSelector).each(function() {
rails.enableFormElement($(this));
});
},
enableFormElement: function(element) {
var method = element.is('button') ? 'html' : 'val';
if (element.data('ujs:enable-with')) element[method](element.data('ujs:enable-with'));
element.prop('disabled', false);
},
/* For 'data-confirm' attribute:
- Fires `confirm` event
- Shows the confirmation dialog
- Fires the `confirm:complete` event
Returns `true` if no function stops the chain and user chose yes; `false` otherwise.
Attaching a handler to the element's `confirm` event that returns a `falsy` value cancels the confirmation dialog.
Attaching a handler to the element's `confirm:complete` event that returns a `falsy` value makes this function
return false. The `confirm:complete` event is fired whether or not the user answered true or false to the dialog.
*/
allowAction: function(element) {
var message = element.data('confirm'),
answer = false, callback;
if (!message) { return true; }
if (rails.fire(element, 'confirm')) {
answer = rails.confirm(message);
callback = rails.fire(element, 'confirm:complete', [answer]);
}
return answer && callback;
},
// Helper function which checks for blank inputs in a form that match the specified CSS selector
blankInputs: function(form, specifiedSelector, nonBlank) {
var inputs = $(), input, valueToCheck,
selector = specifiedSelector || 'input,textarea',
allInputs = form.find(selector);
allInputs.each(function() {
input = $(this);
valueToCheck = input.is('input[type=checkbox],input[type=radio]') ? input.is(':checked') : input.val();
// If nonBlank and valueToCheck are both truthy, or nonBlank and valueToCheck are both falsey
if (!valueToCheck === !nonBlank) {
// Don't count unchecked required radio if other radio with same name is checked
if (input.is('input[type=radio]') && allInputs.filter('input[type=radio]:checked[name="' + input.attr('name') + '"]').length) {
return true; // Skip to next input
}
inputs = inputs.add(input);
}
});
return inputs.length ? inputs : false;
},
// Helper function which checks for non-blank inputs in a form that match the specified CSS selector
nonBlankInputs: function(form, specifiedSelector) {
return rails.blankInputs(form, specifiedSelector, true); // true specifies nonBlank
},
// Helper function, needed to provide consistent behavior in IE
stopEverything: function(e) {
$(e.target).trigger('ujs:everythingStopped');
e.stopImmediatePropagation();
return false;
},
// replace element's html with the 'data-disable-with' after storing original html
// and prevent clicking on it
disableElement: function(element) {
var replacement = element.data('disable-with');
element.data('ujs:enable-with', element.html()); // store enabled state
if (replacement !== undefined) {
element.html(replacement);
}
element.bind('click.railsDisable', function(e) { // prevent further clicking
return rails.stopEverything(e);
});
},
// restore element to its original state which was disabled by 'disableElement' above
enableElement: function(element) {
if (element.data('ujs:enable-with') !== undefined) {
element.html(element.data('ujs:enable-with')); // set to old enabled state
element.removeData('ujs:enable-with'); // clean up cache
}
element.unbind('click.railsDisable'); // enable element
}
};
if (rails.fire($document, 'rails:attachBindings')) {
$.ajaxPrefilter(function(options, originalOptions, xhr){ if ( !options.crossDomain ) { rails.CSRFProtection(xhr); }});
// This event works the same as the load event, except that it fires every
// time the page is loaded.
//
// See https://github.com/rails/jquery-ujs/issues/357
// See https://developer.mozilla.org/en-US/docs/Using_Firefox_1.5_caching
$(window).on("pageshow.rails", function () {
$($.rails.enableSelector).each(function () {
var element = $(this);
if (element.data("ujs:enable-with")) {
$.rails.enableFormElement(element);
}
});
$($.rails.linkDisableSelector).each(function () {
var element = $(this);
if (element.data("ujs:enable-with")) {
$.rails.enableElement(element);
}
});
});
$document.delegate(rails.linkDisableSelector, 'ajax:complete', function() {
rails.enableElement($(this));
});
$document.delegate(rails.buttonDisableSelector, 'ajax:complete', function() {
rails.enableFormElement($(this));
});
$document.delegate(rails.linkClickSelector, 'click.rails', function(e) {
var link = $(this), method = link.data('method'), data = link.data('params'), metaClick = e.metaKey || e.ctrlKey;
if (!rails.allowAction(link)) return rails.stopEverything(e);
if (!metaClick && link.is(rails.linkDisableSelector)) rails.disableElement(link);
if (link.data('remote') !== undefined) {
if (metaClick && (!method || method === 'GET') && !data) { return true; }
var handleRemote = rails.handleRemote(link);
// response from rails.handleRemote() will either be false or a deferred object promise.
if (handleRemote === false) {
rails.enableElement(link);
} else {
handleRemote.fail( function() { rails.enableElement(link); } );
}
return false;
} else if (method) {
rails.handleMethod(link);
return false;
}
});
$document.delegate(rails.buttonClickSelector, 'click.rails', function(e) {
var button = $(this);
if (!rails.allowAction(button)) return rails.stopEverything(e);
if (button.is(rails.buttonDisableSelector)) rails.disableFormElement(button);
var handleRemote = rails.handleRemote(button);
// response from rails.handleRemote() will either be false or a deferred object promise.
if (handleRemote === false) {
rails.enableFormElement(button);
} else {
handleRemote.fail( function() { rails.enableFormElement(button); } );
}
return false;
});
$document.delegate(rails.inputChangeSelector, 'change.rails', function(e) {
var link = $(this);
if (!rails.allowAction(link)) return rails.stopEverything(e);
rails.handleRemote(link);
return false;
});
$document.delegate(rails.formSubmitSelector, 'submit.rails', function(e) {
var form = $(this),
remote = form.data('remote') !== undefined,
blankRequiredInputs,
nonBlankFileInputs;
if (!rails.allowAction(form)) return rails.stopEverything(e);
// skip other logic when required values are missing or file upload is present
if (form.attr('novalidate') == undefined) {
blankRequiredInputs = rails.blankInputs(form, rails.requiredInputSelector);
if (blankRequiredInputs && rails.fire(form, 'ajax:aborted:required', [blankRequiredInputs])) {
return rails.stopEverything(e);
}
}
if (remote) {
nonBlankFileInputs = rails.nonBlankInputs(form, rails.fileInputSelector);
if (nonBlankFileInputs) {
// slight timeout so that the submit button gets properly serialized
// (make it easy for event handler to serialize form without disabled values)
setTimeout(function(){ rails.disableFormElements(form); }, 13);
var aborted = rails.fire(form, 'ajax:aborted:file', [nonBlankFileInputs]);
// re-enable form elements if event bindings return false (canceling normal form submission)
if (!aborted) { setTimeout(function(){ rails.enableFormElements(form); }, 13); }
return aborted;
}
rails.handleRemote(form);
return false;
} else {
// slight timeout so that the submit button gets properly serialized
setTimeout(function(){ rails.disableFormElements(form); }, 13);
}
});
$document.delegate(rails.formInputClickSelector, 'click.rails', function(event) {
var button = $(this);
if (!rails.allowAction(button)) return rails.stopEverything(event);
// register the pressed submit button
var name = button.attr('name'),
data = name ? {name:name, value:button.val()} : null;
button.closest('form').data('ujs:submit-button', data);
});
$document.delegate(rails.formSubmitSelector, 'ajax:send.rails', function(event) {
if (this == event.target) rails.disableFormElements($(this));
});
$document.delegate(rails.formSubmitSelector, 'ajax:complete.rails', function(event) {
if (this == event.target) rails.enableFormElements($(this));
});
$(function(){
rails.refreshCSRFTokens();
});
}
})( jQuery );
//script: pointer config
(function() {
var permissionsContent, pointerContent;
$.extend(decko.editorContentFunctionMap, {
'.pointer-select': function() {
return pointerContent(this.val());
},
'.pointer-multiselect': function() {
return pointerContent(this.val());
},
'.pointer-radio-list': function() {
return pointerContent(this.find('input:checked').val());
},
'.pointer-list-ul': function() {
return pointerContent(this.find('input').map(function() {
return $(this).val();
}));
},
'.pointer-checkbox-list': function() {
return pointerContent(this.find('input:checked').map(function() {
return $(this).val();
}));
},
'.pointer-select-list': function() {
return pointerContent(this.find('.pointer-select select').map(function() {
return $(this).val();
}));
},
'._pointer-filtered-list': function() {
return pointerContent(this.find('._filtered-list-item').map(function() {
return $(this).data('cardName');
}));
},
'.perm-editor': function() {
return permissionsContent(this);
}
});
decko.editorInitFunctionMap['.pointer-list-editor'] = function() {
this.sortable({
handle: '.handle',
cancel: ''
});
return decko.initPointerList(this.find('input'));
};
decko.editorInitFunctionMap['._pointer-filtered-list'] = function() {
return this.sortable({
handle: '._handle',
cancel: ''
});
};
$.extend(decko, {
initPointerList: function(input) {
return decko.initAutoCardPlete(input);
},
initAutoCardPlete: function(input) {
var optionsCard, url;
optionsCard = input.data('options-card');
if (!optionsCard) {
return;
}
url = decko.rootPath + '/' + optionsCard + '.json?view=name_complete';
return input.autocomplete({
source: decko.prepUrl(url)
});
},
pointerContent: function(vals) {
var list;
list = $.map($.makeArray(vals), function(v) {
if (v) {
return '[[' + v + ']]';
}
});
return $.makeArray(list).join("\n");
}
});
pointerContent = function(vals) {
return decko.pointerContent(vals);
};
permissionsContent = function(ed) {
var groups, indivs;
if (ed.find('#inherit').is(':checked')) {
return '_left';
}
groups = ed.find('.perm-group input:checked').map(function() {
return $(this).val();
});
indivs = ed.find('.perm-indiv input').map(function() {
return $(this).val();
});
return pointerContent($.makeArray(groups).concat($.makeArray(indivs)));
};
}).call(this);
//script: ace config
(function() {
var aceEditorContent;
decko.addEditor('.ace-editor-textarea', function() {
return decko.initAce($(this));
}, function() {
return aceEditorContent(this[0]);
});
$.extend(decko, {
setAceConfig: function(string) {
var setter;
setter = function() {
try {
return $.parseJSON(string);
} catch (error) {
return {};
}
};
return decko.aceConfig = setter();
},
configAceEditor: function(editor, mode) {
var conf, hard_conf, user_conf;
conf = {
showGutter: true,
theme: "ace/theme/github",
printMargin: false,
tabSize: 2,
useSoftTabs: true,
maxLines: 30
};
hard_conf = {
mode: "ace/mode/" + mode
};
user_conf = decko.aceConfig != null ? decko.aceConfig : {};
$.extend(conf, user_conf['default'], user_conf[mode], hard_conf);
return editor.setOptions(conf);
},
initAce: function(textarea) {
var editDiv, editor, mode;
mode = textarea.attr("data-ace-mode");
if (!mode) {
textarea.autosize();
return;
}
editDiv = $("
", {
position: "absolute",
width: "auto",
height: textarea.height()
}).insertBefore(textarea);
textarea.css("visibility", "hidden");
textarea.css("height", "0px");
ace.config.set('basePath', '/assets/ace');
editor = ace.edit(editDiv[0]);
editor.getSession().setValue(textarea.val());
decko.configAceEditor(editor, mode);
}
});
aceEditorContent = function(element) {
var ace_div, editor;
ace_div = $(element).siblings(".ace_editor");
editor = ace.edit(ace_div[0]);
return editor.getSession().getValue();
};
$.extend(decko, {
initProseMirror: function(el_id) {
var conf, hard_conf, user_conf;
conf = {
menuBar: true,
tooltipMenu: false
};
hard_conf = {
docFormat: "html"
};
user_conf = decko.proseMirrorConfig != null ? decko.proseMirrorConfig : {};
$.extend(conf, user_conf, hard_conf);
return createProseMirror(el_id, conf);
}
});
}).call(this);
//script: prosemirror config
(function() {
var prosemirrorContent;
decko.addEditor('.prosemirror-editor', function() {
return decko.initProseMirror(this[0].id);
}, function() {
return prosemirrorContent(this[0].id);
});
$.extend(decko, {
setProseMirrorConfig: function(string) {
var setter;
setter = function() {
try {
return $.parseJSON(string);
} catch (error) {
return {};
}
};
return decko.proseMirrorConfig = setter();
},
initProseMirror: function(el_id) {
var conf, hard_conf, user_conf;
conf = {
menuBar: true,
tooltipMenu: false
};
hard_conf = {
docFormat: "html"
};
user_conf = decko.proseMirrorConfig != null ? decko.proseMirrorConfig : {};
$.extend(conf, user_conf, hard_conf);
return createProseMirror(el_id, conf);
}
});
prosemirrorContent = function(id) {
var content;
content = getProseMirrorContent(id);
if (content === '
') {
return '';
}
return content;
};
}).call(this);
//script: tinymce config
(function() {
decko.addEditor('.tinymce-textarea', function() {
return decko.initTinyMCE(this[0].id);
}, function() {
return tinyMCE.get(this[0].id).getContent();
});
$.extend(decko, {
setTinyMCEConfig: function(string) {
var setter;
setter = function() {
try {
return $.parseJSON(string);
} catch (error) {
return {};
}
};
return decko.tinyMCEConfig = setter();
},
initTinyMCE: function(el_id) {
var conf, hard_conf, user_conf;
conf = {
theme: "modern",
plugins: 'autoresize',
autoresize_max_height: 500
};
user_conf = decko.tinyMCEConfig != null ? decko.tinyMCEConfig : {};
hard_conf = {
selector: "#" + el_id,
branding: false,
content_css: decko.cssPath,
entity_encoding: 'raw'
};
$.extend(conf, user_conf, hard_conf);
tinyMCE.baseURL = '/assets/tinymce';
tinyMCE.suffix = '.min';
tinyMCE.remove("#" + el_id);
return tinyMCE.init(conf);
}
});
}).call(this);
//script: ace
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */
/**
* Define a module along with a payload
* @param module a name for the payload
* @param payload a function to call with (require, exports, module) params
*/
(function() {
var ACE_NAMESPACE = "";
var global = (function() {
return this;
})();
if (!ACE_NAMESPACE && typeof requirejs !== "undefined")
return;
var _define = function(module, deps, payload) {
if (typeof module !== 'string') {
if (_define.original)
_define.original.apply(window, arguments);
else {
console.error('dropping module because define wasn\'t a string.');
console.trace();
}
return;
}
if (arguments.length == 2)
payload = deps;
if (!_define.modules) {
_define.modules = {};
_define.payloads = {};
}
_define.payloads[module] = payload;
_define.modules[module] = null;
};
/**
* Get at functionality define()ed using the function above
*/
var _require = function(parentId, module, callback) {
if (Object.prototype.toString.call(module) === "[object Array]") {
var params = [];
for (var i = 0, l = module.length; i < l; ++i) {
var dep = lookup(parentId, module[i]);
if (!dep && _require.original)
return _require.original.apply(window, arguments);
params.push(dep);
}
if (callback) {
callback.apply(null, params);
}
}
else if (typeof module === 'string') {
var payload = lookup(parentId, module);
if (!payload && _require.original)
return _require.original.apply(window, arguments);
if (callback) {
callback();
}
return payload;
}
else {
if (_require.original)
return _require.original.apply(window, arguments);
}
};
var normalizeModule = function(parentId, moduleName) {
// normalize plugin requires
if (moduleName.indexOf("!") !== -1) {
var chunks = moduleName.split("!");
return normalizeModule(parentId, chunks[0]) + "!" + normalizeModule(parentId, chunks[1]);
}
// normalize relative requires
if (moduleName.charAt(0) == ".") {
var base = parentId.split("/").slice(0, -1).join("/");
moduleName = base + "/" + moduleName;
while(moduleName.indexOf(".") !== -1 && previous != moduleName) {
var previous = moduleName;
moduleName = moduleName.replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "");
}
}
return moduleName;
};
/**
* Internal function to lookup moduleNames and resolve them by calling the
* definition function if needed.
*/
var lookup = function(parentId, moduleName) {
moduleName = normalizeModule(parentId, moduleName);
var module = _define.modules[moduleName];
if (!module) {
module = _define.payloads[moduleName];
if (typeof module === 'function') {
var exports = {};
var mod = {
id: moduleName,
uri: '',
exports: exports,
packaged: true
};
var req = function(module, callback) {
return _require(moduleName, module, callback);
};
var returnValue = module(req, exports, mod);
exports = returnValue || mod.exports;
_define.modules[moduleName] = exports;
delete _define.payloads[moduleName];
}
module = _define.modules[moduleName] = exports || module;
}
return module;
};
function exportAce(ns) {
var require = function(module, callback) {
return _require("", module, callback);
};
var root = global;
if (ns) {
if (!global[ns])
global[ns] = {};
root = global[ns];
}
if (!root.define || !root.define.packaged) {
_define.original = root.define;
root.define = _define;
root.define.packaged = true;
}
if (!root.require || !root.require.packaged) {
_require.original = root.require;
root.require = require;
root.require.packaged = true;
}
}
exportAce(ACE_NAMESPACE);
})();
define("ace/lib/regexp",["require","exports","module"], function(require, exports, module) {
"use strict";
var real = {
exec: RegExp.prototype.exec,
test: RegExp.prototype.test,
match: String.prototype.match,
replace: String.prototype.replace,
split: String.prototype.split
},
compliantExecNpcg = real.exec.call(/()??/, "")[1] === undefined, // check `exec` handling of nonparticipating capturing groups
compliantLastIndexIncrement = function () {
var x = /^/g;
real.test.call(x, "");
return !x.lastIndex;
}();
if (compliantLastIndexIncrement && compliantExecNpcg)
return;
RegExp.prototype.exec = function (str) {
var match = real.exec.apply(this, arguments),
name, r2;
if ( typeof(str) == 'string' && match) {
if (!compliantExecNpcg && match.length > 1 && indexOf(match, "") > -1) {
r2 = RegExp(this.source, real.replace.call(getNativeFlags(this), "g", ""));
real.replace.call(str.slice(match.index), r2, function () {
for (var i = 1; i < arguments.length - 2; i++) {
if (arguments[i] === undefined)
match[i] = undefined;
}
});
}
if (this._xregexp && this._xregexp.captureNames) {
for (var i = 1; i < match.length; i++) {
name = this._xregexp.captureNames[i - 1];
if (name)
match[name] = match[i];
}
}
if (!compliantLastIndexIncrement && this.global && !match[0].length && (this.lastIndex > match.index))
this.lastIndex--;
}
return match;
};
if (!compliantLastIndexIncrement) {
RegExp.prototype.test = function (str) {
var match = real.exec.call(this, str);
if (match && this.global && !match[0].length && (this.lastIndex > match.index))
this.lastIndex--;
return !!match;
};
}
function getNativeFlags (regex) {
return (regex.global ? "g" : "") +
(regex.ignoreCase ? "i" : "") +
(regex.multiline ? "m" : "") +
(regex.extended ? "x" : "") + // Proposed for ES4; included in AS3
(regex.sticky ? "y" : "");
}
function indexOf (array, item, from) {
if (Array.prototype.indexOf) // Use the native array method if available
return array.indexOf(item, from);
for (var i = from || 0; i < array.length; i++) {
if (array[i] === item)
return i;
}
return -1;
}
});
define("ace/lib/es5-shim",["require","exports","module"], function(require, exports, module) {
function Empty() {}
if (!Function.prototype.bind) {
Function.prototype.bind = function bind(that) { // .length is 1
var target = this;
if (typeof target != "function") {
throw new TypeError("Function.prototype.bind called on incompatible " + target);
}
var args = slice.call(arguments, 1); // for normal call
var bound = function () {
if (this instanceof bound) {
var result = target.apply(
this,
args.concat(slice.call(arguments))
);
if (Object(result) === result) {
return result;
}
return this;
} else {
return target.apply(
that,
args.concat(slice.call(arguments))
);
}
};
if(target.prototype) {
Empty.prototype = target.prototype;
bound.prototype = new Empty();
Empty.prototype = null;
}
return bound;
};
}
var call = Function.prototype.call;
var prototypeOfArray = Array.prototype;
var prototypeOfObject = Object.prototype;
var slice = prototypeOfArray.slice;
var _toString = call.bind(prototypeOfObject.toString);
var owns = call.bind(prototypeOfObject.hasOwnProperty);
var defineGetter;
var defineSetter;
var lookupGetter;
var lookupSetter;
var supportsAccessors;
if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
defineGetter = call.bind(prototypeOfObject.__defineGetter__);
defineSetter = call.bind(prototypeOfObject.__defineSetter__);
lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
}
if ([1,2].splice(0).length != 2) {
if(function() { // test IE < 9 to splice bug - see issue #138
function makeArray(l) {
var a = new Array(l+2);
a[0] = a[1] = 0;
return a;
}
var array = [], lengthBefore;
array.splice.apply(array, makeArray(20));
array.splice.apply(array, makeArray(26));
lengthBefore = array.length; //46
array.splice(5, 0, "XXX"); // add one element
lengthBefore + 1 == array.length
if (lengthBefore + 1 == array.length) {
return true;// has right splice implementation without bugs
}
}()) {//IE 6/7
var array_splice = Array.prototype.splice;
Array.prototype.splice = function(start, deleteCount) {
if (!arguments.length) {
return [];
} else {
return array_splice.apply(this, [
start === void 0 ? 0 : start,
deleteCount === void 0 ? (this.length - start) : deleteCount
].concat(slice.call(arguments, 2)))
}
};
} else {//IE8
Array.prototype.splice = function(pos, removeCount){
var length = this.length;
if (pos > 0) {
if (pos > length)
pos = length;
} else if (pos == void 0) {
pos = 0;
} else if (pos < 0) {
pos = Math.max(length + pos, 0);
}
if (!(pos+removeCount < length))
removeCount = length - pos;
var removed = this.slice(pos, pos+removeCount);
var insert = slice.call(arguments, 2);
var add = insert.length;
if (pos === length) {
if (add) {
this.push.apply(this, insert);
}
} else {
var remove = Math.min(removeCount, length - pos);
var tailOldPos = pos + remove;
var tailNewPos = tailOldPos + add - remove;
var tailCount = length - tailOldPos;
var lengthAfterRemove = length - remove;
if (tailNewPos < tailOldPos) { // case A
for (var i = 0; i < tailCount; ++i) {
this[tailNewPos+i] = this[tailOldPos+i];
}
} else if (tailNewPos > tailOldPos) { // case B
for (i = tailCount; i--; ) {
this[tailNewPos+i] = this[tailOldPos+i];
}
} // else, add == remove (nothing to do)
if (add && pos === lengthAfterRemove) {
this.length = lengthAfterRemove; // truncate array
this.push.apply(this, insert);
} else {
this.length = lengthAfterRemove + add; // reserves space
for (i = 0; i < add; ++i) {
this[pos+i] = insert[i];
}
}
}
return removed;
};
}
}
if (!Array.isArray) {
Array.isArray = function isArray(obj) {
return _toString(obj) == "[object Array]";
};
}
var boxedString = Object("a"),
splitString = boxedString[0] != "a" || !(0 in boxedString);
if (!Array.prototype.forEach) {
Array.prototype.forEach = function forEach(fun /*, thisp*/) {
var object = toObject(this),
self = splitString && _toString(this) == "[object String]" ?
this.split("") :
object,
thisp = arguments[1],
i = -1,
length = self.length >>> 0;
if (_toString(fun) != "[object Function]") {
throw new TypeError(); // TODO message
}
while (++i < length) {
if (i in self) {
fun.call(thisp, self[i], i, object);
}
}
};
}
if (!Array.prototype.map) {
Array.prototype.map = function map(fun /*, thisp*/) {
var object = toObject(this),
self = splitString && _toString(this) == "[object String]" ?
this.split("") :
object,
length = self.length >>> 0,
result = Array(length),
thisp = arguments[1];
if (_toString(fun) != "[object Function]") {
throw new TypeError(fun + " is not a function");
}
for (var i = 0; i < length; i++) {
if (i in self)
result[i] = fun.call(thisp, self[i], i, object);
}
return result;
};
}
if (!Array.prototype.filter) {
Array.prototype.filter = function filter(fun /*, thisp */) {
var object = toObject(this),
self = splitString && _toString(this) == "[object String]" ?
this.split("") :
object,
length = self.length >>> 0,
result = [],
value,
thisp = arguments[1];
if (_toString(fun) != "[object Function]") {
throw new TypeError(fun + " is not a function");
}
for (var i = 0; i < length; i++) {
if (i in self) {
value = self[i];
if (fun.call(thisp, value, i, object)) {
result.push(value);
}
}
}
return result;
};
}
if (!Array.prototype.every) {
Array.prototype.every = function every(fun /*, thisp */) {
var object = toObject(this),
self = splitString && _toString(this) == "[object String]" ?
this.split("") :
object,
length = self.length >>> 0,
thisp = arguments[1];
if (_toString(fun) != "[object Function]") {
throw new TypeError(fun + " is not a function");
}
for (var i = 0; i < length; i++) {
if (i in self && !fun.call(thisp, self[i], i, object)) {
return false;
}
}
return true;
};
}
if (!Array.prototype.some) {
Array.prototype.some = function some(fun /*, thisp */) {
var object = toObject(this),
self = splitString && _toString(this) == "[object String]" ?
this.split("") :
object,
length = self.length >>> 0,
thisp = arguments[1];
if (_toString(fun) != "[object Function]") {
throw new TypeError(fun + " is not a function");
}
for (var i = 0; i < length; i++) {
if (i in self && fun.call(thisp, self[i], i, object)) {
return true;
}
}
return false;
};
}
if (!Array.prototype.reduce) {
Array.prototype.reduce = function reduce(fun /*, initial*/) {
var object = toObject(this),
self = splitString && _toString(this) == "[object String]" ?
this.split("") :
object,
length = self.length >>> 0;
if (_toString(fun) != "[object Function]") {
throw new TypeError(fun + " is not a function");
}
if (!length && arguments.length == 1) {
throw new TypeError("reduce of empty array with no initial value");
}
var i = 0;
var result;
if (arguments.length >= 2) {
result = arguments[1];
} else {
do {
if (i in self) {
result = self[i++];
break;
}
if (++i >= length) {
throw new TypeError("reduce of empty array with no initial value");
}
} while (true);
}
for (; i < length; i++) {
if (i in self) {
result = fun.call(void 0, result, self[i], i, object);
}
}
return result;
};
}
if (!Array.prototype.reduceRight) {
Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) {
var object = toObject(this),
self = splitString && _toString(this) == "[object String]" ?
this.split("") :
object,
length = self.length >>> 0;
if (_toString(fun) != "[object Function]") {
throw new TypeError(fun + " is not a function");
}
if (!length && arguments.length == 1) {
throw new TypeError("reduceRight of empty array with no initial value");
}
var result, i = length - 1;
if (arguments.length >= 2) {
result = arguments[1];
} else {
do {
if (i in self) {
result = self[i--];
break;
}
if (--i < 0) {
throw new TypeError("reduceRight of empty array with no initial value");
}
} while (true);
}
do {
if (i in this) {
result = fun.call(void 0, result, self[i], i, object);
}
} while (i--);
return result;
};
}
if (!Array.prototype.indexOf || ([0, 1].indexOf(1, 2) != -1)) {
Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) {
var self = splitString && _toString(this) == "[object String]" ?
this.split("") :
toObject(this),
length = self.length >>> 0;
if (!length) {
return -1;
}
var i = 0;
if (arguments.length > 1) {
i = toInteger(arguments[1]);
}
i = i >= 0 ? i : Math.max(0, length + i);
for (; i < length; i++) {
if (i in self && self[i] === sought) {
return i;
}
}
return -1;
};
}
if (!Array.prototype.lastIndexOf || ([0, 1].lastIndexOf(0, -3) != -1)) {
Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) {
var self = splitString && _toString(this) == "[object String]" ?
this.split("") :
toObject(this),
length = self.length >>> 0;
if (!length) {
return -1;
}
var i = length - 1;
if (arguments.length > 1) {
i = Math.min(i, toInteger(arguments[1]));
}
i = i >= 0 ? i : length - Math.abs(i);
for (; i >= 0; i--) {
if (i in self && sought === self[i]) {
return i;
}
}
return -1;
};
}
if (!Object.getPrototypeOf) {
Object.getPrototypeOf = function getPrototypeOf(object) {
return object.__proto__ || (
object.constructor ?
object.constructor.prototype :
prototypeOfObject
);
};
}
if (!Object.getOwnPropertyDescriptor) {
var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a " +
"non-object: ";
Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) {
if ((typeof object != "object" && typeof object != "function") || object === null)
throw new TypeError(ERR_NON_OBJECT + object);
if (!owns(object, property))
return;
var descriptor, getter, setter;
descriptor = { enumerable: true, configurable: true };
if (supportsAccessors) {
var prototype = object.__proto__;
object.__proto__ = prototypeOfObject;
var getter = lookupGetter(object, property);
var setter = lookupSetter(object, property);
object.__proto__ = prototype;
if (getter || setter) {
if (getter) descriptor.get = getter;
if (setter) descriptor.set = setter;
return descriptor;
}
}
descriptor.value = object[property];
return descriptor;
};
}
if (!Object.getOwnPropertyNames) {
Object.getOwnPropertyNames = function getOwnPropertyNames(object) {
return Object.keys(object);
};
}
if (!Object.create) {
var createEmpty;
if (Object.prototype.__proto__ === null) {
createEmpty = function () {
return { "__proto__": null };
};
} else {
createEmpty = function () {
var empty = {};
for (var i in empty)
empty[i] = null;
empty.constructor =
empty.hasOwnProperty =
empty.propertyIsEnumerable =
empty.isPrototypeOf =
empty.toLocaleString =
empty.toString =
empty.valueOf =
empty.__proto__ = null;
return empty;
}
}
Object.create = function create(prototype, properties) {
var object;
if (prototype === null) {
object = createEmpty();
} else {
if (typeof prototype != "object")
throw new TypeError("typeof prototype["+(typeof prototype)+"] != 'object'");
var Type = function () {};
Type.prototype = prototype;
object = new Type();
object.__proto__ = prototype;
}
if (properties !== void 0)
Object.defineProperties(object, properties);
return object;
};
}
function doesDefinePropertyWork(object) {
try {
Object.defineProperty(object, "sentinel", {});
return "sentinel" in object;
} catch (exception) {
}
}
if (Object.defineProperty) {
var definePropertyWorksOnObject = doesDefinePropertyWork({});
var definePropertyWorksOnDom = typeof document == "undefined" ||
doesDefinePropertyWork(document.createElement("div"));
if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) {
var definePropertyFallback = Object.defineProperty;
}
}
if (!Object.defineProperty || definePropertyFallback) {
var ERR_NON_OBJECT_DESCRIPTOR = "Property description must be an object: ";
var ERR_NON_OBJECT_TARGET = "Object.defineProperty called on non-object: "
var ERR_ACCESSORS_NOT_SUPPORTED = "getters & setters can not be defined " +
"on this javascript engine";
Object.defineProperty = function defineProperty(object, property, descriptor) {
if ((typeof object != "object" && typeof object != "function") || object === null)
throw new TypeError(ERR_NON_OBJECT_TARGET + object);
if ((typeof descriptor != "object" && typeof descriptor != "function") || descriptor === null)
throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor);
if (definePropertyFallback) {
try {
return definePropertyFallback.call(Object, object, property, descriptor);
} catch (exception) {
}
}
if (owns(descriptor, "value")) {
if (supportsAccessors && (lookupGetter(object, property) ||
lookupSetter(object, property)))
{
var prototype = object.__proto__;
object.__proto__ = prototypeOfObject;
delete object[property];
object[property] = descriptor.value;
object.__proto__ = prototype;
} else {
object[property] = descriptor.value;
}
} else {
if (!supportsAccessors)
throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
if (owns(descriptor, "get"))
defineGetter(object, property, descriptor.get);
if (owns(descriptor, "set"))
defineSetter(object, property, descriptor.set);
}
return object;
};
}
if (!Object.defineProperties) {
Object.defineProperties = function defineProperties(object, properties) {
for (var property in properties) {
if (owns(properties, property))
Object.defineProperty(object, property, properties[property]);
}
return object;
};
}
if (!Object.seal) {
Object.seal = function seal(object) {
return object;
};
}
if (!Object.freeze) {
Object.freeze = function freeze(object) {
return object;
};
}
try {
Object.freeze(function () {});
} catch (exception) {
Object.freeze = (function freeze(freezeObject) {
return function freeze(object) {
if (typeof object == "function") {
return object;
} else {
return freezeObject(object);
}
};
})(Object.freeze);
}
if (!Object.preventExtensions) {
Object.preventExtensions = function preventExtensions(object) {
return object;
};
}
if (!Object.isSealed) {
Object.isSealed = function isSealed(object) {
return false;
};
}
if (!Object.isFrozen) {
Object.isFrozen = function isFrozen(object) {
return false;
};
}
if (!Object.isExtensible) {
Object.isExtensible = function isExtensible(object) {
if (Object(object) === object) {
throw new TypeError(); // TODO message
}
var name = '';
while (owns(object, name)) {
name += '?';
}
object[name] = true;
var returnValue = owns(object, name);
delete object[name];
return returnValue;
};
}
if (!Object.keys) {
var hasDontEnumBug = true,
dontEnums = [
"toString",
"toLocaleString",
"valueOf",
"hasOwnProperty",
"isPrototypeOf",
"propertyIsEnumerable",
"constructor"
],
dontEnumsLength = dontEnums.length;
for (var key in {"toString": null}) {
hasDontEnumBug = false;
}
Object.keys = function keys(object) {
if (
(typeof object != "object" && typeof object != "function") ||
object === null
) {
throw new TypeError("Object.keys called on a non-object");
}
var keys = [];
for (var name in object) {
if (owns(object, name)) {
keys.push(name);
}
}
if (hasDontEnumBug) {
for (var i = 0, ii = dontEnumsLength; i < ii; i++) {
var dontEnum = dontEnums[i];
if (owns(object, dontEnum)) {
keys.push(dontEnum);
}
}
}
return keys;
};
}
if (!Date.now) {
Date.now = function now() {
return new Date().getTime();
};
}
var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
"\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
"\u2029\uFEFF";
if (!String.prototype.trim || ws.trim()) {
ws = "[" + ws + "]";
var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
trimEndRegexp = new RegExp(ws + ws + "*$");
String.prototype.trim = function trim() {
return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, "");
};
}
function toInteger(n) {
n = +n;
if (n !== n) { // isNaN
n = 0;
} else if (n !== 0 && n !== (1/0) && n !== -(1/0)) {
n = (n > 0 || -1) * Math.floor(Math.abs(n));
}
return n;
}
function isPrimitive(input) {
var type = typeof input;
return (
input === null ||
type === "undefined" ||
type === "boolean" ||
type === "number" ||
type === "string"
);
}
function toPrimitive(input) {
var val, valueOf, toString;
if (isPrimitive(input)) {
return input;
}
valueOf = input.valueOf;
if (typeof valueOf === "function") {
val = valueOf.call(input);
if (isPrimitive(val)) {
return val;
}
}
toString = input.toString;
if (typeof toString === "function") {
val = toString.call(input);
if (isPrimitive(val)) {
return val;
}
}
throw new TypeError();
}
var toObject = function (o) {
if (o == null) { // this matches both null and undefined
throw new TypeError("can't convert "+o+" to object");
}
return Object(o);
};
});
define("ace/lib/fixoldbrowsers",["require","exports","module","ace/lib/regexp","ace/lib/es5-shim"], function(require, exports, module) {
"use strict";
require("./regexp");
require("./es5-shim");
});
define("ace/lib/dom",["require","exports","module"], function(require, exports, module) {
"use strict";
if (typeof document == "undefined")
return;
var XHTML_NS = "http://www.w3.org/1999/xhtml";
exports.getDocumentHead = function(doc) {
if (!doc)
doc = document;
return doc.head || doc.getElementsByTagName("head")[0] || doc.documentElement;
}
exports.createElement = function(tag, ns) {
return document.createElementNS ?
document.createElementNS(ns || XHTML_NS, tag) :
document.createElement(tag);
};
exports.hasCssClass = function(el, name) {
var classes = (el.className || "").split(/\s+/g);
return classes.indexOf(name) !== -1;
};
exports.addCssClass = function(el, name) {
if (!exports.hasCssClass(el, name)) {
el.className += " " + name;
}
};
exports.removeCssClass = function(el, name) {
var classes = el.className.split(/\s+/g);
while (true) {
var index = classes.indexOf(name);
if (index == -1) {
break;
}
classes.splice(index, 1);
}
el.className = classes.join(" ");
};
exports.toggleCssClass = function(el, name) {
var classes = el.className.split(/\s+/g), add = true;
while (true) {
var index = classes.indexOf(name);
if (index == -1) {
break;
}
add = false;
classes.splice(index, 1);
}
if(add)
classes.push(name);
el.className = classes.join(" ");
return add;
};
exports.setCssClass = function(node, className, include) {
if (include) {
exports.addCssClass(node, className);
} else {
exports.removeCssClass(node, className);
}
};
exports.hasCssString = function(id, doc) {
var index = 0, sheets;
doc = doc || document;
if (doc.createStyleSheet && (sheets = doc.styleSheets)) {
while (index < sheets.length)
if (sheets[index++].owningElement.id === id) return true;
} else if ((sheets = doc.getElementsByTagName("style"))) {
while (index < sheets.length)
if (sheets[index++].id === id) return true;
}
return false;
};
exports.importCssString = function importCssString(cssText, id, doc) {
doc = doc || document;
if (id && exports.hasCssString(id, doc))
return null;
var style;
if (doc.createStyleSheet) {
style = doc.createStyleSheet();
style.cssText = cssText;
if (id)
style.owningElement.id = id;
} else {
style = doc.createElementNS
? doc.createElementNS(XHTML_NS, "style")
: doc.createElement("style");
style.appendChild(doc.createTextNode(cssText));
if (id)
style.id = id;
exports.getDocumentHead(doc).appendChild(style);
}
};
exports.importCssStylsheet = function(uri, doc) {
if (doc.createStyleSheet) {
doc.createStyleSheet(uri);
} else {
var link = exports.createElement('link');
link.rel = 'stylesheet';
link.href = uri;
exports.getDocumentHead(doc).appendChild(link);
}
};
exports.getInnerWidth = function(element) {
return (
parseInt(exports.computedStyle(element, "paddingLeft"), 10) +
parseInt(exports.computedStyle(element, "paddingRight"), 10) +
element.clientWidth
);
};
exports.getInnerHeight = function(element) {
return (
parseInt(exports.computedStyle(element, "paddingTop"), 10) +
parseInt(exports.computedStyle(element, "paddingBottom"), 10) +
element.clientHeight
);
};
if (window.pageYOffset !== undefined) {
exports.getPageScrollTop = function() {
return window.pageYOffset;
};
exports.getPageScrollLeft = function() {
return window.pageXOffset;
};
}
else {
exports.getPageScrollTop = function() {
return document.body.scrollTop;
};
exports.getPageScrollLeft = function() {
return document.body.scrollLeft;
};
}
if (window.getComputedStyle)
exports.computedStyle = function(element, style) {
if (style)
return (window.getComputedStyle(element, "") || {})[style] || "";
return window.getComputedStyle(element, "") || {};
};
else
exports.computedStyle = function(element, style) {
if (style)
return element.currentStyle[style];
return element.currentStyle;
};
exports.scrollbarWidth = function(document) {
var inner = exports.createElement("ace_inner");
inner.style.width = "100%";
inner.style.minWidth = "0px";
inner.style.height = "200px";
inner.style.display = "block";
var outer = exports.createElement("ace_outer");
var style = outer.style;
style.position = "absolute";
style.left = "-10000px";
style.overflow = "hidden";
style.width = "200px";
style.minWidth = "0px";
style.height = "150px";
style.display = "block";
outer.appendChild(inner);
var body = document.documentElement;
body.appendChild(outer);
var noScrollbar = inner.offsetWidth;
style.overflow = "scroll";
var withScrollbar = inner.offsetWidth;
if (noScrollbar == withScrollbar) {
withScrollbar = outer.clientWidth;
}
body.removeChild(outer);
return noScrollbar-withScrollbar;
};
exports.setInnerHtml = function(el, innerHtml) {
var element = el.cloneNode(false);//document.createElement("div");
element.innerHTML = innerHtml;
el.parentNode.replaceChild(element, el);
return element;
};
if ("textContent" in document.documentElement) {
exports.setInnerText = function(el, innerText) {
el.textContent = innerText;
};
exports.getInnerText = function(el) {
return el.textContent;
};
}
else {
exports.setInnerText = function(el, innerText) {
el.innerText = innerText;
};
exports.getInnerText = function(el) {
return el.innerText;
};
}
exports.getParentWindow = function(document) {
return document.defaultView || document.parentWindow;
};
});
define("ace/lib/oop",["require","exports","module"], function(require, exports, module) {
"use strict";
exports.inherits = function(ctor, superCtor) {
ctor.super_ = superCtor;
ctor.prototype = Object.create(superCtor.prototype, {
constructor: {
value: ctor,
enumerable: false,
writable: true,
configurable: true
}
});
};
exports.mixin = function(obj, mixin) {
for (var key in mixin) {
obj[key] = mixin[key];
}
return obj;
};
exports.implement = function(proto, mixin) {
exports.mixin(proto, mixin);
};
});
define("ace/lib/keys",["require","exports","module","ace/lib/fixoldbrowsers","ace/lib/oop"], function(require, exports, module) {
"use strict";
require("./fixoldbrowsers");
var oop = require("./oop");
var Keys = (function() {
var ret = {
MODIFIER_KEYS: {
16: 'Shift', 17: 'Ctrl', 18: 'Alt', 224: 'Meta'
},
KEY_MODS: {
"ctrl": 1, "alt": 2, "option" : 2, "shift": 4,
"super": 8, "meta": 8, "command": 8, "cmd": 8
},
FUNCTION_KEYS : {
8 : "Backspace",
9 : "Tab",
13 : "Return",
19 : "Pause",
27 : "Esc",
32 : "Space",
33 : "PageUp",
34 : "PageDown",
35 : "End",
36 : "Home",
37 : "Left",
38 : "Up",
39 : "Right",
40 : "Down",
44 : "Print",
45 : "Insert",
46 : "Delete",
96 : "Numpad0",
97 : "Numpad1",
98 : "Numpad2",
99 : "Numpad3",
100: "Numpad4",
101: "Numpad5",
102: "Numpad6",
103: "Numpad7",
104: "Numpad8",
105: "Numpad9",
'-13': "NumpadEnter",
112: "F1",
113: "F2",
114: "F3",
115: "F4",
116: "F5",
117: "F6",
118: "F7",
119: "F8",
120: "F9",
121: "F10",
122: "F11",
123: "F12",
144: "Numlock",
145: "Scrolllock"
},
PRINTABLE_KEYS: {
32: ' ', 48: '0', 49: '1', 50: '2', 51: '3', 52: '4', 53: '5',
54: '6', 55: '7', 56: '8', 57: '9', 59: ';', 61: '=', 65: 'a',
66: 'b', 67: 'c', 68: 'd', 69: 'e', 70: 'f', 71: 'g', 72: 'h',
73: 'i', 74: 'j', 75: 'k', 76: 'l', 77: 'm', 78: 'n', 79: 'o',
80: 'p', 81: 'q', 82: 'r', 83: 's', 84: 't', 85: 'u', 86: 'v',
87: 'w', 88: 'x', 89: 'y', 90: 'z', 107: '+', 109: '-', 110: '.',
187: '=', 188: ',', 189: '-', 190: '.', 191: '/', 192: '`', 219: '[',
220: '\\',221: ']', 222: '\''
}
};
var name, i;
for (i in ret.FUNCTION_KEYS) {
name = ret.FUNCTION_KEYS[i].toLowerCase();
ret[name] = parseInt(i, 10);
}
for (i in ret.PRINTABLE_KEYS) {
name = ret.PRINTABLE_KEYS[i].toLowerCase();
ret[name] = parseInt(i, 10);
}
oop.mixin(ret, ret.MODIFIER_KEYS);
oop.mixin(ret, ret.PRINTABLE_KEYS);
oop.mixin(ret, ret.FUNCTION_KEYS);
ret.enter = ret["return"];
ret.escape = ret.esc;
ret.del = ret["delete"];
ret[173] = '-';
(function() {
var mods = ["cmd", "ctrl", "alt", "shift"];
for (var i = Math.pow(2, mods.length); i--;) {
ret.KEY_MODS[i] = mods.filter(function(x) {
return i & ret.KEY_MODS[x];
}).join("-") + "-";
}
})();
ret.KEY_MODS[0] = "";
ret.KEY_MODS[-1] = "input";
return ret;
})();
oop.mixin(exports, Keys);
exports.keyCodeToString = function(keyCode) {
var keyString = Keys[keyCode];
if (typeof keyString != "string")
keyString = String.fromCharCode(keyCode);
return keyString.toLowerCase();
};
});
define("ace/lib/useragent",["require","exports","module"], function(require, exports, module) {
"use strict";
exports.OS = {
LINUX: "LINUX",
MAC: "MAC",
WINDOWS: "WINDOWS"
};
exports.getOS = function() {
if (exports.isMac) {
return exports.OS.MAC;
} else if (exports.isLinux) {
return exports.OS.LINUX;
} else {
return exports.OS.WINDOWS;
}
};
if (typeof navigator != "object")
return;
var os = (navigator.platform.match(/mac|win|linux/i) || ["other"])[0].toLowerCase();
var ua = navigator.userAgent;
exports.isWin = (os == "win");
exports.isMac = (os == "mac");
exports.isLinux = (os == "linux");
exports.isIE =
(navigator.appName == "Microsoft Internet Explorer" || navigator.appName.indexOf("MSAppHost") >= 0)
? parseFloat((ua.match(/(?:MSIE |Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1])
: parseFloat((ua.match(/(?:Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1]); // for ie
exports.isOldIE = exports.isIE && exports.isIE < 9;
exports.isGecko = exports.isMozilla = (window.Controllers || window.controllers) && window.navigator.product === "Gecko";
exports.isOldGecko = exports.isGecko && parseInt((ua.match(/rv\:(\d+)/)||[])[1], 10) < 4;
exports.isOpera = window.opera && Object.prototype.toString.call(window.opera) == "[object Opera]";
exports.isWebKit = parseFloat(ua.split("WebKit/")[1]) || undefined;
exports.isChrome = parseFloat(ua.split(" Chrome/")[1]) || undefined;
exports.isAIR = ua.indexOf("AdobeAIR") >= 0;
exports.isIPad = ua.indexOf("iPad") >= 0;
exports.isTouchPad = ua.indexOf("TouchPad") >= 0;
exports.isChromeOS = ua.indexOf(" CrOS ") >= 0;
});
define("ace/lib/event",["require","exports","module","ace/lib/keys","ace/lib/useragent"], function(require, exports, module) {
"use strict";
var keys = require("./keys");
var useragent = require("./useragent");
exports.addListener = function(elem, type, callback) {
if (elem.addEventListener) {
return elem.addEventListener(type, callback, false);
}
if (elem.attachEvent) {
var wrapper = function() {
callback.call(elem, window.event);
};
callback._wrapper = wrapper;
elem.attachEvent("on" + type, wrapper);
}
};
exports.removeListener = function(elem, type, callback) {
if (elem.removeEventListener) {
return elem.removeEventListener(type, callback, false);
}
if (elem.detachEvent) {
elem.detachEvent("on" + type, callback._wrapper || callback);
}
};
exports.stopEvent = function(e) {
exports.stopPropagation(e);
exports.preventDefault(e);
return false;
};
exports.stopPropagation = function(e) {
if (e.stopPropagation)
e.stopPropagation();
else
e.cancelBubble = true;
};
exports.preventDefault = function(e) {
if (e.preventDefault)
e.preventDefault();
else
e.returnValue = false;
};
exports.getButton = function(e) {
if (e.type == "dblclick")
return 0;
if (e.type == "contextmenu" || (useragent.isMac && (e.ctrlKey && !e.altKey && !e.shiftKey)))
return 2;
if (e.preventDefault) {
return e.button;
}
else {
return {1:0, 2:2, 4:1}[e.button];
}
};
exports.capture = function(el, eventHandler, releaseCaptureHandler) {
function onMouseUp(e) {
eventHandler && eventHandler(e);
releaseCaptureHandler && releaseCaptureHandler(e);
exports.removeListener(document, "mousemove", eventHandler, true);
exports.removeListener(document, "mouseup", onMouseUp, true);
exports.removeListener(document, "dragstart", onMouseUp, true);
}
exports.addListener(document, "mousemove", eventHandler, true);
exports.addListener(document, "mouseup", onMouseUp, true);
exports.addListener(document, "dragstart", onMouseUp, true);
return onMouseUp;
};
exports.addMouseWheelListener = function(el, callback) {
if ("onmousewheel" in el) {
exports.addListener(el, "mousewheel", function(e) {
var factor = 8;
if (e.wheelDeltaX !== undefined) {
e.wheelX = -e.wheelDeltaX / factor;
e.wheelY = -e.wheelDeltaY / factor;
} else {
e.wheelX = 0;
e.wheelY = -e.wheelDelta / factor;
}
callback(e);
});
} else if ("onwheel" in el) {
exports.addListener(el, "wheel", function(e) {
var factor = 0.35;
switch (e.deltaMode) {
case e.DOM_DELTA_PIXEL:
e.wheelX = e.deltaX * factor || 0;
e.wheelY = e.deltaY * factor || 0;
break;
case e.DOM_DELTA_LINE:
case e.DOM_DELTA_PAGE:
e.wheelX = (e.deltaX || 0) * 5;
e.wheelY = (e.deltaY || 0) * 5;
break;
}
callback(e);
});
} else {
exports.addListener(el, "DOMMouseScroll", function(e) {
if (e.axis && e.axis == e.HORIZONTAL_AXIS) {
e.wheelX = (e.detail || 0) * 5;
e.wheelY = 0;
} else {
e.wheelX = 0;
e.wheelY = (e.detail || 0) * 5;
}
callback(e);
});
}
};
exports.addMultiMouseDownListener = function(el, timeouts, eventHandler, callbackName) {
var clicks = 0;
var startX, startY, timer;
var eventNames = {
2: "dblclick",
3: "tripleclick",
4: "quadclick"
};
exports.addListener(el, "mousedown", function(e) {
if (exports.getButton(e) !== 0) {
clicks = 0;
} else if (e.detail > 1) {
clicks++;
if (clicks > 4)
clicks = 1;
} else {
clicks = 1;
}
if (useragent.isIE) {
var isNewClick = Math.abs(e.clientX - startX) > 5 || Math.abs(e.clientY - startY) > 5;
if (!timer || isNewClick)
clicks = 1;
if (timer)
clearTimeout(timer);
timer = setTimeout(function() {timer = null}, timeouts[clicks - 1] || 600);
if (clicks == 1) {
startX = e.clientX;
startY = e.clientY;
}
}
e._clicks = clicks;
eventHandler[callbackName]("mousedown", e);
if (clicks > 4)
clicks = 0;
else if (clicks > 1)
return eventHandler[callbackName](eventNames[clicks], e);
});
if (useragent.isOldIE) {
exports.addListener(el, "dblclick", function(e) {
clicks = 2;
if (timer)
clearTimeout(timer);
timer = setTimeout(function() {timer = null}, timeouts[clicks - 1] || 600);
eventHandler[callbackName]("mousedown", e);
eventHandler[callbackName](eventNames[clicks], e);
});
}
};
var getModifierHash = useragent.isMac && useragent.isOpera && !("KeyboardEvent" in window)
? function(e) {
return 0 | (e.metaKey ? 1 : 0) | (e.altKey ? 2 : 0) | (e.shiftKey ? 4 : 0) | (e.ctrlKey ? 8 : 0);
}
: function(e) {
return 0 | (e.ctrlKey ? 1 : 0) | (e.altKey ? 2 : 0) | (e.shiftKey ? 4 : 0) | (e.metaKey ? 8 : 0);
};
exports.getModifierString = function(e) {
return keys.KEY_MODS[getModifierHash(e)];
};
function normalizeCommandKeys(callback, e, keyCode) {
var hashId = getModifierHash(e);
if (!useragent.isMac && pressedKeys) {
if (pressedKeys[91] || pressedKeys[92])
hashId |= 8;
if (pressedKeys.altGr) {
if ((3 & hashId) != 3)
pressedKeys.altGr = 0;
else
return;
}
if (keyCode === 18 || keyCode === 17) {
var location = "location" in e ? e.location : e.keyLocation;
if (keyCode === 17 && location === 1) {
ts = e.timeStamp;
} else if (keyCode === 18 && hashId === 3 && location === 2) {
var dt = -ts;
ts = e.timeStamp;
dt += ts;
if (dt < 3)
pressedKeys.altGr = true;
}
}
}
if (keyCode in keys.MODIFIER_KEYS) {
switch (keys.MODIFIER_KEYS[keyCode]) {
case "Alt":
hashId = 2;
break;
case "Shift":
hashId = 4;
break;
case "Ctrl":
hashId = 1;
break;
default:
hashId = 8;
break;
}
keyCode = -1;
}
if (hashId & 8 && (keyCode === 91 || keyCode === 93)) {
keyCode = -1;
}
if (!hashId && keyCode === 13) {
var location = "location" in e ? e.location : e.keyLocation;
if (location === 3) {
callback(e, hashId, -keyCode);
if (e.defaultPrevented)
return;
}
}
if (useragent.isChromeOS && hashId & 8) {
callback(e, hashId, keyCode);
if (e.defaultPrevented)
return;
else
hashId &= ~8;
}
if (!hashId && !(keyCode in keys.FUNCTION_KEYS) && !(keyCode in keys.PRINTABLE_KEYS)) {
return false;
}
return callback(e, hashId, keyCode);
}
var pressedKeys = null;
var ts = 0;
exports.addCommandKeyListener = function(el, callback) {
var addListener = exports.addListener;
if (useragent.isOldGecko || (useragent.isOpera && !("KeyboardEvent" in window))) {
var lastKeyDownKeyCode = null;
addListener(el, "keydown", function(e) {
lastKeyDownKeyCode = e.keyCode;
});
addListener(el, "keypress", function(e) {
return normalizeCommandKeys(callback, e, lastKeyDownKeyCode);
});
} else {
var lastDefaultPrevented = null;
addListener(el, "keydown", function(e) {
pressedKeys[e.keyCode] = true;
var result = normalizeCommandKeys(callback, e, e.keyCode);
lastDefaultPrevented = e.defaultPrevented;
return result;
});
addListener(el, "keypress", function(e) {
if (lastDefaultPrevented && (e.ctrlKey || e.altKey || e.shiftKey || e.metaKey)) {
exports.stopEvent(e);
lastDefaultPrevented = null;
}
});
addListener(el, "keyup", function(e) {
pressedKeys[e.keyCode] = null;
});
if (!pressedKeys) {
pressedKeys = Object.create(null);
addListener(window, "focus", function(e) {
pressedKeys = Object.create(null);
});
}
}
};
if (window.postMessage && !useragent.isOldIE) {
var postMessageId = 1;
exports.nextTick = function(callback, win) {
win = win || window;
var messageName = "zero-timeout-message-" + postMessageId;
exports.addListener(win, "message", function listener(e) {
if (e.data == messageName) {
exports.stopPropagation(e);
exports.removeListener(win, "message", listener);
callback();
}
});
win.postMessage(messageName, "*");
};
}
exports.nextFrame = window.requestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.msRequestAnimationFrame ||
window.oRequestAnimationFrame;
if (exports.nextFrame)
exports.nextFrame = exports.nextFrame.bind(window);
else
exports.nextFrame = function(callback) {
setTimeout(callback, 17);
};
});
define("ace/lib/lang",["require","exports","module"], function(require, exports, module) {
"use strict";
exports.last = function(a) {
return a[a.length - 1];
};
exports.stringReverse = function(string) {
return string.split("").reverse().join("");
};
exports.stringRepeat = function (string, count) {
var result = '';
while (count > 0) {
if (count & 1)
result += string;
if (count >>= 1)
string += string;
}
return result;
};
var trimBeginRegexp = /^\s\s*/;
var trimEndRegexp = /\s\s*$/;
exports.stringTrimLeft = function (string) {
return string.replace(trimBeginRegexp, '');
};
exports.stringTrimRight = function (string) {
return string.replace(trimEndRegexp, '');
};
exports.copyObject = function(obj) {
var copy = {};
for (var key in obj) {
copy[key] = obj[key];
}
return copy;
};
exports.copyArray = function(array){
var copy = [];
for (var i=0, l=array.length; i
1);
return ev.preventDefault();
};
this.startSelect = function(pos, waitForClickSelection) {
pos = pos || this.editor.renderer.screenToTextCoordinates(this.x, this.y);
var editor = this.editor;
if (this.mousedownEvent.getShiftKey())
editor.selection.selectToPosition(pos);
else if (!waitForClickSelection)
editor.selection.moveToPosition(pos);
if (!waitForClickSelection)
this.select();
if (editor.renderer.scroller.setCapture) {
editor.renderer.scroller.setCapture();
}
editor.setStyle("ace_selecting");
this.setState("select");
};
this.select = function() {
var anchor, editor = this.editor;
var cursor = editor.renderer.screenToTextCoordinates(this.x, this.y);
if (this.$clickSelection) {
var cmp = this.$clickSelection.comparePoint(cursor);
if (cmp == -1) {
anchor = this.$clickSelection.end;
} else if (cmp == 1) {
anchor = this.$clickSelection.start;
} else {
var orientedRange = calcRangeOrientation(this.$clickSelection, cursor);
cursor = orientedRange.cursor;
anchor = orientedRange.anchor;
}
editor.selection.setSelectionAnchor(anchor.row, anchor.column);
}
editor.selection.selectToPosition(cursor);
editor.renderer.scrollCursorIntoView();
};
this.extendSelectionBy = function(unitName) {
var anchor, editor = this.editor;
var cursor = editor.renderer.screenToTextCoordinates(this.x, this.y);
var range = editor.selection[unitName](cursor.row, cursor.column);
if (this.$clickSelection) {
var cmpStart = this.$clickSelection.comparePoint(range.start);
var cmpEnd = this.$clickSelection.comparePoint(range.end);
if (cmpStart == -1 && cmpEnd <= 0) {
anchor = this.$clickSelection.end;
if (range.end.row != cursor.row || range.end.column != cursor.column)
cursor = range.start;
} else if (cmpEnd == 1 && cmpStart >= 0) {
anchor = this.$clickSelection.start;
if (range.start.row != cursor.row || range.start.column != cursor.column)
cursor = range.end;
} else if (cmpStart == -1 && cmpEnd == 1) {
cursor = range.end;
anchor = range.start;
} else {
var orientedRange = calcRangeOrientation(this.$clickSelection, cursor);
cursor = orientedRange.cursor;
anchor = orientedRange.anchor;
}
editor.selection.setSelectionAnchor(anchor.row, anchor.column);
}
editor.selection.selectToPosition(cursor);
editor.renderer.scrollCursorIntoView();
};
this.selectEnd =
this.selectAllEnd =
this.selectByWordsEnd =
this.selectByLinesEnd = function() {
this.$clickSelection = null;
this.editor.unsetStyle("ace_selecting");
if (this.editor.renderer.scroller.releaseCapture) {
this.editor.renderer.scroller.releaseCapture();
}
};
this.focusWait = function() {
var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
var time = Date.now();
if (distance > DRAG_OFFSET || time - this.mousedownEvent.time > this.$focusTimout)
this.startSelect(this.mousedownEvent.getDocumentPosition());
};
this.onDoubleClick = function(ev) {
var pos = ev.getDocumentPosition();
var editor = this.editor;
var session = editor.session;
var range = session.getBracketRange(pos);
if (range) {
if (range.isEmpty()) {
range.start.column--;
range.end.column++;
}
this.setState("select");
} else {
range = editor.selection.getWordRange(pos.row, pos.column);
this.setState("selectByWords");
}
this.$clickSelection = range;
this.select();
};
this.onTripleClick = function(ev) {
var pos = ev.getDocumentPosition();
var editor = this.editor;
this.setState("selectByLines");
var range = editor.getSelectionRange();
if (range.isMultiLine() && range.contains(pos.row, pos.column)) {
this.$clickSelection = editor.selection.getLineRange(range.start.row);
this.$clickSelection.end = editor.selection.getLineRange(range.end.row).end;
} else {
this.$clickSelection = editor.selection.getLineRange(pos.row);
}
this.select();
};
this.onQuadClick = function(ev) {
var editor = this.editor;
editor.selectAll();
this.$clickSelection = editor.getSelectionRange();
this.setState("selectAll");
};
this.onMouseWheel = function(ev) {
if (ev.getAccelKey())
return;
if (ev.getShiftKey() && ev.wheelY && !ev.wheelX) {
ev.wheelX = ev.wheelY;
ev.wheelY = 0;
}
var t = ev.domEvent.timeStamp;
var dt = t - (this.$lastScrollTime||0);
var editor = this.editor;
var isScrolable = editor.renderer.isScrollableBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed);
if (isScrolable || dt < 200) {
this.$lastScrollTime = t;
editor.renderer.scrollBy(ev.wheelX * ev.speed, ev.wheelY * ev.speed);
return ev.stop();
}
};
}).call(DefaultHandlers.prototype);
exports.DefaultHandlers = DefaultHandlers;
function calcDistance(ax, ay, bx, by) {
return Math.sqrt(Math.pow(bx - ax, 2) + Math.pow(by - ay, 2));
}
function calcRangeOrientation(range, cursor) {
if (range.start.row == range.end.row)
var cmp = 2 * cursor.column - range.start.column - range.end.column;
else if (range.start.row == range.end.row - 1 && !range.start.column && !range.end.column)
var cmp = cursor.column - 4;
else
var cmp = 2 * cursor.row - range.start.row - range.end.row;
if (cmp < 0)
return {cursor: range.start, anchor: range.end};
else
return {cursor: range.end, anchor: range.start};
}
});
define("ace/tooltip",["require","exports","module","ace/lib/oop","ace/lib/dom"], function(require, exports, module) {
"use strict";
var oop = require("./lib/oop");
var dom = require("./lib/dom");
function Tooltip (parentNode) {
this.isOpen = false;
this.$element = null;
this.$parentNode = parentNode;
}
(function() {
this.$init = function() {
this.$element = dom.createElement("div");
this.$element.className = "ace_tooltip";
this.$element.style.display = "none";
this.$parentNode.appendChild(this.$element);
return this.$element;
};
this.getElement = function() {
return this.$element || this.$init();
};
this.setText = function(text) {
dom.setInnerText(this.getElement(), text);
};
this.setHtml = function(html) {
this.getElement().innerHTML = html;
};
this.setPosition = function(x, y) {
this.getElement().style.left = x + "px";
this.getElement().style.top = y + "px";
};
this.setClassName = function(className) {
dom.addCssClass(this.getElement(), className);
};
this.show = function(text, x, y) {
if (text != null)
this.setText(text);
if (x != null && y != null)
this.setPosition(x, y);
if (!this.isOpen) {
this.getElement().style.display = "block";
this.isOpen = true;
}
};
this.hide = function() {
if (this.isOpen) {
this.getElement().style.display = "none";
this.isOpen = false;
}
};
this.getHeight = function() {
return this.getElement().offsetHeight;
};
this.getWidth = function() {
return this.getElement().offsetWidth;
};
}).call(Tooltip.prototype);
exports.Tooltip = Tooltip;
});
define("ace/mouse/default_gutter_handler",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/event","ace/tooltip"], function(require, exports, module) {
"use strict";
var dom = require("../lib/dom");
var oop = require("../lib/oop");
var event = require("../lib/event");
var Tooltip = require("../tooltip").Tooltip;
function GutterHandler(mouseHandler) {
var editor = mouseHandler.editor;
var gutter = editor.renderer.$gutterLayer;
var tooltip = new GutterTooltip(editor.container);
mouseHandler.editor.setDefaultHandler("guttermousedown", function(e) {
if (!editor.isFocused() || e.getButton() != 0)
return;
var gutterRegion = gutter.getRegion(e);
if (gutterRegion == "foldWidgets")
return;
var row = e.getDocumentPosition().row;
var selection = editor.session.selection;
if (e.getShiftKey())
selection.selectTo(row, 0);
else {
if (e.domEvent.detail == 2) {
editor.selectAll();
return e.preventDefault();
}
mouseHandler.$clickSelection = editor.selection.getLineRange(row);
}
mouseHandler.setState("selectByLines");
mouseHandler.captureMouse(e);
return e.preventDefault();
});
var tooltipTimeout, mouseEvent, tooltipAnnotation;
function showTooltip() {
var row = mouseEvent.getDocumentPosition().row;
var annotation = gutter.$annotations[row];
if (!annotation)
return hideTooltip();
var maxRow = editor.session.getLength();
if (row == maxRow) {
var screenRow = editor.renderer.pixelToScreenCoordinates(0, mouseEvent.y).row;
var pos = mouseEvent.$pos;
if (screenRow > editor.session.documentToScreenRow(pos.row, pos.column))
return hideTooltip();
}
if (tooltipAnnotation == annotation)
return;
tooltipAnnotation = annotation.text.join("
");
tooltip.setHtml(tooltipAnnotation);
tooltip.show();
editor.on("mousewheel", hideTooltip);
if (mouseHandler.$tooltipFollowsMouse) {
moveTooltip(mouseEvent);
} else {
var gutterElement = gutter.$cells[editor.session.documentToScreenRow(row, 0)].element;
var rect = gutterElement.getBoundingClientRect();
var style = tooltip.getElement().style;
style.left = rect.right + "px";
style.top = rect.bottom + "px";
}
}
function hideTooltip() {
if (tooltipTimeout)
tooltipTimeout = clearTimeout(tooltipTimeout);
if (tooltipAnnotation) {
tooltip.hide();
tooltipAnnotation = null;
editor.removeEventListener("mousewheel", hideTooltip);
}
}
function moveTooltip(e) {
tooltip.setPosition(e.x, e.y);
}
mouseHandler.editor.setDefaultHandler("guttermousemove", function(e) {
var target = e.domEvent.target || e.domEvent.srcElement;
if (dom.hasCssClass(target, "ace_fold-widget"))
return hideTooltip();
if (tooltipAnnotation && mouseHandler.$tooltipFollowsMouse)
moveTooltip(e);
mouseEvent = e;
if (tooltipTimeout)
return;
tooltipTimeout = setTimeout(function() {
tooltipTimeout = null;
if (mouseEvent && !mouseHandler.isMousePressed)
showTooltip();
else
hideTooltip();
}, 50);
});
event.addListener(editor.renderer.$gutter, "mouseout", function(e) {
mouseEvent = null;
if (!tooltipAnnotation || tooltipTimeout)
return;
tooltipTimeout = setTimeout(function() {
tooltipTimeout = null;
hideTooltip();
}, 50);
});
editor.on("changeSession", hideTooltip);
}
function GutterTooltip(parentNode) {
Tooltip.call(this, parentNode);
}
oop.inherits(GutterTooltip, Tooltip);
(function(){
this.setPosition = function(x, y) {
var windowWidth = window.innerWidth || document.documentElement.clientWidth;
var windowHeight = window.innerHeight || document.documentElement.clientHeight;
var width = this.getWidth();
var height = this.getHeight();
x += 15;
y += 15;
if (x + width > windowWidth) {
x -= (x + width) - windowWidth;
}
if (y + height > windowHeight) {
y -= 20 + height;
}
Tooltip.prototype.setPosition.call(this, x, y);
};
}).call(GutterTooltip.prototype);
exports.GutterHandler = GutterHandler;
});
define("ace/mouse/mouse_event",["require","exports","module","ace/lib/event","ace/lib/useragent"], function(require, exports, module) {
"use strict";
var event = require("../lib/event");
var useragent = require("../lib/useragent");
var MouseEvent = exports.MouseEvent = function(domEvent, editor) {
this.domEvent = domEvent;
this.editor = editor;
this.x = this.clientX = domEvent.clientX;
this.y = this.clientY = domEvent.clientY;
this.$pos = null;
this.$inSelection = null;
this.propagationStopped = false;
this.defaultPrevented = false;
};
(function() {
this.stopPropagation = function() {
event.stopPropagation(this.domEvent);
this.propagationStopped = true;
};
this.preventDefault = function() {
event.preventDefault(this.domEvent);
this.defaultPrevented = true;
};
this.stop = function() {
this.stopPropagation();
this.preventDefault();
};
this.getDocumentPosition = function() {
if (this.$pos)
return this.$pos;
this.$pos = this.editor.renderer.screenToTextCoordinates(this.clientX, this.clientY);
return this.$pos;
};
this.inSelection = function() {
if (this.$inSelection !== null)
return this.$inSelection;
var editor = this.editor;
var selectionRange = editor.getSelectionRange();
if (selectionRange.isEmpty())
this.$inSelection = false;
else {
var pos = this.getDocumentPosition();
this.$inSelection = selectionRange.contains(pos.row, pos.column);
}
return this.$inSelection;
};
this.getButton = function() {
return event.getButton(this.domEvent);
};
this.getShiftKey = function() {
return this.domEvent.shiftKey;
};
this.getAccelKey = useragent.isMac
? function() { return this.domEvent.metaKey; }
: function() { return this.domEvent.ctrlKey; };
}).call(MouseEvent.prototype);
});
define("ace/mouse/dragdrop_handler",["require","exports","module","ace/lib/dom","ace/lib/event","ace/lib/useragent"], function(require, exports, module) {
"use strict";
var dom = require("../lib/dom");
var event = require("../lib/event");
var useragent = require("../lib/useragent");
var AUTOSCROLL_DELAY = 200;
var SCROLL_CURSOR_DELAY = 200;
var SCROLL_CURSOR_HYSTERESIS = 5;
function DragdropHandler(mouseHandler) {
var editor = mouseHandler.editor;
var blankImage = dom.createElement("img");
blankImage.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
if (useragent.isOpera)
blankImage.style.cssText = "width:1px;height:1px;position:fixed;top:0;left:0;z-index:2147483647;opacity:0;";
var exports = ["dragWait", "dragWaitEnd", "startDrag", "dragReadyEnd", "onMouseDrag"];
exports.forEach(function(x) {
mouseHandler[x] = this[x];
}, this);
editor.addEventListener("mousedown", this.onMouseDown.bind(mouseHandler));
var mouseTarget = editor.container;
var dragSelectionMarker, x, y;
var timerId, range;
var dragCursor, counter = 0;
var dragOperation;
var isInternal;
var autoScrollStartTime;
var cursorMovedTime;
var cursorPointOnCaretMoved;
this.onDragStart = function(e) {
if (this.cancelDrag || !mouseTarget.draggable) {
var self = this;
setTimeout(function(){
self.startSelect();
self.captureMouse(e);
}, 0);
return e.preventDefault();
}
range = editor.getSelectionRange();
var dataTransfer = e.dataTransfer;
dataTransfer.effectAllowed = editor.getReadOnly() ? "copy" : "copyMove";
if (useragent.isOpera) {
editor.container.appendChild(blankImage);
blankImage.scrollTop = 0;
}
dataTransfer.setDragImage && dataTransfer.setDragImage(blankImage, 0, 0);
if (useragent.isOpera) {
editor.container.removeChild(blankImage);
}
dataTransfer.clearData();
dataTransfer.setData("Text", editor.session.getTextRange());
isInternal = true;
this.setState("drag");
};
this.onDragEnd = function(e) {
mouseTarget.draggable = false;
isInternal = false;
this.setState(null);
if (!editor.getReadOnly()) {
var dropEffect = e.dataTransfer.dropEffect;
if (!dragOperation && dropEffect == "move")
editor.session.remove(editor.getSelectionRange());
editor.renderer.$cursorLayer.setBlinking(true);
}
this.editor.unsetStyle("ace_dragging");
this.editor.renderer.setCursorStyle("");
};
this.onDragEnter = function(e) {
if (editor.getReadOnly() || !canAccept(e.dataTransfer))
return;
x = e.clientX;
y = e.clientY;
if (!dragSelectionMarker)
addDragMarker();
counter++;
e.dataTransfer.dropEffect = dragOperation = getDropEffect(e);
return event.preventDefault(e);
};
this.onDragOver = function(e) {
if (editor.getReadOnly() || !canAccept(e.dataTransfer))
return;
x = e.clientX;
y = e.clientY;
if (!dragSelectionMarker) {
addDragMarker();
counter++;
}
if (onMouseMoveTimer !== null)
onMouseMoveTimer = null;
e.dataTransfer.dropEffect = dragOperation = getDropEffect(e);
return event.preventDefault(e);
};
this.onDragLeave = function(e) {
counter--;
if (counter <= 0 && dragSelectionMarker) {
clearDragMarker();
dragOperation = null;
return event.preventDefault(e);
}
};
this.onDrop = function(e) {
if (!dragCursor)
return;
var dataTransfer = e.dataTransfer;
if (isInternal) {
switch (dragOperation) {
case "move":
if (range.contains(dragCursor.row, dragCursor.column)) {
range = {
start: dragCursor,
end: dragCursor
};
} else {
range = editor.moveText(range, dragCursor);
}
break;
case "copy":
range = editor.moveText(range, dragCursor, true);
break;
}
} else {
var dropData = dataTransfer.getData('Text');
range = {
start: dragCursor,
end: editor.session.insert(dragCursor, dropData)
};
editor.focus();
dragOperation = null;
}
clearDragMarker();
return event.preventDefault(e);
};
event.addListener(mouseTarget, "dragstart", this.onDragStart.bind(mouseHandler));
event.addListener(mouseTarget, "dragend", this.onDragEnd.bind(mouseHandler));
event.addListener(mouseTarget, "dragenter", this.onDragEnter.bind(mouseHandler));
event.addListener(mouseTarget, "dragover", this.onDragOver.bind(mouseHandler));
event.addListener(mouseTarget, "dragleave", this.onDragLeave.bind(mouseHandler));
event.addListener(mouseTarget, "drop", this.onDrop.bind(mouseHandler));
function scrollCursorIntoView(cursor, prevCursor) {
var now = Date.now();
var vMovement = !prevCursor || cursor.row != prevCursor.row;
var hMovement = !prevCursor || cursor.column != prevCursor.column;
if (!cursorMovedTime || vMovement || hMovement) {
editor.$blockScrolling += 1;
editor.moveCursorToPosition(cursor);
editor.$blockScrolling -= 1;
cursorMovedTime = now;
cursorPointOnCaretMoved = {x: x, y: y};
} else {
var distance = calcDistance(cursorPointOnCaretMoved.x, cursorPointOnCaretMoved.y, x, y);
if (distance > SCROLL_CURSOR_HYSTERESIS) {
cursorMovedTime = null;
} else if (now - cursorMovedTime >= SCROLL_CURSOR_DELAY) {
editor.renderer.scrollCursorIntoView();
cursorMovedTime = null;
}
}
}
function autoScroll(cursor, prevCursor) {
var now = Date.now();
var lineHeight = editor.renderer.layerConfig.lineHeight;
var characterWidth = editor.renderer.layerConfig.characterWidth;
var editorRect = editor.renderer.scroller.getBoundingClientRect();
var offsets = {
x: {
left: x - editorRect.left,
right: editorRect.right - x
},
y: {
top: y - editorRect.top,
bottom: editorRect.bottom - y
}
};
var nearestXOffset = Math.min(offsets.x.left, offsets.x.right);
var nearestYOffset = Math.min(offsets.y.top, offsets.y.bottom);
var scrollCursor = {row: cursor.row, column: cursor.column};
if (nearestXOffset / characterWidth <= 2) {
scrollCursor.column += (offsets.x.left < offsets.x.right ? -3 : +2);
}
if (nearestYOffset / lineHeight <= 1) {
scrollCursor.row += (offsets.y.top < offsets.y.bottom ? -1 : +1);
}
var vScroll = cursor.row != scrollCursor.row;
var hScroll = cursor.column != scrollCursor.column;
var vMovement = !prevCursor || cursor.row != prevCursor.row;
if (vScroll || (hScroll && !vMovement)) {
if (!autoScrollStartTime)
autoScrollStartTime = now;
else if (now - autoScrollStartTime >= AUTOSCROLL_DELAY)
editor.renderer.scrollCursorIntoView(scrollCursor);
} else {
autoScrollStartTime = null;
}
}
function onDragInterval() {
var prevCursor = dragCursor;
dragCursor = editor.renderer.screenToTextCoordinates(x, y);
scrollCursorIntoView(dragCursor, prevCursor);
autoScroll(dragCursor, prevCursor);
}
function addDragMarker() {
range = editor.selection.toOrientedRange();
dragSelectionMarker = editor.session.addMarker(range, "ace_selection", editor.getSelectionStyle());
editor.clearSelection();
if (editor.isFocused())
editor.renderer.$cursorLayer.setBlinking(false);
clearInterval(timerId);
onDragInterval();
timerId = setInterval(onDragInterval, 20);
counter = 0;
event.addListener(document, "mousemove", onMouseMove);
}
function clearDragMarker() {
clearInterval(timerId);
editor.session.removeMarker(dragSelectionMarker);
dragSelectionMarker = null;
editor.$blockScrolling += 1;
editor.selection.fromOrientedRange(range);
editor.$blockScrolling -= 1;
if (editor.isFocused() && !isInternal)
editor.renderer.$cursorLayer.setBlinking(!editor.getReadOnly());
range = null;
dragCursor = null;
counter = 0;
autoScrollStartTime = null;
cursorMovedTime = null;
event.removeListener(document, "mousemove", onMouseMove);
}
var onMouseMoveTimer = null;
function onMouseMove() {
if (onMouseMoveTimer == null) {
onMouseMoveTimer = setTimeout(function() {
if (onMouseMoveTimer != null && dragSelectionMarker)
clearDragMarker();
}, 20);
}
}
function canAccept(dataTransfer) {
var types = dataTransfer.types;
return !types || Array.prototype.some.call(types, function(type) {
return type == 'text/plain' || type == 'Text';
});
}
function getDropEffect(e) {
var copyAllowed = ['copy', 'copymove', 'all', 'uninitialized'];
var moveAllowed = ['move', 'copymove', 'linkmove', 'all', 'uninitialized'];
var copyModifierState = useragent.isMac ? e.altKey : e.ctrlKey;
var effectAllowed = "uninitialized";
try {
effectAllowed = e.dataTransfer.effectAllowed.toLowerCase();
} catch (e) {}
var dropEffect = "none";
if (copyModifierState && copyAllowed.indexOf(effectAllowed) >= 0)
dropEffect = "copy";
else if (moveAllowed.indexOf(effectAllowed) >= 0)
dropEffect = "move";
else if (copyAllowed.indexOf(effectAllowed) >= 0)
dropEffect = "copy";
return dropEffect;
}
}
(function() {
this.dragWait = function() {
var interval = Date.now() - this.mousedownEvent.time;
if (interval > this.editor.getDragDelay())
this.startDrag();
};
this.dragWaitEnd = function() {
var target = this.editor.container;
target.draggable = false;
this.startSelect(this.mousedownEvent.getDocumentPosition());
this.selectEnd();
};
this.dragReadyEnd = function(e) {
this.editor.renderer.$cursorLayer.setBlinking(!this.editor.getReadOnly());
this.editor.unsetStyle("ace_dragging");
this.editor.renderer.setCursorStyle("");
this.dragWaitEnd();
};
this.startDrag = function(){
this.cancelDrag = false;
var editor = this.editor;
var target = editor.container;
target.draggable = true;
editor.renderer.$cursorLayer.setBlinking(false);
editor.setStyle("ace_dragging");
var cursorStyle = useragent.isWin ? "default" : "move";
editor.renderer.setCursorStyle(cursorStyle);
this.setState("dragReady");
};
this.onMouseDrag = function(e) {
var target = this.editor.container;
if (useragent.isIE && this.state == "dragReady") {
var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
if (distance > 3)
target.dragDrop();
}
if (this.state === "dragWait") {
var distance = calcDistance(this.mousedownEvent.x, this.mousedownEvent.y, this.x, this.y);
if (distance > 0) {
target.draggable = false;
this.startSelect(this.mousedownEvent.getDocumentPosition());
}
}
};
this.onMouseDown = function(e) {
if (!this.$dragEnabled)
return;
this.mousedownEvent = e;
var editor = this.editor;
var inSelection = e.inSelection();
var button = e.getButton();
var clickCount = e.domEvent.detail || 1;
if (clickCount === 1 && button === 0 && inSelection) {
if (e.editor.inMultiSelectMode && (e.getAccelKey() || e.getShiftKey()))
return;
this.mousedownEvent.time = Date.now();
var eventTarget = e.domEvent.target || e.domEvent.srcElement;
if ("unselectable" in eventTarget)
eventTarget.unselectable = "on";
if (editor.getDragDelay()) {
if (useragent.isWebKit) {
this.cancelDrag = true;
var mouseTarget = editor.container;
mouseTarget.draggable = true;
}
this.setState("dragWait");
} else {
this.startDrag();
}
this.captureMouse(e, this.onMouseDrag.bind(this));
e.defaultPrevented = true;
}
};
}).call(DragdropHandler.prototype);
function calcDistance(ax, ay, bx, by) {
return Math.sqrt(Math.pow(bx - ax, 2) + Math.pow(by - ay, 2));
}
exports.DragdropHandler = DragdropHandler;
});
define("ace/lib/net",["require","exports","module","ace/lib/dom"], function(require, exports, module) {
"use strict";
var dom = require("./dom");
exports.get = function (url, callback) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
callback(xhr.responseText);
}
};
xhr.send(null);
};
exports.loadScript = function(path, callback) {
var head = dom.getDocumentHead();
var s = document.createElement('script');
s.src = path;
head.appendChild(s);
s.onload = s.onreadystatechange = function(_, isAbort) {
if (isAbort || !s.readyState || s.readyState == "loaded" || s.readyState == "complete") {
s = s.onload = s.onreadystatechange = null;
if (!isAbort)
callback();
}
};
};
exports.qualifyURL = function(url) {
var a = document.createElement('a');
a.href = url;
return a.href;
}
});
define("ace/lib/event_emitter",["require","exports","module"], function(require, exports, module) {
"use strict";
var EventEmitter = {};
var stopPropagation = function() { this.propagationStopped = true; };
var preventDefault = function() { this.defaultPrevented = true; };
EventEmitter._emit =
EventEmitter._dispatchEvent = function(eventName, e) {
this._eventRegistry || (this._eventRegistry = {});
this._defaultHandlers || (this._defaultHandlers = {});
var listeners = this._eventRegistry[eventName] || [];
var defaultHandler = this._defaultHandlers[eventName];
if (!listeners.length && !defaultHandler)
return;
if (typeof e != "object" || !e)
e = {};
if (!e.type)
e.type = eventName;
if (!e.stopPropagation)
e.stopPropagation = stopPropagation;
if (!e.preventDefault)
e.preventDefault = preventDefault;
listeners = listeners.slice();
for (var i=0; i 1)
base = parts[parts.length - 2];
var path = options[component + "Path"];
if (path == null) {
path = options.basePath;
} else if (sep == "/") {
component = sep = "";
}
if (path && path.slice(-1) != "/")
path += "/";
return path + component + sep + base + this.get("suffix");
};
exports.setModuleUrl = function(name, subst) {
return options.$moduleUrls[name] = subst;
};
exports.$loading = {};
exports.loadModule = function(moduleName, onLoad) {
var module, moduleType;
if (Array.isArray(moduleName)) {
moduleType = moduleName[0];
moduleName = moduleName[1];
}
try {
module = require(moduleName);
} catch (e) {}
if (module && !exports.$loading[moduleName])
return onLoad && onLoad(module);
if (!exports.$loading[moduleName])
exports.$loading[moduleName] = [];
exports.$loading[moduleName].push(onLoad);
if (exports.$loading[moduleName].length > 1)
return;
var afterLoad = function() {
require([moduleName], function(module) {
exports._emit("load.module", {name: moduleName, module: module});
var listeners = exports.$loading[moduleName];
exports.$loading[moduleName] = null;
listeners.forEach(function(onLoad) {
onLoad && onLoad(module);
});
});
};
if (!exports.get("packaged"))
return afterLoad();
net.loadScript(exports.moduleUrl(moduleName, moduleType), afterLoad);
};
init(true);function init(packaged) {
options.packaged = packaged || require.packaged || module.packaged || (global.define && define.packaged);
if (!global.document)
return "";
var scriptOptions = {};
var scriptUrl = "";
var currentScript = (document.currentScript || document._currentScript ); // native or polyfill
var currentDocument = currentScript && currentScript.ownerDocument || document;
var scripts = currentDocument.getElementsByTagName("script");
for (var i=0; i [" + this.end.row + "/" + this.end.column + "]");
};
this.contains = function(row, column) {
return this.compare(row, column) == 0;
};
this.compareRange = function(range) {
var cmp,
end = range.end,
start = range.start;
cmp = this.compare(end.row, end.column);
if (cmp == 1) {
cmp = this.compare(start.row, start.column);
if (cmp == 1) {
return 2;
} else if (cmp == 0) {
return 1;
} else {
return 0;
}
} else if (cmp == -1) {
return -2;
} else {
cmp = this.compare(start.row, start.column);
if (cmp == -1) {
return -1;
} else if (cmp == 1) {
return 42;
} else {
return 0;
}
}
};
this.comparePoint = function(p) {
return this.compare(p.row, p.column);
};
this.containsRange = function(range) {
return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0;
};
this.intersects = function(range) {
var cmp = this.compareRange(range);
return (cmp == -1 || cmp == 0 || cmp == 1);
};
this.isEnd = function(row, column) {
return this.end.row == row && this.end.column == column;
};
this.isStart = function(row, column) {
return this.start.row == row && this.start.column == column;
};
this.setStart = function(row, column) {
if (typeof row == "object") {
this.start.column = row.column;
this.start.row = row.row;
} else {
this.start.row = row;
this.start.column = column;
}
};
this.setEnd = function(row, column) {
if (typeof row == "object") {
this.end.column = row.column;
this.end.row = row.row;
} else {
this.end.row = row;
this.end.column = column;
}
};
this.inside = function(row, column) {
if (this.compare(row, column) == 0) {
if (this.isEnd(row, column) || this.isStart(row, column)) {
return false;
} else {
return true;
}
}
return false;
};
this.insideStart = function(row, column) {
if (this.compare(row, column) == 0) {
if (this.isEnd(row, column)) {
return false;
} else {
return true;
}
}
return false;
};
this.insideEnd = function(row, column) {
if (this.compare(row, column) == 0) {
if (this.isStart(row, column)) {
return false;
} else {
return true;
}
}
return false;
};
this.compare = function(row, column) {
if (!this.isMultiLine()) {
if (row === this.start.row) {
return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0);
};
}
if (row < this.start.row)
return -1;
if (row > this.end.row)
return 1;
if (this.start.row === row)
return column >= this.start.column ? 0 : -1;
if (this.end.row === row)
return column <= this.end.column ? 0 : 1;
return 0;
};
this.compareStart = function(row, column) {
if (this.start.row == row && this.start.column == column) {
return -1;
} else {
return this.compare(row, column);
}
};
this.compareEnd = function(row, column) {
if (this.end.row == row && this.end.column == column) {
return 1;
} else {
return this.compare(row, column);
}
};
this.compareInside = function(row, column) {
if (this.end.row == row && this.end.column == column) {
return 1;
} else if (this.start.row == row && this.start.column == column) {
return -1;
} else {
return this.compare(row, column);
}
};
this.clipRows = function(firstRow, lastRow) {
if (this.end.row > lastRow)
var end = {row: lastRow + 1, column: 0};
else if (this.end.row < firstRow)
var end = {row: firstRow, column: 0};
if (this.start.row > lastRow)
var start = {row: lastRow + 1, column: 0};
else if (this.start.row < firstRow)
var start = {row: firstRow, column: 0};
return Range.fromPoints(start || this.start, end || this.end);
};
this.extend = function(row, column) {
var cmp = this.compare(row, column);
if (cmp == 0)
return this;
else if (cmp == -1)
var start = {row: row, column: column};
else
var end = {row: row, column: column};
return Range.fromPoints(start || this.start, end || this.end);
};
this.isEmpty = function() {
return (this.start.row === this.end.row && this.start.column === this.end.column);
};
this.isMultiLine = function() {
return (this.start.row !== this.end.row);
};
this.clone = function() {
return Range.fromPoints(this.start, this.end);
};
this.collapseRows = function() {
if (this.end.column == 0)
return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row-1), 0)
else
return new Range(this.start.row, 0, this.end.row, 0)
};
this.toScreenRange = function(session) {
var screenPosStart = session.documentToScreenPosition(this.start);
var screenPosEnd = session.documentToScreenPosition(this.end);
return new Range(
screenPosStart.row, screenPosStart.column,
screenPosEnd.row, screenPosEnd.column
);
};
this.moveBy = function(row, column) {
this.start.row += row;
this.start.column += column;
this.end.row += row;
this.end.column += column;
};
}).call(Range.prototype);
Range.fromPoints = function(start, end) {
return new Range(start.row, start.column, end.row, end.column);
};
Range.comparePoints = comparePoints;
Range.comparePoints = function(p1, p2) {
return p1.row - p2.row || p1.column - p2.column;
};
exports.Range = Range;
});
define("ace/selection",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/lib/event_emitter","ace/range"], function(require, exports, module) {
"use strict";
var oop = require("./lib/oop");
var lang = require("./lib/lang");
var EventEmitter = require("./lib/event_emitter").EventEmitter;
var Range = require("./range").Range;
var Selection = function(session) {
this.session = session;
this.doc = session.getDocument();
this.clearSelection();
this.lead = this.selectionLead = this.doc.createAnchor(0, 0);
this.anchor = this.selectionAnchor = this.doc.createAnchor(0, 0);
var self = this;
this.lead.on("change", function(e) {
self._emit("changeCursor");
if (!self.$isEmpty)
self._emit("changeSelection");
if (!self.$keepDesiredColumnOnChange && e.old.column != e.value.column)
self.$desiredColumn = null;
});
this.selectionAnchor.on("change", function() {
if (!self.$isEmpty)
self._emit("changeSelection");
});
};
(function() {
oop.implement(this, EventEmitter);
this.isEmpty = function() {
return (this.$isEmpty || (
this.anchor.row == this.lead.row &&
this.anchor.column == this.lead.column
));
};
this.isMultiLine = function() {
if (this.isEmpty()) {
return false;
}
return this.getRange().isMultiLine();
};
this.getCursor = function() {
return this.lead.getPosition();
};
this.setSelectionAnchor = function(row, column) {
this.anchor.setPosition(row, column);
if (this.$isEmpty) {
this.$isEmpty = false;
this._emit("changeSelection");
}
};
this.getSelectionAnchor = function() {
if (this.$isEmpty)
return this.getSelectionLead();
else
return this.anchor.getPosition();
};
this.getSelectionLead = function() {
return this.lead.getPosition();
};
this.shiftSelection = function(columns) {
if (this.$isEmpty) {
this.moveCursorTo(this.lead.row, this.lead.column + columns);
return;
}
var anchor = this.getSelectionAnchor();
var lead = this.getSelectionLead();
var isBackwards = this.isBackwards();
if (!isBackwards || anchor.column !== 0)
this.setSelectionAnchor(anchor.row, anchor.column + columns);
if (isBackwards || lead.column !== 0) {
this.$moveSelection(function() {
this.moveCursorTo(lead.row, lead.column + columns);
});
}
};
this.isBackwards = function() {
var anchor = this.anchor;
var lead = this.lead;
return (anchor.row > lead.row || (anchor.row == lead.row && anchor.column > lead.column));
};
this.getRange = function() {
var anchor = this.anchor;
var lead = this.lead;
if (this.isEmpty())
return Range.fromPoints(lead, lead);
if (this.isBackwards()) {
return Range.fromPoints(lead, anchor);
}
else {
return Range.fromPoints(anchor, lead);
}
};
this.clearSelection = function() {
if (!this.$isEmpty) {
this.$isEmpty = true;
this._emit("changeSelection");
}
};
this.selectAll = function() {
var lastRow = this.doc.getLength() - 1;
this.setSelectionAnchor(0, 0);
this.moveCursorTo(lastRow, this.doc.getLine(lastRow).length);
};
this.setRange =
this.setSelectionRange = function(range, reverse) {
if (reverse) {
this.setSelectionAnchor(range.end.row, range.end.column);
this.selectTo(range.start.row, range.start.column);
} else {
this.setSelectionAnchor(range.start.row, range.start.column);
this.selectTo(range.end.row, range.end.column);
}
if (this.getRange().isEmpty())
this.$isEmpty = true;
this.$desiredColumn = null;
};
this.$moveSelection = function(mover) {
var lead = this.lead;
if (this.$isEmpty)
this.setSelectionAnchor(lead.row, lead.column);
mover.call(this);
};
this.selectTo = function(row, column) {
this.$moveSelection(function() {
this.moveCursorTo(row, column);
});
};
this.selectToPosition = function(pos) {
this.$moveSelection(function() {
this.moveCursorToPosition(pos);
});
};
this.moveTo = function(row, column) {
this.clearSelection();
this.moveCursorTo(row, column);
};
this.moveToPosition = function(pos) {
this.clearSelection();
this.moveCursorToPosition(pos);
};
this.selectUp = function() {
this.$moveSelection(this.moveCursorUp);
};
this.selectDown = function() {
this.$moveSelection(this.moveCursorDown);
};
this.selectRight = function() {
this.$moveSelection(this.moveCursorRight);
};
this.selectLeft = function() {
this.$moveSelection(this.moveCursorLeft);
};
this.selectLineStart = function() {
this.$moveSelection(this.moveCursorLineStart);
};
this.selectLineEnd = function() {
this.$moveSelection(this.moveCursorLineEnd);
};
this.selectFileEnd = function() {
this.$moveSelection(this.moveCursorFileEnd);
};
this.selectFileStart = function() {
this.$moveSelection(this.moveCursorFileStart);
};
this.selectWordRight = function() {
this.$moveSelection(this.moveCursorWordRight);
};
this.selectWordLeft = function() {
this.$moveSelection(this.moveCursorWordLeft);
};
this.getWordRange = function(row, column) {
if (typeof column == "undefined") {
var cursor = row || this.lead;
row = cursor.row;
column = cursor.column;
}
return this.session.getWordRange(row, column);
};
this.selectWord = function() {
this.setSelectionRange(this.getWordRange());
};
this.selectAWord = function() {
var cursor = this.getCursor();
var range = this.session.getAWordRange(cursor.row, cursor.column);
this.setSelectionRange(range);
};
this.getLineRange = function(row, excludeLastChar) {
var rowStart = typeof row == "number" ? row : this.lead.row;
var rowEnd;
var foldLine = this.session.getFoldLine(rowStart);
if (foldLine) {
rowStart = foldLine.start.row;
rowEnd = foldLine.end.row;
} else {
rowEnd = rowStart;
}
if (excludeLastChar === true)
return new Range(rowStart, 0, rowEnd, this.session.getLine(rowEnd).length);
else
return new Range(rowStart, 0, rowEnd + 1, 0);
};
this.selectLine = function() {
this.setSelectionRange(this.getLineRange());
};
this.moveCursorUp = function() {
this.moveCursorBy(-1, 0);
};
this.moveCursorDown = function() {
this.moveCursorBy(1, 0);
};
this.moveCursorLeft = function() {
var cursor = this.lead.getPosition(),
fold;
if (fold = this.session.getFoldAt(cursor.row, cursor.column, -1)) {
this.moveCursorTo(fold.start.row, fold.start.column);
} else if (cursor.column === 0) {
if (cursor.row > 0) {
this.moveCursorTo(cursor.row - 1, this.doc.getLine(cursor.row - 1).length);
}
}
else {
var tabSize = this.session.getTabSize();
if (this.session.isTabStop(cursor) && this.doc.getLine(cursor.row).slice(cursor.column-tabSize, cursor.column).split(" ").length-1 == tabSize)
this.moveCursorBy(0, -tabSize);
else
this.moveCursorBy(0, -1);
}
};
this.moveCursorRight = function() {
var cursor = this.lead.getPosition(),
fold;
if (fold = this.session.getFoldAt(cursor.row, cursor.column, 1)) {
this.moveCursorTo(fold.end.row, fold.end.column);
}
else if (this.lead.column == this.doc.getLine(this.lead.row).length) {
if (this.lead.row < this.doc.getLength() - 1) {
this.moveCursorTo(this.lead.row + 1, 0);
}
}
else {
var tabSize = this.session.getTabSize();
var cursor = this.lead;
if (this.session.isTabStop(cursor) && this.doc.getLine(cursor.row).slice(cursor.column, cursor.column+tabSize).split(" ").length-1 == tabSize)
this.moveCursorBy(0, tabSize);
else
this.moveCursorBy(0, 1);
}
};
this.moveCursorLineStart = function() {
var row = this.lead.row;
var column = this.lead.column;
var screenRow = this.session.documentToScreenRow(row, column);
var firstColumnPosition = this.session.screenToDocumentPosition(screenRow, 0);
var beforeCursor = this.session.getDisplayLine(
row, null, firstColumnPosition.row,
firstColumnPosition.column
);
var leadingSpace = beforeCursor.match(/^\s*/);
if (leadingSpace[0].length != column && !this.session.$useEmacsStyleLineStart)
firstColumnPosition.column += leadingSpace[0].length;
this.moveCursorToPosition(firstColumnPosition);
};
this.moveCursorLineEnd = function() {
var lead = this.lead;
var lineEnd = this.session.getDocumentLastRowColumnPosition(lead.row, lead.column);
if (this.lead.column == lineEnd.column) {
var line = this.session.getLine(lineEnd.row);
if (lineEnd.column == line.length) {
var textEnd = line.search(/\s+$/);
if (textEnd > 0)
lineEnd.column = textEnd;
}
}
this.moveCursorTo(lineEnd.row, lineEnd.column);
};
this.moveCursorFileEnd = function() {
var row = this.doc.getLength() - 1;
var column = this.doc.getLine(row).length;
this.moveCursorTo(row, column);
};
this.moveCursorFileStart = function() {
this.moveCursorTo(0, 0);
};
this.moveCursorLongWordRight = function() {
var row = this.lead.row;
var column = this.lead.column;
var line = this.doc.getLine(row);
var rightOfCursor = line.substring(column);
var match;
this.session.nonTokenRe.lastIndex = 0;
this.session.tokenRe.lastIndex = 0;
var fold = this.session.getFoldAt(row, column, 1);
if (fold) {
this.moveCursorTo(fold.end.row, fold.end.column);
return;
}
if (match = this.session.nonTokenRe.exec(rightOfCursor)) {
column += this.session.nonTokenRe.lastIndex;
this.session.nonTokenRe.lastIndex = 0;
rightOfCursor = line.substring(column);
}
if (column >= line.length) {
this.moveCursorTo(row, line.length);
this.moveCursorRight();
if (row < this.doc.getLength() - 1)
this.moveCursorWordRight();
return;
}
if (match = this.session.tokenRe.exec(rightOfCursor)) {
column += this.session.tokenRe.lastIndex;
this.session.tokenRe.lastIndex = 0;
}
this.moveCursorTo(row, column);
};
this.moveCursorLongWordLeft = function() {
var row = this.lead.row;
var column = this.lead.column;
var fold;
if (fold = this.session.getFoldAt(row, column, -1)) {
this.moveCursorTo(fold.start.row, fold.start.column);
return;
}
var str = this.session.getFoldStringAt(row, column, -1);
if (str == null) {
str = this.doc.getLine(row).substring(0, column);
}
var leftOfCursor = lang.stringReverse(str);
var match;
this.session.nonTokenRe.lastIndex = 0;
this.session.tokenRe.lastIndex = 0;
if (match = this.session.nonTokenRe.exec(leftOfCursor)) {
column -= this.session.nonTokenRe.lastIndex;
leftOfCursor = leftOfCursor.slice(this.session.nonTokenRe.lastIndex);
this.session.nonTokenRe.lastIndex = 0;
}
if (column <= 0) {
this.moveCursorTo(row, 0);
this.moveCursorLeft();
if (row > 0)
this.moveCursorWordLeft();
return;
}
if (match = this.session.tokenRe.exec(leftOfCursor)) {
column -= this.session.tokenRe.lastIndex;
this.session.tokenRe.lastIndex = 0;
}
this.moveCursorTo(row, column);
};
this.$shortWordEndIndex = function(rightOfCursor) {
var match, index = 0, ch;
var whitespaceRe = /\s/;
var tokenRe = this.session.tokenRe;
tokenRe.lastIndex = 0;
if (match = this.session.tokenRe.exec(rightOfCursor)) {
index = this.session.tokenRe.lastIndex;
} else {
while ((ch = rightOfCursor[index]) && whitespaceRe.test(ch))
index ++;
if (index < 1) {
tokenRe.lastIndex = 0;
while ((ch = rightOfCursor[index]) && !tokenRe.test(ch)) {
tokenRe.lastIndex = 0;
index ++;
if (whitespaceRe.test(ch)) {
if (index > 2) {
index--;
break;
} else {
while ((ch = rightOfCursor[index]) && whitespaceRe.test(ch))
index ++;
if (index > 2)
break;
}
}
}
}
}
tokenRe.lastIndex = 0;
return index;
};
this.moveCursorShortWordRight = function() {
var row = this.lead.row;
var column = this.lead.column;
var line = this.doc.getLine(row);
var rightOfCursor = line.substring(column);
var fold = this.session.getFoldAt(row, column, 1);
if (fold)
return this.moveCursorTo(fold.end.row, fold.end.column);
if (column == line.length) {
var l = this.doc.getLength();
do {
row++;
rightOfCursor = this.doc.getLine(row);
} while (row < l && /^\s*$/.test(rightOfCursor));
if (!/^\s+/.test(rightOfCursor))
rightOfCursor = "";
column = 0;
}
var index = this.$shortWordEndIndex(rightOfCursor);
this.moveCursorTo(row, column + index);
};
this.moveCursorShortWordLeft = function() {
var row = this.lead.row;
var column = this.lead.column;
var fold;
if (fold = this.session.getFoldAt(row, column, -1))
return this.moveCursorTo(fold.start.row, fold.start.column);
var line = this.session.getLine(row).substring(0, column);
if (column === 0) {
do {
row--;
line = this.doc.getLine(row);
} while (row > 0 && /^\s*$/.test(line));
column = line.length;
if (!/\s+$/.test(line))
line = "";
}
var leftOfCursor = lang.stringReverse(line);
var index = this.$shortWordEndIndex(leftOfCursor);
return this.moveCursorTo(row, column - index);
};
this.moveCursorWordRight = function() {
if (this.session.$selectLongWords)
this.moveCursorLongWordRight();
else
this.moveCursorShortWordRight();
};
this.moveCursorWordLeft = function() {
if (this.session.$selectLongWords)
this.moveCursorLongWordLeft();
else
this.moveCursorShortWordLeft();
};
this.moveCursorBy = function(rows, chars) {
var screenPos = this.session.documentToScreenPosition(
this.lead.row,
this.lead.column
);
if (chars === 0) {
if (this.$desiredColumn)
screenPos.column = this.$desiredColumn;
else
this.$desiredColumn = screenPos.column;
}
var docPos = this.session.screenToDocumentPosition(screenPos.row + rows, screenPos.column);
if (rows !== 0 && chars === 0 && docPos.row === this.lead.row && docPos.column === this.lead.column) {
if (this.session.lineWidgets && this.session.lineWidgets[docPos.row])
docPos.row++;
}
this.moveCursorTo(docPos.row, docPos.column + chars, chars === 0);
};
this.moveCursorToPosition = function(position) {
this.moveCursorTo(position.row, position.column);
};
this.moveCursorTo = function(row, column, keepDesiredColumn) {
var fold = this.session.getFoldAt(row, column, 1);
if (fold) {
row = fold.start.row;
column = fold.start.column;
}
this.$keepDesiredColumnOnChange = true;
this.lead.setPosition(row, column);
this.$keepDesiredColumnOnChange = false;
if (!keepDesiredColumn)
this.$desiredColumn = null;
};
this.moveCursorToScreen = function(row, column, keepDesiredColumn) {
var pos = this.session.screenToDocumentPosition(row, column);
this.moveCursorTo(pos.row, pos.column, keepDesiredColumn);
};
this.detach = function() {
this.lead.detach();
this.anchor.detach();
this.session = this.doc = null;
};
this.fromOrientedRange = function(range) {
this.setSelectionRange(range, range.cursor == range.start);
this.$desiredColumn = range.desiredColumn || this.$desiredColumn;
};
this.toOrientedRange = function(range) {
var r = this.getRange();
if (range) {
range.start.column = r.start.column;
range.start.row = r.start.row;
range.end.column = r.end.column;
range.end.row = r.end.row;
} else {
range = r;
}
range.cursor = this.isBackwards() ? range.start : range.end;
range.desiredColumn = this.$desiredColumn;
return range;
};
this.getRangeOfMovements = function(func) {
var start = this.getCursor();
try {
func.call(null, this);
var end = this.getCursor();
return Range.fromPoints(start,end);
} catch(e) {
return Range.fromPoints(start,start);
} finally {
this.moveCursorToPosition(start);
}
};
this.toJSON = function() {
if (this.rangeCount) {
var data = this.ranges.map(function(r) {
var r1 = r.clone();
r1.isBackwards = r.cursor == r.start;
return r1;
});
} else {
var data = this.getRange();
data.isBackwards = this.isBackwards();
}
return data;
};
this.fromJSON = function(data) {
if (data.start == undefined) {
if (this.rangeList) {
this.toSingleRange(data[0]);
for (var i = data.length; i--; ) {
var r = Range.fromPoints(data[i].start, data[i].end);
if (data.isBackwards)
r.cursor = r.start;
this.addRange(r, true);
}
return;
} else
data = data[0];
}
if (this.rangeList)
this.toSingleRange(data);
this.setSelectionRange(data, data.isBackwards);
};
this.isEqual = function(data) {
if ((data.length || this.rangeCount) && data.length != this.rangeCount)
return false;
if (!data.length || !this.ranges)
return this.getRange().isEqual(data);
for (var i = this.ranges.length; i--; ) {
if (!this.ranges[i].isEqual(data[i]))
return false;
}
return true;
};
}).call(Selection.prototype);
exports.Selection = Selection;
});
define("ace/tokenizer",["require","exports","module"], function(require, exports, module) {
"use strict";
var MAX_TOKEN_COUNT = 2000;
var Tokenizer = function(rules) {
this.states = rules;
this.regExps = {};
this.matchMappings = {};
for (var key in this.states) {
var state = this.states[key];
var ruleRegExps = [];
var matchTotal = 0;
var mapping = this.matchMappings[key] = {defaultToken: "text"};
var flag = "g";
var splitterRurles = [];
for (var i = 0; i < state.length; i++) {
var rule = state[i];
if (rule.defaultToken)
mapping.defaultToken = rule.defaultToken;
if (rule.caseInsensitive)
flag = "gi";
if (rule.regex == null)
continue;
if (rule.regex instanceof RegExp)
rule.regex = rule.regex.toString().slice(1, -1);
var adjustedregex = rule.regex;
var matchcount = new RegExp("(?:(" + adjustedregex + ")|(.))").exec("a").length - 2;
if (Array.isArray(rule.token)) {
if (rule.token.length == 1 || matchcount == 1) {
rule.token = rule.token[0];
} else if (matchcount - 1 != rule.token.length) {
this.reportError("number of classes and regexp groups doesn't match", {
rule: rule,
groupCount: matchcount - 1
});
rule.token = rule.token[0];
} else {
rule.tokenArray = rule.token;
rule.token = null;
rule.onMatch = this.$arrayTokens;
}
} else if (typeof rule.token == "function" && !rule.onMatch) {
if (matchcount > 1)
rule.onMatch = this.$applyToken;
else
rule.onMatch = rule.token;
}
if (matchcount > 1) {
if (/\\\d/.test(rule.regex)) {
adjustedregex = rule.regex.replace(/\\([0-9]+)/g, function(match, digit) {
return "\\" + (parseInt(digit, 10) + matchTotal + 1);
});
} else {
matchcount = 1;
adjustedregex = this.removeCapturingGroups(rule.regex);
}
if (!rule.splitRegex && typeof rule.token != "string")
splitterRurles.push(rule); // flag will be known only at the very end
}
mapping[matchTotal] = i;
matchTotal += matchcount;
ruleRegExps.push(adjustedregex);
if (!rule.onMatch)
rule.onMatch = null;
}
if (!ruleRegExps.length) {
mapping[0] = 0;
ruleRegExps.push("$");
}
splitterRurles.forEach(function(rule) {
rule.splitRegex = this.createSplitterRegexp(rule.regex, flag);
}, this);
this.regExps[key] = new RegExp("(" + ruleRegExps.join(")|(") + ")|($)", flag);
}
};
(function() {
this.$setMaxTokenCount = function(m) {
MAX_TOKEN_COUNT = m | 0;
};
this.$applyToken = function(str) {
var values = this.splitRegex.exec(str).slice(1);
var types = this.token.apply(this, values);
if (typeof types === "string")
return [{type: types, value: str}];
var tokens = [];
for (var i = 0, l = types.length; i < l; i++) {
if (values[i])
tokens[tokens.length] = {
type: types[i],
value: values[i]
};
}
return tokens;
},
this.$arrayTokens = function(str) {
if (!str)
return [];
var values = this.splitRegex.exec(str);
if (!values)
return "text";
var tokens = [];
var types = this.tokenArray;
for (var i = 0, l = types.length; i < l; i++) {
if (values[i + 1])
tokens[tokens.length] = {
type: types[i],
value: values[i + 1]
};
}
return tokens;
};
this.removeCapturingGroups = function(src) {
var r = src.replace(
/\[(?:\\.|[^\]])*?\]|\\.|\(\?[:=!]|(\()/g,
function(x, y) {return y ? "(?:" : x;}
);
return r;
};
this.createSplitterRegexp = function(src, flag) {
if (src.indexOf("(?=") != -1) {
var stack = 0;
var inChClass = false;
var lastCapture = {};
src.replace(/(\\.)|(\((?:\?[=!])?)|(\))|([\[\]])/g, function(
m, esc, parenOpen, parenClose, square, index
) {
if (inChClass) {
inChClass = square != "]";
} else if (square) {
inChClass = true;
} else if (parenClose) {
if (stack == lastCapture.stack) {
lastCapture.end = index+1;
lastCapture.stack = -1;
}
stack--;
} else if (parenOpen) {
stack++;
if (parenOpen.length != 1) {
lastCapture.stack = stack
lastCapture.start = index;
}
}
return m;
});
if (lastCapture.end != null && /^\)*$/.test(src.substr(lastCapture.end)))
src = src.substring(0, lastCapture.start) + src.substr(lastCapture.end);
}
return new RegExp(src, (flag||"").replace("g", ""));
};
this.getLineTokens = function(line, startState) {
if (startState && typeof startState != "string") {
var stack = startState.slice(0);
startState = stack[0];
if (startState === "#tmp") {
stack.shift()
startState = stack.shift()
}
} else
var stack = [];
var currentState = startState || "start";
var state = this.states[currentState];
if (!state) {
currentState = "start";
state = this.states[currentState];
}
var mapping = this.matchMappings[currentState];
var re = this.regExps[currentState];
re.lastIndex = 0;
var match, tokens = [];
var lastIndex = 0;
var matchAttempts = 0;
var token = {type: null, value: ""};
while (match = re.exec(line)) {
var type = mapping.defaultToken;
var rule = null;
var value = match[0];
var index = re.lastIndex;
if (index - value.length > lastIndex) {
var skipped = line.substring(lastIndex, index - value.length);
if (token.type == type) {
token.value += skipped;
} else {
if (token.type)
tokens.push(token);
token = {type: type, value: skipped};
}
}
for (var i = 0; i < match.length-2; i++) {
if (match[i + 1] === undefined)
continue;
rule = state[mapping[i]];
if (rule.onMatch)
type = rule.onMatch(value, currentState, stack);
else
type = rule.token;
if (rule.next) {
if (typeof rule.next == "string") {
currentState = rule.next;
} else {
currentState = rule.next(currentState, stack);
}
state = this.states[currentState];
if (!state) {
this.reportError("state doesn't exist", currentState);
currentState = "start";
state = this.states[currentState];
}
mapping = this.matchMappings[currentState];
lastIndex = index;
re = this.regExps[currentState];
re.lastIndex = index;
}
break;
}
if (value) {
if (typeof type === "string") {
if ((!rule || rule.merge !== false) && token.type === type) {
token.value += value;
} else {
if (token.type)
tokens.push(token);
token = {type: type, value: value};
}
} else if (type) {
if (token.type)
tokens.push(token);
token = {type: null, value: ""};
for (var i = 0; i < type.length; i++)
tokens.push(type[i]);
}
}
if (lastIndex == line.length)
break;
lastIndex = index;
if (matchAttempts++ > MAX_TOKEN_COUNT) {
if (matchAttempts > 2 * line.length) {
this.reportError("infinite loop with in ace tokenizer", {
startState: startState,
line: line
});
}
while (lastIndex < line.length) {
if (token.type)
tokens.push(token);
token = {
value: line.substring(lastIndex, lastIndex += 2000),
type: "overflow"
};
}
currentState = "start";
stack = [];
break;
}
}
if (token.type)
tokens.push(token);
if (stack.length > 1) {
if (stack[0] !== currentState)
stack.unshift("#tmp", currentState);
}
return {
tokens : tokens,
state : stack.length ? stack : currentState
};
};
this.reportError = function(msg, data) {
var e = new Error(msg);
e.data = data;
if (typeof console == "object" && console.error)
console.error(e);
setTimeout(function() { throw e; });
};
}).call(Tokenizer.prototype);
exports.Tokenizer = Tokenizer;
});
define("ace/mode/text_highlight_rules",["require","exports","module","ace/lib/lang"], function(require, exports, module) {
"use strict";
var lang = require("../lib/lang");
var TextHighlightRules = function() {
this.$rules = {
"start" : [{
token : "empty_line",
regex : '^$'
}, {
defaultToken : "text"
}]
};
};
(function() {
this.addRules = function(rules, prefix) {
if (!prefix) {
for (var key in rules)
this.$rules[key] = rules[key];
return;
}
for (var key in rules) {
var state = rules[key];
for (var i = 0; i < state.length; i++) {
var rule = state[i];
if (rule.next || rule.onMatch) {
if (typeof rule.next != "string") {
if (rule.nextState && rule.nextState.indexOf(prefix) !== 0)
rule.nextState = prefix + rule.nextState;
} else {
if (rule.next.indexOf(prefix) !== 0)
rule.next = prefix + rule.next;
}
}
}
this.$rules[prefix + key] = state;
}
};
this.getRules = function() {
return this.$rules;
};
this.embedRules = function (HighlightRules, prefix, escapeRules, states, append) {
var embedRules = typeof HighlightRules == "function"
? new HighlightRules().getRules()
: HighlightRules;
if (states) {
for (var i = 0; i < states.length; i++)
states[i] = prefix + states[i];
} else {
states = [];
for (var key in embedRules)
states.push(prefix + key);
}
this.addRules(embedRules, prefix);
if (escapeRules) {
var addRules = Array.prototype[append ? "push" : "unshift"];
for (var i = 0; i < states.length; i++)
addRules.apply(this.$rules[states[i]], lang.deepCopy(escapeRules));
}
if (!this.$embeds)
this.$embeds = [];
this.$embeds.push(prefix);
};
this.getEmbeds = function() {
return this.$embeds;
};
var pushState = function(currentState, stack) {
if (currentState != "start" || stack.length)
stack.unshift(this.nextState, currentState);
return this.nextState;
};
var popState = function(currentState, stack) {
stack.shift();
return stack.shift() || "start";
};
this.normalizeRules = function() {
var id = 0;
var rules = this.$rules;
function processState(key) {
var state = rules[key];
state.processed = true;
for (var i = 0; i < state.length; i++) {
var rule = state[i];
if (!rule.regex && rule.start) {
rule.regex = rule.start;
if (!rule.next)
rule.next = [];
rule.next.push({
defaultToken: rule.token
}, {
token: rule.token + ".end",
regex: rule.end || rule.start,
next: "pop"
});
rule.token = rule.token + ".start";
rule.push = true;
}
var next = rule.next || rule.push;
if (next && Array.isArray(next)) {
var stateName = rule.stateName;
if (!stateName) {
stateName = rule.token;
if (typeof stateName != "string")
stateName = stateName[0] || "";
if (rules[stateName])
stateName += id++;
}
rules[stateName] = next;
rule.next = stateName;
processState(stateName);
} else if (next == "pop") {
rule.next = popState;
}
if (rule.push) {
rule.nextState = rule.next || rule.push;
rule.next = pushState;
delete rule.push;
}
if (rule.rules) {
for (var r in rule.rules) {
if (rules[r]) {
if (rules[r].push)
rules[r].push.apply(rules[r], rule.rules[r]);
} else {
rules[r] = rule.rules[r];
}
}
}
if (rule.include || typeof rule == "string") {
var includeName = rule.include || rule;
var toInsert = rules[includeName];
} else if (Array.isArray(rule))
toInsert = rule;
if (toInsert) {
var args = [i, 1].concat(toInsert);
if (rule.noEscape)
args = args.filter(function(x) {return !x.next;});
state.splice.apply(state, args);
i--;
toInsert = null;
}
if (rule.keywordMap) {
rule.token = this.createKeywordMapper(
rule.keywordMap, rule.defaultToken || "text", rule.caseInsensitive
);
delete rule.defaultToken;
}
}
}
Object.keys(rules).forEach(processState, this);
};
this.createKeywordMapper = function(map, defaultToken, ignoreCase, splitChar) {
var keywords = Object.create(null);
Object.keys(map).forEach(function(className) {
var a = map[className];
if (ignoreCase)
a = a.toLowerCase();
var list = a.split(splitChar || "|");
for (var i = list.length; i--; )
keywords[list[i]] = className;
});
if (Object.getPrototypeOf(keywords)) {
keywords.__proto__ = null;
}
this.$keywordList = Object.keys(keywords);
map = null;
return ignoreCase
? function(value) {return keywords[value.toLowerCase()] || defaultToken }
: function(value) {return keywords[value] || defaultToken };
};
this.getKeywords = function() {
return this.$keywords;
};
}).call(TextHighlightRules.prototype);
exports.TextHighlightRules = TextHighlightRules;
});
define("ace/mode/behaviour",["require","exports","module"], function(require, exports, module) {
"use strict";
var Behaviour = function() {
this.$behaviours = {};
};
(function () {
this.add = function (name, action, callback) {
switch (undefined) {
case this.$behaviours:
this.$behaviours = {};
case this.$behaviours[name]:
this.$behaviours[name] = {};
}
this.$behaviours[name][action] = callback;
}
this.addBehaviours = function (behaviours) {
for (var key in behaviours) {
for (var action in behaviours[key]) {
this.add(key, action, behaviours[key][action]);
}
}
}
this.remove = function (name) {
if (this.$behaviours && this.$behaviours[name]) {
delete this.$behaviours[name];
}
}
this.inherit = function (mode, filter) {
if (typeof mode === "function") {
var behaviours = new mode().getBehaviours(filter);
} else {
var behaviours = mode.getBehaviours(filter);
}
this.addBehaviours(behaviours);
}
this.getBehaviours = function (filter) {
if (!filter) {
return this.$behaviours;
} else {
var ret = {}
for (var i = 0; i < filter.length; i++) {
if (this.$behaviours[filter[i]]) {
ret[filter[i]] = this.$behaviours[filter[i]];
}
}
return ret;
}
}
}).call(Behaviour.prototype);
exports.Behaviour = Behaviour;
});
define("ace/unicode",["require","exports","module"], function(require, exports, module) {
"use strict";
exports.packages = {};
addUnicodePackage({
L: "0041-005A0061-007A00AA00B500BA00C0-00D600D8-00F600F8-02C102C6-02D102E0-02E402EC02EE0370-037403760377037A-037D03860388-038A038C038E-03A103A3-03F503F7-0481048A-05250531-055605590561-058705D0-05EA05F0-05F20621-064A066E066F0671-06D306D506E506E606EE06EF06FA-06FC06FF07100712-072F074D-07A507B107CA-07EA07F407F507FA0800-0815081A082408280904-0939093D09500958-0961097109720979-097F0985-098C098F09900993-09A809AA-09B009B209B6-09B909BD09CE09DC09DD09DF-09E109F009F10A05-0A0A0A0F0A100A13-0A280A2A-0A300A320A330A350A360A380A390A59-0A5C0A5E0A72-0A740A85-0A8D0A8F-0A910A93-0AA80AAA-0AB00AB20AB30AB5-0AB90ABD0AD00AE00AE10B05-0B0C0B0F0B100B13-0B280B2A-0B300B320B330B35-0B390B3D0B5C0B5D0B5F-0B610B710B830B85-0B8A0B8E-0B900B92-0B950B990B9A0B9C0B9E0B9F0BA30BA40BA8-0BAA0BAE-0BB90BD00C05-0C0C0C0E-0C100C12-0C280C2A-0C330C35-0C390C3D0C580C590C600C610C85-0C8C0C8E-0C900C92-0CA80CAA-0CB30CB5-0CB90CBD0CDE0CE00CE10D05-0D0C0D0E-0D100D12-0D280D2A-0D390D3D0D600D610D7A-0D7F0D85-0D960D9A-0DB10DB3-0DBB0DBD0DC0-0DC60E01-0E300E320E330E40-0E460E810E820E840E870E880E8A0E8D0E94-0E970E99-0E9F0EA1-0EA30EA50EA70EAA0EAB0EAD-0EB00EB20EB30EBD0EC0-0EC40EC60EDC0EDD0F000F40-0F470F49-0F6C0F88-0F8B1000-102A103F1050-1055105A-105D106110651066106E-10701075-1081108E10A0-10C510D0-10FA10FC1100-1248124A-124D1250-12561258125A-125D1260-1288128A-128D1290-12B012B2-12B512B8-12BE12C012C2-12C512C8-12D612D8-13101312-13151318-135A1380-138F13A0-13F41401-166C166F-167F1681-169A16A0-16EA1700-170C170E-17111720-17311740-17511760-176C176E-17701780-17B317D717DC1820-18771880-18A818AA18B0-18F51900-191C1950-196D1970-19741980-19AB19C1-19C71A00-1A161A20-1A541AA71B05-1B331B45-1B4B1B83-1BA01BAE1BAF1C00-1C231C4D-1C4F1C5A-1C7D1CE9-1CEC1CEE-1CF11D00-1DBF1E00-1F151F18-1F1D1F20-1F451F48-1F4D1F50-1F571F591F5B1F5D1F5F-1F7D1F80-1FB41FB6-1FBC1FBE1FC2-1FC41FC6-1FCC1FD0-1FD31FD6-1FDB1FE0-1FEC1FF2-1FF41FF6-1FFC2071207F2090-209421022107210A-211321152119-211D212421262128212A-212D212F-2139213C-213F2145-2149214E218321842C00-2C2E2C30-2C5E2C60-2CE42CEB-2CEE2D00-2D252D30-2D652D6F2D80-2D962DA0-2DA62DA8-2DAE2DB0-2DB62DB8-2DBE2DC0-2DC62DC8-2DCE2DD0-2DD62DD8-2DDE2E2F300530063031-3035303B303C3041-3096309D-309F30A1-30FA30FC-30FF3105-312D3131-318E31A0-31B731F0-31FF3400-4DB54E00-9FCBA000-A48CA4D0-A4FDA500-A60CA610-A61FA62AA62BA640-A65FA662-A66EA67F-A697A6A0-A6E5A717-A71FA722-A788A78BA78CA7FB-A801A803-A805A807-A80AA80C-A822A840-A873A882-A8B3A8F2-A8F7A8FBA90A-A925A930-A946A960-A97CA984-A9B2A9CFAA00-AA28AA40-AA42AA44-AA4BAA60-AA76AA7AAA80-AAAFAAB1AAB5AAB6AAB9-AABDAAC0AAC2AADB-AADDABC0-ABE2AC00-D7A3D7B0-D7C6D7CB-D7FBF900-FA2DFA30-FA6DFA70-FAD9FB00-FB06FB13-FB17FB1DFB1F-FB28FB2A-FB36FB38-FB3CFB3EFB40FB41FB43FB44FB46-FBB1FBD3-FD3DFD50-FD8FFD92-FDC7FDF0-FDFBFE70-FE74FE76-FEFCFF21-FF3AFF41-FF5AFF66-FFBEFFC2-FFC7FFCA-FFCFFFD2-FFD7FFDA-FFDC",
Ll: "0061-007A00AA00B500BA00DF-00F600F8-00FF01010103010501070109010B010D010F01110113011501170119011B011D011F01210123012501270129012B012D012F01310133013501370138013A013C013E014001420144014601480149014B014D014F01510153015501570159015B015D015F01610163016501670169016B016D016F0171017301750177017A017C017E-0180018301850188018C018D019201950199-019B019E01A101A301A501A801AA01AB01AD01B001B401B601B901BA01BD-01BF01C601C901CC01CE01D001D201D401D601D801DA01DC01DD01DF01E101E301E501E701E901EB01ED01EF01F001F301F501F901FB01FD01FF02010203020502070209020B020D020F02110213021502170219021B021D021F02210223022502270229022B022D022F02310233-0239023C023F0240024202470249024B024D024F-02930295-02AF037103730377037B-037D039003AC-03CE03D003D103D5-03D703D903DB03DD03DF03E103E303E503E703E903EB03ED03EF-03F303F503F803FB03FC0430-045F04610463046504670469046B046D046F04710473047504770479047B047D047F0481048B048D048F04910493049504970499049B049D049F04A104A304A504A704A904AB04AD04AF04B104B304B504B704B904BB04BD04BF04C204C404C604C804CA04CC04CE04CF04D104D304D504D704D904DB04DD04DF04E104E304E504E704E904EB04ED04EF04F104F304F504F704F904FB04FD04FF05010503050505070509050B050D050F05110513051505170519051B051D051F0521052305250561-05871D00-1D2B1D62-1D771D79-1D9A1E011E031E051E071E091E0B1E0D1E0F1E111E131E151E171E191E1B1E1D1E1F1E211E231E251E271E291E2B1E2D1E2F1E311E331E351E371E391E3B1E3D1E3F1E411E431E451E471E491E4B1E4D1E4F1E511E531E551E571E591E5B1E5D1E5F1E611E631E651E671E691E6B1E6D1E6F1E711E731E751E771E791E7B1E7D1E7F1E811E831E851E871E891E8B1E8D1E8F1E911E931E95-1E9D1E9F1EA11EA31EA51EA71EA91EAB1EAD1EAF1EB11EB31EB51EB71EB91EBB1EBD1EBF1EC11EC31EC51EC71EC91ECB1ECD1ECF1ED11ED31ED51ED71ED91EDB1EDD1EDF1EE11EE31EE51EE71EE91EEB1EED1EEF1EF11EF31EF51EF71EF91EFB1EFD1EFF-1F071F10-1F151F20-1F271F30-1F371F40-1F451F50-1F571F60-1F671F70-1F7D1F80-1F871F90-1F971FA0-1FA71FB0-1FB41FB61FB71FBE1FC2-1FC41FC61FC71FD0-1FD31FD61FD71FE0-1FE71FF2-1FF41FF61FF7210A210E210F2113212F21342139213C213D2146-2149214E21842C30-2C5E2C612C652C662C682C6A2C6C2C712C732C742C76-2C7C2C812C832C852C872C892C8B2C8D2C8F2C912C932C952C972C992C9B2C9D2C9F2CA12CA32CA52CA72CA92CAB2CAD2CAF2CB12CB32CB52CB72CB92CBB2CBD2CBF2CC12CC32CC52CC72CC92CCB2CCD2CCF2CD12CD32CD52CD72CD92CDB2CDD2CDF2CE12CE32CE42CEC2CEE2D00-2D25A641A643A645A647A649A64BA64DA64FA651A653A655A657A659A65BA65DA65FA663A665A667A669A66BA66DA681A683A685A687A689A68BA68DA68FA691A693A695A697A723A725A727A729A72BA72DA72F-A731A733A735A737A739A73BA73DA73FA741A743A745A747A749A74BA74DA74FA751A753A755A757A759A75BA75DA75FA761A763A765A767A769A76BA76DA76FA771-A778A77AA77CA77FA781A783A785A787A78CFB00-FB06FB13-FB17FF41-FF5A",
Lu: "0041-005A00C0-00D600D8-00DE01000102010401060108010A010C010E01100112011401160118011A011C011E01200122012401260128012A012C012E01300132013401360139013B013D013F0141014301450147014A014C014E01500152015401560158015A015C015E01600162016401660168016A016C016E017001720174017601780179017B017D018101820184018601870189-018B018E-0191019301940196-0198019C019D019F01A001A201A401A601A701A901AC01AE01AF01B1-01B301B501B701B801BC01C401C701CA01CD01CF01D101D301D501D701D901DB01DE01E001E201E401E601E801EA01EC01EE01F101F401F6-01F801FA01FC01FE02000202020402060208020A020C020E02100212021402160218021A021C021E02200222022402260228022A022C022E02300232023A023B023D023E02410243-02460248024A024C024E03700372037603860388-038A038C038E038F0391-03A103A3-03AB03CF03D2-03D403D803DA03DC03DE03E003E203E403E603E803EA03EC03EE03F403F703F903FA03FD-042F04600462046404660468046A046C046E04700472047404760478047A047C047E0480048A048C048E04900492049404960498049A049C049E04A004A204A404A604A804AA04AC04AE04B004B204B404B604B804BA04BC04BE04C004C104C304C504C704C904CB04CD04D004D204D404D604D804DA04DC04DE04E004E204E404E604E804EA04EC04EE04F004F204F404F604F804FA04FC04FE05000502050405060508050A050C050E05100512051405160518051A051C051E0520052205240531-055610A0-10C51E001E021E041E061E081E0A1E0C1E0E1E101E121E141E161E181E1A1E1C1E1E1E201E221E241E261E281E2A1E2C1E2E1E301E321E341E361E381E3A1E3C1E3E1E401E421E441E461E481E4A1E4C1E4E1E501E521E541E561E581E5A1E5C1E5E1E601E621E641E661E681E6A1E6C1E6E1E701E721E741E761E781E7A1E7C1E7E1E801E821E841E861E881E8A1E8C1E8E1E901E921E941E9E1EA01EA21EA41EA61EA81EAA1EAC1EAE1EB01EB21EB41EB61EB81EBA1EBC1EBE1EC01EC21EC41EC61EC81ECA1ECC1ECE1ED01ED21ED41ED61ED81EDA1EDC1EDE1EE01EE21EE41EE61EE81EEA1EEC1EEE1EF01EF21EF41EF61EF81EFA1EFC1EFE1F08-1F0F1F18-1F1D1F28-1F2F1F38-1F3F1F48-1F4D1F591F5B1F5D1F5F1F68-1F6F1FB8-1FBB1FC8-1FCB1FD8-1FDB1FE8-1FEC1FF8-1FFB21022107210B-210D2110-211221152119-211D212421262128212A-212D2130-2133213E213F214521832C00-2C2E2C602C62-2C642C672C692C6B2C6D-2C702C722C752C7E-2C802C822C842C862C882C8A2C8C2C8E2C902C922C942C962C982C9A2C9C2C9E2CA02CA22CA42CA62CA82CAA2CAC2CAE2CB02CB22CB42CB62CB82CBA2CBC2CBE2CC02CC22CC42CC62CC82CCA2CCC2CCE2CD02CD22CD42CD62CD82CDA2CDC2CDE2CE02CE22CEB2CEDA640A642A644A646A648A64AA64CA64EA650A652A654A656A658A65AA65CA65EA662A664A666A668A66AA66CA680A682A684A686A688A68AA68CA68EA690A692A694A696A722A724A726A728A72AA72CA72EA732A734A736A738A73AA73CA73EA740A742A744A746A748A74AA74CA74EA750A752A754A756A758A75AA75CA75EA760A762A764A766A768A76AA76CA76EA779A77BA77DA77EA780A782A784A786A78BFF21-FF3A",
Lt: "01C501C801CB01F21F88-1F8F1F98-1F9F1FA8-1FAF1FBC1FCC1FFC",
Lm: "02B0-02C102C6-02D102E0-02E402EC02EE0374037A0559064006E506E607F407F507FA081A0824082809710E460EC610FC17D718431AA71C78-1C7D1D2C-1D611D781D9B-1DBF2071207F2090-20942C7D2D6F2E2F30053031-3035303B309D309E30FC-30FEA015A4F8-A4FDA60CA67FA717-A71FA770A788A9CFAA70AADDFF70FF9EFF9F",
Lo: "01BB01C0-01C3029405D0-05EA05F0-05F20621-063F0641-064A066E066F0671-06D306D506EE06EF06FA-06FC06FF07100712-072F074D-07A507B107CA-07EA0800-08150904-0939093D09500958-096109720979-097F0985-098C098F09900993-09A809AA-09B009B209B6-09B909BD09CE09DC09DD09DF-09E109F009F10A05-0A0A0A0F0A100A13-0A280A2A-0A300A320A330A350A360A380A390A59-0A5C0A5E0A72-0A740A85-0A8D0A8F-0A910A93-0AA80AAA-0AB00AB20AB30AB5-0AB90ABD0AD00AE00AE10B05-0B0C0B0F0B100B13-0B280B2A-0B300B320B330B35-0B390B3D0B5C0B5D0B5F-0B610B710B830B85-0B8A0B8E-0B900B92-0B950B990B9A0B9C0B9E0B9F0BA30BA40BA8-0BAA0BAE-0BB90BD00C05-0C0C0C0E-0C100C12-0C280C2A-0C330C35-0C390C3D0C580C590C600C610C85-0C8C0C8E-0C900C92-0CA80CAA-0CB30CB5-0CB90CBD0CDE0CE00CE10D05-0D0C0D0E-0D100D12-0D280D2A-0D390D3D0D600D610D7A-0D7F0D85-0D960D9A-0DB10DB3-0DBB0DBD0DC0-0DC60E01-0E300E320E330E40-0E450E810E820E840E870E880E8A0E8D0E94-0E970E99-0E9F0EA1-0EA30EA50EA70EAA0EAB0EAD-0EB00EB20EB30EBD0EC0-0EC40EDC0EDD0F000F40-0F470F49-0F6C0F88-0F8B1000-102A103F1050-1055105A-105D106110651066106E-10701075-1081108E10D0-10FA1100-1248124A-124D1250-12561258125A-125D1260-1288128A-128D1290-12B012B2-12B512B8-12BE12C012C2-12C512C8-12D612D8-13101312-13151318-135A1380-138F13A0-13F41401-166C166F-167F1681-169A16A0-16EA1700-170C170E-17111720-17311740-17511760-176C176E-17701780-17B317DC1820-18421844-18771880-18A818AA18B0-18F51900-191C1950-196D1970-19741980-19AB19C1-19C71A00-1A161A20-1A541B05-1B331B45-1B4B1B83-1BA01BAE1BAF1C00-1C231C4D-1C4F1C5A-1C771CE9-1CEC1CEE-1CF12135-21382D30-2D652D80-2D962DA0-2DA62DA8-2DAE2DB0-2DB62DB8-2DBE2DC0-2DC62DC8-2DCE2DD0-2DD62DD8-2DDE3006303C3041-3096309F30A1-30FA30FF3105-312D3131-318E31A0-31B731F0-31FF3400-4DB54E00-9FCBA000-A014A016-A48CA4D0-A4F7A500-A60BA610-A61FA62AA62BA66EA6A0-A6E5A7FB-A801A803-A805A807-A80AA80C-A822A840-A873A882-A8B3A8F2-A8F7A8FBA90A-A925A930-A946A960-A97CA984-A9B2AA00-AA28AA40-AA42AA44-AA4BAA60-AA6FAA71-AA76AA7AAA80-AAAFAAB1AAB5AAB6AAB9-AABDAAC0AAC2AADBAADCABC0-ABE2AC00-D7A3D7B0-D7C6D7CB-D7FBF900-FA2DFA30-FA6DFA70-FAD9FB1DFB1F-FB28FB2A-FB36FB38-FB3CFB3EFB40FB41FB43FB44FB46-FBB1FBD3-FD3DFD50-FD8FFD92-FDC7FDF0-FDFBFE70-FE74FE76-FEFCFF66-FF6FFF71-FF9DFFA0-FFBEFFC2-FFC7FFCA-FFCFFFD2-FFD7FFDA-FFDC",
M: "0300-036F0483-04890591-05BD05BF05C105C205C405C505C70610-061A064B-065E067006D6-06DC06DE-06E406E706E806EA-06ED07110730-074A07A6-07B007EB-07F30816-0819081B-08230825-08270829-082D0900-0903093C093E-094E0951-0955096209630981-098309BC09BE-09C409C709C809CB-09CD09D709E209E30A01-0A030A3C0A3E-0A420A470A480A4B-0A4D0A510A700A710A750A81-0A830ABC0ABE-0AC50AC7-0AC90ACB-0ACD0AE20AE30B01-0B030B3C0B3E-0B440B470B480B4B-0B4D0B560B570B620B630B820BBE-0BC20BC6-0BC80BCA-0BCD0BD70C01-0C030C3E-0C440C46-0C480C4A-0C4D0C550C560C620C630C820C830CBC0CBE-0CC40CC6-0CC80CCA-0CCD0CD50CD60CE20CE30D020D030D3E-0D440D46-0D480D4A-0D4D0D570D620D630D820D830DCA0DCF-0DD40DD60DD8-0DDF0DF20DF30E310E34-0E3A0E47-0E4E0EB10EB4-0EB90EBB0EBC0EC8-0ECD0F180F190F350F370F390F3E0F3F0F71-0F840F860F870F90-0F970F99-0FBC0FC6102B-103E1056-1059105E-10601062-10641067-106D1071-10741082-108D108F109A-109D135F1712-17141732-1734175217531772177317B6-17D317DD180B-180D18A91920-192B1930-193B19B0-19C019C819C91A17-1A1B1A55-1A5E1A60-1A7C1A7F1B00-1B041B34-1B441B6B-1B731B80-1B821BA1-1BAA1C24-1C371CD0-1CD21CD4-1CE81CED1CF21DC0-1DE61DFD-1DFF20D0-20F02CEF-2CF12DE0-2DFF302A-302F3099309AA66F-A672A67CA67DA6F0A6F1A802A806A80BA823-A827A880A881A8B4-A8C4A8E0-A8F1A926-A92DA947-A953A980-A983A9B3-A9C0AA29-AA36AA43AA4CAA4DAA7BAAB0AAB2-AAB4AAB7AAB8AABEAABFAAC1ABE3-ABEAABECABEDFB1EFE00-FE0FFE20-FE26",
Mn: "0300-036F0483-04870591-05BD05BF05C105C205C405C505C70610-061A064B-065E067006D6-06DC06DF-06E406E706E806EA-06ED07110730-074A07A6-07B007EB-07F30816-0819081B-08230825-08270829-082D0900-0902093C0941-0948094D0951-095509620963098109BC09C1-09C409CD09E209E30A010A020A3C0A410A420A470A480A4B-0A4D0A510A700A710A750A810A820ABC0AC1-0AC50AC70AC80ACD0AE20AE30B010B3C0B3F0B41-0B440B4D0B560B620B630B820BC00BCD0C3E-0C400C46-0C480C4A-0C4D0C550C560C620C630CBC0CBF0CC60CCC0CCD0CE20CE30D41-0D440D4D0D620D630DCA0DD2-0DD40DD60E310E34-0E3A0E47-0E4E0EB10EB4-0EB90EBB0EBC0EC8-0ECD0F180F190F350F370F390F71-0F7E0F80-0F840F860F870F90-0F970F99-0FBC0FC6102D-10301032-10371039103A103D103E10581059105E-10601071-1074108210851086108D109D135F1712-17141732-1734175217531772177317B7-17BD17C617C9-17D317DD180B-180D18A91920-19221927192819321939-193B1A171A181A561A58-1A5E1A601A621A65-1A6C1A73-1A7C1A7F1B00-1B031B341B36-1B3A1B3C1B421B6B-1B731B801B811BA2-1BA51BA81BA91C2C-1C331C361C371CD0-1CD21CD4-1CE01CE2-1CE81CED1DC0-1DE61DFD-1DFF20D0-20DC20E120E5-20F02CEF-2CF12DE0-2DFF302A-302F3099309AA66FA67CA67DA6F0A6F1A802A806A80BA825A826A8C4A8E0-A8F1A926-A92DA947-A951A980-A982A9B3A9B6-A9B9A9BCAA29-AA2EAA31AA32AA35AA36AA43AA4CAAB0AAB2-AAB4AAB7AAB8AABEAABFAAC1ABE5ABE8ABEDFB1EFE00-FE0FFE20-FE26",
Mc: "0903093E-09400949-094C094E0982098309BE-09C009C709C809CB09CC09D70A030A3E-0A400A830ABE-0AC00AC90ACB0ACC0B020B030B3E0B400B470B480B4B0B4C0B570BBE0BBF0BC10BC20BC6-0BC80BCA-0BCC0BD70C01-0C030C41-0C440C820C830CBE0CC0-0CC40CC70CC80CCA0CCB0CD50CD60D020D030D3E-0D400D46-0D480D4A-0D4C0D570D820D830DCF-0DD10DD8-0DDF0DF20DF30F3E0F3F0F7F102B102C10311038103B103C105610571062-10641067-106D108310841087-108C108F109A-109C17B617BE-17C517C717C81923-19261929-192B193019311933-193819B0-19C019C819C91A19-1A1B1A551A571A611A631A641A6D-1A721B041B351B3B1B3D-1B411B431B441B821BA11BA61BA71BAA1C24-1C2B1C341C351CE11CF2A823A824A827A880A881A8B4-A8C3A952A953A983A9B4A9B5A9BAA9BBA9BD-A9C0AA2FAA30AA33AA34AA4DAA7BABE3ABE4ABE6ABE7ABE9ABEAABEC",
Me: "0488048906DE20DD-20E020E2-20E4A670-A672",
N: "0030-003900B200B300B900BC-00BE0660-066906F0-06F907C0-07C90966-096F09E6-09EF09F4-09F90A66-0A6F0AE6-0AEF0B66-0B6F0BE6-0BF20C66-0C6F0C78-0C7E0CE6-0CEF0D66-0D750E50-0E590ED0-0ED90F20-0F331040-10491090-10991369-137C16EE-16F017E0-17E917F0-17F91810-18191946-194F19D0-19DA1A80-1A891A90-1A991B50-1B591BB0-1BB91C40-1C491C50-1C5920702074-20792080-20892150-21822185-21892460-249B24EA-24FF2776-27932CFD30073021-30293038-303A3192-31953220-32293251-325F3280-328932B1-32BFA620-A629A6E6-A6EFA830-A835A8D0-A8D9A900-A909A9D0-A9D9AA50-AA59ABF0-ABF9FF10-FF19",
Nd: "0030-00390660-066906F0-06F907C0-07C90966-096F09E6-09EF0A66-0A6F0AE6-0AEF0B66-0B6F0BE6-0BEF0C66-0C6F0CE6-0CEF0D66-0D6F0E50-0E590ED0-0ED90F20-0F291040-10491090-109917E0-17E91810-18191946-194F19D0-19DA1A80-1A891A90-1A991B50-1B591BB0-1BB91C40-1C491C50-1C59A620-A629A8D0-A8D9A900-A909A9D0-A9D9AA50-AA59ABF0-ABF9FF10-FF19",
Nl: "16EE-16F02160-21822185-218830073021-30293038-303AA6E6-A6EF",
No: "00B200B300B900BC-00BE09F4-09F90BF0-0BF20C78-0C7E0D70-0D750F2A-0F331369-137C17F0-17F920702074-20792080-20892150-215F21892460-249B24EA-24FF2776-27932CFD3192-31953220-32293251-325F3280-328932B1-32BFA830-A835",
P: "0021-00230025-002A002C-002F003A003B003F0040005B-005D005F007B007D00A100AB00B700BB00BF037E0387055A-055F0589058A05BE05C005C305C605F305F40609060A060C060D061B061E061F066A-066D06D40700-070D07F7-07F90830-083E0964096509700DF40E4F0E5A0E5B0F04-0F120F3A-0F3D0F850FD0-0FD4104A-104F10FB1361-13681400166D166E169B169C16EB-16ED1735173617D4-17D617D8-17DA1800-180A1944194519DE19DF1A1E1A1F1AA0-1AA61AA8-1AAD1B5A-1B601C3B-1C3F1C7E1C7F1CD32010-20272030-20432045-20512053-205E207D207E208D208E2329232A2768-277527C527C627E6-27EF2983-299829D8-29DB29FC29FD2CF9-2CFC2CFE2CFF2E00-2E2E2E302E313001-30033008-30113014-301F3030303D30A030FBA4FEA4FFA60D-A60FA673A67EA6F2-A6F7A874-A877A8CEA8CFA8F8-A8FAA92EA92FA95FA9C1-A9CDA9DEA9DFAA5C-AA5FAADEAADFABEBFD3EFD3FFE10-FE19FE30-FE52FE54-FE61FE63FE68FE6AFE6BFF01-FF03FF05-FF0AFF0C-FF0FFF1AFF1BFF1FFF20FF3B-FF3DFF3FFF5BFF5DFF5F-FF65",
Pd: "002D058A05BE140018062010-20152E172E1A301C303030A0FE31FE32FE58FE63FF0D",
Ps: "0028005B007B0F3A0F3C169B201A201E2045207D208D23292768276A276C276E27702772277427C527E627E827EA27EC27EE2983298529872989298B298D298F299129932995299729D829DA29FC2E222E242E262E283008300A300C300E3010301430163018301A301DFD3EFE17FE35FE37FE39FE3BFE3DFE3FFE41FE43FE47FE59FE5BFE5DFF08FF3BFF5BFF5FFF62",
Pe: "0029005D007D0F3B0F3D169C2046207E208E232A2769276B276D276F27712773277527C627E727E927EB27ED27EF298429862988298A298C298E2990299229942996299829D929DB29FD2E232E252E272E293009300B300D300F3011301530173019301B301E301FFD3FFE18FE36FE38FE3AFE3CFE3EFE40FE42FE44FE48FE5AFE5CFE5EFF09FF3DFF5DFF60FF63",
Pi: "00AB2018201B201C201F20392E022E042E092E0C2E1C2E20",
Pf: "00BB2019201D203A2E032E052E0A2E0D2E1D2E21",
Pc: "005F203F20402054FE33FE34FE4D-FE4FFF3F",
Po: "0021-00230025-0027002A002C002E002F003A003B003F0040005C00A100B700BF037E0387055A-055F058905C005C305C605F305F40609060A060C060D061B061E061F066A-066D06D40700-070D07F7-07F90830-083E0964096509700DF40E4F0E5A0E5B0F04-0F120F850FD0-0FD4104A-104F10FB1361-1368166D166E16EB-16ED1735173617D4-17D617D8-17DA1800-18051807-180A1944194519DE19DF1A1E1A1F1AA0-1AA61AA8-1AAD1B5A-1B601C3B-1C3F1C7E1C7F1CD3201620172020-20272030-2038203B-203E2041-20432047-205120532055-205E2CF9-2CFC2CFE2CFF2E002E012E06-2E082E0B2E0E-2E162E182E192E1B2E1E2E1F2E2A-2E2E2E302E313001-3003303D30FBA4FEA4FFA60D-A60FA673A67EA6F2-A6F7A874-A877A8CEA8CFA8F8-A8FAA92EA92FA95FA9C1-A9CDA9DEA9DFAA5C-AA5FAADEAADFABEBFE10-FE16FE19FE30FE45FE46FE49-FE4CFE50-FE52FE54-FE57FE5F-FE61FE68FE6AFE6BFF01-FF03FF05-FF07FF0AFF0CFF0EFF0FFF1AFF1BFF1FFF20FF3CFF61FF64FF65",
S: "0024002B003C-003E005E0060007C007E00A2-00A900AC00AE-00B100B400B600B800D700F702C2-02C502D2-02DF02E5-02EB02ED02EF-02FF03750384038503F604820606-0608060B060E060F06E906FD06FE07F609F209F309FA09FB0AF10B700BF3-0BFA0C7F0CF10CF20D790E3F0F01-0F030F13-0F170F1A-0F1F0F340F360F380FBE-0FC50FC7-0FCC0FCE0FCF0FD5-0FD8109E109F13601390-139917DB194019E0-19FF1B61-1B6A1B74-1B7C1FBD1FBF-1FC11FCD-1FCF1FDD-1FDF1FED-1FEF1FFD1FFE20442052207A-207C208A-208C20A0-20B8210021012103-21062108210921142116-2118211E-2123212521272129212E213A213B2140-2144214A-214D214F2190-2328232B-23E82400-24262440-244A249C-24E92500-26CD26CF-26E126E326E8-26FF2701-27042706-2709270C-27272729-274B274D274F-27522756-275E2761-276727942798-27AF27B1-27BE27C0-27C427C7-27CA27CC27D0-27E527F0-29822999-29D729DC-29FB29FE-2B4C2B50-2B592CE5-2CEA2E80-2E992E9B-2EF32F00-2FD52FF0-2FFB300430123013302030363037303E303F309B309C319031913196-319F31C0-31E33200-321E322A-32503260-327F328A-32B032C0-32FE3300-33FF4DC0-4DFFA490-A4C6A700-A716A720A721A789A78AA828-A82BA836-A839AA77-AA79FB29FDFCFDFDFE62FE64-FE66FE69FF04FF0BFF1C-FF1EFF3EFF40FF5CFF5EFFE0-FFE6FFE8-FFEEFFFCFFFD",
Sm: "002B003C-003E007C007E00AC00B100D700F703F60606-060820442052207A-207C208A-208C2140-2144214B2190-2194219A219B21A021A321A621AE21CE21CF21D221D421F4-22FF2308-230B23202321237C239B-23B323DC-23E125B725C125F8-25FF266F27C0-27C427C7-27CA27CC27D0-27E527F0-27FF2900-29822999-29D729DC-29FB29FE-2AFF2B30-2B442B47-2B4CFB29FE62FE64-FE66FF0BFF1C-FF1EFF5CFF5EFFE2FFE9-FFEC",
Sc: "002400A2-00A5060B09F209F309FB0AF10BF90E3F17DB20A0-20B8A838FDFCFE69FF04FFE0FFE1FFE5FFE6",
Sk: "005E006000A800AF00B400B802C2-02C502D2-02DF02E5-02EB02ED02EF-02FF0375038403851FBD1FBF-1FC11FCD-1FCF1FDD-1FDF1FED-1FEF1FFD1FFE309B309CA700-A716A720A721A789A78AFF3EFF40FFE3",
So: "00A600A700A900AE00B000B60482060E060F06E906FD06FE07F609FA0B700BF3-0BF80BFA0C7F0CF10CF20D790F01-0F030F13-0F170F1A-0F1F0F340F360F380FBE-0FC50FC7-0FCC0FCE0FCF0FD5-0FD8109E109F13601390-1399194019E0-19FF1B61-1B6A1B74-1B7C210021012103-21062108210921142116-2118211E-2123212521272129212E213A213B214A214C214D214F2195-2199219C-219F21A121A221A421A521A7-21AD21AF-21CD21D021D121D321D5-21F32300-2307230C-231F2322-2328232B-237B237D-239A23B4-23DB23E2-23E82400-24262440-244A249C-24E92500-25B625B8-25C025C2-25F72600-266E2670-26CD26CF-26E126E326E8-26FF2701-27042706-2709270C-27272729-274B274D274F-27522756-275E2761-276727942798-27AF27B1-27BE2800-28FF2B00-2B2F2B452B462B50-2B592CE5-2CEA2E80-2E992E9B-2EF32F00-2FD52FF0-2FFB300430123013302030363037303E303F319031913196-319F31C0-31E33200-321E322A-32503260-327F328A-32B032C0-32FE3300-33FF4DC0-4DFFA490-A4C6A828-A82BA836A837A839AA77-AA79FDFDFFE4FFE8FFEDFFEEFFFCFFFD",
Z: "002000A01680180E2000-200A20282029202F205F3000",
Zs: "002000A01680180E2000-200A202F205F3000",
Zl: "2028",
Zp: "2029",
C: "0000-001F007F-009F00AD03780379037F-0383038B038D03A20526-05300557055805600588058B-059005C8-05CF05EB-05EF05F5-0605061C061D0620065F06DD070E070F074B074C07B2-07BF07FB-07FF082E082F083F-08FF093A093B094F095609570973-097809800984098D098E0991099209A909B109B3-09B509BA09BB09C509C609C909CA09CF-09D609D8-09DB09DE09E409E509FC-0A000A040A0B-0A0E0A110A120A290A310A340A370A3A0A3B0A3D0A43-0A460A490A4A0A4E-0A500A52-0A580A5D0A5F-0A650A76-0A800A840A8E0A920AA90AB10AB40ABA0ABB0AC60ACA0ACE0ACF0AD1-0ADF0AE40AE50AF00AF2-0B000B040B0D0B0E0B110B120B290B310B340B3A0B3B0B450B460B490B4A0B4E-0B550B58-0B5B0B5E0B640B650B72-0B810B840B8B-0B8D0B910B96-0B980B9B0B9D0BA0-0BA20BA5-0BA70BAB-0BAD0BBA-0BBD0BC3-0BC50BC90BCE0BCF0BD1-0BD60BD8-0BE50BFB-0C000C040C0D0C110C290C340C3A-0C3C0C450C490C4E-0C540C570C5A-0C5F0C640C650C70-0C770C800C810C840C8D0C910CA90CB40CBA0CBB0CC50CC90CCE-0CD40CD7-0CDD0CDF0CE40CE50CF00CF3-0D010D040D0D0D110D290D3A-0D3C0D450D490D4E-0D560D58-0D5F0D640D650D76-0D780D800D810D840D97-0D990DB20DBC0DBE0DBF0DC7-0DC90DCB-0DCE0DD50DD70DE0-0DF10DF5-0E000E3B-0E3E0E5C-0E800E830E850E860E890E8B0E8C0E8E-0E930E980EA00EA40EA60EA80EA90EAC0EBA0EBE0EBF0EC50EC70ECE0ECF0EDA0EDB0EDE-0EFF0F480F6D-0F700F8C-0F8F0F980FBD0FCD0FD9-0FFF10C6-10CF10FD-10FF1249124E124F12571259125E125F1289128E128F12B112B612B712BF12C112C612C712D7131113161317135B-135E137D-137F139A-139F13F5-13FF169D-169F16F1-16FF170D1715-171F1737-173F1754-175F176D17711774-177F17B417B517DE17DF17EA-17EF17FA-17FF180F181A-181F1878-187F18AB-18AF18F6-18FF191D-191F192C-192F193C-193F1941-1943196E196F1975-197F19AC-19AF19CA-19CF19DB-19DD1A1C1A1D1A5F1A7D1A7E1A8A-1A8F1A9A-1A9F1AAE-1AFF1B4C-1B4F1B7D-1B7F1BAB-1BAD1BBA-1BFF1C38-1C3A1C4A-1C4C1C80-1CCF1CF3-1CFF1DE7-1DFC1F161F171F1E1F1F1F461F471F4E1F4F1F581F5A1F5C1F5E1F7E1F7F1FB51FC51FD41FD51FDC1FF01FF11FF51FFF200B-200F202A-202E2060-206F20722073208F2095-209F20B9-20CF20F1-20FF218A-218F23E9-23FF2427-243F244B-245F26CE26E226E4-26E727002705270A270B2728274C274E2753-2755275F27602795-279727B027BF27CB27CD-27CF2B4D-2B4F2B5A-2BFF2C2F2C5F2CF2-2CF82D26-2D2F2D66-2D6E2D70-2D7F2D97-2D9F2DA72DAF2DB72DBF2DC72DCF2DD72DDF2E32-2E7F2E9A2EF4-2EFF2FD6-2FEF2FFC-2FFF3040309730983100-3104312E-3130318F31B8-31BF31E4-31EF321F32FF4DB6-4DBF9FCC-9FFFA48D-A48FA4C7-A4CFA62C-A63FA660A661A674-A67BA698-A69FA6F8-A6FFA78D-A7FAA82C-A82FA83A-A83FA878-A87FA8C5-A8CDA8DA-A8DFA8FC-A8FFA954-A95EA97D-A97FA9CEA9DA-A9DDA9E0-A9FFAA37-AA3FAA4EAA4FAA5AAA5BAA7C-AA7FAAC3-AADAAAE0-ABBFABEEABEFABFA-ABFFD7A4-D7AFD7C7-D7CAD7FC-F8FFFA2EFA2FFA6EFA6FFADA-FAFFFB07-FB12FB18-FB1CFB37FB3DFB3FFB42FB45FBB2-FBD2FD40-FD4FFD90FD91FDC8-FDEFFDFEFDFFFE1A-FE1FFE27-FE2FFE53FE67FE6C-FE6FFE75FEFD-FF00FFBF-FFC1FFC8FFC9FFD0FFD1FFD8FFD9FFDD-FFDFFFE7FFEF-FFFBFFFEFFFF",
Cc: "0000-001F007F-009F",
Cf: "00AD0600-060306DD070F17B417B5200B-200F202A-202E2060-2064206A-206FFEFFFFF9-FFFB",
Co: "E000-F8FF",
Cs: "D800-DFFF",
Cn: "03780379037F-0383038B038D03A20526-05300557055805600588058B-059005C8-05CF05EB-05EF05F5-05FF06040605061C061D0620065F070E074B074C07B2-07BF07FB-07FF082E082F083F-08FF093A093B094F095609570973-097809800984098D098E0991099209A909B109B3-09B509BA09BB09C509C609C909CA09CF-09D609D8-09DB09DE09E409E509FC-0A000A040A0B-0A0E0A110A120A290A310A340A370A3A0A3B0A3D0A43-0A460A490A4A0A4E-0A500A52-0A580A5D0A5F-0A650A76-0A800A840A8E0A920AA90AB10AB40ABA0ABB0AC60ACA0ACE0ACF0AD1-0ADF0AE40AE50AF00AF2-0B000B040B0D0B0E0B110B120B290B310B340B3A0B3B0B450B460B490B4A0B4E-0B550B58-0B5B0B5E0B640B650B72-0B810B840B8B-0B8D0B910B96-0B980B9B0B9D0BA0-0BA20BA5-0BA70BAB-0BAD0BBA-0BBD0BC3-0BC50BC90BCE0BCF0BD1-0BD60BD8-0BE50BFB-0C000C040C0D0C110C290C340C3A-0C3C0C450C490C4E-0C540C570C5A-0C5F0C640C650C70-0C770C800C810C840C8D0C910CA90CB40CBA0CBB0CC50CC90CCE-0CD40CD7-0CDD0CDF0CE40CE50CF00CF3-0D010D040D0D0D110D290D3A-0D3C0D450D490D4E-0D560D58-0D5F0D640D650D76-0D780D800D810D840D97-0D990DB20DBC0DBE0DBF0DC7-0DC90DCB-0DCE0DD50DD70DE0-0DF10DF5-0E000E3B-0E3E0E5C-0E800E830E850E860E890E8B0E8C0E8E-0E930E980EA00EA40EA60EA80EA90EAC0EBA0EBE0EBF0EC50EC70ECE0ECF0EDA0EDB0EDE-0EFF0F480F6D-0F700F8C-0F8F0F980FBD0FCD0FD9-0FFF10C6-10CF10FD-10FF1249124E124F12571259125E125F1289128E128F12B112B612B712BF12C112C612C712D7131113161317135B-135E137D-137F139A-139F13F5-13FF169D-169F16F1-16FF170D1715-171F1737-173F1754-175F176D17711774-177F17DE17DF17EA-17EF17FA-17FF180F181A-181F1878-187F18AB-18AF18F6-18FF191D-191F192C-192F193C-193F1941-1943196E196F1975-197F19AC-19AF19CA-19CF19DB-19DD1A1C1A1D1A5F1A7D1A7E1A8A-1A8F1A9A-1A9F1AAE-1AFF1B4C-1B4F1B7D-1B7F1BAB-1BAD1BBA-1BFF1C38-1C3A1C4A-1C4C1C80-1CCF1CF3-1CFF1DE7-1DFC1F161F171F1E1F1F1F461F471F4E1F4F1F581F5A1F5C1F5E1F7E1F7F1FB51FC51FD41FD51FDC1FF01FF11FF51FFF2065-206920722073208F2095-209F20B9-20CF20F1-20FF218A-218F23E9-23FF2427-243F244B-245F26CE26E226E4-26E727002705270A270B2728274C274E2753-2755275F27602795-279727B027BF27CB27CD-27CF2B4D-2B4F2B5A-2BFF2C2F2C5F2CF2-2CF82D26-2D2F2D66-2D6E2D70-2D7F2D97-2D9F2DA72DAF2DB72DBF2DC72DCF2DD72DDF2E32-2E7F2E9A2EF4-2EFF2FD6-2FEF2FFC-2FFF3040309730983100-3104312E-3130318F31B8-31BF31E4-31EF321F32FF4DB6-4DBF9FCC-9FFFA48D-A48FA4C7-A4CFA62C-A63FA660A661A674-A67BA698-A69FA6F8-A6FFA78D-A7FAA82C-A82FA83A-A83FA878-A87FA8C5-A8CDA8DA-A8DFA8FC-A8FFA954-A95EA97D-A97FA9CEA9DA-A9DDA9E0-A9FFAA37-AA3FAA4EAA4FAA5AAA5BAA7C-AA7FAAC3-AADAAAE0-ABBFABEEABEFABFA-ABFFD7A4-D7AFD7C7-D7CAD7FC-D7FFFA2EFA2FFA6EFA6FFADA-FAFFFB07-FB12FB18-FB1CFB37FB3DFB3FFB42FB45FBB2-FBD2FD40-FD4FFD90FD91FDC8-FDEFFDFEFDFFFE1A-FE1FFE27-FE2FFE53FE67FE6C-FE6FFE75FEFDFEFEFF00FFBF-FFC1FFC8FFC9FFD0FFD1FFD8FFD9FFDD-FFDFFFE7FFEF-FFF8FFFEFFFF"
});
function addUnicodePackage (pack) {
var codePoint = /\w{4}/g;
for (var name in pack)
exports.packages[name] = pack[name].replace(codePoint, "\\u$&");
};
});
define("ace/token_iterator",["require","exports","module"], function(require, exports, module) {
"use strict";
var TokenIterator = function(session, initialRow, initialColumn) {
this.$session = session;
this.$row = initialRow;
this.$rowTokens = session.getTokens(initialRow);
var token = session.getTokenAt(initialRow, initialColumn);
this.$tokenIndex = token ? token.index : -1;
};
(function() {
this.stepBackward = function() {
this.$tokenIndex -= 1;
while (this.$tokenIndex < 0) {
this.$row -= 1;
if (this.$row < 0) {
this.$row = 0;
return null;
}
this.$rowTokens = this.$session.getTokens(this.$row);
this.$tokenIndex = this.$rowTokens.length - 1;
}
return this.$rowTokens[this.$tokenIndex];
};
this.stepForward = function() {
this.$tokenIndex += 1;
var rowCount;
while (this.$tokenIndex >= this.$rowTokens.length) {
this.$row += 1;
if (!rowCount)
rowCount = this.$session.getLength();
if (this.$row >= rowCount) {
this.$row = rowCount - 1;
return null;
}
this.$rowTokens = this.$session.getTokens(this.$row);
this.$tokenIndex = 0;
}
return this.$rowTokens[this.$tokenIndex];
};
this.getCurrentToken = function () {
return this.$rowTokens[this.$tokenIndex];
};
this.getCurrentTokenRow = function () {
return this.$row;
};
this.getCurrentTokenColumn = function() {
var rowTokens = this.$rowTokens;
var tokenIndex = this.$tokenIndex;
var column = rowTokens[tokenIndex].start;
if (column !== undefined)
return column;
column = 0;
while (tokenIndex > 0) {
tokenIndex -= 1;
column += rowTokens[tokenIndex].value.length;
}
return column;
};
}).call(TokenIterator.prototype);
exports.TokenIterator = TokenIterator;
});
define("ace/mode/text",["require","exports","module","ace/tokenizer","ace/mode/text_highlight_rules","ace/mode/behaviour","ace/unicode","ace/lib/lang","ace/token_iterator","ace/range"], function(require, exports, module) {
"use strict";
var Tokenizer = require("../tokenizer").Tokenizer;
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var Behaviour = require("./behaviour").Behaviour;
var unicode = require("../unicode");
var lang = require("../lib/lang");
var TokenIterator = require("../token_iterator").TokenIterator;
var Range = require("../range").Range;
var Mode = function() {
this.HighlightRules = TextHighlightRules;
this.$behaviour = new Behaviour();
};
(function() {
this.tokenRe = new RegExp("^["
+ unicode.packages.L
+ unicode.packages.Mn + unicode.packages.Mc
+ unicode.packages.Nd
+ unicode.packages.Pc + "\\$_]+", "g"
);
this.nonTokenRe = new RegExp("^(?:[^"
+ unicode.packages.L
+ unicode.packages.Mn + unicode.packages.Mc
+ unicode.packages.Nd
+ unicode.packages.Pc + "\\$_]|\\s])+", "g"
);
this.getTokenizer = function() {
if (!this.$tokenizer) {
this.$highlightRules = this.$highlightRules || new this.HighlightRules();
this.$tokenizer = new Tokenizer(this.$highlightRules.getRules());
}
return this.$tokenizer;
};
this.lineCommentStart = "";
this.blockComment = "";
this.toggleCommentLines = function(state, session, startRow, endRow) {
var doc = session.doc;
var ignoreBlankLines = true;
var shouldRemove = true;
var minIndent = Infinity;
var tabSize = session.getTabSize();
var insertAtTabStop = false;
if (!this.lineCommentStart) {
if (!this.blockComment)
return false;
var lineCommentStart = this.blockComment.start;
var lineCommentEnd = this.blockComment.end;
var regexpStart = new RegExp("^(\\s*)(?:" + lang.escapeRegExp(lineCommentStart) + ")");
var regexpEnd = new RegExp("(?:" + lang.escapeRegExp(lineCommentEnd) + ")\\s*$");
var comment = function(line, i) {
if (testRemove(line, i))
return;
if (!ignoreBlankLines || /\S/.test(line)) {
doc.insertInLine({row: i, column: line.length}, lineCommentEnd);
doc.insertInLine({row: i, column: minIndent}, lineCommentStart);
}
};
var uncomment = function(line, i) {
var m;
if (m = line.match(regexpEnd))
doc.removeInLine(i, line.length - m[0].length, line.length);
if (m = line.match(regexpStart))
doc.removeInLine(i, m[1].length, m[0].length);
};
var testRemove = function(line, row) {
if (regexpStart.test(line))
return true;
var tokens = session.getTokens(row);
for (var i = 0; i < tokens.length; i++) {
if (tokens[i].type === 'comment')
return true;
}
};
} else {
if (Array.isArray(this.lineCommentStart)) {
var regexpStart = this.lineCommentStart.map(lang.escapeRegExp).join("|");
var lineCommentStart = this.lineCommentStart[0];
} else {
var regexpStart = lang.escapeRegExp(this.lineCommentStart);
var lineCommentStart = this.lineCommentStart;
}
regexpStart = new RegExp("^(\\s*)(?:" + regexpStart + ") ?");
insertAtTabStop = session.getUseSoftTabs();
var uncomment = function(line, i) {
var m = line.match(regexpStart);
if (!m) return;
var start = m[1].length, end = m[0].length;
if (!shouldInsertSpace(line, start, end) && m[0][end - 1] == " ")
end--;
doc.removeInLine(i, start, end);
};
var commentWithSpace = lineCommentStart + " ";
var comment = function(line, i) {
if (!ignoreBlankLines || /\S/.test(line)) {
if (shouldInsertSpace(line, minIndent, minIndent))
doc.insertInLine({row: i, column: minIndent}, commentWithSpace);
else
doc.insertInLine({row: i, column: minIndent}, lineCommentStart);
}
};
var testRemove = function(line, i) {
return regexpStart.test(line);
};
var shouldInsertSpace = function(line, before, after) {
var spaces = 0;
while (before-- && line.charAt(before) == " ")
spaces++;
if (spaces % tabSize != 0)
return false;
var spaces = 0;
while (line.charAt(after++) == " ")
spaces++;
if (tabSize > 2)
return spaces % tabSize != tabSize - 1;
else
return spaces % tabSize == 0;
return true;
};
}
function iter(fun) {
for (var i = startRow; i <= endRow; i++)
fun(doc.getLine(i), i);
}
var minEmptyLength = Infinity;
iter(function(line, i) {
var indent = line.search(/\S/);
if (indent !== -1) {
if (indent < minIndent)
minIndent = indent;
if (shouldRemove && !testRemove(line, i))
shouldRemove = false;
} else if (minEmptyLength > line.length) {
minEmptyLength = line.length;
}
});
if (minIndent == Infinity) {
minIndent = minEmptyLength;
ignoreBlankLines = false;
shouldRemove = false;
}
if (insertAtTabStop && minIndent % tabSize != 0)
minIndent = Math.floor(minIndent / tabSize) * tabSize;
iter(shouldRemove ? uncomment : comment);
};
this.toggleBlockComment = function(state, session, range, cursor) {
var comment = this.blockComment;
if (!comment)
return;
if (!comment.start && comment[0])
comment = comment[0];
var iterator = new TokenIterator(session, cursor.row, cursor.column);
var token = iterator.getCurrentToken();
var sel = session.selection;
var initialRange = session.selection.toOrientedRange();
var startRow, colDiff;
if (token && /comment/.test(token.type)) {
var startRange, endRange;
while (token && /comment/.test(token.type)) {
var i = token.value.indexOf(comment.start);
if (i != -1) {
var row = iterator.getCurrentTokenRow();
var column = iterator.getCurrentTokenColumn() + i;
startRange = new Range(row, column, row, column + comment.start.length);
break;
}
token = iterator.stepBackward();
}
var iterator = new TokenIterator(session, cursor.row, cursor.column);
var token = iterator.getCurrentToken();
while (token && /comment/.test(token.type)) {
var i = token.value.indexOf(comment.end);
if (i != -1) {
var row = iterator.getCurrentTokenRow();
var column = iterator.getCurrentTokenColumn() + i;
endRange = new Range(row, column, row, column + comment.end.length);
break;
}
token = iterator.stepForward();
}
if (endRange)
session.remove(endRange);
if (startRange) {
session.remove(startRange);
startRow = startRange.start.row;
colDiff = -comment.start.length;
}
} else {
colDiff = comment.start.length;
startRow = range.start.row;
session.insert(range.end, comment.end);
session.insert(range.start, comment.start);
}
if (initialRange.start.row == startRow)
initialRange.start.column += colDiff;
if (initialRange.end.row == startRow)
initialRange.end.column += colDiff;
session.selection.fromOrientedRange(initialRange);
};
this.getNextLineIndent = function(state, line, tab) {
return this.$getIndent(line);
};
this.checkOutdent = function(state, line, input) {
return false;
};
this.autoOutdent = function(state, doc, row) {
};
this.$getIndent = function(line) {
return line.match(/^\s*/)[0];
};
this.createWorker = function(session) {
return null;
};
this.createModeDelegates = function (mapping) {
this.$embeds = [];
this.$modes = {};
for (var i in mapping) {
if (mapping[i]) {
this.$embeds.push(i);
this.$modes[i] = new mapping[i]();
}
}
var delegations = ['toggleBlockComment', 'toggleCommentLines', 'getNextLineIndent',
'checkOutdent', 'autoOutdent', 'transformAction', 'getCompletions'];
for (var i = 0; i < delegations.length; i++) {
(function(scope) {
var functionName = delegations[i];
var defaultHandler = scope[functionName];
scope[delegations[i]] = function() {
return this.$delegator(functionName, arguments, defaultHandler);
};
} (this));
}
};
this.$delegator = function(method, args, defaultHandler) {
var state = args[0];
if (typeof state != "string")
state = state[0];
for (var i = 0; i < this.$embeds.length; i++) {
if (!this.$modes[this.$embeds[i]]) continue;
var split = state.split(this.$embeds[i]);
if (!split[0] && split[1]) {
args[0] = split[1];
var mode = this.$modes[this.$embeds[i]];
return mode[method].apply(mode, args);
}
}
var ret = defaultHandler.apply(this, args);
return defaultHandler ? ret : undefined;
};
this.transformAction = function(state, action, editor, session, param) {
if (this.$behaviour) {
var behaviours = this.$behaviour.getBehaviours();
for (var key in behaviours) {
if (behaviours[key][action]) {
var ret = behaviours[key][action].apply(this, arguments);
if (ret) {
return ret;
}
}
}
}
};
this.getKeywords = function(append) {
if (!this.completionKeywords) {
var rules = this.$tokenizer.rules;
var completionKeywords = [];
for (var rule in rules) {
var ruleItr = rules[rule];
for (var r = 0, l = ruleItr.length; r < l; r++) {
if (typeof ruleItr[r].token === "string") {
if (/keyword|support|storage/.test(ruleItr[r].token))
completionKeywords.push(ruleItr[r].regex);
}
else if (typeof ruleItr[r].token === "object") {
for (var a = 0, aLength = ruleItr[r].token.length; a < aLength; a++) {
if (/keyword|support|storage/.test(ruleItr[r].token[a])) {
var rule = ruleItr[r].regex.match(/\(.+?\)/g)[a];
completionKeywords.push(rule.substr(1, rule.length - 2));
}
}
}
}
}
this.completionKeywords = completionKeywords;
}
if (!append)
return this.$keywordList;
return completionKeywords.concat(this.$keywordList || []);
};
this.$createKeywordList = function() {
if (!this.$highlightRules)
this.getTokenizer();
return this.$keywordList = this.$highlightRules.$keywordList || [];
};
this.getCompletions = function(state, session, pos, prefix) {
var keywords = this.$keywordList || this.$createKeywordList();
return keywords.map(function(word) {
return {
name: word,
value: word,
score: 0,
meta: "keyword"
};
});
};
this.$id = "ace/mode/text";
}).call(Mode.prototype);
exports.Mode = Mode;
});
define("ace/anchor",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"], function(require, exports, module) {
"use strict";
var oop = require("./lib/oop");
var EventEmitter = require("./lib/event_emitter").EventEmitter;
var Anchor = exports.Anchor = function(doc, row, column) {
this.$onChange = this.onChange.bind(this);
this.attach(doc);
if (typeof column == "undefined")
this.setPosition(row.row, row.column);
else
this.setPosition(row, column);
};
(function() {
oop.implement(this, EventEmitter);
this.getPosition = function() {
return this.$clipPositionToDocument(this.row, this.column);
};
this.getDocument = function() {
return this.document;
};
this.$insertRight = false;
this.onChange = function(e) {
var delta = e.data;
var range = delta.range;
if (range.start.row == range.end.row && range.start.row != this.row)
return;
if (range.start.row > this.row)
return;
if (range.start.row == this.row && range.start.column > this.column)
return;
var row = this.row;
var column = this.column;
var start = range.start;
var end = range.end;
if (delta.action === "insertText") {
if (start.row === row && start.column <= column) {
if (start.column === column && this.$insertRight) {
} else if (start.row === end.row) {
column += end.column - start.column;
} else {
column -= start.column;
row += end.row - start.row;
}
} else if (start.row !== end.row && start.row < row) {
row += end.row - start.row;
}
} else if (delta.action === "insertLines") {
if (start.row === row && column === 0 && this.$insertRight) {
}
else if (start.row <= row) {
row += end.row - start.row;
}
} else if (delta.action === "removeText") {
if (start.row === row && start.column < column) {
if (end.column >= column)
column = start.column;
else
column = Math.max(0, column - (end.column - start.column));
} else if (start.row !== end.row && start.row < row) {
if (end.row === row)
column = Math.max(0, column - end.column) + start.column;
row -= (end.row - start.row);
} else if (end.row === row) {
row -= end.row - start.row;
column = Math.max(0, column - end.column) + start.column;
}
} else if (delta.action == "removeLines") {
if (start.row <= row) {
if (end.row <= row)
row -= end.row - start.row;
else {
row = start.row;
column = 0;
}
}
}
this.setPosition(row, column, true);
};
this.setPosition = function(row, column, noClip) {
var pos;
if (noClip) {
pos = {
row: row,
column: column
};
} else {
pos = this.$clipPositionToDocument(row, column);
}
if (this.row == pos.row && this.column == pos.column)
return;
var old = {
row: this.row,
column: this.column
};
this.row = pos.row;
this.column = pos.column;
this._signal("change", {
old: old,
value: pos
});
};
this.detach = function() {
this.document.removeEventListener("change", this.$onChange);
};
this.attach = function(doc) {
this.document = doc || this.document;
this.document.on("change", this.$onChange);
};
this.$clipPositionToDocument = function(row, column) {
var pos = {};
if (row >= this.document.getLength()) {
pos.row = Math.max(0, this.document.getLength() - 1);
pos.column = this.document.getLine(pos.row).length;
}
else if (row < 0) {
pos.row = 0;
pos.column = 0;
}
else {
pos.row = row;
pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column));
}
if (column < 0)
pos.column = 0;
return pos;
};
}).call(Anchor.prototype);
});
define("ace/document",["require","exports","module","ace/lib/oop","ace/lib/event_emitter","ace/range","ace/anchor"], function(require, exports, module) {
"use strict";
var oop = require("./lib/oop");
var EventEmitter = require("./lib/event_emitter").EventEmitter;
var Range = require("./range").Range;
var Anchor = require("./anchor").Anchor;
var Document = function(text) {
this.$lines = [];
if (text.length === 0) {
this.$lines = [""];
} else if (Array.isArray(text)) {
this._insertLines(0, text);
} else {
this.insert({row: 0, column:0}, text);
}
};
(function() {
oop.implement(this, EventEmitter);
this.setValue = function(text) {
var len = this.getLength();
this.remove(new Range(0, 0, len, this.getLine(len-1).length));
this.insert({row: 0, column:0}, text);
};
this.getValue = function() {
return this.getAllLines().join(this.getNewLineCharacter());
};
this.createAnchor = function(row, column) {
return new Anchor(this, row, column);
};
if ("aaa".split(/a/).length === 0)
this.$split = function(text) {
return text.replace(/\r\n|\r/g, "\n").split("\n");
};
else
this.$split = function(text) {
return text.split(/\r\n|\r|\n/);
};
this.$detectNewLine = function(text) {
var match = text.match(/^.*?(\r\n|\r|\n)/m);
this.$autoNewLine = match ? match[1] : "\n";
this._signal("changeNewLineMode");
};
this.getNewLineCharacter = function() {
switch (this.$newLineMode) {
case "windows":
return "\r\n";
case "unix":
return "\n";
default:
return this.$autoNewLine || "\n";
}
};
this.$autoNewLine = "";
this.$newLineMode = "auto";
this.setNewLineMode = function(newLineMode) {
if (this.$newLineMode === newLineMode)
return;
this.$newLineMode = newLineMode;
this._signal("changeNewLineMode");
};
this.getNewLineMode = function() {
return this.$newLineMode;
};
this.isNewLine = function(text) {
return (text == "\r\n" || text == "\r" || text == "\n");
};
this.getLine = function(row) {
return this.$lines[row] || "";
};
this.getLines = function(firstRow, lastRow) {
return this.$lines.slice(firstRow, lastRow + 1);
};
this.getAllLines = function() {
return this.getLines(0, this.getLength());
};
this.getLength = function() {
return this.$lines.length;
};
this.getTextRange = function(range) {
if (range.start.row == range.end.row) {
return this.getLine(range.start.row)
.substring(range.start.column, range.end.column);
}
var lines = this.getLines(range.start.row, range.end.row);
lines[0] = (lines[0] || "").substring(range.start.column);
var l = lines.length - 1;
if (range.end.row - range.start.row == l)
lines[l] = lines[l].substring(0, range.end.column);
return lines.join(this.getNewLineCharacter());
};
this.$clipPosition = function(position) {
var length = this.getLength();
if (position.row >= length) {
position.row = Math.max(0, length - 1);
position.column = this.getLine(length-1).length;
} else if (position.row < 0)
position.row = 0;
return position;
};
this.insert = function(position, text) {
if (!text || text.length === 0)
return position;
position = this.$clipPosition(position);
if (this.getLength() <= 1)
this.$detectNewLine(text);
var lines = this.$split(text);
var firstLine = lines.splice(0, 1)[0];
var lastLine = lines.length == 0 ? null : lines.splice(lines.length - 1, 1)[0];
position = this.insertInLine(position, firstLine);
if (lastLine !== null) {
position = this.insertNewLine(position); // terminate first line
position = this._insertLines(position.row, lines);
position = this.insertInLine(position, lastLine || "");
}
return position;
};
this.insertLines = function(row, lines) {
if (row >= this.getLength())
return this.insert({row: row, column: 0}, "\n" + lines.join("\n"));
return this._insertLines(Math.max(row, 0), lines);
};
this._insertLines = function(row, lines) {
if (lines.length == 0)
return {row: row, column: 0};
while (lines.length > 0xF000) {
var end = this._insertLines(row, lines.slice(0, 0xF000));
lines = lines.slice(0xF000);
row = end.row;
}
var args = [row, 0];
args.push.apply(args, lines);
this.$lines.splice.apply(this.$lines, args);
var range = new Range(row, 0, row + lines.length, 0);
var delta = {
action: "insertLines",
range: range,
lines: lines
};
this._signal("change", { data: delta });
return range.end;
};
this.insertNewLine = function(position) {
position = this.$clipPosition(position);
var line = this.$lines[position.row] || "";
this.$lines[position.row] = line.substring(0, position.column);
this.$lines.splice(position.row + 1, 0, line.substring(position.column, line.length));
var end = {
row : position.row + 1,
column : 0
};
var delta = {
action: "insertText",
range: Range.fromPoints(position, end),
text: this.getNewLineCharacter()
};
this._signal("change", { data: delta });
return end;
};
this.insertInLine = function(position, text) {
if (text.length == 0)
return position;
var line = this.$lines[position.row] || "";
this.$lines[position.row] = line.substring(0, position.column) + text
+ line.substring(position.column);
var end = {
row : position.row,
column : position.column + text.length
};
var delta = {
action: "insertText",
range: Range.fromPoints(position, end),
text: text
};
this._signal("change", { data: delta });
return end;
};
this.remove = function(range) {
if (!(range instanceof Range))
range = Range.fromPoints(range.start, range.end);
range.start = this.$clipPosition(range.start);
range.end = this.$clipPosition(range.end);
if (range.isEmpty())
return range.start;
var firstRow = range.start.row;
var lastRow = range.end.row;
if (range.isMultiLine()) {
var firstFullRow = range.start.column == 0 ? firstRow : firstRow + 1;
var lastFullRow = lastRow - 1;
if (range.end.column > 0)
this.removeInLine(lastRow, 0, range.end.column);
if (lastFullRow >= firstFullRow)
this._removeLines(firstFullRow, lastFullRow);
if (firstFullRow != firstRow) {
this.removeInLine(firstRow, range.start.column, this.getLine(firstRow).length);
this.removeNewLine(range.start.row);
}
}
else {
this.removeInLine(firstRow, range.start.column, range.end.column);
}
return range.start;
};
this.removeInLine = function(row, startColumn, endColumn) {
if (startColumn == endColumn)
return;
var range = new Range(row, startColumn, row, endColumn);
var line = this.getLine(row);
var removed = line.substring(startColumn, endColumn);
var newLine = line.substring(0, startColumn) + line.substring(endColumn, line.length);
this.$lines.splice(row, 1, newLine);
var delta = {
action: "removeText",
range: range,
text: removed
};
this._signal("change", { data: delta });
return range.start;
};
this.removeLines = function(firstRow, lastRow) {
if (firstRow < 0 || lastRow >= this.getLength())
return this.remove(new Range(firstRow, 0, lastRow + 1, 0));
return this._removeLines(firstRow, lastRow);
};
this._removeLines = function(firstRow, lastRow) {
var range = new Range(firstRow, 0, lastRow + 1, 0);
var removed = this.$lines.splice(firstRow, lastRow - firstRow + 1);
var delta = {
action: "removeLines",
range: range,
nl: this.getNewLineCharacter(),
lines: removed
};
this._signal("change", { data: delta });
return removed;
};
this.removeNewLine = function(row) {
var firstLine = this.getLine(row);
var secondLine = this.getLine(row+1);
var range = new Range(row, firstLine.length, row+1, 0);
var line = firstLine + secondLine;
this.$lines.splice(row, 2, line);
var delta = {
action: "removeText",
range: range,
text: this.getNewLineCharacter()
};
this._signal("change", { data: delta });
};
this.replace = function(range, text) {
if (!(range instanceof Range))
range = Range.fromPoints(range.start, range.end);
if (text.length == 0 && range.isEmpty())
return range.start;
if (text == this.getTextRange(range))
return range.end;
this.remove(range);
if (text) {
var end = this.insert(range.start, text);
}
else {
end = range.start;
}
return end;
};
this.applyDeltas = function(deltas) {
for (var i=0; i=0; i--) {
var delta = deltas[i];
var range = Range.fromPoints(delta.range.start, delta.range.end);
if (delta.action == "insertLines")
this._removeLines(range.start.row, range.end.row - 1);
else if (delta.action == "insertText")
this.remove(range);
else if (delta.action == "removeLines")
this._insertLines(range.start.row, delta.lines);
else if (delta.action == "removeText")
this.insert(range.start, delta.text);
}
};
this.indexToPosition = function(index, startRow) {
var lines = this.$lines || this.getAllLines();
var newlineLength = this.getNewLineCharacter().length;
for (var i = startRow || 0, l = lines.length; i < l; i++) {
index -= lines[i].length + newlineLength;
if (index < 0)
return {row: i, column: index + lines[i].length + newlineLength};
}
return {row: l-1, column: lines[l-1].length};
};
this.positionToIndex = function(pos, startRow) {
var lines = this.$lines || this.getAllLines();
var newlineLength = this.getNewLineCharacter().length;
var index = 0;
var row = Math.min(pos.row, lines.length);
for (var i = startRow || 0; i < row; ++i)
index += lines[i].length + newlineLength;
return index + pos.column;
};
}).call(Document.prototype);
exports.Document = Document;
});
define("ace/background_tokenizer",["require","exports","module","ace/lib/oop","ace/lib/event_emitter"], function(require, exports, module) {
"use strict";
var oop = require("./lib/oop");
var EventEmitter = require("./lib/event_emitter").EventEmitter;
var BackgroundTokenizer = function(tokenizer, editor) {
this.running = false;
this.lines = [];
this.states = [];
this.currentLine = 0;
this.tokenizer = tokenizer;
var self = this;
this.$worker = function() {
if (!self.running) { return; }
var workerStart = new Date();
var currentLine = self.currentLine;
var endLine = -1;
var doc = self.doc;
while (self.lines[currentLine])
currentLine++;
var startLine = currentLine;
var len = doc.getLength();
var processedLines = 0;
self.running = false;
while (currentLine < len) {
self.$tokenizeRow(currentLine);
endLine = currentLine;
do {
currentLine++;
} while (self.lines[currentLine]);
processedLines ++;
if ((processedLines % 5 === 0) && (new Date() - workerStart) > 20) {
self.running = setTimeout(self.$worker, 20);
break;
}
}
self.currentLine = currentLine;
if (startLine <= endLine)
self.fireUpdateEvent(startLine, endLine);
};
};
(function(){
oop.implement(this, EventEmitter);
this.setTokenizer = function(tokenizer) {
this.tokenizer = tokenizer;
this.lines = [];
this.states = [];
this.start(0);
};
this.setDocument = function(doc) {
this.doc = doc;
this.lines = [];
this.states = [];
this.stop();
};
this.fireUpdateEvent = function(firstRow, lastRow) {
var data = {
first: firstRow,
last: lastRow
};
this._signal("update", {data: data});
};
this.start = function(startRow) {
this.currentLine = Math.min(startRow || 0, this.currentLine, this.doc.getLength());
this.lines.splice(this.currentLine, this.lines.length);
this.states.splice(this.currentLine, this.states.length);
this.stop();
this.running = setTimeout(this.$worker, 700);
};
this.scheduleStart = function() {
if (!this.running)
this.running = setTimeout(this.$worker, 700);
}
this.$updateOnChange = function(delta) {
var range = delta.range;
var startRow = range.start.row;
var len = range.end.row - startRow;
if (len === 0) {
this.lines[startRow] = null;
} else if (delta.action == "removeText" || delta.action == "removeLines") {
this.lines.splice(startRow, len + 1, null);
this.states.splice(startRow, len + 1, null);
} else {
var args = Array(len + 1);
args.unshift(startRow, 1);
this.lines.splice.apply(this.lines, args);
this.states.splice.apply(this.states, args);
}
this.currentLine = Math.min(startRow, this.currentLine, this.doc.getLength());
this.stop();
};
this.stop = function() {
if (this.running)
clearTimeout(this.running);
this.running = false;
};
this.getTokens = function(row) {
return this.lines[row] || this.$tokenizeRow(row);
};
this.getState = function(row) {
if (this.currentLine == row)
this.$tokenizeRow(row);
return this.states[row] || "start";
};
this.$tokenizeRow = function(row) {
var line = this.doc.getLine(row);
var state = this.states[row - 1];
var data = this.tokenizer.getLineTokens(line, state, row);
if (this.states[row] + "" !== data.state + "") {
this.states[row] = data.state;
this.lines[row + 1] = null;
if (this.currentLine > row + 1)
this.currentLine = row + 1;
} else if (this.currentLine == row) {
this.currentLine = row + 1;
}
return this.lines[row] = data.tokens;
};
}).call(BackgroundTokenizer.prototype);
exports.BackgroundTokenizer = BackgroundTokenizer;
});
define("ace/search_highlight",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/range"], function(require, exports, module) {
"use strict";
var lang = require("./lib/lang");
var oop = require("./lib/oop");
var Range = require("./range").Range;
var SearchHighlight = function(regExp, clazz, type) {
this.setRegexp(regExp);
this.clazz = clazz;
this.type = type || "text";
};
(function() {
this.MAX_RANGES = 500;
this.setRegexp = function(regExp) {
if (this.regExp+"" == regExp+"")
return;
this.regExp = regExp;
this.cache = [];
};
this.update = function(html, markerLayer, session, config) {
if (!this.regExp)
return;
var start = config.firstRow, end = config.lastRow;
for (var i = start; i <= end; i++) {
var ranges = this.cache[i];
if (ranges == null) {
ranges = lang.getMatchOffsets(session.getLine(i), this.regExp);
if (ranges.length > this.MAX_RANGES)
ranges = ranges.slice(0, this.MAX_RANGES);
ranges = ranges.map(function(match) {
return new Range(i, match.offset, i, match.offset + match.length);
});
this.cache[i] = ranges.length ? ranges : "";
}
for (var j = ranges.length; j --; ) {
markerLayer.drawSingleLineMarker(
html, ranges[j].toScreenRange(session), this.clazz, config);
}
}
};
}).call(SearchHighlight.prototype);
exports.SearchHighlight = SearchHighlight;
});
define("ace/edit_session/fold_line",["require","exports","module","ace/range"], function(require, exports, module) {
"use strict";
var Range = require("../range").Range;
function FoldLine(foldData, folds) {
this.foldData = foldData;
if (Array.isArray(folds)) {
this.folds = folds;
} else {
folds = this.folds = [ folds ];
}
var last = folds[folds.length - 1];
this.range = new Range(folds[0].start.row, folds[0].start.column,
last.end.row, last.end.column);
this.start = this.range.start;
this.end = this.range.end;
this.folds.forEach(function(fold) {
fold.setFoldLine(this);
}, this);
}
(function() {
this.shiftRow = function(shift) {
this.start.row += shift;
this.end.row += shift;
this.folds.forEach(function(fold) {
fold.start.row += shift;
fold.end.row += shift;
});
};
this.addFold = function(fold) {
if (fold.sameRow) {
if (fold.start.row < this.startRow || fold.endRow > this.endRow) {
throw new Error("Can't add a fold to this FoldLine as it has no connection");
}
this.folds.push(fold);
this.folds.sort(function(a, b) {
return -a.range.compareEnd(b.start.row, b.start.column);
});
if (this.range.compareEnd(fold.start.row, fold.start.column) > 0) {
this.end.row = fold.end.row;
this.end.column = fold.end.column;
} else if (this.range.compareStart(fold.end.row, fold.end.column) < 0) {
this.start.row = fold.start.row;
this.start.column = fold.start.column;
}
} else if (fold.start.row == this.end.row) {
this.folds.push(fold);
this.end.row = fold.end.row;
this.end.column = fold.end.column;
} else if (fold.end.row == this.start.row) {
this.folds.unshift(fold);
this.start.row = fold.start.row;
this.start.column = fold.start.column;
} else {
throw new Error("Trying to add fold to FoldRow that doesn't have a matching row");
}
fold.foldLine = this;
};
this.containsRow = function(row) {
return row >= this.start.row && row <= this.end.row;
};
this.walk = function(callback, endRow, endColumn) {
var lastEnd = 0,
folds = this.folds,
fold,
cmp, stop, isNewRow = true;
if (endRow == null) {
endRow = this.end.row;
endColumn = this.end.column;
}
for (var i = 0; i < folds.length; i++) {
fold = folds[i];
cmp = fold.range.compareStart(endRow, endColumn);
if (cmp == -1) {
callback(null, endRow, endColumn, lastEnd, isNewRow);
return;
}
stop = callback(null, fold.start.row, fold.start.column, lastEnd, isNewRow);
stop = !stop && callback(fold.placeholder, fold.start.row, fold.start.column, lastEnd);
if (stop || cmp === 0) {
return;
}
isNewRow = !fold.sameRow;
lastEnd = fold.end.column;
}
callback(null, endRow, endColumn, lastEnd, isNewRow);
};
this.getNextFoldTo = function(row, column) {
var fold, cmp;
for (var i = 0; i < this.folds.length; i++) {
fold = this.folds[i];
cmp = fold.range.compareEnd(row, column);
if (cmp == -1) {
return {
fold: fold,
kind: "after"
};
} else if (cmp === 0) {
return {
fold: fold,
kind: "inside"
};
}
}
return null;
};
this.addRemoveChars = function(row, column, len) {
var ret = this.getNextFoldTo(row, column),
fold, folds;
if (ret) {
fold = ret.fold;
if (ret.kind == "inside"
&& fold.start.column != column
&& fold.start.row != row)
{
window.console && window.console.log(row, column, fold);
} else if (fold.start.row == row) {
folds = this.folds;
var i = folds.indexOf(fold);
if (i === 0) {
this.start.column += len;
}
for (i; i < folds.length; i++) {
fold = folds[i];
fold.start.column += len;
if (!fold.sameRow) {
return;
}
fold.end.column += len;
}
this.end.column += len;
}
}
};
this.split = function(row, column) {
var pos = this.getNextFoldTo(row, column);
if (!pos || pos.kind == "inside")
return null;
var fold = pos.fold;
var folds = this.folds;
var foldData = this.foldData;
var i = folds.indexOf(fold);
var foldBefore = folds[i - 1];
this.end.row = foldBefore.end.row;
this.end.column = foldBefore.end.column;
folds = folds.splice(i, folds.length - i);
var newFoldLine = new FoldLine(foldData, folds);
foldData.splice(foldData.indexOf(this) + 1, 0, newFoldLine);
return newFoldLine;
};
this.merge = function(foldLineNext) {
var folds = foldLineNext.folds;
for (var i = 0; i < folds.length; i++) {
this.addFold(folds[i]);
}
var foldData = this.foldData;
foldData.splice(foldData.indexOf(foldLineNext), 1);
};
this.toString = function() {
var ret = [this.range.toString() + ": [" ];
this.folds.forEach(function(fold) {
ret.push(" " + fold.toString());
});
ret.push("]");
return ret.join("\n");
};
this.idxToPosition = function(idx) {
var lastFoldEndColumn = 0;
for (var i = 0; i < this.folds.length; i++) {
var fold = this.folds[i];
idx -= fold.start.column - lastFoldEndColumn;
if (idx < 0) {
return {
row: fold.start.row,
column: fold.start.column + idx
};
}
idx -= fold.placeholder.length;
if (idx < 0) {
return fold.start;
}
lastFoldEndColumn = fold.end.column;
}
return {
row: this.end.row,
column: this.end.column + idx
};
};
}).call(FoldLine.prototype);
exports.FoldLine = FoldLine;
});
define("ace/range_list",["require","exports","module","ace/range"], function(require, exports, module) {
"use strict";
var Range = require("./range").Range;
var comparePoints = Range.comparePoints;
var RangeList = function() {
this.ranges = [];
};
(function() {
this.comparePoints = comparePoints;
this.pointIndex = function(pos, excludeEdges, startIndex) {
var list = this.ranges;
for (var i = startIndex || 0; i < list.length; i++) {
var range = list[i];
var cmpEnd = comparePoints(pos, range.end);
if (cmpEnd > 0)
continue;
var cmpStart = comparePoints(pos, range.start);
if (cmpEnd === 0)
return excludeEdges && cmpStart !== 0 ? -i-2 : i;
if (cmpStart > 0 || (cmpStart === 0 && !excludeEdges))
return i;
return -i-1;
}
return -i - 1;
};
this.add = function(range) {
var excludeEdges = !range.isEmpty();
var startIndex = this.pointIndex(range.start, excludeEdges);
if (startIndex < 0)
startIndex = -startIndex - 1;
var endIndex = this.pointIndex(range.end, excludeEdges, startIndex);
if (endIndex < 0)
endIndex = -endIndex - 1;
else
endIndex++;
return this.ranges.splice(startIndex, endIndex - startIndex, range);
};
this.addList = function(list) {
var removed = [];
for (var i = list.length; i--; ) {
removed.push.call(removed, this.add(list[i]));
}
return removed;
};
this.substractPoint = function(pos) {
var i = this.pointIndex(pos);
if (i >= 0)
return this.ranges.splice(i, 1);
};
this.merge = function() {
var removed = [];
var list = this.ranges;
list = list.sort(function(a, b) {
return comparePoints(a.start, b.start);
});
var next = list[0], range;
for (var i = 1; i < list.length; i++) {
range = next;
next = list[i];
var cmp = comparePoints(range.end, next.start);
if (cmp < 0)
continue;
if (cmp == 0 && !range.isEmpty() && !next.isEmpty())
continue;
if (comparePoints(range.end, next.end) < 0) {
range.end.row = next.end.row;
range.end.column = next.end.column;
}
list.splice(i, 1);
removed.push(next);
next = range;
i--;
}
this.ranges = list;
return removed;
};
this.contains = function(row, column) {
return this.pointIndex({row: row, column: column}) >= 0;
};
this.containsPoint = function(pos) {
return this.pointIndex(pos) >= 0;
};
this.rangeAtPoint = function(pos) {
var i = this.pointIndex(pos);
if (i >= 0)
return this.ranges[i];
};
this.clipRows = function(startRow, endRow) {
var list = this.ranges;
if (list[0].start.row > endRow || list[list.length - 1].start.row < startRow)
return [];
var startIndex = this.pointIndex({row: startRow, column: 0});
if (startIndex < 0)
startIndex = -startIndex - 1;
var endIndex = this.pointIndex({row: endRow, column: 0}, startIndex);
if (endIndex < 0)
endIndex = -endIndex - 1;
var clipped = [];
for (var i = startIndex; i < endIndex; i++) {
clipped.push(list[i]);
}
return clipped;
};
this.removeAll = function() {
return this.ranges.splice(0, this.ranges.length);
};
this.attach = function(session) {
if (this.session)
this.detach();
this.session = session;
this.onChange = this.$onChange.bind(this);
this.session.on('change', this.onChange);
};
this.detach = function() {
if (!this.session)
return;
this.session.removeListener('change', this.onChange);
this.session = null;
};
this.$onChange = function(e) {
var changeRange = e.data.range;
if (e.data.action[0] == "i"){
var start = changeRange.start;
var end = changeRange.end;
} else {
var end = changeRange.start;
var start = changeRange.end;
}
var startRow = start.row;
var endRow = end.row;
var lineDif = endRow - startRow;
var colDiff = -start.column + end.column;
var ranges = this.ranges;
for (var i = 0, n = ranges.length; i < n; i++) {
var r = ranges[i];
if (r.end.row < startRow)
continue;
if (r.start.row > startRow)
break;
if (r.start.row == startRow && r.start.column >= start.column ) {
if (r.start.column == start.column && this.$insertRight) {
} else {
r.start.column += colDiff;
r.start.row += lineDif;
}
}
if (r.end.row == startRow && r.end.column >= start.column) {
if (r.end.column == start.column && this.$insertRight) {
continue;
}
if (r.end.column == start.column && colDiff > 0 && i < n - 1) {
if (r.end.column > r.start.column && r.end.column == ranges[i+1].start.column)
r.end.column -= colDiff;
}
r.end.column += colDiff;
r.end.row += lineDif;
}
}
if (lineDif != 0 && i < n) {
for (; i < n; i++) {
var r = ranges[i];
r.start.row += lineDif;
r.end.row += lineDif;
}
}
};
}).call(RangeList.prototype);
exports.RangeList = RangeList;
});
define("ace/edit_session/fold",["require","exports","module","ace/range","ace/range_list","ace/lib/oop"], function(require, exports, module) {
"use strict";
var Range = require("../range").Range;
var RangeList = require("../range_list").RangeList;
var oop = require("../lib/oop")
var Fold = exports.Fold = function(range, placeholder) {
this.foldLine = null;
this.placeholder = placeholder;
this.range = range;
this.start = range.start;
this.end = range.end;
this.sameRow = range.start.row == range.end.row;
this.subFolds = this.ranges = [];
};
oop.inherits(Fold, RangeList);
(function() {
this.toString = function() {
return '"' + this.placeholder + '" ' + this.range.toString();
};
this.setFoldLine = function(foldLine) {
this.foldLine = foldLine;
this.subFolds.forEach(function(fold) {
fold.setFoldLine(foldLine);
});
};
this.clone = function() {
var range = this.range.clone();
var fold = new Fold(range, this.placeholder);
this.subFolds.forEach(function(subFold) {
fold.subFolds.push(subFold.clone());
});
fold.collapseChildren = this.collapseChildren;
return fold;
};
this.addSubFold = function(fold) {
if (this.range.isEqual(fold))
return;
if (!this.range.containsRange(fold))
throw new Error("A fold can't intersect already existing fold" + fold.range + this.range);
consumeRange(fold, this.start);
var row = fold.start.row, column = fold.start.column;
for (var i = 0, cmp = -1; i < this.subFolds.length; i++) {
cmp = this.subFolds[i].range.compare(row, column);
if (cmp != 1)
break;
}
var afterStart = this.subFolds[i];
if (cmp == 0)
return afterStart.addSubFold(fold);
var row = fold.range.end.row, column = fold.range.end.column;
for (var j = i, cmp = -1; j < this.subFolds.length; j++) {
cmp = this.subFolds[j].range.compare(row, column);
if (cmp != 1)
break;
}
var afterEnd = this.subFolds[j];
if (cmp == 0)
throw new Error("A fold can't intersect already existing fold" + fold.range + this.range);
var consumedFolds = this.subFolds.splice(i, j - i, fold);
fold.setFoldLine(this.foldLine);
return fold;
};
this.restoreRange = function(range) {
return restoreRange(range, this.start);
};
}).call(Fold.prototype);
function consumePoint(point, anchor) {
point.row -= anchor.row;
if (point.row == 0)
point.column -= anchor.column;
}
function consumeRange(range, anchor) {
consumePoint(range.start, anchor);
consumePoint(range.end, anchor);
}
function restorePoint(point, anchor) {
if (point.row == 0)
point.column += anchor.column;
point.row += anchor.row;
}
function restoreRange(range, anchor) {
restorePoint(range.start, anchor);
restorePoint(range.end, anchor);
}
});
define("ace/edit_session/folding",["require","exports","module","ace/range","ace/edit_session/fold_line","ace/edit_session/fold","ace/token_iterator"], function(require, exports, module) {
"use strict";
var Range = require("../range").Range;
var FoldLine = require("./fold_line").FoldLine;
var Fold = require("./fold").Fold;
var TokenIterator = require("../token_iterator").TokenIterator;
function Folding() {
this.getFoldAt = function(row, column, side) {
var foldLine = this.getFoldLine(row);
if (!foldLine)
return null;
var folds = foldLine.folds;
for (var i = 0; i < folds.length; i++) {
var fold = folds[i];
if (fold.range.contains(row, column)) {
if (side == 1 && fold.range.isEnd(row, column)) {
continue;
} else if (side == -1 && fold.range.isStart(row, column)) {
continue;
}
return fold;
}
}
};
this.getFoldsInRange = function(range) {
var start = range.start;
var end = range.end;
var foldLines = this.$foldData;
var foundFolds = [];
start.column += 1;
end.column -= 1;
for (var i = 0; i < foldLines.length; i++) {
var cmp = foldLines[i].range.compareRange(range);
if (cmp == 2) {
continue;
}
else if (cmp == -2) {
break;
}
var folds = foldLines[i].folds;
for (var j = 0; j < folds.length; j++) {
var fold = folds[j];
cmp = fold.range.compareRange(range);
if (cmp == -2) {
break;
} else if (cmp == 2) {
continue;
} else
if (cmp == 42) {
break;
}
foundFolds.push(fold);
}
}
start.column -= 1;
end.column += 1;
return foundFolds;
};
this.getFoldsInRangeList = function(ranges) {
if (Array.isArray(ranges)) {
var folds = [];
ranges.forEach(function(range) {
folds = folds.concat(this.getFoldsInRange(range));
}, this);
} else {
var folds = this.getFoldsInRange(ranges);
}
return folds;
}
this.getAllFolds = function() {
var folds = [];
var foldLines = this.$foldData;
for (var i = 0; i < foldLines.length; i++)
for (var j = 0; j < foldLines[i].folds.length; j++)
folds.push(foldLines[i].folds[j]);
return folds;
};
this.getFoldStringAt = function(row, column, trim, foldLine) {
foldLine = foldLine || this.getFoldLine(row);
if (!foldLine)
return null;
var lastFold = {
end: { column: 0 }
};
var str, fold;
for (var i = 0; i < foldLine.folds.length; i++) {
fold = foldLine.folds[i];
var cmp = fold.range.compareEnd(row, column);
if (cmp == -1) {
str = this
.getLine(fold.start.row)
.substring(lastFold.end.column, fold.start.column);
break;
}
else if (cmp === 0) {
return null;
}
lastFold = fold;
}
if (!str)
str = this.getLine(fold.start.row).substring(lastFold.end.column);
if (trim == -1)
return str.substring(0, column - lastFold.end.column);
else if (trim == 1)
return str.substring(column - lastFold.end.column);
else
return str;
};
this.getFoldLine = function(docRow, startFoldLine) {
var foldData = this.$foldData;
var i = 0;
if (startFoldLine)
i = foldData.indexOf(startFoldLine);
if (i == -1)
i = 0;
for (i; i < foldData.length; i++) {
var foldLine = foldData[i];
if (foldLine.start.row <= docRow && foldLine.end.row >= docRow) {
return foldLine;
} else if (foldLine.end.row > docRow) {
return null;
}
}
return null;
};
this.getNextFoldLine = function(docRow, startFoldLine) {
var foldData = this.$foldData;
var i = 0;
if (startFoldLine)
i = foldData.indexOf(startFoldLine);
if (i == -1)
i = 0;
for (i; i < foldData.length; i++) {
var foldLine = foldData[i];
if (foldLine.end.row >= docRow) {
return foldLine;
}
}
return null;
};
this.getFoldedRowCount = function(first, last) {
var foldData = this.$foldData, rowCount = last-first+1;
for (var i = 0; i < foldData.length; i++) {
var foldLine = foldData[i],
end = foldLine.end.row,
start = foldLine.start.row;
if (end >= last) {
if(start < last) {
if(start >= first)
rowCount -= last-start;
else
rowCount = 0;//in one fold
}
break;
} else if(end >= first){
if (start >= first) //fold inside range
rowCount -= end-start;
else
rowCount -= end-first+1;
}
}
return rowCount;
};
this.$addFoldLine = function(foldLine) {
this.$foldData.push(foldLine);
this.$foldData.sort(function(a, b) {
return a.start.row - b.start.row;
});
return foldLine;
};
this.addFold = function(placeholder, range) {
var foldData = this.$foldData;
var added = false;
var fold;
if (placeholder instanceof Fold)
fold = placeholder;
else {
fold = new Fold(range, placeholder);
fold.collapseChildren = range.collapseChildren;
}
this.$clipRangeToDocument(fold.range);
var startRow = fold.start.row;
var startColumn = fold.start.column;
var endRow = fold.end.row;
var endColumn = fold.end.column;
if (!(startRow < endRow ||
startRow == endRow && startColumn <= endColumn - 2))
throw new Error("The range has to be at least 2 characters width");
var startFold = this.getFoldAt(startRow, startColumn, 1);
var endFold = this.getFoldAt(endRow, endColumn, -1);
if (startFold && endFold == startFold)
return startFold.addSubFold(fold);
if (startFold && !startFold.range.isStart(startRow, startColumn))
this.removeFold(startFold);
if (endFold && !endFold.range.isEnd(endRow, endColumn))
this.removeFold(endFold);
var folds = this.getFoldsInRange(fold.range);
if (folds.length > 0) {
this.removeFolds(folds);
folds.forEach(function(subFold) {
fold.addSubFold(subFold);
});
}
for (var i = 0; i < foldData.length; i++) {
var foldLine = foldData[i];
if (endRow == foldLine.start.row) {
foldLine.addFold(fold);
added = true;
break;
} else if (startRow == foldLine.end.row) {
foldLine.addFold(fold);
added = true;
if (!fold.sameRow) {
var foldLineNext = foldData[i + 1];
if (foldLineNext && foldLineNext.start.row == endRow) {
foldLine.merge(foldLineNext);
break;
}
}
break;
} else if (endRow <= foldLine.start.row) {
break;
}
}
if (!added)
foldLine = this.$addFoldLine(new FoldLine(this.$foldData, fold));
if (this.$useWrapMode)
this.$updateWrapData(foldLine.start.row, foldLine.start.row);
else
this.$updateRowLengthCache(foldLine.start.row, foldLine.start.row);
this.$modified = true;
this._emit("changeFold", { data: fold, action: "add" });
return fold;
};
this.addFolds = function(folds) {
folds.forEach(function(fold) {
this.addFold(fold);
}, this);
};
this.removeFold = function(fold) {
var foldLine = fold.foldLine;
var startRow = foldLine.start.row;
var endRow = foldLine.end.row;
var foldLines = this.$foldData;
var folds = foldLine.folds;
if (folds.length == 1) {
foldLines.splice(foldLines.indexOf(foldLine), 1);
} else
if (foldLine.range.isEnd(fold.end.row, fold.end.column)) {
folds.pop();
foldLine.end.row = folds[folds.length - 1].end.row;
foldLine.end.column = folds[folds.length - 1].end.column;
} else
if (foldLine.range.isStart(fold.start.row, fold.start.column)) {
folds.shift();
foldLine.start.row = folds[0].start.row;
foldLine.start.column = folds[0].start.column;
} else
if (fold.sameRow) {
folds.splice(folds.indexOf(fold), 1);
} else
{
var newFoldLine = foldLine.split(fold.start.row, fold.start.column);
folds = newFoldLine.folds;
folds.shift();
newFoldLine.start.row = folds[0].start.row;
newFoldLine.start.column = folds[0].start.column;
}
if (!this.$updating) {
if (this.$useWrapMode)
this.$updateWrapData(startRow, endRow);
else
this.$updateRowLengthCache(startRow, endRow);
}
this.$modified = true;
this._emit("changeFold", { data: fold, action: "remove" });
};
this.removeFolds = function(folds) {
var cloneFolds = [];
for (var i = 0; i < folds.length; i++) {
cloneFolds.push(folds[i]);
}
cloneFolds.forEach(function(fold) {
this.removeFold(fold);
}, this);
this.$modified = true;
};
this.expandFold = function(fold) {
this.removeFold(fold);
fold.subFolds.forEach(function(subFold) {
fold.restoreRange(subFold);
this.addFold(subFold);
}, this);
if (fold.collapseChildren > 0) {
this.foldAll(fold.start.row+1, fold.end.row, fold.collapseChildren-1);
}
fold.subFolds = [];
};
this.expandFolds = function(folds) {
folds.forEach(function(fold) {
this.expandFold(fold);
}, this);
};
this.unfold = function(location, expandInner) {
var range, folds;
if (location == null) {
range = new Range(0, 0, this.getLength(), 0);
expandInner = true;
} else if (typeof location == "number")
range = new Range(location, 0, location, this.getLine(location).length);
else if ("row" in location)
range = Range.fromPoints(location, location);
else
range = location;
folds = this.getFoldsInRangeList(range);
if (expandInner) {
this.removeFolds(folds);
} else {
var subFolds = folds;
while (subFolds.length) {
this.expandFolds(subFolds);
subFolds = this.getFoldsInRangeList(range);
}
}
if (folds.length)
return folds;
};
this.isRowFolded = function(docRow, startFoldRow) {
return !!this.getFoldLine(docRow, startFoldRow);
};
this.getRowFoldEnd = function(docRow, startFoldRow) {
var foldLine = this.getFoldLine(docRow, startFoldRow);
return foldLine ? foldLine.end.row : docRow;
};
this.getRowFoldStart = function(docRow, startFoldRow) {
var foldLine = this.getFoldLine(docRow, startFoldRow);
return foldLine ? foldLine.start.row : docRow;
};
this.getFoldDisplayLine = function(foldLine, endRow, endColumn, startRow, startColumn) {
if (startRow == null)
startRow = foldLine.start.row;
if (startColumn == null)
startColumn = 0;
if (endRow == null)
endRow = foldLine.end.row;
if (endColumn == null)
endColumn = this.getLine(endRow).length;
var doc = this.doc;
var textLine = "";
foldLine.walk(function(placeholder, row, column, lastColumn) {
if (row < startRow)
return;
if (row == startRow) {
if (column < startColumn)
return;
lastColumn = Math.max(startColumn, lastColumn);
}
if (placeholder != null) {
textLine += placeholder;
} else {
textLine += doc.getLine(row).substring(lastColumn, column);
}
}, endRow, endColumn);
return textLine;
};
this.getDisplayLine = function(row, endColumn, startRow, startColumn) {
var foldLine = this.getFoldLine(row);
if (!foldLine) {
var line;
line = this.doc.getLine(row);
return line.substring(startColumn || 0, endColumn || line.length);
} else {
return this.getFoldDisplayLine(
foldLine, row, endColumn, startRow, startColumn);
}
};
this.$cloneFoldData = function() {
var fd = [];
fd = this.$foldData.map(function(foldLine) {
var folds = foldLine.folds.map(function(fold) {
return fold.clone();
});
return new FoldLine(fd, folds);
});
return fd;
};
this.toggleFold = function(tryToUnfold) {
var selection = this.selection;
var range = selection.getRange();
var fold;
var bracketPos;
if (range.isEmpty()) {
var cursor = range.start;
fold = this.getFoldAt(cursor.row, cursor.column);
if (fold) {
this.expandFold(fold);
return;
} else if (bracketPos = this.findMatchingBracket(cursor)) {
if (range.comparePoint(bracketPos) == 1) {
range.end = bracketPos;
} else {
range.start = bracketPos;
range.start.column++;
range.end.column--;
}
} else if (bracketPos = this.findMatchingBracket({row: cursor.row, column: cursor.column + 1})) {
if (range.comparePoint(bracketPos) == 1)
range.end = bracketPos;
else
range.start = bracketPos;
range.start.column++;
} else {
range = this.getCommentFoldRange(cursor.row, cursor.column) || range;
}
} else {
var folds = this.getFoldsInRange(range);
if (tryToUnfold && folds.length) {
this.expandFolds(folds);
return;
} else if (folds.length == 1 ) {
fold = folds[0];
}
}
if (!fold)
fold = this.getFoldAt(range.start.row, range.start.column);
if (fold && fold.range.toString() == range.toString()) {
this.expandFold(fold);
return;
}
var placeholder = "...";
if (!range.isMultiLine()) {
placeholder = this.getTextRange(range);
if(placeholder.length < 4)
return;
placeholder = placeholder.trim().substring(0, 2) + "..";
}
this.addFold(placeholder, range);
};
this.getCommentFoldRange = function(row, column, dir) {
var iterator = new TokenIterator(this, row, column);
var token = iterator.getCurrentToken();
if (token && /^comment|string/.test(token.type)) {
var range = new Range();
var re = new RegExp(token.type.replace(/\..*/, "\\."));
if (dir != 1) {
do {
token = iterator.stepBackward();
} while(token && re.test(token.type));
iterator.stepForward();
}
range.start.row = iterator.getCurrentTokenRow();
range.start.column = iterator.getCurrentTokenColumn() + 2;
iterator = new TokenIterator(this, row, column);
if (dir != -1) {
do {
token = iterator.stepForward();
} while(token && re.test(token.type));
token = iterator.stepBackward();
} else
token = iterator.getCurrentToken();
range.end.row = iterator.getCurrentTokenRow();
range.end.column = iterator.getCurrentTokenColumn() + token.value.length - 2;
return range;
}
};
this.foldAll = function(startRow, endRow, depth) {
if (depth == undefined)
depth = 100000; // JSON.stringify doesn't hanle Infinity
var foldWidgets = this.foldWidgets;
if (!foldWidgets)
return; // mode doesn't support folding
endRow = endRow || this.getLength();
startRow = startRow || 0;
for (var row = startRow; row < endRow; row++) {
if (foldWidgets[row] == null)
foldWidgets[row] = this.getFoldWidget(row);
if (foldWidgets[row] != "start")
continue;
var range = this.getFoldWidgetRange(row);
if (range && range.isMultiLine()
&& range.end.row <= endRow
&& range.start.row >= startRow
) {
row = range.end.row;
try {
var fold = this.addFold("...", range);
if (fold)
fold.collapseChildren = depth;
} catch(e) {}
}
}
};
this.$foldStyles = {
"manual": 1,
"markbegin": 1,
"markbeginend": 1
};
this.$foldStyle = "markbegin";
this.setFoldStyle = function(style) {
if (!this.$foldStyles[style])
throw new Error("invalid fold style: " + style + "[" + Object.keys(this.$foldStyles).join(", ") + "]");
if (this.$foldStyle == style)
return;
this.$foldStyle = style;
if (style == "manual")
this.unfold();
var mode = this.$foldMode;
this.$setFolding(null);
this.$setFolding(mode);
};
this.$setFolding = function(foldMode) {
if (this.$foldMode == foldMode)
return;
this.$foldMode = foldMode;
this.removeListener('change', this.$updateFoldWidgets);
this._emit("changeAnnotation");
if (!foldMode || this.$foldStyle == "manual") {
this.foldWidgets = null;
return;
}
this.foldWidgets = [];
this.getFoldWidget = foldMode.getFoldWidget.bind(foldMode, this, this.$foldStyle);
this.getFoldWidgetRange = foldMode.getFoldWidgetRange.bind(foldMode, this, this.$foldStyle);
this.$updateFoldWidgets = this.updateFoldWidgets.bind(this);
this.on('change', this.$updateFoldWidgets);
};
this.getParentFoldRangeData = function (row, ignoreCurrent) {
var fw = this.foldWidgets;
if (!fw || (ignoreCurrent && fw[row]))
return {};
var i = row - 1, firstRange;
while (i >= 0) {
var c = fw[i];
if (c == null)
c = fw[i] = this.getFoldWidget(i);
if (c == "start") {
var range = this.getFoldWidgetRange(i);
if (!firstRange)
firstRange = range;
if (range && range.end.row >= row)
break;
}
i--;
}
return {
range: i !== -1 && range,
firstRange: firstRange
};
}
this.onFoldWidgetClick = function(row, e) {
e = e.domEvent;
var options = {
children: e.shiftKey,
all: e.ctrlKey || e.metaKey,
siblings: e.altKey
};
var range = this.$toggleFoldWidget(row, options);
if (!range) {
var el = (e.target || e.srcElement)
if (el && /ace_fold-widget/.test(el.className))
el.className += " ace_invalid";
}
};
this.$toggleFoldWidget = function(row, options) {
if (!this.getFoldWidget)
return;
var type = this.getFoldWidget(row);
var line = this.getLine(row);
var dir = type === "end" ? -1 : 1;
var fold = this.getFoldAt(row, dir === -1 ? 0 : line.length, dir);
if (fold) {
if (options.children || options.all)
this.removeFold(fold);
else
this.expandFold(fold);
return;
}
var range = this.getFoldWidgetRange(row, true);
if (range && !range.isMultiLine()) {
fold = this.getFoldAt(range.start.row, range.start.column, 1);
if (fold && range.isEqual(fold.range)) {
this.removeFold(fold);
return;
}
}
if (options.siblings) {
var data = this.getParentFoldRangeData(row);
if (data.range) {
var startRow = data.range.start.row + 1;
var endRow = data.range.end.row;
}
this.foldAll(startRow, endRow, options.all ? 10000 : 0);
} else if (options.children) {
endRow = range ? range.end.row : this.getLength();
this.foldAll(row + 1, range.end.row, options.all ? 10000 : 0);
} else if (range) {
if (options.all)
range.collapseChildren = 10000;
this.addFold("...", range);
}
return range;
};
this.toggleFoldWidget = function(toggleParent) {
var row = this.selection.getCursor().row;
row = this.getRowFoldStart(row);
var range = this.$toggleFoldWidget(row, {});
if (range)
return;
var data = this.getParentFoldRangeData(row, true);
range = data.range || data.firstRange;
if (range) {
row = range.start.row;
var fold = this.getFoldAt(row, this.getLine(row).length, 1);
if (fold) {
this.removeFold(fold);
} else {
this.addFold("...", range);
}
}
};
this.updateFoldWidgets = function(e) {
var delta = e.data;
var range = delta.range;
var firstRow = range.start.row;
var len = range.end.row - firstRow;
if (len === 0) {
this.foldWidgets[firstRow] = null;
} else if (delta.action == "removeText" || delta.action == "removeLines") {
this.foldWidgets.splice(firstRow, len + 1, null);
} else {
var args = Array(len + 1);
args.unshift(firstRow, 1);
this.foldWidgets.splice.apply(this.foldWidgets, args);
}
};
}
exports.Folding = Folding;
});
define("ace/edit_session/bracket_match",["require","exports","module","ace/token_iterator","ace/range"], function(require, exports, module) {
"use strict";
var TokenIterator = require("../token_iterator").TokenIterator;
var Range = require("../range").Range;
function BracketMatch() {
this.findMatchingBracket = function(position, chr) {
if (position.column == 0) return null;
var charBeforeCursor = chr || this.getLine(position.row).charAt(position.column-1);
if (charBeforeCursor == "") return null;
var match = charBeforeCursor.match(/([\(\[\{])|([\)\]\}])/);
if (!match)
return null;
if (match[1])
return this.$findClosingBracket(match[1], position);
else
return this.$findOpeningBracket(match[2], position);
};
this.getBracketRange = function(pos) {
var line = this.getLine(pos.row);
var before = true, range;
var chr = line.charAt(pos.column-1);
var match = chr && chr.match(/([\(\[\{])|([\)\]\}])/);
if (!match) {
chr = line.charAt(pos.column);
pos = {row: pos.row, column: pos.column + 1};
match = chr && chr.match(/([\(\[\{])|([\)\]\}])/);
before = false;
}
if (!match)
return null;
if (match[1]) {
var bracketPos = this.$findClosingBracket(match[1], pos);
if (!bracketPos)
return null;
range = Range.fromPoints(pos, bracketPos);
if (!before) {
range.end.column++;
range.start.column--;
}
range.cursor = range.end;
} else {
var bracketPos = this.$findOpeningBracket(match[2], pos);
if (!bracketPos)
return null;
range = Range.fromPoints(bracketPos, pos);
if (!before) {
range.start.column++;
range.end.column--;
}
range.cursor = range.start;
}
return range;
};
this.$brackets = {
")": "(",
"(": ")",
"]": "[",
"[": "]",
"{": "}",
"}": "{"
};
this.$findOpeningBracket = function(bracket, position, typeRe) {
var openBracket = this.$brackets[bracket];
var depth = 1;
var iterator = new TokenIterator(this, position.row, position.column);
var token = iterator.getCurrentToken();
if (!token)
token = iterator.stepForward();
if (!token)
return;
if (!typeRe){
typeRe = new RegExp(
"(\\.?" +
token.type.replace(".", "\\.").replace("rparen", ".paren")
.replace(/\b(?:end|start|begin)\b/, "")
+ ")+"
);
}
var valueIndex = position.column - iterator.getCurrentTokenColumn() - 2;
var value = token.value;
while (true) {
while (valueIndex >= 0) {
var chr = value.charAt(valueIndex);
if (chr == openBracket) {
depth -= 1;
if (depth == 0) {
return {row: iterator.getCurrentTokenRow(),
column: valueIndex + iterator.getCurrentTokenColumn()};
}
}
else if (chr == bracket) {
depth += 1;
}
valueIndex -= 1;
}
do {
token = iterator.stepBackward();
} while (token && !typeRe.test(token.type));
if (token == null)
break;
value = token.value;
valueIndex = value.length - 1;
}
return null;
};
this.$findClosingBracket = function(bracket, position, typeRe) {
var closingBracket = this.$brackets[bracket];
var depth = 1;
var iterator = new TokenIterator(this, position.row, position.column);
var token = iterator.getCurrentToken();
if (!token)
token = iterator.stepForward();
if (!token)
return;
if (!typeRe){
typeRe = new RegExp(
"(\\.?" +
token.type.replace(".", "\\.").replace("lparen", ".paren")
.replace(/\b(?:end|start|begin)\b/, "")
+ ")+"
);
}
var valueIndex = position.column - iterator.getCurrentTokenColumn();
while (true) {
var value = token.value;
var valueLength = value.length;
while (valueIndex < valueLength) {
var chr = value.charAt(valueIndex);
if (chr == closingBracket) {
depth -= 1;
if (depth == 0) {
return {row: iterator.getCurrentTokenRow(),
column: valueIndex + iterator.getCurrentTokenColumn()};
}
}
else if (chr == bracket) {
depth += 1;
}
valueIndex += 1;
}
do {
token = iterator.stepForward();
} while (token && !typeRe.test(token.type));
if (token == null)
break;
valueIndex = 0;
}
return null;
};
}
exports.BracketMatch = BracketMatch;
});
define("ace/edit_session",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/config","ace/lib/event_emitter","ace/selection","ace/mode/text","ace/range","ace/document","ace/background_tokenizer","ace/search_highlight","ace/edit_session/folding","ace/edit_session/bracket_match"], function(require, exports, module) {
"use strict";
var oop = require("./lib/oop");
var lang = require("./lib/lang");
var config = require("./config");
var EventEmitter = require("./lib/event_emitter").EventEmitter;
var Selection = require("./selection").Selection;
var TextMode = require("./mode/text").Mode;
var Range = require("./range").Range;
var Document = require("./document").Document;
var BackgroundTokenizer = require("./background_tokenizer").BackgroundTokenizer;
var SearchHighlight = require("./search_highlight").SearchHighlight;
var EditSession = function(text, mode) {
this.$breakpoints = [];
this.$decorations = [];
this.$frontMarkers = {};
this.$backMarkers = {};
this.$markerId = 1;
this.$undoSelect = true;
this.$foldData = [];
this.$foldData.toString = function() {
return this.join("\n");
}
this.on("changeFold", this.onChangeFold.bind(this));
this.$onChange = this.onChange.bind(this);
if (typeof text != "object" || !text.getLine)
text = new Document(text);
this.setDocument(text);
this.selection = new Selection(this);
config.resetOptions(this);
this.setMode(mode);
config._signal("session", this);
};
(function() {
oop.implement(this, EventEmitter);
this.setDocument = function(doc) {
if (this.doc)
this.doc.removeListener("change", this.$onChange);
this.doc = doc;
doc.on("change", this.$onChange);
if (this.bgTokenizer)
this.bgTokenizer.setDocument(this.getDocument());
this.resetCaches();
};
this.getDocument = function() {
return this.doc;
};
this.$resetRowCache = function(docRow) {
if (!docRow) {
this.$docRowCache = [];
this.$screenRowCache = [];
return;
}
var l = this.$docRowCache.length;
var i = this.$getRowCacheIndex(this.$docRowCache, docRow) + 1;
if (l > i) {
this.$docRowCache.splice(i, l);
this.$screenRowCache.splice(i, l);
}
};
this.$getRowCacheIndex = function(cacheArray, val) {
var low = 0;
var hi = cacheArray.length - 1;
while (low <= hi) {
var mid = (low + hi) >> 1;
var c = cacheArray[mid];
if (val > c)
low = mid + 1;
else if (val < c)
hi = mid - 1;
else
return mid;
}
return low -1;
};
this.resetCaches = function() {
this.$modified = true;
this.$wrapData = [];
this.$rowLengthCache = [];
this.$resetRowCache(0);
if (this.bgTokenizer)
this.bgTokenizer.start(0);
};
this.onChangeFold = function(e) {
var fold = e.data;
this.$resetRowCache(fold.start.row);
};
this.onChange = function(e) {
var delta = e.data;
this.$modified = true;
this.$resetRowCache(delta.range.start.row);
var removedFolds = this.$updateInternalDataOnChange(e);
if (!this.$fromUndo && this.$undoManager && !delta.ignore) {
this.$deltasDoc.push(delta);
if (removedFolds && removedFolds.length != 0) {
this.$deltasFold.push({
action: "removeFolds",
folds: removedFolds
});
}
this.$informUndoManager.schedule();
}
this.bgTokenizer && this.bgTokenizer.$updateOnChange(delta);
this._signal("change", e);
};
this.setValue = function(text) {
this.doc.setValue(text);
this.selection.moveTo(0, 0);
this.$resetRowCache(0);
this.$deltas = [];
this.$deltasDoc = [];
this.$deltasFold = [];
this.setUndoManager(this.$undoManager);
this.getUndoManager().reset();
};
this.getValue =
this.toString = function() {
return this.doc.getValue();
};
this.getSelection = function() {
return this.selection;
};
this.getState = function(row) {
return this.bgTokenizer.getState(row);
};
this.getTokens = function(row) {
return this.bgTokenizer.getTokens(row);
};
this.getTokenAt = function(row, column) {
var tokens = this.bgTokenizer.getTokens(row);
var token, c = 0;
if (column == null) {
i = tokens.length - 1;
c = this.getLine(row).length;
} else {
for (var i = 0; i < tokens.length; i++) {
c += tokens[i].value.length;
if (c >= column)
break;
}
}
token = tokens[i];
if (!token)
return null;
token.index = i;
token.start = c - token.value.length;
return token;
};
this.setUndoManager = function(undoManager) {
this.$undoManager = undoManager;
this.$deltas = [];
this.$deltasDoc = [];
this.$deltasFold = [];
if (this.$informUndoManager)
this.$informUndoManager.cancel();
if (undoManager) {
var self = this;
this.$syncInformUndoManager = function() {
self.$informUndoManager.cancel();
if (self.$deltasFold.length) {
self.$deltas.push({
group: "fold",
deltas: self.$deltasFold
});
self.$deltasFold = [];
}
if (self.$deltasDoc.length) {
self.$deltas.push({
group: "doc",
deltas: self.$deltasDoc
});
self.$deltasDoc = [];
}
if (self.$deltas.length > 0) {
undoManager.execute({
action: "aceupdate",
args: [self.$deltas, self],
merge: self.mergeUndoDeltas
});
}
self.mergeUndoDeltas = false;
self.$deltas = [];
};
this.$informUndoManager = lang.delayedCall(this.$syncInformUndoManager);
}
};
this.markUndoGroup = function() {
if (this.$syncInformUndoManager)
this.$syncInformUndoManager();
};
this.$defaultUndoManager = {
undo: function() {},
redo: function() {},
reset: function() {}
};
this.getUndoManager = function() {
return this.$undoManager || this.$defaultUndoManager;
};
this.getTabString = function() {
if (this.getUseSoftTabs()) {
return lang.stringRepeat(" ", this.getTabSize());
} else {
return "\t";
}
};
this.setUseSoftTabs = function(val) {
this.setOption("useSoftTabs", val);
};
this.getUseSoftTabs = function() {
return this.$useSoftTabs && !this.$mode.$indentWithTabs;
};
this.setTabSize = function(tabSize) {
this.setOption("tabSize", tabSize);
};
this.getTabSize = function() {
return this.$tabSize;
};
this.isTabStop = function(position) {
return this.$useSoftTabs && (position.column % this.$tabSize === 0);
};
this.$overwrite = false;
this.setOverwrite = function(overwrite) {
this.setOption("overwrite", overwrite);
};
this.getOverwrite = function() {
return this.$overwrite;
};
this.toggleOverwrite = function() {
this.setOverwrite(!this.$overwrite);
};
this.addGutterDecoration = function(row, className) {
if (!this.$decorations[row])
this.$decorations[row] = "";
this.$decorations[row] += " " + className;
this._signal("changeBreakpoint", {});
};
this.removeGutterDecoration = function(row, className) {
this.$decorations[row] = (this.$decorations[row] || "").replace(" " + className, "");
this._signal("changeBreakpoint", {});
};
this.getBreakpoints = function() {
return this.$breakpoints;
};
this.setBreakpoints = function(rows) {
this.$breakpoints = [];
for (var i=0; i 0)
inToken = !!line.charAt(column - 1).match(this.tokenRe);
if (!inToken)
inToken = !!line.charAt(column).match(this.tokenRe);
if (inToken)
var re = this.tokenRe;
else if (/^\s+$/.test(line.slice(column-1, column+1)))
var re = /\s/;
else
var re = this.nonTokenRe;
var start = column;
if (start > 0) {
do {
start--;
}
while (start >= 0 && line.charAt(start).match(re));
start++;
}
var end = column;
while (end < line.length && line.charAt(end).match(re)) {
end++;
}
return new Range(row, start, row, end);
};
this.getAWordRange = function(row, column) {
var wordRange = this.getWordRange(row, column);
var line = this.getLine(wordRange.end.row);
while (line.charAt(wordRange.end.column).match(/[ \t]/)) {
wordRange.end.column += 1;
}
return wordRange;
};
this.setNewLineMode = function(newLineMode) {
this.doc.setNewLineMode(newLineMode);
};
this.getNewLineMode = function() {
return this.doc.getNewLineMode();
};
this.setUseWorker = function(useWorker) { this.setOption("useWorker", useWorker); };
this.getUseWorker = function() { return this.$useWorker; };
this.onReloadTokenizer = function(e) {
var rows = e.data;
this.bgTokenizer.start(rows.first);
this._signal("tokenizerUpdate", e);
};
this.$modes = {};
this.$mode = null;
this.$modeId = null;
this.setMode = function(mode, cb) {
if (mode && typeof mode === "object") {
if (mode.getTokenizer)
return this.$onChangeMode(mode);
var options = mode;
var path = options.path;
} else {
path = mode || "ace/mode/text";
}
if (!this.$modes["ace/mode/text"])
this.$modes["ace/mode/text"] = new TextMode();
if (this.$modes[path] && !options) {
this.$onChangeMode(this.$modes[path]);
cb && cb();
return;
}
this.$modeId = path;
config.loadModule(["mode", path], function(m) {
if (this.$modeId !== path)
return cb && cb();
if (this.$modes[path] && !options)
return this.$onChangeMode(this.$modes[path]);
if (m && m.Mode) {
m = new m.Mode(options);
if (!options) {
this.$modes[path] = m;
m.$id = path;
}
this.$onChangeMode(m);
cb && cb();
}
}.bind(this));
if (!this.$mode)
this.$onChangeMode(this.$modes["ace/mode/text"], true);
};
this.$onChangeMode = function(mode, $isPlaceholder) {
if (!$isPlaceholder)
this.$modeId = mode.$id;
if (this.$mode === mode)
return;
this.$mode = mode;
this.$stopWorker();
if (this.$useWorker)
this.$startWorker();
var tokenizer = mode.getTokenizer();
if(tokenizer.addEventListener !== undefined) {
var onReloadTokenizer = this.onReloadTokenizer.bind(this);
tokenizer.addEventListener("update", onReloadTokenizer);
}
if (!this.bgTokenizer) {
this.bgTokenizer = new BackgroundTokenizer(tokenizer);
var _self = this;
this.bgTokenizer.addEventListener("update", function(e) {
_self._signal("tokenizerUpdate", e);
});
} else {
this.bgTokenizer.setTokenizer(tokenizer);
}
this.bgTokenizer.setDocument(this.getDocument());
this.tokenRe = mode.tokenRe;
this.nonTokenRe = mode.nonTokenRe;
if (!$isPlaceholder) {
if (mode.attachToSession)
mode.attachToSession(this);
this.$options.wrapMethod.set.call(this, this.$wrapMethod);
this.$setFolding(mode.foldingRules);
this.bgTokenizer.start(0);
this._emit("changeMode");
}
};
this.$stopWorker = function() {
if (this.$worker) {
this.$worker.terminate();
this.$worker = null;
}
};
this.$startWorker = function() {
try {
this.$worker = this.$mode.createWorker(this);
} catch (e) {
if (typeof console == "object") {
console.log("Could not load worker");
console.log(e);
}
this.$worker = null;
}
};
this.getMode = function() {
return this.$mode;
};
this.$scrollTop = 0;
this.setScrollTop = function(scrollTop) {
if (this.$scrollTop === scrollTop || isNaN(scrollTop))
return;
this.$scrollTop = scrollTop;
this._signal("changeScrollTop", scrollTop);
};
this.getScrollTop = function() {
return this.$scrollTop;
};
this.$scrollLeft = 0;
this.setScrollLeft = function(scrollLeft) {
if (this.$scrollLeft === scrollLeft || isNaN(scrollLeft))
return;
this.$scrollLeft = scrollLeft;
this._signal("changeScrollLeft", scrollLeft);
};
this.getScrollLeft = function() {
return this.$scrollLeft;
};
this.getScreenWidth = function() {
this.$computeWidth();
if (this.lineWidgets)
return Math.max(this.getLineWidgetMaxWidth(), this.screenWidth);
return this.screenWidth;
};
this.getLineWidgetMaxWidth = function() {
if (this.lineWidgetsWidth != null) return this.lineWidgetsWidth;
var width = 0;
this.lineWidgets.forEach(function(w) {
if (w && w.screenWidth > width)
width = w.screenWidth;
});
return this.lineWidgetWidth = width;
};
this.$computeWidth = function(force) {
if (this.$modified || force) {
this.$modified = false;
if (this.$useWrapMode)
return this.screenWidth = this.$wrapLimit;
var lines = this.doc.getAllLines();
var cache = this.$rowLengthCache;
var longestScreenLine = 0;
var foldIndex = 0;
var foldLine = this.$foldData[foldIndex];
var foldStart = foldLine ? foldLine.start.row : Infinity;
var len = lines.length;
for (var i = 0; i < len; i++) {
if (i > foldStart) {
i = foldLine.end.row + 1;
if (i >= len)
break;
foldLine = this.$foldData[foldIndex++];
foldStart = foldLine ? foldLine.start.row : Infinity;
}
if (cache[i] == null)
cache[i] = this.$getStringScreenWidth(lines[i])[0];
if (cache[i] > longestScreenLine)
longestScreenLine = cache[i];
}
this.screenWidth = longestScreenLine;
}
};
this.getLine = function(row) {
return this.doc.getLine(row);
};
this.getLines = function(firstRow, lastRow) {
return this.doc.getLines(firstRow, lastRow);
};
this.getLength = function() {
return this.doc.getLength();
};
this.getTextRange = function(range) {
return this.doc.getTextRange(range || this.selection.getRange());
};
this.insert = function(position, text) {
return this.doc.insert(position, text);
};
this.remove = function(range) {
return this.doc.remove(range);
};
this.undoChanges = function(deltas, dontSelect) {
if (!deltas.length)
return;
this.$fromUndo = true;
var lastUndoRange = null;
for (var i = deltas.length - 1; i != -1; i--) {
var delta = deltas[i];
if (delta.group == "doc") {
this.doc.revertDeltas(delta.deltas);
lastUndoRange =
this.$getUndoSelection(delta.deltas, true, lastUndoRange);
} else {
delta.deltas.forEach(function(foldDelta) {
this.addFolds(foldDelta.folds);
}, this);
}
}
this.$fromUndo = false;
lastUndoRange &&
this.$undoSelect &&
!dontSelect &&
this.selection.setSelectionRange(lastUndoRange);
return lastUndoRange;
};
this.redoChanges = function(deltas, dontSelect) {
if (!deltas.length)
return;
this.$fromUndo = true;
var lastUndoRange = null;
for (var i = 0; i < deltas.length; i++) {
var delta = deltas[i];
if (delta.group == "doc") {
this.doc.applyDeltas(delta.deltas);
lastUndoRange =
this.$getUndoSelection(delta.deltas, false, lastUndoRange);
}
}
this.$fromUndo = false;
lastUndoRange &&
this.$undoSelect &&
!dontSelect &&
this.selection.setSelectionRange(lastUndoRange);
return lastUndoRange;
};
this.setUndoSelect = function(enable) {
this.$undoSelect = enable;
};
this.$getUndoSelection = function(deltas, isUndo, lastUndoRange) {
function isInsert(delta) {
var insert =
delta.action === "insertText" || delta.action === "insertLines";
return isUndo ? !insert : insert;
}
var delta = deltas[0];
var range, point;
var lastDeltaIsInsert = false;
if (isInsert(delta)) {
range = Range.fromPoints(delta.range.start, delta.range.end);
lastDeltaIsInsert = true;
} else {
range = Range.fromPoints(delta.range.start, delta.range.start);
lastDeltaIsInsert = false;
}
for (var i = 1; i < deltas.length; i++) {
delta = deltas[i];
if (isInsert(delta)) {
point = delta.range.start;
if (range.compare(point.row, point.column) == -1) {
range.setStart(delta.range.start);
}
point = delta.range.end;
if (range.compare(point.row, point.column) == 1) {
range.setEnd(delta.range.end);
}
lastDeltaIsInsert = true;
} else {
point = delta.range.start;
if (range.compare(point.row, point.column) == -1) {
range =
Range.fromPoints(delta.range.start, delta.range.start);
}
lastDeltaIsInsert = false;
}
}
if (lastUndoRange != null) {
if (Range.comparePoints(lastUndoRange.start, range.start) === 0) {
lastUndoRange.start.column += range.end.column - range.start.column;
lastUndoRange.end.column += range.end.column - range.start.column;
}
var cmp = lastUndoRange.compareRange(range);
if (cmp == 1) {
range.setStart(lastUndoRange.start);
} else if (cmp == -1) {
range.setEnd(lastUndoRange.end);
}
}
return range;
};
this.replace = function(range, text) {
return this.doc.replace(range, text);
};
this.moveText = function(fromRange, toPosition, copy) {
var text = this.getTextRange(fromRange);
var folds = this.getFoldsInRange(fromRange);
var toRange = Range.fromPoints(toPosition, toPosition);
if (!copy) {
this.remove(fromRange);
var rowDiff = fromRange.start.row - fromRange.end.row;
var collDiff = rowDiff ? -fromRange.end.column : fromRange.start.column - fromRange.end.column;
if (collDiff) {
if (toRange.start.row == fromRange.end.row && toRange.start.column > fromRange.end.column)
toRange.start.column += collDiff;
if (toRange.end.row == fromRange.end.row && toRange.end.column > fromRange.end.column)
toRange.end.column += collDiff;
}
if (rowDiff && toRange.start.row >= fromRange.end.row) {
toRange.start.row += rowDiff;
toRange.end.row += rowDiff;
}
}
toRange.end = this.insert(toRange.start, text);
if (folds.length) {
var oldStart = fromRange.start;
var newStart = toRange.start;
var rowDiff = newStart.row - oldStart.row;
var collDiff = newStart.column - oldStart.column;
this.addFolds(folds.map(function(x) {
x = x.clone();
if (x.start.row == oldStart.row)
x.start.column += collDiff;
if (x.end.row == oldStart.row)
x.end.column += collDiff;
x.start.row += rowDiff;
x.end.row += rowDiff;
return x;
}));
}
return toRange;
};
this.indentRows = function(startRow, endRow, indentString) {
indentString = indentString.replace(/\t/g, this.getTabString());
for (var row=startRow; row<=endRow; row++)
this.insert({row: row, column:0}, indentString);
};
this.outdentRows = function (range) {
var rowRange = range.collapseRows();
var deleteRange = new Range(0, 0, 0, 0);
var size = this.getTabSize();
for (var i = rowRange.start.row; i <= rowRange.end.row; ++i) {
var line = this.getLine(i);
deleteRange.start.row = i;
deleteRange.end.row = i;
for (var j = 0; j < size; ++j)
if (line.charAt(j) != ' ')
break;
if (j < size && line.charAt(j) == '\t') {
deleteRange.start.column = j;
deleteRange.end.column = j + 1;
} else {
deleteRange.start.column = 0;
deleteRange.end.column = j;
}
this.remove(deleteRange);
}
};
this.$moveLines = function(firstRow, lastRow, dir) {
firstRow = this.getRowFoldStart(firstRow);
lastRow = this.getRowFoldEnd(lastRow);
if (dir < 0) {
var row = this.getRowFoldStart(firstRow + dir);
if (row < 0) return 0;
var diff = row-firstRow;
} else if (dir > 0) {
var row = this.getRowFoldEnd(lastRow + dir);
if (row > this.doc.getLength()-1) return 0;
var diff = row-lastRow;
} else {
firstRow = this.$clipRowToDocument(firstRow);
lastRow = this.$clipRowToDocument(lastRow);
var diff = lastRow - firstRow + 1;
}
var range = new Range(firstRow, 0, lastRow, Number.MAX_VALUE);
var folds = this.getFoldsInRange(range).map(function(x){
x = x.clone();
x.start.row += diff;
x.end.row += diff;
return x;
});
var lines = dir == 0
? this.doc.getLines(firstRow, lastRow)
: this.doc.removeLines(firstRow, lastRow);
this.doc.insertLines(firstRow+diff, lines);
folds.length && this.addFolds(folds);
return diff;
};
this.moveLinesUp = function(firstRow, lastRow) {
return this.$moveLines(firstRow, lastRow, -1);
};
this.moveLinesDown = function(firstRow, lastRow) {
return this.$moveLines(firstRow, lastRow, 1);
};
this.duplicateLines = function(firstRow, lastRow) {
return this.$moveLines(firstRow, lastRow, 0);
};
this.$clipRowToDocument = function(row) {
return Math.max(0, Math.min(row, this.doc.getLength()-1));
};
this.$clipColumnToRow = function(row, column) {
if (column < 0)
return 0;
return Math.min(this.doc.getLine(row).length, column);
};
this.$clipPositionToDocument = function(row, column) {
column = Math.max(0, column);
if (row < 0) {
row = 0;
column = 0;
} else {
var len = this.doc.getLength();
if (row >= len) {
row = len - 1;
column = this.doc.getLine(len-1).length;
} else {
column = Math.min(this.doc.getLine(row).length, column);
}
}
return {
row: row,
column: column
};
};
this.$clipRangeToDocument = function(range) {
if (range.start.row < 0) {
range.start.row = 0;
range.start.column = 0;
} else {
range.start.column = this.$clipColumnToRow(
range.start.row,
range.start.column
);
}
var len = this.doc.getLength() - 1;
if (range.end.row > len) {
range.end.row = len;
range.end.column = this.doc.getLine(len).length;
} else {
range.end.column = this.$clipColumnToRow(
range.end.row,
range.end.column
);
}
return range;
};
this.$wrapLimit = 80;
this.$useWrapMode = false;
this.$wrapLimitRange = {
min : null,
max : null
};
this.setUseWrapMode = function(useWrapMode) {
if (useWrapMode != this.$useWrapMode) {
this.$useWrapMode = useWrapMode;
this.$modified = true;
this.$resetRowCache(0);
if (useWrapMode) {
var len = this.getLength();
this.$wrapData = Array(len);
this.$updateWrapData(0, len - 1);
}
this._signal("changeWrapMode");
}
};
this.getUseWrapMode = function() {
return this.$useWrapMode;
};
this.setWrapLimitRange = function(min, max) {
if (this.$wrapLimitRange.min !== min || this.$wrapLimitRange.max !== max) {
this.$wrapLimitRange = {
min: min,
max: max
};
this.$modified = true;
this._signal("changeWrapMode");
}
};
this.adjustWrapLimit = function(desiredLimit, $printMargin) {
var limits = this.$wrapLimitRange;
if (limits.max < 0)
limits = {min: $printMargin, max: $printMargin};
var wrapLimit = this.$constrainWrapLimit(desiredLimit, limits.min, limits.max);
if (wrapLimit != this.$wrapLimit && wrapLimit > 1) {
this.$wrapLimit = wrapLimit;
this.$modified = true;
if (this.$useWrapMode) {
this.$updateWrapData(0, this.getLength() - 1);
this.$resetRowCache(0);
this._signal("changeWrapLimit");
}
return true;
}
return false;
};
this.$constrainWrapLimit = function(wrapLimit, min, max) {
if (min)
wrapLimit = Math.max(min, wrapLimit);
if (max)
wrapLimit = Math.min(max, wrapLimit);
return wrapLimit;
};
this.getWrapLimit = function() {
return this.$wrapLimit;
};
this.setWrapLimit = function (limit) {
this.setWrapLimitRange(limit, limit);
};
this.getWrapLimitRange = function() {
return {
min : this.$wrapLimitRange.min,
max : this.$wrapLimitRange.max
};
};
this.$updateInternalDataOnChange = function(e) {
var useWrapMode = this.$useWrapMode;
var len;
var action = e.data.action;
var firstRow = e.data.range.start.row;
var lastRow = e.data.range.end.row;
var start = e.data.range.start;
var end = e.data.range.end;
var removedFolds = null;
if (action.indexOf("Lines") != -1) {
if (action == "insertLines") {
lastRow = firstRow + (e.data.lines.length);
} else {
lastRow = firstRow;
}
len = e.data.lines ? e.data.lines.length : lastRow - firstRow;
} else {
len = lastRow - firstRow;
}
this.$updating = true;
if (len != 0) {
if (action.indexOf("remove") != -1) {
this[useWrapMode ? "$wrapData" : "$rowLengthCache"].splice(firstRow, len);
var foldLines = this.$foldData;
removedFolds = this.getFoldsInRange(e.data.range);
this.removeFolds(removedFolds);
var foldLine = this.getFoldLine(end.row);
var idx = 0;
if (foldLine) {
foldLine.addRemoveChars(end.row, end.column, start.column - end.column);
foldLine.shiftRow(-len);
var foldLineBefore = this.getFoldLine(firstRow);
if (foldLineBefore && foldLineBefore !== foldLine) {
foldLineBefore.merge(foldLine);
foldLine = foldLineBefore;
}
idx = foldLines.indexOf(foldLine) + 1;
}
for (idx; idx < foldLines.length; idx++) {
var foldLine = foldLines[idx];
if (foldLine.start.row >= end.row) {
foldLine.shiftRow(-len);
}
}
lastRow = firstRow;
} else {
var args = Array(len);
args.unshift(firstRow, 0);
var arr = useWrapMode ? this.$wrapData : this.$rowLengthCache
arr.splice.apply(arr, args);
var foldLines = this.$foldData;
var foldLine = this.getFoldLine(firstRow);
var idx = 0;
if (foldLine) {
var cmp = foldLine.range.compareInside(start.row, start.column);
if (cmp == 0) {
foldLine = foldLine.split(start.row, start.column);
if (foldLine) {
foldLine.shiftRow(len);
foldLine.addRemoveChars(lastRow, 0, end.column - start.column);
}
} else
if (cmp == -1) {
foldLine.addRemoveChars(firstRow, 0, end.column - start.column);
foldLine.shiftRow(len);
}
idx = foldLines.indexOf(foldLine) + 1;
}
for (idx; idx < foldLines.length; idx++) {
var foldLine = foldLines[idx];
if (foldLine.start.row >= firstRow) {
foldLine.shiftRow(len);
}
}
}
} else {
len = Math.abs(e.data.range.start.column - e.data.range.end.column);
if (action.indexOf("remove") != -1) {
removedFolds = this.getFoldsInRange(e.data.range);
this.removeFolds(removedFolds);
len = -len;
}
var foldLine = this.getFoldLine(firstRow);
if (foldLine) {
foldLine.addRemoveChars(firstRow, start.column, len);
}
}
if (useWrapMode && this.$wrapData.length != this.doc.getLength()) {
console.error("doc.getLength() and $wrapData.length have to be the same!");
}
this.$updating = false;
if (useWrapMode)
this.$updateWrapData(firstRow, lastRow);
else
this.$updateRowLengthCache(firstRow, lastRow);
return removedFolds;
};
this.$updateRowLengthCache = function(firstRow, lastRow, b) {
this.$rowLengthCache[firstRow] = null;
this.$rowLengthCache[lastRow] = null;
};
this.$updateWrapData = function(firstRow, lastRow) {
var lines = this.doc.getAllLines();
var tabSize = this.getTabSize();
var wrapData = this.$wrapData;
var wrapLimit = this.$wrapLimit;
var tokens;
var foldLine;
var row = firstRow;
lastRow = Math.min(lastRow, lines.length - 1);
while (row <= lastRow) {
foldLine = this.getFoldLine(row, foldLine);
if (!foldLine) {
tokens = this.$getDisplayTokens(lines[row]);
wrapData[row] = this.$computeWrapSplits(tokens, wrapLimit, tabSize);
row ++;
} else {
tokens = [];
foldLine.walk(function(placeholder, row, column, lastColumn) {
var walkTokens;
if (placeholder != null) {
walkTokens = this.$getDisplayTokens(
placeholder, tokens.length);
walkTokens[0] = PLACEHOLDER_START;
for (var i = 1; i < walkTokens.length; i++) {
walkTokens[i] = PLACEHOLDER_BODY;
}
} else {
walkTokens = this.$getDisplayTokens(
lines[row].substring(lastColumn, column),
tokens.length);
}
tokens = tokens.concat(walkTokens);
}.bind(this),
foldLine.end.row,
lines[foldLine.end.row].length + 1
);
wrapData[foldLine.start.row] = this.$computeWrapSplits(tokens, wrapLimit, tabSize);
row = foldLine.end.row + 1;
}
}
};
var CHAR = 1,
CHAR_EXT = 2,
PLACEHOLDER_START = 3,
PLACEHOLDER_BODY = 4,
PUNCTUATION = 9,
SPACE = 10,
TAB = 11,
TAB_SPACE = 12;
this.$computeWrapSplits = function(tokens, wrapLimit) {
if (tokens.length == 0) {
return [];
}
var splits = [];
var displayLength = tokens.length;
var lastSplit = 0, lastDocSplit = 0;
var isCode = this.$wrapAsCode;
function addSplit(screenPos) {
var displayed = tokens.slice(lastSplit, screenPos);
var len = displayed.length;
displayed.join("").
replace(/12/g, function() {
len -= 1;
}).
replace(/2/g, function() {
len -= 1;
});
lastDocSplit += len;
splits.push(lastDocSplit);
lastSplit = screenPos;
}
while (displayLength - lastSplit > wrapLimit) {
var split = lastSplit + wrapLimit;
if (tokens[split - 1] >= SPACE && tokens[split] >= SPACE) {
addSplit(split);
continue;
}
if (tokens[split] == PLACEHOLDER_START || tokens[split] == PLACEHOLDER_BODY) {
for (split; split != lastSplit - 1; split--) {
if (tokens[split] == PLACEHOLDER_START) {
break;
}
}
if (split > lastSplit) {
addSplit(split);
continue;
}
split = lastSplit + wrapLimit;
for (split; split < tokens.length; split++) {
if (tokens[split] != PLACEHOLDER_BODY) {
break;
}
}
if (split == tokens.length) {
break; // Breaks the while-loop.
}
addSplit(split);
continue;
}
var minSplit = Math.max(split - (isCode ? 10 : wrapLimit-(wrapLimit>>2)), lastSplit - 1);
while (split > minSplit && tokens[split] < PLACEHOLDER_START) {
split --;
}
if (isCode) {
while (split > minSplit && tokens[split] < PLACEHOLDER_START) {
split --;
}
while (split > minSplit && tokens[split] == PUNCTUATION) {
split --;
}
} else {
while (split > minSplit && tokens[split] < SPACE) {
split --;
}
}
if (split > minSplit) {
addSplit(++split);
continue;
}
split = lastSplit + wrapLimit;
if (tokens[split] == CHAR_EXT)
split--;
addSplit(split);
}
return splits;
};
this.$getDisplayTokens = function(str, offset) {
var arr = [];
var tabSize;
offset = offset || 0;
for (var i = 0; i < str.length; i++) {
var c = str.charCodeAt(i);
if (c == 9) {
tabSize = this.getScreenTabSize(arr.length + offset);
arr.push(TAB);
for (var n = 1; n < tabSize; n++) {
arr.push(TAB_SPACE);
}
}
else if (c == 32) {
arr.push(SPACE);
} else if((c > 39 && c < 48) || (c > 57 && c < 64)) {
arr.push(PUNCTUATION);
}
else if (c >= 0x1100 && isFullWidth(c)) {
arr.push(CHAR, CHAR_EXT);
} else {
arr.push(CHAR);
}
}
return arr;
};
this.$getStringScreenWidth = function(str, maxScreenColumn, screenColumn) {
if (maxScreenColumn == 0)
return [0, 0];
if (maxScreenColumn == null)
maxScreenColumn = Infinity;
screenColumn = screenColumn || 0;
var c, column;
for (column = 0; column < str.length; column++) {
c = str.charCodeAt(column);
if (c == 9) {
screenColumn += this.getScreenTabSize(screenColumn);
}
else if (c >= 0x1100 && isFullWidth(c)) {
screenColumn += 2;
} else {
screenColumn += 1;
}
if (screenColumn > maxScreenColumn) {
break;
}
}
return [screenColumn, column];
};
this.lineWidgets = null;
this.getRowLength = function(row) {
if (this.lineWidgets)
var h = this.lineWidgets[row] && this.lineWidgets[row].rowCount || 0;
else
h = 0
if (!this.$useWrapMode || !this.$wrapData[row]) {
return 1 + h;
} else {
return this.$wrapData[row].length + 1 + h;
}
};
this.getRowLineCount = function(row) {
if (!this.$useWrapMode || !this.$wrapData[row]) {
return 1;
} else {
return this.$wrapData[row].length + 1;
}
};
this.getScreenLastRowColumn = function(screenRow) {
var pos = this.screenToDocumentPosition(screenRow, Number.MAX_VALUE);
return this.documentToScreenColumn(pos.row, pos.column);
};
this.getDocumentLastRowColumn = function(docRow, docColumn) {
var screenRow = this.documentToScreenRow(docRow, docColumn);
return this.getScreenLastRowColumn(screenRow);
};
this.getDocumentLastRowColumnPosition = function(docRow, docColumn) {
var screenRow = this.documentToScreenRow(docRow, docColumn);
return this.screenToDocumentPosition(screenRow, Number.MAX_VALUE / 10);
};
this.getRowSplitData = function(row) {
if (!this.$useWrapMode) {
return undefined;
} else {
return this.$wrapData[row];
}
};
this.getScreenTabSize = function(screenColumn) {
return this.$tabSize - screenColumn % this.$tabSize;
};
this.screenToDocumentRow = function(screenRow, screenColumn) {
return this.screenToDocumentPosition(screenRow, screenColumn).row;
};
this.screenToDocumentColumn = function(screenRow, screenColumn) {
return this.screenToDocumentPosition(screenRow, screenColumn).column;
};
this.screenToDocumentPosition = function(screenRow, screenColumn) {
if (screenRow < 0)
return {row: 0, column: 0};
var line;
var docRow = 0;
var docColumn = 0;
var column;
var row = 0;
var rowLength = 0;
var rowCache = this.$screenRowCache;
var i = this.$getRowCacheIndex(rowCache, screenRow);
var l = rowCache.length;
if (l && i >= 0) {
var row = rowCache[i];
var docRow = this.$docRowCache[i];
var doCache = screenRow > rowCache[l - 1];
} else {
var doCache = !l;
}
var maxRow = this.getLength() - 1;
var foldLine = this.getNextFoldLine(docRow);
var foldStart = foldLine ? foldLine.start.row : Infinity;
while (row <= screenRow) {
rowLength = this.getRowLength(docRow);
if (row + rowLength > screenRow || docRow >= maxRow) {
break;
} else {
row += rowLength;
docRow++;
if (docRow > foldStart) {
docRow = foldLine.end.row+1;
foldLine = this.getNextFoldLine(docRow, foldLine);
foldStart = foldLine ? foldLine.start.row : Infinity;
}
}
if (doCache) {
this.$docRowCache.push(docRow);
this.$screenRowCache.push(row);
}
}
if (foldLine && foldLine.start.row <= docRow) {
line = this.getFoldDisplayLine(foldLine);
docRow = foldLine.start.row;
} else if (row + rowLength <= screenRow || docRow > maxRow) {
return {
row: maxRow,
column: this.getLine(maxRow).length
};
} else {
line = this.getLine(docRow);
foldLine = null;
}
if (this.$useWrapMode) {
var splits = this.$wrapData[docRow];
if (splits) {
var splitIndex = Math.floor(screenRow - row);
column = splits[splitIndex];
if(splitIndex > 0 && splits.length) {
docColumn = splits[splitIndex - 1] || splits[splits.length - 1];
line = line.substring(docColumn);
}
}
}
docColumn += this.$getStringScreenWidth(line, screenColumn)[1];
if (this.$useWrapMode && docColumn >= column)
docColumn = column - 1;
if (foldLine)
return foldLine.idxToPosition(docColumn);
return {row: docRow, column: docColumn};
};
this.documentToScreenPosition = function(docRow, docColumn) {
if (typeof docColumn === "undefined")
var pos = this.$clipPositionToDocument(docRow.row, docRow.column);
else
pos = this.$clipPositionToDocument(docRow, docColumn);
docRow = pos.row;
docColumn = pos.column;
var screenRow = 0;
var foldStartRow = null;
var fold = null;
fold = this.getFoldAt(docRow, docColumn, 1);
if (fold) {
docRow = fold.start.row;
docColumn = fold.start.column;
}
var rowEnd, row = 0;
var rowCache = this.$docRowCache;
var i = this.$getRowCacheIndex(rowCache, docRow);
var l = rowCache.length;
if (l && i >= 0) {
var row = rowCache[i];
var screenRow = this.$screenRowCache[i];
var doCache = docRow > rowCache[l - 1];
} else {
var doCache = !l;
}
var foldLine = this.getNextFoldLine(row);
var foldStart = foldLine ?foldLine.start.row :Infinity;
while (row < docRow) {
if (row >= foldStart) {
rowEnd = foldLine.end.row + 1;
if (rowEnd > docRow)
break;
foldLine = this.getNextFoldLine(rowEnd, foldLine);
foldStart = foldLine ?foldLine.start.row :Infinity;
}
else {
rowEnd = row + 1;
}
screenRow += this.getRowLength(row);
row = rowEnd;
if (doCache) {
this.$docRowCache.push(row);
this.$screenRowCache.push(screenRow);
}
}
var textLine = "";
if (foldLine && row >= foldStart) {
textLine = this.getFoldDisplayLine(foldLine, docRow, docColumn);
foldStartRow = foldLine.start.row;
} else {
textLine = this.getLine(docRow).substring(0, docColumn);
foldStartRow = docRow;
}
if (this.$useWrapMode) {
var wrapRow = this.$wrapData[foldStartRow];
if (wrapRow) {
var screenRowOffset = 0;
while (textLine.length >= wrapRow[screenRowOffset]) {
screenRow ++;
screenRowOffset++;
}
textLine = textLine.substring(
wrapRow[screenRowOffset - 1] || 0, textLine.length
);
}
}
return {
row: screenRow,
column: this.$getStringScreenWidth(textLine)[0]
};
};
this.documentToScreenColumn = function(row, docColumn) {
return this.documentToScreenPosition(row, docColumn).column;
};
this.documentToScreenRow = function(docRow, docColumn) {
return this.documentToScreenPosition(docRow, docColumn).row;
};
this.getScreenLength = function() {
var screenRows = 0;
var fold = null;
if (!this.$useWrapMode) {
screenRows = this.getLength();
var foldData = this.$foldData;
for (var i = 0; i < foldData.length; i++) {
fold = foldData[i];
screenRows -= fold.end.row - fold.start.row;
}
} else {
var lastRow = this.$wrapData.length;
var row = 0, i = 0;
var fold = this.$foldData[i++];
var foldStart = fold ? fold.start.row :Infinity;
while (row < lastRow) {
var splits = this.$wrapData[row];
screenRows += splits ? splits.length + 1 : 1;
row ++;
if (row > foldStart) {
row = fold.end.row+1;
fold = this.$foldData[i++];
foldStart = fold ?fold.start.row :Infinity;
}
}
}
if (this.lineWidgets)
screenRows += this.$getWidgetScreenLength();
return screenRows;
};
this.$setFontMetrics = function(fm) {
};
this.destroy = function() {
if (this.bgTokenizer) {
this.bgTokenizer.setDocument(null);
this.bgTokenizer = null;
}
this.$stopWorker();
};
function isFullWidth(c) {
if (c < 0x1100)
return false;
return c >= 0x1100 && c <= 0x115F ||
c >= 0x11A3 && c <= 0x11A7 ||
c >= 0x11FA && c <= 0x11FF ||
c >= 0x2329 && c <= 0x232A ||
c >= 0x2E80 && c <= 0x2E99 ||
c >= 0x2E9B && c <= 0x2EF3 ||
c >= 0x2F00 && c <= 0x2FD5 ||
c >= 0x2FF0 && c <= 0x2FFB ||
c >= 0x3000 && c <= 0x303E ||
c >= 0x3041 && c <= 0x3096 ||
c >= 0x3099 && c <= 0x30FF ||
c >= 0x3105 && c <= 0x312D ||
c >= 0x3131 && c <= 0x318E ||
c >= 0x3190 && c <= 0x31BA ||
c >= 0x31C0 && c <= 0x31E3 ||
c >= 0x31F0 && c <= 0x321E ||
c >= 0x3220 && c <= 0x3247 ||
c >= 0x3250 && c <= 0x32FE ||
c >= 0x3300 && c <= 0x4DBF ||
c >= 0x4E00 && c <= 0xA48C ||
c >= 0xA490 && c <= 0xA4C6 ||
c >= 0xA960 && c <= 0xA97C ||
c >= 0xAC00 && c <= 0xD7A3 ||
c >= 0xD7B0 && c <= 0xD7C6 ||
c >= 0xD7CB && c <= 0xD7FB ||
c >= 0xF900 && c <= 0xFAFF ||
c >= 0xFE10 && c <= 0xFE19 ||
c >= 0xFE30 && c <= 0xFE52 ||
c >= 0xFE54 && c <= 0xFE66 ||
c >= 0xFE68 && c <= 0xFE6B ||
c >= 0xFF01 && c <= 0xFF60 ||
c >= 0xFFE0 && c <= 0xFFE6;
};
}).call(EditSession.prototype);
require("./edit_session/folding").Folding.call(EditSession.prototype);
require("./edit_session/bracket_match").BracketMatch.call(EditSession.prototype);
config.defineOptions(EditSession.prototype, "session", {
wrap: {
set: function(value) {
if (!value || value == "off")
value = false;
else if (value == "free")
value = true;
else if (value == "printMargin")
value = -1;
else if (typeof value == "string")
value = parseInt(value, 10) || false;
if (this.$wrap == value)
return;
if (!value) {
this.setUseWrapMode(false);
} else {
var col = typeof value == "number" ? value : null;
this.setWrapLimitRange(col, col);
this.setUseWrapMode(true);
}
this.$wrap = value;
},
get: function() {
if (this.getUseWrapMode()) {
if (this.$wrap == -1)
return "printMargin";
if (!this.getWrapLimitRange().min)
return "free";
return this.$wrap;
}
return "off";
},
handlesSet: true
},
wrapMethod: {
set: function(val) {
val = val == "auto"
? this.$mode.type != "text"
: val != "text";
if (val != this.$wrapAsCode) {
this.$wrapAsCode = val;
if (this.$useWrapMode) {
this.$modified = true;
this.$resetRowCache(0);
this.$updateWrapData(0, this.getLength() - 1);
}
}
},
initialValue: "auto"
},
firstLineNumber: {
set: function() {this._signal("changeBreakpoint");},
initialValue: 1
},
useWorker: {
set: function(useWorker) {
this.$useWorker = useWorker;
this.$stopWorker();
if (useWorker)
this.$startWorker();
},
initialValue: true
},
useSoftTabs: {initialValue: true},
tabSize: {
set: function(tabSize) {
if (isNaN(tabSize) || this.$tabSize === tabSize) return;
this.$modified = true;
this.$rowLengthCache = [];
this.$tabSize = tabSize;
this._signal("changeTabSize");
},
initialValue: 4,
handlesSet: true
},
overwrite: {
set: function(val) {this._signal("changeOverwrite");},
initialValue: false
},
newLineMode: {
set: function(val) {this.doc.setNewLineMode(val)},
get: function() {return this.doc.getNewLineMode()},
handlesSet: true
},
mode: {
set: function(val) { this.setMode(val) },
get: function() { return this.$modeId }
}
});
exports.EditSession = EditSession;
});
define("ace/search",["require","exports","module","ace/lib/lang","ace/lib/oop","ace/range"], function(require, exports, module) {
"use strict";
var lang = require("./lib/lang");
var oop = require("./lib/oop");
var Range = require("./range").Range;
var Search = function() {
this.$options = {};
};
(function() {
this.set = function(options) {
oop.mixin(this.$options, options);
return this;
};
this.getOptions = function() {
return lang.copyObject(this.$options);
};
this.setOptions = function(options) {
this.$options = options;
};
this.find = function(session) {
var iterator = this.$matchIterator(session, this.$options);
if (!iterator)
return false;
var firstRange = null;
iterator.forEach(function(range, row, offset) {
if (!range.start) {
var column = range.offset + (offset || 0);
firstRange = new Range(row, column, row, column+range.length);
} else
firstRange = range;
return true;
});
return firstRange;
};
this.findAll = function(session) {
var options = this.$options;
if (!options.needle)
return [];
this.$assembleRegExp(options);
var range = options.range;
var lines = range
? session.getLines(range.start.row, range.end.row)
: session.doc.getAllLines();
var ranges = [];
var re = options.re;
if (options.$isMultiLine) {
var len = re.length;
var maxRow = lines.length - len;
var prevRange;
outer: for (var row = re.offset || 0; row <= maxRow; row++) {
for (var j = 0; j < len; j++)
if (lines[row + j].search(re[j]) == -1)
continue outer;
var startLine = lines[row];
var line = lines[row + len - 1];
var startIndex = startLine.length - startLine.match(re[0])[0].length;
var endIndex = line.match(re[len - 1])[0].length;
if (prevRange && prevRange.end.row === row &&
prevRange.end.column > startIndex
) {
continue;
}
ranges.push(prevRange = new Range(
row, startIndex, row + len - 1, endIndex
));
if (len > 2)
row = row + len - 2;
}
} else {
for (var i = 0; i < lines.length; i++) {
var matches = lang.getMatchOffsets(lines[i], re);
for (var j = 0; j < matches.length; j++) {
var match = matches[j];
ranges.push(new Range(i, match.offset, i, match.offset + match.length));
}
}
}
if (range) {
var startColumn = range.start.column;
var endColumn = range.start.column;
var i = 0, j = ranges.length - 1;
while (i < j && ranges[i].start.column < startColumn && ranges[i].start.row == range.start.row)
i++;
while (i < j && ranges[j].end.column > endColumn && ranges[j].end.row == range.end.row)
j--;
ranges = ranges.slice(i, j + 1);
for (i = 0, j = ranges.length; i < j; i++) {
ranges[i].start.row += range.start.row;
ranges[i].end.row += range.start.row;
}
}
return ranges;
};
this.replace = function(input, replacement) {
var options = this.$options;
var re = this.$assembleRegExp(options);
if (options.$isMultiLine)
return replacement;
if (!re)
return;
var match = re.exec(input);
if (!match || match[0].length != input.length)
return null;
replacement = input.replace(re, replacement);
if (options.preserveCase) {
replacement = replacement.split("");
for (var i = Math.min(input.length, input.length); i--; ) {
var ch = input[i];
if (ch && ch.toLowerCase() != ch)
replacement[i] = replacement[i].toUpperCase();
else
replacement[i] = replacement[i].toLowerCase();
}
replacement = replacement.join("");
}
return replacement;
};
this.$matchIterator = function(session, options) {
var re = this.$assembleRegExp(options);
if (!re)
return false;
var self = this, callback, backwards = options.backwards;
if (options.$isMultiLine) {
var len = re.length;
var matchIterator = function(line, row, offset) {
var startIndex = line.search(re[0]);
if (startIndex == -1)
return;
for (var i = 1; i < len; i++) {
line = session.getLine(row + i);
if (line.search(re[i]) == -1)
return;
}
var endIndex = line.match(re[len - 1])[0].length;
var range = new Range(row, startIndex, row + len - 1, endIndex);
if (re.offset == 1) {
range.start.row--;
range.start.column = Number.MAX_VALUE;
} else if (offset)
range.start.column += offset;
if (callback(range))
return true;
};
} else if (backwards) {
var matchIterator = function(line, row, startIndex) {
var matches = lang.getMatchOffsets(line, re);
for (var i = matches.length-1; i >= 0; i--)
if (callback(matches[i], row, startIndex))
return true;
};
} else {
var matchIterator = function(line, row, startIndex) {
var matches = lang.getMatchOffsets(line, re);
for (var i = 0; i < matches.length; i++)
if (callback(matches[i], row, startIndex))
return true;
};
}
return {
forEach: function(_callback) {
callback = _callback;
self.$lineIterator(session, options).forEach(matchIterator);
}
};
};
this.$assembleRegExp = function(options, $disableFakeMultiline) {
if (options.needle instanceof RegExp)
return options.re = options.needle;
var needle = options.needle;
if (!options.needle)
return options.re = false;
if (!options.regExp)
needle = lang.escapeRegExp(needle);
if (options.wholeWord)
needle = "\\b" + needle + "\\b";
var modifier = options.caseSensitive ? "gm" : "gmi";
options.$isMultiLine = !$disableFakeMultiline && /[\n\r]/.test(needle);
if (options.$isMultiLine)
return options.re = this.$assembleMultilineRegExp(needle, modifier);
try {
var re = new RegExp(needle, modifier);
} catch(e) {
re = false;
}
return options.re = re;
};
this.$assembleMultilineRegExp = function(needle, modifier) {
var parts = needle.replace(/\r\n|\r|\n/g, "$\n^").split("\n");
var re = [];
for (var i = 0; i < parts.length; i++) try {
re.push(new RegExp(parts[i], modifier));
} catch(e) {
return false;
}
if (parts[0] == "") {
re.shift();
re.offset = 1;
} else {
re.offset = 0;
}
return re;
};
this.$lineIterator = function(session, options) {
var backwards = options.backwards == true;
var skipCurrent = options.skipCurrent != false;
var range = options.range;
var start = options.start;
if (!start)
start = range ? range[backwards ? "end" : "start"] : session.selection.getRange();
if (start.start)
start = start[skipCurrent != backwards ? "end" : "start"];
var firstRow = range ? range.start.row : 0;
var lastRow = range ? range.end.row : session.getLength() - 1;
var forEach = backwards ? function(callback) {
var row = start.row;
var line = session.getLine(row).substring(0, start.column);
if (callback(line, row))
return;
for (row--; row >= firstRow; row--)
if (callback(session.getLine(row), row))
return;
if (options.wrap == false)
return;
for (row = lastRow, firstRow = start.row; row >= firstRow; row--)
if (callback(session.getLine(row), row))
return;
} : function(callback) {
var row = start.row;
var line = session.getLine(row).substr(start.column);
if (callback(line, row, start.column))
return;
for (row = row+1; row <= lastRow; row++)
if (callback(session.getLine(row), row))
return;
if (options.wrap == false)
return;
for (row = firstRow, lastRow = start.row; row <= lastRow; row++)
if (callback(session.getLine(row), row))
return;
};
return {forEach: forEach};
};
}).call(Search.prototype);
exports.Search = Search;
});
define("ace/keyboard/hash_handler",["require","exports","module","ace/lib/keys","ace/lib/useragent"], function(require, exports, module) {
"use strict";
var keyUtil = require("../lib/keys");
var useragent = require("../lib/useragent");
var KEY_MODS = keyUtil.KEY_MODS;
function HashHandler(config, platform) {
this.platform = platform || (useragent.isMac ? "mac" : "win");
this.commands = {};
this.commandKeyBinding = {};
this.addCommands(config);
this.$singleCommand = true;
}
function MultiHashHandler(config, platform) {
HashHandler.call(this, config, platform);
this.$singleCommand = false;
}
MultiHashHandler.prototype = HashHandler.prototype;
(function() {
this.addCommand = function(command) {
if (this.commands[command.name])
this.removeCommand(command);
this.commands[command.name] = command;
if (command.bindKey)
this._buildKeyHash(command);
};
this.removeCommand = function(command, keepCommand) {
var name = command && (typeof command === 'string' ? command : command.name);
command = this.commands[name];
if (!keepCommand)
delete this.commands[name];
var ckb = this.commandKeyBinding;
for (var keyId in ckb) {
var cmdGroup = ckb[keyId];
if (cmdGroup == command) {
delete ckb[keyId];
} else if (Array.isArray(cmdGroup)) {
var i = cmdGroup.indexOf(command);
if (i != -1) {
cmdGroup.splice(i, 1);
if (cmdGroup.length == 1)
ckb[keyId] = cmdGroup[0];
}
}
}
};
this.bindKey = function(key, command, asDefault) {
if (typeof key == "object")
key = key[this.platform];
if (!key)
return;
if (typeof command == "function")
return this.addCommand({exec: command, bindKey: key, name: command.name || key});
key.split("|").forEach(function(keyPart) {
var chain = "";
if (keyPart.indexOf(" ") != -1) {
var parts = keyPart.split(/\s+/);
keyPart = parts.pop();
parts.forEach(function(keyPart) {
var binding = this.parseKeys(keyPart);
var id = KEY_MODS[binding.hashId] + binding.key;
chain += (chain ? " " : "") + id;
this._addCommandToBinding(chain, "chainKeys");
}, this);
chain += " ";
}
var binding = this.parseKeys(keyPart);
var id = KEY_MODS[binding.hashId] + binding.key;
this._addCommandToBinding(chain + id, command, asDefault);
}, this);
};
this._addCommandToBinding = function(keyId, command, asDefault) {
var ckb = this.commandKeyBinding, i;
if (!command) {
delete ckb[keyId];
} else if (!ckb[keyId] || this.$singleCommand) {
ckb[keyId] = command;
} else {
if (!Array.isArray(ckb[keyId])) {
ckb[keyId] = [ckb[keyId]];
} else if ((i = ckb[keyId].indexOf(command)) != -1) {
ckb[keyId].splice(i, 1);
}
if (asDefault || command.isDefault)
ckb[keyId].unshift(command);
else
ckb[keyId].push(command);
}
};
this.addCommands = function(commands) {
commands && Object.keys(commands).forEach(function(name) {
var command = commands[name];
if (!command)
return;
if (typeof command === "string")
return this.bindKey(command, name);
if (typeof command === "function")
command = { exec: command };
if (typeof command !== "object")
return;
if (!command.name)
command.name = name;
this.addCommand(command);
}, this);
};
this.removeCommands = function(commands) {
Object.keys(commands).forEach(function(name) {
this.removeCommand(commands[name]);
}, this);
};
this.bindKeys = function(keyList) {
Object.keys(keyList).forEach(function(key) {
this.bindKey(key, keyList[key]);
}, this);
};
this._buildKeyHash = function(command) {
this.bindKey(command.bindKey, command);
};
this.parseKeys = function(keys) {
var parts = keys.toLowerCase().split(/[\-\+]([\-\+])?/).filter(function(x){return x});
var key = parts.pop();
var keyCode = keyUtil[key];
if (keyUtil.FUNCTION_KEYS[keyCode])
key = keyUtil.FUNCTION_KEYS[keyCode].toLowerCase();
else if (!parts.length)
return {key: key, hashId: -1};
else if (parts.length == 1 && parts[0] == "shift")
return {key: key.toUpperCase(), hashId: -1};
var hashId = 0;
for (var i = parts.length; i--;) {
var modifier = keyUtil.KEY_MODS[parts[i]];
if (modifier == null) {
if (typeof console != "undefined")
console.error("invalid modifier " + parts[i] + " in " + keys);
return false;
}
hashId |= modifier;
}
return {key: key, hashId: hashId};
};
this.findKeyCommand = function findKeyCommand(hashId, keyString) {
var key = KEY_MODS[hashId] + keyString;
return this.commandKeyBinding[key];
};
this.handleKeyboard = function(data, hashId, keyString, keyCode) {
var key = KEY_MODS[hashId] + keyString;
var command = this.commandKeyBinding[key];
if (data.$keyChain) {
data.$keyChain += " " + key;
command = this.commandKeyBinding[data.$keyChain] || command;
}
if (command) {
if (command == "chainKeys" || command[command.length - 1] == "chainKeys") {
data.$keyChain = data.$keyChain || key;
return {command: "null"};
}
}
if (data.$keyChain && keyCode > 0)
data.$keyChain = "";
return {command: command};
};
}).call(HashHandler.prototype);
exports.HashHandler = HashHandler;
exports.MultiHashHandler = MultiHashHandler;
});
define("ace/commands/command_manager",["require","exports","module","ace/lib/oop","ace/keyboard/hash_handler","ace/lib/event_emitter"], function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var MultiHashHandler = require("../keyboard/hash_handler").MultiHashHandler;
var EventEmitter = require("../lib/event_emitter").EventEmitter;
var CommandManager = function(platform, commands) {
MultiHashHandler.call(this, commands, platform);
this.byName = this.commands;
this.setDefaultHandler("exec", function(e) {
return e.command.exec(e.editor, e.args || {});
});
};
oop.inherits(CommandManager, MultiHashHandler);
(function() {
oop.implement(this, EventEmitter);
this.exec = function(command, editor, args) {
if (Array.isArray(command)) {
for (var i = command.length; i--; ) {
if (this.exec(command[i], editor, args)) return true;
}
return false;
}
if (typeof command === "string")
command = this.commands[command];
if (!command)
return false;
if (editor && editor.$readOnly && !command.readOnly)
return false;
var e = {editor: editor, command: command, args: args};
e.returnValue = this._emit("exec", e);
this._signal("afterExec", e);
return e.returnValue === false ? false : true;
};
this.toggleRecording = function(editor) {
if (this.$inReplay)
return;
editor && editor._emit("changeStatus");
if (this.recording) {
this.macro.pop();
this.removeEventListener("exec", this.$addCommandToMacro);
if (!this.macro.length)
this.macro = this.oldMacro;
return this.recording = false;
}
if (!this.$addCommandToMacro) {
this.$addCommandToMacro = function(e) {
this.macro.push([e.command, e.args]);
}.bind(this);
}
this.oldMacro = this.macro;
this.macro = [];
this.on("exec", this.$addCommandToMacro);
return this.recording = true;
};
this.replay = function(editor) {
if (this.$inReplay || !this.macro)
return;
if (this.recording)
return this.toggleRecording(editor);
try {
this.$inReplay = true;
this.macro.forEach(function(x) {
if (typeof x == "string")
this.exec(x, editor);
else
this.exec(x[0], editor, x[1]);
}, this);
} finally {
this.$inReplay = false;
}
};
this.trimMacro = function(m) {
return m.map(function(x){
if (typeof x[0] != "string")
x[0] = x[0].name;
if (!x[1])
x = x[0];
return x;
});
};
}).call(CommandManager.prototype);
exports.CommandManager = CommandManager;
});
define("ace/commands/default_commands",["require","exports","module","ace/lib/lang","ace/config","ace/range"], function(require, exports, module) {
"use strict";
var lang = require("../lib/lang");
var config = require("../config");
var Range = require("../range").Range;
function bindKey(win, mac) {
return {win: win, mac: mac};
}
exports.commands = [{
name: "showSettingsMenu",
bindKey: bindKey("Ctrl-,", "Command-,"),
exec: function(editor) {
config.loadModule("ace/ext/settings_menu", function(module) {
module.init(editor);
editor.showSettingsMenu();
});
},
readOnly: true
}, {
name: "goToNextError",
bindKey: bindKey("Alt-E", "Ctrl-E"),
exec: function(editor) {
config.loadModule("ace/ext/error_marker", function(module) {
module.showErrorMarker(editor, 1);
});
},
scrollIntoView: "animate",
readOnly: true
}, {
name: "goToPreviousError",
bindKey: bindKey("Alt-Shift-E", "Ctrl-Shift-E"),
exec: function(editor) {
config.loadModule("ace/ext/error_marker", function(module) {
module.showErrorMarker(editor, -1);
});
},
scrollIntoView: "animate",
readOnly: true
}, {
name: "selectall",
bindKey: bindKey("Ctrl-A", "Command-A"),
exec: function(editor) { editor.selectAll(); },
readOnly: true
}, {
name: "centerselection",
bindKey: bindKey(null, "Ctrl-L"),
exec: function(editor) { editor.centerSelection(); },
readOnly: true
}, {
name: "gotoline",
bindKey: bindKey("Ctrl-L", "Command-L"),
exec: function(editor) {
var line = parseInt(prompt("Enter line number:"), 10);
if (!isNaN(line)) {
editor.gotoLine(line);
}
},
readOnly: true
}, {
name: "fold",
bindKey: bindKey("Alt-L|Ctrl-F1", "Command-Alt-L|Command-F1"),
exec: function(editor) { editor.session.toggleFold(false); },
scrollIntoView: "center",
readOnly: true
}, {
name: "unfold",
bindKey: bindKey("Alt-Shift-L|Ctrl-Shift-F1", "Command-Alt-Shift-L|Command-Shift-F1"),
exec: function(editor) { editor.session.toggleFold(true); },
scrollIntoView: "center",
readOnly: true
}, {
name: "toggleFoldWidget",
bindKey: bindKey("F2", "F2"),
exec: function(editor) { editor.session.toggleFoldWidget(); },
scrollIntoView: "center",
readOnly: true
}, {
name: "toggleParentFoldWidget",
bindKey: bindKey("Alt-F2", "Alt-F2"),
exec: function(editor) { editor.session.toggleFoldWidget(true); },
scrollIntoView: "center",
readOnly: true
}, {
name: "foldall",
bindKey: bindKey("Ctrl-Alt-0", "Ctrl-Command-Option-0"),
exec: function(editor) { editor.session.foldAll(); },
scrollIntoView: "center",
readOnly: true
}, {
name: "foldOther",
bindKey: bindKey("Alt-0", "Command-Option-0"),
exec: function(editor) {
editor.session.foldAll();
editor.session.unfold(editor.selection.getAllRanges());
},
scrollIntoView: "center",
readOnly: true
}, {
name: "unfoldall",
bindKey: bindKey("Alt-Shift-0", "Command-Option-Shift-0"),
exec: function(editor) { editor.session.unfold(); },
scrollIntoView: "center",
readOnly: true
}, {
name: "findnext",
bindKey: bindKey("Ctrl-K", "Command-G"),
exec: function(editor) { editor.findNext(); },
multiSelectAction: "forEach",
scrollIntoView: "center",
readOnly: true
}, {
name: "findprevious",
bindKey: bindKey("Ctrl-Shift-K", "Command-Shift-G"),
exec: function(editor) { editor.findPrevious(); },
multiSelectAction: "forEach",
scrollIntoView: "center",
readOnly: true
}, {
name: "selectOrFindNext",
bindKey: bindKey("Alt-K", "Ctrl-G"),
exec: function(editor) {
if (editor.selection.isEmpty())
editor.selection.selectWord();
else
editor.findNext();
},
readOnly: true
}, {
name: "selectOrFindPrevious",
bindKey: bindKey("Alt-Shift-K", "Ctrl-Shift-G"),
exec: function(editor) {
if (editor.selection.isEmpty())
editor.selection.selectWord();
else
editor.findPrevious();
},
readOnly: true
}, {
name: "find",
bindKey: bindKey("Ctrl-F", "Command-F"),
exec: function(editor) {
config.loadModule("ace/ext/searchbox", function(e) {e.Search(editor)});
},
readOnly: true
}, {
name: "overwrite",
bindKey: "Insert",
exec: function(editor) { editor.toggleOverwrite(); },
readOnly: true
}, {
name: "selecttostart",
bindKey: bindKey("Ctrl-Shift-Home", "Command-Shift-Up"),
exec: function(editor) { editor.getSelection().selectFileStart(); },
multiSelectAction: "forEach",
readOnly: true,
scrollIntoView: "animate",
aceCommandGroup: "fileJump"
}, {
name: "gotostart",
bindKey: bindKey("Ctrl-Home", "Command-Home|Command-Up"),
exec: function(editor) { editor.navigateFileStart(); },
multiSelectAction: "forEach",
readOnly: true,
scrollIntoView: "animate",
aceCommandGroup: "fileJump"
}, {
name: "selectup",
bindKey: bindKey("Shift-Up", "Shift-Up"),
exec: function(editor) { editor.getSelection().selectUp(); },
multiSelectAction: "forEach",
readOnly: true
}, {
name: "golineup",
bindKey: bindKey("Up", "Up|Ctrl-P"),
exec: function(editor, args) { editor.navigateUp(args.times); },
multiSelectAction: "forEach",
readOnly: true
}, {
name: "selecttoend",
bindKey: bindKey("Ctrl-Shift-End", "Command-Shift-Down"),
exec: function(editor) { editor.getSelection().selectFileEnd(); },
multiSelectAction: "forEach",
readOnly: true,
scrollIntoView: "animate",
aceCommandGroup: "fileJump"
}, {
name: "gotoend",
bindKey: bindKey("Ctrl-End", "Command-End|Command-Down"),
exec: function(editor) { editor.navigateFileEnd(); },
multiSelectAction: "forEach",
readOnly: true,
scrollIntoView: "animate",
aceCommandGroup: "fileJump"
}, {
name: "selectdown",
bindKey: bindKey("Shift-Down", "Shift-Down"),
exec: function(editor) { editor.getSelection().selectDown(); },
multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true
}, {
name: "golinedown",
bindKey: bindKey("Down", "Down|Ctrl-N"),
exec: function(editor, args) { editor.navigateDown(args.times); },
multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true
}, {
name: "selectwordleft",
bindKey: bindKey("Ctrl-Shift-Left", "Option-Shift-Left"),
exec: function(editor) { editor.getSelection().selectWordLeft(); },
multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true
}, {
name: "gotowordleft",
bindKey: bindKey("Ctrl-Left", "Option-Left"),
exec: function(editor) { editor.navigateWordLeft(); },
multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true
}, {
name: "selecttolinestart",
bindKey: bindKey("Alt-Shift-Left", "Command-Shift-Left"),
exec: function(editor) { editor.getSelection().selectLineStart(); },
multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true
}, {
name: "gotolinestart",
bindKey: bindKey("Alt-Left|Home", "Command-Left|Home|Ctrl-A"),
exec: function(editor) { editor.navigateLineStart(); },
multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true
}, {
name: "selectleft",
bindKey: bindKey("Shift-Left", "Shift-Left"),
exec: function(editor) { editor.getSelection().selectLeft(); },
multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true
}, {
name: "gotoleft",
bindKey: bindKey("Left", "Left|Ctrl-B"),
exec: function(editor, args) { editor.navigateLeft(args.times); },
multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true
}, {
name: "selectwordright",
bindKey: bindKey("Ctrl-Shift-Right", "Option-Shift-Right"),
exec: function(editor) { editor.getSelection().selectWordRight(); },
multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true
}, {
name: "gotowordright",
bindKey: bindKey("Ctrl-Right", "Option-Right"),
exec: function(editor) { editor.navigateWordRight(); },
multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true
}, {
name: "selecttolineend",
bindKey: bindKey("Alt-Shift-Right", "Command-Shift-Right"),
exec: function(editor) { editor.getSelection().selectLineEnd(); },
multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true
}, {
name: "gotolineend",
bindKey: bindKey("Alt-Right|End", "Command-Right|End|Ctrl-E"),
exec: function(editor) { editor.navigateLineEnd(); },
multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true
}, {
name: "selectright",
bindKey: bindKey("Shift-Right", "Shift-Right"),
exec: function(editor) { editor.getSelection().selectRight(); },
multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true
}, {
name: "gotoright",
bindKey: bindKey("Right", "Right|Ctrl-F"),
exec: function(editor, args) { editor.navigateRight(args.times); },
multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true
}, {
name: "selectpagedown",
bindKey: "Shift-PageDown",
exec: function(editor) { editor.selectPageDown(); },
readOnly: true
}, {
name: "pagedown",
bindKey: bindKey(null, "Option-PageDown"),
exec: function(editor) { editor.scrollPageDown(); },
readOnly: true
}, {
name: "gotopagedown",
bindKey: bindKey("PageDown", "PageDown|Ctrl-V"),
exec: function(editor) { editor.gotoPageDown(); },
readOnly: true
}, {
name: "selectpageup",
bindKey: "Shift-PageUp",
exec: function(editor) { editor.selectPageUp(); },
readOnly: true
}, {
name: "pageup",
bindKey: bindKey(null, "Option-PageUp"),
exec: function(editor) { editor.scrollPageUp(); },
readOnly: true
}, {
name: "gotopageup",
bindKey: "PageUp",
exec: function(editor) { editor.gotoPageUp(); },
readOnly: true
}, {
name: "scrollup",
bindKey: bindKey("Ctrl-Up", null),
exec: function(e) { e.renderer.scrollBy(0, -2 * e.renderer.layerConfig.lineHeight); },
readOnly: true
}, {
name: "scrolldown",
bindKey: bindKey("Ctrl-Down", null),
exec: function(e) { e.renderer.scrollBy(0, 2 * e.renderer.layerConfig.lineHeight); },
readOnly: true
}, {
name: "selectlinestart",
bindKey: "Shift-Home",
exec: function(editor) { editor.getSelection().selectLineStart(); },
multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true
}, {
name: "selectlineend",
bindKey: "Shift-End",
exec: function(editor) { editor.getSelection().selectLineEnd(); },
multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true
}, {
name: "togglerecording",
bindKey: bindKey("Ctrl-Alt-E", "Command-Option-E"),
exec: function(editor) { editor.commands.toggleRecording(editor); },
readOnly: true
}, {
name: "replaymacro",
bindKey: bindKey("Ctrl-Shift-E", "Command-Shift-E"),
exec: function(editor) { editor.commands.replay(editor); },
readOnly: true
}, {
name: "jumptomatching",
bindKey: bindKey("Ctrl-P", "Ctrl-P"),
exec: function(editor) { editor.jumpToMatching(); },
multiSelectAction: "forEach",
readOnly: true
}, {
name: "selecttomatching",
bindKey: bindKey("Ctrl-Shift-P", "Ctrl-Shift-P"),
exec: function(editor) { editor.jumpToMatching(true); },
multiSelectAction: "forEach",
readOnly: true
}, {
name: "passKeysToBrowser",
bindKey: bindKey("null", "null"),
exec: function() {},
passEvent: true,
readOnly: true
},
{
name: "cut",
exec: function(editor) {
var range = editor.getSelectionRange();
editor._emit("cut", range);
if (!editor.selection.isEmpty()) {
editor.session.remove(range);
editor.clearSelection();
}
},
scrollIntoView: "cursor",
multiSelectAction: "forEach"
}, {
name: "removeline",
bindKey: bindKey("Ctrl-D", "Command-D"),
exec: function(editor) { editor.removeLines(); },
scrollIntoView: "cursor",
multiSelectAction: "forEachLine"
}, {
name: "duplicateSelection",
bindKey: bindKey("Ctrl-Shift-D", "Command-Shift-D"),
exec: function(editor) { editor.duplicateSelection(); },
scrollIntoView: "cursor",
multiSelectAction: "forEach"
}, {
name: "sortlines",
bindKey: bindKey("Ctrl-Alt-S", "Command-Alt-S"),
exec: function(editor) { editor.sortLines(); },
scrollIntoView: "selection",
multiSelectAction: "forEachLine"
}, {
name: "togglecomment",
bindKey: bindKey("Ctrl-/", "Command-/"),
exec: function(editor) { editor.toggleCommentLines(); },
multiSelectAction: "forEachLine",
scrollIntoView: "selectionPart"
}, {
name: "toggleBlockComment",
bindKey: bindKey("Ctrl-Shift-/", "Command-Shift-/"),
exec: function(editor) { editor.toggleBlockComment(); },
multiSelectAction: "forEach",
scrollIntoView: "selectionPart"
}, {
name: "modifyNumberUp",
bindKey: bindKey("Ctrl-Shift-Up", "Alt-Shift-Up"),
exec: function(editor) { editor.modifyNumber(1); },
multiSelectAction: "forEach"
}, {
name: "modifyNumberDown",
bindKey: bindKey("Ctrl-Shift-Down", "Alt-Shift-Down"),
exec: function(editor) { editor.modifyNumber(-1); },
multiSelectAction: "forEach"
}, {
name: "replace",
bindKey: bindKey("Ctrl-H", "Command-Option-F"),
exec: function(editor) {
config.loadModule("ace/ext/searchbox", function(e) {e.Search(editor, true)});
}
}, {
name: "undo",
bindKey: bindKey("Ctrl-Z", "Command-Z"),
exec: function(editor) { editor.undo(); }
}, {
name: "redo",
bindKey: bindKey("Ctrl-Shift-Z|Ctrl-Y", "Command-Shift-Z|Command-Y"),
exec: function(editor) { editor.redo(); }
}, {
name: "copylinesup",
bindKey: bindKey("Alt-Shift-Up", "Command-Option-Up"),
exec: function(editor) { editor.copyLinesUp(); },
scrollIntoView: "cursor"
}, {
name: "movelinesup",
bindKey: bindKey("Alt-Up", "Option-Up"),
exec: function(editor) { editor.moveLinesUp(); },
scrollIntoView: "cursor"
}, {
name: "copylinesdown",
bindKey: bindKey("Alt-Shift-Down", "Command-Option-Down"),
exec: function(editor) { editor.copyLinesDown(); },
scrollIntoView: "cursor"
}, {
name: "movelinesdown",
bindKey: bindKey("Alt-Down", "Option-Down"),
exec: function(editor) { editor.moveLinesDown(); },
scrollIntoView: "cursor"
}, {
name: "del",
bindKey: bindKey("Delete", "Delete|Ctrl-D|Shift-Delete"),
exec: function(editor) { editor.remove("right"); },
multiSelectAction: "forEach",
scrollIntoView: "cursor"
}, {
name: "backspace",
bindKey: bindKey(
"Shift-Backspace|Backspace",
"Ctrl-Backspace|Shift-Backspace|Backspace|Ctrl-H"
),
exec: function(editor) { editor.remove("left"); },
multiSelectAction: "forEach",
scrollIntoView: "cursor"
}, {
name: "cut_or_delete",
bindKey: bindKey("Shift-Delete", null),
exec: function(editor) {
if (editor.selection.isEmpty()) {
editor.remove("left");
} else {
return false;
}
},
multiSelectAction: "forEach",
scrollIntoView: "cursor"
}, {
name: "removetolinestart",
bindKey: bindKey("Alt-Backspace", "Command-Backspace"),
exec: function(editor) { editor.removeToLineStart(); },
multiSelectAction: "forEach",
scrollIntoView: "cursor"
}, {
name: "removetolineend",
bindKey: bindKey("Alt-Delete", "Ctrl-K"),
exec: function(editor) { editor.removeToLineEnd(); },
multiSelectAction: "forEach",
scrollIntoView: "cursor"
}, {
name: "removewordleft",
bindKey: bindKey("Ctrl-Backspace", "Alt-Backspace|Ctrl-Alt-Backspace"),
exec: function(editor) { editor.removeWordLeft(); },
multiSelectAction: "forEach",
scrollIntoView: "cursor"
}, {
name: "removewordright",
bindKey: bindKey("Ctrl-Delete", "Alt-Delete"),
exec: function(editor) { editor.removeWordRight(); },
multiSelectAction: "forEach",
scrollIntoView: "cursor"
}, {
name: "outdent",
bindKey: bindKey("Shift-Tab", "Shift-Tab"),
exec: function(editor) { editor.blockOutdent(); },
multiSelectAction: "forEach",
scrollIntoView: "selectionPart"
}, {
name: "indent",
bindKey: bindKey("Tab", "Tab"),
exec: function(editor) { editor.indent(); },
multiSelectAction: "forEach",
scrollIntoView: "selectionPart"
}, {
name: "blockoutdent",
bindKey: bindKey("Ctrl-[", "Ctrl-["),
exec: function(editor) { editor.blockOutdent(); },
multiSelectAction: "forEachLine",
scrollIntoView: "selectionPart"
}, {
name: "blockindent",
bindKey: bindKey("Ctrl-]", "Ctrl-]"),
exec: function(editor) { editor.blockIndent(); },
multiSelectAction: "forEachLine",
scrollIntoView: "selectionPart"
}, {
name: "insertstring",
exec: function(editor, str) { editor.insert(str); },
multiSelectAction: "forEach",
scrollIntoView: "cursor"
}, {
name: "inserttext",
exec: function(editor, args) {
editor.insert(lang.stringRepeat(args.text || "", args.times || 1));
},
multiSelectAction: "forEach",
scrollIntoView: "cursor"
}, {
name: "splitline",
bindKey: bindKey(null, "Ctrl-O"),
exec: function(editor) { editor.splitLine(); },
multiSelectAction: "forEach",
scrollIntoView: "cursor"
}, {
name: "transposeletters",
bindKey: bindKey("Ctrl-T", "Ctrl-T"),
exec: function(editor) { editor.transposeLetters(); },
multiSelectAction: function(editor) {editor.transposeSelections(1); },
scrollIntoView: "cursor"
}, {
name: "touppercase",
bindKey: bindKey("Ctrl-U", "Ctrl-U"),
exec: function(editor) { editor.toUpperCase(); },
multiSelectAction: "forEach",
scrollIntoView: "cursor"
}, {
name: "tolowercase",
bindKey: bindKey("Ctrl-Shift-U", "Ctrl-Shift-U"),
exec: function(editor) { editor.toLowerCase(); },
multiSelectAction: "forEach",
scrollIntoView: "cursor"
}, {
name: "expandtoline",
bindKey: bindKey("Ctrl-Shift-L", "Command-Shift-L"),
exec: function(editor) {
var range = editor.selection.getRange();
range.start.column = range.end.column = 0;
range.end.row++;
editor.selection.setRange(range, false);
},
multiSelectAction: "forEach",
scrollIntoView: "cursor",
readOnly: true
}, {
name: "joinlines",
bindKey: bindKey(null, null),
exec: function(editor) {
var isBackwards = editor.selection.isBackwards();
var selectionStart = isBackwards ? editor.selection.getSelectionLead() : editor.selection.getSelectionAnchor();
var selectionEnd = isBackwards ? editor.selection.getSelectionAnchor() : editor.selection.getSelectionLead();
var firstLineEndCol = editor.session.doc.getLine(selectionStart.row).length
var selectedText = editor.session.doc.getTextRange(editor.selection.getRange());
var selectedCount = selectedText.replace(/\n\s*/, " ").length;
var insertLine = editor.session.doc.getLine(selectionStart.row);
for (var i = selectionStart.row + 1; i <= selectionEnd.row + 1; i++) {
var curLine = lang.stringTrimLeft(lang.stringTrimRight(editor.session.doc.getLine(i)));
if (curLine.length !== 0) {
curLine = " " + curLine;
}
insertLine += curLine;
};
if (selectionEnd.row + 1 < (editor.session.doc.getLength() - 1)) {
insertLine += editor.session.doc.getNewLineCharacter();
}
editor.clearSelection();
editor.session.doc.replace(new Range(selectionStart.row, 0, selectionEnd.row + 2, 0), insertLine);
if (selectedCount > 0) {
editor.selection.moveCursorTo(selectionStart.row, selectionStart.column);
editor.selection.selectTo(selectionStart.row, selectionStart.column + selectedCount);
} else {
firstLineEndCol = editor.session.doc.getLine(selectionStart.row).length > firstLineEndCol ? (firstLineEndCol + 1) : firstLineEndCol;
editor.selection.moveCursorTo(selectionStart.row, firstLineEndCol);
}
},
multiSelectAction: "forEach",
readOnly: true
}, {
name: "invertSelection",
bindKey: bindKey(null, null),
exec: function(editor) {
var endRow = editor.session.doc.getLength() - 1;
var endCol = editor.session.doc.getLine(endRow).length;
var ranges = editor.selection.rangeList.ranges;
var newRanges = [];
if (ranges.length < 1) {
ranges = [editor.selection.getRange()];
}
for (var i = 0; i < ranges.length; i++) {
if (i == (ranges.length - 1)) {
if (!(ranges[i].end.row === endRow && ranges[i].end.column === endCol)) {
newRanges.push(new Range(ranges[i].end.row, ranges[i].end.column, endRow, endCol));
}
}
if (i === 0) {
if (!(ranges[i].start.row === 0 && ranges[i].start.column === 0)) {
newRanges.push(new Range(0, 0, ranges[i].start.row, ranges[i].start.column));
}
} else {
newRanges.push(new Range(ranges[i-1].end.row, ranges[i-1].end.column, ranges[i].start.row, ranges[i].start.column));
}
}
editor.exitMultiSelectMode();
editor.clearSelection();
for(var i = 0; i < newRanges.length; i++) {
editor.selection.addRange(newRanges[i], false);
}
},
readOnly: true,
scrollIntoView: "none"
}];
});
define("ace/editor",["require","exports","module","ace/lib/fixoldbrowsers","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/lib/useragent","ace/keyboard/textinput","ace/mouse/mouse_handler","ace/mouse/fold_handler","ace/keyboard/keybinding","ace/edit_session","ace/search","ace/range","ace/lib/event_emitter","ace/commands/command_manager","ace/commands/default_commands","ace/config","ace/token_iterator"], function(require, exports, module) {
"use strict";
require("./lib/fixoldbrowsers");
var oop = require("./lib/oop");
var dom = require("./lib/dom");
var lang = require("./lib/lang");
var useragent = require("./lib/useragent");
var TextInput = require("./keyboard/textinput").TextInput;
var MouseHandler = require("./mouse/mouse_handler").MouseHandler;
var FoldHandler = require("./mouse/fold_handler").FoldHandler;
var KeyBinding = require("./keyboard/keybinding").KeyBinding;
var EditSession = require("./edit_session").EditSession;
var Search = require("./search").Search;
var Range = require("./range").Range;
var EventEmitter = require("./lib/event_emitter").EventEmitter;
var CommandManager = require("./commands/command_manager").CommandManager;
var defaultCommands = require("./commands/default_commands").commands;
var config = require("./config");
var TokenIterator = require("./token_iterator").TokenIterator;
var Editor = function(renderer, session) {
var container = renderer.getContainerElement();
this.container = container;
this.renderer = renderer;
this.commands = new CommandManager(useragent.isMac ? "mac" : "win", defaultCommands);
this.textInput = new TextInput(renderer.getTextAreaContainer(), this);
this.renderer.textarea = this.textInput.getElement();
this.keyBinding = new KeyBinding(this);
this.$mouseHandler = new MouseHandler(this);
new FoldHandler(this);
this.$blockScrolling = 0;
this.$search = new Search().set({
wrap: true
});
this.$historyTracker = this.$historyTracker.bind(this);
this.commands.on("exec", this.$historyTracker);
this.$initOperationListeners();
this._$emitInputEvent = lang.delayedCall(function() {
this._signal("input", {});
if (this.session && this.session.bgTokenizer)
this.session.bgTokenizer.scheduleStart();
}.bind(this));
this.on("change", function(_, _self) {
_self._$emitInputEvent.schedule(31);
});
this.setSession(session || new EditSession(""));
config.resetOptions(this);
config._signal("editor", this);
};
(function(){
oop.implement(this, EventEmitter);
this.$initOperationListeners = function() {
function last(a) {return a[a.length - 1]}
this.selections = [];
this.commands.on("exec", this.startOperation.bind(this), true);
this.commands.on("afterExec", this.endOperation.bind(this), true);
this.$opResetTimer = lang.delayedCall(this.endOperation.bind(this));
this.on("change", function() {
this.curOp || this.startOperation();
this.curOp.docChanged = true;
}.bind(this), true);
this.on("changeSelection", function() {
this.curOp || this.startOperation();
this.curOp.selectionChanged = true;
}.bind(this), true);
};
this.curOp = null;
this.prevOp = {};
this.startOperation = function(commadEvent) {
if (this.curOp) {
if (!commadEvent || this.curOp.command)
return;
this.prevOp = this.curOp;
}
if (!commadEvent) {
this.previousCommand = null;
commadEvent = {};
}
this.$opResetTimer.schedule();
this.curOp = {
command: commadEvent.command || {},
args: commadEvent.args,
scrollTop: this.renderer.scrollTop
};
};
this.endOperation = function(e) {
if (this.curOp) {
if (e && e.returnValue === false)
return this.curOp = null;
var command = this.curOp.command;
if (command && command.scrollIntoView) {
switch (command.scrollIntoView) {
case "center":
this.renderer.scrollCursorIntoView(null, 0.5);
break;
case "animate":
case "cursor":
this.renderer.scrollCursorIntoView();
break;
case "selectionPart":
var range = this.selection.getRange();
var config = this.renderer.layerConfig;
if (range.start.row >= config.lastRow || range.end.row <= config.firstRow) {
this.renderer.scrollSelectionIntoView(this.selection.anchor, this.selection.lead);
}
break;
default:
break;
}
if (command.scrollIntoView == "animate")
this.renderer.animateScrolling(this.curOp.scrollTop);
}
this.prevOp = this.curOp;
this.curOp = null;
}
};
this.$mergeableCommands = ["backspace", "del", "insertstring"];
this.$historyTracker = function(e) {
if (!this.$mergeUndoDeltas)
return;
var prev = this.prevOp;
var mergeableCommands = this.$mergeableCommands;
var shouldMerge = prev.command && (e.command.name == prev.command.name);
if (e.command.name == "insertstring") {
var text = e.args;
if (this.mergeNextCommand === undefined)
this.mergeNextCommand = true;
shouldMerge = shouldMerge
&& this.mergeNextCommand // previous command allows to coalesce with
&& (!/\s/.test(text) || /\s/.test(prev.args)); // previous insertion was of same type
this.mergeNextCommand = true;
} else {
shouldMerge = shouldMerge
&& mergeableCommands.indexOf(e.command.name) !== -1; // the command is mergeable
}
if (
this.$mergeUndoDeltas != "always"
&& Date.now() - this.sequenceStartTime > 2000
) {
shouldMerge = false; // the sequence is too long
}
if (shouldMerge)
this.session.mergeUndoDeltas = true;
else if (mergeableCommands.indexOf(e.command.name) !== -1)
this.sequenceStartTime = Date.now();
};
this.setKeyboardHandler = function(keyboardHandler, cb) {
if (keyboardHandler && typeof keyboardHandler === "string") {
this.$keybindingId = keyboardHandler;
var _self = this;
config.loadModule(["keybinding", keyboardHandler], function(module) {
if (_self.$keybindingId == keyboardHandler)
_self.keyBinding.setKeyboardHandler(module && module.handler);
cb && cb();
});
} else {
this.$keybindingId = null;
this.keyBinding.setKeyboardHandler(keyboardHandler);
cb && cb();
}
};
this.getKeyboardHandler = function() {
return this.keyBinding.getKeyboardHandler();
};
this.setSession = function(session) {
if (this.session == session)
return;
var oldSession = this.session;
if (oldSession) {
this.session.removeEventListener("change", this.$onDocumentChange);
this.session.removeEventListener("changeMode", this.$onChangeMode);
this.session.removeEventListener("tokenizerUpdate", this.$onTokenizerUpdate);
this.session.removeEventListener("changeTabSize", this.$onChangeTabSize);
this.session.removeEventListener("changeWrapLimit", this.$onChangeWrapLimit);
this.session.removeEventListener("changeWrapMode", this.$onChangeWrapMode);
this.session.removeEventListener("onChangeFold", this.$onChangeFold);
this.session.removeEventListener("changeFrontMarker", this.$onChangeFrontMarker);
this.session.removeEventListener("changeBackMarker", this.$onChangeBackMarker);
this.session.removeEventListener("changeBreakpoint", this.$onChangeBreakpoint);
this.session.removeEventListener("changeAnnotation", this.$onChangeAnnotation);
this.session.removeEventListener("changeOverwrite", this.$onCursorChange);
this.session.removeEventListener("changeScrollTop", this.$onScrollTopChange);
this.session.removeEventListener("changeScrollLeft", this.$onScrollLeftChange);
var selection = this.session.getSelection();
selection.removeEventListener("changeCursor", this.$onCursorChange);
selection.removeEventListener("changeSelection", this.$onSelectionChange);
}
this.session = session;
if (session) {
this.$onDocumentChange = this.onDocumentChange.bind(this);
session.addEventListener("change", this.$onDocumentChange);
this.renderer.setSession(session);
this.$onChangeMode = this.onChangeMode.bind(this);
session.addEventListener("changeMode", this.$onChangeMode);
this.$onTokenizerUpdate = this.onTokenizerUpdate.bind(this);
session.addEventListener("tokenizerUpdate", this.$onTokenizerUpdate);
this.$onChangeTabSize = this.renderer.onChangeTabSize.bind(this.renderer);
session.addEventListener("changeTabSize", this.$onChangeTabSize);
this.$onChangeWrapLimit = this.onChangeWrapLimit.bind(this);
session.addEventListener("changeWrapLimit", this.$onChangeWrapLimit);
this.$onChangeWrapMode = this.onChangeWrapMode.bind(this);
session.addEventListener("changeWrapMode", this.$onChangeWrapMode);
this.$onChangeFold = this.onChangeFold.bind(this);
session.addEventListener("changeFold", this.$onChangeFold);
this.$onChangeFrontMarker = this.onChangeFrontMarker.bind(this);
this.session.addEventListener("changeFrontMarker", this.$onChangeFrontMarker);
this.$onChangeBackMarker = this.onChangeBackMarker.bind(this);
this.session.addEventListener("changeBackMarker", this.$onChangeBackMarker);
this.$onChangeBreakpoint = this.onChangeBreakpoint.bind(this);
this.session.addEventListener("changeBreakpoint", this.$onChangeBreakpoint);
this.$onChangeAnnotation = this.onChangeAnnotation.bind(this);
this.session.addEventListener("changeAnnotation", this.$onChangeAnnotation);
this.$onCursorChange = this.onCursorChange.bind(this);
this.session.addEventListener("changeOverwrite", this.$onCursorChange);
this.$onScrollTopChange = this.onScrollTopChange.bind(this);
this.session.addEventListener("changeScrollTop", this.$onScrollTopChange);
this.$onScrollLeftChange = this.onScrollLeftChange.bind(this);
this.session.addEventListener("changeScrollLeft", this.$onScrollLeftChange);
this.selection = session.getSelection();
this.selection.addEventListener("changeCursor", this.$onCursorChange);
this.$onSelectionChange = this.onSelectionChange.bind(this);
this.selection.addEventListener("changeSelection", this.$onSelectionChange);
this.onChangeMode();
this.$blockScrolling += 1;
this.onCursorChange();
this.$blockScrolling -= 1;
this.onScrollTopChange();
this.onScrollLeftChange();
this.onSelectionChange();
this.onChangeFrontMarker();
this.onChangeBackMarker();
this.onChangeBreakpoint();
this.onChangeAnnotation();
this.session.getUseWrapMode() && this.renderer.adjustWrapLimit();
this.renderer.updateFull();
} else {
this.selection = null;
this.renderer.setSession(session);
}
this._signal("changeSession", {
session: session,
oldSession: oldSession
});
oldSession && oldSession._signal("changeEditor", {oldEditor: this});
session && session._signal("changeEditor", {editor: this});
};
this.getSession = function() {
return this.session;
};
this.setValue = function(val, cursorPos) {
this.session.doc.setValue(val);
if (!cursorPos)
this.selectAll();
else if (cursorPos == 1)
this.navigateFileEnd();
else if (cursorPos == -1)
this.navigateFileStart();
return val;
};
this.getValue = function() {
return this.session.getValue();
};
this.getSelection = function() {
return this.selection;
};
this.resize = function(force) {
this.renderer.onResize(force);
};
this.setTheme = function(theme, cb) {
this.renderer.setTheme(theme, cb);
};
this.getTheme = function() {
return this.renderer.getTheme();
};
this.setStyle = function(style) {
this.renderer.setStyle(style);
};
this.unsetStyle = function(style) {
this.renderer.unsetStyle(style);
};
this.getFontSize = function () {
return this.getOption("fontSize") ||
dom.computedStyle(this.container, "fontSize");
};
this.setFontSize = function(size) {
this.setOption("fontSize", size);
};
this.$highlightBrackets = function() {
if (this.session.$bracketHighlight) {
this.session.removeMarker(this.session.$bracketHighlight);
this.session.$bracketHighlight = null;
}
if (this.$highlightPending) {
return;
}
var self = this;
this.$highlightPending = true;
setTimeout(function() {
self.$highlightPending = false;
var session = self.session;
if (!session || !session.bgTokenizer) return;
var pos = session.findMatchingBracket(self.getCursorPosition());
if (pos) {
var range = new Range(pos.row, pos.column, pos.row, pos.column + 1);
} else if (session.$mode.getMatching) {
var range = session.$mode.getMatching(self.session);
}
if (range)
session.$bracketHighlight = session.addMarker(range, "ace_bracket", "text");
}, 50);
};
this.$highlightTags = function() {
if (this.$highlightTagPending)
return;
var self = this;
this.$highlightTagPending = true;
setTimeout(function() {
self.$highlightTagPending = false;
var session = self.session;
if (!session || !session.bgTokenizer) return;
var pos = self.getCursorPosition();
var iterator = new TokenIterator(self.session, pos.row, pos.column);
var token = iterator.getCurrentToken();
if (!token || token.type.indexOf('tag-name') === -1) {
session.removeMarker(session.$tagHighlight);
session.$tagHighlight = null;
return;
}
var tag = token.value;
var depth = 0;
var prevToken = iterator.stepBackward();
if (prevToken.value == '<'){
do {
prevToken = token;
token = iterator.stepForward();
if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) {
if (prevToken.value === '<'){
depth++;
} else if (prevToken.value === ''){
depth--;
}
}
} while (token && depth >= 0);
} else {
do {
token = prevToken;
prevToken = iterator.stepBackward();
if (token && token.value === tag && token.type.indexOf('tag-name') !== -1) {
if (prevToken.value === '<') {
depth++;
} else if (prevToken.value === '') {
depth--;
}
}
} while (prevToken && depth <= 0);
iterator.stepForward();
}
if (!token) {
session.removeMarker(session.$tagHighlight);
session.$tagHighlight = null;
return;
}
var row = iterator.getCurrentTokenRow();
var column = iterator.getCurrentTokenColumn();
var range = new Range(row, column, row, column+token.value.length);
if (session.$tagHighlight && range.compareRange(session.$backMarkers[session.$tagHighlight].range)!==0) {
session.removeMarker(session.$tagHighlight);
session.$tagHighlight = null;
}
if (range && !session.$tagHighlight)
session.$tagHighlight = session.addMarker(range, "ace_bracket", "text");
}, 50);
};
this.focus = function() {
var _self = this;
setTimeout(function() {
_self.textInput.focus();
});
this.textInput.focus();
};
this.isFocused = function() {
return this.textInput.isFocused();
};
this.blur = function() {
this.textInput.blur();
};
this.onFocus = function(e) {
if (this.$isFocused)
return;
this.$isFocused = true;
this.renderer.showCursor();
this.renderer.visualizeFocus();
this._emit("focus", e);
};
this.onBlur = function(e) {
if (!this.$isFocused)
return;
this.$isFocused = false;
this.renderer.hideCursor();
this.renderer.visualizeBlur();
this._emit("blur", e);
};
this.$cursorChange = function() {
this.renderer.updateCursor();
};
this.onDocumentChange = function(e) {
var delta = e.data;
var range = delta.range;
var lastRow;
if (range.start.row == range.end.row && delta.action != "insertLines" && delta.action != "removeLines")
lastRow = range.end.row;
else
lastRow = Infinity;
this.renderer.updateLines(range.start.row, lastRow, this.session.$useWrapMode);
this._signal("change", e);
this.$cursorChange();
this.$updateHighlightActiveLine();
};
this.onTokenizerUpdate = function(e) {
var rows = e.data;
this.renderer.updateLines(rows.first, rows.last);
};
this.onScrollTopChange = function() {
this.renderer.scrollToY(this.session.getScrollTop());
};
this.onScrollLeftChange = function() {
this.renderer.scrollToX(this.session.getScrollLeft());
};
this.onCursorChange = function() {
this.$cursorChange();
if (!this.$blockScrolling) {
this.renderer.scrollCursorIntoView();
}
this.$highlightBrackets();
this.$highlightTags();
this.$updateHighlightActiveLine();
this._signal("changeSelection");
};
this.$updateHighlightActiveLine = function() {
var session = this.getSession();
var highlight;
if (this.$highlightActiveLine) {
if ((this.$selectionStyle != "line" || !this.selection.isMultiLine()))
highlight = this.getCursorPosition();
if (this.renderer.$maxLines && this.session.getLength() === 1 && !(this.renderer.$minLines > 1))
highlight = false;
}
if (session.$highlightLineMarker && !highlight) {
session.removeMarker(session.$highlightLineMarker.id);
session.$highlightLineMarker = null;
} else if (!session.$highlightLineMarker && highlight) {
var range = new Range(highlight.row, highlight.column, highlight.row, Infinity);
range.id = session.addMarker(range, "ace_active-line", "screenLine");
session.$highlightLineMarker = range;
} else if (highlight) {
session.$highlightLineMarker.start.row = highlight.row;
session.$highlightLineMarker.end.row = highlight.row;
session.$highlightLineMarker.start.column = highlight.column;
session._signal("changeBackMarker");
}
};
this.onSelectionChange = function(e) {
var session = this.session;
if (session.$selectionMarker) {
session.removeMarker(session.$selectionMarker);
}
session.$selectionMarker = null;
if (!this.selection.isEmpty()) {
var range = this.selection.getRange();
var style = this.getSelectionStyle();
session.$selectionMarker = session.addMarker(range, "ace_selection", style);
} else {
this.$updateHighlightActiveLine();
}
var re = this.$highlightSelectedWord && this.$getSelectionHighLightRegexp();
this.session.highlight(re);
this._signal("changeSelection");
};
this.$getSelectionHighLightRegexp = function() {
var session = this.session;
var selection = this.getSelectionRange();
if (selection.isEmpty() || selection.isMultiLine())
return;
var startOuter = selection.start.column - 1;
var endOuter = selection.end.column + 1;
var line = session.getLine(selection.start.row);
var lineCols = line.length;
var needle = line.substring(Math.max(startOuter, 0),
Math.min(endOuter, lineCols));
if ((startOuter >= 0 && /^[\w\d]/.test(needle)) ||
(endOuter <= lineCols && /[\w\d]$/.test(needle)))
return;
needle = line.substring(selection.start.column, selection.end.column);
if (!/^[\w\d]+$/.test(needle))
return;
var re = this.$search.$assembleRegExp({
wholeWord: true,
caseSensitive: true,
needle: needle
});
return re;
};
this.onChangeFrontMarker = function() {
this.renderer.updateFrontMarkers();
};
this.onChangeBackMarker = function() {
this.renderer.updateBackMarkers();
};
this.onChangeBreakpoint = function() {
this.renderer.updateBreakpoints();
};
this.onChangeAnnotation = function() {
this.renderer.setAnnotations(this.session.getAnnotations());
};
this.onChangeMode = function(e) {
this.renderer.updateText();
this._emit("changeMode", e);
};
this.onChangeWrapLimit = function() {
this.renderer.updateFull();
};
this.onChangeWrapMode = function() {
this.renderer.onResize(true);
};
this.onChangeFold = function() {
this.$updateHighlightActiveLine();
this.renderer.updateFull();
};
this.getSelectedText = function() {
return this.session.getTextRange(this.getSelectionRange());
};
this.getCopyText = function() {
var text = this.getSelectedText();
this._signal("copy", text);
return text;
};
this.onCopy = function() {
this.commands.exec("copy", this);
};
this.onCut = function() {
this.commands.exec("cut", this);
};
this.onPaste = function(text) {
if (this.$readOnly)
return;
var e = {text: text};
this._signal("paste", e);
this.insert(e.text, true);
};
this.execCommand = function(command, args) {
return this.commands.exec(command, this, args);
};
this.insert = function(text, pasted) {
var session = this.session;
var mode = session.getMode();
var cursor = this.getCursorPosition();
if (this.getBehavioursEnabled() && !pasted) {
var transform = mode.transformAction(session.getState(cursor.row), 'insertion', this, session, text);
if (transform) {
if (text !== transform.text) {
this.session.mergeUndoDeltas = false;
this.$mergeNextCommand = false;
}
text = transform.text;
}
}
if (text == "\t")
text = this.session.getTabString();
if (!this.selection.isEmpty()) {
var range = this.getSelectionRange();
cursor = this.session.remove(range);
this.clearSelection();
}
else if (this.session.getOverwrite()) {
var range = new Range.fromPoints(cursor, cursor);
range.end.column += text.length;
this.session.remove(range);
}
if (text == "\n" || text == "\r\n") {
var line = session.getLine(cursor.row);
if (cursor.column > line.search(/\S|$/)) {
var d = line.substr(cursor.column).search(/\S|$/);
session.doc.removeInLine(cursor.row, cursor.column, cursor.column + d);
}
}
this.clearSelection();
var start = cursor.column;
var lineState = session.getState(cursor.row);
var line = session.getLine(cursor.row);
var shouldOutdent = mode.checkOutdent(lineState, line, text);
var end = session.insert(cursor, text);
if (transform && transform.selection) {
if (transform.selection.length == 2) { // Transform relative to the current column
this.selection.setSelectionRange(
new Range(cursor.row, start + transform.selection[0],
cursor.row, start + transform.selection[1]));
} else { // Transform relative to the current row.
this.selection.setSelectionRange(
new Range(cursor.row + transform.selection[0],
transform.selection[1],
cursor.row + transform.selection[2],
transform.selection[3]));
}
}
if (session.getDocument().isNewLine(text)) {
var lineIndent = mode.getNextLineIndent(lineState, line.slice(0, cursor.column), session.getTabString());
session.insert({row: cursor.row+1, column: 0}, lineIndent);
}
if (shouldOutdent)
mode.autoOutdent(lineState, session, cursor.row);
};
this.onTextInput = function(text) {
this.keyBinding.onTextInput(text);
};
this.onCommandKey = function(e, hashId, keyCode) {
this.keyBinding.onCommandKey(e, hashId, keyCode);
};
this.setOverwrite = function(overwrite) {
this.session.setOverwrite(overwrite);
};
this.getOverwrite = function() {
return this.session.getOverwrite();
};
this.toggleOverwrite = function() {
this.session.toggleOverwrite();
};
this.setScrollSpeed = function(speed) {
this.setOption("scrollSpeed", speed);
};
this.getScrollSpeed = function() {
return this.getOption("scrollSpeed");
};
this.setDragDelay = function(dragDelay) {
this.setOption("dragDelay", dragDelay);
};
this.getDragDelay = function() {
return this.getOption("dragDelay");
};
this.setSelectionStyle = function(val) {
this.setOption("selectionStyle", val);
};
this.getSelectionStyle = function() {
return this.getOption("selectionStyle");
};
this.setHighlightActiveLine = function(shouldHighlight) {
this.setOption("highlightActiveLine", shouldHighlight);
};
this.getHighlightActiveLine = function() {
return this.getOption("highlightActiveLine");
};
this.setHighlightGutterLine = function(shouldHighlight) {
this.setOption("highlightGutterLine", shouldHighlight);
};
this.getHighlightGutterLine = function() {
return this.getOption("highlightGutterLine");
};
this.setHighlightSelectedWord = function(shouldHighlight) {
this.setOption("highlightSelectedWord", shouldHighlight);
};
this.getHighlightSelectedWord = function() {
return this.$highlightSelectedWord;
};
this.setAnimatedScroll = function(shouldAnimate){
this.renderer.setAnimatedScroll(shouldAnimate);
};
this.getAnimatedScroll = function(){
return this.renderer.getAnimatedScroll();
};
this.setShowInvisibles = function(showInvisibles) {
this.renderer.setShowInvisibles(showInvisibles);
};
this.getShowInvisibles = function() {
return this.renderer.getShowInvisibles();
};
this.setDisplayIndentGuides = function(display) {
this.renderer.setDisplayIndentGuides(display);
};
this.getDisplayIndentGuides = function() {
return this.renderer.getDisplayIndentGuides();
};
this.setShowPrintMargin = function(showPrintMargin) {
this.renderer.setShowPrintMargin(showPrintMargin);
};
this.getShowPrintMargin = function() {
return this.renderer.getShowPrintMargin();
};
this.setPrintMarginColumn = function(showPrintMargin) {
this.renderer.setPrintMarginColumn(showPrintMargin);
};
this.getPrintMarginColumn = function() {
return this.renderer.getPrintMarginColumn();
};
this.setReadOnly = function(readOnly) {
this.setOption("readOnly", readOnly);
};
this.getReadOnly = function() {
return this.getOption("readOnly");
};
this.setBehavioursEnabled = function (enabled) {
this.setOption("behavioursEnabled", enabled);
};
this.getBehavioursEnabled = function () {
return this.getOption("behavioursEnabled");
};
this.setWrapBehavioursEnabled = function (enabled) {
this.setOption("wrapBehavioursEnabled", enabled);
};
this.getWrapBehavioursEnabled = function () {
return this.getOption("wrapBehavioursEnabled");
};
this.setShowFoldWidgets = function(show) {
this.setOption("showFoldWidgets", show);
};
this.getShowFoldWidgets = function() {
return this.getOption("showFoldWidgets");
};
this.setFadeFoldWidgets = function(fade) {
this.setOption("fadeFoldWidgets", fade);
};
this.getFadeFoldWidgets = function() {
return this.getOption("fadeFoldWidgets");
};
this.remove = function(dir) {
if (this.selection.isEmpty()){
if (dir == "left")
this.selection.selectLeft();
else
this.selection.selectRight();
}
var range = this.getSelectionRange();
if (this.getBehavioursEnabled()) {
var session = this.session;
var state = session.getState(range.start.row);
var new_range = session.getMode().transformAction(state, 'deletion', this, session, range);
if (range.end.column === 0) {
var text = session.getTextRange(range);
if (text[text.length - 1] == "\n") {
var line = session.getLine(range.end.row);
if (/^\s+$/.test(line)) {
range.end.column = line.length;
}
}
}
if (new_range)
range = new_range;
}
this.session.remove(range);
this.clearSelection();
};
this.removeWordRight = function() {
if (this.selection.isEmpty())
this.selection.selectWordRight();
this.session.remove(this.getSelectionRange());
this.clearSelection();
};
this.removeWordLeft = function() {
if (this.selection.isEmpty())
this.selection.selectWordLeft();
this.session.remove(this.getSelectionRange());
this.clearSelection();
};
this.removeToLineStart = function() {
if (this.selection.isEmpty())
this.selection.selectLineStart();
this.session.remove(this.getSelectionRange());
this.clearSelection();
};
this.removeToLineEnd = function() {
if (this.selection.isEmpty())
this.selection.selectLineEnd();
var range = this.getSelectionRange();
if (range.start.column == range.end.column && range.start.row == range.end.row) {
range.end.column = 0;
range.end.row++;
}
this.session.remove(range);
this.clearSelection();
};
this.splitLine = function() {
if (!this.selection.isEmpty()) {
this.session.remove(this.getSelectionRange());
this.clearSelection();
}
var cursor = this.getCursorPosition();
this.insert("\n");
this.moveCursorToPosition(cursor);
};
this.transposeLetters = function() {
if (!this.selection.isEmpty()) {
return;
}
var cursor = this.getCursorPosition();
var column = cursor.column;
if (column === 0)
return;
var line = this.session.getLine(cursor.row);
var swap, range;
if (column < line.length) {
swap = line.charAt(column) + line.charAt(column-1);
range = new Range(cursor.row, column-1, cursor.row, column+1);
}
else {
swap = line.charAt(column-1) + line.charAt(column-2);
range = new Range(cursor.row, column-2, cursor.row, column);
}
this.session.replace(range, swap);
};
this.toLowerCase = function() {
var originalRange = this.getSelectionRange();
if (this.selection.isEmpty()) {
this.selection.selectWord();
}
var range = this.getSelectionRange();
var text = this.session.getTextRange(range);
this.session.replace(range, text.toLowerCase());
this.selection.setSelectionRange(originalRange);
};
this.toUpperCase = function() {
var originalRange = this.getSelectionRange();
if (this.selection.isEmpty()) {
this.selection.selectWord();
}
var range = this.getSelectionRange();
var text = this.session.getTextRange(range);
this.session.replace(range, text.toUpperCase());
this.selection.setSelectionRange(originalRange);
};
this.indent = function() {
var session = this.session;
var range = this.getSelectionRange();
if (range.start.row < range.end.row) {
var rows = this.$getSelectedRows();
session.indentRows(rows.first, rows.last, "\t");
return;
} else if (range.start.column < range.end.column) {
var text = session.getTextRange(range);
if (!/^\s+$/.test(text)) {
var rows = this.$getSelectedRows();
session.indentRows(rows.first, rows.last, "\t");
return;
}
}
var line = session.getLine(range.start.row);
var position = range.start;
var size = session.getTabSize();
var column = session.documentToScreenColumn(position.row, position.column);
if (this.session.getUseSoftTabs()) {
var count = (size - column % size);
var indentString = lang.stringRepeat(" ", count);
} else {
var count = column % size;
while (line[range.start.column] == " " && count) {
range.start.column--;
count--;
}
this.selection.setSelectionRange(range);
indentString = "\t";
}
return this.insert(indentString);
};
this.blockIndent = function() {
var rows = this.$getSelectedRows();
this.session.indentRows(rows.first, rows.last, "\t");
};
this.blockOutdent = function() {
var selection = this.session.getSelection();
this.session.outdentRows(selection.getRange());
};
this.sortLines = function() {
var rows = this.$getSelectedRows();
var session = this.session;
var lines = [];
for (i = rows.first; i <= rows.last; i++)
lines.push(session.getLine(i));
lines.sort(function(a, b) {
if (a.toLowerCase() < b.toLowerCase()) return -1;
if (a.toLowerCase() > b.toLowerCase()) return 1;
return 0;
});
var deleteRange = new Range(0, 0, 0, 0);
for (var i = rows.first; i <= rows.last; i++) {
var line = session.getLine(i);
deleteRange.start.row = i;
deleteRange.end.row = i;
deleteRange.end.column = line.length;
session.replace(deleteRange, lines[i-rows.first]);
}
};
this.toggleCommentLines = function() {
var state = this.session.getState(this.getCursorPosition().row);
var rows = this.$getSelectedRows();
this.session.getMode().toggleCommentLines(state, this.session, rows.first, rows.last);
};
this.toggleBlockComment = function() {
var cursor = this.getCursorPosition();
var state = this.session.getState(cursor.row);
var range = this.getSelectionRange();
this.session.getMode().toggleBlockComment(state, this.session, range, cursor);
};
this.getNumberAt = function(row, column) {
var _numberRx = /[\-]?[0-9]+(?:\.[0-9]+)?/g;
_numberRx.lastIndex = 0;
var s = this.session.getLine(row);
while (_numberRx.lastIndex < column) {
var m = _numberRx.exec(s);
if(m.index <= column && m.index+m[0].length >= column){
var number = {
value: m[0],
start: m.index,
end: m.index+m[0].length
};
return number;
}
}
return null;
};
this.modifyNumber = function(amount) {
var row = this.selection.getCursor().row;
var column = this.selection.getCursor().column;
var charRange = new Range(row, column-1, row, column);
var c = this.session.getTextRange(charRange);
if (!isNaN(parseFloat(c)) && isFinite(c)) {
var nr = this.getNumberAt(row, column);
if (nr) {
var fp = nr.value.indexOf(".") >= 0 ? nr.start + nr.value.indexOf(".") + 1 : nr.end;
var decimals = nr.start + nr.value.length - fp;
var t = parseFloat(nr.value);
t *= Math.pow(10, decimals);
if(fp !== nr.end && column < fp){
amount *= Math.pow(10, nr.end - column - 1);
} else {
amount *= Math.pow(10, nr.end - column);
}
t += amount;
t /= Math.pow(10, decimals);
var nnr = t.toFixed(decimals);
var replaceRange = new Range(row, nr.start, row, nr.end);
this.session.replace(replaceRange, nnr);
this.moveCursorTo(row, Math.max(nr.start +1, column + nnr.length - nr.value.length));
}
}
};
this.removeLines = function() {
var rows = this.$getSelectedRows();
var range;
if (rows.first === 0 || rows.last+1 < this.session.getLength())
range = new Range(rows.first, 0, rows.last+1, 0);
else
range = new Range(
rows.first-1, this.session.getLine(rows.first-1).length,
rows.last, this.session.getLine(rows.last).length
);
this.session.remove(range);
this.clearSelection();
};
this.duplicateSelection = function() {
var sel = this.selection;
var doc = this.session;
var range = sel.getRange();
var reverse = sel.isBackwards();
if (range.isEmpty()) {
var row = range.start.row;
doc.duplicateLines(row, row);
} else {
var point = reverse ? range.start : range.end;
var endPoint = doc.insert(point, doc.getTextRange(range), false);
range.start = point;
range.end = endPoint;
sel.setSelectionRange(range, reverse);
}
};
this.moveLinesDown = function() {
this.$moveLines(function(firstRow, lastRow) {
return this.session.moveLinesDown(firstRow, lastRow);
});
};
this.moveLinesUp = function() {
this.$moveLines(function(firstRow, lastRow) {
return this.session.moveLinesUp(firstRow, lastRow);
});
};
this.moveText = function(range, toPosition, copy) {
return this.session.moveText(range, toPosition, copy);
};
this.copyLinesUp = function() {
this.$moveLines(function(firstRow, lastRow) {
this.session.duplicateLines(firstRow, lastRow);
return 0;
});
};
this.copyLinesDown = function() {
this.$moveLines(function(firstRow, lastRow) {
return this.session.duplicateLines(firstRow, lastRow);
});
};
this.$moveLines = function(mover) {
var selection = this.selection;
if (!selection.inMultiSelectMode || this.inVirtualSelectionMode) {
var range = selection.toOrientedRange();
var rows = this.$getSelectedRows(range);
var linesMoved = mover.call(this, rows.first, rows.last);
range.moveBy(linesMoved, 0);
selection.fromOrientedRange(range);
} else {
var ranges = selection.rangeList.ranges;
selection.rangeList.detach(this.session);
for (var i = ranges.length; i--; ) {
var rangeIndex = i;
var rows = ranges[i].collapseRows();
var last = rows.end.row;
var first = rows.start.row;
while (i--) {
rows = ranges[i].collapseRows();
if (first - rows.end.row <= 1)
first = rows.end.row;
else
break;
}
i++;
var linesMoved = mover.call(this, first, last);
while (rangeIndex >= i) {
ranges[rangeIndex].moveBy(linesMoved, 0);
rangeIndex--;
}
}
selection.fromOrientedRange(selection.ranges[0]);
selection.rangeList.attach(this.session);
}
};
this.$getSelectedRows = function() {
var range = this.getSelectionRange().collapseRows();
return {
first: this.session.getRowFoldStart(range.start.row),
last: this.session.getRowFoldEnd(range.end.row)
};
};
this.onCompositionStart = function(text) {
this.renderer.showComposition(this.getCursorPosition());
};
this.onCompositionUpdate = function(text) {
this.renderer.setCompositionText(text);
};
this.onCompositionEnd = function() {
this.renderer.hideComposition();
};
this.getFirstVisibleRow = function() {
return this.renderer.getFirstVisibleRow();
};
this.getLastVisibleRow = function() {
return this.renderer.getLastVisibleRow();
};
this.isRowVisible = function(row) {
return (row >= this.getFirstVisibleRow() && row <= this.getLastVisibleRow());
};
this.isRowFullyVisible = function(row) {
return (row >= this.renderer.getFirstFullyVisibleRow() && row <= this.renderer.getLastFullyVisibleRow());
};
this.$getVisibleRowCount = function() {
return this.renderer.getScrollBottomRow() - this.renderer.getScrollTopRow() + 1;
};
this.$moveByPage = function(dir, select) {
var renderer = this.renderer;
var config = this.renderer.layerConfig;
var rows = dir * Math.floor(config.height / config.lineHeight);
this.$blockScrolling++;
if (select === true) {
this.selection.$moveSelection(function(){
this.moveCursorBy(rows, 0);
});
} else if (select === false) {
this.selection.moveCursorBy(rows, 0);
this.selection.clearSelection();
}
this.$blockScrolling--;
var scrollTop = renderer.scrollTop;
renderer.scrollBy(0, rows * config.lineHeight);
if (select != null)
renderer.scrollCursorIntoView(null, 0.5);
renderer.animateScrolling(scrollTop);
};
this.selectPageDown = function() {
this.$moveByPage(1, true);
};
this.selectPageUp = function() {
this.$moveByPage(-1, true);
};
this.gotoPageDown = function() {
this.$moveByPage(1, false);
};
this.gotoPageUp = function() {
this.$moveByPage(-1, false);
};
this.scrollPageDown = function() {
this.$moveByPage(1);
};
this.scrollPageUp = function() {
this.$moveByPage(-1);
};
this.scrollToRow = function(row) {
this.renderer.scrollToRow(row);
};
this.scrollToLine = function(line, center, animate, callback) {
this.renderer.scrollToLine(line, center, animate, callback);
};
this.centerSelection = function() {
var range = this.getSelectionRange();
var pos = {
row: Math.floor(range.start.row + (range.end.row - range.start.row) / 2),
column: Math.floor(range.start.column + (range.end.column - range.start.column) / 2)
};
this.renderer.alignCursor(pos, 0.5);
};
this.getCursorPosition = function() {
return this.selection.getCursor();
};
this.getCursorPositionScreen = function() {
return this.session.documentToScreenPosition(this.getCursorPosition());
};
this.getSelectionRange = function() {
return this.selection.getRange();
};
this.selectAll = function() {
this.$blockScrolling += 1;
this.selection.selectAll();
this.$blockScrolling -= 1;
};
this.clearSelection = function() {
this.selection.clearSelection();
};
this.moveCursorTo = function(row, column) {
this.selection.moveCursorTo(row, column);
};
this.moveCursorToPosition = function(pos) {
this.selection.moveCursorToPosition(pos);
};
this.jumpToMatching = function(select, expand) {
var cursor = this.getCursorPosition();
var iterator = new TokenIterator(this.session, cursor.row, cursor.column);
var prevToken = iterator.getCurrentToken();
var token = prevToken || iterator.stepForward();
if (!token) return;
var matchType;
var found = false;
var depth = {};
var i = cursor.column - token.start;
var bracketType;
var brackets = {
")": "(",
"(": "(",
"]": "[",
"[": "[",
"{": "{",
"}": "{"
};
do {
if (token.value.match(/[{}()\[\]]/g)) {
for (; i < token.value.length && !found; i++) {
if (!brackets[token.value[i]]) {
continue;
}
bracketType = brackets[token.value[i]] + '.' + token.type.replace("rparen", "lparen");
if (isNaN(depth[bracketType])) {
depth[bracketType] = 0;
}
switch (token.value[i]) {
case '(':
case '[':
case '{':
depth[bracketType]++;
break;
case ')':
case ']':
case '}':
depth[bracketType]--;
if (depth[bracketType] === -1) {
matchType = 'bracket';
found = true;
}
break;
}
}
}
else if (token && token.type.indexOf('tag-name') !== -1) {
if (isNaN(depth[token.value])) {
depth[token.value] = 0;
}
if (prevToken.value === '<') {
depth[token.value]++;
}
else if (prevToken.value === '') {
depth[token.value]--;
}
if (depth[token.value] === -1) {
matchType = 'tag';
found = true;
}
}
if (!found) {
prevToken = token;
token = iterator.stepForward();
i = 0;
}
} while (token && !found);
if (!matchType)
return;
var range, pos;
if (matchType === 'bracket') {
range = this.session.getBracketRange(cursor);
if (!range) {
range = new Range(
iterator.getCurrentTokenRow(),
iterator.getCurrentTokenColumn() + i - 1,
iterator.getCurrentTokenRow(),
iterator.getCurrentTokenColumn() + i - 1
);
pos = range.start;
if (expand || pos.row === cursor.row && Math.abs(pos.column - cursor.column) < 2)
range = this.session.getBracketRange(pos);
}
}
else if (matchType === 'tag') {
if (token && token.type.indexOf('tag-name') !== -1)
var tag = token.value;
else
return;
range = new Range(
iterator.getCurrentTokenRow(),
iterator.getCurrentTokenColumn() - 2,
iterator.getCurrentTokenRow(),
iterator.getCurrentTokenColumn() - 2
);
if (range.compare(cursor.row, cursor.column) === 0) {
found = false;
do {
token = prevToken;
prevToken = iterator.stepBackward();
if (prevToken) {
if (prevToken.type.indexOf('tag-close') !== -1) {
range.setEnd(iterator.getCurrentTokenRow(), iterator.getCurrentTokenColumn() + 1);
}
if (token.value === tag && token.type.indexOf('tag-name') !== -1) {
if (prevToken.value === '<') {
depth[tag]++;
}
else if (prevToken.value === '') {
depth[tag]--;
}
if (depth[tag] === 0)
found = true;
}
}
} while (prevToken && !found);
}
if (token && token.type.indexOf('tag-name')) {
pos = range.start;
if (pos.row == cursor.row && Math.abs(pos.column - cursor.column) < 2)
pos = range.end;
}
}
pos = range && range.cursor || pos;
if (pos) {
if (select) {
if (range && expand) {
this.selection.setRange(range);
} else if (range && range.isEqual(this.getSelectionRange())) {
this.clearSelection();
} else {
this.selection.selectTo(pos.row, pos.column);
}
} else {
this.selection.moveTo(pos.row, pos.column);
}
}
};
this.gotoLine = function(lineNumber, column, animate) {
this.selection.clearSelection();
this.session.unfold({row: lineNumber - 1, column: column || 0});
this.$blockScrolling += 1;
this.exitMultiSelectMode && this.exitMultiSelectMode();
this.moveCursorTo(lineNumber - 1, column || 0);
this.$blockScrolling -= 1;
if (!this.isRowFullyVisible(lineNumber - 1))
this.scrollToLine(lineNumber - 1, true, animate);
};
this.navigateTo = function(row, column) {
this.selection.moveTo(row, column);
};
this.navigateUp = function(times) {
if (this.selection.isMultiLine() && !this.selection.isBackwards()) {
var selectionStart = this.selection.anchor.getPosition();
return this.moveCursorToPosition(selectionStart);
}
this.selection.clearSelection();
this.selection.moveCursorBy(-times || -1, 0);
};
this.navigateDown = function(times) {
if (this.selection.isMultiLine() && this.selection.isBackwards()) {
var selectionEnd = this.selection.anchor.getPosition();
return this.moveCursorToPosition(selectionEnd);
}
this.selection.clearSelection();
this.selection.moveCursorBy(times || 1, 0);
};
this.navigateLeft = function(times) {
if (!this.selection.isEmpty()) {
var selectionStart = this.getSelectionRange().start;
this.moveCursorToPosition(selectionStart);
}
else {
times = times || 1;
while (times--) {
this.selection.moveCursorLeft();
}
}
this.clearSelection();
};
this.navigateRight = function(times) {
if (!this.selection.isEmpty()) {
var selectionEnd = this.getSelectionRange().end;
this.moveCursorToPosition(selectionEnd);
}
else {
times = times || 1;
while (times--) {
this.selection.moveCursorRight();
}
}
this.clearSelection();
};
this.navigateLineStart = function() {
this.selection.moveCursorLineStart();
this.clearSelection();
};
this.navigateLineEnd = function() {
this.selection.moveCursorLineEnd();
this.clearSelection();
};
this.navigateFileEnd = function() {
this.selection.moveCursorFileEnd();
this.clearSelection();
};
this.navigateFileStart = function() {
this.selection.moveCursorFileStart();
this.clearSelection();
};
this.navigateWordRight = function() {
this.selection.moveCursorWordRight();
this.clearSelection();
};
this.navigateWordLeft = function() {
this.selection.moveCursorWordLeft();
this.clearSelection();
};
this.replace = function(replacement, options) {
if (options)
this.$search.set(options);
var range = this.$search.find(this.session);
var replaced = 0;
if (!range)
return replaced;
if (this.$tryReplace(range, replacement)) {
replaced = 1;
}
if (range !== null) {
this.selection.setSelectionRange(range);
this.renderer.scrollSelectionIntoView(range.start, range.end);
}
return replaced;
};
this.replaceAll = function(replacement, options) {
if (options) {
this.$search.set(options);
}
var ranges = this.$search.findAll(this.session);
var replaced = 0;
if (!ranges.length)
return replaced;
this.$blockScrolling += 1;
var selection = this.getSelectionRange();
this.selection.moveTo(0, 0);
for (var i = ranges.length - 1; i >= 0; --i) {
if(this.$tryReplace(ranges[i], replacement)) {
replaced++;
}
}
this.selection.setSelectionRange(selection);
this.$blockScrolling -= 1;
return replaced;
};
this.$tryReplace = function(range, replacement) {
var input = this.session.getTextRange(range);
replacement = this.$search.replace(input, replacement);
if (replacement !== null) {
range.end = this.session.replace(range, replacement);
return range;
} else {
return null;
}
};
this.getLastSearchOptions = function() {
return this.$search.getOptions();
};
this.find = function(needle, options, animate) {
if (!options)
options = {};
if (typeof needle == "string" || needle instanceof RegExp)
options.needle = needle;
else if (typeof needle == "object")
oop.mixin(options, needle);
var range = this.selection.getRange();
if (options.needle == null) {
needle = this.session.getTextRange(range)
|| this.$search.$options.needle;
if (!needle) {
range = this.session.getWordRange(range.start.row, range.start.column);
needle = this.session.getTextRange(range);
}
this.$search.set({needle: needle});
}
this.$search.set(options);
if (!options.start)
this.$search.set({start: range});
var newRange = this.$search.find(this.session);
if (options.preventScroll)
return newRange;
if (newRange) {
this.revealRange(newRange, animate);
return newRange;
}
if (options.backwards)
range.start = range.end;
else
range.end = range.start;
this.selection.setRange(range);
};
this.findNext = function(options, animate) {
this.find({skipCurrent: true, backwards: false}, options, animate);
};
this.findPrevious = function(options, animate) {
this.find(options, {skipCurrent: true, backwards: true}, animate);
};
this.revealRange = function(range, animate) {
this.$blockScrolling += 1;
this.session.unfold(range);
this.selection.setSelectionRange(range);
this.$blockScrolling -= 1;
var scrollTop = this.renderer.scrollTop;
this.renderer.scrollSelectionIntoView(range.start, range.end, 0.5);
if (animate !== false)
this.renderer.animateScrolling(scrollTop);
};
this.undo = function() {
this.$blockScrolling++;
this.session.getUndoManager().undo();
this.$blockScrolling--;
this.renderer.scrollCursorIntoView(null, 0.5);
};
this.redo = function() {
this.$blockScrolling++;
this.session.getUndoManager().redo();
this.$blockScrolling--;
this.renderer.scrollCursorIntoView(null, 0.5);
};
this.destroy = function() {
this.renderer.destroy();
this._signal("destroy", this);
if (this.session) {
this.session.destroy();
}
};
this.setAutoScrollEditorIntoView = function(enable) {
if (!enable)
return;
var rect;
var self = this;
var shouldScroll = false;
if (!this.$scrollAnchor)
this.$scrollAnchor = document.createElement("div");
var scrollAnchor = this.$scrollAnchor;
scrollAnchor.style.cssText = "position:absolute";
this.container.insertBefore(scrollAnchor, this.container.firstChild);
var onChangeSelection = this.on("changeSelection", function() {
shouldScroll = true;
});
var onBeforeRender = this.renderer.on("beforeRender", function() {
if (shouldScroll)
rect = self.renderer.container.getBoundingClientRect();
});
var onAfterRender = this.renderer.on("afterRender", function() {
if (shouldScroll && rect && (self.isFocused()
|| self.searchBox && self.searchBox.isFocused())
) {
var renderer = self.renderer;
var pos = renderer.$cursorLayer.$pixelPos;
var config = renderer.layerConfig;
var top = pos.top - config.offset;
if (pos.top >= 0 && top + rect.top < 0) {
shouldScroll = true;
} else if (pos.top < config.height &&
pos.top + rect.top + config.lineHeight > window.innerHeight) {
shouldScroll = false;
} else {
shouldScroll = null;
}
if (shouldScroll != null) {
scrollAnchor.style.top = top + "px";
scrollAnchor.style.left = pos.left + "px";
scrollAnchor.style.height = config.lineHeight + "px";
scrollAnchor.scrollIntoView(shouldScroll);
}
shouldScroll = rect = null;
}
});
this.setAutoScrollEditorIntoView = function(enable) {
if (enable)
return;
delete this.setAutoScrollEditorIntoView;
this.removeEventListener("changeSelection", onChangeSelection);
this.renderer.removeEventListener("afterRender", onAfterRender);
this.renderer.removeEventListener("beforeRender", onBeforeRender);
};
};
this.$resetCursorStyle = function() {
var style = this.$cursorStyle || "ace";
var cursorLayer = this.renderer.$cursorLayer;
if (!cursorLayer)
return;
cursorLayer.setSmoothBlinking(/smooth/.test(style));
cursorLayer.isBlinking = !this.$readOnly && style != "wide";
dom.setCssClass(cursorLayer.element, "ace_slim-cursors", /slim/.test(style));
};
}).call(Editor.prototype);
config.defineOptions(Editor.prototype, "editor", {
selectionStyle: {
set: function(style) {
this.onSelectionChange();
this._signal("changeSelectionStyle", {data: style});
},
initialValue: "line"
},
highlightActiveLine: {
set: function() {this.$updateHighlightActiveLine();},
initialValue: true
},
highlightSelectedWord: {
set: function(shouldHighlight) {this.$onSelectionChange();},
initialValue: true
},
readOnly: {
set: function(readOnly) {
this.$resetCursorStyle();
},
initialValue: false
},
cursorStyle: {
set: function(val) { this.$resetCursorStyle(); },
values: ["ace", "slim", "smooth", "wide"],
initialValue: "ace"
},
mergeUndoDeltas: {
values: [false, true, "always"],
initialValue: true
},
behavioursEnabled: {initialValue: true},
wrapBehavioursEnabled: {initialValue: true},
autoScrollEditorIntoView: {
set: function(val) {this.setAutoScrollEditorIntoView(val)}
},
hScrollBarAlwaysVisible: "renderer",
vScrollBarAlwaysVisible: "renderer",
highlightGutterLine: "renderer",
animatedScroll: "renderer",
showInvisibles: "renderer",
showPrintMargin: "renderer",
printMarginColumn: "renderer",
printMargin: "renderer",
fadeFoldWidgets: "renderer",
showFoldWidgets: "renderer",
showLineNumbers: "renderer",
showGutter: "renderer",
displayIndentGuides: "renderer",
fontSize: "renderer",
fontFamily: "renderer",
maxLines: "renderer",
minLines: "renderer",
scrollPastEnd: "renderer",
fixedWidthGutter: "renderer",
theme: "renderer",
scrollSpeed: "$mouseHandler",
dragDelay: "$mouseHandler",
dragEnabled: "$mouseHandler",
focusTimout: "$mouseHandler",
tooltipFollowsMouse: "$mouseHandler",
firstLineNumber: "session",
overwrite: "session",
newLineMode: "session",
useWorker: "session",
useSoftTabs: "session",
tabSize: "session",
wrap: "session",
foldStyle: "session",
mode: "session"
});
exports.Editor = Editor;
});
define("ace/undomanager",["require","exports","module"], function(require, exports, module) {
"use strict";
var UndoManager = function() {
this.reset();
};
(function() {
this.execute = function(options) {
var deltas = options.args[0];
this.$doc = options.args[1];
if (options.merge && this.hasUndo()){
this.dirtyCounter--;
deltas = this.$undoStack.pop().concat(deltas);
}
this.$undoStack.push(deltas);
this.$redoStack = [];
if (this.dirtyCounter < 0) {
this.dirtyCounter = NaN;
}
this.dirtyCounter++;
};
this.undo = function(dontSelect) {
var deltas = this.$undoStack.pop();
var undoSelectionRange = null;
if (deltas) {
undoSelectionRange =
this.$doc.undoChanges(deltas, dontSelect);
this.$redoStack.push(deltas);
this.dirtyCounter--;
}
return undoSelectionRange;
};
this.redo = function(dontSelect) {
var deltas = this.$redoStack.pop();
var redoSelectionRange = null;
if (deltas) {
redoSelectionRange =
this.$doc.redoChanges(deltas, dontSelect);
this.$undoStack.push(deltas);
this.dirtyCounter++;
}
return redoSelectionRange;
};
this.reset = function() {
this.$undoStack = [];
this.$redoStack = [];
this.dirtyCounter = 0;
};
this.hasUndo = function() {
return this.$undoStack.length > 0;
};
this.hasRedo = function() {
return this.$redoStack.length > 0;
};
this.markClean = function() {
this.dirtyCounter = 0;
};
this.isClean = function() {
return this.dirtyCounter === 0;
};
}).call(UndoManager.prototype);
exports.UndoManager = UndoManager;
});
define("ace/layer/gutter",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/lang","ace/lib/event_emitter"], function(require, exports, module) {
"use strict";
var dom = require("../lib/dom");
var oop = require("../lib/oop");
var lang = require("../lib/lang");
var EventEmitter = require("../lib/event_emitter").EventEmitter;
var Gutter = function(parentEl) {
this.element = dom.createElement("div");
this.element.className = "ace_layer ace_gutter-layer";
parentEl.appendChild(this.element);
this.setShowFoldWidgets(this.$showFoldWidgets);
this.gutterWidth = 0;
this.$annotations = [];
this.$updateAnnotations = this.$updateAnnotations.bind(this);
this.$cells = [];
};
(function() {
oop.implement(this, EventEmitter);
this.setSession = function(session) {
if (this.session)
this.session.removeEventListener("change", this.$updateAnnotations);
this.session = session;
if (session)
session.on("change", this.$updateAnnotations);
};
this.addGutterDecoration = function(row, className){
if (window.console)
console.warn && console.warn("deprecated use session.addGutterDecoration");
this.session.addGutterDecoration(row, className);
};
this.removeGutterDecoration = function(row, className){
if (window.console)
console.warn && console.warn("deprecated use session.removeGutterDecoration");
this.session.removeGutterDecoration(row, className);
};
this.setAnnotations = function(annotations) {
this.$annotations = [];
for (var i = 0; i < annotations.length; i++) {
var annotation = annotations[i];
var row = annotation.row;
var rowInfo = this.$annotations[row];
if (!rowInfo)
rowInfo = this.$annotations[row] = {text: []};
var annoText = annotation.text;
annoText = annoText ? lang.escapeHTML(annoText) : annotation.html || "";
if (rowInfo.text.indexOf(annoText) === -1)
rowInfo.text.push(annoText);
var type = annotation.type;
if (type == "error")
rowInfo.className = " ace_error";
else if (type == "warning" && rowInfo.className != " ace_error")
rowInfo.className = " ace_warning";
else if (type == "info" && (!rowInfo.className))
rowInfo.className = " ace_info";
}
};
this.$updateAnnotations = function (e) {
if (!this.$annotations.length)
return;
var delta = e.data;
var range = delta.range;
var firstRow = range.start.row;
var len = range.end.row - firstRow;
if (len === 0) {
} else if (delta.action == "removeText" || delta.action == "removeLines") {
this.$annotations.splice(firstRow, len + 1, null);
} else {
var args = new Array(len + 1);
args.unshift(firstRow, 1);
this.$annotations.splice.apply(this.$annotations, args);
}
};
this.update = function(config) {
var session = this.session;
var firstRow = config.firstRow;
var lastRow = Math.min(config.lastRow + config.gutterOffset, // needed to compensate for hor scollbar
session.getLength() - 1);
var fold = session.getNextFoldLine(firstRow);
var foldStart = fold ? fold.start.row : Infinity;
var foldWidgets = this.$showFoldWidgets && session.foldWidgets;
var breakpoints = session.$breakpoints;
var decorations = session.$decorations;
var firstLineNumber = session.$firstLineNumber;
var lastLineNumber = 0;
var gutterRenderer = session.gutterRenderer || this.$renderer;
var cell = null;
var index = -1;
var row = firstRow;
while (true) {
if (row > foldStart) {
row = fold.end.row + 1;
fold = session.getNextFoldLine(row, fold);
foldStart = fold ? fold.start.row : Infinity;
}
if (row > lastRow) {
while (this.$cells.length > index + 1) {
cell = this.$cells.pop();
this.element.removeChild(cell.element);
}
break;
}
cell = this.$cells[++index];
if (!cell) {
cell = {element: null, textNode: null, foldWidget: null};
cell.element = dom.createElement("div");
cell.textNode = document.createTextNode('');
cell.element.appendChild(cell.textNode);
this.element.appendChild(cell.element);
this.$cells[index] = cell;
}
var className = "ace_gutter-cell ";
if (breakpoints[row])
className += breakpoints[row];
if (decorations[row])
className += decorations[row];
if (this.$annotations[row])
className += this.$annotations[row].className;
if (cell.element.className != className)
cell.element.className = className;
var height = session.getRowLength(row) * config.lineHeight + "px";
if (height != cell.element.style.height)
cell.element.style.height = height;
if (foldWidgets) {
var c = foldWidgets[row];
if (c == null)
c = foldWidgets[row] = session.getFoldWidget(row);
}
if (c) {
if (!cell.foldWidget) {
cell.foldWidget = dom.createElement("span");
cell.element.appendChild(cell.foldWidget);
}
var className = "ace_fold-widget ace_" + c;
if (c == "start" && row == foldStart && row < fold.end.row)
className += " ace_closed";
else
className += " ace_open";
if (cell.foldWidget.className != className)
cell.foldWidget.className = className;
var height = config.lineHeight + "px";
if (cell.foldWidget.style.height != height)
cell.foldWidget.style.height = height;
} else {
if (cell.foldWidget) {
cell.element.removeChild(cell.foldWidget);
cell.foldWidget = null;
}
}
var text = lastLineNumber = gutterRenderer
? gutterRenderer.getText(session, row)
: row + firstLineNumber;
if (text != cell.textNode.data)
cell.textNode.data = text;
row++;
}
this.element.style.height = config.minHeight + "px";
if (this.$fixedWidth || session.$useWrapMode)
lastLineNumber = session.getLength() + firstLineNumber;
var gutterWidth = gutterRenderer
? gutterRenderer.getWidth(session, lastLineNumber, config)
: lastLineNumber.toString().length * config.characterWidth;
var padding = this.$padding || this.$computePadding();
gutterWidth += padding.left + padding.right;
if (gutterWidth !== this.gutterWidth && !isNaN(gutterWidth)) {
this.gutterWidth = gutterWidth;
this.element.style.width = Math.ceil(this.gutterWidth) + "px";
this._emit("changeGutterWidth", gutterWidth);
}
};
this.$fixedWidth = false;
this.$showLineNumbers = true;
this.$renderer = "";
this.setShowLineNumbers = function(show) {
this.$renderer = !show && {
getWidth: function() {return ""},
getText: function() {return ""}
};
};
this.getShowLineNumbers = function() {
return this.$showLineNumbers;
};
this.$showFoldWidgets = true;
this.setShowFoldWidgets = function(show) {
if (show)
dom.addCssClass(this.element, "ace_folding-enabled");
else
dom.removeCssClass(this.element, "ace_folding-enabled");
this.$showFoldWidgets = show;
this.$padding = null;
};
this.getShowFoldWidgets = function() {
return this.$showFoldWidgets;
};
this.$computePadding = function() {
if (!this.element.firstChild)
return {left: 0, right: 0};
var style = dom.computedStyle(this.element.firstChild);
this.$padding = {};
this.$padding.left = parseInt(style.paddingLeft) + 1 || 0;
this.$padding.right = parseInt(style.paddingRight) || 0;
return this.$padding;
};
this.getRegion = function(point) {
var padding = this.$padding || this.$computePadding();
var rect = this.element.getBoundingClientRect();
if (point.x < padding.left + rect.left)
return "markers";
if (this.$showFoldWidgets && point.x > rect.right - padding.right)
return "foldWidgets";
};
}).call(Gutter.prototype);
exports.Gutter = Gutter;
});
define("ace/layer/marker",["require","exports","module","ace/range","ace/lib/dom"], function(require, exports, module) {
"use strict";
var Range = require("../range").Range;
var dom = require("../lib/dom");
var Marker = function(parentEl) {
this.element = dom.createElement("div");
this.element.className = "ace_layer ace_marker-layer";
parentEl.appendChild(this.element);
};
(function() {
this.$padding = 0;
this.setPadding = function(padding) {
this.$padding = padding;
};
this.setSession = function(session) {
this.session = session;
};
this.setMarkers = function(markers) {
this.markers = markers;
};
this.update = function(config) {
var config = config || this.config;
if (!config)
return;
this.config = config;
var html = [];
for (var key in this.markers) {
var marker = this.markers[key];
if (!marker.range) {
marker.update(html, this, this.session, config);
continue;
}
var range = marker.range.clipRows(config.firstRow, config.lastRow);
if (range.isEmpty()) continue;
range = range.toScreenRange(this.session);
if (marker.renderer) {
var top = this.$getTop(range.start.row, config);
var left = this.$padding + range.start.column * config.characterWidth;
marker.renderer(html, range, left, top, config);
} else if (marker.type == "fullLine") {
this.drawFullLineMarker(html, range, marker.clazz, config);
} else if (marker.type == "screenLine") {
this.drawScreenLineMarker(html, range, marker.clazz, config);
} else if (range.isMultiLine()) {
if (marker.type == "text")
this.drawTextMarker(html, range, marker.clazz, config);
else
this.drawMultiLineMarker(html, range, marker.clazz, config);
} else {
this.drawSingleLineMarker(html, range, marker.clazz + " ace_start", config);
}
}
this.element.innerHTML = html.join("");
};
this.$getTop = function(row, layerConfig) {
return (row - layerConfig.firstRowScreen) * layerConfig.lineHeight;
};
this.drawTextMarker = function(stringBuilder, range, clazz, layerConfig, extraStyle) {
var row = range.start.row;
var lineRange = new Range(
row, range.start.column,
row, this.session.getScreenLastRowColumn(row)
);
this.drawSingleLineMarker(stringBuilder, lineRange, clazz + " ace_start", layerConfig, 1, extraStyle);
row = range.end.row;
lineRange = new Range(row, 0, row, range.end.column);
this.drawSingleLineMarker(stringBuilder, lineRange, clazz, layerConfig, 0, extraStyle);
for (row = range.start.row + 1; row < range.end.row; row++) {
lineRange.start.row = row;
lineRange.end.row = row;
lineRange.end.column = this.session.getScreenLastRowColumn(row);
this.drawSingleLineMarker(stringBuilder, lineRange, clazz, layerConfig, 1, extraStyle);
}
};
this.drawMultiLineMarker = function(stringBuilder, range, clazz, config, extraStyle) {
var padding = this.$padding;
var height = config.lineHeight;
var top = this.$getTop(range.start.row, config);
var left = padding + range.start.column * config.characterWidth;
extraStyle = extraStyle || "";
stringBuilder.push(
""
);
top = this.$getTop(range.end.row, config);
var width = range.end.column * config.characterWidth;
stringBuilder.push(
""
);
height = (range.end.row - range.start.row - 1) * config.lineHeight;
if (height < 0)
return;
top = this.$getTop(range.start.row + 1, config);
stringBuilder.push(
""
);
};
this.drawSingleLineMarker = function(stringBuilder, range, clazz, config, extraLength, extraStyle) {
var height = config.lineHeight;
var width = (range.end.column + (extraLength || 0) - range.start.column) * config.characterWidth;
var top = this.$getTop(range.start.row, config);
var left = this.$padding + range.start.column * config.characterWidth;
stringBuilder.push(
""
);
};
this.drawFullLineMarker = function(stringBuilder, range, clazz, config, extraStyle) {
var top = this.$getTop(range.start.row, config);
var height = config.lineHeight;
if (range.start.row != range.end.row)
height += this.$getTop(range.end.row, config) - top;
stringBuilder.push(
""
);
};
this.drawScreenLineMarker = function(stringBuilder, range, clazz, config, extraStyle) {
var top = this.$getTop(range.start.row, config);
var height = config.lineHeight;
stringBuilder.push(
""
);
};
}).call(Marker.prototype);
exports.Marker = Marker;
});
define("ace/layer/text",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/lib/useragent","ace/lib/event_emitter"], function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var dom = require("../lib/dom");
var lang = require("../lib/lang");
var useragent = require("../lib/useragent");
var EventEmitter = require("../lib/event_emitter").EventEmitter;
var Text = function(parentEl) {
this.element = dom.createElement("div");
this.element.className = "ace_layer ace_text-layer";
parentEl.appendChild(this.element);
this.$updateEolChar = this.$updateEolChar.bind(this);
};
(function() {
oop.implement(this, EventEmitter);
this.EOF_CHAR = "\xB6";
this.EOL_CHAR_LF = "\xAC";
this.EOL_CHAR_CRLF = "\xa4";
this.EOL_CHAR = this.EOL_CHAR_LF;
this.TAB_CHAR = "\u2192"; //"\u21E5";
this.SPACE_CHAR = "\xB7";
this.$padding = 0;
this.$updateEolChar = function() {
var EOL_CHAR = this.session.doc.getNewLineCharacter() == "\n"
? this.EOL_CHAR_LF
: this.EOL_CHAR_CRLF;
if (this.EOL_CHAR != EOL_CHAR) {
this.EOL_CHAR = EOL_CHAR;
return true;
}
}
this.setPadding = function(padding) {
this.$padding = padding;
this.element.style.padding = "0 " + padding + "px";
};
this.getLineHeight = function() {
return this.$fontMetrics.$characterSize.height || 0;
};
this.getCharacterWidth = function() {
return this.$fontMetrics.$characterSize.width || 0;
};
this.$setFontMetrics = function(measure) {
this.$fontMetrics = measure;
this.$fontMetrics.on("changeCharacterSize", function(e) {
this._signal("changeCharacterSize", e);
}.bind(this));
this.$pollSizeChanges();
}
this.checkForSizeChanges = function() {
this.$fontMetrics.checkForSizeChanges();
};
this.$pollSizeChanges = function() {
return this.$pollSizeChangesTimer = this.$fontMetrics.$pollSizeChanges();
};
this.setSession = function(session) {
this.session = session;
if (session)
this.$computeTabString();
};
this.showInvisibles = false;
this.setShowInvisibles = function(showInvisibles) {
if (this.showInvisibles == showInvisibles)
return false;
this.showInvisibles = showInvisibles;
this.$computeTabString();
return true;
};
this.displayIndentGuides = true;
this.setDisplayIndentGuides = function(display) {
if (this.displayIndentGuides == display)
return false;
this.displayIndentGuides = display;
this.$computeTabString();
return true;
};
this.$tabStrings = [];
this.onChangeTabSize =
this.$computeTabString = function() {
var tabSize = this.session.getTabSize();
this.tabSize = tabSize;
var tabStr = this.$tabStrings = [0];
for (var i = 1; i < tabSize + 1; i++) {
if (this.showInvisibles) {
tabStr.push(""
+ this.TAB_CHAR
+ lang.stringRepeat("\xa0", i - 1)
+ "");
} else {
tabStr.push(lang.stringRepeat("\xa0", i));
}
}
if (this.displayIndentGuides) {
this.$indentGuideRe = /\s\S| \t|\t |\s$/;
var className = "ace_indent-guide";
var spaceClass = "";
var tabClass = "";
if (this.showInvisibles) {
className += " ace_invisible";
spaceClass = " ace_invisible_space";
tabClass = " ace_invisible_tab";
var spaceContent = lang.stringRepeat(this.SPACE_CHAR, this.tabSize);
var tabContent = this.TAB_CHAR + lang.stringRepeat("\xa0", this.tabSize - 1);
} else{
var spaceContent = lang.stringRepeat("\xa0", this.tabSize);
var tabContent = spaceContent;
}
this.$tabStrings[" "] = "" + spaceContent + "";
this.$tabStrings["\t"] = "" + tabContent + "";
}
};
this.updateLines = function(config, firstRow, lastRow) {
if (this.config.lastRow != config.lastRow ||
this.config.firstRow != config.firstRow) {
this.scrollLines(config);
}
this.config = config;
var first = Math.max(firstRow, config.firstRow);
var last = Math.min(lastRow, config.lastRow);
var lineElements = this.element.childNodes;
var lineElementsIdx = 0;
for (var row = config.firstRow; row < first; row++) {
var foldLine = this.session.getFoldLine(row);
if (foldLine) {
if (foldLine.containsRow(first)) {
first = foldLine.start.row;
break;
} else {
row = foldLine.end.row;
}
}
lineElementsIdx ++;
}
var row = first;
var foldLine = this.session.getNextFoldLine(row);
var foldStart = foldLine ? foldLine.start.row : Infinity;
while (true) {
if (row > foldStart) {
row = foldLine.end.row+1;
foldLine = this.session.getNextFoldLine(row, foldLine);
foldStart = foldLine ? foldLine.start.row :Infinity;
}
if (row > last)
break;
var lineElement = lineElements[lineElementsIdx++];
if (lineElement) {
var html = [];
this.$renderLine(
html, row, !this.$useLineGroups(), row == foldStart ? foldLine : false
);
lineElement.style.height = config.lineHeight * this.session.getRowLength(row) + "px";
lineElement.innerHTML = html.join("");
}
row++;
}
};
this.scrollLines = function(config) {
var oldConfig = this.config;
this.config = config;
if (!oldConfig || oldConfig.lastRow < config.firstRow)
return this.update(config);
if (config.lastRow < oldConfig.firstRow)
return this.update(config);
var el = this.element;
if (oldConfig.firstRow < config.firstRow)
for (var row=this.session.getFoldedRowCount(oldConfig.firstRow, config.firstRow - 1); row>0; row--)
el.removeChild(el.firstChild);
if (oldConfig.lastRow > config.lastRow)
for (var row=this.session.getFoldedRowCount(config.lastRow + 1, oldConfig.lastRow); row>0; row--)
el.removeChild(el.lastChild);
if (config.firstRow < oldConfig.firstRow) {
var fragment = this.$renderLinesFragment(config, config.firstRow, oldConfig.firstRow - 1);
if (el.firstChild)
el.insertBefore(fragment, el.firstChild);
else
el.appendChild(fragment);
}
if (config.lastRow > oldConfig.lastRow) {
var fragment = this.$renderLinesFragment(config, oldConfig.lastRow + 1, config.lastRow);
el.appendChild(fragment);
}
};
this.$renderLinesFragment = function(config, firstRow, lastRow) {
var fragment = this.element.ownerDocument.createDocumentFragment();
var row = firstRow;
var foldLine = this.session.getNextFoldLine(row);
var foldStart = foldLine ? foldLine.start.row : Infinity;
while (true) {
if (row > foldStart) {
row = foldLine.end.row+1;
foldLine = this.session.getNextFoldLine(row, foldLine);
foldStart = foldLine ? foldLine.start.row : Infinity;
}
if (row > lastRow)
break;
var container = dom.createElement("div");
var html = [];
this.$renderLine(html, row, false, row == foldStart ? foldLine : false);
container.innerHTML = html.join("");
if (this.$useLineGroups()) {
container.className = 'ace_line_group';
fragment.appendChild(container);
container.style.height = config.lineHeight * this.session.getRowLength(row) + "px";
} else {
while(container.firstChild)
fragment.appendChild(container.firstChild);
}
row++;
}
return fragment;
};
this.update = function(config) {
this.config = config;
var html = [];
var firstRow = config.firstRow, lastRow = config.lastRow;
var row = firstRow;
var foldLine = this.session.getNextFoldLine(row);
var foldStart = foldLine ? foldLine.start.row : Infinity;
while (true) {
if (row > foldStart) {
row = foldLine.end.row+1;
foldLine = this.session.getNextFoldLine(row, foldLine);
foldStart = foldLine ? foldLine.start.row :Infinity;
}
if (row > lastRow)
break;
if (this.$useLineGroups())
html.push("")
this.$renderLine(html, row, false, row == foldStart ? foldLine : false);
if (this.$useLineGroups())
html.push("
"); // end the line group
row++;
}
this.element.innerHTML = html.join("");
};
this.$textToken = {
"text": true,
"rparen": true,
"lparen": true
};
this.$renderToken = function(stringBuilder, screenColumn, token, value) {
var self = this;
var replaceReg = /\t|&|<|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\u3000\uFEFF])|[\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3000-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]/g;
var replaceFunc = function(c, a, b, tabIdx, idx4) {
if (a) {
return self.showInvisibles ?
"" + lang.stringRepeat(self.SPACE_CHAR, c.length) + "" :
lang.stringRepeat("\xa0", c.length);
} else if (c == "&") {
return "&";
} else if (c == "<") {
return "<";
} else if (c == "\t") {
var tabSize = self.session.getScreenTabSize(screenColumn + tabIdx);
screenColumn += tabSize - 1;
return self.$tabStrings[tabSize];
} else if (c == "\u3000") {
var classToUse = self.showInvisibles ? "ace_cjk ace_invisible ace_invisible_space" : "ace_cjk";
var space = self.showInvisibles ? self.SPACE_CHAR : "";
screenColumn += 1;
return "" + space + "";
} else if (b) {
return "" + self.SPACE_CHAR + "";
} else {
screenColumn += 1;
return "" + c + "";
}
};
var output = value.replace(replaceReg, replaceFunc);
if (!this.$textToken[token.type]) {
var classes = "ace_" + token.type.replace(/\./g, " ace_");
var style = "";
if (token.type == "fold")
style = " style='width:" + (token.value.length * this.config.characterWidth) + "px;' ";
stringBuilder.push("", output, "");
}
else {
stringBuilder.push(output);
}
return screenColumn + value.length;
};
this.renderIndentGuide = function(stringBuilder, value, max) {
var cols = value.search(this.$indentGuideRe);
if (cols <= 0 || cols >= max)
return value;
if (value[0] == " ") {
cols -= cols % this.tabSize;
stringBuilder.push(lang.stringRepeat(this.$tabStrings[" "], cols/this.tabSize));
return value.substr(cols);
} else if (value[0] == "\t") {
stringBuilder.push(lang.stringRepeat(this.$tabStrings["\t"], cols));
return value.substr(cols);
}
return value;
};
this.$renderWrappedLine = function(stringBuilder, tokens, splits, onlyContents) {
var chars = 0;
var split = 0;
var splitChars = splits[0];
var screenColumn = 0;
for (var i = 0; i < tokens.length; i++) {
var token = tokens[i];
var value = token.value;
if (i == 0 && this.displayIndentGuides) {
chars = value.length;
value = this.renderIndentGuide(stringBuilder, value, splitChars);
if (!value)
continue;
chars -= value.length;
}
if (chars + value.length < splitChars) {
screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value);
chars += value.length;
} else {
while (chars + value.length >= splitChars) {
screenColumn = this.$renderToken(
stringBuilder, screenColumn,
token, value.substring(0, splitChars - chars)
);
value = value.substring(splitChars - chars);
chars = splitChars;
if (!onlyContents) {
stringBuilder.push("",
"
"
);
}
split ++;
screenColumn = 0;
splitChars = splits[split] || Number.MAX_VALUE;
}
if (value.length != 0) {
chars += value.length;
screenColumn = this.$renderToken(
stringBuilder, screenColumn, token, value
);
}
}
}
};
this.$renderSimpleLine = function(stringBuilder, tokens) {
var screenColumn = 0;
var token = tokens[0];
var value = token.value;
if (this.displayIndentGuides)
value = this.renderIndentGuide(stringBuilder, value);
if (value)
screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value);
for (var i = 1; i < tokens.length; i++) {
token = tokens[i];
value = token.value;
screenColumn = this.$renderToken(stringBuilder, screenColumn, token, value);
}
};
this.$renderLine = function(stringBuilder, row, onlyContents, foldLine) {
if (!foldLine && foldLine != false)
foldLine = this.session.getFoldLine(row);
if (foldLine)
var tokens = this.$getFoldLineTokens(row, foldLine);
else
var tokens = this.session.getTokens(row);
if (!onlyContents) {
stringBuilder.push(
"
"
);
}
if (tokens.length) {
var splits = this.session.getRowSplitData(row);
if (splits && splits.length)
this.$renderWrappedLine(stringBuilder, tokens, splits, onlyContents);
else
this.$renderSimpleLine(stringBuilder, tokens);
}
if (this.showInvisibles) {
if (foldLine)
row = foldLine.end.row
stringBuilder.push(
"",
row == this.session.getLength() - 1 ? this.EOF_CHAR : this.EOL_CHAR,
""
);
}
if (!onlyContents)
stringBuilder.push("
");
};
this.$getFoldLineTokens = function(row, foldLine) {
var session = this.session;
var renderTokens = [];
function addTokens(tokens, from, to) {
var idx = 0, col = 0;
while ((col + tokens[idx].value.length) < from) {
col += tokens[idx].value.length;
idx++;
if (idx == tokens.length)
return;
}
if (col != from) {
var value = tokens[idx].value.substring(from - col);
if (value.length > (to - from))
value = value.substring(0, to - from);
renderTokens.push({
type: tokens[idx].type,
value: value
});
col = from + value.length;
idx += 1;
}
while (col < to && idx < tokens.length) {
var value = tokens[idx].value;
if (value.length + col > to) {
renderTokens.push({
type: tokens[idx].type,
value: value.substring(0, to - col)
});
} else
renderTokens.push(tokens[idx]);
col += value.length;
idx += 1;
}
}
var tokens = session.getTokens(row);
foldLine.walk(function(placeholder, row, column, lastColumn, isNewRow) {
if (placeholder != null) {
renderTokens.push({
type: "fold",
value: placeholder
});
} else {
if (isNewRow)
tokens = session.getTokens(row);
if (tokens.length)
addTokens(tokens, lastColumn, column);
}
}, foldLine.end.row, this.session.getLine(foldLine.end.row).length);
return renderTokens;
};
this.$useLineGroups = function() {
return this.session.getUseWrapMode();
};
this.destroy = function() {
clearInterval(this.$pollSizeChangesTimer);
if (this.$measureNode)
this.$measureNode.parentNode.removeChild(this.$measureNode);
delete this.$measureNode;
};
}).call(Text.prototype);
exports.Text = Text;
});
define("ace/layer/cursor",["require","exports","module","ace/lib/dom"], function(require, exports, module) {
"use strict";
var dom = require("../lib/dom");
var IE8;
var Cursor = function(parentEl) {
this.element = dom.createElement("div");
this.element.className = "ace_layer ace_cursor-layer";
parentEl.appendChild(this.element);
if (IE8 === undefined)
IE8 = "opacity" in this.element;
this.isVisible = false;
this.isBlinking = true;
this.blinkInterval = 1000;
this.smoothBlinking = false;
this.cursors = [];
this.cursor = this.addCursor();
dom.addCssClass(this.element, "ace_hidden-cursors");
this.$updateCursors = this.$updateVisibility.bind(this);
};
(function() {
this.$updateVisibility = function(val) {
var cursors = this.cursors;
for (var i = cursors.length; i--; )
cursors[i].style.visibility = val ? "" : "hidden";
};
this.$updateOpacity = function(val) {
var cursors = this.cursors;
for (var i = cursors.length; i--; )
cursors[i].style.opacity = val ? "" : "0";
};
this.$padding = 0;
this.setPadding = function(padding) {
this.$padding = padding;
};
this.setSession = function(session) {
this.session = session;
};
this.setBlinking = function(blinking) {
if (blinking != this.isBlinking){
this.isBlinking = blinking;
this.restartTimer();
}
};
this.setBlinkInterval = function(blinkInterval) {
if (blinkInterval != this.blinkInterval){
this.blinkInterval = blinkInterval;
this.restartTimer();
}
};
this.setSmoothBlinking = function(smoothBlinking) {
if (smoothBlinking != this.smoothBlinking && !IE8) {
this.smoothBlinking = smoothBlinking;
dom.setCssClass(this.element, "ace_smooth-blinking", smoothBlinking);
this.$updateCursors(true);
this.$updateCursors = (smoothBlinking
? this.$updateOpacity
: this.$updateVisibility).bind(this);
this.restartTimer();
}
};
this.addCursor = function() {
var el = dom.createElement("div");
el.className = "ace_cursor";
this.element.appendChild(el);
this.cursors.push(el);
return el;
};
this.removeCursor = function() {
if (this.cursors.length > 1) {
var el = this.cursors.pop();
el.parentNode.removeChild(el);
return el;
}
};
this.hideCursor = function() {
this.isVisible = false;
dom.addCssClass(this.element, "ace_hidden-cursors");
this.restartTimer();
};
this.showCursor = function() {
this.isVisible = true;
dom.removeCssClass(this.element, "ace_hidden-cursors");
this.restartTimer();
};
this.restartTimer = function() {
var update = this.$updateCursors;
clearInterval(this.intervalId);
clearTimeout(this.timeoutId);
if (this.smoothBlinking) {
dom.removeCssClass(this.element, "ace_smooth-blinking");
}
update(true);
if (!this.isBlinking || !this.blinkInterval || !this.isVisible)
return;
if (this.smoothBlinking) {
setTimeout(function(){
dom.addCssClass(this.element, "ace_smooth-blinking");
}.bind(this));
}
var blink = function(){
this.timeoutId = setTimeout(function() {
update(false);
}, 0.6 * this.blinkInterval);
}.bind(this);
this.intervalId = setInterval(function() {
update(true);
blink();
}, this.blinkInterval);
blink();
};
this.getPixelPosition = function(position, onScreen) {
if (!this.config || !this.session)
return {left : 0, top : 0};
if (!position)
position = this.session.selection.getCursor();
var pos = this.session.documentToScreenPosition(position);
var cursorLeft = this.$padding + pos.column * this.config.characterWidth;
var cursorTop = (pos.row - (onScreen ? this.config.firstRowScreen : 0)) *
this.config.lineHeight;
return {left : cursorLeft, top : cursorTop};
};
this.update = function(config) {
this.config = config;
var selections = this.session.$selectionMarkers;
var i = 0, cursorIndex = 0;
if (selections === undefined || selections.length === 0){
selections = [{cursor: null}];
}
for (var i = 0, n = selections.length; i < n; i++) {
var pixelPos = this.getPixelPosition(selections[i].cursor, true);
if ((pixelPos.top > config.height + config.offset ||
pixelPos.top < 0) && i > 1) {
continue;
}
var style = (this.cursors[cursorIndex++] || this.addCursor()).style;
style.left = pixelPos.left + "px";
style.top = pixelPos.top + "px";
style.width = config.characterWidth + "px";
style.height = config.lineHeight + "px";
}
while (this.cursors.length > cursorIndex)
this.removeCursor();
var overwrite = this.session.getOverwrite();
this.$setOverwrite(overwrite);
this.$pixelPos = pixelPos;
this.restartTimer();
};
this.$setOverwrite = function(overwrite) {
if (overwrite != this.overwrite) {
this.overwrite = overwrite;
if (overwrite)
dom.addCssClass(this.element, "ace_overwrite-cursors");
else
dom.removeCssClass(this.element, "ace_overwrite-cursors");
}
};
this.destroy = function() {
clearInterval(this.intervalId);
clearTimeout(this.timeoutId);
};
}).call(Cursor.prototype);
exports.Cursor = Cursor;
});
define("ace/scrollbar",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/event","ace/lib/event_emitter"], function(require, exports, module) {
"use strict";
var oop = require("./lib/oop");
var dom = require("./lib/dom");
var event = require("./lib/event");
var EventEmitter = require("./lib/event_emitter").EventEmitter;
var ScrollBar = function(parent) {
this.element = dom.createElement("div");
this.element.className = "ace_scrollbar ace_scrollbar" + this.classSuffix;
this.inner = dom.createElement("div");
this.inner.className = "ace_scrollbar-inner";
this.element.appendChild(this.inner);
parent.appendChild(this.element);
this.setVisible(false);
this.skipEvent = false;
event.addListener(this.element, "scroll", this.onScroll.bind(this));
event.addListener(this.element, "mousedown", event.preventDefault);
};
(function() {
oop.implement(this, EventEmitter);
this.setVisible = function(isVisible) {
this.element.style.display = isVisible ? "" : "none";
this.isVisible = isVisible;
};
}).call(ScrollBar.prototype);
var VScrollBar = function(parent, renderer) {
ScrollBar.call(this, parent);
this.scrollTop = 0;
renderer.$scrollbarWidth =
this.width = dom.scrollbarWidth(parent.ownerDocument);
this.inner.style.width =
this.element.style.width = (this.width || 15) + 5 + "px";
};
oop.inherits(VScrollBar, ScrollBar);
(function() {
this.classSuffix = '-v';
this.onScroll = function() {
if (!this.skipEvent) {
this.scrollTop = this.element.scrollTop;
this._emit("scroll", {data: this.scrollTop});
}
this.skipEvent = false;
};
this.getWidth = function() {
return this.isVisible ? this.width : 0;
};
this.setHeight = function(height) {
this.element.style.height = height + "px";
};
this.setInnerHeight = function(height) {
this.inner.style.height = height + "px";
};
this.setScrollHeight = function(height) {
this.inner.style.height = height + "px";
};
this.setScrollTop = function(scrollTop) {
if (this.scrollTop != scrollTop) {
this.skipEvent = true;
this.scrollTop = this.element.scrollTop = scrollTop;
}
};
}).call(VScrollBar.prototype);
var HScrollBar = function(parent, renderer) {
ScrollBar.call(this, parent);
this.scrollLeft = 0;
this.height = renderer.$scrollbarWidth;
this.inner.style.height =
this.element.style.height = (this.height || 15) + 5 + "px";
};
oop.inherits(HScrollBar, ScrollBar);
(function() {
this.classSuffix = '-h';
this.onScroll = function() {
if (!this.skipEvent) {
this.scrollLeft = this.element.scrollLeft;
this._emit("scroll", {data: this.scrollLeft});
}
this.skipEvent = false;
};
this.getHeight = function() {
return this.isVisible ? this.height : 0;
};
this.setWidth = function(width) {
this.element.style.width = width + "px";
};
this.setInnerWidth = function(width) {
this.inner.style.width = width + "px";
};
this.setScrollWidth = function(width) {
this.inner.style.width = width + "px";
};
this.setScrollLeft = function(scrollLeft) {
if (this.scrollLeft != scrollLeft) {
this.skipEvent = true;
this.scrollLeft = this.element.scrollLeft = scrollLeft;
}
};
}).call(HScrollBar.prototype);
exports.ScrollBar = VScrollBar; // backward compatibility
exports.ScrollBarV = VScrollBar; // backward compatibility
exports.ScrollBarH = HScrollBar; // backward compatibility
exports.VScrollBar = VScrollBar;
exports.HScrollBar = HScrollBar;
});
define("ace/renderloop",["require","exports","module","ace/lib/event"], function(require, exports, module) {
"use strict";
var event = require("./lib/event");
var RenderLoop = function(onRender, win) {
this.onRender = onRender;
this.pending = false;
this.changes = 0;
this.window = win || window;
};
(function() {
this.schedule = function(change) {
this.changes = this.changes | change;
if (!this.pending && this.changes) {
this.pending = true;
var _self = this;
event.nextFrame(function() {
_self.pending = false;
var changes;
while (changes = _self.changes) {
_self.changes = 0;
_self.onRender(changes);
}
}, this.window);
}
};
}).call(RenderLoop.prototype);
exports.RenderLoop = RenderLoop;
});
define("ace/layer/font_metrics",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/lib/lang","ace/lib/useragent","ace/lib/event_emitter"], function(require, exports, module) {
var oop = require("../lib/oop");
var dom = require("../lib/dom");
var lang = require("../lib/lang");
var useragent = require("../lib/useragent");
var EventEmitter = require("../lib/event_emitter").EventEmitter;
var CHAR_COUNT = 0;
var FontMetrics = exports.FontMetrics = function(parentEl, interval) {
this.el = dom.createElement("div");
this.$setMeasureNodeStyles(this.el.style, true);
this.$main = dom.createElement("div");
this.$setMeasureNodeStyles(this.$main.style);
this.$measureNode = dom.createElement("div");
this.$setMeasureNodeStyles(this.$measureNode.style);
this.el.appendChild(this.$main);
this.el.appendChild(this.$measureNode);
parentEl.appendChild(this.el);
if (!CHAR_COUNT)
this.$testFractionalRect();
this.$measureNode.innerHTML = lang.stringRepeat("X", CHAR_COUNT);
this.$characterSize = {width: 0, height: 0};
this.checkForSizeChanges();
};
(function() {
oop.implement(this, EventEmitter);
this.$characterSize = {width: 0, height: 0};
this.$testFractionalRect = function() {
var el = dom.createElement("div");
this.$setMeasureNodeStyles(el.style);
el.style.width = "0.2px";
document.documentElement.appendChild(el);
var w = el.getBoundingClientRect().width;
if (w > 0 && w < 1)
CHAR_COUNT = 50;
else
CHAR_COUNT = 100;
el.parentNode.removeChild(el);
};
this.$setMeasureNodeStyles = function(style, isRoot) {
style.width = style.height = "auto";
style.left = style.top = "-100px";
style.visibility = "hidden";
style.position = "fixed";
style.whiteSpace = "pre";
if (useragent.isIE < 8) {
style["font-family"] = "inherit";
} else {
style.font = "inherit";
}
style.overflow = isRoot ? "hidden" : "visible";
};
this.checkForSizeChanges = function() {
var size = this.$measureSizes();
if (size && (this.$characterSize.width !== size.width || this.$characterSize.height !== size.height)) {
this.$measureNode.style.fontWeight = "bold";
var boldSize = this.$measureSizes();
this.$measureNode.style.fontWeight = "";
this.$characterSize = size;
this.charSizes = Object.create(null);
this.allowBoldFonts = boldSize && boldSize.width === size.width && boldSize.height === size.height;
this._emit("changeCharacterSize", {data: size});
}
};
this.$pollSizeChanges = function() {
if (this.$pollSizeChangesTimer)
return this.$pollSizeChangesTimer;
var self = this;
return this.$pollSizeChangesTimer = setInterval(function() {
self.checkForSizeChanges();
}, 500);
};
this.setPolling = function(val) {
if (val) {
this.$pollSizeChanges();
} else {
if (this.$pollSizeChangesTimer)
this.$pollSizeChangesTimer;
}
};
this.$measureSizes = function() {
if (CHAR_COUNT === 50) {
var rect = null;
try {
rect = this.$measureNode.getBoundingClientRect();
} catch(e) {
rect = {width: 0, height:0 };
};
var size = {
height: rect.height,
width: rect.width / CHAR_COUNT
};
} else {
var size = {
height: this.$measureNode.clientHeight,
width: this.$measureNode.clientWidth / CHAR_COUNT
};
}
if (size.width === 0 || size.height === 0)
return null;
return size;
};
this.$measureCharWidth = function(ch) {
this.$main.innerHTML = lang.stringRepeat(ch, CHAR_COUNT);
var rect = this.$main.getBoundingClientRect();
return rect.width / CHAR_COUNT;
};
this.getCharacterWidth = function(ch) {
var w = this.charSizes[ch];
if (w === undefined) {
this.charSizes[ch] = this.$measureCharWidth(ch) / this.$characterSize.width;
}
return w;
};
this.destroy = function() {
clearInterval(this.$pollSizeChangesTimer);
if (this.el && this.el.parentNode)
this.el.parentNode.removeChild(this.el);
};
}).call(FontMetrics.prototype);
});
define("ace/virtual_renderer",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/config","ace/lib/useragent","ace/layer/gutter","ace/layer/marker","ace/layer/text","ace/layer/cursor","ace/scrollbar","ace/scrollbar","ace/renderloop","ace/layer/font_metrics","ace/lib/event_emitter"], function(require, exports, module) {
"use strict";
var oop = require("./lib/oop");
var dom = require("./lib/dom");
var config = require("./config");
var useragent = require("./lib/useragent");
var GutterLayer = require("./layer/gutter").Gutter;
var MarkerLayer = require("./layer/marker").Marker;
var TextLayer = require("./layer/text").Text;
var CursorLayer = require("./layer/cursor").Cursor;
var HScrollBar = require("./scrollbar").HScrollBar;
var VScrollBar = require("./scrollbar").VScrollBar;
var RenderLoop = require("./renderloop").RenderLoop;
var FontMetrics = require("./layer/font_metrics").FontMetrics;
var EventEmitter = require("./lib/event_emitter").EventEmitter;
var editorCss = ".ace_editor {\
position: relative;\
overflow: hidden;\
font: 12px/normal 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;\
direction: ltr;\
}\
.ace_scroller {\
position: absolute;\
overflow: hidden;\
top: 0;\
bottom: 0;\
background-color: inherit;\
-ms-user-select: none;\
-moz-user-select: none;\
-webkit-user-select: none;\
user-select: none;\
cursor: text;\
}\
.ace_content {\
position: absolute;\
-moz-box-sizing: border-box;\
-webkit-box-sizing: border-box;\
box-sizing: border-box;\
min-width: 100%;\
}\
.ace_dragging .ace_scroller:before{\
position: absolute;\
top: 0;\
left: 0;\
right: 0;\
bottom: 0;\
content: '';\
background: rgba(250, 250, 250, 0.01);\
z-index: 1000;\
}\
.ace_dragging.ace_dark .ace_scroller:before{\
background: rgba(0, 0, 0, 0.01);\
}\
.ace_selecting, .ace_selecting * {\
cursor: text !important;\
}\
.ace_gutter {\
position: absolute;\
overflow : hidden;\
width: auto;\
top: 0;\
bottom: 0;\
left: 0;\
cursor: default;\
z-index: 4;\
-ms-user-select: none;\
-moz-user-select: none;\
-webkit-user-select: none;\
user-select: none;\
}\
.ace_gutter-active-line {\
position: absolute;\
left: 0;\
right: 0;\
}\
.ace_scroller.ace_scroll-left {\
box-shadow: 17px 0 16px -16px rgba(0, 0, 0, 0.4) inset;\
}\
.ace_gutter-cell {\
padding-left: 19px;\
padding-right: 6px;\
background-repeat: no-repeat;\
}\
.ace_gutter-cell.ace_error {\
background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAABOFBMVEX/////////QRswFAb/Ui4wFAYwFAYwFAaWGAfDRymzOSH/PxswFAb/SiUwFAYwFAbUPRvjQiDllog5HhHdRybsTi3/Tyv9Tir+Syj/UC3////XurebMBIwFAb/RSHbPx/gUzfdwL3kzMivKBAwFAbbvbnhPx66NhowFAYwFAaZJg8wFAaxKBDZurf/RB6mMxb/SCMwFAYwFAbxQB3+RB4wFAb/Qhy4Oh+4QifbNRcwFAYwFAYwFAb/QRzdNhgwFAYwFAbav7v/Uy7oaE68MBK5LxLewr/r2NXewLswFAaxJw4wFAbkPRy2PyYwFAaxKhLm1tMwFAazPiQwFAaUGAb/QBrfOx3bvrv/VC/maE4wFAbRPBq6MRO8Qynew8Dp2tjfwb0wFAbx6eju5+by6uns4uH9/f36+vr/GkHjAAAAYnRSTlMAGt+64rnWu/bo8eAA4InH3+DwoN7j4eLi4xP99Nfg4+b+/u9B/eDs1MD1mO7+4PHg2MXa347g7vDizMLN4eG+Pv7i5evs/v79yu7S3/DV7/498Yv24eH+4ufQ3Ozu/v7+y13sRqwAAADLSURBVHjaZc/XDsFgGIBhtDrshlitmk2IrbHFqL2pvXf/+78DPokj7+Fz9qpU/9UXJIlhmPaTaQ6QPaz0mm+5gwkgovcV6GZzd5JtCQwgsxoHOvJO15kleRLAnMgHFIESUEPmawB9ngmelTtipwwfASilxOLyiV5UVUyVAfbG0cCPHig+GBkzAENHS0AstVF6bacZIOzgLmxsHbt2OecNgJC83JERmePUYq8ARGkJx6XtFsdddBQgZE2nPR6CICZhawjA4Fb/chv+399kfR+MMMDGOQAAAABJRU5ErkJggg==\");\
background-repeat: no-repeat;\
background-position: 2px center;\
}\
.ace_gutter-cell.ace_warning {\
background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAmVBMVEX///8AAAD///8AAAAAAABPSzb/5sAAAAB/blH/73z/ulkAAAAAAAD85pkAAAAAAAACAgP/vGz/rkDerGbGrV7/pkQICAf////e0IsAAAD/oED/qTvhrnUAAAD/yHD/njcAAADuv2r/nz//oTj/p064oGf/zHAAAAA9Nir/tFIAAAD/tlTiuWf/tkIAAACynXEAAAAAAAAtIRW7zBpBAAAAM3RSTlMAABR1m7RXO8Ln31Z36zT+neXe5OzooRDfn+TZ4p3h2hTf4t3k3ucyrN1K5+Xaks52Sfs9CXgrAAAAjklEQVR42o3PbQ+CIBQFYEwboPhSYgoYunIqqLn6/z8uYdH8Vmdnu9vz4WwXgN/xTPRD2+sgOcZjsge/whXZgUaYYvT8QnuJaUrjrHUQreGczuEafQCO/SJTufTbroWsPgsllVhq3wJEk2jUSzX3CUEDJC84707djRc5MTAQxoLgupWRwW6UB5fS++NV8AbOZgnsC7BpEAAAAABJRU5ErkJggg==\");\
background-position: 2px center;\
}\
.ace_gutter-cell.ace_info {\
background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAAAAAA6mKC9AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAJ0Uk5TAAB2k804AAAAPklEQVQY02NgIB68QuO3tiLznjAwpKTgNyDbMegwisCHZUETUZV0ZqOquBpXj2rtnpSJT1AEnnRmL2OgGgAAIKkRQap2htgAAAAASUVORK5CYII=\");\
background-position: 2px center;\
}\
.ace_dark .ace_gutter-cell.ace_info {\
background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAJFBMVEUAAAChoaGAgIAqKiq+vr6tra1ZWVmUlJSbm5s8PDxubm56enrdgzg3AAAAAXRSTlMAQObYZgAAAClJREFUeNpjYMAPdsMYHegyJZFQBlsUlMFVCWUYKkAZMxZAGdxlDMQBAG+TBP4B6RyJAAAAAElFTkSuQmCC\");\
}\
.ace_scrollbar {\
position: absolute;\
right: 0;\
bottom: 0;\
z-index: 6;\
}\
.ace_scrollbar-inner {\
position: absolute;\
cursor: text;\
left: 0;\
top: 0;\
}\
.ace_scrollbar-v{\
overflow-x: hidden;\
overflow-y: scroll;\
top: 0;\
}\
.ace_scrollbar-h {\
overflow-x: scroll;\
overflow-y: hidden;\
left: 0;\
}\
.ace_print-margin {\
position: absolute;\
height: 100%;\
}\
.ace_text-input {\
position: absolute;\
z-index: 0;\
width: 0.5em;\
height: 1em;\
opacity: 0;\
background: transparent;\
-moz-appearance: none;\
appearance: none;\
border: none;\
resize: none;\
outline: none;\
overflow: hidden;\
font: inherit;\
padding: 0 1px;\
margin: 0 -1px;\
text-indent: -1em;\
-ms-user-select: text;\
-moz-user-select: text;\
-webkit-user-select: text;\
user-select: text;\
}\
.ace_text-input.ace_composition {\
background: inherit;\
color: inherit;\
z-index: 1000;\
opacity: 1;\
text-indent: 0;\
}\
.ace_layer {\
z-index: 1;\
position: absolute;\
overflow: hidden;\
white-space: pre;\
height: 100%;\
width: 100%;\
-moz-box-sizing: border-box;\
-webkit-box-sizing: border-box;\
box-sizing: border-box;\
pointer-events: none;\
}\
.ace_gutter-layer {\
position: relative;\
width: auto;\
text-align: right;\
pointer-events: auto;\
}\
.ace_text-layer {\
font: inherit !important;\
}\
.ace_cjk {\
display: inline-block;\
text-align: center;\
}\
.ace_cursor-layer {\
z-index: 4;\
}\
.ace_cursor {\
z-index: 4;\
position: absolute;\
-moz-box-sizing: border-box;\
-webkit-box-sizing: border-box;\
box-sizing: border-box;\
border-left: 2px solid\
}\
.ace_slim-cursors .ace_cursor {\
border-left-width: 1px;\
}\
.ace_overwrite-cursors .ace_cursor {\
border-left-width: 0;\
border-bottom: 1px solid;\
}\
.ace_hidden-cursors .ace_cursor {\
opacity: 0.2;\
}\
.ace_smooth-blinking .ace_cursor {\
-webkit-transition: opacity 0.18s;\
transition: opacity 0.18s;\
}\
.ace_editor.ace_multiselect .ace_cursor {\
border-left-width: 1px;\
}\
.ace_marker-layer .ace_step, .ace_marker-layer .ace_stack {\
position: absolute;\
z-index: 3;\
}\
.ace_marker-layer .ace_selection {\
position: absolute;\
z-index: 5;\
}\
.ace_marker-layer .ace_bracket {\
position: absolute;\
z-index: 6;\
}\
.ace_marker-layer .ace_active-line {\
position: absolute;\
z-index: 2;\
}\
.ace_marker-layer .ace_selected-word {\
position: absolute;\
z-index: 4;\
-moz-box-sizing: border-box;\
-webkit-box-sizing: border-box;\
box-sizing: border-box;\
}\
.ace_line .ace_fold {\
-moz-box-sizing: border-box;\
-webkit-box-sizing: border-box;\
box-sizing: border-box;\
display: inline-block;\
height: 11px;\
margin-top: -2px;\
vertical-align: middle;\
background-image:\
url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII=\"),\
url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACJJREFUeNpi+P//fxgTAwPDBxDxD078RSX+YeEyDFMCIMAAI3INmXiwf2YAAAAASUVORK5CYII=\");\
background-repeat: no-repeat, repeat-x;\
background-position: center center, top left;\
color: transparent;\
border: 1px solid black;\
border-radius: 2px;\
cursor: pointer;\
pointer-events: auto;\
}\
.ace_dark .ace_fold {\
}\
.ace_fold:hover{\
background-image:\
url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAAJCAYAAADU6McMAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJpJREFUeNpi/P//PwOlgAXGYGRklAVSokD8GmjwY1wasKljQpYACtpCFeADcHVQfQyMQAwzwAZI3wJKvCLkfKBaMSClBlR7BOQikCFGQEErIH0VqkabiGCAqwUadAzZJRxQr/0gwiXIal8zQQPnNVTgJ1TdawL0T5gBIP1MUJNhBv2HKoQHHjqNrA4WO4zY0glyNKLT2KIfIMAAQsdgGiXvgnYAAAAASUVORK5CYII=\"),\
url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAA3CAYAAADNNiA5AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACBJREFUeNpi+P//fz4TAwPDZxDxD5X4i5fLMEwJgAADAEPVDbjNw87ZAAAAAElFTkSuQmCC\");\
}\
.ace_tooltip {\
background-color: #FFF;\
background-image: -webkit-linear-gradient(top, transparent, rgba(0, 0, 0, 0.1));\
background-image: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.1));\
border: 1px solid gray;\
border-radius: 1px;\
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);\
color: black;\
max-width: 100%;\
padding: 3px 4px;\
position: fixed;\
z-index: 999999;\
-moz-box-sizing: border-box;\
-webkit-box-sizing: border-box;\
box-sizing: border-box;\
cursor: default;\
white-space: pre;\
word-wrap: break-word;\
line-height: normal;\
font-style: normal;\
font-weight: normal;\
letter-spacing: normal;\
pointer-events: none;\
}\
.ace_folding-enabled > .ace_gutter-cell {\
padding-right: 13px;\
}\
.ace_fold-widget {\
-moz-box-sizing: border-box;\
-webkit-box-sizing: border-box;\
box-sizing: border-box;\
margin: 0 -12px 0 1px;\
display: none;\
width: 11px;\
vertical-align: top;\
background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42mWKsQ0AMAzC8ixLlrzQjzmBiEjp0A6WwBCSPgKAXoLkqSot7nN3yMwR7pZ32NzpKkVoDBUxKAAAAABJRU5ErkJggg==\");\
background-repeat: no-repeat;\
background-position: center;\
border-radius: 3px;\
border: 1px solid transparent;\
cursor: pointer;\
}\
.ace_folding-enabled .ace_fold-widget {\
display: inline-block; \
}\
.ace_fold-widget.ace_end {\
background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAANElEQVR42m3HwQkAMAhD0YzsRchFKI7sAikeWkrxwScEB0nh5e7KTPWimZki4tYfVbX+MNl4pyZXejUO1QAAAABJRU5ErkJggg==\");\
}\
.ace_fold-widget.ace_closed {\
background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAGCAYAAAAG5SQMAAAAOUlEQVR42jXKwQkAMAgDwKwqKD4EwQ26sSOkVWjgIIHAzPiCgaqiqnJHZnKICBERHN194O5b9vbLuAVRL+l0YWnZAAAAAElFTkSuQmCCXA==\");\
}\
.ace_fold-widget:hover {\
border: 1px solid rgba(0, 0, 0, 0.3);\
background-color: rgba(255, 255, 255, 0.2);\
box-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);\
}\
.ace_fold-widget:active {\
border: 1px solid rgba(0, 0, 0, 0.4);\
background-color: rgba(0, 0, 0, 0.05);\
box-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);\
}\
.ace_dark .ace_fold-widget {\
background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHklEQVQIW2P4//8/AzoGEQ7oGCaLLAhWiSwB146BAQCSTPYocqT0AAAAAElFTkSuQmCC\");\
}\
.ace_dark .ace_fold-widget.ace_end {\
background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAH0lEQVQIW2P4//8/AxQ7wNjIAjDMgC4AxjCVKBirIAAF0kz2rlhxpAAAAABJRU5ErkJggg==\");\
}\
.ace_dark .ace_fold-widget.ace_closed {\
background-image: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAAFCAYAAACAcVaiAAAAHElEQVQIW2P4//+/AxAzgDADlOOAznHAKgPWAwARji8UIDTfQQAAAABJRU5ErkJggg==\");\
}\
.ace_dark .ace_fold-widget:hover {\
box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);\
background-color: rgba(255, 255, 255, 0.1);\
}\
.ace_dark .ace_fold-widget:active {\
box-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);\
}\
.ace_fold-widget.ace_invalid {\
background-color: #FFB4B4;\
border-color: #DE5555;\
}\
.ace_fade-fold-widgets .ace_fold-widget {\
-webkit-transition: opacity 0.4s ease 0.05s;\
transition: opacity 0.4s ease 0.05s;\
opacity: 0;\
}\
.ace_fade-fold-widgets:hover .ace_fold-widget {\
-webkit-transition: opacity 0.05s ease 0.05s;\
transition: opacity 0.05s ease 0.05s;\
opacity:1;\
}\
.ace_underline {\
text-decoration: underline;\
}\
.ace_bold {\
font-weight: bold;\
}\
.ace_nobold .ace_bold {\
font-weight: normal;\
}\
.ace_italic {\
font-style: italic;\
}\
.ace_error-marker {\
background-color: rgba(255, 0, 0,0.2);\
position: absolute;\
z-index: 9;\
}\
.ace_highlight-marker {\
background-color: rgba(255, 255, 0,0.2);\
position: absolute;\
z-index: 8;\
}\
";
dom.importCssString(editorCss, "ace_editor");
var VirtualRenderer = function(container, theme) {
var _self = this;
this.container = container || dom.createElement("div");
this.$keepTextAreaAtCursor = !useragent.isOldIE;
dom.addCssClass(this.container, "ace_editor");
this.setTheme(theme);
this.$gutter = dom.createElement("div");
this.$gutter.className = "ace_gutter";
this.container.appendChild(this.$gutter);
this.scroller = dom.createElement("div");
this.scroller.className = "ace_scroller";
this.container.appendChild(this.scroller);
this.content = dom.createElement("div");
this.content.className = "ace_content";
this.scroller.appendChild(this.content);
this.$gutterLayer = new GutterLayer(this.$gutter);
this.$gutterLayer.on("changeGutterWidth", this.onGutterResize.bind(this));
this.$markerBack = new MarkerLayer(this.content);
var textLayer = this.$textLayer = new TextLayer(this.content);
this.canvas = textLayer.element;
this.$markerFront = new MarkerLayer(this.content);
this.$cursorLayer = new CursorLayer(this.content);
this.$horizScroll = false;
this.$vScroll = false;
this.scrollBar =
this.scrollBarV = new VScrollBar(this.container, this);
this.scrollBarH = new HScrollBar(this.container, this);
this.scrollBarV.addEventListener("scroll", function(e) {
if (!_self.$scrollAnimation)
_self.session.setScrollTop(e.data - _self.scrollMargin.top);
});
this.scrollBarH.addEventListener("scroll", function(e) {
if (!_self.$scrollAnimation)
_self.session.setScrollLeft(e.data - _self.scrollMargin.left);
});
this.scrollTop = 0;
this.scrollLeft = 0;
this.cursorPos = {
row : 0,
column : 0
};
this.$fontMetrics = new FontMetrics(this.container, 500);
this.$textLayer.$setFontMetrics(this.$fontMetrics);
this.$textLayer.addEventListener("changeCharacterSize", function(e) {
_self.updateCharacterSize();
_self.onResize(true, _self.gutterWidth, _self.$size.width, _self.$size.height);
_self._signal("changeCharacterSize", e);
});
this.$size = {
width: 0,
height: 0,
scrollerHeight: 0,
scrollerWidth: 0,
$dirty: true
};
this.layerConfig = {
width : 1,
padding : 0,
firstRow : 0,
firstRowScreen: 0,
lastRow : 0,
lineHeight : 0,
characterWidth : 0,
minHeight : 1,
maxHeight : 1,
offset : 0,
height : 1,
gutterOffset: 1
};
this.scrollMargin = {
left: 0,
right: 0,
top: 0,
bottom: 0,
v: 0,
h: 0
};
this.$loop = new RenderLoop(
this.$renderChanges.bind(this),
this.container.ownerDocument.defaultView
);
this.$loop.schedule(this.CHANGE_FULL);
this.updateCharacterSize();
this.setPadding(4);
config.resetOptions(this);
config._emit("renderer", this);
};
(function() {
this.CHANGE_CURSOR = 1;
this.CHANGE_MARKER = 2;
this.CHANGE_GUTTER = 4;
this.CHANGE_SCROLL = 8;
this.CHANGE_LINES = 16;
this.CHANGE_TEXT = 32;
this.CHANGE_SIZE = 64;
this.CHANGE_MARKER_BACK = 128;
this.CHANGE_MARKER_FRONT = 256;
this.CHANGE_FULL = 512;
this.CHANGE_H_SCROLL = 1024;
oop.implement(this, EventEmitter);
this.updateCharacterSize = function() {
if (this.$textLayer.allowBoldFonts != this.$allowBoldFonts) {
this.$allowBoldFonts = this.$textLayer.allowBoldFonts;
this.setStyle("ace_nobold", !this.$allowBoldFonts);
}
this.layerConfig.characterWidth =
this.characterWidth = this.$textLayer.getCharacterWidth();
this.layerConfig.lineHeight =
this.lineHeight = this.$textLayer.getLineHeight();
this.$updatePrintMargin();
};
this.setSession = function(session) {
if (this.session)
this.session.doc.off("changeNewLineMode", this.onChangeNewLineMode);
this.session = session;
if (session && this.scrollMargin.top && session.getScrollTop() <= 0)
session.setScrollTop(-this.scrollMargin.top);
this.$cursorLayer.setSession(session);
this.$markerBack.setSession(session);
this.$markerFront.setSession(session);
this.$gutterLayer.setSession(session);
this.$textLayer.setSession(session);
if (!session)
return;
this.$loop.schedule(this.CHANGE_FULL);
this.session.$setFontMetrics(this.$fontMetrics);
this.onChangeNewLineMode = this.onChangeNewLineMode.bind(this);
this.onChangeNewLineMode()
this.session.doc.on("changeNewLineMode", this.onChangeNewLineMode);
};
this.updateLines = function(firstRow, lastRow, force) {
if (lastRow === undefined)
lastRow = Infinity;
if (!this.$changedLines) {
this.$changedLines = {
firstRow: firstRow,
lastRow: lastRow
};
}
else {
if (this.$changedLines.firstRow > firstRow)
this.$changedLines.firstRow = firstRow;
if (this.$changedLines.lastRow < lastRow)
this.$changedLines.lastRow = lastRow;
}
if (this.$changedLines.lastRow < this.layerConfig.firstRow) {
if (force)
this.$changedLines.lastRow = this.layerConfig.lastRow;
else
return;
}
if (this.$changedLines.firstRow > this.layerConfig.lastRow)
return;
this.$loop.schedule(this.CHANGE_LINES);
};
this.onChangeNewLineMode = function() {
this.$loop.schedule(this.CHANGE_TEXT);
this.$textLayer.$updateEolChar();
};
this.onChangeTabSize = function() {
this.$loop.schedule(this.CHANGE_TEXT | this.CHANGE_MARKER);
this.$textLayer.onChangeTabSize();
};
this.updateText = function() {
this.$loop.schedule(this.CHANGE_TEXT);
};
this.updateFull = function(force) {
if (force)
this.$renderChanges(this.CHANGE_FULL, true);
else
this.$loop.schedule(this.CHANGE_FULL);
};
this.updateFontSize = function() {
this.$textLayer.checkForSizeChanges();
};
this.$changes = 0;
this.$updateSizeAsync = function() {
if (this.$loop.pending)
this.$size.$dirty = true;
else
this.onResize();
};
this.onResize = function(force, gutterWidth, width, height) {
if (this.resizing > 2)
return;
else if (this.resizing > 0)
this.resizing++;
else
this.resizing = force ? 1 : 0;
var el = this.container;
if (!height)
height = el.clientHeight || el.scrollHeight;
if (!width)
width = el.clientWidth || el.scrollWidth;
var changes = this.$updateCachedSize(force, gutterWidth, width, height);
if (!this.$size.scrollerHeight || (!width && !height))
return this.resizing = 0;
if (force)
this.$gutterLayer.$padding = null;
if (force)
this.$renderChanges(changes | this.$changes, true);
else
this.$loop.schedule(changes | this.$changes);
if (this.resizing)
this.resizing = 0;
};
this.$updateCachedSize = function(force, gutterWidth, width, height) {
height -= (this.$extraHeight || 0);
var changes = 0;
var size = this.$size;
var oldSize = {
width: size.width,
height: size.height,
scrollerHeight: size.scrollerHeight,
scrollerWidth: size.scrollerWidth
};
if (height && (force || size.height != height)) {
size.height = height;
changes |= this.CHANGE_SIZE;
size.scrollerHeight = size.height;
if (this.$horizScroll)
size.scrollerHeight -= this.scrollBarH.getHeight();
this.scrollBarV.element.style.bottom = this.scrollBarH.getHeight() + "px";
changes = changes | this.CHANGE_SCROLL;
}
if (width && (force || size.width != width)) {
changes |= this.CHANGE_SIZE;
size.width = width;
if (gutterWidth == null)
gutterWidth = this.$showGutter ? this.$gutter.offsetWidth : 0;
this.gutterWidth = gutterWidth;
this.scrollBarH.element.style.left =
this.scroller.style.left = gutterWidth + "px";
size.scrollerWidth = Math.max(0, width - gutterWidth - this.scrollBarV.getWidth());
this.scrollBarH.element.style.right =
this.scroller.style.right = this.scrollBarV.getWidth() + "px";
this.scroller.style.bottom = this.scrollBarH.getHeight() + "px";
if (this.session && this.session.getUseWrapMode() && this.adjustWrapLimit() || force)
changes |= this.CHANGE_FULL;
}
size.$dirty = !width || !height;
if (changes)
this._signal("resize", oldSize);
return changes;
};
this.onGutterResize = function() {
var gutterWidth = this.$showGutter ? this.$gutter.offsetWidth : 0;
if (gutterWidth != this.gutterWidth)
this.$changes |= this.$updateCachedSize(true, gutterWidth, this.$size.width, this.$size.height);
if (this.session.getUseWrapMode() && this.adjustWrapLimit()) {
this.$loop.schedule(this.CHANGE_FULL);
} else if (this.$size.$dirty) {
this.$loop.schedule(this.CHANGE_FULL);
} else {
this.$computeLayerConfig();
this.$loop.schedule(this.CHANGE_MARKER);
}
};
this.adjustWrapLimit = function() {
var availableWidth = this.$size.scrollerWidth - this.$padding * 2;
var limit = Math.floor(availableWidth / this.characterWidth);
return this.session.adjustWrapLimit(limit, this.$showPrintMargin && this.$printMarginColumn);
};
this.setAnimatedScroll = function(shouldAnimate){
this.setOption("animatedScroll", shouldAnimate);
};
this.getAnimatedScroll = function() {
return this.$animatedScroll;
};
this.setShowInvisibles = function(showInvisibles) {
this.setOption("showInvisibles", showInvisibles);
};
this.getShowInvisibles = function() {
return this.getOption("showInvisibles");
};
this.getDisplayIndentGuides = function() {
return this.getOption("displayIndentGuides");
};
this.setDisplayIndentGuides = function(display) {
this.setOption("displayIndentGuides", display);
};
this.setShowPrintMargin = function(showPrintMargin) {
this.setOption("showPrintMargin", showPrintMargin);
};
this.getShowPrintMargin = function() {
return this.getOption("showPrintMargin");
};
this.setPrintMarginColumn = function(showPrintMargin) {
this.setOption("printMarginColumn", showPrintMargin);
};
this.getPrintMarginColumn = function() {
return this.getOption("printMarginColumn");
};
this.getShowGutter = function(){
return this.getOption("showGutter");
};
this.setShowGutter = function(show){
return this.setOption("showGutter", show);
};
this.getFadeFoldWidgets = function(){
return this.getOption("fadeFoldWidgets")
};
this.setFadeFoldWidgets = function(show) {
this.setOption("fadeFoldWidgets", show);
};
this.setHighlightGutterLine = function(shouldHighlight) {
this.setOption("highlightGutterLine", shouldHighlight);
};
this.getHighlightGutterLine = function() {
return this.getOption("highlightGutterLine");
};
this.$updateGutterLineHighlight = function() {
var pos = this.$cursorLayer.$pixelPos;
var height = this.layerConfig.lineHeight;
if (this.session.getUseWrapMode()) {
var cursor = this.session.selection.getCursor();
cursor.column = 0;
pos = this.$cursorLayer.getPixelPosition(cursor, true);
height *= this.session.getRowLength(cursor.row);
}
this.$gutterLineHighlight.style.top = pos.top - this.layerConfig.offset + "px";
this.$gutterLineHighlight.style.height = height + "px";
};
this.$updatePrintMargin = function() {
if (!this.$showPrintMargin && !this.$printMarginEl)
return;
if (!this.$printMarginEl) {
var containerEl = dom.createElement("div");
containerEl.className = "ace_layer ace_print-margin-layer";
this.$printMarginEl = dom.createElement("div");
this.$printMarginEl.className = "ace_print-margin";
containerEl.appendChild(this.$printMarginEl);
this.content.insertBefore(containerEl, this.content.firstChild);
}
var style = this.$printMarginEl.style;
style.left = ((this.characterWidth * this.$printMarginColumn) + this.$padding) + "px";
style.visibility = this.$showPrintMargin ? "visible" : "hidden";
if (this.session && this.session.$wrap == -1)
this.adjustWrapLimit();
};
this.getContainerElement = function() {
return this.container;
};
this.getMouseEventTarget = function() {
return this.content;
};
this.getTextAreaContainer = function() {
return this.container;
};
this.$moveTextAreaToCursor = function() {
if (!this.$keepTextAreaAtCursor)
return;
var config = this.layerConfig;
var posTop = this.$cursorLayer.$pixelPos.top;
var posLeft = this.$cursorLayer.$pixelPos.left;
posTop -= config.offset;
var h = this.lineHeight;
if (posTop < 0 || posTop > config.height - h)
return;
var w = this.characterWidth;
if (this.$composition) {
var val = this.textarea.value.replace(/^\x01+/, "");
w *= (this.session.$getStringScreenWidth(val)[0]+2);
h += 2;
}
posLeft -= this.scrollLeft;
if (posLeft > this.$size.scrollerWidth - w)
posLeft = this.$size.scrollerWidth - w;
posLeft += this.gutterWidth;
this.textarea.style.height = h + "px";
this.textarea.style.width = w + "px";
this.textarea.style.left = Math.min(posLeft, this.$size.scrollerWidth - w) + "px";
this.textarea.style.top = Math.min(posTop, this.$size.height - h) + "px";
};
this.getFirstVisibleRow = function() {
return this.layerConfig.firstRow;
};
this.getFirstFullyVisibleRow = function() {
return this.layerConfig.firstRow + (this.layerConfig.offset === 0 ? 0 : 1);
};
this.getLastFullyVisibleRow = function() {
var flint = Math.floor((this.layerConfig.height + this.layerConfig.offset) / this.layerConfig.lineHeight);
return this.layerConfig.firstRow - 1 + flint;
};
this.getLastVisibleRow = function() {
return this.layerConfig.lastRow;
};
this.$padding = null;
this.setPadding = function(padding) {
this.$padding = padding;
this.$textLayer.setPadding(padding);
this.$cursorLayer.setPadding(padding);
this.$markerFront.setPadding(padding);
this.$markerBack.setPadding(padding);
this.$loop.schedule(this.CHANGE_FULL);
this.$updatePrintMargin();
};
this.setScrollMargin = function(top, bottom, left, right) {
var sm = this.scrollMargin;
sm.top = top|0;
sm.bottom = bottom|0;
sm.right = right|0;
sm.left = left|0;
sm.v = sm.top + sm.bottom;
sm.h = sm.left + sm.right;
if (sm.top && this.scrollTop <= 0 && this.session)
this.session.setScrollTop(-sm.top);
this.updateFull();
};
this.getHScrollBarAlwaysVisible = function() {
return this.$hScrollBarAlwaysVisible;
};
this.setHScrollBarAlwaysVisible = function(alwaysVisible) {
this.setOption("hScrollBarAlwaysVisible", alwaysVisible);
};
this.getVScrollBarAlwaysVisible = function() {
return this.$hScrollBarAlwaysVisible;
};
this.setVScrollBarAlwaysVisible = function(alwaysVisible) {
this.setOption("vScrollBarAlwaysVisible", alwaysVisible);
};
this.$updateScrollBarV = function() {
var scrollHeight = this.layerConfig.maxHeight;
var scrollerHeight = this.$size.scrollerHeight;
if (!this.$maxLines && this.$scrollPastEnd) {
scrollHeight -= (scrollerHeight - this.lineHeight) * this.$scrollPastEnd;
if (this.scrollTop > scrollHeight - scrollerHeight) {
scrollHeight = this.scrollTop + scrollerHeight;
this.scrollBarV.scrollTop = null;
}
}
this.scrollBarV.setScrollHeight(scrollHeight + this.scrollMargin.v);
this.scrollBarV.setScrollTop(this.scrollTop + this.scrollMargin.top);
};
this.$updateScrollBarH = function() {
this.scrollBarH.setScrollWidth(this.layerConfig.width + 2 * this.$padding + this.scrollMargin.h);
this.scrollBarH.setScrollLeft(this.scrollLeft + this.scrollMargin.left);
};
this.$frozen = false;
this.freeze = function() {
this.$frozen = true;
};
this.unfreeze = function() {
this.$frozen = false;
};
this.$renderChanges = function(changes, force) {
if (this.$changes) {
changes |= this.$changes;
this.$changes = 0;
}
if ((!this.session || !this.container.offsetWidth || this.$frozen) || (!changes && !force)) {
this.$changes |= changes;
return;
}
if (this.$size.$dirty) {
this.$changes |= changes;
return this.onResize(true);
}
if (!this.lineHeight) {
this.$textLayer.checkForSizeChanges();
}
this._signal("beforeRender");
var config = this.layerConfig;
if (changes & this.CHANGE_FULL ||
changes & this.CHANGE_SIZE ||
changes & this.CHANGE_TEXT ||
changes & this.CHANGE_LINES ||
changes & this.CHANGE_SCROLL ||
changes & this.CHANGE_H_SCROLL
) {
changes |= this.$computeLayerConfig();
if (config.firstRow != this.layerConfig.firstRow && config.firstRowScreen == this.layerConfig.firstRowScreen) {
var st = this.scrollTop + (config.firstRow - this.layerConfig.firstRow) * this.lineHeight;
if (st > 0) {
this.scrollTop = st;
changes = changes | this.CHANGE_SCROLL;
changes |= this.$computeLayerConfig();
}
}
config = this.layerConfig;
this.$updateScrollBarV();
if (changes & this.CHANGE_H_SCROLL)
this.$updateScrollBarH();
this.$gutterLayer.element.style.marginTop = (-config.offset) + "px";
this.content.style.marginTop = (-config.offset) + "px";
this.content.style.width = config.width + 2 * this.$padding + "px";
this.content.style.height = config.minHeight + "px";
}
if (changes & this.CHANGE_H_SCROLL) {
this.content.style.marginLeft = -this.scrollLeft + "px";
this.scroller.className = this.scrollLeft <= 0 ? "ace_scroller" : "ace_scroller ace_scroll-left";
}
if (changes & this.CHANGE_FULL) {
this.$textLayer.update(config);
if (this.$showGutter)
this.$gutterLayer.update(config);
this.$markerBack.update(config);
this.$markerFront.update(config);
this.$cursorLayer.update(config);
this.$moveTextAreaToCursor();
this.$highlightGutterLine && this.$updateGutterLineHighlight();
this._signal("afterRender");
return;
}
if (changes & this.CHANGE_SCROLL) {
if (changes & this.CHANGE_TEXT || changes & this.CHANGE_LINES)
this.$textLayer.update(config);
else
this.$textLayer.scrollLines(config);
if (this.$showGutter)
this.$gutterLayer.update(config);
this.$markerBack.update(config);
this.$markerFront.update(config);
this.$cursorLayer.update(config);
this.$highlightGutterLine && this.$updateGutterLineHighlight();
this.$moveTextAreaToCursor();
this._signal("afterRender");
return;
}
if (changes & this.CHANGE_TEXT) {
this.$textLayer.update(config);
if (this.$showGutter)
this.$gutterLayer.update(config);
}
else if (changes & this.CHANGE_LINES) {
if (this.$updateLines() || (changes & this.CHANGE_GUTTER) && this.$showGutter)
this.$gutterLayer.update(config);
}
else if (changes & this.CHANGE_TEXT || changes & this.CHANGE_GUTTER) {
if (this.$showGutter)
this.$gutterLayer.update(config);
}
if (changes & this.CHANGE_CURSOR) {
this.$cursorLayer.update(config);
this.$moveTextAreaToCursor();
this.$highlightGutterLine && this.$updateGutterLineHighlight();
}
if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_FRONT)) {
this.$markerFront.update(config);
}
if (changes & (this.CHANGE_MARKER | this.CHANGE_MARKER_BACK)) {
this.$markerBack.update(config);
}
this._signal("afterRender");
};
this.$autosize = function() {
var height = this.session.getScreenLength() * this.lineHeight;
var maxHeight = this.$maxLines * this.lineHeight;
var desiredHeight = Math.max(
(this.$minLines||1) * this.lineHeight,
Math.min(maxHeight, height)
) + this.scrollMargin.v + (this.$extraHeight || 0);
var vScroll = height > maxHeight;
if (desiredHeight != this.desiredHeight ||
this.$size.height != this.desiredHeight || vScroll != this.$vScroll) {
if (vScroll != this.$vScroll) {
this.$vScroll = vScroll;
this.scrollBarV.setVisible(vScroll);
}
var w = this.container.clientWidth;
this.container.style.height = desiredHeight + "px";
this.$updateCachedSize(true, this.$gutterWidth, w, desiredHeight);
this.desiredHeight = desiredHeight;
this._signal("autosize");
}
};
this.$computeLayerConfig = function() {
if (this.$maxLines && this.lineHeight > 1)
this.$autosize();
var session = this.session;
var size = this.$size;
var hideScrollbars = size.height <= 2 * this.lineHeight;
var screenLines = this.session.getScreenLength();
var maxHeight = screenLines * this.lineHeight;
var offset = this.scrollTop % this.lineHeight;
var minHeight = size.scrollerHeight + this.lineHeight;
var longestLine = this.$getLongestLine();
var horizScroll = !hideScrollbars && (this.$hScrollBarAlwaysVisible ||
size.scrollerWidth - longestLine - 2 * this.$padding < 0);
var hScrollChanged = this.$horizScroll !== horizScroll;
if (hScrollChanged) {
this.$horizScroll = horizScroll;
this.scrollBarH.setVisible(horizScroll);
}
var scrollPastEnd = !this.$maxLines && this.$scrollPastEnd
? (size.scrollerHeight - this.lineHeight) * this.$scrollPastEnd
: 0;
maxHeight += scrollPastEnd;
this.session.setScrollTop(Math.max(-this.scrollMargin.top,
Math.min(this.scrollTop, maxHeight - size.scrollerHeight + this.scrollMargin.bottom)));
this.session.setScrollLeft(Math.max(-this.scrollMargin.left, Math.min(this.scrollLeft,
longestLine + 2 * this.$padding - size.scrollerWidth + this.scrollMargin.right)));
var vScroll = !hideScrollbars && (this.$vScrollBarAlwaysVisible ||
size.scrollerHeight - maxHeight + scrollPastEnd < 0 || this.scrollTop);
var vScrollChanged = this.$vScroll !== vScroll;
if (vScrollChanged) {
this.$vScroll = vScroll;
this.scrollBarV.setVisible(vScroll);
}
var lineCount = Math.ceil(minHeight / this.lineHeight) - 1;
var firstRow = Math.max(0, Math.round((this.scrollTop - offset) / this.lineHeight));
var lastRow = firstRow + lineCount;
var firstRowScreen, firstRowHeight;
var lineHeight = this.lineHeight;
firstRow = session.screenToDocumentRow(firstRow, 0);
var foldLine = session.getFoldLine(firstRow);
if (foldLine) {
firstRow = foldLine.start.row;
}
firstRowScreen = session.documentToScreenRow(firstRow, 0);
firstRowHeight = session.getRowLength(firstRow) * lineHeight;
lastRow = Math.min(session.screenToDocumentRow(lastRow, 0), session.getLength() - 1);
minHeight = size.scrollerHeight + session.getRowLength(lastRow) * lineHeight +
firstRowHeight;
offset = this.scrollTop - firstRowScreen * lineHeight;
var changes = 0;
if (this.layerConfig.width != longestLine)
changes = this.CHANGE_H_SCROLL;
if (hScrollChanged || vScrollChanged) {
changes = this.$updateCachedSize(true, this.gutterWidth, size.width, size.height);
this._signal("scrollbarVisibilityChanged");
if (vScrollChanged)
longestLine = this.$getLongestLine();
}
this.layerConfig = {
width : longestLine,
padding : this.$padding,
firstRow : firstRow,
firstRowScreen: firstRowScreen,
lastRow : lastRow,
lineHeight : lineHeight,
characterWidth : this.characterWidth,
minHeight : minHeight,
maxHeight : maxHeight,
offset : offset,
gutterOffset : Math.max(0, Math.ceil((offset + size.height - size.scrollerHeight) / lineHeight)),
height : this.$size.scrollerHeight
};
return changes;
};
this.$updateLines = function() {
var firstRow = this.$changedLines.firstRow;
var lastRow = this.$changedLines.lastRow;
this.$changedLines = null;
var layerConfig = this.layerConfig;
if (firstRow > layerConfig.lastRow + 1) { return; }
if (lastRow < layerConfig.firstRow) { return; }
if (lastRow === Infinity) {
if (this.$showGutter)
this.$gutterLayer.update(layerConfig);
this.$textLayer.update(layerConfig);
return;
}
this.$textLayer.updateLines(layerConfig, firstRow, lastRow);
return true;
};
this.$getLongestLine = function() {
var charCount = this.session.getScreenWidth();
if (this.showInvisibles && !this.session.$useWrapMode)
charCount += 1;
return Math.max(this.$size.scrollerWidth - 2 * this.$padding, Math.round(charCount * this.characterWidth));
};
this.updateFrontMarkers = function() {
this.$markerFront.setMarkers(this.session.getMarkers(true));
this.$loop.schedule(this.CHANGE_MARKER_FRONT);
};
this.updateBackMarkers = function() {
this.$markerBack.setMarkers(this.session.getMarkers());
this.$loop.schedule(this.CHANGE_MARKER_BACK);
};
this.addGutterDecoration = function(row, className){
this.$gutterLayer.addGutterDecoration(row, className);
};
this.removeGutterDecoration = function(row, className){
this.$gutterLayer.removeGutterDecoration(row, className);
};
this.updateBreakpoints = function(rows) {
this.$loop.schedule(this.CHANGE_GUTTER);
};
this.setAnnotations = function(annotations) {
this.$gutterLayer.setAnnotations(annotations);
this.$loop.schedule(this.CHANGE_GUTTER);
};
this.updateCursor = function() {
this.$loop.schedule(this.CHANGE_CURSOR);
};
this.hideCursor = function() {
this.$cursorLayer.hideCursor();
};
this.showCursor = function() {
this.$cursorLayer.showCursor();
};
this.scrollSelectionIntoView = function(anchor, lead, offset) {
this.scrollCursorIntoView(anchor, offset);
this.scrollCursorIntoView(lead, offset);
};
this.scrollCursorIntoView = function(cursor, offset, $viewMargin) {
if (this.$size.scrollerHeight === 0)
return;
var pos = this.$cursorLayer.getPixelPosition(cursor);
var left = pos.left;
var top = pos.top;
var topMargin = $viewMargin && $viewMargin.top || 0;
var bottomMargin = $viewMargin && $viewMargin.bottom || 0;
var scrollTop = this.$scrollAnimation ? this.session.getScrollTop() : this.scrollTop;
if (scrollTop + topMargin > top) {
if (offset)
top -= offset * this.$size.scrollerHeight;
if (top === 0)
top = -this.scrollMargin.top;
this.session.setScrollTop(top);
} else if (scrollTop + this.$size.scrollerHeight - bottomMargin < top + this.lineHeight) {
if (offset)
top += offset * this.$size.scrollerHeight;
this.session.setScrollTop(top + this.lineHeight - this.$size.scrollerHeight);
}
var scrollLeft = this.scrollLeft;
if (scrollLeft > left) {
if (left < this.$padding + 2 * this.layerConfig.characterWidth)
left = -this.scrollMargin.left;
this.session.setScrollLeft(left);
} else if (scrollLeft + this.$size.scrollerWidth < left + this.characterWidth) {
this.session.setScrollLeft(Math.round(left + this.characterWidth - this.$size.scrollerWidth));
} else if (scrollLeft <= this.$padding && left - scrollLeft < this.characterWidth) {
this.session.setScrollLeft(0);
}
};
this.getScrollTop = function() {
return this.session.getScrollTop();
};
this.getScrollLeft = function() {
return this.session.getScrollLeft();
};
this.getScrollTopRow = function() {
return this.scrollTop / this.lineHeight;
};
this.getScrollBottomRow = function() {
return Math.max(0, Math.floor((this.scrollTop + this.$size.scrollerHeight) / this.lineHeight) - 1);
};
this.scrollToRow = function(row) {
this.session.setScrollTop(row * this.lineHeight);
};
this.alignCursor = function(cursor, alignment) {
if (typeof cursor == "number")
cursor = {row: cursor, column: 0};
var pos = this.$cursorLayer.getPixelPosition(cursor);
var h = this.$size.scrollerHeight - this.lineHeight;
var offset = pos.top - h * (alignment || 0);
this.session.setScrollTop(offset);
return offset;
};
this.STEPS = 8;
this.$calcSteps = function(fromValue, toValue){
var i = 0;
var l = this.STEPS;
var steps = [];
var func = function(t, x_min, dx) {
return dx * (Math.pow(t - 1, 3) + 1) + x_min;
};
for (i = 0; i < l; ++i)
steps.push(func(i / this.STEPS, fromValue, toValue - fromValue));
return steps;
};
this.scrollToLine = function(line, center, animate, callback) {
var pos = this.$cursorLayer.getPixelPosition({row: line, column: 0});
var offset = pos.top;
if (center)
offset -= this.$size.scrollerHeight / 2;
var initialScroll = this.scrollTop;
this.session.setScrollTop(offset);
if (animate !== false)
this.animateScrolling(initialScroll, callback);
};
this.animateScrolling = function(fromValue, callback) {
var toValue = this.scrollTop;
if (!this.$animatedScroll)
return;
var _self = this;
if (fromValue == toValue)
return;
if (this.$scrollAnimation) {
var oldSteps = this.$scrollAnimation.steps;
if (oldSteps.length) {
fromValue = oldSteps[0];
if (fromValue == toValue)
return;
}
}
var steps = _self.$calcSteps(fromValue, toValue);
this.$scrollAnimation = {from: fromValue, to: toValue, steps: steps};
clearInterval(this.$timer);
_self.session.setScrollTop(steps.shift());
_self.session.$scrollTop = toValue;
this.$timer = setInterval(function() {
if (steps.length) {
_self.session.setScrollTop(steps.shift());
_self.session.$scrollTop = toValue;
} else if (toValue != null) {
_self.session.$scrollTop = -1;
_self.session.setScrollTop(toValue);
toValue = null;
} else {
_self.$timer = clearInterval(_self.$timer);
_self.$scrollAnimation = null;
callback && callback();
}
}, 10);
};
this.scrollToY = function(scrollTop) {
if (this.scrollTop !== scrollTop) {
this.$loop.schedule(this.CHANGE_SCROLL);
this.scrollTop = scrollTop;
}
};
this.scrollToX = function(scrollLeft) {
if (this.scrollLeft !== scrollLeft)
this.scrollLeft = scrollLeft;
this.$loop.schedule(this.CHANGE_H_SCROLL);
};
this.scrollTo = function(x, y) {
this.session.setScrollTop(y);
this.session.setScrollLeft(y);
};
this.scrollBy = function(deltaX, deltaY) {
deltaY && this.session.setScrollTop(this.session.getScrollTop() + deltaY);
deltaX && this.session.setScrollLeft(this.session.getScrollLeft() + deltaX);
};
this.isScrollableBy = function(deltaX, deltaY) {
if (deltaY < 0 && this.session.getScrollTop() >= 1 - this.scrollMargin.top)
return true;
if (deltaY > 0 && this.session.getScrollTop() + this.$size.scrollerHeight
- this.layerConfig.maxHeight < -1 + this.scrollMargin.bottom)
return true;
if (deltaX < 0 && this.session.getScrollLeft() >= 1 - this.scrollMargin.left)
return true;
if (deltaX > 0 && this.session.getScrollLeft() + this.$size.scrollerWidth
- this.layerConfig.width < -1 + this.scrollMargin.right)
return true;
};
this.pixelToScreenCoordinates = function(x, y) {
var canvasPos = this.scroller.getBoundingClientRect();
var offset = (x + this.scrollLeft - canvasPos.left - this.$padding) / this.characterWidth;
var row = Math.floor((y + this.scrollTop - canvasPos.top) / this.lineHeight);
var col = Math.round(offset);
return {row: row, column: col, side: offset - col > 0 ? 1 : -1};
};
this.screenToTextCoordinates = function(x, y) {
var canvasPos = this.scroller.getBoundingClientRect();
var col = Math.round(
(x + this.scrollLeft - canvasPos.left - this.$padding) / this.characterWidth
);
var row = (y + this.scrollTop - canvasPos.top) / this.lineHeight;
return this.session.screenToDocumentPosition(row, Math.max(col, 0));
};
this.textToScreenCoordinates = function(row, column) {
var canvasPos = this.scroller.getBoundingClientRect();
var pos = this.session.documentToScreenPosition(row, column);
var x = this.$padding + Math.round(pos.column * this.characterWidth);
var y = pos.row * this.lineHeight;
return {
pageX: canvasPos.left + x - this.scrollLeft,
pageY: canvasPos.top + y - this.scrollTop
};
};
this.visualizeFocus = function() {
dom.addCssClass(this.container, "ace_focus");
};
this.visualizeBlur = function() {
dom.removeCssClass(this.container, "ace_focus");
};
this.showComposition = function(position) {
if (!this.$composition)
this.$composition = {
keepTextAreaAtCursor: this.$keepTextAreaAtCursor,
cssText: this.textarea.style.cssText
};
this.$keepTextAreaAtCursor = true;
dom.addCssClass(this.textarea, "ace_composition");
this.textarea.style.cssText = "";
this.$moveTextAreaToCursor();
};
this.setCompositionText = function(text) {
this.$moveTextAreaToCursor();
};
this.hideComposition = function() {
if (!this.$composition)
return;
dom.removeCssClass(this.textarea, "ace_composition");
this.$keepTextAreaAtCursor = this.$composition.keepTextAreaAtCursor;
this.textarea.style.cssText = this.$composition.cssText;
this.$composition = null;
};
this.setTheme = function(theme, cb) {
var _self = this;
this.$themeId = theme;
_self._dispatchEvent('themeChange',{theme:theme});
if (!theme || typeof theme == "string") {
var moduleName = theme || this.$options.theme.initialValue;
config.loadModule(["theme", moduleName], afterLoad);
} else {
afterLoad(theme);
}
function afterLoad(module) {
if (_self.$themeId != theme)
return cb && cb();
if (!module.cssClass)
return;
dom.importCssString(
module.cssText,
module.cssClass,
_self.container.ownerDocument
);
if (_self.theme)
dom.removeCssClass(_self.container, _self.theme.cssClass);
var padding = "padding" in module ? module.padding
: "padding" in (_self.theme || {}) ? 4 : _self.$padding;
if (_self.$padding && padding != _self.$padding)
_self.setPadding(padding);
_self.$theme = module.cssClass;
_self.theme = module;
dom.addCssClass(_self.container, module.cssClass);
dom.setCssClass(_self.container, "ace_dark", module.isDark);
if (_self.$size) {
_self.$size.width = 0;
_self.$updateSizeAsync();
}
_self._dispatchEvent('themeLoaded', {theme:module});
cb && cb();
}
};
this.getTheme = function() {
return this.$themeId;
};
this.setStyle = function(style, include) {
dom.setCssClass(this.container, style, include !== false);
};
this.unsetStyle = function(style) {
dom.removeCssClass(this.container, style);
};
this.setCursorStyle = function(style) {
if (this.scroller.style.cursor != style)
this.scroller.style.cursor = style;
};
this.setMouseCursor = function(cursorStyle) {
this.scroller.style.cursor = cursorStyle;
};
this.destroy = function() {
this.$textLayer.destroy();
this.$cursorLayer.destroy();
};
}).call(VirtualRenderer.prototype);
config.defineOptions(VirtualRenderer.prototype, "renderer", {
animatedScroll: {initialValue: false},
showInvisibles: {
set: function(value) {
if (this.$textLayer.setShowInvisibles(value))
this.$loop.schedule(this.CHANGE_TEXT);
},
initialValue: false
},
showPrintMargin: {
set: function() { this.$updatePrintMargin(); },
initialValue: true
},
printMarginColumn: {
set: function() { this.$updatePrintMargin(); },
initialValue: 80
},
printMargin: {
set: function(val) {
if (typeof val == "number")
this.$printMarginColumn = val;
this.$showPrintMargin = !!val;
this.$updatePrintMargin();
},
get: function() {
return this.$showPrintMargin && this.$printMarginColumn;
}
},
showGutter: {
set: function(show){
this.$gutter.style.display = show ? "block" : "none";
this.$loop.schedule(this.CHANGE_FULL);
this.onGutterResize();
},
initialValue: true
},
fadeFoldWidgets: {
set: function(show) {
dom.setCssClass(this.$gutter, "ace_fade-fold-widgets", show);
},
initialValue: false
},
showFoldWidgets: {
set: function(show) {this.$gutterLayer.setShowFoldWidgets(show)},
initialValue: true
},
showLineNumbers: {
set: function(show) {
this.$gutterLayer.setShowLineNumbers(show);
this.$loop.schedule(this.CHANGE_GUTTER);
},
initialValue: true
},
displayIndentGuides: {
set: function(show) {
if (this.$textLayer.setDisplayIndentGuides(show))
this.$loop.schedule(this.CHANGE_TEXT);
},
initialValue: true
},
highlightGutterLine: {
set: function(shouldHighlight) {
if (!this.$gutterLineHighlight) {
this.$gutterLineHighlight = dom.createElement("div");
this.$gutterLineHighlight.className = "ace_gutter-active-line";
this.$gutter.appendChild(this.$gutterLineHighlight);
return;
}
this.$gutterLineHighlight.style.display = shouldHighlight ? "" : "none";
if (this.$cursorLayer.$pixelPos)
this.$updateGutterLineHighlight();
},
initialValue: false,
value: true
},
hScrollBarAlwaysVisible: {
set: function(val) {
if (!this.$hScrollBarAlwaysVisible || !this.$horizScroll)
this.$loop.schedule(this.CHANGE_SCROLL);
},
initialValue: false
},
vScrollBarAlwaysVisible: {
set: function(val) {
if (!this.$vScrollBarAlwaysVisible || !this.$vScroll)
this.$loop.schedule(this.CHANGE_SCROLL);
},
initialValue: false
},
fontSize: {
set: function(size) {
if (typeof size == "number")
size = size + "px";
this.container.style.fontSize = size;
this.updateFontSize();
},
initialValue: 12
},
fontFamily: {
set: function(name) {
this.container.style.fontFamily = name;
this.updateFontSize();
}
},
maxLines: {
set: function(val) {
this.updateFull();
}
},
minLines: {
set: function(val) {
this.updateFull();
}
},
scrollPastEnd: {
set: function(val) {
val = +val || 0;
if (this.$scrollPastEnd == val)
return;
this.$scrollPastEnd = val;
this.$loop.schedule(this.CHANGE_SCROLL);
},
initialValue: 0,
handlesSet: true
},
fixedWidthGutter: {
set: function(val) {
this.$gutterLayer.$fixedWidth = !!val;
this.$loop.schedule(this.CHANGE_GUTTER);
}
},
theme: {
set: function(val) { this.setTheme(val) },
get: function() { return this.$themeId || this.theme; },
initialValue: "./theme/textmate",
handlesSet: true
}
});
exports.VirtualRenderer = VirtualRenderer;
});
define("ace/worker/worker_client",["require","exports","module","ace/lib/oop","ace/lib/net","ace/lib/event_emitter","ace/config"], function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
var net = require("../lib/net");
var EventEmitter = require("../lib/event_emitter").EventEmitter;
var config = require("../config");
var WorkerClient = function(topLevelNamespaces, mod, classname, workerUrl) {
this.$sendDeltaQueue = this.$sendDeltaQueue.bind(this);
this.changeListener = this.changeListener.bind(this);
this.onMessage = this.onMessage.bind(this);
if (require.nameToUrl && !require.toUrl)
require.toUrl = require.nameToUrl;
if (config.get("packaged") || !require.toUrl) {
workerUrl = workerUrl || config.moduleUrl(mod, "worker");
} else {
var normalizePath = this.$normalizePath;
workerUrl = workerUrl || normalizePath(require.toUrl("ace/worker/worker.js", null, "_"));
var tlns = {};
topLevelNamespaces.forEach(function(ns) {
tlns[ns] = normalizePath(require.toUrl(ns, null, "_").replace(/(\.js)?(\?.*)?$/, ""));
});
}
try {
this.$worker = new Worker(workerUrl);
} catch(e) {
if (e instanceof window.DOMException) {
var blob = this.$workerBlob(workerUrl);
var URL = window.URL || window.webkitURL;
var blobURL = URL.createObjectURL(blob);
this.$worker = new Worker(blobURL);
URL.revokeObjectURL(blobURL);
} else {
throw e;
}
}
this.$worker.postMessage({
init : true,
tlns : tlns,
module : mod,
classname : classname
});
this.callbackId = 1;
this.callbacks = {};
this.$worker.onmessage = this.onMessage;
};
(function(){
oop.implement(this, EventEmitter);
this.onMessage = function(e) {
var msg = e.data;
switch(msg.type) {
case "event":
this._signal(msg.name, {data: msg.data});
break;
case "call":
var callback = this.callbacks[msg.id];
if (callback) {
callback(msg.data);
delete this.callbacks[msg.id];
}
break;
case "error":
this.reportError(msg.data);
break;
case "log":
window.console && console.log && console.log.apply(console, msg.data);
break;
}
};
this.reportError = function(err) {
window.console && console.error && console.error(err);
};
this.$normalizePath = function(path) {
return net.qualifyURL(path);
};
this.terminate = function() {
this._signal("terminate", {});
this.deltaQueue = null;
this.$worker.terminate();
this.$worker = null;
if (this.$doc)
this.$doc.off("change", this.changeListener);
this.$doc = null;
};
this.send = function(cmd, args) {
this.$worker.postMessage({command: cmd, args: args});
};
this.call = function(cmd, args, callback) {
if (callback) {
var id = this.callbackId++;
this.callbacks[id] = callback;
args.push(id);
}
this.send(cmd, args);
};
this.emit = function(event, data) {
try {
this.$worker.postMessage({event: event, data: {data: data.data}});
}
catch(ex) {
console.error(ex.stack);
}
};
this.attachToDocument = function(doc) {
if(this.$doc)
this.terminate();
this.$doc = doc;
this.call("setValue", [doc.getValue()]);
doc.on("change", this.changeListener);
};
this.changeListener = function(e) {
if (!this.deltaQueue) {
this.deltaQueue = [e.data];
setTimeout(this.$sendDeltaQueue, 0);
} else
this.deltaQueue.push(e.data);
};
this.$sendDeltaQueue = function() {
var q = this.deltaQueue;
if (!q) return;
this.deltaQueue = null;
if (q.length > 20 && q.length > this.$doc.getLength() >> 1) {
this.call("setValue", [this.$doc.getValue()]);
} else
this.emit("change", {data: q});
};
this.$workerBlob = function(workerUrl) {
var script = "importScripts('" + net.qualifyURL(workerUrl) + "');";
try {
return new Blob([script], {"type": "application/javascript"});
} catch (e) { // Backwards-compatibility
var BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder;
var blobBuilder = new BlobBuilder();
blobBuilder.append(script);
return blobBuilder.getBlob("application/javascript");
}
};
}).call(WorkerClient.prototype);
var UIWorkerClient = function(topLevelNamespaces, mod, classname) {
this.$sendDeltaQueue = this.$sendDeltaQueue.bind(this);
this.changeListener = this.changeListener.bind(this);
this.callbackId = 1;
this.callbacks = {};
this.messageBuffer = [];
var main = null;
var emitSync = false;
var sender = Object.create(EventEmitter);
var _self = this;
this.$worker = {};
this.$worker.terminate = function() {};
this.$worker.postMessage = function(e) {
_self.messageBuffer.push(e);
if (main) {
if (emitSync)
setTimeout(processNext);
else
processNext();
}
};
this.setEmitSync = function(val) { emitSync = val };
var processNext = function() {
var msg = _self.messageBuffer.shift();
if (msg.command)
main[msg.command].apply(main, msg.args);
else if (msg.event)
sender._signal(msg.event, msg.data);
};
sender.postMessage = function(msg) {
_self.onMessage({data: msg});
};
sender.callback = function(data, callbackId) {
this.postMessage({type: "call", id: callbackId, data: data});
};
sender.emit = function(name, data) {
this.postMessage({type: "event", name: name, data: data});
};
config.loadModule(["worker", mod], function(Main) {
main = new Main[classname](sender);
while (_self.messageBuffer.length)
processNext();
});
};
UIWorkerClient.prototype = WorkerClient.prototype;
exports.UIWorkerClient = UIWorkerClient;
exports.WorkerClient = WorkerClient;
});
define("ace/placeholder",["require","exports","module","ace/range","ace/lib/event_emitter","ace/lib/oop"], function(require, exports, module) {
"use strict";
var Range = require("./range").Range;
var EventEmitter = require("./lib/event_emitter").EventEmitter;
var oop = require("./lib/oop");
var PlaceHolder = function(session, length, pos, others, mainClass, othersClass) {
var _self = this;
this.length = length;
this.session = session;
this.doc = session.getDocument();
this.mainClass = mainClass;
this.othersClass = othersClass;
this.$onUpdate = this.onUpdate.bind(this);
this.doc.on("change", this.$onUpdate);
this.$others = others;
this.$onCursorChange = function() {
setTimeout(function() {
_self.onCursorChange();
});
};
this.$pos = pos;
var undoStack = session.getUndoManager().$undoStack || session.getUndoManager().$undostack || {length: -1};
this.$undoStackDepth = undoStack.length;
this.setup();
session.selection.on("changeCursor", this.$onCursorChange);
};
(function() {
oop.implement(this, EventEmitter);
this.setup = function() {
var _self = this;
var doc = this.doc;
var session = this.session;
var pos = this.$pos;
this.selectionBefore = session.selection.toJSON();
if (session.selection.inMultiSelectMode)
session.selection.toSingleRange();
this.pos = doc.createAnchor(pos.row, pos.column);
this.markerId = session.addMarker(new Range(pos.row, pos.column, pos.row, pos.column + this.length), this.mainClass, null, false);
this.pos.on("change", function(event) {
session.removeMarker(_self.markerId);
_self.markerId = session.addMarker(new Range(event.value.row, event.value.column, event.value.row, event.value.column+_self.length), _self.mainClass, null, false);
});
this.others = [];
this.$others.forEach(function(other) {
var anchor = doc.createAnchor(other.row, other.column);
_self.others.push(anchor);
});
session.setUndoSelect(false);
};
this.showOtherMarkers = function() {
if(this.othersActive) return;
var session = this.session;
var _self = this;
this.othersActive = true;
this.others.forEach(function(anchor) {
anchor.markerId = session.addMarker(new Range(anchor.row, anchor.column, anchor.row, anchor.column+_self.length), _self.othersClass, null, false);
anchor.on("change", function(event) {
session.removeMarker(anchor.markerId);
anchor.markerId = session.addMarker(new Range(event.value.row, event.value.column, event.value.row, event.value.column+_self.length), _self.othersClass, null, false);
});
});
};
this.hideOtherMarkers = function() {
if(!this.othersActive) return;
this.othersActive = false;
for (var i = 0; i < this.others.length; i++) {
this.session.removeMarker(this.others[i].markerId);
}
};
this.onUpdate = function(event) {
var delta = event.data;
var range = delta.range;
if(range.start.row !== range.end.row) return;
if(range.start.row !== this.pos.row) return;
if (this.$updating) return;
this.$updating = true;
var lengthDiff = delta.action === "insertText" ? range.end.column - range.start.column : range.start.column - range.end.column;
if(range.start.column >= this.pos.column && range.start.column <= this.pos.column + this.length + 1) {
var distanceFromStart = range.start.column - this.pos.column;
this.length += lengthDiff;
if(!this.session.$fromUndo) {
if(delta.action === "insertText") {
for (var i = this.others.length - 1; i >= 0; i--) {
var otherPos = this.others[i];
var newPos = {row: otherPos.row, column: otherPos.column + distanceFromStart};
if(otherPos.row === range.start.row && range.start.column < otherPos.column)
newPos.column += lengthDiff;
this.doc.insert(newPos, delta.text);
}
} else if(delta.action === "removeText") {
for (var i = this.others.length - 1; i >= 0; i--) {
var otherPos = this.others[i];
var newPos = {row: otherPos.row, column: otherPos.column + distanceFromStart};
if(otherPos.row === range.start.row && range.start.column < otherPos.column)
newPos.column += lengthDiff;
this.doc.remove(new Range(newPos.row, newPos.column, newPos.row, newPos.column - lengthDiff));
}
}
if(range.start.column === this.pos.column && delta.action === "insertText") {
setTimeout(function() {
this.pos.setPosition(this.pos.row, this.pos.column - lengthDiff);
for (var i = 0; i < this.others.length; i++) {
var other = this.others[i];
var newPos = {row: other.row, column: other.column - lengthDiff};
if(other.row === range.start.row && range.start.column < other.column)
newPos.column += lengthDiff;
other.setPosition(newPos.row, newPos.column);
}
}.bind(this), 0);
}
else if(range.start.column === this.pos.column && delta.action === "removeText") {
setTimeout(function() {
for (var i = 0; i < this.others.length; i++) {
var other = this.others[i];
if(other.row === range.start.row && range.start.column < other.column) {
other.setPosition(other.row, other.column - lengthDiff);
}
}
}.bind(this), 0);
}
}
this.pos._emit("change", {value: this.pos});
for (var i = 0; i < this.others.length; i++) {
this.others[i]._emit("change", {value: this.others[i]});
}
}
this.$updating = false;
};
this.onCursorChange = function(event) {
if (this.$updating || !this.session) return;
var pos = this.session.selection.getCursor();
if (pos.row === this.pos.row && pos.column >= this.pos.column && pos.column <= this.pos.column + this.length) {
this.showOtherMarkers();
this._emit("cursorEnter", event);
} else {
this.hideOtherMarkers();
this._emit("cursorLeave", event);
}
};
this.detach = function() {
this.session.removeMarker(this.markerId);
this.hideOtherMarkers();
this.doc.removeEventListener("change", this.$onUpdate);
this.session.selection.removeEventListener("changeCursor", this.$onCursorChange);
this.pos.detach();
for (var i = 0; i < this.others.length; i++) {
this.others[i].detach();
}
this.session.setUndoSelect(true);
this.session = null;
};
this.cancel = function() {
if(this.$undoStackDepth === -1)
throw Error("Canceling placeholders only supported with undo manager attached to session.");
var undoManager = this.session.getUndoManager();
var undosRequired = (undoManager.$undoStack || undoManager.$undostack).length - this.$undoStackDepth;
for (var i = 0; i < undosRequired; i++) {
undoManager.undo(true);
}
if (this.selectionBefore)
this.session.selection.fromJSON(this.selectionBefore);
};
}).call(PlaceHolder.prototype);
exports.PlaceHolder = PlaceHolder;
});
define("ace/mouse/multi_select_handler",["require","exports","module","ace/lib/event","ace/lib/useragent"], function(require, exports, module) {
var event = require("../lib/event");
var useragent = require("../lib/useragent");
function isSamePoint(p1, p2) {
return p1.row == p2.row && p1.column == p2.column;
}
function onMouseDown(e) {
var ev = e.domEvent;
var alt = ev.altKey;
var shift = ev.shiftKey;
var ctrl = ev.ctrlKey;
var accel = e.getAccelKey();
var button = e.getButton();
if (ctrl && useragent.isMac)
button = ev.button;
if (e.editor.inMultiSelectMode && button == 2) {
e.editor.textInput.onContextMenu(e.domEvent);
return;
}
if (!ctrl && !alt && !accel) {
if (button === 0 && e.editor.inMultiSelectMode)
e.editor.exitMultiSelectMode();
return;
}
if (button !== 0)
return;
var editor = e.editor;
var selection = editor.selection;
var isMultiSelect = editor.inMultiSelectMode;
var pos = e.getDocumentPosition();
var cursor = selection.getCursor();
var inSelection = e.inSelection() || (selection.isEmpty() && isSamePoint(pos, cursor));
var mouseX = e.x, mouseY = e.y;
var onMouseSelection = function(e) {
mouseX = e.clientX;
mouseY = e.clientY;
};
var session = editor.session;
var screenAnchor = editor.renderer.pixelToScreenCoordinates(mouseX, mouseY);
var screenCursor = screenAnchor;
var selectionMode;
if (editor.$mouseHandler.$enableJumpToDef) {
if (ctrl && alt || accel && alt)
selectionMode = "add";
else if (alt)
selectionMode = "block";
} else {
if (accel && !alt) {
selectionMode = "add";
if (!isMultiSelect && shift)
return;
} else if (alt) {
selectionMode = "block";
}
}
if (selectionMode && useragent.isMac && ev.ctrlKey) {
editor.$mouseHandler.cancelContextMenu();
}
if (selectionMode == "add") {
if (!isMultiSelect && inSelection)
return; // dragging
if (!isMultiSelect) {
var range = selection.toOrientedRange();
editor.addSelectionMarker(range);
}
var oldRange = selection.rangeList.rangeAtPoint(pos);
editor.$blockScrolling++;
editor.inVirtualSelectionMode = true;
if (shift) {
oldRange = null;
range = selection.ranges[0];
editor.removeSelectionMarker(range);
}
editor.once("mouseup", function() {
var tmpSel = selection.toOrientedRange();
if (oldRange && tmpSel.isEmpty() && isSamePoint(oldRange.cursor, tmpSel.cursor))
selection.substractPoint(tmpSel.cursor);
else {
if (shift) {
selection.substractPoint(range.cursor);
} else if (range) {
editor.removeSelectionMarker(range);
selection.addRange(range);
}
selection.addRange(tmpSel);
}
editor.$blockScrolling--;
editor.inVirtualSelectionMode = false;
});
} else if (selectionMode == "block") {
e.stop();
editor.inVirtualSelectionMode = true;
var initialRange;
var rectSel = [];
var blockSelect = function() {
var newCursor = editor.renderer.pixelToScreenCoordinates(mouseX, mouseY);
var cursor = session.screenToDocumentPosition(newCursor.row, newCursor.column);
if (isSamePoint(screenCursor, newCursor) && isSamePoint(cursor, selection.lead))
return;
screenCursor = newCursor;
editor.selection.moveToPosition(cursor);
editor.renderer.scrollCursorIntoView();
editor.removeSelectionMarkers(rectSel);
rectSel = selection.rectangularRangeBlock(screenCursor, screenAnchor);
if (editor.$mouseHandler.$clickSelection && rectSel.length == 1 && rectSel[0].isEmpty())
rectSel[0] = editor.$mouseHandler.$clickSelection.clone();
rectSel.forEach(editor.addSelectionMarker, editor);
editor.updateSelectionMarkers();
};
if (isMultiSelect && !accel) {
selection.toSingleRange();
} else if (!isMultiSelect && accel) {
initialRange = selection.toOrientedRange();
editor.addSelectionMarker(initialRange);
}
if (shift)
screenAnchor = session.documentToScreenPosition(selection.lead);
else
selection.moveToPosition(pos);
screenCursor = {row: -1, column: -1};
var onMouseSelectionEnd = function(e) {
clearInterval(timerId);
editor.removeSelectionMarkers(rectSel);
if (!rectSel.length)
rectSel = [selection.toOrientedRange()];
editor.$blockScrolling++;
if (initialRange) {
editor.removeSelectionMarker(initialRange);
selection.toSingleRange(initialRange);
}
for (var i = 0; i < rectSel.length; i++)
selection.addRange(rectSel[i]);
editor.inVirtualSelectionMode = false;
editor.$mouseHandler.$clickSelection = null;
editor.$blockScrolling--;
};
var onSelectionInterval = blockSelect;
event.capture(editor.container, onMouseSelection, onMouseSelectionEnd);
var timerId = setInterval(function() {onSelectionInterval();}, 20);
return e.preventDefault();
}
}
exports.onMouseDown = onMouseDown;
});
define("ace/commands/multi_select_commands",["require","exports","module","ace/keyboard/hash_handler"], function(require, exports, module) {
exports.defaultCommands = [{
name: "addCursorAbove",
exec: function(editor) { editor.selectMoreLines(-1); },
bindKey: {win: "Ctrl-Alt-Up", mac: "Ctrl-Alt-Up"},
readonly: true
}, {
name: "addCursorBelow",
exec: function(editor) { editor.selectMoreLines(1); },
bindKey: {win: "Ctrl-Alt-Down", mac: "Ctrl-Alt-Down"},
readonly: true
}, {
name: "addCursorAboveSkipCurrent",
exec: function(editor) { editor.selectMoreLines(-1, true); },
bindKey: {win: "Ctrl-Alt-Shift-Up", mac: "Ctrl-Alt-Shift-Up"},
readonly: true
}, {
name: "addCursorBelowSkipCurrent",
exec: function(editor) { editor.selectMoreLines(1, true); },
bindKey: {win: "Ctrl-Alt-Shift-Down", mac: "Ctrl-Alt-Shift-Down"},
readonly: true
}, {
name: "selectMoreBefore",
exec: function(editor) { editor.selectMore(-1); },
bindKey: {win: "Ctrl-Alt-Left", mac: "Ctrl-Alt-Left"},
readonly: true
}, {
name: "selectMoreAfter",
exec: function(editor) { editor.selectMore(1); },
bindKey: {win: "Ctrl-Alt-Right", mac: "Ctrl-Alt-Right"},
readonly: true
}, {
name: "selectNextBefore",
exec: function(editor) { editor.selectMore(-1, true); },
bindKey: {win: "Ctrl-Alt-Shift-Left", mac: "Ctrl-Alt-Shift-Left"},
readonly: true
}, {
name: "selectNextAfter",
exec: function(editor) { editor.selectMore(1, true); },
bindKey: {win: "Ctrl-Alt-Shift-Right", mac: "Ctrl-Alt-Shift-Right"},
readonly: true
}, {
name: "splitIntoLines",
exec: function(editor) { editor.multiSelect.splitIntoLines(); },
bindKey: {win: "Ctrl-Alt-L", mac: "Ctrl-Alt-L"},
readonly: true
}, {
name: "alignCursors",
exec: function(editor) { editor.alignCursors(); },
bindKey: {win: "Ctrl-Alt-A", mac: "Ctrl-Alt-A"}
}, {
name: "findAll",
exec: function(editor) { editor.findAll(); },
bindKey: {win: "Ctrl-Alt-K", mac: "Ctrl-Alt-G"},
readonly: true
}];
exports.multiSelectCommands = [{
name: "singleSelection",
bindKey: "esc",
exec: function(editor) { editor.exitMultiSelectMode(); },
readonly: true,
isAvailable: function(editor) {return editor && editor.inMultiSelectMode}
}];
var HashHandler = require("../keyboard/hash_handler").HashHandler;
exports.keyboardHandler = new HashHandler(exports.multiSelectCommands);
});
define("ace/multi_select",["require","exports","module","ace/range_list","ace/range","ace/selection","ace/mouse/multi_select_handler","ace/lib/event","ace/lib/lang","ace/commands/multi_select_commands","ace/search","ace/edit_session","ace/editor","ace/config"], function(require, exports, module) {
var RangeList = require("./range_list").RangeList;
var Range = require("./range").Range;
var Selection = require("./selection").Selection;
var onMouseDown = require("./mouse/multi_select_handler").onMouseDown;
var event = require("./lib/event");
var lang = require("./lib/lang");
var commands = require("./commands/multi_select_commands");
exports.commands = commands.defaultCommands.concat(commands.multiSelectCommands);
var Search = require("./search").Search;
var search = new Search();
function find(session, needle, dir) {
search.$options.wrap = true;
search.$options.needle = needle;
search.$options.backwards = dir == -1;
return search.find(session);
}
var EditSession = require("./edit_session").EditSession;
(function() {
this.getSelectionMarkers = function() {
return this.$selectionMarkers;
};
}).call(EditSession.prototype);
(function() {
this.ranges = null;
this.rangeList = null;
this.addRange = function(range, $blockChangeEvents) {
if (!range)
return;
if (!this.inMultiSelectMode && this.rangeCount === 0) {
var oldRange = this.toOrientedRange();
this.rangeList.add(oldRange);
this.rangeList.add(range);
if (this.rangeList.ranges.length != 2) {
this.rangeList.removeAll();
return $blockChangeEvents || this.fromOrientedRange(range);
}
this.rangeList.removeAll();
this.rangeList.add(oldRange);
this.$onAddRange(oldRange);
}
if (!range.cursor)
range.cursor = range.end;
var removed = this.rangeList.add(range);
this.$onAddRange(range);
if (removed.length)
this.$onRemoveRange(removed);
if (this.rangeCount > 1 && !this.inMultiSelectMode) {
this._signal("multiSelect");
this.inMultiSelectMode = true;
this.session.$undoSelect = false;
this.rangeList.attach(this.session);
}
return $blockChangeEvents || this.fromOrientedRange(range);
};
this.toSingleRange = function(range) {
range = range || this.ranges[0];
var removed = this.rangeList.removeAll();
if (removed.length)
this.$onRemoveRange(removed);
range && this.fromOrientedRange(range);
};
this.substractPoint = function(pos) {
var removed = this.rangeList.substractPoint(pos);
if (removed) {
this.$onRemoveRange(removed);
return removed[0];
}
};
this.mergeOverlappingRanges = function() {
var removed = this.rangeList.merge();
if (removed.length)
this.$onRemoveRange(removed);
else if(this.ranges[0])
this.fromOrientedRange(this.ranges[0]);
};
this.$onAddRange = function(range) {
this.rangeCount = this.rangeList.ranges.length;
this.ranges.unshift(range);
this._signal("addRange", {range: range});
};
this.$onRemoveRange = function(removed) {
this.rangeCount = this.rangeList.ranges.length;
if (this.rangeCount == 1 && this.inMultiSelectMode) {
var lastRange = this.rangeList.ranges.pop();
removed.push(lastRange);
this.rangeCount = 0;
}
for (var i = removed.length; i--; ) {
var index = this.ranges.indexOf(removed[i]);
this.ranges.splice(index, 1);
}
this._signal("removeRange", {ranges: removed});
if (this.rangeCount === 0 && this.inMultiSelectMode) {
this.inMultiSelectMode = false;
this._signal("singleSelect");
this.session.$undoSelect = true;
this.rangeList.detach(this.session);
}
lastRange = lastRange || this.ranges[0];
if (lastRange && !lastRange.isEqual(this.getRange()))
this.fromOrientedRange(lastRange);
};
this.$initRangeList = function() {
if (this.rangeList)
return;
this.rangeList = new RangeList();
this.ranges = [];
this.rangeCount = 0;
};
this.getAllRanges = function() {
return this.rangeCount ? this.rangeList.ranges.concat() : [this.getRange()];
};
this.splitIntoLines = function () {
if (this.rangeCount > 1) {
var ranges = this.rangeList.ranges;
var lastRange = ranges[ranges.length - 1];
var range = Range.fromPoints(ranges[0].start, lastRange.end);
this.toSingleRange();
this.setSelectionRange(range, lastRange.cursor == lastRange.start);
} else {
var range = this.getRange();
var isBackwards = this.isBackwards();
var startRow = range.start.row;
var endRow = range.end.row;
if (startRow == endRow) {
if (isBackwards)
var start = range.end, end = range.start;
else
var start = range.start, end = range.end;
this.addRange(Range.fromPoints(end, end));
this.addRange(Range.fromPoints(start, start));
return;
}
var rectSel = [];
var r = this.getLineRange(startRow, true);
r.start.column = range.start.column;
rectSel.push(r);
for (var i = startRow + 1; i < endRow; i++)
rectSel.push(this.getLineRange(i, true));
r = this.getLineRange(endRow, true);
r.end.column = range.end.column;
rectSel.push(r);
rectSel.forEach(this.addRange, this);
}
};
this.toggleBlockSelection = function () {
if (this.rangeCount > 1) {
var ranges = this.rangeList.ranges;
var lastRange = ranges[ranges.length - 1];
var range = Range.fromPoints(ranges[0].start, lastRange.end);
this.toSingleRange();
this.setSelectionRange(range, lastRange.cursor == lastRange.start);
} else {
var cursor = this.session.documentToScreenPosition(this.selectionLead);
var anchor = this.session.documentToScreenPosition(this.selectionAnchor);
var rectSel = this.rectangularRangeBlock(cursor, anchor);
rectSel.forEach(this.addRange, this);
}
};
this.rectangularRangeBlock = function(screenCursor, screenAnchor, includeEmptyLines) {
var rectSel = [];
var xBackwards = screenCursor.column < screenAnchor.column;
if (xBackwards) {
var startColumn = screenCursor.column;
var endColumn = screenAnchor.column;
} else {
var startColumn = screenAnchor.column;
var endColumn = screenCursor.column;
}
var yBackwards = screenCursor.row < screenAnchor.row;
if (yBackwards) {
var startRow = screenCursor.row;
var endRow = screenAnchor.row;
} else {
var startRow = screenAnchor.row;
var endRow = screenCursor.row;
}
if (startColumn < 0)
startColumn = 0;
if (startRow < 0)
startRow = 0;
if (startRow == endRow)
includeEmptyLines = true;
for (var row = startRow; row <= endRow; row++) {
var range = Range.fromPoints(
this.session.screenToDocumentPosition(row, startColumn),
this.session.screenToDocumentPosition(row, endColumn)
);
if (range.isEmpty()) {
if (docEnd && isSamePoint(range.end, docEnd))
break;
var docEnd = range.end;
}
range.cursor = xBackwards ? range.start : range.end;
rectSel.push(range);
}
if (yBackwards)
rectSel.reverse();
if (!includeEmptyLines) {
var end = rectSel.length - 1;
while (rectSel[end].isEmpty() && end > 0)
end--;
if (end > 0) {
var start = 0;
while (rectSel[start].isEmpty())
start++;
}
for (var i = end; i >= start; i--) {
if (rectSel[i].isEmpty())
rectSel.splice(i, 1);
}
}
return rectSel;
};
}).call(Selection.prototype);
var Editor = require("./editor").Editor;
(function() {
this.updateSelectionMarkers = function() {
this.renderer.updateCursor();
this.renderer.updateBackMarkers();
};
this.addSelectionMarker = function(orientedRange) {
if (!orientedRange.cursor)
orientedRange.cursor = orientedRange.end;
var style = this.getSelectionStyle();
orientedRange.marker = this.session.addMarker(orientedRange, "ace_selection", style);
this.session.$selectionMarkers.push(orientedRange);
this.session.selectionMarkerCount = this.session.$selectionMarkers.length;
return orientedRange;
};
this.removeSelectionMarker = function(range) {
if (!range.marker)
return;
this.session.removeMarker(range.marker);
var index = this.session.$selectionMarkers.indexOf(range);
if (index != -1)
this.session.$selectionMarkers.splice(index, 1);
this.session.selectionMarkerCount = this.session.$selectionMarkers.length;
};
this.removeSelectionMarkers = function(ranges) {
var markerList = this.session.$selectionMarkers;
for (var i = ranges.length; i--; ) {
var range = ranges[i];
if (!range.marker)
continue;
this.session.removeMarker(range.marker);
var index = markerList.indexOf(range);
if (index != -1)
markerList.splice(index, 1);
}
this.session.selectionMarkerCount = markerList.length;
};
this.$onAddRange = function(e) {
this.addSelectionMarker(e.range);
this.renderer.updateCursor();
this.renderer.updateBackMarkers();
};
this.$onRemoveRange = function(e) {
this.removeSelectionMarkers(e.ranges);
this.renderer.updateCursor();
this.renderer.updateBackMarkers();
};
this.$onMultiSelect = function(e) {
if (this.inMultiSelectMode)
return;
this.inMultiSelectMode = true;
this.setStyle("ace_multiselect");
this.keyBinding.addKeyboardHandler(commands.keyboardHandler);
this.commands.setDefaultHandler("exec", this.$onMultiSelectExec);
this.renderer.updateCursor();
this.renderer.updateBackMarkers();
};
this.$onSingleSelect = function(e) {
if (this.session.multiSelect.inVirtualMode)
return;
this.inMultiSelectMode = false;
this.unsetStyle("ace_multiselect");
this.keyBinding.removeKeyboardHandler(commands.keyboardHandler);
this.commands.removeDefaultHandler("exec", this.$onMultiSelectExec);
this.renderer.updateCursor();
this.renderer.updateBackMarkers();
this._emit("changeSelection");
};
this.$onMultiSelectExec = function(e) {
var command = e.command;
var editor = e.editor;
if (!editor.multiSelect)
return;
if (!command.multiSelectAction) {
var result = command.exec(editor, e.args || {});
editor.multiSelect.addRange(editor.multiSelect.toOrientedRange());
editor.multiSelect.mergeOverlappingRanges();
} else if (command.multiSelectAction == "forEach") {
result = editor.forEachSelection(command, e.args);
} else if (command.multiSelectAction == "forEachLine") {
result = editor.forEachSelection(command, e.args, true);
} else if (command.multiSelectAction == "single") {
editor.exitMultiSelectMode();
result = command.exec(editor, e.args || {});
} else {
result = command.multiSelectAction(editor, e.args || {});
}
return result;
};
this.forEachSelection = function(cmd, args, options) {
if (this.inVirtualSelectionMode)
return;
var keepOrder = options && options.keepOrder;
var $byLines = options == true || options && options.$byLines
var session = this.session;
var selection = this.selection;
var rangeList = selection.rangeList;
var ranges = (keepOrder ? selection : rangeList).ranges;
var result;
if (!ranges.length)
return cmd.exec ? cmd.exec(this, args || {}) : cmd(this, args || {});
var reg = selection._eventRegistry;
selection._eventRegistry = {};
var tmpSel = new Selection(session);
this.inVirtualSelectionMode = true;
for (var i = ranges.length; i--;) {
if ($byLines) {
while (i > 0 && ranges[i].start.row == ranges[i - 1].end.row)
i--;
}
tmpSel.fromOrientedRange(ranges[i]);
tmpSel.index = i;
this.selection = session.selection = tmpSel;
var cmdResult = cmd.exec ? cmd.exec(this, args || {}) : cmd(this, args || {});
if (!result && cmdResult !== undefined)
result = cmdResult;
tmpSel.toOrientedRange(ranges[i]);
}
tmpSel.detach();
this.selection = session.selection = selection;
this.inVirtualSelectionMode = false;
selection._eventRegistry = reg;
selection.mergeOverlappingRanges();
var anim = this.renderer.$scrollAnimation;
this.onCursorChange();
this.onSelectionChange();
if (anim && anim.from == anim.to)
this.renderer.animateScrolling(anim.from);
return result;
};
this.exitMultiSelectMode = function() {
if (!this.inMultiSelectMode || this.inVirtualSelectionMode)
return;
this.multiSelect.toSingleRange();
};
this.getSelectedText = function() {
var text = "";
if (this.inMultiSelectMode && !this.inVirtualSelectionMode) {
var ranges = this.multiSelect.rangeList.ranges;
var buf = [];
for (var i = 0; i < ranges.length; i++) {
buf.push(this.session.getTextRange(ranges[i]));
}
var nl = this.session.getDocument().getNewLineCharacter();
text = buf.join(nl);
if (text.length == (buf.length - 1) * nl.length)
text = "";
} else if (!this.selection.isEmpty()) {
text = this.session.getTextRange(this.getSelectionRange());
}
return text;
};
this.$checkMultiselectChange = function(e, anchor) {
if (this.inMultiSelectMode && !this.inVirtualSelectionMode) {
var range = this.multiSelect.ranges[0];
if (this.multiSelect.isEmpty() && anchor == this.multiSelect.anchor)
return;
var pos = anchor == this.multiSelect.anchor
? range.cursor == range.start ? range.end : range.start
: range.cursor;
if (!isSamePoint(pos, anchor))
this.multiSelect.toSingleRange(this.multiSelect.toOrientedRange());
}
};
this.onPaste = function(text) {
if (this.$readOnly)
return;
var e = {text: text};
this._signal("paste", e);
text = e.text;
if (!this.inMultiSelectMode || this.inVirtualSelectionMode)
return this.insert(text);
var lines = text.split(/\r\n|\r|\n/);
var ranges = this.selection.rangeList.ranges;
if (lines.length > ranges.length || lines.length < 2 || !lines[1])
return this.commands.exec("insertstring", this, text);
for (var i = ranges.length; i--;) {
var range = ranges[i];
if (!range.isEmpty())
this.session.remove(range);
this.session.insert(range.start, lines[i]);
}
};
this.findAll = function(needle, options, additive) {
options = options || {};
options.needle = needle || options.needle;
if (options.needle == undefined) {
var range = this.selection.isEmpty()
? this.selection.getWordRange()
: this.selection.getRange();
options.needle = this.session.getTextRange(range);
}
this.$search.set(options);
var ranges = this.$search.findAll(this.session);
if (!ranges.length)
return 0;
this.$blockScrolling += 1;
var selection = this.multiSelect;
if (!additive)
selection.toSingleRange(ranges[0]);
for (var i = ranges.length; i--; )
selection.addRange(ranges[i], true);
if (range && selection.rangeList.rangeAtPoint(range.start))
selection.addRange(range, true);
this.$blockScrolling -= 1;
return ranges.length;
};
this.selectMoreLines = function(dir, skip) {
var range = this.selection.toOrientedRange();
var isBackwards = range.cursor == range.end;
var screenLead = this.session.documentToScreenPosition(range.cursor);
if (this.selection.$desiredColumn)
screenLead.column = this.selection.$desiredColumn;
var lead = this.session.screenToDocumentPosition(screenLead.row + dir, screenLead.column);
if (!range.isEmpty()) {
var screenAnchor = this.session.documentToScreenPosition(isBackwards ? range.end : range.start);
var anchor = this.session.screenToDocumentPosition(screenAnchor.row + dir, screenAnchor.column);
} else {
var anchor = lead;
}
if (isBackwards) {
var newRange = Range.fromPoints(lead, anchor);
newRange.cursor = newRange.start;
} else {
var newRange = Range.fromPoints(anchor, lead);
newRange.cursor = newRange.end;
}
newRange.desiredColumn = screenLead.column;
if (!this.selection.inMultiSelectMode) {
this.selection.addRange(range);
} else {
if (skip)
var toRemove = range.cursor;
}
this.selection.addRange(newRange);
if (toRemove)
this.selection.substractPoint(toRemove);
};
this.transposeSelections = function(dir) {
var session = this.session;
var sel = session.multiSelect;
var all = sel.ranges;
for (var i = all.length; i--; ) {
var range = all[i];
if (range.isEmpty()) {
var tmp = session.getWordRange(range.start.row, range.start.column);
range.start.row = tmp.start.row;
range.start.column = tmp.start.column;
range.end.row = tmp.end.row;
range.end.column = tmp.end.column;
}
}
sel.mergeOverlappingRanges();
var words = [];
for (var i = all.length; i--; ) {
var range = all[i];
words.unshift(session.getTextRange(range));
}
if (dir < 0)
words.unshift(words.pop());
else
words.push(words.shift());
for (var i = all.length; i--; ) {
var range = all[i];
var tmp = range.clone();
session.replace(range, words[i]);
range.start.row = tmp.start.row;
range.start.column = tmp.start.column;
}
};
this.selectMore = function(dir, skip, stopAtFirst) {
var session = this.session;
var sel = session.multiSelect;
var range = sel.toOrientedRange();
if (range.isEmpty()) {
range = session.getWordRange(range.start.row, range.start.column);
range.cursor = dir == -1 ? range.start : range.end;
this.multiSelect.addRange(range);
if (stopAtFirst)
return;
}
var needle = session.getTextRange(range);
var newRange = find(session, needle, dir);
if (newRange) {
newRange.cursor = dir == -1 ? newRange.start : newRange.end;
this.$blockScrolling += 1;
this.session.unfold(newRange);
this.multiSelect.addRange(newRange);
this.$blockScrolling -= 1;
this.renderer.scrollCursorIntoView(null, 0.5);
}
if (skip)
this.multiSelect.substractPoint(range.cursor);
};
this.alignCursors = function() {
var session = this.session;
var sel = session.multiSelect;
var ranges = sel.ranges;
var row = -1;
var sameRowRanges = ranges.filter(function(r) {
if (r.cursor.row == row)
return true;
row = r.cursor.row;
});
if (!ranges.length || sameRowRanges.length == ranges.length - 1) {
var range = this.selection.getRange();
var fr = range.start.row, lr = range.end.row;
var guessRange = fr == lr;
if (guessRange) {
var max = this.session.getLength();
var line;
do {
line = this.session.getLine(lr);
} while (/[=:]/.test(line) && ++lr < max);
do {
line = this.session.getLine(fr);
} while (/[=:]/.test(line) && --fr > 0);
if (fr < 0) fr = 0;
if (lr >= max) lr = max - 1;
}
var lines = this.session.doc.removeLines(fr, lr);
lines = this.$reAlignText(lines, guessRange);
this.session.doc.insert({row: fr, column: 0}, lines.join("\n") + "\n");
if (!guessRange) {
range.start.column = 0;
range.end.column = lines[lines.length - 1].length;
}
this.selection.setRange(range);
} else {
sameRowRanges.forEach(function(r) {
sel.substractPoint(r.cursor);
});
var maxCol = 0;
var minSpace = Infinity;
var spaceOffsets = ranges.map(function(r) {
var p = r.cursor;
var line = session.getLine(p.row);
var spaceOffset = line.substr(p.column).search(/\S/g);
if (spaceOffset == -1)
spaceOffset = 0;
if (p.column > maxCol)
maxCol = p.column;
if (spaceOffset < minSpace)
minSpace = spaceOffset;
return spaceOffset;
});
ranges.forEach(function(r, i) {
var p = r.cursor;
var l = maxCol - p.column;
var d = spaceOffsets[i] - minSpace;
if (l > d)
session.insert(p, lang.stringRepeat(" ", l - d));
else
session.remove(new Range(p.row, p.column, p.row, p.column - l + d));
r.start.column = r.end.column = maxCol;
r.start.row = r.end.row = p.row;
r.cursor = r.end;
});
sel.fromOrientedRange(ranges[0]);
this.renderer.updateCursor();
this.renderer.updateBackMarkers();
}
};
this.$reAlignText = function(lines, forceLeft) {
var isLeftAligned = true, isRightAligned = true;
var startW, textW, endW;
return lines.map(function(line) {
var m = line.match(/(\s*)(.*?)(\s*)([=:].*)/);
if (!m)
return [line];
if (startW == null) {
startW = m[1].length;
textW = m[2].length;
endW = m[3].length;
return m;
}
if (startW + textW + endW != m[1].length + m[2].length + m[3].length)
isRightAligned = false;
if (startW != m[1].length)
isLeftAligned = false;
if (startW > m[1].length)
startW = m[1].length;
if (textW < m[2].length)
textW = m[2].length;
if (endW > m[3].length)
endW = m[3].length;
return m;
}).map(forceLeft ? alignLeft :
isLeftAligned ? isRightAligned ? alignRight : alignLeft : unAlign);
function spaces(n) {
return lang.stringRepeat(" ", n);
}
function alignLeft(m) {
return !m[2] ? m[0] : spaces(startW) + m[2]
+ spaces(textW - m[2].length + endW)
+ m[4].replace(/^([=:])\s+/, "$1 ");
}
function alignRight(m) {
return !m[2] ? m[0] : spaces(startW + textW - m[2].length) + m[2]
+ spaces(endW, " ")
+ m[4].replace(/^([=:])\s+/, "$1 ");
}
function unAlign(m) {
return !m[2] ? m[0] : spaces(startW) + m[2]
+ spaces(endW)
+ m[4].replace(/^([=:])\s+/, "$1 ");
}
};
}).call(Editor.prototype);
function isSamePoint(p1, p2) {
return p1.row == p2.row && p1.column == p2.column;
}
exports.onSessionChange = function(e) {
var session = e.session;
if (session && !session.multiSelect) {
session.$selectionMarkers = [];
session.selection.$initRangeList();
session.multiSelect = session.selection;
}
this.multiSelect = session && session.multiSelect;
var oldSession = e.oldSession;
if (oldSession) {
oldSession.multiSelect.off("addRange", this.$onAddRange);
oldSession.multiSelect.off("removeRange", this.$onRemoveRange);
oldSession.multiSelect.off("multiSelect", this.$onMultiSelect);
oldSession.multiSelect.off("singleSelect", this.$onSingleSelect);
oldSession.multiSelect.lead.off("change", this.$checkMultiselectChange);
oldSession.multiSelect.anchor.off("change", this.$checkMultiselectChange);
}
if (session) {
session.multiSelect.on("addRange", this.$onAddRange);
session.multiSelect.on("removeRange", this.$onRemoveRange);
session.multiSelect.on("multiSelect", this.$onMultiSelect);
session.multiSelect.on("singleSelect", this.$onSingleSelect);
session.multiSelect.lead.on("change", this.$checkMultiselectChange);
session.multiSelect.anchor.on("change", this.$checkMultiselectChange);
}
if (session && this.inMultiSelectMode != session.selection.inMultiSelectMode) {
if (session.selection.inMultiSelectMode)
this.$onMultiSelect();
else
this.$onSingleSelect();
}
};
function MultiSelect(editor) {
if (editor.$multiselectOnSessionChange)
return;
editor.$onAddRange = editor.$onAddRange.bind(editor);
editor.$onRemoveRange = editor.$onRemoveRange.bind(editor);
editor.$onMultiSelect = editor.$onMultiSelect.bind(editor);
editor.$onSingleSelect = editor.$onSingleSelect.bind(editor);
editor.$multiselectOnSessionChange = exports.onSessionChange.bind(editor);
editor.$checkMultiselectChange = editor.$checkMultiselectChange.bind(editor);
editor.$multiselectOnSessionChange(editor);
editor.on("changeSession", editor.$multiselectOnSessionChange);
editor.on("mousedown", onMouseDown);
editor.commands.addCommands(commands.defaultCommands);
addAltCursorListeners(editor);
}
function addAltCursorListeners(editor){
var el = editor.textInput.getElement();
var altCursor = false;
event.addListener(el, "keydown", function(e) {
if (e.keyCode == 18 && !(e.ctrlKey || e.shiftKey || e.metaKey)) {
if (!altCursor) {
editor.renderer.setMouseCursor("crosshair");
altCursor = true;
}
} else if (altCursor) {
reset();
}
});
event.addListener(el, "keyup", reset);
event.addListener(el, "blur", reset);
function reset(e) {
if (altCursor) {
editor.renderer.setMouseCursor("");
altCursor = false;
}
}
}
exports.MultiSelect = MultiSelect;
require("./config").defineOptions(Editor.prototype, "editor", {
enableMultiselect: {
set: function(val) {
MultiSelect(this);
if (val) {
this.on("changeSession", this.$multiselectOnSessionChange);
this.on("mousedown", onMouseDown);
} else {
this.off("changeSession", this.$multiselectOnSessionChange);
this.off("mousedown", onMouseDown);
}
},
value: true
}
});
});
define("ace/mode/folding/fold_mode",["require","exports","module","ace/range"], function(require, exports, module) {
"use strict";
var Range = require("../../range").Range;
var FoldMode = exports.FoldMode = function() {};
(function() {
this.foldingStartMarker = null;
this.foldingStopMarker = null;
this.getFoldWidget = function(session, foldStyle, row) {
var line = session.getLine(row);
if (this.foldingStartMarker.test(line))
return "start";
if (foldStyle == "markbeginend"
&& this.foldingStopMarker
&& this.foldingStopMarker.test(line))
return "end";
return "";
};
this.getFoldWidgetRange = function(session, foldStyle, row) {
return null;
};
this.indentationBlock = function(session, row, column) {
var re = /\S/;
var line = session.getLine(row);
var startLevel = line.search(re);
if (startLevel == -1)
return;
var startColumn = column || line.length;
var maxRow = session.getLength();
var startRow = row;
var endRow = row;
while (++row < maxRow) {
var level = session.getLine(row).search(re);
if (level == -1)
continue;
if (level <= startLevel)
break;
endRow = row;
}
if (endRow > startRow) {
var endColumn = session.getLine(endRow).length;
return new Range(startRow, startColumn, endRow, endColumn);
}
};
this.openingBracketBlock = function(session, bracket, row, column, typeRe) {
var start = {row: row, column: column + 1};
var end = session.$findClosingBracket(bracket, start, typeRe);
if (!end)
return;
var fw = session.foldWidgets[end.row];
if (fw == null)
fw = session.getFoldWidget(end.row);
if (fw == "start" && end.row > start.row) {
end.row --;
end.column = session.getLine(end.row).length;
}
return Range.fromPoints(start, end);
};
this.closingBracketBlock = function(session, bracket, row, column, typeRe) {
var end = {row: row, column: column};
var start = session.$findOpeningBracket(bracket, end);
if (!start)
return;
start.column++;
end.column--;
return Range.fromPoints(start, end);
};
}).call(FoldMode.prototype);
});
define("ace/theme/textmate",["require","exports","module","ace/lib/dom"], function(require, exports, module) {
"use strict";
exports.isDark = false;
exports.cssClass = "ace-tm";
exports.cssText = ".ace-tm .ace_gutter {\
background: #f0f0f0;\
color: #333;\
}\
.ace-tm .ace_print-margin {\
width: 1px;\
background: #e8e8e8;\
}\
.ace-tm .ace_fold {\
background-color: #6B72E6;\
}\
.ace-tm {\
background-color: #FFFFFF;\
color: black;\
}\
.ace-tm .ace_cursor {\
color: black;\
}\
.ace-tm .ace_invisible {\
color: rgb(191, 191, 191);\
}\
.ace-tm .ace_storage,\
.ace-tm .ace_keyword {\
color: blue;\
}\
.ace-tm .ace_constant {\
color: rgb(197, 6, 11);\
}\
.ace-tm .ace_constant.ace_buildin {\
color: rgb(88, 72, 246);\
}\
.ace-tm .ace_constant.ace_language {\
color: rgb(88, 92, 246);\
}\
.ace-tm .ace_constant.ace_library {\
color: rgb(6, 150, 14);\
}\
.ace-tm .ace_invalid {\
background-color: rgba(255, 0, 0, 0.1);\
color: red;\
}\
.ace-tm .ace_support.ace_function {\
color: rgb(60, 76, 114);\
}\
.ace-tm .ace_support.ace_constant {\
color: rgb(6, 150, 14);\
}\
.ace-tm .ace_support.ace_type,\
.ace-tm .ace_support.ace_class {\
color: rgb(109, 121, 222);\
}\
.ace-tm .ace_keyword.ace_operator {\
color: rgb(104, 118, 135);\
}\
.ace-tm .ace_string {\
color: rgb(3, 106, 7);\
}\
.ace-tm .ace_comment {\
color: rgb(76, 136, 107);\
}\
.ace-tm .ace_comment.ace_doc {\
color: rgb(0, 102, 255);\
}\
.ace-tm .ace_comment.ace_doc.ace_tag {\
color: rgb(128, 159, 191);\
}\
.ace-tm .ace_constant.ace_numeric {\
color: rgb(0, 0, 205);\
}\
.ace-tm .ace_variable {\
color: rgb(49, 132, 149);\
}\
.ace-tm .ace_xml-pe {\
color: rgb(104, 104, 91);\
}\
.ace-tm .ace_entity.ace_name.ace_function {\
color: #0000A2;\
}\
.ace-tm .ace_heading {\
color: rgb(12, 7, 255);\
}\
.ace-tm .ace_list {\
color:rgb(185, 6, 144);\
}\
.ace-tm .ace_meta.ace_tag {\
color:rgb(0, 22, 142);\
}\
.ace-tm .ace_string.ace_regex {\
color: rgb(255, 0, 0)\
}\
.ace-tm .ace_marker-layer .ace_selection {\
background: rgb(181, 213, 255);\
}\
.ace-tm.ace_multiselect .ace_selection.ace_start {\
box-shadow: 0 0 3px 0px white;\
border-radius: 2px;\
}\
.ace-tm .ace_marker-layer .ace_step {\
background: rgb(252, 255, 0);\
}\
.ace-tm .ace_marker-layer .ace_stack {\
background: rgb(164, 229, 101);\
}\
.ace-tm .ace_marker-layer .ace_bracket {\
margin: -1px 0 0 -1px;\
border: 1px solid rgb(192, 192, 192);\
}\
.ace-tm .ace_marker-layer .ace_active-line {\
background: rgba(0, 0, 0, 0.07);\
}\
.ace-tm .ace_gutter-active-line {\
background-color : #dcdcdc;\
}\
.ace-tm .ace_marker-layer .ace_selected-word {\
background: rgb(250, 250, 255);\
border: 1px solid rgb(200, 200, 250);\
}\
.ace-tm .ace_indent-guide {\
background: url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAACCAYAAACZgbYnAAAAE0lEQVQImWP4////f4bLly//BwAmVgd1/w11/gAAAABJRU5ErkJggg==\") right repeat-y;\
}\
";
var dom = require("../lib/dom");
dom.importCssString(exports.cssText, exports.cssClass);
});
define("ace/line_widgets",["require","exports","module","ace/lib/oop","ace/lib/dom","ace/range"], function(require, exports, module) {
"use strict";
var oop = require("./lib/oop");
var dom = require("./lib/dom");
var Range = require("./range").Range;
function LineWidgets(session) {
this.session = session;
this.session.widgetManager = this;
this.session.getRowLength = this.getRowLength;
this.session.$getWidgetScreenLength = this.$getWidgetScreenLength;
this.updateOnChange = this.updateOnChange.bind(this);
this.renderWidgets = this.renderWidgets.bind(this);
this.measureWidgets = this.measureWidgets.bind(this);
this.session._changedWidgets = [];
this.$onChangeEditor = this.$onChangeEditor.bind(this);
this.session.on("change", this.updateOnChange);
this.session.on("changeEditor", this.$onChangeEditor);
}
(function() {
this.getRowLength = function(row) {
var h;
if (this.lineWidgets)
h = this.lineWidgets[row] && this.lineWidgets[row].rowCount || 0;
else
h = 0;
if (!this.$useWrapMode || !this.$wrapData[row]) {
return 1 + h;
} else {
return this.$wrapData[row].length + 1 + h;
}
};
this.$getWidgetScreenLength = function() {
var screenRows = 0;
this.lineWidgets.forEach(function(w){
if (w && w.rowCount)
screenRows +=w.rowCount;
});
return screenRows;
};
this.$onChangeEditor = function(e) {
this.attach(e.editor);
};
this.attach = function(editor) {
if (editor && editor.widgetManager && editor.widgetManager != this)
editor.widgetManager.detach();
if (this.editor == editor)
return;
this.detach();
this.editor = editor;
if (editor) {
editor.widgetManager = this;
editor.renderer.on("beforeRender", this.measureWidgets);
editor.renderer.on("afterRender", this.renderWidgets);
}
};
this.detach = function(e) {
var editor = this.editor;
if (!editor)
return;
this.editor = null;
editor.widgetManager = null;
editor.renderer.off("beforeRender", this.measureWidgets);
editor.renderer.off("afterRender", this.renderWidgets);
var lineWidgets = this.session.lineWidgets;
lineWidgets && lineWidgets.forEach(function(w) {
if (w && w.el && w.el.parentNode) {
w._inDocument = false;
w.el.parentNode.removeChild(w.el);
}
});
};
this.updateOnChange = function(e) {
var lineWidgets = this.session.lineWidgets;
if (!lineWidgets) return;
var delta = e.data;
var range = delta.range;
var startRow = range.start.row;
var len = range.end.row - startRow;
if (len === 0) {
} else if (delta.action == "removeText" || delta.action == "removeLines") {
var removed = lineWidgets.splice(startRow + 1, len);
removed.forEach(function(w) {
w && this.removeLineWidget(w);
}, this);
this.$updateRows();
} else {
var args = new Array(len);
args.unshift(startRow, 0);
lineWidgets.splice.apply(lineWidgets, args);
this.$updateRows();
}
};
this.$updateRows = function() {
var lineWidgets = this.session.lineWidgets;
if (!lineWidgets) return;
var noWidgets = true;
lineWidgets.forEach(function(w, i) {
if (w) {
noWidgets = false;
w.row = i;
}
});
if (noWidgets)
this.session.lineWidgets = null;
};
this.addLineWidget = function(w) {
if (!this.session.lineWidgets)
this.session.lineWidgets = new Array(this.session.getLength());
this.session.lineWidgets[w.row] = w;
var renderer = this.editor.renderer;
if (w.html && !w.el) {
w.el = dom.createElement("div");
w.el.innerHTML = w.html;
}
if (w.el) {
dom.addCssClass(w.el, "ace_lineWidgetContainer");
w.el.style.position = "absolute";
w.el.style.zIndex = 5;
renderer.container.appendChild(w.el);
w._inDocument = true;
}
if (!w.coverGutter) {
w.el.style.zIndex = 3;
}
if (!w.pixelHeight) {
w.pixelHeight = w.el.offsetHeight;
}
if (w.rowCount == null)
w.rowCount = w.pixelHeight / renderer.layerConfig.lineHeight;
this.session._emit("changeFold", {data:{start:{row: w.row}}});
this.$updateRows();
this.renderWidgets(null, renderer);
return w;
};
this.removeLineWidget = function(w) {
w._inDocument = false;
if (w.el && w.el.parentNode)
w.el.parentNode.removeChild(w.el);
if (w.editor && w.editor.destroy) try {
w.editor.destroy();
} catch(e){}
if (this.session.lineWidgets)
this.session.lineWidgets[w.row] = undefined;
this.session._emit("changeFold", {data:{start:{row: w.row}}});
this.$updateRows();
};
this.onWidgetChanged = function(w) {
this.session._changedWidgets.push(w);
this.editor && this.editor.renderer.updateFull();
};
this.measureWidgets = function(e, renderer) {
var changedWidgets = this.session._changedWidgets;
var config = renderer.layerConfig;
if (!changedWidgets || !changedWidgets.length) return;
var min = Infinity;
for (var i = 0; i < changedWidgets.length; i++) {
var w = changedWidgets[i];
if (!w._inDocument) {
w._inDocument = true;
renderer.container.appendChild(w.el);
}
w.h = w.el.offsetHeight;
if (!w.fixedWidth) {
w.w = w.el.offsetWidth;
w.screenWidth = Math.ceil(w.w / config.characterWidth);
}
var rowCount = w.h / config.lineHeight;
if (w.coverLine) {
rowCount -= this.session.getRowLineCount(w.row);
if (rowCount < 0)
rowCount = 0;
}
if (w.rowCount != rowCount) {
w.rowCount = rowCount;
if (w.row < min)
min = w.row;
}
}
if (min != Infinity) {
this.session._emit("changeFold", {data:{start:{row: min}}});
this.session.lineWidgetWidth = null;
}
this.session._changedWidgets = [];
};
this.renderWidgets = function(e, renderer) {
var config = renderer.layerConfig;
var lineWidgets = this.session.lineWidgets;
if (!lineWidgets)
return;
var first = Math.min(this.firstRow, config.firstRow);
var last = Math.max(this.lastRow, config.lastRow, lineWidgets.length);
while (first > 0 && !lineWidgets[first])
first--;
this.firstRow = config.firstRow;
this.lastRow = config.lastRow;
renderer.$cursorLayer.config = config;
for (var i = first; i <= last; i++) {
var w = lineWidgets[i];
if (!w || !w.el) continue;
if (!w._inDocument) {
w._inDocument = true;
renderer.container.appendChild(w.el);
}
var top = renderer.$cursorLayer.getPixelPosition({row: i, column:0}, true).top;
if (!w.coverLine)
top += config.lineHeight * this.session.getRowLineCount(w.row);
w.el.style.top = top - config.offset + "px";
var left = w.coverGutter ? 0 : renderer.gutterWidth;
if (!w.fixedWidth)
left -= renderer.scrollLeft;
w.el.style.left = left + "px";
if (w.fixedWidth) {
w.el.style.right = renderer.scrollBar.getWidth() + "px";
} else {
w.el.style.right = "";
}
}
};
}).call(LineWidgets.prototype);
exports.LineWidgets = LineWidgets;
});
define("ace/ext/error_marker",["require","exports","module","ace/line_widgets","ace/lib/dom","ace/range"], function(require, exports, module) {
"use strict";
var LineWidgets = require("../line_widgets").LineWidgets;
var dom = require("../lib/dom");
var Range = require("../range").Range;
function binarySearch(array, needle, comparator) {
var first = 0;
var last = array.length - 1;
while (first <= last) {
var mid = (first + last) >> 1;
var c = comparator(needle, array[mid]);
if (c > 0)
first = mid + 1;
else if (c < 0)
last = mid - 1;
else
return mid;
}
return -(first + 1);
}
function findAnnotations(session, row, dir) {
var annotations = session.getAnnotations().sort(Range.comparePoints);
if (!annotations.length)
return;
var i = binarySearch(annotations, {row: row, column: -1}, Range.comparePoints);
if (i < 0)
i = -i - 1;
if (i >= annotations.length - 1)
i = dir > 0 ? 0 : annotations.length - 1;
else if (i === 0 && dir < 0)
i = annotations.length - 1;
var annotation = annotations[i];
if (!annotation || !dir)
return;
if (annotation.row === row) {
do {
annotation = annotations[i += dir];
} while (annotation && annotation.row === row);
if (!annotation)
return annotations.slice();
}
var matched = [];
row = annotation.row;
do {
matched[dir < 0 ? "unshift" : "push"](annotation);
annotation = annotations[i += dir];
} while (annotation && annotation.row == row);
return matched.length && matched;
}
exports.showErrorMarker = function(editor, dir) {
var session = editor.session;
if (!session.widgetManager) {
session.widgetManager = new LineWidgets(session);
session.widgetManager.attach(editor);
}
var pos = editor.getCursorPosition();
var row = pos.row;
var oldWidget = session.lineWidgets && session.lineWidgets[row];
if (oldWidget) {
oldWidget.destroy();
} else {
row -= dir;
}
var annotations = findAnnotations(session, row, dir);
var gutterAnno;
if (annotations) {
var annotation = annotations[0];
pos.column = (annotation.pos && typeof annotation.column != "number"
? annotation.pos.sc
: annotation.column) || 0;
pos.row = annotation.row;
gutterAnno = editor.renderer.$gutterLayer.$annotations[pos.row];
} else if (oldWidget) {
return;
} else {
gutterAnno = {
text: ["Looks good!"],
className: "ace_ok"
};
}
editor.session.unfold(pos.row);
editor.selection.moveToPosition(pos);
var w = {
row: pos.row,
fixedWidth: true,
coverGutter: true,
el: dom.createElement("div")
};
var el = w.el.appendChild(dom.createElement("div"));
var arrow = w.el.appendChild(dom.createElement("div"));
arrow.className = "error_widget_arrow " + gutterAnno.className;
var left = editor.renderer.$cursorLayer
.getPixelPosition(pos).left;
arrow.style.left = left + editor.renderer.gutterWidth - 5 + "px";
w.el.className = "error_widget_wrapper";
el.className = "error_widget " + gutterAnno.className;
el.innerHTML = gutterAnno.text.join("
");
el.appendChild(dom.createElement("div"));
var kb = function(_, hashId, keyString) {
if (hashId === 0 && (keyString === "esc" || keyString === "return")) {
w.destroy();
return {command: "null"};
}
};
w.destroy = function() {
if (editor.$mouseHandler.isMousePressed)
return;
editor.keyBinding.removeKeyboardHandler(kb);
session.widgetManager.removeLineWidget(w);
editor.off("changeSelection", w.destroy);
editor.off("changeSession", w.destroy);
editor.off("mouseup", w.destroy);
editor.off("change", w.destroy);
};
editor.keyBinding.addKeyboardHandler(kb);
editor.on("changeSelection", w.destroy);
editor.on("changeSession", w.destroy);
editor.on("mouseup", w.destroy);
editor.on("change", w.destroy);
editor.session.widgetManager.addLineWidget(w);
w.el.onmousedown = editor.focus.bind(editor);
editor.renderer.scrollCursorIntoView(null, 0.5, {bottom: w.el.offsetHeight});
};
dom.importCssString("\
.error_widget_wrapper {\
background: inherit;\
color: inherit;\
border:none\
}\
.error_widget {\
border-top: solid 2px;\
border-bottom: solid 2px;\
margin: 5px 0;\
padding: 10px 40px;\
white-space: pre-wrap;\
}\
.error_widget.ace_error, .error_widget_arrow.ace_error{\
border-color: #ff5a5a\
}\
.error_widget.ace_warning, .error_widget_arrow.ace_warning{\
border-color: #F1D817\
}\
.error_widget.ace_info, .error_widget_arrow.ace_info{\
border-color: #5a5a5a\
}\
.error_widget.ace_ok, .error_widget_arrow.ace_ok{\
border-color: #5aaa5a\
}\
.error_widget_arrow {\
position: absolute;\
border: solid 5px;\
border-top-color: transparent!important;\
border-right-color: transparent!important;\
border-left-color: transparent!important;\
top: -5px;\
}\
", "");
});
define("ace/ace",["require","exports","module","ace/lib/fixoldbrowsers","ace/lib/dom","ace/lib/event","ace/editor","ace/edit_session","ace/undomanager","ace/virtual_renderer","ace/worker/worker_client","ace/keyboard/hash_handler","ace/placeholder","ace/multi_select","ace/mode/folding/fold_mode","ace/theme/textmate","ace/ext/error_marker","ace/config"], function(require, exports, module) {
"use strict";
require("./lib/fixoldbrowsers");
var dom = require("./lib/dom");
var event = require("./lib/event");
var Editor = require("./editor").Editor;
var EditSession = require("./edit_session").EditSession;
var UndoManager = require("./undomanager").UndoManager;
var Renderer = require("./virtual_renderer").VirtualRenderer;
require("./worker/worker_client");
require("./keyboard/hash_handler");
require("./placeholder");
require("./multi_select");
require("./mode/folding/fold_mode");
require("./theme/textmate");
require("./ext/error_marker");
exports.config = require("./config");
exports.require = require;
exports.edit = function(el) {
if (typeof(el) == "string") {
var _id = el;
el = document.getElementById(_id);
if (!el)
throw new Error("ace.edit can't find div #" + _id);
}
if (el && el.env && el.env.editor instanceof Editor)
return el.env.editor;
var value = "";
if (el && /input|textarea/i.test(el.tagName)) {
var oldNode = el;
value = oldNode.value;
el = dom.createElement("pre");
oldNode.parentNode.replaceChild(el, oldNode);
} else {
value = dom.getInnerText(el);
el.innerHTML = '';
}
var doc = exports.createEditSession(value);
var editor = new Editor(new Renderer(el));
editor.setSession(doc);
var env = {
document: doc,
editor: editor,
onResize: editor.resize.bind(editor, null)
};
if (oldNode) env.textarea = oldNode;
event.addListener(window, "resize", env.onResize);
editor.on("destroy", function() {
event.removeListener(window, "resize", env.onResize);
env.editor.container.env = null; // prevent memory leak on old ie
});
editor.container.env = editor.env = env;
return editor;
};
exports.createEditSession = function(text, mode) {
var doc = new EditSession(text, mode);
doc.setUndoManager(new UndoManager());
return doc;
}
exports.EditSession = EditSession;
exports.UndoManager = UndoManager;
});
(function() {
window.require(["ace/ace"], function(a) {
a && a.config.init(true);
if (!window.ace)
window.ace = a;
for (var key in a) if (a.hasOwnProperty(key))
window.ace[key] = a[key];
});
})();
//script: prosemirror
!function(e){function r(e,r,o){return 4===arguments.length?t.apply(this,arguments):void n(e,{declarative:!0,deps:r,declare:o})}function t(e,r,t,o){n(e,{declarative:!1,deps:r,executingRequire:t,execute:o})}function n(e,r){r.name=e,e in g||(g[e]=r),r.normalizedDeps=r.deps}function o(e,r){if(r[e.groupIndex]=r[e.groupIndex]||[],-1==m.call(r[e.groupIndex],e)){r[e.groupIndex].push(e);for(var t=0,n=e.normalizedDeps.length;n>t;t++){var a=e.normalizedDeps[t],u=g[a];if(u&&!u.evaluated){var d=e.groupIndex+(u.declarative!=e.declarative);if(void 0===u.groupIndex||u.groupIndex
=0;a--){for(var u=t[a],i=0;ia;a++){var d=t.importers[a];if(!d.locked)for(var i=0;ia;a++){var l,s=r.normalizedDeps[a],c=g[s],f=D[s];f?l=f.exports:c&&!c.declarative?l=c.esModule:c?(d(c),f=c.module,l=f.exports):l=v(s),f&&f.importers?(f.importers.push(t),t.dependencies.push(f)):t.dependencies.push(null),t.setters[a]&&t.setters[a](l)}}}function i(e){var r,t=g[e];if(t)t.declarative?p(e,[]):t.evaluated||l(t),r=t.module.exports;else if(r=v(e),!r)throw new Error("Unable to load dependency "+e+".");return(!t||t.declarative)&&r&&r.__useDefault?r["default"]:r}function l(r){if(!r.module){var t={},n=r.module={exports:t,id:r.name};if(!r.executingRequire)for(var o=0,a=r.normalizedDeps.length;a>o;o++){var u=r.normalizedDeps[o],d=g[u];d&&l(d)}r.evaluated=!0;var c=r.execute.call(e,function(e){for(var t=0,n=r.deps.length;n>t;t++)if(r.deps[t]==e)return i(r.normalizedDeps[t]);throw new TypeError("Module "+e+" not declared as a dependency.")},t,n);c&&(n.exports=c),t=n.exports,t&&t.__esModule?r.esModule=t:r.esModule=s(t)}}function s(e){var r={};if("object"==typeof e||"function"==typeof e){var t=e&&e.hasOwnProperty;if(h)for(var n in e)f(r,e,n)||c(r,e,n,t);else for(var n in e)c(r,e,n,t)}return r["default"]=e,y(r,"__useDefault",{value:!0}),r}function c(e,r,t,n){(!n||r.hasOwnProperty(t))&&(e[t]=r[t])}function f(e,r,t){try{var n;return(n=Object.getOwnPropertyDescriptor(r,t))&&y(e,t,n),!0}catch(o){return!1}}function p(r,t){var n=g[r];if(n&&!n.evaluated&&n.declarative){t.push(r);for(var o=0,a=n.normalizedDeps.length;a>o;o++){var u=n.normalizedDeps[o];-1==m.call(t,u)&&(g[u]?p(u,t):v(u))}n.evaluated||(n.evaluated=!0,n.module.execute.call(e))}}function v(e){if(I[e])return I[e];if("@node/"==e.substr(0,6))return _(e.substr(6));var r=g[e];if(!r)throw"Module "+e+" not present.";return a(e),p(e,[]),g[e]=void 0,r.declarative&&y(r.module.exports,"__esModule",{value:!0}),I[e]=r.declarative?r.module.exports:r.esModule}var g={},m=Array.prototype.indexOf||function(e){for(var r=0,t=this.length;t>r;r++)if(this[r]===e)return r;return-1},h=!0;try{Object.getOwnPropertyDescriptor({a:0},"a")}catch(x){h=!1}var y;!function(){try{Object.defineProperty({},"a",{})&&(y=Object.defineProperty)}catch(e){y=function(e,r,t){try{e[r]=t.value||t.get.call(e)}catch(n){}}}}();var D={},_="undefined"!=typeof System&&System._nodeRequire||"undefined"!=typeof require&&require.resolve&&"undefined"!=typeof process&&require,I={"@empty":{}};return function(e,n,o){return function(a){a(function(a){for(var u={_nodeRequire:_,register:r,registerDynamic:t,get:v,set:function(e,r){I[e]=r},newModule:function(e){return e}},d=0;d1)for(var d=1;d*",
group: "block",
parseDOM: [{tag: "p"}],
toDOM: function toDOM() {
return ["p", 0];
}
},
blockquote: {
content: "block+",
group: "block",
defining: true,
parseDOM: [{tag: "blockquote"}],
toDOM: function toDOM() {
return ["blockquote", 0];
}
},
horizontal_rule: {
group: "block",
parseDOM: [{tag: "hr"}],
toDOM: function toDOM() {
return ["hr"];
}
},
heading: {
attrs: {level: {default: 1}},
content: "inline<_>*",
group: "block",
defining: true,
parseDOM: [{
tag: "h1",
attrs: {level: 1}
}, {
tag: "h2",
attrs: {level: 2}
}, {
tag: "h3",
attrs: {level: 3}
}, {
tag: "h4",
attrs: {level: 4}
}, {
tag: "h5",
attrs: {level: 5}
}, {
tag: "h6",
attrs: {level: 6}
}],
toDOM: function toDOM(node) {
return ["h" + node.attrs.level, 0];
}
},
code_block: {
content: "text*",
group: "block",
code: true,
defining: true,
parseDOM: [{
tag: "pre",
preserveWhitespace: true
}],
toDOM: function toDOM() {
return ["pre", ["code", 0]];
}
},
text: {
group: "inline",
toDOM: function toDOM(node) {
return node.text;
}
},
image: {
inline: true,
attrs: {
src: {},
alt: {default: null},
title: {default: null}
},
group: "inline",
draggable: true,
parseDOM: [{
tag: "img[src]",
getAttrs: function getAttrs(dom) {
return {
src: dom.getAttribute("src"),
title: dom.getAttribute("title"),
alt: dom.getAttribute("alt")
};
}
}],
toDOM: function toDOM(node) {
return ["img", node.attrs];
}
},
hard_break: {
inline: true,
group: "inline",
selectable: false,
parseDOM: [{tag: "br"}],
toDOM: function toDOM() {
return ["br"];
}
}
};
exports.nodes = nodes;
var marks = {
em: {
parseDOM: [{tag: "i"}, {tag: "em"}, {
style: "font-style",
getAttrs: function(value) {
return value == "italic" && null;
}
}],
toDOM: function toDOM() {
return ["em"];
}
},
strong: {
parseDOM: [{tag: "strong"}, {
tag: "b",
getAttrs: function(node) {
return node.style.fontWeight != "normal" && null;
}
}, {
style: "font-weight",
getAttrs: function(value) {
return /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null;
}
}],
toDOM: function toDOM() {
return ["strong"];
}
},
link: {
attrs: {
href: {},
title: {default: null}
},
parseDOM: [{
tag: "a[href]",
getAttrs: function getAttrs(dom) {
return {
href: dom.getAttribute("href"),
title: dom.getAttribute("title")
};
}
}],
toDOM: function toDOM(node) {
return ["a", node.attrs];
}
},
code: {
parseDOM: [{tag: "code"}],
toDOM: function toDOM() {
return ["code"];
}
}
};
exports.marks = marks;
var schema = new Schema({
nodes: nodes,
marks: marks
});
exports.schema = schema;
return module.exports;
});
$__System.registerDynamic("4", ["2"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
module.exports = $__require('2');
return module.exports;
});
$__System.registerDynamic("5", ["6"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var ref = $__require('6');
var InputRule = ref.InputRule;
var emDash = new InputRule(/--$/, "—");
exports.emDash = emDash;
var ellipsis = new InputRule(/\.\.\.$/, "…");
exports.ellipsis = ellipsis;
var openDoubleQuote = new InputRule(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/, "“");
exports.openDoubleQuote = openDoubleQuote;
var closeDoubleQuote = new InputRule(/"$/, "”");
exports.closeDoubleQuote = closeDoubleQuote;
var openSingleQuote = new InputRule(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/, "‘");
exports.openSingleQuote = openSingleQuote;
var closeSingleQuote = new InputRule(/'$/, "’");
exports.closeSingleQuote = closeSingleQuote;
var smartQuotes = [openDoubleQuote, closeDoubleQuote, openSingleQuote, closeSingleQuote];
exports.smartQuotes = smartQuotes;
var allInputRules = [emDash, ellipsis].concat(smartQuotes);
exports.allInputRules = allInputRules;
return module.exports;
});
$__System.registerDynamic("6", ["7"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var ref = $__require('7');
var Plugin = ref.Plugin;
var PluginKey = ref.PluginKey;
var InputRule = function InputRule(match, handler) {
this.match = match;
this.handler = typeof handler == "string" ? stringHandler(handler) : handler;
};
exports.InputRule = InputRule;
function stringHandler(string) {
return function(state, match, start, end) {
var insert = string;
if (match[1]) {
var offset = match[0].lastIndexOf(match[1]);
insert += match[0].slice(offset + match[1].length);
start += offset;
var cutOff = start - end;
if (cutOff > 0) {
insert = match[0].slice(offset - cutOff, offset) + insert;
start = end;
}
}
var marks = state.doc.resolve(start).marks();
return state.tr.replaceWith(start, end, state.schema.text(insert, marks));
};
}
var MAX_MATCH = 500;
var stateKey = new PluginKey("fromInputRule");
function inputRules(ref) {
var rules = ref.rules;
return new Plugin({
state: {
init: function init() {
return null;
},
apply: function apply(tr, prev) {
var stored = tr.getMeta(stateKey);
if (stored) {
return stored;
}
return tr.selectionSet || tr.docChanged ? null : prev;
}
},
props: {
handleTextInput: function handleTextInput(view, from, to, text) {
var state = view.state,
$from = state.doc.resolve(from);
var textBefore = $from.parent.textBetween(Math.max(0, $from.parentOffset - MAX_MATCH), $from.parentOffset, null, "\ufffc") + text;
for (var i = 0; i < rules.length; i++) {
var match = rules[i].match.exec(textBefore);
var tr = match && rules[i].handler(state, match, from - (match[0].length - text.length), to);
if (!tr) {
continue;
}
view.dispatch(tr.setMeta(stateKey, {
transform: tr,
from: from,
to: to,
text: text
}));
return true;
}
return false;
},
handleKeyDown: function handleKeyDown(view, event) {
if (event.keyCode == 8) {
return maybeUndoInputRule(view.state, view.dispatch, this.getState(view.state));
}
return false;
}
}
});
}
exports.inputRules = inputRules;
function maybeUndoInputRule(state, dispatch, undoable) {
if (!undoable) {
return false;
}
var tr = state.tr,
toUndo = undoable.transform;
for (var i = toUndo.steps.length - 1; i >= 0; i--) {
tr.step(toUndo.steps[i].invert(toUndo.docs[i]));
}
var marks = tr.doc.resolve(undoable.from).marks();
dispatch(tr.replaceWith(undoable.from, undoable.to, state.schema.text(undoable.text, marks)));
return true;
}
return module.exports;
});
$__System.registerDynamic("8", ["6", "9"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var ref = $__require('6');
var InputRule = ref.InputRule;
var ref$1 = $__require('9');
var findWrapping = ref$1.findWrapping;
var canJoin = ref$1.canJoin;
function wrappingInputRule(regexp, nodeType, getAttrs, joinPredicate) {
return new InputRule(regexp, function(state, match, start, end) {
var attrs = getAttrs instanceof Function ? getAttrs(match) : getAttrs;
var tr = state.tr.delete(start, end);
var $start = tr.doc.resolve(start),
range = $start.blockRange(),
wrapping = range && findWrapping(range, nodeType, attrs);
if (!wrapping) {
return null;
}
tr.wrap(range, wrapping);
var before = tr.doc.resolve(start - 1).nodeBefore;
if (before && before.type == nodeType && canJoin(tr.doc, start - 1) && (!joinPredicate || joinPredicate(match, before))) {
tr.join(start - 1);
}
return tr;
});
}
exports.wrappingInputRule = wrappingInputRule;
function textblockTypeInputRule(regexp, nodeType, getAttrs) {
return new InputRule(regexp, function(state, match, start, end) {
var $start = state.doc.resolve(start);
var attrs = getAttrs instanceof Function ? getAttrs(match) : getAttrs;
if (!$start.node(-1).canReplaceWith($start.index(-1), $start.indexAfter(-1), nodeType, attrs)) {
return null;
}
return state.tr.delete(start, end).setBlockType(start, start, nodeType, attrs);
});
}
exports.textblockTypeInputRule = textblockTypeInputRule;
function blockQuoteRule(nodeType) {
return wrappingInputRule(/^\s*> $/, nodeType);
}
exports.blockQuoteRule = blockQuoteRule;
function orderedListRule(nodeType) {
return wrappingInputRule(/^(\d+)\. $/, nodeType, function(match) {
return ({order: +match[1]});
}, function(match, node) {
return node.childCount + node.attrs.order == +match[1];
});
}
exports.orderedListRule = orderedListRule;
function bulletListRule(nodeType) {
return wrappingInputRule(/^\s*([-+*]) $/, nodeType);
}
exports.bulletListRule = bulletListRule;
function codeBlockRule(nodeType) {
return textblockTypeInputRule(/^```$/, nodeType);
}
exports.codeBlockRule = codeBlockRule;
function headingRule(nodeType, maxLevel) {
return textblockTypeInputRule(new RegExp("^(#{1," + maxLevel + "}) $"), nodeType, function(match) {
return ({level: match[1].length});
});
}
exports.headingRule = headingRule;
return module.exports;
});
$__System.registerDynamic("a", ["6", "5", "8"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
;
var assign;
((assign = $__require('6'), exports.InputRule = assign.InputRule, exports.inputRules = assign.inputRules));
;
var assign$1;
((assign$1 = $__require('5'), exports.emDash = assign$1.emDash, exports.ellipsis = assign$1.ellipsis, exports.openDoubleQuote = assign$1.openDoubleQuote, exports.closeDoubleQuote = assign$1.closeDoubleQuote, exports.openSingleQuote = assign$1.openSingleQuote, exports.closeSingleQuote = assign$1.closeSingleQuote, exports.smartQuotes = assign$1.smartQuotes, exports.allInputRules = assign$1.allInputRules));
;
var assign$2;
((assign$2 = $__require('8'), exports.wrappingInputRule = assign$2.wrappingInputRule, exports.textblockTypeInputRule = assign$2.textblockTypeInputRule, exports.blockQuoteRule = assign$2.blockQuoteRule, exports.orderedListRule = assign$2.orderedListRule, exports.bulletListRule = assign$2.bulletListRule, exports.codeBlockRule = assign$2.codeBlockRule, exports.headingRule = assign$2.headingRule));
return module.exports;
});
$__System.registerDynamic("b", ["a"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
module.exports = $__require('a');
return module.exports;
});
$__System.registerDynamic("c", [], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var base = {
8: "Backspace",
9: "Tab",
10: "Enter",
12: "NumLock",
13: "Enter",
16: "Shift",
17: "Control",
18: "Alt",
20: "CapsLock",
27: "Escape",
32: " ",
33: "PageUp",
34: "PageDown",
35: "End",
36: "Home",
37: "ArrowLeft",
38: "ArrowUp",
39: "ArrowRight",
40: "ArrowDown",
44: "PrintScreen",
45: "Insert",
46: "Delete",
59: ";",
61: "=",
91: "Meta",
92: "Meta",
106: "*",
107: "+",
108: ",",
109: "-",
110: ".",
111: "/",
144: "NumLock",
145: "ScrollLock",
160: "Shift",
161: "Shift",
162: "Control",
163: "Control",
164: "Alt",
165: "Alt",
173: "-",
186: ";",
187: "=",
188: ",",
189: "-",
190: ".",
191: "/",
192: "`",
219: "[",
220: "\\",
221: "]",
222: "'",
229: "q"
};
var shift = {
48: ")",
49: "!",
50: "@",
51: "#",
52: "$",
53: "%",
54: "^",
55: "&",
56: "*",
57: "(",
59: ";",
61: "+",
173: "_",
186: ":",
187: "+",
188: "<",
189: "_",
190: ">",
191: "?",
192: "~",
219: "{",
220: "|",
221: "}",
222: "\"",
229: "Q"
};
var chrome = typeof navigator != "undefined" && /Chrome\/(\d+)/.exec(navigator.userAgent);
var brokenModifierNames = chrome && +chrome[1] < 57;
for (var i = 0; i < 10; i++)
base[48 + i] = base[96 + i] = String(i);
for (var i = 1; i <= 24; i++)
base[i + 111] = "F" + i;
for (var i = 65; i <= 90; i++) {
base[i] = String.fromCharCode(i + 32);
shift[i] = String.fromCharCode(i);
}
for (var code in base)
if (!shift.hasOwnProperty(code))
shift[code] = base[code];
function keyName(event) {
var name = ((!brokenModifierNames || !event.ctrlKey && !event.altKey && !event.metaKey) && event.key) || (event.shiftKey ? shift : base)[event.keyCode] || event.key || "Unidentified";
if (name == "Esc")
name = "Escape";
if (name == "Del")
name = "Delete";
if (name == "Left")
name = "ArrowLeft";
if (name == "Up")
name = "ArrowUp";
if (name == "Right")
name = "ArrowRight";
if (name == "Down")
name = "ArrowDown";
return name;
}
module.exports = keyName;
keyName.base = base;
keyName.shift = shift;
return module.exports;
});
$__System.registerDynamic("d", ["c"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
module.exports = $__require('c');
return module.exports;
});
$__System.registerDynamic("e", ["d", "7"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var keyName = $__require('d');
var ref = $__require('7');
var Plugin = ref.Plugin;
var mac = typeof navigator != "undefined" ? /Mac/.test(navigator.platform) : false;
function normalizeKeyName(name) {
var parts = name.split(/-(?!$)/),
result = parts[parts.length - 1];
if (result == "Space") {
result = " ";
}
var alt,
ctrl,
shift,
meta;
for (var i = 0; i < parts.length - 1; i++) {
var mod = parts[i];
if (/^(cmd|meta|m)$/i.test(mod)) {
meta = true;
} else if (/^a(lt)?$/i.test(mod)) {
alt = true;
} else if (/^(c|ctrl|control)$/i.test(mod)) {
ctrl = true;
} else if (/^s(hift)?$/i.test(mod)) {
shift = true;
} else if (/^mod$/i.test(mod)) {
if (mac) {
meta = true;
} else {
ctrl = true;
}
} else {
throw new Error("Unrecognized modifier name: " + mod);
}
}
if (alt) {
result = "Alt-" + result;
}
if (ctrl) {
result = "Ctrl-" + result;
}
if (meta) {
result = "Meta-" + result;
}
if (shift) {
result = "Shift-" + result;
}
return result;
}
function normalize(map) {
var copy = Object.create(null);
for (var prop in map) {
copy[normalizeKeyName(prop)] = map[prop];
}
return copy;
}
function modifiers(name, event, shift) {
if (event.altKey) {
name = "Alt-" + name;
}
if (event.ctrlKey) {
name = "Ctrl-" + name;
}
if (event.metaKey) {
name = "Meta-" + name;
}
if (shift !== false && event.shiftKey) {
name = "Shift-" + name;
}
return name;
}
function keymap(bindings) {
var map = normalize(bindings);
return new Plugin({props: {handleKeyDown: function handleKeyDown(view, event) {
var name = keyName(event),
isChar = name.length == 1 && name != " ",
baseName;
var direct = map[modifiers(name, event, !isChar)];
if (direct && direct(view.state, view.dispatch, view)) {
return true;
}
if (event.shiftKey && isChar && (baseName = keyName.base[event.keyCode])) {
var withShift = map[modifiers(baseName, event, true)];
if (withShift && withShift(view.state, view.dispatch, view)) {
return true;
}
}
return false;
}}});
}
exports.keymap = keymap;
return module.exports;
});
$__System.registerDynamic("f", ["e"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
module.exports = $__require('e');
return module.exports;
});
$__System.registerDynamic("10", ["7", "11"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var ref = $__require('7');
var Plugin = ref.Plugin;
var ref$1 = $__require('11');
var Decoration = ref$1.Decoration;
var DecorationSet = ref$1.DecorationSet;
var gecko = typeof navigator != "undefined" && /gecko\/\d/i.test(navigator.userAgent);
var linux = typeof navigator != "undefined" && /linux/i.test(navigator.platform);
function dropCursor(options) {
function dispatch(view, data) {
view.dispatch(view.state.tr.setMeta(plugin, data));
}
var timeout = null;
function scheduleRemoval(view) {
clearTimeout(timeout);
timeout = setTimeout(function() {
if (plugin.getState(view.state)) {
dispatch(view, {type: "remove"});
}
}, 1000);
}
var plugin = new Plugin({
state: {
init: function init() {
return null;
},
apply: function apply(tr, prev, state) {
if (gecko && linux) {
return null;
}
var command = tr.getMeta(plugin);
if (!command) {
return prev;
}
if (command.type == "set") {
return pluginStateFor(state, command.pos, options);
}
return null;
}
},
props: {
handleDOMEvents: {
dragover: function dragover(view, event) {
var active = plugin.getState(view.state);
var pos = view.posAtCoords({
left: event.clientX,
top: event.clientY
});
if (pos && (!active || active.pos != pos.pos)) {
dispatch(view, {
type: "set",
pos: pos.pos
});
}
scheduleRemoval(view);
return false;
},
dragend: function dragend(view) {
if (plugin.getState(view.state)) {
dispatch(view, {type: "remove"});
}
return false;
},
drop: function drop(view) {
if (plugin.getState(view.state)) {
dispatch(view, {type: "remove"});
}
return false;
},
dragleave: function dragleave(view, event) {
if (event.target == view.content) {
dispatch(view, {type: "remove"});
}
return false;
}
},
decorations: function decorations(state) {
var active = plugin.getState(state);
return active && active.deco;
}
}
});
return plugin;
}
exports.dropCursor = dropCursor;
function style(options, side) {
var width = (options && options.width) || 1;
var color = (options && options.color) || "black";
return ("border-" + side + ": " + width + "px solid " + color + "; margin-" + side + ": -" + width + "px");
}
function pluginStateFor(state, pos, options) {
var $pos = state.doc.resolve(pos),
deco;
if (!$pos.parent.isTextblock) {
var before,
after;
if (before = $pos.nodeBefore) {
deco = Decoration.node(pos - before.nodeSize, pos, {
nodeName: "div",
style: style(options, "right")
});
} else if (after = $pos.nodeAfter) {
deco = Decoration.node(pos, pos + after.nodeSize, {
nodeName: "div",
style: style(options, "left")
});
}
}
if (!deco) {
var node = document.createElement("span");
node.textContent = "\u200b";
node.style.cssText = style(options, "left") + "; display: inline-block; pointer-events: none";
deco = Decoration.widget(pos, node);
}
return {
pos: pos,
deco: DecorationSet.create(state.doc, [deco])
};
}
return module.exports;
});
$__System.registerDynamic("12", ["10"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
module.exports = $__require('10');
return module.exports;
});
$__System.registerDynamic("13", [], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
function windowRect() {
return {
left: 0,
right: window.innerWidth,
top: 0,
bottom: window.innerHeight
};
}
function parentNode(node) {
var parent = node.parentNode;
return parent.nodeType == 11 ? parent.host : parent;
}
function scrollRectIntoView(view, rect) {
var scrollThreshold = view.someProp("scrollThreshold") || 0,
scrollMargin = view.someProp("scrollMargin");
if (scrollMargin == null) {
scrollMargin = 5;
}
for (var parent = view.content; ; parent = parentNode(parent)) {
var atBody = parent == document.body;
var bounding = atBody ? windowRect() : parent.getBoundingClientRect();
var moveX = 0,
moveY = 0;
if (rect.top < bounding.top + scrollThreshold) {
moveY = -(bounding.top - rect.top + scrollMargin);
} else if (rect.bottom > bounding.bottom - scrollThreshold) {
moveY = rect.bottom - bounding.bottom + scrollMargin;
}
if (rect.left < bounding.left + scrollThreshold) {
moveX = -(bounding.left - rect.left + scrollMargin);
} else if (rect.right > bounding.right - scrollThreshold) {
moveX = rect.right - bounding.right + scrollMargin;
}
if (moveX || moveY) {
if (atBody) {
window.scrollBy(moveX, moveY);
} else {
if (moveY) {
parent.scrollTop += moveY;
}
if (moveX) {
parent.scrollLeft += moveX;
}
}
}
if (atBody) {
break;
}
}
}
exports.scrollRectIntoView = scrollRectIntoView;
function storeScrollPos(view) {
var rect = view.content.getBoundingClientRect(),
startY = Math.max(0, rect.top);
var refDOM,
refTop;
for (var x = (rect.left + rect.right) / 2,
y = startY + 1; y < Math.min(innerHeight, rect.bottom); y += 5) {
var dom = view.root.elementFromPoint(x, y);
if (dom == view.content || !view.content.contains(dom)) {
continue;
}
var localRect = dom.getBoundingClientRect();
if (localRect.top >= startY - 20) {
refDOM = dom;
refTop = localRect.top;
break;
}
}
var stack = [];
for (var dom$1 = view.content; dom$1; dom$1 = parentNode(dom$1)) {
stack.push({
dom: dom$1,
top: dom$1.scrollTop,
left: dom$1.scrollLeft
});
if (dom$1 == document.body) {
break;
}
}
return {
refDOM: refDOM,
refTop: refTop,
stack: stack
};
}
exports.storeScrollPos = storeScrollPos;
function resetScrollPos(ref) {
var refDOM = ref.refDOM;
var refTop = ref.refTop;
var stack = ref.stack;
var newRefTop = refDOM ? refDOM.getBoundingClientRect().top : 0;
var dTop = newRefTop == 0 ? 0 : newRefTop - refTop;
for (var i = 0; i < stack.length; i++) {
var ref$1 = stack[i];
var dom = ref$1.dom;
var top = ref$1.top;
var left = ref$1.left;
if (dom.scrollTop != top + dTop) {
dom.scrollTop = top + dTop;
}
if (dom.scrollLeft != left) {
dom.scrollLeft = left;
}
}
}
exports.resetScrollPos = resetScrollPos;
function findOffsetInNode(node, coords) {
var closest,
dxClosest = 2e8,
coordsClosest,
offset = 0;
var rowBot = coords.top,
rowTop = coords.top;
for (var child = node.firstChild,
childIndex = 0; child; child = child.nextSibling, childIndex++) {
var rects = (void 0);
if (child.nodeType == 1) {
rects = child.getClientRects();
} else if (child.nodeType == 3) {
rects = textRange(child).getClientRects();
} else {
continue;
}
for (var i = 0; i < rects.length; i++) {
var rect = rects[i];
if (rect.top <= rowBot && rect.bottom >= rowTop) {
rowBot = Math.max(rect.bottom, rowBot);
rowTop = Math.min(rect.top, rowTop);
var dx = rect.left > coords.left ? rect.left - coords.left : rect.right < coords.left ? coords.left - rect.right : 0;
if (dx < dxClosest) {
closest = child;
dxClosest = dx;
coordsClosest = dx && closest.nodeType == 3 ? {
left: rect.right < coords.left ? rect.right : rect.left,
top: coords.top
} : coords;
if (child.nodeType == 1 && dx) {
offset = childIndex + (coords.left >= (rect.left + rect.right) / 2 ? 1 : 0);
}
continue;
}
}
if (!closest && (coords.left >= rect.right && coords.top >= rect.top || coords.left >= rect.left && coords.top >= rect.bottom)) {
offset = childIndex + 1;
}
}
}
if (closest && closest.nodeType == 3) {
return findOffsetInText(closest, coordsClosest);
}
if (!closest || (dxClosest && closest.nodeType == 1)) {
return {
node: node,
offset: offset
};
}
return findOffsetInNode(closest, coordsClosest);
}
function findOffsetInText(node, coords) {
var len = node.nodeValue.length;
var range = document.createRange();
for (var i = 0; i < len; i++) {
range.setEnd(node, i + 1);
range.setStart(node, i);
var rect = singleRect(range, 1);
if (rect.top == rect.bottom) {
continue;
}
if (rect.left - 1 <= coords.left && rect.right + 1 >= coords.left && rect.top - 1 <= coords.top && rect.bottom + 1 >= coords.top) {
return {
node: node,
offset: i + (coords.left >= (rect.left + rect.right) / 2 ? 1 : 0)
};
}
}
return {
node: node,
offset: 0
};
}
function targetKludge(dom, coords) {
if (/^[uo]l$/i.test(dom.nodeName)) {
for (var child = dom.firstChild; child; child = child.nextSibling) {
if (!child.pmViewDesc || !/^li$/i.test(child.nodeName)) {
continue;
}
var childBox = child.getBoundingClientRect();
if (coords.left > childBox.left - 2) {
break;
}
if (childBox.top <= coords.top && childBox.bottom >= coords.top) {
return child;
}
}
}
return dom;
}
function posAtCoords(view, coords) {
var elt = targetKludge(view.root.elementFromPoint(coords.left, coords.top + 1), coords);
if (!view.content.contains(elt.nodeType == 3 ? elt.parentNode : elt)) {
return null;
}
var ref = findOffsetInNode(elt, coords);
var node = ref.node;
var offset = ref.offset;
var bias = -1;
if (node.nodeType == 1 && !node.firstChild) {
var rect = node.getBoundingClientRect();
bias = rect.left != rect.right && coords.left > (rect.left + rect.right) / 2 ? 1 : -1;
}
var desc = view.docView.nearestDesc(elt, true);
return {
pos: view.docView.posFromDOM(node, offset, bias),
inside: desc && (desc.posAtStart - desc.border)
};
}
exports.posAtCoords = posAtCoords;
function textRange(node, from, to) {
var range = document.createRange();
range.setEnd(node, to == null ? node.nodeValue.length : to);
range.setStart(node, from || 0);
return range;
}
function singleRect(object, bias) {
var rects = object.getClientRects();
return !rects.length ? object.getBoundingClientRect() : rects[bias < 0 ? 0 : rects.length - 1];
}
function coordsAtPos(view, pos) {
var ref = view.docView.domFromPos(pos);
var node = ref.node;
var offset = ref.offset;
var side,
rect;
if (node.nodeType == 3) {
if (offset < node.nodeValue.length) {
rect = singleRect(textRange(node, offset, offset + 1), -1);
side = "left";
}
if ((!rect || rect.left == rect.right) && offset) {
rect = singleRect(textRange(node, offset - 1, offset), 1);
side = "right";
}
} else if (node.firstChild) {
if (offset < node.childNodes.length) {
var child = node.childNodes[offset];
rect = singleRect(child.nodeType == 3 ? textRange(child) : child, -1);
side = "left";
}
if ((!rect || rect.top == rect.bottom) && offset) {
var child$1 = node.childNodes[offset - 1];
rect = singleRect(child$1.nodeType == 3 ? textRange(child$1) : child$1, 1);
side = "right";
}
} else {
rect = node.getBoundingClientRect();
side = "left";
}
var x = rect[side];
return {
top: rect.top,
bottom: rect.bottom,
left: x,
right: x
};
}
exports.coordsAtPos = coordsAtPos;
function withFlushedState(view, state, f) {
var viewState = view.state,
active = view.root.activeElement;
if (viewState != state || !view.inDOMChange) {
view.updateState(state);
}
if (active != view.content) {
view.focus();
}
try {
return f();
} finally {
if (viewState != state) {
view.updateState(viewState);
}
if (active != view.content) {
active.focus();
}
}
}
function endOfTextblockVertical(view, state, dir) {
var $pos = dir == "up" ? state.selection.$from : state.selection.$to;
if (!$pos.depth) {
return false;
}
return withFlushedState(view, state, function() {
var dom = view.docView.domAfterPos($pos.before());
var coords = coordsAtPos(view, $pos.pos);
for (var child = dom.firstChild; child; child = child.nextSibling) {
var boxes = (void 0);
if (child.nodeType == 1) {
boxes = child.getClientRects();
} else if (child.nodeType == 3) {
boxes = textRange(child, 0, child.nodeValue.length).getClientRects();
} else {
continue;
}
for (var i = 0; i < boxes.length; i++) {
var box = boxes[i];
if (dir == "up" ? box.bottom < coords.top + 1 : box.top > coords.bottom - 1) {
return false;
}
}
}
return true;
});
}
var maybeRTL = /[\u0590-\u08ac]/;
function endOfTextblockHorizontal(view, state, dir) {
var ref = state.selection;
var $head = ref.$head;
var empty = ref.empty;
if (!empty || !$head.parent.isTextblock || !$head.depth) {
return false;
}
var offset = $head.parentOffset,
atStart = !offset,
atEnd = offset == $head.parent.content.size;
if (!atStart && !atEnd && !maybeRTL.test($head.parent.textContent)) {
return false;
}
var sel = getSelection();
if (!sel.modify) {
return dir == "left" || dir == "backward" ? atStart : atEnd;
}
return withFlushedState(view, state, function() {
var oldRange = sel.getRangeAt(0);
sel.modify("move", dir, "character");
var parentDOM = view.docView.domAfterPos($head.before());
var result = !parentDOM.contains(sel.focusNode.nodeType == 1 ? sel.focusNode : sel.focusNode.parentNode) || view.docView.posFromDOM(sel.focusNode, sel.focusOffset) == $head.pos;
sel.removeAllRanges();
sel.addRange(oldRange);
return result;
});
}
var cachedState = null,
cachedDir = null,
cachedResult = false;
function endOfTextblock(view, state, dir) {
if (cachedState == state && cachedDir == dir) {
return cachedResult;
}
cachedState = state;
cachedDir = dir;
return cachedResult = dir == "up" || dir == "down" ? endOfTextblockVertical(view, state, dir) : endOfTextblockHorizontal(view, state, dir);
}
exports.endOfTextblock = endOfTextblock;
return module.exports;
});
$__System.registerDynamic("14", ["3", "15"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var ref = $__require('3');
var DOMSerializer = ref.DOMSerializer;
var browser = $__require('15');
var NOT_DIRTY = 0,
CHILD_DIRTY = 1,
CONTENT_DIRTY = 2,
NODE_DIRTY = 3;
var ViewDesc = function(parent, children, dom, contentDOM) {
this.parent = parent;
this.children = children;
this.dom = dom;
dom.pmViewDesc = this;
this.contentDOM = contentDOM;
this.dirty = NOT_DIRTY;
};
var prototypeAccessors = {
size: {},
border: {},
posAtStart: {},
posAtEnd: {},
contentLost: {}
};
ViewDesc.prototype.matchesWidget = function() {
return false;
};
ViewDesc.prototype.matchesMark = function() {
return false;
};
ViewDesc.prototype.matchesNode = function() {
return false;
};
ViewDesc.prototype.matchesHack = function() {
return false;
};
ViewDesc.prototype.parseRule = function() {
return null;
};
ViewDesc.prototype.stopEvent = function() {
return false;
};
prototypeAccessors.size.get = function() {
var this$1 = this;
var size = 0;
for (var i = 0; i < this.children.length; i++) {
size += this$1.children[i].size;
}
return size;
};
prototypeAccessors.border.get = function() {
return 0;
};
ViewDesc.prototype.destroy = function() {
var this$1 = this;
this.parent = null;
if (this.dom.pmViewDesc == this) {
this.dom.pmViewDesc = null;
}
for (var i = 0; i < this.children.length; i++) {
this$1.children[i].destroy();
}
};
ViewDesc.prototype.posBeforeChild = function(child) {
var this$1 = this;
for (var i = 0,
pos = this.posAtStart; i < this.children.length; i++) {
var cur = this$1.children[i];
if (cur == child) {
return pos;
}
pos += cur.size;
}
};
prototypeAccessors.posAtStart.get = function() {
return this.parent ? this.parent.posBeforeChild(this) + this.border : 0;
};
prototypeAccessors.posAtEnd.get = function() {
return this.posAtStart + this.size - 2 * this.border;
};
ViewDesc.prototype.localPosFromDOM = function(dom, offset, bias) {
var this$1 = this;
if (this.contentDOM && this.contentDOM.contains(dom.nodeType == 1 ? dom : dom.parentNode)) {
if (bias < 0) {
var domBefore,
desc;
if (dom == this.contentDOM) {
domBefore = dom.childNodes[offset - 1];
} else {
while (dom.parentNode != this.contentDOM) {
dom = dom.parentNode;
}
domBefore = dom.previousSibling;
}
while (domBefore && !((desc = domBefore.pmViewDesc) && desc.parent == this)) {
domBefore = domBefore.previousSibling;
}
return domBefore ? this.posBeforeChild(desc) + desc.size : this.posAtStart;
} else {
var domAfter,
desc$1;
if (dom == this.contentDOM) {
domAfter = dom.childNodes[offset];
} else {
while (dom.parentNode != this.contentDOM) {
dom = dom.parentNode;
}
domAfter = dom.nextSibling;
}
while (domAfter && !((desc$1 = domAfter.pmViewDesc) && desc$1.parent == this)) {
domAfter = domAfter.nextSibling;
}
return domAfter ? this.posBeforeChild(desc$1) : this.posAtEnd;
}
}
var atEnd;
if (this.contentDOM && this.contentDOM != this.dom && this.dom.contains(this.contentDOM)) {
atEnd = dom.compareDocumentPosition(this.contentDOM) & 2;
} else if (this.dom.firstChild) {
if (offset == 0) {
for (var search = dom; ; search = search.parentNode) {
if (search == this$1.dom) {
atEnd = false;
break;
}
if (search.parentNode.firstChild != search) {
break;
}
}
}
if (atEnd == null && offset == dom.childNodes.length) {
for (var search$1 = dom; ; search$1 = search$1.parentNode) {
if (search$1 == this$1.dom) {
atEnd = true;
break;
}
if (search$1.parentNode.lastChild != search$1) {
break;
}
}
}
}
return (atEnd == null ? bias > 0 : atEnd) ? this.posAtEnd : this.posAtStart;
};
ViewDesc.prototype.nearestDesc = function(dom, onlyNodes) {
var this$1 = this;
for (var first = true,
cur = dom; cur; cur = cur.parentNode) {
var desc = this$1.getDesc(cur);
if (desc && (!onlyNodes || desc.node)) {
if (first && desc.nodeDOM && !(desc.nodeDOM.nodeType == 1 && desc.nodeDOM.contains(dom))) {
first = false;
} else {
return desc;
}
}
}
};
ViewDesc.prototype.getDesc = function(dom) {
var this$1 = this;
var desc = dom.pmViewDesc;
for (var cur = desc; cur; cur = cur.parent) {
if (cur == this$1) {
return desc;
}
}
};
ViewDesc.prototype.posFromDOM = function(dom, offset, bias) {
var this$1 = this;
for (var scan = dom; ; scan = scan.parentNode) {
var desc = this$1.getDesc(scan);
if (desc) {
return desc.localPosFromDOM(dom, offset, bias);
}
}
};
ViewDesc.prototype.descAt = function(pos) {
var this$1 = this;
for (var i = 0,
offset = 0; i < this.children.length; i++) {
var child = this$1.children[i],
end = offset + child.size;
if (offset == pos && end != offset) {
while (!child.border && child.children.length) {
child = child.children[0];
}
return child;
}
if (pos < end) {
return child.descAt(pos - offset - child.border);
}
offset = end;
}
};
ViewDesc.prototype.domFromPos = function(pos, searchDOM) {
var this$1 = this;
if (!this.contentDOM) {
return {
node: this.dom,
offset: 0
};
}
for (var offset = 0,
i = 0; ; i++) {
if (offset == pos) {
return {
node: this$1.contentDOM,
offset: searchDOM ? this$1.findDOMOffset(i, searchDOM) : i
};
}
if (i == this$1.children.length) {
throw new Error("Invalid position " + pos);
}
var child = this$1.children[i],
end = offset + child.size;
if (pos < end) {
return child.domFromPos(pos - offset - child.border, searchDOM);
}
offset = end;
}
};
ViewDesc.prototype.findDOMOffset = function(i, searchDOM) {
var this$1 = this;
var content = this.contentDOM;
if (searchDOM < 0) {
for (var j = i - 1; j >= 0; j--) {
var child = this$1.children[j];
if (!child.size) {
continue;
}
var found = Array.prototype.indexOf.call(content.childNodes, child.dom);
if (found > -1) {
return found + 1;
}
}
return 0;
} else {
for (var j$1 = i; j$1 < this.children.length; j$1++) {
var child$1 = this$1.children[j$1];
if (!child$1.size) {
continue;
}
var found$1 = Array.prototype.indexOf.call(content.childNodes, child$1.dom);
if (found$1 > -1) {
return found$1;
}
}
return content.childNodes.length;
}
};
ViewDesc.prototype.domAfterPos = function(pos) {
var ref = this.domFromPos(pos);
var node = ref.node;
var offset = ref.offset;
if (node.nodeType != 1 || offset == node.childNodes.length) {
throw new RangeError("No node after pos " + pos);
}
return node.childNodes[offset];
};
ViewDesc.prototype.setSelection = function(anchor, head, root) {
var this$1 = this;
var from = Math.min(anchor, head),
to = Math.max(anchor, head);
for (var i = 0,
offset = 0; i < this.children.length; i++) {
var child = this$1.children[i],
end = offset + child.size;
if (from > offset && to < end) {
return child.setSelection(anchor - offset - child.border, head - offset - child.border, root);
}
offset = end;
}
var anchorDOM = this.domFromPos(anchor),
headDOM = this.domFromPos(head);
var domSel = root.getSelection(),
range = document.createRange();
if (domSel.extend) {
range.setEnd(anchorDOM.node, anchorDOM.offset);
range.collapse(false);
} else {
if (anchor > head) {
var tmp = anchorDOM;
anchorDOM = headDOM;
headDOM = tmp;
}
range.setEnd(headDOM.node, headDOM.offset);
range.setStart(anchorDOM.node, anchorDOM.offset);
}
domSel.removeAllRanges();
domSel.addRange(range);
if (domSel.extend) {
domSel.extend(headDOM.node, headDOM.offset);
}
};
ViewDesc.prototype.ignoreMutation = function(_mutation) {
return !this.contentDOM;
};
prototypeAccessors.contentLost.get = function() {
return this.contentDOM && this.contentDOM != this.dom && !this.dom.contains(this.contentDOM);
};
ViewDesc.prototype.markDirty = function(from, to) {
var this$1 = this;
for (var offset = 0,
i = 0; i < this.children.length; i++) {
var child = this$1.children[i],
end = offset + child.size;
if (offset == end ? from <= end && to >= offset : from < end && to > offset) {
var startInside = offset + child.border,
endInside = end - child.border;
if (from >= startInside && to <= endInside) {
this$1.dirty = from == offset || to == end ? CONTENT_DIRTY : CHILD_DIRTY;
if (from == startInside && to == endInside && child.contentLost) {
child.dirty = NODE_DIRTY;
} else {
child.markDirty(from - startInside, to - startInside);
}
return;
} else {
child.dirty = NODE_DIRTY;
}
}
offset = end;
}
this.dirty = CONTENT_DIRTY;
};
Object.defineProperties(ViewDesc.prototype, prototypeAccessors);
var nothing = [];
var WidgetViewDesc = (function(ViewDesc) {
function WidgetViewDesc(parent, widget) {
ViewDesc.call(this, parent, nothing, widget.type.widget, null);
this.widget = widget;
}
if (ViewDesc)
WidgetViewDesc.__proto__ = ViewDesc;
WidgetViewDesc.prototype = Object.create(ViewDesc && ViewDesc.prototype);
WidgetViewDesc.prototype.constructor = WidgetViewDesc;
WidgetViewDesc.prototype.matchesWidget = function(widget) {
return this.dirty == NOT_DIRTY && widget.type.eq(this.widget.type);
};
WidgetViewDesc.prototype.parseRule = function() {
return {ignore: true};
};
WidgetViewDesc.prototype.stopEvent = function(event) {
var stop = this.widget.type.options.stopEvent;
return stop ? stop(event) : false;
};
return WidgetViewDesc;
}(ViewDesc));
var MarkViewDesc = (function(ViewDesc) {
function MarkViewDesc(parent, mark, dom) {
ViewDesc.call(this, parent, [], dom, dom);
this.mark = mark;
}
if (ViewDesc)
MarkViewDesc.__proto__ = ViewDesc;
MarkViewDesc.prototype = Object.create(ViewDesc && ViewDesc.prototype);
MarkViewDesc.prototype.constructor = MarkViewDesc;
MarkViewDesc.create = function(parent, mark, view) {
var custom = customNodeViews(view)[mark.type.name];
var spec = custom && custom(mark, view);
var dom = spec && spec.dom || DOMSerializer.renderSpec(document, mark.type.spec.toDOM(mark)).dom;
return new MarkViewDesc(parent, mark, dom);
};
MarkViewDesc.prototype.parseRule = function() {
return {
mark: this.mark.type.name,
attrs: this.mark.attrs,
contentElement: this.contentDOM
};
};
MarkViewDesc.prototype.matchesMark = function(mark) {
return this.dirty != NODE_DIRTY && this.mark.eq(mark);
};
return MarkViewDesc;
}(ViewDesc));
var NodeViewDesc = (function(ViewDesc) {
function NodeViewDesc(parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM, view) {
ViewDesc.call(this, parent, node.isLeaf ? nothing : [], dom, contentDOM);
this.nodeDOM = nodeDOM;
this.node = node;
this.outerDeco = outerDeco;
this.innerDeco = innerDeco;
if (contentDOM) {
this.updateChildren(view);
}
}
if (ViewDesc)
NodeViewDesc.__proto__ = ViewDesc;
NodeViewDesc.prototype = Object.create(ViewDesc && ViewDesc.prototype);
NodeViewDesc.prototype.constructor = NodeViewDesc;
var prototypeAccessors$1 = {
size: {},
border: {}
};
NodeViewDesc.create = function(parent, node, outerDeco, innerDeco, view) {
var custom = customNodeViews(view)[node.type.name],
descObj;
var spec = custom && custom(node, view, function() {
if (descObj && descObj.parent) {
return descObj.parent.posBeforeChild(descObj);
}
}, outerDeco);
var dom = spec && spec.dom,
contentDOM = spec && spec.contentDOM;
if (!dom) {
var assign;
((assign = DOMSerializer.renderSpec(document, node.type.spec.toDOM(node)), dom = assign.dom, contentDOM = assign.contentDOM));
}
if (!contentDOM && !node.isText) {
dom.contentEditable = false;
}
var nodeDOM = dom;
dom = applyOuterDeco(dom, outerDeco, node);
if (spec) {
return descObj = new CustomNodeViewDesc(parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM, spec, view);
} else if (node.isText) {
return new TextViewDesc(parent, node, outerDeco, innerDeco, dom, nodeDOM, view);
} else {
return new NodeViewDesc(parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM, view);
}
};
NodeViewDesc.prototype.parseRule = function() {
return {
node: this.node.type.name,
attrs: this.node.attrs,
contentElement: this.contentLost ? null : this.contentDOM
};
};
NodeViewDesc.prototype.matchesNode = function(node, outerDeco, innerDeco) {
return this.dirty == NOT_DIRTY && node.eq(this.node) && sameOuterDeco(outerDeco, this.outerDeco) && innerDeco.eq(this.innerDeco);
};
prototypeAccessors$1.size.get = function() {
return this.node.nodeSize;
};
prototypeAccessors$1.border.get = function() {
return this.node.isLeaf ? 0 : 1;
};
NodeViewDesc.prototype.updateChildren = function(view) {
var this$1 = this;
var updater = new ViewTreeUpdater(this);
iterDeco(this.node, this.innerDeco, function(widget) {
updater.placeWidget(widget);
}, function(child, outerDeco, innerDeco, i) {
updater.syncToMarks(child.marks, view);
updater.findNodeMatch(child, outerDeco, innerDeco) || updater.updateNextNode(child, outerDeco, innerDeco, view, this$1.node.content, i) || updater.addNode(child, outerDeco, innerDeco, view);
});
updater.syncToMarks(nothing, view);
if (this.node.isTextblock) {
updater.addTextblockHacks();
}
updater.destroyRest();
if (updater.changed || this.dirty == CONTENT_DIRTY) {
this.renderChildren();
}
};
NodeViewDesc.prototype.renderChildren = function() {
renderDescs(this.contentDOM, this.children, NodeViewDesc.is);
if (browser.ios) {
iosHacks(this.dom);
}
};
NodeViewDesc.prototype.update = function(node, outerDeco, innerDeco, view) {
if (this.dirty == NODE_DIRTY || !node.sameMarkup(this.node)) {
return false;
}
this.updateOuterDeco(outerDeco);
this.node = node;
this.innerDeco = innerDeco;
if (!node.isLeaf) {
this.updateChildren(view);
}
this.dirty = NOT_DIRTY;
return true;
};
NodeViewDesc.prototype.updateOuterDeco = function(outerDeco) {
if (sameOuterDeco(outerDeco, this.outerDeco)) {
return;
}
var needsWrap = this.nodeDOM.nodeType != 1;
this.dom = patchOuterDeco(this.dom, this.nodeDOM, computeOuterDeco(this.outerDeco, this.node, needsWrap), computeOuterDeco(outerDeco, this.node, needsWrap));
this.outerDeco = outerDeco;
};
NodeViewDesc.prototype.selectNode = function() {
this.nodeDOM.classList.add("ProseMirror-selectednode");
};
NodeViewDesc.prototype.deselectNode = function() {
this.nodeDOM.classList.remove("ProseMirror-selectednode");
};
Object.defineProperties(NodeViewDesc.prototype, prototypeAccessors$1);
return NodeViewDesc;
}(ViewDesc));
function docViewDesc(doc, outerDeco, innerDeco, dom, view) {
applyOuterDeco(dom, outerDeco, doc, true);
return new NodeViewDesc(null, doc, outerDeco, innerDeco, dom, dom, dom, view);
}
exports.docViewDesc = docViewDesc;
var TextViewDesc = (function(NodeViewDesc) {
function TextViewDesc(parent, node, outerDeco, innerDeco, dom, nodeDOM, view) {
NodeViewDesc.call(this, parent, node, outerDeco, innerDeco, dom, null, nodeDOM, view);
var textDOM = nodeDOM;
while (textDOM.nodeType != 3) {
textDOM = textDOM.firstChild;
if (!textDOM) {
throw new RangeError("Text node rendered without text DOM");
}
}
this.textDOM = textDOM;
}
if (NodeViewDesc)
TextViewDesc.__proto__ = NodeViewDesc;
TextViewDesc.prototype = Object.create(NodeViewDesc && NodeViewDesc.prototype);
TextViewDesc.prototype.constructor = TextViewDesc;
TextViewDesc.prototype.parseRule = function() {
return {skip: this.textDOM.parentNode};
};
TextViewDesc.prototype.update = function(node, outerDeco) {
if (this.dirty == NODE_DIRTY || (this.dirty != NOT_DIRTY && !this.inParent()) || !node.sameMarkup(this.node)) {
return false;
}
this.updateOuterDeco(outerDeco);
if ((this.dirty != NOT_DIRTY || node.text != this.node.text) && node.text != this.textDOM.nodeValue) {
this.textDOM.nodeValue = node.text;
}
this.node = node;
this.dirty = NOT_DIRTY;
return true;
};
TextViewDesc.prototype.inParent = function() {
var parentDOM = this.parent.contentDOM;
for (var n = this.textDOM; n; n = n.parentNode) {
if (n == parentDOM) {
return true;
}
}
return false;
};
TextViewDesc.prototype.domFromPos = function(pos, searchDOM) {
return {
node: this.textDOM,
offset: searchDOM ? Math.max(pos, this.textDOM.nodeValue.length) : pos
};
};
TextViewDesc.prototype.localPosFromDOM = function(dom, offset, bias) {
if (dom == this.textDOM) {
return this.posAtStart + Math.min(offset, this.node.text.length);
}
return NodeViewDesc.prototype.localPosFromDOM.call(this, dom, offset, bias);
};
TextViewDesc.prototype.ignoreMutation = function(mutation) {
return mutation.type != "characterData";
};
return TextViewDesc;
}(NodeViewDesc));
var BRHackViewDesc = (function(ViewDesc) {
function BRHackViewDesc() {
ViewDesc.apply(this, arguments);
}
if (ViewDesc)
BRHackViewDesc.__proto__ = ViewDesc;
BRHackViewDesc.prototype = Object.create(ViewDesc && ViewDesc.prototype);
BRHackViewDesc.prototype.constructor = BRHackViewDesc;
BRHackViewDesc.prototype.parseRule = function() {
return {ignore: true};
};
BRHackViewDesc.prototype.matchesHack = function() {
return this.dirty == NOT_DIRTY;
};
return BRHackViewDesc;
}(ViewDesc));
var CustomNodeViewDesc = (function(NodeViewDesc) {
function CustomNodeViewDesc(parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM, spec, view) {
NodeViewDesc.call(this, parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM, view);
this.spec = spec;
}
if (NodeViewDesc)
CustomNodeViewDesc.__proto__ = NodeViewDesc;
CustomNodeViewDesc.prototype = Object.create(NodeViewDesc && NodeViewDesc.prototype);
CustomNodeViewDesc.prototype.constructor = CustomNodeViewDesc;
CustomNodeViewDesc.prototype.update = function(node, outerDeco, innerDeco, view) {
if (this.dirty == NODE_DIRTY) {
return false;
}
if (this.spec.update) {
var result = this.spec.update(node, outerDeco);
if (result) {
this.node = node;
if (this.contentDOM) {
this.updateChildren(view);
}
}
return result;
} else if (!this.contentDOM && !node.isLeaf) {
return false;
} else {
return NodeViewDesc.prototype.update.call(this, node, outerDeco, this.contentDOM ? this.innerDeco : innerDeco, view);
}
};
CustomNodeViewDesc.prototype.selectNode = function() {
this.spec.selectNode ? this.spec.selectNode() : NodeViewDesc.prototype.selectNode.call(this);
};
CustomNodeViewDesc.prototype.deselectNode = function() {
this.spec.deselectNode ? this.spec.deselectNode() : NodeViewDesc.prototype.deselectNode.call(this);
};
CustomNodeViewDesc.prototype.setSelection = function(anchor, head, root) {
this.spec.setSelection ? this.spec.setSelection(anchor, head, root) : NodeViewDesc.prototype.setSelection.call(this, anchor, head, root);
};
CustomNodeViewDesc.prototype.destroy = function() {
if (this.spec.destroy) {
this.spec.destroy();
}
NodeViewDesc.prototype.destroy.call(this);
};
CustomNodeViewDesc.prototype.stopEvent = function(event) {
return this.spec.stopEvent ? this.spec.stopEvent(event) : false;
};
CustomNodeViewDesc.prototype.ignoreMutation = function(mutation) {
return this.spec.ignoreMutation ? this.spec.ignoreMutation(mutation) : NodeViewDesc.prototype.ignoreMutation.call(this, mutation);
};
return CustomNodeViewDesc;
}(NodeViewDesc));
function renderDescs(parentDOM, descs) {
var dom = parentDOM.firstChild;
for (var i = 0; i < descs.length; i++) {
var desc = descs[i],
childDOM = desc.dom;
if (childDOM.parentNode == parentDOM) {
while (childDOM != dom) {
dom = rm(dom);
}
dom = dom.nextSibling;
} else {
parentDOM.insertBefore(childDOM, dom);
}
if (desc instanceof MarkViewDesc) {
renderDescs(desc.contentDOM, desc.children);
}
}
while (dom) {
dom = rm(dom);
}
}
var OuterDecoLevel = function(nodeName) {
if (nodeName) {
this.nodeName = nodeName;
}
};
OuterDecoLevel.prototype = Object.create(null);
var noDeco = [new OuterDecoLevel];
function computeOuterDeco(outerDeco, node, needsWrap) {
if (outerDeco.length == 0) {
return noDeco;
}
var top = needsWrap ? noDeco[0] : new OuterDecoLevel,
result = [top];
for (var i = 0; i < outerDeco.length; i++) {
var attrs = outerDeco[i].type.attrs,
cur = top;
if (!attrs) {
continue;
}
if (attrs.nodeName) {
result.push(cur = new OuterDecoLevel(attrs.nodeName));
}
for (var name in attrs) {
var val = attrs[name];
if (val == null) {
continue;
}
if (needsWrap && result.length == 1) {
result.push(cur = top = new OuterDecoLevel(node.isInline ? "span" : "div"));
}
if (name == "class") {
cur.class = (cur.class ? cur.class + " " : "") + val;
} else if (name == "style") {
cur.style = (cur.style ? cur.style + ";" : "") + val;
} else if (name != "nodeName") {
cur[name] = val;
}
}
}
return result;
}
function patchOuterDeco(outerDOM, nodeDOM, prevComputed, curComputed) {
if (prevComputed == noDeco && curComputed == noDeco) {
return nodeDOM;
}
var curDOM = nodeDOM;
for (var i = 0; i < curComputed.length; i++) {
var deco = curComputed[i],
prev = prevComputed[i];
if (i) {
var parent = (void 0);
if (prev && prev.nodeName == deco.nodeName && curDOM != outerDOM && (parent = nodeDOM.parentNode) && parent.tagName.toLowerCase() == deco.nodeName) {
curDOM = parent;
} else {
parent = document.createElement(deco.nodeName);
parent.appendChild(curDOM);
curDOM = parent;
}
}
patchAttributes(curDOM, prev || noDeco[0], deco);
}
return curDOM;
}
function patchAttributes(dom, prev, cur) {
for (var name in prev) {
if (name != "class" && name != "style" && name != "nodeName" && !(name in cur)) {
dom.removeAttribute(name);
}
}
for (var name$1 in cur) {
if (name$1 != "class" && name$1 != "style" && name$1 != "nodeName" && cur[name$1] != prev[name$1]) {
dom.setAttribute(name$1, cur[name$1]);
}
}
if (prev.class != cur.class) {
var prevList = prev.class ? prev.class.split(" ") : nothing;
var curList = cur.class ? cur.class.split(" ") : nothing;
for (var i = 0; i < prevList.length; i++) {
if (curList.indexOf(prevList[i]) == -1) {
dom.classList.remove(prevList[i]);
}
}
for (var i$1 = 0; i$1 < curList.length; i$1++) {
if (prevList.indexOf(curList[i$1]) == -1) {
dom.classList.add(curList[i$1]);
}
}
}
if (prev.style != cur.style) {
var text = dom.style.cssText,
found;
if (prev.style && (found = text.indexOf(prev.style)) > -1) {
text = text.slice(0, found) + text.slice(found + prev.style.length);
}
dom.style.cssText = text + (cur.style || "");
}
}
function applyOuterDeco(dom, deco, node) {
return patchOuterDeco(dom, dom, noDeco, computeOuterDeco(deco, node, dom.nodeType != 1));
}
function sameOuterDeco(a, b) {
if (a.length != b.length) {
return false;
}
for (var i = 0; i < a.length; i++) {
if (!a[i].type.eq(b[i].type)) {
return false;
}
}
return true;
}
function rm(dom) {
var next = dom.nextSibling;
dom.parentNode.removeChild(dom);
return next;
}
var ViewTreeUpdater = function(top) {
this.top = top;
this.index = 0;
this.stack = [];
this.changed = false;
};
ViewTreeUpdater.prototype.destroyBetween = function(start, end) {
var this$1 = this;
if (start == end) {
return;
}
for (var i = start; i < end; i++) {
this$1.top.children[i].destroy();
}
this.top.children.splice(start, end - start);
this.changed = true;
};
ViewTreeUpdater.prototype.destroyRest = function() {
this.destroyBetween(this.index, this.top.children.length);
};
ViewTreeUpdater.prototype.syncToMarks = function(marks, view) {
var this$1 = this;
var keep = 0,
depth = this.stack.length >> 1;
var maxKeep = Math.min(depth, marks.length),
next;
while (keep < maxKeep && (keep == depth - 1 ? this.top : this.stack[(keep + 1) << 1]).matchesMark(marks[keep])) {
keep++;
}
while (keep < depth) {
this$1.destroyRest();
this$1.top.dirty = NOT_DIRTY;
this$1.index = this$1.stack.pop();
this$1.top = this$1.stack.pop();
depth--;
}
while (depth < marks.length) {
this$1.stack.push(this$1.top, this$1.index + 1);
if (this$1.index < this$1.top.children.length && (next = this$1.top.children[this$1.index]).matchesMark(marks[depth])) {
this$1.top = next;
} else {
var markDesc = MarkViewDesc.create(this$1.top, marks[depth], view);
this$1.top.children.splice(this$1.index, 0, markDesc);
this$1.top = markDesc;
this$1.changed = true;
}
this$1.index = 0;
depth++;
}
};
ViewTreeUpdater.prototype.findNodeMatch = function(node, outerDeco, innerDeco) {
var this$1 = this;
for (var i = this.index,
children = this.top.children,
e = Math.min(children.length, i + 5); i < e; i++) {
if (children[i].matchesNode(node, outerDeco, innerDeco)) {
this$1.destroyBetween(this$1.index, i);
this$1.index++;
return true;
}
}
return false;
};
ViewTreeUpdater.prototype.updateNextNode = function(node, outerDeco, innerDeco, view, siblings, index) {
if (this.index == this.top.children.length) {
return false;
}
var next = this.top.children[this.index];
if (next instanceof NodeViewDesc) {
for (var i = index + 1,
e = Math.min(siblings.childCount, i + 5); i < e; i++) {
if (next.node == siblings.child(i)) {
return false;
}
}
var nextDOM = next.dom;
if (next.update(node, outerDeco, innerDeco, view)) {
if (next.dom != nextDOM) {
this.changed = true;
}
this.index++;
return true;
}
}
return false;
};
ViewTreeUpdater.prototype.addNode = function(node, outerDeco, innerDeco, view) {
this.top.children.splice(this.index++, 0, NodeViewDesc.create(this.top, node, outerDeco, innerDeco, view));
this.changed = true;
};
ViewTreeUpdater.prototype.placeWidget = function(widget) {
if (this.index < this.top.children.length && this.top.children[this.index].matchesWidget(widget)) {
this.index++;
} else {
this.top.children.splice(this.index++, 0, new WidgetViewDesc(this.top, widget));
this.changed = true;
}
};
ViewTreeUpdater.prototype.addTextblockHacks = function() {
var lastChild = this.top.children[this.index - 1];
while (lastChild instanceof MarkViewDesc) {
lastChild = lastChild.children[lastChild.children.length - 1];
}
if (!lastChild || !(lastChild instanceof TextViewDesc) || /\n$/.test(lastChild.node.text)) {
if (this.index < this.top.children.length && this.top.children[this.index].matchesHack()) {
this.index++;
} else {
var dom = document.createElement("br");
this.top.children.splice(this.index++, 0, new BRHackViewDesc(this.top, nothing, dom, null));
this.changed = true;
}
}
};
function iterDeco(parent, deco, onWidget, onNode) {
var locals = deco.locals(parent),
offset = 0;
if (locals.length == 0) {
for (var i = 0; i < parent.childCount; i++) {
var child = parent.child(i);
onNode(child, locals, deco.forChild(offset, child), i);
offset += child.nodeSize;
}
return;
}
var decoIndex = 0,
active = [],
restNode = null;
for (var parentIndex = 0; ; ) {
while (decoIndex < locals.length && locals[decoIndex].to == offset) {
onWidget(locals[decoIndex++]);
}
var child$1 = (void 0);
if (restNode) {
child$1 = restNode;
restNode = null;
} else if (parentIndex < parent.childCount) {
child$1 = parent.child(parentIndex++);
} else {
break;
}
for (var i$1 = 0; i$1 < active.length; i$1++) {
if (active[i$1].to <= offset) {
active.splice(i$1--, 1);
}
}
while (decoIndex < locals.length && locals[decoIndex].from == offset) {
active.push(locals[decoIndex++]);
}
var end = offset + child$1.nodeSize;
if (child$1.isText) {
var cutAt = end;
if (decoIndex < locals.length && locals[decoIndex].from < cutAt) {
cutAt = locals[decoIndex].from;
}
for (var i$2 = 0; i$2 < active.length; i$2++) {
if (active[i$2].to < cutAt) {
cutAt = active[i$2].to;
}
}
if (cutAt < end) {
restNode = child$1.cut(cutAt - offset);
child$1 = child$1.cut(0, cutAt - offset);
end = cutAt;
}
}
onNode(child$1, active.length ? active.slice() : nothing, deco.forChild(offset, child$1), parentIndex - 1);
offset = end;
}
}
var cachedCustomViews,
cachedCustomFor;
function customNodeViews(view) {
if (cachedCustomFor == view.props) {
return cachedCustomViews;
}
cachedCustomFor = view.props;
return cachedCustomViews = buildCustomViews(view);
}
function buildCustomViews(view) {
var result = {};
view.someProp("nodeViews", function(obj) {
for (var prop in obj) {
if (!Object.prototype.hasOwnProperty.call(result, prop)) {
result[prop] = obj[prop];
}
}
});
return result;
}
function iosHacks(dom) {
if (dom.nodeName == "UL" || dom.nodeName == "OL") {
var oldCSS = dom.style.cssText;
dom.style.cssText = oldCSS + "; list-style: square !important";
window.getComputedStyle(dom).listStyle;
dom.style.cssText = oldCSS;
}
}
return module.exports;
});
$__System.registerDynamic("15", [], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var result = module.exports = {};
if (typeof navigator != "undefined") {
var ie_upto10 = /MSIE \d/.test(navigator.userAgent);
var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);
result.mac = /Mac/.test(navigator.platform);
result.ie = ie_upto10 || !!ie_11up;
result.ie_version = ie_upto10 ? document.documentMode || 6 : ie_11up && +ie_11up[1];
result.gecko = /gecko\/\d/i.test(navigator.userAgent);
result.ios = /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent);
result.webkit = 'WebkitAppearance' in document.documentElement.style;
}
return module.exports;
});
$__System.registerDynamic("16", ["7", "15"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var ref = $__require('7');
var Selection = ref.Selection;
var NodeSelection = ref.NodeSelection;
var TextSelection = ref.TextSelection;
var browser = $__require('15');
function moveSelectionBlock(state, dir) {
var ref = state.selection;
var $from = ref.$from;
var $to = ref.$to;
var node = ref.node;
var $side = dir > 0 ? $to : $from;
var $start = node && node.isBlock ? $side : $side.depth ? state.doc.resolve(dir > 0 ? $side.after() : $side.before()) : null;
return $start && Selection.findFrom($start, dir);
}
function apply(view, sel) {
view.dispatch(view.state.tr.setSelection(sel).scrollIntoView());
return true;
}
function selectHorizontally(view, dir) {
var ref = view.state.selection;
var empty = ref.empty;
var node = ref.node;
var $from = ref.$from;
var $to = ref.$to;
if (!empty && !node) {
return false;
}
if (node && node.isInline) {
return apply(view, new TextSelection(dir > 0 ? $to : $from));
}
if (!node && !view.endOfTextblock(dir > 0 ? "right" : "left")) {
var ref$1 = dir > 0 ? $from.parent.childAfter($from.parentOffset) : $from.parent.childBefore($from.parentOffset);
var nextNode = ref$1.node;
var offset = ref$1.offset;
if (nextNode && NodeSelection.isSelectable(nextNode) && offset == $from.parentOffset - (dir > 0 ? 0 : nextNode.nodeSize)) {
return apply(view, new NodeSelection(dir < 0 ? view.state.doc.resolve($from.pos - nextNode.nodeSize) : $from));
}
return false;
}
var next = moveSelectionBlock(view.state, dir);
if (next && (next instanceof NodeSelection || node)) {
return apply(view, next);
}
return false;
}
function nodeLen(node) {
return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;
}
function isIgnorable(dom) {
var desc = dom.pmViewDesc;
return desc && desc.size == 0;
}
function skipIgnoredNodesLeft(view) {
var sel = view.root.getSelection();
var node = sel.anchorNode,
offset = sel.anchorOffset;
var moveNode,
moveOffset;
for (; ; ) {
if (offset > 0) {
if (node.nodeType != 1) {
break;
}
var before = node.childNodes[offset - 1];
if (isIgnorable(before)) {
moveNode = node;
moveOffset = --offset;
} else {
break;
}
} else if (isBlockNode(node)) {
break;
} else {
var prev = node.previousSibling;
while (prev && isIgnorable(prev)) {
moveNode = node.parentNode;
moveOffset = Array.prototype.indexOf.call(moveNode.childNodes, prev);
prev = prev.previousSibling;
}
if (!prev) {
node = node.parentNode;
if (node == view.content) {
break;
}
offset = 0;
} else {
node = prev;
offset = nodeLen(node);
}
}
}
if (moveNode) {
setSel(sel, moveNode, moveOffset);
}
}
function skipIgnoredNodesRight(view) {
var sel = view.root.getSelection();
var node = sel.anchorNode,
offset = sel.anchorOffset,
len = nodeLen(node);
var moveNode,
moveOffset;
for (; ; ) {
if (offset < len) {
if (node.nodeType != 1) {
break;
}
var after = node.childNodes[offset];
if (isIgnorable(after)) {
moveNode = node;
moveOffset = ++offset;
} else {
break;
}
} else if (isBlockNode(node)) {
break;
} else {
var next = node.nextSibling;
while (next && isIgnorable(next)) {
moveNode = next.parentNode;
moveOffset = Array.prototype.indexOf.call(moveNode.childNodes, next) + 1;
next = next.nextSibling;
}
if (!next) {
node = node.parentNode;
if (node == view.content) {
break;
}
offset = len = 0;
} else {
node = next;
offset = 0;
len = nodeLen(node);
}
}
}
if (moveNode) {
setSel(sel, moveNode, moveOffset);
}
}
function isBlockNode(dom) {
var desc = dom.pmViewDesc;
return desc && desc.node && desc.node.isBlock;
}
function setSel(sel, node, offset) {
var range = document.createRange();
range.setEnd(node, offset);
range.setStart(node, offset);
sel.removeAllRanges();
sel.addRange(range);
}
function selectVertically(view, dir) {
var ref = view.state.selection;
var empty = ref.empty;
var node = ref.node;
var $from = ref.$from;
var $to = ref.$to;
if (!empty && !node) {
return false;
}
var leavingTextblock = true,
$start = dir < 0 ? $from : $to;
if (!node || node.isInline) {
leavingTextblock = view.endOfTextblock(dir < 0 ? "up" : "down");
}
if (leavingTextblock) {
var next = moveSelectionBlock(view.state, dir);
if (next && (next instanceof NodeSelection)) {
return apply(view, next);
}
}
if (!node || node.isInline) {
return false;
}
var beyond = Selection.findFrom($start, dir);
return beyond ? apply(view, beyond) : true;
}
function stopNativeHorizontalDelete(view, dir) {
var ref = view.state.selection;
var $head = ref.$head;
var $anchor = ref.$anchor;
var empty = ref.empty;
if (!$head || !$head.sameParent($anchor) || !$head.parent.isTextblock) {
return true;
}
if (!empty) {
return false;
}
if (view.endOfTextblock(dir > 0 ? "forward" : "backward")) {
return true;
}
var nextNode = !$head.textOffset && (dir < 0 ? $head.nodeBefore : $head.nodeAfter);
if (nextNode && !nextNode.isText) {
var tr = view.state.tr;
if (dir < 0) {
tr.delete($head.pos - nextNode.nodeSize, $head.pos);
} else {
tr.delete($head.pos, $head.pos + nextNode.nodeSize);
}
view.dispatch(tr);
return true;
}
return false;
}
function getMods(event) {
var result = "";
if (event.ctrlKey) {
result += "c";
}
if (event.metaKey) {
result += "m";
}
if (event.altKey) {
result += "a";
}
if (event.shiftKey) {
result += "s";
}
return result;
}
function captureKeyDown(view, event) {
var code = event.keyCode,
mods = getMods(event);
if (code == 8) {
return stopNativeHorizontalDelete(view, -1) || skipIgnoredNodesLeft(view);
} else if (code == 46) {
return stopNativeHorizontalDelete(view, 1) || skipIgnoredNodesRight(view);
} else if (code == 13 || code == 27) {
return true;
} else if (code == 37) {
return selectHorizontally(view, -1) || skipIgnoredNodesLeft(view);
} else if (code == 39) {
return selectHorizontally(view, 1) || skipIgnoredNodesRight(view);
} else if (code == 38) {
return selectVertically(view, -1);
} else if (code == 40) {
return selectVertically(view, 1);
} else if (mods == (browser.mac ? "m" : "c") && (code == 66 || code == 73 || code == 89 || code == 90)) {
return true;
} else if (browser.mac && ((code == 68 || code == 72) && mods == "c") || (code == 68 && mods == "a")) {
return stopNativeHorizontalDelete(view, code == 68 ? 1 : -1) || skipIgnoredNodesRight(view);
}
return false;
}
exports.captureKeyDown = captureKeyDown;
return module.exports;
});
$__System.registerDynamic("17", ["3", "7", "18"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var ref = $__require('3');
var Fragment = ref.Fragment;
var DOMParser = ref.DOMParser;
var ref$1 = $__require('7');
var Selection = ref$1.Selection;
var ref$2 = $__require('18');
var TrackMappings = ref$2.TrackMappings;
var DOMChange = function(view, id, composing) {
var this$1 = this;
this.view = view;
this.id = id;
this.state = view.state;
this.composing = composing;
this.from = this.to = null;
this.timeout = composing ? null : setTimeout(function() {
return this$1.finish();
}, 20);
this.mappings = new TrackMappings(view.state);
};
DOMChange.prototype.addRange = function(from, to) {
if (this.from == null) {
this.from = from;
this.to = to;
} else {
this.from = Math.min(from, this.from);
this.to = Math.max(to, this.to);
}
};
DOMChange.prototype.changedRange = function() {
if (this.from == null) {
return rangeAroundSelection(this.state.selection);
}
var $from = this.state.doc.resolve(Math.min(this.from, this.state.selection.from)),
$to = this.state.doc.resolve(this.to);
var shared = $from.sharedDepth(this.to);
return {
from: $from.before(shared + 1),
to: $to.after(shared + 1)
};
};
DOMChange.prototype.finish = function(force) {
clearTimeout(this.timeout);
if (this.composing && !force) {
return;
}
var range = this.changedRange();
if (this.from == null) {
this.view.docView.markDirty(range.from, range.to);
} else {
this.view.docView.markDirty(this.from, this.to);
}
var mapping = this.mappings.getMapping(this.view.state);
this.destroy();
if (mapping) {
readDOMChange(this.view, mapping, this.state, range);
}
if (this.view.docView.dirty) {
this.view.updateState(this.view.state);
}
};
DOMChange.prototype.destroy = function() {
this.mappings.destroy();
this.view.inDOMChange = null;
};
DOMChange.prototype.compositionEnd = function() {
var this$1 = this;
if (this.composing) {
this.composing = false;
this.timeout = setTimeout(function() {
return this$1.finish();
}, 50);
}
};
DOMChange.start = function(view, composing) {
if (view.inDOMChange) {
if (composing) {
clearTimeout(view.inDOMChange.timeout);
view.inDOMChange.composing = true;
}
} else {
var id = Math.floor(Math.random() * 0xffffffff);
view.inDOMChange = new DOMChange(view, id, composing);
}
return view.inDOMChange;
};
exports.DOMChange = DOMChange;
function parseBetween(view, oldState, from, to) {
var ref = view.docView.domFromPos(from, -1);
var parent = ref.node;
var startOff = ref.offset;
var ref$1 = view.docView.domFromPos(to, 1);
var parentRight = ref$1.node;
var endOff = ref$1.offset;
if (parent != parentRight) {
return null;
}
if (endOff == parent.childNodes.length) {
for (var scan = parent; scan != view.content; ) {
if (!scan) {
return null;
}
if (scan.nextSibling) {
if (!scan.nextSibling.pmViewDesc) {
return null;
}
break;
}
scan = scan.parentNode;
}
}
var domSel = view.root.getSelection(),
find = null,
anchor = domSel.anchorNode;
if (anchor && view.content.contains(anchor.nodeType == 1 ? anchor : anchor.parentNode)) {
find = [{
node: anchor,
offset: domSel.anchorOffset
}];
if (!domSel.isCollapsed) {
find.push({
node: domSel.focusNode,
offset: domSel.focusOffset
});
}
}
var startDoc = oldState.doc;
var parser = view.someProp("domParser") || DOMParser.fromSchema(view.state.schema);
var $from = startDoc.resolve(from);
var sel = null,
doc = parser.parse(parent, {
topNode: $from.parent.copy(),
topStart: $from.index(),
topOpen: true,
from: startOff,
to: endOff,
preserveWhitespace: true,
editableContent: true,
findPositions: find,
ruleFromNode: ruleFromNode
});
if (find && find[0].pos != null) {
var anchor$1 = find[0].pos,
head = find[1] && find[1].pos;
if (head == null) {
head = anchor$1;
}
sel = {
anchor: anchor$1 + from,
head: head + from
};
}
return {
doc: doc,
sel: sel
};
}
function ruleFromNode(dom) {
var desc = dom.pmViewDesc;
if (desc) {
return desc.parseRule();
} else if (dom.nodeName == "BR" && dom.parentNode && dom.parentNode.lastChild == dom) {
return {ignore: true};
}
}
function isAtEnd($pos, depth) {
for (var i = depth || 0; i < $pos.depth; i++) {
if ($pos.index(i) + 1 < $pos.node(i).childCount) {
return false;
}
}
return $pos.parentOffset == $pos.parent.content.size;
}
function isAtStart($pos, depth) {
for (var i = depth || 0; i < $pos.depth; i++) {
if ($pos.index(0) > 0) {
return false;
}
}
return $pos.parentOffset == 0;
}
function rangeAroundSelection(selection) {
var $from = selection.$from;
var $to = selection.$to;
if ($from.sameParent($to) && $from.parent.isTextblock && $from.parentOffset && $to.parentOffset < $to.parent.content.size) {
var startOff = Math.max(0, $from.parentOffset);
var size = $from.parent.content.size;
var endOff = Math.min(size, $to.parentOffset);
if (startOff > 0) {
startOff = $from.parent.childBefore(startOff).offset;
}
if (endOff < size) {
var after = $from.parent.childAfter(endOff);
endOff = after.offset + after.node.nodeSize;
}
var nodeStart = $from.start();
return {
from: nodeStart + startOff,
to: nodeStart + endOff
};
} else {
for (var depth = 0; ; depth++) {
var fromStart = isAtStart($from, depth + 1),
toEnd = isAtEnd($to, depth + 1);
if (fromStart || toEnd || $from.index(depth) != $to.index(depth) || $to.node(depth).isTextblock) {
var from = $from.before(depth + 1),
to = $to.after(depth + 1);
if (fromStart && $from.index(depth) > 0) {
from -= $from.node(depth).child($from.index(depth) - 1).nodeSize;
}
if (toEnd && $to.index(depth) + 1 < $to.node(depth).childCount) {
to += $to.node(depth).child($to.index(depth) + 1).nodeSize;
}
return {
from: from,
to: to
};
}
}
}
}
function keyEvent(keyCode, key) {
var event = document.createEvent("Event");
event.initEvent("keydown", true, true);
event.keyCode = keyCode;
event.key = event.code = key;
return event;
}
function readDOMChange(view, mapping, oldState, range) {
var parseResult,
doc = oldState.doc;
for (; ; ) {
parseResult = parseBetween(view, oldState, range.from, range.to);
if (parseResult) {
break;
}
var $from$1 = doc.resolve(range.from),
$to$1 = doc.resolve(range.to);
range = {
from: $from$1.depth ? $from$1.before() : 0,
to: $to$1.depth ? $to$1.after() : doc.content.size
};
}
var parsed = parseResult.doc;
var parsedSel = parseResult.sel;
var compare = doc.slice(range.from, range.to);
var change = findDiff(compare.content, parsed.content, range.from, oldState.selection.from);
if (!change) {
if (parsedSel) {
var sel = resolveSelection(view.state.doc, mapping, parsedSel);
if (sel && !sel.eq(view.state.selection)) {
view.dispatch(view.state.tr.setSelection(sel));
}
}
return;
}
var $from = parsed.resolveNoCache(change.start - range.from);
var $to = parsed.resolveNoCache(change.endB - range.from);
var nextSel;
if (!$from.sameParent($to) && $from.pos < parsed.content.size && (nextSel = Selection.findFrom(parsed.resolve($from.pos + 1), 1, true)) && nextSel.head == $to.pos && view.someProp("handleKeyDown", function(f) {
return f(view, keyEvent(13, "Enter"));
})) {
return;
}
if (oldState.selection.anchor > change.start && looksLikeJoin(doc, change.start, change.endA, $from, $to) && view.someProp("handleKeyDown", function(f) {
return f(view, keyEvent(8, "Backspace"));
})) {
return;
}
var from = mapping.map(change.start),
to = mapping.map(change.endA, -1);
var tr,
storedMarks,
markChange,
$from1;
if ($from.sameParent($to) && $from.parent.isTextblock) {
if ($from.pos == $to.pos) {
tr = view.state.tr.delete(from, to);
var $start = doc.resolve(change.start);
if ($start.parentOffset < $start.parent.content.size) {
storedMarks = $start.marks(true);
}
} else if (change.endA == change.endB && ($from1 = doc.resolve(change.start)) && (markChange = isMarkChange($from.parent.content.cut($from.parentOffset, $to.parentOffset), $from1.parent.content.cut($from1.parentOffset, change.endA - $from1.start())))) {
tr = view.state.tr;
if (markChange.type == "add") {
tr.addMark(from, to, markChange.mark);
} else {
tr.removeMark(from, to, markChange.mark);
}
} else if ($from.parent.child($from.index()).isText && $from.index() == $to.index() - ($to.textOffset ? 0 : 1)) {
var text = $from.parent.textBetween($from.parentOffset, $to.parentOffset);
if (view.someProp("handleTextInput", function(f) {
return f(view, from, to, text);
})) {
return;
}
tr = view.state.tr.insertText(text, from, to);
}
}
if (!tr) {
tr = view.state.tr.replace(from, to, parsed.slice(change.start - range.from, change.endB - range.from));
}
if (parsedSel) {
var sel$1 = resolveSelection(tr.doc, mapping, parsedSel);
if (sel$1) {
tr.setSelection(sel$1);
}
}
if (storedMarks) {
tr.setStoredMarks(storedMarks);
}
view.dispatch(tr.scrollIntoView());
}
function resolveSelection(doc, mapping, parsedSel) {
if (Math.max(parsedSel.anchor, parsedSel.head) > doc.content.size) {
return null;
}
return Selection.between(doc.resolve(mapping.map(parsedSel.anchor)), doc.resolve(mapping.map(parsedSel.head)));
}
function isMarkChange(cur, prev) {
var curMarks = cur.firstChild.marks,
prevMarks = prev.firstChild.marks;
var added = curMarks,
removed = prevMarks,
type,
mark,
update;
for (var i = 0; i < prevMarks.length; i++) {
added = prevMarks[i].removeFromSet(added);
}
for (var i$1 = 0; i$1 < curMarks.length; i$1++) {
removed = curMarks[i$1].removeFromSet(removed);
}
if (added.length == 1 && removed.length == 0) {
mark = added[0];
type = "add";
update = function(node) {
return node.mark(mark.addToSet(node.marks));
};
} else if (added.length == 0 && removed.length == 1) {
mark = removed[0];
type = "remove";
update = function(node) {
return node.mark(mark.removeFromSet(node.marks));
};
} else {
return null;
}
var updated = [];
for (var i$2 = 0; i$2 < prev.childCount; i$2++) {
updated.push(update(prev.child(i$2)));
}
if (Fragment.from(updated).eq(cur)) {
return {
mark: mark,
type: type
};
}
}
function looksLikeJoin(old, start, end, $newStart, $newEnd) {
if (!$newStart.parent.isTextblock || end - start <= $newEnd.pos - $newStart.pos || skipClosingAndOpening($newStart, true, false) < $newEnd.pos) {
return false;
}
var $start = old.resolve(start);
if ($start.parentOffset < $start.parent.content.size || !$start.parent.isTextblock) {
return false;
}
var $next = old.resolve(skipClosingAndOpening($start, true, true));
if (!$next.parent.isTextblock || $next.pos > end || skipClosingAndOpening($next, true, false) < end) {
return false;
}
return $newStart.parent.content.cut($newStart.parentOffset).eq($next.parent.content);
}
function skipClosingAndOpening($pos, fromEnd, mayOpen) {
var depth = $pos.depth,
end = fromEnd ? $pos.end() : $pos.pos;
while (depth > 0 && (fromEnd || $pos.indexAfter(depth) == $pos.node(depth).childCount)) {
depth--;
end++;
fromEnd = false;
}
if (mayOpen) {
var next = $pos.node(depth).maybeChild($pos.indexAfter(depth));
while (next && !next.isLeaf) {
next = next.firstChild;
end++;
}
}
return end;
}
function findDiff(a, b, pos, preferedStart) {
var start = a.findDiffStart(b, pos);
if (start == null) {
return null;
}
var ref = a.findDiffEnd(b, pos + a.size, pos + b.size);
var endA = ref.a;
var endB = ref.b;
if (endA < start && a.size < b.size) {
var move = preferedStart <= start && preferedStart >= endA ? start - preferedStart : 0;
start -= move;
endB = start + (endB - endA);
endA = start;
} else if (endB < start) {
var move$1 = preferedStart <= start && preferedStart >= endB ? start - preferedStart : 0;
start -= move$1;
endA = start + (endA - endB);
endB = start;
}
return {
start: start,
endA: endA,
endB: endB
};
}
return module.exports;
});
$__System.registerDynamic("19", ["3"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var ref = $__require('3');
var Slice = ref.Slice;
var Fragment = ref.Fragment;
var DOMParser = ref.DOMParser;
var DOMSerializer = ref.DOMSerializer;
function toClipboard(view, range, dataTransfer) {
var doc = view.state.doc,
fullSlice = doc.slice(range.from, range.to, !range.node);
var slice = fullSlice,
context;
if (!range.node) {
var cut = Math.max(0, range.$from.sharedDepth(range.to) - 1);
context = sliceContext(slice, cut);
var content = slice.content;
for (var i = 0; i < cut; i++) {
content = content.firstChild.content;
}
slice = new Slice(content, slice.openLeft - cut, slice.openRight - cut);
}
var serializer = view.someProp("clipboardSerializer") || DOMSerializer.fromSchema(view.state.schema);
var dom = serializer.serializeFragment(slice.content),
wrap = document.createElement("div");
wrap.appendChild(dom);
var child = wrap.firstChild.nodeType == 1 && wrap.firstChild;
if (child) {
if (range.node) {
child.setAttribute("data-pm-node-selection", true);
} else {
child.setAttribute("data-pm-context", context);
}
}
dataTransfer.clearData();
dataTransfer.setData("text/html", wrap.innerHTML);
dataTransfer.setData("text/plain", slice.content.textBetween(0, slice.content.size, "\n\n"));
return fullSlice;
}
exports.toClipboard = toClipboard;
var cachedCanUpdateClipboard = null;
function canUpdateClipboard(dataTransfer) {
if (cachedCanUpdateClipboard != null) {
return cachedCanUpdateClipboard;
}
dataTransfer.setData("text/html", "
");
return cachedCanUpdateClipboard = dataTransfer.getData("text/html") == "
";
}
exports.canUpdateClipboard = canUpdateClipboard;
function fromClipboard(view, dataTransfer, plainText, $context) {
var txt = dataTransfer.getData("text/plain");
var html = dataTransfer.getData("text/html");
if (!html && !txt) {
return null;
}
var dom,
inCode = $context.parent.type.spec.code;
if ((plainText || inCode || !html) && txt) {
view.someProp("transformPastedText", function(f) {
return txt = f(txt);
});
if (inCode) {
return new Slice(Fragment.from(view.state.schema.text(txt)), 0, 0);
}
dom = document.createElement("div");
txt.split(/(?:\r\n?|\n)+/).forEach(function(block) {
dom.appendChild(document.createElement("p")).textContent = block;
});
} else {
view.someProp("transformPastedHTML", function(f) {
return html = f(html);
});
dom = readHTML(html);
}
var parser = view.someProp("clipboardParser") || view.someProp("domParser") || DOMParser.fromSchema(view.state.schema);
var slice = parser.parseSlice(dom, {preserveWhitespace: true}),
context;
if (dom.querySelector("[data-pm-node-selection]")) {
slice = new Slice(slice.content, 0, 0);
} else if (context = dom.querySelector("[data-pm-context]")) {
slice = addContext(slice, context.getAttribute("data-pm-context"));
} else {
slice = normalizeSiblings(slice, $context);
}
return slice;
}
exports.fromClipboard = fromClipboard;
function normalizeSiblings(slice, $context) {
if (slice.content.childCount < 2) {
return slice;
}
var loop = function(d) {
var parent = $context.node(d);
var match = parent.contentMatchAt($context.index(d));
var lastWrap = (void 0),
result = [];
slice.content.forEach(function(node) {
if (!result) {
return;
}
var wrap = match.findWrappingFor(node),
inLast;
if (!wrap) {
return result = null;
}
if (inLast = result.length && lastWrap.length && addToSibling(wrap, lastWrap, node, result[result.length - 1], 0)) {
result[result.length - 1] = inLast;
} else {
if (result.length) {
result[result.length - 1] = closeRight(result[result.length - 1], lastWrap.length);
}
var wrapped = withWrappers(node, wrap);
result.push(wrapped);
match = match.matchType(wrapped.type, wrapped.attrs);
lastWrap = wrap;
}
});
if (result) {
return {v: Slice.maxOpen(Fragment.from(result))};
}
};
for (var d = $context.depth; d >= 0; d--) {
var returned = loop(d);
if (returned)
return returned.v;
}
return slice;
}
function withWrappers(node, wrap, from) {
if (from === void 0)
from = 0;
for (var i = wrap.length - 1; i >= from; i--) {
node = wrap[i].type.create(wrap[i].attrs, Fragment.from(node));
}
return node;
}
function addToSibling(wrap, lastWrap, node, sibling, depth) {
if (depth < wrap.length && depth < lastWrap.length && wrap[depth].type == lastWrap[depth].type) {
var inner = addToSibling(wrap, lastWrap, node, sibling.lastChild, depth + 1);
if (inner) {
return sibling.copy(sibling.content.replaceChild(sibling.childCount - 1, inner));
}
var match = sibling.contentMatchAt(sibling.childCount);
if (depth == wrap.length - 1 ? match.matchNode(node) : match.matchType(wrap[depth + 1].type, wrap[depth + 1].attrs)) {
return sibling.copy(sibling.content.append(Fragment.from(withWrappers(node, wrap, depth + 1))));
}
}
}
function closeRight(node, depth) {
if (depth == 0) {
return node;
}
var fragment = node.content.replaceChild(node.childCount - 1, closeRight(node.lastChild, depth - 1));
var fill = node.contentMatchAt(node.childCount).fillBefore(Fragment.empty, true);
return node.copy(fragment.append(fill));
}
var wrapMap = {
thead: "table",
colgroup: "table",
col: "table colgroup",
tr: "table tbody",
td: "table tbody tr",
th: "table tbody tr"
};
var detachedDoc = null;
function readHTML(html) {
var metas = /(\s*]*>)*/.exec(html);
if (metas) {
html = html.slice(metas[0].length);
}
var doc = detachedDoc || (detachedDoc = document.implementation.createHTMLDocument("title"));
var elt = doc.createElement("div");
var firstTag = /(?:]*>)*<([a-z][^>\s]+)/i.exec(html),
wrap,
depth = 0;
if (wrap = firstTag && wrapMap[firstTag[1].toLowerCase()]) {
var nodes = wrap.split(" ");
html = nodes.map(function(n) {
return "<" + n + ">";
}).join("") + html + nodes.map(function(n) {
return "" + n + ">";
}).reverse().join("");
depth = nodes.length;
}
elt.innerHTML = html;
for (var i = 0; i < depth; i++) {
elt = elt.firstChild;
}
return elt;
}
function sliceContext(slice, depth) {
var result = [],
content = slice.content;
for (var i = 0; i < depth; i++) {
var node = content.firstChild;
result.push(node.type.name, node.type.hasRequiredAttrs() ? node.attrs : null);
content = node.content;
}
return JSON.stringify(result);
}
function addContext(slice, context) {
if (!slice.size) {
return slice;
}
var schema = slice.content.firstChild.type.schema,
array;
try {
array = JSON.parse(context);
} catch (e) {
return slice;
}
var content = slice.content;
var openLeft = slice.openLeft;
var openRight = slice.openRight;
for (var i = array.length - 2; i >= 0; i -= 2) {
var type = schema.nodes[array[i]];
if (!type || type.hasRequiredAttrs()) {
break;
}
content = Fragment.from(type.create(array[i + 1], content));
openLeft++;
openRight++;
}
return new Slice(content, openLeft, openRight);
}
return module.exports;
});
$__System.registerDynamic("18", ["7", "9"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var ref = $__require('7');
var EditorState = ref.EditorState;
var ref$1 = $__require('9');
var Mapping = ref$1.Mapping;
var TrackedRecord = function(prev, mapping, state) {
this.prev = prev;
this.mapping = mapping;
this.state = state;
};
var TrackMappings = function(state) {
this.seen = [new TrackedRecord(null, null, state)];
EditorState.addApplyListener(this.track = this.track.bind(this));
};
TrackMappings.prototype.destroy = function() {
EditorState.removeApplyListener(this.track);
};
TrackMappings.prototype.find = function(state) {
var this$1 = this;
for (var i = this.seen.length - 1; i >= 0; i--) {
var record = this$1.seen[i];
if (record.state == state) {
return record;
}
}
};
TrackMappings.prototype.track = function(old, tr, state) {
var found = this.seen.length < 200 ? this.find(old) : null;
if (found) {
this.seen.push(new TrackedRecord(found, tr.docChanged ? tr.mapping : null, state));
}
};
TrackMappings.prototype.getMapping = function(state) {
var found = this.find(state);
if (!found) {
return null;
}
var mappings = [];
for (var rec = found; rec; rec = rec.prev) {
if (rec.mapping) {
mappings.push(rec.mapping);
}
}
var result = new Mapping;
for (var i = mappings.length - 1; i >= 0; i--) {
result.appendMapping(mappings[i]);
}
return result;
};
exports.TrackMappings = TrackMappings;
return module.exports;
});
$__System.registerDynamic("1a", ["7", "15", "16", "17", "19", "18"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var ref = $__require('7');
var Selection = ref.Selection;
var NodeSelection = ref.NodeSelection;
var TextSelection = ref.TextSelection;
var browser = $__require('15');
var ref$1 = $__require('16');
var captureKeyDown = ref$1.captureKeyDown;
var ref$2 = $__require('17');
var DOMChange = ref$2.DOMChange;
var ref$3 = $__require('19');
var fromClipboard = ref$3.fromClipboard;
var toClipboard = ref$3.toClipboard;
var canUpdateClipboard = ref$3.canUpdateClipboard;
var ref$4 = $__require('18');
var TrackMappings = ref$4.TrackMappings;
var handlers = {},
editHandlers = {};
function initInput(view) {
view.shiftKey = false;
view.mouseDown = null;
view.dragging = null;
view.inDOMChange = null;
view.mutationObserver = window.MutationObserver && new window.MutationObserver(function(mutations) {
return registerMutations(view, mutations);
});
startObserving(view);
var loop = function(event) {
var handler = handlers[event];
view.content.addEventListener(event, function(event) {
if (eventBelongsToView(view, event) && !runCustomHandler(view, event) && (view.editable || !(event.type in editHandlers))) {
handler(view, event);
}
});
};
for (var event in handlers)
loop(event);
view.extraHandlers = Object.create(null);
ensureListeners(view);
}
exports.initInput = initInput;
function destroyInput(view) {
stopObserving(view);
if (view.inDOMChange) {
view.inDOMChange.destroy();
}
if (view.dragging) {
view.dragging.destroy();
}
}
exports.destroyInput = destroyInput;
function ensureListeners(view) {
view.someProp("handleDOMEvents", function(handlers) {
for (var type in handlers) {
if (!view.extraHandlers[type] && !handlers.hasOwnProperty(type)) {
view.extraHandlers[type] = true;
view.content.addEventListener(type, function(event) {
return runCustomHandler(view, event);
});
}
}
});
}
exports.ensureListeners = ensureListeners;
function runCustomHandler(view, event) {
return view.someProp("handleDOMEvents", function(handlers) {
var handler = handlers[event.type];
return handler ? handler(view, event) : false;
});
}
function eventBelongsToView(view, event) {
if (!event.bubbles) {
return true;
}
if (event.defaultPrevented) {
return false;
}
for (var node = event.target; node != view.content; node = node.parentNode) {
if (!node || node.nodeType == 11 || (node.pmViewDesc && node.pmViewDesc.stopEvent(event))) {
return false;
}
}
return true;
}
function dispatchEvent(view, event) {
if (!runCustomHandler(view, event) && handlers[event.type] && (view.editable || !(event.type in editHandlers))) {
handlers[event.type](view, event);
}
}
exports.dispatchEvent = dispatchEvent;
editHandlers.keydown = function(view, event) {
if (event.keyCode == 16) {
view.shiftKey = true;
}
if (view.inDOMChange) {
return;
}
if (view.someProp("handleKeyDown", function(f) {
return f(view, event);
}) || captureKeyDown(view, event)) {
event.preventDefault();
} else {
view.selectionReader.poll();
}
};
editHandlers.keyup = function(view, e) {
if (e.keyCode == 16) {
view.shiftKey = false;
}
};
editHandlers.keypress = function(view, event) {
if (view.inDOMChange || !event.charCode || event.ctrlKey && !event.altKey || browser.mac && event.metaKey) {
return;
}
if (view.someProp("handleKeyPress", function(f) {
return f(view, event);
})) {
event.preventDefault();
return;
}
var ref = view.state.selection;
var node = ref.node;
var $from = ref.$from;
var $to = ref.$to;
if (node || !$from.sameParent($to)) {
var text = String.fromCharCode(event.charCode);
if (!view.someProp("handleTextInput", function(f) {
return f(view, $from.pos, $to.pos, text);
})) {
view.dispatch(view.state.tr.insertText(text).scrollIntoView());
}
event.preventDefault();
}
};
function eventCoords(event) {
return {
left: event.clientX,
top: event.clientY
};
}
var lastClick = {
time: 0,
x: 0,
y: 0
},
oneButLastClick = lastClick;
function isNear(event, click) {
var dx = click.x - event.clientX,
dy = click.y - event.clientY;
return dx * dx + dy * dy < 100;
}
function runHandlerOnContext(view, propName, pos, inside, event) {
if (inside == -1) {
return false;
}
var $pos = view.state.doc.resolve(inside);
var loop = function(i) {
if (view.someProp(propName, function(f) {
return i > $pos.depth ? f(view, pos, $pos.nodeAfter, $pos.before(i), event, true) : f(view, pos, $pos.node(i), $pos.before(i), event, false);
})) {
return {v: true};
}
};
for (var i = $pos.depth + 1; i > 0; i--) {
var returned = loop(i);
if (returned)
return returned.v;
}
return false;
}
function updateSelection(view, selection, origin) {
view.focus();
var tr = view.state.tr.setSelection(selection);
if (origin == "pointer") {
tr.setMeta("pointer", true);
}
view.dispatch(tr);
}
function selectClickedLeaf(view, inside) {
if (inside == -1) {
return false;
}
var $pos = view.state.doc.resolve(inside),
node = $pos.nodeAfter;
if (node && node.isLeaf && NodeSelection.isSelectable(node)) {
updateSelection(view, new NodeSelection($pos), "pointer");
return true;
}
return false;
}
function selectClickedNode(view, inside) {
if (inside == -1) {
return false;
}
var ref = view.state.selection;
var selectedNode = ref.node;
var $from = ref.$from;
var selectAt;
var $pos = view.state.doc.resolve(inside);
for (var i = $pos.depth + 1; i > 0; i--) {
var node = i > $pos.depth ? $pos.nodeAfter : $pos.node(i);
if (NodeSelection.isSelectable(node)) {
if (selectedNode && $from.depth > 0 && i >= $from.depth && $pos.before($from.depth + 1) == $from.pos) {
selectAt = $pos.before($from.depth);
} else {
selectAt = $pos.before(i);
}
break;
}
}
if (selectAt != null) {
updateSelection(view, NodeSelection.create(view.state.doc, selectAt), "pointer");
return true;
} else {
return false;
}
}
function handleSingleClick(view, pos, inside, event, selectNode) {
return runHandlerOnContext(view, "handleClickOn", pos, inside, event) || view.someProp("handleClick", function(f) {
return f(view, pos, event);
}) || (selectNode ? selectClickedNode(view, inside) : selectClickedLeaf(view, inside));
}
function handleDoubleClick(view, pos, inside, event) {
return runHandlerOnContext(view, "handleDoubleClickOn", pos, inside, event) || view.someProp("handleDoubleClick", function(f) {
return f(view, pos, event);
});
}
function handleTripleClick(view, pos, inside, event) {
return runHandlerOnContext(view, "handleTripleClickOn", pos, inside, event) || view.someProp("handleTripleClick", function(f) {
return f(view, pos, event);
}) || defaultTripleClick(view, inside);
}
function defaultTripleClick(view, inside) {
var doc = view.state.doc;
if (inside == -1) {
if (doc.isTextblock) {
updateSelection(view, TextSelection.create(doc, 0, doc.content.size), "pointer");
return true;
}
return false;
}
var $pos = doc.resolve(inside);
for (var i = $pos.depth + 1; i > 0; i--) {
var node = i > $pos.depth ? $pos.nodeAfter : $pos.node(i);
var nodePos = $pos.before(i);
if (node.isTextblock) {
updateSelection(view, TextSelection.create(doc, nodePos + 1, nodePos + 1 + node.content.size), "pointer");
} else if (NodeSelection.isSelectable(node)) {
updateSelection(view, NodeSelection.create(doc, nodePos), "pointer");
} else {
continue;
}
return true;
}
}
function forceDOMFlush(view) {
if (!view.inDOMChange) {
return false;
}
view.inDOMChange.finish(true);
return true;
}
var selectNodeModifier = browser.mac ? "metaKey" : "ctrlKey";
handlers.mousedown = function(view, event) {
var flushed = forceDOMFlush(view);
var now = Date.now(),
type;
if (now - lastClick.time >= 500 || !isNear(event, lastClick) || event[selectNodeModifier]) {
type = "singleClick";
} else if (now - oneButLastClick.time >= 600 || !isNear(event, oneButLastClick)) {
type = "doubleClick";
} else {
type = "tripleClick";
}
oneButLastClick = lastClick;
lastClick = {
time: now,
x: event.clientX,
y: event.clientY
};
var pos = view.posAtCoords(eventCoords(event));
if (!pos) {
return;
}
if (type == "singleClick") {
view.mouseDown = new MouseDown(view, pos, event, flushed);
} else if ((type == "doubleClick" ? handleDoubleClick : handleTripleClick)(view, pos.pos, pos.inside, event)) {
event.preventDefault();
} else {
view.selectionReader.poll("pointer");
}
};
var MouseDown = function(view, pos, event, flushed) {
var this$1 = this;
this.view = view;
this.pos = pos;
this.flushed = flushed;
this.selectNode = event[selectNodeModifier];
this.allowDefault = event.shiftKey;
var targetNode,
targetPos;
if (pos.inside > -1) {
targetNode = view.state.doc.nodeAt(pos.inside);
targetPos = pos.inside;
} else {
var $pos = view.state.doc.resolve(pos.pos);
targetNode = $pos.parent;
targetPos = $pos.depth ? $pos.before() : 0;
}
this.mightDrag = (targetNode.type.spec.draggable || targetNode == view.state.selection.node) ? {
node: targetNode,
pos: targetPos
} : null;
this.target = flushed ? null : event.target;
if (this.target && this.mightDrag) {
stopObserving(this.view);
this.target.draggable = true;
if (browser.gecko && (this.setContentEditable = !this.target.hasAttribute("contentEditable"))) {
setTimeout(function() {
return this$1.target.setAttribute("contentEditable", "false");
}, 20);
}
startObserving(this.view);
}
view.root.addEventListener("mouseup", this.up = this.up.bind(this));
view.root.addEventListener("mousemove", this.move = this.move.bind(this));
view.selectionReader.poll("pointer");
};
MouseDown.prototype.done = function() {
this.view.root.removeEventListener("mouseup", this.up);
this.view.root.removeEventListener("mousemove", this.move);
if (this.mightDrag && this.target) {
stopObserving(this.view);
this.target.draggable = false;
if (browser.gecko && this.setContentEditable) {
this.target.removeAttribute("contentEditable");
}
startObserving(this.view);
}
};
MouseDown.prototype.up = function(event) {
this.done();
if (!this.view.content.contains(event.target.nodeType == 3 ? event.target.parentNode : event.target)) {
return;
}
if (this.allowDefault) {
this.view.selectionReader.poll("pointer");
} else if (handleSingleClick(this.view, this.pos.pos, this.pos.inside, event, this.selectNode)) {
event.preventDefault();
} else if (this.flushed) {
updateSelection(this.view, Selection.near(this.view.state.doc.resolve(this.pos.pos)), "pointer");
event.preventDefault();
} else {
this.view.selectionReader.poll("pointer");
}
};
MouseDown.prototype.move = function(event) {
if (!this.allowDefault && (Math.abs(this.x - event.clientX) > 4 || Math.abs(this.y - event.clientY) > 4)) {
this.allowDefault = true;
}
this.view.selectionReader.poll("pointer");
};
handlers.touchdown = function(view) {
forceDOMFlush(view);
view.selectionReader.poll("pointer");
};
handlers.contextmenu = function(view, e) {
forceDOMFlush(view);
var pos = view.posAtCoords(eventCoords(e));
if (pos && view.someProp("handleContextMenu", function(f) {
return f(view, pos.pos, e);
})) {
e.preventDefault();
}
};
editHandlers.compositionstart = editHandlers.compositionupdate = function(view) {
DOMChange.start(view, true);
if (view.state.storedMarks) {
view.inDOMChange.finish(true);
}
};
editHandlers.compositionend = function(view, e) {
if (!view.inDOMChange) {
if (e.data) {
DOMChange.start(view, true);
} else {
return;
}
}
view.inDOMChange.compositionEnd();
};
var observeOptions = {
childList: true,
characterData: true,
attributes: true,
subtree: true
};
function startObserving(view) {
if (view.mutationObserver) {
view.mutationObserver.observe(view.content, observeOptions);
}
if (browser.ie && browser.ie_version <= 11) {
view.content.addEventListener("DOMCharacterDataModified", view.onCharData || (view.onCharData = function(e) {
registerMutation(view, {
target: e.target,
type: "characterData"
});
}));
}
}
exports.startObserving = startObserving;
function flushObserver(view) {
if (view.mutationObserver) {
registerMutations(view, view.mutationObserver.takeRecords());
}
}
exports.flushObserver = flushObserver;
function stopObserving(view) {
if (view.mutationObserver) {
flushObserver(view);
view.mutationObserver.disconnect();
}
if (browser.ie && browser.ie_version <= 11) {
view.content.removeEventListener("DOMCharacterDataModified", view.onCharData);
}
}
exports.stopObserving = stopObserving;
function registerMutations(view, mutations) {
if (view.editable) {
for (var i = 0; i < mutations.length; i++) {
registerMutation(view, mutations[i]);
}
}
}
function registerMutation(view, mut) {
var desc = view.docView.nearestDesc(mut.target);
if (mut.type == "attributes" && (desc == view.docView || mut.attributeName == "contenteditable")) {
return;
}
if (!desc || desc.ignoreMutation(mut)) {
return;
}
var from,
to;
if (mut.type == "childList") {
var fromOffset = mut.previousSibling && mut.previousSibling.parentNode == mut.target ? Array.prototype.indexOf.call(mut.target.childNodes, mut.previousSibling) + 1 : 0;
if (fromOffset == -1) {
return;
}
from = desc.localPosFromDOM(mut.target, fromOffset, -1);
var toOffset = mut.nextSibling && mut.nextSibling.parentNode == mut.target ? Array.prototype.indexOf.call(mut.target.childNodes, mut.nextSibling) : mut.target.childNodes.length;
if (toOffset == -1) {
return;
}
to = desc.localPosFromDOM(mut.target, toOffset, 1);
} else if (mut.type == "attributes") {
from = desc.posAtStart - desc.border;
to = desc.posAtEnd + desc.border;
} else {
from = desc.posAtStart;
to = desc.posAtEnd;
}
DOMChange.start(view).addRange(from, to);
}
editHandlers.input = function(view) {
return DOMChange.start(view);
};
handlers.copy = editHandlers.cut = function(view, e) {
var sel = view.state.selection,
cut = e.type == "cut";
if (sel.empty) {
return;
}
if (!e.clipboardData || !canUpdateClipboard(e.clipboardData)) {
if (cut && browser.ie && browser.ie_version <= 11) {
DOMChange.start(view);
}
return;
}
toClipboard(view, sel, e.clipboardData);
e.preventDefault();
if (cut) {
view.dispatch(view.state.tr.deleteRange(sel.from, sel.to).scrollIntoView());
}
};
function sliceSingleNode(slice) {
return slice.openLeft == 0 && slice.openRight == 0 && slice.content.childCount == 1 ? slice.content.firstChild : null;
}
editHandlers.paste = function(view, e) {
if (!e.clipboardData) {
if (browser.ie && browser.ie_version <= 11) {
DOMChange.start(view);
}
return;
}
var slice = fromClipboard(view, e.clipboardData, view.shiftKey, view.state.selection.$from);
if (slice) {
e.preventDefault();
view.someProp("transformPasted", function(f) {
slice = f(slice);
});
var singleNode = sliceSingleNode(slice);
var tr = singleNode ? view.state.tr.replaceSelectionWith(singleNode) : view.state.tr.replaceSelection(slice);
view.dispatch(tr.scrollIntoView());
}
};
var Dragging = function(state, slice, range, move) {
this.slice = slice;
this.range = range;
this.move = move && new TrackMappings(state);
};
Dragging.prototype.destroy = function() {
if (this.move) {
this.move.destroy();
}
};
function clearDragging(view) {
if (view.dragging) {
view.dragging.destroy();
view.dragging = null;
}
}
function dropPos(slice, $pos) {
if (!slice || !slice.content.size) {
return $pos.pos;
}
var content = slice.content;
for (var i = 0; i < slice.openLeft; i++) {
content = content.firstChild.content;
}
for (var d = $pos.depth; d >= 0; d--) {
var bias = d == $pos.depth ? 0 : $pos.pos <= ($pos.start(d + 1) + $pos.end(d + 1)) / 2 ? -1 : 1;
var insertPos = $pos.index(d) + (bias > 0 ? 1 : 0);
if ($pos.node(d).canReplace(insertPos, insertPos, content)) {
return bias == 0 ? $pos.pos : bias < 0 ? $pos.before(d + 1) : $pos.after(d + 1);
}
}
return $pos.pos;
}
handlers.dragstart = function(view, e) {
var mouseDown = view.mouseDown;
if (mouseDown) {
mouseDown.done();
}
if (!e.dataTransfer) {
return;
}
var sel = view.state.selection,
draggedRange;
var pos = sel.empty ? null : view.posAtCoords(eventCoords(e));
if (pos != null && pos.pos >= sel.from && pos.pos <= sel.to) {
draggedRange = sel;
} else if (mouseDown && mouseDown.mightDrag) {
draggedRange = NodeSelection.create(view.state.doc, mouseDown.mightDrag.pos);
}
if (draggedRange) {
var slice = toClipboard(view, draggedRange, e.dataTransfer);
view.dragging = new Dragging(view.state, slice, draggedRange, !e.ctrlKey);
}
};
handlers.dragend = function(view) {
window.setTimeout(function() {
return clearDragging(view);
}, 50);
};
editHandlers.dragover = editHandlers.dragenter = function(_, e) {
return e.preventDefault();
};
editHandlers.drop = function(view, e) {
var dragging = view.dragging;
clearDragging(view);
if (!e.dataTransfer) {
return;
}
var $mouse = view.state.doc.resolve(view.posAtCoords(eventCoords(e)).pos);
if (!$mouse) {
return;
}
var slice = dragging && dragging.slice || fromClipboard(view, e.dataTransfer, false, $mouse);
if (!slice) {
return;
}
var insertPos = dropPos(slice, view.state.doc.resolve($mouse.pos));
e.preventDefault();
var tr = view.state.tr;
if (dragging && dragging.move) {
var ref = dragging.range;
var from = ref.from;
var to = ref.to;
var mapping = dragging.move.getMapping(view.state);
if (mapping) {
tr.deleteRange(mapping.map(from, 1), mapping.map(to, -1));
}
}
view.someProp("transformPasted", function(f) {
slice = f(slice);
});
var pos = tr.mapping.map(insertPos);
var isNode = slice.openLeft == 0 && slice.openRight == 0 && slice.content.childCount == 1;
if (isNode) {
tr.replaceRangeWith(pos, pos, slice.content.firstChild);
} else {
tr.replaceRange(pos, pos, slice);
}
var $pos = tr.doc.resolve(pos);
if (isNode && NodeSelection.isSelectable(slice.content.firstChild) && $pos.nodeAfter && $pos.nodeAfter.sameMarkup(slice.content.firstChild)) {
tr.setSelection(new NodeSelection($pos));
} else {
tr.setSelection(Selection.between($pos, tr.doc.resolve(tr.mapping.map(insertPos))));
}
view.focus();
view.dispatch(tr);
};
handlers.focus = function(view, event) {
if (!view.focused) {
view.content.classList.add("ProseMirror-focused");
view.focused = true;
}
view.someProp("onFocus", function(f) {
f(view, event);
});
};
handlers.blur = function(view, event) {
if (view.focused) {
view.content.classList.remove("ProseMirror-focused");
view.focused = false;
}
view.someProp("onBlur", function(f) {
f(view, event);
});
};
for (var prop in editHandlers) {
handlers[prop] = editHandlers[prop];
}
return module.exports;
});
$__System.registerDynamic("1b", ["7", "15", "1a"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var ref = $__require('7');
var Selection = ref.Selection;
var NodeSelection = ref.NodeSelection;
var browser = $__require('15');
var ref$1 = $__require('1a');
var flushObserver = ref$1.flushObserver;
var SelectionReader = function(view) {
var this$1 = this;
this.view = view;
this.lastAnchorNode = this.lastHeadNode = this.lastAnchorOffset = this.lastHeadOffset = null;
this.lastSelection = view.state.selection;
this.poller = poller(this);
view.content.addEventListener("focus", function() {
return this$1.poller.start();
});
view.content.addEventListener("blur", function() {
return this$1.poller.stop();
});
if (!view.editable) {
this.poller.start();
}
};
SelectionReader.prototype.destroy = function() {
this.poller.stop();
};
SelectionReader.prototype.poll = function(origin) {
this.poller.poll(origin);
};
SelectionReader.prototype.editableChanged = function() {
if (!this.view.editable) {
this.poller.start();
} else if (!this.view.hasFocus()) {
this.poller.stop();
}
};
SelectionReader.prototype.domChanged = function() {
var sel = this.view.root.getSelection();
return sel.anchorNode != this.lastAnchorNode || sel.anchorOffset != this.lastAnchorOffset || sel.focusNode != this.lastHeadNode || sel.focusOffset != this.lastHeadOffset;
};
SelectionReader.prototype.storeDOMState = function(selection) {
var sel = this.view.root.getSelection();
this.lastAnchorNode = sel.anchorNode;
this.lastAnchorOffset = sel.anchorOffset;
this.lastHeadNode = sel.focusNode;
this.lastHeadOffset = sel.focusOffset;
this.lastSelection = selection;
};
SelectionReader.prototype.readFromDOM = function(origin) {
if (!this.view.inDOMChange) {
flushObserver(this.view);
}
if (!this.view.hasFocus() || this.view.inDOMChange || !this.domChanged()) {
return;
}
var domSel = this.view.root.getSelection(),
doc = this.view.state.doc;
var nearestDesc = this.view.docView.nearestDesc(domSel.focusNode);
if (!nearestDesc.size) {
this.storeDOMState();
return;
}
var head = this.view.docView.posFromDOM(domSel.focusNode, domSel.focusOffset);
var $head = doc.resolve(head),
$anchor,
selection;
if (domSel.isCollapsed) {
$anchor = $head;
while (nearestDesc && !nearestDesc.node) {
nearestDesc = nearestDesc.parent;
}
if (nearestDesc && nearestDesc.node.isLeaf && NodeSelection.isSelectable(nearestDesc.node)) {
var pos = nearestDesc.posAtStart;
selection = new NodeSelection(head == pos ? $head : doc.resolve(pos));
}
} else {
$anchor = doc.resolve(this.view.docView.posFromDOM(domSel.anchorNode, domSel.anchorOffset));
}
if (!selection) {
var bias = this.view.state.selection.head != null && this.view.state.selection.head < $head.pos ? 1 : -1;
selection = Selection.between($anchor, $head, bias);
if (bias == -1 && selection.node) {
selection = Selection.between($anchor, $head, 1);
}
}
if ($head.pos == selection.head && $anchor.pos == selection.anchor) {
this.storeDOMState(selection);
}
if (!this.view.state.selection.eq(selection)) {
var tr = this.view.state.tr.setSelection(selection);
if (origin == "pointer") {
tr.setMeta("pointer", true);
}
this.view.dispatch(tr);
}
};
exports.SelectionReader = SelectionReader;
var SelectionChangePoller = function(reader) {
var this$1 = this;
this.listening = false;
this.curOrigin = null;
this.originTime = 0;
this.reader = reader;
this.readFunc = function() {
return reader.readFromDOM(this$1.originTime > Date.now() - 50 ? this$1.curOrigin : null);
};
};
SelectionChangePoller.prototype.poll = function(origin) {
this.curOrigin = origin;
this.originTime = Date.now();
};
SelectionChangePoller.prototype.start = function() {
if (!this.listening) {
document.addEventListener("selectionchange", this.readFunc);
this.listening = true;
if (this.reader.view.hasFocus()) {
this.readFunc();
}
}
};
SelectionChangePoller.prototype.stop = function() {
if (this.listening) {
document.removeEventListener("selectionchange", this.readFunc);
this.listening = false;
}
};
var TimeoutPoller = function(reader) {
this.polling = null;
this.reader = reader;
this.pollFunc = this.doPoll.bind(this, null);
};
TimeoutPoller.prototype.doPoll = function(origin) {
var view = this.reader.view;
if (view.focused || !view.editable) {
this.reader.readFromDOM(origin);
this.polling = setTimeout(this.pollFunc, 100);
} else {
this.polling = null;
}
};
TimeoutPoller.prototype.poll = function(origin) {
clearTimeout(this.polling);
this.polling = setTimeout(origin ? this.doPoll.bind(this, origin) : this.pollFunc, 0);
};
TimeoutPoller.prototype.start = function() {
if (this.polling == null) {
this.poll();
}
};
TimeoutPoller.prototype.stop = function() {
clearTimeout(this.polling);
this.polling = null;
};
function poller(reader) {
return new ("onselectionchange" in document ? SelectionChangePoller : TimeoutPoller)(reader);
}
function selectionToDOM(view, sel, takeFocus) {
syncNodeSelection(view, sel);
if (!view.hasFocus()) {
if (!takeFocus) {
return;
} else if (browser.gecko && view.editable) {
view.content.focus();
}
}
var reader = view.selectionReader;
if (sel == reader.lastSelection && !reader.domChanged()) {
return;
}
var anchor = sel.anchor;
var head = sel.head;
var resetEditable;
if (anchor == null) {
anchor = sel.from;
head = sel.to;
if (browser.webkit && sel.node.isBlock) {
var desc = view.docView.descAt(sel.from);
if (!desc.contentDOM && desc.dom.contentEditable == "false") {
resetEditable = desc.dom;
desc.dom.contentEditable = "true";
}
}
}
view.docView.setSelection(anchor, head, view.root);
if (resetEditable) {
resetEditable.contentEditable = "false";
}
reader.storeDOMState(sel);
}
exports.selectionToDOM = selectionToDOM;
function syncNodeSelection(view, sel) {
if (sel instanceof NodeSelection) {
var desc = view.docView.descAt(sel.from);
if (desc != view.lastSelectedViewDesc) {
clearNodeSelection(view);
if (desc) {
desc.selectNode();
}
view.lastSelectedViewDesc = desc;
}
} else {
clearNodeSelection(view);
}
}
function clearNodeSelection(view) {
if (view.lastSelectedViewDesc) {
view.lastSelectedViewDesc.deselectNode();
view.lastSelectedViewDesc = null;
}
}
return module.exports;
});
$__System.registerDynamic("1c", [], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
function compareObjs(a, b) {
if (a == b) {
return true;
}
for (var p in a) {
if (a[p] !== b[p]) {
return false;
}
}
for (var p$1 in b) {
if (!(p$1 in a)) {
return false;
}
}
return true;
}
var WidgetType = function(widget, options) {
if (widget.nodeType != 1) {
var wrap = document.createElement("span");
wrap.appendChild(widget);
widget = wrap;
}
widget.contentEditable = false;
widget.classList.add("ProseMirror-widget");
this.widget = widget;
this.options = options || noOptions;
};
WidgetType.prototype.map = function(mapping, span, offset, oldOffset) {
var ref = mapping.mapResult(span.from + oldOffset, this.options.associative == "left" ? -1 : 1);
var pos = ref.pos;
var deleted = ref.deleted;
return deleted ? null : new Decoration(pos - offset, pos - offset, this);
};
WidgetType.prototype.valid = function() {
return true;
};
WidgetType.prototype.eq = function(other) {
return this == other || (other instanceof WidgetType && (this.widget == other.widget || this.options.key) && compareObjs(this.options, other.options));
};
var InlineType = function(attrs, options) {
this.options = options || noOptions;
this.attrs = attrs;
};
InlineType.prototype.map = function(mapping, span, offset, oldOffset) {
var from = mapping.map(span.from + oldOffset, this.options.inclusiveLeft ? -1 : 1) - offset;
var to = mapping.map(span.to + oldOffset, this.options.inclusiveRight ? 1 : -1) - offset;
return from >= to ? null : new Decoration(from, to, this);
};
InlineType.prototype.valid = function(_, span) {
return span.from < span.to;
};
InlineType.prototype.eq = function(other) {
return this == other || (other instanceof InlineType && compareObjs(this.attrs, other.attrs) && compareObjs(this.options, other.options));
};
InlineType.is = function(span) {
return span.type instanceof InlineType;
};
var NodeType = function(attrs, options) {
this.attrs = attrs;
this.options = options || noOptions;
};
NodeType.prototype.map = function(mapping, span, offset, oldOffset) {
var from = mapping.mapResult(span.from + oldOffset, 1);
if (from.deleted) {
return null;
}
var to = mapping.mapResult(span.to + oldOffset, -1);
if (to.deleted || to.pos <= from.pos) {
return null;
}
return new Decoration(from.pos - offset, to.pos - offset, this);
};
NodeType.prototype.valid = function(node, span) {
var ref = node.content.findIndex(span.from);
var index = ref.index;
var offset = ref.offset;
return offset == span.from && offset + node.child(index).nodeSize == span.to;
};
NodeType.prototype.eq = function(other) {
return this == other || (other instanceof NodeType && compareObjs(this.attrs, other.attrs) && compareObjs(this.options, other.options));
};
var Decoration = function(from, to, type) {
this.from = from;
this.to = to;
this.type = type;
};
var prototypeAccessors = {options: {}};
Decoration.prototype.copy = function(from, to) {
return new Decoration(from, to, this.type);
};
Decoration.prototype.eq = function(other) {
return this.type.eq(other.type) && this.from == other.from && this.to == other.to;
};
Decoration.prototype.map = function(mapping, offset, oldOffset) {
return this.type.map(mapping, this, offset, oldOffset);
};
Decoration.widget = function(pos, dom, options) {
return new Decoration(pos, pos, new WidgetType(dom, options));
};
Decoration.inline = function(from, to, attrs, options) {
return new Decoration(from, to, new InlineType(attrs, options));
};
Decoration.node = function(from, to, attrs, options) {
return new Decoration(from, to, new NodeType(attrs, options));
};
prototypeAccessors.options.get = function() {
return this.type.options;
};
Object.defineProperties(Decoration.prototype, prototypeAccessors);
exports.Decoration = Decoration;
var none = [],
noOptions = {};
var DecorationSet = function(local, children) {
this.local = local && local.length ? local : none;
this.children = children && children.length ? children : none;
};
DecorationSet.create = function(doc, decorations) {
return decorations.length ? buildTree(decorations, doc, 0, noOptions) : empty;
};
DecorationSet.prototype.find = function(start, end) {
var result = [];
this.findInner(start == null ? 0 : start, end == null ? 1e9 : end, result, 0);
return result;
};
DecorationSet.prototype.findInner = function(start, end, result, offset) {
var this$1 = this;
for (var i = 0; i < this.local.length; i++) {
var span = this$1.local[i];
if (span.from <= end && span.to >= start) {
result.push(span.copy(span.from + offset, span.to + offset));
}
}
for (var i$1 = 0; i$1 < this.children.length; i$1 += 3) {
if (this$1.children[i$1] < end && this$1.children[i$1 + 1] > start) {
var childOff = this$1.children[i$1] + 1;
this$1.children[i$1 + 2].findInner(start - childOff, end - childOff, result, offset + childOff);
}
}
};
DecorationSet.prototype.map = function(mapping, doc, options) {
if (this == empty || mapping.maps.length == 0) {
return this;
}
return this.mapInner(mapping, doc, 0, 0, options || noOptions);
};
DecorationSet.prototype.mapInner = function(mapping, node, offset, oldOffset, options) {
var this$1 = this;
var newLocal;
for (var i = 0; i < this.local.length; i++) {
var mapped = this$1.local[i].map(mapping, offset, oldOffset);
if (mapped && mapped.type.valid(node, mapped)) {
(newLocal || (newLocal = [])).push(mapped);
} else if (options.onRemove) {
options.onRemove(this$1.local[i].options);
}
}
if (this.children.length) {
return mapChildren(this.children, newLocal, mapping, node, offset, oldOffset, options);
} else {
return newLocal ? new DecorationSet(newLocal.sort(byPos)) : empty;
}
};
DecorationSet.prototype.add = function(doc, decorations) {
if (!decorations.length) {
return this;
}
if (this == empty) {
return DecorationSet.create(doc, decorations);
}
return this.addInner(doc, decorations, 0);
};
DecorationSet.prototype.addInner = function(doc, decorations, offset) {
var this$1 = this;
var children,
childIndex = 0;
doc.forEach(function(childNode, childOffset) {
var baseOffset = childOffset + offset,
found;
if (!(found = takeSpansForNode(decorations, childNode, baseOffset))) {
return;
}
if (!children) {
children = this$1.children.slice();
}
while (childIndex < children.length && children[childIndex] < childOffset) {
childIndex += 3;
}
if (children[childIndex] == childOffset) {
children[childIndex + 2] = children[childIndex + 2].addInner(childNode, found, baseOffset + 1);
} else {
children.splice(childIndex, 0, childOffset, childOffset + childNode.nodeSize, buildTree(found, childNode, baseOffset + 1, noOptions));
}
childIndex += 3;
});
var local = moveSpans(childIndex ? withoutNulls(decorations) : decorations, -offset);
return new DecorationSet(local.length ? this.local.concat(local).sort(byPos) : this.local, children || this.children);
};
DecorationSet.prototype.remove = function(decorations) {
if (decorations.length == 0 || this == empty) {
return this;
}
return this.removeInner(decorations, 0);
};
DecorationSet.prototype.removeInner = function(decorations, offset) {
var this$1 = this;
var children = this.children,
local = this.local;
for (var i = 0; i < children.length; i += 3) {
var found = (void 0),
from = children[i] + offset,
to = children[i + 1] + offset;
for (var j = 0,
span = (void 0); j < decorations.length; j++) {
if (span = decorations[j]) {
if (span.from > from && span.to < to) {
decorations[j] = null;
;
(found || (found = [])).push(span);
}
}
}
if (!found) {
continue;
}
if (children == this$1.children) {
children = this$1.children.slice();
}
var removed = children[i + 2].removeInner(found, from + 1);
if (removed != empty) {
children[i + 2] = removed;
} else {
children.splice(i, 3);
i -= 3;
}
}
if (local.length) {
for (var i$1 = 0,
span$1 = (void 0); i$1 < decorations.length; i$1++) {
if (span$1 = decorations[i$1]) {
for (var j$1 = 0; j$1 < local.length; j$1++) {
if (local[j$1].type == span$1.type) {
if (local == this$1.local) {
local = this$1.local.slice();
}
local.splice(j$1--, 1);
}
}
}
}
}
if (children == this.children && local == this.local) {
return this;
}
return local.length || children.length ? new DecorationSet(local, children) : empty;
};
DecorationSet.prototype.forChild = function(offset, node) {
var this$1 = this;
if (this == empty) {
return this;
}
if (node.isLeaf) {
return DecorationSet.empty;
}
var child,
local;
for (var i = 0; i < this.children.length; i += 3) {
if (this$1.children[i] >= offset) {
if (this$1.children[i] == offset) {
child = this$1.children[i + 2];
}
break;
}
}
var start = offset + 1,
end = start + node.content.size;
for (var i$1 = 0; i$1 < this.local.length; i$1++) {
var dec = this$1.local[i$1];
if (dec.from < end && dec.to > start && (dec.type instanceof InlineType)) {
var from = Math.max(start, dec.from) - start,
to = Math.min(end, dec.to) - start;
if (from < to) {
(local || (local = [])).push(dec.copy(from, to));
}
}
}
if (local) {
var localSet = new DecorationSet(local);
return child ? new DecorationGroup([localSet, child]) : localSet;
}
return child || empty;
};
DecorationSet.prototype.eq = function(other) {
var this$1 = this;
if (this == other) {
return true;
}
if (!(other instanceof DecorationSet) || this.local.length != other.local.length || this.children.length != other.children.length) {
return false;
}
for (var i = 0; i < this.local.length; i++) {
if (!this$1.local[i].eq(other.local[i])) {
return false;
}
}
for (var i$1 = 0; i$1 < this.children.length; i$1 += 3) {
if (this$1.children[i$1] != other.children[i$1] || this$1.children[i$1 + 1] != other.children[i$1 + 1] || !this$1.children[i$1 + 2].eq(other.children[i$1 + 2])) {
return false;
}
}
return false;
};
DecorationSet.prototype.locals = function(node) {
return removeOverlap(this.localsInner(node));
};
DecorationSet.prototype.localsInner = function(node) {
var this$1 = this;
if (this == empty) {
return none;
}
if (node.isTextblock || !this.local.some(InlineType.is)) {
return this.local;
}
var result = [];
for (var i = 0; i < this.local.length; i++) {
if (!(this$1.local[i].type instanceof InlineType)) {
result.push(this$1.local[i]);
}
}
return result;
};
exports.DecorationSet = DecorationSet;
var empty = new DecorationSet();
DecorationSet.empty = empty;
var DecorationGroup = function(members) {
this.members = members;
};
DecorationGroup.prototype.forChild = function(offset, child) {
var this$1 = this;
if (child.isLeaf) {
return DecorationSet.empty;
}
var found = [];
for (var i = 0; i < this.members.length; i++) {
var result = this$1.members[i].forChild(offset, child);
if (result == empty) {
continue;
}
if (result instanceof DecorationGroup) {
found = found.concat(result.members);
} else {
found.push(result);
}
}
return DecorationGroup.from(found);
};
DecorationGroup.prototype.eq = function(other) {
var this$1 = this;
if (!(other instanceof DecorationGroup) || other.members.length != this.members.length) {
return false;
}
for (var i = 0; i < this.members.length; i++) {
if (!this$1.members[i].eq(other.members[i])) {
return false;
}
}
return true;
};
DecorationGroup.prototype.locals = function(node) {
var this$1 = this;
var result,
sorted = true;
for (var i = 0; i < this.members.length; i++) {
var locals = this$1.members[i].localsInner(node);
if (!locals.length) {
continue;
}
if (!result) {
result = locals;
} else {
if (sorted) {
result = result.slice();
sorted = false;
}
for (var j = 0; j < locals.length; j++) {
result.push(locals[j]);
}
}
}
return result ? removeOverlap(sorted ? result : result.sort(byPos)) : none;
};
DecorationGroup.from = function(members) {
switch (members.length) {
case 0:
return empty;
case 1:
return members[0];
default:
return new DecorationGroup(members);
}
};
function mapChildren(oldChildren, newLocal, mapping, node, offset, oldOffset, options) {
var children = oldChildren.slice();
var shift = function(oldStart, oldEnd, newStart, newEnd) {
for (var i = 0; i < children.length; i += 3) {
var end = children[i + 1],
dSize = (void 0);
if (end == -1 || oldStart > end + oldOffset) {
continue;
}
if (oldEnd >= children[i] + oldOffset) {
children[i + 1] = -1;
} else if (dSize = (newEnd - newStart) - (oldEnd - oldStart)) {
children[i] += dSize;
children[i + 1] += dSize;
}
}
};
for (var i = 0; i < mapping.maps.length; i++) {
mapping.maps[i].forEach(shift);
}
var mustRebuild = false;
for (var i$1 = 0; i$1 < children.length; i$1 += 3) {
if (children[i$1 + 1] == -1) {
var from = mapping.map(children[i$1] + oldOffset),
fromLocal = from - offset;
if (fromLocal < 0 || fromLocal >= node.content.size) {
mustRebuild = true;
continue;
}
var to = mapping.map(oldChildren[i$1 + 1] + oldOffset, -1),
toLocal = to - offset;
var ref = node.content.findIndex(fromLocal);
var index = ref.index;
var childOffset = ref.offset;
var childNode = node.maybeChild(index);
if (childNode && childOffset == fromLocal && childOffset + childNode.nodeSize == toLocal) {
var mapped = children[i$1 + 2].mapInner(mapping, childNode, from + 1, children[i$1] + oldOffset + 1, options);
if (mapped != empty) {
children[i$1] = fromLocal;
children[i$1 + 1] = toLocal;
children[i$1 + 2] = mapped;
} else {
children.splice(i$1, 3);
i$1 -= 3;
}
} else {
mustRebuild = true;
}
}
}
if (mustRebuild) {
var decorations = mapAndGatherRemainingDecorations(children, newLocal ? moveSpans(newLocal, offset) : [], mapping, oldOffset, options);
var built = buildTree(decorations, node, 0, options);
newLocal = built.local;
for (var i$2 = 0; i$2 < children.length; i$2 += 3) {
if (children[i$2 + 1] == -1) {
children.splice(i$2, 3);
i$2 -= 3;
}
}
for (var i$3 = 0,
j = 0; i$3 < built.children.length; i$3 += 3) {
var from$1 = built.children[i$3];
while (j < children.length && children[j] < from$1) {
j += 3;
}
children.splice(j, 0, built.children[i$3], built.children[i$3 + 1], built.children[i$3 + 2]);
}
}
return new DecorationSet(newLocal && newLocal.sort(byPos), children);
}
function moveSpans(spans, offset) {
if (!offset || !spans.length) {
return spans;
}
var result = [];
for (var i = 0; i < spans.length; i++) {
var span = spans[i];
result.push(new Decoration(span.from + offset, span.to + offset, span.type));
}
return result;
}
function mapAndGatherRemainingDecorations(children, decorations, mapping, oldOffset, options) {
function gather(set, oldOffset) {
for (var i = 0; i < set.local.length; i++) {
var mapped = set.local[i].map(mapping, 0, oldOffset);
if (mapped) {
decorations.push(mapped);
} else if (options.onRemove) {
options.onRemove(set.local[i].options);
}
}
for (var i$1 = 0; i$1 < set.children.length; i$1 += 3) {
gather(set.children[i$1 + 2], set.children[i$1] + oldOffset + 1);
}
}
for (var i = 0; i < children.length; i += 3) {
if (children[i + 1] == -1) {
gather(children[i + 2], children[i] + oldOffset + 1);
}
}
return decorations;
}
function takeSpansForNode(spans, node, offset) {
if (node.isLeaf) {
return null;
}
var end = offset + node.nodeSize,
found = null;
for (var i = 0,
span = (void 0); i < spans.length; i++) {
if ((span = spans[i]) && span.from > offset && span.to < end) {
;
(found || (found = [])).push(span);
spans[i] = null;
}
}
return found;
}
function withoutNulls(array) {
var result = [];
for (var i = 0; i < array.length; i++) {
if (array[i] != null) {
result.push(array[i]);
}
}
return result;
}
function buildTree(spans, node, offset, options) {
var children = [],
hasNulls = false;
node.forEach(function(childNode, localStart) {
var found = takeSpansForNode(spans, childNode, localStart + offset);
if (found) {
hasNulls = true;
var subtree = buildTree(found, childNode, offset + localStart + 1, options);
if (subtree != empty) {
children.push(localStart, localStart + childNode.nodeSize, subtree);
}
}
});
var locals = moveSpans(hasNulls ? withoutNulls(spans) : spans, -offset).sort(byPos);
for (var i = 0; i < locals.length; i++) {
if (!locals[i].type.valid(node, locals[i])) {
if (options.onRemove) {
options.onRemove(locals[i].options);
}
locals.splice(i--, 1);
}
}
return locals.length || children.length ? new DecorationSet(locals, children) : empty;
}
function byPos(a, b) {
return a.from - b.from || a.to - b.to;
}
function removeOverlap(spans) {
var working = spans;
for (var i = 0; i < working.length - 1; i++) {
var span = working[i];
if (span.from != span.to) {
for (var j = i + 1; j < working.length; j++) {
var next = working[j];
if (next.from == span.from) {
if (next.to != span.to) {
if (working == spans) {
working = spans.slice();
}
working[j] = next.copy(next.from, span.to);
insertAhead(working, j + 1, next.copy(span.to, next.to));
}
continue;
} else {
if (next.from < span.to) {
if (working == spans) {
working = spans.slice();
}
working[i] = span.copy(span.from, next.from);
insertAhead(working, j, span.copy(next.from, span.to));
}
break;
}
}
}
}
return working;
}
exports.removeOverlap = removeOverlap;
function insertAhead(array, i, deco) {
while (i < array.length && byPos(deco, array[i]) > 0) {
i++;
}
array.splice(i, 0, deco);
}
function viewDecorations(view) {
var found = [];
view.someProp("decorations", function(f) {
var result = f(view.state);
if (result && result != empty) {
found.push(result);
}
});
return DecorationGroup.from(found);
}
exports.viewDecorations = viewDecorations;
return module.exports;
});
$__System.registerDynamic("1d", ["13", "14", "1a", "1b", "1c"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var ref = $__require('13');
var scrollRectIntoView = ref.scrollRectIntoView;
var posAtCoords = ref.posAtCoords;
var coordsAtPos = ref.coordsAtPos;
var endOfTextblock = ref.endOfTextblock;
var storeScrollPos = ref.storeScrollPos;
var resetScrollPos = ref.resetScrollPos;
var ref$1 = $__require('14');
var docViewDesc = ref$1.docViewDesc;
var ref$2 = $__require('1a');
var initInput = ref$2.initInput;
var destroyInput = ref$2.destroyInput;
var dispatchEvent = ref$2.dispatchEvent;
var startObserving = ref$2.startObserving;
var stopObserving = ref$2.stopObserving;
var ensureListeners = ref$2.ensureListeners;
var ref$3 = $__require('1b');
var SelectionReader = ref$3.SelectionReader;
var selectionToDOM = ref$3.selectionToDOM;
var ref$4 = $__require('1c');
var viewDecorations = ref$4.viewDecorations;
var Decoration = ref$4.Decoration;
var assign;
((assign = $__require('1c'), exports.Decoration = assign.Decoration, exports.DecorationSet = assign.DecorationSet));
var EditorView = function(place, props) {
this.props = props;
this.state = props.state;
this.dispatch = this.dispatch.bind(this);
this._root = null;
this.focused = false;
this.content = document.createElement("div");
if (place && place.appendChild) {
place.appendChild(this.content);
} else if (place) {
place(this.content);
}
this.editable = getEditable(this);
this.docView = docViewDesc(this.state.doc, computeDocDeco(this), viewDecorations(this), this.content, this);
this.lastSelectedViewDesc = null;
this.selectionReader = new SelectionReader(this);
initInput(this);
this.pluginViews = [];
this.updatePluginViews();
};
var prototypeAccessors = {root: {}};
EditorView.prototype.update = function(props) {
if (props.handleDOMEvents != this.props.handleDOMEvents) {
ensureListeners(this);
}
this.props = props;
this.updateState(props.state);
};
EditorView.prototype.updateState = function(state) {
var prev = this.state;
this.state = state;
if (prev.plugins != state.plugins) {
ensureListeners(this);
}
if (this.inDOMChange) {
return;
}
var prevEditable = this.editable;
this.editable = getEditable(this);
var innerDeco = viewDecorations(this),
outerDeco = computeDocDeco(this);
var scrollToSelection = state.scrollToSelection > prev.scrollToSelection || prev.config != state.config;
var updateDoc = !this.docView.matchesNode(state.doc, outerDeco, innerDeco);
var updateSel = updateDoc || !state.selection.eq(prev.selection) || this.selectionReader.domChanged();
var oldScrollPos = !scrollToSelection && updateSel && storeScrollPos(this);
if (updateSel) {
stopObserving(this);
if (updateDoc) {
this.docView.update(state.doc, outerDeco, innerDeco, this);
}
selectionToDOM(this, state.selection);
startObserving(this);
}
if (prevEditable != this.editable) {
this.selectionReader.editableChanged();
}
this.updatePluginViews(prev);
if (scrollToSelection) {
if (state.selection.node) {
scrollRectIntoView(this, this.docView.domAfterPos(state.selection.from).getBoundingClientRect());
} else {
scrollRectIntoView(this, this.coordsAtPos(state.selection.head));
}
} else if (oldScrollPos) {
resetScrollPos(oldScrollPos);
}
};
EditorView.prototype.destroyPluginViews = function() {
var view;
while (view = this.pluginViews.pop()) {
if (view.destroy) {
view.destroy();
}
}
};
EditorView.prototype.updatePluginViews = function(prevState) {
var this$1 = this;
var plugins = this.state.plugins;
if (!prevState || prevState.plugins != plugins) {
this.destroyPluginViews();
for (var i = 0; i < plugins.length; i++) {
var plugin = plugins[i];
if (plugin.options.view) {
this$1.pluginViews.push(plugin.options.view(this$1));
}
}
} else {
for (var i$1 = 0; i$1 < this.pluginViews.length; i$1++) {
var pluginView = this$1.pluginViews[i$1];
if (pluginView.update) {
pluginView.update(this$1);
}
}
}
};
EditorView.prototype.hasFocus = function() {
if (this.editable && this.content.ownerDocument.activeElement != this.content) {
return false;
}
var sel = this.root.getSelection();
return sel.rangeCount && this.content.contains(sel.anchorNode.nodeType == 3 ? sel.anchorNode.parentNode : sel.anchorNode);
};
EditorView.prototype.someProp = function(propName, f) {
var prop = this.props && this.props[propName],
value;
if (prop != null && (value = f ? f(prop) : prop)) {
return value;
}
var plugins = this.state.plugins;
if (plugins) {
for (var i = 0; i < plugins.length; i++) {
var prop$1 = plugins[i].props[propName];
if (prop$1 != null && (value = f ? f(prop$1) : prop$1)) {
return value;
}
}
}
};
EditorView.prototype.focus = function() {
stopObserving(this);
selectionToDOM(this, this.state.selection, true);
startObserving(this);
if (this.editable) {
this.content.focus();
}
};
prototypeAccessors.root.get = function() {
var this$1 = this;
var cached = this._root;
if (cached == null) {
for (var search = this.content.parentNode; search; search = search.parentNode) {
if (search.nodeType == 9 || (search.nodeType == 11 && search.host)) {
return this$1._root = search;
}
}
}
return cached || document;
};
EditorView.prototype.posAtCoords = function(coords) {
return posAtCoords(this, coords);
};
EditorView.prototype.coordsAtPos = function(pos) {
return coordsAtPos(this, pos);
};
EditorView.prototype.endOfTextblock = function(dir, state) {
return endOfTextblock(this, state || this.state, dir);
};
EditorView.prototype.destroy = function() {
destroyInput(this);
this.destroyPluginViews();
this.docView.destroy();
this.selectionReader.destroy();
if (this.content.parentNode) {
this.content.parentNode.removeChild(this.content);
}
};
EditorView.prototype.dispatchEvent = function(event) {
return dispatchEvent(this, event);
};
EditorView.prototype.dispatch = function(tr) {
var dispatchTransaction = this.props.dispatchTransaction;
if (dispatchTransaction) {
dispatchTransaction(tr);
} else {
this.updateState(this.state.apply(tr));
}
};
Object.defineProperties(EditorView.prototype, prototypeAccessors);
exports.EditorView = EditorView;
function computeDocDeco(view) {
var attrs = Object.create(null);
attrs.class = "ProseMirror" + (view.focused ? " ProseMirror-focused" : "") + (view.state.selection.node ? " ProseMirror-nodeselection" : "");
attrs.contenteditable = String(view.editable);
view.someProp("attributes", function(value) {
if (typeof value == "function") {
value = value(view.state);
}
if (value) {
for (var attr in value) {
if (attr == "class") {
attrs.class += " " + value[attr];
} else if (!attrs[attr] && attr != "contenteditable" && attr != "nodeName") {
attrs[attr] = String(value[attr]);
}
}
}
});
return [Decoration.node(0, view.state.doc.content.size, attrs)];
}
function getEditable(view) {
return !view.someProp("editable", function(value) {
return value(view.state) === false;
});
}
return module.exports;
});
$__System.registerDynamic("11", ["1d"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
module.exports = $__require('1d');
return module.exports;
});
$__System.registerDynamic("1e", [], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
"format cjs";
(function(root, factory) {
if (typeof exports === 'object') {
module.exports = factory();
} else if (typeof define === 'function' && define.amd) {
define(factory);
} else {
root.crel = factory();
}
}(this, function() {
var fn = 'function',
obj = 'object',
nodeType = 'nodeType',
textContent = 'textContent',
setAttribute = 'setAttribute',
attrMapString = 'attrMap',
isNodeString = 'isNode',
isElementString = 'isElement',
d = typeof document === obj ? document : {},
isType = function(a, type) {
return typeof a === type;
},
isNode = typeof Node === fn ? function(object) {
return object instanceof Node;
} : function(object) {
return object && isType(object, obj) && (nodeType in object) && isType(object.ownerDocument, obj);
},
isElement = function(object) {
return crel[isNodeString](object) && object[nodeType] === 1;
},
isArray = function(a) {
return a instanceof Array;
},
appendChild = function(element, child) {
if (!crel[isNodeString](child)) {
child = d.createTextNode(child);
}
element.appendChild(child);
};
function crel() {
var args = arguments,
element = args[0],
child,
settings = args[1],
childIndex = 2,
argumentsLength = args.length,
attributeMap = crel[attrMapString];
element = crel[isElementString](element) ? element : d.createElement(element);
if (argumentsLength === 1) {
return element;
}
if (!isType(settings, obj) || crel[isNodeString](settings) || isArray(settings)) {
--childIndex;
settings = null;
}
if ((argumentsLength - childIndex) === 1 && isType(args[childIndex], 'string') && element[textContent] !== undefined) {
element[textContent] = args[childIndex];
} else {
for (; childIndex < argumentsLength; ++childIndex) {
child = args[childIndex];
if (child == null) {
continue;
}
if (isArray(child)) {
for (var i = 0; i < child.length; ++i) {
appendChild(element, child[i]);
}
} else {
appendChild(element, child);
}
}
}
for (var key in settings) {
if (!attributeMap[key]) {
if (isType(settings[key], fn)) {
element[key] = settings[key];
} else {
element[setAttribute](key, settings[key]);
}
} else {
var attr = attributeMap[key];
if (typeof attr === fn) {
attr(element, settings[key]);
} else {
element[setAttribute](attr, settings[key]);
}
}
}
return element;
}
crel[attrMapString] = {};
crel[isElementString] = isElement;
crel[isNodeString] = isNode;
if (typeof Proxy !== 'undefined') {
crel.proxy = new Proxy(crel, {get: function(target, key) {
!(key in crel) && (crel[key] = crel.bind(null, key));
return crel[key];
}});
}
return crel;
}));
return module.exports;
});
$__System.registerDynamic("1f", ["1e"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
module.exports = $__require('1e');
return module.exports;
});
$__System.registerDynamic("20", [], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var SVG = "http://www.w3.org/2000/svg";
var XLINK = "http://www.w3.org/1999/xlink";
var prefix = "ProseMirror-icon";
function hashPath(path) {
var hash = 0;
for (var i = 0; i < path.length; i++) {
hash = (((hash << 5) - hash) + path.charCodeAt(i)) | 0;
}
return hash;
}
function getIcon(icon) {
var node = document.createElement("div");
node.className = prefix;
if (icon.path) {
var name = "pm-icon-" + hashPath(icon.path).toString(16);
if (!document.getElementById(name)) {
buildSVG(name, icon);
}
var svg = node.appendChild(document.createElementNS(SVG, "svg"));
svg.style.width = (icon.width / icon.height) + "em";
var use = svg.appendChild(document.createElementNS(SVG, "use"));
use.setAttributeNS(XLINK, "href", /([^#]*)/.exec(document.location)[1] + "#" + name);
} else if (icon.dom) {
node.appendChild(icon.dom.cloneNode(true));
} else {
node.appendChild(document.createElement("span")).textContent = icon.text || '';
if (icon.css) {
node.firstChild.style.cssText = icon.css;
}
}
return node;
}
exports.getIcon = getIcon;
function buildSVG(name, data) {
var collection = document.getElementById(prefix + "-collection");
if (!collection) {
collection = document.createElementNS(SVG, "svg");
collection.id = prefix + "-collection";
collection.style.display = "none";
document.body.insertBefore(collection, document.body.firstChild);
}
var sym = document.createElementNS(SVG, "symbol");
sym.id = name;
sym.setAttribute("viewBox", "0 0 " + data.width + " " + data.height);
var path = sym.appendChild(document.createElementNS(SVG, "path"));
path.setAttribute("d", data.path);
collection.appendChild(sym);
}
return module.exports;
});
$__System.registerDynamic("21", ["1f", "22", "23", "20"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var crel = $__require('1f');
var ref = $__require('22');
var lift = ref.lift;
var joinUp = ref.joinUp;
var selectParentNode = ref.selectParentNode;
var wrapIn = ref.wrapIn;
var setBlockType = ref.setBlockType;
var ref$1 = $__require('23');
var undo = ref$1.undo;
var redo = ref$1.redo;
var ref$2 = $__require('20');
var getIcon = ref$2.getIcon;
var prefix = "ProseMirror-menu";
var MenuItem = function MenuItem(spec) {
this.spec = spec;
};
MenuItem.prototype.render = function render(view) {
var disabled = false,
spec = this.spec;
if (spec.select && !spec.select(view.state)) {
if (spec.onDeselected == "disable") {
disabled = true;
} else {
return null;
}
}
var active = spec.active && !disabled && spec.active(view.state);
var dom;
if (spec.render) {
dom = spec.render(view);
} else if (spec.icon) {
dom = getIcon(spec.icon);
if (active) {
dom.classList.add(prefix + "-active");
}
} else if (spec.label) {
dom = crel("div", null, translate(view, spec.label));
} else {
throw new RangeError("MenuItem without render, icon, or label property");
}
if (spec.title) {
dom.setAttribute("title", translate(view, spec.title));
}
if (spec.class) {
dom.classList.add(spec.class);
}
if (disabled) {
dom.classList.add(prefix + "-disabled");
}
if (spec.css) {
dom.style.cssText += spec.css;
}
if (!disabled) {
dom.addEventListener(spec.execEvent || "mousedown", function(e) {
e.preventDefault();
spec.run(view.state, view.dispatch, view);
});
}
return dom;
};
exports.MenuItem = MenuItem;
function translate(view, text) {
return view.props.translate ? view.props.translate(text) : text;
}
var lastMenuEvent = {
time: 0,
node: null
};
function markMenuEvent(e) {
lastMenuEvent.time = Date.now();
lastMenuEvent.node = e.target;
}
function isMenuEvent(wrapper) {
return Date.now() - 100 < lastMenuEvent.time && lastMenuEvent.node && wrapper.contains(lastMenuEvent.node);
}
var Dropdown = function Dropdown(content, options) {
this.options = options || {};
this.content = Array.isArray(content) ? content : [content];
};
Dropdown.prototype.render = function render(view) {
var this$1 = this;
var items = renderDropdownItems(this.content, view);
if (!items.length) {
return null;
}
var label = crel("div", {
class: prefix + "-dropdown " + (this.options.class || ""),
style: this.options.css,
title: this.options.title && translate(view, this.options.title)
}, translate(view, this.options.label));
var wrap = crel("div", {class: prefix + "-dropdown-wrap"}, label);
var open = null,
listeningOnClose = null;
var close = function() {
if (open && open.close()) {
open = null;
window.removeEventListener("mousedown", listeningOnClose);
}
};
label.addEventListener("mousedown", function(e) {
e.preventDefault();
markMenuEvent(e);
if (open) {
close();
} else {
open = this$1.expand(wrap, items);
window.addEventListener("mousedown", listeningOnClose = function() {
if (!isMenuEvent(wrap)) {
close();
}
});
}
});
return wrap;
};
Dropdown.prototype.expand = function expand(dom, items) {
var menuDOM = crel("div", {class: prefix + "-dropdown-menu " + (this.options.class || "")}, items);
var done = false;
function close() {
if (done) {
return;
}
done = true;
dom.removeChild(menuDOM);
return true;
}
dom.appendChild(menuDOM);
return {
close: close,
node: menuDOM
};
};
exports.Dropdown = Dropdown;
function renderDropdownItems(items, view) {
var rendered = [];
for (var i = 0; i < items.length; i++) {
var inner = items[i].render(view);
if (inner) {
rendered.push(crel("div", {class: prefix + "-dropdown-item"}, inner));
}
}
return rendered;
}
var DropdownSubmenu = function DropdownSubmenu(content, options) {
this.options = options || {};
this.content = Array.isArray(content) ? content : [content];
};
DropdownSubmenu.prototype.render = function render(view) {
var items = renderDropdownItems(this.content, view);
if (!items.length) {
return null;
}
var label = crel("div", {class: prefix + "-submenu-label"}, translate(view, this.options.label));
var wrap = crel("div", {class: prefix + "-submenu-wrap"}, label, crel("div", {class: prefix + "-submenu"}, items));
var listeningOnClose = null;
label.addEventListener("mousedown", function(e) {
e.preventDefault();
markMenuEvent(e);
wrap.classList.toggle(prefix + "-submenu-wrap-active");
if (!listeningOnClose) {
window.addEventListener("mousedown", listeningOnClose = function() {
if (!isMenuEvent(wrap)) {
wrap.classList.remove(prefix + "-submenu-wrap-active");
window.removeEventListener("mousedown", listeningOnClose);
listeningOnClose = null;
}
});
}
});
return wrap;
};
exports.DropdownSubmenu = DropdownSubmenu;
function renderGrouped(view, content) {
var result = document.createDocumentFragment(),
needSep = false;
for (var i = 0; i < content.length; i++) {
var items = content[i],
added = false;
for (var j = 0; j < items.length; j++) {
var rendered = items[j].render(view);
if (rendered) {
if (!added && needSep) {
result.appendChild(separator());
}
result.appendChild(crel("span", {class: prefix + "item"}, rendered));
added = true;
}
}
if (added) {
needSep = true;
}
}
return result;
}
exports.renderGrouped = renderGrouped;
function separator() {
return crel("span", {class: prefix + "separator"});
}
var icons = {
join: {
width: 800,
height: 900,
path: "M0 75h800v125h-800z M0 825h800v-125h-800z M250 400h100v-100h100v100h100v100h-100v100h-100v-100h-100z"
},
lift: {
width: 1024,
height: 1024,
path: "M219 310v329q0 7-5 12t-12 5q-8 0-13-5l-164-164q-5-5-5-13t5-13l164-164q5-5 13-5 7 0 12 5t5 12zM1024 749v109q0 7-5 12t-12 5h-987q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h987q7 0 12 5t5 12zM1024 530v109q0 7-5 12t-12 5h-621q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h621q7 0 12 5t5 12zM1024 310v109q0 7-5 12t-12 5h-621q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h621q7 0 12 5t5 12zM1024 91v109q0 7-5 12t-12 5h-987q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h987q7 0 12 5t5 12z"
},
selectParentNode: {
text: "\u2b1a",
css: "font-weight: bold"
},
undo: {
width: 1024,
height: 1024,
path: "M761 1024c113-206 132-520-313-509v253l-384-384 384-384v248c534-13 594 472 313 775z"
},
redo: {
width: 1024,
height: 1024,
path: "M576 248v-248l384 384-384 384v-253c-446-10-427 303-313 509-280-303-221-789 313-775z"
},
strong: {
width: 805,
height: 1024,
path: "M317 869q42 18 80 18 214 0 214-191 0-65-23-102-15-25-35-42t-38-26-46-14-48-6-54-1q-41 0-57 5 0 30-0 90t-0 90q0 4-0 38t-0 55 2 47 6 38zM309 442q24 4 62 4 46 0 81-7t62-25 42-51 14-81q0-40-16-70t-45-46-61-24-70-8q-28 0-74 7 0 28 2 86t2 86q0 15-0 45t-0 45q0 26 0 39zM0 950l1-53q8-2 48-9t60-15q4-6 7-15t4-19 3-18 1-21 0-19v-37q0-561-12-585-2-4-12-8t-25-6-28-4-27-2-17-1l-2-47q56-1 194-6t213-5q13 0 39 0t38 0q40 0 78 7t73 24 61 40 42 59 16 78q0 29-9 54t-22 41-36 32-41 25-48 22q88 20 146 76t58 141q0 57-20 102t-53 74-78 48-93 27-100 8q-25 0-75-1t-75-1q-60 0-175 6t-132 6z"
},
em: {
width: 585,
height: 1024,
path: "M0 949l9-48q3-1 46-12t63-21q16-20 23-57 0-4 35-165t65-310 29-169v-14q-13-7-31-10t-39-4-33-3l10-58q18 1 68 3t85 4 68 1q27 0 56-1t69-4 56-3q-2 22-10 50-17 5-58 16t-62 19q-4 10-8 24t-5 22-4 26-3 24q-15 84-50 239t-44 203q-1 5-7 33t-11 51-9 47-3 32l0 10q9 2 105 17-1 25-9 56-6 0-18 0t-18 0q-16 0-49-5t-49-5q-78-1-117-1-29 0-81 5t-69 6z"
},
code: {
width: 896,
height: 1024,
path: "M608 192l-96 96 224 224-224 224 96 96 288-320-288-320zM288 192l-288 320 288 320 96-96-224-224 224-224-96-96z"
},
link: {
width: 951,
height: 1024,
path: "M832 694q0-22-16-38l-118-118q-16-16-38-16-24 0-41 18 1 1 10 10t12 12 8 10 7 14 2 15q0 22-16 38t-38 16q-8 0-15-2t-14-7-10-8-12-12-10-10q-18 17-18 41 0 22 16 38l117 118q15 15 38 15 22 0 38-14l84-83q16-16 16-38zM430 292q0-22-16-38l-117-118q-16-16-38-16-22 0-38 15l-84 83q-16 16-16 38 0 22 16 38l118 118q15 15 38 15 24 0 41-17-1-1-10-10t-12-12-8-10-7-14-2-15q0-22 16-38t38-16q8 0 15 2t14 7 10 8 12 12 10 10q18-17 18-41zM941 694q0 68-48 116l-84 83q-47 47-116 47-69 0-116-48l-117-118q-47-47-47-116 0-70 50-119l-50-50q-49 50-118 50-68 0-116-48l-118-118q-48-48-48-116t48-116l84-83q47-47 116-47 69 0 116 48l117 118q47 47 47 116 0 70-50 119l50 50q49-50 118-50 68 0 116 48l118 118q48 48 48 116z"
},
bulletList: {
width: 768,
height: 896,
path: "M0 512h128v-128h-128v128zM0 256h128v-128h-128v128zM0 768h128v-128h-128v128zM256 512h512v-128h-512v128zM256 256h512v-128h-512v128zM256 768h512v-128h-512v128z"
},
orderedList: {
width: 768,
height: 896,
path: "M320 512h448v-128h-448v128zM320 768h448v-128h-448v128zM320 128v128h448v-128h-448zM79 384h78v-256h-36l-85 23v50l43-2v185zM189 590c0-36-12-78-96-78-33 0-64 6-83 16l1 66c21-10 42-15 67-15s32 11 32 28c0 26-30 58-110 112v50h192v-67l-91 2c49-30 87-66 87-113l1-1z"
},
blockquote: {
width: 640,
height: 896,
path: "M0 448v256h256v-256h-128c0 0 0-128 128-128v-128c0 0-256 0-256 256zM640 320v-128c0 0-256 0-256 256v256h256v-256h-128c0 0 0-128 128-128z"
}
};
exports.icons = icons;
var joinUpItem = new MenuItem({
title: "Join with above block",
run: joinUp,
select: function(state) {
return joinUp(state);
},
icon: icons.join
});
exports.joinUpItem = joinUpItem;
var liftItem = new MenuItem({
title: "Lift out of enclosing block",
run: lift,
select: function(state) {
return lift(state);
},
icon: icons.lift
});
exports.liftItem = liftItem;
var selectParentNodeItem = new MenuItem({
title: "Select parent node",
run: selectParentNode,
select: function(state) {
return selectParentNode(state);
},
icon: icons.selectParentNode
});
exports.selectParentNodeItem = selectParentNodeItem;
var undoItem = new MenuItem({
title: "Undo last change",
run: undo,
select: function(state) {
return undo(state);
},
icon: icons.undo
});
exports.undoItem = undoItem;
var redoItem = new MenuItem({
title: "Redo last undone change",
run: redo,
select: function(state) {
return redo(state);
},
icon: icons.redo
});
exports.redoItem = redoItem;
function wrapItem(nodeType, options) {
var passedOptions = {
run: function run(state, dispatch) {
return wrapIn(nodeType, options.attrs)(state, dispatch);
},
select: function select(state) {
return wrapIn(nodeType, options.attrs instanceof Function ? null : options.attrs)(state);
}
};
for (var prop in options) {
passedOptions[prop] = options[prop];
}
return new MenuItem(passedOptions);
}
exports.wrapItem = wrapItem;
function blockTypeItem(nodeType, options) {
var command = setBlockType(nodeType, options.attrs);
var passedOptions = {
run: command,
select: function select(state) {
return command(state);
},
active: function active(state) {
var ref = state.selection;
var $from = ref.$from;
var to = ref.to;
var node = ref.node;
if (node) {
return node.hasMarkup(nodeType, options.attrs);
}
return to <= $from.end() && $from.parent.hasMarkup(nodeType, options.attrs);
}
};
for (var prop in options) {
passedOptions[prop] = options[prop];
}
return new MenuItem(passedOptions);
}
exports.blockTypeItem = blockTypeItem;
return module.exports;
});
$__System.registerDynamic("24", ["1f", "11", "21"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var crel = $__require('1f');
var ref = $__require('11');
var EditorView = ref.EditorView;
var ref$1 = $__require('21');
var renderGrouped = ref$1.renderGrouped;
var prefix = "ProseMirror-menubar";
var MenuBarEditorView = function MenuBarEditorView(place, props) {
var this$1 = this;
this.wrapper = crel("div", {class: prefix + "-wrapper"});
if (place && place.appendChild) {
place.appendChild(this.wrapper);
} else if (place) {
place(this.wrapper);
}
if (!props.dispatchTransaction) {
props.dispatchTransaction = function(tr) {
return this$1.updateState(this$1.editor.state.apply(tr));
};
}
this.editor = new EditorView(this.wrapper, props);
this.menu = crel("div", {class: prefix});
this.menu.className = prefix;
this.spacer = null;
this.wrapper.insertBefore(this.menu, this.wrapper.firstChild);
this.maxHeight = 0;
this.widthForMaxHeight = 0;
this.floating = false;
this.props = props;
this.updateMenu();
if (this.editor.someProp("floatingMenu")) {
this.updateFloat();
this.scrollFunc = function() {
var root = this$1.editor.root;
if (!(root.body || root).contains(this$1.wrapper)) {
window.removeEventListener("scroll", this$1.scrollFunc);
} else {
this$1.updateFloat();
}
};
window.addEventListener("scroll", this.scrollFunc);
}
};
MenuBarEditorView.prototype.update = function update(props) {
this.props = props;
this.editor.update(props);
this.updateMenu();
};
MenuBarEditorView.prototype.updateState = function updateState(state) {
this.editor.updateState(state);
this.updateMenu();
};
MenuBarEditorView.prototype.updateMenu = function updateMenu() {
this.menu.textContent = "";
this.menu.appendChild(renderGrouped(this.editor, this.editor.someProp("menuContent")));
if (this.floating) {
this.updateScrollCursor();
} else {
if (this.menu.offsetWidth != this.widthForMaxHeight) {
this.widthForMaxHeight = this.menu.offsetWidth;
this.maxHeight = 0;
}
if (this.menu.offsetHeight > this.maxHeight) {
this.maxHeight = this.menu.offsetHeight;
this.menu.style.minHeight = this.maxHeight + "px";
}
}
};
MenuBarEditorView.prototype.updateScrollCursor = function updateScrollCursor() {
var selection = this.editor.root.getSelection();
if (!selection.focusNode) {
return;
}
var rects = selection.getRangeAt(0).getClientRects();
var selRect = rects[selectionIsInverted(selection) ? 0 : rects.length - 1];
if (!selRect) {
return;
}
var menuRect = this.menu.getBoundingClientRect();
if (selRect.top < menuRect.bottom && selRect.bottom > menuRect.top) {
var scrollable = findWrappingScrollable(this.wrapper);
if (scrollable) {
scrollable.scrollTop -= (menuRect.bottom - selRect.top);
}
}
};
MenuBarEditorView.prototype.updateFloat = function updateFloat() {
var parent = this.wrapper,
editorRect = parent.getBoundingClientRect();
if (this.floating) {
if (editorRect.top >= 0 || editorRect.bottom < this.menu.offsetHeight + 10) {
this.floating = false;
this.menu.style.position = this.menu.style.left = this.menu.style.width = "";
this.menu.style.display = "";
this.spacer.parentNode.removeChild(this.spacer);
this.spacer = null;
} else {
var border = (parent.offsetWidth - parent.clientWidth) / 2;
this.menu.style.left = (editorRect.left + border) + "px";
this.menu.style.display = (editorRect.top > window.innerHeight ? "none" : "");
}
} else {
if (editorRect.top < 0 && editorRect.bottom >= this.menu.offsetHeight + 10) {
this.floating = true;
var menuRect = this.menu.getBoundingClientRect();
this.menu.style.left = menuRect.left + "px";
this.menu.style.width = menuRect.width + "px";
this.menu.style.position = "fixed";
this.spacer = crel("div", {
class: prefix + "-spacer",
style: ("height: " + (menuRect.height) + "px")
});
parent.insertBefore(this.spacer, this.menu);
}
}
};
MenuBarEditorView.prototype.destroy = function destroy() {
this.editor.destroy();
};
exports.MenuBarEditorView = MenuBarEditorView;
function selectionIsInverted(selection) {
if (selection.anchorNode == selection.focusNode) {
return selection.anchorOffset > selection.focusOffset;
}
return selection.anchorNode.compareDocumentPosition(selection.focusNode) == Node.DOCUMENT_POSITION_FOLLOWING;
}
function findWrappingScrollable(node) {
for (var cur = node.parentNode; cur; cur = cur.parentNode) {
if (cur.scrollHeight > cur.clientHeight) {
return cur;
}
}
}
return module.exports;
});
$__System.registerDynamic("25", ["21", "24"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
;
var assign;
((assign = $__require('21'), exports.MenuItem = assign.MenuItem, exports.Dropdown = assign.Dropdown, exports.DropdownSubmenu = assign.DropdownSubmenu, exports.renderGrouped = assign.renderGrouped, exports.icons = assign.icons, exports.joinUpItem = assign.joinUpItem, exports.liftItem = assign.liftItem, exports.selectParentNodeItem = assign.selectParentNodeItem, exports.undoItem = assign.undoItem, exports.redoItem = assign.redoItem, exports.wrapItem = assign.wrapItem, exports.blockTypeItem = assign.blockTypeItem));
exports.MenuBarEditorView = $__require('24').MenuBarEditorView;
return module.exports;
});
$__System.registerDynamic("26", ["25"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
module.exports = $__require('25');
return module.exports;
});
$__System.registerDynamic("27", [], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var prefix = "ProseMirror-prompt";
function openPrompt(options) {
var wrapper = document.body.appendChild(document.createElement("div"));
wrapper.className = prefix;
var mouseOutside = function(e) {
if (!wrapper.contains(e.target)) {
close();
}
};
setTimeout(function() {
return window.addEventListener("mousedown", mouseOutside);
}, 50);
var close = function() {
window.removeEventListener("mousedown", mouseOutside);
if (wrapper.parentNode) {
wrapper.parentNode.removeChild(wrapper);
}
};
var domFields = [];
for (var name in options.fields) {
domFields.push(options.fields[name].render());
}
var submitButton = document.createElement("button");
submitButton.type = "submit";
submitButton.className = prefix + "-submit";
submitButton.textContent = "OK";
var cancelButton = document.createElement("button");
cancelButton.type = "button";
cancelButton.className = prefix + "-cancel";
cancelButton.textContent = "Cancel";
cancelButton.addEventListener("click", close);
var form = wrapper.appendChild(document.createElement("form"));
if (options.title) {
form.appendChild(document.createElement("h5")).textContent = options.title;
}
domFields.forEach(function(field) {
form.appendChild(document.createElement("div")).appendChild(field);
});
var buttons = form.appendChild(document.createElement("div"));
buttons.className = prefix + "-buttons";
buttons.appendChild(submitButton);
buttons.appendChild(document.createTextNode(" "));
buttons.appendChild(cancelButton);
var box = wrapper.getBoundingClientRect();
wrapper.style.top = ((window.innerHeight - box.height) / 2) + "px";
wrapper.style.left = ((window.innerWidth - box.width) / 2) + "px";
var submit = function() {
var params = getValues(options.fields, domFields);
if (params) {
close();
options.callback(params);
}
};
form.addEventListener("submit", function(e) {
e.preventDefault();
submit();
});
form.addEventListener("keydown", function(e) {
if (e.keyCode == 27) {
e.preventDefault();
close();
} else if (e.keyCode == 13 && !(e.ctrlKey || e.metaKey || e.shiftKey)) {
e.preventDefault();
submit();
} else if (e.keyCode == 9) {
window.setTimeout(function() {
if (!wrapper.contains(document.activeElement)) {
close();
}
}, 500);
}
});
var input = form.elements[0];
if (input) {
input.focus();
}
}
exports.openPrompt = openPrompt;
function getValues(fields, domFields) {
var result = Object.create(null),
i = 0;
for (var name in fields) {
var field = fields[name],
dom = domFields[i++];
var value = field.read(dom),
bad = field.validate(value);
if (bad) {
reportInvalid(dom, bad);
return null;
}
result[name] = field.clean(value);
}
return result;
}
function reportInvalid(dom, message) {
var parent = dom.parentNode;
var msg = parent.appendChild(document.createElement("div"));
msg.style.left = (dom.offsetLeft + dom.offsetWidth + 2) + "px";
msg.style.top = (dom.offsetTop - 5) + "px";
msg.className = "ProseMirror-invalid";
msg.textContent = message;
setTimeout(function() {
return parent.removeChild(msg);
}, 1500);
}
var Field = function Field(options) {
this.options = options;
};
Field.prototype.read = function read(dom) {
return dom.value;
};
Field.prototype.validateType = function validateType(_value) {};
Field.prototype.validate = function validate(value) {
if (!value && this.options.required) {
return "Required field";
}
return this.validateType(value) || (this.options.validate && this.options.validate(value));
};
Field.prototype.clean = function clean(value) {
return this.options.clean ? this.options.clean(value) : value;
};
exports.Field = Field;
var TextField = (function(Field) {
function TextField() {
Field.apply(this, arguments);
}
if (Field)
TextField.__proto__ = Field;
TextField.prototype = Object.create(Field && Field.prototype);
TextField.prototype.constructor = TextField;
TextField.prototype.render = function render() {
var input = document.createElement("input");
input.type = "text";
input.placeholder = this.options.label;
input.value = this.options.value || "";
input.autocomplete = "off";
return input;
};
return TextField;
}(Field));
exports.TextField = TextField;
var SelectField = (function(Field) {
function SelectField() {
Field.apply(this, arguments);
}
if (Field)
SelectField.__proto__ = Field;
SelectField.prototype = Object.create(Field && Field.prototype);
SelectField.prototype.constructor = SelectField;
SelectField.prototype.render = function render() {
var this$1 = this;
var select = document.createElement("select");
this.options.options.forEach(function(o) {
var opt = select.appendChild(document.createElement("option"));
opt.value = o.value;
opt.selected = o.value == this$1.options.value;
opt.label = o.label;
});
return select;
};
return SelectField;
}(Field));
exports.SelectField = SelectField;
return module.exports;
});
$__System.registerDynamic("28", ["26", "29", "7", "22", "2a", "27"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var ref = $__require('26');
var wrapItem = ref.wrapItem;
var blockTypeItem = ref.blockTypeItem;
var Dropdown = ref.Dropdown;
var DropdownSubmenu = ref.DropdownSubmenu;
var joinUpItem = ref.joinUpItem;
var liftItem = ref.liftItem;
var selectParentNodeItem = ref.selectParentNodeItem;
var undoItem = ref.undoItem;
var redoItem = ref.redoItem;
var icons = ref.icons;
var MenuItem = ref.MenuItem;
var ref$1 = $__require('29');
var createTable = ref$1.createTable;
var addColumnBefore = ref$1.addColumnBefore;
var addColumnAfter = ref$1.addColumnAfter;
var removeColumn = ref$1.removeColumn;
var addRowBefore = ref$1.addRowBefore;
var addRowAfter = ref$1.addRowAfter;
var removeRow = ref$1.removeRow;
var ref$2 = $__require('7');
var Selection = ref$2.Selection;
var ref$3 = $__require('22');
var toggleMark = ref$3.toggleMark;
var ref$4 = $__require('2a');
var wrapInList = ref$4.wrapInList;
var ref$5 = $__require('27');
var TextField = ref$5.TextField;
var openPrompt = ref$5.openPrompt;
function canInsert(state, nodeType, attrs) {
var $from = state.selection.$from;
for (var d = $from.depth; d >= 0; d--) {
var index = $from.index(d);
if ($from.node(d).canReplaceWith(index, index, nodeType, attrs)) {
return true;
}
}
return false;
}
function insertImageItem(nodeType) {
return new MenuItem({
title: "Insert image",
label: "Image",
select: function select(state) {
return canInsert(state, nodeType);
},
run: function run(state, _, view) {
var ref = state.selection;
var node = ref.node;
var from = ref.from;
var to = ref.to;
var attrs = nodeType && node && node.type == nodeType && node.attrs;
openPrompt({
title: "Insert image",
fields: {
src: new TextField({
label: "Location",
required: true,
value: attrs && attrs.src
}),
title: new TextField({
label: "Title",
value: attrs && attrs.title
}),
alt: new TextField({
label: "Description",
value: attrs ? attrs.title : state.doc.textBetween(from, to, " ")
})
},
callback: function callback(attrs) {
view.dispatch(view.state.tr.replaceSelectionWith(nodeType.createAndFill(attrs)));
view.focus();
}
});
}
});
}
function positiveInteger(value) {
if (!/^[1-9]\d*$/.test(value)) {
return "Should be a positive integer";
}
}
function insertTableItem(tableType) {
return new MenuItem({
title: "Insert a table",
run: function run(_, _a, view) {
openPrompt({
title: "Insert table",
fields: {
rows: new TextField({
label: "Rows",
validate: positiveInteger
}),
cols: new TextField({
label: "Columns",
validate: positiveInteger
})
},
callback: function callback(ref) {
var rows = ref.rows;
var cols = ref.cols;
var tr = view.state.tr.replaceSelectionWith(createTable(tableType, +rows, +cols));
tr.setSelection(Selection.near(tr.doc.resolve(view.state.selection.from)));
view.dispatch(tr.scrollIntoView());
view.focus();
}
});
},
select: function select(state) {
var $from = state.selection.$from;
for (var d = $from.depth; d >= 0; d--) {
var index = $from.index(d);
if ($from.node(d).canReplaceWith(index, index, tableType)) {
return true;
}
}
return false;
},
label: "Table"
});
}
function cmdItem(cmd, options) {
var passedOptions = {
label: options.title,
run: cmd,
select: function select(state) {
return cmd(state);
}
};
for (var prop in options) {
passedOptions[prop] = options[prop];
}
return new MenuItem(passedOptions);
}
function markActive(state, type) {
var ref = state.selection;
var from = ref.from;
var $from = ref.$from;
var to = ref.to;
var empty = ref.empty;
if (empty) {
return type.isInSet(state.storedMarks || $from.marks());
} else {
return state.doc.rangeHasMark(from, to, type);
}
}
function markItem(markType, options) {
var passedOptions = {active: function active(state) {
return markActive(state, markType);
}};
for (var prop in options) {
passedOptions[prop] = options[prop];
}
return cmdItem(toggleMark(markType), passedOptions);
}
function linkItem(markType) {
return markItem(markType, {
title: "Add or remove link",
icon: icons.link,
run: function run(state, dispatch, view) {
if (markActive(state, markType)) {
toggleMark(markType)(state, dispatch);
return true;
}
openPrompt({
title: "Create a link",
fields: {
href: new TextField({
label: "Link target",
required: true,
clean: function(val) {
if (!/^https?:\/\//i.test(val)) {
val = 'http://' + val;
}
return val;
}
}),
title: new TextField({label: "Title"})
},
callback: function callback(attrs) {
toggleMark(markType, attrs)(view.state, view.dispatch);
view.focus();
}
});
}
});
}
function wrapListItem(nodeType, options) {
return cmdItem(wrapInList(nodeType, options.attrs), options);
}
function buildMenuItems(schema) {
var r = {},
type;
if (type = schema.marks.strong) {
r.toggleStrong = markItem(type, {
title: "Toggle strong style",
icon: icons.strong
});
}
if (type = schema.marks.em) {
r.toggleEm = markItem(type, {
title: "Toggle emphasis",
icon: icons.em
});
}
if (type = schema.marks.code) {
r.toggleCode = markItem(type, {
title: "Toggle code font",
icon: icons.code
});
}
if (type = schema.marks.link) {
r.toggleLink = linkItem(type);
}
if (type = schema.nodes.image) {
r.insertImage = insertImageItem(type);
}
if (type = schema.nodes.bullet_list) {
r.wrapBulletList = wrapListItem(type, {
title: "Wrap in bullet list",
icon: icons.bulletList
});
}
if (type = schema.nodes.ordered_list) {
r.wrapOrderedList = wrapListItem(type, {
title: "Wrap in ordered list",
icon: icons.orderedList
});
}
if (type = schema.nodes.blockquote) {
r.wrapBlockQuote = wrapItem(type, {
title: "Wrap in block quote",
icon: icons.blockquote
});
}
if (type = schema.nodes.paragraph) {
r.makeParagraph = blockTypeItem(type, {
title: "Change to paragraph",
label: "Plain"
});
}
if (type = schema.nodes.code_block) {
r.makeCodeBlock = blockTypeItem(type, {
title: "Change to code block",
label: "Code"
});
}
if (type = schema.nodes.heading) {
for (var i = 1; i <= 10; i++) {
r["makeHead" + i] = blockTypeItem(type, {
title: "Change to heading " + i,
label: "Level " + i,
attrs: {level: i}
});
}
}
if (type = schema.nodes.horizontal_rule) {
var hr = type;
r.insertHorizontalRule = new MenuItem({
title: "Insert horizontal rule",
label: "Horizontal rule",
select: function select(state) {
return canInsert(state, hr);
},
run: function run(state, dispatch) {
dispatch(state.tr.replaceSelectionWith(hr.create()));
}
});
}
if (type = schema.nodes.table) {
r.insertTable = insertTableItem(type);
}
if (type = schema.nodes.table_row) {
r.addRowBefore = cmdItem(addRowBefore, {title: "Add row before"});
r.addRowAfter = cmdItem(addRowAfter, {title: "Add row after"});
r.removeRow = cmdItem(removeRow, {title: "Remove row"});
r.addColumnBefore = cmdItem(addColumnBefore, {title: "Add column before"});
r.addColumnAfter = cmdItem(addColumnAfter, {title: "Add column after"});
r.removeColumn = cmdItem(removeColumn, {title: "Remove column"});
}
var cut = function(arr) {
return arr.filter(function(x) {
return x;
});
};
r.insertMenu = new Dropdown(cut([r.insertImage, r.insertHorizontalRule, r.insertTable]), {label: "Insert"});
r.typeMenu = new Dropdown(cut([r.makeParagraph, r.makeCodeBlock, r.makeHead1 && new DropdownSubmenu(cut([r.makeHead1, r.makeHead2, r.makeHead3, r.makeHead4, r.makeHead5, r.makeHead6]), {label: "Heading"})]), {label: "Type..."});
var tableItems = cut([r.addRowBefore, r.addRowAfter, r.removeRow, r.addColumnBefore, r.addColumnAfter, r.removeColumn]);
if (tableItems.length) {
r.tableMenu = new Dropdown(tableItems, {label: "Table"});
}
r.inlineMenu = [cut([r.toggleStrong, r.toggleEm, r.toggleCode, r.toggleLink]), [r.insertMenu]];
r.blockMenu = [cut([r.typeMenu, r.tableMenu, r.wrapBulletList, r.wrapOrderedList, r.wrapBlockQuote, joinUpItem, liftItem, selectParentNodeItem])];
r.fullMenu = r.inlineMenu.concat(r.blockMenu).concat([[undoItem, redoItem]]);
return r;
}
exports.buildMenuItems = buildMenuItems;
return module.exports;
});
$__System.registerDynamic("2b", ["9", "3", "7"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var ref = $__require('9');
var joinPoint = ref.joinPoint;
var canJoin = ref.canJoin;
var findWrapping = ref.findWrapping;
var liftTarget = ref.liftTarget;
var canSplit = ref.canSplit;
var ReplaceAroundStep = ref.ReplaceAroundStep;
var ref$1 = $__require('3');
var Slice = ref$1.Slice;
var Fragment = ref$1.Fragment;
var ref$2 = $__require('7');
var Selection = ref$2.Selection;
var TextSelection = ref$2.TextSelection;
var NodeSelection = ref$2.NodeSelection;
function deleteSelection(state, dispatch) {
if (state.selection.empty) {
return false;
}
if (dispatch) {
var ref = state.selection;
var $from = ref.$from;
var $to = ref.$to;
var tr = state.tr.deleteSelection().scrollIntoView();
if ($from.sameParent($to) && $from.parent.isTextblock) {
tr.setStoredMarks($from.marks(true));
}
dispatch(tr);
}
return true;
}
exports.deleteSelection = deleteSelection;
function joinBackward(state, dispatch, view) {
var ref = state.selection;
var $head = ref.$head;
var empty = ref.empty;
if (!empty || (view ? !view.endOfTextblock("backward", state) : $head.parentOffset > 0)) {
return false;
}
var before,
cut;
for (var i = $head.depth - 1; !before && i >= 0; i--) {
if ($head.index(i) > 0) {
cut = $head.before(i + 1);
before = $head.node(i).child($head.index(i) - 1);
}
}
if (!before) {
var range = $head.blockRange(),
target = range && liftTarget(range);
if (target == null) {
return false;
}
if (dispatch) {
dispatch(state.tr.lift(range, target).scrollIntoView());
}
return true;
}
if (before.isLeaf && NodeSelection.isSelectable(before) && $head.parent.content.size == 0) {
if (dispatch) {
var tr = state.tr.delete(cut, cut + $head.parent.nodeSize);
tr.setSelection(NodeSelection.create(tr.doc, cut - before.nodeSize));
dispatch(tr.scrollIntoView());
}
return true;
}
if (before.isLeaf) {
if (dispatch) {
dispatch(state.tr.delete(cut - before.nodeSize, cut).scrollIntoView());
}
return true;
}
return deleteBarrier(state, cut, dispatch) || selectNextNode(state, cut, -1, dispatch);
}
exports.joinBackward = joinBackward;
function joinForward(state, dispatch, view) {
var ref = state.selection;
var $head = ref.$head;
var empty = ref.empty;
if (!empty || (view ? !view.endOfTextblock("forward", state) : $head.parentOffset < $head.parent.content.size)) {
return false;
}
var after,
cut;
for (var i = $head.depth - 1; !after && i >= 0; i--) {
var parent = $head.node(i);
if ($head.index(i) + 1 < parent.childCount) {
after = parent.child($head.index(i) + 1);
cut = $head.after(i + 1);
}
}
if (!after) {
return false;
}
if (after.isLeaf) {
if (dispatch) {
dispatch(state.tr.delete(cut, cut + after.nodeSize).scrollIntoView());
}
return true;
}
return deleteBarrier(state, cut, dispatch) || selectNextNode(state, cut, 1, dispatch);
}
exports.joinForward = joinForward;
function joinUp(state, dispatch) {
var ref = state.selection;
var node = ref.node;
var from = ref.from;
var point;
if (node) {
if (node.isTextblock || !canJoin(state.doc, from)) {
return false;
}
point = from;
} else {
point = joinPoint(state.doc, from, -1);
if (point == null) {
return false;
}
}
if (dispatch) {
var tr = state.tr.join(point);
if (state.selection.node) {
tr.setSelection(NodeSelection.create(tr.doc, point - state.doc.resolve(point).nodeBefore.nodeSize));
}
dispatch(tr.scrollIntoView());
}
return true;
}
exports.joinUp = joinUp;
function joinDown(state, dispatch) {
var node = state.selection.node,
nodeAt = state.selection.from;
var point = joinPointBelow(state);
if (!point) {
return false;
}
if (dispatch) {
var tr = state.tr.join(point);
if (node) {
tr.setSelection(NodeSelection.create(tr.doc, nodeAt));
}
dispatch(tr.scrollIntoView());
}
return true;
}
exports.joinDown = joinDown;
function lift(state, dispatch) {
var ref = state.selection;
var $from = ref.$from;
var $to = ref.$to;
var range = $from.blockRange($to),
target = range && liftTarget(range);
if (target == null) {
return false;
}
if (dispatch) {
dispatch(state.tr.lift(range, target).scrollIntoView());
}
return true;
}
exports.lift = lift;
function newlineInCode(state, dispatch) {
var ref = state.selection;
var $head = ref.$head;
var anchor = ref.anchor;
if (!$head || !$head.parent.type.spec.code || $head.sharedDepth(anchor) != $head.depth) {
return false;
}
if (dispatch) {
dispatch(state.tr.insertText("\n").scrollIntoView());
}
return true;
}
exports.newlineInCode = newlineInCode;
function exitCode(state, dispatch) {
var ref = state.selection;
var $head = ref.$head;
var anchor = ref.anchor;
if (!$head || !$head.parent.type.spec.code || $head.sharedDepth(anchor) != $head.depth) {
return false;
}
var above = $head.node(-1),
after = $head.indexAfter(-1),
type = above.defaultContentType(after);
if (!above.canReplaceWith(after, after, type)) {
return false;
}
if (dispatch) {
var pos = $head.after(),
tr = state.tr.replaceWith(pos, pos, type.createAndFill());
tr.setSelection(Selection.near(tr.doc.resolve(pos), 1));
dispatch(tr.scrollIntoView());
}
return true;
}
exports.exitCode = exitCode;
function createParagraphNear(state, dispatch) {
var ref = state.selection;
var $from = ref.$from;
var $to = ref.$to;
var node = ref.node;
if (!node || !node.isBlock) {
return false;
}
var type = $from.parent.defaultContentType($to.indexAfter());
if (!type || !type.isTextblock) {
return false;
}
if (dispatch) {
var side = ($from.parentOffset ? $to : $from).pos;
var tr = state.tr.insert(side, type.createAndFill());
tr.setSelection(TextSelection.create(tr.doc, side + 1));
dispatch(tr.scrollIntoView());
}
return true;
}
exports.createParagraphNear = createParagraphNear;
function liftEmptyBlock(state, dispatch) {
var ref = state.selection;
var $head = ref.$head;
var empty = ref.empty;
if (!empty || $head.parent.content.size) {
return false;
}
if ($head.depth > 1 && $head.after() != $head.end(-1)) {
var before = $head.before();
if (canSplit(state.doc, before)) {
if (dispatch) {
dispatch(state.tr.split(before).scrollIntoView());
}
return true;
}
}
var range = $head.blockRange(),
target = range && liftTarget(range);
if (target == null) {
return false;
}
if (dispatch) {
dispatch(state.tr.lift(range, target).scrollIntoView());
}
return true;
}
exports.liftEmptyBlock = liftEmptyBlock;
function splitBlock(state, dispatch) {
var ref = state.selection;
var $from = ref.$from;
var $to = ref.$to;
var node = ref.node;
if (node && node.isBlock) {
if (!$from.parentOffset || !canSplit(state.doc, $from.pos)) {
return false;
}
if (dispatch) {
dispatch(state.tr.split($from.pos).scrollIntoView());
}
return true;
}
if (dispatch) {
var atEnd = $to.parentOffset == $to.parent.content.size;
var tr = state.tr.delete($from.pos, $to.pos);
var deflt = $from.depth == 0 ? null : $from.node(-1).defaultContentType($from.indexAfter(-1));
var types = atEnd ? [{type: deflt}] : null;
var can = canSplit(tr.doc, $from.pos, 1, types);
if (!types && !can && canSplit(tr.doc, $from.pos, 1, [{type: deflt}])) {
types = [{type: deflt}];
can = true;
}
if (can) {
tr.split($from.pos, 1, types);
if (!atEnd && !$from.parentOffset && $from.parent.type != deflt && $from.node(-1).canReplace($from.index(-1), $from.indexAfter(-1), Fragment.from(deflt.create(), $from.parent))) {
tr.setNodeType($from.before(), deflt);
}
}
dispatch(tr.scrollIntoView());
}
return true;
}
exports.splitBlock = splitBlock;
function selectParentNode(state, dispatch) {
var sel = state.selection,
pos;
if (sel.node) {
if (!sel.$from.depth) {
return false;
}
pos = sel.$from.before();
} else {
var same = sel.$head.sharedDepth(sel.anchor);
if (same == 0) {
return false;
}
pos = sel.$head.before(same);
}
if (dispatch) {
dispatch(state.tr.setSelection(NodeSelection.create(state.doc, pos)));
}
return true;
}
exports.selectParentNode = selectParentNode;
function joinMaybeClear(state, $pos, dispatch) {
var before = $pos.nodeBefore,
after = $pos.nodeAfter,
index = $pos.index();
if (!before || !after || !before.type.compatibleContent(after.type)) {
return false;
}
if (!before.content.size && $pos.parent.canReplace(index - 1, index)) {
if (dispatch) {
dispatch(state.tr.delete($pos.pos - before.nodeSize, $pos.pos).scrollIntoView());
}
return true;
}
if (!$pos.parent.canReplace(index, index + 1)) {
return false;
}
if (dispatch) {
dispatch(state.tr.clearNonMatching($pos.pos, before.contentMatchAt(before.childCount)).join($pos.pos).scrollIntoView());
}
return true;
}
function deleteBarrier(state, cut, dispatch) {
var $cut = state.doc.resolve(cut),
before = $cut.nodeBefore,
after = $cut.nodeAfter,
conn,
match;
if (joinMaybeClear(state, $cut, dispatch)) {
return true;
} else if (after.isTextblock && $cut.parent.canReplace($cut.index(), $cut.index() + 1) && (conn = (match = before.contentMatchAt(before.childCount)).findWrappingFor(after)) && match.matchType((conn[0] || after).type, (conn[0] || after).attrs).validEnd()) {
if (dispatch) {
var end = cut + after.nodeSize,
wrap = Fragment.empty;
for (var i = conn.length - 1; i >= 0; i--) {
wrap = Fragment.from(conn[i].type.create(conn[i].attrs, wrap));
}
wrap = Fragment.from(before.copy(wrap));
var tr = state.tr.step(new ReplaceAroundStep(cut - 1, end, cut, end, new Slice(wrap, 1, 0), conn.length, true));
var joinAt = end + 2 * conn.length;
if (canJoin(tr.doc, joinAt)) {
tr.join(joinAt);
}
dispatch(tr.scrollIntoView());
}
return true;
} else {
var selAfter = Selection.findFrom($cut, 1);
var range = selAfter.$from.blockRange(selAfter.$to),
target = range && liftTarget(range);
if (target == null) {
return false;
}
if (dispatch) {
dispatch(state.tr.lift(range, target).scrollIntoView());
}
return true;
}
}
function selectNextNode(state, cut, dir, dispatch) {
var $cut = state.doc.resolve(cut);
var node = dir > 0 ? $cut.nodeAfter : $cut.nodeBefore;
if (!node || !NodeSelection.isSelectable(node)) {
return false;
}
if (dispatch) {
dispatch(state.tr.setSelection(NodeSelection.create(state.doc, cut - (dir > 0 ? 0 : node.nodeSize))).scrollIntoView());
}
return true;
}
function joinPointBelow(state) {
var ref = state.selection;
var node = ref.node;
var to = ref.to;
if (node) {
return canJoin(state.doc, to) ? to : null;
} else {
return joinPoint(state.doc, to, 1);
}
}
function wrapIn(nodeType, attrs) {
return function(state, dispatch) {
var ref = state.selection;
var $from = ref.$from;
var $to = ref.$to;
var range = $from.blockRange($to),
wrapping = range && findWrapping(range, nodeType, attrs);
if (!wrapping) {
return false;
}
if (dispatch) {
dispatch(state.tr.wrap(range, wrapping).scrollIntoView());
}
return true;
};
}
exports.wrapIn = wrapIn;
function setBlockType(nodeType, attrs) {
return function(state, dispatch) {
var ref = state.selection;
var $from = ref.$from;
var $to = ref.$to;
var node = ref.node;
var depth;
if (node) {
depth = $from.depth;
} else {
if (!$from.depth || $to.pos > $from.end()) {
return false;
}
depth = $from.depth - 1;
}
var target = node || $from.parent;
if (!target.isTextblock || target.hasMarkup(nodeType, attrs)) {
return false;
}
var index = $from.index(depth);
if (!$from.node(depth).canReplaceWith(index, index + 1, nodeType)) {
return false;
}
if (dispatch) {
var where = $from.before(depth + 1);
dispatch(state.tr.clearNonMatching(where, nodeType.contentExpr.start(attrs)).setNodeType(where, nodeType, attrs).scrollIntoView());
}
return true;
};
}
exports.setBlockType = setBlockType;
function markApplies(doc, from, to, type) {
var can = doc.contentMatchAt(0).allowsMark(type);
doc.nodesBetween(from, to, function(node) {
if (can) {
return false;
}
can = node.isTextblock && node.contentMatchAt(0).allowsMark(type);
});
return can;
}
function toggleMark(markType, attrs) {
return function(state, dispatch) {
var ref = state.selection;
var empty = ref.empty;
var from = ref.from;
var to = ref.to;
var $from = ref.$from;
if (!markApplies(state.doc, from, to, markType)) {
return false;
}
if (dispatch) {
if (empty) {
if (markType.isInSet(state.storedMarks || $from.marks())) {
dispatch(state.tr.removeStoredMark(markType));
} else {
dispatch(state.tr.addStoredMark(markType.create(attrs)));
}
} else {
if (state.doc.rangeHasMark(from, to, markType)) {
dispatch(state.tr.removeMark(from, to, markType).scrollIntoView());
} else {
dispatch(state.tr.addMark(from, to, markType.create(attrs)).scrollIntoView());
}
}
}
return true;
};
}
exports.toggleMark = toggleMark;
function wrapDispatchForJoin(dispatch, isJoinable) {
return function(tr) {
if (!tr.isGeneric) {
return dispatch(tr);
}
var ranges = [];
for (var i = 0; i < tr.mapping.maps.length; i++) {
var map = tr.mapping.maps[i];
for (var j = 0; j < ranges.length; j++) {
ranges[j] = map.map(ranges[j]);
}
map.forEach(function(_s, _e, from, to) {
return ranges.push(from, to);
});
}
var joinable = [];
for (var i$1 = 0; i$1 < ranges.length; i$1 += 2) {
var from = ranges[i$1],
to = ranges[i$1 + 1];
var $from = tr.doc.resolve(from),
depth = $from.sharedDepth(to),
parent = $from.node(depth);
for (var index = $from.indexAfter(depth),
pos = $from.after(depth + 1); pos <= to; ++index) {
var after = parent.maybeChild(index);
if (!after) {
break;
}
if (index && joinable.indexOf(pos) == -1) {
var before = parent.child(index - 1);
if (before.type == after.type && isJoinable(before, after)) {
joinable.push(pos);
}
}
pos += after.nodeSize;
}
}
joinable.sort(function(a, b) {
return a - b;
});
for (var i$2 = joinable.length - 1; i$2 >= 0; i$2--) {
if (canJoin(tr.doc, joinable[i$2])) {
tr.join(joinable[i$2]);
}
}
dispatch(tr);
};
}
function autoJoin(command, isJoinable) {
if (Array.isArray(isJoinable)) {
var types = isJoinable;
isJoinable = function(node) {
return types.indexOf(node.type.name) > -1;
};
}
return function(state, dispatch) {
return command(state, dispatch && wrapDispatchForJoin(dispatch, isJoinable));
};
}
exports.autoJoin = autoJoin;
function chainCommands() {
var commands = [],
len = arguments.length;
while (len--)
commands[len] = arguments[len];
return function(state, dispatch, view) {
for (var i = 0; i < commands.length; i++) {
if (commands[i](state, dispatch, view)) {
return true;
}
}
return false;
};
}
exports.chainCommands = chainCommands;
var baseKeymap = {
"Enter": chainCommands(newlineInCode, createParagraphNear, liftEmptyBlock, splitBlock),
"Mod-Enter": exitCode,
"Backspace": chainCommands(deleteSelection, joinBackward),
"Mod-Backspace": chainCommands(deleteSelection, joinBackward),
"Delete": chainCommands(deleteSelection, joinForward),
"Mod-Delete": chainCommands(deleteSelection, joinForward),
"Alt-ArrowUp": joinUp,
"Alt-ArrowDown": joinDown,
"Mod-BracketLeft": lift,
"Escape": selectParentNode
};
var mac = typeof navigator != "undefined" ? /Mac/.test(navigator.platform) : typeof os != "undefined" ? os.platform() == "darwin" : false;
if (mac) {
var extra = {
"Ctrl-h": baseKeymap["Backspace"],
"Alt-Backspace": baseKeymap["Mod-Backspace"],
"Ctrl-d": baseKeymap["Delete"],
"Ctrl-Alt-Backspace": baseKeymap["Mod-Delete"],
"Alt-Delete": baseKeymap["Mod-Delete"],
"Alt-d": baseKeymap["Mod-Delete"]
};
for (var prop in extra) {
baseKeymap[prop] = extra[prop];
}
}
exports.baseKeymap = baseKeymap;
return module.exports;
});
$__System.registerDynamic("22", ["2b"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
module.exports = $__require('2b');
return module.exports;
});
$__System.registerDynamic("2c", ["3", "9", "7"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var ref = $__require('3');
var Fragment = ref.Fragment;
var Slice = ref.Slice;
var ref$1 = $__require('9');
var Step = ref$1.Step;
var StepResult = ref$1.StepResult;
var StepMap = ref$1.StepMap;
var ReplaceStep = ref$1.ReplaceStep;
var ref$2 = $__require('7');
var Selection = ref$2.Selection;
var table = {
attrs: {columns: {default: 1}},
parseDOM: [{
tag: "table",
getAttrs: function getAttrs(dom) {
var row = dom.querySelector("tr");
if (!row || !row.children.length) {
return false;
}
return {columns: row.children.length};
}
}],
toDOM: function toDOM() {
return ["table", ["tbody", 0]];
}
};
exports.table = table;
var tableRow = {
attrs: {columns: {default: 1}},
parseDOM: [{
tag: "tr",
getAttrs: function(dom) {
return dom.children.length ? {columns: dom.children.length} : false;
}
}],
toDOM: function toDOM() {
return ["tr", 0];
},
tableRow: true
};
exports.tableRow = tableRow;
var tableCell = {
parseDOM: [{tag: "td"}],
toDOM: function toDOM() {
return ["td", 0];
}
};
exports.tableCell = tableCell;
function add(obj, props) {
var copy = {};
for (var prop in obj) {
copy[prop] = obj[prop];
}
for (var prop$1 in props) {
copy[prop$1] = props[prop$1];
}
return copy;
}
function addTableNodes(nodes, cellContent, tableGroup) {
return nodes.append({
table: add(table, {
content: "table_row[columns=.columns]+",
group: tableGroup
}),
table_row: add(tableRow, {content: "table_cell{.columns}"}),
table_cell: add(tableCell, {content: cellContent})
});
}
exports.addTableNodes = addTableNodes;
function createTable(nodeType, rows, columns, attrs) {
attrs = setColumns(attrs, columns);
var rowType = nodeType.contentExpr.elements[0].nodeTypes[0];
var cellType = rowType.contentExpr.elements[0].nodeTypes[0];
var cell = cellType.createAndFill(),
cells = [];
for (var i = 0; i < columns; i++) {
cells.push(cell);
}
var row = rowType.create({columns: columns}, Fragment.from(cells)),
rowNodes = [];
for (var i$1 = 0; i$1 < rows; i$1++) {
rowNodes.push(row);
}
return nodeType.create(attrs, Fragment.from(rowNodes));
}
exports.createTable = createTable;
function setColumns(attrs, columns) {
var result = Object.create(null);
if (attrs) {
for (var prop in attrs) {
result[prop] = attrs[prop];
}
}
result.columns = columns;
return result;
}
function adjustColumns(attrs, diff) {
return setColumns(attrs, attrs.columns + diff);
}
var AddColumnStep = (function(Step) {
function AddColumnStep(positions, cells) {
Step.call(this);
this.positions = positions;
this.cells = cells;
}
if (Step)
AddColumnStep.__proto__ = Step;
AddColumnStep.prototype = Object.create(Step && Step.prototype);
AddColumnStep.prototype.constructor = AddColumnStep;
AddColumnStep.create = function create(doc, tablePos, columnIndex, cellType, cellAttrs) {
var cell = cellType.createAndFill(cellAttrs);
var positions = [],
cells = [];
var table = doc.nodeAt(tablePos);
table.forEach(function(row, rowOff) {
var cellPos = tablePos + 2 + rowOff;
for (var i = 0; i < columnIndex; i++) {
cellPos += row.child(i).nodeSize;
}
positions.push(cellPos);
cells.push(cell);
});
return new AddColumnStep(positions, cells);
};
AddColumnStep.prototype.apply = function apply(doc) {
var this$1 = this;
var index = null,
table = null,
tablePos = null;
for (var i = 0; i < this.positions.length; i++) {
var $pos = doc.resolve(this$1.positions[i]);
if ($pos.depth < 2 || $pos.index(-1) != i) {
return StepResult.fail("Invalid cell insert position");
}
if (table == null) {
table = $pos.node(-1);
if (table.childCount != this$1.positions.length) {
return StepResult.fail("Mismatch in number of rows");
}
tablePos = $pos.before(-1);
index = $pos.index();
} else if ($pos.before(-1) != tablePos || $pos.index() != index) {
return StepResult.fail("Column insert positions not consistent");
}
}
var updatedRows = [];
for (var i$1 = 0; i$1 < table.childCount; i$1++) {
var row = table.child(i$1),
rowCells = index ? [] : [this$1.cells[i$1]];
for (var j = 0; j < row.childCount; j++) {
rowCells.push(row.child(j));
if (j + 1 == index) {
rowCells.push(this$1.cells[i$1]);
}
}
updatedRows.push(row.type.create(adjustColumns(row.attrs, 1), Fragment.from(rowCells)));
}
var updatedTable = table.type.create(adjustColumns(table.attrs, 1), Fragment.from(updatedRows));
return StepResult.fromReplace(doc, tablePos, tablePos + table.nodeSize, new Slice(Fragment.from(updatedTable), 0, 0));
};
AddColumnStep.prototype.getMap = function getMap() {
var this$1 = this;
var ranges = [];
for (var i = 0; i < this.positions.length; i++) {
ranges.push(this$1.positions[i], 0, this$1.cells[i].nodeSize);
}
return new StepMap(ranges);
};
AddColumnStep.prototype.invert = function invert(doc) {
var this$1 = this;
var $first = doc.resolve(this.positions[0]);
var table = $first.node(-1);
var from = [],
to = [],
dPos = 0;
for (var i = 0; i < table.childCount; i++) {
var pos = this$1.positions[i] + dPos,
size = this$1.cells[i].nodeSize;
from.push(pos);
to.push(pos + size);
dPos += size;
}
return new RemoveColumnStep(from, to);
};
AddColumnStep.prototype.map = function map(mapping) {
return new AddColumnStep(this.positions.map(function(p) {
return mapping.map(p);
}), this.cells);
};
AddColumnStep.prototype.toJSON = function toJSON() {
return {
stepType: this.jsonID,
positions: this.positions,
cells: this.cells.map(function(c) {
return c.toJSON();
})
};
};
AddColumnStep.fromJSON = function fromJSON(schema, json) {
return new AddColumnStep(json.positions, json.cells.map(schema.nodeFromJSON));
};
return AddColumnStep;
}(Step));
exports.AddColumnStep = AddColumnStep;
Step.jsonID("addTableColumn", AddColumnStep);
var RemoveColumnStep = (function(Step) {
function RemoveColumnStep(from, to) {
Step.call(this);
this.from = from;
this.to = to;
}
if (Step)
RemoveColumnStep.__proto__ = Step;
RemoveColumnStep.prototype = Object.create(Step && Step.prototype);
RemoveColumnStep.prototype.constructor = RemoveColumnStep;
RemoveColumnStep.create = function create(doc, tablePos, columnIndex) {
var from = [],
to = [];
var table = doc.nodeAt(tablePos);
table.forEach(function(row, rowOff) {
var cellPos = tablePos + 2 + rowOff;
for (var i = 0; i < columnIndex; i++) {
cellPos += row.child(i).nodeSize;
}
from.push(cellPos);
to.push(cellPos + row.child(columnIndex).nodeSize);
});
return new RemoveColumnStep(from, to);
};
RemoveColumnStep.prototype.apply = function apply(doc) {
var this$1 = this;
var index = null,
table = null,
tablePos = null;
for (var i = 0; i < this.from.length; i++) {
var $from = doc.resolve(this$1.from[i]),
after = $from.nodeAfter;
if ($from.depth < 2 || $from.index(-1) != i || !after || this$1.from[i] + after.nodeSize != this$1.to[i]) {
return StepResult.fail("Invalid cell delete positions");
}
if (table == null) {
table = $from.node(-1);
if (table.childCount != this$1.from.length) {
return StepResult.fail("Mismatch in number of rows");
}
tablePos = $from.before(-1);
index = $from.index();
} else if ($from.before(-1) != tablePos || $from.index() != index) {
return StepResult.fail("Column delete positions not consistent");
}
}
var updatedRows = [];
for (var i$1 = 0; i$1 < table.childCount; i$1++) {
var row = table.child(i$1),
rowCells = [];
for (var j = 0; j < row.childCount; j++) {
if (j != index) {
rowCells.push(row.child(j));
}
}
updatedRows.push(row.type.create(adjustColumns(row.attrs, -1), Fragment.from(rowCells)));
}
var updatedTable = table.type.create(adjustColumns(table.attrs, -1), Fragment.from(updatedRows));
return StepResult.fromReplace(doc, tablePos, tablePos + table.nodeSize, new Slice(Fragment.from(updatedTable), 0, 0));
};
RemoveColumnStep.prototype.getMap = function getMap() {
var this$1 = this;
var ranges = [];
for (var i = 0; i < this.from.length; i++) {
ranges.push(this$1.from[i], this$1.to[i] - this$1.from[i], 0);
}
return new StepMap(ranges);
};
RemoveColumnStep.prototype.invert = function invert(doc) {
var this$1 = this;
var $first = doc.resolve(this.from[0]);
var table = $first.node(-1),
index = $first.index();
var positions = [],
cells = [],
dPos = 0;
for (var i = 0; i < table.childCount; i++) {
positions.push(this$1.from[i] - dPos);
var cell = table.child(i).child(index);
dPos += cell.nodeSize;
cells.push(cell);
}
return new AddColumnStep(positions, cells);
};
RemoveColumnStep.prototype.map = function map(mapping) {
var this$1 = this;
var from = [],
to = [];
for (var i = 0; i < this.from.length; i++) {
var start = mapping.map(this$1.from[i], 1),
end = mapping.map(this$1.to[i], -1);
if (end <= start) {
return null;
}
from.push(start);
to.push(end);
}
return new RemoveColumnStep(from, to);
};
RemoveColumnStep.fromJSON = function fromJSON(_schema, json) {
return new RemoveColumnStep(json.from, json.to);
};
return RemoveColumnStep;
}(Step));
exports.RemoveColumnStep = RemoveColumnStep;
Step.jsonID("removeTableColumn", RemoveColumnStep);
function findRow($pos, pred) {
for (var d = $pos.depth; d > 0; d--) {
if ($pos.node(d).type.spec.tableRow && (!pred || pred(d))) {
return d;
}
}
return -1;
}
function addColumnBefore(state, dispatch) {
var $from = state.selection.$from,
cellFrom;
var rowDepth = findRow($from, function(d) {
return cellFrom = d == $from.depth ? $from.nodeBefore : $from.node(d + 1);
});
if (rowDepth == -1) {
return false;
}
if (dispatch) {
dispatch(state.tr.step(AddColumnStep.create(state.doc, $from.before(rowDepth - 1), $from.index(rowDepth), cellFrom.type, cellFrom.attrs)));
}
return true;
}
exports.addColumnBefore = addColumnBefore;
function addColumnAfter(state, dispatch) {
var $from = state.selection.$from,
cellFrom;
var rowDepth = findRow($from, function(d) {
return cellFrom = d == $from.depth ? $from.nodeAfter : $from.node(d + 1);
});
if (rowDepth == -1) {
return false;
}
if (dispatch) {
dispatch(state.tr.step(AddColumnStep.create(state.doc, $from.before(rowDepth - 1), $from.indexAfter(rowDepth) + (rowDepth == $from.depth ? 1 : 0), cellFrom.type, cellFrom.attrs)));
}
return true;
}
exports.addColumnAfter = addColumnAfter;
function removeColumn(state, dispatch) {
var $from = state.selection.$from;
var rowDepth = findRow($from, function(d) {
return $from.node(d).childCount > 1;
});
if (rowDepth == -1) {
return false;
}
if (dispatch) {
dispatch(state.tr.step(RemoveColumnStep.create(state.doc, $from.before(rowDepth - 1), $from.index(rowDepth))));
}
return true;
}
exports.removeColumn = removeColumn;
function addRow(state, dispatch, side) {
var $from = state.selection.$from;
var rowDepth = findRow($from);
if (rowDepth == -1) {
return false;
}
if (dispatch) {
var exampleRow = $from.node(rowDepth);
var cells = [],
pos = side < 0 ? $from.before(rowDepth) : $from.after(rowDepth);
exampleRow.forEach(function(cell) {
return cells.push(cell.type.createAndFill(cell.attrs));
});
var row = exampleRow.copy(Fragment.from(cells));
dispatch(state.tr.step(new ReplaceStep(pos, pos, new Slice(Fragment.from(row), 0, 0))));
}
return true;
}
function addRowBefore(state, dispatch) {
return addRow(state, dispatch, -1);
}
exports.addRowBefore = addRowBefore;
function addRowAfter(state, dispatch) {
return addRow(state, dispatch, 1);
}
exports.addRowAfter = addRowAfter;
function removeRow(state, dispatch) {
var $from = state.selection.$from;
var rowDepth = findRow($from, function(d) {
return $from.node(d - 1).childCount > 1;
});
if (rowDepth == -1) {
return false;
}
if (dispatch) {
dispatch(state.tr.step(new ReplaceStep($from.before(rowDepth), $from.after(rowDepth), Slice.empty)));
}
return true;
}
exports.removeRow = removeRow;
function moveCell(state, dir, dispatch) {
var ref = state.selection;
var $from = ref.$from;
var rowDepth = findRow($from);
if (rowDepth == -1) {
return false;
}
var row = $from.node(rowDepth),
newIndex = $from.index(rowDepth) + dir;
if (newIndex >= 0 && newIndex < row.childCount) {
var $cellStart = state.doc.resolve(row.content.offsetAt(newIndex) + $from.start(rowDepth));
var sel = Selection.findFrom($cellStart, 1);
if (!sel || sel.from >= $cellStart.end()) {
return false;
}
if (dispatch) {
dispatch(state.tr.setSelection(sel).scrollIntoView());
}
return true;
} else {
var rowIndex = $from.index(rowDepth - 1) + dir,
table = $from.node(rowDepth - 1);
if (rowIndex < 0 || rowIndex >= table.childCount) {
return false;
}
var cellStart = dir > 0 ? $from.after(rowDepth) + 2 : $from.before(rowDepth) - 2 - table.child(rowIndex).lastChild.content.size;
var $cellStart$1 = state.doc.resolve(cellStart),
sel$1 = Selection.findFrom($cellStart$1, 1);
if (!sel$1 || sel$1.from >= $cellStart$1.end()) {
return false;
}
if (dispatch) {
dispatch(state.tr.setSelection(sel$1).scrollIntoView());
}
return true;
}
}
function selectNextCell(state, dispatch) {
return moveCell(state, 1, dispatch);
}
exports.selectNextCell = selectNextCell;
function selectPreviousCell(state, dispatch) {
return moveCell(state, -1, dispatch);
}
exports.selectPreviousCell = selectPreviousCell;
return module.exports;
});
$__System.registerDynamic("29", ["2c"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
module.exports = $__require('2c');
return module.exports;
});
$__System.registerDynamic("2d", [], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var GOOD_LEAF_SIZE = 200;
var RopeSequence = function RopeSequence() {};
RopeSequence.prototype.append = function append(other) {
if (!other.length) {
return this;
}
other = RopeSequence.from(other);
return (!this.length && other) || (other.length < GOOD_LEAF_SIZE && this.leafAppend(other)) || (this.length < GOOD_LEAF_SIZE && other.leafPrepend(this)) || this.appendInner(other);
};
RopeSequence.prototype.prepend = function prepend(other) {
if (!other.length) {
return this;
}
return RopeSequence.from(other).append(this);
};
RopeSequence.prototype.appendInner = function appendInner(other) {
return new Append(this, other);
};
RopeSequence.prototype.slice = function slice(from, to) {
if (from === void 0)
from = 0;
if (to === void 0)
to = this.length;
if (from >= to) {
return RopeSequence.empty;
}
return this.sliceInner(Math.max(0, from), Math.min(this.length, to));
};
RopeSequence.prototype.get = function get(i) {
if (i < 0 || i >= this.length) {
return undefined;
}
return this.getInner(i);
};
RopeSequence.prototype.forEach = function forEach(f, from, to) {
if (from === void 0)
from = 0;
if (to === void 0)
to = this.length;
if (from <= to) {
this.forEachInner(f, from, to, 0);
} else {
this.forEachInvertedInner(f, from, to, 0);
}
};
RopeSequence.prototype.map = function map(f, from, to) {
if (from === void 0)
from = 0;
if (to === void 0)
to = this.length;
var result = [];
this.forEach(function(elt, i) {
return result.push(f(elt, i));
}, from, to);
return result;
};
RopeSequence.from = function from(values) {
if (values instanceof RopeSequence) {
return values;
}
return values && values.length ? new Leaf(values) : RopeSequence.empty;
};
var Leaf = (function(RopeSequence) {
function Leaf(values) {
RopeSequence.call(this);
this.values = values;
}
if (RopeSequence)
Leaf.__proto__ = RopeSequence;
Leaf.prototype = Object.create(RopeSequence && RopeSequence.prototype);
Leaf.prototype.constructor = Leaf;
var prototypeAccessors = {
length: {},
depth: {}
};
Leaf.prototype.flatten = function flatten() {
return this.values;
};
Leaf.prototype.sliceInner = function sliceInner(from, to) {
if (from == 0 && to == this.length) {
return this;
}
return new Leaf(this.values.slice(from, to));
};
Leaf.prototype.getInner = function getInner(i) {
return this.values[i];
};
Leaf.prototype.forEachInner = function forEachInner(f, from, to, start) {
var this$1 = this;
for (var i = from; i < to; i++) {
if (f(this$1.values[i], start + i) === false) {
return false;
}
}
};
Leaf.prototype.forEachInvertedInner = function forEachInvertedInner(f, from, to, start) {
var this$1 = this;
for (var i = from - 1; i >= to; i--) {
if (f(this$1.values[i], start + i) === false) {
return false;
}
}
};
Leaf.prototype.leafAppend = function leafAppend(other) {
if (this.length + other.length <= GOOD_LEAF_SIZE) {
return new Leaf(this.values.concat(other.flatten()));
}
};
Leaf.prototype.leafPrepend = function leafPrepend(other) {
if (this.length + other.length <= GOOD_LEAF_SIZE) {
return new Leaf(other.flatten().concat(this.values));
}
};
prototypeAccessors.length.get = function() {
return this.values.length;
};
prototypeAccessors.depth.get = function() {
return 0;
};
Object.defineProperties(Leaf.prototype, prototypeAccessors);
return Leaf;
}(RopeSequence));
RopeSequence.empty = new Leaf([]);
var Append = (function(RopeSequence) {
function Append(left, right) {
RopeSequence.call(this);
this.left = left;
this.right = right;
this.length = left.length + right.length;
this.depth = Math.max(left.depth, right.depth) + 1;
}
if (RopeSequence)
Append.__proto__ = RopeSequence;
Append.prototype = Object.create(RopeSequence && RopeSequence.prototype);
Append.prototype.constructor = Append;
Append.prototype.flatten = function flatten() {
return this.left.flatten().concat(this.right.flatten());
};
Append.prototype.getInner = function getInner(i) {
return i < this.left.length ? this.left.get(i) : this.right.get(i - this.left.length);
};
Append.prototype.forEachInner = function forEachInner(f, from, to, start) {
var leftLen = this.left.length;
if (from < leftLen && this.left.forEachInner(f, from, Math.min(to, leftLen), start) === false) {
return false;
}
if (to > leftLen && this.right.forEachInner(f, Math.max(from - leftLen, 0), Math.min(this.length, to) - leftLen, start + leftLen) === false) {
return false;
}
};
Append.prototype.forEachInvertedInner = function forEachInvertedInner(f, from, to, start) {
var leftLen = this.left.length;
if (from > leftLen && this.right.forEachInvertedInner(f, from - leftLen, Math.max(to, leftLen) - leftLen, start + leftLen) === false) {
return false;
}
if (to < leftLen && this.left.forEachInvertedInner(f, Math.min(from, leftLen), to, start) === false) {
return false;
}
};
Append.prototype.sliceInner = function sliceInner(from, to) {
if (from == 0 && to == this.length) {
return this;
}
var leftLen = this.left.length;
if (to <= leftLen) {
return this.left.slice(from, to);
}
if (from >= leftLen) {
return this.right.slice(from - leftLen, to - leftLen);
}
return this.left.slice(from, leftLen).append(this.right.slice(0, to - leftLen));
};
Append.prototype.leafAppend = function leafAppend(other) {
var inner = this.right.leafAppend(other);
if (inner) {
return new Append(this.left, inner);
}
};
Append.prototype.leafPrepend = function leafPrepend(other) {
var inner = this.left.leafPrepend(other);
if (inner) {
return new Append(inner, this.right);
}
};
Append.prototype.appendInner = function appendInner(other) {
if (this.left.depth >= Math.max(this.right.depth, other.depth) + 1) {
return new Append(this.left, new Append(this.right, other));
}
return new Append(this, other);
};
return Append;
}(RopeSequence));
module.exports = RopeSequence;
return module.exports;
});
$__System.registerDynamic("2e", ["2d"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
module.exports = $__require('2d');
return module.exports;
});
$__System.registerDynamic("2f", [], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var Selection = function Selection($from, $to) {
this.$from = $from;
this.$to = $to;
};
var prototypeAccessors = {
from: {},
to: {},
empty: {}
};
prototypeAccessors.from.get = function() {
return this.$from.pos;
};
prototypeAccessors.to.get = function() {
return this.$to.pos;
};
prototypeAccessors.empty.get = function() {
return this.from == this.to;
};
Selection.findFrom = function findFrom($pos, dir, textOnly) {
var inner = $pos.parent.isTextblock ? new TextSelection($pos) : findSelectionIn($pos.node(0), $pos.parent, $pos.pos, $pos.index(), dir, textOnly);
if (inner) {
return inner;
}
for (var depth = $pos.depth - 1; depth >= 0; depth--) {
var found = dir < 0 ? findSelectionIn($pos.node(0), $pos.node(depth), $pos.before(depth + 1), $pos.index(depth), dir, textOnly) : findSelectionIn($pos.node(0), $pos.node(depth), $pos.after(depth + 1), $pos.index(depth) + 1, dir, textOnly);
if (found) {
return found;
}
}
};
Selection.near = function near($pos, bias, textOnly) {
if (bias === void 0)
bias = 1;
if (textOnly === void 0)
textOnly = false;
var result = this.findFrom($pos, bias, textOnly) || this.findFrom($pos, -bias, textOnly);
if (!result) {
throw new RangeError("Searching for selection in invalid document " + $pos.node(0));
}
return result;
};
Selection.atStart = function atStart(doc, textOnly) {
return findSelectionIn(doc, doc, 0, 0, 1, textOnly);
};
Selection.atEnd = function atEnd(doc, textOnly) {
return findSelectionIn(doc, doc, doc.content.size, doc.childCount, -1, textOnly);
};
Selection.between = function between($anchor, $head, bias) {
var found = Selection.near($head, bias);
if (found instanceof TextSelection) {
var nearAnchor = Selection.findFrom($anchor, $anchor.pos > found.to ? -1 : 1, true);
found = new TextSelection(nearAnchor.$anchor, found.$head);
} else if ($anchor.pos < found.from || $anchor.pos > found.to) {
var inv = $anchor.pos > found.to;
var foundAnchor = Selection.findFrom($anchor, inv ? -1 : 1, true);
var foundHead = Selection.findFrom(inv ? found.$from : found.$to, inv ? 1 : -1, true);
if (foundAnchor && foundHead) {
found = new TextSelection(foundAnchor.$anchor, foundHead.$head);
}
}
return found;
};
Selection.mapJSON = function mapJSON(json, mapping) {
if (json.anchor != null) {
return {
head: mapping.map(json.head),
anchor: mapping.map(json.anchor)
};
} else {
return {
node: mapping.map(json.node),
after: mapping.map(json.after, -1)
};
}
};
Selection.fromJSON = function fromJSON(doc, json) {
if (json.head != null) {
var $anchor = doc.resolve(json.anchor),
$head = doc.resolve(json.head);
if ($anchor.parent.isTextblock && $head.parent.isTextblock) {
return new TextSelection($anchor, $head);
} else {
return Selection.between($anchor, $head);
}
} else {
var $pos = doc.resolve(json.node),
after = $pos.nodeAfter;
if (after && json.after == json.pos + after.nodeSize && NodeSelection.isSelectable(after)) {
return new NodeSelection($pos);
} else {
return Selection.near($pos);
}
}
};
Object.defineProperties(Selection.prototype, prototypeAccessors);
exports.Selection = Selection;
var TextSelection = (function(Selection) {
function TextSelection($anchor, $head) {
if ($head === void 0)
$head = $anchor;
var inv = $anchor.pos > $head.pos;
Selection.call(this, inv ? $head : $anchor, inv ? $anchor : $head);
this.$anchor = $anchor;
this.$head = $head;
}
if (Selection)
TextSelection.__proto__ = Selection;
TextSelection.prototype = Object.create(Selection && Selection.prototype);
TextSelection.prototype.constructor = TextSelection;
var prototypeAccessors$1 = {
anchor: {},
head: {},
inverted: {}
};
prototypeAccessors$1.anchor.get = function() {
return this.$anchor.pos;
};
prototypeAccessors$1.head.get = function() {
return this.$head.pos;
};
prototypeAccessors$1.inverted.get = function() {
return this.anchor > this.head;
};
TextSelection.prototype.eq = function eq(other) {
return other instanceof TextSelection && other.head == this.head && other.anchor == this.anchor;
};
TextSelection.prototype.map = function map(doc, mapping) {
var $head = doc.resolve(mapping.map(this.head));
if (!$head.parent.isTextblock) {
return Selection.near($head);
}
var $anchor = doc.resolve(mapping.map(this.anchor));
return new TextSelection($anchor.parent.isTextblock ? $anchor : $head, $head);
};
TextSelection.prototype.toJSON = function toJSON() {
return {
head: this.head,
anchor: this.anchor
};
};
TextSelection.create = function create(doc, anchor, head) {
if (head === void 0)
head = anchor;
var $anchor = doc.resolve(anchor);
return new this($anchor, head == anchor ? $anchor : doc.resolve(head));
};
Object.defineProperties(TextSelection.prototype, prototypeAccessors$1);
return TextSelection;
}(Selection));
exports.TextSelection = TextSelection;
var NodeSelection = (function(Selection) {
function NodeSelection($from) {
var $to = $from.node(0).resolve($from.pos + $from.nodeAfter.nodeSize);
Selection.call(this, $from, $to);
this.node = $from.nodeAfter;
}
if (Selection)
NodeSelection.__proto__ = Selection;
NodeSelection.prototype = Object.create(Selection && Selection.prototype);
NodeSelection.prototype.constructor = NodeSelection;
NodeSelection.prototype.eq = function eq(other) {
return other instanceof NodeSelection && this.from == other.from;
};
NodeSelection.prototype.map = function map(doc, mapping) {
var from = mapping.mapResult(this.from, 1),
to = mapping.mapResult(this.to, -1);
var $from = doc.resolve(from.pos),
node = $from.nodeAfter;
if (!from.deleted && !to.deleted && node && to.pos == from.pos + node.nodeSize && NodeSelection.isSelectable(node)) {
return new NodeSelection($from);
}
return Selection.near($from);
};
NodeSelection.prototype.toJSON = function toJSON() {
return {
node: this.from,
after: this.to
};
};
NodeSelection.create = function create(doc, from) {
return new this(doc.resolve(from));
};
NodeSelection.isSelectable = function isSelectable(node) {
return !node.isText && node.type.spec.selectable !== false;
};
return NodeSelection;
}(Selection));
exports.NodeSelection = NodeSelection;
function findSelectionIn(doc, node, pos, index, dir, text) {
if (node.isTextblock) {
return TextSelection.create(doc, pos);
}
for (var i = index - (dir > 0 ? 0 : 1); dir > 0 ? i < node.childCount : i >= 0; i += dir) {
var child = node.child(i);
if (!child.isLeaf) {
var inner = findSelectionIn(doc, child, pos + dir, dir < 0 ? child.childCount : 0, dir, text);
if (inner) {
return inner;
}
} else if (!text && NodeSelection.isSelectable(child)) {
return NodeSelection.create(doc, pos - (dir < 0 ? child.nodeSize : 0));
}
pos += child.nodeSize * dir;
}
}
return module.exports;
});
$__System.registerDynamic("30", ["9", "3", "2f"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var ref = $__require('9');
var Transform = ref.Transform;
var ref$1 = $__require('3');
var Mark = ref$1.Mark;
var ref$2 = $__require('2f');
var Selection = ref$2.Selection;
var UPDATED_SEL = 1,
UPDATED_MARKS = 2,
UPDATED_SCROLL = 4;
var Transaction = (function(Transform) {
function Transaction(state) {
Transform.call(this, state.doc);
this.time = Date.now();
this.curSelection = state.selection;
this.curSelectionFor = 0;
this.storedMarks = state.storedMarks;
this.updated = 0;
this.meta = Object.create(null);
}
if (Transform)
Transaction.__proto__ = Transform;
Transaction.prototype = Object.create(Transform && Transform.prototype);
Transaction.prototype.constructor = Transaction;
var prototypeAccessors = {
docChanged: {},
selection: {},
selectionSet: {},
storedMarksSet: {},
isGeneric: {},
scrolledIntoView: {}
};
prototypeAccessors.docChanged.get = function() {
return this.steps.length > 0;
};
prototypeAccessors.selection.get = function() {
if (this.curSelectionFor < this.steps.length) {
this.curSelection = this.curSelection.map(this.doc, this.mapping.slice(this.curSelectionFor));
this.curSelectionFor = this.steps.length;
}
return this.curSelection;
};
Transaction.prototype.setSelection = function setSelection(selection) {
this.curSelection = selection;
this.curSelectionFor = this.steps.length;
this.updated = (this.updated | UPDATED_SEL) & ~UPDATED_MARKS;
this.storedMarks = null;
return this;
};
prototypeAccessors.selectionSet.get = function() {
return (this.updated & UPDATED_SEL) > 0;
};
Transaction.prototype.setStoredMarks = function setStoredMarks(marks) {
this.storedMarks = marks;
this.updated |= UPDATED_MARKS;
return this;
};
prototypeAccessors.storedMarksSet.get = function() {
return (this.updated & UPDATED_MARKS) > 0;
};
Transaction.prototype.addStep = function addStep(step, doc) {
Transform.prototype.addStep.call(this, step, doc);
this.updated = this.updated & ~UPDATED_MARKS;
this.storedMarks = null;
};
Transaction.prototype.setTime = function setTime(time) {
this.time = time;
return this;
};
Transaction.prototype.replaceSelection = function replaceSelection(slice) {
var ref = this.selection;
var from = ref.from;
var to = ref.to;
var startLen = this.steps.length;
this.replaceRange(from, to, slice);
var lastNode = slice.content.lastChild,
lastParent = null;
for (var i = 0; i < slice.openRight; i++) {
lastParent = lastNode;
lastNode = lastNode.lastChild;
}
selectionToInsertionEnd(this, startLen, (lastNode ? lastNode.isInline : lastParent && lastParent.isTextblock) ? -1 : 1);
return this;
};
Transaction.prototype.replaceSelectionWith = function replaceSelectionWith(node, inheritMarks) {
var ref = this.selection;
var $from = ref.$from;
var from = ref.from;
var to = ref.to;
var startLen = this.steps.length;
if (inheritMarks !== false) {
node = node.mark(this.storedMarks || $from.marks(to > from));
}
this.replaceRangeWith(from, to, node);
selectionToInsertionEnd(this, startLen, node.isInline ? -1 : 1);
return this;
};
Transaction.prototype.deleteSelection = function deleteSelection() {
var ref = this.selection;
var from = ref.from;
var to = ref.to;
return this.deleteRange(from, to);
};
Transaction.prototype.insertText = function insertText(text, from, to) {
if (to === void 0)
to = from;
var schema = this.doc.type.schema;
if (from == null) {
if (!text) {
return this.deleteSelection();
}
return this.replaceSelectionWith(schema.text(text), true);
} else {
if (!text) {
return this.deleteRange(from, to);
}
var node = schema.text(text, this.storedMarks || this.doc.resolve(from).marks(to > from));
return this.replaceRangeWith(from, to, node);
}
};
Transaction.prototype.setMeta = function setMeta(key, value) {
this.meta[typeof key == "string" ? key : key.key] = value;
return this;
};
Transaction.prototype.getMeta = function getMeta(key) {
return this.meta[typeof key == "string" ? key : key.key];
};
prototypeAccessors.isGeneric.get = function() {
var this$1 = this;
for (var _ in this$1.meta) {
return false;
}
return true;
};
Transaction.prototype.scrollIntoView = function scrollIntoView() {
this.updated |= UPDATED_SCROLL;
return this;
};
prototypeAccessors.scrolledIntoView.get = function() {
return (this.updated & UPDATED_SCROLL) > 0;
};
Transaction.prototype.addStoredMark = function addStoredMark(mark) {
this.storedMarks = mark.addToSet(this.storedMarks || currentMarks(this.selection));
return this;
};
Transaction.prototype.removeStoredMark = function removeStoredMark(mark) {
this.storedMarks = mark.removeFromSet(this.storedMarks || currentMarks(this.selection));
return this;
};
Object.defineProperties(Transaction.prototype, prototypeAccessors);
return Transaction;
}(Transform));
exports.Transaction = Transaction;
function selectionToInsertionEnd(tr, startLen, bias) {
if (tr.steps.length == startLen) {
return;
}
var map = tr.mapping.maps[tr.mapping.maps.length - 1],
end;
map.forEach(function(_from, _to, _newFrom, newTo) {
return end = newTo;
});
if (end != null) {
tr.setSelection(Selection.near(tr.doc.resolve(end), bias));
}
}
function currentMarks(selection) {
return selection.head == null ? Mark.none : selection.$head.marks();
}
return module.exports;
});
$__System.registerDynamic("31", ["3", "2f", "30"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var ref = $__require('3');
var Node = ref.Node;
var ref$1 = $__require('2f');
var Selection = ref$1.Selection;
var ref$2 = $__require('30');
var Transaction = ref$2.Transaction;
function bind(f, self) {
return !self || !f ? f : f.bind(self);
}
var FieldDesc = function FieldDesc(name, desc, self) {
this.name = name;
this.init = bind(desc.init, self);
this.apply = bind(desc.apply, self);
};
var baseFields = [new FieldDesc("doc", {
init: function init(config) {
return config.doc || config.schema.nodes.doc.createAndFill();
},
apply: function apply(tr) {
return tr.doc;
}
}), new FieldDesc("selection", {
init: function init(config, instance) {
return config.selection || Selection.atStart(instance.doc);
},
apply: function apply(tr) {
return tr.selection;
}
}), new FieldDesc("storedMarks", {
init: function init() {
return null;
},
apply: function apply(tr, _marks, _old, state) {
return state.selection.empty ? tr.storedMarks : null;
}
}), new FieldDesc("scrollToSelection", {
init: function init() {
return 0;
},
apply: function apply(tr, prev) {
return tr.scrolledIntoView ? prev + 1 : prev;
}
})];
var Configuration = function Configuration(schema, plugins) {
var this$1 = this;
this.schema = schema;
this.fields = baseFields.concat();
this.plugins = [];
this.pluginsByKey = Object.create(null);
if (plugins) {
plugins.forEach(function(plugin) {
if (this$1.pluginsByKey[plugin.key]) {
throw new RangeError("Adding different instances of a keyed plugin (" + plugin.key + ")");
}
this$1.plugins.push(plugin);
this$1.pluginsByKey[plugin.key] = plugin;
if (plugin.options.state) {
this$1.fields.push(new FieldDesc(plugin.key, plugin.options.state, plugin));
}
});
}
};
var EditorState = function EditorState(config) {
this.config = config;
};
var prototypeAccessors = {
schema: {},
plugins: {},
tr: {}
};
prototypeAccessors.schema.get = function() {
return this.config.schema;
};
prototypeAccessors.plugins.get = function() {
return this.config.plugins;
};
EditorState.prototype.apply = function apply(tr) {
return this.applyTransaction(tr).state;
};
EditorState.prototype.filterTransaction = function filterTransaction(tr, ignore) {
var this$1 = this;
if (ignore === void 0)
ignore = -1;
for (var i = 0; i < this.config.plugins.length; i++) {
if (i != ignore) {
var plugin = this$1.config.plugins[i];
if (plugin.options.filterTransaction && !plugin.options.filterTransaction.call(plugin, tr, this$1)) {
return false;
}
}
}
return true;
};
EditorState.prototype.applyTransaction = function applyTransaction(tr) {
var this$1 = this;
if (!this.filterTransaction(tr)) {
return {
state: this,
transactions: []
};
}
var trs = [tr],
newState = this.applyInner(tr),
seen = null;
outer: for (; ; ) {
var haveNew = false;
for (var i = 0; i < this.config.plugins.length; i++) {
var plugin = this$1.config.plugins[i];
if (plugin.options.appendTransaction) {
var n = seen ? seen[i].n : 0,
oldState = seen ? seen[i].state : this$1;
var tr$1 = n < trs.length && plugin.options.appendTransaction.call(plugin, n ? trs.slice(n) : trs, oldState, newState);
if (tr$1 && newState.filterTransaction(tr$1, i)) {
if (!seen) {
seen = [];
for (var j = 0; j < this.config.plugins.length; j++) {
seen.push(j < i ? {
state: newState,
n: trs.length
} : {
state: this$1,
n: 0
});
}
}
trs.push(tr$1);
newState = newState.applyInner(tr$1);
haveNew = true;
}
if (seen) {
seen[i] = {
state: newState,
n: trs.length
};
}
}
}
if (!haveNew) {
return {
state: newState,
transactions: trs
};
}
}
};
EditorState.prototype.applyInner = function applyInner(tr) {
var this$1 = this;
if (!tr.before.eq(this.doc)) {
throw new RangeError("Applying a mismatched transaction");
}
var newInstance = new EditorState(this.config),
fields = this.config.fields;
for (var i = 0; i < fields.length; i++) {
var field = fields[i];
newInstance[field.name] = field.apply(tr, this$1[field.name], this$1, newInstance);
}
for (var i$1 = 0; i$1 < applyListeners.length; i$1++) {
applyListeners[i$1](this$1, tr, newInstance);
}
return newInstance;
};
prototypeAccessors.tr.get = function() {
return new Transaction(this);
};
EditorState.create = function create(config) {
var $config = new Configuration(config.schema || config.doc.type.schema, config.plugins);
var instance = new EditorState($config);
for (var i = 0; i < $config.fields.length; i++) {
instance[$config.fields[i].name] = $config.fields[i].init(config, instance);
}
return instance;
};
EditorState.prototype.reconfigure = function reconfigure(config) {
var this$1 = this;
var $config = new Configuration(config.schema || this.schema, config.plugins);
var fields = $config.fields,
instance = new EditorState($config);
for (var i = 0; i < fields.length; i++) {
var name = fields[i].name;
instance[name] = this$1.hasOwnProperty(name) ? this$1[name] : fields[i].init(config, instance);
}
return instance;
};
EditorState.prototype.toJSON = function toJSON(pluginFields) {
var this$1 = this;
var result = {
doc: this.doc.toJSON(),
selection: this.selection.toJSON()
};
if (pluginFields) {
for (var prop in pluginFields) {
if (prop == "doc" || prop == "selection") {
throw new RangeError("The JSON fields `doc` and `selection` are reserved");
}
var plugin = pluginFields[prop],
state = plugin.options.state;
if (state && state.toJSON) {
result[prop] = state.toJSON.call(plugin, this$1[plugin.key]);
}
}
}
return result;
};
EditorState.fromJSON = function fromJSON(config, json, pluginFields) {
if (!config.schema) {
throw new RangeError("Required config field 'schema' missing");
}
var $config = new Configuration(config.schema, config.plugins);
var instance = new EditorState($config);
$config.fields.forEach(function(field) {
if (field.name == "doc") {
instance.doc = Node.fromJSON(config.schema, json.doc);
} else if (field.name == "selection") {
instance.selection = Selection.fromJSON(instance.doc, json.selection);
} else {
if (pluginFields) {
for (var prop in pluginFields) {
var plugin = pluginFields[prop],
state = plugin.options.state;
if (plugin.key == field.name && state && state.fromJSON && Object.prototype.hasOwnProperty.call(json, prop)) {
instance[field.name] = state.fromJSON.call(plugin, config, json[prop], instance);
return;
}
}
}
instance[field.name] = field.init(config, instance);
}
});
return instance;
};
EditorState.addApplyListener = function addApplyListener(f) {
applyListeners.push(f);
};
EditorState.removeApplyListener = function removeApplyListener(f) {
var found = applyListeners.indexOf(f);
if (found > -1) {
applyListeners.splice(found, 1);
}
};
Object.defineProperties(EditorState.prototype, prototypeAccessors);
exports.EditorState = EditorState;
var applyListeners = [];
return module.exports;
});
$__System.registerDynamic("32", [], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var Plugin = function Plugin(options) {
var this$1 = this;
this.props = {};
if (options.props) {
for (var prop in options.props) {
var val = options.props[prop];
if (val instanceof Function) {
val = val.bind(this$1);
}
this$1.props[prop] = val;
}
}
this.options = options;
this.key = options.key ? options.key.key : createKey("plugin");
};
Plugin.prototype.getState = function getState(state) {
return state[this.key];
};
exports.Plugin = Plugin;
var keys = Object.create(null);
function createKey(name) {
if (name in keys) {
return name + "$" + ++keys[name];
}
keys[name] = 0;
return name + "$";
}
var PluginKey = function PluginKey(name) {
if (name === void 0)
name = "key";
this.key = createKey(name);
};
PluginKey.prototype.get = function get(state) {
return state.config.pluginsByKey[this.key];
};
PluginKey.prototype.getState = function getState(state) {
return state[this.key];
};
exports.PluginKey = PluginKey;
return module.exports;
});
$__System.registerDynamic("33", ["2f", "30", "31", "32"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
;
var assign;
((assign = $__require('2f'), exports.Selection = assign.Selection, exports.TextSelection = assign.TextSelection, exports.NodeSelection = assign.NodeSelection));
exports.Transaction = $__require('30').Transaction;
exports.EditorState = $__require('31').EditorState;
;
var assign$1;
((assign$1 = $__require('32'), exports.Plugin = assign$1.Plugin, exports.PluginKey = assign$1.PluginKey));
return module.exports;
});
$__System.registerDynamic("7", ["33"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
module.exports = $__require('33');
return module.exports;
});
$__System.registerDynamic("34", ["2e", "9", "7"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var RopeSequence = $__require('2e');
var ref = $__require('9');
var Mapping = ref.Mapping;
var ref$1 = $__require('7');
var Selection = ref$1.Selection;
var Plugin = ref$1.Plugin;
var PluginKey = ref$1.PluginKey;
var max_empty_items = 500;
var Branch = function Branch(items, eventCount) {
this.items = items;
this.eventCount = eventCount;
};
Branch.prototype.popEvent = function popEvent(state, preserveItems) {
var this$1 = this;
if (this.eventCount == 0) {
return null;
}
var end = this.items.length;
for (; ; end--) {
var next = this$1.items.get(end - 1);
if (next.selection) {
--end;
break;
}
}
var remap,
mapFrom;
if (preserveItems) {
remap = this.remapping(end, this.items.length);
mapFrom = remap.maps.length;
}
var transform = state.tr;
var selection,
remaining;
var addAfter = [],
addBefore = [];
this.items.forEach(function(item, i) {
if (!item.step) {
if (!remap) {
remap = this$1.remapping(end, i + 1);
mapFrom = remap.maps.length;
}
mapFrom--;
addBefore.push(item);
return;
}
if (remap) {
addBefore.push(new Item(item.map));
var step = item.step.map(remap.slice(mapFrom)),
map;
if (step && transform.maybeStep(step).doc) {
map = transform.mapping.maps[transform.mapping.maps.length - 1];
addAfter.push(new Item(map, null, null, addAfter.length + addBefore.length));
}
mapFrom--;
if (map) {
remap.appendMap(map, mapFrom);
}
} else {
transform.maybeStep(item.step);
}
if (item.selection) {
selection = remap ? Selection.mapJSON(item.selection, remap.slice(mapFrom)) : item.selection;
remaining = new Branch(this$1.items.slice(0, end).append(addBefore.reverse().concat(addAfter)), this$1.eventCount - 1);
return false;
}
}, this.items.length, 0);
return {
remaining: remaining,
transform: transform,
selection: selection
};
};
Branch.prototype.addTransform = function addTransform(transform, selection, histOptions) {
var newItems = [],
eventCount = this.eventCount + (selection ? 1 : 0);
var oldItems = this.items,
lastItem = !histOptions.preserveItems && oldItems.length ? oldItems.get(oldItems.length - 1) : null;
for (var i = 0; i < transform.steps.length; i++) {
var step = transform.steps[i].invert(transform.docs[i]);
var item = new Item(transform.mapping.maps[i], step, selection),
merged = (void 0);
if (merged = lastItem && lastItem.merge(item)) {
item = merged;
if (i) {
newItems.pop();
} else {
oldItems = oldItems.slice(0, oldItems.length - 1);
}
}
newItems.push(item);
selection = null;
if (!histOptions.preserveItems) {
lastItem = item;
}
}
var overflow = eventCount - histOptions.depth;
if (overflow > DEPTH_OVERFLOW) {
oldItems = cutOffEvents(oldItems, overflow);
eventCount -= overflow;
}
return new Branch(oldItems.append(newItems), eventCount);
};
Branch.prototype.remapping = function remapping(from, to) {
var maps = [],
mirrors = [];
this.items.forEach(function(item, i) {
if (item.mirrorOffset != null) {
var mirrorPos = i - item.mirrorOffset;
if (mirrorPos >= from) {
mirrors.push(maps.length - item.mirrorOffset, maps.length);
}
}
maps.push(item.map);
}, from, to);
return new Mapping(maps, mirrors);
};
Branch.prototype.addMaps = function addMaps(array) {
if (this.eventCount == 0) {
return this;
}
return new Branch(this.items.append(array.map(function(map) {
return new Item(map);
})), this.eventCount);
};
Branch.prototype.rebased = function rebased(rebasedTransform, rebasedCount) {
if (!this.eventCount) {
return this;
}
var rebasedItems = [],
start = this.items.length - rebasedCount,
startPos = 0;
if (start < 0) {
startPos = -start;
start = 0;
}
var mapping = rebasedTransform.mapping;
var newUntil = rebasedTransform.steps.length;
var eventCount = this.eventCount;
var iRebased = startPos;
this.items.forEach(function(item) {
var pos = mapping.getMirror(iRebased++);
if (pos == null) {
return;
}
newUntil = Math.min(newUntil, pos);
var map = mapping.maps[pos];
if (item.step) {
var step = rebasedTransform.steps[pos].invert(rebasedTransform.docs[pos]);
var selection = item.selection && Selection.mapJSON(item.selection, mapping.slice(iRebased - 1, pos));
rebasedItems.push(new Item(map, step, selection));
} else {
if (item.selection) {
eventCount--;
}
rebasedItems.push(new Item(map));
}
}, start);
var newMaps = [];
for (var i = rebasedCount; i < newUntil; i++) {
newMaps.push(new Item(mapping.maps[i]));
}
var items = this.items.slice(0, start).append(newMaps).append(rebasedItems);
var branch = new Branch(items, eventCount);
if (branch.emptyItemCount() > max_empty_items) {
branch = branch.compress(this.items.length - rebasedItems.length);
}
return branch;
};
Branch.prototype.emptyItemCount = function emptyItemCount() {
var count = 0;
this.items.forEach(function(item) {
if (!item.step) {
count++;
}
});
return count;
};
Branch.prototype.compress = function compress(upto) {
if (upto === void 0)
upto = this.items.length;
var remap = this.remapping(0, upto),
mapFrom = remap.maps.length;
var items = [],
events = 0;
this.items.forEach(function(item, i) {
if (i >= upto) {
items.push(item);
if (item.selection) {
events++;
}
} else if (item.step) {
var step = item.step.map(remap.slice(mapFrom)),
map = step && step.getMap();
mapFrom--;
if (map) {
remap.appendMap(map, mapFrom);
}
if (step) {
var selection = item.selection && Selection.mapJSON(item.selection, remap.slice(mapFrom));
if (selection) {
events++;
}
var newItem = new Item(map.invert(), step, selection),
merged,
last = items.length - 1;
if (merged = items.length && items[last].merge(newItem)) {
items[last] = merged;
} else {
items.push(newItem);
}
}
} else if (item.map) {
mapFrom--;
}
}, this.items.length, 0);
return new Branch(RopeSequence.from(items.reverse()), events);
};
Branch.empty = new Branch(RopeSequence.empty, 0);
function cutOffEvents(items, n) {
var cutPoint;
items.forEach(function(item, i) {
if (item.selection && (n-- == 0)) {
cutPoint = i;
return false;
}
});
return items.slice(cutPoint);
}
var Item = function Item(map, step, selection, mirrorOffset) {
this.map = map;
this.step = step;
this.selection = selection;
this.mirrorOffset = mirrorOffset;
};
Item.prototype.merge = function merge(other) {
if (this.step && other.step && !other.selection) {
var step = other.step.merge(this.step);
if (step) {
return new Item(step.getMap().invert(), step, this.selection);
}
}
};
var HistoryState = function HistoryState(done, undone, prevMap, prevTime) {
this.done = done;
this.undone = undone;
this.prevMap = prevMap;
this.prevTime = prevTime;
};
exports.HistoryState = HistoryState;
var DEPTH_OVERFLOW = 20;
function applyTransaction(history, selection, tr, options) {
var newState = tr.getMeta(historyKey),
rebased;
if (newState) {
return newState;
} else if (tr.steps.length == 0) {
if (tr.getMeta(closeHistoryKey)) {
return new HistoryState(history.done, history.undone, null, 0);
} else {
return history;
}
} else if (tr.getMeta("addToHistory") !== false) {
var newGroup = history.prevTime < (tr.time || 0) - options.newGroupDelay || !isAdjacentToLastStep(tr, history.prevMap, history.done);
return new HistoryState(history.done.addTransform(tr, newGroup ? selection.toJSON() : null, options), Branch.empty, tr.mapping.maps[tr.steps.length - 1], tr.time);
} else if (rebased = tr.getMeta("rebased")) {
return new HistoryState(history.done.rebased(tr, rebased), history.undone.rebased(tr, rebased), history.prevMap && tr.mapping.maps[tr.steps.length - 1], history.prevTime);
} else {
return new HistoryState(history.done.addMaps(tr.mapping.maps), history.undone.addMaps(tr.mapping.maps), history.prevMap, history.prevTime);
}
}
function isAdjacentToLastStep(transform, prevMap, done) {
if (!prevMap) {
return false;
}
var firstMap = transform.mapping.maps[0],
adjacent = false;
if (!firstMap) {
return true;
}
firstMap.forEach(function(start, end) {
done.items.forEach(function(item) {
if (item.step) {
prevMap.forEach(function(_start, _end, rStart, rEnd) {
if (start <= rEnd && end >= rStart) {
adjacent = true;
}
});
return false;
} else {
start = item.map.invert().map(start, -1);
end = item.map.invert().map(end, 1);
}
}, done.items.length, 0);
});
return adjacent;
}
function histTransaction(history, state, dispatch, redo) {
var histOptions = historyKey.get(state).options.config;
var pop = (redo ? history.undone : history.done).popEvent(state, histOptions.preserveItems);
if (!pop) {
return;
}
var selectionBefore = state.selection;
var selection = Selection.fromJSON(pop.transform.doc, pop.selection);
var added = (redo ? history.done : history.undone).addTransform(pop.transform, selectionBefore.toJSON(), histOptions);
var newHist = new HistoryState(redo ? added : pop.remaining, redo ? pop.remaining : added, null, 0);
dispatch(pop.transform.setSelection(selection).setMeta(historyKey, newHist).scrollIntoView());
}
function closeHistory(state) {
return state.tr.setMeta(closeHistoryKey, true);
}
exports.closeHistory = closeHistory;
var historyKey = new PluginKey("history");
var closeHistoryKey = new PluginKey("closeHistory");
function history(config) {
config = {
depth: config && config.depth || 100,
preserveItems: !!(config && config.preserveItems),
newGroupDelay: config && config.newGroupDelay || 500
};
return new Plugin({
key: historyKey,
state: {
init: function init() {
return new HistoryState(Branch.empty, Branch.empty, null, 0);
},
apply: function apply(tr, hist, state) {
return applyTransaction(hist, state.selection, tr, config);
}
},
config: config
});
}
exports.history = history;
function undo(state, dispatch) {
var hist = historyKey.getState(state);
if (!hist || hist.done.eventCount == 0) {
return false;
}
if (dispatch) {
histTransaction(hist, state, dispatch, false);
}
return true;
}
exports.undo = undo;
function redo(state, dispatch) {
var hist = historyKey.getState(state);
if (!hist || hist.undone.eventCount == 0) {
return false;
}
if (dispatch) {
histTransaction(hist, state, dispatch, true);
}
return true;
}
exports.redo = redo;
function undoDepth(state) {
var hist = historyKey.getState(state);
return hist ? hist.done.eventCount : 0;
}
exports.undoDepth = undoDepth;
function redoDepth(state) {
var hist = historyKey.getState(state);
return hist ? hist.undone.eventCount : 0;
}
exports.redoDepth = redoDepth;
return module.exports;
});
$__System.registerDynamic("23", ["34"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
module.exports = $__require('34');
return module.exports;
});
$__System.registerDynamic("35", ["22", "29", "2a", "23"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var ref = $__require('22');
var wrapIn = ref.wrapIn;
var setBlockType = ref.setBlockType;
var chainCommands = ref.chainCommands;
var toggleMark = ref.toggleMark;
var exitCode = ref.exitCode;
var ref$1 = $__require('29');
var selectNextCell = ref$1.selectNextCell;
var selectPreviousCell = ref$1.selectPreviousCell;
var ref$2 = $__require('2a');
var wrapInList = ref$2.wrapInList;
var splitListItem = ref$2.splitListItem;
var liftListItem = ref$2.liftListItem;
var sinkListItem = ref$2.sinkListItem;
var ref$3 = $__require('23');
var undo = ref$3.undo;
var redo = ref$3.redo;
var mac = typeof navigator != "undefined" ? /Mac/.test(navigator.platform) : false;
function buildKeymap(schema, mapKeys) {
var keys = {},
type;
function bind(key, cmd) {
if (mapKeys) {
var mapped = mapKeys[key];
if (mapped === false) {
return;
}
if (mapped) {
key = mapped;
}
}
keys[key] = cmd;
}
bind("Mod-z", undo);
bind("Shift-Mod-z", redo);
if (!mac) {
bind("Mod-y", redo);
}
if (type = schema.marks.strong) {
bind("Mod-b", toggleMark(type));
}
if (type = schema.marks.em) {
bind("Mod-i", toggleMark(type));
}
if (type = schema.marks.code) {
bind("Mod-`", toggleMark(type));
}
if (type = schema.nodes.bullet_list) {
bind("Shift-Ctrl-8", wrapInList(type));
}
if (type = schema.nodes.ordered_list) {
bind("Shift-Ctrl-9", wrapInList(type));
}
if (type = schema.nodes.blockquote) {
bind("Ctrl->", wrapIn(type));
}
if (type = schema.nodes.hard_break) {
var br = type,
cmd = chainCommands(exitCode, function(state, dispatch) {
dispatch(state.tr.replaceSelectionWith(br.create()).scrollIntoView());
return true;
});
bind("Mod-Enter", cmd);
bind("Shift-Enter", cmd);
if (mac) {
bind("Ctrl-Enter", cmd);
}
}
if (type = schema.nodes.list_item) {
bind("Enter", splitListItem(type));
bind("Mod-[", liftListItem(type));
bind("Mod-]", sinkListItem(type));
}
if (type = schema.nodes.paragraph) {
bind("Shift-Ctrl-0", setBlockType(type));
}
if (type = schema.nodes.code_block) {
bind("Shift-Ctrl-\\", setBlockType(type));
}
if (type = schema.nodes.heading) {
for (var i = 1; i <= 6; i++) {
bind("Shift-Ctrl-" + i, setBlockType(type, {level: i}));
}
}
if (type = schema.nodes.horizontal_rule) {
var hr = type;
bind("Mod-_", function(state, dispatch) {
dispatch(state.tr.replaceSelectionWith(hr.create()).scrollIntoView());
return true;
});
}
if (schema.nodes.table_row) {
bind("Tab", selectNextCell);
bind("Shift-Tab", selectPreviousCell);
}
return keys;
}
exports.buildKeymap = buildKeymap;
return module.exports;
});
$__System.registerDynamic("36", ["b", "f", "23", "22", "7", "12", "28", "35"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var ref = $__require('b');
var blockQuoteRule = ref.blockQuoteRule;
var orderedListRule = ref.orderedListRule;
var bulletListRule = ref.bulletListRule;
var codeBlockRule = ref.codeBlockRule;
var headingRule = ref.headingRule;
var inputRules = ref.inputRules;
var allInputRules = ref.allInputRules;
var ref$1 = $__require('f');
var keymap = ref$1.keymap;
var ref$2 = $__require('23');
var history = ref$2.history;
var ref$3 = $__require('22');
var baseKeymap = ref$3.baseKeymap;
var ref$4 = $__require('7');
var Plugin = ref$4.Plugin;
var ref$5 = $__require('12');
var dropCursor = ref$5.dropCursor;
var ref$6 = $__require('28');
var buildMenuItems = ref$6.buildMenuItems;
exports.buildMenuItems = buildMenuItems;
var ref$7 = $__require('35');
var buildKeymap = ref$7.buildKeymap;
exports.buildKeymap = buildKeymap;
function exampleSetup(options) {
var plugins = [inputRules({rules: allInputRules.concat(buildInputRules(options.schema))}), keymap(buildKeymap(options.schema, options.mapKeys)), keymap(baseKeymap), dropCursor()];
if (options.history !== false) {
plugins.push(history());
}
return plugins.concat(new Plugin({props: {
attributes: {class: "ProseMirror-example-setup-style"},
menuContent: buildMenuItems(options.schema).fullMenu,
floatingMenu: true
}}));
}
exports.exampleSetup = exampleSetup;
function buildInputRules(schema) {
var result = [],
type;
if (type = schema.nodes.blockquote) {
result.push(blockQuoteRule(type));
}
if (type = schema.nodes.ordered_list) {
result.push(orderedListRule(type));
}
if (type = schema.nodes.bullet_list) {
result.push(bulletListRule(type));
}
if (type = schema.nodes.code_block) {
result.push(codeBlockRule(type));
}
if (type = schema.nodes.heading) {
result.push(headingRule(type, 6));
}
return result;
}
exports.buildInputRules = buildInputRules;
return module.exports;
});
$__System.registerDynamic("37", ["36"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
module.exports = $__require('36');
return module.exports;
});
$__System.registerDynamic("38", ["3", "39"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var ref = $__require('3');
var Fragment = ref.Fragment;
var Slice = ref.Slice;
var ref$1 = $__require('39');
var Step = ref$1.Step;
var StepResult = ref$1.StepResult;
function mapFragment(fragment, f, parent) {
var mapped = [];
for (var i = 0; i < fragment.childCount; i++) {
var child = fragment.child(i);
if (child.content.size) {
child = child.copy(mapFragment(child.content, f, child));
}
if (child.isInline) {
child = f(child, parent, i);
}
mapped.push(child);
}
return Fragment.fromArray(mapped);
}
var AddMarkStep = (function(Step) {
function AddMarkStep(from, to, mark) {
Step.call(this);
this.from = from;
this.to = to;
this.mark = mark;
}
if (Step)
AddMarkStep.__proto__ = Step;
AddMarkStep.prototype = Object.create(Step && Step.prototype);
AddMarkStep.prototype.constructor = AddMarkStep;
AddMarkStep.prototype.apply = function apply(doc) {
var this$1 = this;
var oldSlice = doc.slice(this.from, this.to),
$from = doc.resolve(this.from);
var parent = $from.node($from.sharedDepth(this.to));
var slice = new Slice(mapFragment(oldSlice.content, function(node, parent, index) {
if (!parent.contentMatchAt(index + 1).allowsMark(this$1.mark.type)) {
return node;
}
return node.mark(this$1.mark.addToSet(node.marks));
}, parent), oldSlice.openLeft, oldSlice.openRight);
return StepResult.fromReplace(doc, this.from, this.to, slice);
};
AddMarkStep.prototype.invert = function invert() {
return new RemoveMarkStep(this.from, this.to, this.mark);
};
AddMarkStep.prototype.map = function map(mapping) {
var from = mapping.mapResult(this.from, 1),
to = mapping.mapResult(this.to, -1);
if (from.deleted && to.deleted || from.pos >= to.pos) {
return null;
}
return new AddMarkStep(from.pos, to.pos, this.mark);
};
AddMarkStep.prototype.merge = function merge(other) {
if (other instanceof AddMarkStep && other.mark.eq(this.mark) && this.from <= other.to && this.to >= other.from) {
return new AddMarkStep(Math.min(this.from, other.from), Math.max(this.to, other.to), this.mark);
}
};
AddMarkStep.fromJSON = function fromJSON(schema, json) {
return new AddMarkStep(json.from, json.to, schema.markFromJSON(json.mark));
};
return AddMarkStep;
}(Step));
exports.AddMarkStep = AddMarkStep;
Step.jsonID("addMark", AddMarkStep);
var RemoveMarkStep = (function(Step) {
function RemoveMarkStep(from, to, mark) {
Step.call(this);
this.from = from;
this.to = to;
this.mark = mark;
}
if (Step)
RemoveMarkStep.__proto__ = Step;
RemoveMarkStep.prototype = Object.create(Step && Step.prototype);
RemoveMarkStep.prototype.constructor = RemoveMarkStep;
RemoveMarkStep.prototype.apply = function apply(doc) {
var this$1 = this;
var oldSlice = doc.slice(this.from, this.to);
var slice = new Slice(mapFragment(oldSlice.content, function(node) {
return node.mark(this$1.mark.removeFromSet(node.marks));
}), oldSlice.openLeft, oldSlice.openRight);
return StepResult.fromReplace(doc, this.from, this.to, slice);
};
RemoveMarkStep.prototype.invert = function invert() {
return new AddMarkStep(this.from, this.to, this.mark);
};
RemoveMarkStep.prototype.map = function map(mapping) {
var from = mapping.mapResult(this.from, 1),
to = mapping.mapResult(this.to, -1);
if (from.deleted && to.deleted || from.pos >= to.pos) {
return null;
}
return new RemoveMarkStep(from.pos, to.pos, this.mark);
};
RemoveMarkStep.prototype.merge = function merge(other) {
if (other instanceof RemoveMarkStep && other.mark.eq(this.mark) && this.from <= other.to && this.to >= other.from) {
return new RemoveMarkStep(Math.min(this.from, other.from), Math.max(this.to, other.to), this.mark);
}
};
RemoveMarkStep.fromJSON = function fromJSON(schema, json) {
return new RemoveMarkStep(json.from, json.to, schema.markFromJSON(json.mark));
};
return RemoveMarkStep;
}(Step));
exports.RemoveMarkStep = RemoveMarkStep;
Step.jsonID("removeMark", RemoveMarkStep);
return module.exports;
});
$__System.registerDynamic("3a", ["3", "3b", "38", "3c"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var ref = $__require('3');
var MarkType = ref.MarkType;
var Slice = ref.Slice;
var Fragment = ref.Fragment;
var ref$1 = $__require('3b');
var Transform = ref$1.Transform;
var ref$2 = $__require('38');
var AddMarkStep = ref$2.AddMarkStep;
var RemoveMarkStep = ref$2.RemoveMarkStep;
var ref$3 = $__require('3c');
var ReplaceStep = ref$3.ReplaceStep;
Transform.prototype.addMark = function(from, to, mark) {
var this$1 = this;
var removed = [],
added = [],
removing = null,
adding = null;
this.doc.nodesBetween(from, to, function(node, pos, parent, index) {
if (!node.isInline) {
return;
}
var marks = node.marks;
if (mark.isInSet(marks) || !parent.contentMatchAt(index + 1).allowsMark(mark.type)) {
adding = removing = null;
} else {
var start = Math.max(pos, from),
end = Math.min(pos + node.nodeSize, to);
var rm = mark.type.isInSet(marks);
if (!rm) {
removing = null;
} else if (removing && removing.mark.eq(rm)) {
removing.to = end;
} else {
removed.push(removing = new RemoveMarkStep(start, end, rm));
}
if (adding) {
adding.to = end;
} else {
added.push(adding = new AddMarkStep(start, end, mark));
}
}
});
removed.forEach(function(s) {
return this$1.step(s);
});
added.forEach(function(s) {
return this$1.step(s);
});
return this;
};
Transform.prototype.removeMark = function(from, to, mark) {
var this$1 = this;
if (mark === void 0)
mark = null;
var matched = [],
step = 0;
this.doc.nodesBetween(from, to, function(node, pos) {
if (!node.isInline) {
return;
}
step++;
var toRemove = null;
if (mark instanceof MarkType) {
var found = mark.isInSet(node.marks);
if (found) {
toRemove = [found];
}
} else if (mark) {
if (mark.isInSet(node.marks)) {
toRemove = [mark];
}
} else {
toRemove = node.marks;
}
if (toRemove && toRemove.length) {
var end = Math.min(pos + node.nodeSize, to);
for (var i = 0; i < toRemove.length; i++) {
var style = toRemove[i],
found$1 = (void 0);
for (var j = 0; j < matched.length; j++) {
var m = matched[j];
if (m.step == step - 1 && style.eq(matched[j].style)) {
found$1 = m;
}
}
if (found$1) {
found$1.to = end;
found$1.step = step;
} else {
matched.push({
style: style,
from: Math.max(pos, from),
to: end,
step: step
});
}
}
}
});
matched.forEach(function(m) {
return this$1.step(new RemoveMarkStep(m.from, m.to, m.style));
});
return this;
};
Transform.prototype.clearMarkup = function(from, to) {
var this$1 = this;
var delSteps = [];
this.doc.nodesBetween(from, to, function(node, pos) {
if (!node.isInline) {
return;
}
if (!node.type.isText) {
delSteps.push(new ReplaceStep(pos, pos + node.nodeSize, Slice.empty));
return;
}
for (var i = 0; i < node.marks.length; i++) {
this$1.step(new RemoveMarkStep(Math.max(pos, from), Math.min(pos + node.nodeSize, to), node.marks[i]));
}
});
for (var i = delSteps.length - 1; i >= 0; i--) {
this$1.step(delSteps[i]);
}
return this;
};
Transform.prototype.clearNonMatching = function(pos, match) {
var this$1 = this;
var node = this.doc.nodeAt(pos);
var delSteps = [],
cur = pos + 1;
for (var i = 0; i < node.childCount; i++) {
var child = node.child(i),
end = cur + child.nodeSize;
var allowed = match.matchType(child.type, child.attrs);
if (!allowed) {
delSteps.push(new ReplaceStep(cur, end, Slice.empty));
} else {
match = allowed;
for (var j = 0; j < child.marks.length; j++) {
if (!match.allowsMark(child.marks[j])) {
this$1.step(new RemoveMarkStep(cur, end, child.marks[j]));
}
}
}
cur = end;
}
if (!match.validEnd()) {
var fill = match.fillBefore(Fragment.empty, true);
this.replace(cur, cur, new Slice(fill, 0, 0));
}
for (var i$1 = delSteps.length - 1; i$1 >= 0; i$1--) {
this$1.step(delSteps[i$1]);
}
return this;
};
return module.exports;
});
$__System.registerDynamic("3b", ["3d"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var ref = $__require('3d');
var Mapping = ref.Mapping;
var TransformError = (function(Error) {
function TransformError() {
Error.apply(this, arguments);
}
if (Error)
TransformError.__proto__ = Error;
TransformError.prototype = Object.create(Error && Error.prototype);
TransformError.prototype.constructor = TransformError;
return TransformError;
}(Error));
exports.TransformError = TransformError;
var Transform = function Transform(doc) {
this.doc = doc;
this.steps = [];
this.docs = [];
this.mapping = new Mapping;
};
var prototypeAccessors = {before: {}};
prototypeAccessors.before.get = function() {
return this.docs.length ? this.docs[0] : this.doc;
};
Transform.prototype.step = function step(object) {
var result = this.maybeStep(object);
if (result.failed) {
throw new TransformError(result.failed);
}
return this;
};
Transform.prototype.maybeStep = function maybeStep(step) {
var result = step.apply(this.doc);
if (!result.failed) {
this.addStep(step, result.doc);
}
return result;
};
Transform.prototype.addStep = function addStep(step, doc) {
this.docs.push(this.doc);
this.steps.push(step);
this.mapping.appendMap(step.getMap());
this.doc = doc;
};
Object.defineProperties(Transform.prototype, prototypeAccessors);
exports.Transform = Transform;
return module.exports;
});
$__System.registerDynamic("39", ["3", "3d"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var ref = $__require('3');
var ReplaceError = ref.ReplaceError;
var ref$1 = $__require('3d');
var StepMap = ref$1.StepMap;
function mustOverride() {
throw new Error("Override me");
}
var stepsByID = Object.create(null);
var Step = function Step() {};
Step.prototype.apply = function apply(_doc) {
return mustOverride();
};
Step.prototype.getMap = function getMap() {
return StepMap.empty;
};
Step.prototype.invert = function invert(_doc) {
return mustOverride();
};
Step.prototype.map = function map(_mapping) {
return mustOverride();
};
Step.prototype.merge = function merge(_other) {
return null;
};
Step.prototype.toJSON = function toJSON() {
var this$1 = this;
var obj = {stepType: this.jsonID};
for (var prop in this$1) {
if (this$1.hasOwnProperty(prop)) {
var val = this$1[prop];
obj[prop] = val && val.toJSON ? val.toJSON() : val;
}
}
return obj;
};
Step.fromJSON = function fromJSON(schema, json) {
return stepsByID[json.stepType].fromJSON(schema, json);
};
Step.jsonID = function jsonID(id, stepClass) {
if (id in stepsByID) {
throw new RangeError("Duplicate use of step JSON ID " + id);
}
stepsByID[id] = stepClass;
stepClass.prototype.jsonID = id;
return stepClass;
};
exports.Step = Step;
var StepResult = function StepResult(doc, failed) {
this.doc = doc;
this.failed = failed;
};
StepResult.ok = function ok(doc) {
return new StepResult(doc, null);
};
StepResult.fail = function fail(message) {
return new StepResult(null, message);
};
StepResult.fromReplace = function fromReplace(doc, from, to, slice) {
try {
return StepResult.ok(doc.replace(from, to, slice));
} catch (e) {
if (e instanceof ReplaceError) {
return StepResult.fail(e.message);
}
throw e;
}
};
exports.StepResult = StepResult;
return module.exports;
});
$__System.registerDynamic("3d", [], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var lower16 = 0xffff;
var factor16 = Math.pow(2, 16);
function makeRecover(index, offset) {
return index + offset * factor16;
}
function recoverIndex(value) {
return value & lower16;
}
function recoverOffset(value) {
return (value - (value & lower16)) / factor16;
}
var MapResult = function MapResult(pos, deleted, recover) {
if (deleted === void 0)
deleted = false;
if (recover === void 0)
recover = null;
this.pos = pos;
this.deleted = deleted;
this.recover = recover;
};
exports.MapResult = MapResult;
var StepMap = function StepMap(ranges, inverted) {
if (inverted === void 0)
inverted = false;
this.ranges = ranges;
this.inverted = inverted;
};
StepMap.prototype.recover = function recover(value) {
var this$1 = this;
var diff = 0,
index = recoverIndex(value);
if (!this.inverted) {
for (var i = 0; i < index; i++) {
diff += this$1.ranges[i * 3 + 2] - this$1.ranges[i * 3 + 1];
}
}
return this.ranges[index * 3] + diff + recoverOffset(value);
};
StepMap.prototype.mapResult = function mapResult(pos, assoc) {
return this._map(pos, assoc, false);
};
StepMap.prototype.map = function map(pos, assoc) {
return this._map(pos, assoc, true);
};
StepMap.prototype._map = function _map(pos, assoc, simple) {
var this$1 = this;
var diff = 0,
oldIndex = this.inverted ? 2 : 1,
newIndex = this.inverted ? 1 : 2;
for (var i = 0; i < this.ranges.length; i += 3) {
var start = this$1.ranges[i] - (this$1.inverted ? diff : 0);
if (start > pos) {
break;
}
var oldSize = this$1.ranges[i + oldIndex],
newSize = this$1.ranges[i + newIndex],
end = start + oldSize;
if (pos <= end) {
var side = !oldSize ? assoc : pos == start ? -1 : pos == end ? 1 : assoc;
var result = start + diff + (side < 0 ? 0 : newSize);
if (simple) {
return result;
}
var recover = makeRecover(i / 3, pos - start);
return new MapResult(result, assoc < 0 ? pos != start : pos != end, recover);
}
diff += newSize - oldSize;
}
return simple ? pos + diff : new MapResult(pos + diff);
};
StepMap.prototype.touches = function touches(pos, recover) {
var this$1 = this;
var diff = 0,
index = recoverIndex(recover);
var oldIndex = this.inverted ? 2 : 1,
newIndex = this.inverted ? 1 : 2;
for (var i = 0; i < this.ranges.length; i += 3) {
var start = this$1.ranges[i] - (this$1.inverted ? diff : 0);
if (start > pos) {
break;
}
var oldSize = this$1.ranges[i + oldIndex],
end = start + oldSize;
if (pos <= end && i == index * 3) {
return true;
}
diff += this$1.ranges[i + newIndex] - oldSize;
}
return false;
};
StepMap.prototype.forEach = function forEach(f) {
var this$1 = this;
var oldIndex = this.inverted ? 2 : 1,
newIndex = this.inverted ? 1 : 2;
for (var i = 0,
diff = 0; i < this.ranges.length; i += 3) {
var start = this$1.ranges[i],
oldStart = start - (this$1.inverted ? diff : 0),
newStart = start + (this$1.inverted ? 0 : diff);
var oldSize = this$1.ranges[i + oldIndex],
newSize = this$1.ranges[i + newIndex];
f(oldStart, oldStart + oldSize, newStart, newStart + newSize);
diff += newSize - oldSize;
}
};
StepMap.prototype.invert = function invert() {
return new StepMap(this.ranges, !this.inverted);
};
StepMap.prototype.toString = function toString() {
return (this.inverted ? "-" : "") + JSON.stringify(this.ranges);
};
exports.StepMap = StepMap;
StepMap.empty = new StepMap([]);
var Mapping = function Mapping(maps, mirror, from, to) {
this.maps = maps || [];
this.from = from || 0;
this.to = to == null ? this.maps.length : to;
this.mirror = mirror;
};
Mapping.prototype.slice = function slice(from, to) {
if (from === void 0)
from = 0;
if (to === void 0)
to = this.maps.length;
return new Mapping(this.maps, this.mirror, from, to);
};
Mapping.prototype.copy = function copy() {
return new Mapping(this.maps.slice(), this.mirror && this.mirror.slice(), this.from, this.to);
};
Mapping.prototype.getMirror = function getMirror(n) {
var this$1 = this;
if (this.mirror) {
for (var i = 0; i < this.mirror.length; i++) {
if (this$1.mirror[i] == n) {
return this$1.mirror[i + (i % 2 ? -1 : 1)];
}
}
}
};
Mapping.prototype.setMirror = function setMirror(n, m) {
if (!this.mirror) {
this.mirror = [];
}
this.mirror.push(n, m);
};
Mapping.prototype.appendMap = function appendMap(map, mirrors) {
this.to = this.maps.push(map);
if (mirrors != null) {
this.setMirror(this.maps.length - 1, mirrors);
}
};
Mapping.prototype.appendMapping = function appendMapping(mapping) {
var this$1 = this;
for (var i = 0,
startSize = this.maps.length; i < mapping.maps.length; i++) {
var mirr = mapping.getMirror(i);
this$1.appendMap(mapping.maps[i], mirr != null && mirr < i ? startSize + mirr : null);
}
};
Mapping.prototype.map = function map(pos, assoc) {
var this$1 = this;
if (this.mirror) {
return this._map(pos, assoc, true);
}
for (var i = this.from; i < this.to; i++) {
pos = this$1.maps[i].map(pos, assoc);
}
return pos;
};
Mapping.prototype.mapResult = function mapResult(pos, assoc) {
return this._map(pos, assoc, false);
};
Mapping.prototype._map = function _map(pos, assoc, simple) {
var this$1 = this;
var deleted = false,
recoverables = null;
for (var i = this.from; i < this.to; i++) {
var map = this$1.maps[i],
rec = recoverables && recoverables[i];
if (rec != null && map.touches(pos, rec)) {
pos = map.recover(rec);
continue;
}
var result = map.mapResult(pos, assoc);
if (result.recover != null) {
var corr = this$1.getMirror(i);
if (corr != null && corr > i && corr < this$1.to) {
if (result.deleted) {
i = corr;
pos = this$1.maps[corr].recover(result.recover);
continue;
} else {
;
(recoverables || (recoverables = Object.create(null)))[corr] = result.recover;
}
}
}
if (result.deleted) {
deleted = true;
}
pos = result.pos;
}
return simple ? pos : new MapResult(pos, deleted);
};
exports.Mapping = Mapping;
return module.exports;
});
$__System.registerDynamic("3c", ["3", "39", "3d"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var ref = $__require('3');
var Slice = ref.Slice;
var ref$1 = $__require('39');
var Step = ref$1.Step;
var StepResult = ref$1.StepResult;
var ref$2 = $__require('3d');
var StepMap = ref$2.StepMap;
var ReplaceStep = (function(Step) {
function ReplaceStep(from, to, slice, structure) {
Step.call(this);
this.from = from;
this.to = to;
this.slice = slice;
this.structure = !!structure;
}
if (Step)
ReplaceStep.__proto__ = Step;
ReplaceStep.prototype = Object.create(Step && Step.prototype);
ReplaceStep.prototype.constructor = ReplaceStep;
ReplaceStep.prototype.apply = function apply(doc) {
if (this.structure && contentBetween(doc, this.from, this.to)) {
return StepResult.fail("Structure replace would overwrite content");
}
return StepResult.fromReplace(doc, this.from, this.to, this.slice);
};
ReplaceStep.prototype.getMap = function getMap() {
return new StepMap([this.from, this.to - this.from, this.slice.size]);
};
ReplaceStep.prototype.invert = function invert(doc) {
return new ReplaceStep(this.from, this.from + this.slice.size, doc.slice(this.from, this.to));
};
ReplaceStep.prototype.map = function map(mapping) {
var from = mapping.mapResult(this.from, 1),
to = mapping.mapResult(this.to, -1);
if (from.deleted && to.deleted) {
return null;
}
return new ReplaceStep(from.pos, Math.max(from.pos, to.pos), this.slice);
};
ReplaceStep.prototype.merge = function merge(other) {
if (!(other instanceof ReplaceStep) || other.structure != this.structure) {
return null;
}
if (this.from + this.slice.size == other.from && !this.slice.openRight && !other.slice.openLeft) {
var slice = this.slice.size + other.slice.size == 0 ? Slice.empty : new Slice(this.slice.content.append(other.slice.content), this.slice.openLeft, other.slice.openRight);
return new ReplaceStep(this.from, this.to + (other.to - other.from), slice, this.structure);
} else if (other.to == this.from && !this.slice.openLeft && !other.slice.openRight) {
var slice$1 = this.slice.size + other.slice.size == 0 ? Slice.empty : new Slice(other.slice.content.append(this.slice.content), other.slice.openLeft, this.slice.openRight);
return new ReplaceStep(other.from, this.to, slice$1, this.structure);
} else {
return null;
}
};
ReplaceStep.prototype.toJSON = function toJSON() {
var json = {
stepType: "replace",
from: this.from,
to: this.to
};
if (this.slice.size) {
json.slice = this.slice.toJSON();
}
if (this.structure) {
json.structure = true;
}
return json;
};
ReplaceStep.fromJSON = function fromJSON(schema, json) {
return new ReplaceStep(json.from, json.to, Slice.fromJSON(schema, json.slice), !!json.structure);
};
return ReplaceStep;
}(Step));
exports.ReplaceStep = ReplaceStep;
Step.jsonID("replace", ReplaceStep);
var ReplaceAroundStep = (function(Step) {
function ReplaceAroundStep(from, to, gapFrom, gapTo, slice, insert, structure) {
Step.call(this);
this.from = from;
this.to = to;
this.gapFrom = gapFrom;
this.gapTo = gapTo;
this.slice = slice;
this.insert = insert;
this.structure = !!structure;
}
if (Step)
ReplaceAroundStep.__proto__ = Step;
ReplaceAroundStep.prototype = Object.create(Step && Step.prototype);
ReplaceAroundStep.prototype.constructor = ReplaceAroundStep;
ReplaceAroundStep.prototype.apply = function apply(doc) {
if (this.structure && (contentBetween(doc, this.from, this.gapFrom) || contentBetween(doc, this.gapTo, this.to))) {
return StepResult.fail("Structure gap-replace would overwrite content");
}
var gap = doc.slice(this.gapFrom, this.gapTo);
if (gap.openLeft || gap.openRight) {
return StepResult.fail("Gap is not a flat range");
}
var inserted = this.slice.insertAt(this.insert, gap.content);
if (!inserted) {
return StepResult.fail("Content does not fit in gap");
}
return StepResult.fromReplace(doc, this.from, this.to, inserted);
};
ReplaceAroundStep.prototype.getMap = function getMap() {
return new StepMap([this.from, this.gapFrom - this.from, this.insert, this.gapTo, this.to - this.gapTo, this.slice.size - this.insert]);
};
ReplaceAroundStep.prototype.invert = function invert(doc) {
var gap = this.gapTo - this.gapFrom;
return new ReplaceAroundStep(this.from, this.from + this.slice.size + gap, this.from + this.insert, this.from + this.insert + gap, doc.slice(this.from, this.to).removeBetween(this.gapFrom - this.from, this.gapTo - this.from), this.gapFrom - this.from, this.structure);
};
ReplaceAroundStep.prototype.map = function map(mapping) {
var from = mapping.mapResult(this.from, 1),
to = mapping.mapResult(this.to, -1);
var gapFrom = mapping.map(this.gapFrom, -1),
gapTo = mapping.map(this.gapTo, 1);
if ((from.deleted && to.deleted) || gapFrom < from.pos || gapTo > to.pos) {
return null;
}
return new ReplaceAroundStep(from.pos, to.pos, gapFrom, gapTo, this.slice, this.insert, this.structure);
};
ReplaceAroundStep.toJSON = function toJSON() {
var json = {
stepType: "replaceAround",
from: this.from,
to: this.to,
gapFrom: this.gapFrom,
gapTo: this.gapTo,
slice: this.slice.toJSON()
};
if (this.structure) {
json.structure = true;
}
return true;
};
ReplaceAroundStep.fromJSON = function fromJSON(schema, json) {
return new ReplaceAroundStep(json.from, json.to, json.gapFrom, json.gapTo, Slice.fromJSON(schema, json.slice), json.insert, !!json.structure);
};
return ReplaceAroundStep;
}(Step));
exports.ReplaceAroundStep = ReplaceAroundStep;
Step.jsonID("replaceAround", ReplaceAroundStep);
function contentBetween(doc, from, to) {
var $from = doc.resolve(from),
dist = to - from,
depth = $from.depth;
while (dist > 0 && depth > 0 && $from.indexAfter(depth) == $from.node(depth).childCount) {
depth--;
dist--;
}
if (dist > 0) {
var next = $from.node(depth).maybeChild($from.indexAfter(depth));
while (dist > 0) {
if (!next || next.isLeaf) {
return true;
}
next = next.firstChild;
dist--;
}
}
return false;
}
return module.exports;
});
$__System.registerDynamic("3e", ["3", "3b", "3c"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var ref = $__require('3');
var Slice = ref.Slice;
var Fragment = ref.Fragment;
var ref$1 = $__require('3b');
var Transform = ref$1.Transform;
var ref$2 = $__require('3c');
var ReplaceStep = ref$2.ReplaceStep;
var ReplaceAroundStep = ref$2.ReplaceAroundStep;
function canCut(node, start, end) {
return (start == 0 || node.canReplace(start, node.childCount)) && (end == node.childCount || node.canReplace(0, end));
}
function liftTarget(range) {
var parent = range.parent;
var content = parent.content.cutByIndex(range.startIndex, range.endIndex);
for (var depth = range.depth; ; --depth) {
var node = range.$from.node(depth),
index = range.$from.index(depth),
endIndex = range.$to.indexAfter(depth);
if (depth < range.depth && node.canReplace(index, endIndex, content)) {
return depth;
}
if (depth == 0 || !canCut(node, index, endIndex)) {
break;
}
}
}
exports.liftTarget = liftTarget;
Transform.prototype.lift = function(range, target) {
var $from = range.$from;
var $to = range.$to;
var depth = range.depth;
var gapStart = $from.before(depth + 1),
gapEnd = $to.after(depth + 1);
var start = gapStart,
end = gapEnd;
var before = Fragment.empty,
openLeft = 0;
for (var d = depth,
splitting = false; d > target; d--) {
if (splitting || $from.index(d) > 0) {
splitting = true;
before = Fragment.from($from.node(d).copy(before));
openLeft++;
} else {
start--;
}
}
var after = Fragment.empty,
openRight = 0;
for (var d$1 = depth,
splitting$1 = false; d$1 > target; d$1--) {
if (splitting$1 || $to.after(d$1 + 1) < $to.end(d$1)) {
splitting$1 = true;
after = Fragment.from($to.node(d$1).copy(after));
openRight++;
} else {
end++;
}
}
return this.step(new ReplaceAroundStep(start, end, gapStart, gapEnd, new Slice(before.append(after), openLeft, openRight), before.size - openLeft, true));
};
function findWrapping(range, nodeType, attrs, innerRange) {
if (innerRange === void 0)
innerRange = range;
var wrap = {
type: nodeType,
attrs: attrs
};
var around = findWrappingOutside(range, wrap);
var inner = around && findWrappingInside(innerRange, wrap);
if (!inner) {
return null;
}
return around.concat(wrap).concat(inner);
}
exports.findWrapping = findWrapping;
function findWrappingOutside(range, wrap) {
var parent = range.parent;
var startIndex = range.startIndex;
var endIndex = range.endIndex;
var around = parent.contentMatchAt(startIndex).findWrapping(wrap.type, wrap.attrs);
if (!around) {
return null;
}
var outer = around.length ? around[0] : wrap;
if (!parent.canReplaceWith(startIndex, endIndex, outer.type, outer.attrs)) {
return null;
}
return around;
}
function findWrappingInside(range, wrap) {
var parent = range.parent;
var startIndex = range.startIndex;
var endIndex = range.endIndex;
var inner = parent.child(startIndex);
var inside = wrap.type.contentExpr.start(wrap.attrs).findWrappingFor(inner);
if (!inside) {
return null;
}
var last = inside.length ? inside[inside.length - 1] : wrap;
var innerMatch = last.type.contentExpr.start(last.attrs);
for (var i = startIndex; i < endIndex; i++) {
innerMatch = innerMatch && innerMatch.matchNode(parent.child(i));
}
if (!innerMatch || !innerMatch.validEnd()) {
return null;
}
return inside;
}
Transform.prototype.wrap = function(range, wrappers) {
var content = Fragment.empty;
for (var i = wrappers.length - 1; i >= 0; i--) {
content = Fragment.from(wrappers[i].type.create(wrappers[i].attrs, content));
}
var start = range.start,
end = range.end;
return this.step(new ReplaceAroundStep(start, end, start, end, new Slice(content, 0, 0), wrappers.length, true));
};
Transform.prototype.setBlockType = function(from, to, type, attrs) {
var this$1 = this;
if (to === void 0)
to = from;
if (!type.isTextblock) {
throw new RangeError("Type given to setBlockType should be a textblock");
}
var mapFrom = this.steps.length;
this.doc.nodesBetween(from, to, function(node, pos) {
if (node.isTextblock && !node.hasMarkup(type, attrs)) {
this$1.clearNonMatching(this$1.mapping.slice(mapFrom).map(pos, 1), type.contentExpr.start(attrs));
var mapping = this$1.mapping.slice(mapFrom);
var startM = mapping.map(pos, 1),
endM = mapping.map(pos + node.nodeSize, 1);
this$1.step(new ReplaceAroundStep(startM, endM, startM + 1, endM - 1, new Slice(Fragment.from(type.create(attrs)), 0, 0), 1, true));
return false;
}
});
return this;
};
Transform.prototype.setNodeType = function(pos, type, attrs) {
var node = this.doc.nodeAt(pos);
if (!node) {
throw new RangeError("No node at given position");
}
if (!type) {
type = node.type;
}
if (node.isLeaf) {
return this.replaceWith(pos, pos + node.nodeSize, type.create(attrs, null, node.marks));
}
if (!type.validContent(node.content, attrs)) {
throw new RangeError("Invalid content for node type " + type.name);
}
return this.step(new ReplaceAroundStep(pos, pos + node.nodeSize, pos + 1, pos + node.nodeSize - 1, new Slice(Fragment.from(type.create(attrs)), 0, 0), 1, true));
};
function canSplit(doc, pos, depth, typesAfter) {
if (depth === void 0)
depth = 1;
var $pos = doc.resolve(pos),
base = $pos.depth - depth;
if (base < 0 || !$pos.parent.canReplace($pos.index(), $pos.parent.childCount) || !$pos.parent.canReplace(0, $pos.indexAfter())) {
return false;
}
for (var d = $pos.depth - 1,
i = depth - 1; d > base; d--, i--) {
var node = $pos.node(d),
index$1 = $pos.index(d);
var typeAfter = typesAfter && typesAfter[i];
if (!node.canReplace(0, index$1) || !node.canReplaceWith(index$1, node.childCount, typeAfter ? typeAfter.type : $pos.node(d + 1).type, typeAfter ? typeAfter.attrs : $pos.node(d + 1).attrs)) {
return false;
}
}
var index = $pos.indexAfter(base);
var baseType = typesAfter && typesAfter[0];
return $pos.node(base).canReplaceWith(index, index, baseType ? baseType.type : $pos.node(base + 1).type, baseType ? baseType.attrs : $pos.node(base + 1).attrs);
}
exports.canSplit = canSplit;
Transform.prototype.split = function(pos, depth, typesAfter) {
if (depth === void 0)
depth = 1;
var $pos = this.doc.resolve(pos),
before = Fragment.empty,
after = Fragment.empty;
for (var d = $pos.depth,
e = $pos.depth - depth,
i = depth - 1; d > e; d--, i--) {
before = Fragment.from($pos.node(d).copy(before));
var typeAfter = typesAfter && typesAfter[i];
after = Fragment.from(typeAfter ? typeAfter.type.create(typeAfter.attrs, after) : $pos.node(d).copy(after));
}
return this.step(new ReplaceStep(pos, pos, new Slice(before.append(after), depth, depth, true)));
};
function canJoin(doc, pos) {
var $pos = doc.resolve(pos),
index = $pos.index();
return joinable($pos.nodeBefore, $pos.nodeAfter) && $pos.parent.canReplace(index, index + 1);
}
exports.canJoin = canJoin;
function joinable(a, b) {
return a && b && !a.isLeaf && a.canAppend(b);
}
function joinPoint(doc, pos, dir) {
if (dir === void 0)
dir = -1;
var $pos = doc.resolve(pos);
for (var d = $pos.depth; ; d--) {
var before = (void 0),
after = (void 0);
if (d == $pos.depth) {
before = $pos.nodeBefore;
after = $pos.nodeAfter;
} else if (dir > 0) {
before = $pos.node(d + 1);
after = $pos.node(d).maybeChild($pos.index(d) + 1);
} else {
before = $pos.node(d).maybeChild($pos.index(d) - 1);
after = $pos.node(d + 1);
}
if (before && !before.isTextblock && joinable(before, after)) {
return pos;
}
if (d == 0) {
break;
}
pos = dir < 0 ? $pos.before(d) : $pos.after(d);
}
}
exports.joinPoint = joinPoint;
Transform.prototype.join = function(pos, depth) {
if (depth === void 0)
depth = 1;
var step = new ReplaceStep(pos - depth, pos + depth, Slice.empty, true);
return this.step(step);
};
function insertPoint(doc, pos, nodeType, attrs) {
var $pos = doc.resolve(pos);
if ($pos.parent.canReplaceWith($pos.index(), $pos.index(), nodeType, attrs)) {
return pos;
}
if ($pos.parentOffset == 0) {
for (var d = $pos.depth - 1; d >= 0; d--) {
var index = $pos.index(d);
if ($pos.node(d).canReplaceWith(index, index, nodeType, attrs)) {
return $pos.before(d + 1);
}
if (index > 0) {
return null;
}
}
}
if ($pos.parentOffset == $pos.parent.content.size) {
for (var d$1 = $pos.depth - 1; d$1 >= 0; d$1--) {
var index$1 = $pos.indexAfter(d$1);
if ($pos.node(d$1).canReplaceWith(index$1, index$1, nodeType, attrs)) {
return $pos.after(d$1 + 1);
}
if (index$1 < $pos.node(d$1).childCount) {
return null;
}
}
}
}
exports.insertPoint = insertPoint;
return module.exports;
});
$__System.registerDynamic("3f", ["3", "3c", "3b", "3e"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var ref = $__require('3');
var Fragment = ref.Fragment;
var Slice = ref.Slice;
var ref$1 = $__require('3c');
var ReplaceStep = ref$1.ReplaceStep;
var ReplaceAroundStep = ref$1.ReplaceAroundStep;
var ref$2 = $__require('3b');
var Transform = ref$2.Transform;
var ref$3 = $__require('3e');
var insertPoint = ref$3.insertPoint;
Transform.prototype.replaceRange = function(from, to, slice) {
var this$1 = this;
if (!slice.size) {
return this.deleteRange(from, to);
}
var $from = this.doc.resolve(from);
if (fitsTrivially($from, this.doc.resolve(to), slice)) {
return this.step(new ReplaceStep(from, to, slice));
}
var canExpand = coveredDepths($from, this.doc.resolve(to)),
preferredExpand = 0;
canExpand.unshift($from.depth + 1);
for (var d = $from.depth; d > 0; d--) {
if ($from.node(d).type.spec.defining) {
break;
}
var found = canExpand.indexOf(d, 1);
if (found > -1) {
preferredExpand = found;
}
}
var leftNodes = [],
preferredDepth = slice.openLeft;
for (var content = slice.content,
i = 0; ; i++) {
var node = content.firstChild;
leftNodes.push(node);
if (i == slice.openLeft) {
break;
}
content = node.content;
}
if (preferredDepth > 0 && leftNodes[preferredDepth - 1].type.spec.defining) {
preferredDepth -= 1;
} else if (preferredDepth >= 2 && leftNodes[preferredDepth - 1].isTextblock && leftNodes[preferredDepth - 2].type.spec.defining) {
preferredDepth -= 2;
}
for (var j = slice.openLeft; j >= 0; j--) {
var openDepth = (j + preferredDepth + 1) % (slice.openLeft + 1);
var insert = leftNodes[openDepth];
if (!insert) {
continue;
}
for (var i$1 = 0; i$1 < canExpand.length; i$1++) {
var expandDepth = canExpand[(i$1 + preferredExpand) % canExpand.length];
var parent = $from.node(expandDepth - 1),
index = $from.index(expandDepth - 1);
if (parent.canReplaceWith(index, index, insert.type, insert.attrs, insert.marks)) {
return this$1.replace($from.before(expandDepth), expandDepth > $from.depth ? to : $from.after(expandDepth), new Slice(closeFragment(slice.content, 0, slice.openLeft, openDepth), openDepth, slice.openRight));
}
}
}
return this.replace(from, to, slice);
};
function closeFragment(fragment, depth, oldOpen, newOpen, parent) {
if (depth < oldOpen) {
var first = fragment.firstChild;
fragment = fragment.replaceChild(0, first.copy(closeFragment(first.content, depth + 1, oldOpen, newOpen, first)));
}
if (depth > newOpen) {
fragment = parent.contentMatchAt(0).fillBefore(fragment).append(fragment);
}
return fragment;
}
Transform.prototype.replaceRangeWith = function(from, to, node) {
if (!node.isInline && from == to && this.doc.resolve(from).parent.content.size) {
var point = insertPoint(this.doc, from, node.type, node.attrs);
if (point != null) {
from = to = point;
}
}
return this.replaceRange(from, to, new Slice(Fragment.from(node), 0, 0));
};
Transform.prototype.deleteRange = function(from, to) {
var $from = this.doc.resolve(from);
var covered = coveredDepths($from, this.doc.resolve(to)),
grown = false;
for (var i = 0; i < covered.length; i++) {
if ($from.node(covered[i]).contentMatchAt(0).validEnd()) {
from = $from.start(covered[i]);
to = $from.end(covered[i]);
grown = true;
break;
}
}
if (!grown && covered.length) {
var depth = covered[covered.length - 1];
if ($from.node(depth - 1).canReplace($from.index(depth - 1), $from.indexAfter(depth - 1))) {
from = $from.before(depth);
to = $from.after(depth);
}
}
return this.delete(from, to);
};
function coveredDepths($from, $to) {
var result = [];
for (var i = 0; i < $from.depth; i++) {
var depth = $from.depth - i;
if ($from.pos - i > $from.start(depth)) {
break;
}
if ($to.depth >= depth && $to.pos + ($to.depth - depth) == $from.end(depth)) {
result.push(depth);
}
}
return result;
}
Transform.prototype.delete = function(from, to) {
return this.replace(from, to, Slice.empty);
};
function replaceStep(doc, from, to, slice) {
if (to === void 0)
to = from;
if (slice === void 0)
slice = Slice.empty;
if (from == to && !slice.size) {
return null;
}
var $from = doc.resolve(from),
$to = doc.resolve(to);
if (fitsTrivially($from, $to, slice)) {
return new ReplaceStep(from, to, slice);
}
var placed = placeSlice($from, slice);
var fittedLeft = fitLeft($from, placed);
var fitted = fitRight($from, $to, fittedLeft);
if (!fitted) {
return null;
}
if (fittedLeft.size != fitted.size && canMoveText($from, $to, fittedLeft)) {
var d = $to.depth,
after = $to.after(d);
while (d > 1 && after == $to.end(--d)) {
++after;
}
var fittedAfter = fitRight($from, doc.resolve(after), fittedLeft);
if (fittedAfter) {
return new ReplaceAroundStep(from, after, to, $to.end(), fittedAfter, fittedLeft.size);
}
}
return new ReplaceStep(from, to, fitted);
}
exports.replaceStep = replaceStep;
Transform.prototype.replace = function(from, to, slice) {
if (to === void 0)
to = from;
if (slice === void 0)
slice = Slice.empty;
var step = replaceStep(this.doc, from, to, slice);
if (step) {
this.step(step);
}
return this;
};
Transform.prototype.replaceWith = function(from, to, content) {
return this.replace(from, to, new Slice(Fragment.from(content), 0, 0));
};
Transform.prototype.insert = function(pos, content) {
return this.replaceWith(pos, pos, content);
};
function fitLeftInner($from, depth, placed, placedBelow) {
var content = Fragment.empty,
openRight = 0,
placedHere = placed[depth];
if ($from.depth > depth) {
var inner = fitLeftInner($from, depth + 1, placed, placedBelow || placedHere);
openRight = inner.openRight + 1;
content = Fragment.from($from.node(depth + 1).copy(inner.content));
}
if (placedHere) {
content = content.append(placedHere.content);
openRight = placedHere.openRight;
}
if (placedBelow) {
content = content.append($from.node(depth).contentMatchAt($from.indexAfter(depth)).fillBefore(Fragment.empty, true));
openRight = 0;
}
return {
content: content,
openRight: openRight
};
}
function fitLeft($from, placed) {
var ref = fitLeftInner($from, 0, placed, false);
var content = ref.content;
var openRight = ref.openRight;
return new Slice(content, $from.depth, openRight || 0);
}
function fitRightJoin(content, parent, $from, $to, depth, openLeft, openRight) {
var match,
count = content.childCount,
matchCount = count - (openRight > 0 ? 1 : 0);
if (openLeft < 0) {
match = parent.contentMatchAt(matchCount);
} else if (count == 1 && openRight > 0) {
match = $from.node(depth).contentMatchAt(openLeft ? $from.index(depth) : $from.indexAfter(depth));
} else {
match = $from.node(depth).contentMatchAt($from.indexAfter(depth)).matchFragment(content, count > 0 && openLeft ? 1 : 0, matchCount);
}
var toNode = $to.node(depth);
if (openRight > 0 && depth < $to.depth) {
var after = toNode.content.cutByIndex($to.indexAfter(depth)).addToStart(content.lastChild);
var joinable$1 = match.fillBefore(after, true);
if (joinable$1 && joinable$1.size && openLeft > 0 && count == 1) {
joinable$1 = null;
}
if (joinable$1) {
var inner = fitRightJoin(content.lastChild.content, content.lastChild, $from, $to, depth + 1, count == 1 ? openLeft - 1 : -1, openRight - 1);
if (inner) {
var last = content.lastChild.copy(inner);
if (joinable$1.size) {
return content.cutByIndex(0, count - 1).append(joinable$1).addToEnd(last);
} else {
return content.replaceChild(count - 1, last);
}
}
}
}
if (openRight > 0) {
match = match.matchNode(count == 1 && openLeft > 0 ? $from.node(depth + 1) : content.lastChild);
}
var toIndex = $to.index(depth);
if (toIndex == toNode.childCount && !toNode.type.compatibleContent(parent.type)) {
return null;
}
var joinable = match.fillBefore(toNode.content, true, toIndex);
if (!joinable) {
return null;
}
if (openRight > 0) {
var closed = fitRightClosed(content.lastChild, openRight - 1, $from, depth + 1, count == 1 ? openLeft - 1 : -1);
content = content.replaceChild(count - 1, closed);
}
content = content.append(joinable);
if ($to.depth > depth) {
content = content.addToEnd(fitRightSeparate($to, depth + 1));
}
return content;
}
function fitRightClosed(node, openRight, $from, depth, openLeft) {
var match,
content = node.content,
count = content.childCount;
if (openLeft >= 0) {
match = $from.node(depth).contentMatchAt($from.indexAfter(depth)).matchFragment(content, openLeft > 0 ? 1 : 0, count);
} else {
match = node.contentMatchAt(count);
}
if (openRight > 0) {
var closed = fitRightClosed(content.lastChild, openRight - 1, $from, depth + 1, count == 1 ? openLeft - 1 : -1);
content = content.replaceChild(count - 1, closed);
}
return node.copy(content.append(match.fillBefore(Fragment.empty, true)));
}
function fitRightSeparate($to, depth) {
var node = $to.node(depth);
var fill = node.contentMatchAt(0).fillBefore(node.content, true, $to.index(depth));
if ($to.depth > depth) {
fill = fill.addToEnd(fitRightSeparate($to, depth + 1));
}
return node.copy(fill);
}
function normalizeSlice(content, openLeft, openRight) {
while (openLeft > 0 && openRight > 0 && content.childCount == 1) {
content = content.firstChild.content;
openLeft--;
openRight--;
}
return new Slice(content, openLeft, openRight);
}
function fitRight($from, $to, slice) {
var fitted = fitRightJoin(slice.content, $from.node(0), $from, $to, 0, slice.openLeft, slice.openRight);
if (!fitted) {
return null;
}
return normalizeSlice(fitted, slice.openLeft, $to.depth);
}
function fitsTrivially($from, $to, slice) {
return !slice.openLeft && !slice.openRight && $from.start() == $to.start() && $from.parent.canReplace($from.index(), $to.index(), slice.content);
}
function canMoveText($from, $to, slice) {
if (!$to.parent.isTextblock) {
return false;
}
var match;
if (!slice.openRight) {
var parent = $from.node($from.depth - (slice.openLeft - slice.openRight));
if (!parent.isTextblock) {
return false;
}
match = parent.contentMatchAt(parent.childCount);
if (slice.size) {
match = match.matchFragment(slice.content, slice.openLeft ? 1 : 0);
}
} else {
var parent$1 = nodeRight(slice.content, slice.openRight);
if (!parent$1.isTextblock) {
return false;
}
match = parent$1.contentMatchAt(parent$1.childCount);
}
match = match.matchFragment($to.parent.content, $to.index());
return match && match.validEnd();
}
function nodeLeft(content, depth) {
for (var i = 1; i < depth; i++) {
content = content.firstChild.content;
}
return content.firstChild;
}
function nodeRight(content, depth) {
for (var i = 1; i < depth; i++) {
content = content.lastChild.content;
}
return content.lastChild;
}
function placeSlice($from, slice) {
var dFrom = $from.depth,
unplaced = null;
var placed = [],
parents = null;
for (var dSlice = slice.openLeft; ; --dSlice) {
var curType = (void 0),
curAttrs = (void 0),
curFragment = (void 0);
if (dSlice >= 0) {
if (dSlice > 0) {
;
var assign;
((assign = nodeLeft(slice.content, dSlice), curType = assign.type, curAttrs = assign.attrs, curFragment = assign.content));
} else if (dSlice == 0) {
curFragment = slice.content;
}
if (dSlice < slice.openLeft) {
curFragment = curFragment.cut(curFragment.firstChild.nodeSize);
}
} else {
curFragment = Fragment.empty;
var parent = parents[parents.length + dSlice - 1];
curType = parent.type;
curAttrs = parent.attrs;
}
if (unplaced) {
curFragment = curFragment.addToStart(unplaced);
}
if (curFragment.size == 0 && dSlice <= 0) {
break;
}
var found = findPlacement(curFragment, $from, dFrom, placed);
if (found) {
if (found.fragment.size > 0) {
placed[found.depth] = {
content: found.fragment,
openRight: endOfContent(slice, dSlice) ? slice.openRight - dSlice : 0,
depth: found.depth
};
}
if (dSlice <= 0) {
break;
}
unplaced = null;
dFrom = found.depth - (curType == $from.node(found.depth).type ? 1 : 0);
} else {
if (dSlice == 0) {
var top = $from.node(0);
var wrap = top.contentMatchAt($from.index(0)).findWrappingFor(curFragment.firstChild);
if (!wrap || wrap.length == 0) {
break;
}
var last = wrap[wrap.length - 1];
if (!last.type.contentExpr.matches(last.attrs, curFragment)) {
break;
}
parents = [{
type: top.type,
attrs: top.attrs
}].concat(wrap);
;
var assign$1;
((assign$1 = last, curType = assign$1.type, curAttrs = assign$1.attrs));
}
if (curFragment.size) {
curFragment = curType.contentExpr.start(curAttrs).fillBefore(curFragment, true).append(curFragment);
unplaced = curType.create(curAttrs, curFragment);
} else {
unplaced = null;
}
}
}
return placed;
}
function endOfContent(slice, depth) {
for (var i = 0,
content = slice.content; i < depth; i++) {
if (content.childCount > 1) {
return false;
}
content = content.firstChild.content;
}
return true;
}
function findPlacement(fragment, $from, start, placed) {
var hasMarks = false;
for (var i = 0; i < fragment.childCount; i++) {
if (fragment.child(i).marks.length) {
hasMarks = true;
}
}
for (var d = start; d >= 0; d--) {
var startMatch = $from.node(d).contentMatchAt($from.indexAfter(d));
var existing = placed[d];
if (existing) {
startMatch = startMatch.matchFragment(existing.content);
}
var match = startMatch.fillBefore(fragment);
if (match) {
return {
depth: d,
fragment: (existing ? existing.content.append(match) : match).append(fragment)
};
}
if (hasMarks) {
var stripped = matchStrippingMarks(startMatch, fragment);
if (stripped) {
return {
depth: d,
fragment: existing ? existing.content.append(stripped) : stripped
};
}
}
}
}
function matchStrippingMarks(match, fragment) {
var newNodes = [];
for (var i = 0; i < fragment.childCount; i++) {
var node = fragment.child(i),
stripped = node.mark(node.marks.filter(function(m) {
return match.allowsMark(m.type);
}));
match = match.matchNode(stripped);
if (!match) {
return null;
}
newNodes.push(stripped);
}
return Fragment.from(newNodes);
}
return module.exports;
});
$__System.registerDynamic("40", ["3b", "39", "3e", "3d", "38", "3c", "3a", "3f"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
;
var assign;
((assign = $__require('3b'), exports.Transform = assign.Transform, exports.TransformError = assign.TransformError));
;
var assign$1;
((assign$1 = $__require('39'), exports.Step = assign$1.Step, exports.StepResult = assign$1.StepResult));
;
var assign$2;
((assign$2 = $__require('3e'), exports.joinPoint = assign$2.joinPoint, exports.canJoin = assign$2.canJoin, exports.canSplit = assign$2.canSplit, exports.insertPoint = assign$2.insertPoint, exports.liftTarget = assign$2.liftTarget, exports.findWrapping = assign$2.findWrapping));
;
var assign$3;
((assign$3 = $__require('3d'), exports.StepMap = assign$3.StepMap, exports.MapResult = assign$3.MapResult, exports.Mapping = assign$3.Mapping));
;
var assign$4;
((assign$4 = $__require('38'), exports.AddMarkStep = assign$4.AddMarkStep, exports.RemoveMarkStep = assign$4.RemoveMarkStep));
;
var assign$5;
((assign$5 = $__require('3c'), exports.ReplaceStep = assign$5.ReplaceStep, exports.ReplaceAroundStep = assign$5.ReplaceAroundStep));
$__require('3a');
;
var assign$6;
((assign$6 = $__require('3f'), exports.replaceStep = assign$6.replaceStep));
return module.exports;
});
$__System.registerDynamic("9", ["40"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
module.exports = $__require('40');
return module.exports;
});
$__System.registerDynamic("41", [], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
function OrderedMap(content) {
this.content = content;
}
OrderedMap.prototype = {
constructor: OrderedMap,
find: function(key) {
for (var i = 0; i < this.content.length; i += 2)
if (this.content[i] === key)
return i;
return -1;
},
get: function(key) {
var found = this.find(key);
return found == -1 ? undefined : this.content[found + 1];
},
update: function(key, value, newKey) {
var self = newKey && newKey != key ? this.remove(newKey) : this;
var found = self.find(key),
content = self.content.slice();
if (found == -1) {
content.push(newKey || key, value);
} else {
content[found + 1] = value;
if (newKey)
content[found] = newKey;
}
return new OrderedMap(content);
},
remove: function(key) {
var found = this.find(key);
if (found == -1)
return this;
var content = this.content.slice();
content.splice(found, 2);
return new OrderedMap(content);
},
addToStart: function(key, value) {
return new OrderedMap([key, value].concat(this.remove(key).content));
},
addToEnd: function(key, value) {
var content = this.remove(key).content.slice();
content.push(key, value);
return new OrderedMap(content);
},
addBefore: function(place, key, value) {
var without = this.remove(key),
content = without.content.slice();
var found = without.find(place);
content.splice(found == -1 ? content.length : found, 0, key, value);
return new OrderedMap(content);
},
forEach: function(f) {
for (var i = 0; i < this.content.length; i += 2)
f(this.content[i], this.content[i + 1]);
},
prepend: function(map) {
map = OrderedMap.from(map);
if (!map.size)
return this;
return new OrderedMap(map.content.concat(this.subtract(map).content));
},
append: function(map) {
map = OrderedMap.from(map);
if (!map.size)
return this;
return new OrderedMap(this.subtract(map).content.concat(map.content));
},
subtract: function(map) {
var result = this;
map = OrderedMap.from(map);
for (var i = 0; i < map.content.length; i += 2)
result = result.remove(map.content[i]);
return result;
},
get size() {
return this.content.length >> 1;
}
};
OrderedMap.from = function(value) {
if (value instanceof OrderedMap)
return value;
var content = [];
if (value)
for (var prop in value)
content.push(prop, value[prop]);
return new OrderedMap(content);
};
module.exports = OrderedMap;
return module.exports;
});
$__System.registerDynamic("42", ["41"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
module.exports = $__require('41');
return module.exports;
});
$__System.registerDynamic("43", ["44"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var ref = $__require('44');
var Mark = ref.Mark;
var ResolvedPos = function(pos, path, parentOffset) {
this.pos = pos;
this.path = path;
this.depth = path.length / 3 - 1;
this.parentOffset = parentOffset;
};
var prototypeAccessors = {
parent: {},
textOffset: {},
nodeAfter: {},
nodeBefore: {}
};
ResolvedPos.prototype.resolveDepth = function(val) {
if (val == null) {
return this.depth;
}
if (val < 0) {
return this.depth + val;
}
return val;
};
prototypeAccessors.parent.get = function() {
return this.node(this.depth);
};
ResolvedPos.prototype.node = function(depth) {
return this.path[this.resolveDepth(depth) * 3];
};
ResolvedPos.prototype.index = function(depth) {
return this.path[this.resolveDepth(depth) * 3 + 1];
};
ResolvedPos.prototype.indexAfter = function(depth) {
depth = this.resolveDepth(depth);
return this.index(depth) + (depth == this.depth && !this.textOffset ? 0 : 1);
};
ResolvedPos.prototype.start = function(depth) {
depth = this.resolveDepth(depth);
return depth == 0 ? 0 : this.path[depth * 3 - 1] + 1;
};
ResolvedPos.prototype.end = function(depth) {
depth = this.resolveDepth(depth);
return this.start(depth) + this.node(depth).content.size;
};
ResolvedPos.prototype.before = function(depth) {
depth = this.resolveDepth(depth);
if (!depth) {
throw new RangeError("There is no position before the top-level node");
}
return depth == this.depth + 1 ? this.pos : this.path[depth * 3 - 1];
};
ResolvedPos.prototype.after = function(depth) {
depth = this.resolveDepth(depth);
if (!depth) {
throw new RangeError("There is no position after the top-level node");
}
return depth == this.depth + 1 ? this.pos : this.path[depth * 3 - 1] + this.path[depth * 3].nodeSize;
};
prototypeAccessors.textOffset.get = function() {
return this.pos - this.path[this.path.length - 1];
};
prototypeAccessors.nodeAfter.get = function() {
var parent = this.parent,
index = this.index(this.depth);
if (index == parent.childCount) {
return null;
}
var dOff = this.pos - this.path[this.path.length - 1],
child = parent.child(index);
return dOff ? parent.child(index).cut(dOff) : child;
};
prototypeAccessors.nodeBefore.get = function() {
var index = this.index(this.depth);
var dOff = this.pos - this.path[this.path.length - 1];
if (dOff) {
return this.parent.child(index).cut(0, dOff);
}
return index == 0 ? null : this.parent.child(index - 1);
};
ResolvedPos.prototype.marks = function(after) {
var parent = this.parent,
index = this.index();
if (parent.content.size == 0) {
return Mark.none;
}
if ((after && index < parent.childCount) || index == 0 || this.textOffset) {
return parent.child(index).marks;
}
var marks = parent.child(index - 1).marks;
for (var i = 0; i < marks.length; i++) {
if (marks[i].type.spec.inclusiveRight === false) {
marks = marks[i--].removeFromSet(marks);
}
}
return marks;
};
ResolvedPos.prototype.sharedDepth = function(pos) {
var this$1 = this;
for (var depth = this.depth; depth > 0; depth--) {
if (this$1.start(depth) <= pos && this$1.end(depth) >= pos) {
return depth;
}
}
return 0;
};
ResolvedPos.prototype.blockRange = function(other, pred) {
var this$1 = this;
if (other === void 0)
other = this;
if (other.pos < this.pos) {
return other.blockRange(this);
}
for (var d = this.depth - (this.parent.isTextblock || this.pos == other.pos ? 1 : 0); d >= 0; d--) {
if (other.pos <= this$1.end(d) && (!pred || pred(this$1.node(d)))) {
return new NodeRange(this$1, other, d);
}
}
};
ResolvedPos.prototype.sameParent = function(other) {
return this.pos - this.parentOffset == other.pos - other.parentOffset;
};
ResolvedPos.prototype.toString = function() {
var this$1 = this;
var str = "";
for (var i = 1; i <= this.depth; i++) {
str += (str ? "/" : "") + this$1.node(i).type.name + "_" + this$1.index(i - 1);
}
return str + ":" + this.parentOffset;
};
ResolvedPos.resolve = function(doc, pos) {
if (!(pos >= 0 && pos <= doc.content.size)) {
throw new RangeError("Position " + pos + " out of range");
}
var path = [];
var start = 0,
parentOffset = pos;
for (var node = doc; ; ) {
var ref = node.content.findIndex(parentOffset);
var index = ref.index;
var offset = ref.offset;
var rem = parentOffset - offset;
path.push(node, index, start + offset);
if (!rem) {
break;
}
node = node.child(index);
if (node.isText) {
break;
}
parentOffset = rem - 1;
start += offset + 1;
}
return new ResolvedPos(pos, path, parentOffset);
};
ResolvedPos.resolveCached = function(doc, pos) {
for (var i = 0; i < resolveCache.length; i++) {
var cached = resolveCache[i];
if (cached.pos == pos && cached.node(0) == doc) {
return cached;
}
}
var result = resolveCache[resolveCachePos] = ResolvedPos.resolve(doc, pos);
resolveCachePos = (resolveCachePos + 1) % resolveCacheSize;
return result;
};
Object.defineProperties(ResolvedPos.prototype, prototypeAccessors);
exports.ResolvedPos = ResolvedPos;
var resolveCache = [],
resolveCachePos = 0,
resolveCacheSize = 6;
var NodeRange = function($from, $to, depth) {
this.$from = $from;
this.$to = $to;
this.depth = depth;
};
var prototypeAccessors$1 = {
start: {},
end: {},
parent: {},
startIndex: {},
endIndex: {}
};
prototypeAccessors$1.start.get = function() {
return this.$from.before(this.depth + 1);
};
prototypeAccessors$1.end.get = function() {
return this.$to.after(this.depth + 1);
};
prototypeAccessors$1.parent.get = function() {
return this.$from.node(this.depth);
};
prototypeAccessors$1.startIndex.get = function() {
return this.$from.index(this.depth);
};
prototypeAccessors$1.endIndex.get = function() {
return this.$to.indexAfter(this.depth);
};
Object.defineProperties(NodeRange.prototype, prototypeAccessors$1);
exports.NodeRange = NodeRange;
return module.exports;
});
$__System.registerDynamic("45", ["46", "44", "47", "43", "48"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var ref = $__require('46');
var Fragment = ref.Fragment;
var ref$1 = $__require('44');
var Mark = ref$1.Mark;
var ref$2 = $__require('47');
var Slice = ref$2.Slice;
var replace = ref$2.replace;
var ref$3 = $__require('43');
var ResolvedPos = ref$3.ResolvedPos;
var ref$4 = $__require('48');
var compareDeep = ref$4.compareDeep;
var emptyAttrs = Object.create(null);
var warnedAboutMarksAt = false;
var Node = function(type, attrs, content, marks) {
this.type = type;
this.attrs = attrs;
this.content = content || Fragment.empty;
this.marks = marks || Mark.none;
};
var prototypeAccessors = {
nodeSize: {},
childCount: {},
textContent: {},
firstChild: {},
lastChild: {},
isBlock: {},
isTextblock: {},
isInline: {},
isText: {},
isLeaf: {}
};
prototypeAccessors.nodeSize.get = function() {
return this.isLeaf ? 1 : 2 + this.content.size;
};
prototypeAccessors.childCount.get = function() {
return this.content.childCount;
};
Node.prototype.child = function(index) {
return this.content.child(index);
};
Node.prototype.maybeChild = function(index) {
return this.content.maybeChild(index);
};
Node.prototype.forEach = function(f) {
this.content.forEach(f);
};
Node.prototype.nodesBetween = function(from, to, f, pos) {
if (pos === void 0)
pos = 0;
this.content.nodesBetween(from, to, f, pos, this);
};
Node.prototype.descendants = function(f) {
this.nodesBetween(0, this.content.size, f);
};
prototypeAccessors.textContent.get = function() {
return this.textBetween(0, this.content.size, "");
};
Node.prototype.textBetween = function(from, to, blockSeparator, leafText) {
return this.content.textBetween(from, to, blockSeparator, leafText);
};
prototypeAccessors.firstChild.get = function() {
return this.content.firstChild;
};
prototypeAccessors.lastChild.get = function() {
return this.content.lastChild;
};
Node.prototype.eq = function(other) {
return this == other || (this.sameMarkup(other) && this.content.eq(other.content));
};
Node.prototype.sameMarkup = function(other) {
return this.hasMarkup(other.type, other.attrs, other.marks);
};
Node.prototype.hasMarkup = function(type, attrs, marks) {
return this.type == type && compareDeep(this.attrs, attrs || type.defaultAttrs || emptyAttrs) && Mark.sameSet(this.marks, marks || Mark.none);
};
Node.prototype.copy = function(content) {
if (content === void 0)
content = null;
if (content == this.content) {
return this;
}
return new this.constructor(this.type, this.attrs, content, this.marks);
};
Node.prototype.mark = function(marks) {
return marks == this.marks ? this : new this.constructor(this.type, this.attrs, this.content, marks);
};
Node.prototype.cut = function(from, to) {
if (from == 0 && to == this.content.size) {
return this;
}
return this.copy(this.content.cut(from, to));
};
Node.prototype.slice = function(from, to, includeParents) {
if (to === void 0)
to = this.content.size;
if (includeParents === void 0)
includeParents = false;
if (from == to) {
return Slice.empty;
}
var $from = this.resolve(from),
$to = this.resolve(to);
var depth = includeParents ? 0 : $from.sharedDepth(to);
var start = $from.start(depth),
node = $from.node(depth);
var content = node.content.cut($from.pos - start, $to.pos - start);
return new Slice(content, $from.depth - depth, $to.depth - depth);
};
Node.prototype.replace = function(from, to, slice) {
return replace(this.resolve(from), this.resolve(to), slice);
};
Node.prototype.nodeAt = function(pos) {
for (var node = this; ; ) {
var ref = node.content.findIndex(pos);
var index = ref.index;
var offset = ref.offset;
node = node.maybeChild(index);
if (!node) {
return null;
}
if (offset == pos || node.isText) {
return node;
}
pos -= offset + 1;
}
};
Node.prototype.childAfter = function(pos) {
var ref = this.content.findIndex(pos);
var index = ref.index;
var offset = ref.offset;
return {
node: this.content.maybeChild(index),
index: index,
offset: offset
};
};
Node.prototype.childBefore = function(pos) {
if (pos == 0) {
return {
node: null,
index: 0,
offset: 0
};
}
var ref = this.content.findIndex(pos);
var index = ref.index;
var offset = ref.offset;
if (offset < pos) {
return {
node: this.content.child(index),
index: index,
offset: offset
};
}
var node = this.content.child(index - 1);
return {
node: node,
index: index - 1,
offset: offset - node.nodeSize
};
};
Node.prototype.resolve = function(pos) {
return ResolvedPos.resolveCached(this, pos);
};
Node.prototype.resolveNoCache = function(pos) {
return ResolvedPos.resolve(this, pos);
};
Node.prototype.marksAt = function(pos, useAfter) {
if (!warnedAboutMarksAt && typeof console != "undefined" && console.warn) {
warnedAboutMarksAt = true;
console.warn("Node.marksAt is deprecated. Use ResolvedPos.marks instead.");
}
return this.resolve(pos).marks(useAfter);
};
Node.prototype.rangeHasMark = function(from, to, type) {
var found = false;
this.nodesBetween(from, to, function(node) {
if (type.isInSet(node.marks)) {
found = true;
}
return !found;
});
return found;
};
prototypeAccessors.isBlock.get = function() {
return this.type.isBlock;
};
prototypeAccessors.isTextblock.get = function() {
return this.type.isTextblock;
};
prototypeAccessors.isInline.get = function() {
return this.type.isInline;
};
prototypeAccessors.isText.get = function() {
return this.type.isText;
};
prototypeAccessors.isLeaf.get = function() {
return this.type.isLeaf;
};
Node.prototype.toString = function() {
var name = this.type.name;
if (this.content.size) {
name += "(" + this.content.toStringInner() + ")";
}
return wrapMarks(this.marks, name);
};
Node.prototype.contentMatchAt = function(index) {
return this.type.contentExpr.getMatchAt(this.attrs, this.content, index);
};
Node.prototype.canReplace = function(from, to, replacement, start, end) {
return this.type.contentExpr.checkReplace(this.attrs, this.content, from, to, replacement, start, end);
};
Node.prototype.canReplaceWith = function(from, to, type, attrs, marks) {
return this.type.contentExpr.checkReplaceWith(this.attrs, this.content, from, to, type, attrs, marks || Mark.none);
};
Node.prototype.canAppend = function(other) {
if (other.content.size) {
return this.canReplace(this.childCount, this.childCount, other.content);
} else {
return this.type.compatibleContent(other.type);
}
};
Node.prototype.defaultContentType = function(at) {
var elt = this.contentMatchAt(at).nextElement;
return elt && elt.defaultType();
};
Node.prototype.toJSON = function() {
var this$1 = this;
var obj = {type: this.type.name};
for (var _ in this$1.attrs) {
obj.attrs = this$1.attrs;
break;
}
if (this.content.size) {
obj.content = this.content.toJSON();
}
if (this.marks.length) {
obj.marks = this.marks.map(function(n) {
return n.toJSON();
});
}
return obj;
};
Node.fromJSON = function(schema, json) {
var marks = json.marks && json.marks.map(schema.markFromJSON);
if (json.type == "text") {
return schema.text(json.text, marks);
}
return schema.nodeType(json.type).create(json.attrs, Fragment.fromJSON(schema, json.content), marks);
};
Object.defineProperties(Node.prototype, prototypeAccessors);
exports.Node = Node;
var TextNode = (function(Node) {
function TextNode(type, attrs, content, marks) {
Node.call(this, type, attrs, null, marks);
if (!content) {
throw new RangeError("Empty text nodes are not allowed");
}
this.text = content;
}
if (Node)
TextNode.__proto__ = Node;
TextNode.prototype = Object.create(Node && Node.prototype);
TextNode.prototype.constructor = TextNode;
var prototypeAccessors$1 = {
textContent: {},
nodeSize: {}
};
TextNode.prototype.toString = function() {
return wrapMarks(this.marks, JSON.stringify(this.text));
};
prototypeAccessors$1.textContent.get = function() {
return this.text;
};
TextNode.prototype.textBetween = function(from, to) {
return this.text.slice(from, to);
};
prototypeAccessors$1.nodeSize.get = function() {
return this.text.length;
};
TextNode.prototype.mark = function(marks) {
return new TextNode(this.type, this.attrs, this.text, marks);
};
TextNode.prototype.withText = function(text) {
if (text == this.text) {
return this;
}
return new TextNode(this.type, this.attrs, text, this.marks);
};
TextNode.prototype.cut = function(from, to) {
if (from === void 0)
from = 0;
if (to === void 0)
to = this.text.length;
if (from == 0 && to == this.text.length) {
return this;
}
return this.withText(this.text.slice(from, to));
};
TextNode.prototype.eq = function(other) {
return this.sameMarkup(other) && this.text == other.text;
};
TextNode.prototype.toJSON = function() {
var base = Node.prototype.toJSON.call(this);
base.text = this.text;
return base;
};
Object.defineProperties(TextNode.prototype, prototypeAccessors$1);
return TextNode;
}(Node));
exports.TextNode = TextNode;
function wrapMarks(marks, str) {
for (var i = marks.length - 1; i >= 0; i--) {
str = marks[i].type.name + "(" + str + ")";
}
return str;
}
return module.exports;
});
$__System.registerDynamic("49", ["42", "45", "46", "44", "4a"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var OrderedMap = $__require('42');
var ref = $__require('45');
var Node = ref.Node;
var TextNode = ref.TextNode;
var ref$1 = $__require('46');
var Fragment = ref$1.Fragment;
var ref$2 = $__require('44');
var Mark = ref$2.Mark;
var ref$3 = $__require('4a');
var ContentExpr = ref$3.ContentExpr;
function defaultAttrs(attrs) {
var defaults = Object.create(null);
for (var attrName in attrs) {
var attr = attrs[attrName];
if (attr.default === undefined) {
return null;
}
defaults[attrName] = attr.default;
}
return defaults;
}
function computeAttrs(attrs, value) {
var built = Object.create(null);
for (var name in attrs) {
var given = value && value[name];
if (given == null) {
var attr = attrs[name];
if (attr.default !== undefined) {
given = attr.default;
} else if (attr.compute) {
given = attr.compute();
} else {
throw new RangeError("No value supplied for attribute " + name);
}
}
built[name] = given;
}
return built;
}
function initAttrs(attrs) {
var result = Object.create(null);
if (attrs) {
for (var name in attrs) {
result[name] = new Attribute(attrs[name]);
}
}
return result;
}
var NodeType = function(name, schema, spec) {
this.name = name;
this.schema = schema;
this.spec = spec;
this.attrs = initAttrs(spec.attrs);
this.defaultAttrs = defaultAttrs(this.attrs);
this.contentExpr = null;
this.isBlock = !(spec.inline || name == "text");
this.isText = name == "text";
};
var prototypeAccessors = {
isInline: {},
isTextblock: {},
isLeaf: {}
};
prototypeAccessors.isInline.get = function() {
return !this.isBlock;
};
prototypeAccessors.isTextblock.get = function() {
return this.isBlock && this.contentExpr.inlineContent;
};
prototypeAccessors.isLeaf.get = function() {
return this.contentExpr.isLeaf;
};
NodeType.prototype.hasRequiredAttrs = function(ignore) {
var this$1 = this;
for (var n in this$1.attrs) {
if (this$1.attrs[n].isRequired && (!ignore || !(n in ignore))) {
return true;
}
}
return false;
};
NodeType.prototype.compatibleContent = function(other) {
return this == other || this.contentExpr.compatible(other.contentExpr);
};
NodeType.prototype.computeAttrs = function(attrs) {
if (!attrs && this.defaultAttrs) {
return this.defaultAttrs;
} else {
return computeAttrs(this.attrs, attrs);
}
};
NodeType.prototype.create = function(attrs, content, marks) {
if (typeof content == "string") {
throw new Error("Calling create with string");
}
return new Node(this, this.computeAttrs(attrs), Fragment.from(content), Mark.setFrom(marks));
};
NodeType.prototype.createChecked = function(attrs, content, marks) {
attrs = this.computeAttrs(attrs);
content = Fragment.from(content);
if (!this.validContent(content, attrs)) {
throw new RangeError("Invalid content for node " + this.name);
}
return new Node(this, attrs, content, Mark.setFrom(marks));
};
NodeType.prototype.createAndFill = function(attrs, content, marks) {
attrs = this.computeAttrs(attrs);
content = Fragment.from(content);
if (content.size) {
var before = this.contentExpr.start(attrs).fillBefore(content);
if (!before) {
return null;
}
content = before.append(content);
}
var after = this.contentExpr.getMatchAt(attrs, content).fillBefore(Fragment.empty, true);
if (!after) {
return null;
}
return new Node(this, attrs, content.append(after), Mark.setFrom(marks));
};
NodeType.prototype.validContent = function(content, attrs) {
return this.contentExpr.matches(attrs, content);
};
NodeType.compile = function(nodes, schema) {
var result = Object.create(null);
nodes.forEach(function(name, spec) {
return result[name] = new NodeType(name, schema, spec);
});
if (!result.doc) {
throw new RangeError("Every schema needs a 'doc' type");
}
if (!result.text) {
throw new RangeError("Every schema needs a 'text' type");
}
return result;
};
Object.defineProperties(NodeType.prototype, prototypeAccessors);
exports.NodeType = NodeType;
var Attribute = function(options) {
this.default = options.default;
this.compute = options.compute;
};
var prototypeAccessors$1 = {isRequired: {}};
prototypeAccessors$1.isRequired.get = function() {
return this.default === undefined && !this.compute;
};
Object.defineProperties(Attribute.prototype, prototypeAccessors$1);
var MarkType = function(name, rank, schema, spec) {
this.name = name;
this.schema = schema;
this.spec = spec;
this.attrs = initAttrs(spec.attrs);
this.rank = rank;
var defaults = defaultAttrs(this.attrs);
this.instance = defaults && new Mark(this, defaults);
};
MarkType.prototype.create = function(attrs) {
if (!attrs && this.instance) {
return this.instance;
}
return new Mark(this, computeAttrs(this.attrs, attrs));
};
MarkType.compile = function(marks, schema) {
var result = Object.create(null),
rank = 0;
marks.forEach(function(name, spec) {
return result[name] = new MarkType(name, rank++, schema, spec);
});
return result;
};
MarkType.prototype.removeFromSet = function(set) {
var this$1 = this;
for (var i = 0; i < set.length; i++) {
if (set[i].type == this$1) {
return set.slice(0, i).concat(set.slice(i + 1));
}
}
return set;
};
MarkType.prototype.isInSet = function(set) {
var this$1 = this;
for (var i = 0; i < set.length; i++) {
if (set[i].type == this$1) {
return set[i];
}
}
};
exports.MarkType = MarkType;
var Schema = function(spec) {
var this$1 = this;
this.nodeSpec = OrderedMap.from(spec.nodes);
this.markSpec = OrderedMap.from(spec.marks);
this.nodes = NodeType.compile(this.nodeSpec, this);
this.marks = MarkType.compile(this.markSpec, this);
for (var prop in this$1.nodes) {
if (prop in this$1.marks) {
throw new RangeError(prop + " can not be both a node and a mark");
}
var type = this$1.nodes[prop];
type.contentExpr = ContentExpr.parse(type, this$1.nodeSpec.get(prop).content || "", this$1.nodeSpec);
}
this.cached = Object.create(null);
this.cached.wrappings = Object.create(null);
this.nodeFromJSON = this.nodeFromJSON.bind(this);
this.markFromJSON = this.markFromJSON.bind(this);
};
Schema.prototype.node = function(type, attrs, content, marks) {
if (typeof type == "string") {
type = this.nodeType(type);
} else if (!(type instanceof NodeType)) {
throw new RangeError("Invalid node type: " + type);
} else if (type.schema != this) {
throw new RangeError("Node type from different schema used (" + type.name + ")");
}
return type.createChecked(attrs, content, marks);
};
Schema.prototype.text = function(text$1, marks) {
var type = this.nodes.text;
return new TextNode(type, type.defaultAttrs, text$1, Mark.setFrom(marks));
};
Schema.prototype.mark = function(type, attrs) {
if (typeof type == "string") {
type = this.marks[type];
}
return type.create(attrs);
};
Schema.prototype.nodeFromJSON = function(json) {
return Node.fromJSON(this, json);
};
Schema.prototype.markFromJSON = function(json) {
return Mark.fromJSON(this, json);
};
Schema.prototype.nodeType = function(name) {
var found = this.nodes[name];
if (!found) {
throw new RangeError("Unknown node type: " + name);
}
return found;
};
exports.Schema = Schema;
return module.exports;
});
$__System.registerDynamic("4a", ["46", "44"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var ref = $__require('46');
var Fragment = ref.Fragment;
var ref$1 = $__require('44');
var Mark = ref$1.Mark;
var ContentExpr = function(nodeType, elements, inlineContent) {
this.nodeType = nodeType;
this.elements = elements;
this.inlineContent = inlineContent;
};
var prototypeAccessors = {isLeaf: {}};
prototypeAccessors.isLeaf.get = function() {
return this.elements.length == 0;
};
ContentExpr.prototype.start = function(attrs) {
return new ContentMatch(this, attrs, 0, 0);
};
ContentExpr.prototype.atType = function(parentAttrs, type, attrs, marks) {
var this$1 = this;
if (marks === void 0)
marks = Mark.none;
for (var i = 0; i < this.elements.length; i++) {
if (this$1.elements[i].matchesType(type, attrs, marks, parentAttrs, this$1)) {
return new ContentMatch(this$1, parentAttrs, i, 0);
}
}
};
ContentExpr.prototype.matches = function(attrs, fragment, from, to) {
return this.start(attrs).matchToEnd(fragment, from, to);
};
ContentExpr.prototype.getMatchAt = function(attrs, fragment, index) {
if (index === void 0)
index = fragment.childCount;
if (this.elements.length == 1) {
return new ContentMatch(this, attrs, 0, index);
} else {
return this.start(attrs).matchFragment(fragment, 0, index);
}
};
ContentExpr.prototype.checkReplace = function(attrs, content, from, to, replacement, start, end) {
var this$1 = this;
if (replacement === void 0)
replacement = Fragment.empty;
if (start === void 0)
start = 0;
if (end === void 0)
end = replacement.childCount;
if (this.elements.length == 1) {
var elt = this.elements[0];
if (!checkCount(elt, content.childCount - (to - from) + (end - start), attrs, this)) {
return false;
}
for (var i = start; i < end; i++) {
if (!elt.matches(replacement.child(i), attrs, this$1)) {
return false;
}
}
return true;
}
var match = this.getMatchAt(attrs, content, from).matchFragment(replacement, start, end);
return match ? match.matchToEnd(content, to) : false;
};
ContentExpr.prototype.checkReplaceWith = function(attrs, content, from, to, type, typeAttrs, marks) {
if (this.elements.length == 1) {
var elt = this.elements[0];
if (!checkCount(elt, content.childCount - (to - from) + 1, attrs, this)) {
return false;
}
return elt.matchesType(type, typeAttrs, marks, attrs, this);
}
var match = this.getMatchAt(attrs, content, from).matchType(type, typeAttrs, marks);
return match ? match.matchToEnd(content, to) : false;
};
ContentExpr.prototype.compatible = function(other) {
var this$1 = this;
for (var i = 0; i < this.elements.length; i++) {
var elt = this$1.elements[i];
for (var j = 0; j < other.elements.length; j++) {
if (other.elements[j].compatible(elt)) {
return true;
}
}
}
return false;
};
ContentExpr.prototype.generateContent = function(attrs) {
return this.start(attrs).fillBefore(Fragment.empty, true);
};
ContentExpr.parse = function(nodeType, expr, specs) {
var elements = [],
pos = 0,
inline = null;
for (; ; ) {
pos += /^\s*/.exec(expr.slice(pos))[0].length;
if (pos == expr.length) {
break;
}
var types = /^(?:(\w+)|\(\s*(\w+(?:\s*\|\s*\w+)*)\s*\))/.exec(expr.slice(pos));
if (!types) {
throw new SyntaxError("Invalid content expression '" + expr + "' at " + pos);
}
pos += types[0].length;
var attrs = /^\[([^\]]+)\]/.exec(expr.slice(pos));
if (attrs) {
pos += attrs[0].length;
}
var marks = /^<(?:(_)|\s*(\w+(?:\s+\w+)*)\s*)>/.exec(expr.slice(pos));
if (marks) {
pos += marks[0].length;
}
var repeat = /^(?:([+*?])|\{\s*(\d+|\.\w+)\s*(,\s*(\d+|\.\w+)?)?\s*\})/.exec(expr.slice(pos));
if (repeat) {
pos += repeat[0].length;
}
var nodeTypes = expandTypes(nodeType.schema, specs, types[1] ? [types[1]] : types[2].split(/\s*\|\s*/));
for (var i = 0; i < nodeTypes.length; i++) {
if (inline == null) {
inline = nodeTypes[i].isInline;
} else if (inline != nodeTypes[i].isInline) {
throw new SyntaxError("Mixing inline and block content in a single node");
}
}
var attrSet = !attrs ? null : parseAttrs(nodeType, attrs[1]);
var markSet = !marks ? false : marks[1] ? true : checkMarks(nodeType.schema, marks[2].split(/\s+/));
var ref = parseRepeat(nodeType, repeat);
var min = ref.min;
var max = ref.max;
if (min != 0 && (nodeTypes[0].hasRequiredAttrs(attrSet) || nodeTypes[0].isText)) {
throw new SyntaxError("Node type " + types[0] + " in type " + nodeType.name + " is required, but has non-optional attributes");
}
var newElt = new ContentElement(nodeTypes, attrSet, markSet, min, max);
for (var i$1 = elements.length - 1; i$1 >= 0; i$1--) {
var prev = elements[i$1];
if (prev.min != prev.max && prev.overlaps(newElt)) {
throw new SyntaxError("Possibly ambiguous overlapping adjacent content expressions in '" + expr + "'");
}
if (prev.min != 0) {
break;
}
}
elements.push(newElt);
}
return new ContentExpr(nodeType, elements, !!inline);
};
Object.defineProperties(ContentExpr.prototype, prototypeAccessors);
exports.ContentExpr = ContentExpr;
var ContentElement = function(nodeTypes, attrs, marks, min, max) {
this.nodeTypes = nodeTypes;
this.attrs = attrs;
this.marks = marks;
this.min = min;
this.max = max;
};
ContentElement.prototype.matchesType = function(type, attrs, marks, parentAttrs, parentExpr) {
var this$1 = this;
if (this.nodeTypes.indexOf(type) == -1) {
return false;
}
if (this.attrs) {
if (!attrs) {
return false;
}
for (var prop in this$1.attrs) {
if (attrs[prop] != resolveValue(this$1.attrs[prop], parentAttrs, parentExpr)) {
return false;
}
}
}
if (this.marks === true) {
return true;
}
if (this.marks === false) {
return marks.length == 0;
}
for (var i = 0; i < marks.length; i++) {
if (this$1.marks.indexOf(marks[i].type) == -1) {
return false;
}
}
return true;
};
ContentElement.prototype.matches = function(node, parentAttrs, parentExpr) {
return this.matchesType(node.type, node.attrs, node.marks, parentAttrs, parentExpr);
};
ContentElement.prototype.compatible = function(other) {
var this$1 = this;
for (var i = 0; i < this.nodeTypes.length; i++) {
if (other.nodeTypes.indexOf(this$1.nodeTypes[i]) != -1) {
return true;
}
}
return false;
};
ContentElement.prototype.constrainedAttrs = function(parentAttrs, expr) {
var this$1 = this;
if (!this.attrs) {
return null;
}
var attrs = Object.create(null);
for (var prop in this$1.attrs) {
attrs[prop] = resolveValue(this$1.attrs[prop], parentAttrs, expr);
}
return attrs;
};
ContentElement.prototype.createFiller = function(parentAttrs, expr) {
var type = this.nodeTypes[0],
attrs = type.computeAttrs(this.constrainedAttrs(parentAttrs, expr));
return type.create(attrs, type.contentExpr.generateContent(attrs));
};
ContentElement.prototype.defaultType = function() {
var first = this.nodeTypes[0];
if (!(first.hasRequiredAttrs() || first.isText)) {
return first;
}
};
ContentElement.prototype.overlaps = function(other) {
return this.nodeTypes.some(function(t) {
return other.nodeTypes.indexOf(t) > -1;
});
};
ContentElement.prototype.allowsMark = function(markType) {
return this.marks === true || this.marks && this.marks.indexOf(markType) > -1;
};
var ContentMatch = function(expr, attrs, index, count) {
this.expr = expr;
this.attrs = attrs;
this.index = index;
this.count = count;
};
var prototypeAccessors$1 = {
element: {},
nextElement: {}
};
prototypeAccessors$1.element.get = function() {
return this.expr.elements[this.index];
};
prototypeAccessors$1.nextElement.get = function() {
var this$1 = this;
for (var i = this.index,
count = this.count; i < this.expr.elements.length; i++) {
var element = this$1.expr.elements[i];
if (this$1.resolveValue(element.max) > count) {
return element;
}
count = 0;
}
};
ContentMatch.prototype.move = function(index, count) {
return new ContentMatch(this.expr, this.attrs, index, count);
};
ContentMatch.prototype.resolveValue = function(value) {
return value instanceof AttrValue ? resolveValue(value, this.attrs, this.expr) : value;
};
ContentMatch.prototype.matchNode = function(node) {
return this.matchType(node.type, node.attrs, node.marks);
};
ContentMatch.prototype.matchType = function(type, attrs, marks) {
var this$1 = this;
if (marks === void 0)
marks = Mark.none;
for (var ref = this,
index = ref.index,
count = ref.count; index < this.expr.elements.length; index++, count = 0) {
var elt = this$1.expr.elements[index],
max = this$1.resolveValue(elt.max);
if (count < max && elt.matchesType(type, attrs, marks, this$1.attrs, this$1.expr)) {
count++;
return this$1.move(index, count);
}
if (count < this$1.resolveValue(elt.min)) {
return null;
}
}
};
ContentMatch.prototype.matchFragment = function(fragment, from, to) {
var this$1 = this;
if (from === void 0)
from = 0;
if (to === void 0)
to = fragment.childCount;
if (from == to) {
return this;
}
var fragPos = from,
end = this.expr.elements.length;
for (var ref = this,
index = ref.index,
count = ref.count; index < end; index++, count = 0) {
var elt = this$1.expr.elements[index],
max = this$1.resolveValue(elt.max);
while (count < max && fragPos < to) {
if (elt.matches(fragment.child(fragPos), this$1.attrs, this$1.expr)) {
count++;
if (++fragPos == to) {
return this$1.move(index, count);
}
} else {
break;
}
}
if (count < this$1.resolveValue(elt.min)) {
return null;
}
}
return false;
};
ContentMatch.prototype.matchToEnd = function(fragment, start, end) {
var matched = this.matchFragment(fragment, start, end);
return matched && matched.validEnd() || false;
};
ContentMatch.prototype.validEnd = function() {
var this$1 = this;
for (var i = this.index,
count = this.count; i < this.expr.elements.length; i++, count = 0) {
if (count < this$1.resolveValue(this$1.expr.elements[i].min)) {
return false;
}
}
return true;
};
ContentMatch.prototype.fillBefore = function(after, toEnd, startIndex) {
var this$1 = this;
var added = [],
match = this,
index = startIndex || 0,
end = this.expr.elements.length;
for (; ; ) {
var fits = match.matchFragment(after, index);
if (fits && (!toEnd || fits.validEnd())) {
return Fragment.from(added);
}
if (fits === false) {
return null;
}
var elt = match.element;
if (match.count < this$1.resolveValue(elt.min)) {
added.push(elt.createFiller(this$1.attrs, this$1.expr));
match = match.move(match.index, match.count + 1);
} else if (match.index < end) {
match = match.move(match.index + 1, 0);
} else if (after.childCount > index) {
return null;
} else {
return Fragment.from(added);
}
}
};
ContentMatch.prototype.possibleContent = function() {
var this$1 = this;
var found = [];
for (var i = this.index,
count = this.count; i < this.expr.elements.length; i++, count = 0) {
var elt = this$1.expr.elements[i],
attrs = elt.constrainedAttrs(this$1.attrs, this$1.expr);
if (count < this$1.resolveValue(elt.max)) {
for (var j = 0; j < elt.nodeTypes.length; j++) {
var type = elt.nodeTypes[j];
if (!type.hasRequiredAttrs(attrs) && !type.isText) {
found.push({
type: type,
attrs: attrs
});
}
}
}
if (this$1.resolveValue(elt.min) > count) {
break;
}
}
return found;
};
ContentMatch.prototype.allowsMark = function(markType) {
return this.element.allowsMark(markType);
};
ContentMatch.prototype.findWrapping = function(target, targetAttrs, targetMarks) {
var seen = Object.create(null),
first = {
match: this,
via: null
},
active = [first];
while (active.length) {
var current = active.shift(),
match = current.match;
if (match.matchType(target, targetAttrs, targetMarks)) {
var result = [];
for (var obj = current; obj != first; obj = obj.via) {
result.push({
type: obj.match.expr.nodeType,
attrs: obj.match.attrs
});
}
return result.reverse();
}
var possible = match.possibleContent();
for (var i = 0; i < possible.length; i++) {
var ref = possible[i];
var type = ref.type;
var attrs = ref.attrs;
var fullAttrs = type.computeAttrs(attrs);
if (!type.isLeaf && !(type.name in seen) && (current == first || match.matchType(type, fullAttrs).validEnd())) {
active.push({
match: type.contentExpr.start(fullAttrs),
via: current
});
seen[type.name] = true;
}
}
}
};
ContentMatch.prototype.findWrappingFor = function(node) {
return this.findWrapping(node.type, node.attrs, node.marks);
};
Object.defineProperties(ContentMatch.prototype, prototypeAccessors$1);
exports.ContentMatch = ContentMatch;
var AttrValue = function(attr) {
this.attr = attr;
};
function parseValue(nodeType, value) {
if (value.charAt(0) == ".") {
var attr = value.slice(1);
if (!nodeType.attrs[attr]) {
throw new SyntaxError("Node type " + nodeType.name + " has no attribute " + attr);
}
return new AttrValue(attr);
} else {
return JSON.parse(value);
}
}
function checkMarks(schema, marks) {
var found = [];
for (var i = 0; i < marks.length; i++) {
var mark = schema.marks[marks[i]];
if (mark) {
found.push(mark);
} else {
throw new SyntaxError("Unknown mark type: '" + marks[i] + "'");
}
}
return found;
}
function resolveValue(value, attrs, expr) {
if (!(value instanceof AttrValue)) {
return value;
}
var attrVal = attrs && attrs[value.attr];
return attrVal !== undefined ? attrVal : expr.nodeType.defaultAttrs[value.attr];
}
function checkCount(elt, count, attrs, expr) {
return count >= resolveValue(elt.min, attrs, expr) && count <= resolveValue(elt.max, attrs, expr);
}
function expandTypes(schema, specs, types) {
var result = [];
types.forEach(function(type) {
var found = schema.nodes[type];
if (found) {
if (result.indexOf(found) == -1) {
result.push(found);
}
} else {
specs.forEach(function(name, spec) {
if (spec.group && spec.group.split(" ").indexOf(type) > -1) {
found = schema.nodes[name];
if (result.indexOf(found) == -1) {
result.push(found);
}
}
});
}
if (!found) {
throw new SyntaxError("Node type or group '" + type + "' does not exist");
}
});
return result;
}
var many = 2e9;
function parseRepeat(nodeType, match) {
var min = 1,
max = 1;
if (match) {
if (match[1] == "+") {
max = many;
} else if (match[1] == "*") {
min = 0;
max = many;
} else if (match[1] == "?") {
min = 0;
} else if (match[2]) {
min = parseValue(nodeType, match[2]);
if (match[3]) {
max = match[4] ? parseValue(nodeType, match[4]) : many;
} else {
max = min;
}
}
if (max == 0 || min > max) {
throw new SyntaxError("Invalid repeat count in '" + match[0] + "'");
}
}
return {
min: min,
max: max
};
}
function parseAttrs(nodeType, expr) {
var parts = expr.split(/\s*,\s*/);
var attrs = Object.create(null);
for (var i = 0; i < parts.length; i++) {
var match = /^(\w+)=(\w+|\"(?:\\.|[^\\])*\"|\.\w+)$/.exec(parts[i]);
if (!match) {
throw new SyntaxError("Invalid attribute syntax: " + parts[i]);
}
attrs[match[1]] = parseValue(nodeType, match[2]);
}
return attrs;
}
return module.exports;
});
$__System.registerDynamic("4b", [], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
function findDiffStart(a, b, pos) {
for (var i = 0; ; i++) {
if (i == a.childCount || i == b.childCount) {
return a.childCount == b.childCount ? null : pos;
}
var childA = a.child(i),
childB = b.child(i);
if (childA == childB) {
pos += childA.nodeSize;
continue;
}
if (!childA.sameMarkup(childB)) {
return pos;
}
if (childA.isText && childA.text != childB.text) {
for (var j = 0; childA.text[j] == childB.text[j]; j++) {
pos++;
}
return pos;
}
if (childA.content.size || childB.content.size) {
var inner = findDiffStart(childA.content, childB.content, pos + 1);
if (inner != null) {
return inner;
}
}
pos += childA.nodeSize;
}
}
exports.findDiffStart = findDiffStart;
function findDiffEnd(a, b, posA, posB) {
for (var iA = a.childCount,
iB = b.childCount; ; ) {
if (iA == 0 || iB == 0) {
return iA == iB ? null : {
a: posA,
b: posB
};
}
var childA = a.child(--iA),
childB = b.child(--iB),
size = childA.nodeSize;
if (childA == childB) {
posA -= size;
posB -= size;
continue;
}
if (!childA.sameMarkup(childB)) {
return {
a: posA,
b: posB
};
}
if (childA.isText && childA.text != childB.text) {
var same = 0,
minSize = Math.min(childA.text.length, childB.text.length);
while (same < minSize && childA.text[childA.text.length - same - 1] == childB.text[childB.text.length - same - 1]) {
same++;
posA--;
posB--;
}
return {
a: posA,
b: posB
};
}
if (childA.content.size || childB.content.size) {
var inner = findDiffEnd(childA.content, childB.content, posA - 1, posB - 1);
if (inner) {
return inner;
}
}
posA -= size;
posB -= size;
}
}
exports.findDiffEnd = findDiffEnd;
return module.exports;
});
$__System.registerDynamic("46", ["4b"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var ref = $__require('4b');
var findDiffStart = ref.findDiffStart;
var findDiffEnd = ref.findDiffEnd;
var Fragment = function(content, size) {
var this$1 = this;
this.content = content;
this.size = size || 0;
if (size == null) {
for (var i = 0; i < content.length; i++) {
this$1.size += content[i].nodeSize;
}
}
};
var prototypeAccessors = {
firstChild: {},
lastChild: {},
childCount: {}
};
Fragment.prototype.nodesBetween = function(from, to, f, nodeStart, parent) {
var this$1 = this;
for (var i = 0,
pos = 0; pos < to; i++) {
var child = this$1.content[i],
end = pos + child.nodeSize;
if (end > from && f(child, nodeStart + pos, parent, i) !== false && child.content.size) {
var start = pos + 1;
child.nodesBetween(Math.max(0, from - start), Math.min(child.content.size, to - start), f, nodeStart + start);
}
pos = end;
}
};
Fragment.prototype.textBetween = function(from, to, blockSeparator, leafText) {
var text = "",
separated = true;
this.nodesBetween(from, to, function(node, pos) {
if (node.isText) {
text += node.text.slice(Math.max(from, pos) - pos, to - pos);
separated = !blockSeparator;
} else if (node.isLeaf && leafText) {
text += leafText;
separated = !blockSeparator;
} else if (!separated && node.isBlock) {
text += blockSeparator;
separated = true;
}
}, 0);
return text;
};
Fragment.prototype.append = function(other) {
if (!other.size) {
return this;
}
if (!this.size) {
return other;
}
var last = this.lastChild,
first = other.firstChild,
content = this.content.slice(),
i = 0;
if (last.isText && last.sameMarkup(first)) {
content[content.length - 1] = last.withText(last.text + first.text);
i = 1;
}
for (; i < other.content.length; i++) {
content.push(other.content[i]);
}
return new Fragment(content, this.size + other.size);
};
Fragment.prototype.cut = function(from, to) {
var this$1 = this;
if (to == null) {
to = this.size;
}
if (from == 0 && to == this.size) {
return this;
}
var result = [],
size = 0;
if (to > from) {
for (var i = 0,
pos = 0; pos < to; i++) {
var child = this$1.content[i],
end = pos + child.nodeSize;
if (end > from) {
if (pos < from || end > to) {
if (child.isText) {
child = child.cut(Math.max(0, from - pos), Math.min(child.text.length, to - pos));
} else {
child = child.cut(Math.max(0, from - pos - 1), Math.min(child.content.size, to - pos - 1));
}
}
result.push(child);
size += child.nodeSize;
}
pos = end;
}
}
return new Fragment(result, size);
};
Fragment.prototype.cutByIndex = function(from, to) {
if (from == to) {
return Fragment.empty;
}
if (from == 0 && to == this.content.length) {
return this;
}
return new Fragment(this.content.slice(from, to));
};
Fragment.prototype.replaceChild = function(index, node) {
var current = this.content[index];
if (current == node) {
return this;
}
var copy = this.content.slice();
var size = this.size + node.nodeSize - current.nodeSize;
copy[index] = node;
return new Fragment(copy, size);
};
Fragment.prototype.addToStart = function(node) {
return new Fragment([node].concat(this.content), this.size + node.nodeSize);
};
Fragment.prototype.addToEnd = function(node) {
return new Fragment(this.content.concat(node), this.size + node.nodeSize);
};
Fragment.prototype.eq = function(other) {
var this$1 = this;
if (this.content.length != other.content.length) {
return false;
}
for (var i = 0; i < this.content.length; i++) {
if (!this$1.content[i].eq(other.content[i])) {
return false;
}
}
return true;
};
prototypeAccessors.firstChild.get = function() {
return this.content.length ? this.content[0] : null;
};
prototypeAccessors.lastChild.get = function() {
return this.content.length ? this.content[this.content.length - 1] : null;
};
prototypeAccessors.childCount.get = function() {
return this.content.length;
};
Fragment.prototype.child = function(index) {
var found = this.content[index];
if (!found) {
throw new RangeError("Index " + index + " out of range for " + this);
}
return found;
};
Fragment.prototype.offsetAt = function(index) {
var this$1 = this;
var offset = 0;
for (var i = 0; i < index; i++) {
offset += this$1.content[i].nodeSize;
}
return offset;
};
Fragment.prototype.maybeChild = function(index) {
return this.content[index];
};
Fragment.prototype.forEach = function(f) {
var this$1 = this;
for (var i = 0,
p = 0; i < this.content.length; i++) {
var child = this$1.content[i];
f(child, p, i);
p += child.nodeSize;
}
};
Fragment.prototype.findDiffStart = function(other, pos) {
if (pos === void 0)
pos = 0;
return findDiffStart(this, other, pos);
};
Fragment.prototype.findDiffEnd = function(other, pos, otherPos) {
if (pos === void 0)
pos = this.size;
if (otherPos === void 0)
otherPos = other.size;
return findDiffEnd(this, other, pos, otherPos);
};
Fragment.prototype.findIndex = function(pos, round) {
var this$1 = this;
if (round === void 0)
round = -1;
if (pos == 0) {
return retIndex(0, pos);
}
if (pos == this.size) {
return retIndex(this.content.length, pos);
}
if (pos > this.size || pos < 0) {
throw new RangeError(("Position " + pos + " outside of fragment (" + (this) + ")"));
}
for (var i = 0,
curPos = 0; ; i++) {
var cur = this$1.child(i),
end = curPos + cur.nodeSize;
if (end >= pos) {
if (end == pos || round > 0) {
return retIndex(i + 1, end);
}
return retIndex(i, curPos);
}
curPos = end;
}
};
Fragment.prototype.toString = function() {
return "<" + this.toStringInner() + ">";
};
Fragment.prototype.toStringInner = function() {
return this.content.join(", ");
};
Fragment.prototype.toJSON = function() {
return this.content.length ? this.content.map(function(n) {
return n.toJSON();
}) : null;
};
Fragment.fromJSON = function(schema, value) {
return value ? new Fragment(value.map(schema.nodeFromJSON)) : Fragment.empty;
};
Fragment.fromArray = function(array) {
if (!array.length) {
return Fragment.empty;
}
var joined,
size = 0;
for (var i = 0; i < array.length; i++) {
var node = array[i];
size += node.nodeSize;
if (i && node.isText && array[i - 1].sameMarkup(node)) {
if (!joined) {
joined = array.slice(0, i);
}
joined[joined.length - 1] = node.withText(joined[joined.length - 1].text + node.text);
} else if (joined) {
joined.push(node);
}
}
return new Fragment(joined || array, size);
};
Fragment.from = function(nodes) {
if (!nodes) {
return Fragment.empty;
}
if (nodes instanceof Fragment) {
return nodes;
}
if (Array.isArray(nodes)) {
return this.fromArray(nodes);
}
return new Fragment([nodes], nodes.nodeSize);
};
Object.defineProperties(Fragment.prototype, prototypeAccessors);
exports.Fragment = Fragment;
var found = {
index: 0,
offset: 0
};
function retIndex(index, offset) {
found.index = index;
found.offset = offset;
return found;
}
Fragment.empty = new Fragment([], 0);
return module.exports;
});
$__System.registerDynamic("47", ["46"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var ref = $__require('46');
var Fragment = ref.Fragment;
var ReplaceError = (function(Error) {
function ReplaceError(message) {
Error.call(this, message);
this.message = message;
}
if (Error)
ReplaceError.__proto__ = Error;
ReplaceError.prototype = Object.create(Error && Error.prototype);
ReplaceError.prototype.constructor = ReplaceError;
return ReplaceError;
}(Error));
exports.ReplaceError = ReplaceError;
var Slice = function(content, openLeft, openRight) {
this.content = content;
this.openLeft = openLeft;
this.openRight = openRight;
};
var prototypeAccessors = {size: {}};
prototypeAccessors.size.get = function() {
return this.content.size - this.openLeft - this.openRight;
};
Slice.prototype.insertAt = function(pos, fragment) {
var content = insertInto(this.content, pos + this.openLeft, fragment, null);
return content && new Slice(content, this.openLeft, this.openRight);
};
Slice.prototype.removeBetween = function(from, to) {
return new Slice(removeRange(this.content, from + this.openLeft, to + this.openLeft), this.openLeft, this.openRight);
};
Slice.prototype.eq = function(other) {
return this.content.eq(other.content) && this.openLeft == other.openLeft && this.openRight == other.openRight;
};
Slice.prototype.toString = function() {
return this.content + "(" + this.openLeft + "," + this.openRight + ")";
};
Slice.prototype.toJSON = function() {
if (!this.content.size) {
return null;
}
return {
content: this.content.toJSON(),
openLeft: this.openLeft,
openRight: this.openRight
};
};
Slice.fromJSON = function(schema, json) {
if (!json) {
return Slice.empty;
}
return new Slice(Fragment.fromJSON(schema, json.content), json.openLeft, json.openRight);
};
Slice.maxOpen = function(fragment) {
var openLeft = 0,
openRight = 0;
for (var n = fragment.firstChild; n && !n.isLeaf; n = n.firstChild) {
openLeft++;
}
for (var n$1 = fragment.lastChild; n$1 && !n$1.isLeaf; n$1 = n$1.lastChild) {
openRight++;
}
return new Slice(fragment, openLeft, openRight);
};
Object.defineProperties(Slice.prototype, prototypeAccessors);
exports.Slice = Slice;
function removeRange(content, from, to) {
var ref = content.findIndex(from);
var index = ref.index;
var offset = ref.offset;
var child = content.maybeChild(index);
var ref$1 = content.findIndex(to);
var indexTo = ref$1.index;
var offsetTo = ref$1.offset;
if (offset == from || child.isText) {
if (offsetTo != to && !content.child(indexTo).isText) {
throw new RangeError("Removing non-flat range");
}
return content.cut(0, from).append(content.cut(to));
}
if (index != indexTo) {
throw new RangeError("Removing non-flat range");
}
return content.replaceChild(index, child.copy(removeRange(child.content, from - offset - 1, to - offset - 1)));
}
function insertInto(content, dist, insert, parent) {
var ref = content.findIndex(dist);
var index = ref.index;
var offset = ref.offset;
var child = content.maybeChild(index);
if (offset == dist || child.isText) {
if (parent && !parent.canReplace(index, index, insert)) {
return null;
}
return content.cut(0, dist).append(insert).append(content.cut(dist));
}
var inner = insertInto(child.content, dist - offset - 1, insert);
return inner && content.replaceChild(index, child.copy(inner));
}
Slice.empty = new Slice(Fragment.empty, 0, 0);
function replace($from, $to, slice) {
if (slice.openLeft > $from.depth) {
throw new ReplaceError("Inserted content deeper than insertion position");
}
if ($from.depth - slice.openLeft != $to.depth - slice.openRight) {
throw new ReplaceError("Inconsistent open depths");
}
return replaceOuter($from, $to, slice, 0);
}
exports.replace = replace;
function replaceOuter($from, $to, slice, depth) {
var index = $from.index(depth),
node = $from.node(depth);
if (index == $to.index(depth) && depth < $from.depth - slice.openLeft) {
var inner = replaceOuter($from, $to, slice, depth + 1);
return node.copy(node.content.replaceChild(index, inner));
} else if (!slice.content.size) {
return close(node, replaceTwoWay($from, $to, depth));
} else if (!slice.openLeft && !slice.openRight && $from.depth == depth && $to.depth == depth) {
var parent = $from.parent,
content = parent.content;
return close(parent, content.cut(0, $from.parentOffset).append(slice.content).append(content.cut($to.parentOffset)));
} else {
var ref = prepareSliceForReplace(slice, $from);
var start = ref.start;
var end = ref.end;
return close(node, replaceThreeWay($from, start, end, $to, depth));
}
}
function checkJoin(main, sub) {
if (!sub.type.compatibleContent(main.type)) {
throw new ReplaceError("Cannot join " + sub.type.name + " onto " + main.type.name);
}
}
function joinable($before, $after, depth) {
var node = $before.node(depth);
checkJoin(node, $after.node(depth));
return node;
}
function addNode(child, target) {
var last = target.length - 1;
if (last >= 0 && child.isText && child.sameMarkup(target[last])) {
target[last] = child.withText(target[last].text + child.text);
} else {
target.push(child);
}
}
function addRange($start, $end, depth, target) {
var node = ($end || $start).node(depth);
var startIndex = 0,
endIndex = $end ? $end.index(depth) : node.childCount;
if ($start) {
startIndex = $start.index(depth);
if ($start.depth > depth) {
startIndex++;
} else if ($start.textOffset) {
addNode($start.nodeAfter, target);
startIndex++;
}
}
for (var i = startIndex; i < endIndex; i++) {
addNode(node.child(i), target);
}
if ($end && $end.depth == depth && $end.textOffset) {
addNode($end.nodeBefore, target);
}
}
function close(node, content) {
if (!node.type.validContent(content, node.attrs)) {
throw new ReplaceError("Invalid content for node " + node.type.name);
}
return node.copy(content);
}
function replaceThreeWay($from, $start, $end, $to, depth) {
var openLeft = $from.depth > depth && joinable($from, $start, depth + 1);
var openRight = $to.depth > depth && joinable($end, $to, depth + 1);
var content = [];
addRange(null, $from, depth, content);
if (openLeft && openRight && $start.index(depth) == $end.index(depth)) {
checkJoin(openLeft, openRight);
addNode(close(openLeft, replaceThreeWay($from, $start, $end, $to, depth + 1)), content);
} else {
if (openLeft) {
addNode(close(openLeft, replaceTwoWay($from, $start, depth + 1)), content);
}
addRange($start, $end, depth, content);
if (openRight) {
addNode(close(openRight, replaceTwoWay($end, $to, depth + 1)), content);
}
}
addRange($to, null, depth, content);
return new Fragment(content);
}
function replaceTwoWay($from, $to, depth) {
var content = [];
addRange(null, $from, depth, content);
if ($from.depth > depth) {
var type = joinable($from, $to, depth + 1);
addNode(close(type, replaceTwoWay($from, $to, depth + 1)), content);
}
addRange($to, null, depth, content);
return new Fragment(content);
}
function prepareSliceForReplace(slice, $along) {
var extra = $along.depth - slice.openLeft,
parent = $along.node(extra);
var node = parent.copy(slice.content);
for (var i = extra - 1; i >= 0; i--) {
node = $along.node(i).copy(Fragment.from(node));
}
return {
start: node.resolveNoCache(slice.openLeft + extra),
end: node.resolveNoCache(node.content.size - slice.openRight - extra)
};
}
return module.exports;
});
$__System.registerDynamic("48", [], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
function compareDeep(a, b) {
if (a === b) {
return true;
}
if (!(a && typeof a == "object") || !(b && typeof b == "object")) {
return false;
}
var array = Array.isArray(a);
if (Array.isArray(b) != array) {
return false;
}
if (array) {
if (a.length != b.length) {
return false;
}
for (var i = 0; i < a.length; i++) {
if (!compareDeep(a[i], b[i])) {
return false;
}
}
} else {
for (var p in a) {
if (!(p in b) || !compareDeep(a[p], b[p])) {
return false;
}
}
for (var p$1 in b) {
if (!(p$1 in a)) {
return false;
}
}
}
return true;
}
exports.compareDeep = compareDeep;
return module.exports;
});
$__System.registerDynamic("44", ["48"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var ref = $__require('48');
var compareDeep = ref.compareDeep;
var Mark = function(type, attrs) {
this.type = type;
this.attrs = attrs;
};
Mark.prototype.addToSet = function(set) {
var this$1 = this;
for (var i = 0; i < set.length; i++) {
var other = set[i];
if (other.type == this$1.type) {
if (this$1.eq(other)) {
return set;
}
var copy = set.slice();
copy[i] = this$1;
return copy;
}
if (other.type.rank > this$1.type.rank) {
return set.slice(0, i).concat(this$1).concat(set.slice(i));
}
}
return set.concat(this);
};
Mark.prototype.removeFromSet = function(set) {
var this$1 = this;
for (var i = 0; i < set.length; i++) {
if (this$1.eq(set[i])) {
return set.slice(0, i).concat(set.slice(i + 1));
}
}
return set;
};
Mark.prototype.isInSet = function(set) {
var this$1 = this;
for (var i = 0; i < set.length; i++) {
if (this$1.eq(set[i])) {
return true;
}
}
return false;
};
Mark.prototype.eq = function(other) {
if (this == other) {
return true;
}
if (this.type != other.type) {
return false;
}
if (!compareDeep(other.attrs, this.attrs)) {
return false;
}
return true;
};
Mark.prototype.toJSON = function() {
var this$1 = this;
var obj = {type: this.type.name};
for (var _ in this$1.attrs) {
obj.attrs = this$1.attrs;
break;
}
return obj;
};
Mark.fromJSON = function(schema, json) {
return schema.marks[json.type].create(json.attrs);
};
Mark.sameSet = function(a, b) {
if (a == b) {
return true;
}
if (a.length != b.length) {
return false;
}
for (var i = 0; i < a.length; i++) {
if (!a[i].eq(b[i])) {
return false;
}
}
return true;
};
Mark.setFrom = function(marks) {
if (!marks || marks.length == 0) {
return Mark.none;
}
if (marks instanceof Mark) {
return [marks];
}
var copy = marks.slice();
copy.sort(function(a, b) {
return a.type.rank - b.type.rank;
});
return copy;
};
exports.Mark = Mark;
Mark.none = [];
return module.exports;
});
$__System.registerDynamic("4c", ["46", "47", "44"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var ref = $__require('46');
var Fragment = ref.Fragment;
var ref$1 = $__require('47');
var Slice = ref$1.Slice;
var ref$2 = $__require('44');
var Mark = ref$2.Mark;
var DOMParser = function(schema, rules) {
var this$1 = this;
this.schema = schema;
this.rules = rules;
this.tags = [];
this.styles = [];
rules.forEach(function(rule) {
if (rule.tag) {
this$1.tags.push(rule);
} else if (rule.style) {
this$1.styles.push(rule);
}
});
};
DOMParser.prototype.parse = function(dom, options) {
if (options === void 0)
options = {};
var context = new ParseContext(this, options, false);
context.addAll(dom, null, options.from, options.to);
return context.finish();
};
DOMParser.prototype.parseSlice = function(dom, options) {
if (options === void 0)
options = {};
var context = new ParseContext(this, options, true);
context.addAll(dom, null, options.from, options.to);
return Slice.maxOpen(context.finish());
};
DOMParser.prototype.matchTag = function(dom) {
var this$1 = this;
for (var i = 0; i < this.tags.length; i++) {
var rule = this$1.tags[i];
if (matches(dom, rule.tag)) {
if (rule.getAttrs) {
var result = rule.getAttrs(dom);
if (result === false) {
continue;
}
rule.attrs = result;
}
return rule;
}
}
};
DOMParser.prototype.matchStyle = function(prop, value) {
var this$1 = this;
for (var i = 0; i < this.styles.length; i++) {
var rule = this$1.styles[i];
if (rule.style == prop) {
if (rule.getAttrs) {
var result = rule.getAttrs(value);
if (result === false) {
continue;
}
rule.attrs = result;
}
return rule;
}
}
};
DOMParser.schemaRules = function(schema) {
var result = [];
function insert(rule) {
var priority = rule.priority == null ? 50 : rule.priority,
i = 0;
for (; i < result.length; i++) {
var next = result[i],
nextPriority = next.priority == null ? 50 : next.priority;
if (nextPriority < priority) {
break;
}
}
result.splice(i, 0, rule);
}
var loop = function(name) {
var rules = schema.marks[name].spec.parseDOM;
if (rules) {
rules.forEach(function(rule) {
insert(rule = copy(rule));
rule.mark = name;
});
}
};
for (var name in schema.marks)
loop(name);
var loop$1 = function(name) {
var rules$1 = schema.nodes[name$1].spec.parseDOM;
if (rules$1) {
rules$1.forEach(function(rule) {
insert(rule = copy(rule));
rule.node = name$1;
});
}
};
for (var name$1 in schema.nodes)
loop$1(name);
return result;
};
DOMParser.fromSchema = function(schema) {
return schema.cached.domParser || (schema.cached.domParser = new DOMParser(schema, DOMParser.schemaRules(schema)));
};
exports.DOMParser = DOMParser;
var blockTags = {
address: true,
article: true,
aside: true,
blockquote: true,
canvas: true,
dd: true,
div: true,
dl: true,
fieldset: true,
figcaption: true,
figure: true,
footer: true,
form: true,
h1: true,
h2: true,
h3: true,
h4: true,
h5: true,
h6: true,
header: true,
hgroup: true,
hr: true,
li: true,
noscript: true,
ol: true,
output: true,
p: true,
pre: true,
section: true,
table: true,
tfoot: true,
ul: true
};
var ignoreTags = {
head: true,
noscript: true,
object: true,
script: true,
style: true,
title: true
};
var listTags = {
ol: true,
ul: true
};
var OPT_PRESERVE_WS = 1,
OPT_OPEN_LEFT = 2;
var NodeContext = function(type, attrs, solid, match, options) {
this.type = type;
this.attrs = attrs;
this.solid = solid;
this.match = match || (options & OPT_OPEN_LEFT ? null : type.contentExpr.start(attrs));
this.options = options;
this.content = [];
};
NodeContext.prototype.findWrapping = function(type, attrs) {
if (!this.match) {
if (!this.type) {
return [];
}
var found = this.type.contentExpr.atType(this.attrs, type, attrs);
if (!found) {
var start = this.type.contentExpr.start(this.attrs),
wrap;
if (wrap = start.findWrapping(type, attrs)) {
this.match = start;
return wrap;
}
}
if (found) {
this.match = found;
} else {
return null;
}
}
return this.match.findWrapping(type, attrs);
};
NodeContext.prototype.finish = function(openRight) {
if (!(this.options & OPT_PRESERVE_WS)) {
var last = this.content[this.content.length - 1],
m;
if (last && last.isText && (m = /\s+$/.exec(last.text))) {
if (last.text.length == m[0].length) {
this.content.pop();
} else {
this.content[this.content.length - 1] = last.withText(last.text.slice(0, last.text.length - m[0].length));
}
}
}
var content = Fragment.from(this.content);
if (!openRight && this.match) {
content = content.append(this.match.fillBefore(Fragment.empty, true));
}
return this.type ? this.type.create(this.attrs, content) : content;
};
var ParseContext = function(parser, options, open) {
this.parser = parser;
this.options = options;
this.isOpen = open;
var topNode = options.topNode,
topContext;
var topOptions = (options.preserveWhitespace ? OPT_PRESERVE_WS : 0) | (open ? OPT_OPEN_LEFT : 0);
if (topNode) {
topContext = new NodeContext(topNode.type, topNode.attrs, true, topNode.contentMatchAt(options.topStart || 0), topOptions);
} else if (open) {
topContext = new NodeContext(null, null, true, null, topOptions);
} else {
topContext = new NodeContext(parser.schema.nodes.doc, null, true, null, topOptions);
}
this.nodes = [topContext];
this.marks = Mark.none;
this.open = 0;
this.find = options.findPositions;
};
var prototypeAccessors = {
top: {},
currentPos: {}
};
prototypeAccessors.top.get = function() {
return this.nodes[this.open];
};
ParseContext.prototype.addMark = function(mark) {
var old = this.marks;
this.marks = mark.addToSet(this.marks);
return old;
};
ParseContext.prototype.addDOM = function(dom) {
if (dom.nodeType == 3) {
this.addTextNode(dom);
} else if (dom.nodeType == 1) {
var style = dom.getAttribute("style");
if (style) {
this.addElementWithStyles(parseStyles(style), dom);
} else {
this.addElement(dom);
}
}
};
ParseContext.prototype.addTextNode = function(dom) {
var value = dom.nodeValue;
var top = this.top;
if ((top.type && top.type.isTextblock) || /\S/.test(value)) {
if (!(top.options & OPT_PRESERVE_WS)) {
value = value.replace(/\s+/g, " ");
if (/^\s/.test(value)) {
var nodeBefore = top.content[top.content.length - 1];
if (!nodeBefore || nodeBefore.isText && /\s$/.test(nodeBefore.text)) {
value = value.slice(1);
}
}
}
if (value) {
this.insertNode(this.parser.schema.text(value, this.marks));
}
this.findInText(dom);
} else {
this.findInside(dom);
}
};
ParseContext.prototype.addElement = function(dom) {
var name = dom.nodeName.toLowerCase();
if (listTags.hasOwnProperty(name)) {
normalizeList(dom);
}
var rule = (this.options.ruleFromNode && this.options.ruleFromNode(dom)) || this.parser.matchTag(dom);
if (rule ? rule.ignore : ignoreTags.hasOwnProperty(name)) {
this.findInside(dom);
} else if (!rule || rule.skip) {
if (rule && rule.skip.nodeType) {
dom = rule.skip;
}
var sync = blockTags.hasOwnProperty(name) && this.top;
this.addAll(dom);
if (sync) {
this.sync(sync);
}
} else {
this.addElementByRule(dom, rule);
}
};
ParseContext.prototype.addElementWithStyles = function(styles, dom) {
var this$1 = this;
var oldMarks = this.marks,
ignore = false;
for (var i = 0; i < styles.length; i += 2) {
var rule = this$1.parser.matchStyle(styles[i], styles[i + 1]);
if (!rule) {
continue;
}
if (rule.ignore) {
ignore = true;
break;
}
this$1.addMark(this$1.parser.schema.marks[rule.mark].create(rule.attrs));
}
if (!ignore) {
this.addElement(dom);
}
this.marks = oldMarks;
};
ParseContext.prototype.addElementByRule = function(dom, rule) {
var this$1 = this;
var sync,
before,
nodeType,
markType,
mark;
if (rule.node) {
nodeType = this.parser.schema.nodes[rule.node];
if (nodeType.isLeaf) {
this.insertNode(nodeType.create(rule.attrs, null, this.marks));
} else {
sync = this.enter(nodeType, rule.attrs, rule.preserveWhitespace) && this.top;
}
} else {
markType = this.parser.schema.marks[rule.mark];
before = this.addMark(mark = markType.create(rule.attrs));
}
if (nodeType && nodeType.isLeaf) {
this.findInside(dom);
} else if (rule.getContent) {
this.findInside(dom);
rule.getContent(dom).forEach(function(node) {
return this$1.insertNode(mark ? node.mark(mark.addToSet(node.marks)) : node);
});
} else {
var contentDOM = rule.contentElement;
if (typeof contentDOM == "string") {
contentDOM = dom.querySelector(contentDOM);
}
if (!contentDOM) {
contentDOM = dom;
}
this.findAround(dom, contentDOM, true);
this.addAll(contentDOM, sync);
if (sync) {
this.sync(sync);
this.open--;
} else if (before) {
this.marks = before;
}
this.findAround(dom, contentDOM, true);
}
return true;
};
ParseContext.prototype.addAll = function(parent, sync, startIndex, endIndex) {
var this$1 = this;
var index = startIndex || 0;
for (var dom = startIndex ? parent.childNodes[startIndex] : parent.firstChild,
end = endIndex == null ? null : parent.childNodes[endIndex]; dom != end; dom = dom.nextSibling, ++index) {
this$1.findAtPoint(parent, index);
this$1.addDOM(dom);
if (sync && blockTags.hasOwnProperty(dom.nodeName.toLowerCase())) {
this$1.sync(sync);
}
}
this.findAtPoint(parent, index);
};
ParseContext.prototype.findPlace = function(type, attrs) {
var this$1 = this;
var route,
sync;
for (var depth = this.open; depth >= 0; depth--) {
var node = this$1.nodes[depth];
var found = node.findWrapping(type, attrs);
if (found && (!route || route.length > found.length)) {
route = found;
sync = node;
if (!found.length) {
break;
}
}
if (node.solid) {
break;
}
}
if (!route) {
return false;
}
this.sync(sync);
for (var i = 0; i < route.length; i++) {
this$1.enterInner(route[i].type, route[i].attrs, false);
}
return true;
};
ParseContext.prototype.insertNode = function(node) {
if (this.findPlace(node.type, node.attrs)) {
this.closeExtra();
var top = this.top;
if (top.match) {
var match = top.match.matchNode(node);
if (!match) {
node = node.mark(node.marks.filter(function(mark) {
return top.match.allowsMark(mark.type);
}));
match = top.match.matchNode(node);
}
top.match = match;
}
top.content.push(node);
}
};
ParseContext.prototype.enter = function(type, attrs, preserveWS) {
var ok = this.findPlace(type, attrs);
if (ok) {
this.enterInner(type, attrs, true, preserveWS);
}
return ok;
};
ParseContext.prototype.enterInner = function(type, attrs, solid, preserveWS) {
this.closeExtra();
var top = this.top;
top.match = top.match && top.match.matchType(type, attrs);
var options = preserveWS == null ? top.options & OPT_PRESERVE_WS : preserveWS ? OPT_PRESERVE_WS : 0;
if ((top.options & OPT_OPEN_LEFT) && top.content.length == 0) {
options |= OPT_OPEN_LEFT;
}
this.nodes.push(new NodeContext(type, attrs, solid, null, options));
this.open++;
};
ParseContext.prototype.closeExtra = function(openRight) {
var this$1 = this;
var i = this.nodes.length - 1;
if (i > this.open) {
this.marks = Mark.none;
for (; i > this.open; i--) {
this$1.nodes[i - 1].content.push(this$1.nodes[i].finish(openRight));
}
this.nodes.length = this.open + 1;
}
};
ParseContext.prototype.finish = function() {
this.open = 0;
this.closeExtra(this.isOpen);
return this.nodes[0].finish(this.isOpen || this.options.topOpen);
};
ParseContext.prototype.sync = function(to) {
var this$1 = this;
for (var i = this.open; i >= 0; i--) {
if (this$1.nodes[i] == to) {
this$1.open = i;
return;
}
}
};
prototypeAccessors.currentPos.get = function() {
var this$1 = this;
this.closeExtra();
var pos = 0;
for (var i = this.open; i >= 0; i--) {
var content = this$1.nodes[i].content;
for (var j = content.length - 1; j >= 0; j--) {
pos += content[j].nodeSize;
}
if (i) {
pos++;
}
}
return pos;
};
ParseContext.prototype.findAtPoint = function(parent, offset) {
var this$1 = this;
if (this.find) {
for (var i = 0; i < this.find.length; i++) {
if (this$1.find[i].node == parent && this$1.find[i].offset == offset) {
this$1.find[i].pos = this$1.currentPos;
}
}
}
};
ParseContext.prototype.findInside = function(parent) {
var this$1 = this;
if (this.find) {
for (var i = 0; i < this.find.length; i++) {
if (this$1.find[i].pos == null && parent.contains(this$1.find[i].node)) {
this$1.find[i].pos = this$1.currentPos;
}
}
}
};
ParseContext.prototype.findAround = function(parent, content, before) {
var this$1 = this;
if (parent != content && this.find) {
for (var i = 0; i < this.find.length; i++) {
if (this$1.find[i].pos == null && parent.contains(this$1.find[i].node)) {
var pos = content.compareDocumentPosition(this$1.find[i].node);
if (pos & (before ? 2 : 4)) {
this$1.find[i].pos = this$1.currentPos;
}
}
}
}
};
ParseContext.prototype.findInText = function(textNode) {
var this$1 = this;
if (this.find) {
for (var i = 0; i < this.find.length; i++) {
if (this$1.find[i].node == textNode) {
this$1.find[i].pos = this$1.currentPos - (textNode.nodeValue.length - this$1.find[i].offset);
}
}
}
};
Object.defineProperties(ParseContext.prototype, prototypeAccessors);
function normalizeList(dom) {
for (var child = dom.firstChild,
prevItem = null; child; child = child.nextSibling) {
var name = child.nodeType == 1 ? child.nodeName.toLowerCase() : null;
if (name && listTags.hasOwnProperty(name) && prevItem) {
prevItem.appendChild(child);
child = prevItem;
} else if (name == "li") {
prevItem = child;
} else if (name) {
prevItem = null;
}
}
}
function matches(dom, selector) {
return (dom.matches || dom.msMatchesSelector || dom.webkitMatchesSelector || dom.mozMatchesSelector).call(dom, selector);
}
function parseStyles(style) {
var re = /\s*([\w-]+)\s*:\s*([^;]+)/g,
m,
result = [];
while (m = re.exec(style)) {
result.push(m[1], m[2].trim());
}
return result;
}
function copy(obj) {
var copy = {};
for (var prop in obj) {
copy[prop] = obj[prop];
}
return copy;
}
return module.exports;
});
$__System.registerDynamic("4d", [], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var DOMSerializer = function(nodes, marks) {
this.nodes = nodes || {};
this.marks = marks || {};
};
DOMSerializer.prototype.serializeFragment = function(fragment, options, target) {
var this$1 = this;
if (options === void 0)
options = {};
if (!target) {
target = doc(options).createDocumentFragment();
}
var top = target,
active = null;
fragment.forEach(function(node) {
if (active || node.marks.length) {
if (!active) {
active = [];
}
var keep = 0;
for (; keep < Math.min(active.length, node.marks.length); ++keep) {
if (!node.marks[keep].eq(active[keep])) {
break;
}
}
while (keep < active.length) {
active.pop();
top = top.parentNode;
}
while (active.length < node.marks.length) {
var add = node.marks[active.length];
active.push(add);
top = top.appendChild(this$1.serializeMark(add, options));
}
}
top.appendChild(this$1.serializeNode(node, options));
});
return target;
};
DOMSerializer.prototype.serializeNode = function(node, options) {
if (options === void 0)
options = {};
return this.renderStructure(this.nodes[node.type.name](node), node, options);
};
DOMSerializer.prototype.serializeNodeAndMarks = function(node, options) {
var this$1 = this;
if (options === void 0)
options = {};
var dom = this.serializeNode(node, options);
for (var i = node.marks.length - 1; i >= 0; i--) {
var wrap = this$1.serializeMark(node.marks[i], options);
wrap.appendChild(dom);
dom = wrap;
}
return dom;
};
DOMSerializer.prototype.serializeMark = function(mark, options) {
if (options === void 0)
options = {};
return this.renderStructure(this.marks[mark.type.name](mark), null, options);
};
DOMSerializer.renderSpec = function(doc, structure) {
if (typeof structure == "string") {
return {dom: doc.createTextNode(structure)};
}
if (structure.nodeType != null) {
return {dom: structure};
}
var dom = doc.createElement(structure[0]),
contentDOM = null;
var attrs = structure[1],
start = 1;
if (attrs && typeof attrs == "object" && attrs.nodeType == null && !Array.isArray(attrs)) {
start = 2;
for (var name in attrs) {
if (name == "style") {
dom.style.cssText = attrs[name];
} else if (attrs[name] != null) {
dom.setAttribute(name, attrs[name]);
}
}
}
for (var i = start; i < structure.length; i++) {
var child = structure[i];
if (child === 0) {
if (i < structure.length - 1 || i > start) {
throw new RangeError("Content hole must be the only child of its parent node");
}
return {
dom: dom,
contentDOM: dom
};
} else {
var ref = DOMSerializer.renderSpec(doc, child);
var inner = ref.dom;
var innerContent = ref.contentDOM;
dom.appendChild(inner);
if (innerContent) {
if (contentDOM) {
throw new RangeError("Multiple content holes");
}
contentDOM = innerContent;
}
}
}
return {
dom: dom,
contentDOM: contentDOM
};
};
DOMSerializer.prototype.renderStructure = function(structure, node, options) {
var ref = DOMSerializer.renderSpec(doc(options), structure);
var dom = ref.dom;
var contentDOM = ref.contentDOM;
if (node && !node.isLeaf) {
if (!contentDOM) {
throw new RangeError("No content hole in template for non-leaf node");
}
if (options.onContent) {
options.onContent(node, contentDOM, options);
} else {
this.serializeFragment(node.content, options, contentDOM);
}
} else if (contentDOM) {
throw new RangeError("Content hole not allowed in a mark or leaf node spec");
}
return dom;
};
DOMSerializer.fromSchema = function(schema) {
return schema.cached.domSerializer || (schema.cached.domSerializer = new DOMSerializer(this.nodesFromSchema(schema), this.marksFromSchema(schema)));
};
DOMSerializer.nodesFromSchema = function(schema) {
return gatherToDOM(schema.nodes);
};
DOMSerializer.marksFromSchema = function(schema) {
return gatherToDOM(schema.marks);
};
exports.DOMSerializer = DOMSerializer;
function gatherToDOM(obj) {
var result = {};
for (var name in obj) {
var toDOM = obj[name].spec.toDOM;
if (toDOM) {
result[name] = toDOM;
}
}
return result;
}
function doc(options) {
return options.document || window.document;
}
return module.exports;
});
$__System.registerDynamic("4e", ["45", "43", "46", "47", "44", "49", "4a", "4c", "4d"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
exports.Node = $__require('45').Node;
;
var assign;
((assign = $__require('43'), exports.ResolvedPos = assign.ResolvedPos, exports.NodeRange = assign.NodeRange));
exports.Fragment = $__require('46').Fragment;
;
var assign$1;
((assign$1 = $__require('47'), exports.Slice = assign$1.Slice, exports.ReplaceError = assign$1.ReplaceError));
exports.Mark = $__require('44').Mark;
;
var assign$2;
((assign$2 = $__require('49'), exports.Schema = assign$2.Schema, exports.NodeType = assign$2.NodeType, exports.MarkType = assign$2.MarkType));
;
var assign$3;
((assign$3 = $__require('4a'), exports.ContentMatch = assign$3.ContentMatch));
exports.DOMParser = $__require('4c').DOMParser;
exports.DOMSerializer = $__require('4d').DOMSerializer;
return module.exports;
});
$__System.registerDynamic("3", ["4e"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
module.exports = $__require('4e');
return module.exports;
});
$__System.registerDynamic("4f", ["9", "3"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
var ref = $__require('9');
var findWrapping = ref.findWrapping;
var liftTarget = ref.liftTarget;
var canSplit = ref.canSplit;
var ReplaceAroundStep = ref.ReplaceAroundStep;
var ref$1 = $__require('3');
var Slice = ref$1.Slice;
var Fragment = ref$1.Fragment;
var NodeRange = ref$1.NodeRange;
var orderedList = {
attrs: {order: {default: 1}},
parseDOM: [{
tag: "ol",
getAttrs: function getAttrs(dom) {
return {order: dom.hasAttribute("start") ? +dom.getAttribute("start") : 1};
}
}],
toDOM: function toDOM(node) {
return ["ol", {start: node.attrs.order == 1 ? null : node.attrs.order}, 0];
}
};
exports.orderedList = orderedList;
var bulletList = {
parseDOM: [{tag: "ul"}],
toDOM: function toDOM() {
return ["ul", 0];
}
};
exports.bulletList = bulletList;
var listItem = {
parseDOM: [{tag: "li"}],
toDOM: function toDOM() {
return ["li", 0];
},
defining: true
};
exports.listItem = listItem;
function add(obj, props) {
var copy = {};
for (var prop in obj) {
copy[prop] = obj[prop];
}
for (var prop$1 in props) {
copy[prop$1] = props[prop$1];
}
return copy;
}
function addListNodes(nodes, itemContent, listGroup) {
return nodes.append({
ordered_list: add(orderedList, {
content: "list_item+",
group: listGroup
}),
bullet_list: add(bulletList, {
content: "list_item+",
group: listGroup
}),
list_item: add(listItem, {content: itemContent})
});
}
exports.addListNodes = addListNodes;
function wrapInList(nodeType, attrs) {
return function(state, dispatch) {
var ref = state.selection;
var $from = ref.$from;
var $to = ref.$to;
var range = $from.blockRange($to),
doJoin = false,
outerRange = range;
if (range.depth >= 2 && $from.node(range.depth - 1).type.compatibleContent(nodeType) && range.startIndex == 0) {
if ($from.index(range.depth - 1) == 0) {
return false;
}
var $insert = state.doc.resolve(range.start - 2);
outerRange = new NodeRange($insert, $insert, range.depth);
if (range.endIndex < range.parent.childCount) {
range = new NodeRange($from, state.doc.resolve($to.end(range.depth)), range.depth);
}
doJoin = true;
}
var wrap = findWrapping(outerRange, nodeType, attrs, range);
if (!wrap) {
return false;
}
if (dispatch) {
dispatch(doWrapInList(state.tr, range, wrap, doJoin, nodeType).scrollIntoView());
}
return true;
};
}
exports.wrapInList = wrapInList;
function doWrapInList(tr, range, wrappers, joinBefore, nodeType) {
var content = Fragment.empty;
for (var i = wrappers.length - 1; i >= 0; i--) {
content = Fragment.from(wrappers[i].type.create(wrappers[i].attrs, content));
}
tr.step(new ReplaceAroundStep(range.start - (joinBefore ? 2 : 0), range.end, range.start, range.end, new Slice(content, 0, 0), wrappers.length, true));
var found = 0;
for (var i$1 = 0; i$1 < wrappers.length; i$1++) {
if (wrappers[i$1].type == nodeType) {
found = i$1 + 1;
}
}
var splitDepth = wrappers.length - found;
var splitPos = range.start + wrappers.length - (joinBefore ? 2 : 0),
parent = range.parent;
for (var i$2 = range.startIndex,
e = range.endIndex,
first = true; i$2 < e; i$2++, first = false) {
if (!first && canSplit(tr.doc, splitPos, splitDepth)) {
tr.split(splitPos, splitDepth);
}
splitPos += parent.child(i$2).nodeSize + (first ? 0 : 2 * splitDepth);
}
return tr;
}
function splitListItem(nodeType) {
return function(state, dispatch) {
var ref = state.selection;
var $from = ref.$from;
var $to = ref.$to;
var node = ref.node;
if ((node && node.isBlock) || !$from.parent.content.size || $from.depth < 2 || !$from.sameParent($to)) {
return false;
}
var grandParent = $from.node(-1);
if (grandParent.type != nodeType) {
return false;
}
var nextType = $to.pos == $from.end() ? grandParent.defaultContentType($from.indexAfter(-1)) : null;
var tr = state.tr.delete($from.pos, $to.pos);
var types = nextType && [null, {type: nextType}];
if (!canSplit(tr.doc, $from.pos, 2, types)) {
return false;
}
if (dispatch) {
dispatch(tr.split($from.pos, 2, types).scrollIntoView());
}
return true;
};
}
exports.splitListItem = splitListItem;
function liftListItem(nodeType) {
return function(state, dispatch) {
var ref = state.selection;
var $from = ref.$from;
var $to = ref.$to;
var range = $from.blockRange($to, function(node) {
return node.childCount && node.firstChild.type == nodeType;
});
if (!range || range.depth < 2 || $from.node(range.depth - 1).type != nodeType) {
return false;
}
if (dispatch) {
var tr = state.tr,
end = range.end,
endOfList = $to.end(range.depth);
if (end < endOfList) {
tr.step(new ReplaceAroundStep(end - 1, endOfList, end, endOfList, new Slice(Fragment.from(nodeType.create(null, range.parent.copy())), 1, 0), 1, true));
range = new NodeRange(tr.doc.resolveNoCache($from.pos), tr.doc.resolveNoCache(endOfList), range.depth);
}
dispatch(tr.lift(range, liftTarget(range)).scrollIntoView());
}
return true;
};
}
exports.liftListItem = liftListItem;
function sinkListItem(nodeType) {
return function(state, dispatch) {
var ref = state.selection;
var $from = ref.$from;
var $to = ref.$to;
var range = $from.blockRange($to, function(node) {
return node.childCount && node.firstChild.type == nodeType;
});
if (!range) {
return false;
}
var startIndex = range.startIndex;
if (startIndex == 0) {
return false;
}
var parent = range.parent,
nodeBefore = parent.child(startIndex - 1);
if (nodeBefore.type != nodeType) {
return false;
}
if (dispatch) {
var nestedBefore = nodeBefore.lastChild && nodeBefore.lastChild.type == parent.type;
var inner = Fragment.from(nestedBefore ? nodeType.create() : null);
var slice = new Slice(Fragment.from(nodeType.create(null, Fragment.from(parent.copy(inner)))), nestedBefore ? 3 : 1, 0);
var before = range.start,
after = range.end;
dispatch(state.tr.step(new ReplaceAroundStep(before - (nestedBefore ? 3 : 1), after, before, after, slice, 1, true)).scrollIntoView());
}
return true;
};
}
exports.sinkListItem = sinkListItem;
return module.exports;
});
$__System.registerDynamic("2a", ["4f"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
module.exports = $__require('4f');
return module.exports;
});
$__System.register("50", ["3", "4", "7", "11", "26", "37", "2a"], function (_export) {
"use strict";
var Schema, DOMParser, DOMSerializer, baseSchema, EditorState, EditorView, MenuBarEditorView, exampleSetup, buildMenuItems, addListNodes, schema, proseMirrorMap, parser;
_export("getProseMirror", getProseMirror);
_export("getPMContent", getPMContent);
_export("createProseMirror", createProseMirror);
function getProseMirror(id) {
return proseMirrorMap[id];
}
function getPMContent(id) {
var pm = proseMirrorMap[id];
var fragment = DOMSerializer.fromSchema(schema).serializeFragment(pm.editor.state.doc.content);
var tmp = document.createElement("div");
tmp.appendChild(fragment);
return tmp.innerHTML;
}
function createProseMirror(id, opts) {
var place = document.getElementById(id);
proseMirrorMap[id] = new MenuBarEditorView(place, {
floatingMenu: true,
//menuContent: buildMenuItems(schema).fullMenu,
state: EditorState.create({
//schema: schema,
doc: parser(place),
plugins: exampleSetup({ schema: schema })
}),
onAction: function onAction(action) {
proseMirrorMap[id].updateState(proseMirrorMap[id].editor.state.applyAction(action));
}
});
return proseMirrorMap[id];
}
return {
setters: [function (_4) {
Schema = _4.Schema;
DOMParser = _4.DOMParser;
DOMSerializer = _4.DOMSerializer;
}, function (_5) {
baseSchema = _5.schema;
}, function (_) {
EditorState = _.EditorState;
}, function (_3) {
EditorView = _3.EditorView;
}, function (_2) {
MenuBarEditorView = _2.MenuBarEditorView;
}, function (_6) {
exampleSetup = _6.exampleSetup;
buildMenuItems = _6.buildMenuItems;
}, function (_a) {
addListNodes = _a.addListNodes;
}],
execute: function () {
schema = new Schema({
nodes: addListNodes(baseSchema.nodeSpec, "paragraph block*", "block"),
marks: baseSchema.markSpec
});
proseMirrorMap = {};
;
;
parser = function parser(slot) {
var content = $(slot).find('.d0-card-content').val();
var domNode = document.createElement("div");
domNode.innerHTML = content;
return DOMParser.fromSchema(schema).parse(domNode);
};
;
}
};
});
$__System.registerDynamic("1", ["50"], true, function($__require, exports, module) {
;
var define,
global = this,
GLOBAL = this;
pm = $__require('50');
createProseMirror = pm.createProseMirror;
getProseMirror = pm.getProseMirror;
getProseMirrorContent = pm.getPMContent;
return module.exports;
});
})
(function(factory) {
factory();
});
//# sourceMappingURL=script_prosemirror.js.map
//script: tinymce
// 4.7.2 (2017-11-07)
!function(){var a={},b=function(b){for(var c=a[b],e=c.deps,f=c.defn,g=e.length,h=new Array(g),i=0;i-1},h=function(a,b){return t(a,b).isSome()},i=function(a,b){for(var c=[],d=0;d=0;c--){var d=a[c];b(d,c,a)}},n=function(a,b){for(var c=[],d=[],e=0,f=a.length;e=534;return{opera:f,webkit:g,ie:h,gecko:k,mac:l,iOS:m,android:n,contentEditable:v,transparentSrc:"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",caretAfter:8!=h,range:e.getSelection&&"Range"in e,documentMode:h&&!j?b.documentMode||7:10,fileApi:o,ceFalse:h===!1||h>8,canHaveCSP:h===!1||h>11,desktop:!p&&!q,windowsPhone:r}}),h("1n",clearInterval),h("1o",clearTimeout),h("1p",setInterval),h("1q",setTimeout),g("1d",[],function(){function a(a,b){return function(){a.apply(b,arguments)}}function b(b){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof b)throw new TypeError("not a function");this._state=null,this._value=null,this._deferreds=[],h(b,a(d,this),a(e,this))}function c(a){var b=this;return null===this._state?void this._deferreds.push(a):void i(function(){var c=b._state?a.onFulfilled:a.onRejected;if(null===c)return void(b._state?a.resolve:a.reject)(b._value);var d;try{d=c(b._value)}catch(b){return void a.reject(b)}a.resolve(d)})}function d(b){try{if(b===this)throw new TypeError("A promise cannot be resolved with itself.");if(b&&("object"==typeof b||"function"==typeof b)){var c=b.then;if("function"==typeof c)return void h(a(c,b),a(d,this),a(e,this))}this._state=!0,this._value=b,f.call(this)}catch(a){e.call(this,a)}}function e(a){this._state=!1,this._value=a,f.call(this)}function f(){for(var a=0,b=this._deferreds.length;a0&&(d=c[0]),a.deepPath&&(c=a.deepPath(),c&&c.length>0&&(d=c[0])),d},n=function(b,d){var e,k,l=d||{};for(e in b)g[e]||(l[e]=b[e]);if(l.target||(l.target=l.srcElement||a),c.experimentalShadowDom&&(l.target=m(b,l.target)),b&&f.test(b.type)&&b.pageX===k&&b.clientX!==k){var n=l.target.ownerDocument||a,o=n.documentElement,p=n.body;l.pageX=b.clientX+(o&&o.scrollLeft||p&&p.scrollLeft||0)-(o&&o.clientLeft||p&&p.clientLeft||0),l.pageY=b.clientY+(o&&o.scrollTop||p&&p.scrollTop||0)-(o&&o.clientTop||p&&p.clientTop||0)}return l.preventDefault=function(){l.isDefaultPrevented=j,b&&(b.preventDefault?b.preventDefault():b.returnValue=!1)},l.stopPropagation=function(){l.isPropagationStopped=j,b&&(b.stopPropagation?b.stopPropagation():b.cancelBubble=!0)},l.stopImmediatePropagation=function(){l.isImmediatePropagationStopped=j,l.stopPropagation()},h(l)===!1&&(l.isDefaultPrevented=i,l.isPropagationStopped=i,l.isImmediatePropagationStopped=i),"undefined"==typeof l.metaKey&&(l.metaKey=!1),l},o=function(a,b,e){var f=a.document,g={type:"ready"};if(e.domLoaded)return void b(g);var h=function(){return"complete"===f.readyState||"interactive"===f.readyState&&f.body},i=function(){e.domLoaded||(e.domLoaded=!0,b(g))},j=function(){h()&&(l(f,"readystatechange",j),i())},m=function(){try{f.documentElement.doScroll("left")}catch(a){return void d.setTimeout(m)}i()};!f.addEventListener||c.ie&&c.ie<11?(k(f,"readystatechange",j),f.documentElement.doScroll&&a.self===a.top&&m()):h()?i():k(a,"DOMContentLoaded",i),k(a,"load",i)},p=function(){var c,d,f,g,h,i=this,j={};d=e+(+new Date).toString(32),g="onmouseenter"in a.documentElement,f="onfocusin"in a.documentElement,h={mouseenter:"mouseover",mouseleave:"mouseout"},c=1,i.domLoaded=!1,i.events=j;var m=function(a,b){var c,d,e,f,g=j[b];if(c=g&&g[a.type])for(d=0,e=c.length;dt.cacheLength&&delete a[b.shift()],a[c+" "]=d}var b=[];return a}function c(a){return a[K]=!0,a}function d(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||T)-(~a.sourceIndex||T);if(d)return d;if(c)for(;c=c.nextSibling;)if(c===b)return-1;return a?1:-1}function e(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function f(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function g(a){return c(function(b){return b=+b,c(function(c,d){for(var e,f=a([],c.length,b),g=f.length;g--;)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function h(a){return a&&typeof a.getElementsByTagName!==S&&a}function i(){}function j(a){for(var b=0,c=a.length,d="";b1?function(b,c,d){for(var e=a.length;e--;)if(!a[e](b,c,d))return!1;return!0}:a[0]}function m(b,c,d){for(var e=0,f=c.length;e-1&&(c[j]=!(g[j]=l))}}else t=n(t===g?t.splice(q,t.length):t),f?f(null,g,t,i):Y.apply(g,t)})}function p(a){for(var b,c,d,e=a.length,f=t.relative[a[0].type],g=f||t.relative[" "],h=f?1:0,i=k(function(a){return a===b},g,!0),m=k(function(a){return $.call(b,a)>-1},g,!0),n=[function(a,c,d){return!f&&(d||c!==z)||((b=c).nodeType?i(a,c,d):m(a,c,d))}];h1&&l(n),h>1&&j(a.slice(0,h-1).concat({value:" "===a[h-2].type?"*":""})).replace(ea,"$1"),c,h0,f=b.length>0,g=function(c,g,h,i,j){var k,l,m,o=0,p="0",q=c&&[],r=[],s=z,u=c||f&&t.find.TAG("*",j),v=M+=null==s?1:Math.random()||.1,w=u.length;for(j&&(z=g!==D&&g);p!==w&&null!=(k=u[p]);p++){if(f&&k){for(l=0;m=b[l++];)if(m(k,g,h)){i.push(k);break}j&&(M=v)}e&&((k=!m&&k)&&o--,c&&q.push(k))}if(o+=p,e&&p!==o){for(l=0;m=d[l++];)m(q,r,g,h);if(c){if(o>0)for(;p--;)q[p]||r[p]||(r[p]=W.call(i));r=n(r)}Y.apply(i,r),j&&!c&&r.length>0&&o+d.length>1&&a.uniqueSort(i)}return j&&(M=v,z=s),q};return e?c(g):g}var r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K="sizzle"+-new Date,L=window.document,M=0,N=0,O=b(),P=b(),Q=b(),R=function(a,b){return a===b&&(B=!0),0},S="undefined",T=1<<31,U={}.hasOwnProperty,V=[],W=V.pop,X=V.push,Y=V.push,Z=V.slice,$=V.indexOf||function(a){for(var b=0,c=this.length;b+~]|"+aa+")"+aa+"*"),ha=new RegExp("="+aa+"*([^\\]'\"]*?)"+aa+"*\\]","g"),ia=new RegExp(da),ja=new RegExp("^"+ba+"$"),ka={ID:new RegExp("^#("+ba+")"),CLASS:new RegExp("^\\.("+ba+")"),TAG:new RegExp("^("+ba+"|[*])"),ATTR:new RegExp("^"+ca),PSEUDO:new RegExp("^"+da),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+aa+"*(even|odd|(([+-]|)(\\d*)n|)"+aa+"*(?:([+-]|)"+aa+"*(\\d+)|))"+aa+"*\\)|)","i"),bool:new RegExp("^(?:"+_+")$","i"),needsContext:new RegExp("^"+aa+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+aa+"*((?:-\\d)?\\d*)"+aa+"*\\)|)(?=[^-]|$)","i")},la=/^(?:input|select|textarea|button)$/i,ma=/^h\d$/i,na=/^[^{]+\{\s*\[native \w/,oa=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,pa=/[+~]/,qa=/'|\\/g,ra=new RegExp("\\\\([\\da-f]{1,6}"+aa+"?|("+aa+")|.)","ig"),sa=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:d<0?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)};try{Y.apply(V=Z.call(L.childNodes),L.childNodes),V[L.childNodes.length].nodeType}catch(a){Y={apply:V.length?function(a,b){X.apply(a,Z.call(b))}:function(a,b){for(var c=a.length,d=0;a[c++]=b[d++];);a.length=c-1}}}s=a.support={},v=a.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return!!b&&"HTML"!==b.nodeName},C=a.setDocument=function(a){function b(a){try{return a.top}catch(a){}return null}var c,e=a?a.ownerDocument||a:L,f=e.defaultView;return e!==D&&9===e.nodeType&&e.documentElement?(D=e,E=e.documentElement,F=!v(e),f&&f!==b(f)&&(f.addEventListener?f.addEventListener("unload",function(){C()},!1):f.attachEvent&&f.attachEvent("onunload",function(){C()})),s.attributes=!0,s.getElementsByTagName=!0,s.getElementsByClassName=na.test(e.getElementsByClassName),s.getById=!0,t.find.ID=function(a,b){if(typeof b.getElementById!==S&&F){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},t.filter.ID=function(a){var b=a.replace(ra,sa);return function(a){return a.getAttribute("id")===b}},t.find.TAG=s.getElementsByTagName?function(a,b){if(typeof b.getElementsByTagName!==S)return b.getElementsByTagName(a)}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){for(;c=f[e++];)1===c.nodeType&&d.push(c);return d}return f},t.find.CLASS=s.getElementsByClassName&&function(a,b){if(F)return b.getElementsByClassName(a)},H=[],G=[],s.disconnectedMatch=!0,G=G.length&&new RegExp(G.join("|")),H=H.length&&new RegExp(H.join("|")),c=na.test(E.compareDocumentPosition),J=c||na.test(E.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)for(;b=b.parentNode;)if(b===a)return!0;return!1},R=c?function(a,b){if(a===b)return B=!0,0;var c=!a.compareDocumentPosition-!b.compareDocumentPosition;return c?c:(c=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&c||!s.sortDetached&&b.compareDocumentPosition(a)===c?a===e||a.ownerDocument===L&&J(L,a)?-1:b===e||b.ownerDocument===L&&J(L,b)?1:A?$.call(A,a)-$.call(A,b):0:4&c?-1:1)}:function(a,b){if(a===b)return B=!0,0;var c,f=0,g=a.parentNode,h=b.parentNode,i=[a],j=[b];if(!g||!h)return a===e?-1:b===e?1:g?-1:h?1:A?$.call(A,a)-$.call(A,b):0;if(g===h)return d(a,b);for(c=a;c=c.parentNode;)i.unshift(c);for(c=b;c=c.parentNode;)j.unshift(c);for(;i[f]===j[f];)f++;return f?d(i[f],j[f]):i[f]===L?-1:j[f]===L?1:0},e):D},a.matches=function(b,c){return a(b,null,null,c)},a.matchesSelector=function(b,c){if((b.ownerDocument||b)!==D&&C(b),c=c.replace(ha,"='$1']"),s.matchesSelector&&F&&(!H||!H.test(c))&&(!G||!G.test(c)))try{var d=I.call(b,c);if(d||s.disconnectedMatch||b.document&&11!==b.document.nodeType)return d}catch(a){}return a(c,D,null,[b]).length>0},a.contains=function(a,b){return(a.ownerDocument||a)!==D&&C(a),J(a,b)},a.attr=function(a,b){(a.ownerDocument||a)!==D&&C(a);var c=t.attrHandle[b.toLowerCase()],d=c&&U.call(t.attrHandle,b.toLowerCase())?c(a,b,!F):void 0;return void 0!==d?d:s.attributes||!F?a.getAttribute(b):(d=a.getAttributeNode(b))&&d.specified?d.value:null},a.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},a.uniqueSort=function(a){var b,c=[],d=0,e=0;if(B=!s.detectDuplicates,A=!s.sortStable&&a.slice(0),a.sort(R),B){for(;b=a[e++];)b===a[e]&&(d=c.push(e));for(;d--;)a.splice(c[d],1)}return A=null,a},u=a.getText=function(a){var b,c="",d=0,e=a.nodeType;if(e){if(1===e||9===e||11===e){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=u(a)}else if(3===e||4===e)return a.nodeValue}else for(;b=a[d++];)c+=u(b);return c},t=a.selectors={cacheLength:50,createPseudo:c,match:ka,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(ra,sa),a[3]=(a[3]||a[4]||a[5]||"").replace(ra,sa),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(b){return b[1]=b[1].toLowerCase(),"nth"===b[1].slice(0,3)?(b[3]||a.error(b[0]),b[4]=+(b[4]?b[5]+(b[6]||1):2*("even"===b[3]||"odd"===b[3])),b[5]=+(b[7]+b[8]||"odd"===b[3])):b[3]&&a.error(b[0]),b},PSEUDO:function(a){var b,c=!a[6]&&a[2];return ka.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&ia.test(c)&&(b=w(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(ra,sa).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=O[a+" "];return b||(b=new RegExp("(^|"+aa+")"+a+"("+aa+"|$)"))&&O(a,function(a){return b.test("string"==typeof a.className&&a.className||typeof a.getAttribute!==S&&a.getAttribute("class")||"")})},ATTR:function(b,c,d){return function(e){var f=a.attr(e,b);return null==f?"!="===c:!c||(f+="","="===c?f===d:"!="===c?f!==d:"^="===c?d&&0===f.indexOf(d):"*="===c?d&&f.indexOf(d)>-1:"$="===c?d&&f.slice(-d.length)===d:"~="===c?(" "+f+" ").indexOf(d)>-1:"|="===c&&(f===d||f.slice(0,d.length+1)===d+"-"))}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){for(;p;){for(l=b;l=l[p];)if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){for(k=q[K]||(q[K]={}),j=k[a]||[],n=j[0]===M&&j[1],m=j[0]===M&&j[2],l=n&&q.childNodes[n];l=++n&&l&&l[p]||(m=n=0)||o.pop();)if(1===l.nodeType&&++m&&l===b){k[a]=[M,n,m];break}}else if(s&&(j=(b[K]||(b[K]={}))[a])&&j[0]===M)m=j[1];else for(;(l=++n&&l&&l[p]||(m=n=0)||o.pop())&&((h?l.nodeName.toLowerCase()!==r:1!==l.nodeType)||!++m||(s&&((l[K]||(l[K]={}))[a]=[M,m]),l!==b)););return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(b,d){var e,f=t.pseudos[b]||t.setFilters[b.toLowerCase()]||a.error("unsupported pseudo: "+b);return f[K]?f(d):f.length>1?(e=[b,b,"",d],t.setFilters.hasOwnProperty(b.toLowerCase())?c(function(a,b){for(var c,e=f(a,d),g=e.length;g--;)c=$.call(a,e[g]),a[c]=!(b[c]=e[g])}):function(a){return f(a,0,e)}):f}},pseudos:{not:c(function(a){var b=[],d=[],e=x(a.replace(ea,"$1"));return e[K]?c(function(a,b,c,d){for(var f,g=e(a,null,d,[]),h=a.length;h--;)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,c,f){return b[0]=a,e(b,null,f,d),!d.pop()}}),has:c(function(b){return function(c){return a(b,c).length>0}}),contains:c(function(a){return a=a.replace(ra,sa),function(b){return(b.textContent||b.innerText||u(b)).indexOf(a)>-1}}),lang:c(function(b){return ja.test(b||"")||a.error("unsupported lang: "+b),b=b.replace(ra,sa).toLowerCase(),function(a){var c;do if(c=F?a.lang:a.getAttribute("xml:lang")||a.getAttribute("lang"))return c=c.toLowerCase(),c===b||0===c.indexOf(b+"-");while((a=a.parentNode)&&1===a.nodeType);return!1}}),target:function(a){var b=window.location&&window.location.hash;return b&&b.slice(1)===a.id},root:function(a){return a===E},focus:function(a){return a===D.activeElement&&(!D.hasFocus||D.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!t.pseudos.empty(a)},header:function(a){return ma.test(a.nodeName)},input:function(a){return la.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:g(function(){return[0]}),last:g(function(a,b){return[b-1]}),eq:g(function(a,b,c){return[c<0?c+b:c]}),even:g(function(a,b){for(var c=0;c=0;)a.push(d);return a}),gt:g(function(a,b,c){for(var d=c<0?c+b:c;++d2&&"ID"===(g=f[0]).type&&s.getById&&9===b.nodeType&&F&&t.relative[f[1].type]){if(b=(t.find.ID(g.matches[0].replace(ra,sa),b)||[])[0],!b)return c;l&&(b=b.parentNode),a=a.slice(f.shift().value.length)}for(e=ka.needsContext.test(a)?0:f.length;e--&&(g=f[e],!t.relative[i=g.type]);)if((k=t.find[i])&&(d=k(g.matches[0].replace(ra,sa),pa.test(f[0].type)&&h(b.parentNode)||b))){if(f.splice(e,1),a=d.length&&j(f),!a)return Y.apply(c,d),c;break}}return(l||x(a,m))(d,b,!F,c,pa.test(a)&&h(b.parentNode)||b),c},s.sortStable=K.split("").sort(R).join("")===K,s.detectDuplicates=!!B,C(),s.sortDetached=!0,a}),g("1r",[],function(){var a=Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)},b=function(b){var c,d,e=b;if(!a(b))for(e=[],c=0,d=b.length;c)[^>]*$|#([\w\-]*)$)/,k=b.Event,l=e.makeMap("children,contents,next,prev"),m=function(a){return"undefined"!=typeof a},n=function(a){return"string"==typeof a},o=function(a){return a&&a==a.window},p=function(a,b){var c,d,e;for(b=b||g,e=b.createElement("div"),c=b.createDocumentFragment(),e.innerHTML=a;d=e.firstChild;)c.appendChild(d);return c},q=function(a,b,c,d){var e;if(n(b))b=p(b,F(a[0]));else if(b.length&&!b.nodeType){if(b=z.makeArray(b),d)for(e=b.length-1;e>=0;e--)q(a,b[e],c,d);else for(e=0;e"===b.charAt(b.length-1)&&b.length>=3?[null,b,null]:j.exec(b),!d)return z(c).find(b);if(d[1])for(e=p(b,F(c)).firstChild;e;)h.call(f,e),e=e.nextSibling;else{if(e=F(c).getElementById(d[2]),!e)return f;if(e.id!==d[2])return f.find(b);f.length=1,f[0]=e}}else this.add(b,!1);return f},toArray:function(){return e.toArray(this)},add:function(a,b){var c,d,e=this;if(n(a))return e.add(z(a));if(b!==!1)for(c=z.unique(e.toArray().concat(z.makeArray(a))),e.length=c.length,d=0;d1&&(l[a]||(e=z.unique(e)),0===a.indexOf("parents")&&(e=e.reverse())),e=z(e),c?e.filter(c):e}}),D({parentsUntil:function(a,b){return G(a,"parentNode",b)},nextUntil:function(a,b){return H(a,"nextSibling",1,b).slice(1)},prevUntil:function(a,b){return H(a,"previousSibling",1,b).slice(1)}},function(a,b){z.fn[a]=function(c,d){var e=this,f=[];return e.each(function(){var a=b.call(f,this,c,f);a&&(z.isArray(a)?f.push.apply(f,a):f.push(a))}),this.length>1&&(f=z.unique(f),0!==a.indexOf("parents")&&"prevUntil"!==a||(f=f.reverse())),f=z(f),d?f.filter(d):f}}),z.fn.is=function(a){return!!a&&this.filter(a).length>0},z.fn.init.prototype=z.fn,z.overrideDefaults=function(a){var b,c=function(d,e){return b=b||a(),0===arguments.length&&(d=b.element),e||(e=b.context),new c.fn.init(d,e)};return z.extend(c,this),c};var J=function(a,b,c){D(c,function(c,d){a[c]=a[c]||{},a[c][b]=d})};return d.ie&&d.ie<8&&(J(x,"get",{maxlength:function(a){var b=a.maxLength;return 2147483647===b?f:b},size:function(a){var b=a.size;return 20===b?f:b},"class":function(a){return a.className},style:function(a){var b=a.style.cssText;return 0===b.length?f:b}}),J(x,"set",{"class":function(a,b){a.className=b},style:function(a,b){a.style.cssText=b}})),d.ie&&d.ie<9&&(w["float"]="styleFloat",J(y,"set",{opacity:function(a,b){var c=a.style;null===b||""===b?c.removeAttribute("filter"):(c.zoom=1,c.filter="alpha(opacity="+100*b+")")}})),z.attrHooks=x,z.cssHooks=y,z}),g("4r",[],function(){var a=function(a){var b,c=!1;return function(){return c||(c=!0,b=a.apply(null,arguments)),b}};return{cached:a}}),h("6v",Number),g("6h",["1i","6v","3a"],function(a,b,c){var d=function(a,b){for(var c=0;c1)throw c.error("HTML does not have a single root node",a),"HTML must have a single root node";return h(f.childNodes[0])},f=function(a,b){var c=b||d,e=c.createElement(a);return h(e)},g=function(a,b){var c=b||d,e=c.createTextNode(a);return h(e)},h=function(c){if(null===c||void 0===c)throw new b("Node cannot be null or undefined");return{dom:a.constant(c)}};return{fromHtml:e,fromTag:f,fromText:g,fromDom:h}}),g("4b",[],function(){return{ATTRIBUTE:2,CDATA_SECTION:4,COMMENT:8,DOCUMENT:9,DOCUMENT_TYPE:10,DOCUMENT_FRAGMENT:11,ELEMENT:1,TEXT:3,PROCESSING_INSTRUCTION:7,ENTITY_REFERENCE:5,ENTITY:6,NOTATION:12}}),g("3e",["4b"],function(a){var b=function(a){var b=a.dom().nodeName;return b.toLowerCase()},c=function(a){return a.dom().nodeType},d=function(a){return a.dom().nodeValue},e=function(a){return function(b){return c(b)===a}},f=function(d){return c(d)===a.COMMENT||"#comment"===b(d)},g=e(a.ELEMENT),h=e(a.TEXT),i=e(a.DOCUMENT);return{name:b,type:c,value:d,isElement:g,isText:h,isDocument:i,isComment:f}}),g("27",["4","3a"],function(a,b){var c=function(c){if(null===c)return"null";var d=typeof c;return"object"===d&&a.prototype.isPrototypeOf(c)?"array":"object"===d&&b.prototype.isPrototypeOf(c)?"string":d},d=function(a){return function(b){return c(b)===a}};return{isString:d("string"),isObject:d("object"),isArray:d("array"),isNull:d("null"),isBoolean:d("boolean"),isUndefined:d("undefined"),isFunction:d("function"),isNumber:d("number")}}),g("4e",["2m","39"],function(a,b){var c=function(){var a=b.keys,c=function(a){var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(c);return b};return void 0===a?c:a}(),d=function(a,b){for(var d=c(a),e=0,f=d.length;e0})},v=function(a){var b={},c=a.dom();if(i.isSupported(c))for(var d=0;d0&&e.unsuppMessage(m);var n={};return a.each(h,function(a){n[a]=b.constant(f[a])}),a.each(i,function(a){n[a]=b.constant(g.prototype.hasOwnProperty.call(f,a)?d.some(f[a]):d.none())}),n}}}),g("44",["4x","4y"],function(a,b){return{immutable:a,immutableBag:b}}),g("4z",[],function(){var a=function(a,b){var c=[],d=function(a){return c.push(a),b(a)},e=b(a);do e=e.bind(d);while(e.isSome());return c};return{toArray:a}}),g("4a",["3b"],function(a){var b=function(){var b=a.getOrDie("Node");return b},c=function(a,b,c){return 0!==(a.compareDocumentPosition(b)&c)},d=function(a,d){return c(a,d,b().DOCUMENT_POSITION_PRECEDING)},e=function(a,d){return c(a,d,b().DOCUMENT_POSITION_CONTAINED_BY)};return{documentPositionPreceding:d,documentPositionContainedBy:e}}),g("30",["1i","2m","1v","4b","5","1j"],function(a,b,c,d,e,f){var g=0,h=1,i=2,j=3,k=function(){var a=f.createElement("span");return void 0!==a.matches?g:void 0!==a.msMatchesSelector?h:void 0!==a.webkitMatchesSelector?i:void 0!==a.mozMatchesSelector?j:-1}(),l=d.ELEMENT,m=d.DOCUMENT,n=function(a,b){var c=a.dom();if(c.nodeType!==l)return!1;if(k===g)return c.matches(b);if(k===h)return c.msMatchesSelector(b);if(k===i)return c.webkitMatchesSelector(b);if(k===j)return c.mozMatchesSelector(b);throw new e("Browser lacks native selectors")},o=function(a){return a.nodeType!==l&&a.nodeType!==m||0===a.childElementCount},p=function(b,d){var e=void 0===d?f:d.dom();return o(e)?[]:a.map(e.querySelectorAll(b),c.fromDom)},q=function(a,d){var e=void 0===d?f:d.dom();return o(e)?b.none():b.from(e.querySelector(a)).map(c.fromDom)};return{all:p,is:n,one:q}}),g("32",["1i","1","4a","3c","30"],function(a,b,c,d,e){var f=function(a,b){return a.dom()===b.dom()},g=function(a,b){return a.dom().isEqualNode(b.dom())},h=function(c,d){return a.exists(d,b.curry(f,c))},i=function(a,b){var c=a.dom(),d=b.dom();return c!==d&&c.contains(d)},j=function(a,b){return c.documentPositionContainedBy(a.dom(),b.dom())},k=d.detect().browser,l=k.isIE()?j:i;return{eq:f,isEqualNode:g,member:h,contains:l,is:e.is}}),g("3g",["27","1i","1","2m","44","4z","32","1v"],function(a,b,c,d,e,f,g,h){var i=function(a){return h.fromDom(a.dom().ownerDocument)},j=function(a){var b=i(a);return h.fromDom(b.dom().documentElement)},k=function(a){var b=a.dom(),c=b.ownerDocument.defaultView;return h.fromDom(c)},l=function(a){var b=a.dom();return d.from(b.parentNode).map(h.fromDom)},m=function(a){return l(a).bind(function(c){var d=u(c);return b.findIndex(d,function(b){return g.eq(a,b)})})},n=function(b,d){for(var e=a.isFunction(d)?d:c.constant(!1),f=b.dom(),g=[];null!==f.parentNode&&void 0!==f.parentNode;){var i=f.parentNode,j=h.fromDom(i);if(g.push(j),e(j)===!0)break;f=i}return g},o=function(a){var c=function(c){return b.filter(c,function(b){return!g.eq(a,b)})};return l(a).map(u).map(c).getOr([])},p=function(a){var b=a.dom();return d.from(b.offsetParent).map(h.fromDom)},q=function(a){var b=a.dom();return d.from(b.previousSibling).map(h.fromDom)},r=function(a){var b=a.dom();return d.from(b.nextSibling).map(h.fromDom)},s=function(a){return b.reverse(f.toArray(a,q))},t=function(a){return f.toArray(a,r)},u=function(a){var c=a.dom();return b.map(c.childNodes,h.fromDom)},v=function(a,b){var c=a.dom().childNodes;return d.from(c[b]).map(h.fromDom)},w=function(a){return v(a,0)},x=function(a){return v(a,a.dom().childNodes.length-1)},y=function(a,b){return a.dom().childNodes.length},z=e.immutable("element","offset"),A=function(a,b){var c=u(a);return c.length>0&&b=b.length&&c(d)}};0===b.length?c([]):a.each(b,function(a,b){a.get(f(b))})})};return{par:b}}),g("3i",["1i","3h","52"],function(a,b,c){var d=function(a){return c.par(a,b.nu)},e=function(b,c){var e=a.map(b,c);return d(e)},f=function(a,b){return function(c){return b(c).bind(a)}};return{par:d,mapM:e,compose:f}}),g("3j",["1","2m"],function(a,b){var c=function(d){var e=function(a){return d===a},f=function(a){return c(d)},g=function(a){return c(d)},h=function(a){return c(a(d))},i=function(a){a(d)},j=function(a){return a(d)},k=function(a,b){return b(d)},l=function(a){return a(d)},m=function(a){return a(d)},n=function(){return b.some(d)};return{is:e,isValue:a.constant(!0),isError:a.constant(!1),getOr:a.constant(d),getOrThunk:a.constant(d),getOrDie:a.constant(d),or:f,orThunk:g,fold:k,map:h,each:i,bind:j,exists:l,forall:m,toOption:n}},d=function(c){var e=function(a){return a()},f=function(){return a.die(c)()},g=function(a){return a},h=function(a){return a()},i=function(a){return d(c)},j=function(a){return d(c)},k=function(a,b){return a(c)};return{is:a.constant(!1),isValue:a.constant(!1),isError:a.constant(!0),getOr:a.identity,getOrThunk:e,getOrDie:f,or:g,orThunk:h,fold:k,map:i,each:a.noop,bind:j,exists:a.constant(!1),forall:a.constant(!0),toOption:b.none}};return{value:c,error:d}}),g("1t",["1i","1","3h","3i","3j","1m","15","1e"],function(a,b,c,d,e,f,g,h){"use strict";return function(i,j){var k,l=0,m={};j=j||{},k=j.maxLoadTime||5e3;var n=function(a){i.getElementsByTagName("head")[0].appendChild(a)},o=function(a,b,c){var d,e,j,o,p=function(){for(var a=o.passed,b=a.length;b--;)a[b]();o.status=2,o.passed=[],o.failed=[]},q=function(){for(var a=o.failed,b=a.length;b--;)a[b]();o.status=3,o.passed=[],o.failed=[]},r=function(){var a=f.userAgent.match(/WebKit\/(\d*)/);return!!(a&&a[1]<536)},s=function(a,b){a()||((new Date).getTime()-j0)return e=i.createElement("style"),e.textContent='@import "'+a+'"',u(),void n(e);t()}n(d),d.href=a}},p=function(a){return c.nu(function(c){o(a,b.compose(c,b.constant(e.value(a))),b.compose(c,b.constant(e.error(a))))})},q=function(a){return a.fold(b.identity,b.identity)},r=function(b,c,e){d.par(a.map(b,p)).get(function(b){var d=a.partition(b,function(a){return a.isValue()});d.fail.length>0?e(d.fail.map(q)):c(d.pass.map(q))})};return{load:o,loadAll:r}}}),g("s",[],function(){return function(a,b){var c=a,d=function(a,c,d,e){var f,g;if(a){if(!e&&a[c])return a[c];if(a!=b){if(f=a[d])return f;for(g=a.parentNode;g&&g!=b;g=g.parentNode)if(f=g[d])return f}}},e=function(a,c,d,e){var f,g,h;if(a){if(f=a[d],b&&f===b)return;if(f){if(!e)for(h=f[c];h;h=h[c])if(!h[c])return h;return f}if(g=a.parentNode,g&&g!==b)return g}};this.current=function(){return c},this.next=function(a){return c=d(c,"firstChild","nextSibling",a)},this.prev=function(a){return c=d(c,"lastChild","previousSibling",a)},this.prev2=function(a){return c=e(c,"lastChild","previousSibling",a)}}}),g("3k",["1i","1","3e"],function(a,b,c){var d=["article","aside","details","div","dt","figcaption","footer","form","fieldset","header","hgroup","html","main","nav","section","summary","body","p","dl","multicol","dd","figure","address","center","blockquote","h1","h2","h3","h4","h5","h6","listing","xmp","pre","plaintext","menu","dir","ul","ol","li","hr","table","tbody","thead","tfoot","th","tr","td","caption"],e=["area","base","basefont","br","col","frame","hr","img","input","isindex","link","meta","param","embed","source","wbr","track"],f=["td","th"],g=["thead","tbody","tfoot"],h=["h1","h2","h3","h4","h5","h6","p","div","address","pre","form","blockquote","center","dir","fieldset","header","footer","article","section","hgroup","aside","nav","figure"],i=["h1","h2","h3","h4","h5","h6"],j=["li","dd","dt"],k=["ul","ol","dl"],l=function(d){var e;return function(f){return e=e?e:a.mapToObject(d,b.constant(!0)),e.hasOwnProperty(c.name(f))}},m=l(i),n=l(d),o=function(a){return c.isElement(a)&&!n(a)},p=function(a){return c.isElement(a)&&"br"===c.name(a)};return{isBlock:n,isInline:o,isHeading:m,isTextBlock:l(h),isList:l(k),isListItem:l(j),isVoid:l(e),isTableSection:l(g),isTableCell:l(f),isBr:p}}),g("1y",[],function(){var a=function(a){return function(b){return!!b&&b.nodeType==a}},b=a(1),c=function(a){return a=a.toLowerCase().split(" "),function(b){var c,d;if(b&&b.nodeType)for(d=b.nodeName.toLowerCase(),c=0;c=0;j--)g(h,k[j]);if(c.isDocument(i)===!1){if(c.isText(i)&&i.nodeValue.length>0){var l=d.trim(i.nodeValue).length;if(h.isBlock(i.parentNode)||l>0)return;if(0===l&&e(i))return}else if(c.isElement(i)&&(k=i.childNodes,1===k.length&&f(k[0])&&i.parentNode.insertBefore(k[0],i),k.length||b.isVoid(a.fromDom(i))))return;h.remove(i)}return i}};return{trimNode:g}}),g("v",["1v","1e"],function(a,b){var c,d,e,f=b.makeMap,g=/[&<>\"\u0060\u007E-\uD7FF\uE000-\uFFEF]|[\uD800-\uDBFF][\uDC00-\uDFFF]/g,h=/[<>&\u007E-\uD7FF\uE000-\uFFEF]|[\uD800-\uDBFF][\uDC00-\uDFFF]/g,i=/[<>&\"\']/g,j=/([a-z0-9]+);?|&([a-z0-9]+);/gi,k={128:"\u20ac",130:"\u201a",131:"\u0192",132:"\u201e",133:"\u2026",134:"\u2020",135:"\u2021",136:"\u02c6",137:"\u2030",138:"\u0160",139:"\u2039",140:"\u0152",142:"\u017d",145:"\u2018",146:"\u2019",147:"\u201c",148:"\u201d",149:"\u2022",150:"\u2013",151:"\u2014",152:"\u02dc",153:"\u2122",154:"\u0161",155:"\u203a",156:"\u0153",158:"\u017e",159:"\u0178"};d={'"':""","'":"'","<":"<",">":">","&":"&","`":"`"},e={"<":"<",">":">","&":"&",""":'"',"'":"'"};var l=function(b){var c;return c=a.fromTag("div").dom(),c.innerHTML=b,c.textContent||c.innerText||b},m=function(a,b){var c,e,f,g={};if(a){for(a=a.split(","),b=b||10,c=0;c1?""+(1024*(a.charCodeAt(0)-55296)+(a.charCodeAt(1)-56320)+65536)+";":d[a]||""+a.charCodeAt(0)+";"})},encodeNamed:function(a,b,e){return e=e||c,a.replace(b?g:h,function(a){return d[a]||e[a]||a})},getEncodeFunc:function(a,b){b=m(b)||c;var e=function(a,c){return a.replace(c?g:h,function(a){return void 0!==d[a]?d[a]:void 0!==b[a]?b[a]:a.length>1?""+(1024*(a.charCodeAt(0)-55296)+(a.charCodeAt(1)-56320)+65536)+";":""+a.charCodeAt(0)+";"})},i=function(a,c){return n.encodeNamed(a,c,b)};return a=f(a.replace(/\+/g,",")),a.named&&a.numeric?e:a.named?b?i:n.encodeNamed:a.numeric?n.encodeNumeric:n.encodeRaw},decode:function(a){return a.replace(j,function(a,b){return b?(b="x"===b.charAt(0).toLowerCase()?parseInt(b.substr(1),16):parseInt(b,10),b>65535?(b-=65536,String.fromCharCode(55296+(b>>10),56320+(1023&b))):k[b]||String.fromCharCode(b)):e[a]||c[a]||l(a)})}};return n}),g("y",["1e"],function(a){var b={},c={},d=a.makeMap,e=a.each,f=a.extend,g=a.explode,h=a.inArray,i=function(b,c){return b=a.trim(b),b?b.split(c||" "):[]},j=function(a){var d,f,g,h,j,k,l={},m=function(a,b,e){var f,g,h,j=function(a,b){var c,d,e={};for(c=0,d=a.length;c]*>","gi")});var E=function(a){return new RegExp("^"+a.replace(/([?+*])/g,".$1")+"$")},F=function(a){var b,c,e,f,g,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x=/^([#+\-])?([^\[!\/]+)(?:\/([^\[!]+))?(?:(!?)\[([^\]]+)\])?$/,z=/^([!\-])?(\w+[\\:]:\w+|[^=:<]+)?(?:([=:<])(.*))?$/,B=/[*?+]/;if(a)for(a=i(a,","),y["@"]&&(t=y["@"].attributes,u=y["@"].attributesOrder),b=0,c=a.length;b1?a:"0"+a};return"#"+e(b)+e(c)+e(d)};return{toHex:function(a){return a.replace(g,m)},parse:function(b){var d,e,f,n,o={},p=a.url_converter,q=a.url_converter_scope||this,r=function(a,b,d){var e,f,g,h;if(e=o[a+"-top"+b],e&&(f=o[a+"-right"+b],f&&(g=o[a+"-bottom"+b],g&&(h=o[a+"-left"+b])))){var i=[e,f,g,h];for(c=i.length-1;c--&&i[c]===i[c+1];);c>-1&&d||(o[a+b]=c==-1?i[0]:i.join(" "),delete o[a+"-top"+b],delete o[a+"-right"+b],delete o[a+"-bottom"+b],delete o[a+"-left"+b])}},s=function(a){var b,c=o[a];if(c){for(c=c.split(" "),b=c.length;b--;)if(c[b]!==c[0])return!1;return o[a]=c[0],!0}},t=function(a,b,c,d){s(b)&&s(c)&&s(d)&&(o[a]=o[b]+" "+o[c]+" "+o[d],delete o[b],delete o[c],delete o[d])},u=function(a){return n=!0,k[a]},v=function(a,b){return n&&(a=a.replace(/\uFEFF[0-9]/g,function(a){return k[a]})),b||(a=a.replace(/\\([\'\";:])/g,"$1")),a},w=function(a){return String.fromCharCode(parseInt(a.slice(1),16))},x=function(a){return a.replace(/\\[0-9a-f]+/gi,w)},y=function(b,c,d,e,f,g){if(f=f||g)return f=v(f),"'"+f.replace(/\'/g,"\\'")+"'";if(c=v(c||d||e),!a.allow_script_urls){var h=c.replace(/[\s\r\n]+/g,"");if(/(java|vb)script:/i.test(h))return"";if(!a.allow_svg_data_urls&&/^data:image\/svg/i.test(h))return""}return p&&(c=p.call(q,c,"style")),"url('"+c.replace(/\'/g,"\\'")+"')"};if(b){for(b=b.replace(/[\u0000-\u001F]/g,""),b=b.replace(/\\[\"\';:\uFEFF]/g,u).replace(/\"[^\"]+\"|\'[^\']+\'/g,function(a){return a.replace(/[;:]/g,u)});d=i.exec(b);)if(i.lastIndex=d.index+d[0].length,e=d[1].replace(j,"").toLowerCase(),f=d[2].replace(j,""),e&&f){if(e=x(e),f=x(f),e.indexOf(l)!==-1||e.indexOf('"')!==-1)continue;if(!a.allow_script_urls&&("behavior"==e||/expression\s*\(|\/\*|\*\//.test(f)))continue;"font-weight"===e&&"700"===f?f="bold":"color"!==e&&"background-color"!==e||(f=f.toLowerCase()),f=f.replace(g,m),f=f.replace(h,y),o[e]=n?v(f,!0):f}r("border","",!0),r("border","-width"),r("border","-color"),r("border","-style"),r("padding",""),r("margin",""),t("border","border-width","border-style","border-color"),"medium none"===o.border&&delete o.border,"none"===o["border-image"]&&delete o["border-image"]}return o},serialize:function(a,b){var c,d,g="",h=function(b){var c,d,f,h;if(c=e[b])for(d=0,f=c.length;d0?" ":"")+b+": "+h+";")},i=function(a,b){var c;return c=f["*"],(!c||!c[a])&&(c=f[b],!c||!c[a])};if(b&&e)h("*"),h(b);else for(c in a)d=a[c],!d||f&&!i(c,b)||(g+=(g.length>0?" ":"")+c+": "+d+";");return g}}}}),g("l",["1j","2","b","m","n","1s","r","1t","s","1u","v","y","10","1e"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n){var o=n.each,p=n.is,q=n.grep,r=c.ie,s=/^([a-z0-9],?)+$/i,t=/^[ \t\r\n]*$/,u=function(a,b){var c,d={},e=b.keep_values;return c={set:function(c,d,e){b.url_converter&&(d=b.url_converter.call(b.url_converter_scope||a,d,e,c[0])),c.attr("data-mce-"+e,d).attr(e,d)},get:function(a,b){return a.attr("data-mce-"+b)||a.attr(b)}},d={style:{set:function(a,b){return null!==b&&"object"==typeof b?void a.css(b):(e&&a.attr("data-mce-style",b),void a.attr("style",b))},get:function(b){var c=b.attr("data-mce-style")||b.attr("style");return c=a.serializeStyle(a.parseStyle(c),b[0].nodeName)}}},e&&(d.href=d.src=c),d},v=function(a,b){var c=b.attr("style");c=a.serializeStyle(a.parseStyle(c),b[0].nodeName),c||(c=null),b.attr("data-mce-style",c)},w=function(a,b){var c,d,e=0;if(a)for(c=a.nodeType,a=a.previousSibling;a;a=a.previousSibling)d=a.nodeType,(!b||3!=d||d!=c&&a.nodeValue.length)&&(e++,c=d);return e},x=function(a,c){var f,g=this;g.doc=a,g.win=b,g.files={},g.counter=0,g.stdMode=!r||a.documentMode>=8,g.boxModel=!r||"CSS1Compat"==a.compatMode||g.stdMode,g.styleSheetLoader=new h(a),g.boundEvents=[],g.settings=c=c||{},g.schema=c.schema?c.schema:new l({}),g.styles=new m({url_converter:c.url_converter,url_converter_scope:c.url_converter_scope},c.schema),g.fixDoc(a),g.events=c.ownEvents?new e(c.proxy):e.Event,g.attrHooks=u(g,c),f=g.schema.getBlockElements(),g.$=d.overrideDefaults(function(){return{context:a,element:g.getRoot()}}),g.isBlock=function(a){if(!a)return!1;var b=a.nodeType;return b?!(1!==b||!f[a.nodeName]):!!f[a]}};return x.prototype={$$:function(a){return"string"==typeof a&&(a=this.get(a)),this.$(a)},root:null,fixDoc:function(a){var b,c=this.settings;if(r&&c.schema){"abbr article aside audio canvas details figcaption figure footer header hgroup mark menu meter nav output progress section summary time video".replace(/\w+/g,function(b){a.createElement(b)});for(b in c.schema.getCustomElements())a.createElement(b)}},clone:function(a,b){var c,d,e=this;return!r||1!==a.nodeType||b?a.cloneNode(b):(d=e.doc,b?c.firstChild:(c=d.createElement(a.nodeName),o(e.getAttribs(a),function(b){e.setAttrib(c,b.nodeName,e.getAttrib(a,b.nodeName))}),c))},getRoot:function(){var a=this;return a.settings.root_element||a.doc.body},getViewPort:function(a){var b,c;return a=a?a:this.win,b=a.document,c=this.boxModel?b.documentElement:b.body,{x:a.pageXOffset||c.scrollLeft,y:a.pageYOffset||c.scrollTop,w:a.innerWidth||c.clientWidth,h:a.innerHeight||c.clientHeight}},getRect:function(a){var b,c,d=this;return a=d.get(a),b=d.getPos(a),c=d.getSize(a),{x:b.x,y:b.y,w:c.w,h:c.h}},getSize:function(a){var b,c,d=this;return a=d.get(a),b=d.getStyle(a,"width"),c=d.getStyle(a,"height"),b.indexOf("px")===-1&&(b=0),c.indexOf("px")===-1&&(c=0),{w:parseInt(b,10)||a.offsetWidth||a.clientWidth,h:parseInt(c,10)||a.offsetHeight||a.clientHeight}},getParent:function(a,b,c){return this.getParents(a,b,c,!1)},getParents:function(a,b,c,d){var e,f=this,g=[];for(a=f.get(a),d=void 0===d,c=c||("BODY"!=f.getRoot().nodeName?f.getRoot().parentNode:null),p(b,"string")&&(e=b,b="*"===b?function(a){return 1==a.nodeType}:function(a){return f.is(a,e)});a&&a!=c&&a.nodeType&&9!==a.nodeType;){if(!b||b(a)){if(!d)return a;g.push(a)}a=a.parentNode}return d?g:null},get:function(a){var b;return a&&this.doc&&"string"==typeof a&&(b=a,a=this.doc.getElementById(a),a&&a.id!==b)?this.doc.getElementsByName(b)[1]:a},getNext:function(a,b){return this._findSib(a,b,"nextSibling")},getPrev:function(a,b){return this._findSib(a,b,"previousSibling")},select:function(a,b){var c=this;return g(a,c.get(b)||c.settings.root_element||c.doc,[])},is:function(a,b){var c;if(!a)return!1;if(void 0===a.length){if("*"===b)return 1==a.nodeType;if(s.test(b)){for(b=b.toLowerCase().split(/,/),a=a.nodeName.toLowerCase(),c=b.length-1;c>=0;c--)if(b[c]==a)return!0;return!1}}if(a.nodeType&&1!=a.nodeType)return!1;var d=a.nodeType?[a]:a;return g(b,d[0].ownerDocument||d[0],null,d).length>0},add:function(a,b,c,d,e){var f=this;return this.run(a,function(a){var g;return g=p(b,"string")?f.doc.createElement(b):b,f.setAttribs(g,c),d&&(d.nodeType?g.appendChild(d):f.setHTML(g,d)),e?g:a.appendChild(g)})},create:function(a,b,c){return this.add(this.doc.createElement(a),a,b,c,1)},createHTML:function(a,b,c){var d,e="";e+="<"+a;for(d in b)b.hasOwnProperty(d)&&null!==b[d]&&"undefined"!=typeof b[d]&&(e+=" "+d+'="'+this.encode(b[d])+'"');return"undefined"!=typeof c?e+">"+c+""+a+">":e+" />"},createFragment:function(a){var b,c,d,e=this.doc;for(d=e.createElement("div"),b=e.createDocumentFragment(),a&&(d.innerHTML=a);c=d.firstChild;)b.appendChild(c);return b},remove:function(a,b){return a=this.$$(a),b?a.each(function(){for(var a;a=this.firstChild;)3==a.nodeType&&0===a.data.length?this.removeChild(a):this.parentNode.insertBefore(a,this)}).remove():a.remove(),a.length>1?a.toArray():a[0]},setStyle:function(a,b,c){a=this.$$(a).css(b,c),this.settings.update_styles&&v(this,a)},getStyle:function(a,b,d){return a=this.$$(a),d?a.css(b):(b=b.replace(/-(\D)/g,function(a,b){return b.toUpperCase()}),"float"==b&&(b=c.ie&&c.ie<12?"styleFloat":"cssFloat"),a[0]&&a[0].style?a[0].style[b]:void 0)},setStyles:function(a,b){a=this.$$(a).css(b),this.settings.update_styles&&v(this,a)},removeAllAttribs:function(a){return this.run(a,function(a){var b,c=a.attributes;for(b=c.length-1;b>=0;b--)a.removeAttributeNode(c.item(b))})},setAttrib:function(a,b,c){var d,e,f=this,g=f.settings;""===c&&(c=null),a=f.$$(a),d=a.attr(b),a.length&&(e=f.attrHooks[b],e&&e.set?e.set(a,c,b):a.attr(b,c),d!=c&&g.onSetAttrib&&g.onSetAttrib({attrElm:a,attrName:b,attrValue:c}))},setAttribs:function(a,b){var c=this;c.$$(a).each(function(a,d){
o(b,function(a,b){c.setAttrib(d,b,a)})})},getAttrib:function(a,b,c){var d,e,f=this;return a=f.$$(a),a.length&&(d=f.attrHooks[b],e=d&&d.get?d.get(a,b):a.attr(b)),"undefined"==typeof e&&(e=c||""),e},getPos:function(a,b){return f.getPos(this.doc.body,this.get(a),b)},parseStyle:function(a){return this.styles.parse(a)},serializeStyle:function(a,b){return this.styles.serialize(a,b)},addStyle:function(b){var c,d,e=this,f=e.doc;if(e!==x.DOM&&f===a){var g=x.DOM.addedStyles;if(g=g||[],g[b])return;g[b]=!0,x.DOM.addedStyles=g}d=f.getElementById("mceDefaultStyles"),d||(d=f.createElement("style"),d.id="mceDefaultStyles",d.type="text/css",c=f.getElementsByTagName("head")[0],c.firstChild?c.insertBefore(d,c.firstChild):c.appendChild(d)),d.styleSheet?d.styleSheet.cssText+=b:d.appendChild(f.createTextNode(b))},loadCSS:function(b){var c,d=this,e=d.doc;return d!==x.DOM&&e===a?void x.DOM.loadCSS(b):(b||(b=""),c=e.getElementsByTagName("head")[0],void o(b.split(","),function(a){var b;a=n._addCacheSuffix(a),d.files[a]||(d.files[a]=!0,b=d.create("link",{rel:"stylesheet",href:a}),r&&e.documentMode&&e.recalc&&(b.onload=function(){e.recalc&&e.recalc(),b.onload=null}),c.appendChild(b))}))},addClass:function(a,b){this.$$(a).addClass(b)},removeClass:function(a,b){this.toggleClass(a,b,!1)},hasClass:function(a,b){return this.$$(a).hasClass(b)},toggleClass:function(a,b,c){this.$$(a).toggleClass(b,c).each(function(){""===this.className&&d(this).attr("class",null)})},show:function(a){this.$$(a).show()},hide:function(a){this.$$(a).hide()},isHidden:function(a){return"none"==this.$$(a).css("display")},uniqueId:function(a){return(a?a:"mce_")+this.counter++},setHTML:function(a,b){a=this.$$(a),r?a.each(function(a,c){if(c.canHaveHTML!==!1){for(;c.firstChild;)c.removeChild(c.firstChild);try{c.innerHTML="
"+b,c.removeChild(c.firstChild)}catch(a){d("").html("
"+b).contents().slice(1).appendTo(c)}return b}}):a.html(b)},getOuterHTML:function(a){return a=this.get(a),1==a.nodeType&&"outerHTML"in a?a.outerHTML:d("").append(d(a).clone()).html()},setOuterHTML:function(a,b){var c=this;c.$$(a).each(function(){try{if("outerHTML"in this)return void(this.outerHTML=b)}catch(a){}c.remove(d(this).html(b),!0)})},decode:k.decode,encode:k.encodeAllRaw,insertAfter:function(a,b){return b=this.get(b),this.run(a,function(a){var c,d;return c=b.parentNode,d=b.nextSibling,d?c.insertBefore(a,d):c.appendChild(a),a})},replace:function(a,b,c){var d=this;return d.run(b,function(b){return p(b,"array")&&(a=a.cloneNode(!0)),c&&o(q(b.childNodes),function(b){a.appendChild(b)}),b.parentNode.replaceChild(a,b)})},rename:function(a,b){var c,d=this;return a.nodeName!=b.toUpperCase()&&(c=d.create(b),o(d.getAttribs(a),function(b){d.setAttrib(c,b.nodeName,d.getAttrib(a,b.nodeName))}),d.replace(c,a,1)),c||a},findCommonAncestor:function(a,b){for(var c,d=a;d;){for(c=b;c&&d!=c;)c=c.parentNode;if(d==c)break;d=d.parentNode}return!d&&a.ownerDocument?a.ownerDocument.documentElement:d},toHex:function(a){return this.styles.toHex(n.trim(a))},run:function(a,b,c){var d,e=this;return"string"==typeof a&&(a=e.get(a)),!!a&&(c=c||this,a.nodeType||!a.length&&0!==a.length?b.call(c,a):(d=[],o(a,function(a,f){a&&("string"==typeof a&&(a=e.get(a)),d.push(b.call(c,a,f)))}),d))},getAttribs:function(a){var b;if(a=this.get(a),!a)return[];if(r){if(b=[],"OBJECT"==a.nodeName)return a.attributes;"OPTION"===a.nodeName&&this.getAttrib(a,"selected")&&b.push({specified:1,nodeName:"selected"});var c=/<\/?[\w:\-]+ ?|=[\"][^\"]+\"|=\'[^\']+\'|=[\w\-]+|>/gi;return a.cloneNode(!1).outerHTML.replace(c,"").replace(/[\w:\-]+/gi,function(a){b.push({specified:1,nodeName:a})}),b}return a.attributes},isEmpty:function(a,b){var c,d,e,f,g,h,j=this,k=0;if(a=a.firstChild){g=new i(a,a.parentNode),b=b||(j.schema?j.schema.getNonEmptyElements():null),f=j.schema?j.schema.getWhiteSpaceElements():{};do{if(e=a.nodeType,1===e){var l=a.getAttribute("data-mce-bogus");if(l){a=g.next("all"===l);continue}if(h=a.nodeName.toLowerCase(),b&&b[h]){if("br"===h){k++,a=g.next();continue}return!1}for(d=j.getAttribs(a),c=d.length;c--;)if(h=d[c].nodeName,"name"===h||"data-mce-bookmark"===h)return!1}if(8==e)return!1;if(3===e&&!t.test(a.nodeValue))return!1;if(3===e&&a.parentNode&&f[a.parentNode.nodeName]&&t.test(a.nodeValue))return!1;a=g.next()}while(a)}return k<=1},createRng:function(){return this.doc.createRange()},nodeIndex:w,split:function(a,b,c){var d,e,f,g=this,h=g.createRng();if(a&&b)return h.setStart(a.parentNode,g.nodeIndex(a)),h.setEnd(b.parentNode,g.nodeIndex(b)),d=h.extractContents(),h=g.createRng(),h.setStart(b.parentNode,g.nodeIndex(b)+1),h.setEnd(a.parentNode,g.nodeIndex(a)+1),e=h.extractContents(),f=a.parentNode,f.insertBefore(j.trimNode(g,d),a),c?f.insertBefore(c,a):f.insertBefore(b,a),f.insertBefore(j.trimNode(g,e),a),g.remove(a),c||b},bind:function(a,b,c,d){var e=this;if(n.isArray(a)){for(var f=a.length;f--;)a[f]=e.bind(a[f],b,c,d);return a}return!e.settings.collect||a!==e.doc&&a!==e.win||e.boundEvents.push([a,b,c,d]),e.events.bind(a,b,c,d||e)},unbind:function(a,b,c){var d,e=this;if(n.isArray(a)){for(d=a.length;d--;)a[d]=e.unbind(a[d],b,c);return a}if(e.boundEvents&&(a===e.doc||a===e.win))for(d=e.boundEvents.length;d--;){var f=e.boundEvents[d];a!=f[0]||b&&b!=f[1]||c&&c!=f[2]||this.events.unbind(f[0],f[1],f[2])}return this.events.unbind(a,b,c)},fire:function(a,b,c){return this.events.fire(a,b,c)},getContentEditable:function(a){var b;return a&&1==a.nodeType?(b=a.getAttribute("data-mce-contenteditable"),b&&"inherit"!==b?b:"inherit"!==a.contentEditable?a.contentEditable:null):null},getContentEditableParent:function(a){for(var b=this.getRoot(),c=null;a&&a!==b&&(c=this.getContentEditable(a),null===c);a=a.parentNode);return c},destroy:function(){var a=this;if(a.boundEvents){for(var b=a.boundEvents.length;b--;){var c=a.boundEvents[b];this.events.unbind(c[0],c[1],c[2])}a.boundEvents=null}g.setDocument&&g.setDocument(),a.win=a.doc=a.root=a.events=a.frag=null},isChildOf:function(a,b){for(;a;){if(b===a)return!0;a=a.parentNode}return!1},dumpRng:function(a){return"startContainer: "+a.startContainer.nodeName+", startOffset: "+a.startOffset+", endContainer: "+a.endContainer.nodeName+", endOffset: "+a.endOffset},_findSib:function(a,b,c){var d=this,e=b;if(a)for("string"==typeof e&&(e=function(a){return d.is(a,b)}),a=a[c];a;a=a[c])if(e(a))return a;return null}},x.DOM=new x(a),x.nodeIndex=w,x}),g("o",["1j","l","1e"],function(a,b,c){var d=b.DOM,e=c.each,f=c.grep,g=function(a){return"function"==typeof a},h=function(){var b,h=0,i=1,j=2,k=3,l={},m=[],n={},o=[],p=0,q=function(b,e,f){var h,i,j=d,k=function(){j.remove(i),h&&(h.onreadystatechange=h.onload=h=null),e()},l=function(){g(f)?f():"undefined"!=typeof console&&console.log&&console.log("Failed to load script: "+b)};i=j.uniqueId(),h=a.createElement("script"),h.id=i,h.type="text/javascript",h.src=c._addCacheSuffix(b),"onreadystatechange"in h?h.onreadystatechange=function(){/loaded|complete/.test(h.readyState)&&k()}:h.onload=k,h.onerror=l,(a.getElementsByTagName("head")[0]||a.body).appendChild(h)};this.isDone=function(a){return l[a]==j},this.markDone=function(a){l[a]=j},this.add=this.load=function(a,c,d,e){var f=l[a];f==b&&(m.push(a),l[a]=h),c&&(n[a]||(n[a]=[]),n[a].push({success:c,failure:e,scope:d||this}))},this.remove=function(a){delete l[a],delete n[a]},this.loadQueue=function(a,b,c){this.loadScripts(m,a,b,c)},this.loadScripts=function(a,c,d,h){var m,r=[],s=function(a,c){e(n[c],function(b){g(b[a])&&b[a].call(b.scope)}),n[c]=b};o.push({success:c,failure:h,scope:d||this}),(m=function(){var b=f(a);if(a.length=0,e(b,function(a){return l[a]===j?void s("success",a):l[a]===k?void s("failure",a):void(l[a]!==i&&(l[a]=i,p++,q(a,function(){l[a]=j,p--,s("success",a),m()},function(){l[a]=k,p--,r.push(a),s("failure",a),m()})))}),!p){var c=o.slice(0);o.length=0,e(c,function(a){0===r.length?g(a.success)&&a.success.call(a.scope):g(a.failure)&&a.failure.call(a.scope,r)})}})()}};return h.ScriptLoader=new h,h}),g("6",["1i","o","1e"],function(a,b,c){var d=c.each,e=function(){var a=this;a.items=[],a.urls={},a.lookup={},a._listeners=[]};return e.prototype={get:function(a){if(this.lookup[a])return this.lookup[a].instance},dependencies:function(a){var b;return this.lookup[a]&&(b=this.lookup[a].dependencies),b||[]},requireLangPack:function(a,c){var d=e.language;if(d&&e.languageLoad!==!1){if(c)if(c=","+c+",",c.indexOf(","+d.substr(0,2)+",")!=-1)d=d.substr(0,2);else if(c.indexOf(","+d+",")==-1)return;b.ScriptLoader.add(this.urls[a]+"/langs/"+d+".js")}},add:function(b,c,e){this.items.push(c),this.lookup[b]={instance:c,dependencies:e};var f=a.partition(this._listeners,function(a){return a.name===b});return this._listeners=f.fail,d(f.pass,function(a){a.callback()}),c},remove:function(a){delete this.urls[a],delete this.lookup[a]},createUrl:function(a,b){return"object"==typeof b?b:{prefix:a.prefix,resource:b,suffix:a.suffix}},addComponents:function(a,c){var e=this.urls[a];d(c,function(a){b.ScriptLoader.add(e+"/"+a)})},load:function(a,c,f,g,h){var i=this,j=c,k=function(){var e=i.dependencies(a);d(e,function(a){var b=i.createUrl(c,a);i.load(b.resource,b,void 0,void 0)}),f&&(g?f.call(g):f.call(b))};i.urls[a]||("object"==typeof c&&(j=c.prefix+c.resource+c.suffix),0!==j.indexOf("/")&&j.indexOf("://")==-1&&(j=e.baseURL+"/"+j),i.urls[a]=j.substring(0,j.lastIndexOf("/")),i.lookup[a]?k():b.ScriptLoader.add(j,k,g,h))},waitFor:function(a,b){this.lookup.hasOwnProperty(a)?b():this._listeners.push({name:a,callback:b})}},e.PluginManager=new e,e.ThemeManager=new e,e}),g("2z",[],function(){var a="\ufeff",b=function(b){return b===a},c=function(b){return b.replace(new RegExp(a,"g"),"")};return{isZwsp:b,ZWSP:a,trim:c}}),g("2x",["1j","1y","2z"],function(a,b,c){var d=b.isElement,e=b.isText,f=function(a){return e(a)&&(a=a.parentNode),d(a)&&a.hasAttribute("data-mce-caret")},g=function(a){return e(a)&&c.isZwsp(a.data)},h=function(a){return f(a)||g(a)},i=function(a){return a.firstChild!==a.lastChild||!b.isBr(a.firstChild)},j=function(a,b){var d,f,g,i;if(d=a.ownerDocument,g=d.createTextNode(c.ZWSP),i=a.parentNode,b){if(f=a.previousSibling,e(f)){if(h(f))return f;if(r(f))return f.splitText(f.data.length-1)}i.insertBefore(g,a)}else{if(f=a.nextSibling,e(f)){if(h(f))return f;if(q(f))return f.splitText(1),f}a.nextSibling?i.insertBefore(g,a.nextSibling):i.appendChild(g)}return g},k=function(a){if(b.isText(a)){var d=a.data;return d.length>0&&d.charAt(0)!==c.ZWSP&&a.insertData(0,c.ZWSP),a}return null},l=function(a){if(b.isText(a)){var d=a.data;return d.length>0&&d.charAt(d.length-1)!==c.ZWSP&&a.insertData(d.length,c.ZWSP),a}return null},m=function(a){return a&&b.isText(a.container())&&a.container().data.charAt(a.offset())===c.ZWSP},n=function(a){return a&&b.isText(a.container())&&a.container().data.charAt(a.offset()-1)===c.ZWSP},o=function(){var b=a.createElement("br");return b.setAttribute("data-mce-bogus","1"),b},p=function(a,b,c){var d,e,f;return d=b.ownerDocument,e=d.createElement(a),e.setAttribute("data-mce-caret",c?"before":"after"),e.setAttribute("data-mce-bogus","all"),e.appendChild(o()),f=b.parentNode,c?f.insertBefore(e,b):b.nextSibling?f.insertBefore(e,b.nextSibling):f.appendChild(e),e},q=function(a){return e(a)&&a.data[0]==c.ZWSP},r=function(a){return e(a)&&a.data[a.data.length-1]==c.ZWSP},s=function(a){var c=a.getElementsByTagName("br"),d=c[c.length-1];b.isBogus(d)&&d.parentNode.removeChild(d)},t=function(a){return a&&a.hasAttribute("data-mce-caret")?(s(a),a.removeAttribute("data-mce-caret"),a.removeAttribute("data-mce-bogus"),a.removeAttribute("style"),a.removeAttribute("_moz_abspos"),a):null};return{isCaretContainer:h,isCaretContainerBlock:f,isCaretContainerInline:g,showCaretContainerBlock:t,insertInline:j,prependInline:k,appendInline:l,isBeforeInline:m,isAfterInline:n,insertBlock:p,hasContent:i,startsWithCaretContainer:q,endsWithCaretContainer:r}}),g("3m",["1y","1r","2x"],function(a,b,c){var d=a.isContentEditableTrue,e=a.isContentEditableFalse,f=a.isBr,g=a.isText,h=a.matchNodeNames("script style textarea"),i=a.matchNodeNames("img input textarea hr iframe video audio object"),j=a.matchNodeNames("table"),k=c.isCaretContainer,l=function(a){return!k(a)&&(g(a)?!h(a.parentNode):i(a)||f(a)||j(a)||e(a))},m=function(a,b){for(a=a.parentNode;a&&a!=b;a=a.parentNode){if(e(a))return!1;if(d(a))return!0}return!0},n=function(a){return!!e(a)&&b.reduce(a.getElementsByTagName("*"),function(a,b){return a||d(b)},!1)!==!0},o=function(a){return i(a)||n(a)},p=function(a,b){return l(a)&&m(a,b)};return{isCaretCandidate:l,isInEditable:m,isAtomic:o,isEditableCaretCandidate:p}}),g("3n",[],function(){var a=Math.round,b=function(b){return b?{left:a(b.left),top:a(b.top),bottom:a(b.bottom),right:a(b.right),width:a(b.width),height:a(b.height)}:{left:0,top:0,bottom:0,right:0,width:0,height:0}},c=function(a,c){return a=b(a),c?a.right=a.left:(a.left=a.left+a.width,a.right=a.left),a.width=0,a},d=function(a,b){return a.left===b.left&&a.top===b.top&&a.bottom===b.bottom&&a.right===b.right},e=function(a,b,c){return a>=0&&a<=Math.min(b.height,c.height)/2},f=function(a,b){return a.bottom-a.height/2b.bottom)&&e(b.top-a.bottom,a,b)},g=function(a,b){return a.top>b.bottom||!(a.bottomb.right},j=function(a,b){return f(a,b)?-1:g(a,b)?1:h(a,b)?-1:i(a,b)?1:0},k=function(a,b,c){return b>=a.left&&b<=a.right&&c>=a.top&&c<=a.bottom};return{clone:b,collapse:c,isEqual:d,isAbove:f,isBelow:g,isLeft:h,isRight:i,compare:j,containsXY:k}}),g("2t",[],function(){var a=function(a){var b=a.startContainer,c=a.startOffset;return b.hasChildNodes()&&a.endOffset==c+1?b.childNodes[c]:null},b=function(a,b){return 1===a.nodeType&&a.hasChildNodes()&&(b>=a.childNodes.length&&(b=a.childNodes.length-1),a=a.childNodes[b]),a};return{getSelectedNode:a,getNode:b}}),g("3o",[],function(){var a=new RegExp("[\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\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08e3-\u0902\u093a\u093c\u0941-\u0948\u094d\u0951-\u0957\u0962-\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2-\u09e3\u0a01-\u0a02\u0a3c\u0a41-\u0a42\u0a47-\u0a48\u0a4b-\u0a4d\u0a51\u0a70-\u0a71\u0a75\u0a81-\u0a82\u0abc\u0ac1-\u0ac5\u0ac7-\u0ac8\u0acd\u0ae2-\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62-\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c00\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55-\u0c56\u0c62-\u0c63\u0c81\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc-\u0ccd\u0cd5-\u0cd6\u0ce2-\u0ce3\u0d01\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62-\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb-\u0ebc\u0ec8-\u0ecd\u0f18-\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86-\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039-\u103a\u103d-\u103e\u1058-\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085-\u1086\u108d\u109d\u135d-\u135f\u1712-\u1714\u1732-\u1734\u1752-\u1753\u1772-\u1773\u17b4-\u17b5\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927-\u1928\u1932\u1939-\u193b\u1a17-\u1a18\u1a1b\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1ab0-\u1abd\u1abe\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80-\u1b81\u1ba2-\u1ba5\u1ba8-\u1ba9\u1bab-\u1bad\u1be6\u1be8-\u1be9\u1bed\u1bef-\u1bf1\u1c2c-\u1c33\u1c36-\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1cf4\u1cf8-\u1cf9\u1dc0-\u1df5\u1dfc-\u1dff\u200c-\u200d\u20d0-\u20dc\u20dd-\u20e0\u20e1\u20e2-\u20e4\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302d\u302e-\u302f\u3099-\u309a\ua66f\ua670-\ua672\ua674-\ua67d\ua69e-\ua69f\ua6f0-\ua6f1\ua802\ua806\ua80b\ua825-\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\ua9e5\uaa29-\uaa2e\uaa31-\uaa32\uaa35-\uaa36\uaa43\uaa4c\uaa7c\uaab0\uaab2-\uaab4\uaab7-\uaab8\uaabe-\uaabf\uaac1\uaaec-\uaaed\uaaf6\uabe5\uabe8\uabed\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\uff9e-\uff9f]"),b=function(b){return"string"==typeof b&&b.charCodeAt(0)>=768&&a.test(b)};return{isExtendingChar:b}}),g("3p",[],function(){var a=[].slice,b=function(a){return function(){return a}},c=function(a){return function(b){return!a(b)}},d=function(a,b){return function(c){return a(b(c))}},e=function(){var b=a.call(arguments);return function(a){for(var c=0;c=b.length?b.apply(this,c.slice(1)):function(){var a=c.concat([].slice.call(arguments));return g.apply(this,a)}},h=function(){};return{constant:b,negate:c,and:f,or:e,curry:g,compose:d,noop:h}}),g("2y",["3m","l","1y","3n","2t","3o","3p"],function(a,b,c,d,e,f,g){var h=c.isElement,i=a.isCaretCandidate,j=c.matchStyleValues("display","block table"),k=c.matchStyleValues("float","left right"),l=g.and(h,i,g.negate(k)),m=g.negate(c.matchStyleValues("white-space","pre pre-line pre-wrap")),n=c.isText,o=c.isBr,p=b.nodeIndex,q=e.getNode,r=function(a){return"createRange"in a?a.createRange():b.DOM.createRng()},s=function(a){return a&&/[\r\n\t ]/.test(a)},t=function(a){var b,c=a.startContainer,d=a.startOffset;return!!(s(a.toString())&&m(c.parentNode)&&(b=c.data,s(b[d-1])||s(b[d+1])))},u=function(a){var b,c,e=[],g=function(a){var b,c=a.ownerDocument,e=r(c),f=c.createTextNode("\xa0"),g=a.parentNode;return g.insertBefore(f,a),e.setStart(f,0),e.setEnd(f,1),b=d.clone(e.getBoundingClientRect()),g.removeChild(f),b},i=function(a){var b,c;return c=a.getClientRects(),b=c.length>0?d.clone(c[0]):d.clone(a.getBoundingClientRect()),o(a)&&0===b.left?g(a):b},k=function(a,b){return a=d.collapse(a,b),a.width=1,a.right=a.left+1,a},m=function(a){0!==a.height&&(e.length>0&&d.isEqual(a,e[e.length-1])||e.push(a))},p=function(a,b){var c=r(a.ownerDocument);if(b0&&(c.setStart(a,b-1),c.setEnd(a,b),t(c)||m(k(i(c),!1))),b=a.data.length:b>=a.childNodes.length},f=function(){var c;return c=r(a.ownerDocument),c.setStart(a,b),c.setEnd(a,b),c},h=function(){return c||(c=u(new v(a,b))),c},i=function(){return h().length>0},j=function(c){return c&&a===c.container()&&b===c.offset()},k=function(c){return q(a,c?b-1:b)};return{container:g.constant(a),offset:g.constant(b),toRange:f,getClientRects:h,isVisible:i,isAtStart:d,isAtEnd:e,isEqual:j,getNode:k}};return v.fromRangeStart=function(a){return new v(a.startContainer,a.startOffset)},v.fromRangeEnd=function(a){return new v(a.endContainer,a.endOffset)},v.after=function(a){return new v(a.parentNode,p(a)+1)},v.before=function(a){return new v(a.parentNode,p(a))},v.isAtStart=function(a){return!!a&&a.isAtStart()},v.isAtEnd=function(a){return!!a&&a.isAtEnd()},v.isTextPosition=function(a){return!!a&&c.isText(a.container())},v}),g("53",["3p","s","1y","2y","2x","3m"],function(a,b,c,d,e,f){var g=c.isContentEditableTrue,h=c.isContentEditableFalse,i=c.matchStyleValues("display","block table table-cell table-caption list-item"),j=e.isCaretContainer,k=e.isCaretContainerBlock,l=a.curry,m=c.isElement,n=f.isCaretCandidate,o=function(a){return a>0},p=function(a){return a<0},q=function(a,b){for(var c;c=a(b);)if(!k(c))return c;return null},r=function(a,c,d,e,f){var g=new b(a,e);if(p(c)){if((h(a)||k(a))&&(a=q(g.prev,!0),d(a)))return a;for(;a=q(g.prev,f);)if(d(a))return a}if(o(c)){if((h(a)||k(a))&&(a=q(g.next,!0),d(a)))return a;for(;a=q(g.next,f);)if(d(a))return a}return null},s=function(a,b){for(a=a.parentNode;a&&a!=b;a=a.parentNode)if(g(a))return a;return b},t=function(a,b){for(;a&&a!=b;){if(i(a))return a;a=a.parentNode}return null},u=function(a,b,c){return t(a.container(),c)==t(b.container(),c)},v=function(a,b,c){return s(a.container(),c)==s(b.container(),c)},w=function(a,b){var c,d;return b?(c=b.container(),d=b.offset(),m(c)?c.childNodes[d+a]:null):null},x=function(a,b){var c=b.ownerDocument.createRange();return a?(c.setStartBefore(b),c.setEndBefore(b)):(c.setStartAfter(b),c.setEndAfter(b)),c},y=function(a,b,c){return t(b,a)==t(c,a)},z=function(a,b,c){var d,e;for(e=a?"previousSibling":"nextSibling";c&&c!=b;){if(d=c[e],j(d)&&(d=d[e]),h(d)){if(y(b,d,c))return d;break}if(n(d))break;c=c.parentNode}return null},A=l(x,!0),B=l(x,!1),C=function(a,b,d){var f,g,i,k,n=l(z,!0,b),o=l(z,!1,b);if(g=d.startContainer,i=d.startOffset,e.isCaretContainerBlock(g)){if(m(g)||(g=g.parentNode),k=g.getAttribute("data-mce-caret"),"before"==k&&(f=g.nextSibling,h(f)))return A(f);if("after"==k&&(f=g.previousSibling,h(f)))return B(f)}if(!d.collapsed)return d;if(c.isText(g)){if(j(g)){if(1===a){if(f=o(g))return A(f);if(f=n(g))return B(f)}if(a===-1){if(f=n(g))return B(f);if(f=o(g))return A(f)}return d}if(e.endsWithCaretContainer(g)&&i>=g.data.length-1)return 1===a&&(f=o(g))?A(f):d;if(e.startsWithCaretContainer(g)&&i<=1)return a===-1&&(f=n(g))?B(f):d;if(i===g.data.length)return f=o(g),f?A(f):d;if(0===i)return f=n(g),f?B(f):d}return d},D=function(a,b){return h(w(a,b))};return{isForwards:o,isBackwards:p,findNode:r,getEditingHost:s,getParentBlock:t,isInSameBlock:u,isInSameEditingHost:v,isBeforeContentEditableFalse:l(D,0),isAfterContentEditableFalse:l(D,-1),normalizeRange:C}}),g("3q",["1y","3m","2y","53","1r","3p"],function(a,b,c,d,e,f){var g=a.isContentEditableFalse,h=a.isText,i=a.isElement,j=a.isBr,k=d.isForwards,l=d.isBackwards,m=b.isCaretCandidate,n=b.isAtomic,o=b.isEditableCaretCandidate,p=function(a,b){for(var c=[];a&&a!=b;)c.push(a),a=a.parentNode;return c},q=function(a,b){return a.hasChildNodes()&&b0)return c(v,--w);if(k(a)&&w0&&(y=q(v,w-1),m(y)))return!n(y)&&(z=d.findNode(y,a,o,y))?h(z)?c(z,z.data.length):c.after(z):h(y)?c(y,y.data.length):c.before(y);if(k(a)&&w0&&o(a[a.length-1])?a.slice(0,-1):a},q=function(a,b){var c=a.getParent(b,a.isBlock);return c&&"LI"===c.nodeName?c:null},r=function(a,b){return!!q(a,b)},s=function(a,b){var c=b.cloneRange(),d=b.cloneRange();return c.setStartBefore(a),d.setEndAfter(a),[c.cloneContents(),d.cloneContents()]},t=function(c,d){var e=a.before(c),f=new b(d),g=f.next(e);return g?g.toRange():null},u=function(c,d){var e=a.after(c),f=new b(d),g=f.prev(e);return g?g.toRange():null},v=function(a,b,c,e){var f=s(a,e),g=a.parentNode;return g.insertBefore(f[0],a),d.each(b,function(b){g.insertBefore(b,a)}),g.insertBefore(f[1],a),g.removeChild(a),u(b[b.length-1],c)},w=function(a,b,c){var e=a.parentNode;return d.each(b,function(b){e.insertBefore(b,a)}),t(a,c)},x=function(a,b,c,d){return d.insertAfter(b.reverse(),a),u(b[0],c)},y=function(c,d,e,f){var g=k(d,c,f),h=q(d,e.startContainer),i=p(l(g.firstChild)),j=1,m=2,n=d.getRoot(),o=function(c){var f=a.fromRangeStart(e),g=new b(d.getRoot()),i=c===j?g.prev(f):g.next(f);return!i||q(d,i.getNode())!==h};return o(j)?w(h,i,n):o(m)?x(h,i,n,d):v(h,i,n,e)};return{isListFragment:i,insertAtCaret:y,isParentBlockLi:r,trimListItems:p,listItems:l}}),g("2w",["1y","l","3p","1r","2y"],function(a,b,c,d,e){var f=a.isText,g=a.isBogus,h=b.nodeIndex,i=function(a){var b=a.parentNode;return g(b)?i(b):b},j=function(a){return a?d.reduce(a.childNodes,function(a,b){return g(b)&&"BR"!=b.nodeName?a=a.concat(j(b)):a.push(b),a},[]):[]},k=function(a,b){for(;(a=a.previousSibling)&&f(a);)b+=a.data.length;return b},l=function(a){return function(b){return a===b}},m=function(b){var c,e,g;return c=j(i(b)),e=d.findIndex(c,l(b),b),c=c.slice(0,e+1),g=d.reduce(c,function(a,b,d){return f(b)&&f(c[d-1])&&a++,a},0),c=d.filter(c,a.matchNodeNames(b.nodeName)),e=d.findIndex(c,l(b),b),e-g},n=function(a){var b;return b=f(a)?"text()":a.nodeName.toLowerCase(),b+"["+m(a)+"]"},o=function(a,b,c){var d=[];for(b=b.parentNode;b!=a&&(!c||!c(b));b=b.parentNode)d.push(b);return d},p=function(b,e){var g,h,i,j,l,m=[];return g=e.container(),h=e.offset(),f(g)?i=k(g,h):(j=g.childNodes,h>=j.length?(i="after",h=j.length-1):i="before",g=j[h]),m.push(n(g)),l=o(b,g),l=d.filter(l,c.negate(a.isBogus)),m=m.concat(d.map(l,function(a){return n(a)})),m.reverse().join("/")+","+i},q=function(b,c,e){var g=j(b);return g=d.filter(g,function(a,b){return!f(a)||!f(g[b-1])}),g=d.filter(g,a.matchNodeNames(c)),g[e]},r=function(a,b){for(var c,d=a,g=0;f(d);){if(c=d.data.length,b>=g&&b<=g+c){a=d,b-=g;break}if(!f(d.nextSibling)){a=d,b=c;break}g+=c,d=d.nextSibling}return b>a.data.length&&(b=a.data.length),new e(a,b)},s=function(a,b){var c,g,i;return b?(c=b.split(","),b=c[0].split("/"),i=c.length>1?c[1]:"before",g=d.reduce(b,function(a,b){return(b=/([\w\-\(\)]+)\[([0-9]+)\]/.exec(b))?("text()"===b[1]&&(b[1]="#text"),q(a,b[1],parseInt(b[2],10))):null},a),g?f(g)?r(g,parseInt(i,10)):(i="after"===i?h(g)+1:h(g),new e(g.parentNode,i)):null):null};return{create:p,resolve:s}}),g("j",["b","2w","2x","2y","1y","2t","2z","1e"],function(a,b,c,d,e,f,g,h){var i=e.isContentEditableFalse,j=function(a,b){var c,d;for(d=g.trim(a.data.slice(0,b)).length,c=a.previousSibling;c&&3===c.nodeType;c=c.previousSibling)d+=g.trim(c.data).length;return d},k=function(a){e.isText(a)&&0===a.data.length&&a.parentNode.removeChild(a)},l=function(g){var l=g.dom;this.getBookmark=function(a,m){var n,o,p,q,r,s,t,u="",v=function(a,b){var c=0;return h.each(l.select(a),function(a){if("all"!==a.getAttribute("data-mce-bogus"))return a!=b&&void c++}),c},w=function(a){var b=function(b){var c,d,e,f=b?"start":"end";c=a[f+"Container"],d=a[f+"Offset"],1==c.nodeType&&"TR"==c.nodeName&&(e=c.childNodes,c=e[Math.min(b?d:d-1,e.length-1)],c&&(d=b?0:c.childNodes.length,a["set"+(b?"Start":"End")](c,d)))};return b(!0),b(),a},x=function(a){var b=l.getRoot(),c={},d=function(a,c){var d,e=a[c?"startContainer":"endContainer"],f=a[c?"startOffset":"endOffset"],g=[],h=0;for(3===e.nodeType?g.push(m?j(e,f):f):(d=e.childNodes,f>=d.length&&d.length&&(h=1,f=Math.max(0,d.length-1)),g.push(l.nodeIndex(d[f],m)+h));e&&e!=b;e=e.parentNode)g.push(l.nodeIndex(e,m));return g};return c.start=d(a,!0),g.isCollapsed()||(c.end=d(a)),c},y=function(a){var b=function(a,b){var d;if(e.isElement(a)&&(a=f.getNode(a,b),i(a)))return a;if(c.isCaretContainer(a)){if(e.isText(a)&&c.isCaretContainerBlock(a)&&(a=a.parentNode),d=a.previousSibling,i(d))return d;if(d=a.nextSibling,i(d))return d}};return b(a.startContainer,a.startOffset)||b(a.endContainer,a.endOffset)};if(2==a)return s=g.getNode(),r=s?s.nodeName:null,n=g.getRng(),i(s)||"IMG"==r?{name:r,index:v(r,s)}:(s=y(n),s?(r=s.tagName,{name:r,index:v(r,s)}):x(n));if(3==a)return n=g.getRng(),{start:b.create(l.getRoot(),d.fromRangeStart(n)),end:b.create(l.getRoot(),d.fromRangeEnd(n))};if(a)return{rng:g.getRng()};if(n=g.getRng(),p=l.uniqueId(),q=g.isCollapsed(),t="overflow:hidden;line-height:0px",s=g.getNode(),r=s.nodeName,"IMG"==r)return{name:r,index:v(r,s)};if(o=w(n.cloneRange()),!q){o.collapse(!1);var z=l.create("span",{"data-mce-type":"bookmark",id:p+"_end",style:t},u);o.insertNode(z),k(z.nextSibling)}n=w(n),n.collapse(!0);var A=l.create("span",{"data-mce-type":"bookmark",id:p+"_start",style:t},u);return n.insertNode(A),k(A.previousSibling),g.moveToBookmark({id:p,keep:1}),{id:p}},this.moveToBookmark=function(c){var d,e,f,i,j,k,m=function(a){var b,f,g,h,i=c[a?"start":"end"];if(i){for(g=i[0],f=e,b=i.length-1;b>=1;b--){if(h=f.childNodes,i[b]>h.length-1)return;f=h[i[b]]}3===f.nodeType&&(g=Math.min(i[0],f.nodeValue.length)),1===f.nodeType&&(g=Math.min(i[0],f.childNodes.length)),a?d.setStart(f,g):d.setEnd(f,g)}return!0},n=function(b){var d,e,g,m,n=l.get(c.id+"_"+b),o=c.keep;if(n&&(d=n.parentNode,"start"==b?(o?(d=n.firstChild,e=1):e=l.nodeIndex(n),f=i=d,j=k=e):(o?(d=n.firstChild,e=1):e=l.nodeIndex(n),i=d,k=e),!o)){for(m=n.previousSibling,g=n.nextSibling,h.each(h.grep(n.childNodes),function(a){3==a.nodeType&&(a.nodeValue=a.nodeValue.replace(/\uFEFF/g,""))});n=l.get(c.id+"_"+b);)l.remove(n,1);m&&g&&m.nodeType==g.nodeType&&3==m.nodeType&&!a.opera&&(e=m.nodeValue.length,m.appendData(g.nodeValue),l.remove(g),"start"==b?(f=i=m,j=k=e):(i=m,k=e))}},o=function(b){return!l.isBlock(b)||b.innerHTML||a.ie||(b.innerHTML='
'),b},p=function(){var a,d;return a=l.createRng(),d=b.resolve(l.getRoot(),c.start),a.setStart(d.container(),d.offset()),d=b.resolve(l.getRoot(),c.end),a.setEnd(d.container(),d.offset()),a};c&&(h.isArray(c.start)?(d=l.createRng(),e=l.getRoot(),m(!0)&&m()&&g.setRng(d)):"string"==typeof c.start?g.setRng(p(c)):c.id?(n("start"),n("end"),f&&(d=l.createRng(),d.setStart(o(f),j),d.setEnd(o(i),k),g.setRng(d))):c.name?g.select(l.select(c.name)[c.index]):c.rng&&g.setRng(c.rng))}};return l.isBookmarkNode=function(a){return a&&"SPAN"===a.tagName&&"bookmark"===a.getAttribute("data-mce-type")},l}),g("3r",["j","1e"],function(a,b){var c=b.each,d=function(b){this.compare=function(d,e){if(d.nodeName!=e.nodeName)return!1;var f=function(a){var d={};return c(b.getAttribs(a),function(c){var e=c.nodeName.toLowerCase();0!==e.indexOf("_")&&"style"!==e&&0!==e.indexOf("data-")&&(d[e]=b.getAttrib(a,e))}),d},g=function(a,b){var c,d;for(d in a)if(a.hasOwnProperty(d)){if(c=b[d],"undefined"==typeof c)return!1;if(a[d]!=c)return!1;delete b[d]}for(d in b)if(b.hasOwnProperty(d))return!1;return!0};return!!g(f(d),f(e))&&(!!g(b.parseStyle(b.getAttrib(d,"style")),b.parseStyle(b.getAttrib(e,"style")))&&(!a.isBookmarkNode(d)&&!a.isBookmarkNode(e)));
}};return d}),g("40",["3g"],function(a){var b=function(b,c){var d=a.parent(b);d.each(function(a){a.dom().insertBefore(c.dom(),b.dom())})},c=function(c,d){var f=a.nextSibling(c);f.fold(function(){var b=a.parent(c);b.each(function(a){e(a,d)})},function(a){b(a,d)})},d=function(b,c){var d=a.firstChild(b);d.fold(function(){e(b,c)},function(a){b.dom().insertBefore(c.dom(),a.dom())})},e=function(a,b){a.dom().appendChild(b.dom())},f=function(c,d,f){a.child(c,f).fold(function(){e(c,d)},function(a){b(a,d)})},g=function(a,c){b(a,c),e(c,a)};return{before:b,after:c,prepend:d,append:e,appendAt:f,wrap:g}}),g("54",["1i","40"],function(a,b){var c=function(c,d){a.each(d,function(a){b.before(c,a)})},d=function(c,d){a.each(d,function(a,e){var f=0===e?c:d[e-1];b.after(f,a)})},e=function(c,d){a.each(d.slice().reverse(),function(a){b.prepend(c,a)})},f=function(c,d){a.each(d,function(a){b.append(c,a)})};return{before:c,after:d,prepend:e,append:f}}),g("45",["1i","54","3g"],function(a,b,c){var d=function(b){b.dom().textContent="",a.each(c.children(b),function(a){e(a)})},e=function(a){var b=a.dom();null!==b.parentNode&&b.parentNode.removeChild(b)},f=function(a){var d=c.children(a);d.length>0&&b.before(a,d),e(a)};return{empty:d,remove:e,unwrap:f}}),g("55",["3c","2m","5"],function(a,b,c){return function(d,e){var f=function(a){if(!d(a))throw new c("Can only get "+e+" value of a "+e+" node");return j(a).getOr("")},g=function(a){try{return h(a)}catch(a){return b.none()}},h=function(a){return d(a)?b.from(a.dom().nodeValue):b.none()},i=a.detect().browser,j=i.isIE()&&10===i.version.major?g:h,k=function(a,b){if(!d(a))throw new c("Can only set raw "+e+" value of a "+e+" node");a.dom().nodeValue=b};return{get:f,getOption:j,set:k}}}),g("4c",["3e","55"],function(a,b){var c=b(a.isText,"text"),d=function(a){return c.get(a)},e=function(a){return c.getOption(a)},f=function(a,b){c.set(a,b)};return{get:d,getOption:e,set:f}}),g("64",["1i","4t","3g"],function(a,b,c){var d=function(a){return h(b.body(),a)},e=function(b,d,e){return a.filter(c.parents(b,e),d)},f=function(b,d){return a.filter(c.siblings(b),d)},g=function(b,d){return a.filter(c.children(b),d)},h=function(b,d){var e=[];return a.each(c.children(b),function(a){d(a)&&(e=e.concat([a])),e=e.concat(h(a,d))}),e};return{all:d,ancestors:e,siblings:f,children:g,descendants:h}}),g("56",["64","30"],function(a,b){var c=function(a){return b.all(a)},d=function(c,d,e){return a.ancestors(c,function(a){return b.is(a,d)},e)},e=function(c,d){return a.siblings(c,function(a){return b.is(a,d)})},f=function(c,d){return a.children(c,function(a){return b.is(a,d)})},g=function(a,c){return b.all(c,a)};return{all:c,ancestors:d,siblings:e,children:f,descendants:g}}),g("3s",["1i","40","45","1v","3e","4c","56","3g","3k"],function(a,b,c,d,e,f,g,h,i){var j=function(a){for(var b=[],c=a.dom();c;)b.push(d.fromDom(c)),c=c.lastChild;return b},k=function(b){var d=g.descendants(b,"br"),e=a.filter(j(b).slice(-1),i.isBr);d.length===e.length&&a.each(e,c.remove)},l=function(a){c.empty(a),b.append(a,d.fromHtml('
'))},m=function(a){return e.isText(a)?"\xa0"===f.get(a):i.isBr(a)},n=function(b){return 1===a.filter(h.children(b),m).length},o=function(a){h.lastChild(a).each(function(b){h.prevSibling(b).each(function(d){i.isBlock(a)&&i.isBr(b)&&i.isBlock(d)&&c.remove(b)})})};return{removeTrailingBr:k,fillWithPaddingBr:l,isPaddedElement:n,trimBlockTrailingBr:o}}),g("11",["v","1e"],function(a,b){var c=b.makeMap;return function(b){var d,e,f,g,h,i=[];return b=b||{},d=b.indent,e=c(b.indent_before||""),f=c(b.indent_after||""),g=a.getEncodeFunc(b.entity_encoding||"raw",b.entities),h="html"==b.element_format,{start:function(a,b,c){var j,k,l,m;if(d&&e[a]&&i.length>0&&(m=i[i.length-1],m.length>0&&"\n"!==m&&i.push("\n")),i.push("<",a),b)for(j=0,k=b.length;j":i[i.length]=" />",c&&d&&f[a]&&i.length>0&&(m=i[i.length-1],m.length>0&&"\n"!==m&&i.push("\n"))},end:function(a){var b;i.push("",a,">"),d&&f[a]&&i.length>0&&(b=i[i.length-1],b.length>0&&"\n"!==b&&i.push("\n"))},text:function(a,b){a.length>0&&(i[i.length]=b?a:g(a))},cdata:function(a){i.push("")},comment:function(a){i.push("")},pi:function(a,b){b?i.push("",a," ",g(b),"?>"):i.push("",a,"?>"),d&&i.push("\n")},doctype:function(a){i.push("",d?"\n":"")},reset:function(){i.length=0},getContent:function(){return i.join("").replace(/\n$/,"")}}}}),g("z",["11","y"],function(a,b){return function(c,d){var e=this,f=new a(c);c=c||{},c.validate=!("validate"in c)||c.validate,e.schema=d=d||new b,e.writer=f,e.serialize=function(a){var b,e;e=c.validate,b={3:function(a){f.text(a.value,a.raw)},8:function(a){f.comment(a.value)},7:function(a){f.pi(a.name,a.value)},10:function(a){f.doctype(a.value)},4:function(a){f.cdata(a.value)},11:function(a){if(a=a.firstChild)do g(a);while(a=a.next)}},f.reset();var g=function(a){var c,h,i,j,k,l,m,n,o,p=b[a.type];if(p)p(a);else{if(c=a.name,h=a.shortEnded,i=a.attributes,e&&i&&i.length>1&&(l=[],l.map={},o=d.getElementRule(a.name))){for(m=0,n=o.attributesOrder.length;m0?a=a.replace(/^ /," "):e("previousSibling")||(a=a.replace(/^ /," ")),d|)$/," "):e("nextSibling")||(a=a.replace(/( | )(
|)$/," "))),a},E=function(){var a,c,d;a=B.getRng(!0),c=a.startContainer,d=a.startOffset,3==c.nodeType&&a.collapsed&&("\xa0"===c.data[d]?(c.deleteData(d,1),/[\u00a0| ]$/.test(b)||(b+=" ")):"\xa0"===c.data[d-1]&&(c.deleteData(d-1,1),/[\u00a0| ]$/.test(b)||(b=" "+b)))},F=function(){if(z){var b=a.getBody(),c=new g(C);l.each(C.select("*[data-mce-fragment]"),function(a){for(var d=a.parentNode;d&&d!=b;d=d.parentNode)A[a.nodeName.toLowerCase()]&&c.compare(d,a)&&C.remove(a,!0)})}},G=function(a){for(var b=a;b=b.walk();)1===b.type&&b.attr("data-mce-fragment","1")},H=function(a){l.each(a.getElementsByTagName("*"),function(a){a.removeAttribute("data-mce-fragment")})},I=function(a){return!!a.getAttribute("data-mce-fragment")},J=function(b){return b&&!a.schema.getShortEndedElements()[b.nodeName]},K=function(b){var d,g,h,i=function(b){for(var c=a.getBody();b&&b!==c;b=b.parentNode)if("false"===a.dom.getContentEditable(b))return b;return null};if(b){if(B.scrollIntoView(b),d=i(b))return C.remove(b),void B.select(d);v=C.createRng(),w=b.previousSibling,w&&3==w.nodeType?(v.setStart(w,w.nodeValue.length),c.ie||(x=b.nextSibling,x&&3==x.nodeType&&(w.appendData(x.data),x.parentNode.removeChild(x)))):(v.setStartBefore(b),v.setEndBefore(b));var j=function(b){var c=e.fromRangeStart(b),d=new f(a.getBody());if(c=d.next(c))return c.toRange()};g=C.getParent(b,C.isBlock),C.remove(b),g&&C.isEmpty(g)&&(a.$(g).empty(),v.setStart(g,0),v.setEnd(g,0),m(g)||I(g)||!(h=j(v))?C.add(g,C.create("br",{"data-mce-bogus":"1"})):(v=h,C.remove(g))),B.setRng(v)}};if(/^ | $/.test(b)&&(b=D(b)),i=a.parser,z=h.merge,p=new j({validate:a.settings.validate},a.schema),y='',t={content:b,format:"html",selection:!0,paste:h.paste},t=a.fire("BeforeSetContent",t),t.isDefaultPrevented())return void a.fire("SetContent",{content:t.content,format:"html",selection:!0,paste:h.paste});b=t.content,b.indexOf("{$caret}")==-1&&(b+="{$caret}"),b=b.replace(/\{\$caret\}/,y),v=B.getRng();var L=v.startContainer||(v.parentElement?v.parentElement():null),M=a.getBody();L===M&&B.isCollapsed()&&C.isBlock(M.firstChild)&&J(M.firstChild)&&C.isEmpty(M.firstChild)&&(v=C.createRng(),v.setStart(M.firstChild,0),v.setEnd(M.firstChild,0),B.setRng(v)),B.isCollapsed()||(a.selection.setRng(k.normalize(a.selection.getRng())),a.getDoc().execCommand("Delete",!1,null),E()),q=B.getNode();var N={context:q.nodeName.toLowerCase(),data:h.data,insert:!0};if(s=i.parse(b,N),h.paste===!0&&d.isListFragment(a.schema,s)&&d.isParentBlockLi(C,q))return v=d.insertAtCaret(p,C,a.selection.getRng(!0),s),a.selection.setRng(v),void a.fire("SetContent",t);if(G(s),w=s.lastChild,"mce_marker"==w.attr("id"))for(u=w,w=w.prev;w;w=w.walk(!0))if(3==w.type||!C.isBlock(w.name)){a.schema.isValidChild(w.parent.name,"span")&&w.parent.insert(u,w,"br"===w.name);break}if(a._selectionOverrides.showBlockCaretContainer(q),N.invalid){for(B.setContent(y),q=B.getNode(),r=a.getBody(),9==q.nodeType?q=w=r:w=q;w!==r;)q=w,w=w.parentNode;b=q==r?r.innerHTML:C.getOuterHTML(q),b=p.serialize(i.parse(b.replace(//i,function(){return p.serialize(s)}))),q==r?C.setHTML(r,b):C.setOuterHTML(q,b)}else b=p.serialize(s),n(a,b,q);F(),K(C.get("mce_marker")),H(a.getBody()),o(a.dom,a.selection.getStart()),a.fire("SetContent",t),a.addVisual()},q=function(a){var b;return"string"!=typeof a?(b=l.extend({paste:a.paste,data:{paste:a.paste}},a),{content:a.content,details:b}):{content:a,details:{}}},r=function(a,b){var c=q(b);p(a,c.content,c.details)};return{insertAtCaret:r}}),g("59",["2m"],function(a){var b=function(a){for(var b=[],c=function(a){b.push(a)},d=0;d0})},p=function(c){return a.filter(c,b.curry(a.contains,m))},q=function(b,d){var e=c.bifilter(d,function(c,d){return a.contains(b,d)});return j(e.t,e.f)},r=function(a,b,c){var d=a.sections(),e=d.hasOwnProperty(b)?d[b]:{};return i.extend({},c,e)},s=function(a,b){return a.sections().hasOwnProperty(b)},t=function(a,b,c){return{id:a,theme:"modern",delta_width:0,delta_height:0,popup_css:"",plugins:"",document_base_url:b,add_form_submit_trigger:!0,submit_patch:!0,add_unload_trigger:!0,convert_urls:!0,relative_urls:!0,remove_script_host:!0,object_resizing:!0,doctype:"",visual:!0,font_size_style_values:"xx-small,x-small,small,medium,large,x-large,xx-large",font_size_legacy_values:"xx-small,small,medium,large,x-large,xx-large,300%",forced_root_block:"p",hidden_input:!0,padd_empty_editor:!0,render_ui:!0,indentation:"30px",inline_styles:!0,convert_fonts_to_spans:!0,indent:"simple",indent_before:"p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,th,ul,ol,li,dl,dt,dd,area,table,thead,tfoot,tbody,tr,section,article,hgroup,aside,figure,figcaption,option,optgroup,datalist",indent_after:"p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,th,ul,ol,li,dl,dt,dd,area,table,thead,tfoot,tbody,tr,section,article,hgroup,aside,figure,figcaption,option,optgroup,datalist",entity_encoding:"named",url_converter:c.convertURL,url_converter_scope:c,ie7_compat:!0}},u=function(a,b){var c=b.external_plugins?b.external_plugins:{};return a&&a.external_plugins?i.extend({},a.external_plugins,c):c},v=function(a,b){return[].concat(o(a)).concat(o(b))},w=function(a,b,c,d){var e=o(c.forced_plugins),f=o(d.plugins),g=a&&s(b,"mobile")?p(f):f,h=v(e,g);return i.extend(d,{plugins:h.join(" ")})},x=function(a,b){var c=b.settings().inline;return a&&s(b,"mobile")&&!c},y=function(a,b,c,d){var e=q(["mobile"],d),f=i.extend(b,c,e.settings(),x(a,e)?r(e,"mobile",n):{},{validate:!0,content_editable:e.settings().inline,external_plugins:u(c,e.settings())});return w(a,e,c,f)},z=function(a,b,c,d,e){var f=t(b,c,a);return y(l,f,d,e)},A=function(a,b){return d.from(a.settings[b])},B=function(a,b,c){return d.from(b.settings[c]).filter(a)};return{getEditorSettings:z,get:A,getString:b.curry(B,g.isString),combineSettings:y}}),g("5b",[],function(){var a=/[\u0591-\u07FF\uFB1D-\uFDFF\uFE70-\uFEFC]/,b=function(b){return a.test(b)};return{hasStrongRtl:b}}),g("43",["1i","1","2m","1v","30","21","2x","2y","53","l","1y","5b"],function(a,b,c,d,e,f,g,h,i,j,k,l){var m=function(a,b){var c=f.getString(a,"inline_boundaries_selector").getOr("a[href],code");return e.is(d.fromDom(b),c)},n=function(a){return"rtl"===j.DOM.getStyle(a,"direction",!0)||l.hasStrongRtl(a.textContent)},o=function(b,c,d){return a.filter(j.DOM.getParents(d.container(),"*",c),b)},p=function(a,b,d){var e=o(a,b,d);return c.from(e[e.length-1])},q=function(a,b,c){var d=i.getParentBlock(b,a),e=i.getParentBlock(c,a);return d&&d===e},r=function(a){return g.isBeforeInline(a)||g.isAfterInline(a)},s=function(a,b){var c=b.container(),d=b.offset();return a?g.isCaretContainerInline(c)?k.isText(c.nextSibling)?new h(c.nextSibling,0):h.after(c):g.isBeforeInline(b)?new h(c,d+1):b:g.isCaretContainerInline(c)?k.isText(c.previousSibling)?new h(c.previousSibling,c.previousSibling.data.length):h.before(c):g.isAfterInline(b)?new h(c,d-1):b},t=b.curry(s,!0),u=b.curry(s,!1);return{isInlineTarget:m,findRootInline:p,isRtl:n,isAtZwsp:r,normalizePosition:s,normalizeForwards:t,normalizeBackwards:u,hasSameParentBlock:q}}),g("3x",["2m","59","32","1v","5a","41","3k","43"],function(a,b,c,d,e,f,g,h){var i=function(a){return function(b){return c.eq(a,d.fromDom(b.dom().parentNode))}},j=function(b,d){return c.contains(b,d)?e.closest(d,function(a){return g.isTextBlock(a)||g.isListItem(a)},i(b)):a.none()},k=function(a){var b=a.getBody(),c=b.firstChild&&a.dom.isBlock(b.firstChild)?b.firstChild:b;a.selection.setCursorLocation(c,0)},l=function(a){a.dom.isEmpty(a.getBody())&&(a.setContent(""),k(a))},m=function(a,c,d){return b.liftN([f.firstPositionIn(d),f.lastPositionIn(d)],function(b,e){var g=h.normalizePosition(!0,b),i=h.normalizePosition(!1,e),j=h.normalizePosition(!1,c);return a?f.nextPosition(d,j).map(function(a){return a.isEqual(i)&&c.isEqual(g)}).getOr(!1):f.prevPosition(d,j).map(function(a){return a.isEqual(g)&&c.isEqual(i)}).getOr(!1)}).getOr(!0)};return{getParentBlock:j,paddEmptyBody:l,willDeleteLastPositionInElement:m}}),g("47",["5a","30","5g"],function(a,b,c){var d=function(a){return b.one(a)},e=function(c,d,e){return a.ancestor(c,function(a){return b.is(a,d)},e)},f=function(c,d){return a.sibling(c,function(a){return b.is(a,d)})},g=function(c,d){return a.child(c,function(a){return b.is(a,d)})},h=function(a,c){return b.one(c,a)},i=function(a,d,f){return c(b.is,e,a,d,f)};return{first:d,ancestor:e,sibling:f,child:g,descendant:h,closest:i}}),g("65",["47"],function(a){var b=function(b){return a.first(b).isSome()},c=function(b,c,d){return a.ancestor(b,c,d).isSome()},d=function(b,c){return a.sibling(b,c).isSome()},e=function(b,c){return a.child(b,c).isSome()},f=function(b,c){return a.descendant(b,c).isSome()},g=function(b,c,d){return a.closest(b,c,d).isSome()};return{any:b,ancestor:c,sibling:d,child:e,descendant:f,closest:g}}),g("5k",["1","32","1v","65","3m","1y","s"],function(a,b,c,d,e,f,g){var h=function(e,f){var g=c.fromDom(e),h=c.fromDom(f);return d.ancestor(h,"pre,code",a.curry(b.eq,g))},i=function(a,b){return f.isText(b)&&/^[ \t\r\n]*$/.test(b.data)&&h(a,b)===!1},j=function(a){return f.isElement(a)&&"A"===a.nodeName&&a.hasAttribute("name")},k=function(a,b){return e.isCaretCandidate(b)&&i(a,b)===!1||j(b)||l(b)},l=f.hasAttribute("data-mce-bookmark"),m=f.hasAttribute("data-mce-bogus"),n=f.hasAttributeValue("data-mce-bogus","all"),o=function(a){var b,c,d=0;if(k(a,a))return!1;if(c=a.firstChild,!c)return!0;b=new g(c,a);do if(n(c))c=b.next(!0);else if(m(c))c=b.next();else if(f.isBr(c))d++,c=b.next();else{if(k(a,c))return!1;c=b.next()}while(c);return d<=1},p=function(a){return o(a.dom())};return{isEmpty:p}}),g("57",["1i","1","2m","59","44","32","1v","3e","5a","3g","41","2y","3x","5k","1y"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o){var p=e.immutable("block","position"),q=e.immutable("from","to"),r=function(a,b){var c=g.fromDom(a),d=g.fromDom(b.container());return m.getParentBlock(c,d).map(function(a){return p(a,b)})},s=function(a){return f.eq(a.from().block(),a.to().block())===!1},t=function(a){return j.parent(a.from().block()).bind(function(b){return j.parent(a.to().block()).filter(function(a){return f.eq(b,a)})}).isSome()},u=function(a){return o.isContentEditableFalse(a.from().block())===!1&&o.isContentEditableFalse(a.to().block())===!1},v=function(a,b,d){return o.isBr(d.position().getNode())&&n.isEmpty(d.block())===!1?k.positionIn(!1,d.block().dom()).bind(function(e){return e.isEqual(d.position())?k.fromPosition(b,a,e).bind(function(b){return r(a,b)}):c.some(d)}).getOr(d):d},w=function(a,b,c){var e=r(a,l.fromRangeStart(c)),f=e.bind(function(c){return k.fromPosition(b,a,c.position()).bind(function(c){return r(a,c).map(function(c){return v(a,b,c)})})});return d.liftN([e,f],q).filter(function(a){return s(a)&&t(a)&&u(a)})},x=function(a,b,d){return d.collapsed?w(a,b,d):c.none()};return{read:x}}),g("5l",["1","32","3g"],function(a,b,c){var d=function(a){return a.slice(0,-1)},e=function(a,e,f){return b.contains(e,a)?d(c.parents(a,function(a){return f(a)||b.eq(a,e)})):[]},f=function(b,c){return e(b,c,a.constant(!1))},g=function(a,b){return[a].concat(f(a,b))};return{parentsUntil:e,parents:f,parentsAndSelf:g}}),g("58",["1i","2m","32","40","45","1v","3g","41","2y","3k","5k","1y","5l"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){var n=function(b){var c=g.children(b);return a.findIndex(c,j.isBlock).fold(function(){return c},function(a){return c.slice(0,a)})},o=function(b){var c=n(b);return a.each(c,function(a){e.remove(a)}),c},p=function(a,b){h.positionIn(a,b.dom()).each(function(a){var b=a.getNode();l.isBr(b)&&e.remove(f.fromDom(b))})},q=function(b,c){var d=m.parentsAndSelf(c,b);return a.find(d.reverse(),k.isEmpty).each(e.remove)},r=function(a,d){var e=g.parents(d,function(b){return c.eq(b,a)});return b.from(e[e.length-2])},s=function(a,d){return c.contains(d,a)?g.parent(a).bind(function(e){return c.eq(e,d)?b.some(a):r(d,a)}):b.none()},t=function(b,c,f){if(k.isEmpty(f))return e.remove(f),h.firstPositionIn(c.dom());p(!0,c),p(!1,f);var g=o(c);return s(c,f).fold(function(){q(b,c);var e=h.lastPositionIn(f.dom());return a.each(g,function(a){d.append(f,a)}),e},function(e){var j=h.prevPosition(f.dom(),i.before(e.dom()));return a.each(g,function(a){d.before(e,a)}),q(b,c),j})},u=function(a,b,c,d){return b?t(a,d,c):t(a,c,d)};return{mergeBlocks:u}}),g("3u",["1v","57","58"],function(a,b,c){var d=function(d,e){var f,g=a.fromDom(d.getBody());return f=b.read(g.dom(),e,d.selection.getRng()).bind(function(a){return c.mergeBlocks(g,e,a.from().block(),a.to().block())}),f.each(function(a){d.selection.setRng(a.toRange())}),f.isSome()};return{backspaceDelete:d}}),g("3v",["59","32","1v","41","2y","3x","58"],function(a,b,c,d,e,f,g){var h=function(d,e){var h=e.getRng();return a.liftN([f.getParentBlock(d,c.fromDom(h.startContainer)),f.getParentBlock(d,c.fromDom(h.endContainer))],function(a,c){return b.eq(a,c)===!1&&(h.deleteContents(),g.mergeBlocks(d,!0,a,c).each(function(a){e.setRng(a.toRange())}),!0)}).getOr(!1)},i=function(a,b){var c=d.prevPosition(a.dom(),e.fromRangeStart(b)).isNone(),f=d.nextPosition(a.dom(),e.fromRangeEnd(b)).isNone();return c&&f},j=function(a){return a.setContent(""),a.selection.setCursorLocation(),!0},k=function(a){var b=c.fromDom(a.getBody()),d=a.selection.getRng();return i(b,d)?j(a):h(b,a.selection)},l=function(a,b){return!a.selection.isCollapsed()&&k(a,a.selection.getRng())};return{backspaceDelete:l}}),g("5f",["1i","4e","27","4","5","3d"],function(a,b,c,d,e,f){var g=function(g){if(!c.isArray(g))throw new e("cases must be an array");if(0===g.length)throw new e("there must be at least one case");var h=[],i={};return a.each(g,function(j,k){var l=b.keys(j);if(1!==l.length)throw new e("one and only one name per case");var m=l[0],n=j[m];if(void 0!==i[m])throw new e("duplicate key detected:"+m);if("cata"===m)throw new e("cannot have a case named cata (sorry)");if(!c.isArray(n))throw new e("case arguments must be an array");h.push(m),i[m]=function(){var c=arguments.length;if(c!==n.length)throw new e("Wrong number of arguments to case "+m+". Expected "+n.length+" ("+n+"), got "+c);for(var i=new d(c),j=0;jl.before(b).offset()},p=function(a,b){return o(b,a)?new l(b.container(),b.offset()-1):b},q=function(a){return n.isText(a)?new l(a,0):l.before(a)},r=function(a){return n.isText(a)?new l(a,a.data.length):l.after(a)},s=function(a){return j.isCaretCandidate(a.previousSibling)?b.some(r(a.previousSibling)):a.previousSibling?k.lastPositionIn(a.previousSibling):b.none()},t=function(a){return j.isCaretCandidate(a.nextSibling)?b.some(q(a.nextSibling)):a.nextSibling?k.firstPositionIn(a.nextSibling):b.none()},u=function(a,c){var d=l.before(c.previousSibling?c.previousSibling:c.parentNode);return k.prevPosition(a,d).fold(function(){return k.nextPosition(a,l.after(c))},b.some)},v=function(a,c){return k.nextPosition(a,l.after(c)).fold(function(){return k.prevPosition(a,l.before(c))},b.some)},w=function(a,b){return s(b).orThunk(function(){return t(b)}).orThunk(function(){return u(a,b)})},x=function(a,b){return t(b).orThunk(function(){return s(b)}).orThunk(function(){return v(a,b)})},y=function(a,b,c){return a?x(b,c):w(b,c)},z=function(b,c,d){return y(b,c,d).map(a.curry(p,d))},A=function(a,b,c){c.fold(function(){a.focus()},function(c){a.selection.setRng(c.toRange(),b)})},B=function(a){return function(b){return b.dom()===a}},C=function(a,b){return b&&a.schema.getBlockElements().hasOwnProperty(g.name(b))},D=function(a){if(m.isEmpty(a)){var c=f.fromHtml('
');return e.empty(a),d.append(a,c),b.some(l.before(c.dom()))}return b.none()},E=function(a,b){return c.liftN([i.prevSibling(a),i.nextSibling(a),b],function(b,c,d){var f,g=b.dom(),h=c.dom();return n.isText(g)&&n.isText(h)?(f=g.data.length,g.appendData(h.data),e.remove(c),e.remove(a),d.container()===h?new l(g,f):d):(e.remove(a),d)}).orThunk(function(){return e.remove(a),b})},F=function(c,d,e){var f=z(d,c.getBody(),e.dom()),g=h.ancestor(e,a.curry(C,c),B(c.getBody())),i=E(e,f);g.bind(D).fold(function(){A(c,d,i)},function(a){A(c,d,b.some(a))})};return{deleteElement:F}}),g("3w",["1i","45","1v","56","2y","5c","5d","3x","1y"],function(a,b,c,d,e,f,g,h,i){var j=function(a,b){return function(d){return g.deleteElement(a,b,c.fromDom(d)),!0}},k=function(a,b){return function(c){var d=b?e.before(c):e.after(c);return a.selection.setRng(d.toRange()),!0}},l=function(a){return function(b){return a.selection.setRng(b.toRange()),!0}},m=function(a,b){var c=f.read(a.getBody(),b,a.selection.getRng()).map(function(c){return c.fold(j(a,b),k(a,b),l(a))});return c.getOr(!1)},n=function(c){a.each(d.descendants(c,".mce-offscreen-selection"),b.remove)},o=function(a,b){var d=a.selection.getNode();return!!i.isContentEditableFalse(d)&&(n(c.fromDom(a.getBody())),g.deleteElement(a,b,c.fromDom(a.selection.getNode())),h.paddEmptyBody(a),!0)},p=function(a,b){for(;b&&b!==a;){if(i.isContentEditableTrue(b)||i.isContentEditableFalse(b))return b;b=b.parentNode}return null},q=function(a){var b,c=p(a.getBody(),a.selection.getNode());return i.isContentEditableTrue(c)&&a.dom.isBlock(c)&&a.dom.isEmpty(c)&&(b=a.dom.create("br",{"data-mce-bogus":"1"}),a.dom.setHTML(c,""),c.appendChild(b),a.selection.setRng(e.before(b).toRange())),!0},r=function(a,b){return a.selection.isCollapsed()?m(a,b):o(a,b)};return{backspaceDelete:r,paddEmptyElement:q}}),g("66",["1","1y","2z"],function(a,b,c){var d=b.isText,e=function(a){return d(a)&&a.data[0]===c.ZWSP},f=function(a){return d(a)&&a.data[a.data.length-1]===c.ZWSP},g=function(a){return a.ownerDocument.createTextNode(c.ZWSP)},h=function(a){if(d(a.previousSibling))return f(a.previousSibling)?a.previousSibling:(a.previousSibling.appendData(c.ZWSP),a.previousSibling);if(d(a))return e(a)?a:(a.insertData(0,c.ZWSP),a);var b=g(a);return a.parentNode.insertBefore(b,a),b},i=function(a){if(d(a.nextSibling))return e(a.nextSibling)?a.nextSibling:(a.nextSibling.insertData(0,c.ZWSP),a.nextSibling);if(d(a))return f(a)?a:(a.appendData(c.ZWSP),a);var b=g(a);return a.nextSibling?a.parentNode.insertBefore(b,a.nextSibling):a.parentNode.appendChild(b),b},j=function(a,b){return a?h(b):i(b)};return{insertInline:j,insertInlineBefore:a.curry(j,!0),insertInlineAfter:a.curry(j,!1)}}),g("67",["1i","2x","2y","1y","2z"],function(a,b,c,d,e){var f=d.isElement,g=d.isText,h=function(a){var b=a.parentNode;b&&b.removeChild(a)},i=function(a){try{return a.nodeValue}catch(a){return""}},j=function(a,b){0===b.length?h(a):a.nodeValue=b},k=function(a){var b=e.trim(a);return{count:a.length-b.length,text:b}},l=function(a,b){return r(a),b},m=function(a,b){var d=k(a.data.substr(0,b.offset())),e=k(a.data.substr(b.offset())),f=d.text+e.text;return f.length>0?(j(a,f),new c(a,b.offset()-d.count)):b},n=function(b,d){var e=d.container(),f=a.indexOf(e.childNodes,b).map(function(a){return a=j.nodeValue.length&&(k=c.nodeIndex(j),j=j.parentNode),1===j.nodeType))for(i=j.childNodes,k0&&3===c.node.nodeType&&" "===c.node.nodeValue.charAt(c.offset-1)&&c.offset>1&&(a=c.node,a.splitText(c.offset-1))}return a},k=function(a){return"BR"===a.nodeName&&a.getAttribute("data-mce-bogus")&&!a.nextSibling},l=function(a,b){for(var c=b;c;){if(1===c.nodeType&&a.getContentEditable(c))return"false"===a.getContentEditable(c)?c:b;c=c.parentNode}return b},m=function(a,b,c,d){var e,f,g=c.nodeValue;return"undefined"==typeof d&&(d=a?g.length:0),a?(e=g.lastIndexOf(" ",d),f=g.lastIndexOf("\xa0",d),e=e>f?e:f,e===-1||b||e++):(e=g.indexOf(" ",d),f=g.indexOf("\xa0",d),e=e!==-1&&(f===-1||e0:h=0;g--){if(h=i[g].selector,!h||i[g].defaultBlock)return!0;for(f=e.length-1;f>=0;f--)if(j.is(e[f],h))return!0}return!1};return{matchNode:g,matchName:e,match:h,matchAll:i,canApply:j,matchesUnInheritedFormatSelector:c}}),g("2v",["1y"],function(a){var b=function(a,b){return a.splitText(b)},c=function(c){var d=c.startContainer,e=c.startOffset,f=c.endContainer,g=c.endOffset;return d===f&&a.isText(d)?e>0&&ee?(g-=e,d=f=b(f,g).previousSibling,g=f.nodeValue.length,e=0):g=0):(a.isText(d)&&e>0&&e0&&g1)return[];1===a.nodeType&&b.push(a),a=a.firstChild}return b},x=function(a){return w(a).length>0},y=function(a){var b;if(a)for(b=new k(a,a),a=b.current();a;a=b.next())if(3===a.nodeType)return a;return null},z=function(a){var c=d.fromTag("span");return f.setAll(c,{id:t,"data-mce-bogus":"1"}),a&&b.append(c,d.fromText(s)),c},A=function(a,b){for(;b&&b!==a;){if(b.id===t)return b;b=b.parentNode}return null},B=function(a,b,c){var d;d=A(a,c.getStart()),d&&!b.isEmpty(d)&&r.walk(d,function(a){1!==a.nodeType||a.id===t||b.isEmpty(a)||b.setAttrib(a,"data-mce-bogus",null)},"childNodes")},C=function(a){var b=y(a);return b&&b.nodeValue.charAt(0)===s&&b.deleteData(0,1),b},D=function(a,b,c,e){var f,g,h;f=b.getRng(!0),g=a.getParent(c,a.isBlock),x(c)?(e!==!1&&(f.setStartBefore(c),f.setEndBefore(c)),a.remove(c)):(h=C(c),f.startContainer===h&&f.startOffset>0&&f.setStart(h,f.startOffset-1),f.endContainer===h&&f.endOffset>0&&f.setEnd(h,f.endOffset-1),a.remove(c,!0)),g&&a.isEmpty(g)&&j.fillWithPaddingBr(d.fromDom(g)),b.setRng(f)},E=function(a,b,c,d,e){if(d)D(b,c,d,e);else if(d=A(a,c.getStart()),!d)for(;d=b.get(t);)D(b,c,d,!1)},F=function(a,b,c){var e=a.dom,f=e.getParent(c,q.curry(m.isTextBlock,a));f&&e.isEmpty(f)?c.parentNode.replaceChild(b,c):(j.removeTrailingBr(d.fromDom(c)),e.isEmpty(c)?c.parentNode.replaceChild(b,c):e.insertAfter(b,c))},G=function(a,b){return a.appendChild(b),b},H=function(b,c){var d=a.foldr(b,function(a,b){return G(a,b.cloneNode(!1))},c);return G(d,d.ownerDocument.createTextNode(s))},I=function(b,c){g.descendant(d.fromDom(c),"#"+t).each(function(c){a.each(w(c.dom()),function(a){b.setAttrib(a,"data-mce-bogus","1")})})},J=function(a,b,c){var d,e,f,g,h,i,j,k=a.selection;d=k.getRng(!0),g=d.startOffset,i=d.startContainer,j=i.nodeValue,e=A(a.getBody(),k.getStart()),e&&(f=y(e));var m=/[^\s\u00a0\u00ad\u200b\ufeff]/;j&&g>0&&g1};return{getRanges:d,getSelectedNodes:e,hasMultipleRanges:f}}),g("5m",["1i","1v","56","3k","36"],function(a,b,c,d,e){var f=function(b){return a.filter(e.getSelectedNodes(b),d.isTableCell)},g=function(a){var b=c.descendants(a,"td[data-mce-selected],th[data-mce-selected]");return b},h=function(a,b){var c=g(b),d=f(a);return c.length>0?c:d},i=function(a){return h(e.getRanges(a.selection.getSel()),b.fromDom(a.getBody()))};return{getCellsFromRanges:f,getCellsFromElement:g,getCellsFromElementOrRanges:h,getCellsFromEditor:i}}),g("3z",["1i","1","2m","32","1v","3e","41","2y","5d","5j","3k","5k","3s","5l","5m"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o){var p=function(b,c){return a.each(c,m.fillWithPaddingBr),b.selection.setCursorLocation(c[0].dom(),0),!0},q=function(a,b){return i.deleteElement(a,!1,b),!0},r=function(a,c,d){return j.getActionFromRange(c,d).map(function(c){return c.fold(b.curry(q,a),b.curry(p,a))})},s=function(a,b){return y(a,b)},t=function(a,b,c,d){return w(b,d).fold(function(){return r(a,b,c)},function(b){return s(a,b)}).getOr(!1)},u=function(a,b){var c=e.fromDom(a.getBody()),d=a.selection.getRng(),f=o.getCellsFromEditor(a);return 0!==f.length?p(a,f):t(a,c,d,b)},v=function(b,c){return a.find(n.parentsAndSelf(c,b),k.isTableCell)},w=function(b,c){return a.find(n.parentsAndSelf(c,b),function(a){return"caption"===f.name(a)})},x=function(a,b,c,f,h){return g.navigate(c,a.getBody(),h).bind(function(a){return v(b,e.fromDom(a.getNode())).map(function(a){return d.eq(a,f)===!1})})},y=function(a,b){return m.fillWithPaddingBr(b),a.selection.setCursorLocation(b.dom(),0),c.some(!0)},z=function(a,b,c,d){return g.firstPositionIn(a.dom()).bind(function(e){return g.lastPositionIn(a.dom()).map(function(a){return b?c.isEqual(e)&&d.isEqual(a):c.isEqual(a)&&d.isEqual(e)})}).getOr(!0)},A=function(a,b){return y(a,b)},B=function(a,b,c){return w(a,e.fromDom(c.getNode())).map(function(a){return d.eq(a,b)===!1})},C=function(a,b,d,e,f){return g.navigate(d,a.getBody(),f).bind(function(c){return z(e,d,f,c)?A(a,e):B(b,e,c)}).or(c.some(!0))},D=function(a,b,c,d){var e=h.fromRangeStart(a.selection.getRng());return v(c,d).bind(function(d){return l.isEmpty(d)?y(a,d):x(a,c,b,d,e)})},E=function(a,b,c,d){var e=h.fromRangeStart(a.selection.getRng());return l.isEmpty(d)?y(a,d):C(a,c,b,d,e)},F=function(a,b,c){var d=e.fromDom(a.getBody());return w(d,c).fold(function(){return D(a,b,d,c)},function(c){return E(a,b,d,c)}).getOr(!1)},G=function(a,b){var c=e.fromDom(a.selection.getStart(!0));return a.selection.isCollapsed()?F(a,b,c):u(a,c)};return{backspaceDelete:G}}),g("1x",["3u","3v","3w","3x","3y","3z"],function(a,b,c,d,e,f){var g=function(a,b){a.getDoc().execCommand(b,!1,null)},h=function(h){c.backspaceDelete(h,!1)||e.backspaceDelete(h,!1)||a.backspaceDelete(h,!1)||f.backspaceDelete(h)||b.backspaceDelete(h,!1)||(g(h,"Delete"),d.paddEmptyBody(h))},i=function(d){c.backspaceDelete(d,!0)||e.backspaceDelete(d,!0)||a.backspaceDelete(d,!0)||f.backspaceDelete(d)||b.backspaceDelete(d,!0)||g(d,"ForwardDelete")};return{deleteCommand:h,forwardDeleteCommand:i}}),g("2s",[],function(){var a=function(a,b){return a&&b&&a.startContainer===b.startContainer&&a.startOffset===b.startOffset&&a.endContainer===b.endContainer&&a.endOffset===b.endOffset};return{isEq:a}}),g("2r",["2m","44","2x","1y","s","2e","2s"],function(a,b,c,d,e,f,g){var h=b.immutable("container","offset"),i=function(a,b,c){for(;a&&a!==b;){if(c(a))return a;a=a.parentNode}return null},j=function(a,b,c){return null!==i(a,b,c)},k=function(a,b,c){return j(a,b,function(a){return a.nodeName===c})},l=function(a){return a&&"TABLE"===a.nodeName},m=function(a){return a&&/^(TD|TH|CAPTION)$/.test(a.nodeName)},n=function(a,b){return c.isCaretContainer(a)&&j(a,b,f.isCaretNode)===!1},o=function(a,b,c){for(var f=new e(b,a.getParent(b.parentNode,a.isBlock)||a.getRoot());b=f[c?"prev":"next"]();)if(d.isBr(b))return!0},p=function(a,b){return a.previousSibling&&a.previousSibling.nodeName===b},q=function(a,b){for(;b&&b!==a;){if(d.isContentEditableFalse(b))return!0;b=b.parentNode}return!1},r=function(b,c,f,g,i){var j,l,m,o,p=b.getRoot(),q=b.schema.getNonEmptyElements();if(m=b.getParent(i.parentNode,b.isBlock)||p,g&&d.isBr(i)&&c&&b.isEmpty(m))return a.some(h(i.parentNode,b.nodeIndex(i)));for(j=new e(i,m);o=j[g?"prev":"next"]();){if("false"===b.getContentEditableParent(o)||n(o,p))return a.none();if(d.isText(o)&&o.nodeValue.length>0)return k(o,p,"A")===!1?a.some(h(o,g?o.nodeValue.length:0)):a.none();if(b.isBlock(o)||q[o.nodeName.toLowerCase()])return a.none();l=o}return f&&l?a.some(h(l,0)):a.none()},s=function(b,f,g,i){var j,k,n,s,t,u,v,w=b.getRoot(),x=!1;if(j=i[(g?"start":"end")+"Container"],k=i[(g?"start":"end")+"Offset"],v=d.isElement(j)&&k===j.childNodes.length,t=b.schema.getNonEmptyElements(),u=g,c.isCaretContainer(j))return a.none();if(d.isElement(j)&&k>j.childNodes.length-1&&(u=!1),d.isDocument(j)&&(j=w,k=0),j===w){if(u&&(s=j.childNodes[k>0?k-1:0])){if(c.isCaretContainer(s))return a.none();if(t[s.nodeName]||l(s))return a.none()}if(j.hasChildNodes()){if(k=Math.min(!u&&k>0?k-1:k,j.childNodes.length-1),j=j.childNodes[k],k=d.isText(j)&&v?j.data.length:0,!f&&j===w.lastChild&&l(j))return a.none();if(q(w,j)||c.isCaretContainer(j))return a.none();if(j.hasChildNodes()&&l(j)===!1){s=j,n=new e(j,w);do{if(d.isContentEditableFalse(s)||c.isCaretContainer(s)){x=!1;break}if(d.isText(s)&&s.nodeValue.length>0){k=u?0:s.nodeValue.length,j=s,x=!0;break}if(t[s.nodeName.toLowerCase()]&&!m(s)){k=b.nodeIndex(s),j=s.parentNode,"IMG"!==s.nodeName&&"PRE"!==s.nodeName||u||k++,x=!0;break}}while(s=u?n.next():n.prev())}}}return f&&(d.isText(j)&&0===k&&r(b,v,f,!0,j).each(function(a){j=a.container(),k=a.offset(),x=!0}),d.isElement(j)&&(s=j.childNodes[k],s||(s=j.childNodes[k-1]),!s||!d.isBr(s)||p(s,"A")||o(b,s,!1)||o(b,s,!0)||r(b,v,f,!0,s).each(function(a){j=a.container(),k=a.offset(),x=!0}))),u&&!f&&d.isText(j)&&k===j.nodeValue.length&&r(b,v,f,!1,j).each(function(a){j=a.container(),k=a.offset(),x=!0}),x?a.some(h(j,k)):a.none()},t=function(b,c){var d=c.collapsed,e=c.cloneRange();return s(b,d,!0,e).each(function(a){e.setStart(a.container(),a.offset())}),d||s(b,d,!1,e).each(function(a){e.setEnd(a.container(),a.offset())}),d&&e.collapse(!0),g.isEq(c,e)?a.none():a.some(e)};return{normalize:t}}),g("1z",["1","40","1v","41","2y","1y","s","42","43","2r"],function(a,b,c,d,e,f,g,h,i,j){var k=function(a,b,c){for(var d,e=new g(b,c),f=a.getNonEmptyElements();d=e.next();)if(f[d.nodeName.toLowerCase()]||d.length>0)return!0},l=function(a,b,c){var d=a.create("span",{}," ");c.parentNode.insertBefore(d,c),b.scrollIntoView(d),a.remove(d)},m=function(a,b,c,d){var e=a.createRng();d?(e.setStartBefore(c),e.setEndBefore(c)):(e.setStartAfter(c),e.setEndAfter(c)),b.setRng(e)},n=function(a,b){var c,d,e=a.selection,f=a.dom,g=e.getRng(!0);j.normalize(f,g).each(function(a){g.setStart(a.startContainer,a.startOffset),g.setEnd(a.endContainer,a.endOffset)});var h=g.startOffset,i=g.startContainer;if(1===i.nodeType&&i.hasChildNodes()){var n=h>i.childNodes.length-1;i=i.childNodes[Math.min(h,i.childNodes.length-1)]||i,h=n&&3===i.nodeType?i.nodeValue.length:0}var o=f.getParent(i,f.isBlock),p=o?f.getParent(o.parentNode,f.isBlock):null,q=p?p.nodeName.toUpperCase():"",r=b&&b.ctrlKey;"LI"!==q||r||(o=p),i&&3===i.nodeType&&h>=i.nodeValue.length&&(k(a.schema,i,o)||(c=f.create("br"),g.insertNode(c),g.setStartAfter(c),g.setEndAfter(c),d=!0)),c=f.create("br"),g.insertNode(c),l(f,e,c),m(f,e,c,d),a.undoManager.add()},o=function(a,d){var e=c.fromTag("br");b.before(c.fromDom(d),e),a.undoManager.add()},p=function(a,d){r(a.getBody(),d)||b.after(c.fromDom(d),c.fromTag("br"));var e=c.fromTag("br");b.after(c.fromDom(d),e),l(a.dom,a.selection,e.dom()),m(a.dom,a.selection,e.dom(),!1),a.undoManager.add()},q=function(a){return f.isBr(a.getNode())},r=function(a,b){return!!q(e.after(b))||d.nextPosition(a,e.after(b)).map(function(a){return f.isBr(a.getNode())}).getOr(!1)},s=function(a){return a&&"A"===a.nodeName&&"href"in a},t=function(b){return b.fold(a.constant(!1),s,s,a.constant(!1))},u=function(b){var c=a.curry(i.isInlineTarget,b),d=e.fromRangeStart(b.selection.getRng());return h.readLocation(c,b.getBody(),d).filter(t)},v=function(b,c){c.fold(a.noop,a.curry(o,b),a.curry(p,b),a.noop)},w=function(b,c){var d=u(b);d.isSome()?d.each(a.curry(v,b)):n(b,c)};return{insertBr:w}}),g("5n",["5f","1"],function(a,b){var c=a.generate([{before:["element"]},{on:["element","offset"]},{after:["element"]}]),d=function(a,b,c,d){return a.fold(b,c,d)},e=function(a){return a.fold(b.identity,b.identity,b.identity)};return{before:c.before,on:c.on,after:c.after,cata:d,getStart:e}}),g("4d",["5f","44","1v","3g","5n"],function(a,b,c,d,e){var f=a.generate([{domRange:["rng"]},{relative:["startSitu","finishSitu"]},{exact:["start","soffset","finish","foffset"]}]),g=b.immutable("start","soffset","finish","foffset"),h=function(a){return f.exact(a.start(),a.soffset(),a.finish(),a.foffset())},i=function(a){return a.match({domRange:function(a){return c.fromDom(a.startContainer)},relative:function(a,b){return e.getStart(a)},exact:function(a,b,c,d){return a}})},j=function(a){var b=i(a);return d.defaultView(b)};return{domRange:f.domRange,relative:f.relative,exact:f.exact,exactFromRange:h,range:g,getWin:j}}),g("20",["1","2m","3c","32","1v","3e","4c","3g","4d","1j"],function(a,b,c,d,e,f,g,h,i,j){var k=c.detect().browser,l=function(a,b){var c=f.isText(b)?g.get(b).length:h.children(b).length+1;return a>c?c:a<0?0:a},m=function(a){return i.range(a.start(),l(a.soffset(),a.start()),a.finish(),l(a.foffset(),a.finish()))},n=function(a,b){return d.contains(a,b)||d.eq(a,b)},o=function(a){return function(b){return n(a,b.start())&&n(a,b.finish())}},p=function(a){return a.inline===!0||k.isIE()},q=function(a){return i.range(e.fromDom(a.startContainer),a.startOffset,e.fromDom(a.endContainer),a.endOffset)},r=function(a){var c=a.getSelection(),d=c&&0!==c.rangeCount?b.from(c.getRangeAt(0)):b.none();return d.map(q)},s=function(a){var b=h.defaultView(a);return r(b.dom()).filter(o(a))},t=function(a,c){return b.from(c).filter(o(a)).map(m)},u=function(a){var c=j.createRange();return c.setStart(a.start().dom(),a.soffset()),c.setEnd(a.finish().dom(),a.foffset()),b.some(c)},v=function(a){var c=p(a)?s(e.fromDom(a.getBody())):b.none();a.bookmark=c.isSome()?c:a.bookmark},w=function(a,c){var d=e.fromDom(a.getBody()),f=p(a)?b.from(c):b.none(),g=f.map(q).filter(o(d));a.bookmark=g.isSome()?g:a.bookmark},x=function(c){var d=c.bookmark?c.bookmark:b.none();return d.bind(a.curry(t,e.fromDom(c.getBody()))).bind(u)},y=function(a){x(a).each(function(b){a.selection.setRng(b)})};return{store:v,storeNative:w,readRange:r,restore:y,getRng:x,getBookmark:s,validate:t}}),g("8",["b","1w","1x","1y","1z","20","1e"],function(a,b,c,d,e,f,g){var h=g.each,i=g.extend,j=g.map,k=g.inArray,l=g.explode,m=!0,n=!1;return function(g){var o,p,q,r,s={state:{},exec:{},value:{}},t=g.settings;g.on("PreInit",function(){o=g.dom,p=g.selection,t=g.settings,q=g.formatter});var u=function(a,b,c,d){var e,i,j=0;if(!g.removed){if(/^(mceAddUndoLevel|mceEndUndoLevel|mceBeginUndoLevel|mceRepaint)$/.test(a)||d&&d.skip_focus?f.restore(g):g.focus(),d=g.fire("BeforeExecCommand",{command:a,ui:b,value:c}),d.isDefaultPrevented())return!1;if(i=a.toLowerCase(),e=s.exec[i])return e(i,b,c),g.fire("ExecCommand",{command:a,ui:b,value:c}),!0;if(h(g.plugins,function(d){if(d.execCommand&&d.execCommand(a,b,c))return g.fire("ExecCommand",{command:a,ui:b,value:c}),j=!0,!1}),j)return j;if(g.theme&&g.theme.execCommand&&g.theme.execCommand(a,b,c))return g.fire("ExecCommand",{command:a,ui:b,value:c}),!0;try{j=g.getDoc().execCommand(a,b,c)}catch(a){}return!!j&&(g.fire("ExecCommand",{command:a,ui:b,value:c}),!0)}},v=function(a){var b;if(!g.quirks.isHidden()&&!g.removed){if(a=a.toLowerCase(),b=s.state[a])return b(a);try{return g.getDoc().queryCommandState(a)}catch(a){}return!1}},w=function(a){var b;if(!g.quirks.isHidden()&&!g.removed){if(a=a.toLowerCase(),b=s.value[a])return b(a);try{return g.getDoc().queryCommandValue(a)}catch(a){}}},x=function(a,b){b=b||"exec",h(a,function(a,c){h(c.toLowerCase().split(","),function(c){s[b][c]=a})})},y=function(a,b,c){
a=a.toLowerCase(),s.exec[a]=function(a,d,e,f){return b.call(c||g,d,e,f)}},z=function(a){if(a=a.toLowerCase(),s.exec[a])return!0;try{return g.getDoc().queryCommandSupported(a)}catch(a){}return!1},A=function(a,b,c){a=a.toLowerCase(),s.state[a]=function(){return b.call(c||g)}},B=function(a,b,c){a=a.toLowerCase(),s.value[a]=function(){return b.call(c||g)}},C=function(a){return a=a.toLowerCase(),!!s.exec[a]};i(this,{execCommand:u,queryCommandState:v,queryCommandValue:w,queryCommandSupported:z,addCommands:x,addCommand:y,addQueryStateHandler:A,addQueryValueHandler:B,hasCustomCommand:C});var D=function(a,b,c){return void 0===b&&(b=n),void 0===c&&(c=null),g.getDoc().execCommand(a,b,c)},E=function(a){return q.match(a)},F=function(a,b){q.toggle(a,b?{value:b}:void 0),g.nodeChanged()},G=function(a){r=p.getBookmark(a)},H=function(){p.moveToBookmark(r)};x({"mceResetDesignMode,mceBeginUndoLevel":function(){},"mceEndUndoLevel,mceAddUndoLevel":function(){g.undoManager.add()},"Cut,Copy,Paste":function(b){var c,d=g.getDoc();try{D(b)}catch(a){c=m}if("paste"!==b||d.queryCommandEnabled(b)||(c=!0),c||!d.queryCommandSupported(b)){var e=g.translate("Your browser doesn't support direct access to the clipboard. Please use the Ctrl+X/C/V keyboard shortcuts instead.");a.mac&&(e=e.replace(/Ctrl\+/g,"\u2318+")),g.notificationManager.open({text:e,type:"error"})}},unlink:function(){if(p.isCollapsed()){var a=g.dom.getParent(g.selection.getStart(),"a");return void(a&&g.dom.remove(a,!0))}q.remove("link")},"JustifyLeft,JustifyCenter,JustifyRight,JustifyFull,JustifyNone":function(a){var b=a.substring(7);"full"==b&&(b="justify"),h("left,center,right,justify".split(","),function(a){b!=a&&q.remove("align"+a)}),"none"!=b&&F("align"+b)},"InsertUnorderedList,InsertOrderedList":function(a){var b,c;D(a),b=o.getParent(p.getNode(),"ol,ul"),b&&(c=b.parentNode,/^(H[1-6]|P|ADDRESS|PRE)$/.test(c.nodeName)&&(G(),o.split(c,b),H()))},"Bold,Italic,Underline,Strikethrough,Superscript,Subscript":function(a){F(a)},"ForeColor,HiliteColor,FontName":function(a,b,c){F(a,c)},FontSize:function(a,b,c){var d,e;c>=1&&c<=7&&(e=l(t.font_size_style_values),d=l(t.font_size_classes),c=d?d[c-1]||c:e[c-1]||c),F(a,c)},RemoveFormat:function(a){q.remove(a)},mceBlockQuote:function(){F("blockquote")},FormatBlock:function(a,b,c){return F(c||"p")},mceCleanup:function(){var a=p.getBookmark();g.setContent(g.getContent({cleanup:m}),{cleanup:m}),p.moveToBookmark(a)},mceRemoveNode:function(a,b,c){var d=c||p.getNode();d!=g.getBody()&&(G(),g.dom.remove(d,m),H())},mceSelectNodeDepth:function(a,b,c){var d=0;o.getParent(p.getNode(),function(a){if(1==a.nodeType&&d++==c)return p.select(a),n},g.getBody())},mceSelectNode:function(a,b,c){p.select(c)},mceInsertContent:function(a,c,d){b.insertAtCaret(g,d)},mceInsertRawHTML:function(a,b,c){p.setContent("tiny_mce_marker"),g.setContent(g.getContent().replace(/tiny_mce_marker/g,function(){return c}))},mceToggleFormat:function(a,b,c){F(c)},mceSetContent:function(a,b,c){g.setContent(c)},"Indent,Outdent":function(a){var b,c,d;b=t.indentation,c=/[a-z%]+$/i.exec(b),b=parseInt(b,10),v("InsertUnorderedList")||v("InsertOrderedList")?D(a):(t.forced_root_block||o.getParent(p.getNode(),o.isBlock)||q.apply("div"),h(p.getSelectedBlocks(),function(e){if("false"!==o.getContentEditable(e)&&"LI"!==e.nodeName){var f=g.getParam("indent_use_margin",!1)?"margin":"padding";f="TABLE"===e.nodeName?"margin":f,f+="rtl"==o.getStyle(e,"direction",!0)?"Right":"Left","outdent"==a?(d=Math.max(0,parseInt(e.style[f]||0,10)-b),o.setStyle(e,f,d?d+c:"")):(d=parseInt(e.style[f]||0,10)+b+c,o.setStyle(e,f,d))}}))},mceRepaint:function(){},InsertHorizontalRule:function(){g.execCommand("mceInsertContent",!1,"
")},mceToggleVisualAid:function(){g.hasVisual=!g.hasVisual,g.addVisual()},mceReplaceContent:function(a,b,c){g.execCommand("mceInsertContent",!1,c.replace(/\{\$selection\}/g,p.getContent({format:"text"})))},mceInsertLink:function(a,b,c){var d;"string"==typeof c&&(c={href:c}),d=o.getParent(p.getNode(),"a"),c.href=c.href.replace(" ","%20"),d&&c.href||q.remove("link"),c.href&&q.apply("link",c,d)},selectAll:function(){var a=o.getParent(p.getStart(),d.isContentEditableTrue);if(a){var b=o.createRng();b.selectNodeContents(a),p.setRng(b)}},"delete":function(){c.deleteCommand(g)},forwardDelete:function(){c.forwardDeleteCommand(g)},mceNewDocument:function(){g.setContent("")},InsertLineBreak:function(a,b,c){return e.insertBr(g,c),!0}}),x({"JustifyLeft,JustifyCenter,JustifyRight,JustifyFull":function(a){var b="align"+a.substring(7),c=p.isCollapsed()?[o.getParent(p.getNode(),o.isBlock)]:p.getSelectedBlocks(),d=j(c,function(a){return!!q.matchNode(a,b)});return k(d,m)!==-1},"Bold,Italic,Underline,Strikethrough,Superscript,Subscript":function(a){return E(a)},mceBlockQuote:function(){return E("blockquote")},Outdent:function(){var a;if(t.inline_styles){if((a=o.getParent(p.getStart(),o.isBlock))&&parseInt(a.style.paddingLeft,10)>0)return m;if((a=o.getParent(p.getEnd(),o.isBlock))&&parseInt(a.style.paddingLeft,10)>0)return m}return v("InsertUnorderedList")||v("InsertOrderedList")||!t.inline_styles&&!!o.getParent(p.getNode(),"BLOCKQUOTE")},"InsertUnorderedList,InsertOrderedList":function(a){var b=o.getParent(p.getNode(),"ul,ol");return b&&("insertunorderedlist"===a&&"UL"===b.tagName||"insertorderedlist"===a&&"OL"===b.tagName)}},"state"),x({"FontSize,FontName":function(a){var b,c=0;return(b=o.getParent(p.getNode(),"span"))&&(c="fontsize"==a?b.style.fontSize:b.style.fontFamily.replace(/, /g,",").replace(/[\'\"]/g,"").toLowerCase()),c}},"value"),x({Undo:function(){g.undoManager.undo()},Redo:function(){g.undoManager.redo()}})}}),g("16",["1e"],function(a){var b=a.makeMap("focus blur focusin focusout click dblclick mousedown mouseup mousemove mouseover beforepaste paste cut copy selectionchange mouseout mouseenter mouseleave wheel keydown keypress keyup input contextmenu dragstart dragend dragover draggesture dragdrop drop drag submit compositionstart compositionend compositionupdate touchstart touchmove touchend"," "),c=function(b){var c,d,e=this,f={},g=function(){return!1},h=function(){return!0};b=b||{},c=b.scope||e,d=b.toggleEvent||g;var i=function(a,d){var e,i,j,l;if(a=a.toLowerCase(),d=d||{},d.type=a,d.target||(d.target=c),d.preventDefault||(d.preventDefault=function(){d.isDefaultPrevented=h},d.stopPropagation=function(){d.isPropagationStopped=h},d.stopImmediatePropagation=function(){d.isImmediatePropagationStopped=h},d.isDefaultPrevented=g,d.isPropagationStopped=g,d.isImmediatePropagationStopped=g),b.beforeFire&&b.beforeFire(d),e=f[a])for(i=0,j=e.length;i0&&b.preventDefault()},a.dom.bind(b,"click",c),{unbind:function(){a.dom.unbind(b,"click",c)}}},c=function(c,d){c._clickBlocker&&(c._clickBlocker.unbind(),c._clickBlocker=null),d?(c._clickBlocker=b(c),c.selection.controlSelection.hideResizeRect(),c.readonly=!0,c.getBody().contentEditable=!1):(c.readonly=!1,c.getBody().contentEditable=!0,a(c,"StyleWithCSS",!1),a(c,"enableInlineTableEditing",!1),a(c,"enableObjectResizing",!1),c.focus(),c.nodeChanged())},d=function(a,b){var d=a.readonly?"readonly":"design";b!=d&&(a.initialized?c(a,"readonly"==b):a.on("init",function(){c(a,"readonly"==b)}),a.fire("SwitchMode",{mode:b}))};return{setMode:d}}),g("c",["1e","b"],function(a,b){var c=a.each,d=a.explode,e={f9:120,f10:121,f11:122},f=a.makeMap("alt,ctrl,shift,meta,access");return function(g){var h=this,i={},j=[],k=function(a){var g,h,i={};c(d(a,"+"),function(a){a in f?i[a]=!0:/^[0-9]{2,}$/.test(a)?i.keyCode=parseInt(a,10):(i.charCode=a.charCodeAt(0),i.keyCode=e[a]||a.toUpperCase().charCodeAt(0))}),g=[i.keyCode];for(h in f)i[h]?g.push(h):i[h]=!1;return i.id=g.join(","),i.access&&(i.alt=!0,b.mac?i.ctrl=!0:i.shift=!0),i.meta&&(b.mac?i.meta=!0:(i.ctrl=!0,i.meta=!1)),i},l=function(b,c,e,f){var h;return h=a.map(d(b,">"),k),h[h.length-1]=a.extend(h[h.length-1],{func:e,scope:f||g}),a.extend(h[0],{desc:g.translate(c),subpatterns:h.slice(1)})},m=function(a){return a.altKey||a.ctrlKey||a.metaKey},n=function(a){return"keydown"===a.type&&a.keyCode>=112&&a.keyCode<=123},o=function(a,b){return!!b&&(b.ctrl==a.ctrlKey&&b.meta==a.metaKey&&(b.alt==a.altKey&&b.shift==a.shiftKey&&(!!(a.keyCode==b.keyCode||a.charCode&&a.charCode==b.charCode)&&(a.preventDefault(),!0))))},p=function(a){return a.func?a.func.call(a.scope):null};g.on("keyup keypress keydown",function(a){!m(a)&&!n(a)||a.isDefaultPrevented()||(c(i,function(b){if(o(a,b))return j=b.subpatterns.slice(0),"keydown"==a.type&&p(b),!0}),o(a,j[0])&&(1===j.length&&"keydown"==a.type&&p(j[0]),j.shift()))}),h.add=function(b,e,f,h){var j;return j=f,"string"==typeof f?f=function(){g.execCommand(j,!1,null)}:a.isArray(j)&&(f=function(){g.execCommand(j[0],j[1],j[2])}),c(d(a.trim(b.toLowerCase())),function(a){var b=l(a,e,f,h);i[b.id]=b}),!0},h.remove=function(a){var b=l(a);return!!i[b.id]&&(delete i[b.id],!0)}}}),g("5o",["5a"],function(a){var b=function(b){return a.first(b).isSome()},c=function(b,c,d){return a.ancestor(b,c,d).isSome()},d=function(b,c,d){return a.closest(b,c,d).isSome()},e=function(b,c){return a.sibling(b,c).isSome()},f=function(b,c){return a.child(b,c).isSome()},g=function(b,c){return a.descendant(b,c).isSome()};return{any:b,ancestor:c,closest:d,sibling:e,child:f,descendant:g}}),g("4g",["1","2m","32","1v","5o","3g","1j"],function(a,b,c,d,e,f,g){var h=function(a){a.dom().focus()},i=function(a){a.dom().blur()},j=function(a){var b=f.owner(a).dom();return a.dom()===b.activeElement},k=function(a){var c=void 0!==a?a.dom():g;return b.from(c.activeElement).map(d.fromDom)},l=function(b){var d=f.owner(b),g=k(d).filter(function(d){return e.closest(d,a.curry(c.eq,b))});g.fold(function(){h(b)},a.noop)},m=function(a){return k(f.owner(a)).filter(function(b){return a.dom().contains(b.dom())})};return{hasFocus:j,focus:h,blur:i,active:k,search:m,focusInside:l}}),g("23",["2m","32","4g","1v","b","41","3k","2t","20"],function(a,b,c,d,e,f,g,h,i){var j=function(a,b){return a.dom.getParent(b,function(b){return"true"===a.dom.getContentEditable(b)})},k=function(b){return b.collapsed?a.from(h.getNode(b.startContainer,b.startOffset)).map(d.fromDom):a.none()},l=function(c,d){return k(d).bind(function(d){return g.isTableSection(d)?a.some(d):b.contains(c,d)===!1?a.some(c):a.none()})},m=function(a,b){l(d.fromDom(a.getBody()),b).bind(function(a){return f.firstPositionIn(a.dom())}).fold(function(){a.selection.normalize()},function(b){a.selection.setRng(b.toRange())})},n=function(a){if(a.setActive)try{a.setActive()}catch(b){a.focus()}else a.focus()},o=function(a){return c.hasFocus(a)||c.search(a).isSome()},p=function(a){return a.iframeElement&&c.hasFocus(d.fromDom(a.iframeElement))},q=function(a){var b=a.getBody();return b&&o(d.fromDom(b))},r=function(a){return a.inline?q(a):p(a)},s=function(a){var b,c=a.selection,d=a.settings.content_editable,f=a.getBody(),g=c.getRng();return a.quirks.refreshContentEditable(),b=j(a,c.getNode()),a.$.contains(f,b)?(n(b),m(a,g),void t(a)):(void 0!==a.bookmark&&r(a)===!1&&i.getRng(a).each(function(b){a.selection.setRng(b),g=b}),d||(e.opera||n(f),a.getWin().focus()),(e.gecko||d)&&(n(f),m(a,g)),void t(a))},t=function(a){a.editorManager.setActive(a)},u=function(a,b){a.removed||(b?t(a):s(a))};return{focus:u,hasFocus:r}}),g("2n",["1","2m","32","1v","3f","3g"],function(a,b,c,d,e,f){var g=function(a,b){var c=b.dom();return c[a]},h=function(a,b){return parseInt(e.get(b,a),10)},i=a.curry(g,"clientWidth"),j=a.curry(g,"clientHeight"),k=a.curry(h,"margin-top"),l=a.curry(h,"margin-left"),m=function(a){return a.dom().getBoundingClientRect()},n=function(a,b,c){var d=i(a),e=j(a);return b>=0&&c>=0&&b<=d&&c<=e},o=function(a,b,c,d){var e=m(b),f=a?e.left+b.dom().clientLeft+l(b):0,g=a?e.top+b.dom().clientTop+k(b):0,h=c-f,i=d-g;return{x:h,y:i}},p=function(a,b,c){var e=d.fromDom(a.getBody()),g=a.inline?e:f.documentElement(e),h=o(a.inline,g,b,c);return n(g,h.x,h.y)},q=function(a){return b.from(a).map(d.fromDom)},r=function(a){var b=a.inline?a.getBody():a.getContentAreaContainer();return q(b).map(function(a){return c.contains(f.owner(a),a)}).getOr(!1)};return{isXYInContentArea:p,isEditorAttachedToDom:r}}),g("2o",[],function(){return function(){var a=function(){throw new Error("Theme did not provide a NotificationManager implementation.")};return{open:a,close:a,reposition:a,getArgs:a}}}),g("g",["1i","2m","2n","2o","15"],function(a,b,c,d,e){return function(f){var g=[],h=function(){var a=f.theme;return a&&a.getNotificationManagerImpl?a.getNotificationManagerImpl():d()},i=function(){return b.from(g[0])},j=function(a,b){return!(a.type!==b.type||a.text!==b.text||a.progressBar||a.timeout||b.progressBar||b.timeout)},k=function(){g.length>0&&h().reposition(g)},l=function(a){g.push(a)},m=function(b){a.findIndex(g,function(a){return a===b}).each(function(a){g.splice(a,1)})},n=function(b){if(!f.removed&&c.isEditorAttachedToDom(f))return a.find(g,function(a){return j(h().getArgs(a),b)}).getOrThunk(function(){f.editorManager.setActive(f);var a=h().open(b,function(){m(a),k()});return l(a),k(),a})},o=function(){i().each(function(a){h().close(a),m(a),k()})},p=function(){return g},q=function(b){b.on("SkinLoaded",function(){var a=b.settings.service_message;a&&n({text:a,type:"warning",timeout:0,icon:""})}),b.on("ResizeEditor ResizeWindow",function(){e.requestAnimationFrame(k)}),b.on("remove",function(){a.each(g,function(a){h().close(a)})})};return q(f),{open:n,close:o,getNotifications:p}}}),g("2p",[],function(){return function(){var a=function(){throw new Error("Theme did not provide a WindowManager implementation.")};return{open:a,alert:a,confirm:a,close:a,getParams:a,setParams:a}}}),g("h",["1i","2m","20","2p"],function(a,b,c,d){return function(e){var f=[],g=function(){var a=e.theme;return a&&a.getWindowManagerImpl?a.getWindowManagerImpl():d()},h=function(a,b){return function(){return b?b.apply(a,arguments):void 0}},i=function(a){e.fire("OpenWindow",{win:a})},j=function(a){e.fire("CloseWindow",{win:a})},k=function(a){f.push(a),i(a)},l=function(b){a.findIndex(f,function(a){return a===b}).each(function(a){f.splice(a,1),j(b),0===f.length&&e.focus()})},m=function(){return b.from(f[f.length-1])},n=function(a,b){e.editorManager.setActive(e),c.store(e);var d=g().open(a,b,l);return k(d),d},o=function(a,b,c){var d=g().alert(a,h(c?c:this,b),l);k(d)},p=function(a,b,c){var d=g().confirm(a,h(c?c:this,b),l);k(d)},q=function(){m().each(function(a){g().close(a),l(a)})},r=function(){return m().map(g().getParams).getOr(null)},s=function(a){m().each(function(b){g().setParams(b,a)})},t=function(){return f};return e.on("remove",function(){a.each(f.slice(0),function(a){g().close(a)})}),{windows:f,open:n,alert:o,confirm:p,close:q,getParams:r,setParams:s,getWindows:t}}}),g("28",["2","6"],function(a,b){var c=b.PluginManager,d=function(a,b){for(var d in c.urls){var e=c.urls[d]+"/plugin"+b+".js";if(e===a)return d}return null},e=function(a,b){var c=d(b,a.suffix);return c?"Failed to load plugin: "+c+" from url "+b:"Failed to load plugin url: "+b},f=function(a,b){a.notificationManager.open({type:"error",text:b})},g=function(a,b){a._skinLoaded?f(a,b):a.on("SkinLoaded",function(){f(a,b)})},h=function(a,b){g(a,"Failed to upload image: "+b)},i=function(a,b){g(a,e(a,b))},j=function(b){var c=a.console;c&&!a.test&&(c.error?c.error.apply(c,arguments):c.log.apply(c,arguments))};return{pluginLoadError:i,uploadError:h,displayError:g,initError:j}}),g("4i",["6"],function(a){return a.PluginManager}),g("4j",["6"],function(a){return a.ThemeManager}),g("4m",["1r","1y","m"],function(a,b,c){var d={},e=a.filter,f=a.each,g=function(a,b){var c=d[a];c||(d[a]=c=[]),d[a].push(b)},h=function(a,b){f(d[a],function(a){a(b)})};return g("pre",function(d){var g,h,i=d.selection.getRng(),j=function(b){return g(b.previousSibling)&&a.indexOf(h,b.previousSibling)!==-1},k=function(a,b){c(b).remove(),c(a).append("
").append(b.childNodes)};g=b.matchNodeNames("pre"),i.collapsed||(h=d.selection.getSelectedBlocks(),f(e(e(h,g),j),function(a){k(a.previousSibling,a)}))}),{postProcess:h}}),g("2u",["1e"],function(a){var b=a.each,c=function(a,b){var c=a.childNodes;return b--,b>c.length-1?b=c.length-1:b<0&&(b=0),c[b]||a},d=function(a,d,e){var f,g,h,i,j,k,l,m=d.startContainer,n=d.startOffset,o=d.endContainer,p=d.endOffset;if(l=a.select("td[data-mce-selected],th[data-mce-selected]"),l.length>0)return void b(l,function(a){e([a])});var q=function(a){var b;return b=a[0],3===b.nodeType&&b===m&&n>=b.nodeValue.length&&a.splice(0,1),b=a[a.length-1],0===p&&a.length>0&&b===o&&3===b.nodeType&&a.splice(a.length-1,1),a},r=function(a,b,c){for(var d=[];a&&a!=c;a=a[b])d.push(a);return d},s=function(a,b){do{if(a.parentNode===b)return a;a=a.parentNode}while(a)},t=function(a,b,c){var d=c?"nextSibling":"previousSibling";for(i=a,j=i.parentNode;i&&i!=b;i=j)j=i.parentNode,k=r(i===a?i:i[d],d),k.length&&(c||k.reverse(),e(q(k)))};if(1===m.nodeType&&m.hasChildNodes()&&(m=m.childNodes[n]),1===o.nodeType&&o.hasChildNodes()&&(o=c(o,p)),m===o)return e(q([m]));for(f=a.findCommonAncestor(m,o),i=m;i;i=i.parentNode){if(i===o)return t(m,f,!0);if(i===f)break}for(i=o;i;i=i.parentNode){if(i===m)return t(o,f);if(i===f)break}g=s(m,f)||m,h=s(o,f)||o,t(m,g,!0),k=r(g===m?g:g.nextSibling,"nextSibling",h===o?h.nextSibling:h),k.length&&e(q(k)),t(o,h)};return{walk:d}}),g("2j",["j","1y","s","2e","48","49","2h","2u","1e"],function(a,b,c,d,e,f,g,h,i){var j=/^(src|href|style)$/,k=i.each,l=f.isEq,m=function(a){return/^(TH|TD)$/.test(a.nodeName)},n=function(a,d,e){var f,g,h;return f=d[e?"startContainer":"endContainer"],g=d[e?"startOffset":"endOffset"],b.isElement(f)&&(h=f.childNodes.length-1,!e&&g&&g--,f=f.childNodes[g>h?h:g]),b.isText(f)&&e&&g>=f.nodeValue.length&&(f=new c(f,a.getBody()).next()||f),b.isText(f)&&!e&&0===g&&(f=new c(f,a.getBody()).prev()||f),f},o=function(a,b,c,d){var e=a.create(c,d);return b.parentNode.insertBefore(e,b),e.appendChild(b),e},p=function(a,c,d){return!!l(c,d.inline)||(!!l(c,d.block)||(d.selector?b.isElement(c)&&a.is(c,d.selector):void 0))},q=function(a,b){return b.links&&"A"===a.tagName},r=function(a,b,c,d){return b=f.getNonWhiteSpaceSibling(b,c,d),!b||"BR"===b.nodeName||a.isBlock(b)},s=function(a,b,c){var d,e=b.parentNode,g=a.dom,h=a.settings.forced_root_block;c.block&&(h?e===g.getRoot()&&(c.list_block&&l(b,c.list_block)||k(i.grep(b.childNodes),function(b){f.isValid(a,h,b.nodeName.toLowerCase())?d?d.appendChild(b):(d=o(g,b,h),g.setAttribs(d,a.settings.forced_root_block_attrs)):d=0})):g.isBlock(b)&&!g.isBlock(e)&&(r(g,b,!1)||r(g,b.firstChild,!0,1)||b.insertBefore(g.create("br"),b.firstChild),r(g,b,!0)||r(g,b.lastChild,!1,1)||b.appendChild(g.create("br")))),c.selector&&c.inline&&!l(c.inline,b)||g.remove(b,1)},t=function(a,b,c,d,e){var g,h,i,m=a.dom;if(!p(m,d,b)&&!q(d,b))return!1;if("all"!==b.remove)for(k(b.styles,function(a,g){a=f.normalizeStyleValue(m,f.replaceVars(a,c),g),"number"==typeof g&&(g=a,e=0),(b.remove_similar||!e||l(f.getStyle(m,e,g),a))&&m.setStyle(d,g,""),i=1}),i&&""===m.getAttrib(d,"style")&&(d.removeAttribute("style"),d.removeAttribute("data-mce-style")),k(b.attributes,function(a,b){var g;if(a=f.replaceVars(a,c),"number"==typeof b&&(b=a,e=0),!e||l(m.getAttrib(e,b),a)){if("class"===b&&(a=m.getAttrib(d,b),a&&(g="",k(a.split(/\s+/),function(a){/mce\-\w+/.test(a)&&(g+=(g?" ":"")+a)}),g)))return void m.setAttrib(d,b,g);"class"===b&&d.removeAttribute("className"),j.test(b)&&d.removeAttribute("data-mce-"+b),d.removeAttribute(b)}}),k(b.classes,function(a){a=f.replaceVars(a,c),e&&!m.hasClass(e,a)||m.removeClass(d,a)}),h=m.getAttribs(d),g=0;g1||!d.isBlock(c))&&0===f?void d.remove(c,1):void((u.inline||u.wrapper)&&(u.exact||1!==f||(c=k(c)),h.mergeWithChildren(b,t,p,c),h.mergeWithParents(b,u,o,p,c),h.mergeBackgroundColorAndFontSize(d,u,p,c),h.mergeSubSup(d,u,p,c),h.mergeSiblings(d,u,p,c)))})};if("false"!==w.getContentEditable(x.getNode())){if(u){if(q)q.nodeType?z(t,q)||(s=w.createRng(),s.setStartBefore(q),s.setEndAfter(q),A(w,d.expandRng(b,s,t),null,!0)):A(w,q,null,!0);else if(v&&u.inline&&!w.select("td[data-mce-selected],th[data-mce-selected]").length)c.applyCaretFormat(b,o,p);else{var B=b.selection.getNode();b.settings.forced_root_block||!t[0].defaultBlock||w.getParent(B,w.isBlock)||n(b,t[0].defaultBlock),b.selection.setRng(i.normalize(b.selection.getRng())),r=x.getBookmark(),A(w,d.expandRng(b,x.getRng(!0),t),r),u.styles&&h.mergeUnderlineAndColor(w,u,p,B),x.moveToBookmark(r),e.moveStart(w,x,x.getRng(!0)),b.nodeChanged()}f.postProcess(o,b)}}else{q=x.getNode();for(var C=0,D=t.length;C0&&c[0],j=i&&i.name;if(h=l(a,j))j===h?(g=c[0],c=c.slice(1)):g=h;else if(i)g=c[0],c=c.slice(1);else if(!d)return a;return g&&(f=k(g),f.appendChild(a)),d&&(f||(f=e.create("div"),f.appendChild(a)),b.each(d,function(b){var c=k(b);f.insertBefore(c,a)})),m(f,c,g&&g.siblings)};return a&&a.length?(g=a[0],f=k(g),h=e.create("div"),h.appendChild(m(f,a.slice(1),g.siblings)),h):""},g=function(a,b){return f(i(a),b)},h=function(a){var c,d={classes:[],attrs:{}};return a=d.selector=b.trim(a),"*"!==a&&(c=a.replace(/(?:([#\.]|::?)([\w\-]+)|(\[)([^\]]+)\]?)/g,function(a,c,e,f,g){switch(c){case"#":d.attrs.id=e;break;case".":d.classes.push(e);break;case":":b.inArray("checked disabled enabled read-only required".split(" "),e)!==-1&&(d.attrs[e]=e)}if("["===f){var h=g.match(/([\w\-]+)(?:\=\"([^\"]+))?/);h&&(d.attrs[h[1]]=h[2])}return""})),d.name=c||"div",d},i=function(a){return a&&"string"==typeof a?(a=a.split(/\s*,\s*/)[0],a=a.replace(/\s*(~\+|~|\+|>)\s*/g,"$1"),b.map(a.split(/(?:>|\s+(?![^\[\]]+\]))/),function(a){var c=b.map(a.split(/(?:~\+|~|\+)/),h),d=c.pop();return c.length&&(d.siblings=c),d}).reverse()):[]},j=function(a,b){var c,g,h,j,k,l,m="";if(l=a.settings.preview_styles,l===!1)return"";"string"!=typeof l&&(l="font-family font-size font-weight font-style text-decoration text-transform color background-color border border-radius outline text-shadow");var n=function(a){return a.replace(/%(\w+)/g,"")};if("string"==typeof b){if(b=a.formatter.get(b),!b)return;b=b[0]}return"preview"in b&&(l=b.preview,l===!1)?"":(c=b.block||b.inline||"span",j=i(b.selector),j.length?(j[0].name||(j[0].name=c),c=b.selector,g=f(j,a)):g=f([c],a),h=e.select(c,g)[0]||g.firstChild,d(b.styles,function(a,b){a=n(a),a&&e.setStyle(h,b,a)}),d(b.attributes,function(a,b){a=n(a),a&&e.setAttrib(h,b,a)}),d(b.classes,function(a){a=n(a),e.hasClass(h,a)||e.addClass(h,a)}),a.fire("PreviewFormats"),e.setStyles(g,{position:"absolute",left:-65535}),a.getBody().appendChild(g),k=e.getStyle(a.getBody(),"fontSize",!0),k=/px$/.test(k)?parseInt(k,10):0,d(l.split(" "),function(b){var c=e.getStyle(h,b,!0);if(!("background-color"===b&&/transparent|rgba\s*\([^)]+,\s*0\)/.test(c)&&(c=e.getStyle(a.getBody(),b,!0),"#ffffff"===e.toHex(c).toLowerCase())||"color"===b&&"#000000"===e.toHex(c).toLowerCase())){if("font-size"===b&&/em|%$/.test(c)){if(0===k)return;c=parseFloat(c,10)/(/%$/.test(c)?100:1),c=c*k+"px"}"border"===b&&c&&(m+="padding:0 2px;"),m+=b+":"+c+";"}}),a.fire("AfterPreviewFormats"),e.remove(g),m)};return{getCssText:j,parseSelector:i,selectorToHtml:g}}),g("2k",["2d","2h","2j"],function(a,b,c){var d=function(d,e,f,g,h){var i=e.get(f);!b.match(d,f,g,h)||"toggle"in i[0]&&!i[0].toggle?a.applyFormat(d,f,g,h):c.remove(d,f,g,h)};return{toggle:d}}),g("2l",[],function(){var a=function(a){a.addShortcut("meta+b","","Bold"),a.addShortcut("meta+i","","Italic"),a.addShortcut("meta+u","","Underline");for(var b=1;b<=6;b++)a.addShortcut("access+"+b,"",["FormatBlock",!1,"h"+b]);a.addShortcut("access+7","",["FormatBlock",!1,"p"]),a.addShortcut("access+8","",["FormatBlock",!1,"div"]),a.addShortcut("access+9","",["FormatBlock",!1,"address"])};return{setup:a}}),g("f",["2c","1","2d","2e","2f","2g","2h","2i","2j","2k","2l"],function(a,b,c,d,e,f,g,h,i,j,k){return function(l){var m=f(l),n=a(null);return k.setup(l),d.setup(l),{get:m.get,register:m.register,unregister:m.unregister,apply:b.curry(c.applyFormat,l),remove:b.curry(i.remove,l),toggle:b.curry(j.toggle,l,m),match:b.curry(g.match,l),matchAll:b.curry(g.matchAll,l),matchNode:b.curry(g.matchNode,l),canApply:b.curry(g.canApply,l),formatChanged:b.curry(e.formatChanged,l,n),getCssText:b.curry(h.getCssText,l)}}}),g("69",["1","1v","47","2x"],function(a,b,c,d){var e=function(d){return c.descendant(b.fromDom(d.getBody()),"*[data-mce-caret]").fold(a.constant(null),function(a){return a.dom()})},f=function(a){a.selection.setRng(a.selection.getRng())},g=function(a,b){b.hasAttribute("data-mce-caret")&&(d.showCaretContainerBlock(b),f(a),a.selection.scrollIntoView(b))},h=function(a,b){var c=e(a);if(c)return"compositionstart"===b.type?(b.preventDefault(),b.stopPropagation(),void g(c)):void(d.hasContent(c)&&g(a,c))},i=function(b){b.on("keyup compositionstart",a.curry(h,b))};return{setup:i}}),g("31",["1i","3n"],function(a,b){var c=function(c,d,e){return!e.collapsed&&a.foldl(e.getClientRects(),function(a,e){return a||b.containsXY(e,c,d)},!1)};return{isXYWithinRange:c}}),g("1g",["b"],function(a){return{BACKSPACE:8,DELETE:46,DOWN:40,ENTER:13,LEFT:37,RIGHT:39,SPACEBAR:32,TAB:9,UP:38,modifierPressed:function(a){return a.shiftKey||a.ctrlKey||a.altKey||this.metaKeyPressed(a)},metaKeyPressed:function(b){return a.mac?b.metaKey:b.ctrlKey&&!b.altKey}}}),g("k",["1","1v","30","1j","1y","31","b","15","1e","1g"],function(a,b,c,d,e,f,g,h,i,j){var k=e.isContentEditableFalse,l=e.isContentEditableTrue,m=function(a,b){for(;b&&b!=a;){if(l(b)||k(b))return b;b=b.parentNode}return null},n=function(a){return a&&"IMG"===a.nodeName},o=function(a,b){return n(a.target)&&!f.isXYWithinRange(a.clientX,a.clientY,b)},p=function(a,b){var c=b.target;o(b,a.selection.getRng())&&!b.isDefaultPrevented()&&(b.preventDefault(),a.selection.select(c))};return function(e,f){var l,n,o,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F=f.dom,G=i.each,H=f.getDoc(),I=d,J=g.ie&&g.ie<11,K=Math.abs,L=Math.round,M=f.getBody();q={nw:[0,0,-1,-1],ne:[1,0,1,-1],se:[1,1,1,1],sw:[0,1,-1,1]};var N=".mce-content-body";f.contentStyles.push(N+" div.mce-resizehandle {position: absolute;border: 1px solid black;box-sizing: content-box;background: #FFF;width: 7px;height: 7px;z-index: 10000}"+N+" .mce-resizehandle:hover {background: #000}"+N+" img[data-mce-selected],"+N+" hr[data-mce-selected] {outline: 1px solid black;resize: none}"+N+" .mce-clonedresizable {position: absolute;"+(g.gecko?"":"outline: 1px dashed black;")+"opacity: .5;filter: alpha(opacity=50);z-index: 10000}"+N+" .mce-resize-helper {background: #555;background: rgba(0,0,0,0.75);border-radius: 3px;border: 1px;color: white;display: none;font-family: sans-serif;font-size: 12px;white-space: nowrap;line-height: 14px;margin: 5px 10px;padding: 5px;position: absolute;z-index: 10001}");var O=function(a){var d=f.settings.object_resizing;return d!==!1&&!g.iOS&&("string"!=typeof d&&(d="table,img,div"),"false"!==a.getAttribute("data-mce-resize")&&(a!=f.getBody()&&c.is(b.fromDom(a),d)))},P=function(a){var b,c,d,e,g;b=a.screenX-t,c=a.screenY-u,B=b*r[2]+x,C=c*r[3]+y,B=B<5?5:B,C=C<5?5:C,d="IMG"==l.nodeName&&f.settings.resize_img_proportional!==!1?!j.modifierPressed(a):j.modifierPressed(a)||"IMG"==l.nodeName&&r[2]*r[3]!==0,d&&(K(b)>K(c)?(C=L(B*z),B=L(C/z)):(B=L(C/z),C=L(B*z))),F.setStyles(n,{width:B,height:C}),e=r.startPos.x+b,g=r.startPos.y+c,e=e>0?e:0,g=g>0?g:0,F.setStyles(o,{left:e,top:g,display:"block"}),o.innerHTML=B+" × "+C,r[2]<0&&n.clientWidth<=B&&F.setStyle(n,"left",v+(x-B)),r[3]<0&&n.clientHeight<=C&&F.setStyle(n,"top",w+(y-C)),b=M.scrollWidth-D,c=M.scrollHeight-E,b+c!==0&&F.setStyles(o,{left:e-b,top:g-c}),A||(f.fire("ObjectResizeStart",{target:l,width:x,height:y}),A=!0)},Q=function(){A=!1;var a=function(a,b){b&&(l.style[a]||!f.schema.isValid(l.nodeName.toLowerCase(),a)?F.setStyle(l,a,b):F.setAttrib(l,a,b))};a("width",B),a("height",C),F.unbind(H,"mousemove",P),F.unbind(H,"mouseup",Q),I!=H&&(F.unbind(I,"mousemove",P),F.unbind(I,"mouseup",Q)),F.remove(n),F.remove(o),J&&"TABLE"!=l.nodeName||R(l),f.fire("ObjectResized",{target:l,width:B,height:C}),F.setAttrib(l,"style",F.getAttrib(l,"style")),f.nodeChanged()},R=function(a,b,c){var d,e,h,i,j;S(),_(),d=F.getPos(a,M),v=d.x,w=d.y,j=a.getBoundingClientRect(),e=j.width||j.right-j.left,h=j.height||j.bottom-j.top,l!=a&&($(),l=a,B=C=0),i=f.fire("ObjectSelected",{target:a}),O(a)&&!i.isDefaultPrevented()?G(q,function(a,d){var f,i=function(b){t=b.screenX,u=b.screenY,x=l.clientWidth,y=l.clientHeight,z=y/x,r=a,a.startPos={x:e*a[0]+v,y:h*a[1]+w},D=M.scrollWidth,E=M.scrollHeight,n=l.cloneNode(!0),F.addClass(n,"mce-clonedresizable"),F.setAttrib(n,"data-mce-bogus","all"),n.contentEditable=!1,n.unSelectabe=!0,F.setStyles(n,{left:v,top:w,margin:0}),n.removeAttribute("data-mce-selected"),M.appendChild(n),F.bind(H,"mousemove",P),F.bind(H,"mouseup",Q),I!=H&&(F.bind(I,"mousemove",P),F.bind(I,"mouseup",Q)),o=F.add(M,"div",{"class":"mce-resize-helper","data-mce-bogus":"all"},x+" × "+y)};return b?void(d==b&&i(c)):(f=F.get("mceResizeHandle"+d),f&&F.remove(f),f=F.add(M,"div",{id:"mceResizeHandle"+d,"data-mce-bogus":"all","class":"mce-resizehandle",unselectable:!0,style:"cursor:"+d+"-resize; margin:0; padding:0"}),g.ie&&(f.contentEditable=!1),F.bind(f,"mousedown",function(a){a.stopImmediatePropagation(),a.preventDefault(),i(a)}),a.elm=f,void F.setStyles(f,{left:e*a[0]+v-f.offsetWidth/2,top:h*a[1]+w-f.offsetHeight/2}))}):S(),l.setAttribute("data-mce-selected","1")},S=function(){var a,b;_(),l&&l.removeAttribute("data-mce-selected");for(a in q)b=F.get("mceResizeHandle"+a),b&&(F.unbind(b),F.remove(b))},T=function(a){var b,c,d=function(a,b){if(a)do if(a===b)return!0;while(a=a.parentNode)};if(!A&&!f.removed)return G(F.select("img[data-mce-selected],hr[data-mce-selected]"),function(a){a.removeAttribute("data-mce-selected")}),c="mousedown"==a.type?a.target:e.getNode(),c=F.$(c).closest(J?"table":"table,img,hr")[0],d(c,M)&&(aa(),b=e.getStart(!0),d(b,c)&&d(e.getEnd(!0),c)&&(!J||c!=b&&"IMG"!==b.nodeName))?void R(c):void S()},U=function(a,b,c){a&&a.attachEvent&&a.attachEvent("on"+b,c)},V=function(a,b,c){a&&a.detachEvent&&a.detachEvent("on"+b,c)},W=function(a){var b,c,d,e,g,h,i,j=a.srcElement;b=j.getBoundingClientRect(),h=s.clientX-b.left,i=s.clientY-b.top;for(c in q)if(d=q[c],e=j.offsetWidth*d[0],g=j.offsetHeight*d[1],K(e-h)<8&&K(g-i)<8){r=d;break}A=!0,f.fire("ObjectResizeStart",{target:l,width:l.clientWidth,height:l.clientHeight}),f.getDoc().selection.empty(),R(j,c,s)},X=function(a){a.preventDefault?a.preventDefault():a.returnValue=!1},Y=function(a){return k(m(f.getBody(),a))},Z=function(a){var b=a.srcElement;if(Y(b))return void X(a);if(b!=l){if(f.fire("ObjectSelected",{target:b}),$(),0===b.id.indexOf("mceResizeHandle"))return void(a.returnValue=!1);"IMG"!=b.nodeName&&"TABLE"!=b.nodeName||(S(),l=b,U(b,"resizestart",W))}},$=function(){V(l,"resizestart",W)},_=function(){for(var a in q){var b=q[a];b.elm&&(F.unbind(b.elm),delete b.elm)}},aa=function(){try{f.getDoc().execCommand("enableObjectResizing",!1,!1)}catch(a){}},ba=function(a){var b;if(J){b=H.body.createControlRange();try{return b.addElement(a),b.select(),!0}catch(a){}}};f.on("init",function(){J?(f.on("ObjectResized",function(a){"TABLE"!=a.target.nodeName&&(S(),ba(a.target))}),U(M,"controlselect",Z),f.on("mousedown",function(a){s=a})):(aa(),g.ie>=11&&(f.on("mousedown click",function(a){var b=a.target,c=b.nodeName;A||!/^(TABLE|IMG|HR)$/.test(c)||Y(b)||(2!==a.button&&f.selection.select(b,"TABLE"==c),"mousedown"==a.type&&f.nodeChanged())}),f.dom.bind(M,"mscontrolselect",function(a){var b=function(a){h.setEditorTimeout(f,function(){f.selection.select(a)})};return Y(a.target)?(a.preventDefault(),void b(a.target)):void(/^(TABLE|IMG|HR)$/.test(a.target.nodeName)&&(a.preventDefault(),"IMG"==a.target.tagName&&b(a.target)))})));var b=h.throttle(function(a){f.composing||T(a)});f.on("nodechange ResizeEditor ResizeWindow drop",b),f.on("keyup compositionend",function(a){l&&"TABLE"==l.nodeName&&b(a)}),f.on("hide blur",S),f.on("contextmenu",a.curry(p,f))}),f.on("remove",_);var ca=function(){l=n=null,J&&($(),V(M,"controlselect",Z))};return{isResizable:O,showResizeRect:R,hideResizeRect:S,updateResizeRect:T,controlSelect:ba,destroy:ca}}}),g("33",["1y"],function(a){var b=function(a){for(var b=0,c=0,d=a;d&&d.nodeType;)b+=d.offsetLeft||0,c+=d.offsetTop||0,d=d.offsetParent;return{x:b,y:c}},c=function(a,b,c){var d={elm:b,alignToTop:c};return a.fire("scrollIntoView",d),d.isDefaultPrevented()},d=function(d,e,f){var g,h,i,j,k=d.dom,l=k.getRoot(),m=0;if(!c(d,e,f)&&a.isElement(e)){if(f===!1&&(m=e.offsetHeight),"BODY"!==l.nodeName){var n=d.selection.getScrollContainer();if(n)return g=b(e).y-b(n).y+m,j=n.clientHeight,i=n.scrollTop,void((gi+j)&&(n.scrollTop=gi+j)&&d.getWin().scrollTo(0,g0){c=(g[0].bottom+g[0].top)/2;try{return f.moveToPoint(a,c),f.collapse(!0),f}catch(a){}}return null},f=function(b,e){var f=b&&b.parentElement?b.parentElement():null;return a.isContentEditableFalse(d(f,e,c))?null:b},g=function(a,b,c){var d,g;if(c.caretPositionFromPoint)g=c.caretPositionFromPoint(a,b),g&&(d=c.createRange(),d.setStart(g.offsetNode,g.offset),d.collapse(!0));else if(c.caretRangeFromPoint)d=c.caretRangeFromPoint(a,b);else if(c.body.createTextRange){d=c.body.createTextRange();try{d.moveToPoint(a,b),d.collapse(!0)}catch(f){d=e(a,b,c)}return f(d,c.body)}return d};return{fromPoint:g}}),g("34",["1i"],function(a){var b=function(b,c){return a.map(c,function(a){var c=b.fire("GetSelectionRange",{range:a});return c.range!==a?c.range:a})};return{processRanges:b}}),g("5t",["46","1v","40","54","45","3g"],function(a,b,c,d,e,f){var g=function(a,c){return b.fromDom(a.dom().cloneNode(c))},h=function(a){return g(a,!1)},i=function(a){return g(a,!0)},j=function(c,d){var e=b.fromTag(d),f=a.clone(c);return a.setAll(e,f),e},k=function(a,b){var c=j(a,b),e=f.children(i(a));return d.append(c,e),c},l=function(a,b){var g=j(a,b);c.before(a,g);var h=f.children(a);return d.append(g,h),e.remove(a),g};return{shallow:h,shallowAs:j,deep:i,copy:k,mutate:l}}),g("5u",["1i","1v","1j"],function(a,b,c){var d=function(d,e){var f=e||c,g=f.createDocumentFragment();return a.each(d,function(a){g.appendChild(a.dom())}),b.fromDom(g)};return{fromElements:d}}),g("5v",["1i","1","2m","59","32","1v","3e","3g","1y"],function(a,b,c,d,e,f,g,h,i){var j=function(a){var b=a.startContainer,d=a.startOffset;return i.isText(b)?0===d?c.some(f.fromDom(b)):c.none():c.from(b.childNodes[d]).map(f.fromDom)},k=function(a){var b=a.endContainer,d=a.endOffset;return i.isText(b)?d===b.data.length?c.some(f.fromDom(b)):c.none():c.from(b.childNodes[d-1]).map(f.fromDom)},l=function(a){return h.firstChild(a).fold(b.constant([a]),function(b){return[a].concat(l(b))})},m=function(a){return h.lastChild(a).fold(b.constant([a]),function(b){return"br"===g.name(b)?h.prevSibling(b).map(function(b){return[a].concat(m(b))}).getOr([]):[a].concat(m(b))})},n=function(c,f){return d.liftN([j(f),k(f)],function(d,f){var g=a.find(l(c),b.curry(e.eq,d)),h=a.find(m(c),b.curry(e.eq,f));return g.isSome()&&h.isSome()}).getOr(!1)};return{hasAllContentsSelected:n}}),g("5w",["1i","2m","44","32","40","54","5t","1v","46","56"],function(a,b,c,d,e,f,g,h,i,j){var k=c.immutable("element","width","rows"),l=c.immutable("element","cells"),m=c.immutable("x","y"),n=function(a,b){var c=parseInt(i.get(a,b),10);return isNaN(c)?1:c},o=function(a,b,c,d,e){for(var f=n(e,"rowspan"),h=n(e,"colspan"),i=a.rows(),j=c;ja?b.cells().length:a},0)},s=function(a,c){for(var e=a.rows(),f=0;f0?g.fromElements([e]):e},s=function(a){return k.isListItem(a)?j.parent(a).filter(k.isList).fold(b.constant([]),function(b){return[a,b]}):k.isList(a)?[a]:[]},t=function(b,c){var d=f.fromDom(c.commonAncestorContainer),g=l.parentsAndSelf(d,b),h=a.filter(g,function(a){return k.isInline(a)||k.isHeading(a)}),i=q(g,c),j=h.concat(i.length?i:s(d));return a.map(j,e.shallow)},u=function(){return g.fromElements([])},v=function(a,b){return r(f.fromDom(b.cloneContents()),t(a,b))},w=function(a,d){return i.ancestor(d,"table",b.curry(c.eq,a))},x=function(a,b){return w(a,b[0]).bind(function(a){var c=b[0],d=b[b.length-1],e=n.fromDom(a);return n.subsection(e,c,d).map(function(a){return g.fromElements([n.toDom(a)])})}).getOrThunk(u)},y=function(a,b){return b.length>0&&b[0].collapsed?u():v(a,b[0])},z=function(a,b){var c=o.getCellsFromElementOrRanges(b,a);return c.length>0?x(a,c):y(a,b)};return{read:z}}),g("35",["1v","34","4p","36","2z"],function(a,b,c,d,e){var f=function(f,g){var h,i,j,k=f.selection.getRng(),l=f.dom.create("body"),m=f.selection.getSel(),n=b.processRanges(f,d.getRanges(m));return g=g||{},h=i="",g.get=!0,g.format=g.format||"html",g.selection=!0,g=f.fire("BeforeGetContent",g),g.isDefaultPrevented()?(f.fire("GetContent",g),g.content):"text"===g.format?f.selection.isCollapsed()?"":e.trim(k.text||(m.toString?m.toString():"")):(k.cloneContents?(j=g.contextual?c.read(a.fromDom(f.getBody()),n).dom():k.cloneContents(),j&&l.appendChild(j)):void 0!==k.item||void 0!==k.htmlText?(l.innerHTML="
"+(k.item?k.item(0).outerHTML:k.htmlText),l.removeChild(l.firstChild)):l.innerHTML=k.toString(),/^\s/.test(l.innerHTML)&&(h=" "),/\s+$/.test(l.innerHTML)&&(i=" "),g.getInner=!0,g.content=f.selection.isCollapsed()?"":h+f.selection.serializer.serialize(l,g)+i,f.fire("GetContent",g),g.content)};return{getContent:f}}),g("37",[],function(){var a=function(a,b,c){var d,e,f,g=a.selection.getRng(),h=a.getDoc();if(c=c||{format:"html"},c.set=!0,c.selection=!0,c.content=b,!c.no_events&&(c=a.fire("BeforeSetContent",c),c.isDefaultPrevented()))return void a.fire("SetContent",c);if(b=c.content,g.insertNode){b+='_',g.startContainer==h&&g.endContainer==h?h.body.innerHTML=b:(g.deleteContents(),0===h.body.childNodes.length?h.body.innerHTML=b:g.createContextualFragment?g.insertNode(g.createContextualFragment(b)):(e=h.createDocumentFragment(),f=h.createElement("div"),e.appendChild(f),f.outerHTML=b,g.insertNode(e))),d=a.dom.get("__caret"),g=h.createRange(),g.setStartBefore(d),g.setEndBefore(d),a.selection.setRng(g),a.dom.remove("__caret");try{a.selection.setRng(g)}catch(a){}}else g.item&&(h.execCommand("Delete",!1,null),g=a.getRng()),/^\s+/.test(b)?(g.pasteHTML('_'+b),a.dom.remove("__mce_tmp")):g.pasteHTML(b);c.no_events||a.fire("SetContent",c)};return{setContent:a}}),g("p",["32","1v","b","2y","j","k","33","s","23","2q","34","35","36","2r","20","37","1e"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q){var r=q.each,s=q.trim,t=function(c){return!(!c||!c.ownerDocument)&&a.contains(b.fromDom(c.ownerDocument),b.fromDom(c))},u=function(a){return!!a&&(!!a.select||t(a.startContainer)&&t(a.endContainer))},v=function(a,b,c,d){var g=this;g.dom=a,g.win=b,g.serializer=c,g.editor=d,g.bookmarkManager=new e(g),g.controlSelection=new f(g,d)};return v.prototype={setCursorLocation:function(a,b){var c=this,d=c.dom.createRng();a?(d.setStart(a,b),d.setEnd(a,b),c.setRng(d),c.collapse(!1)):(c._moveEndPoint(d,c.editor.getBody(),!0),c.setRng(d))},getContent:function(a){return l.getContent(this.editor,a)},setContent:function(a,b){p.setContent(this.editor,a,b)},getStart:function(a){var b,c=this,d=c.getRng();return b=d.startContainer,1==b.nodeType&&b.hasChildNodes()&&(a&&d.collapsed||(b=b.childNodes[Math.min(b.childNodes.length-1,d.startOffset)])),b&&3==b.nodeType?b.parentNode:b},getEnd:function(a){var b,c,d=this,e=d.getRng();return b=e.endContainer,c=e.endOffset,1==b.nodeType&&b.hasChildNodes()&&(a&&e.collapsed||(b=b.childNodes[c>0?c-1:c])),b&&3==b.nodeType?b.parentNode:b},getBookmark:function(a,b){return this.bookmarkManager.getBookmark(a,b)},moveToBookmark:function(a){return this.bookmarkManager.moveToBookmark(a)},select:function(a,b){var c,d=this,e=d.dom,f=e.createRng();if(a){if(!b&&d.controlSelection.controlSelect(a))return;c=e.nodeIndex(a),f.setStart(a.parentNode,c),f.setEnd(a.parentNode,c+1),b&&(d._moveEndPoint(f,a,!0),d._moveEndPoint(f,a)),d.setRng(f)}return a},isCollapsed:function(){var a=this,b=a.getRng(),c=a.getSel();return!(!b||b.item)&&(b.compareEndPoints?0===b.compareEndPoints("StartToEnd",b):!c||b.collapsed)},collapse:function(a){var b=this,c=b.getRng();c.collapse(!!a),b.setRng(c)},getSel:function(){var a=this.win;return a.getSelection?a.getSelection():a.document.selection},getRng:function(a){var b,c,d,e,f=this,g=function(a,b,c){try{return b.compareBoundaryPoints(a,c)}catch(a){return-1}};if(!f.win)return null;if(e=f.win.document,"undefined"==typeof e||null===e)return null;if(void 0!==f.editor.bookmark&&i.hasFocus(f.editor)===!1){var h=o.getRng(f.editor);if(h.isSome())return h.getOr(e.createRange())}try{(b=f.getSel())&&(c=b.rangeCount>0?b.getRangeAt(0):b.createRange?b.createRange():e.createRange())}catch(a){}return c=k.processRanges(f.editor,[c])[0],c||(c=e.createRange?e.createRange():e.body.createTextRange()),c.setStart&&9===c.startContainer.nodeType&&c.collapsed&&(d=f.dom.getRoot(),c.setStart(d,0),c.setEnd(d,0)),f.selectedRange&&f.explicitRange&&(0===g(c.START_TO_START,c,f.selectedRange)&&0===g(c.END_TO_END,c,f.selectedRange)?c=f.explicitRange:(f.selectedRange=null,f.explicitRange=null)),c},setRng:function(a,b){var d,e,f,g=this;if(u(a))if(a.select){g.explicitRange=null;try{a.select()}catch(a){}}else{if(d=g.getSel(),f=g.editor.fire("SetSelectionRange",{range:a,forward:b}),a=f.range,d){g.explicitRange=a;try{d.removeAllRanges(),d.addRange(a)}catch(a){}b===!1&&d.extend&&(d.collapse(a.endContainer,a.endOffset),d.extend(a.startContainer,a.startOffset)),g.selectedRange=d.rangeCount>0?d.getRangeAt(0):null}a.collapsed||a.startContainer!==a.endContainer||!d.setBaseAndExtent||c.ie||a.endOffset-a.startOffset<2&&a.startContainer.hasChildNodes()&&(e=a.startContainer.childNodes[a.startOffset],e&&"IMG"===e.tagName&&(d.setBaseAndExtent(a.startContainer,a.startOffset,a.endContainer,a.endOffset),d.anchorNode===a.startContainer&&d.focusNode===a.endContainer||d.setBaseAndExtent(e,0,e,1))),g.editor.fire("AfterSetSelectionRange",{range:a,forward:b})}},setNode:function(a){var b=this;return b.setContent(b.dom.getOuterHTML(a)),a},getNode:function(){var a,b,c,d,e,f=this,g=f.getRng(),h=f.dom.getRoot(),i=function(a,b){for(var c=a;a&&3===a.nodeType&&0===a.length;)a=b?a.nextSibling:a.previousSibling;return a||c};return g?(b=g.startContainer,c=g.endContainer,d=g.startOffset,e=g.endOffset,a=g.commonAncestorContainer,!g.collapsed&&(b==c&&e-d<2&&b.hasChildNodes()&&(a=b.childNodes[d]),3===b.nodeType&&3===c.nodeType&&(b=b.length===d?i(b.nextSibling,!0):b.parentNode,c=0===e?i(c.previousSibling,!1):c.parentNode,b&&b===c))?b:a&&3==a.nodeType?a.parentNode:a):h},getSelectedBlocks:function(a,b){var c,d,e=this,f=e.dom,g=[];if(d=f.getRoot(),a=f.getParent(a||e.getStart(),f.isBlock),b=f.getParent(b||e.getEnd(),f.isBlock),a&&a!=d&&g.push(a),a&&b&&a!=b){c=a;for(var i=new h(a,d);(c=i.next())&&c!=b;)f.isBlock(c)&&g.push(c)}return b&&a!=b&&b!=d&&g.push(b),g},isForward:function(){var a,b,c=this.dom,d=this.getSel();return!(d&&d.anchorNode&&d.focusNode)||(a=c.createRng(),a.setStart(d.anchorNode,d.anchorOffset),a.collapse(!0),b=c.createRng(),b.setStart(d.focusNode,d.focusOffset),b.collapse(!0),a.compareBoundaryPoints(a.START_TO_START,b)<=0)},normalize:function(){var a=this,b=a.getRng();if(!m.hasMultipleRanges(a.getSel())){var c=n.normalize(a.dom,b);return c.each(function(b){a.setRng(b,a.isForward())}),c.getOr(b)}return b},selectorChanged:function(a,b){var c,d=this;return d.selectorChangedData||(d.selectorChangedData={},c={},d.editor.on("NodeChange",function(a){var b=a.element,e=d.dom,f=e.getParents(b,null,e.getRoot()),g={};r(d.selectorChangedData,function(a,b){r(f,function(d){if(e.is(d,b))return c[b]||(r(a,function(a){a(!0,{node:d,selector:b,parents:f})}),c[b]=a),g[b]=a,!1})}),r(c,function(a,d){g[d]||(delete c[d],r(a,function(a){a(!1,{node:b,selector:d,parents:f})}))})})),d.selectorChangedData[a]||(d.selectorChangedData[a]=[]),d.selectorChangedData[a].push(b),d},getScrollContainer:function(){for(var a,b=this.dom.getRoot();b&&"BODY"!=b.nodeName;){if(b.scrollHeight>b.clientHeight){a=b;break}b=b.parentNode}return a},scrollIntoView:function(a,b){g.scrollIntoView(this.editor,a,b)},placeCaretAt:function(a,b){this.setRng(j.fromPoint(a,b,this.editor.getDoc()))},_moveEndPoint:function(a,b,d){var e=b,f=new h(b,e),g=this.dom.schema.getNonEmptyElements();do{if(3==b.nodeType&&0!==s(b.nodeValue).length)return void(d?a.setStart(b,0):a.setEnd(b,b.nodeValue.length));if(g[b.nodeName]&&!/^(TD|TH)$/.test(b.nodeName))return void(d?a.setStartBefore(b):"BR"==b.nodeName?a.setEndBefore(b):a.setEndAfter(b));if(c.ie&&c.ie<11&&this.dom.isBlock(b)&&this.dom.isEmpty(b))return void(d?a.setStart(b,0):a.setEnd(b,0))}while(b=d?f.next():f.prev());"BODY"==e.nodeName&&(d?a.setStart(e,0):a.setEnd(e,e.childNodes.length))},getBoundingClientRect:function(){var a=this.getRng();return a.collapsed?d.fromRangeStart(a).getClientRects()[0]:a.getBoundingClientRect()},destroy:function(){this.win=null,this.controlSelection.destroy()}},v}),g("w",[],function(){var a=/^[ \t\r\n]*$/,b={"#text":3,"#comment":8,"#cdata":4,"#pi":7,"#doctype":10,"#document-fragment":11},c=function(a,b,c){var d,e,f=c?"lastChild":"firstChild",g=c?"prev":"next";if(a[f])return a[f];if(a!==b){if(d=a[g])return d;for(e=a.parent;e&&e!==b;e=e.parent)if(d=e[g])return d}},d=function(a,b){this.name=a,this.type=b,1===b&&(this.attributes=[],this.attributes.map={})};return d.prototype={replace:function(a){var b=this;return a.parent&&a.remove(),b.insert(a,b),b.remove(),b},attr:function(a,b){var c,d,e,f=this;if("string"!=typeof a){for(d in a)f.attr(d,a[d]);return f}if(c=f.attributes){if(b!==e){if(null===b){if(a in c.map)for(delete c.map[a],d=c.length;d--;)if(c[d].name===a)return c=c.splice(d,1),f;return f}if(a in c.map){for(d=c.length;d--;)if(c[d].name===a){c[d].value=b;break}}else c.push({name:a,value:b});return c.map[a]=b,f}return c.map[a]}},clone:function(){var a,b,c,e,f,g=this,h=new d(g.name,g.type);
if(c=g.attributes){for(f=[],f.map={},a=0,b=c.length;a/g,"")},g=function(a,b,c){var d,e,f,g,h=1;for(g=a.getShortEndedElements(),f=/<([!?\/])?([A-Za-z0-9\-_\:\.]+)((?:\s+[^"\'>]+(?:(?:"[^"]*")|(?:\'[^\']*\')|[^>]*))*|\/|\s+)>/g,f.lastIndex=d=c;e=f.exec(b);){if(d=f.lastIndex,"/"===e[1])h--;else if(!e[1]){if(e[2]in g)continue;h++}if(0===h)break}return d},h=function(h,i){var j=this,k=function(){};h=h||{},j.schema=i=i||new a,h.fix_self_closing!==!1&&(h.fix_self_closing=!0),d("comment cdata text start end pi doctype".split(" "),function(a){a&&(j[a]=h[a]||k)}),j.parse=function(a){var d,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M=this,N=0,O=[],P=0,Q=b.decode,R=c.makeMap("src,href,data,background,formaction,poster"),S=/((java|vb)script|mhtml):/i,T=/^data:/i,U=function(a){var b,c;for(b=O.length;b--&&O[b].name!==a;);if(b>=0){for(c=O.length-1;c>=b;c--)a=O[c],a.valid&&M.end(a.name);O.length=b}},V=function(a,b,c,d,f){var g,i,j=/[\s\u0000-\u001F]+/g;if(b=b.toLowerCase(),c=b in s?b:Q(c||d||f||""),u&&!p&&e(b)===!1){if(g=z[b],!g&&A){for(i=A.length;i--&&(g=A[i],!g.pattern.test(b)););i===-1&&(g=null)}if(!g)return;if(g.validValues&&!(c in g.validValues))return}if(R[b]&&!h.allow_script_urls){var k=c.replace(j,"");try{k=decodeURIComponent(k)}catch(a){k=unescape(k)}if(S.test(k))return;if(!h.allow_html_data_urls&&T.test(k)&&!/^data:image\//i.test(k))return}p&&(b in R||0===b.indexOf("on"))||(l.map[b]=c,l.push({name:b,value:c}))};for(H=new RegExp("<(?:(?:!--([\\w\\W]*?)-->)|(?:!\\[CDATA\\[([\\w\\W]*?)\\]\\]>)|(?:!DOCTYPE([\\w\\W]*?)>)|(?:\\?([^\\s\\/<>]+) ?([\\w\\W]*?)[?/]>)|(?:\\/([A-Za-z][A-Za-z0-9\\-_\\:\\.]*)>)|(?:([A-Za-z][A-Za-z0-9\\-_\\:\\.]*)((?:\\s+[^\"'>]+(?:(?:\"[^\"]*\")|(?:'[^']*')|[^>]*))*|\\/|\\s+)>))","g"),I=/([\w:\-]+)(?:\s*=\s*(?:(?:\"((?:[^\"])*)\")|(?:\'((?:[^\'])*)\')|([^>\s]+)))?/g,r=i.getShortEndedElements(),G=h.self_closing_elements||i.getSelfClosingElements(),s=i.getBoolAttrs(),u=h.validate,q=h.remove_internals,L=h.fix_self_closing,J=i.getSpecialElements(),E=a+">";d=H.exec(E);){if(Na.length){M.text(Q(a.substr(d.index))),N=d.index+d[0].length;continue}if(j=j.toLowerCase(),":"===j.charAt(0)&&(j=j.substr(1)),t=j in r,L&&G[j]&&O.length>0&&O[O.length-1].name===j&&U(j),!u||(v=i.getElementRule(j))){if(w=!0,u&&(z=v.attributes,A=v.attributePatterns),(y=d[8])?(p=y.indexOf("data-mce-type")!==-1,p&&q&&(w=!1),l=[],l.map={},y.replace(I,V)):(l=[],l.map={}),u&&!p){if(B=v.attributesRequired,C=v.attributesDefault,D=v.attributesForced,F=v.removeEmptyAttrs,F&&!l.length&&(w=!1),D)for(m=D.length;m--;)x=D[m],o=x.name,K=x.value,"{$uid}"===K&&(K="mce_"+P++),l.map[o]=K,l.push({name:o,value:K});if(C)for(m=C.length;m--;)x=C[m],o=x.name,o in l.map||(K=x.value,"{$uid}"===K&&(K="mce_"+P++),l.map[o]=K,l.push({name:o,value:K}));if(B){for(m=B.length;m--&&!(B[m]in l.map););m===-1&&(w=!1)}if(x=l.map["data-mce-bogus"]){if("all"===x){N=g(i,a,H.lastIndex),H.lastIndex=N;continue}w=!1}}w&&M.start(j,l,t)}else w=!1;if(k=J[j]){k.lastIndex=N=d.index+d[0].length,(d=k.exec(a))?(w&&(n=a.substr(N,d.index-N)),N=d.index+d[0].length):(n=a.substr(N),N=a.length),w&&(n.length>0&&M.text(n,!0),M.end(j)),H.lastIndex=N;continue}t||(y&&y.indexOf("/")==y.length-1?w&&M.end(j):O.push({name:j,valid:w}))}else(j=d[1])?(">"===j.charAt(0)&&(j=" "+j),h.allow_conditional_comments||"[if"!==j.substr(0,3).toLowerCase()||(j=" "+j),M.comment(j)):(j=d[2])?M.cdata(f(j)):(j=d[3])?M.doctype(j):(j=d[4])&&M.pi(j,d[5]);N=d.index+d[0].length}for(N=0;m--)j=O[m],j.valid&&M.end(j.name)}};return h.findEndTag=g,h}),g("u",["w","y","x","1e"],function(a,b,c,d){var e=d.makeMap,f=d.each,g=d.explode,h=d.extend,i=function(b,c,d,e){var f=b.padd_empty_with_br||c.insert;f&&d[e.name]?e.empty().append(new a("br","1")).shortEnded=!0:e.empty().append(new a("#text","3")).value="\xa0"},j=function(a){return k(a,"#text")&&"\xa0"===a.firstChild.value},k=function(a,b){return a&&a.firstChild&&a.firstChild===a.lastChild&&a.firstChild.name===b},l=function(a,b){var c=a.getElementRule(b.name);return c&&c.paddEmpty},m=function(a,b,c,d){return d.isEmpty(b,c,function(b){return l(a,b)})};return function(l,n){var o=this,p={},q=[],r={},s={};l=l||{},l.validate=!("validate"in l)||l.validate,l.root_name=l.root_name||"body",o.schema=n=n||new b;var t=function(b){var c,d,f,g,h,i,j,l,p,q,r,s,t,u,v,w;for(s=e("tr,td,th,tbody,thead,tfoot,table"),q=n.getNonEmptyElements(),r=n.getWhiteSpaceElements(),t=n.getTextBlockElements(),u=n.getSpecialElements(),c=0;c1){for(g.reverse(),h=i=o.filterNode(g[0].clone()),p=0;p0)return void(b.value=d);if(c=b.next){if(3==c.type&&c.value.length){b=b.prev;continue}if(!f[c.name]&&"script"!=c.name&&"style"!=c.name){b=b.prev;continue}}e=b.prev,b.remove(),b=e}},P=function(a){var b,c={};for(b in a)"li"!==b&&"p"!=b&&(c[b]=a[b]);return c};if(f=new c({validate:A,allow_script_urls:l.allow_script_urls,allow_conditional_comments:l.allow_conditional_comments,self_closing_elements:P(n.getSelfClosingElements()),cdata:function(a){k.append(N("#cdata",4)).value=a},text:function(a,b){var c;D||(a=a.replace(F," "),k.lastChild&&B[k.lastChild.name]&&(a=a.replace(C,""))),0!==a.length&&(c=N("#text",3),c.raw=!!b,k.append(c).value=a)},comment:function(a){k.append(N("#comment",8)).value=a},pi:function(a,b){k.append(N(a,7)).value=b,O(k)},doctype:function(a){var b;b=k.append(N("#doctype",10)),b.value=a,O(k)},start:function(a,b,c){var d,e,f,g,h;if(f=A?n.getElementRule(a):{}){for(d=N(f.outputName||a,1),d.attributes=b,d.shortEnded=c,k.append(d),h=I[k.name],h&&I[d.name]&&!h[d.name]&&L.push(d),e=q.length;e--;)g=q[e].name,g in b.map&&(y=s[g],y?y.push(d):s[g]=[d]);B[a]&&O(d),c||(k=d),!D&&H[a]&&(D=!0)}},end:function(a){var b,c,e,f,g;if(c=A?n.getElementRule(a):{}){if(B[a]&&!D){if(b=k.firstChild,b&&3===b.type)if(e=b.value.replace(C,""),e.length>0)b.value=e,b=b.next;else for(f=b.next,b.remove(),b=f;b&&3===b.type;)e=b.value,f=b.next,(0===e.length||G.test(e))&&(b.remove(),b=f),b=f;if(b=k.lastChild,b&&3===b.type)if(e=b.value.replace(E,""),e.length>0)b.value=e,b=b.prev;else for(f=b.prev,b.remove(),b=f;b&&3===b.type;)e=b.value,f=b.prev,(0===e.length||G.test(e))&&(b.remove(),b=f),b=f}if(D&&H[a]&&(D=!1),c.removeEmpty&&m(n,J,H,k)&&!k.attributes.map.name&&!k.attributes.map.id)return g=k.parent,B[k.name]?k.empty().remove():k.unwrap(),void(k=g);c.paddEmpty&&(j(k)||m(n,J,H,k))&&i(l,d,B,k),k=k.parent}}},n),g=k=new a(d.context||l.root_name,11),f.parse(b),A&&L.length&&(d.context?d.invalid=!0:t(L)),K&&("body"==g.name||d.isRootContent)&&M(),!d.invalid){for(z in r){for(y=p[z],o=r[z],w=o.length;w--;)o[w].parent||o.splice(w,1);for(u=0,v=y.length;u0});return b.concat(["noopener"]).sort().join(" ")},f=function(a){var b=a?d.trim(a):"";return/\b(noopener)\b/g.test(b)?b:e(b)};if(!l.allow_unsafe_link_target)for(;c--;)b=a[c],"a"===b.name&&"_blank"===b.attr("target")&&b.attr("rel",f(b.attr("rel")))}),l.allow_html_in_named_anchor||o.addAttributeFilter("id,name",function(a){for(var b,c,d,e,f=a.length;f--;)if(e=a[f],"a"===e.name&&e.firstChild&&!e.attr("href")){d=e.parent,b=e.lastChild;do c=b.prev,d.insert(b,e),b=c;while(b)}}),l.fix_list_elements&&o.addNodeFilter("ul,ol",function(b){for(var c,d,e=b.length;e--;)if(c=b[e],d=c.parent,"ul"===d.name||"ol"===d.name)if(c.prev&&"li"===c.prev.name)c.prev.append(c);else{var f=new a("li",1);f.attr("style","list-style-type: none"),c.wrap(f)}}),l.validate&&n.getValidClasses()&&o.addAttributeFilter("class",function(a){for(var b,c,d,e,f,g,h,i=a.length,j=n.getValidClasses();i--;){for(b=a[i],c=b.attr("class").split(" "),f="",d=0;d]+data-mce-bogus[^>]+>[\u200b\ufeff]+<\\/span>","\\s?("+s.join("|")+')="[^"]+"'].join("|"),"gi");return a=i.trim(a.replace(b,""))},u=function(a){var b,c,d,e,g,h=a,i=/<(\w+) [^>]*data-mce-bogus="all"[^>]*>/g,j=o.schema;for(h=t(h),g=j.getShortEndedElements();e=i.exec(h);)c=i.lastIndex,d=e[0].length,b=g[e[1]]?c:f.findEndTag(j,h,c),h=h.substring(0,c-d)+h.substring(b),i.lastIndex=c-d;return h},v=function(){return u(o.getBody().innerHTML)},w=function(a){j.inArray(s,a)===-1&&(r.addAttributeFilter(a,function(a,b){for(var c=a.length;c--;)a[c].attr(b,null)}),s.push(a))};return p=p||m,q=q||new g(c),c.entity_encoding=c.entity_encoding||"named",c.remove_trailing_brs=!("remove_trailing_brs"in c)||c.remove_trailing_brs,r=new d(c,q),r.addAttributeFilter("data-mce-tabindex",function(a,b){for(var c,d=a.length;d--;)c=a[d],c.attr("tabindex",c.attributes.map["data-mce-tabindex"]),c.attr(b,null)}),r.addAttributeFilter("src,href,style",function(a,b){for(var d,e,f,g=a.length,h="data-mce-"+b,i=c.url_converter,j=c.url_converter_scope;g--;)d=a[g],e=d.attributes.map[h],e!==f?(d.attr(b,e.length>0?e:null),d.attr(h,null)):(e=d.attributes.map[b],"style"===b?e=p.serializeStyle(p.parseStyle(e),d.name):i&&(e=i.call(j,e,b,d.name)),d.attr(b,e.length>0?e:null))}),r.addAttributeFilter("class",function(a){for(var b,c,d=a.length;d--;)b=a[d],c=b.attr("class"),c&&(c=b.attr("class").replace(/(?:^|\s)mce-item-\w+(?!\S)/g,""),b.attr("class",c.length>0?c:null))}),r.addAttributeFilter("data-mce-type",function(a,b,c){for(var d,e=a.length;e--;)d=a[e],"bookmark"!==d.attributes.map["data-mce-type"]||c.cleanup||d.remove()}),r.addNodeFilter("noscript",function(a){for(var b,c=a.length;c--;)b=a[c].firstChild,b&&(b.value=e.decode(b.value))}),r.addNodeFilter("script,style",function(a,b){for(var d,e,f,g=a.length,h=function(a){return a.replace(/()/g,"\n").replace(/^[\r\n]*|[\r\n]*$/g,"").replace(/^\s*(()?|\s*\/\/\s*\]\]>(-->)?|\/\/\s*(-->)?|\]\]>|\/\*\s*-->\s*\*\/|\s*-->\s*)\s*$/g,"")};g--;)d=a[g],e=d.firstChild?d.firstChild.value:"","script"===b?(f=d.attr("type"),f&&d.attr("type","mce-no/type"==f?null:f.replace(/^mce\-/,"")),"xhtml"===c.element_format&&e.length>0&&(d.firstChild.value="// ")):"xhtml"===c.element_format&&e.length>0&&(d.firstChild.value="")}),r.addNodeFilter("#comment",function(a){for(var b,c=a.length;c--;)b=a[c],0===b.value.indexOf("[CDATA[")?(b.name="#cdata",b.type=4,b.value=b.value.replace(/^\[CDATA\[|\]\]$/g,"")):0===b.value.indexOf("mce:protected ")&&(b.name="#text",b.type=3,b.raw=!0,b.value=unescape(b.value).substr(14))}),r.addNodeFilter("xml:namespace,input",function(a,b){for(var c,d=a.length;d--;)c=a[d],7===c.type?c.remove():1===c.type&&("input"!==b||"type"in c.attributes.map||c.attr("type","text"))}),r.addAttributeFilter("data-mce-src,data-mce-href,data-mce-style,data-mce-selected,data-mce-expando,data-mce-type,data-mce-resize",function(a,b){for(var c=a.length;c--;)a[c].attr(b,null)}),{schema:q,addNodeFilter:r.addNodeFilter,addAttributeFilter:r.addAttributeFilter,serialize:function(d,e){var f,g,j,m,o,s,t=this;return b.ie&&p.select("script,style,select,map").length>0?(o=d.innerHTML,d=d.cloneNode(!1),p.setHTML(d,o)):d=d.cloneNode(!0),f=a.implementation,f.createHTMLDocument&&(g=f.createHTMLDocument(""),k("BODY"==d.nodeName?d.childNodes:[d],function(a){g.body.appendChild(g.importNode(a,!0))}),d="BODY"!=d.nodeName?g.body.firstChild:g.body,j=p.doc,p.doc=g),e=e||{},e.format=e.format||"html",e.selection&&(e.forced_root_block=""),e.no_events||(e.node=d,t.onPreProcess(e)),o=i.trim(l(e.getInner?d.innerHTML:p.getOuterHTML(d))),s=r.parse(o,e),n(s),m=new h(c,q),e.content=m.serialize(s),e.no_events||t.onPostProcess(e),j&&(p.doc=j),e.node=null,e.content},addRules:function(a){q.addValidElements(a)},setRules:function(a){q.setValidElements(a)},onPreProcess:function(a){o&&o.fire("PreProcess",a)},onPostProcess:function(a){o&&o.fire("PostProcess",a)},addTempAttr:w,trimHtml:t,getTrimmedContent:v,trimContent:u}}}),g("38",["3b"],function(a){return function(){var b=a.getOrDie("XMLHttpRequest");return new b}}),g("6i",["38","2","3p","1d","1e"],function(a,b,c,d,e){return function(c,f){var g={},h=function(a,b){return a?a.replace(/\/$/,"")+"/"+b.replace(/^\//,""):b},i=function(c,d,e,g){var i,j;i=new a,i.open("POST",f.url),i.withCredentials=f.credentials,i.upload.onprogress=function(a){g(a.loaded/a.total*100)},i.onerror=function(){e("Image upload failed due to a XHR Transport error. Code: "+i.status)},i.onload=function(){var a;return i.status<200||i.status>=300?void e("HTTP Error: "+i.status):(a=JSON.parse(i.responseText),a&&"string"==typeof a.location?void d(h(f.basePath,a.location)):void e("Invalid JSON: "+i.responseText))},j=new b.FormData,j.append("file",c.blob(),c.filename()),i.send(j)},j=function(){return new d(function(a){a([])})},k=function(a,b){return{url:b,blobInfo:a,status:!0}},l=function(a,b){return{url:"",blobInfo:a,status:!1,error:b}},m=function(a,b){e.each(g[a],function(a){a(b)}),delete g[a]},n=function(a,b,e){return c.markPending(a.blobUri()),new d(function(d){var f,g,h=function(){};try{var i=function(){f&&(f.close(),g=h)},j=function(b){i(),c.markUploaded(a.blobUri(),b),m(a.blobUri(),k(a,b)),d(k(a,b))},n=function(b){i(),c.removeFailed(a.blobUri()),m(a.blobUri(),l(a,b)),d(l(a,b))};g=function(a){a<0||a>100||(f||(f=e()),f.progressBar.value(a))},b(a,j,n,g)}catch(b){d(l(a,b.message))}})},o=function(a){return a===i},p=function(a){var b=a.blobUri();return new d(function(a){g[b]=g[b]||[],g[b].push(a)})},q=function(a,b){return a=e.grep(a,function(a){return!c.isUploaded(a.blobUri())}),d.all(e.map(a,function(a){return c.isPending(a.blobUri())?p(a):n(a,f.handler,b)}))},r=function(a,b){return!f.url&&o(f.handler)?j():q(a,b)};return f=e.extend({credentials:!1,handler:i},f),{upload:r}}}),g("74",["3b"],function(a){return function(b,c){var d=a.getOrDie("Blob");return new d(b,c)}}),g("75",["3b"],function(a){return function(){var b=a.getOrDie("FileReader");return new b}});g("76",["3b"],function(a){return function(b){var c=a.getOrDie("Uint8Array");return new c(b)}});g("77",["3b"],function(a){var b=function(b){var c=a.getOrDie("requestAnimationFrame");c(b)},c=function(b){var c=a.getOrDie("atob");return c(b)};return{atob:c,requestAnimationFrame:b}}),g("6w",["74","75","76","77","38","1d"],function(a,b,c,d,e,f){var g=function(a){return new f(function(b,c){var d=function(){c("Cannot convert "+a+" to Blob. Resource might not exist or is inaccessible.")};try{var f=new e;f.open("GET",a,!0),f.responseType="blob",f.onload=function(){200==this.status?b(this.response):d()},f.onerror=d,f.send()}catch(a){d()}})},h=function(a){var b,c;return a=decodeURIComponent(a).split(","),c=/data:([^;]+)/.exec(a[0]),c&&(b=c[1]),{type:b,data:a[1]}},i=function(b){return new f(function(e){var f,g,i;b=h(b);try{f=d.atob(b.data)}catch(b){return void e(new a([]))}for(g=new c(f.length),i=0;i=b.left&&a<=b.right};return b.reduce(a,function(a,b){var e,f;return e=Math.min(k(a,c),l(a,c)),f=Math.min(k(b,c),l(b,c)),d(c,b)?b:d(c,a)?a:f==e&&h(b.node)?b:f=a.top&&e<=a.bottom}),g=m(f,c),g&&(g=m(o(a,g),c),g&&h(g.node))?q(g,c):null};return{findClosestClientRect:m,findLineNodeRects:o,closestCaret:r}}),g("78",["3p","1r","73","3m","53","3q","2y","3n"],function(a,b,c,d,e,f,g,h){var i=a.curry,j=function(a,b,c,f){for(;f=e.findNode(f,a,d.isEditableCaretCandidate,b);)if(c(f))return},k=function(a,d,e,f,g,h){var i,k,l=0,m=[],n=function(f){var h,i,j;for(j=c.getClientRects(f),a==-1&&(j=j.reverse()),h=0;h0&&d(i,b.last(m))&&l++,i.line=l,g(i))return!0;m.push(i)}};return(k=b.last(h.getClientRects()))?(i=h.getNode(),n(i),j(a,f,n,i),m):m},l=function(a,b){return b.line>a},m=function(a,b){return b.line===a},n=i(k,-1,h.isAbove,h.isBelow),o=i(k,1,h.isBelow,h.isAbove),p=function(a,c,d,e){var i,j,k,l,m,n,o=new f(c),p=[],q=0,r=function(c){return 1==a?b.last(c.getClientRects()):b.last(c.getClientRects())};1==a?(i=o.next,j=h.isBelow,k=h.isAbove,l=g.after(e)):(i=o.prev,j=h.isAbove,k=h.isBelow,l=g.before(e)),n=r(l);do if(l.isVisible()&&(m=r(l),!k(m,n))){if(p.length>0&&j(m,b.last(p))&&q++,m=h.clone(m),m.position=l,m.line=q,d(m))return p;p.push(m)}while(l=i(l));return p};return{upUntil:n,downUntil:o,positionsUntil:p,isAboveLine:i(l),isLine:i(m)}}),g("6u",["2y","53","1y","3p"],function(a,b,c,d){var e=c.isContentEditableTrue,f=c.isContentEditableFalse,g=function(a,b,c,d){return b._selectionOverrides.showCaret(a,c,d)},h=function(a){var b=a.ownerDocument.createRange();return b.selectNode(a),b},i=function(a,b){var c;return c=a.fire("BeforeObjectSelected",{target:b}),c.isDefaultPrevented()?null:h(b)},j=function(c,h){var i,j;return h=b.normalizeRange(1,c.getBody(),h),i=a.fromRangeStart(h),f(i.getNode())?g(1,c,i.getNode(),!i.isAtEnd()):f(i.getNode(!0))?g(1,c,i.getNode(!0),!1):(j=c.dom.getParent(i.getNode(),d.or(f,e)),f(j)?g(1,c,j,!1):null)},k=function(a,b){var c;return b&&b.collapsed?(c=j(a,b),c?c:b):b};return{showCaret:g,selectNode:i,renderCaretAtRange:j,renderRangeCaret:k}}),g("6x",["b","2x","2y","53","3q","6s","78","1y","6u","2t","1r","3p"],function(a,b,c,d,e,f,g,h,i,j,k,l){var m=h.isContentEditableFalse,n=j.getSelectedNode,o=d.isAfterContentEditableFalse,p=d.isBeforeContentEditableFalse,q=function(a,b){for(;b=a(b);)if(b.isVisible())return b;return b},r=function(a,b){var c=d.isInSameBlock(a,b);return!(c||!h.isBr(a.getNode()))||c},s=function(a){return b.isCaretContainerBlock(a.startContainer)},t=function(a,b,e){return e=d.normalizeRange(a,b,e),a===-1?c.fromRangeStart(e):c.fromRangeEnd(e)},u=function(a,b,c,d,e){var f,g,h,j;return!e.collapsed&&(f=n(e),m(f))?i.showCaret(a,b,f,a===-1):(j=s(e),g=t(a,b.getBody(),e),d(g)?i.selectNode(b,g.getNode(a===-1)):(g=c(g))?d(g)?i.showCaret(a,b,g.getNode(a===-1),1===a):(h=c(g),d(h)&&r(g,h)?i.showCaret(a,b,h.getNode(a===-1),1===a):j?i.renderRangeCaret(b,g.toRange()):null):j?e:null)},v=function(a,b,c,d){var e,h,j,l,q,r,s,u,v;if(v=n(d),
e=t(a,b.getBody(),d),h=c(b.getBody(),g.isAboveLine(1),e),j=k.filter(h,g.isLine(1)),q=k.last(e.getClientRects()),p(e)&&(v=e.getNode()),o(e)&&(v=e.getNode(!0)),!q)return null;if(r=q.left,l=f.findClosestClientRect(j,r),l&&m(l.node))return s=Math.abs(r-l.left),u=Math.abs(r-l.right),i.showCaret(a,b,l.node,s=11)&&(c.innerHTML='
'),c},x=function(a,b,d){var f,g,h,i=new e(a.getBody()),j=l.curry(q,i.next),k=l.curry(q,i.prev);if(d.collapsed&&a.settings.forced_root_block){if(f=a.dom.getParent(d.startContainer,"PRE"),!f)return;g=1===b?j(c.fromRangeStart(d)):k(c.fromRangeStart(d)),g||(h=w(a),1===b?a.$(f).after(h):a.$(f).before(h),a.selection.select(h,!0),a.selection.collapse())}},y=function(a,b){var c,d=new e(a.getBody()),f=l.curry(q,d.next),g=l.curry(q,d.prev),h=b?1:-1,i=b?f:g,j=b?p:o,k=a.selection.getRng();return(c=u(h,a,i,j,k))?c:(c=x(a,h,k),c?c:null)},z=function(a,b){var c,d=b?1:-1,e=b?g.downUntil:g.upUntil,f=a.selection.getRng();return(c=v(d,a,e,f))?c:(c=x(a,d,f),c?c:null)},A=function(a,b){return function(){var c=y(a,b);return!!c&&(a.selection.setRng(c),!0)}},B=function(a,b){return function(){var c=z(a,b);return!!c&&(a.selection.setRng(c),!0)}};return{moveH:A,moveV:B}}),g("79",["27","4","5"],function(a,b,c){var d=function(a,b){return b},e=function(b,c){var d=a.isObject(b)&&a.isObject(c);return d?g(b,c):c},f=function(a){return function(){for(var d=new b(arguments.length),e=0;e'},m=function(a,b){return a.nodeName===b||a.previousSibling&&a.previousSibling.nodeName===b},n=function(a){return a&&/^(OL|UL|LI)$/.test(a.nodeName)},o=function(a){return n(a)&&n(a.parentNode)},p=function(a,b){return b&&a.isBlock(b)&&!/^(TD|TH|CAPTION|FORM)$/.test(b.nodeName)&&!/^(fixed|absolute)/i.test(b.style.position)&&"true"!==a.getContentEditable(b)},q=function(a,b,c){var d,e=c,f=[];if(e){for(;e=e.firstChild;){if(a.isBlock(e))return;1!=e.nodeType||b[e.nodeName.toLowerCase()]||f.push(e)}for(d=f.length;d--;)e=f[d],!e.hasChildNodes()||e.firstChild==e.lastChild&&""===e.firstChild.nodeValue?a.remove(e):h(e)&&a.remove(e)}},r=function(a,c,d){return b.isText(c)===!1?d:a?1===d&&c.data.charAt(d-1)===f.ZWSP?0:d:d===c.data.length-1&&c.data.charAt(d)===f.ZWSP?c.data.length:d},s=function(a){var b=a.cloneRange();return b.setStart(a.startContainer,r(!0,a.startContainer,a.startOffset)),b.setEnd(a.endContainer,r(!1,a.endContainer,a.endOffset)),b},t=function(a){for(;a;){if(1===a.nodeType||3===a.nodeType&&a.data&&/[\r\n\s]/.test(a.data))return a;a=a.nextSibling}},u=function(a,b){a.execCommand("InsertLineBreak",!1,b)},v=function(a){do 3===a.nodeType&&(a.nodeValue=a.nodeValue.replace(/^[\r\n]+/,"")),a=a.firstChild;while(a)},w=function(a,b){var c,d,e=a.getRoot();for(c=b;c!==e&&"false"!==a.getContentEditable(c);)"true"===a.getContentEditable(c)&&(d=c),c=c.parentNode;return c!==e?d:e},x=function(a,b){var c=a.settings.forced_root_block;c&&c.toLowerCase()===b.tagName.toLowerCase()&&a.dom.setAttribs(b,a.settings.forced_root_block_attrs)},y=function(a,b,c,d,e){var f,g,h,j,k,l,m=b||"P",n=a.dom,o=w(n,d);if(g=n.getParent(d,n.isBlock),!g||!p(n,g)){if(g=g||o,l=g==a.getBody()||i(g)?g.nodeName.toLowerCase():g.parentNode.nodeName.toLowerCase(),!g.hasChildNodes())return f=n.create(m),x(a,f),g.appendChild(f),c.setStart(f,0),c.setEnd(f,0),f;for(j=d;j.parentNode!=g;)j=j.parentNode;for(;j&&!n.isBlock(j);)h=j,j=j.previousSibling;if(h&&a.schema.isValidChild(l,m.toLowerCase())){for(f=n.create(m),x(a,f),h.parentNode.insertBefore(f,h),j=h;j&&!n.isBlock(j);)k=j.nextSibling,f.appendChild(j),j=k;c.setStart(d,e),c.setEnd(d,e)}}return d},z=function(a,b){var c;b.normalize(),c=b.lastChild,c&&!/^(left|right)$/gi.test(a.getStyle(c,"float",!0))||a.add(b,"br")},A=function(a){var b=a.parentNode;return/^(LI|DT|DD)$/.test(b.nodeName)?b:a},B=function(a,b,c){for(var d=a[c?"firstChild":"lastChild"];d&&1!=d.nodeType;)d=d[c?"nextSibling":"previousSibling"];return d===b},C=function(b,f){var g,h,i,n,C,D,E,F,G,H,I,J,K,L=b.dom,M=b.selection,N=b.settings,O=b.schema,P=O.getNonEmptyElements(),Q=b.selection.getRng(),R=function(a){var b,d,e,f,g=a,h=O.getMoveCaretBeforeOnEnterElements();if(a){if(/^(LI|DT|DD)$/.test(a.nodeName)){var i=t(a.firstChild);i&&/^(UL|OL|DL)$/.test(i.nodeName)&&a.insertBefore(L.doc.createTextNode("\xa0"),a.firstChild)}if(e=L.createRng(),a.normalize(),a.hasChildNodes()){for(b=new c(a,a);d=b.current();){if(3==d.nodeType){e.setStart(d,0),e.setEnd(d,0);break}if(h[d.nodeName.toLowerCase()]){e.setStartBefore(d),e.setEndBefore(d);break}g=d,d=b.next()}d||(e.setStart(g,0),e.setEnd(g,0))}else"BR"==a.nodeName?a.nextSibling&&L.isBlock(a.nextSibling)?(e.setStartBefore(a),e.setEndBefore(a)):(e.setStartAfter(a),e.setEndAfter(a)):(e.setStart(a,0),e.setEnd(a,0));M.setRng(e),L.remove(f),M.scrollIntoView(a)}},S=function(a){var c,e,f,g=i,j=O.getTextInlineElements();if(a||"TABLE"==H||"HR"==H?(c=L.create(a||J),x(b,c)):c=C.cloneNode(!1),f=c,N.keep_styles===!1)L.setAttrib(c,"style",null),L.setAttrib(c,"class",null);else do if(j[g.nodeName]){if(d.isCaretNode(g))continue;e=g.cloneNode(!1),L.setAttrib(e,"id",""),c.hasChildNodes()?(e.appendChild(c.firstChild),c.appendChild(e)):(f=e,c.appendChild(e))}while((g=g.parentNode)&&g!=h);return l(f),c},T=function(a){var b,d,e,f;if(f=r(a,i,n),3==i.nodeType&&(a?f>0:fi.childNodes.length-1,i=i.childNodes[Math.min(n,i.childNodes.length-1)]||i,n=K&&3==i.nodeType?i.nodeValue.length:0),h=w(L,i)){if(!L.isBlock(h)&&h!=L.getRoot())return void(J&&!D||u(b,f));if((J&&!D||!J&&D)&&(i=y(b,J,Q,i,n)),C=L.getParent(i,L.isBlock),G=C?L.getParent(C.parentNode,L.isBlock):null,H=C?C.nodeName.toUpperCase():"",I=G?G.nodeName.toUpperCase():"","LI"!=I||f.ctrlKey||(C=G,G=G.parentNode,H=I),/^(LI|DT|DD)$/.test(H)){if(!J&&D)return void u(b,f);if(L.isEmpty(C))return void U()}if("PRE"==H&&N.br_in_pre!==!1){if(!D)return void u(b,f)}else if(!J&&!D&&"LI"!=H||J&&D)return void u(b,f);J&&C===b.getBody()||(J=J||"P",a.isCaretContainerBlock(C)?(E=a.showCaretContainerBlock(C),L.isEmpty(C)&&l(C),R(E)):T()?V():T(!0)?(E=C.parentNode.insertBefore(S(),C),R(m(C,"HR")?E:C)):(g=s(Q).cloneRange(),g.setEndAfter(C),F=g.extractContents(),v(F),E=F.firstChild,L.insertAfter(F,C),q(L,P,E),z(L,C),L.isEmpty(C)&&l(C),E.normalize(),L.isEmpty(E)?(L.remove(E),V()):R(E)),L.setAttrib(E,"id",""),b.fire("NewBlock",{newBlock:E}))}};return{insert:C}}),g("6o",["70","1g"],function(a,b){var c=function(a){a.typing&&(a.typing=!1,a.add())},d=function(b,d){d.isDefaultPrevented()||(d.preventDefault(),c(b.undoManager),b.undoManager.transact(function(){b.selection.isCollapsed()===!1&&b.execCommand("Delete"),a.insert(b,d)}))},e=function(a){a.on("keydown",function(c){c.keyCode===b.ENTER&&d(a,c)})};return{setup:e}}),g("71",["1","2y","1y","42","43"],function(a,b,c,d,e){var f=function(a,b){return j(a)&&c.isText(b.container())},g=function(a,b){var c=b.container(),d=b.offset();c.insertData(d,"\xa0"),a.selection.setCursorLocation(c,d+1)},h=function(a,b,c){return!!f(c,b)&&(g(a,b),!0)},i=function(c){var f=a.curry(e.isInlineTarget,c),g=b.fromRangeStart(c.selection.getRng()),i=d.readLocation(f,c.getBody(),g);return i.map(a.curry(h,c,g)).getOr(!1)},j=function(b){return b.fold(a.constant(!1),a.constant(!0),a.constant(!0),a.constant(!1))},k=function(a){return!!a.selection.isCollapsed()&&i(a)};return{insertAtSelection:k}}),g("6p",["71","6y","1g"],function(a,b,c){var d=function(d,e){b.execute([{keyCode:c.SPACEBAR,action:b.action(a.insertAtSelection,d)}],e).each(function(a){e.preventDefault()})},e=function(a){a.on("keydown",function(b){b.isDefaultPrevented()===!1&&d(a,b)})};return{setup:e}}),g("6c",["6m","5i","6n","6o","6p"],function(a,b,c,d,e){var f=function(f){var g=b.setupSelectedState(f);a.setup(f,g),c.setup(f,g),d.setup(f),e.setup(f)};return{setup:f}}),g("6d",["b","2s","15"],function(a,b,c){return function(d){var e,f=[],g=function(a){var b,c;if(c=d.$(a).parentsUntil(d.getBody()).add(a),c.length===f.length){for(b=c.length;b>=0&&c[b]===f[b];b--);if(b===-1)return f=c,!0}return f=c,!1};"onselectionchange"in d.getDoc()||d.on("NodeChange Click MouseUp KeyUp Focus",function(a){var c,f;c=d.selection.getRng(),f={startContainer:c.startContainer,startOffset:c.startOffset,endContainer:c.endContainer,endOffset:c.endOffset},"nodechange"!=a.type&&b.isEq(f,e)||d.fire("SelectionChange"),e=f}),d.on("contextmenu",function(){d.fire("SelectionChange")}),d.on("SelectionChange",function(){var b=d.selection.getStart(!0);!b||!a.range&&d.selection.isCollapsed()||!g(b)&&d.dom.isChildOf(b,d.getBody())&&d.nodeChanged({selectionChange:!0})}),d.on("MouseUp",function(a){a.isDefaultPrevented()||("IMG"==d.selection.getNode().nodeName?c.setEditorTimeout(d,function(){d.nodeChanged()}):d.nodeChanged())}),this.nodeChanged=function(a){var b,c,e,f=d.selection;d.initialized&&f&&!d.settings.disable_nodechange&&!d.readonly&&(e=d.getBody(),b=f.getStart(!0)||e,b.ownerDocument==d.getDoc()&&d.dom.isChildOf(b,e)||(b=e),c=[],d.dom.getParent(b,function(a){return a===e||void c.push(a)}),a=a||{},a.element=b,a.parents=c,d.fire("NodeChange",a))}}}),g("72",[],function(){var a=function(a){var b,c,d,e;return e=a.getBoundingClientRect(),b=a.ownerDocument,c=b.documentElement,d=b.defaultView,{top:e.top+d.pageYOffset-c.clientTop,left:e.left+d.pageXOffset-c.clientLeft}},b=function(b){return b.inline?a(b.getBody()):{left:0,top:0}},c=function(a){var b=a.getBody();return a.inline?{left:b.scrollLeft,top:b.scrollTop}:{left:0,top:0}},d=function(a){var b=a.getBody(),c=a.getDoc().documentElement,d={left:b.scrollLeft,top:b.scrollTop},e={left:b.scrollLeft||c.scrollLeft,top:b.scrollTop||c.scrollTop};return a.inline?d:e},e=function(b,c){if(c.target.ownerDocument!==b.getDoc()){var e=a(b.getContentAreaContainer()),f=d(b);return{left:c.pageX-e.left+f.left,top:c.pageY-e.top+f.top}}return{left:c.pageX,top:c.pageY}},f=function(a,b,c){return{pageX:c.left-a.left+b.left,pageY:c.top-a.top+b.top}},g=function(a,d){return f(b(a),c(a),e(a,d))};return{calc:g}}),g("6q",["1j","l","72","1y","1r","15","3p"],function(a,b,c,d,e,f,g){var h=d.isContentEditableFalse,i=d.isContentEditableTrue,j=function(a,b){return h(b)&&b!==a},k=function(a,b,c){return b!==c&&!a.dom.isChildOf(b,c)&&!h(b)},l=function(a){var b=a.cloneNode(!0);return b.removeAttribute("data-mce-selected"),b},m=function(a,b,c,d){var e=b.cloneNode(!0);a.dom.setStyles(e,{width:c,height:d}),a.dom.setAttrib(e,"data-mce-selected",null);var f=a.dom.create("div",{"class":"mce-drag-container","data-mce-bogus":"all",unselectable:"on",contenteditable:"false"});return a.dom.setStyles(f,{position:"absolute",opacity:.5,overflow:"hidden",border:0,padding:0,margin:0,width:c,height:d}),a.dom.setStyles(e,{margin:0,boxSizing:"border-box"}),f.appendChild(e),f},n=function(a,b){a.parentNode!==b&&b.appendChild(a)},o=function(a,b,c,d,e,f){var g=0,h=0;a.style.left=b.pageX+"px",a.style.top=b.pageY+"px",b.pageX+c>e&&(g=b.pageX+c-e),b.pageY+d>f&&(h=b.pageY+d-f),a.style.width=c-g+"px",a.style.height=d-h+"px"},p=function(a){a&&a.parentNode&&a.parentNode.removeChild(a)},q=function(a){return 0===a.button},r=function(a){return a.element},s=function(a,b){return{pageX:b.pageX-a.relX,pageY:b.pageY+5}},t=function(a,b){return function(c){if(q(c)){var d=e.find(b.dom.getParents(c.target),g.or(h,i));if(j(b.getBody(),d)){var f=b.dom.getPos(d),k=b.getBody(),l=b.getDoc().documentElement;a.element=d,a.screenX=c.screenX,a.screenY=c.screenY,a.maxX=(b.inline?k.scrollWidth:l.offsetWidth)-2,a.maxY=(b.inline?k.scrollHeight:l.offsetHeight)-2,a.relX=c.pageX-f.x,a.relY=c.pageY-f.y,a.width=d.offsetWidth,a.height=d.offsetHeight,a.ghost=m(b,d,a.width,a.height)}}}},u=function(a,b){var d=f.throttle(function(a,c){b._selectionOverrides.hideFakeCaret(),b.selection.placeCaretAt(a,c)},0);return function(e){var f=Math.max(Math.abs(e.screenX-a.screenX),Math.abs(e.screenY-a.screenY));if(r(a)&&!a.dragging&&f>10){var g=b.fire("dragstart",{target:a.element});if(g.isDefaultPrevented())return;a.dragging=!0,b.focus()}if(a.dragging){var h=s(a,c.calc(b,e));n(a.ghost,b.getBody()),o(a.ghost,h,a.width,a.height,a.maxX,a.maxY),d(e.clientX,e.clientY)}}},v=function(a){var b=a.getSel().getRangeAt(0),c=b.startContainer;return 3===c.nodeType?c.parentNode:c},w=function(a,b){return function(c){if(a.dragging&&k(b,v(b.selection),a.element)){var d=l(a.element),e=b.fire("drop",{targetClone:d,clientX:c.clientX,clientY:c.clientY});e.isDefaultPrevented()||(d=e.targetClone,b.undoManager.transact(function(){p(a.element),b.insertContent(b.dom.getOuterHTML(d)),b._selectionOverrides.hideFakeCaret()}))}y(a)}},x=function(a,b){return function(){y(a),a.dragging&&b.fire("dragend")}},y=function(a){a.dragging=!1,a.element=null,p(a.ghost)},z=function(c){var d,e,f,g,h,i,j={};d=b.DOM,i=a,e=t(j,c),f=u(j,c),g=w(j,c),h=x(j,c),c.on("mousedown",e),c.on("mousemove",f),c.on("mouseup",g),d.bind(i,"mousemove",f),d.bind(i,"mouseup",h),c.on("remove",function(){d.unbind(i,"mousemove",f),d.unbind(i,"mouseup",h)})},A=function(a){a.on("drop",function(b){var c="undefined"!=typeof b.clientX?a.getDoc().elementFromPoint(b.clientX,b.clientY):null;(h(c)||h(a.dom.getContentEditableParent(c)))&&b.preventDefault()})},B=function(a){z(a),A(a)};return{init:B}}),g("6r",["1n","2x","67","m","1y","3n","15"],function(a,b,c,d,e,f,g){var h=e.isContentEditableFalse,i=function(a){return a&&/^(TD|TH)$/i.test(a.nodeName)};return function(e,j){var k,l,m=null,n=function(a,b){var c,d,g,h,i,j=f.collapse(a.getBoundingClientRect(),b);return"BODY"==e.tagName?(c=e.ownerDocument.documentElement,d=e.scrollLeft||c.scrollLeft,g=e.scrollTop||c.scrollTop):(i=e.getBoundingClientRect(),d=e.scrollLeft-i.left,g=e.scrollTop-i.top),j.left+=d,j.right+=d,j.top+=g,j.bottom+=g,j.width=1,h=a.offsetWidth-a.clientWidth,h>0&&(b&&(h*=-1),j.left+=h,j.right+=h),j},o=function(){var a,c,f,g,h;for(a=d("*[contentEditable=false]",e),g=0;g').css(f).appendTo(e),a&&m.addClass("mce-visual-caret-before"),s(),g=c.ownerDocument.createRange(),g.setStart(l,0),g.setEnd(l,0),g):(l=b.insertInline(c,a),g=c.ownerDocument.createRange(),h(l.nextSibling)?(g.setStart(l,0),g.setEnd(l,0)):(g.setStart(l,1),g.setEnd(l,1)),g)},q=function(){o(),l&&(c.remove(l),l=null),m&&(m.remove(),m=null),a(k)},r=function(){return e.ownerDocument.activeElement===e},s=function(){k=g.setInterval(function(){r()?d("div.mce-visual-caret",e).toggleClass("mce-visual-caret-hidden"):d("div.mce-visual-caret",e).addClass("mce-visual-caret-hidden")},500)},t=function(){g.clearInterval(k)},u=function(){return".mce-visual-caret {position: absolute;background-color: black;background-color: currentcolor;}.mce-visual-caret-hidden {display: none;}*[data-mce-caret] {position: absolute;left: -1000px;right: auto;top: 0;margin: 0;padding: 0;}"};return{show:p,hide:q,getCss:u,destroy:t}}}),g("5r",["1o","1q"],function(a,b){var c=function(c,d){var e=null,f=null,g=function(){null!==e&&(a(e),e=null,f=null)},h=function(){f=arguments,null===e&&(e=b(function(){c.apply(null,f),e=null,f=null},d))};return{cancel:g,throttle:h}},d=function(c,d){var e=null,f=function(){null!==e&&(a(e),e=null)},g=function(){var a=arguments;null===e&&(e=b(function(){c.apply(null,a),e=null,a=null},d))};return{cancel:f,throttle:g}},e=function(c,d){var e=null,f=function(){null!==e&&(a(e),e=null)},g=function(){var f=arguments;null!==e&&a(e),e=b(function(){c.apply(null,f),e=null,f=null},d)};return{cancel:f,throttle:g}};return{adaptable:c,first:d,last:e}}),g("6t",["5r","6u"],function(a,b){var c=function(c){var d=a.first(function(){if(!c.removed){var a=b.renderRangeCaret(c,c.selection.getRng());c.selection.setRng(a)}},0);c.on("focus",function(){d.throttle()}),c.on("blur",function(){d.cancel()})};return{setup:c}}),g("6e",["1i","45","1v","46","56","47","6q","2n","b","2x","2y","53","3q","6r","6s","3k","1y","31","6t","6u","1g"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u){var v=q.isContentEditableTrue,w=q.isContentEditableFalse,x=l.isAfterContentEditableFalse,y=l.isBeforeContentEditableFalse,z=function(q){var z,A=function(a){return q.dom.isBlock(a)},B=q.getBody(),C=new n(q.getBody(),A),D="sel-"+q.dom.uniqueId(),E=function(a){return q.dom.hasClass(a,"mce-offscreen-selection")},F=function(){var a=q.dom.get(D);return a?a.getElementsByTagName("*")[0]:a},G=function(a){a&&q.selection.setRng(a)},H=function(){return q.selection.getRng()},I=function(a,b){q.selection.scrollIntoView(a,b)},J=function(a,b,c){var d;return d=q.fire("ShowCaret",{target:b,direction:a,before:c}),d.isDefaultPrevented()?null:(I(b,a===-1),C.show(c,b))},K=function(a,b){return b=l.normalizeRange(a,B,b),a==-1?k.fromRangeStart(b):k.fromRangeEnd(b)},L=function(a){a.hasAttribute("data-mce-caret")&&(j.showCaretContainerBlock(a),G(H()),I(a[0]))},M=function(){var a=function(a){for(var b=q.getBody();a&&a!=b;){if(v(a)||w(a))return a;a=a.parentNode}return null};q.on("mouseup",function(a){var b=H();b.collapsed&&h.isXYInContentArea(q,a.clientX,a.clientY)&&G(t.renderCaretAtRange(q,b))}),q.on("click",function(b){var c;c=a(b.target),c&&(w(c)&&(b.preventDefault(),q.focus()),v(c)&&q.dom.isChildOf(c,q.selection.getNode())&&R())}),q.on("blur NewBlock",function(){R()});var b=function(b){var c=!1;b.on("touchstart",function(){c=!1}),b.on("touchmove",function(){c=!0}),b.on("touchend",function(d){var e=a(d.target);w(e)&&(c||(d.preventDefault(),Q(t.selectNode(b,e))))})},d=function(a){var b=new m(a);if(!a.firstChild)return!1;var c=k.before(a.firstChild),d=b.next(c);return d&&!y(d)&&!x(d)},e=function(a,b){var c=q.dom.getParent(a,q.dom.isBlock),d=q.dom.getParent(b,q.dom.isBlock);return c===d},f=function(a,b){var c=q.dom.getParent(a,q.dom.isBlock),f=q.dom.getParent(b,q.dom.isBlock);return c&&!e(c,f)&&d(c)};b(q),q.on("mousedown",function(b){var d;if(h.isXYInContentArea(q,b.clientX,b.clientY)!==!1)if(d=a(b.target))w(d)?(b.preventDefault(),Q(t.selectNode(q,d))):(R(),v(d)&&b.shiftKey||r.isXYWithinRange(b.clientX,b.clientY,q.selection.getRng())||(p.isVoid(c.fromDom(b.target))?q.selection.select(b.target):q.selection.placeCaretAt(b.clientX,b.clientY)));else{R(),T();var e=o.closestCaret(B,b.clientX,b.clientY);e&&(f(b.target,e.node)||(b.preventDefault(),q.getBody().focus(),G(J(1,e.node,e.before))))}}),q.on("keypress",function(a){if(!u.modifierPressed(a))switch(a.keyCode){default:w(q.selection.getNode())&&a.preventDefault()}}),q.on("getSelectionRange",function(a){var b=a.range;if(z){if(!z.parentNode)return void(z=null);b=b.cloneRange(),b.selectNode(z),a.range=b}}),q.on("setSelectionRange",function(a){var b;b=Q(a.range,a.forward),b&&(a.range=b)}),q.on("AfterSetSelectionRange",function(a){var b=a.range;P(b)||T(),E(b.startContainer.parentNode)||R()}),q.on("copy",function(a){var b=a.clipboardData;if(!a.isDefaultPrevented()&&a.clipboardData&&!i.ie){var c=F();c&&(a.preventDefault(),b.clearData(),b.setData("text/html",c.outerHTML),b.setData("text/plain",c.outerText))}}),g.init(q),s.setup(q)},N=function(){var a=q.contentStyles,b=".mce-content-body";a.push(C.getCss()),a.push(b+" .mce-offscreen-selection {position: absolute;left: -9999999999px;max-width: 1000000px;}"+b+" *[contentEditable=false] {cursor: default;}"+b+" *[contentEditable=true] {cursor: text;}")},O=function(a){return j.isCaretContainer(a)||j.startsWithCaretContainer(a)||j.endsWithCaretContainer(a)},P=function(a){return O(a.startContainer)||O(a.endContainer)},Q=function(b,g){var h,j,k,l,m,n,o,p,r,s,t=q.$,u=q.dom;if(!b)return null;if(b.collapsed){if(!P(b))if(g===!1){if(p=K(-1,b),w(p.getNode(!0)))return J(-1,p.getNode(!0),!1);if(w(p.getNode()))return J(-1,p.getNode(),!p.isAtEnd())}else{if(p=K(1,b),w(p.getNode()))return J(1,p.getNode(),!p.isAtEnd());if(w(p.getNode(!0)))return J(1,p.getNode(!0),!1)}return null}return l=b.startContainer,m=b.startOffset,n=b.endOffset,3==l.nodeType&&0==m&&w(l.parentNode)&&(l=l.parentNode,m=u.nodeIndex(l),l=l.parentNode),1!=l.nodeType?null:(n==m+1&&(h=l.childNodes[m]),w(h)?(r=s=h.cloneNode(!0),o=q.fire("ObjectSelected",{target:h,targetClone:r}),o.isDefaultPrevented()?null:(j=f.descendant(c.fromDom(q.getBody()),"#"+D).fold(function(){return t([])},function(a){return t([a.dom()])}),r=o.targetClone,0===j.length&&(j=t('
').attr("id",D),j.appendTo(q.getBody())),b=q.dom.createRng(),r===s&&i.ie?(j.empty().append('
\xa0
').append(r),b.setStartAfter(j[0].firstChild.firstChild),b.setEndAfter(r)):(j.empty().append("\xa0").append(r).append("\xa0"),b.setStart(j[0].firstChild,1),b.setEnd(j[0].lastChild,0)),j.css({top:u.getPos(h,q.getBody()).y}),j[0].focus(),k=q.selection.getSel(),k.removeAllRanges(),k.addRange(b),a.each(e.descendants(c.fromDom(q.getBody()),"*[data-mce-selected]"),function(a){d.remove(a,"data-mce-selected")}),h.setAttribute("data-mce-selected",1),z=h,T(),b)):null)},R=function(){z&&(z.removeAttribute("data-mce-selected"),f.descendant(c.fromDom(q.getBody()),"#"+D).each(b.remove),z=null)},S=function(){C.destroy(),z=null},T=function(){C.hide()};return i.ceFalse&&(M(),N()),{showCaret:J,showBlockCaretContainer:L,hideFakeCaret:T,destroy:S}};return z}),g("5s",[],function(){var a=0,b=1,c=2,d=function(d,e){var f=d.length+e.length+2,g=new Array(f),h=new Array(f),i=function(a,b,c){return{start:a,end:b,diag:c}},j=function(f,g,h,i,k){var m=l(f,g,h,i);if(null===m||m.start===g&&m.diag===g-i||m.end===f&&m.diag===f-h)for(var n=f,o=h;n
i-h?(k.push([c,d[n]]),++n):(k.push([b,e[o]]),++o);else{j(f,m.start,h,m.start-m.diag,k);for(var p=m.start;p=a&&s>=c&&d[r]===e[s];)h[q]=r--,s--;if(l%2===0&&-o<=p&&p<=o&&h[q]<=g[q+l])return k(h[q],p+a-c,b,f)}}},m=[];return j(0,d.length,0,e.length,m),m};return{KEEP:a,DELETE:c,INSERT:b,diff:d}}),g("4l",["1j","v","5s","1r"],function(a,b,c,d){var e=function(a){return 1===a.nodeType?a.outerHTML:3===a.nodeType?b.encodeRaw(a.data,!1):8===a.nodeType?"":""},f=function(b){var c,d,e;for(e=a.createElement("div"),c=a.createDocumentFragment(),b&&(e.innerHTML=b);d=e.firstChild;)c.appendChild(d);return c},g=function(a,b,c){var d=f(b);if(a.hasChildNodes()&&c0})},k=function(a,b){var f=d.map(b.childNodes,e);return i(c.diff(f,a),b),b};return{read:j,write:k}}),g("2b",["1i","4l"],function(a,b){var c=function(a){return a.indexOf("")!==-1},d=function(a){return{type:"fragmented",fragments:a,content:"",bookmark:null,beforeBookmark:null}},e=function(a){return{type:"complete",fragments:null,content:a,bookmark:null,beforeBookmark:null}},f=function(f){var g,h,i;return g=b.read(f.getBody()),i=a.bind(g,function(a){var b=f.serializer.trimContent(a);return b.length>0?[b]:[]}),h=i.join(""),c(h)?d(i):e(h)},g=function(a,c,d){"fragmented"===c.type?b.write(c.fragments,a.getBody()):a.setContent(c.content,{format:"raw"}),a.selection.moveToBookmark(d?c.beforeBookmark:c.bookmark)},h=function(a){return"fragmented"===a.type?a.fragments.join(""):a.content},i=function(a,b){return!!a&&!!b&&h(a)===h(b)};return{createFragmentedLevel:d,createCompleteLevel:e,createFromEditor:f,applyToEditor:g,isEq:i}}),g("d",["1g","1e","2b"],function(a,b,c){return function(a){var d,e,f=this,g=0,h=[],i=0,j=function(){return 0===i},k=function(a){j()&&(f.typing=a)},l=function(b){a.setDirty(b)},m=function(a){k(!1),f.add({},a)},n=function(){f.typing&&(k(!1),f.add())};return a.on("init",function(){f.add()}),a.on("BeforeExecCommand",function(a){var b=a.command;"Undo"!==b&&"Redo"!==b&&"mceRepaint"!==b&&(n(),f.beforeChange())}),a.on("ExecCommand",function(a){var b=a.command;"Undo"!==b&&"Redo"!==b&&"mceRepaint"!==b&&m(a)}),a.on("ObjectResizeStart Cut",function(){f.beforeChange()}),a.on("SaveContent ObjectResized blur",m),a.on("DragEnd",m),a.on("KeyUp",function(b){var d=b.keyCode;b.isDefaultPrevented()||((d>=33&&d<=36||d>=37&&d<=40||45===d||b.ctrlKey)&&(m(),a.nodeChanged()),46!==d&&8!==d||a.nodeChanged(),e&&f.typing&&c.isEq(c.createFromEditor(a),h[0])===!1&&(a.isDirty()===!1&&(l(!0),a.fire("change",{level:h[0],lastLevel:null})),a.fire("TypingUndo"),e=!1,a.nodeChanged()))}),a.on("KeyDown",function(a){var b=a.keyCode;if(!a.isDefaultPrevented()){if(b>=33&&b<=36||b>=37&&b<=40||45===b)return void(f.typing&&m(a));var c=a.ctrlKey&&!a.altKey||a.metaKey;!(b<16||b>20)||224===b||91===b||f.typing||c||(f.beforeChange(),k(!0),f.add({},a),e=!0)}}),a.on("MouseDown",function(a){f.typing&&m(a)}),a.addShortcut("meta+z","","Undo"),a.addShortcut("meta+y,meta+shift+z","","Redo"),a.on("AddUndo Undo Redo ClearUndos",function(b){b.isDefaultPrevented()||a.nodeChanged()}),f={data:h,typing:!1,beforeChange:function(){j()&&(d=a.selection.getBookmark(2,!0))},add:function(e,f){var i,k,m,n=a.settings;if(m=c.createFromEditor(a),e=e||{},e=b.extend(e,m),j()===!1||a.removed)return null;if(k=h[g],a.fire("BeforeAddUndo",{level:e,lastLevel:k,originalEvent:f}).isDefaultPrevented())return null;if(k&&c.isEq(k,e))return null;if(h[g]&&(h[g].beforeBookmark=d),n.custom_undo_redo_levels&&h.length>n.custom_undo_redo_levels){for(i=0;i0&&(l(!0),a.fire("change",o)),e},undo:function(){var b;return f.typing&&(f.add(),f.typing=!1,k(!1)),g>0&&(b=h[--g],c.applyToEditor(a,b,!0),l(!0),a.fire("undo",{level:b})),b},redo:function(){var b;return g0||f.typing&&h[0]&&!c.isEq(c.createFromEditor(a),h[0])},hasRedo:function(){return g0&&(c=t+escape(i.id)+","+escape(b),a.dataTransfer.setData(u,c)))},y=function(a){var b;return a.dataTransfer&&(b=a.dataTransfer.getData(u),b&&b.indexOf(t)>=0)?(b=b.substr(t.length).split(","),{id:unescape(b[0]),html:unescape(b[1])}):null},z=function(a,b){i.queryCommandSupported("mceInsertClipboardContent")?i.execCommand("mceInsertClipboardContent",!1,{content:a,internal:b}):i.execCommand("mceInsertContent",!1,a)},A=function(){var a=function(a){var b=m.create("body"),c=a.cloneContents();return b.appendChild(c),n.serializer.serialize(b,{format:"html"})},b=function(b){var c=a(b),d=m.createRng();d.selectNode(i.getBody());var e=a(d);return c===e};i.on("keydown",function(a){var c,d,e=a.keyCode;if(!w(a)&&(e==l||e==k)){if(c=i.selection.isCollapsed(),d=i.getBody(),c&&!m.isEmpty(d))return;if(!c&&!b(i.selection.getRng()))return;a.preventDefault(),i.setContent(""),d.firstChild&&m.isBlock(d.firstChild)?i.selection.setCursorLocation(d.firstChild,0):i.selection.setCursorLocation(d,0),i.nodeChanged()}})},B=function(){i.shortcuts.add("meta+a",null,"SelectAll")},C=function(){i.settings.content_editable||m.bind(i.getDoc(),"mousedown mouseup",function(a){var b;if(a.target==i.getDoc().documentElement)if(b=n.getRng(),i.getBody().focus(),"mousedown"==a.type){if(d.isCaretContainer(b.startContainer))return;n.placeCaretAt(a.clientX,a.clientY)}else n.setRng(b)})},D=function(){i.on("keydown",function(a){if(!w(a)&&a.keyCode===k){if(!i.getBody().getElementsByTagName("hr").length)return;if(n.isCollapsed()&&0===n.getRng(!0).startOffset){var b=n.getNode(),c=b.previousSibling;if("HR"==b.nodeName)return m.remove(b),void a.preventDefault();c&&c.nodeName&&"hr"===c.nodeName.toLowerCase()&&(m.remove(c),a.preventDefault())}}})},E=function(){b.Range.prototype.getClientRects||i.on("mousedown",function(a){if(!w(a)&&"HTML"===a.target.nodeName){var b=i.getBody();b.blur(),f.setEditorTimeout(i,function(){b.focus()})}})},F=function(){i.on("click",function(a){var b=a.target;/^(IMG|HR)$/.test(b.nodeName)&&"false"!==m.getContentEditableParent(b)&&(a.preventDefault(),i.selection.select(b),i.nodeChanged()),"A"==b.nodeName&&m.hasClass(b,"mce-item-anchor")&&(a.preventDefault(),n.select(b))})},G=function(){var a=function(){var a=m.getAttribs(n.getStart().cloneNode(!1));return function(){var b=n.getStart();b!==i.getBody()&&(m.setAttrib(b,"style",null),j(a,function(a){b.setAttributeNode(a.cloneNode(!0))}))}},b=function(){return!n.isCollapsed()&&m.getParent(n.getStart(),m.isBlock)!=m.getParent(n.getEnd(),m.isBlock)};i.on("keypress",function(c){var d;if(!w(c)&&(8==c.keyCode||46==c.keyCode)&&b())return d=a(),i.getDoc().execCommand("delete",!1,null),d(),c.preventDefault(),!1}),m.bind(i.getDoc(),"cut",function(c){var d;!w(c)&&b()&&(d=a(),f.setEditorTimeout(i,function(){d()}))})},H=function(){i.on("keydown",function(a){if(!w(a)&&a.keyCode===k&&n.isCollapsed()&&0===n.getRng(!0).startOffset){var b=n.getNode().previousSibling;if(b&&b.nodeName&&"table"===b.nodeName.toLowerCase())return a.preventDefault(),!1}})},I=function(){i.on("keydown",function(a){var b,c,d,e,f;if(!w(a)&&a.keyCode==h.BACKSPACE&&(b=n.getRng(),c=b.startContainer,d=b.startOffset,e=m.getRoot(),f=c,b.collapsed&&0===d)){for(;f&&f.parentNode&&f.parentNode.firstChild==f&&f.parentNode!=e;)f=f.parentNode;"BLOCKQUOTE"===f.tagName&&(i.formatter.toggle("blockquote",null,f),b=m.createRng(),b.setStart(c,0),b.setEnd(c,0),n.setRng(b))}})},J=function(){var a=function(){W(),v("StyleWithCSS",!1),v("enableInlineTableEditing",!1),o.object_resizing||v("enableObjectResizing",!1)};o.readonly||i.on("BeforeExecCommand MouseDown",a)},K=function(){var a=function(){j(m.select("a"),function(a){var b=a.parentNode,c=m.getRoot();if(b.lastChild===a){for(;b&&!m.isBlock(b);){if(b.parentNode.lastChild!==b||b===c)return;b=b.parentNode}m.add(b,"br",{"data-mce-bogus":1})}})};i.on("SetContent ExecCommand",function(b){"setcontent"!=b.type&&"mceInsertLink"!==b.command||a()})},L=function(){o.forced_root_block&&i.on("init",function(){v("DefaultParagraphSeparator",o.forced_root_block)})},M=function(){i.on("keyup focusin mouseup",function(a){h.modifierPressed(a)||n.normalize()},!0)},N=function(){i.contentStyles.push("img:-moz-broken {-moz-force-broken-image-icon:1;min-width:24px;min-height:24px}")},O=function(){i.inline||i.on("keydown",function(){a.activeElement==a.body&&i.getWin().focus()})},P=function(){i.inline||(i.contentStyles.push("body {min-height: 150px}"),i.on("click",function(a){var b;if("HTML"==a.target.nodeName){if(c.ie>11)return void i.getBody().focus();b=i.selection.getRng(),i.getBody().focus(),i.selection.setRng(b),i.selection.normalize(),i.nodeChanged()}}))},Q=function(){c.mac&&i.on("keydown",function(a){!h.metaKeyPressed(a)||a.shiftKey||37!=a.keyCode&&39!=a.keyCode||(a.preventDefault(),i.selection.getSel().modify("move",37==a.keyCode?"backward":"forward","lineboundary"))})},R=function(){v("AutoUrlDetect",!1)},S=function(){i.on("click",function(a){var b=a.target;do if("A"===b.tagName)return void a.preventDefault();while(b=b.parentNode)}),i.contentStyles.push(".mce-content-body {-webkit-touch-callout: none}")},T=function(){i.on("init",function(){i.dom.bind(i.getBody(),"submit",function(a){a.preventDefault()})})},U=function(){p.addNodeFilter("br",function(a){for(var b=a.length;b--;)"Apple-interchange-newline"==a[b].attr("class")&&a[b].remove()})},V=function(){i.on("dragstart",function(a){x(a)}),i.on("drop",function(a){if(!w(a)){var b=y(a);if(b&&b.id!=i.id){a.preventDefault();var c=e.fromPoint(a.x,a.y,i.getDoc());n.setRng(c),z(b.html,!0)}}})},W=function(){},X=function(){var a;return!q||i.removed?0:(a=i.selection.getSel(),!a||!a.rangeCount||0===a.rangeCount)};return I(),A(),c.windowsPhone||M(),s&&(C(),F(),L(),T(),H(),U(),c.iOS?(O(),P(),S()):B()),c.ie>=11&&(P(),H()),c.ie&&(B(),R(),V()),q&&(D(),E(),G(),J(),K(),N(),Q(),H()),{refreshContentEditable:W,isHidden:X}}}),g("5p",["40","1v","46","1j","2","f","69","l","p","q","6a","28","6b","u","w","y","6c","6d","6e","d","15","6f","1e"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w){var x=h.DOM,y=function(d,e){var f=b.fromDom(d.getDoc().head),g=b.fromTag("style");c.set(g,"type","text/css"),a.append(g,b.fromText(e)),a.append(f,g)},z=function(a){var b=new n(a.settings,a.schema);return b.addAttributeFilter("src,href,style,tabindex",function(b,c){for(var d,e,f,g=b.length,h=a.dom;g--;)if(d=b[g],e=d.attr(c),f="data-mce-"+c,!d.attributes.map[f]){if(0===e.indexOf("data:")||0===e.indexOf("blob:"))continue;"style"===c?(e=h.serializeStyle(h.parseStyle(e),d.name),e.length||(e=null),d.attr(f,e),d.attr(c,e)):"tabindex"===c?(d.attr(f,e),d.attr(c,null)):d.attr(f,a.convertURL(e,c,d.name))}}),b.addNodeFilter("script",function(a){for(var b,c,d=a.length;d--;)b=a[d],c=b.attr("type")||"no/type",0!==c.indexOf("mce-")&&b.attr("type","mce-"+c)}),b.addNodeFilter("#cdata",function(a){for(var b,c=a.length;c--;)b=a[c],b.type=8,b.name="#comment",b.value="[CDATA["+b.value+"]]"}),b.addNodeFilter("p,h1,h2,h3,h4,h5,h6,div",function(b){for(var c,d=b.length,e=a.schema.getNonEmptyElements();d--;)c=b[d],c.isEmpty(e)&&0===c.getAll("br").length&&(c.append(new o("br",1)).shortEnded=!0)}),b},A=function(a){a.settings.auto_focus&&u.setEditorTimeout(a,function(){var b;b=a.settings.auto_focus===!0?a:a.editorManager.get(a.settings.auto_focus),b.destroyed||b.focus()},100)},B=function(a){a.bindPendingEventDelegates(),a.initialized=!0,a.fire("init"),a.focus(!0),a.nodeChanged({initial:!0}),a.execCallback("init_instance_callback",a),A(a)},C=function(a){return a.inline?x.styleSheetLoader:a.dom.styleSheetLoader},D=function(a,b){var c,l,n=a.settings,o=a.getElement(),u=a.getDoc();n.inline||(a.getElement().style.visibility=a.orgVisibility),b||n.content_editable||(u.open(),u.write(a.iframeHTML),u.close()),n.content_editable&&(a.on("remove",function(){var a=this.getBody();x.removeClass(a,"mce-content-body"),x.removeClass(a,"mce-edit-focus"),x.setAttrib(a,"contentEditable",null)}),x.addClass(o,"mce-content-body"),a.contentDocument=u=n.content_document||d,a.contentWindow=n.content_window||e,a.bodyElement=o,n.content_document=n.content_window=null,n.root_name=o.nodeName.toLowerCase()),c=a.getBody(),c.disabled=!0,a.readonly=n.readonly,a.readonly||(a.inline&&"static"===x.getStyle(c,"position",!0)&&(c.style.position="relative"),c.contentEditable=a.getParam("content_editable_state",!0)),c.disabled=!1,a.editorUpload=new k(a),a.schema=new p(n),a.dom=new h(u,{keep_values:!0,url_converter:a.convertURL,url_converter_scope:a,hex_colors:n.force_hex_style_colors,class_filter:n.class_filter,update_styles:!0,root_element:a.inline?a.getBody():null,collect:n.content_editable,schema:a.schema,onSetAttrib:function(b){a.fire("SetAttrib",b)}}),a.parser=z(a),a.serializer=new j(n,a),a.selection=new i(a.dom,a.getWin(),a.serializer,a),a.formatter=new f(a),a.undoManager=new t(a),a._nodeChangeDispatcher=new r(a),a._selectionOverrides=new s(a),g.setup(a),q.setup(a),m.setup(a),a.fire("PreInit"),n.browser_spellcheck||n.gecko_spellcheck||(u.body.spellcheck=!1,x.setAttrib(c,"spellcheck","false")),a.quirks=new v(a),a.fire("PostRender"),n.directionality&&(c.dir=n.directionality),n.nowrap&&(c.style.whiteSpace="nowrap"),n.protect&&a.on("BeforeSetContent",function(a){w.each(n.protect,function(b){a.content=a.content.replace(b,function(a){return""})})}),a.on("SetContent",function(){a.addVisual(a.getBody())}),n.padd_empty_editor&&a.on("PostProcess",function(a){a.content=a.content.replace(/^(]*>( | |\s|\u00a0|
|)<\/p>[\r\n]*|
[\r\n]*)$/,"")}),a.load({initial:!0,format:"html"}),a.startContent=a.getContent({format:"raw"}),a.on("compositionstart compositionend",function(b){a.composing="compositionstart"===b.type}),a.contentStyles.length>0&&(l="",w.each(a.contentStyles,function(a){l+=a+"\r\n"}),a.dom.addStyle(l)),C(a).loadAll(a.contentCSS,function(b){B(a)},function(b){B(a)}),n.content_style&&y(a,n.content_style)};return{initContentBody:D}}),g("6g",[],function(){var a=function(a,b,c){var d=a.getParam(b,c);if(d.indexOf("=")!==-1){var e=a.getParam(b,"","hash");return e.hasOwnProperty(a.id)?e[a.id]:c}return d},b=function(a){return a.getParam("iframe_attrs",{})},c=function(a){return a.getParam("doctype","")},d=function(a){return a.getParam("document_base_url","")},e=function(b){return a(b,"body_id","tinymce")},f=function(b){return a(b,"body_class","")},g=function(a){return a.getParam("content_security_policy","")};return{getIframeAttrs:b,getDocType:c,getDocumentBaseUrl:d,getBodyId:e,getBodyClass:f,getContentSecurityPolicy:g}}),g("5q",["1v","46","3f","1j","2","b","6g","l","5p","26"],function(a,b,c,d,e,f,g,h,i,j){var k=h.DOM,l=function(a,b){if(d.domain!==e.location.hostname&&f.ie&&f.ie<12){var c=j.uuid("mce");a[c]=function(){i.initContentBody(a)};var g='javascript:(function(){document.open();document.domain="'+d.domain+'";var ed = window.parent.tinymce.get("'+a.id+'");document.write(ed.iframeHTML);document.close();ed.'+c+"(true);})()";return k.setAttrib(b,"src",g),!0}return!1},m=function(a){var b="number"==typeof a?a+"px":a;return b?b:""},n=function(d,e,f,g){var h=a.fromTag("iframe");return b.setAll(h,g),b.setAll(h,{id:d+"_ifr",frameBorder:"0",allowTransparency:"true",title:e}),c.setAll(h,{width:"100%",height:m(f),display:"block"}),h},o=function(a){var b,c,d;return d=g.getDocType(a)+"
",g.getDocumentBaseUrl(a)!==a.documentBaseUrl&&(d+=''),d+='',b=g.getBodyId(a),c=g.getBodyClass(a),g.getContentSecurityPolicy(a)&&(d+=''),d+='
'},p=function(a,b){var c=a.editorManager.translate("Rich Text Area. Press ALT-F9 for menu. Press ALT-F10 for toolbar. Press ALT-0 for help"),d=n(a.id,c,b.height,g.getIframeAttrs(a)).dom();d.onload=function(){d.onload=null,a.fire("load")};var e=l(a,d);return a.contentAreaContainer=b.iframeContainer,a.iframeElement=d,a.iframeHTML=o(a),k.add(b.iframeContainer,d),e},q=function(a,b){var c=p(a,b);b.editorContainer&&(k.get(b.editorContainer).style.display=a.orgDisplay,a.hidden=k.isHidden(b.editorContainer)),a.getElement().style.display="none",k.setAttrib(a.id,"aria-hidden",!0),c||i.initContentBody(a)};return{init:q}}),g("4h",["27","1j","2","4i","4j","l","5p","5q","1e"],function(a,b,c,d,e,f,g,h,i){var j=f.DOM,k=function(a,b,c){var e,f,g=d.get(c);if(e=d.urls[c]||a.documentBaseUrl.replace(/\/$/,""),c=i.trim(c),g&&i.inArray(b,c)===-1){if(i.each(d.dependencies(c),function(c){k(a,b,c)}),a.plugins[c])return;f=new g(a,e,a.$),a.plugins[c]=f,f.init&&(f.init(a,e),b.push(c))}},l=function(a){return a.replace(/^\-/,"")},m=function(a){var b=[];i.each(a.settings.plugins.split(/[ ,]/),function(c){k(a,b,l(c))})},n=function(b){var c,d=b.settings.theme;a.isString(d)?(b.settings.theme=l(d),c=e.get(d),b.theme=new c(b,e.urls[d]),b.theme.init&&b.theme.init(b,e.urls[d]||b.documentBaseUrl.replace(/\/$/,""),b.$)):b.theme={}},o=function(a){var b,c,d,e,f,g=a.settings,h=a.getElement();return b=g.width||j.getStyle(h,"width")||"100%",c=g.height||j.getStyle(h,"height")||h.offsetHeight,d=g.min_height||100,e=/^[0-9\.]+(|px)$/i,e.test(""+b)&&(b=Math.max(parseInt(b,10),100)),e.test(""+c)&&(c=Math.max(parseInt(c,10),d)),f=a.theme.renderUI({targetNode:h,width:b,height:c,deltaWidth:g.delta_width,deltaHeight:g.delta_height}),g.content_editable||(c=(f.iframeHeight||c)+("number"==typeof c?f.deltaHeight||0:""),c=c.length)for(d=0,e=a.length;d=c.length||a[d]!=c[d]){f=d+1;break}if(a.length=a.length||a[d]!=c[d]){f=d+1;break}if(1===f)return b;for(d=0,e=a.length-(f-1);d=0;d--)0!==b[d].length&&"."!==b[d]&&(".."!==b[d]?g>0?g--:h.push(b[d]):g++);return d=a.length-g,f=d<=0?h.reverse().join("/"):a.slice(0,d).join("/")+"/"+h.reverse().join("/"),0!==f.indexOf("/")&&(f="/"+f),e&&f.lastIndexOf("/")!==f.length-1&&(f+=e),f},getURI:function(a){var b,c=this;return c.source&&!a||(b="",a||(b+=c.protocol?c.protocol+"://":"//",c.userInfo&&(b+=c.userInfo+"@"),c.host&&(b+=c.host),c.port&&(b+=":"+c.port)),c.path&&(b+=c.path),c.query&&(b+="?"+c.query),c.anchor&&(b+="#"+c.anchor),c.source=b),c.source}},g.parseDataUri=function(a){var b,c;return a=decodeURIComponent(a).split(","),c=/data:([^;]+)/.exec(a[0]),c&&(b=c[1]),{type:b,data:a[1]}},g.getDocumentBaseUrl=function(a){var b;return b=0!==a.protocol.indexOf("http")&&"file:"!==a.protocol?a.href:a.protocol+"//"+a.host+a.pathname,/^[^:]+:\/\/\/?[^\/]+\//.test(b)&&(b=b.replace(/[\?#].*$/,"").replace(/[\/\\][^\/]+$/,""),/[\/\\]$/.test(b)||(b+="/")),b},g}),g("7",["6","8","a","21","b","22","c","l","m","23","z","24","25","1e","1f","26"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p){var q=h.DOM,r=n.extend,s=n.each,t=n.trim,u=n.resolve,v=e.ie,w=function(c,f,h){var j,k,l=this;j=l.documentBaseUrl=h.documentBaseURL,k=h.baseURI,f=d.getEditorSettings(l,c,j,h.defaultSettings,f),l.settings=f,a.language=f.language||"en",a.languageLoad=f.language_load,a.baseURL=h.baseURL,l.id=c,l.setDirty(!1),l.plugins={},l.documentBaseURI=new o(f.document_base_url,{base_uri:k}),l.baseURI=k,l.contentCSS=[],l.contentStyles=[],l.shortcuts=new g(l),l.loadedCSS={},l.editorCommands=new b(l),l.suffix=h.suffix,l.editorManager=h,l.inline=f.inline,l.buttons={},l.menuItems={},f.cache_suffix&&(e.cacheSuffix=f.cache_suffix.replace(/^[\?\&]+/,"")),f.override_viewport===!1&&(e.overrideViewPort=!1),h.fire("SetupEditor",l),l.execCallback("setup",l),l.$=i.overrideDefaults(function(){return{context:l.inline?l.getBody():l.getDoc(),element:l.getBody()}})};return w.prototype={render:function(){l.render(this)},focus:function(a){j.focus(this,a)},execCallback:function(a){var b,c=this,d=c.settings[a];if(d)return c.callbackLookup&&(b=c.callbackLookup[a])&&(d=b.func,b=b.scope),"string"==typeof d&&(b=d.replace(/\.\w+$/,""),b=b?u(b):0,d=u(d),c.callbackLookup=c.callbackLookup||{},c.callbackLookup[a]={func:d,scope:b}),d.apply(b||c,Array.prototype.slice.call(arguments,1))},translate:function(a){if(a&&n.is(a,"string")){var b=this.settings.language||"en",c=this.editorManager.i18n;a=c.data[b+"."+a]||a.replace(/\{\#([^\}]+)\}/g,function(a,d){return c.data[b+"."+d]||"{#"+d+"}"})}return this.editorManager.translate(a)},getLang:function(a,b){return this.editorManager.i18n.data[(this.settings.language||"en")+"."+a]||(void 0!==b?b:"{#"+a+"}")},getParam:function(a,b,c){var d,e=a in this.settings?this.settings[a]:b;return"hash"===c?(d={},"string"==typeof e?s(e.indexOf("=")>0?e.split(/[;,](?![^=;,]*(?:[;,]|$))/):e.split(","),function(a){a=a.split("="),a.length>1?d[t(a[0])]=t(a[1]):d[t(a[0])]=t(a)}):d=e,d):e},nodeChanged:function(a){this._nodeChangeDispatcher.nodeChanged(a)},addButton:function(a,b){var c=this;b.cmd&&(b.onclick=function(){c.execCommand(b.cmd)}),b.text||b.icon||(b.icon=a),c.buttons=c.buttons,b.tooltip=b.tooltip||b.title,c.buttons[a]=b},addSidebar:function(a,b){return m.add(this,a,b)},addMenuItem:function(a,b){var c=this;b.cmd&&(b.onclick=function(){c.execCommand(b.cmd)}),c.menuItems=c.menuItems,c.menuItems[a]=b},addContextToolbar:function(a,b){var c,d=this;d.contextToolbars=d.contextToolbars||[],"string"==typeof a&&(c=a,a=function(a){return d.dom.is(a,c)}),d.contextToolbars.push({id:p.uuid("mcet"),predicate:a,items:b})},addCommand:function(a,b,c){this.editorCommands.addCommand(a,b,c)},addQueryStateHandler:function(a,b,c){this.editorCommands.addQueryStateHandler(a,b,c)},addQueryValueHandler:function(a,b,c){this.editorCommands.addQueryValueHandler(a,b,c)},addShortcut:function(a,b,c,d){this.shortcuts.add(a,b,c,d)},execCommand:function(a,b,c,d){return this.editorCommands.execCommand(a,b,c,d)},queryCommandState:function(a){return this.editorCommands.queryCommandState(a)},queryCommandValue:function(a){return this.editorCommands.queryCommandValue(a)},queryCommandSupported:function(a){return this.editorCommands.queryCommandSupported(a)},show:function(){var a=this;a.hidden&&(a.hidden=!1,a.inline?a.getBody().contentEditable=!0:(q.show(a.getContainer()),q.hide(a.id)),a.load(),a.fire("show"))},hide:function(){var a=this,b=a.getDoc();a.hidden||(v&&b&&!a.inline&&b.execCommand("SelectAll"),a.save(),a.inline?(a.getBody().contentEditable=!1,a==a.editorManager.focusedEditor&&(a.editorManager.focusedEditor=null)):(q.hide(a.getContainer()),q.setStyle(a.id,"display",a.orgDisplay)),a.hidden=!0,a.fire("hide"))},isHidden:function(){return!!this.hidden},setProgressState:function(a,b){this.fire("ProgressState",{state:a,time:b})},load:function(a){var b,c=this,d=c.getElement();return c.removed?"":d?(a=a||{},a.load=!0,b=c.setContent(void 0!==d.value?d.value:d.innerHTML,a),a.element=d,a.no_events||c.fire("LoadContent",a),a.element=d=null,b):void 0},save:function(a){var b,c,d=this,e=d.getElement();if(e&&d.initialized&&!d.removed)return a=a||{},a.save=!0,a.element=e,b=a.content=d.getContent(a),a.no_events||d.fire("SaveContent",a),"raw"==a.format&&d.fire("RawSaveContent",a),b=a.content,/TEXTAREA|INPUT/i.test(e.nodeName)?e.value=b:(d.inline||(e.innerHTML=b),(c=q.getParent(d.id,"form"))&&s(c.elements,function(a){if(a.name==d.id)return a.value=b,!1})),a.element=e=null,a.set_dirty!==!1&&d.setDirty(!1),b},setContent:function(a,b){var c,d,e=this,f=e.getBody();return b=b||{},b.format=b.format||"html",b.set=!0,b.content=a,b.no_events||e.fire("BeforeSetContent",b),a=b.content,0===a.length||/^\s+$/.test(a)?(d=v&&v<11?"":'
',"TABLE"==f.nodeName?a=""+d+" |
":/^(UL|OL)$/.test(f.nodeName)&&(a=""+d+""),c=e.settings.forced_root_block,c&&e.schema.isValidChild(f.nodeName.toLowerCase(),c.toLowerCase())?(a=d,a=e.dom.createHTML(c,e.settings.forced_root_block_attrs,a)):v||a||(a='
'),e.dom.setHTML(f,a),e.fire("SetContent",b)):("raw"!==b.format&&(a=new k({validate:e.validate},e.schema).serialize(e.parser.parse(a,{isRootContent:!0,insert:!0}))),b.content=t(a),e.dom.setHTML(f,b.content),b.no_events||e.fire("SetContent",b)),b.content},getContent:function(a){var b,c=this,d=c.getBody();return c.removed?"":(a=a||{},a.format=a.format||"html",a.get=!0,a.getInner=!0,a.no_events||c.fire("BeforeGetContent",a),b="raw"==a.format?n.trim(c.serializer.getTrimmedContent()):"text"==a.format?d.innerText||d.textContent:c.serializer.serialize(d,a),"text"!=a.format?a.content=t(b):a.content=b,a.no_events||c.fire("GetContent",a),a.content)},insertContent:function(a,b){b&&(a=r({content:a},b)),this.execCommand("mceInsertContent",!1,a)},isDirty:function(){return!this.isNotDirty},setDirty:function(a){var b=!this.isNotDirty;this.isNotDirty=!a,a&&a!=b&&this.fire("dirty")},setMode:function(a){f.setMode(this,a)},getContainer:function(){var a=this;return a.container||(a.container=q.get(a.editorContainer||a.id+"_parent")),a.container},getContentAreaContainer:function(){return this.contentAreaContainer},getElement:function(){return this.targetElm||(this.targetElm=q.get(this.id)),this.targetElm},getWin:function(){var a,b=this;return b.contentWindow||(a=b.iframeElement,a&&(b.contentWindow=a.contentWindow)),b.contentWindow},getDoc:function(){var a,b=this;return b.contentDocument||(a=b.getWin(),a&&(b.contentDocument=a.document)),b.contentDocument},getBody:function(){var a=this.getDoc();return this.bodyElement||(a?a.body:null)},convertURL:function(a,b,c){var d=this,e=d.settings;return e.urlconverter_callback?d.execCallback("urlconverter_callback",a,c,!0,b):!e.convert_urls||c&&"LINK"==c.nodeName||0===a.indexOf("file:")||0===a.length?a:e.relative_urls?d.documentBaseURI.toRelative(a):a=d.documentBaseURI.toAbsolute(a,e.remove_script_host)},addVisual:function(a){var b,c=this,d=c.settings,e=c.dom;a=a||c.getBody(),void 0===c.hasVisual&&(c.hasVisual=d.visual),s(e.select("table,a",a),function(a){var f;switch(a.nodeName){case"TABLE":return b=d.visual_table_class||"mce-item-table",f=e.getAttrib(a,"border"),void(f&&"0"!=f||!c.hasVisual?e.removeClass(a,b):e.addClass(a,b));case"A":return void(e.getAttrib(a,"href",!1)||(f=e.getAttrib(a,"name")||a.id,b=d.visual_anchor_class||"mce-item-anchor",f&&c.hasVisual?e.addClass(a,b):e.removeClass(a,b)))}}),c.fire("VisualAid",{element:a,hasVisual:c.hasVisual})},remove:function(){var a=this;a.removed||(a.save(),a.removed=1,a.unbindAllNativeEvents(),a.hasHiddenInput&&q.remove(a.getElement().nextSibling),a.inline||(v&&v<10&&a.getDoc().execCommand("SelectAll",!1,null),q.setStyle(a.id,"display",a.orgDisplay),a.getBody().onload=null),a.fire("remove"),a.editorManager.remove(a),q.remove(a.getContainer()),a._selectionOverrides.destroy(),a.editorUpload.destroy(),a.destroy())},destroy:function(a){var b,c=this;if(!c.destroyed){if(!a&&!c.removed)return void c.remove();a||(c.editorManager.off("beforeunload",c._beforeUnload),c.theme&&c.theme.destroy&&c.theme.destroy(),c.selection.destroy(),c.dom.destroy()),b=c.formElement,b&&(b._mceOldSubmit&&(b.submit=b._mceOldSubmit,b._mceOldSubmit=null),q.unbind(b,"submit reset",c.formEventDelegate)),c.contentAreaContainer=c.formElement=c.container=c.editorContainer=null,c.bodyElement=c.contentDocument=c.contentWindow=null,c.iframeElement=c.targetElm=null,c.selection&&(c.selection=c.selection.win=c.selection.dom=c.selection.dom.doc=null),c.destroyed=1}},uploadImages:function(a){return this.editorUpload.uploadImages(a)},_scanForImages:function(){return this.editorUpload.scanForImages()}},r(w.prototype,c),w}),g("29",["1e"],function(a){var b=a.each,c=a.explode,d=function(a){a.on("AddEditor",function(a){var d=a.editor;d.on("preInit",function(){var a,e,f,g=d.settings,h=function(a,c){b(c,function(b,c){b&&f.setStyle(a,c,b)}),f.rename(a,"span")},i=function(c){f=d.dom,g.convert_fonts_to_spans&&b(f.select("font,u,strike",c.node),function(b){a[b.nodeName.toLowerCase()](f,b)})};g.inline_styles&&(e=c(g.font_size_legacy_values),a={font:function(a,b){h(b,{backgroundColor:b.style.backgroundColor,color:b.color,fontFamily:b.face,fontSize:e[parseInt(b.size,10)-1]})},u:function(a,b){"html4"===d.settings.schema&&h(b,{textDecoration:"underline"})},strike:function(a,b){h(b,{textDecoration:"line-through"})}},d.on("PreProcess SetContent",i))})})};return{register:d}}),g("e",["1j"],function(a){var b=function(a){return a.className.toString().indexOf("mce-")!==-1};return{isEditorUIElement:b}}),g("4k",["5r","3c","1j","l","20"],function(a,b,c,d,e){var f=function(a){return"nodechange"===a.type&&a.selectionChange},g=function(a,b){var e=function(){b.throttle()};d.DOM.bind(c,"mouseup",e),a.on("remove",function(){
d.DOM.unbind(c,"mouseup",e)})},h=function(a){a.on("focusout",function(){e.store(a)})},i=function(a,b){a.on("mouseup touchend",function(a){b.throttle()})},j=function(a,c){var d=b.detect().browser;d.isIE()||d.isEdge()?h(a):i(a,c),a.on("keyup nodechange",function(b){f(b)||e.store(a)})},k=function(b){var c=a.first(function(){e.store(b)},0);b.inline&&g(b,c),b.on("init",function(){j(b,c)}),b.on("remove",function(){c.cancel()})};return{register:k}}),g("2a",["1","1j","e","l","4k","15"],function(a,b,c,d,e,f){var g,h=d.DOM,i=function(a){return c.isEditorUIElement(a)},j=function(a,b){var c=a?a.settings.custom_ui_selector:"",d=h.getParent(b,function(b){return i(b)||!!c&&a.dom.is(b,c)});return null!==d},k=function(){try{return b.activeElement}catch(a){return b.body}},l=function(a,c){var d=c.editor;e.register(d),d.on("focusin",function(){var b=a.focusedEditor;b!=d&&(b&&b.fire("blur",{focusedEditor:d}),a.setActive(d),a.focusedEditor=d,d.fire("focus",{blurredEditor:b}),d.focus(!0))}),d.on("focusout",function(){f.setEditorTimeout(d,function(){var b=a.focusedEditor;j(d,k())||b!=d||(d.fire("blur",{focusedEditor:null}),a.focusedEditor=null)})}),g||(g=function(c){var d,e=a.activeEditor;d=c.target,e&&d.ownerDocument===b&&(d===b.body||j(e,d)||a.focusedEditor!==e||(e.fire("blur",{focusedEditor:null}),a.focusedEditor=null))},h.bind(b,"focusin",g))},m=function(a,c){a.focusedEditor==c.editor&&(a.focusedEditor=null),a.activeEditor||(h.unbind(b,"focusin",g),g=null)},n=function(b){b.on("AddEditor",a.curry(l,b)),b.on("RemoveEditor",a.curry(m,b))};return{setup:n,isEditorUIElement:i,isUIElement:j}}),g("17",["1e"],function(a){"use strict";var b={},c="en";return{setCode:function(a){a&&(c=a,this.rtl=!!this.data[a]&&"rtl"===this.data[a]._dir)},getCode:function(){return c},rtl:!1,add:function(a,c){var d=b[a];d||(b[a]=d={});for(var e in c)d[e]=c[e];this.setCode(a)},translate:function(d){var e=b[c]||{},f=function(b){return a.is(b,"function")?Object.prototype.toString.call(b):g(b)?"":""+b},g=function(b){return""===b||null===b||a.is(b,"undefined")},h=function(b){return b=f(b),a.hasOwn(e,b)?f(e[b]):b};if(g(d))return"";if(a.is(d,"object")&&a.hasOwn(d,"raw"))return f(d.raw);if(a.is(d,"array")){var i=d.slice(1);d=h(d[0]).replace(/\{([0-9]+)\}/g,function(b,c){return a.hasOwn(i,c)?f(i[c]):b})}return h(d).replace(/{context:\w+}$/,"")},data:b}}),g("9",["1i","27","1j","2","6","7","b","28","29","l","m","2a","17","1c","1d","1e","1f"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q){var r,s,t=j.DOM,u=p.explode,v=p.each,w=p.extend,x=0,y=!1,z=[],A=[],B=function(a){return"length"!==a},C=function(a){v(s.get(),function(b){"scroll"===a.type?b.fire("ScrollWindow",a):b.fire("ResizeWindow",a)})},D=function(a){a!==y&&(a?k(d).on("resize scroll",C):k(d).off("resize scroll",C),y=a)},E=function(b){var c=A;delete z[b.id];for(var d=0;d0?A[0]:null),s.focusedEditor===b&&(s.focusedEditor=null),c.length!==A.length},F=function(a){return a&&a.initialized&&!(a.getContainer()||a.getBody()).parentNode&&(E(a),a.unbindAllNativeEvents(),a.destroy(!0),a.removed=!0,a=null),a};return s={defaultSettings:{},$:k,majorVersion:"4",minorVersion:"7.2",releaseDate:"2017-11-07",editors:z,i18n:m,activeEditor:null,settings:{},setup:function(){var a,b,e,f,g=this,h="";if(b=q.getDocumentBaseUrl(c.location),/^[^:]+:\/\/\/?[^\/]+\//.test(b)&&(b=b.replace(/[\?#].*$/,"").replace(/[\/\\][^\/]+$/,""),/[\/\\]$/.test(b)||(b+="/")),e=d.tinymce||d.tinyMCEPreInit)a=e.base||e.baseURL,h=e.suffix;else{for(var i=c.getElementsByTagName("script"),j=0;j0&&v(u(b),function(a){var b;(b=t.get(a))?d.push(b):v(c.forms,function(b){v(b.elements,function(b){b.name===a&&(a="mce_editor_"+x++,t.setAttrib(b,"id",a),d.push(b))})})});break;case"textareas":case"specific_textareas":v(t.select("textarea"),function(b){a.editor_deselector&&n(b,a.editor_deselector)||a.editor_selector&&!n(b,a.editor_selector)||d.push(b)})}return d},r=function(a){b=a},s=function(){var b,c=0,e=[],g=function(a,d,g){var h=new f(a,d,i);e.push(h),h.on("init",function(){++c===b.length&&r(e)}),h.targetElm=h.targetElm||g,h.render()};return t.unbind(d,"ready",s),m("onpageload"),b=k.unique(q(a)),a.types?void v(a.types,function(c){p.each(b,function(b){return!t.is(b,c.selector)||(g(l(b),w({},a,c),b),!1)})}):(p.each(b,function(a){F(i.get(a.id))}),b=p.grep(b,function(a){return!i.get(a.id)}),void(0===b.length?r([]):v(b,function(b){j(a,b)?h.initError("Could not initialize inline editor on invalid inline target element",b):g(l(b),a,b)})))};return i.settings=a,t.bind(d,"ready",s),new o(function(a){b?a(b):r=function(b){a(b)}})},get:function(c){return 0===arguments.length?A.slice(0):b.isString(c)?a.find(A,function(a){return a.id===c}).getOr(null):b.isNumber(c)&&A[c]?A[c]:null},add:function(a){var b,c=this;return b=z[a.id],b===a?a:(null===c.get(a.id)&&(B(a.id)&&(z[a.id]=a),z.push(a),A.push(a)),D(!0),c.activeEditor=a,c.fire("AddEditor",{editor:a}),r||(r=function(){c.fire("BeforeUnload")},t.bind(d,"beforeunload",r)),a)},createEditor:function(a,b){return this.add(new f(a,b,this))},remove:function(a){var c,e,f=this;{if(a)return b.isString(a)?(a=a.selector||a,void v(t.select(a),function(a){e=f.get(a.id),e&&f.remove(e)})):(e=a,b.isNull(f.get(e.id))?null:(E(e)&&f.fire("RemoveEditor",{editor:e}),0===A.length&&t.unbind(d,"beforeunload",r),e.remove(),D(A.length>0),e));for(c=A.length-1;c>=0;c--)f.remove(A[c])}},execCommand:function(a,b,c){var d=this,e=d.get(c);switch(a){case"mceAddEditor":return d.get(c)||new f(c,d.settings,d).render(),!0;case"mceRemoveEditor":return e&&e.remove(),!0;case"mceToggleEditor":return e?(e.isHidden()?e.show():e.hide(),!0):(d.execCommand("mceAddEditor",0,c),!0)}return!!d.activeEditor&&d.activeEditor.execCommand(a,b,c)},triggerSave:function(){v(A,function(a){a.save()})},addI18n:function(a,b){m.add(a,b)},translate:function(a){return m.translate(a)},setActive:function(a){var b=this.activeEditor;this.activeEditor!=a&&(b&&b.fire("deactivate",{relatedTarget:a}),a.fire("activate",{relatedTarget:b})),this.activeEditor=a}},w(s,n),s.setup(),i.register(s),s}),g("i",["1","2q","2r","2s","2t","2u","2v"],function(a,b,c,d,e,f,g){var h=function(b){var d=function(a,c){return f.walk(b,a,c)},e=g.split,h=function(d){return c.normalize(b,d).fold(a.constant(!1),function(a){return d.setStart(a.startContainer,a.startOffset),d.setEnd(a.endContainer,a.endOffset),!0})};return{walk:d,split:e,normalize:h}};return h.compareRanges=d.isEq,h.getCaretRangeFromPoint=b.fromPoint,h.getSelectedNode=e.getSelectedNode,h.getNode=e.getNode,h}),g("t",[],function(){"use strict";var a=Math.min,b=Math.max,c=Math.round,d=function(a,b,d){var e,f,g,h,j,k;return e=b.x,f=b.y,g=a.w,h=a.h,j=b.w,k=b.h,d=(d||"").split(""),"b"===d[0]&&(f+=k),"r"===d[1]&&(e+=j),"c"===d[0]&&(f+=c(k/2)),"c"===d[1]&&(e+=c(j/2)),"b"===d[3]&&(f-=h),"r"===d[4]&&(e-=g),"c"===d[3]&&(f-=c(h/2)),"c"===d[4]&&(e-=c(g/2)),i(e,f,g,h)},e=function(a,b,c,e){var f,g;for(g=0;g=c.x&&f.x+f.w<=c.w+c.x&&f.y>=c.y&&f.y+f.h<=c.h+c.y)return e[g];return null},f=function(a,b,c){return i(a.x-b,a.y-c,a.w+2*b,a.h+2*c)},g=function(c,d){var e,f,g,h;return e=b(c.x,d.x),f=b(c.y,d.y),g=a(c.x+c.w,d.x+d.w),h=a(c.y+c.h,d.y+d.h),g-e<0||h-f<0?null:i(e,f,g-e,h-f)},h=function(a,c,d){var e,f,g,h,j,k,l,m,n,o;return j=a.x,k=a.y,l=a.x+a.w,m=a.y+a.h,n=c.x+c.w,o=c.y+c.h,e=b(0,c.x-j),f=b(0,c.y-k),g=b(0,l-n),h=b(0,m-o),j+=e,k+=f,d&&(l+=e,m+=f,j-=g,k-=h),l-=g,m-=h,i(j,k,l-j,m-k)},i=function(a,b,c,d){return{x:a,y:b,w:c,h:d}},j=function(a){return i(a.left,a.top,a.width,a.height)};return{inflate:f,relativePosition:d,findBestRelativePosition:e,intersect:g,clamp:h,create:i,fromClientRect:j}}),g("12",[],function(){"use strict";var a={};return{add:function(b,c){a[b.toLowerCase()]=c},has:function(b){return!!a[b.toLowerCase()]},get:function(b){var c=b.toLowerCase(),d=a.hasOwnProperty(c)?a[c]:null;if(null===d)throw new Error("Could not find module for type: "+b);return d},create:function(b,c){var d;if("string"==typeof b?(c=c||{},c.type=b):(c=b,b=c.type),b=b.toLowerCase(),d=a[b],!d)throw new Error("Could not find control by type: "+b);return d=new d(c),d.type=b,d}}}),g("13",["1e"],function(a){var b,c,d=a.each,e=a.extend,f=function(){};return f.extend=b=function(a){var f,g,h,i=this,j=i.prototype,k=function(){var a,b,d,e=this;if(!c&&(e.init&&e.init.apply(e,arguments),b=e.Mixins))for(a=b.length;a--;)d=b[a],d.init&&d.init.apply(e,arguments)},l=function(){return this},m=function(a,b){return function(){var c,d=this,e=d._super;return d._super=j[a],c=b.apply(d,arguments),d._super=e,c}};c=!0,f=new i,c=!1,a.Mixins&&(d(a.Mixins,function(b){for(var c in b)"init"!==c&&(a[c]=b[c])}),j.Mixins&&(a.Mixins=j.Mixins.concat(a.Mixins))),a.Methods&&d(a.Methods.split(","),function(b){a[b]=l}),a.Properties&&d(a.Properties.split(","),function(b){var c="_"+b;a[b]=function(a){var b,d=this;return a!==b?(d[c]=a,d):d[c]}}),a.Statics&&d(a.Statics,function(a,b){k[b]=a}),a.Defaults&&j.Defaults&&(a.Defaults=e({},j.Defaults,a.Defaults));for(g in a)h=a[g],"function"==typeof h&&j[g]?f[g]=m(g,h):f[g]=h;return k.prototype=f,k.constructor=k,k.extend=b,k},f}),g("14",[],function(){var a=Math.min,b=Math.max,c=Math.round,d=function(d){var e=this,f=0,g=0,h=0,i=function(d,e,f){var g,h,i,j,k,l;return g=0,h=0,i=0,d/=255,e/=255,f/=255,k=a(d,a(e,f)),l=b(d,b(e,f)),k==l?(i=k,{h:0,s:0,v:100*i}):(j=d==k?e-f:f==k?d-e:f-d,g=d==k?3:f==k?1:5,g=60*(g-j/(l-k)),h=(l-k)/l,i=l,{h:c(g),s:c(100*h),v:c(100*i)})},j=function(d,e,i){var j,k,l,m;if(d=(parseInt(d,10)||0)%360,e=parseInt(e,10)/100,i=parseInt(i,10)/100,e=b(0,a(e,1)),i=b(0,a(i,1)),0===e)return void(f=g=h=c(255*i));switch(j=d/60,k=i*e,l=k*(1-Math.abs(j%2-1)),m=i-k,Math.floor(j)){case 0:f=k,g=l,h=0;break;case 1:f=l,g=k,h=0;break;case 2:f=0,g=k,h=l;break;case 3:f=0,g=l,h=k;break;case 4:f=l,g=0,h=k;break;case 5:f=k,g=0,h=l;break;default:f=g=h=0}f=c(255*(f+m)),g=c(255*(g+m)),h=c(255*(h+m))},k=function(){var a=function(a){return a=parseInt(a,10).toString(16),a.length>1?a:"0"+a};return"#"+a(f)+a(g)+a(h)},l=function(){return{r:f,g:g,b:h}},m=function(){return i(f,g,h)},n=function(a){var b;return"object"==typeof a?"r"in a?(f=a.r,g=a.g,h=a.b):"v"in a&&j(a.h,a.s,a.v):(b=/rgb\s*\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)[^\)]*\)/gi.exec(a))?(f=parseInt(b[1],10),g=parseInt(b[2],10),h=parseInt(b[3],10)):(b=/#([0-F]{2})([0-F]{2})([0-F]{2})/gi.exec(a))?(f=parseInt(b[1],16),g=parseInt(b[2],16),h=parseInt(b[3],16)):(b=/#([0-F])([0-F])([0-F])/gi.exec(a))&&(f=parseInt(b[1]+b[1],16),g=parseInt(b[2]+b[2],16),h=parseInt(b[3]+b[3],16)),f=f<0?0:f>255?255:f,g=g<0?0:g>255?255:g,h=h<0?0:h>255?255:h,e};d&&n(d),e.toRgb=l,e.toHsv=m,e.toHex=k,e.parse=n};return d}),g("18",["2"],function(a){var b=function(a,c){var d,e,f,g;if(c=c||'"',null===a)return"null";if(f=typeof a,"string"==f)return e="\bb\tt\nn\ff\rr\"\"''\\\\",c+a.replace(/([\u0080-\uFFFF\x00-\x1f\"\'\\])/g,function(a,b){return'"'===c&&"'"===a?a:(d=e.indexOf(b),d+1?"\\"+e.charAt(d+1):(a=b.charCodeAt().toString(16),"\\u"+"0000".substring(a.length)+a))})+c;if("object"==f){if(a.hasOwnProperty&&"[object Array]"===Object.prototype.toString.call(a)){for(d=0,e="[";d0?",":"")+b(a[d],c);return e+"]"}e="{";for(g in a)a.hasOwnProperty(g)&&(e+="function"!=typeof a[g]?(e.length>1?","+c:c)+g+c+":"+b(a[g],c):"");return e+"}"}return""+a};return{serialize:b,parse:function(b){try{return a[String.fromCharCode(101)+"val"]("("+b+")")}catch(a){}}}}),g("19",["l"],function(a){return{callbacks:{},count:0,send:function(b){var c=this,d=a.DOM,e=void 0!==b.count?b.count:c.count,f="tinymce_jsonp_"+e;c.callbacks[e]=function(a){d.remove(f),delete c.callbacks[e],b.callback(a)},d.add(d.doc.body,"script",{id:f,src:b.url,type:"text/javascript"}),c.count++}}}),g("1h",["38","1q","1c","1e"],function(a,b,c,d){var e={send:function(c){var f,g=0,h=function(){!c.async||4==f.readyState||g++>1e4?(c.success&&g<1e4&&200==f.status?c.success.call(c.success_scope,""+f.responseText,f,c):c.error&&c.error.call(c.error_scope,g>1e4?"TIMED_OUT":"GENERAL",f,c),f=null):b(h,10)};if(c.scope=c.scope||this,c.success_scope=c.success_scope||c.scope,c.error_scope=c.error_scope||c.scope,c.async=c.async!==!1,c.data=c.data||"",e.fire("beforeInitialize",{settings:c}),f=new a){if(f.overrideMimeType&&f.overrideMimeType(c.content_type),f.open(c.type||(c.data?"POST":"GET"),c.url,c.async),c.crossDomain&&(f.withCredentials=!0),c.content_type&&f.setRequestHeader("Content-Type",c.content_type),c.requestheaders&&d.each(c.requestheaders,function(a){f.setRequestHeader(a.key,a.value)}),f.setRequestHeader("X-Requested-With","XMLHttpRequest"),f=e.fire("beforeSend",{xhr:f,settings:c}).xhr,f.send(c.data),!c.async)return h();b(h,10)}}};return d.extend(e,c),e}),g("1a",["18","1h","1e"],function(a,b,c){var d=c.extend,e=function(a){this.settings=d({},a),this.count=0};return e.sendRPC=function(a){return(new e).send(a)},e.prototype={send:function(c){var e=c.error,f=c.success;c=d(this.settings,c),c.success=function(b,d){b=a.parse(b),"undefined"==typeof b&&(b={error:"JSON Parse error."}),b.error?e.call(c.error_scope||c.scope,b.error,d):f.call(c.success_scope||c.scope,b.result)},c.error=function(a,b){e&&e.call(c.error_scope||c.scope,a,b)},c.data=a.serialize({id:c.id||"c"+this.count++,method:c.method,params:c.params}),c.content_type="application/json",b.send(c)}},e}),g("1b",["1j","2"],function(a,b){var c,d,e,f,g,h;try{if(b.localStorage)return b.localStorage}catch(a){}g="tinymce",d=a.documentElement,h=!!d.addBehavior,h&&d.addBehavior("#default#userData");var i=function(){f=[];for(var a in e)f.push(a);c.length=f.length},j=function(){var a,b,c,f=0;if(e={},h){var j=function(a){var c,d;return d=void 0!==a?f+a:b.indexOf(",",f),d===-1||d>b.length?null:(c=b.substring(f,d),f=d+1,c)};d.load(g),b=d.getAttribute(g)||"";do{var k=j();if(null===k)break;if(a=j(parseInt(k,32)||0),null!==a){if(k=j(),null===k)break;c=j(parseInt(k,32)||0),a&&(e[a]=c)}}while(null!==a);i()}},k=function(){var a,b="";if(h){for(var c in e)a=e[c],b+=(b?",":"")+c.length.toString(32)+","+c+","+a.length.toString(32)+","+a;d.setAttribute(g,b);try{d.save(g)}catch(a){}i()}};return c={key:function(a){return f[a]},getItem:function(a){return a in e?e[a]:null},setItem:function(a,b){e[a]=""+b,k()},removeItem:function(a){delete e[a],k()},clear:function(){e={},k()}},j(),c}),g("3",["6","7","8","9","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","1g","1h"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V){var W=d,X={geom:{Rect:x},util:{Promise:R,Delay:J,Tools:S,VK:U,URI:T,Class:H,EventDispatcher:K,Observable:Q,I18n:L,XHR:V,JSON:M,JSONRequest:O,JSONP:N,LocalStorage:P,Color:I},dom:{EventUtils:r,Sizzle:v,DomQuery:q,TreeWalker:w,DOMUtils:p,ScriptLoader:s,RangeUtils:m,Serializer:u,ControlSelection:o,BookmarkManager:n,Selection:t,Event:r.Event},html:{Styles:E,Entities:z,Node:A,Schema:C,SaxParser:B,DomParser:y,Writer:F,Serializer:D},ui:{Factory:G},Env:f,AddOnManager:a,Formatter:j,UndoManager:h,EditorCommands:c,WindowManager:l,NotificationManager:k,EditorObservable:e,Shortcuts:g,Editor:b,FocusManager:i,EditorManager:d,DOM:p.DOM,ScriptLoader:s.ScriptLoader,PluginManager:a.PluginManager,ThemeManager:a.ThemeManager,trim:S.trim,isArray:S.isArray,is:S.is,toArray:S.toArray,makeMap:S.makeMap,each:S.each,map:S.map,grep:S.grep,inArray:S.inArray,extend:S.extend,create:S.create,walk:S.walk,createNS:S.createNS,resolve:S.resolve,explode:S.explode,_addCacheSuffix:S._addCacheSuffix,isOpera:f.opera,isWebKit:f.webkit,isIE:f.ie,isGecko:f.gecko,isMac:f.mac};return W=S.extend(W,X)}),g("0",["1","2","3"],function(a,b,c){var d=this||b,e=function(b){"function"!=typeof d.define||d.define.amd||(d.define("ephox/tinymce",[],a.constant(b)),d.define("9",[],a.constant(b))),"object"==typeof module&&(module.exports=b)},f=function(a){b.tinymce=a,b.tinyMCE=a};return function(){return f(c),e(c),c}}),d("0")()}();
//script: bootstrap
/*
Copyright (C) Federico Zivolo 2017
Distributed under the MIT License (license terms are at http://opensource.org/licenses/MIT).
*/(function(e,t){'object'==typeof exports&&'undefined'!=typeof module?module.exports=t():'function'==typeof define&&define.amd?define(t):e.Popper=t()})(this,function(){'use strict';function e(e){return e&&'[object Function]'==={}.toString.call(e)}function t(e,t){if(1!==e.nodeType)return[];var o=window.getComputedStyle(e,null);return t?o[t]:o}function o(e){return'HTML'===e.nodeName?e:e.parentNode||e.host}function n(e){if(!e||-1!==['HTML','BODY','#document'].indexOf(e.nodeName))return window.document.body;var i=t(e),r=i.overflow,p=i.overflowX,s=i.overflowY;return /(auto|scroll)/.test(r+s+p)?e:n(o(e))}function r(e){var o=e&&e.offsetParent,i=o&&o.nodeName;return i&&'BODY'!==i&&'HTML'!==i?-1!==['TD','TABLE'].indexOf(o.nodeName)&&'static'===t(o,'position')?r(o):o:window.document.documentElement}function p(e){var t=e.nodeName;return'BODY'!==t&&('HTML'===t||r(e.firstElementChild)===e)}function s(e){return null===e.parentNode?e:s(e.parentNode)}function d(e,t){if(!e||!e.nodeType||!t||!t.nodeType)return window.document.documentElement;var o=e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING,i=o?e:t,n=o?t:e,a=document.createRange();a.setStart(i,0),a.setEnd(n,0);var l=a.commonAncestorContainer;if(e!==l&&t!==l||i.contains(n))return p(l)?l:r(l);var f=s(e);return f.host?d(f.host,t):d(e,s(t).host)}function a(e){var t=1=o.clientWidth&&i>=o.clientHeight}),l=0i[e]&&!t.escapeWithReference&&(n=V(p[o],i[e]-('right'===e?p.width:p.height))),se({},o,n)}};return n.forEach(function(e){var t=-1===['left','top'].indexOf(e)?'secondary':'primary';p=de({},p,s[t](e))}),e.offsets.popper=p,e},priority:['left','right','top','bottom'],padding:5,boundariesElement:'scrollParent'},keepTogether:{order:400,enabled:!0,fn:function(e){var t=e.offsets,o=t.popper,i=t.reference,n=e.placement.split('-')[0],r=_,p=-1!==['top','bottom'].indexOf(n),s=p?'right':'bottom',d=p?'left':'top',a=p?'width':'height';return o[s]r(i[s])&&(e.offsets.popper[d]=r(i[s])),e}},arrow:{order:500,enabled:!0,fn:function(e,o){if(!F(e.instance.modifiers,'arrow','keepTogether'))return e;var i=o.element;if('string'==typeof i){if(i=e.instance.popper.querySelector(i),!i)return e;}else if(!e.instance.popper.contains(i))return console.warn('WARNING: `arrow.element` must be child of its popper element!'),e;var n=e.placement.split('-')[0],r=e.offsets,p=r.popper,s=r.reference,d=-1!==['left','right'].indexOf(n),a=d?'height':'width',l=d?'Top':'Left',f=l.toLowerCase(),m=d?'left':'top',c=d?'bottom':'right',g=O(i)[a];s[c]-gp[c]&&(e.offsets.popper[f]+=s[f]+g-p[c]);var u=s[f]+s[a]/2-g/2,b=t(e.instance.popper,'margin'+l).replace('px',''),y=u-h(e.offsets.popper)[f]-b;return y=X(V(p[a]-g,y),0),e.arrowElement=i,e.offsets.arrow={},e.offsets.arrow[f]=Math.round(y),e.offsets.arrow[m]='',e},element:'[x-arrow]'},flip:{order:600,enabled:!0,fn:function(e,t){if(W(e.instance.modifiers,'inner'))return e;if(e.flipped&&e.placement===e.originalPlacement)return e;var o=w(e.instance.popper,e.instance.reference,t.padding,t.boundariesElement),i=e.placement.split('-')[0],n=L(i),r=e.placement.split('-')[1]||'',p=[];switch(t.behavior){case fe.FLIP:p=[i,n];break;case fe.CLOCKWISE:p=K(i);break;case fe.COUNTERCLOCKWISE:p=K(i,!0);break;default:p=t.behavior;}return p.forEach(function(s,d){if(i!==s||p.length===d+1)return e;i=e.placement.split('-')[0],n=L(i);var a=e.offsets.popper,l=e.offsets.reference,f=_,m='left'===i&&f(a.right)>f(l.left)||'right'===i&&f(a.left)f(l.top)||'bottom'===i&&f(a.top)f(o.right),g=f(a.top)f(o.bottom),b='left'===i&&c||'right'===i&&h||'top'===i&&g||'bottom'===i&&u,y=-1!==['top','bottom'].indexOf(i),w=!!t.flipVariations&&(y&&'start'===r&&c||y&&'end'===r&&h||!y&&'start'===r&&g||!y&&'end'===r&&u);(m||b||w)&&(e.flipped=!0,(m||b)&&(i=p[d+1]),w&&(r=j(r)),e.placement=i+(r?'-'+r:''),e.offsets.popper=de({},e.offsets.popper,S(e.instance.popper,e.offsets.reference,e.placement)),e=N(e.instance.modifiers,e,'flip'))}),e},behavior:'flip',padding:5,boundariesElement:'viewport'},inner:{order:700,enabled:!1,fn:function(e){var t=e.placement,o=t.split('-')[0],i=e.offsets,n=i.popper,r=i.reference,p=-1!==['left','right'].indexOf(o),s=-1===['top','left'].indexOf(o);return n[p?'left':'top']=r[o]-(s?n[p?'width':'height']:0),e.placement=L(t),e.offsets.popper=h(n),e}},hide:{order:800,enabled:!0,fn:function(e){if(!F(e.instance.modifiers,'hide','preventOverflow'))return e;var t=e.offsets.reference,o=T(e.instance.modifiers,function(e){return'preventOverflow'===e.name}).boundaries;if(t.bottomo.right||t.top>o.bottom||t.right0?n:null}catch(t){return null}},reflow:function(t){return t.offsetHeight},triggerTransitionEnd:function(t){e(t).trigger(r.end)},supportsTransitionEnd:function(){return Boolean(r)},isElement:function(t){return(t[0]||t).nodeType},typeCheckConfig:function(e,n,i){for(var s in i)if(Object.prototype.hasOwnProperty.call(i,s)){var r=i[s],o=n[s],l=o&&a.isElement(o)?"element":t(o);if(!new RegExp(r).test(l))throw new Error(e.toUpperCase()+': Option "'+s+'" provided type "'+l+'" but expected type "'+r+'".')}}};return r=i(),e.fn.emulateTransitionEnd=s,a.supportsTransitionEnd()&&(e.event.special[a.TRANSITION_END]=n()),a}(),r=function(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),t},o=function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,t.__proto__=e},a=function(){var t="alert",n=e.fn[t],i={CLOSE:"close.bs.alert",CLOSED:"closed.bs.alert",CLICK_DATA_API:"click.bs.alert.data-api"},o={ALERT:"alert",FADE:"fade",SHOW:"show"},a=function(){function t(t){this._element=t}var n=t.prototype;return n.close=function(t){t=t||this._element;var e=this._getRootElement(t);this._triggerCloseEvent(e).isDefaultPrevented()||this._removeElement(e)},n.dispose=function(){e.removeData(this._element,"bs.alert"),this._element=null},n._getRootElement=function(t){var n=s.getSelectorFromElement(t),i=!1;return n&&(i=e(n)[0]),i||(i=e(t).closest("."+o.ALERT)[0]),i},n._triggerCloseEvent=function(t){var n=e.Event(i.CLOSE);return e(t).trigger(n),n},n._removeElement=function(t){var n=this;e(t).removeClass(o.SHOW),s.supportsTransitionEnd()&&e(t).hasClass(o.FADE)?e(t).one(s.TRANSITION_END,function(e){return n._destroyElement(t,e)}).emulateTransitionEnd(150):this._destroyElement(t)},n._destroyElement=function(t){e(t).detach().trigger(i.CLOSED).remove()},t._jQueryInterface=function(n){return this.each(function(){var i=e(this),s=i.data("bs.alert");s||(s=new t(this),i.data("bs.alert",s)),"close"===n&&s[n](this)})},t._handleDismiss=function(t){return function(e){e&&e.preventDefault(),t.close(this)}},r(t,null,[{key:"VERSION",get:function(){return"4.0.0-beta.2"}}]),t}();return e(document).on(i.CLICK_DATA_API,{DISMISS:'[data-dismiss="alert"]'}.DISMISS,a._handleDismiss(new a)),e.fn[t]=a._jQueryInterface,e.fn[t].Constructor=a,e.fn[t].noConflict=function(){return e.fn[t]=n,a._jQueryInterface},a}(),l=function(){var t="button",n=e.fn[t],i={ACTIVE:"active",BUTTON:"btn",FOCUS:"focus"},s={DATA_TOGGLE_CARROT:'[data-toggle^="button"]',DATA_TOGGLE:'[data-toggle="buttons"]',INPUT:"input",ACTIVE:".active",BUTTON:".btn"},o={CLICK_DATA_API:"click.bs.button.data-api",FOCUS_BLUR_DATA_API:"focus.bs.button.data-api blur.bs.button.data-api"},a=function(){function t(t){this._element=t}var n=t.prototype;return n.toggle=function(){var t=!0,n=!0,r=e(this._element).closest(s.DATA_TOGGLE)[0];if(r){var o=e(this._element).find(s.INPUT)[0];if(o){if("radio"===o.type)if(o.checked&&e(this._element).hasClass(i.ACTIVE))t=!1;else{var a=e(r).find(s.ACTIVE)[0];a&&e(a).removeClass(i.ACTIVE)}if(t){if(o.hasAttribute("disabled")||r.hasAttribute("disabled")||o.classList.contains("disabled")||r.classList.contains("disabled"))return;o.checked=!e(this._element).hasClass(i.ACTIVE),e(o).trigger("change")}o.focus(),n=!1}}n&&this._element.setAttribute("aria-pressed",!e(this._element).hasClass(i.ACTIVE)),t&&e(this._element).toggleClass(i.ACTIVE)},n.dispose=function(){e.removeData(this._element,"bs.button"),this._element=null},t._jQueryInterface=function(n){return this.each(function(){var i=e(this).data("bs.button");i||(i=new t(this),e(this).data("bs.button",i)),"toggle"===n&&i[n]()})},r(t,null,[{key:"VERSION",get:function(){return"4.0.0-beta.2"}}]),t}();return e(document).on(o.CLICK_DATA_API,s.DATA_TOGGLE_CARROT,function(t){t.preventDefault();var n=t.target;e(n).hasClass(i.BUTTON)||(n=e(n).closest(s.BUTTON)),a._jQueryInterface.call(e(n),"toggle")}).on(o.FOCUS_BLUR_DATA_API,s.DATA_TOGGLE_CARROT,function(t){var n=e(t.target).closest(s.BUTTON)[0];e(n).toggleClass(i.FOCUS,/^focus(in)?$/.test(t.type))}),e.fn[t]=a._jQueryInterface,e.fn[t].Constructor=a,e.fn[t].noConflict=function(){return e.fn[t]=n,a._jQueryInterface},a}(),h=function(){var t="carousel",n="bs.carousel",i="."+n,o=e.fn[t],a={interval:5e3,keyboard:!0,slide:!1,pause:"hover",wrap:!0},l={interval:"(number|boolean)",keyboard:"boolean",slide:"(boolean|string)",pause:"(string|boolean)",wrap:"boolean"},h={NEXT:"next",PREV:"prev",LEFT:"left",RIGHT:"right"},c={SLIDE:"slide"+i,SLID:"slid"+i,KEYDOWN:"keydown"+i,MOUSEENTER:"mouseenter"+i,MOUSELEAVE:"mouseleave"+i,TOUCHEND:"touchend"+i,LOAD_DATA_API:"load.bs.carousel.data-api",CLICK_DATA_API:"click.bs.carousel.data-api"},u={CAROUSEL:"carousel",ACTIVE:"active",SLIDE:"slide",RIGHT:"carousel-item-right",LEFT:"carousel-item-left",NEXT:"carousel-item-next",PREV:"carousel-item-prev",ITEM:"carousel-item"},d={ACTIVE:".active",ACTIVE_ITEM:".active.carousel-item",ITEM:".carousel-item",NEXT_PREV:".carousel-item-next, .carousel-item-prev",INDICATORS:".carousel-indicators",DATA_SLIDE:"[data-slide], [data-slide-to]",DATA_RIDE:'[data-ride="carousel"]'},f=function(){function o(t,n){this._items=null,this._interval=null,this._activeElement=null,this._isPaused=!1,this._isSliding=!1,this.touchTimeout=null,this._config=this._getConfig(n),this._element=e(t)[0],this._indicatorsElement=e(this._element).find(d.INDICATORS)[0],this._addEventListeners()}var f=o.prototype;return f.next=function(){this._isSliding||this._slide(h.NEXT)},f.nextWhenVisible=function(){!document.hidden&&e(this._element).is(":visible")&&"hidden"!==e(this._element).css("visibility")&&this.next()},f.prev=function(){this._isSliding||this._slide(h.PREV)},f.pause=function(t){t||(this._isPaused=!0),e(this._element).find(d.NEXT_PREV)[0]&&s.supportsTransitionEnd()&&(s.triggerTransitionEnd(this._element),this.cycle(!0)),clearInterval(this._interval),this._interval=null},f.cycle=function(t){t||(this._isPaused=!1),this._interval&&(clearInterval(this._interval),this._interval=null),this._config.interval&&!this._isPaused&&(this._interval=setInterval((document.visibilityState?this.nextWhenVisible:this.next).bind(this),this._config.interval))},f.to=function(t){var n=this;this._activeElement=e(this._element).find(d.ACTIVE_ITEM)[0];var i=this._getItemIndex(this._activeElement);if(!(t>this._items.length-1||t<0))if(this._isSliding)e(this._element).one(c.SLID,function(){return n.to(t)});else{if(i===t)return this.pause(),void this.cycle();var s=t>i?h.NEXT:h.PREV;this._slide(s,this._items[t])}},f.dispose=function(){e(this._element).off(i),e.removeData(this._element,n),this._items=null,this._config=null,this._element=null,this._interval=null,this._isPaused=null,this._isSliding=null,this._activeElement=null,this._indicatorsElement=null},f._getConfig=function(n){return n=e.extend({},a,n),s.typeCheckConfig(t,n,l),n},f._addEventListeners=function(){var t=this;this._config.keyboard&&e(this._element).on(c.KEYDOWN,function(e){return t._keydown(e)}),"hover"===this._config.pause&&(e(this._element).on(c.MOUSEENTER,function(e){return t.pause(e)}).on(c.MOUSELEAVE,function(e){return t.cycle(e)}),"ontouchstart"in document.documentElement&&e(this._element).on(c.TOUCHEND,function(){t.pause(),t.touchTimeout&&clearTimeout(t.touchTimeout),t.touchTimeout=setTimeout(function(e){return t.cycle(e)},500+t._config.interval)}))},f._keydown=function(t){if(!/input|textarea/i.test(t.target.tagName))switch(t.which){case 37:t.preventDefault(),this.prev();break;case 39:t.preventDefault(),this.next();break;default:return}},f._getItemIndex=function(t){return this._items=e.makeArray(e(t).parent().find(d.ITEM)),this._items.indexOf(t)},f._getItemByDirection=function(t,e){var n=t===h.NEXT,i=t===h.PREV,s=this._getItemIndex(e),r=this._items.length-1;if((i&&0===s||n&&s===r)&&!this._config.wrap)return e;var o=(s+(t===h.PREV?-1:1))%this._items.length;return-1===o?this._items[this._items.length-1]:this._items[o]},f._triggerSlideEvent=function(t,n){var i=this._getItemIndex(t),s=this._getItemIndex(e(this._element).find(d.ACTIVE_ITEM)[0]),r=e.Event(c.SLIDE,{relatedTarget:t,direction:n,from:s,to:i});return e(this._element).trigger(r),r},f._setActiveIndicatorElement=function(t){if(this._indicatorsElement){e(this._indicatorsElement).find(d.ACTIVE).removeClass(u.ACTIVE);var n=this._indicatorsElement.children[this._getItemIndex(t)];n&&e(n).addClass(u.ACTIVE)}},f._slide=function(t,n){var i,r,o,a=this,l=e(this._element).find(d.ACTIVE_ITEM)[0],f=this._getItemIndex(l),_=n||l&&this._getItemByDirection(t,l),g=this._getItemIndex(_),m=Boolean(this._interval);if(t===h.NEXT?(i=u.LEFT,r=u.NEXT,o=h.LEFT):(i=u.RIGHT,r=u.PREV,o=h.RIGHT),_&&e(_).hasClass(u.ACTIVE))this._isSliding=!1;else if(!this._triggerSlideEvent(_,o).isDefaultPrevented()&&l&&_){this._isSliding=!0,m&&this.pause(),this._setActiveIndicatorElement(_);var p=e.Event(c.SLID,{relatedTarget:_,direction:o,from:f,to:g});s.supportsTransitionEnd()&&e(this._element).hasClass(u.SLIDE)?(e(_).addClass(r),s.reflow(_),e(l).addClass(i),e(_).addClass(i),e(l).one(s.TRANSITION_END,function(){e(_).removeClass(i+" "+r).addClass(u.ACTIVE),e(l).removeClass(u.ACTIVE+" "+r+" "+i),a._isSliding=!1,setTimeout(function(){return e(a._element).trigger(p)},0)}).emulateTransitionEnd(600)):(e(l).removeClass(u.ACTIVE),e(_).addClass(u.ACTIVE),this._isSliding=!1,e(this._element).trigger(p)),m&&this.cycle()}},o._jQueryInterface=function(t){return this.each(function(){var i=e(this).data(n),s=e.extend({},a,e(this).data());"object"==typeof t&&e.extend(s,t);var r="string"==typeof t?t:s.slide;if(i||(i=new o(this,s),e(this).data(n,i)),"number"==typeof t)i.to(t);else if("string"==typeof r){if("undefined"==typeof i[r])throw new Error('No method named "'+r+'"');i[r]()}else s.interval&&(i.pause(),i.cycle())})},o._dataApiClickHandler=function(t){var i=s.getSelectorFromElement(this);if(i){var r=e(i)[0];if(r&&e(r).hasClass(u.CAROUSEL)){var a=e.extend({},e(r).data(),e(this).data()),l=this.getAttribute("data-slide-to");l&&(a.interval=!1),o._jQueryInterface.call(e(r),a),l&&e(r).data(n).to(l),t.preventDefault()}}},r(o,null,[{key:"VERSION",get:function(){return"4.0.0-beta.2"}},{key:"Default",get:function(){return a}}]),o}();return e(document).on(c.CLICK_DATA_API,d.DATA_SLIDE,f._dataApiClickHandler),e(window).on(c.LOAD_DATA_API,function(){e(d.DATA_RIDE).each(function(){var t=e(this);f._jQueryInterface.call(t,t.data())})}),e.fn[t]=f._jQueryInterface,e.fn[t].Constructor=f,e.fn[t].noConflict=function(){return e.fn[t]=o,f._jQueryInterface},f}(),c=function(){var t="collapse",n="bs.collapse",i=e.fn[t],o={toggle:!0,parent:""},a={toggle:"boolean",parent:"(string|element)"},l={SHOW:"show.bs.collapse",SHOWN:"shown.bs.collapse",HIDE:"hide.bs.collapse",HIDDEN:"hidden.bs.collapse",CLICK_DATA_API:"click.bs.collapse.data-api"},h={SHOW:"show",COLLAPSE:"collapse",COLLAPSING:"collapsing",COLLAPSED:"collapsed"},c={WIDTH:"width",HEIGHT:"height"},u={ACTIVES:".show, .collapsing",DATA_TOGGLE:'[data-toggle="collapse"]'},d=function(){function i(t,n){this._isTransitioning=!1,this._element=t,this._config=this._getConfig(n),this._triggerArray=e.makeArray(e('[data-toggle="collapse"][href="#'+t.id+'"],[data-toggle="collapse"][data-target="#'+t.id+'"]'));for(var i=e(u.DATA_TOGGLE),r=0;r0&&this._triggerArray.push(o)}this._parent=this._config.parent?this._getParent():null,this._config.parent||this._addAriaAndCollapsedClass(this._element,this._triggerArray),this._config.toggle&&this.toggle()}var d=i.prototype;return d.toggle=function(){e(this._element).hasClass(h.SHOW)?this.hide():this.show()},d.show=function(){var t=this;if(!this._isTransitioning&&!e(this._element).hasClass(h.SHOW)){var r,o;if(this._parent&&((r=e.makeArray(e(this._parent).children().children(u.ACTIVES))).length||(r=null)),!(r&&(o=e(r).data(n))&&o._isTransitioning)){var a=e.Event(l.SHOW);if(e(this._element).trigger(a),!a.isDefaultPrevented()){r&&(i._jQueryInterface.call(e(r),"hide"),o||e(r).data(n,null));var c=this._getDimension();e(this._element).removeClass(h.COLLAPSE).addClass(h.COLLAPSING),this._element.style[c]=0,this._triggerArray.length&&e(this._triggerArray).removeClass(h.COLLAPSED).attr("aria-expanded",!0),this.setTransitioning(!0);var d=function(){e(t._element).removeClass(h.COLLAPSING).addClass(h.COLLAPSE).addClass(h.SHOW),t._element.style[c]="",t.setTransitioning(!1),e(t._element).trigger(l.SHOWN)};if(s.supportsTransitionEnd()){var f="scroll"+(c[0].toUpperCase()+c.slice(1));e(this._element).one(s.TRANSITION_END,d).emulateTransitionEnd(600),this._element.style[c]=this._element[f]+"px"}else d()}}}},d.hide=function(){var t=this;if(!this._isTransitioning&&e(this._element).hasClass(h.SHOW)){var n=e.Event(l.HIDE);if(e(this._element).trigger(n),!n.isDefaultPrevented()){var i=this._getDimension();if(this._element.style[i]=this._element.getBoundingClientRect()[i]+"px",s.reflow(this._element),e(this._element).addClass(h.COLLAPSING).removeClass(h.COLLAPSE).removeClass(h.SHOW),this._triggerArray.length)for(var r=0;r0},g._getPopperConfig=function(){var t=this,n={};"function"==typeof this._config.offset?n.fn=function(n){return n.offsets=e.extend({},n.offsets,t._config.offset(n.offsets)||{}),n}:n.offset=this._config.offset;var i={placement:this._getPlacement(),modifiers:{offset:n,flip:{enabled:this._config.flip}}};return this._inNavbar&&(i.modifiers.applyStyle={enabled:!this._inNavbar}),i},a._jQueryInterface=function(t){return this.each(function(){var n=e(this).data(i),s="object"==typeof t?t:null;if(n||(n=new a(this,s),e(this).data(i,n)),"string"==typeof t){if("undefined"==typeof n[t])throw new Error('No method named "'+t+'"');n[t]()}})},a._clearMenus=function(t){if(!t||3!==t.which&&("keyup"!==t.type||9===t.which))for(var n=e.makeArray(e(u.DATA_TOGGLE)),s=0;s0&&r--,40===t.which&&rdocument.documentElement.clientHeight;!this._isBodyOverflowing&&t&&(this._element.style.paddingLeft=this._scrollbarWidth+"px"),this._isBodyOverflowing&&!t&&(this._element.style.paddingRight=this._scrollbarWidth+"px")},u._resetAdjustments=function(){this._element.style.paddingLeft="",this._element.style.paddingRight=""},u._checkScrollbar=function(){var t=document.body.getBoundingClientRect();this._isBodyOverflowing=t.left+t.right
',trigger:"hover focus",title:"",delay:0,html:!1,selector:!1,placement:"top",offset:0,container:!1,fallbackPlacement:"flip"},u={SHOW:"show",OUT:"out"},d={HIDE:"hide"+i,HIDDEN:"hidden"+i,SHOW:"show"+i,SHOWN:"shown"+i,INSERTED:"inserted"+i,CLICK:"click"+i,FOCUSIN:"focusin"+i,FOCUSOUT:"focusout"+i,MOUSEENTER:"mouseenter"+i,MOUSELEAVE:"mouseleave"+i},f={FADE:"fade",SHOW:"show"},_={TOOLTIP:".tooltip",TOOLTIP_INNER:".tooltip-inner",ARROW:".arrow"},g={HOVER:"hover",FOCUS:"focus",CLICK:"click",MANUAL:"manual"},m=function(){function o(t,e){this._isEnabled=!0,this._timeout=0,this._hoverState="",this._activeTrigger={},this._popper=null,this.element=t,this.config=this._getConfig(e),this.tip=null,this._setListeners()}var m=o.prototype;return m.enable=function(){this._isEnabled=!0},m.disable=function(){this._isEnabled=!1},m.toggleEnabled=function(){this._isEnabled=!this._isEnabled},m.toggle=function(t){if(this._isEnabled)if(t){var n=this.constructor.DATA_KEY,i=e(t.currentTarget).data(n);i||(i=new this.constructor(t.currentTarget,this._getDelegateConfig()),e(t.currentTarget).data(n,i)),i._activeTrigger.click=!i._activeTrigger.click,i._isWithActiveTrigger()?i._enter(null,i):i._leave(null,i)}else{if(e(this.getTipElement()).hasClass(f.SHOW))return void this._leave(null,this);this._enter(null,this)}},m.dispose=function(){clearTimeout(this._timeout),e.removeData(this.element,this.constructor.DATA_KEY),e(this.element).off(this.constructor.EVENT_KEY),e(this.element).closest(".modal").off("hide.bs.modal"),this.tip&&e(this.tip).remove(),this._isEnabled=null,this._timeout=null,this._hoverState=null,this._activeTrigger=null,null!==this._popper&&this._popper.destroy(),this._popper=null,this.element=null,this.config=null,this.tip=null},m.show=function(){var t=this;if("none"===e(this.element).css("display"))throw new Error("Please use show on visible elements");var i=e.Event(this.constructor.Event.SHOW);if(this.isWithContent()&&this._isEnabled){e(this.element).trigger(i);var r=e.contains(this.element.ownerDocument.documentElement,this.element);if(i.isDefaultPrevented()||!r)return;var a=this.getTipElement(),l=s.getUID(this.constructor.NAME);a.setAttribute("id",l),this.element.setAttribute("aria-describedby",l),this.setContent(),this.config.animation&&e(a).addClass(f.FADE);var h="function"==typeof this.config.placement?this.config.placement.call(this,a,this.element):this.config.placement,c=this._getAttachment(h);this.addAttachmentClass(c);var d=!1===this.config.container?document.body:e(this.config.container);e(a).data(this.constructor.DATA_KEY,this),e.contains(this.element.ownerDocument.documentElement,this.tip)||e(a).appendTo(d),e(this.element).trigger(this.constructor.Event.INSERTED),this._popper=new n(this.element,a,{placement:c,modifiers:{offset:{offset:this.config.offset},flip:{behavior:this.config.fallbackPlacement},arrow:{element:_.ARROW}},onCreate:function(e){e.originalPlacement!==e.placement&&t._handlePopperPlacementChange(e)},onUpdate:function(e){t._handlePopperPlacementChange(e)}}),e(a).addClass(f.SHOW),"ontouchstart"in document.documentElement&&e("body").children().on("mouseover",null,e.noop);var g=function(){t.config.animation&&t._fixTransition();var n=t._hoverState;t._hoverState=null,e(t.element).trigger(t.constructor.Event.SHOWN),n===u.OUT&&t._leave(null,t)};s.supportsTransitionEnd()&&e(this.tip).hasClass(f.FADE)?e(this.tip).one(s.TRANSITION_END,g).emulateTransitionEnd(o._TRANSITION_DURATION):g()}},m.hide=function(t){var n=this,i=this.getTipElement(),r=e.Event(this.constructor.Event.HIDE),o=function(){n._hoverState!==u.SHOW&&i.parentNode&&i.parentNode.removeChild(i),n._cleanTipClass(),n.element.removeAttribute("aria-describedby"),e(n.element).trigger(n.constructor.Event.HIDDEN),null!==n._popper&&n._popper.destroy(),t&&t()};e(this.element).trigger(r),r.isDefaultPrevented()||(e(i).removeClass(f.SHOW),"ontouchstart"in document.documentElement&&e("body").children().off("mouseover",null,e.noop),this._activeTrigger[g.CLICK]=!1,this._activeTrigger[g.FOCUS]=!1,this._activeTrigger[g.HOVER]=!1,s.supportsTransitionEnd()&&e(this.tip).hasClass(f.FADE)?e(i).one(s.TRANSITION_END,o).emulateTransitionEnd(150):o(),this._hoverState="")},m.update=function(){null!==this._popper&&this._popper.scheduleUpdate()},m.isWithContent=function(){return Boolean(this.getTitle())},m.addAttachmentClass=function(t){e(this.getTipElement()).addClass("bs-tooltip-"+t)},m.getTipElement=function(){return this.tip=this.tip||e(this.config.template)[0],this.tip},m.setContent=function(){var t=e(this.getTipElement());this.setElementContent(t.find(_.TOOLTIP_INNER),this.getTitle()),t.removeClass(f.FADE+" "+f.SHOW)},m.setElementContent=function(t,n){var i=this.config.html;"object"==typeof n&&(n.nodeType||n.jquery)?i?e(n).parent().is(t)||t.empty().append(n):t.text(e(n).text()):t[i?"html":"text"](n)},m.getTitle=function(){var t=this.element.getAttribute("data-original-title");return t||(t="function"==typeof this.config.title?this.config.title.call(this.element):this.config.title),t},m._getAttachment=function(t){return h[t.toUpperCase()]},m._setListeners=function(){var t=this;this.config.trigger.split(" ").forEach(function(n){if("click"===n)e(t.element).on(t.constructor.Event.CLICK,t.config.selector,function(e){return t.toggle(e)});else if(n!==g.MANUAL){var i=n===g.HOVER?t.constructor.Event.MOUSEENTER:t.constructor.Event.FOCUSIN,s=n===g.HOVER?t.constructor.Event.MOUSELEAVE:t.constructor.Event.FOCUSOUT;e(t.element).on(i,t.config.selector,function(e){return t._enter(e)}).on(s,t.config.selector,function(e){return t._leave(e)})}e(t.element).closest(".modal").on("hide.bs.modal",function(){return t.hide()})}),this.config.selector?this.config=e.extend({},this.config,{trigger:"manual",selector:""}):this._fixTitle()},m._fixTitle=function(){var t=typeof this.element.getAttribute("data-original-title");(this.element.getAttribute("title")||"string"!==t)&&(this.element.setAttribute("data-original-title",this.element.getAttribute("title")||""),this.element.setAttribute("title",""))},m._enter=function(t,n){var i=this.constructor.DATA_KEY;(n=n||e(t.currentTarget).data(i))||(n=new this.constructor(t.currentTarget,this._getDelegateConfig()),e(t.currentTarget).data(i,n)),t&&(n._activeTrigger["focusin"===t.type?g.FOCUS:g.HOVER]=!0),e(n.getTipElement()).hasClass(f.SHOW)||n._hoverState===u.SHOW?n._hoverState=u.SHOW:(clearTimeout(n._timeout),n._hoverState=u.SHOW,n.config.delay&&n.config.delay.show?n._timeout=setTimeout(function(){n._hoverState===u.SHOW&&n.show()},n.config.delay.show):n.show())},m._leave=function(t,n){var i=this.constructor.DATA_KEY;(n=n||e(t.currentTarget).data(i))||(n=new this.constructor(t.currentTarget,this._getDelegateConfig()),e(t.currentTarget).data(i,n)),t&&(n._activeTrigger["focusout"===t.type?g.FOCUS:g.HOVER]=!1),n._isWithActiveTrigger()||(clearTimeout(n._timeout),n._hoverState=u.OUT,n.config.delay&&n.config.delay.hide?n._timeout=setTimeout(function(){n._hoverState===u.OUT&&n.hide()},n.config.delay.hide):n.hide())},m._isWithActiveTrigger=function(){for(var t in this._activeTrigger)if(this._activeTrigger[t])return!0;return!1},m._getConfig=function(n){return"number"==typeof(n=e.extend({},this.constructor.Default,e(this.element).data(),n)).delay&&(n.delay={show:n.delay,hide:n.delay}),"number"==typeof n.title&&(n.title=n.title.toString()),"number"==typeof n.content&&(n.content=n.content.toString()),s.typeCheckConfig(t,n,this.constructor.DefaultType),n},m._getDelegateConfig=function(){var t={};if(this.config)for(var e in this.config)this.constructor.Default[e]!==this.config[e]&&(t[e]=this.config[e]);return t},m._cleanTipClass=function(){var t=e(this.getTipElement()),n=t.attr("class").match(a);null!==n&&n.length>0&&t.removeClass(n.join(""))},m._handlePopperPlacementChange=function(t){this._cleanTipClass(),this.addAttachmentClass(this._getAttachment(t.placement))},m._fixTransition=function(){var t=this.getTipElement(),n=this.config.animation;null===t.getAttribute("x-placement")&&(e(t).removeClass(f.FADE),this.config.animation=!1,this.hide(),this.show(),this.config.animation=n)},o._jQueryInterface=function(t){return this.each(function(){var n=e(this).data("bs.tooltip"),i="object"==typeof t&&t;if((n||!/dispose|hide/.test(t))&&(n||(n=new o(this,i),e(this).data("bs.tooltip",n)),"string"==typeof t)){if("undefined"==typeof n[t])throw new Error('No method named "'+t+'"');n[t]()}})},r(o,null,[{key:"VERSION",get:function(){return"4.0.0-beta.2"}},{key:"Default",get:function(){return c}},{key:"NAME",get:function(){return t}},{key:"DATA_KEY",get:function(){return"bs.tooltip"}},{key:"Event",get:function(){return d}},{key:"EVENT_KEY",get:function(){return i}},{key:"DefaultType",get:function(){return l}}]),o}();return e.fn[t]=m._jQueryInterface,e.fn[t].Constructor=m,e.fn[t].noConflict=function(){return e.fn[t]=o,m._jQueryInterface},m}(),_=function(){var t="popover",n=".bs.popover",i=e.fn[t],s=new RegExp("(^|\\s)bs-popover\\S+","g"),a=e.extend({},f.Default,{placement:"right",trigger:"click",content:"",template:'
'}),l=e.extend({},f.DefaultType,{content:"(string|element|function)"}),h={FADE:"fade",SHOW:"show"},c={TITLE:".popover-header",CONTENT:".popover-body"},u={HIDE:"hide"+n,HIDDEN:"hidden"+n,SHOW:"show"+n,SHOWN:"shown"+n,INSERTED:"inserted"+n,CLICK:"click"+n,FOCUSIN:"focusin"+n,FOCUSOUT:"focusout"+n,MOUSEENTER:"mouseenter"+n,MOUSELEAVE:"mouseleave"+n},d=function(i){function d(){return i.apply(this,arguments)||this}o(d,i);var f=d.prototype;return f.isWithContent=function(){return this.getTitle()||this._getContent()},f.addAttachmentClass=function(t){e(this.getTipElement()).addClass("bs-popover-"+t)},f.getTipElement=function(){return this.tip=this.tip||e(this.config.template)[0],this.tip},f.setContent=function(){var t=e(this.getTipElement());this.setElementContent(t.find(c.TITLE),this.getTitle()),this.setElementContent(t.find(c.CONTENT),this._getContent()),t.removeClass(h.FADE+" "+h.SHOW)},f._getContent=function(){return this.element.getAttribute("data-content")||("function"==typeof this.config.content?this.config.content.call(this.element):this.config.content)},f._cleanTipClass=function(){var t=e(this.getTipElement()),n=t.attr("class").match(s);null!==n&&n.length>0&&t.removeClass(n.join(""))},d._jQueryInterface=function(t){return this.each(function(){var n=e(this).data("bs.popover"),i="object"==typeof t?t:null;if((n||!/destroy|hide/.test(t))&&(n||(n=new d(this,i),e(this).data("bs.popover",n)),"string"==typeof t)){if("undefined"==typeof n[t])throw new Error('No method named "'+t+'"');n[t]()}})},r(d,null,[{key:"VERSION",get:function(){return"4.0.0-beta.2"}},{key:"Default",get:function(){return a}},{key:"NAME",get:function(){return t}},{key:"DATA_KEY",get:function(){return"bs.popover"}},{key:"Event",get:function(){return u}},{key:"EVENT_KEY",get:function(){return n}},{key:"DefaultType",get:function(){return l}}]),d}(f);return e.fn[t]=d._jQueryInterface,e.fn[t].Constructor=d,e.fn[t].noConflict=function(){return e.fn[t]=i,d._jQueryInterface},d}(),g=function(){var t="scrollspy",n=e.fn[t],i={offset:10,method:"auto",target:""},o={offset:"number",method:"string",target:"(string|element)"},a={ACTIVATE:"activate.bs.scrollspy",SCROLL:"scroll.bs.scrollspy",LOAD_DATA_API:"load.bs.scrollspy.data-api"},l={DROPDOWN_ITEM:"dropdown-item",DROPDOWN_MENU:"dropdown-menu",ACTIVE:"active"},h={DATA_SPY:'[data-spy="scroll"]',ACTIVE:".active",NAV_LIST_GROUP:".nav, .list-group",NAV_LINKS:".nav-link",NAV_ITEMS:".nav-item",LIST_ITEMS:".list-group-item",DROPDOWN:".dropdown",DROPDOWN_ITEMS:".dropdown-item",DROPDOWN_TOGGLE:".dropdown-toggle"},c={OFFSET:"offset",POSITION:"position"},u=function(){function n(t,n){var i=this;this._element=t,this._scrollElement="BODY"===t.tagName?window:t,this._config=this._getConfig(n),this._selector=this._config.target+" "+h.NAV_LINKS+","+this._config.target+" "+h.LIST_ITEMS+","+this._config.target+" "+h.DROPDOWN_ITEMS,this._offsets=[],this._targets=[],this._activeTarget=null,this._scrollHeight=0,e(this._scrollElement).on(a.SCROLL,function(t){return i._process(t)}),this.refresh(),this._process()}var u=n.prototype;return u.refresh=function(){var t=this,n=this._scrollElement!==this._scrollElement.window?c.POSITION:c.OFFSET,i="auto"===this._config.method?n:this._config.method,r=i===c.POSITION?this._getScrollTop():0;this._offsets=[],this._targets=[],this._scrollHeight=this._getScrollHeight(),e.makeArray(e(this._selector)).map(function(t){var n,o=s.getSelectorFromElement(t);if(o&&(n=e(o)[0]),n){var a=n.getBoundingClientRect();if(a.width||a.height)return[e(n)[i]().top+r,o]}return null}).filter(function(t){return t}).sort(function(t,e){return t[0]-e[0]}).forEach(function(e){t._offsets.push(e[0]),t._targets.push(e[1])})},u.dispose=function(){e.removeData(this._element,"bs.scrollspy"),e(this._scrollElement).off(".bs.scrollspy"),this._element=null,this._scrollElement=null,this._config=null,this._selector=null,this._offsets=null,this._targets=null,this._activeTarget=null,this._scrollHeight=null},u._getConfig=function(n){if("string"!=typeof(n=e.extend({},i,n)).target){var r=e(n.target).attr("id");r||(r=s.getUID(t),e(n.target).attr("id",r)),n.target="#"+r}return s.typeCheckConfig(t,n,o),n},u._getScrollTop=function(){return this._scrollElement===window?this._scrollElement.pageYOffset:this._scrollElement.scrollTop},u._getScrollHeight=function(){return this._scrollElement.scrollHeight||Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)},u._getOffsetHeight=function(){return this._scrollElement===window?window.innerHeight:this._scrollElement.getBoundingClientRect().height},u._process=function(){var t=this._getScrollTop()+this._config.offset,e=this._getScrollHeight(),n=this._config.offset+e-this._getOffsetHeight();if(this._scrollHeight!==e&&this.refresh(),t>=n){var i=this._targets[this._targets.length-1];this._activeTarget!==i&&this._activate(i)}else{if(this._activeTarget&&t