diff --git a/.gitignore b/.gitignore index dfcfd56..1ee5385 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ mono_crash.* [Rr]eleases/ x64/ x86/ +[Ww][Ii][Nn]32/ [Aa][Rr][Mm]/ [Aa][Rr][Mm]64/ bld/ @@ -61,6 +62,9 @@ project.lock.json project.fragment.lock.json artifacts/ +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + # StyleCop StyleCopReport.xml @@ -137,6 +141,11 @@ _TeamCity* .axoCover/* !.axoCover/settings.json +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + # Visual Studio code coverage results *.coverage *.coveragexml @@ -348,3 +357,6 @@ MigrationBackup/ # Ionide (cross platform F# VS Code tools) working folder .ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd diff --git a/MarkdownEditor.sln b/MarkdownEditor.sln index 058353d..e23fde2 100644 --- a/MarkdownEditor.sln +++ b/MarkdownEditor.sln @@ -1,12 +1,19 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.31729.503 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.32014.148 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PSC.Blazor.Components.MarkdownEditor", "PSC.Blazor.Components.MarkdownEditor\PSC.Blazor.Components.MarkdownEditor.csproj", "{6F56954A-A45C-432C-9F63-699D15042667}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MarkdownEditorDemo", "MarkdownEditorDemo\MarkdownEditorDemo.csproj", "{4A71D48E-5A73-49F6-B813-2919DB84DC29}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MarkdownEditorDemo.Api", "MarkdownEditorDemo.Api\MarkdownEditorDemo.Api.csproj", "{9771B329-8344-4839-81D5-78B9F9AA79F4}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Other files", "Other files", "{E62D6583-788F-4BDE-833F-6EE650453874}" + ProjectSection(SolutionItems) = preProject + README.md = README.md + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -21,6 +28,10 @@ Global {4A71D48E-5A73-49F6-B813-2919DB84DC29}.Debug|Any CPU.Build.0 = Debug|Any CPU {4A71D48E-5A73-49F6-B813-2919DB84DC29}.Release|Any CPU.ActiveCfg = Release|Any CPU {4A71D48E-5A73-49F6-B813-2919DB84DC29}.Release|Any CPU.Build.0 = Release|Any CPU + {9771B329-8344-4839-81D5-78B9F9AA79F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9771B329-8344-4839-81D5-78B9F9AA79F4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9771B329-8344-4839-81D5-78B9F9AA79F4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9771B329-8344-4839-81D5-78B9F9AA79F4}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/MarkdownEditorDemo.Api/Controllers/FilesController.cs b/MarkdownEditorDemo.Api/Controllers/FilesController.cs new file mode 100644 index 0000000..2c76b69 --- /dev/null +++ b/MarkdownEditorDemo.Api/Controllers/FilesController.cs @@ -0,0 +1,112 @@ +namespace MarkdownEditorDemo.Api.Controllers; + +/// +/// Files controller +/// +[ApiController] +[Route("api/[Controller]")] +public class FilesController : ControllerBase +{ + /// + /// The logger + /// + private readonly ILogger _logger; + /// + /// The HTTP context accessor + /// + private readonly IHttpContextAccessor _httpContextAccessor; + /// + /// The file size limit + /// + private readonly long _fileSizeLimit; + /// + /// The permitted extensions + /// + private readonly string[] _permittedExtensions = { ".gif", ".png", ".jpg", ".jpeg" }; + /// + /// The target folder path + /// + private readonly string _targetFolderPath; + + /// + /// Initializes a new instance of the class. + /// + /// The logger. + /// The configuration. + public FilesController(ILogger logger, IConfiguration config, IHttpContextAccessor httpContextAccessor) + { + _logger = logger; + _httpContextAccessor = httpContextAccessor; + + _fileSizeLimit = config.GetValue("FileSizeLimit"); + _targetFolderPath = (string)System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase); + _targetFolderPath = Path.Combine(_targetFolderPath, "Uploads").Replace("file:\\", ""); + + Directory.CreateDirectory(_targetFolderPath); + } + + /// + /// Uploads a file. + /// + /// + [HttpPost] + [DisableFormValueModelBinding] + public async Task Upload() + { + if (!Request.ContentType.IsMultipartContentType()) + { + ModelState.AddModelError("File", "The request couldn't be processed (Error 1)."); + _logger.LogWarning($"The request content type [{Request.ContentType}] is invalid."); + return BadRequest(ModelState); + } + + var boundary = MediaTypeHeaderValue.Parse(Request.ContentType).GetBoundary(new FormOptions().MultipartBoundaryLengthLimit); + var reader = new MultipartReader(boundary, HttpContext.Request.Body); + var section = await reader.ReadNextSectionAsync(); + + string trustedFileNameForFileStorage = String.Empty; + + while (section != null) + { + var hasContentDispositionHeader = ContentDispositionHeaderValue.TryParse(section.ContentDisposition, + out var contentDisposition); + + if (hasContentDispositionHeader) + { + if (contentDisposition.IsFileDisposition()) + { + // Don't trust the file name sent by the client. To display the file name, HTML-encode the value. + var trustedFileNameForDisplay = WebUtility.HtmlEncode(contentDisposition.FileName.Value); + trustedFileNameForFileStorage = Path.GetFileNameWithoutExtension(Path.GetRandomFileName()) + + Path.GetExtension(trustedFileNameForDisplay); + + var streamedFileContent = await FileHelpers.ProcessStreamedFile(section, contentDisposition, + ModelState, _permittedExtensions, _fileSizeLimit); + + if (!ModelState.IsValid) + return BadRequest(ModelState); + + var trustedFilePath = Path.Combine(_targetFolderPath, trustedFileNameForFileStorage); + using (var targetStream = System.IO.File.Create(trustedFilePath)) + { + await targetStream.WriteAsync(streamedFileContent); + _logger.LogInformation($"Uploaded file '{trustedFileNameForDisplay}' saved to '{_targetFolderPath}' " + + $"as {trustedFileNameForFileStorage}"); + } + } + } + + // Drain any remaining section body that hasn't been consumed and read the headers for the next section. + section = await reader.ReadNextSectionAsync(); + } + + if (!string.IsNullOrEmpty(trustedFileNameForFileStorage)) + { + string host = $"{_httpContextAccessor.HttpContext.Request.Scheme}://{_httpContextAccessor.HttpContext.Request.Host.Value}"; + int index = FileHelpers.GetExtensionId(Path.GetExtension(trustedFileNameForFileStorage)); + return Ok($"{host}/{index}/{Path.GetFileName(trustedFileNameForFileStorage)}"); + } + else + return BadRequest("It wasn't possible to upload the file"); + } +} \ No newline at end of file diff --git a/MarkdownEditorDemo.Api/Controllers/HomeController.cs b/MarkdownEditorDemo.Api/Controllers/HomeController.cs new file mode 100644 index 0000000..3ff568c --- /dev/null +++ b/MarkdownEditorDemo.Api/Controllers/HomeController.cs @@ -0,0 +1,56 @@ +namespace MarkdownEditorDemo.Api.Controllers +{ + public class HomeController : Controller + { + /// + /// The logger + /// + private readonly ILogger _logger; + /// + /// The target folder path + /// + private readonly string _targetFolderPath; + + /// + /// Initializes a new instance of the class. + /// + /// The logger. + /// The configuration. + public HomeController(ILogger logger, IConfiguration config) + { + _logger = logger; + + _targetFolderPath = (string)System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().CodeBase); + _targetFolderPath = Path.Combine(_targetFolderPath, "Uploads"); + } + + [HttpGet] + [Route("{fileType}/{fileName}")] + public async Task Download(int fileType, string fileName) + { + string ext = FileHelpers.GetExtensionById(fileType); + if (ext == null) + { + _logger.LogInformation($"Extension not found."); + return BadRequest($"Extension not found."); + } + + if(ext != Path.GetExtension(fileName)) + { + _logger.LogInformation($"File not valid."); + return BadRequest($"File not valid."); + } + + var trustedFilePath = Path.Combine(_targetFolderPath, fileName).Replace("file:\\", ""); + if (!System.IO.File.Exists(trustedFilePath)) + { + _logger.LogInformation($"File {trustedFilePath} not exists"); + return NotFound($"File {trustedFilePath} not exists"); + } + + _logger.LogInformation($"Downloading file [{trustedFilePath}]."); + var bytes = await System.IO.File.ReadAllBytesAsync(trustedFilePath); + return File(bytes, ext.GetMimeTypes(), trustedFilePath); + } + } +} diff --git a/MarkdownEditorDemo.Api/Controllers/ImageController.cs b/MarkdownEditorDemo.Api/Controllers/ImageController.cs new file mode 100644 index 0000000..3c7ca07 --- /dev/null +++ b/MarkdownEditorDemo.Api/Controllers/ImageController.cs @@ -0,0 +1,59 @@ +using Microsoft.AspNetCore.Mvc; + +namespace MarkdownEditorDemo.Api.Controllers +{ + [ApiController] + [Route("api/[controller]")] + public class ImageController : Controller + { + [HttpPost] + public async Task Upload(IFormFile files) + { + long size = files.Length; + + var filePath = Path.GetTempFileName(); + + using (var stream = System.IO.File.Create(filePath)) + { + await files.CopyToAsync(stream); + } + + // Process uploaded files + // Don't rely on or trust the FileName property without validation. + + return Ok(); + + //// Check if thefile is there + //if (file == null) + // return BadRequest("File is required"); + + //// Get the file name + //var fileName = file.FileName; + + //// Get the extension + //var extension = Path.GetExtension(fileName); + + //// Validate the extension based on your business needs + + //// Generate a new file to avoid dublicates = (FileName withoutExtension - GUId.extension) + //var newFileName = $"{Path.GetFileNameWithoutExtension(fileName)}-{Guid.NewGuid().ToString()}{extension}"; + + //// Create the full path of the file including the directory (For this demo we will save the file insidea folder called Data within wwwroot) + //var directoryPath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot", "Data"); + //var fullPath = Path.Combine(directoryPath, newFileName); + + //// Maek sure the directory is ther bycreating it if it's not exist + //Directory.CreateDirectory(directoryPath); + + //// Create a new file stream where you want to put your file and copy the content from the current file stream to the new one + //using (var fileStream = new FileStream(fullPath, FileMode.Create, FileAccess.Write)) + //{ + // // Copy the content to the new stream + // await file.CopyToAsync(fileStream); + //} + + //// You are done return the new URL which is (yourapplication url/data/newfilename) + //return Ok($"https://localhost:44302/Data/{newFileName}"); + } + } +} \ No newline at end of file diff --git a/MarkdownEditorDemo.Api/Extensions/MultipartRequestExtensions.cs b/MarkdownEditorDemo.Api/Extensions/MultipartRequestExtensions.cs new file mode 100644 index 0000000..6ac440a --- /dev/null +++ b/MarkdownEditorDemo.Api/Extensions/MultipartRequestExtensions.cs @@ -0,0 +1,25 @@ +namespace MarkdownEditorDemo.Api.Extensions; + +public static class MultipartRequestExtensions +{ + // Content-Type: multipart/form-data; boundary="----WebKitFormBoundarymx2fSWqWSd0OxQqq" + // The spec at https://tools.ietf.org/html/rfc2046#section-5.1 states that 70 characters is a reasonable limit. + public static string GetBoundary(this MediaTypeHeaderValue contentType, int lengthLimit) + { + var boundary = HeaderUtilities.RemoveQuotes(contentType.Boundary).Value; + + if (string.IsNullOrWhiteSpace(boundary)) + throw new InvalidDataException("Missing content-type boundary."); + + if (boundary.Length > lengthLimit) + throw new InvalidDataException($"Multipart boundary length limit {lengthLimit} exceeded."); + + return boundary; + } + + public static bool IsMultipartContentType(this string contentType) + { + return !string.IsNullOrEmpty(contentType) + && contentType.IndexOf("multipart/", StringComparison.OrdinalIgnoreCase) >= 0; + } +} \ No newline at end of file diff --git a/MarkdownEditorDemo.Api/Extensions/StringExtensions.cs b/MarkdownEditorDemo.Api/Extensions/StringExtensions.cs new file mode 100644 index 0000000..3f36d67 --- /dev/null +++ b/MarkdownEditorDemo.Api/Extensions/StringExtensions.cs @@ -0,0 +1,31 @@ +namespace MarkdownEditorDemo.Api.Extensions +{ + public static class StringExtensions + { + /// + /// Gets the MIME types. + /// + /// The ext. + /// + public static string GetMimeTypes(this string ext) + { + switch (ext) + { + case ".txt": return "text/plain"; + case ".csv": return "text/csv"; + case ".pdf": return "application/pdf"; + case ".doc": return "application/vnd.ms-word"; + case ".xls": return "application/vnd.ms-excel"; + case ".ppt": return "application/vnd.ms-powerpoint"; + case ".docx": return "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; + case ".xlsx": return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; + case ".pptx": return "application/vnd.openxmlformats-officedocument.presentationml.presentation"; + case ".png": return "image/png"; + case ".jpg": return "image/jpeg"; + case ".jpeg": return "image/jpeg"; + case ".gif": return "image/gif"; + default: return "application/octet-stream"; + } + } + } +} \ No newline at end of file diff --git a/MarkdownEditorDemo.Api/Filters/ModelBinding.cs b/MarkdownEditorDemo.Api/Filters/ModelBinding.cs new file mode 100644 index 0000000..2d5efb2 --- /dev/null +++ b/MarkdownEditorDemo.Api/Filters/ModelBinding.cs @@ -0,0 +1,21 @@ +using Microsoft.AspNetCore.Mvc.Filters; +using Microsoft.AspNetCore.Mvc.ModelBinding; + +namespace MarkdownEditorDemo.Api.Filters +{ + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)] + public class DisableFormValueModelBindingAttribute : Attribute, IResourceFilter + { + public void OnResourceExecuting(ResourceExecutingContext context) + { + var factories = context.ValueProviderFactories; + factories.RemoveType(); + factories.RemoveType(); + factories.RemoveType(); + } + + public void OnResourceExecuted(ResourceExecutedContext context) + { + } + } +} diff --git a/MarkdownEditorDemo.Api/GlobalUsing.cs b/MarkdownEditorDemo.Api/GlobalUsing.cs new file mode 100644 index 0000000..37fd88e --- /dev/null +++ b/MarkdownEditorDemo.Api/GlobalUsing.cs @@ -0,0 +1,8 @@ +global using MarkdownEditorDemo.Api.Extensions; +global using MarkdownEditorDemo.Api.Filters; +global using MarkdownEditorDemo.Api.Utilities; +global using Microsoft.AspNetCore.Http.Features; +global using Microsoft.AspNetCore.Mvc; +global using Microsoft.AspNetCore.WebUtilities; +global using Microsoft.Net.Http.Headers; +global using System.Net; \ No newline at end of file diff --git a/MarkdownEditorDemo.Api/MarkdownEditorDemo.Api.csproj b/MarkdownEditorDemo.Api/MarkdownEditorDemo.Api.csproj new file mode 100644 index 0000000..e712599 --- /dev/null +++ b/MarkdownEditorDemo.Api/MarkdownEditorDemo.Api.csproj @@ -0,0 +1,14 @@ + + + + net6.0 + enable + enable + + + + + + + + diff --git a/MarkdownEditorDemo.Api/Program.cs b/MarkdownEditorDemo.Api/Program.cs new file mode 100644 index 0000000..750fd58 --- /dev/null +++ b/MarkdownEditorDemo.Api/Program.cs @@ -0,0 +1,43 @@ +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. + +builder.Services.AddControllers(); +// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle +builder.Services.AddEndpointsApiExplorer(); +builder.Services.AddSwaggerGen(); +builder.Services.AddApplicationInsightsTelemetry(); + +builder.Services.AddSingleton(); + +// Add CORS +var MyAllowSpecificOrigins = "_myAllowSpecificOrigins"; +builder.Services.AddCors(options => +{ + options.AddPolicy(name: MyAllowSpecificOrigins, + builder => + { + builder.AllowAnyOrigin() + .AllowAnyMethod() + .AllowAnyHeader(); + }); +}); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.UseSwagger(); + app.UseSwaggerUI(); +} + +app.UseHttpsRedirection(); + +app.UseAuthorization(); + +app.UseCors(MyAllowSpecificOrigins); + +app.MapControllers(); + +app.Run(); diff --git a/MarkdownEditorDemo.Api/Properties/launchSettings.json b/MarkdownEditorDemo.Api/Properties/launchSettings.json new file mode 100644 index 0000000..00ba441 --- /dev/null +++ b/MarkdownEditorDemo.Api/Properties/launchSettings.json @@ -0,0 +1,31 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:3845", + "sslPort": 44304 + } + }, + "profiles": { + "MarkdownEditorDemo.Api": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7013;http://localhost:5013", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/MarkdownEditorDemo.Api/Properties/serviceDependencies.json b/MarkdownEditorDemo.Api/Properties/serviceDependencies.json new file mode 100644 index 0000000..c264e8c --- /dev/null +++ b/MarkdownEditorDemo.Api/Properties/serviceDependencies.json @@ -0,0 +1,7 @@ +{ + "dependencies": { + "appInsights1": { + "type": "appInsights" + } + } +} \ No newline at end of file diff --git a/MarkdownEditorDemo.Api/Properties/serviceDependencies.local.json b/MarkdownEditorDemo.Api/Properties/serviceDependencies.local.json new file mode 100644 index 0000000..5a956e8 --- /dev/null +++ b/MarkdownEditorDemo.Api/Properties/serviceDependencies.local.json @@ -0,0 +1,7 @@ +{ + "dependencies": { + "appInsights1": { + "type": "appInsights.sdk" + } + } +} \ No newline at end of file diff --git a/MarkdownEditorDemo.Api/Utilities/FileHelpers.cs b/MarkdownEditorDemo.Api/Utilities/FileHelpers.cs new file mode 100644 index 0000000..603cc91 --- /dev/null +++ b/MarkdownEditorDemo.Api/Utilities/FileHelpers.cs @@ -0,0 +1,194 @@ +using Microsoft.AspNetCore.Mvc.ModelBinding; + +namespace MarkdownEditorDemo.Api.Utilities +{ + /// + /// FileHelpers + /// + public static class FileHelpers + { + // If you require a check on specific characters in the IsValidFileExtensionAndSignature + // method, supply the characters in the _allowedChars field. + private static readonly byte[] AllowedChars = { }; + + // For more file signatures, see the File Signatures Database (https://www.filesignatures.net/) + // and the official specifications for the file types you wish to add. + private static readonly Dictionary> FileSignature = new Dictionary> + { + { ".gif", new List { + new byte[] { 0x47, 0x49, 0x46, 0x38 } } + }, + { ".png", new List { + new byte[] { 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A } } + }, + { ".jpeg", new List + { + new byte[] { 0xFF, 0xD8, 0xFF, 0xE0 }, + new byte[] { 0xFF, 0xD8, 0xFF, 0xE2 }, + new byte[] { 0xFF, 0xD8, 0xFF, 0xE3 }, + } + }, + { ".jpg", new List + { + new byte[] { 0xFF, 0xD8, 0xFF, 0xE0 }, + new byte[] { 0xFF, 0xD8, 0xFF, 0xE1 }, + new byte[] { 0xFF, 0xD8, 0xFF, 0xE8 }, + } + }, + { ".zip", new List + { + new byte[] { 0x50, 0x4B, 0x03, 0x04 }, + new byte[] { 0x50, 0x4B, 0x4C, 0x49, 0x54, 0x45 }, + new byte[] { 0x50, 0x4B, 0x53, 0x70, 0x58 }, + new byte[] { 0x50, 0x4B, 0x05, 0x06 }, + new byte[] { 0x50, 0x4B, 0x07, 0x08 }, + new byte[] { 0x57, 0x69, 0x6E, 0x5A, 0x69, 0x70 }, + } + }, + }; + + /// + /// Gets the extension identifier. + /// + /// The extension. + /// + public static int GetExtensionId(this string extension) + { + for (int i = 0; i < FileSignature.Count; ++i) + { + if (FileSignature.ElementAt(i).Key == extension) + return i; + } + return -1; + } + + /// + /// Gets the extension by identifier. + /// + /// The identifier. + /// + public static string GetExtensionById(this int id) + { + if (id >= 0 && id <= FileSignature.Count) + return FileSignature.ElementAt(id).Key; + else + return null; + } + + /// + /// Gets the byte[] from the MemoryStream for a file + /// + /// + /// + /// + /// + /// + /// + public static async Task ProcessStreamedFile( + MultipartSection section, ContentDispositionHeaderValue contentDisposition, + ModelStateDictionary modelState, string[] permittedExtensions, long sizeLimit) + { + try + { + using (var memoryStream = new MemoryStream()) + { + await section.Body.CopyToAsync(memoryStream); + + // Check if the file is empty or exceeds the size limit. + if (memoryStream.Length == 0) + modelState.AddModelError("File", "The file is empty."); + else if (memoryStream.Length > sizeLimit) + { + var megabyteSizeLimit = sizeLimit / 1048576; + modelState.AddModelError("File", $"The file exceeds {megabyteSizeLimit:N1} MB."); + } + else if (!IsValidFileExtensionAndSignature(contentDisposition.FileName.Value, memoryStream, permittedExtensions)) + modelState.AddModelError("File", "The file type isn't permitted or the file's signature doesn't match the file's extension."); + else + return memoryStream.ToArray(); + } + } + catch (Exception ex) + { + modelState.AddModelError("File", $"The upload failed. Please contact the Help Desk for support. Error: {ex.HResult}"); + } + + return new byte[0]; + } + + private static bool IsValidFileExtensionAndSignature(string fileName, Stream data, IEnumerable permittedExtensions) + { + if (string.IsNullOrEmpty(fileName) || data == null || data.Length == 0) + { + return false; + } + + var ext = Path.GetExtension(fileName).ToLowerInvariant(); + + if (string.IsNullOrEmpty(ext) || !permittedExtensions.Contains(ext)) + { + return false; + } + + data.Position = 0; + + using (var reader = new BinaryReader(data)) + { + if (ext.Equals(".txt") || ext.Equals(".csv") || ext.Equals(".prn")) + { + if (AllowedChars.Length == 0) + { + // Limits characters to ASCII encoding. + for (var i = 0; i < data.Length; i++) + { + if (reader.ReadByte() > sbyte.MaxValue) + { + return false; + } + } + } + else + { + // Limits characters to ASCII encoding and + // values of the _allowedChars array. + for (var i = 0; i < data.Length; i++) + { + var b = reader.ReadByte(); + if (b > sbyte.MaxValue || + !AllowedChars.Contains(b)) + { + return false; + } + } + } + + return true; + } + + // Uncomment the following code block if you must permit + // files whose signature isn't provided in the _fileSignature + // dictionary. We recommend that you add file signatures + // for files (when possible) for all file types you intend + // to allow on the system and perform the file signature + // check. + /* + if (!_fileSignature.ContainsKey(ext)) + { + return true; + } + */ + + // File signature check + // -------------------- + // With the file signatures provided in the _fileSignature + // dictionary, the following code tests the input content's + // file signature. + var signatures = FileSignature[ext]; + var headerBytes = reader.ReadBytes(signatures.Max(m => m.Length)); + + return signatures.Any(signature => + headerBytes.Take(signature.Length).SequenceEqual(signature)); + } + } + } +} \ No newline at end of file diff --git a/MarkdownEditorDemo.Api/WeatherForecast.cs b/MarkdownEditorDemo.Api/WeatherForecast.cs new file mode 100644 index 0000000..b98e38f --- /dev/null +++ b/MarkdownEditorDemo.Api/WeatherForecast.cs @@ -0,0 +1,13 @@ +namespace MarkdownEditorDemo.Api +{ + public class WeatherForecast + { + public DateTime Date { get; set; } + + public int TemperatureC { get; set; } + + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); + + public string? Summary { get; set; } + } +} \ No newline at end of file diff --git a/MarkdownEditorDemo.Api/appsettings.Development.json b/MarkdownEditorDemo.Api/appsettings.Development.json new file mode 100644 index 0000000..0c208ae --- /dev/null +++ b/MarkdownEditorDemo.Api/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/MarkdownEditorDemo.Api/appsettings.json b/MarkdownEditorDemo.Api/appsettings.json new file mode 100644 index 0000000..f726d3b --- /dev/null +++ b/MarkdownEditorDemo.Api/appsettings.json @@ -0,0 +1,11 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Debug", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*", + "StoredFilesPath": "C:\\Projects\\TmpImageMDE", + "FileSizeLimit": 2097152 +} diff --git a/MarkdownEditorDemo/MarkdownEditorDemo.csproj b/MarkdownEditorDemo/MarkdownEditorDemo.csproj index a6bac62..84eafd2 100644 --- a/MarkdownEditorDemo/MarkdownEditorDemo.csproj +++ b/MarkdownEditorDemo/MarkdownEditorDemo.csproj @@ -1,14 +1,14 @@ - net5.0 + net6.0 service-worker-assets.js - - - + + + diff --git a/MarkdownEditorDemo/Models/FormData.cs b/MarkdownEditorDemo/Models/FormData.cs index 1a1a8b5..0728e10 100644 --- a/MarkdownEditorDemo/Models/FormData.cs +++ b/MarkdownEditorDemo/Models/FormData.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace MarkdownEditorDemo.Models +namespace MarkdownEditorDemo.Models { public class FormData { diff --git a/MarkdownEditorDemo/Pages/Index.razor b/MarkdownEditorDemo/Pages/Index.razor index c248e32..561f5e2 100644 --- a/MarkdownEditorDemo/Pages/Index.razor +++ b/MarkdownEditorDemo/Pages/Index.razor @@ -1,14 +1,38 @@ @page "/" - - - +
+ -@code { - FormData form = new FormData(); +
- private void DoSave() +

Result

+ @((MarkupString)markdownHtml) +
+ +@code { + string markdownValue = "# Markdown Editor for Blazor\nThis component is using [EasyMDE](https://easy-markdown-editor.tk/) " + + "to display a nice editor and all functionalities are mapped. See the documentation for more details.\n\n" + + "Go ahead, play around with the editor! Be sure to check out **bold**, *italic*, " + + "[links](https://google.com) and all the other features. " + + "You can type the Markdown syntax, use the toolbar, or use shortcuts like `ctrl-b` or `cmd-b`."; + string markdownHtml; + + protected override void OnInitialized() { + markdownHtml = Markdig.Markdown.ToHtml(markdownValue ?? string.Empty); + base.OnInitialized(); + } + Task OnMarkdownValueChanged(string value) + { + return Task.CompletedTask; + } + + Task OnMarkdownValueHTMLChanged(string value) + { + markdownHtml = value; + return Task.CompletedTask; } -} +} \ No newline at end of file diff --git a/MarkdownEditorDemo/Pages/Upload.razor b/MarkdownEditorDemo/Pages/Upload.razor new file mode 100644 index 0000000..1727746 --- /dev/null +++ b/MarkdownEditorDemo/Pages/Upload.razor @@ -0,0 +1,71 @@ +@page "/upload" +@using PSC.Blazor.Components.MarkdownEditor.Models +@using System.Net.Http.Headers + +
+ + +
+ +

Result

+ @((MarkupString)markdownHtml) +
+ +@code { + string markdownValue = "# Markdown Editor for Blazor\nThis component is using [EasyMDE](https://easy-markdown-editor.tk/) " + + "to display a nice editor and all functionalities are mapped. See the documentation for more details.\n\n" + + "Go ahead, play around with the editor! Be sure to check out **bold**, *italic*, " + + "[links](https://google.com) and all the other features. " + + "You can type the Markdown syntax, use the toolbar, or use shortcuts like `ctrl-b` or `cmd-b`."; + string markdownHtml; + + protected override void OnInitialized() + { + markdownHtml = Markdig.Markdown.ToHtml(markdownValue ?? string.Empty); + + base.OnInitialized(); + } + + Task OnMarkdownValueChanged(string value) + { + markdownValue = value; + return Task.CompletedTask; + } + + async Task OnImageUploadChanged(FileChangedEventArgs e) + { + this.StateHasChanged(); + } + + Task OnImageUploadStarted(FileStartedEventArgs e) + { + Console.WriteLine($"Started Image: {e.File.Name}"); + return Task.CompletedTask; + } + + Task OnImageUploadProgressed(FileProgressedEventArgs e) + { + Console.WriteLine($"Image: {e.File.Name} Progress: {(int)e.Percentage}"); + return Task.CompletedTask; + } + + Task OnImageUploadEnded(FileEndedEventArgs e) + { + Console.WriteLine($"Finished Image: {e.File.Name}, Success: {e.Success}"); + return Task.CompletedTask; + } + + Task OnMarkdownValueHTMLChanged(string value) + { + markdownHtml = value; + return Task.CompletedTask; + } +} \ No newline at end of file diff --git a/MarkdownEditorDemo/Program.cs b/MarkdownEditorDemo/Program.cs index 53f6e4d..cd76d10 100644 --- a/MarkdownEditorDemo/Program.cs +++ b/MarkdownEditorDemo/Program.cs @@ -1,11 +1,7 @@ using Microsoft.AspNetCore.Components.WebAssembly.Hosting; -using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; using System; -using System.Collections.Generic; using System.Net.Http; -using System.Text; using System.Threading.Tasks; namespace MarkdownEditorDemo diff --git a/MarkdownEditorDemo/Shared/NavMenu.razor b/MarkdownEditorDemo/Shared/NavMenu.razor index 6299848..298f4dc 100644 --- a/MarkdownEditorDemo/Shared/NavMenu.razor +++ b/MarkdownEditorDemo/Shared/NavMenu.razor @@ -12,6 +12,11 @@ Home + diff --git a/MarkdownEditorDemo/_Imports.razor b/MarkdownEditorDemo/_Imports.razor index 149108d..23b6d8a 100644 --- a/MarkdownEditorDemo/_Imports.razor +++ b/MarkdownEditorDemo/_Imports.razor @@ -9,4 +9,5 @@ @using MarkdownEditorDemo @using MarkdownEditorDemo.Shared @using MarkdownEditorDemo.Models -@using PSC.Blazor.Components.MarkdownEditor \ No newline at end of file +@using PSC.Blazor.Components.MarkdownEditor +@using PSC.Blazor.Components.MarkdownEditor.EventsArgs \ No newline at end of file diff --git a/MarkdownEditorDemo/libman.json b/MarkdownEditorDemo/libman.json index 9ff2cff..1d84ba3 100644 --- a/MarkdownEditorDemo/libman.json +++ b/MarkdownEditorDemo/libman.json @@ -5,6 +5,10 @@ { "library": "font-awesome@5.15.4", "destination": "wwwroot/lib/font-awesome/" + }, + { + "library": "jquery@3.6.0", + "destination": "wwwroot/lib/query/" } ] } \ No newline at end of file diff --git a/MarkdownEditorDemo/wwwroot/css/app.css b/MarkdownEditorDemo/wwwroot/css/app.css index 82fc22a..061e702 100644 --- a/MarkdownEditorDemo/wwwroot/css/app.css +++ b/MarkdownEditorDemo/wwwroot/css/app.css @@ -48,3 +48,16 @@ a, .btn-link { right: 0.75rem; top: 0.5rem; } + +img { + max-width: 100%; +} + +table { + margin-bottom: 15px; +} + +table td, table th { + border: 1px solid #ddd; + padding: 5px; +} \ No newline at end of file diff --git a/MarkdownEditorDemo/wwwroot/index.html b/MarkdownEditorDemo/wwwroot/index.html index ccec010..3fbe3ba 100644 --- a/MarkdownEditorDemo/wwwroot/index.html +++ b/MarkdownEditorDemo/wwwroot/index.html @@ -12,6 +12,8 @@ + + @@ -24,6 +26,10 @@ + + + + - + \ No newline at end of file diff --git a/MarkdownEditorDemo/wwwroot/lib/query/jquery.js b/MarkdownEditorDemo/wwwroot/lib/query/jquery.js new file mode 100644 index 0000000..fc6c299 --- /dev/null +++ b/MarkdownEditorDemo/wwwroot/lib/query/jquery.js @@ -0,0 +1,10881 @@ +/*! + * jQuery JavaScript Library v3.6.0 + * https://jquery.com/ + * + * Includes Sizzle.js + * https://sizzlejs.com/ + * + * Copyright OpenJS Foundation and other contributors + * Released under the MIT license + * https://jquery.org/license + * + * Date: 2021-03-02T17:08Z + */ +( function( global, factory ) { + + "use strict"; + + if ( typeof module === "object" && typeof module.exports === "object" ) { + + // For CommonJS and CommonJS-like environments where a proper `window` + // is present, execute the factory and get jQuery. + // For environments that do not have a `window` with a `document` + // (such as Node.js), expose a factory as module.exports. + // This accentuates the need for the creation of a real `window`. + // e.g. var jQuery = require("jquery")(window); + // See ticket #14549 for more info. + module.exports = global.document ? + factory( global, true ) : + function( w ) { + if ( !w.document ) { + throw new Error( "jQuery requires a window with a document" ); + } + return factory( w ); + }; + } else { + factory( global ); + } + +// Pass this if window is not defined yet +} )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) { + +// Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1 +// throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode +// arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common +// enough that all such attempts are guarded in a try block. +"use strict"; + +var arr = []; + +var getProto = Object.getPrototypeOf; + +var slice = arr.slice; + +var flat = arr.flat ? function( array ) { + return arr.flat.call( array ); +} : function( array ) { + return arr.concat.apply( [], array ); +}; + + +var push = arr.push; + +var indexOf = arr.indexOf; + +var class2type = {}; + +var toString = class2type.toString; + +var hasOwn = class2type.hasOwnProperty; + +var fnToString = hasOwn.toString; + +var ObjectFunctionString = fnToString.call( Object ); + +var support = {}; + +var isFunction = function isFunction( obj ) { + + // Support: Chrome <=57, Firefox <=52 + // In some browsers, typeof returns "function" for HTML elements + // (i.e., `typeof document.createElement( "object" ) === "function"`). + // We don't want to classify *any* DOM node as a function. + // Support: QtWeb <=3.8.5, WebKit <=534.34, wkhtmltopdf tool <=0.12.5 + // Plus for old WebKit, typeof returns "function" for HTML collections + // (e.g., `typeof document.getElementsByTagName("div") === "function"`). (gh-4756) + return typeof obj === "function" && typeof obj.nodeType !== "number" && + typeof obj.item !== "function"; + }; + + +var isWindow = function isWindow( obj ) { + return obj != null && obj === obj.window; + }; + + +var document = window.document; + + + + var preservedScriptAttributes = { + type: true, + src: true, + nonce: true, + noModule: true + }; + + function DOMEval( code, node, doc ) { + doc = doc || document; + + var i, val, + script = doc.createElement( "script" ); + + script.text = code; + if ( node ) { + for ( i in preservedScriptAttributes ) { + + // Support: Firefox 64+, Edge 18+ + // Some browsers don't support the "nonce" property on scripts. + // On the other hand, just using `getAttribute` is not enough as + // the `nonce` attribute is reset to an empty string whenever it + // becomes browsing-context connected. + // See https://github.com/whatwg/html/issues/2369 + // See https://html.spec.whatwg.org/#nonce-attributes + // The `node.getAttribute` check was added for the sake of + // `jQuery.globalEval` so that it can fake a nonce-containing node + // via an object. + val = node[ i ] || node.getAttribute && node.getAttribute( i ); + if ( val ) { + script.setAttribute( i, val ); + } + } + } + doc.head.appendChild( script ).parentNode.removeChild( script ); + } + + +function toType( obj ) { + if ( obj == null ) { + return obj + ""; + } + + // Support: Android <=2.3 only (functionish RegExp) + return typeof obj === "object" || typeof obj === "function" ? + class2type[ toString.call( obj ) ] || "object" : + typeof obj; +} +/* global Symbol */ +// Defining this global in .eslintrc.json would create a danger of using the global +// unguarded in another place, it seems safer to define global only for this module + + + +var + version = "3.6.0", + + // Define a local copy of jQuery + jQuery = function( selector, context ) { + + // The jQuery object is actually just the init constructor 'enhanced' + // Need init if jQuery is called (just allow error to be thrown if not included) + return new jQuery.fn.init( selector, context ); + }; + +jQuery.fn = jQuery.prototype = { + + // The current version of jQuery being used + jquery: version, + + constructor: jQuery, + + // The default length of a jQuery object is 0 + length: 0, + + toArray: function() { + return slice.call( this ); + }, + + // Get the Nth element in the matched element set OR + // Get the whole matched element set as a clean array + get: function( num ) { + + // Return all the elements in a clean array + if ( num == null ) { + return slice.call( this ); + } + + // Return just the one element from the set + return num < 0 ? this[ num + this.length ] : this[ num ]; + }, + + // Take an array of elements and push it onto the stack + // (returning the new matched element set) + pushStack: function( elems ) { + + // Build a new jQuery matched element set + var ret = jQuery.merge( this.constructor(), elems ); + + // Add the old object onto the stack (as a reference) + ret.prevObject = this; + + // Return the newly-formed element set + return ret; + }, + + // Execute a callback for every element in the matched set. + each: function( callback ) { + return jQuery.each( this, callback ); + }, + + map: function( callback ) { + return this.pushStack( jQuery.map( this, function( elem, i ) { + return callback.call( elem, i, elem ); + } ) ); + }, + + slice: function() { + return this.pushStack( slice.apply( this, arguments ) ); + }, + + first: function() { + return this.eq( 0 ); + }, + + last: function() { + return this.eq( -1 ); + }, + + even: function() { + return this.pushStack( jQuery.grep( this, function( _elem, i ) { + return ( i + 1 ) % 2; + } ) ); + }, + + odd: function() { + return this.pushStack( jQuery.grep( this, function( _elem, i ) { + return i % 2; + } ) ); + }, + + eq: function( i ) { + var len = this.length, + j = +i + ( i < 0 ? len : 0 ); + return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] ); + }, + + end: function() { + return this.prevObject || this.constructor(); + }, + + // For internal use only. + // Behaves like an Array's method, not like a jQuery method. + push: push, + sort: arr.sort, + splice: arr.splice +}; + +jQuery.extend = jQuery.fn.extend = function() { + var options, name, src, copy, copyIsArray, clone, + target = arguments[ 0 ] || {}, + i = 1, + length = arguments.length, + deep = false; + + // Handle a deep copy situation + if ( typeof target === "boolean" ) { + deep = target; + + // Skip the boolean and the target + target = arguments[ i ] || {}; + i++; + } + + // Handle case when target is a string or something (possible in deep copy) + if ( typeof target !== "object" && !isFunction( target ) ) { + target = {}; + } + + // Extend jQuery itself if only one argument is passed + if ( i === length ) { + target = this; + i--; + } + + for ( ; i < length; i++ ) { + + // Only deal with non-null/undefined values + if ( ( options = arguments[ i ] ) != null ) { + + // Extend the base object + for ( name in options ) { + copy = options[ name ]; + + // Prevent Object.prototype pollution + // Prevent never-ending loop + if ( name === "__proto__" || target === copy ) { + continue; + } + + // Recurse if we're merging plain objects or arrays + if ( deep && copy && ( jQuery.isPlainObject( copy ) || + ( copyIsArray = Array.isArray( copy ) ) ) ) { + src = target[ name ]; + + // Ensure proper type for the source value + if ( copyIsArray && !Array.isArray( src ) ) { + clone = []; + } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) { + clone = {}; + } else { + clone = src; + } + copyIsArray = false; + + // Never move original objects, clone them + target[ name ] = jQuery.extend( deep, clone, copy ); + + // Don't bring in undefined values + } else if ( copy !== undefined ) { + target[ name ] = copy; + } + } + } + } + + // Return the modified object + return target; +}; + +jQuery.extend( { + + // Unique for each copy of jQuery on the page + expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ), + + // Assume jQuery is ready without the ready module + isReady: true, + + error: function( msg ) { + throw new Error( msg ); + }, + + noop: function() {}, + + isPlainObject: function( obj ) { + var proto, Ctor; + + // Detect obvious negatives + // Use toString instead of jQuery.type to catch host objects + if ( !obj || toString.call( obj ) !== "[object Object]" ) { + return false; + } + + proto = getProto( obj ); + + // Objects with no prototype (e.g., `Object.create( null )`) are plain + if ( !proto ) { + return true; + } + + // Objects with prototype are plain iff they were constructed by a global Object function + Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor; + return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString; + }, + + isEmptyObject: function( obj ) { + var name; + + for ( name in obj ) { + return false; + } + return true; + }, + + // Evaluates a script in a provided context; falls back to the global one + // if not specified. + globalEval: function( code, options, doc ) { + DOMEval( code, { nonce: options && options.nonce }, doc ); + }, + + each: function( obj, callback ) { + var length, i = 0; + + if ( isArrayLike( obj ) ) { + length = obj.length; + for ( ; i < length; i++ ) { + if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { + break; + } + } + } else { + for ( i in obj ) { + if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) { + break; + } + } + } + + return obj; + }, + + // results is for internal usage only + makeArray: function( arr, results ) { + var ret = results || []; + + if ( arr != null ) { + if ( isArrayLike( Object( arr ) ) ) { + jQuery.merge( ret, + typeof arr === "string" ? + [ arr ] : arr + ); + } else { + push.call( ret, arr ); + } + } + + return ret; + }, + + inArray: function( elem, arr, i ) { + return arr == null ? -1 : indexOf.call( arr, elem, i ); + }, + + // Support: Android <=4.0 only, PhantomJS 1 only + // push.apply(_, arraylike) throws on ancient WebKit + merge: function( first, second ) { + var len = +second.length, + j = 0, + i = first.length; + + for ( ; j < len; j++ ) { + first[ i++ ] = second[ j ]; + } + + first.length = i; + + return first; + }, + + grep: function( elems, callback, invert ) { + var callbackInverse, + matches = [], + i = 0, + length = elems.length, + callbackExpect = !invert; + + // Go through the array, only saving the items + // that pass the validator function + for ( ; i < length; i++ ) { + callbackInverse = !callback( elems[ i ], i ); + if ( callbackInverse !== callbackExpect ) { + matches.push( elems[ i ] ); + } + } + + return matches; + }, + + // arg is for internal usage only + map: function( elems, callback, arg ) { + var length, value, + i = 0, + ret = []; + + // Go through the array, translating each of the items to their new values + if ( isArrayLike( elems ) ) { + length = elems.length; + for ( ; i < length; i++ ) { + value = callback( elems[ i ], i, arg ); + + if ( value != null ) { + ret.push( value ); + } + } + + // Go through every key on the object, + } else { + for ( i in elems ) { + value = callback( elems[ i ], i, arg ); + + if ( value != null ) { + ret.push( value ); + } + } + } + + // Flatten any nested arrays + return flat( ret ); + }, + + // A global GUID counter for objects + guid: 1, + + // jQuery.support is not used in Core but other projects attach their + // properties to it so it needs to exist. + support: support +} ); + +if ( typeof Symbol === "function" ) { + jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ]; +} + +// Populate the class2type map +jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ), + function( _i, name ) { + class2type[ "[object " + name + "]" ] = name.toLowerCase(); + } ); + +function isArrayLike( obj ) { + + // Support: real iOS 8.2 only (not reproducible in simulator) + // `in` check used to prevent JIT error (gh-2145) + // hasOwn isn't used here due to false negatives + // regarding Nodelist length in IE + var length = !!obj && "length" in obj && obj.length, + type = toType( obj ); + + if ( isFunction( obj ) || isWindow( obj ) ) { + return false; + } + + return type === "array" || length === 0 || + typeof length === "number" && length > 0 && ( length - 1 ) in obj; +} +var Sizzle = +/*! + * Sizzle CSS Selector Engine v2.3.6 + * https://sizzlejs.com/ + * + * Copyright JS Foundation and other contributors + * Released under the MIT license + * https://js.foundation/ + * + * Date: 2021-02-16 + */ +( function( window ) { +var i, + support, + Expr, + getText, + isXML, + tokenize, + compile, + select, + outermostContext, + sortInput, + hasDuplicate, + + // Local document vars + setDocument, + document, + docElem, + documentIsHTML, + rbuggyQSA, + rbuggyMatches, + matches, + contains, + + // Instance-specific data + expando = "sizzle" + 1 * new Date(), + preferredDoc = window.document, + dirruns = 0, + done = 0, + classCache = createCache(), + tokenCache = createCache(), + compilerCache = createCache(), + nonnativeSelectorCache = createCache(), + sortOrder = function( a, b ) { + if ( a === b ) { + hasDuplicate = true; + } + return 0; + }, + + // Instance methods + hasOwn = ( {} ).hasOwnProperty, + arr = [], + pop = arr.pop, + pushNative = arr.push, + push = arr.push, + slice = arr.slice, + + // Use a stripped-down indexOf as it's faster than native + // https://jsperf.com/thor-indexof-vs-for/5 + indexOf = function( list, elem ) { + var i = 0, + len = list.length; + for ( ; i < len; i++ ) { + if ( list[ i ] === elem ) { + return i; + } + } + return -1; + }, + + booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|" + + "ismap|loop|multiple|open|readonly|required|scoped", + + // Regular expressions + + // http://www.w3.org/TR/css3-selectors/#whitespace + whitespace = "[\\x20\\t\\r\\n\\f]", + + // https://www.w3.org/TR/css-syntax-3/#ident-token-diagram + identifier = "(?:\\\\[\\da-fA-F]{1,6}" + whitespace + + "?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+", + + // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors + attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace + + + // Operator (capture 2) + "*([*^$|!~]?=)" + whitespace + + + // "Attribute values must be CSS identifiers [capture 5] + // or strings [capture 3 or capture 4]" + "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + + whitespace + "*\\]", + + pseudos = ":(" + identifier + ")(?:\\((" + + + // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments: + // 1. quoted (capture 3; capture 4 or capture 5) + "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" + + + // 2. simple (capture 6) + "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" + + + // 3. anything else (capture 2) + ".*" + + ")\\)|)", + + // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter + rwhitespace = new RegExp( whitespace + "+", "g" ), + rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + + whitespace + "+$", "g" ), + + rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), + rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + + "*" ), + rdescend = new RegExp( whitespace + "|>" ), + + rpseudo = new RegExp( pseudos ), + ridentifier = new RegExp( "^" + identifier + "$" ), + + matchExpr = { + "ID": new RegExp( "^#(" + identifier + ")" ), + "CLASS": new RegExp( "^\\.(" + identifier + ")" ), + "TAG": new RegExp( "^(" + identifier + "|[*])" ), + "ATTR": new RegExp( "^" + attributes ), + "PSEUDO": new RegExp( "^" + pseudos ), + "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + + whitespace + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + + whitespace + "*(\\d+)|))" + whitespace + "*\\)|)", "i" ), + "bool": new RegExp( "^(?:" + booleans + ")$", "i" ), + + // For use in libraries implementing .is() + // We use this for POS matching in `select` + "needsContext": new RegExp( "^" + whitespace + + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace + + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" ) + }, + + rhtml = /HTML$/i, + rinputs = /^(?:input|select|textarea|button)$/i, + rheader = /^h\d$/i, + + rnative = /^[^{]+\{\s*\[native \w/, + + // Easily-parseable/retrievable ID or TAG or CLASS selectors + rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/, + + rsibling = /[+~]/, + + // CSS escapes + // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters + runescape = new RegExp( "\\\\[\\da-fA-F]{1,6}" + whitespace + "?|\\\\([^\\r\\n\\f])", "g" ), + funescape = function( escape, nonHex ) { + var high = "0x" + escape.slice( 1 ) - 0x10000; + + return nonHex ? + + // Strip the backslash prefix from a non-hex escape sequence + nonHex : + + // Replace a hexadecimal escape sequence with the encoded Unicode code point + // Support: IE <=11+ + // For values outside the Basic Multilingual Plane (BMP), manually construct a + // surrogate pair + high < 0 ? + String.fromCharCode( high + 0x10000 ) : + String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 ); + }, + + // CSS string/identifier serialization + // https://drafts.csswg.org/cssom/#common-serializing-idioms + rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g, + fcssescape = function( ch, asCodePoint ) { + if ( asCodePoint ) { + + // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER + if ( ch === "\0" ) { + return "\uFFFD"; + } + + // Control characters and (dependent upon position) numbers get escaped as code points + return ch.slice( 0, -1 ) + "\\" + + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " "; + } + + // Other potentially-special ASCII characters get backslash-escaped + return "\\" + ch; + }, + + // Used for iframes + // See setDocument() + // Removing the function wrapper causes a "Permission Denied" + // error in IE + unloadHandler = function() { + setDocument(); + }, + + inDisabledFieldset = addCombinator( + function( elem ) { + return elem.disabled === true && elem.nodeName.toLowerCase() === "fieldset"; + }, + { dir: "parentNode", next: "legend" } + ); + +// Optimize for push.apply( _, NodeList ) +try { + push.apply( + ( arr = slice.call( preferredDoc.childNodes ) ), + preferredDoc.childNodes + ); + + // Support: Android<4.0 + // Detect silently failing push.apply + // eslint-disable-next-line no-unused-expressions + arr[ preferredDoc.childNodes.length ].nodeType; +} catch ( e ) { + push = { apply: arr.length ? + + // Leverage slice if possible + function( target, els ) { + pushNative.apply( target, slice.call( els ) ); + } : + + // Support: IE<9 + // Otherwise append directly + function( target, els ) { + var j = target.length, + i = 0; + + // Can't trust NodeList.length + while ( ( target[ j++ ] = els[ i++ ] ) ) {} + target.length = j - 1; + } + }; +} + +function Sizzle( selector, context, results, seed ) { + var m, i, elem, nid, match, groups, newSelector, + newContext = context && context.ownerDocument, + + // nodeType defaults to 9, since context defaults to document + nodeType = context ? context.nodeType : 9; + + results = results || []; + + // Return early from calls with invalid selector or context + if ( typeof selector !== "string" || !selector || + nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) { + + return results; + } + + // Try to shortcut find operations (as opposed to filters) in HTML documents + if ( !seed ) { + setDocument( context ); + context = context || document; + + if ( documentIsHTML ) { + + // If the selector is sufficiently simple, try using a "get*By*" DOM method + // (excepting DocumentFragment context, where the methods don't exist) + if ( nodeType !== 11 && ( match = rquickExpr.exec( selector ) ) ) { + + // ID selector + if ( ( m = match[ 1 ] ) ) { + + // Document context + if ( nodeType === 9 ) { + if ( ( elem = context.getElementById( m ) ) ) { + + // Support: IE, Opera, Webkit + // TODO: identify versions + // getElementById can match elements by name instead of ID + if ( elem.id === m ) { + results.push( elem ); + return results; + } + } else { + return results; + } + + // Element context + } else { + + // Support: IE, Opera, Webkit + // TODO: identify versions + // getElementById can match elements by name instead of ID + if ( newContext && ( elem = newContext.getElementById( m ) ) && + contains( context, elem ) && + elem.id === m ) { + + results.push( elem ); + return results; + } + } + + // Type selector + } else if ( match[ 2 ] ) { + push.apply( results, context.getElementsByTagName( selector ) ); + return results; + + // Class selector + } else if ( ( m = match[ 3 ] ) && support.getElementsByClassName && + context.getElementsByClassName ) { + + push.apply( results, context.getElementsByClassName( m ) ); + return results; + } + } + + // Take advantage of querySelectorAll + if ( support.qsa && + !nonnativeSelectorCache[ selector + " " ] && + ( !rbuggyQSA || !rbuggyQSA.test( selector ) ) && + + // Support: IE 8 only + // Exclude object elements + ( nodeType !== 1 || context.nodeName.toLowerCase() !== "object" ) ) { + + newSelector = selector; + newContext = context; + + // qSA considers elements outside a scoping root when evaluating child or + // descendant combinators, which is not what we want. + // In such cases, we work around the behavior by prefixing every selector in the + // list with an ID selector referencing the scope context. + // The technique has to be used as well when a leading combinator is used + // as such selectors are not recognized by querySelectorAll. + // Thanks to Andrew Dupont for this technique. + if ( nodeType === 1 && + ( rdescend.test( selector ) || rcombinators.test( selector ) ) ) { + + // Expand context for sibling selectors + newContext = rsibling.test( selector ) && testContext( context.parentNode ) || + context; + + // We can use :scope instead of the ID hack if the browser + // supports it & if we're not changing the context. + if ( newContext !== context || !support.scope ) { + + // Capture the context ID, setting it first if necessary + if ( ( nid = context.getAttribute( "id" ) ) ) { + nid = nid.replace( rcssescape, fcssescape ); + } else { + context.setAttribute( "id", ( nid = expando ) ); + } + } + + // Prefix every selector in the list + groups = tokenize( selector ); + i = groups.length; + while ( i-- ) { + groups[ i ] = ( nid ? "#" + nid : ":scope" ) + " " + + toSelector( groups[ i ] ); + } + newSelector = groups.join( "," ); + } + + try { + push.apply( results, + newContext.querySelectorAll( newSelector ) + ); + return results; + } catch ( qsaError ) { + nonnativeSelectorCache( selector, true ); + } finally { + if ( nid === expando ) { + context.removeAttribute( "id" ); + } + } + } + } + } + + // All others + return select( selector.replace( rtrim, "$1" ), context, results, seed ); +} + +/** + * Create key-value caches of limited size + * @returns {function(string, object)} Returns the Object data after storing it on itself with + * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength) + * deleting the oldest entry + */ +function createCache() { + var keys = []; + + function cache( key, value ) { + + // Use (key + " ") to avoid collision with native prototype properties (see Issue #157) + if ( keys.push( key + " " ) > Expr.cacheLength ) { + + // Only keep the most recent entries + delete cache[ keys.shift() ]; + } + return ( cache[ key + " " ] = value ); + } + return cache; +} + +/** + * Mark a function for special use by Sizzle + * @param {Function} fn The function to mark + */ +function markFunction( fn ) { + fn[ expando ] = true; + return fn; +} + +/** + * Support testing using an element + * @param {Function} fn Passed the created element and returns a boolean result + */ +function assert( fn ) { + var el = document.createElement( "fieldset" ); + + try { + return !!fn( el ); + } catch ( e ) { + return false; + } finally { + + // Remove from its parent by default + if ( el.parentNode ) { + el.parentNode.removeChild( el ); + } + + // release memory in IE + el = null; + } +} + +/** + * Adds the same handler for all of the specified attrs + * @param {String} attrs Pipe-separated list of attributes + * @param {Function} handler The method that will be applied + */ +function addHandle( attrs, handler ) { + var arr = attrs.split( "|" ), + i = arr.length; + + while ( i-- ) { + Expr.attrHandle[ arr[ i ] ] = handler; + } +} + +/** + * Checks document order of two siblings + * @param {Element} a + * @param {Element} b + * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b + */ +function siblingCheck( a, b ) { + var cur = b && a, + diff = cur && a.nodeType === 1 && b.nodeType === 1 && + a.sourceIndex - b.sourceIndex; + + // Use IE sourceIndex if available on both nodes + if ( diff ) { + return diff; + } + + // Check if b follows a + if ( cur ) { + while ( ( cur = cur.nextSibling ) ) { + if ( cur === b ) { + return -1; + } + } + } + + return a ? 1 : -1; +} + +/** + * Returns a function to use in pseudos for input types + * @param {String} type + */ +function createInputPseudo( type ) { + return function( elem ) { + var name = elem.nodeName.toLowerCase(); + return name === "input" && elem.type === type; + }; +} + +/** + * Returns a function to use in pseudos for buttons + * @param {String} type + */ +function createButtonPseudo( type ) { + return function( elem ) { + var name = elem.nodeName.toLowerCase(); + return ( name === "input" || name === "button" ) && elem.type === type; + }; +} + +/** + * Returns a function to use in pseudos for :enabled/:disabled + * @param {Boolean} disabled true for :disabled; false for :enabled + */ +function createDisabledPseudo( disabled ) { + + // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable + return function( elem ) { + + // Only certain elements can match :enabled or :disabled + // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled + // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled + if ( "form" in elem ) { + + // Check for inherited disabledness on relevant non-disabled elements: + // * listed form-associated elements in a disabled fieldset + // https://html.spec.whatwg.org/multipage/forms.html#category-listed + // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled + // * option elements in a disabled optgroup + // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled + // All such elements have a "form" property. + if ( elem.parentNode && elem.disabled === false ) { + + // Option elements defer to a parent optgroup if present + if ( "label" in elem ) { + if ( "label" in elem.parentNode ) { + return elem.parentNode.disabled === disabled; + } else { + return elem.disabled === disabled; + } + } + + // Support: IE 6 - 11 + // Use the isDisabled shortcut property to check for disabled fieldset ancestors + return elem.isDisabled === disabled || + + // Where there is no isDisabled, check manually + /* jshint -W018 */ + elem.isDisabled !== !disabled && + inDisabledFieldset( elem ) === disabled; + } + + return elem.disabled === disabled; + + // Try to winnow out elements that can't be disabled before trusting the disabled property. + // Some victims get caught in our net (label, legend, menu, track), but it shouldn't + // even exist on them, let alone have a boolean value. + } else if ( "label" in elem ) { + return elem.disabled === disabled; + } + + // Remaining elements are neither :enabled nor :disabled + return false; + }; +} + +/** + * Returns a function to use in pseudos for positionals + * @param {Function} fn + */ +function createPositionalPseudo( fn ) { + return markFunction( function( argument ) { + argument = +argument; + return markFunction( function( seed, matches ) { + var j, + matchIndexes = fn( [], seed.length, argument ), + i = matchIndexes.length; + + // Match elements found at the specified indexes + while ( i-- ) { + if ( seed[ ( j = matchIndexes[ i ] ) ] ) { + seed[ j ] = !( matches[ j ] = seed[ j ] ); + } + } + } ); + } ); +} + +/** + * Checks a node for validity as a Sizzle context + * @param {Element|Object=} context + * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value + */ +function testContext( context ) { + return context && typeof context.getElementsByTagName !== "undefined" && context; +} + +// Expose support vars for convenience +support = Sizzle.support = {}; + +/** + * Detects XML nodes + * @param {Element|Object} elem An element or a document + * @returns {Boolean} True iff elem is a non-HTML XML node + */ +isXML = Sizzle.isXML = function( elem ) { + var namespace = elem && elem.namespaceURI, + docElem = elem && ( elem.ownerDocument || elem ).documentElement; + + // Support: IE <=8 + // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes + // https://bugs.jquery.com/ticket/4833 + return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" ); +}; + +/** + * Sets document-related variables once based on the current document + * @param {Element|Object} [doc] An element or document object to use to set the document + * @returns {Object} Returns the current document + */ +setDocument = Sizzle.setDocument = function( node ) { + var hasCompare, subWindow, + doc = node ? node.ownerDocument || node : preferredDoc; + + // Return early if doc is invalid or already selected + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + if ( doc == document || doc.nodeType !== 9 || !doc.documentElement ) { + return document; + } + + // Update global variables + document = doc; + docElem = document.documentElement; + documentIsHTML = !isXML( document ); + + // Support: IE 9 - 11+, Edge 12 - 18+ + // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936) + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + if ( preferredDoc != document && + ( subWindow = document.defaultView ) && subWindow.top !== subWindow ) { + + // Support: IE 11, Edge + if ( subWindow.addEventListener ) { + subWindow.addEventListener( "unload", unloadHandler, false ); + + // Support: IE 9 - 10 only + } else if ( subWindow.attachEvent ) { + subWindow.attachEvent( "onunload", unloadHandler ); + } + } + + // Support: IE 8 - 11+, Edge 12 - 18+, Chrome <=16 - 25 only, Firefox <=3.6 - 31 only, + // Safari 4 - 5 only, Opera <=11.6 - 12.x only + // IE/Edge & older browsers don't support the :scope pseudo-class. + // Support: Safari 6.0 only + // Safari 6.0 supports :scope but it's an alias of :root there. + support.scope = assert( function( el ) { + docElem.appendChild( el ).appendChild( document.createElement( "div" ) ); + return typeof el.querySelectorAll !== "undefined" && + !el.querySelectorAll( ":scope fieldset div" ).length; + } ); + + /* Attributes + ---------------------------------------------------------------------- */ + + // Support: IE<8 + // Verify that getAttribute really returns attributes and not properties + // (excepting IE8 booleans) + support.attributes = assert( function( el ) { + el.className = "i"; + return !el.getAttribute( "className" ); + } ); + + /* getElement(s)By* + ---------------------------------------------------------------------- */ + + // Check if getElementsByTagName("*") returns only elements + support.getElementsByTagName = assert( function( el ) { + el.appendChild( document.createComment( "" ) ); + return !el.getElementsByTagName( "*" ).length; + } ); + + // Support: IE<9 + support.getElementsByClassName = rnative.test( document.getElementsByClassName ); + + // Support: IE<10 + // Check if getElementById returns elements by name + // The broken getElementById methods don't pick up programmatically-set names, + // so use a roundabout getElementsByName test + support.getById = assert( function( el ) { + docElem.appendChild( el ).id = expando; + return !document.getElementsByName || !document.getElementsByName( expando ).length; + } ); + + // ID filter and find + if ( support.getById ) { + Expr.filter[ "ID" ] = function( id ) { + var attrId = id.replace( runescape, funescape ); + return function( elem ) { + return elem.getAttribute( "id" ) === attrId; + }; + }; + Expr.find[ "ID" ] = function( id, context ) { + if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { + var elem = context.getElementById( id ); + return elem ? [ elem ] : []; + } + }; + } else { + Expr.filter[ "ID" ] = function( id ) { + var attrId = id.replace( runescape, funescape ); + return function( elem ) { + var node = typeof elem.getAttributeNode !== "undefined" && + elem.getAttributeNode( "id" ); + return node && node.value === attrId; + }; + }; + + // Support: IE 6 - 7 only + // getElementById is not reliable as a find shortcut + Expr.find[ "ID" ] = function( id, context ) { + if ( typeof context.getElementById !== "undefined" && documentIsHTML ) { + var node, i, elems, + elem = context.getElementById( id ); + + if ( elem ) { + + // Verify the id attribute + node = elem.getAttributeNode( "id" ); + if ( node && node.value === id ) { + return [ elem ]; + } + + // Fall back on getElementsByName + elems = context.getElementsByName( id ); + i = 0; + while ( ( elem = elems[ i++ ] ) ) { + node = elem.getAttributeNode( "id" ); + if ( node && node.value === id ) { + return [ elem ]; + } + } + } + + return []; + } + }; + } + + // Tag + Expr.find[ "TAG" ] = support.getElementsByTagName ? + function( tag, context ) { + if ( typeof context.getElementsByTagName !== "undefined" ) { + return context.getElementsByTagName( tag ); + + // DocumentFragment nodes don't have gEBTN + } else if ( support.qsa ) { + return context.querySelectorAll( tag ); + } + } : + + function( tag, context ) { + var elem, + tmp = [], + i = 0, + + // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too + results = context.getElementsByTagName( tag ); + + // Filter out possible comments + if ( tag === "*" ) { + while ( ( elem = results[ i++ ] ) ) { + if ( elem.nodeType === 1 ) { + tmp.push( elem ); + } + } + + return tmp; + } + return results; + }; + + // Class + Expr.find[ "CLASS" ] = support.getElementsByClassName && function( className, context ) { + if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) { + return context.getElementsByClassName( className ); + } + }; + + /* QSA/matchesSelector + ---------------------------------------------------------------------- */ + + // QSA and matchesSelector support + + // matchesSelector(:active) reports false when true (IE9/Opera 11.5) + rbuggyMatches = []; + + // qSa(:focus) reports false when true (Chrome 21) + // We allow this because of a bug in IE8/9 that throws an error + // whenever `document.activeElement` is accessed on an iframe + // So, we allow :focus to pass through QSA all the time to avoid the IE error + // See https://bugs.jquery.com/ticket/13378 + rbuggyQSA = []; + + if ( ( support.qsa = rnative.test( document.querySelectorAll ) ) ) { + + // Build QSA regex + // Regex strategy adopted from Diego Perini + assert( function( el ) { + + var input; + + // Select is set to empty string on purpose + // This is to test IE's treatment of not explicitly + // setting a boolean content attribute, + // since its presence should be enough + // https://bugs.jquery.com/ticket/12359 + docElem.appendChild( el ).innerHTML = "" + + ""; + + // Support: IE8, Opera 11-12.16 + // Nothing should be selected when empty strings follow ^= or $= or *= + // The test attribute must be unknown in Opera but "safe" for WinRT + // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section + if ( el.querySelectorAll( "[msallowcapture^='']" ).length ) { + rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" ); + } + + // Support: IE8 + // Boolean attributes and "value" are not treated correctly + if ( !el.querySelectorAll( "[selected]" ).length ) { + rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" ); + } + + // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+ + if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) { + rbuggyQSA.push( "~=" ); + } + + // Support: IE 11+, Edge 15 - 18+ + // IE 11/Edge don't find elements on a `[name='']` query in some cases. + // Adding a temporary attribute to the document before the selection works + // around the issue. + // Interestingly, IE 10 & older don't seem to have the issue. + input = document.createElement( "input" ); + input.setAttribute( "name", "" ); + el.appendChild( input ); + if ( !el.querySelectorAll( "[name='']" ).length ) { + rbuggyQSA.push( "\\[" + whitespace + "*name" + whitespace + "*=" + + whitespace + "*(?:''|\"\")" ); + } + + // Webkit/Opera - :checked should return selected option elements + // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked + // IE8 throws error here and will not see later tests + if ( !el.querySelectorAll( ":checked" ).length ) { + rbuggyQSA.push( ":checked" ); + } + + // Support: Safari 8+, iOS 8+ + // https://bugs.webkit.org/show_bug.cgi?id=136851 + // In-page `selector#id sibling-combinator selector` fails + if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) { + rbuggyQSA.push( ".#.+[+~]" ); + } + + // Support: Firefox <=3.6 - 5 only + // Old Firefox doesn't throw on a badly-escaped identifier. + el.querySelectorAll( "\\\f" ); + rbuggyQSA.push( "[\\r\\n\\f]" ); + } ); + + assert( function( el ) { + el.innerHTML = "" + + ""; + + // Support: Windows 8 Native Apps + // The type and name attributes are restricted during .innerHTML assignment + var input = document.createElement( "input" ); + input.setAttribute( "type", "hidden" ); + el.appendChild( input ).setAttribute( "name", "D" ); + + // Support: IE8 + // Enforce case-sensitivity of name attribute + if ( el.querySelectorAll( "[name=d]" ).length ) { + rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" ); + } + + // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled) + // IE8 throws error here and will not see later tests + if ( el.querySelectorAll( ":enabled" ).length !== 2 ) { + rbuggyQSA.push( ":enabled", ":disabled" ); + } + + // Support: IE9-11+ + // IE's :disabled selector does not pick up the children of disabled fieldsets + docElem.appendChild( el ).disabled = true; + if ( el.querySelectorAll( ":disabled" ).length !== 2 ) { + rbuggyQSA.push( ":enabled", ":disabled" ); + } + + // Support: Opera 10 - 11 only + // Opera 10-11 does not throw on post-comma invalid pseudos + el.querySelectorAll( "*,:x" ); + rbuggyQSA.push( ",.*:" ); + } ); + } + + if ( ( support.matchesSelector = rnative.test( ( matches = docElem.matches || + docElem.webkitMatchesSelector || + docElem.mozMatchesSelector || + docElem.oMatchesSelector || + docElem.msMatchesSelector ) ) ) ) { + + assert( function( el ) { + + // Check to see if it's possible to do matchesSelector + // on a disconnected node (IE 9) + support.disconnectedMatch = matches.call( el, "*" ); + + // This should fail with an exception + // Gecko does not error, returns false instead + matches.call( el, "[s!='']:x" ); + rbuggyMatches.push( "!=", pseudos ); + } ); + } + + rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join( "|" ) ); + rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join( "|" ) ); + + /* Contains + ---------------------------------------------------------------------- */ + hasCompare = rnative.test( docElem.compareDocumentPosition ); + + // Element contains another + // Purposefully self-exclusive + // As in, an element does not contain itself + contains = hasCompare || rnative.test( docElem.contains ) ? + function( a, b ) { + var adown = a.nodeType === 9 ? a.documentElement : a, + bup = b && b.parentNode; + return a === bup || !!( bup && bup.nodeType === 1 && ( + adown.contains ? + adown.contains( bup ) : + a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16 + ) ); + } : + function( a, b ) { + if ( b ) { + while ( ( b = b.parentNode ) ) { + if ( b === a ) { + return true; + } + } + } + return false; + }; + + /* Sorting + ---------------------------------------------------------------------- */ + + // Document order sorting + sortOrder = hasCompare ? + function( a, b ) { + + // Flag for duplicate removal + if ( a === b ) { + hasDuplicate = true; + return 0; + } + + // Sort on method existence if only one input has compareDocumentPosition + var compare = !a.compareDocumentPosition - !b.compareDocumentPosition; + if ( compare ) { + return compare; + } + + // Calculate position if both inputs belong to the same document + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + compare = ( a.ownerDocument || a ) == ( b.ownerDocument || b ) ? + a.compareDocumentPosition( b ) : + + // Otherwise we know they are disconnected + 1; + + // Disconnected nodes + if ( compare & 1 || + ( !support.sortDetached && b.compareDocumentPosition( a ) === compare ) ) { + + // Choose the first element that is related to our preferred document + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + if ( a == document || a.ownerDocument == preferredDoc && + contains( preferredDoc, a ) ) { + return -1; + } + + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + if ( b == document || b.ownerDocument == preferredDoc && + contains( preferredDoc, b ) ) { + return 1; + } + + // Maintain original order + return sortInput ? + ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : + 0; + } + + return compare & 4 ? -1 : 1; + } : + function( a, b ) { + + // Exit early if the nodes are identical + if ( a === b ) { + hasDuplicate = true; + return 0; + } + + var cur, + i = 0, + aup = a.parentNode, + bup = b.parentNode, + ap = [ a ], + bp = [ b ]; + + // Parentless nodes are either documents or disconnected + if ( !aup || !bup ) { + + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + /* eslint-disable eqeqeq */ + return a == document ? -1 : + b == document ? 1 : + /* eslint-enable eqeqeq */ + aup ? -1 : + bup ? 1 : + sortInput ? + ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) : + 0; + + // If the nodes are siblings, we can do a quick check + } else if ( aup === bup ) { + return siblingCheck( a, b ); + } + + // Otherwise we need full lists of their ancestors for comparison + cur = a; + while ( ( cur = cur.parentNode ) ) { + ap.unshift( cur ); + } + cur = b; + while ( ( cur = cur.parentNode ) ) { + bp.unshift( cur ); + } + + // Walk down the tree looking for a discrepancy + while ( ap[ i ] === bp[ i ] ) { + i++; + } + + return i ? + + // Do a sibling check if the nodes have a common ancestor + siblingCheck( ap[ i ], bp[ i ] ) : + + // Otherwise nodes in our document sort first + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + /* eslint-disable eqeqeq */ + ap[ i ] == preferredDoc ? -1 : + bp[ i ] == preferredDoc ? 1 : + /* eslint-enable eqeqeq */ + 0; + }; + + return document; +}; + +Sizzle.matches = function( expr, elements ) { + return Sizzle( expr, null, null, elements ); +}; + +Sizzle.matchesSelector = function( elem, expr ) { + setDocument( elem ); + + if ( support.matchesSelector && documentIsHTML && + !nonnativeSelectorCache[ expr + " " ] && + ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) && + ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) { + + try { + var ret = matches.call( elem, expr ); + + // IE 9's matchesSelector returns false on disconnected nodes + if ( ret || support.disconnectedMatch || + + // As well, disconnected nodes are said to be in a document + // fragment in IE 9 + elem.document && elem.document.nodeType !== 11 ) { + return ret; + } + } catch ( e ) { + nonnativeSelectorCache( expr, true ); + } + } + + return Sizzle( expr, document, null, [ elem ] ).length > 0; +}; + +Sizzle.contains = function( context, elem ) { + + // Set document vars if needed + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + if ( ( context.ownerDocument || context ) != document ) { + setDocument( context ); + } + return contains( context, elem ); +}; + +Sizzle.attr = function( elem, name ) { + + // Set document vars if needed + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + if ( ( elem.ownerDocument || elem ) != document ) { + setDocument( elem ); + } + + var fn = Expr.attrHandle[ name.toLowerCase() ], + + // Don't get fooled by Object.prototype properties (jQuery #13807) + val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ? + fn( elem, name, !documentIsHTML ) : + undefined; + + return val !== undefined ? + val : + support.attributes || !documentIsHTML ? + elem.getAttribute( name ) : + ( val = elem.getAttributeNode( name ) ) && val.specified ? + val.value : + null; +}; + +Sizzle.escape = function( sel ) { + return ( sel + "" ).replace( rcssescape, fcssescape ); +}; + +Sizzle.error = function( msg ) { + throw new Error( "Syntax error, unrecognized expression: " + msg ); +}; + +/** + * Document sorting and removing duplicates + * @param {ArrayLike} results + */ +Sizzle.uniqueSort = function( results ) { + var elem, + duplicates = [], + j = 0, + i = 0; + + // Unless we *know* we can detect duplicates, assume their presence + hasDuplicate = !support.detectDuplicates; + sortInput = !support.sortStable && results.slice( 0 ); + results.sort( sortOrder ); + + if ( hasDuplicate ) { + while ( ( elem = results[ i++ ] ) ) { + if ( elem === results[ i ] ) { + j = duplicates.push( i ); + } + } + while ( j-- ) { + results.splice( duplicates[ j ], 1 ); + } + } + + // Clear input after sorting to release objects + // See https://github.com/jquery/sizzle/pull/225 + sortInput = null; + + return results; +}; + +/** + * Utility function for retrieving the text value of an array of DOM nodes + * @param {Array|Element} elem + */ +getText = Sizzle.getText = function( elem ) { + var node, + ret = "", + i = 0, + nodeType = elem.nodeType; + + if ( !nodeType ) { + + // If no nodeType, this is expected to be an array + while ( ( node = elem[ i++ ] ) ) { + + // Do not traverse comment nodes + ret += getText( node ); + } + } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) { + + // Use textContent for elements + // innerText usage removed for consistency of new lines (jQuery #11153) + if ( typeof elem.textContent === "string" ) { + return elem.textContent; + } else { + + // Traverse its children + for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { + ret += getText( elem ); + } + } + } else if ( nodeType === 3 || nodeType === 4 ) { + return elem.nodeValue; + } + + // Do not include comment or processing instruction nodes + + return ret; +}; + +Expr = Sizzle.selectors = { + + // Can be adjusted by the user + cacheLength: 50, + + createPseudo: markFunction, + + match: matchExpr, + + attrHandle: {}, + + find: {}, + + relative: { + ">": { dir: "parentNode", first: true }, + " ": { dir: "parentNode" }, + "+": { dir: "previousSibling", first: true }, + "~": { dir: "previousSibling" } + }, + + preFilter: { + "ATTR": function( match ) { + match[ 1 ] = match[ 1 ].replace( runescape, funescape ); + + // Move the given value to match[3] whether quoted or unquoted + match[ 3 ] = ( match[ 3 ] || match[ 4 ] || + match[ 5 ] || "" ).replace( runescape, funescape ); + + if ( match[ 2 ] === "~=" ) { + match[ 3 ] = " " + match[ 3 ] + " "; + } + + return match.slice( 0, 4 ); + }, + + "CHILD": function( match ) { + + /* matches from matchExpr["CHILD"] + 1 type (only|nth|...) + 2 what (child|of-type) + 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...) + 4 xn-component of xn+y argument ([+-]?\d*n|) + 5 sign of xn-component + 6 x of xn-component + 7 sign of y-component + 8 y of y-component + */ + match[ 1 ] = match[ 1 ].toLowerCase(); + + if ( match[ 1 ].slice( 0, 3 ) === "nth" ) { + + // nth-* requires argument + if ( !match[ 3 ] ) { + Sizzle.error( match[ 0 ] ); + } + + // numeric x and y parameters for Expr.filter.CHILD + // remember that false/true cast respectively to 0/1 + match[ 4 ] = +( match[ 4 ] ? + match[ 5 ] + ( match[ 6 ] || 1 ) : + 2 * ( match[ 3 ] === "even" || match[ 3 ] === "odd" ) ); + match[ 5 ] = +( ( match[ 7 ] + match[ 8 ] ) || match[ 3 ] === "odd" ); + + // other types prohibit arguments + } else if ( match[ 3 ] ) { + Sizzle.error( match[ 0 ] ); + } + + return match; + }, + + "PSEUDO": function( match ) { + var excess, + unquoted = !match[ 6 ] && match[ 2 ]; + + if ( matchExpr[ "CHILD" ].test( match[ 0 ] ) ) { + return null; + } + + // Accept quoted arguments as-is + if ( match[ 3 ] ) { + match[ 2 ] = match[ 4 ] || match[ 5 ] || ""; + + // Strip excess characters from unquoted arguments + } else if ( unquoted && rpseudo.test( unquoted ) && + + // Get excess from tokenize (recursively) + ( excess = tokenize( unquoted, true ) ) && + + // advance to the next closing parenthesis + ( excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length ) ) { + + // excess is a negative index + match[ 0 ] = match[ 0 ].slice( 0, excess ); + match[ 2 ] = unquoted.slice( 0, excess ); + } + + // Return only captures needed by the pseudo filter method (type and argument) + return match.slice( 0, 3 ); + } + }, + + filter: { + + "TAG": function( nodeNameSelector ) { + var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase(); + return nodeNameSelector === "*" ? + function() { + return true; + } : + function( elem ) { + return elem.nodeName && elem.nodeName.toLowerCase() === nodeName; + }; + }, + + "CLASS": function( className ) { + var pattern = classCache[ className + " " ]; + + return pattern || + ( pattern = new RegExp( "(^|" + whitespace + + ")" + className + "(" + whitespace + "|$)" ) ) && classCache( + className, function( elem ) { + return pattern.test( + typeof elem.className === "string" && elem.className || + typeof elem.getAttribute !== "undefined" && + elem.getAttribute( "class" ) || + "" + ); + } ); + }, + + "ATTR": function( name, operator, check ) { + return function( elem ) { + var result = Sizzle.attr( elem, name ); + + if ( result == null ) { + return operator === "!="; + } + if ( !operator ) { + return true; + } + + result += ""; + + /* eslint-disable max-len */ + + return operator === "=" ? result === check : + operator === "!=" ? result !== check : + operator === "^=" ? check && result.indexOf( check ) === 0 : + operator === "*=" ? check && result.indexOf( check ) > -1 : + operator === "$=" ? check && result.slice( -check.length ) === check : + operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 : + operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" : + false; + /* eslint-enable max-len */ + + }; + }, + + "CHILD": function( type, what, _argument, first, last ) { + var simple = type.slice( 0, 3 ) !== "nth", + forward = type.slice( -4 ) !== "last", + ofType = what === "of-type"; + + return first === 1 && last === 0 ? + + // Shortcut for :nth-*(n) + function( elem ) { + return !!elem.parentNode; + } : + + function( elem, _context, xml ) { + var cache, uniqueCache, outerCache, node, nodeIndex, start, + dir = simple !== forward ? "nextSibling" : "previousSibling", + parent = elem.parentNode, + name = ofType && elem.nodeName.toLowerCase(), + useCache = !xml && !ofType, + diff = false; + + if ( parent ) { + + // :(first|last|only)-(child|of-type) + if ( simple ) { + while ( dir ) { + node = elem; + while ( ( node = node[ dir ] ) ) { + if ( ofType ? + node.nodeName.toLowerCase() === name : + node.nodeType === 1 ) { + + return false; + } + } + + // Reverse direction for :only-* (if we haven't yet done so) + start = dir = type === "only" && !start && "nextSibling"; + } + return true; + } + + start = [ forward ? parent.firstChild : parent.lastChild ]; + + // non-xml :nth-child(...) stores cache data on `parent` + if ( forward && useCache ) { + + // Seek `elem` from a previously-cached index + + // ...in a gzip-friendly way + node = parent; + outerCache = node[ expando ] || ( node[ expando ] = {} ); + + // Support: IE <9 only + // Defend against cloned attroperties (jQuery gh-1709) + uniqueCache = outerCache[ node.uniqueID ] || + ( outerCache[ node.uniqueID ] = {} ); + + cache = uniqueCache[ type ] || []; + nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; + diff = nodeIndex && cache[ 2 ]; + node = nodeIndex && parent.childNodes[ nodeIndex ]; + + while ( ( node = ++nodeIndex && node && node[ dir ] || + + // Fallback to seeking `elem` from the start + ( diff = nodeIndex = 0 ) || start.pop() ) ) { + + // When found, cache indexes on `parent` and break + if ( node.nodeType === 1 && ++diff && node === elem ) { + uniqueCache[ type ] = [ dirruns, nodeIndex, diff ]; + break; + } + } + + } else { + + // Use previously-cached element index if available + if ( useCache ) { + + // ...in a gzip-friendly way + node = elem; + outerCache = node[ expando ] || ( node[ expando ] = {} ); + + // Support: IE <9 only + // Defend against cloned attroperties (jQuery gh-1709) + uniqueCache = outerCache[ node.uniqueID ] || + ( outerCache[ node.uniqueID ] = {} ); + + cache = uniqueCache[ type ] || []; + nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ]; + diff = nodeIndex; + } + + // xml :nth-child(...) + // or :nth-last-child(...) or :nth(-last)?-of-type(...) + if ( diff === false ) { + + // Use the same loop as above to seek `elem` from the start + while ( ( node = ++nodeIndex && node && node[ dir ] || + ( diff = nodeIndex = 0 ) || start.pop() ) ) { + + if ( ( ofType ? + node.nodeName.toLowerCase() === name : + node.nodeType === 1 ) && + ++diff ) { + + // Cache the index of each encountered element + if ( useCache ) { + outerCache = node[ expando ] || + ( node[ expando ] = {} ); + + // Support: IE <9 only + // Defend against cloned attroperties (jQuery gh-1709) + uniqueCache = outerCache[ node.uniqueID ] || + ( outerCache[ node.uniqueID ] = {} ); + + uniqueCache[ type ] = [ dirruns, diff ]; + } + + if ( node === elem ) { + break; + } + } + } + } + } + + // Incorporate the offset, then check against cycle size + diff -= last; + return diff === first || ( diff % first === 0 && diff / first >= 0 ); + } + }; + }, + + "PSEUDO": function( pseudo, argument ) { + + // pseudo-class names are case-insensitive + // http://www.w3.org/TR/selectors/#pseudo-classes + // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters + // Remember that setFilters inherits from pseudos + var args, + fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] || + Sizzle.error( "unsupported pseudo: " + pseudo ); + + // The user may use createPseudo to indicate that + // arguments are needed to create the filter function + // just as Sizzle does + if ( fn[ expando ] ) { + return fn( argument ); + } + + // But maintain support for old signatures + if ( fn.length > 1 ) { + args = [ pseudo, pseudo, "", argument ]; + return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ? + markFunction( function( seed, matches ) { + var idx, + matched = fn( seed, argument ), + i = matched.length; + while ( i-- ) { + idx = indexOf( seed, matched[ i ] ); + seed[ idx ] = !( matches[ idx ] = matched[ i ] ); + } + } ) : + function( elem ) { + return fn( elem, 0, args ); + }; + } + + return fn; + } + }, + + pseudos: { + + // Potentially complex pseudos + "not": markFunction( function( selector ) { + + // Trim the selector passed to compile + // to avoid treating leading and trailing + // spaces as combinators + var input = [], + results = [], + matcher = compile( selector.replace( rtrim, "$1" ) ); + + return matcher[ expando ] ? + markFunction( function( seed, matches, _context, xml ) { + var elem, + unmatched = matcher( seed, null, xml, [] ), + i = seed.length; + + // Match elements unmatched by `matcher` + while ( i-- ) { + if ( ( elem = unmatched[ i ] ) ) { + seed[ i ] = !( matches[ i ] = elem ); + } + } + } ) : + function( elem, _context, xml ) { + input[ 0 ] = elem; + matcher( input, null, xml, results ); + + // Don't keep the element (issue #299) + input[ 0 ] = null; + return !results.pop(); + }; + } ), + + "has": markFunction( function( selector ) { + return function( elem ) { + return Sizzle( selector, elem ).length > 0; + }; + } ), + + "contains": markFunction( function( text ) { + text = text.replace( runescape, funescape ); + return function( elem ) { + return ( elem.textContent || getText( elem ) ).indexOf( text ) > -1; + }; + } ), + + // "Whether an element is represented by a :lang() selector + // is based solely on the element's language value + // being equal to the identifier C, + // or beginning with the identifier C immediately followed by "-". + // The matching of C against the element's language value is performed case-insensitively. + // The identifier C does not have to be a valid language name." + // http://www.w3.org/TR/selectors/#lang-pseudo + "lang": markFunction( function( lang ) { + + // lang value must be a valid identifier + if ( !ridentifier.test( lang || "" ) ) { + Sizzle.error( "unsupported lang: " + lang ); + } + lang = lang.replace( runescape, funescape ).toLowerCase(); + return function( elem ) { + var elemLang; + do { + if ( ( elemLang = documentIsHTML ? + elem.lang : + elem.getAttribute( "xml:lang" ) || elem.getAttribute( "lang" ) ) ) { + + elemLang = elemLang.toLowerCase(); + return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0; + } + } while ( ( elem = elem.parentNode ) && elem.nodeType === 1 ); + return false; + }; + } ), + + // Miscellaneous + "target": function( elem ) { + var hash = window.location && window.location.hash; + return hash && hash.slice( 1 ) === elem.id; + }, + + "root": function( elem ) { + return elem === docElem; + }, + + "focus": function( elem ) { + return elem === document.activeElement && + ( !document.hasFocus || document.hasFocus() ) && + !!( elem.type || elem.href || ~elem.tabIndex ); + }, + + // Boolean properties + "enabled": createDisabledPseudo( false ), + "disabled": createDisabledPseudo( true ), + + "checked": function( elem ) { + + // In CSS3, :checked should return both checked and selected elements + // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked + var nodeName = elem.nodeName.toLowerCase(); + return ( nodeName === "input" && !!elem.checked ) || + ( nodeName === "option" && !!elem.selected ); + }, + + "selected": function( elem ) { + + // Accessing this property makes selected-by-default + // options in Safari work properly + if ( elem.parentNode ) { + // eslint-disable-next-line no-unused-expressions + elem.parentNode.selectedIndex; + } + + return elem.selected === true; + }, + + // Contents + "empty": function( elem ) { + + // http://www.w3.org/TR/selectors/#empty-pseudo + // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5), + // but not by others (comment: 8; processing instruction: 7; etc.) + // nodeType < 6 works because attributes (2) do not appear as children + for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) { + if ( elem.nodeType < 6 ) { + return false; + } + } + return true; + }, + + "parent": function( elem ) { + return !Expr.pseudos[ "empty" ]( elem ); + }, + + // Element/input types + "header": function( elem ) { + return rheader.test( elem.nodeName ); + }, + + "input": function( elem ) { + return rinputs.test( elem.nodeName ); + }, + + "button": function( elem ) { + var name = elem.nodeName.toLowerCase(); + return name === "input" && elem.type === "button" || name === "button"; + }, + + "text": function( elem ) { + var attr; + return elem.nodeName.toLowerCase() === "input" && + elem.type === "text" && + + // Support: IE<8 + // New HTML5 attribute values (e.g., "search") appear with elem.type === "text" + ( ( attr = elem.getAttribute( "type" ) ) == null || + attr.toLowerCase() === "text" ); + }, + + // Position-in-collection + "first": createPositionalPseudo( function() { + return [ 0 ]; + } ), + + "last": createPositionalPseudo( function( _matchIndexes, length ) { + return [ length - 1 ]; + } ), + + "eq": createPositionalPseudo( function( _matchIndexes, length, argument ) { + return [ argument < 0 ? argument + length : argument ]; + } ), + + "even": createPositionalPseudo( function( matchIndexes, length ) { + var i = 0; + for ( ; i < length; i += 2 ) { + matchIndexes.push( i ); + } + return matchIndexes; + } ), + + "odd": createPositionalPseudo( function( matchIndexes, length ) { + var i = 1; + for ( ; i < length; i += 2 ) { + matchIndexes.push( i ); + } + return matchIndexes; + } ), + + "lt": createPositionalPseudo( function( matchIndexes, length, argument ) { + var i = argument < 0 ? + argument + length : + argument > length ? + length : + argument; + for ( ; --i >= 0; ) { + matchIndexes.push( i ); + } + return matchIndexes; + } ), + + "gt": createPositionalPseudo( function( matchIndexes, length, argument ) { + var i = argument < 0 ? argument + length : argument; + for ( ; ++i < length; ) { + matchIndexes.push( i ); + } + return matchIndexes; + } ) + } +}; + +Expr.pseudos[ "nth" ] = Expr.pseudos[ "eq" ]; + +// Add button/input type pseudos +for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) { + Expr.pseudos[ i ] = createInputPseudo( i ); +} +for ( i in { submit: true, reset: true } ) { + Expr.pseudos[ i ] = createButtonPseudo( i ); +} + +// Easy API for creating new setFilters +function setFilters() {} +setFilters.prototype = Expr.filters = Expr.pseudos; +Expr.setFilters = new setFilters(); + +tokenize = Sizzle.tokenize = function( selector, parseOnly ) { + var matched, match, tokens, type, + soFar, groups, preFilters, + cached = tokenCache[ selector + " " ]; + + if ( cached ) { + return parseOnly ? 0 : cached.slice( 0 ); + } + + soFar = selector; + groups = []; + preFilters = Expr.preFilter; + + while ( soFar ) { + + // Comma and first run + if ( !matched || ( match = rcomma.exec( soFar ) ) ) { + if ( match ) { + + // Don't consume trailing commas as valid + soFar = soFar.slice( match[ 0 ].length ) || soFar; + } + groups.push( ( tokens = [] ) ); + } + + matched = false; + + // Combinators + if ( ( match = rcombinators.exec( soFar ) ) ) { + matched = match.shift(); + tokens.push( { + value: matched, + + // Cast descendant combinators to space + type: match[ 0 ].replace( rtrim, " " ) + } ); + soFar = soFar.slice( matched.length ); + } + + // Filters + for ( type in Expr.filter ) { + if ( ( match = matchExpr[ type ].exec( soFar ) ) && ( !preFilters[ type ] || + ( match = preFilters[ type ]( match ) ) ) ) { + matched = match.shift(); + tokens.push( { + value: matched, + type: type, + matches: match + } ); + soFar = soFar.slice( matched.length ); + } + } + + if ( !matched ) { + break; + } + } + + // Return the length of the invalid excess + // if we're just parsing + // Otherwise, throw an error or return tokens + return parseOnly ? + soFar.length : + soFar ? + Sizzle.error( selector ) : + + // Cache the tokens + tokenCache( selector, groups ).slice( 0 ); +}; + +function toSelector( tokens ) { + var i = 0, + len = tokens.length, + selector = ""; + for ( ; i < len; i++ ) { + selector += tokens[ i ].value; + } + return selector; +} + +function addCombinator( matcher, combinator, base ) { + var dir = combinator.dir, + skip = combinator.next, + key = skip || dir, + checkNonElements = base && key === "parentNode", + doneName = done++; + + return combinator.first ? + + // Check against closest ancestor/preceding element + function( elem, context, xml ) { + while ( ( elem = elem[ dir ] ) ) { + if ( elem.nodeType === 1 || checkNonElements ) { + return matcher( elem, context, xml ); + } + } + return false; + } : + + // Check against all ancestor/preceding elements + function( elem, context, xml ) { + var oldCache, uniqueCache, outerCache, + newCache = [ dirruns, doneName ]; + + // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching + if ( xml ) { + while ( ( elem = elem[ dir ] ) ) { + if ( elem.nodeType === 1 || checkNonElements ) { + if ( matcher( elem, context, xml ) ) { + return true; + } + } + } + } else { + while ( ( elem = elem[ dir ] ) ) { + if ( elem.nodeType === 1 || checkNonElements ) { + outerCache = elem[ expando ] || ( elem[ expando ] = {} ); + + // Support: IE <9 only + // Defend against cloned attroperties (jQuery gh-1709) + uniqueCache = outerCache[ elem.uniqueID ] || + ( outerCache[ elem.uniqueID ] = {} ); + + if ( skip && skip === elem.nodeName.toLowerCase() ) { + elem = elem[ dir ] || elem; + } else if ( ( oldCache = uniqueCache[ key ] ) && + oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) { + + // Assign to newCache so results back-propagate to previous elements + return ( newCache[ 2 ] = oldCache[ 2 ] ); + } else { + + // Reuse newcache so results back-propagate to previous elements + uniqueCache[ key ] = newCache; + + // A match means we're done; a fail means we have to keep checking + if ( ( newCache[ 2 ] = matcher( elem, context, xml ) ) ) { + return true; + } + } + } + } + } + return false; + }; +} + +function elementMatcher( matchers ) { + return matchers.length > 1 ? + function( elem, context, xml ) { + var i = matchers.length; + while ( i-- ) { + if ( !matchers[ i ]( elem, context, xml ) ) { + return false; + } + } + return true; + } : + matchers[ 0 ]; +} + +function multipleContexts( selector, contexts, results ) { + var i = 0, + len = contexts.length; + for ( ; i < len; i++ ) { + Sizzle( selector, contexts[ i ], results ); + } + return results; +} + +function condense( unmatched, map, filter, context, xml ) { + var elem, + newUnmatched = [], + i = 0, + len = unmatched.length, + mapped = map != null; + + for ( ; i < len; i++ ) { + if ( ( elem = unmatched[ i ] ) ) { + if ( !filter || filter( elem, context, xml ) ) { + newUnmatched.push( elem ); + if ( mapped ) { + map.push( i ); + } + } + } + } + + return newUnmatched; +} + +function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) { + if ( postFilter && !postFilter[ expando ] ) { + postFilter = setMatcher( postFilter ); + } + if ( postFinder && !postFinder[ expando ] ) { + postFinder = setMatcher( postFinder, postSelector ); + } + return markFunction( function( seed, results, context, xml ) { + var temp, i, elem, + preMap = [], + postMap = [], + preexisting = results.length, + + // Get initial elements from seed or context + elems = seed || multipleContexts( + selector || "*", + context.nodeType ? [ context ] : context, + [] + ), + + // Prefilter to get matcher input, preserving a map for seed-results synchronization + matcherIn = preFilter && ( seed || !selector ) ? + condense( elems, preMap, preFilter, context, xml ) : + elems, + + matcherOut = matcher ? + + // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results, + postFinder || ( seed ? preFilter : preexisting || postFilter ) ? + + // ...intermediate processing is necessary + [] : + + // ...otherwise use results directly + results : + matcherIn; + + // Find primary matches + if ( matcher ) { + matcher( matcherIn, matcherOut, context, xml ); + } + + // Apply postFilter + if ( postFilter ) { + temp = condense( matcherOut, postMap ); + postFilter( temp, [], context, xml ); + + // Un-match failing elements by moving them back to matcherIn + i = temp.length; + while ( i-- ) { + if ( ( elem = temp[ i ] ) ) { + matcherOut[ postMap[ i ] ] = !( matcherIn[ postMap[ i ] ] = elem ); + } + } + } + + if ( seed ) { + if ( postFinder || preFilter ) { + if ( postFinder ) { + + // Get the final matcherOut by condensing this intermediate into postFinder contexts + temp = []; + i = matcherOut.length; + while ( i-- ) { + if ( ( elem = matcherOut[ i ] ) ) { + + // Restore matcherIn since elem is not yet a final match + temp.push( ( matcherIn[ i ] = elem ) ); + } + } + postFinder( null, ( matcherOut = [] ), temp, xml ); + } + + // Move matched elements from seed to results to keep them synchronized + i = matcherOut.length; + while ( i-- ) { + if ( ( elem = matcherOut[ i ] ) && + ( temp = postFinder ? indexOf( seed, elem ) : preMap[ i ] ) > -1 ) { + + seed[ temp ] = !( results[ temp ] = elem ); + } + } + } + + // Add elements to results, through postFinder if defined + } else { + matcherOut = condense( + matcherOut === results ? + matcherOut.splice( preexisting, matcherOut.length ) : + matcherOut + ); + if ( postFinder ) { + postFinder( null, results, matcherOut, xml ); + } else { + push.apply( results, matcherOut ); + } + } + } ); +} + +function matcherFromTokens( tokens ) { + var checkContext, matcher, j, + len = tokens.length, + leadingRelative = Expr.relative[ tokens[ 0 ].type ], + implicitRelative = leadingRelative || Expr.relative[ " " ], + i = leadingRelative ? 1 : 0, + + // The foundational matcher ensures that elements are reachable from top-level context(s) + matchContext = addCombinator( function( elem ) { + return elem === checkContext; + }, implicitRelative, true ), + matchAnyContext = addCombinator( function( elem ) { + return indexOf( checkContext, elem ) > -1; + }, implicitRelative, true ), + matchers = [ function( elem, context, xml ) { + var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( + ( checkContext = context ).nodeType ? + matchContext( elem, context, xml ) : + matchAnyContext( elem, context, xml ) ); + + // Avoid hanging onto element (issue #299) + checkContext = null; + return ret; + } ]; + + for ( ; i < len; i++ ) { + if ( ( matcher = Expr.relative[ tokens[ i ].type ] ) ) { + matchers = [ addCombinator( elementMatcher( matchers ), matcher ) ]; + } else { + matcher = Expr.filter[ tokens[ i ].type ].apply( null, tokens[ i ].matches ); + + // Return special upon seeing a positional matcher + if ( matcher[ expando ] ) { + + // Find the next relative operator (if any) for proper handling + j = ++i; + for ( ; j < len; j++ ) { + if ( Expr.relative[ tokens[ j ].type ] ) { + break; + } + } + return setMatcher( + i > 1 && elementMatcher( matchers ), + i > 1 && toSelector( + + // If the preceding token was a descendant combinator, insert an implicit any-element `*` + tokens + .slice( 0, i - 1 ) + .concat( { value: tokens[ i - 2 ].type === " " ? "*" : "" } ) + ).replace( rtrim, "$1" ), + matcher, + i < j && matcherFromTokens( tokens.slice( i, j ) ), + j < len && matcherFromTokens( ( tokens = tokens.slice( j ) ) ), + j < len && toSelector( tokens ) + ); + } + matchers.push( matcher ); + } + } + + return elementMatcher( matchers ); +} + +function matcherFromGroupMatchers( elementMatchers, setMatchers ) { + var bySet = setMatchers.length > 0, + byElement = elementMatchers.length > 0, + superMatcher = function( seed, context, xml, results, outermost ) { + var elem, j, matcher, + matchedCount = 0, + i = "0", + unmatched = seed && [], + setMatched = [], + contextBackup = outermostContext, + + // We must always have either seed elements or outermost context + elems = seed || byElement && Expr.find[ "TAG" ]( "*", outermost ), + + // Use integer dirruns iff this is the outermost matcher + dirrunsUnique = ( dirruns += contextBackup == null ? 1 : Math.random() || 0.1 ), + len = elems.length; + + if ( outermost ) { + + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + outermostContext = context == document || context || outermost; + } + + // Add elements passing elementMatchers directly to results + // Support: IE<9, Safari + // Tolerate NodeList properties (IE: "length"; Safari: ) matching elements by id + for ( ; i !== len && ( elem = elems[ i ] ) != null; i++ ) { + if ( byElement && elem ) { + j = 0; + + // Support: IE 11+, Edge 17 - 18+ + // IE/Edge sometimes throw a "Permission denied" error when strict-comparing + // two documents; shallow comparisons work. + // eslint-disable-next-line eqeqeq + if ( !context && elem.ownerDocument != document ) { + setDocument( elem ); + xml = !documentIsHTML; + } + while ( ( matcher = elementMatchers[ j++ ] ) ) { + if ( matcher( elem, context || document, xml ) ) { + results.push( elem ); + break; + } + } + if ( outermost ) { + dirruns = dirrunsUnique; + } + } + + // Track unmatched elements for set filters + if ( bySet ) { + + // They will have gone through all possible matchers + if ( ( elem = !matcher && elem ) ) { + matchedCount--; + } + + // Lengthen the array for every element, matched or not + if ( seed ) { + unmatched.push( elem ); + } + } + } + + // `i` is now the count of elements visited above, and adding it to `matchedCount` + // makes the latter nonnegative. + matchedCount += i; + + // Apply set filters to unmatched elements + // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount` + // equals `i`), unless we didn't visit _any_ elements in the above loop because we have + // no element matchers and no seed. + // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that + // case, which will result in a "00" `matchedCount` that differs from `i` but is also + // numerically zero. + if ( bySet && i !== matchedCount ) { + j = 0; + while ( ( matcher = setMatchers[ j++ ] ) ) { + matcher( unmatched, setMatched, context, xml ); + } + + if ( seed ) { + + // Reintegrate element matches to eliminate the need for sorting + if ( matchedCount > 0 ) { + while ( i-- ) { + if ( !( unmatched[ i ] || setMatched[ i ] ) ) { + setMatched[ i ] = pop.call( results ); + } + } + } + + // Discard index placeholder values to get only actual matches + setMatched = condense( setMatched ); + } + + // Add matches to results + push.apply( results, setMatched ); + + // Seedless set matches succeeding multiple successful matchers stipulate sorting + if ( outermost && !seed && setMatched.length > 0 && + ( matchedCount + setMatchers.length ) > 1 ) { + + Sizzle.uniqueSort( results ); + } + } + + // Override manipulation of globals by nested matchers + if ( outermost ) { + dirruns = dirrunsUnique; + outermostContext = contextBackup; + } + + return unmatched; + }; + + return bySet ? + markFunction( superMatcher ) : + superMatcher; +} + +compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) { + var i, + setMatchers = [], + elementMatchers = [], + cached = compilerCache[ selector + " " ]; + + if ( !cached ) { + + // Generate a function of recursive functions that can be used to check each element + if ( !match ) { + match = tokenize( selector ); + } + i = match.length; + while ( i-- ) { + cached = matcherFromTokens( match[ i ] ); + if ( cached[ expando ] ) { + setMatchers.push( cached ); + } else { + elementMatchers.push( cached ); + } + } + + // Cache the compiled function + cached = compilerCache( + selector, + matcherFromGroupMatchers( elementMatchers, setMatchers ) + ); + + // Save selector and tokenization + cached.selector = selector; + } + return cached; +}; + +/** + * A low-level selection function that works with Sizzle's compiled + * selector functions + * @param {String|Function} selector A selector or a pre-compiled + * selector function built with Sizzle.compile + * @param {Element} context + * @param {Array} [results] + * @param {Array} [seed] A set of elements to match against + */ +select = Sizzle.select = function( selector, context, results, seed ) { + var i, tokens, token, type, find, + compiled = typeof selector === "function" && selector, + match = !seed && tokenize( ( selector = compiled.selector || selector ) ); + + results = results || []; + + // Try to minimize operations if there is only one selector in the list and no seed + // (the latter of which guarantees us context) + if ( match.length === 1 ) { + + // Reduce context if the leading compound selector is an ID + tokens = match[ 0 ] = match[ 0 ].slice( 0 ); + if ( tokens.length > 2 && ( token = tokens[ 0 ] ).type === "ID" && + context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[ 1 ].type ] ) { + + context = ( Expr.find[ "ID" ]( token.matches[ 0 ] + .replace( runescape, funescape ), context ) || [] )[ 0 ]; + if ( !context ) { + return results; + + // Precompiled matchers will still verify ancestry, so step up a level + } else if ( compiled ) { + context = context.parentNode; + } + + selector = selector.slice( tokens.shift().value.length ); + } + + // Fetch a seed set for right-to-left matching + i = matchExpr[ "needsContext" ].test( selector ) ? 0 : tokens.length; + while ( i-- ) { + token = tokens[ i ]; + + // Abort if we hit a combinator + if ( Expr.relative[ ( type = token.type ) ] ) { + break; + } + if ( ( find = Expr.find[ type ] ) ) { + + // Search, expanding context for leading sibling combinators + if ( ( seed = find( + token.matches[ 0 ].replace( runescape, funescape ), + rsibling.test( tokens[ 0 ].type ) && testContext( context.parentNode ) || + context + ) ) ) { + + // If seed is empty or no tokens remain, we can return early + tokens.splice( i, 1 ); + selector = seed.length && toSelector( tokens ); + if ( !selector ) { + push.apply( results, seed ); + return results; + } + + break; + } + } + } + } + + // Compile and execute a filtering function if one is not provided + // Provide `match` to avoid retokenization if we modified the selector above + ( compiled || compile( selector, match ) )( + seed, + context, + !documentIsHTML, + results, + !context || rsibling.test( selector ) && testContext( context.parentNode ) || context + ); + return results; +}; + +// One-time assignments + +// Sort stability +support.sortStable = expando.split( "" ).sort( sortOrder ).join( "" ) === expando; + +// Support: Chrome 14-35+ +// Always assume duplicates if they aren't passed to the comparison function +support.detectDuplicates = !!hasDuplicate; + +// Initialize against the default document +setDocument(); + +// Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27) +// Detached nodes confoundingly follow *each other* +support.sortDetached = assert( function( el ) { + + // Should return 1, but returns 4 (following) + return el.compareDocumentPosition( document.createElement( "fieldset" ) ) & 1; +} ); + +// Support: IE<8 +// Prevent attribute/property "interpolation" +// https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx +if ( !assert( function( el ) { + el.innerHTML = ""; + return el.firstChild.getAttribute( "href" ) === "#"; +} ) ) { + addHandle( "type|href|height|width", function( elem, name, isXML ) { + if ( !isXML ) { + return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 ); + } + } ); +} + +// Support: IE<9 +// Use defaultValue in place of getAttribute("value") +if ( !support.attributes || !assert( function( el ) { + el.innerHTML = ""; + el.firstChild.setAttribute( "value", "" ); + return el.firstChild.getAttribute( "value" ) === ""; +} ) ) { + addHandle( "value", function( elem, _name, isXML ) { + if ( !isXML && elem.nodeName.toLowerCase() === "input" ) { + return elem.defaultValue; + } + } ); +} + +// Support: IE<9 +// Use getAttributeNode to fetch booleans when getAttribute lies +if ( !assert( function( el ) { + return el.getAttribute( "disabled" ) == null; +} ) ) { + addHandle( booleans, function( elem, name, isXML ) { + var val; + if ( !isXML ) { + return elem[ name ] === true ? name.toLowerCase() : + ( val = elem.getAttributeNode( name ) ) && val.specified ? + val.value : + null; + } + } ); +} + +return Sizzle; + +} )( window ); + + + +jQuery.find = Sizzle; +jQuery.expr = Sizzle.selectors; + +// Deprecated +jQuery.expr[ ":" ] = jQuery.expr.pseudos; +jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort; +jQuery.text = Sizzle.getText; +jQuery.isXMLDoc = Sizzle.isXML; +jQuery.contains = Sizzle.contains; +jQuery.escapeSelector = Sizzle.escape; + + + + +var dir = function( elem, dir, until ) { + var matched = [], + truncate = until !== undefined; + + while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) { + if ( elem.nodeType === 1 ) { + if ( truncate && jQuery( elem ).is( until ) ) { + break; + } + matched.push( elem ); + } + } + return matched; +}; + + +var siblings = function( n, elem ) { + var matched = []; + + for ( ; n; n = n.nextSibling ) { + if ( n.nodeType === 1 && n !== elem ) { + matched.push( n ); + } + } + + return matched; +}; + + +var rneedsContext = jQuery.expr.match.needsContext; + + + +function nodeName( elem, name ) { + + return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase(); + +} +var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i ); + + + +// Implement the identical functionality for filter and not +function winnow( elements, qualifier, not ) { + if ( isFunction( qualifier ) ) { + return jQuery.grep( elements, function( elem, i ) { + return !!qualifier.call( elem, i, elem ) !== not; + } ); + } + + // Single element + if ( qualifier.nodeType ) { + return jQuery.grep( elements, function( elem ) { + return ( elem === qualifier ) !== not; + } ); + } + + // Arraylike of elements (jQuery, arguments, Array) + if ( typeof qualifier !== "string" ) { + return jQuery.grep( elements, function( elem ) { + return ( indexOf.call( qualifier, elem ) > -1 ) !== not; + } ); + } + + // Filtered directly for both simple and complex selectors + return jQuery.filter( qualifier, elements, not ); +} + +jQuery.filter = function( expr, elems, not ) { + var elem = elems[ 0 ]; + + if ( not ) { + expr = ":not(" + expr + ")"; + } + + if ( elems.length === 1 && elem.nodeType === 1 ) { + return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : []; + } + + return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) { + return elem.nodeType === 1; + } ) ); +}; + +jQuery.fn.extend( { + find: function( selector ) { + var i, ret, + len = this.length, + self = this; + + if ( typeof selector !== "string" ) { + return this.pushStack( jQuery( selector ).filter( function() { + for ( i = 0; i < len; i++ ) { + if ( jQuery.contains( self[ i ], this ) ) { + return true; + } + } + } ) ); + } + + ret = this.pushStack( [] ); + + for ( i = 0; i < len; i++ ) { + jQuery.find( selector, self[ i ], ret ); + } + + return len > 1 ? jQuery.uniqueSort( ret ) : ret; + }, + filter: function( selector ) { + return this.pushStack( winnow( this, selector || [], false ) ); + }, + not: function( selector ) { + return this.pushStack( winnow( this, selector || [], true ) ); + }, + is: function( selector ) { + return !!winnow( + this, + + // If this is a positional/relative selector, check membership in the returned set + // so $("p:first").is("p:last") won't return true for a doc with two "p". + typeof selector === "string" && rneedsContext.test( selector ) ? + jQuery( selector ) : + selector || [], + false + ).length; + } +} ); + + +// Initialize a jQuery object + + +// A central reference to the root jQuery(document) +var rootjQuery, + + // A simple way to check for HTML strings + // Prioritize #id over to avoid XSS via location.hash (#9521) + // Strict HTML recognition (#11290: must start with <) + // Shortcut simple #id case for speed + rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/, + + init = jQuery.fn.init = function( selector, context, root ) { + var match, elem; + + // HANDLE: $(""), $(null), $(undefined), $(false) + if ( !selector ) { + return this; + } + + // Method init() accepts an alternate rootjQuery + // so migrate can support jQuery.sub (gh-2101) + root = root || rootjQuery; + + // Handle HTML strings + if ( typeof selector === "string" ) { + if ( selector[ 0 ] === "<" && + selector[ selector.length - 1 ] === ">" && + selector.length >= 3 ) { + + // Assume that strings that start and end with <> are HTML and skip the regex check + match = [ null, selector, null ]; + + } else { + match = rquickExpr.exec( selector ); + } + + // Match html or make sure no context is specified for #id + if ( match && ( match[ 1 ] || !context ) ) { + + // HANDLE: $(html) -> $(array) + if ( match[ 1 ] ) { + context = context instanceof jQuery ? context[ 0 ] : context; + + // Option to run scripts is true for back-compat + // Intentionally let the error be thrown if parseHTML is not present + jQuery.merge( this, jQuery.parseHTML( + match[ 1 ], + context && context.nodeType ? context.ownerDocument || context : document, + true + ) ); + + // HANDLE: $(html, props) + if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) { + for ( match in context ) { + + // Properties of context are called as methods if possible + if ( isFunction( this[ match ] ) ) { + this[ match ]( context[ match ] ); + + // ...and otherwise set as attributes + } else { + this.attr( match, context[ match ] ); + } + } + } + + return this; + + // HANDLE: $(#id) + } else { + elem = document.getElementById( match[ 2 ] ); + + if ( elem ) { + + // Inject the element directly into the jQuery object + this[ 0 ] = elem; + this.length = 1; + } + return this; + } + + // HANDLE: $(expr, $(...)) + } else if ( !context || context.jquery ) { + return ( context || root ).find( selector ); + + // HANDLE: $(expr, context) + // (which is just equivalent to: $(context).find(expr) + } else { + return this.constructor( context ).find( selector ); + } + + // HANDLE: $(DOMElement) + } else if ( selector.nodeType ) { + this[ 0 ] = selector; + this.length = 1; + return this; + + // HANDLE: $(function) + // Shortcut for document ready + } else if ( isFunction( selector ) ) { + return root.ready !== undefined ? + root.ready( selector ) : + + // Execute immediately if ready is not present + selector( jQuery ); + } + + return jQuery.makeArray( selector, this ); + }; + +// Give the init function the jQuery prototype for later instantiation +init.prototype = jQuery.fn; + +// Initialize central reference +rootjQuery = jQuery( document ); + + +var rparentsprev = /^(?:parents|prev(?:Until|All))/, + + // Methods guaranteed to produce a unique set when starting from a unique set + guaranteedUnique = { + children: true, + contents: true, + next: true, + prev: true + }; + +jQuery.fn.extend( { + has: function( target ) { + var targets = jQuery( target, this ), + l = targets.length; + + return this.filter( function() { + var i = 0; + for ( ; i < l; i++ ) { + if ( jQuery.contains( this, targets[ i ] ) ) { + return true; + } + } + } ); + }, + + closest: function( selectors, context ) { + var cur, + i = 0, + l = this.length, + matched = [], + targets = typeof selectors !== "string" && jQuery( selectors ); + + // Positional selectors never match, since there's no _selection_ context + if ( !rneedsContext.test( selectors ) ) { + for ( ; i < l; i++ ) { + for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) { + + // Always skip document fragments + if ( cur.nodeType < 11 && ( targets ? + targets.index( cur ) > -1 : + + // Don't pass non-elements to Sizzle + cur.nodeType === 1 && + jQuery.find.matchesSelector( cur, selectors ) ) ) { + + matched.push( cur ); + break; + } + } + } + } + + return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched ); + }, + + // Determine the position of an element within the set + index: function( elem ) { + + // No argument, return index in parent + if ( !elem ) { + return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1; + } + + // Index in selector + if ( typeof elem === "string" ) { + return indexOf.call( jQuery( elem ), this[ 0 ] ); + } + + // Locate the position of the desired element + return indexOf.call( this, + + // If it receives a jQuery object, the first element is used + elem.jquery ? elem[ 0 ] : elem + ); + }, + + add: function( selector, context ) { + return this.pushStack( + jQuery.uniqueSort( + jQuery.merge( this.get(), jQuery( selector, context ) ) + ) + ); + }, + + addBack: function( selector ) { + return this.add( selector == null ? + this.prevObject : this.prevObject.filter( selector ) + ); + } +} ); + +function sibling( cur, dir ) { + while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {} + return cur; +} + +jQuery.each( { + parent: function( elem ) { + var parent = elem.parentNode; + return parent && parent.nodeType !== 11 ? parent : null; + }, + parents: function( elem ) { + return dir( elem, "parentNode" ); + }, + parentsUntil: function( elem, _i, until ) { + return dir( elem, "parentNode", until ); + }, + next: function( elem ) { + return sibling( elem, "nextSibling" ); + }, + prev: function( elem ) { + return sibling( elem, "previousSibling" ); + }, + nextAll: function( elem ) { + return dir( elem, "nextSibling" ); + }, + prevAll: function( elem ) { + return dir( elem, "previousSibling" ); + }, + nextUntil: function( elem, _i, until ) { + return dir( elem, "nextSibling", until ); + }, + prevUntil: function( elem, _i, until ) { + return dir( elem, "previousSibling", until ); + }, + siblings: function( elem ) { + return siblings( ( elem.parentNode || {} ).firstChild, elem ); + }, + children: function( elem ) { + return siblings( elem.firstChild ); + }, + contents: function( elem ) { + if ( elem.contentDocument != null && + + // Support: IE 11+ + // elements with no `data` attribute has an object + // `contentDocument` with a `null` prototype. + getProto( elem.contentDocument ) ) { + + return elem.contentDocument; + } + + // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only + // Treat the template element as a regular one in browsers that + // don't support it. + if ( nodeName( elem, "template" ) ) { + elem = elem.content || elem; + } + + return jQuery.merge( [], elem.childNodes ); + } +}, function( name, fn ) { + jQuery.fn[ name ] = function( until, selector ) { + var matched = jQuery.map( this, fn, until ); + + if ( name.slice( -5 ) !== "Until" ) { + selector = until; + } + + if ( selector && typeof selector === "string" ) { + matched = jQuery.filter( selector, matched ); + } + + if ( this.length > 1 ) { + + // Remove duplicates + if ( !guaranteedUnique[ name ] ) { + jQuery.uniqueSort( matched ); + } + + // Reverse order for parents* and prev-derivatives + if ( rparentsprev.test( name ) ) { + matched.reverse(); + } + } + + return this.pushStack( matched ); + }; +} ); +var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g ); + + + +// Convert String-formatted options into Object-formatted ones +function createOptions( options ) { + var object = {}; + jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) { + object[ flag ] = true; + } ); + return object; +} + +/* + * Create a callback list using the following parameters: + * + * options: an optional list of space-separated options that will change how + * the callback list behaves or a more traditional option object + * + * By default a callback list will act like an event callback list and can be + * "fired" multiple times. + * + * Possible options: + * + * once: will ensure the callback list can only be fired once (like a Deferred) + * + * memory: will keep track of previous values and will call any callback added + * after the list has been fired right away with the latest "memorized" + * values (like a Deferred) + * + * unique: will ensure a callback can only be added once (no duplicate in the list) + * + * stopOnFalse: interrupt callings when a callback returns false + * + */ +jQuery.Callbacks = function( options ) { + + // Convert options from String-formatted to Object-formatted if needed + // (we check in cache first) + options = typeof options === "string" ? + createOptions( options ) : + jQuery.extend( {}, options ); + + var // Flag to know if list is currently firing + firing, + + // Last fire value for non-forgettable lists + memory, + + // Flag to know if list was already fired + fired, + + // Flag to prevent firing + locked, + + // Actual callback list + list = [], + + // Queue of execution data for repeatable lists + queue = [], + + // Index of currently firing callback (modified by add/remove as needed) + firingIndex = -1, + + // Fire callbacks + fire = function() { + + // Enforce single-firing + locked = locked || options.once; + + // Execute callbacks for all pending executions, + // respecting firingIndex overrides and runtime changes + fired = firing = true; + for ( ; queue.length; firingIndex = -1 ) { + memory = queue.shift(); + while ( ++firingIndex < list.length ) { + + // Run callback and check for early termination + if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false && + options.stopOnFalse ) { + + // Jump to end and forget the data so .add doesn't re-fire + firingIndex = list.length; + memory = false; + } + } + } + + // Forget the data if we're done with it + if ( !options.memory ) { + memory = false; + } + + firing = false; + + // Clean up if we're done firing for good + if ( locked ) { + + // Keep an empty list if we have data for future add calls + if ( memory ) { + list = []; + + // Otherwise, this object is spent + } else { + list = ""; + } + } + }, + + // Actual Callbacks object + self = { + + // Add a callback or a collection of callbacks to the list + add: function() { + if ( list ) { + + // If we have memory from a past run, we should fire after adding + if ( memory && !firing ) { + firingIndex = list.length - 1; + queue.push( memory ); + } + + ( function add( args ) { + jQuery.each( args, function( _, arg ) { + if ( isFunction( arg ) ) { + if ( !options.unique || !self.has( arg ) ) { + list.push( arg ); + } + } else if ( arg && arg.length && toType( arg ) !== "string" ) { + + // Inspect recursively + add( arg ); + } + } ); + } )( arguments ); + + if ( memory && !firing ) { + fire(); + } + } + return this; + }, + + // Remove a callback from the list + remove: function() { + jQuery.each( arguments, function( _, arg ) { + var index; + while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) { + list.splice( index, 1 ); + + // Handle firing indexes + if ( index <= firingIndex ) { + firingIndex--; + } + } + } ); + return this; + }, + + // Check if a given callback is in the list. + // If no argument is given, return whether or not list has callbacks attached. + has: function( fn ) { + return fn ? + jQuery.inArray( fn, list ) > -1 : + list.length > 0; + }, + + // Remove all callbacks from the list + empty: function() { + if ( list ) { + list = []; + } + return this; + }, + + // Disable .fire and .add + // Abort any current/pending executions + // Clear all callbacks and values + disable: function() { + locked = queue = []; + list = memory = ""; + return this; + }, + disabled: function() { + return !list; + }, + + // Disable .fire + // Also disable .add unless we have memory (since it would have no effect) + // Abort any pending executions + lock: function() { + locked = queue = []; + if ( !memory && !firing ) { + list = memory = ""; + } + return this; + }, + locked: function() { + return !!locked; + }, + + // Call all callbacks with the given context and arguments + fireWith: function( context, args ) { + if ( !locked ) { + args = args || []; + args = [ context, args.slice ? args.slice() : args ]; + queue.push( args ); + if ( !firing ) { + fire(); + } + } + return this; + }, + + // Call all the callbacks with the given arguments + fire: function() { + self.fireWith( this, arguments ); + return this; + }, + + // To know if the callbacks have already been called at least once + fired: function() { + return !!fired; + } + }; + + return self; +}; + + +function Identity( v ) { + return v; +} +function Thrower( ex ) { + throw ex; +} + +function adoptValue( value, resolve, reject, noValue ) { + var method; + + try { + + // Check for promise aspect first to privilege synchronous behavior + if ( value && isFunction( ( method = value.promise ) ) ) { + method.call( value ).done( resolve ).fail( reject ); + + // Other thenables + } else if ( value && isFunction( ( method = value.then ) ) ) { + method.call( value, resolve, reject ); + + // Other non-thenables + } else { + + // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer: + // * false: [ value ].slice( 0 ) => resolve( value ) + // * true: [ value ].slice( 1 ) => resolve() + resolve.apply( undefined, [ value ].slice( noValue ) ); + } + + // For Promises/A+, convert exceptions into rejections + // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in + // Deferred#then to conditionally suppress rejection. + } catch ( value ) { + + // Support: Android 4.0 only + // Strict mode functions invoked without .call/.apply get global-object context + reject.apply( undefined, [ value ] ); + } +} + +jQuery.extend( { + + Deferred: function( func ) { + var tuples = [ + + // action, add listener, callbacks, + // ... .then handlers, argument index, [final state] + [ "notify", "progress", jQuery.Callbacks( "memory" ), + jQuery.Callbacks( "memory" ), 2 ], + [ "resolve", "done", jQuery.Callbacks( "once memory" ), + jQuery.Callbacks( "once memory" ), 0, "resolved" ], + [ "reject", "fail", jQuery.Callbacks( "once memory" ), + jQuery.Callbacks( "once memory" ), 1, "rejected" ] + ], + state = "pending", + promise = { + state: function() { + return state; + }, + always: function() { + deferred.done( arguments ).fail( arguments ); + return this; + }, + "catch": function( fn ) { + return promise.then( null, fn ); + }, + + // Keep pipe for back-compat + pipe: function( /* fnDone, fnFail, fnProgress */ ) { + var fns = arguments; + + return jQuery.Deferred( function( newDefer ) { + jQuery.each( tuples, function( _i, tuple ) { + + // Map tuples (progress, done, fail) to arguments (done, fail, progress) + var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ]; + + // deferred.progress(function() { bind to newDefer or newDefer.notify }) + // deferred.done(function() { bind to newDefer or newDefer.resolve }) + // deferred.fail(function() { bind to newDefer or newDefer.reject }) + deferred[ tuple[ 1 ] ]( function() { + var returned = fn && fn.apply( this, arguments ); + if ( returned && isFunction( returned.promise ) ) { + returned.promise() + .progress( newDefer.notify ) + .done( newDefer.resolve ) + .fail( newDefer.reject ); + } else { + newDefer[ tuple[ 0 ] + "With" ]( + this, + fn ? [ returned ] : arguments + ); + } + } ); + } ); + fns = null; + } ).promise(); + }, + then: function( onFulfilled, onRejected, onProgress ) { + var maxDepth = 0; + function resolve( depth, deferred, handler, special ) { + return function() { + var that = this, + args = arguments, + mightThrow = function() { + var returned, then; + + // Support: Promises/A+ section 2.3.3.3.3 + // https://promisesaplus.com/#point-59 + // Ignore double-resolution attempts + if ( depth < maxDepth ) { + return; + } + + returned = handler.apply( that, args ); + + // Support: Promises/A+ section 2.3.1 + // https://promisesaplus.com/#point-48 + if ( returned === deferred.promise() ) { + throw new TypeError( "Thenable self-resolution" ); + } + + // Support: Promises/A+ sections 2.3.3.1, 3.5 + // https://promisesaplus.com/#point-54 + // https://promisesaplus.com/#point-75 + // Retrieve `then` only once + then = returned && + + // Support: Promises/A+ section 2.3.4 + // https://promisesaplus.com/#point-64 + // Only check objects and functions for thenability + ( typeof returned === "object" || + typeof returned === "function" ) && + returned.then; + + // Handle a returned thenable + if ( isFunction( then ) ) { + + // Special processors (notify) just wait for resolution + if ( special ) { + then.call( + returned, + resolve( maxDepth, deferred, Identity, special ), + resolve( maxDepth, deferred, Thrower, special ) + ); + + // Normal processors (resolve) also hook into progress + } else { + + // ...and disregard older resolution values + maxDepth++; + + then.call( + returned, + resolve( maxDepth, deferred, Identity, special ), + resolve( maxDepth, deferred, Thrower, special ), + resolve( maxDepth, deferred, Identity, + deferred.notifyWith ) + ); + } + + // Handle all other returned values + } else { + + // Only substitute handlers pass on context + // and multiple values (non-spec behavior) + if ( handler !== Identity ) { + that = undefined; + args = [ returned ]; + } + + // Process the value(s) + // Default process is resolve + ( special || deferred.resolveWith )( that, args ); + } + }, + + // Only normal processors (resolve) catch and reject exceptions + process = special ? + mightThrow : + function() { + try { + mightThrow(); + } catch ( e ) { + + if ( jQuery.Deferred.exceptionHook ) { + jQuery.Deferred.exceptionHook( e, + process.stackTrace ); + } + + // Support: Promises/A+ section 2.3.3.3.4.1 + // https://promisesaplus.com/#point-61 + // Ignore post-resolution exceptions + if ( depth + 1 >= maxDepth ) { + + // Only substitute handlers pass on context + // and multiple values (non-spec behavior) + if ( handler !== Thrower ) { + that = undefined; + args = [ e ]; + } + + deferred.rejectWith( that, args ); + } + } + }; + + // Support: Promises/A+ section 2.3.3.3.1 + // https://promisesaplus.com/#point-57 + // Re-resolve promises immediately to dodge false rejection from + // subsequent errors + if ( depth ) { + process(); + } else { + + // Call an optional hook to record the stack, in case of exception + // since it's otherwise lost when execution goes async + if ( jQuery.Deferred.getStackHook ) { + process.stackTrace = jQuery.Deferred.getStackHook(); + } + window.setTimeout( process ); + } + }; + } + + return jQuery.Deferred( function( newDefer ) { + + // progress_handlers.add( ... ) + tuples[ 0 ][ 3 ].add( + resolve( + 0, + newDefer, + isFunction( onProgress ) ? + onProgress : + Identity, + newDefer.notifyWith + ) + ); + + // fulfilled_handlers.add( ... ) + tuples[ 1 ][ 3 ].add( + resolve( + 0, + newDefer, + isFunction( onFulfilled ) ? + onFulfilled : + Identity + ) + ); + + // rejected_handlers.add( ... ) + tuples[ 2 ][ 3 ].add( + resolve( + 0, + newDefer, + isFunction( onRejected ) ? + onRejected : + Thrower + ) + ); + } ).promise(); + }, + + // Get a promise for this deferred + // If obj is provided, the promise aspect is added to the object + promise: function( obj ) { + return obj != null ? jQuery.extend( obj, promise ) : promise; + } + }, + deferred = {}; + + // Add list-specific methods + jQuery.each( tuples, function( i, tuple ) { + var list = tuple[ 2 ], + stateString = tuple[ 5 ]; + + // promise.progress = list.add + // promise.done = list.add + // promise.fail = list.add + promise[ tuple[ 1 ] ] = list.add; + + // Handle state + if ( stateString ) { + list.add( + function() { + + // state = "resolved" (i.e., fulfilled) + // state = "rejected" + state = stateString; + }, + + // rejected_callbacks.disable + // fulfilled_callbacks.disable + tuples[ 3 - i ][ 2 ].disable, + + // rejected_handlers.disable + // fulfilled_handlers.disable + tuples[ 3 - i ][ 3 ].disable, + + // progress_callbacks.lock + tuples[ 0 ][ 2 ].lock, + + // progress_handlers.lock + tuples[ 0 ][ 3 ].lock + ); + } + + // progress_handlers.fire + // fulfilled_handlers.fire + // rejected_handlers.fire + list.add( tuple[ 3 ].fire ); + + // deferred.notify = function() { deferred.notifyWith(...) } + // deferred.resolve = function() { deferred.resolveWith(...) } + // deferred.reject = function() { deferred.rejectWith(...) } + deferred[ tuple[ 0 ] ] = function() { + deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments ); + return this; + }; + + // deferred.notifyWith = list.fireWith + // deferred.resolveWith = list.fireWith + // deferred.rejectWith = list.fireWith + deferred[ tuple[ 0 ] + "With" ] = list.fireWith; + } ); + + // Make the deferred a promise + promise.promise( deferred ); + + // Call given func if any + if ( func ) { + func.call( deferred, deferred ); + } + + // All done! + return deferred; + }, + + // Deferred helper + when: function( singleValue ) { + var + + // count of uncompleted subordinates + remaining = arguments.length, + + // count of unprocessed arguments + i = remaining, + + // subordinate fulfillment data + resolveContexts = Array( i ), + resolveValues = slice.call( arguments ), + + // the primary Deferred + primary = jQuery.Deferred(), + + // subordinate callback factory + updateFunc = function( i ) { + return function( value ) { + resolveContexts[ i ] = this; + resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value; + if ( !( --remaining ) ) { + primary.resolveWith( resolveContexts, resolveValues ); + } + }; + }; + + // Single- and empty arguments are adopted like Promise.resolve + if ( remaining <= 1 ) { + adoptValue( singleValue, primary.done( updateFunc( i ) ).resolve, primary.reject, + !remaining ); + + // Use .then() to unwrap secondary thenables (cf. gh-3000) + if ( primary.state() === "pending" || + isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) { + + return primary.then(); + } + } + + // Multiple arguments are aggregated like Promise.all array elements + while ( i-- ) { + adoptValue( resolveValues[ i ], updateFunc( i ), primary.reject ); + } + + return primary.promise(); + } +} ); + + +// These usually indicate a programmer mistake during development, +// warn about them ASAP rather than swallowing them by default. +var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/; + +jQuery.Deferred.exceptionHook = function( error, stack ) { + + // Support: IE 8 - 9 only + // Console exists when dev tools are open, which can happen at any time + if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) { + window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack ); + } +}; + + + + +jQuery.readyException = function( error ) { + window.setTimeout( function() { + throw error; + } ); +}; + + + + +// The deferred used on DOM ready +var readyList = jQuery.Deferred(); + +jQuery.fn.ready = function( fn ) { + + readyList + .then( fn ) + + // Wrap jQuery.readyException in a function so that the lookup + // happens at the time of error handling instead of callback + // registration. + .catch( function( error ) { + jQuery.readyException( error ); + } ); + + return this; +}; + +jQuery.extend( { + + // Is the DOM ready to be used? Set to true once it occurs. + isReady: false, + + // A counter to track how many items to wait for before + // the ready event fires. See #6781 + readyWait: 1, + + // Handle when the DOM is ready + ready: function( wait ) { + + // Abort if there are pending holds or we're already ready + if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) { + return; + } + + // Remember that the DOM is ready + jQuery.isReady = true; + + // If a normal DOM Ready event fired, decrement, and wait if need be + if ( wait !== true && --jQuery.readyWait > 0 ) { + return; + } + + // If there are functions bound, to execute + readyList.resolveWith( document, [ jQuery ] ); + } +} ); + +jQuery.ready.then = readyList.then; + +// The ready event handler and self cleanup method +function completed() { + document.removeEventListener( "DOMContentLoaded", completed ); + window.removeEventListener( "load", completed ); + jQuery.ready(); +} + +// Catch cases where $(document).ready() is called +// after the browser event has already occurred. +// Support: IE <=9 - 10 only +// Older IE sometimes signals "interactive" too soon +if ( document.readyState === "complete" || + ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) { + + // Handle it asynchronously to allow scripts the opportunity to delay ready + window.setTimeout( jQuery.ready ); + +} else { + + // Use the handy event callback + document.addEventListener( "DOMContentLoaded", completed ); + + // A fallback to window.onload, that will always work + window.addEventListener( "load", completed ); +} + + + + +// Multifunctional method to get and set values of a collection +// The value/s can optionally be executed if it's a function +var access = function( elems, fn, key, value, chainable, emptyGet, raw ) { + var i = 0, + len = elems.length, + bulk = key == null; + + // Sets many values + if ( toType( key ) === "object" ) { + chainable = true; + for ( i in key ) { + access( elems, fn, i, key[ i ], true, emptyGet, raw ); + } + + // Sets one value + } else if ( value !== undefined ) { + chainable = true; + + if ( !isFunction( value ) ) { + raw = true; + } + + if ( bulk ) { + + // Bulk operations run against the entire set + if ( raw ) { + fn.call( elems, value ); + fn = null; + + // ...except when executing function values + } else { + bulk = fn; + fn = function( elem, _key, value ) { + return bulk.call( jQuery( elem ), value ); + }; + } + } + + if ( fn ) { + for ( ; i < len; i++ ) { + fn( + elems[ i ], key, raw ? + value : + value.call( elems[ i ], i, fn( elems[ i ], key ) ) + ); + } + } + } + + if ( chainable ) { + return elems; + } + + // Gets + if ( bulk ) { + return fn.call( elems ); + } + + return len ? fn( elems[ 0 ], key ) : emptyGet; +}; + + +// Matches dashed string for camelizing +var rmsPrefix = /^-ms-/, + rdashAlpha = /-([a-z])/g; + +// Used by camelCase as callback to replace() +function fcamelCase( _all, letter ) { + return letter.toUpperCase(); +} + +// Convert dashed to camelCase; used by the css and data modules +// Support: IE <=9 - 11, Edge 12 - 15 +// Microsoft forgot to hump their vendor prefix (#9572) +function camelCase( string ) { + return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); +} +var acceptData = function( owner ) { + + // Accepts only: + // - Node + // - Node.ELEMENT_NODE + // - Node.DOCUMENT_NODE + // - Object + // - Any + return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType ); +}; + + + + +function Data() { + this.expando = jQuery.expando + Data.uid++; +} + +Data.uid = 1; + +Data.prototype = { + + cache: function( owner ) { + + // Check if the owner object already has a cache + var value = owner[ this.expando ]; + + // If not, create one + if ( !value ) { + value = {}; + + // We can accept data for non-element nodes in modern browsers, + // but we should not, see #8335. + // Always return an empty object. + if ( acceptData( owner ) ) { + + // If it is a node unlikely to be stringify-ed or looped over + // use plain assignment + if ( owner.nodeType ) { + owner[ this.expando ] = value; + + // Otherwise secure it in a non-enumerable property + // configurable must be true to allow the property to be + // deleted when data is removed + } else { + Object.defineProperty( owner, this.expando, { + value: value, + configurable: true + } ); + } + } + } + + return value; + }, + set: function( owner, data, value ) { + var prop, + cache = this.cache( owner ); + + // Handle: [ owner, key, value ] args + // Always use camelCase key (gh-2257) + if ( typeof data === "string" ) { + cache[ camelCase( data ) ] = value; + + // Handle: [ owner, { properties } ] args + } else { + + // Copy the properties one-by-one to the cache object + for ( prop in data ) { + cache[ camelCase( prop ) ] = data[ prop ]; + } + } + return cache; + }, + get: function( owner, key ) { + return key === undefined ? + this.cache( owner ) : + + // Always use camelCase key (gh-2257) + owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ]; + }, + access: function( owner, key, value ) { + + // In cases where either: + // + // 1. No key was specified + // 2. A string key was specified, but no value provided + // + // Take the "read" path and allow the get method to determine + // which value to return, respectively either: + // + // 1. The entire cache object + // 2. The data stored at the key + // + if ( key === undefined || + ( ( key && typeof key === "string" ) && value === undefined ) ) { + + return this.get( owner, key ); + } + + // When the key is not a string, or both a key and value + // are specified, set or extend (existing objects) with either: + // + // 1. An object of properties + // 2. A key and value + // + this.set( owner, key, value ); + + // Since the "set" path can have two possible entry points + // return the expected data based on which path was taken[*] + return value !== undefined ? value : key; + }, + remove: function( owner, key ) { + var i, + cache = owner[ this.expando ]; + + if ( cache === undefined ) { + return; + } + + if ( key !== undefined ) { + + // Support array or space separated string of keys + if ( Array.isArray( key ) ) { + + // If key is an array of keys... + // We always set camelCase keys, so remove that. + key = key.map( camelCase ); + } else { + key = camelCase( key ); + + // If a key with the spaces exists, use it. + // Otherwise, create an array by matching non-whitespace + key = key in cache ? + [ key ] : + ( key.match( rnothtmlwhite ) || [] ); + } + + i = key.length; + + while ( i-- ) { + delete cache[ key[ i ] ]; + } + } + + // Remove the expando if there's no more data + if ( key === undefined || jQuery.isEmptyObject( cache ) ) { + + // Support: Chrome <=35 - 45 + // Webkit & Blink performance suffers when deleting properties + // from DOM nodes, so set to undefined instead + // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted) + if ( owner.nodeType ) { + owner[ this.expando ] = undefined; + } else { + delete owner[ this.expando ]; + } + } + }, + hasData: function( owner ) { + var cache = owner[ this.expando ]; + return cache !== undefined && !jQuery.isEmptyObject( cache ); + } +}; +var dataPriv = new Data(); + +var dataUser = new Data(); + + + +// Implementation Summary +// +// 1. Enforce API surface and semantic compatibility with 1.9.x branch +// 2. Improve the module's maintainability by reducing the storage +// paths to a single mechanism. +// 3. Use the same single mechanism to support "private" and "user" data. +// 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData) +// 5. Avoid exposing implementation details on user objects (eg. expando properties) +// 6. Provide a clear path for implementation upgrade to WeakMap in 2014 + +var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, + rmultiDash = /[A-Z]/g; + +function getData( data ) { + if ( data === "true" ) { + return true; + } + + if ( data === "false" ) { + return false; + } + + if ( data === "null" ) { + return null; + } + + // Only convert to a number if it doesn't change the string + if ( data === +data + "" ) { + return +data; + } + + if ( rbrace.test( data ) ) { + return JSON.parse( data ); + } + + return data; +} + +function dataAttr( elem, key, data ) { + var name; + + // If nothing was found internally, try to fetch any + // data from the HTML5 data-* attribute + if ( data === undefined && elem.nodeType === 1 ) { + name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase(); + data = elem.getAttribute( name ); + + if ( typeof data === "string" ) { + try { + data = getData( data ); + } catch ( e ) {} + + // Make sure we set the data so it isn't changed later + dataUser.set( elem, key, data ); + } else { + data = undefined; + } + } + return data; +} + +jQuery.extend( { + hasData: function( elem ) { + return dataUser.hasData( elem ) || dataPriv.hasData( elem ); + }, + + data: function( elem, name, data ) { + return dataUser.access( elem, name, data ); + }, + + removeData: function( elem, name ) { + dataUser.remove( elem, name ); + }, + + // TODO: Now that all calls to _data and _removeData have been replaced + // with direct calls to dataPriv methods, these can be deprecated. + _data: function( elem, name, data ) { + return dataPriv.access( elem, name, data ); + }, + + _removeData: function( elem, name ) { + dataPriv.remove( elem, name ); + } +} ); + +jQuery.fn.extend( { + data: function( key, value ) { + var i, name, data, + elem = this[ 0 ], + attrs = elem && elem.attributes; + + // Gets all values + if ( key === undefined ) { + if ( this.length ) { + data = dataUser.get( elem ); + + if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) { + i = attrs.length; + while ( i-- ) { + + // Support: IE 11 only + // The attrs elements can be null (#14894) + if ( attrs[ i ] ) { + name = attrs[ i ].name; + if ( name.indexOf( "data-" ) === 0 ) { + name = camelCase( name.slice( 5 ) ); + dataAttr( elem, name, data[ name ] ); + } + } + } + dataPriv.set( elem, "hasDataAttrs", true ); + } + } + + return data; + } + + // Sets multiple values + if ( typeof key === "object" ) { + return this.each( function() { + dataUser.set( this, key ); + } ); + } + + return access( this, function( value ) { + var data; + + // The calling jQuery object (element matches) is not empty + // (and therefore has an element appears at this[ 0 ]) and the + // `value` parameter was not undefined. An empty jQuery object + // will result in `undefined` for elem = this[ 0 ] which will + // throw an exception if an attempt to read a data cache is made. + if ( elem && value === undefined ) { + + // Attempt to get data from the cache + // The key will always be camelCased in Data + data = dataUser.get( elem, key ); + if ( data !== undefined ) { + return data; + } + + // Attempt to "discover" the data in + // HTML5 custom data-* attrs + data = dataAttr( elem, key ); + if ( data !== undefined ) { + return data; + } + + // We tried really hard, but the data doesn't exist. + return; + } + + // Set the data... + this.each( function() { + + // We always store the camelCased key + dataUser.set( this, key, value ); + } ); + }, null, value, arguments.length > 1, null, true ); + }, + + removeData: function( key ) { + return this.each( function() { + dataUser.remove( this, key ); + } ); + } +} ); + + +jQuery.extend( { + queue: function( elem, type, data ) { + var queue; + + if ( elem ) { + type = ( type || "fx" ) + "queue"; + queue = dataPriv.get( elem, type ); + + // Speed up dequeue by getting out quickly if this is just a lookup + if ( data ) { + if ( !queue || Array.isArray( data ) ) { + queue = dataPriv.access( elem, type, jQuery.makeArray( data ) ); + } else { + queue.push( data ); + } + } + return queue || []; + } + }, + + dequeue: function( elem, type ) { + type = type || "fx"; + + var queue = jQuery.queue( elem, type ), + startLength = queue.length, + fn = queue.shift(), + hooks = jQuery._queueHooks( elem, type ), + next = function() { + jQuery.dequeue( elem, type ); + }; + + // If the fx queue is dequeued, always remove the progress sentinel + if ( fn === "inprogress" ) { + fn = queue.shift(); + startLength--; + } + + if ( fn ) { + + // Add a progress sentinel to prevent the fx queue from being + // automatically dequeued + if ( type === "fx" ) { + queue.unshift( "inprogress" ); + } + + // Clear up the last queue stop function + delete hooks.stop; + fn.call( elem, next, hooks ); + } + + if ( !startLength && hooks ) { + hooks.empty.fire(); + } + }, + + // Not public - generate a queueHooks object, or return the current one + _queueHooks: function( elem, type ) { + var key = type + "queueHooks"; + return dataPriv.get( elem, key ) || dataPriv.access( elem, key, { + empty: jQuery.Callbacks( "once memory" ).add( function() { + dataPriv.remove( elem, [ type + "queue", key ] ); + } ) + } ); + } +} ); + +jQuery.fn.extend( { + queue: function( type, data ) { + var setter = 2; + + if ( typeof type !== "string" ) { + data = type; + type = "fx"; + setter--; + } + + if ( arguments.length < setter ) { + return jQuery.queue( this[ 0 ], type ); + } + + return data === undefined ? + this : + this.each( function() { + var queue = jQuery.queue( this, type, data ); + + // Ensure a hooks for this queue + jQuery._queueHooks( this, type ); + + if ( type === "fx" && queue[ 0 ] !== "inprogress" ) { + jQuery.dequeue( this, type ); + } + } ); + }, + dequeue: function( type ) { + return this.each( function() { + jQuery.dequeue( this, type ); + } ); + }, + clearQueue: function( type ) { + return this.queue( type || "fx", [] ); + }, + + // Get a promise resolved when queues of a certain type + // are emptied (fx is the type by default) + promise: function( type, obj ) { + var tmp, + count = 1, + defer = jQuery.Deferred(), + elements = this, + i = this.length, + resolve = function() { + if ( !( --count ) ) { + defer.resolveWith( elements, [ elements ] ); + } + }; + + if ( typeof type !== "string" ) { + obj = type; + type = undefined; + } + type = type || "fx"; + + while ( i-- ) { + tmp = dataPriv.get( elements[ i ], type + "queueHooks" ); + if ( tmp && tmp.empty ) { + count++; + tmp.empty.add( resolve ); + } + } + resolve(); + return defer.promise( obj ); + } +} ); +var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source; + +var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" ); + + +var cssExpand = [ "Top", "Right", "Bottom", "Left" ]; + +var documentElement = document.documentElement; + + + + var isAttached = function( elem ) { + return jQuery.contains( elem.ownerDocument, elem ); + }, + composed = { composed: true }; + + // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only + // Check attachment across shadow DOM boundaries when possible (gh-3504) + // Support: iOS 10.0-10.2 only + // Early iOS 10 versions support `attachShadow` but not `getRootNode`, + // leading to errors. We need to check for `getRootNode`. + if ( documentElement.getRootNode ) { + isAttached = function( elem ) { + return jQuery.contains( elem.ownerDocument, elem ) || + elem.getRootNode( composed ) === elem.ownerDocument; + }; + } +var isHiddenWithinTree = function( elem, el ) { + + // isHiddenWithinTree might be called from jQuery#filter function; + // in that case, element will be second argument + elem = el || elem; + + // Inline style trumps all + return elem.style.display === "none" || + elem.style.display === "" && + + // Otherwise, check computed style + // Support: Firefox <=43 - 45 + // Disconnected elements can have computed display: none, so first confirm that elem is + // in the document. + isAttached( elem ) && + + jQuery.css( elem, "display" ) === "none"; + }; + + + +function adjustCSS( elem, prop, valueParts, tween ) { + var adjusted, scale, + maxIterations = 20, + currentValue = tween ? + function() { + return tween.cur(); + } : + function() { + return jQuery.css( elem, prop, "" ); + }, + initial = currentValue(), + unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ), + + // Starting value computation is required for potential unit mismatches + initialInUnit = elem.nodeType && + ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) && + rcssNum.exec( jQuery.css( elem, prop ) ); + + if ( initialInUnit && initialInUnit[ 3 ] !== unit ) { + + // Support: Firefox <=54 + // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144) + initial = initial / 2; + + // Trust units reported by jQuery.css + unit = unit || initialInUnit[ 3 ]; + + // Iteratively approximate from a nonzero starting point + initialInUnit = +initial || 1; + + while ( maxIterations-- ) { + + // Evaluate and update our best guess (doubling guesses that zero out). + // Finish if the scale equals or crosses 1 (making the old*new product non-positive). + jQuery.style( elem, prop, initialInUnit + unit ); + if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) { + maxIterations = 0; + } + initialInUnit = initialInUnit / scale; + + } + + initialInUnit = initialInUnit * 2; + jQuery.style( elem, prop, initialInUnit + unit ); + + // Make sure we update the tween properties later on + valueParts = valueParts || []; + } + + if ( valueParts ) { + initialInUnit = +initialInUnit || +initial || 0; + + // Apply relative offset (+=/-=) if specified + adjusted = valueParts[ 1 ] ? + initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] : + +valueParts[ 2 ]; + if ( tween ) { + tween.unit = unit; + tween.start = initialInUnit; + tween.end = adjusted; + } + } + return adjusted; +} + + +var defaultDisplayMap = {}; + +function getDefaultDisplay( elem ) { + var temp, + doc = elem.ownerDocument, + nodeName = elem.nodeName, + display = defaultDisplayMap[ nodeName ]; + + if ( display ) { + return display; + } + + temp = doc.body.appendChild( doc.createElement( nodeName ) ); + display = jQuery.css( temp, "display" ); + + temp.parentNode.removeChild( temp ); + + if ( display === "none" ) { + display = "block"; + } + defaultDisplayMap[ nodeName ] = display; + + return display; +} + +function showHide( elements, show ) { + var display, elem, + values = [], + index = 0, + length = elements.length; + + // Determine new display value for elements that need to change + for ( ; index < length; index++ ) { + elem = elements[ index ]; + if ( !elem.style ) { + continue; + } + + display = elem.style.display; + if ( show ) { + + // Since we force visibility upon cascade-hidden elements, an immediate (and slow) + // check is required in this first loop unless we have a nonempty display value (either + // inline or about-to-be-restored) + if ( display === "none" ) { + values[ index ] = dataPriv.get( elem, "display" ) || null; + if ( !values[ index ] ) { + elem.style.display = ""; + } + } + if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) { + values[ index ] = getDefaultDisplay( elem ); + } + } else { + if ( display !== "none" ) { + values[ index ] = "none"; + + // Remember what we're overwriting + dataPriv.set( elem, "display", display ); + } + } + } + + // Set the display of the elements in a second loop to avoid constant reflow + for ( index = 0; index < length; index++ ) { + if ( values[ index ] != null ) { + elements[ index ].style.display = values[ index ]; + } + } + + return elements; +} + +jQuery.fn.extend( { + show: function() { + return showHide( this, true ); + }, + hide: function() { + return showHide( this ); + }, + toggle: function( state ) { + if ( typeof state === "boolean" ) { + return state ? this.show() : this.hide(); + } + + return this.each( function() { + if ( isHiddenWithinTree( this ) ) { + jQuery( this ).show(); + } else { + jQuery( this ).hide(); + } + } ); + } +} ); +var rcheckableType = ( /^(?:checkbox|radio)$/i ); + +var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i ); + +var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i ); + + + +( function() { + var fragment = document.createDocumentFragment(), + div = fragment.appendChild( document.createElement( "div" ) ), + input = document.createElement( "input" ); + + // Support: Android 4.0 - 4.3 only + // Check state lost if the name is set (#11217) + // Support: Windows Web Apps (WWA) + // `name` and `type` must use .setAttribute for WWA (#14901) + input.setAttribute( "type", "radio" ); + input.setAttribute( "checked", "checked" ); + input.setAttribute( "name", "t" ); + + div.appendChild( input ); + + // Support: Android <=4.1 only + // Older WebKit doesn't clone checked state correctly in fragments + support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked; + + // Support: IE <=11 only + // Make sure textarea (and checkbox) defaultValue is properly cloned + div.innerHTML = ""; + support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue; + + // Support: IE <=9 only + // IE <=9 replaces "; + support.option = !!div.lastChild; +} )(); + + +// We have to close these tags to support XHTML (#13200) +var wrapMap = { + + // XHTML parsers do not magically insert elements in the + // same way that tag soup parsers do. So we cannot shorten + // this by omitting or other required elements. + thead: [ 1, "", "
" ], + col: [ 2, "", "
" ], + tr: [ 2, "", "
" ], + td: [ 3, "", "
" ], + + _default: [ 0, "", "" ] +}; + +wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; +wrapMap.th = wrapMap.td; + +// Support: IE <=9 only +if ( !support.option ) { + wrapMap.optgroup = wrapMap.option = [ 1, "" ]; +} + + +function getAll( context, tag ) { + + // Support: IE <=9 - 11 only + // Use typeof to avoid zero-argument method invocation on host objects (#15151) + var ret; + + if ( typeof context.getElementsByTagName !== "undefined" ) { + ret = context.getElementsByTagName( tag || "*" ); + + } else if ( typeof context.querySelectorAll !== "undefined" ) { + ret = context.querySelectorAll( tag || "*" ); + + } else { + ret = []; + } + + if ( tag === undefined || tag && nodeName( context, tag ) ) { + return jQuery.merge( [ context ], ret ); + } + + return ret; +} + + +// Mark scripts as having already been evaluated +function setGlobalEval( elems, refElements ) { + var i = 0, + l = elems.length; + + for ( ; i < l; i++ ) { + dataPriv.set( + elems[ i ], + "globalEval", + !refElements || dataPriv.get( refElements[ i ], "globalEval" ) + ); + } +} + + +var rhtml = /<|&#?\w+;/; + +function buildFragment( elems, context, scripts, selection, ignored ) { + var elem, tmp, tag, wrap, attached, j, + fragment = context.createDocumentFragment(), + nodes = [], + i = 0, + l = elems.length; + + for ( ; i < l; i++ ) { + elem = elems[ i ]; + + if ( elem || elem === 0 ) { + + // Add nodes directly + if ( toType( elem ) === "object" ) { + + // Support: Android <=4.0 only, PhantomJS 1 only + // push.apply(_, arraylike) throws on ancient WebKit + jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem ); + + // Convert non-html into a text node + } else if ( !rhtml.test( elem ) ) { + nodes.push( context.createTextNode( elem ) ); + + // Convert html into DOM nodes + } else { + tmp = tmp || fragment.appendChild( context.createElement( "div" ) ); + + // Deserialize a standard representation + tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase(); + wrap = wrapMap[ tag ] || wrapMap._default; + tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ]; + + // Descend through wrappers to the right content + j = wrap[ 0 ]; + while ( j-- ) { + tmp = tmp.lastChild; + } + + // Support: Android <=4.0 only, PhantomJS 1 only + // push.apply(_, arraylike) throws on ancient WebKit + jQuery.merge( nodes, tmp.childNodes ); + + // Remember the top-level container + tmp = fragment.firstChild; + + // Ensure the created nodes are orphaned (#12392) + tmp.textContent = ""; + } + } + } + + // Remove wrapper from fragment + fragment.textContent = ""; + + i = 0; + while ( ( elem = nodes[ i++ ] ) ) { + + // Skip elements already in the context collection (trac-4087) + if ( selection && jQuery.inArray( elem, selection ) > -1 ) { + if ( ignored ) { + ignored.push( elem ); + } + continue; + } + + attached = isAttached( elem ); + + // Append to fragment + tmp = getAll( fragment.appendChild( elem ), "script" ); + + // Preserve script evaluation history + if ( attached ) { + setGlobalEval( tmp ); + } + + // Capture executables + if ( scripts ) { + j = 0; + while ( ( elem = tmp[ j++ ] ) ) { + if ( rscriptType.test( elem.type || "" ) ) { + scripts.push( elem ); + } + } + } + } + + return fragment; +} + + +var rtypenamespace = /^([^.]*)(?:\.(.+)|)/; + +function returnTrue() { + return true; +} + +function returnFalse() { + return false; +} + +// Support: IE <=9 - 11+ +// focus() and blur() are asynchronous, except when they are no-op. +// So expect focus to be synchronous when the element is already active, +// and blur to be synchronous when the element is not already active. +// (focus and blur are always synchronous in other supported browsers, +// this just defines when we can count on it). +function expectSync( elem, type ) { + return ( elem === safeActiveElement() ) === ( type === "focus" ); +} + +// Support: IE <=9 only +// Accessing document.activeElement can throw unexpectedly +// https://bugs.jquery.com/ticket/13393 +function safeActiveElement() { + try { + return document.activeElement; + } catch ( err ) { } +} + +function on( elem, types, selector, data, fn, one ) { + var origFn, type; + + // Types can be a map of types/handlers + if ( typeof types === "object" ) { + + // ( types-Object, selector, data ) + if ( typeof selector !== "string" ) { + + // ( types-Object, data ) + data = data || selector; + selector = undefined; + } + for ( type in types ) { + on( elem, type, selector, data, types[ type ], one ); + } + return elem; + } + + if ( data == null && fn == null ) { + + // ( types, fn ) + fn = selector; + data = selector = undefined; + } else if ( fn == null ) { + if ( typeof selector === "string" ) { + + // ( types, selector, fn ) + fn = data; + data = undefined; + } else { + + // ( types, data, fn ) + fn = data; + data = selector; + selector = undefined; + } + } + if ( fn === false ) { + fn = returnFalse; + } else if ( !fn ) { + return elem; + } + + if ( one === 1 ) { + origFn = fn; + fn = function( event ) { + + // Can use an empty set, since event contains the info + jQuery().off( event ); + return origFn.apply( this, arguments ); + }; + + // Use same guid so caller can remove using origFn + fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ ); + } + return elem.each( function() { + jQuery.event.add( this, types, fn, data, selector ); + } ); +} + +/* + * Helper functions for managing events -- not part of the public interface. + * Props to Dean Edwards' addEvent library for many of the ideas. + */ +jQuery.event = { + + global: {}, + + add: function( elem, types, handler, data, selector ) { + + var handleObjIn, eventHandle, tmp, + events, t, handleObj, + special, handlers, type, namespaces, origType, + elemData = dataPriv.get( elem ); + + // Only attach events to objects that accept data + if ( !acceptData( elem ) ) { + return; + } + + // Caller can pass in an object of custom data in lieu of the handler + if ( handler.handler ) { + handleObjIn = handler; + handler = handleObjIn.handler; + selector = handleObjIn.selector; + } + + // Ensure that invalid selectors throw exceptions at attach time + // Evaluate against documentElement in case elem is a non-element node (e.g., document) + if ( selector ) { + jQuery.find.matchesSelector( documentElement, selector ); + } + + // Make sure that the handler has a unique ID, used to find/remove it later + if ( !handler.guid ) { + handler.guid = jQuery.guid++; + } + + // Init the element's event structure and main handler, if this is the first + if ( !( events = elemData.events ) ) { + events = elemData.events = Object.create( null ); + } + if ( !( eventHandle = elemData.handle ) ) { + eventHandle = elemData.handle = function( e ) { + + // Discard the second event of a jQuery.event.trigger() and + // when an event is called after a page has unloaded + return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ? + jQuery.event.dispatch.apply( elem, arguments ) : undefined; + }; + } + + // Handle multiple events separated by a space + types = ( types || "" ).match( rnothtmlwhite ) || [ "" ]; + t = types.length; + while ( t-- ) { + tmp = rtypenamespace.exec( types[ t ] ) || []; + type = origType = tmp[ 1 ]; + namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort(); + + // There *must* be a type, no attaching namespace-only handlers + if ( !type ) { + continue; + } + + // If event changes its type, use the special event handlers for the changed type + special = jQuery.event.special[ type ] || {}; + + // If selector defined, determine special event api type, otherwise given type + type = ( selector ? special.delegateType : special.bindType ) || type; + + // Update special based on newly reset type + special = jQuery.event.special[ type ] || {}; + + // handleObj is passed to all event handlers + handleObj = jQuery.extend( { + type: type, + origType: origType, + data: data, + handler: handler, + guid: handler.guid, + selector: selector, + needsContext: selector && jQuery.expr.match.needsContext.test( selector ), + namespace: namespaces.join( "." ) + }, handleObjIn ); + + // Init the event handler queue if we're the first + if ( !( handlers = events[ type ] ) ) { + handlers = events[ type ] = []; + handlers.delegateCount = 0; + + // Only use addEventListener if the special events handler returns false + if ( !special.setup || + special.setup.call( elem, data, namespaces, eventHandle ) === false ) { + + if ( elem.addEventListener ) { + elem.addEventListener( type, eventHandle ); + } + } + } + + if ( special.add ) { + special.add.call( elem, handleObj ); + + if ( !handleObj.handler.guid ) { + handleObj.handler.guid = handler.guid; + } + } + + // Add to the element's handler list, delegates in front + if ( selector ) { + handlers.splice( handlers.delegateCount++, 0, handleObj ); + } else { + handlers.push( handleObj ); + } + + // Keep track of which events have ever been used, for event optimization + jQuery.event.global[ type ] = true; + } + + }, + + // Detach an event or set of events from an element + remove: function( elem, types, handler, selector, mappedTypes ) { + + var j, origCount, tmp, + events, t, handleObj, + special, handlers, type, namespaces, origType, + elemData = dataPriv.hasData( elem ) && dataPriv.get( elem ); + + if ( !elemData || !( events = elemData.events ) ) { + return; + } + + // Once for each type.namespace in types; type may be omitted + types = ( types || "" ).match( rnothtmlwhite ) || [ "" ]; + t = types.length; + while ( t-- ) { + tmp = rtypenamespace.exec( types[ t ] ) || []; + type = origType = tmp[ 1 ]; + namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort(); + + // Unbind all events (on this namespace, if provided) for the element + if ( !type ) { + for ( type in events ) { + jQuery.event.remove( elem, type + types[ t ], handler, selector, true ); + } + continue; + } + + special = jQuery.event.special[ type ] || {}; + type = ( selector ? special.delegateType : special.bindType ) || type; + handlers = events[ type ] || []; + tmp = tmp[ 2 ] && + new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ); + + // Remove matching events + origCount = j = handlers.length; + while ( j-- ) { + handleObj = handlers[ j ]; + + if ( ( mappedTypes || origType === handleObj.origType ) && + ( !handler || handler.guid === handleObj.guid ) && + ( !tmp || tmp.test( handleObj.namespace ) ) && + ( !selector || selector === handleObj.selector || + selector === "**" && handleObj.selector ) ) { + handlers.splice( j, 1 ); + + if ( handleObj.selector ) { + handlers.delegateCount--; + } + if ( special.remove ) { + special.remove.call( elem, handleObj ); + } + } + } + + // Remove generic event handler if we removed something and no more handlers exist + // (avoids potential for endless recursion during removal of special event handlers) + if ( origCount && !handlers.length ) { + if ( !special.teardown || + special.teardown.call( elem, namespaces, elemData.handle ) === false ) { + + jQuery.removeEvent( elem, type, elemData.handle ); + } + + delete events[ type ]; + } + } + + // Remove data and the expando if it's no longer used + if ( jQuery.isEmptyObject( events ) ) { + dataPriv.remove( elem, "handle events" ); + } + }, + + dispatch: function( nativeEvent ) { + + var i, j, ret, matched, handleObj, handlerQueue, + args = new Array( arguments.length ), + + // Make a writable jQuery.Event from the native event object + event = jQuery.event.fix( nativeEvent ), + + handlers = ( + dataPriv.get( this, "events" ) || Object.create( null ) + )[ event.type ] || [], + special = jQuery.event.special[ event.type ] || {}; + + // Use the fix-ed jQuery.Event rather than the (read-only) native event + args[ 0 ] = event; + + for ( i = 1; i < arguments.length; i++ ) { + args[ i ] = arguments[ i ]; + } + + event.delegateTarget = this; + + // Call the preDispatch hook for the mapped type, and let it bail if desired + if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) { + return; + } + + // Determine handlers + handlerQueue = jQuery.event.handlers.call( this, event, handlers ); + + // Run delegates first; they may want to stop propagation beneath us + i = 0; + while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) { + event.currentTarget = matched.elem; + + j = 0; + while ( ( handleObj = matched.handlers[ j++ ] ) && + !event.isImmediatePropagationStopped() ) { + + // If the event is namespaced, then each handler is only invoked if it is + // specially universal or its namespaces are a superset of the event's. + if ( !event.rnamespace || handleObj.namespace === false || + event.rnamespace.test( handleObj.namespace ) ) { + + event.handleObj = handleObj; + event.data = handleObj.data; + + ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle || + handleObj.handler ).apply( matched.elem, args ); + + if ( ret !== undefined ) { + if ( ( event.result = ret ) === false ) { + event.preventDefault(); + event.stopPropagation(); + } + } + } + } + } + + // Call the postDispatch hook for the mapped type + if ( special.postDispatch ) { + special.postDispatch.call( this, event ); + } + + return event.result; + }, + + handlers: function( event, handlers ) { + var i, handleObj, sel, matchedHandlers, matchedSelectors, + handlerQueue = [], + delegateCount = handlers.delegateCount, + cur = event.target; + + // Find delegate handlers + if ( delegateCount && + + // Support: IE <=9 + // Black-hole SVG instance trees (trac-13180) + cur.nodeType && + + // Support: Firefox <=42 + // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861) + // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click + // Support: IE 11 only + // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343) + !( event.type === "click" && event.button >= 1 ) ) { + + for ( ; cur !== this; cur = cur.parentNode || this ) { + + // Don't check non-elements (#13208) + // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764) + if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) { + matchedHandlers = []; + matchedSelectors = {}; + for ( i = 0; i < delegateCount; i++ ) { + handleObj = handlers[ i ]; + + // Don't conflict with Object.prototype properties (#13203) + sel = handleObj.selector + " "; + + if ( matchedSelectors[ sel ] === undefined ) { + matchedSelectors[ sel ] = handleObj.needsContext ? + jQuery( sel, this ).index( cur ) > -1 : + jQuery.find( sel, this, null, [ cur ] ).length; + } + if ( matchedSelectors[ sel ] ) { + matchedHandlers.push( handleObj ); + } + } + if ( matchedHandlers.length ) { + handlerQueue.push( { elem: cur, handlers: matchedHandlers } ); + } + } + } + } + + // Add the remaining (directly-bound) handlers + cur = this; + if ( delegateCount < handlers.length ) { + handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } ); + } + + return handlerQueue; + }, + + addProp: function( name, hook ) { + Object.defineProperty( jQuery.Event.prototype, name, { + enumerable: true, + configurable: true, + + get: isFunction( hook ) ? + function() { + if ( this.originalEvent ) { + return hook( this.originalEvent ); + } + } : + function() { + if ( this.originalEvent ) { + return this.originalEvent[ name ]; + } + }, + + set: function( value ) { + Object.defineProperty( this, name, { + enumerable: true, + configurable: true, + writable: true, + value: value + } ); + } + } ); + }, + + fix: function( originalEvent ) { + return originalEvent[ jQuery.expando ] ? + originalEvent : + new jQuery.Event( originalEvent ); + }, + + special: { + load: { + + // Prevent triggered image.load events from bubbling to window.load + noBubble: true + }, + click: { + + // Utilize native event to ensure correct state for checkable inputs + setup: function( data ) { + + // For mutual compressibility with _default, replace `this` access with a local var. + // `|| data` is dead code meant only to preserve the variable through minification. + var el = this || data; + + // Claim the first handler + if ( rcheckableType.test( el.type ) && + el.click && nodeName( el, "input" ) ) { + + // dataPriv.set( el, "click", ... ) + leverageNative( el, "click", returnTrue ); + } + + // Return false to allow normal processing in the caller + return false; + }, + trigger: function( data ) { + + // For mutual compressibility with _default, replace `this` access with a local var. + // `|| data` is dead code meant only to preserve the variable through minification. + var el = this || data; + + // Force setup before triggering a click + if ( rcheckableType.test( el.type ) && + el.click && nodeName( el, "input" ) ) { + + leverageNative( el, "click" ); + } + + // Return non-false to allow normal event-path propagation + return true; + }, + + // For cross-browser consistency, suppress native .click() on links + // Also prevent it if we're currently inside a leveraged native-event stack + _default: function( event ) { + var target = event.target; + return rcheckableType.test( target.type ) && + target.click && nodeName( target, "input" ) && + dataPriv.get( target, "click" ) || + nodeName( target, "a" ); + } + }, + + beforeunload: { + postDispatch: function( event ) { + + // Support: Firefox 20+ + // Firefox doesn't alert if the returnValue field is not set. + if ( event.result !== undefined && event.originalEvent ) { + event.originalEvent.returnValue = event.result; + } + } + } + } +}; + +// Ensure the presence of an event listener that handles manually-triggered +// synthetic events by interrupting progress until reinvoked in response to +// *native* events that it fires directly, ensuring that state changes have +// already occurred before other listeners are invoked. +function leverageNative( el, type, expectSync ) { + + // Missing expectSync indicates a trigger call, which must force setup through jQuery.event.add + if ( !expectSync ) { + if ( dataPriv.get( el, type ) === undefined ) { + jQuery.event.add( el, type, returnTrue ); + } + return; + } + + // Register the controller as a special universal handler for all event namespaces + dataPriv.set( el, type, false ); + jQuery.event.add( el, type, { + namespace: false, + handler: function( event ) { + var notAsync, result, + saved = dataPriv.get( this, type ); + + if ( ( event.isTrigger & 1 ) && this[ type ] ) { + + // Interrupt processing of the outer synthetic .trigger()ed event + // Saved data should be false in such cases, but might be a leftover capture object + // from an async native handler (gh-4350) + if ( !saved.length ) { + + // Store arguments for use when handling the inner native event + // There will always be at least one argument (an event object), so this array + // will not be confused with a leftover capture object. + saved = slice.call( arguments ); + dataPriv.set( this, type, saved ); + + // Trigger the native event and capture its result + // Support: IE <=9 - 11+ + // focus() and blur() are asynchronous + notAsync = expectSync( this, type ); + this[ type ](); + result = dataPriv.get( this, type ); + if ( saved !== result || notAsync ) { + dataPriv.set( this, type, false ); + } else { + result = {}; + } + if ( saved !== result ) { + + // Cancel the outer synthetic event + event.stopImmediatePropagation(); + event.preventDefault(); + + // Support: Chrome 86+ + // In Chrome, if an element having a focusout handler is blurred by + // clicking outside of it, it invokes the handler synchronously. If + // that handler calls `.remove()` on the element, the data is cleared, + // leaving `result` undefined. We need to guard against this. + return result && result.value; + } + + // If this is an inner synthetic event for an event with a bubbling surrogate + // (focus or blur), assume that the surrogate already propagated from triggering the + // native event and prevent that from happening again here. + // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the + // bubbling surrogate propagates *after* the non-bubbling base), but that seems + // less bad than duplication. + } else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) { + event.stopPropagation(); + } + + // If this is a native event triggered above, everything is now in order + // Fire an inner synthetic event with the original arguments + } else if ( saved.length ) { + + // ...and capture the result + dataPriv.set( this, type, { + value: jQuery.event.trigger( + + // Support: IE <=9 - 11+ + // Extend with the prototype to reset the above stopImmediatePropagation() + jQuery.extend( saved[ 0 ], jQuery.Event.prototype ), + saved.slice( 1 ), + this + ) + } ); + + // Abort handling of the native event + event.stopImmediatePropagation(); + } + } + } ); +} + +jQuery.removeEvent = function( elem, type, handle ) { + + // This "if" is needed for plain objects + if ( elem.removeEventListener ) { + elem.removeEventListener( type, handle ); + } +}; + +jQuery.Event = function( src, props ) { + + // Allow instantiation without the 'new' keyword + if ( !( this instanceof jQuery.Event ) ) { + return new jQuery.Event( src, props ); + } + + // Event object + if ( src && src.type ) { + this.originalEvent = src; + this.type = src.type; + + // Events bubbling up the document may have been marked as prevented + // by a handler lower down the tree; reflect the correct value. + this.isDefaultPrevented = src.defaultPrevented || + src.defaultPrevented === undefined && + + // Support: Android <=2.3 only + src.returnValue === false ? + returnTrue : + returnFalse; + + // Create target properties + // Support: Safari <=6 - 7 only + // Target should not be a text node (#504, #13143) + this.target = ( src.target && src.target.nodeType === 3 ) ? + src.target.parentNode : + src.target; + + this.currentTarget = src.currentTarget; + this.relatedTarget = src.relatedTarget; + + // Event type + } else { + this.type = src; + } + + // Put explicitly provided properties onto the event object + if ( props ) { + jQuery.extend( this, props ); + } + + // Create a timestamp if incoming event doesn't have one + this.timeStamp = src && src.timeStamp || Date.now(); + + // Mark it as fixed + this[ jQuery.expando ] = true; +}; + +// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding +// https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html +jQuery.Event.prototype = { + constructor: jQuery.Event, + isDefaultPrevented: returnFalse, + isPropagationStopped: returnFalse, + isImmediatePropagationStopped: returnFalse, + isSimulated: false, + + preventDefault: function() { + var e = this.originalEvent; + + this.isDefaultPrevented = returnTrue; + + if ( e && !this.isSimulated ) { + e.preventDefault(); + } + }, + stopPropagation: function() { + var e = this.originalEvent; + + this.isPropagationStopped = returnTrue; + + if ( e && !this.isSimulated ) { + e.stopPropagation(); + } + }, + stopImmediatePropagation: function() { + var e = this.originalEvent; + + this.isImmediatePropagationStopped = returnTrue; + + if ( e && !this.isSimulated ) { + e.stopImmediatePropagation(); + } + + this.stopPropagation(); + } +}; + +// Includes all common event props including KeyEvent and MouseEvent specific props +jQuery.each( { + altKey: true, + bubbles: true, + cancelable: true, + changedTouches: true, + ctrlKey: true, + detail: true, + eventPhase: true, + metaKey: true, + pageX: true, + pageY: true, + shiftKey: true, + view: true, + "char": true, + code: true, + charCode: true, + key: true, + keyCode: true, + button: true, + buttons: true, + clientX: true, + clientY: true, + offsetX: true, + offsetY: true, + pointerId: true, + pointerType: true, + screenX: true, + screenY: true, + targetTouches: true, + toElement: true, + touches: true, + which: true +}, jQuery.event.addProp ); + +jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) { + jQuery.event.special[ type ] = { + + // Utilize native event if possible so blur/focus sequence is correct + setup: function() { + + // Claim the first handler + // dataPriv.set( this, "focus", ... ) + // dataPriv.set( this, "blur", ... ) + leverageNative( this, type, expectSync ); + + // Return false to allow normal processing in the caller + return false; + }, + trigger: function() { + + // Force setup before trigger + leverageNative( this, type ); + + // Return non-false to allow normal event-path propagation + return true; + }, + + // Suppress native focus or blur as it's already being fired + // in leverageNative. + _default: function() { + return true; + }, + + delegateType: delegateType + }; +} ); + +// Create mouseenter/leave events using mouseover/out and event-time checks +// so that event delegation works in jQuery. +// Do the same for pointerenter/pointerleave and pointerover/pointerout +// +// Support: Safari 7 only +// Safari sends mouseenter too often; see: +// https://bugs.chromium.org/p/chromium/issues/detail?id=470258 +// for the description of the bug (it existed in older Chrome versions as well). +jQuery.each( { + mouseenter: "mouseover", + mouseleave: "mouseout", + pointerenter: "pointerover", + pointerleave: "pointerout" +}, function( orig, fix ) { + jQuery.event.special[ orig ] = { + delegateType: fix, + bindType: fix, + + handle: function( event ) { + var ret, + target = this, + related = event.relatedTarget, + handleObj = event.handleObj; + + // For mouseenter/leave call the handler if related is outside the target. + // NB: No relatedTarget if the mouse left/entered the browser window + if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) { + event.type = handleObj.origType; + ret = handleObj.handler.apply( this, arguments ); + event.type = fix; + } + return ret; + } + }; +} ); + +jQuery.fn.extend( { + + on: function( types, selector, data, fn ) { + return on( this, types, selector, data, fn ); + }, + one: function( types, selector, data, fn ) { + return on( this, types, selector, data, fn, 1 ); + }, + off: function( types, selector, fn ) { + var handleObj, type; + if ( types && types.preventDefault && types.handleObj ) { + + // ( event ) dispatched jQuery.Event + handleObj = types.handleObj; + jQuery( types.delegateTarget ).off( + handleObj.namespace ? + handleObj.origType + "." + handleObj.namespace : + handleObj.origType, + handleObj.selector, + handleObj.handler + ); + return this; + } + if ( typeof types === "object" ) { + + // ( types-object [, selector] ) + for ( type in types ) { + this.off( type, selector, types[ type ] ); + } + return this; + } + if ( selector === false || typeof selector === "function" ) { + + // ( types [, fn] ) + fn = selector; + selector = undefined; + } + if ( fn === false ) { + fn = returnFalse; + } + return this.each( function() { + jQuery.event.remove( this, types, fn, selector ); + } ); + } +} ); + + +var + + // Support: IE <=10 - 11, Edge 12 - 13 only + // In IE/Edge using regex groups here causes severe slowdowns. + // See https://connect.microsoft.com/IE/feedback/details/1736512/ + rnoInnerhtml = /\s*$/g; + +// Prefer a tbody over its parent table for containing new rows +function manipulationTarget( elem, content ) { + if ( nodeName( elem, "table" ) && + nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) { + + return jQuery( elem ).children( "tbody" )[ 0 ] || elem; + } + + return elem; +} + +// Replace/restore the type attribute of script elements for safe DOM manipulation +function disableScript( elem ) { + elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type; + return elem; +} +function restoreScript( elem ) { + if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) { + elem.type = elem.type.slice( 5 ); + } else { + elem.removeAttribute( "type" ); + } + + return elem; +} + +function cloneCopyEvent( src, dest ) { + var i, l, type, pdataOld, udataOld, udataCur, events; + + if ( dest.nodeType !== 1 ) { + return; + } + + // 1. Copy private data: events, handlers, etc. + if ( dataPriv.hasData( src ) ) { + pdataOld = dataPriv.get( src ); + events = pdataOld.events; + + if ( events ) { + dataPriv.remove( dest, "handle events" ); + + for ( type in events ) { + for ( i = 0, l = events[ type ].length; i < l; i++ ) { + jQuery.event.add( dest, type, events[ type ][ i ] ); + } + } + } + } + + // 2. Copy user data + if ( dataUser.hasData( src ) ) { + udataOld = dataUser.access( src ); + udataCur = jQuery.extend( {}, udataOld ); + + dataUser.set( dest, udataCur ); + } +} + +// Fix IE bugs, see support tests +function fixInput( src, dest ) { + var nodeName = dest.nodeName.toLowerCase(); + + // Fails to persist the checked state of a cloned checkbox or radio button. + if ( nodeName === "input" && rcheckableType.test( src.type ) ) { + dest.checked = src.checked; + + // Fails to return the selected option to the default selected state when cloning options + } else if ( nodeName === "input" || nodeName === "textarea" ) { + dest.defaultValue = src.defaultValue; + } +} + +function domManip( collection, args, callback, ignored ) { + + // Flatten any nested arrays + args = flat( args ); + + var fragment, first, scripts, hasScripts, node, doc, + i = 0, + l = collection.length, + iNoClone = l - 1, + value = args[ 0 ], + valueIsFunction = isFunction( value ); + + // We can't cloneNode fragments that contain checked, in WebKit + if ( valueIsFunction || + ( l > 1 && typeof value === "string" && + !support.checkClone && rchecked.test( value ) ) ) { + return collection.each( function( index ) { + var self = collection.eq( index ); + if ( valueIsFunction ) { + args[ 0 ] = value.call( this, index, self.html() ); + } + domManip( self, args, callback, ignored ); + } ); + } + + if ( l ) { + fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored ); + first = fragment.firstChild; + + if ( fragment.childNodes.length === 1 ) { + fragment = first; + } + + // Require either new content or an interest in ignored elements to invoke the callback + if ( first || ignored ) { + scripts = jQuery.map( getAll( fragment, "script" ), disableScript ); + hasScripts = scripts.length; + + // Use the original fragment for the last item + // instead of the first because it can end up + // being emptied incorrectly in certain situations (#8070). + for ( ; i < l; i++ ) { + node = fragment; + + if ( i !== iNoClone ) { + node = jQuery.clone( node, true, true ); + + // Keep references to cloned scripts for later restoration + if ( hasScripts ) { + + // Support: Android <=4.0 only, PhantomJS 1 only + // push.apply(_, arraylike) throws on ancient WebKit + jQuery.merge( scripts, getAll( node, "script" ) ); + } + } + + callback.call( collection[ i ], node, i ); + } + + if ( hasScripts ) { + doc = scripts[ scripts.length - 1 ].ownerDocument; + + // Reenable scripts + jQuery.map( scripts, restoreScript ); + + // Evaluate executable scripts on first document insertion + for ( i = 0; i < hasScripts; i++ ) { + node = scripts[ i ]; + if ( rscriptType.test( node.type || "" ) && + !dataPriv.access( node, "globalEval" ) && + jQuery.contains( doc, node ) ) { + + if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) { + + // Optional AJAX dependency, but won't run scripts if not present + if ( jQuery._evalUrl && !node.noModule ) { + jQuery._evalUrl( node.src, { + nonce: node.nonce || node.getAttribute( "nonce" ) + }, doc ); + } + } else { + DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc ); + } + } + } + } + } + } + + return collection; +} + +function remove( elem, selector, keepData ) { + var node, + nodes = selector ? jQuery.filter( selector, elem ) : elem, + i = 0; + + for ( ; ( node = nodes[ i ] ) != null; i++ ) { + if ( !keepData && node.nodeType === 1 ) { + jQuery.cleanData( getAll( node ) ); + } + + if ( node.parentNode ) { + if ( keepData && isAttached( node ) ) { + setGlobalEval( getAll( node, "script" ) ); + } + node.parentNode.removeChild( node ); + } + } + + return elem; +} + +jQuery.extend( { + htmlPrefilter: function( html ) { + return html; + }, + + clone: function( elem, dataAndEvents, deepDataAndEvents ) { + var i, l, srcElements, destElements, + clone = elem.cloneNode( true ), + inPage = isAttached( elem ); + + // Fix IE cloning issues + if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) && + !jQuery.isXMLDoc( elem ) ) { + + // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2 + destElements = getAll( clone ); + srcElements = getAll( elem ); + + for ( i = 0, l = srcElements.length; i < l; i++ ) { + fixInput( srcElements[ i ], destElements[ i ] ); + } + } + + // Copy the events from the original to the clone + if ( dataAndEvents ) { + if ( deepDataAndEvents ) { + srcElements = srcElements || getAll( elem ); + destElements = destElements || getAll( clone ); + + for ( i = 0, l = srcElements.length; i < l; i++ ) { + cloneCopyEvent( srcElements[ i ], destElements[ i ] ); + } + } else { + cloneCopyEvent( elem, clone ); + } + } + + // Preserve script evaluation history + destElements = getAll( clone, "script" ); + if ( destElements.length > 0 ) { + setGlobalEval( destElements, !inPage && getAll( elem, "script" ) ); + } + + // Return the cloned set + return clone; + }, + + cleanData: function( elems ) { + var data, elem, type, + special = jQuery.event.special, + i = 0; + + for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) { + if ( acceptData( elem ) ) { + if ( ( data = elem[ dataPriv.expando ] ) ) { + if ( data.events ) { + for ( type in data.events ) { + if ( special[ type ] ) { + jQuery.event.remove( elem, type ); + + // This is a shortcut to avoid jQuery.event.remove's overhead + } else { + jQuery.removeEvent( elem, type, data.handle ); + } + } + } + + // Support: Chrome <=35 - 45+ + // Assign undefined instead of using delete, see Data#remove + elem[ dataPriv.expando ] = undefined; + } + if ( elem[ dataUser.expando ] ) { + + // Support: Chrome <=35 - 45+ + // Assign undefined instead of using delete, see Data#remove + elem[ dataUser.expando ] = undefined; + } + } + } + } +} ); + +jQuery.fn.extend( { + detach: function( selector ) { + return remove( this, selector, true ); + }, + + remove: function( selector ) { + return remove( this, selector ); + }, + + text: function( value ) { + return access( this, function( value ) { + return value === undefined ? + jQuery.text( this ) : + this.empty().each( function() { + if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { + this.textContent = value; + } + } ); + }, null, value, arguments.length ); + }, + + append: function() { + return domManip( this, arguments, function( elem ) { + if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { + var target = manipulationTarget( this, elem ); + target.appendChild( elem ); + } + } ); + }, + + prepend: function() { + return domManip( this, arguments, function( elem ) { + if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { + var target = manipulationTarget( this, elem ); + target.insertBefore( elem, target.firstChild ); + } + } ); + }, + + before: function() { + return domManip( this, arguments, function( elem ) { + if ( this.parentNode ) { + this.parentNode.insertBefore( elem, this ); + } + } ); + }, + + after: function() { + return domManip( this, arguments, function( elem ) { + if ( this.parentNode ) { + this.parentNode.insertBefore( elem, this.nextSibling ); + } + } ); + }, + + empty: function() { + var elem, + i = 0; + + for ( ; ( elem = this[ i ] ) != null; i++ ) { + if ( elem.nodeType === 1 ) { + + // Prevent memory leaks + jQuery.cleanData( getAll( elem, false ) ); + + // Remove any remaining nodes + elem.textContent = ""; + } + } + + return this; + }, + + clone: function( dataAndEvents, deepDataAndEvents ) { + dataAndEvents = dataAndEvents == null ? false : dataAndEvents; + deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; + + return this.map( function() { + return jQuery.clone( this, dataAndEvents, deepDataAndEvents ); + } ); + }, + + html: function( value ) { + return access( this, function( value ) { + var elem = this[ 0 ] || {}, + i = 0, + l = this.length; + + if ( value === undefined && elem.nodeType === 1 ) { + return elem.innerHTML; + } + + // See if we can take a shortcut and just use innerHTML + if ( typeof value === "string" && !rnoInnerhtml.test( value ) && + !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) { + + value = jQuery.htmlPrefilter( value ); + + try { + for ( ; i < l; i++ ) { + elem = this[ i ] || {}; + + // Remove element nodes and prevent memory leaks + if ( elem.nodeType === 1 ) { + jQuery.cleanData( getAll( elem, false ) ); + elem.innerHTML = value; + } + } + + elem = 0; + + // If using innerHTML throws an exception, use the fallback method + } catch ( e ) {} + } + + if ( elem ) { + this.empty().append( value ); + } + }, null, value, arguments.length ); + }, + + replaceWith: function() { + var ignored = []; + + // Make the changes, replacing each non-ignored context element with the new content + return domManip( this, arguments, function( elem ) { + var parent = this.parentNode; + + if ( jQuery.inArray( this, ignored ) < 0 ) { + jQuery.cleanData( getAll( this ) ); + if ( parent ) { + parent.replaceChild( elem, this ); + } + } + + // Force callback invocation + }, ignored ); + } +} ); + +jQuery.each( { + appendTo: "append", + prependTo: "prepend", + insertBefore: "before", + insertAfter: "after", + replaceAll: "replaceWith" +}, function( name, original ) { + jQuery.fn[ name ] = function( selector ) { + var elems, + ret = [], + insert = jQuery( selector ), + last = insert.length - 1, + i = 0; + + for ( ; i <= last; i++ ) { + elems = i === last ? this : this.clone( true ); + jQuery( insert[ i ] )[ original ]( elems ); + + // Support: Android <=4.0 only, PhantomJS 1 only + // .get() because push.apply(_, arraylike) throws on ancient WebKit + push.apply( ret, elems.get() ); + } + + return this.pushStack( ret ); + }; +} ); +var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" ); + +var getStyles = function( elem ) { + + // Support: IE <=11 only, Firefox <=30 (#15098, #14150) + // IE throws on elements created in popups + // FF meanwhile throws on frame elements through "defaultView.getComputedStyle" + var view = elem.ownerDocument.defaultView; + + if ( !view || !view.opener ) { + view = window; + } + + return view.getComputedStyle( elem ); + }; + +var swap = function( elem, options, callback ) { + var ret, name, + old = {}; + + // Remember the old values, and insert the new ones + for ( name in options ) { + old[ name ] = elem.style[ name ]; + elem.style[ name ] = options[ name ]; + } + + ret = callback.call( elem ); + + // Revert the old values + for ( name in options ) { + elem.style[ name ] = old[ name ]; + } + + return ret; +}; + + +var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" ); + + + +( function() { + + // Executing both pixelPosition & boxSizingReliable tests require only one layout + // so they're executed at the same time to save the second computation. + function computeStyleTests() { + + // This is a singleton, we need to execute it only once + if ( !div ) { + return; + } + + container.style.cssText = "position:absolute;left:-11111px;width:60px;" + + "margin-top:1px;padding:0;border:0"; + div.style.cssText = + "position:relative;display:block;box-sizing:border-box;overflow:scroll;" + + "margin:auto;border:1px;padding:1px;" + + "width:60%;top:1%"; + documentElement.appendChild( container ).appendChild( div ); + + var divStyle = window.getComputedStyle( div ); + pixelPositionVal = divStyle.top !== "1%"; + + // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44 + reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12; + + // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3 + // Some styles come back with percentage values, even though they shouldn't + div.style.right = "60%"; + pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36; + + // Support: IE 9 - 11 only + // Detect misreporting of content dimensions for box-sizing:border-box elements + boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36; + + // Support: IE 9 only + // Detect overflow:scroll screwiness (gh-3699) + // Support: Chrome <=64 + // Don't get tricked when zoom affects offsetWidth (gh-4029) + div.style.position = "absolute"; + scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12; + + documentElement.removeChild( container ); + + // Nullify the div so it wouldn't be stored in the memory and + // it will also be a sign that checks already performed + div = null; + } + + function roundPixelMeasures( measure ) { + return Math.round( parseFloat( measure ) ); + } + + var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal, + reliableTrDimensionsVal, reliableMarginLeftVal, + container = document.createElement( "div" ), + div = document.createElement( "div" ); + + // Finish early in limited (non-browser) environments + if ( !div.style ) { + return; + } + + // Support: IE <=9 - 11 only + // Style of cloned element affects source element cloned (#8908) + div.style.backgroundClip = "content-box"; + div.cloneNode( true ).style.backgroundClip = ""; + support.clearCloneStyle = div.style.backgroundClip === "content-box"; + + jQuery.extend( support, { + boxSizingReliable: function() { + computeStyleTests(); + return boxSizingReliableVal; + }, + pixelBoxStyles: function() { + computeStyleTests(); + return pixelBoxStylesVal; + }, + pixelPosition: function() { + computeStyleTests(); + return pixelPositionVal; + }, + reliableMarginLeft: function() { + computeStyleTests(); + return reliableMarginLeftVal; + }, + scrollboxSize: function() { + computeStyleTests(); + return scrollboxSizeVal; + }, + + // Support: IE 9 - 11+, Edge 15 - 18+ + // IE/Edge misreport `getComputedStyle` of table rows with width/height + // set in CSS while `offset*` properties report correct values. + // Behavior in IE 9 is more subtle than in newer versions & it passes + // some versions of this test; make sure not to make it pass there! + // + // Support: Firefox 70+ + // Only Firefox includes border widths + // in computed dimensions. (gh-4529) + reliableTrDimensions: function() { + var table, tr, trChild, trStyle; + if ( reliableTrDimensionsVal == null ) { + table = document.createElement( "table" ); + tr = document.createElement( "tr" ); + trChild = document.createElement( "div" ); + + table.style.cssText = "position:absolute;left:-11111px;border-collapse:separate"; + tr.style.cssText = "border:1px solid"; + + // Support: Chrome 86+ + // Height set through cssText does not get applied. + // Computed height then comes back as 0. + tr.style.height = "1px"; + trChild.style.height = "9px"; + + // Support: Android 8 Chrome 86+ + // In our bodyBackground.html iframe, + // display for all div elements is set to "inline", + // which causes a problem only in Android 8 Chrome 86. + // Ensuring the div is display: block + // gets around this issue. + trChild.style.display = "block"; + + documentElement + .appendChild( table ) + .appendChild( tr ) + .appendChild( trChild ); + + trStyle = window.getComputedStyle( tr ); + reliableTrDimensionsVal = ( parseInt( trStyle.height, 10 ) + + parseInt( trStyle.borderTopWidth, 10 ) + + parseInt( trStyle.borderBottomWidth, 10 ) ) === tr.offsetHeight; + + documentElement.removeChild( table ); + } + return reliableTrDimensionsVal; + } + } ); +} )(); + + +function curCSS( elem, name, computed ) { + var width, minWidth, maxWidth, ret, + + // Support: Firefox 51+ + // Retrieving style before computed somehow + // fixes an issue with getting wrong values + // on detached elements + style = elem.style; + + computed = computed || getStyles( elem ); + + // getPropertyValue is needed for: + // .css('filter') (IE 9 only, #12537) + // .css('--customProperty) (#3144) + if ( computed ) { + ret = computed.getPropertyValue( name ) || computed[ name ]; + + if ( ret === "" && !isAttached( elem ) ) { + ret = jQuery.style( elem, name ); + } + + // A tribute to the "awesome hack by Dean Edwards" + // Android Browser returns percentage for some values, + // but width seems to be reliably pixels. + // This is against the CSSOM draft spec: + // https://drafts.csswg.org/cssom/#resolved-values + if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) { + + // Remember the original values + width = style.width; + minWidth = style.minWidth; + maxWidth = style.maxWidth; + + // Put in the new values to get a computed value out + style.minWidth = style.maxWidth = style.width = ret; + ret = computed.width; + + // Revert the changed values + style.width = width; + style.minWidth = minWidth; + style.maxWidth = maxWidth; + } + } + + return ret !== undefined ? + + // Support: IE <=9 - 11 only + // IE returns zIndex value as an integer. + ret + "" : + ret; +} + + +function addGetHookIf( conditionFn, hookFn ) { + + // Define the hook, we'll check on the first run if it's really needed. + return { + get: function() { + if ( conditionFn() ) { + + // Hook not needed (or it's not possible to use it due + // to missing dependency), remove it. + delete this.get; + return; + } + + // Hook needed; redefine it so that the support test is not executed again. + return ( this.get = hookFn ).apply( this, arguments ); + } + }; +} + + +var cssPrefixes = [ "Webkit", "Moz", "ms" ], + emptyStyle = document.createElement( "div" ).style, + vendorProps = {}; + +// Return a vendor-prefixed property or undefined +function vendorPropName( name ) { + + // Check for vendor prefixed names + var capName = name[ 0 ].toUpperCase() + name.slice( 1 ), + i = cssPrefixes.length; + + while ( i-- ) { + name = cssPrefixes[ i ] + capName; + if ( name in emptyStyle ) { + return name; + } + } +} + +// Return a potentially-mapped jQuery.cssProps or vendor prefixed property +function finalPropName( name ) { + var final = jQuery.cssProps[ name ] || vendorProps[ name ]; + + if ( final ) { + return final; + } + if ( name in emptyStyle ) { + return name; + } + return vendorProps[ name ] = vendorPropName( name ) || name; +} + + +var + + // Swappable if display is none or starts with table + // except "table", "table-cell", or "table-caption" + // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display + rdisplayswap = /^(none|table(?!-c[ea]).+)/, + rcustomProp = /^--/, + cssShow = { position: "absolute", visibility: "hidden", display: "block" }, + cssNormalTransform = { + letterSpacing: "0", + fontWeight: "400" + }; + +function setPositiveNumber( _elem, value, subtract ) { + + // Any relative (+/-) values have already been + // normalized at this point + var matches = rcssNum.exec( value ); + return matches ? + + // Guard against undefined "subtract", e.g., when used as in cssHooks + Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) : + value; +} + +function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) { + var i = dimension === "width" ? 1 : 0, + extra = 0, + delta = 0; + + // Adjustment may not be necessary + if ( box === ( isBorderBox ? "border" : "content" ) ) { + return 0; + } + + for ( ; i < 4; i += 2 ) { + + // Both box models exclude margin + if ( box === "margin" ) { + delta += jQuery.css( elem, box + cssExpand[ i ], true, styles ); + } + + // If we get here with a content-box, we're seeking "padding" or "border" or "margin" + if ( !isBorderBox ) { + + // Add padding + delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); + + // For "border" or "margin", add border + if ( box !== "padding" ) { + delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); + + // But still keep track of it otherwise + } else { + extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); + } + + // If we get here with a border-box (content + padding + border), we're seeking "content" or + // "padding" or "margin" + } else { + + // For "content", subtract padding + if ( box === "content" ) { + delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); + } + + // For "content" or "padding", subtract border + if ( box !== "margin" ) { + delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); + } + } + } + + // Account for positive content-box scroll gutter when requested by providing computedVal + if ( !isBorderBox && computedVal >= 0 ) { + + // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border + // Assuming integer scroll gutter, subtract the rest and round down + delta += Math.max( 0, Math.ceil( + elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] - + computedVal - + delta - + extra - + 0.5 + + // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter + // Use an explicit zero to avoid NaN (gh-3964) + ) ) || 0; + } + + return delta; +} + +function getWidthOrHeight( elem, dimension, extra ) { + + // Start with computed style + var styles = getStyles( elem ), + + // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322). + // Fake content-box until we know it's needed to know the true value. + boxSizingNeeded = !support.boxSizingReliable() || extra, + isBorderBox = boxSizingNeeded && + jQuery.css( elem, "boxSizing", false, styles ) === "border-box", + valueIsBorderBox = isBorderBox, + + val = curCSS( elem, dimension, styles ), + offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ); + + // Support: Firefox <=54 + // Return a confounding non-pixel value or feign ignorance, as appropriate. + if ( rnumnonpx.test( val ) ) { + if ( !extra ) { + return val; + } + val = "auto"; + } + + + // Support: IE 9 - 11 only + // Use offsetWidth/offsetHeight for when box sizing is unreliable. + // In those cases, the computed value can be trusted to be border-box. + if ( ( !support.boxSizingReliable() && isBorderBox || + + // Support: IE 10 - 11+, Edge 15 - 18+ + // IE/Edge misreport `getComputedStyle` of table rows with width/height + // set in CSS while `offset*` properties report correct values. + // Interestingly, in some cases IE 9 doesn't suffer from this issue. + !support.reliableTrDimensions() && nodeName( elem, "tr" ) || + + // Fall back to offsetWidth/offsetHeight when value is "auto" + // This happens for inline elements with no explicit setting (gh-3571) + val === "auto" || + + // Support: Android <=4.1 - 4.3 only + // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602) + !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) && + + // Make sure the element is visible & connected + elem.getClientRects().length ) { + + isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; + + // Where available, offsetWidth/offsetHeight approximate border box dimensions. + // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the + // retrieved value as a content box dimension. + valueIsBorderBox = offsetProp in elem; + if ( valueIsBorderBox ) { + val = elem[ offsetProp ]; + } + } + + // Normalize "" and auto + val = parseFloat( val ) || 0; + + // Adjust for the element's box model + return ( val + + boxModelAdjustment( + elem, + dimension, + extra || ( isBorderBox ? "border" : "content" ), + valueIsBorderBox, + styles, + + // Provide the current computed size to request scroll gutter calculation (gh-3589) + val + ) + ) + "px"; +} + +jQuery.extend( { + + // Add in style property hooks for overriding the default + // behavior of getting and setting a style property + cssHooks: { + opacity: { + get: function( elem, computed ) { + if ( computed ) { + + // We should always get a number back from opacity + var ret = curCSS( elem, "opacity" ); + return ret === "" ? "1" : ret; + } + } + } + }, + + // Don't automatically add "px" to these possibly-unitless properties + cssNumber: { + "animationIterationCount": true, + "columnCount": true, + "fillOpacity": true, + "flexGrow": true, + "flexShrink": true, + "fontWeight": true, + "gridArea": true, + "gridColumn": true, + "gridColumnEnd": true, + "gridColumnStart": true, + "gridRow": true, + "gridRowEnd": true, + "gridRowStart": true, + "lineHeight": true, + "opacity": true, + "order": true, + "orphans": true, + "widows": true, + "zIndex": true, + "zoom": true + }, + + // Add in properties whose names you wish to fix before + // setting or getting the value + cssProps: {}, + + // Get and set the style property on a DOM Node + style: function( elem, name, value, extra ) { + + // Don't set styles on text and comment nodes + if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) { + return; + } + + // Make sure that we're working with the right name + var ret, type, hooks, + origName = camelCase( name ), + isCustomProp = rcustomProp.test( name ), + style = elem.style; + + // Make sure that we're working with the right name. We don't + // want to query the value if it is a CSS custom property + // since they are user-defined. + if ( !isCustomProp ) { + name = finalPropName( origName ); + } + + // Gets hook for the prefixed version, then unprefixed version + hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; + + // Check if we're setting a value + if ( value !== undefined ) { + type = typeof value; + + // Convert "+=" or "-=" to relative numbers (#7345) + if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) { + value = adjustCSS( elem, name, ret ); + + // Fixes bug #9237 + type = "number"; + } + + // Make sure that null and NaN values aren't set (#7116) + if ( value == null || value !== value ) { + return; + } + + // If a number was passed in, add the unit (except for certain CSS properties) + // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append + // "px" to a few hardcoded values. + if ( type === "number" && !isCustomProp ) { + value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" ); + } + + // background-* props affect original clone's values + if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) { + style[ name ] = "inherit"; + } + + // If a hook was provided, use that value, otherwise just set the specified value + if ( !hooks || !( "set" in hooks ) || + ( value = hooks.set( elem, value, extra ) ) !== undefined ) { + + if ( isCustomProp ) { + style.setProperty( name, value ); + } else { + style[ name ] = value; + } + } + + } else { + + // If a hook was provided get the non-computed value from there + if ( hooks && "get" in hooks && + ( ret = hooks.get( elem, false, extra ) ) !== undefined ) { + + return ret; + } + + // Otherwise just get the value from the style object + return style[ name ]; + } + }, + + css: function( elem, name, extra, styles ) { + var val, num, hooks, + origName = camelCase( name ), + isCustomProp = rcustomProp.test( name ); + + // Make sure that we're working with the right name. We don't + // want to modify the value if it is a CSS custom property + // since they are user-defined. + if ( !isCustomProp ) { + name = finalPropName( origName ); + } + + // Try prefixed name followed by the unprefixed name + hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; + + // If a hook was provided get the computed value from there + if ( hooks && "get" in hooks ) { + val = hooks.get( elem, true, extra ); + } + + // Otherwise, if a way to get the computed value exists, use that + if ( val === undefined ) { + val = curCSS( elem, name, styles ); + } + + // Convert "normal" to computed value + if ( val === "normal" && name in cssNormalTransform ) { + val = cssNormalTransform[ name ]; + } + + // Make numeric if forced or a qualifier was provided and val looks numeric + if ( extra === "" || extra ) { + num = parseFloat( val ); + return extra === true || isFinite( num ) ? num || 0 : val; + } + + return val; + } +} ); + +jQuery.each( [ "height", "width" ], function( _i, dimension ) { + jQuery.cssHooks[ dimension ] = { + get: function( elem, computed, extra ) { + if ( computed ) { + + // Certain elements can have dimension info if we invisibly show them + // but it must have a current display style that would benefit + return rdisplayswap.test( jQuery.css( elem, "display" ) ) && + + // Support: Safari 8+ + // Table columns in Safari have non-zero offsetWidth & zero + // getBoundingClientRect().width unless display is changed. + // Support: IE <=11 only + // Running getBoundingClientRect on a disconnected node + // in IE throws an error. + ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ? + swap( elem, cssShow, function() { + return getWidthOrHeight( elem, dimension, extra ); + } ) : + getWidthOrHeight( elem, dimension, extra ); + } + }, + + set: function( elem, value, extra ) { + var matches, + styles = getStyles( elem ), + + // Only read styles.position if the test has a chance to fail + // to avoid forcing a reflow. + scrollboxSizeBuggy = !support.scrollboxSize() && + styles.position === "absolute", + + // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991) + boxSizingNeeded = scrollboxSizeBuggy || extra, + isBorderBox = boxSizingNeeded && + jQuery.css( elem, "boxSizing", false, styles ) === "border-box", + subtract = extra ? + boxModelAdjustment( + elem, + dimension, + extra, + isBorderBox, + styles + ) : + 0; + + // Account for unreliable border-box dimensions by comparing offset* to computed and + // faking a content-box to get border and padding (gh-3699) + if ( isBorderBox && scrollboxSizeBuggy ) { + subtract -= Math.ceil( + elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] - + parseFloat( styles[ dimension ] ) - + boxModelAdjustment( elem, dimension, "border", false, styles ) - + 0.5 + ); + } + + // Convert to pixels if value adjustment is needed + if ( subtract && ( matches = rcssNum.exec( value ) ) && + ( matches[ 3 ] || "px" ) !== "px" ) { + + elem.style[ dimension ] = value; + value = jQuery.css( elem, dimension ); + } + + return setPositiveNumber( elem, value, subtract ); + } + }; +} ); + +jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft, + function( elem, computed ) { + if ( computed ) { + return ( parseFloat( curCSS( elem, "marginLeft" ) ) || + elem.getBoundingClientRect().left - + swap( elem, { marginLeft: 0 }, function() { + return elem.getBoundingClientRect().left; + } ) + ) + "px"; + } + } +); + +// These hooks are used by animate to expand properties +jQuery.each( { + margin: "", + padding: "", + border: "Width" +}, function( prefix, suffix ) { + jQuery.cssHooks[ prefix + suffix ] = { + expand: function( value ) { + var i = 0, + expanded = {}, + + // Assumes a single number if not a string + parts = typeof value === "string" ? value.split( " " ) : [ value ]; + + for ( ; i < 4; i++ ) { + expanded[ prefix + cssExpand[ i ] + suffix ] = + parts[ i ] || parts[ i - 2 ] || parts[ 0 ]; + } + + return expanded; + } + }; + + if ( prefix !== "margin" ) { + jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber; + } +} ); + +jQuery.fn.extend( { + css: function( name, value ) { + return access( this, function( elem, name, value ) { + var styles, len, + map = {}, + i = 0; + + if ( Array.isArray( name ) ) { + styles = getStyles( elem ); + len = name.length; + + for ( ; i < len; i++ ) { + map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles ); + } + + return map; + } + + return value !== undefined ? + jQuery.style( elem, name, value ) : + jQuery.css( elem, name ); + }, name, value, arguments.length > 1 ); + } +} ); + + +function Tween( elem, options, prop, end, easing ) { + return new Tween.prototype.init( elem, options, prop, end, easing ); +} +jQuery.Tween = Tween; + +Tween.prototype = { + constructor: Tween, + init: function( elem, options, prop, end, easing, unit ) { + this.elem = elem; + this.prop = prop; + this.easing = easing || jQuery.easing._default; + this.options = options; + this.start = this.now = this.cur(); + this.end = end; + this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" ); + }, + cur: function() { + var hooks = Tween.propHooks[ this.prop ]; + + return hooks && hooks.get ? + hooks.get( this ) : + Tween.propHooks._default.get( this ); + }, + run: function( percent ) { + var eased, + hooks = Tween.propHooks[ this.prop ]; + + if ( this.options.duration ) { + this.pos = eased = jQuery.easing[ this.easing ]( + percent, this.options.duration * percent, 0, 1, this.options.duration + ); + } else { + this.pos = eased = percent; + } + this.now = ( this.end - this.start ) * eased + this.start; + + if ( this.options.step ) { + this.options.step.call( this.elem, this.now, this ); + } + + if ( hooks && hooks.set ) { + hooks.set( this ); + } else { + Tween.propHooks._default.set( this ); + } + return this; + } +}; + +Tween.prototype.init.prototype = Tween.prototype; + +Tween.propHooks = { + _default: { + get: function( tween ) { + var result; + + // Use a property on the element directly when it is not a DOM element, + // or when there is no matching style property that exists. + if ( tween.elem.nodeType !== 1 || + tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) { + return tween.elem[ tween.prop ]; + } + + // Passing an empty string as a 3rd parameter to .css will automatically + // attempt a parseFloat and fallback to a string if the parse fails. + // Simple values such as "10px" are parsed to Float; + // complex values such as "rotate(1rad)" are returned as-is. + result = jQuery.css( tween.elem, tween.prop, "" ); + + // Empty strings, null, undefined and "auto" are converted to 0. + return !result || result === "auto" ? 0 : result; + }, + set: function( tween ) { + + // Use step hook for back compat. + // Use cssHook if its there. + // Use .style if available and use plain properties where available. + if ( jQuery.fx.step[ tween.prop ] ) { + jQuery.fx.step[ tween.prop ]( tween ); + } else if ( tween.elem.nodeType === 1 && ( + jQuery.cssHooks[ tween.prop ] || + tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) { + jQuery.style( tween.elem, tween.prop, tween.now + tween.unit ); + } else { + tween.elem[ tween.prop ] = tween.now; + } + } + } +}; + +// Support: IE <=9 only +// Panic based approach to setting things on disconnected nodes +Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = { + set: function( tween ) { + if ( tween.elem.nodeType && tween.elem.parentNode ) { + tween.elem[ tween.prop ] = tween.now; + } + } +}; + +jQuery.easing = { + linear: function( p ) { + return p; + }, + swing: function( p ) { + return 0.5 - Math.cos( p * Math.PI ) / 2; + }, + _default: "swing" +}; + +jQuery.fx = Tween.prototype.init; + +// Back compat <1.8 extension point +jQuery.fx.step = {}; + + + + +var + fxNow, inProgress, + rfxtypes = /^(?:toggle|show|hide)$/, + rrun = /queueHooks$/; + +function schedule() { + if ( inProgress ) { + if ( document.hidden === false && window.requestAnimationFrame ) { + window.requestAnimationFrame( schedule ); + } else { + window.setTimeout( schedule, jQuery.fx.interval ); + } + + jQuery.fx.tick(); + } +} + +// Animations created synchronously will run synchronously +function createFxNow() { + window.setTimeout( function() { + fxNow = undefined; + } ); + return ( fxNow = Date.now() ); +} + +// Generate parameters to create a standard animation +function genFx( type, includeWidth ) { + var which, + i = 0, + attrs = { height: type }; + + // If we include width, step value is 1 to do all cssExpand values, + // otherwise step value is 2 to skip over Left and Right + includeWidth = includeWidth ? 1 : 0; + for ( ; i < 4; i += 2 - includeWidth ) { + which = cssExpand[ i ]; + attrs[ "margin" + which ] = attrs[ "padding" + which ] = type; + } + + if ( includeWidth ) { + attrs.opacity = attrs.width = type; + } + + return attrs; +} + +function createTween( value, prop, animation ) { + var tween, + collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ), + index = 0, + length = collection.length; + for ( ; index < length; index++ ) { + if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) { + + // We're done with this property + return tween; + } + } +} + +function defaultPrefilter( elem, props, opts ) { + var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display, + isBox = "width" in props || "height" in props, + anim = this, + orig = {}, + style = elem.style, + hidden = elem.nodeType && isHiddenWithinTree( elem ), + dataShow = dataPriv.get( elem, "fxshow" ); + + // Queue-skipping animations hijack the fx hooks + if ( !opts.queue ) { + hooks = jQuery._queueHooks( elem, "fx" ); + if ( hooks.unqueued == null ) { + hooks.unqueued = 0; + oldfire = hooks.empty.fire; + hooks.empty.fire = function() { + if ( !hooks.unqueued ) { + oldfire(); + } + }; + } + hooks.unqueued++; + + anim.always( function() { + + // Ensure the complete handler is called before this completes + anim.always( function() { + hooks.unqueued--; + if ( !jQuery.queue( elem, "fx" ).length ) { + hooks.empty.fire(); + } + } ); + } ); + } + + // Detect show/hide animations + for ( prop in props ) { + value = props[ prop ]; + if ( rfxtypes.test( value ) ) { + delete props[ prop ]; + toggle = toggle || value === "toggle"; + if ( value === ( hidden ? "hide" : "show" ) ) { + + // Pretend to be hidden if this is a "show" and + // there is still data from a stopped show/hide + if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) { + hidden = true; + + // Ignore all other no-op show/hide data + } else { + continue; + } + } + orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop ); + } + } + + // Bail out if this is a no-op like .hide().hide() + propTween = !jQuery.isEmptyObject( props ); + if ( !propTween && jQuery.isEmptyObject( orig ) ) { + return; + } + + // Restrict "overflow" and "display" styles during box animations + if ( isBox && elem.nodeType === 1 ) { + + // Support: IE <=9 - 11, Edge 12 - 15 + // Record all 3 overflow attributes because IE does not infer the shorthand + // from identically-valued overflowX and overflowY and Edge just mirrors + // the overflowX value there. + opts.overflow = [ style.overflow, style.overflowX, style.overflowY ]; + + // Identify a display type, preferring old show/hide data over the CSS cascade + restoreDisplay = dataShow && dataShow.display; + if ( restoreDisplay == null ) { + restoreDisplay = dataPriv.get( elem, "display" ); + } + display = jQuery.css( elem, "display" ); + if ( display === "none" ) { + if ( restoreDisplay ) { + display = restoreDisplay; + } else { + + // Get nonempty value(s) by temporarily forcing visibility + showHide( [ elem ], true ); + restoreDisplay = elem.style.display || restoreDisplay; + display = jQuery.css( elem, "display" ); + showHide( [ elem ] ); + } + } + + // Animate inline elements as inline-block + if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) { + if ( jQuery.css( elem, "float" ) === "none" ) { + + // Restore the original display value at the end of pure show/hide animations + if ( !propTween ) { + anim.done( function() { + style.display = restoreDisplay; + } ); + if ( restoreDisplay == null ) { + display = style.display; + restoreDisplay = display === "none" ? "" : display; + } + } + style.display = "inline-block"; + } + } + } + + if ( opts.overflow ) { + style.overflow = "hidden"; + anim.always( function() { + style.overflow = opts.overflow[ 0 ]; + style.overflowX = opts.overflow[ 1 ]; + style.overflowY = opts.overflow[ 2 ]; + } ); + } + + // Implement show/hide animations + propTween = false; + for ( prop in orig ) { + + // General show/hide setup for this element animation + if ( !propTween ) { + if ( dataShow ) { + if ( "hidden" in dataShow ) { + hidden = dataShow.hidden; + } + } else { + dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } ); + } + + // Store hidden/visible for toggle so `.stop().toggle()` "reverses" + if ( toggle ) { + dataShow.hidden = !hidden; + } + + // Show elements before animating them + if ( hidden ) { + showHide( [ elem ], true ); + } + + /* eslint-disable no-loop-func */ + + anim.done( function() { + + /* eslint-enable no-loop-func */ + + // The final step of a "hide" animation is actually hiding the element + if ( !hidden ) { + showHide( [ elem ] ); + } + dataPriv.remove( elem, "fxshow" ); + for ( prop in orig ) { + jQuery.style( elem, prop, orig[ prop ] ); + } + } ); + } + + // Per-property setup + propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim ); + if ( !( prop in dataShow ) ) { + dataShow[ prop ] = propTween.start; + if ( hidden ) { + propTween.end = propTween.start; + propTween.start = 0; + } + } + } +} + +function propFilter( props, specialEasing ) { + var index, name, easing, value, hooks; + + // camelCase, specialEasing and expand cssHook pass + for ( index in props ) { + name = camelCase( index ); + easing = specialEasing[ name ]; + value = props[ index ]; + if ( Array.isArray( value ) ) { + easing = value[ 1 ]; + value = props[ index ] = value[ 0 ]; + } + + if ( index !== name ) { + props[ name ] = value; + delete props[ index ]; + } + + hooks = jQuery.cssHooks[ name ]; + if ( hooks && "expand" in hooks ) { + value = hooks.expand( value ); + delete props[ name ]; + + // Not quite $.extend, this won't overwrite existing keys. + // Reusing 'index' because we have the correct "name" + for ( index in value ) { + if ( !( index in props ) ) { + props[ index ] = value[ index ]; + specialEasing[ index ] = easing; + } + } + } else { + specialEasing[ name ] = easing; + } + } +} + +function Animation( elem, properties, options ) { + var result, + stopped, + index = 0, + length = Animation.prefilters.length, + deferred = jQuery.Deferred().always( function() { + + // Don't match elem in the :animated selector + delete tick.elem; + } ), + tick = function() { + if ( stopped ) { + return false; + } + var currentTime = fxNow || createFxNow(), + remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ), + + // Support: Android 2.3 only + // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497) + temp = remaining / animation.duration || 0, + percent = 1 - temp, + index = 0, + length = animation.tweens.length; + + for ( ; index < length; index++ ) { + animation.tweens[ index ].run( percent ); + } + + deferred.notifyWith( elem, [ animation, percent, remaining ] ); + + // If there's more to do, yield + if ( percent < 1 && length ) { + return remaining; + } + + // If this was an empty animation, synthesize a final progress notification + if ( !length ) { + deferred.notifyWith( elem, [ animation, 1, 0 ] ); + } + + // Resolve the animation and report its conclusion + deferred.resolveWith( elem, [ animation ] ); + return false; + }, + animation = deferred.promise( { + elem: elem, + props: jQuery.extend( {}, properties ), + opts: jQuery.extend( true, { + specialEasing: {}, + easing: jQuery.easing._default + }, options ), + originalProperties: properties, + originalOptions: options, + startTime: fxNow || createFxNow(), + duration: options.duration, + tweens: [], + createTween: function( prop, end ) { + var tween = jQuery.Tween( elem, animation.opts, prop, end, + animation.opts.specialEasing[ prop ] || animation.opts.easing ); + animation.tweens.push( tween ); + return tween; + }, + stop: function( gotoEnd ) { + var index = 0, + + // If we are going to the end, we want to run all the tweens + // otherwise we skip this part + length = gotoEnd ? animation.tweens.length : 0; + if ( stopped ) { + return this; + } + stopped = true; + for ( ; index < length; index++ ) { + animation.tweens[ index ].run( 1 ); + } + + // Resolve when we played the last frame; otherwise, reject + if ( gotoEnd ) { + deferred.notifyWith( elem, [ animation, 1, 0 ] ); + deferred.resolveWith( elem, [ animation, gotoEnd ] ); + } else { + deferred.rejectWith( elem, [ animation, gotoEnd ] ); + } + return this; + } + } ), + props = animation.props; + + propFilter( props, animation.opts.specialEasing ); + + for ( ; index < length; index++ ) { + result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts ); + if ( result ) { + if ( isFunction( result.stop ) ) { + jQuery._queueHooks( animation.elem, animation.opts.queue ).stop = + result.stop.bind( result ); + } + return result; + } + } + + jQuery.map( props, createTween, animation ); + + if ( isFunction( animation.opts.start ) ) { + animation.opts.start.call( elem, animation ); + } + + // Attach callbacks from options + animation + .progress( animation.opts.progress ) + .done( animation.opts.done, animation.opts.complete ) + .fail( animation.opts.fail ) + .always( animation.opts.always ); + + jQuery.fx.timer( + jQuery.extend( tick, { + elem: elem, + anim: animation, + queue: animation.opts.queue + } ) + ); + + return animation; +} + +jQuery.Animation = jQuery.extend( Animation, { + + tweeners: { + "*": [ function( prop, value ) { + var tween = this.createTween( prop, value ); + adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween ); + return tween; + } ] + }, + + tweener: function( props, callback ) { + if ( isFunction( props ) ) { + callback = props; + props = [ "*" ]; + } else { + props = props.match( rnothtmlwhite ); + } + + var prop, + index = 0, + length = props.length; + + for ( ; index < length; index++ ) { + prop = props[ index ]; + Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || []; + Animation.tweeners[ prop ].unshift( callback ); + } + }, + + prefilters: [ defaultPrefilter ], + + prefilter: function( callback, prepend ) { + if ( prepend ) { + Animation.prefilters.unshift( callback ); + } else { + Animation.prefilters.push( callback ); + } + } +} ); + +jQuery.speed = function( speed, easing, fn ) { + var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : { + complete: fn || !fn && easing || + isFunction( speed ) && speed, + duration: speed, + easing: fn && easing || easing && !isFunction( easing ) && easing + }; + + // Go to the end state if fx are off + if ( jQuery.fx.off ) { + opt.duration = 0; + + } else { + if ( typeof opt.duration !== "number" ) { + if ( opt.duration in jQuery.fx.speeds ) { + opt.duration = jQuery.fx.speeds[ opt.duration ]; + + } else { + opt.duration = jQuery.fx.speeds._default; + } + } + } + + // Normalize opt.queue - true/undefined/null -> "fx" + if ( opt.queue == null || opt.queue === true ) { + opt.queue = "fx"; + } + + // Queueing + opt.old = opt.complete; + + opt.complete = function() { + if ( isFunction( opt.old ) ) { + opt.old.call( this ); + } + + if ( opt.queue ) { + jQuery.dequeue( this, opt.queue ); + } + }; + + return opt; +}; + +jQuery.fn.extend( { + fadeTo: function( speed, to, easing, callback ) { + + // Show any hidden elements after setting opacity to 0 + return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show() + + // Animate to the value specified + .end().animate( { opacity: to }, speed, easing, callback ); + }, + animate: function( prop, speed, easing, callback ) { + var empty = jQuery.isEmptyObject( prop ), + optall = jQuery.speed( speed, easing, callback ), + doAnimation = function() { + + // Operate on a copy of prop so per-property easing won't be lost + var anim = Animation( this, jQuery.extend( {}, prop ), optall ); + + // Empty animations, or finishing resolves immediately + if ( empty || dataPriv.get( this, "finish" ) ) { + anim.stop( true ); + } + }; + + doAnimation.finish = doAnimation; + + return empty || optall.queue === false ? + this.each( doAnimation ) : + this.queue( optall.queue, doAnimation ); + }, + stop: function( type, clearQueue, gotoEnd ) { + var stopQueue = function( hooks ) { + var stop = hooks.stop; + delete hooks.stop; + stop( gotoEnd ); + }; + + if ( typeof type !== "string" ) { + gotoEnd = clearQueue; + clearQueue = type; + type = undefined; + } + if ( clearQueue ) { + this.queue( type || "fx", [] ); + } + + return this.each( function() { + var dequeue = true, + index = type != null && type + "queueHooks", + timers = jQuery.timers, + data = dataPriv.get( this ); + + if ( index ) { + if ( data[ index ] && data[ index ].stop ) { + stopQueue( data[ index ] ); + } + } else { + for ( index in data ) { + if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) { + stopQueue( data[ index ] ); + } + } + } + + for ( index = timers.length; index--; ) { + if ( timers[ index ].elem === this && + ( type == null || timers[ index ].queue === type ) ) { + + timers[ index ].anim.stop( gotoEnd ); + dequeue = false; + timers.splice( index, 1 ); + } + } + + // Start the next in the queue if the last step wasn't forced. + // Timers currently will call their complete callbacks, which + // will dequeue but only if they were gotoEnd. + if ( dequeue || !gotoEnd ) { + jQuery.dequeue( this, type ); + } + } ); + }, + finish: function( type ) { + if ( type !== false ) { + type = type || "fx"; + } + return this.each( function() { + var index, + data = dataPriv.get( this ), + queue = data[ type + "queue" ], + hooks = data[ type + "queueHooks" ], + timers = jQuery.timers, + length = queue ? queue.length : 0; + + // Enable finishing flag on private data + data.finish = true; + + // Empty the queue first + jQuery.queue( this, type, [] ); + + if ( hooks && hooks.stop ) { + hooks.stop.call( this, true ); + } + + // Look for any active animations, and finish them + for ( index = timers.length; index--; ) { + if ( timers[ index ].elem === this && timers[ index ].queue === type ) { + timers[ index ].anim.stop( true ); + timers.splice( index, 1 ); + } + } + + // Look for any animations in the old queue and finish them + for ( index = 0; index < length; index++ ) { + if ( queue[ index ] && queue[ index ].finish ) { + queue[ index ].finish.call( this ); + } + } + + // Turn off finishing flag + delete data.finish; + } ); + } +} ); + +jQuery.each( [ "toggle", "show", "hide" ], function( _i, name ) { + var cssFn = jQuery.fn[ name ]; + jQuery.fn[ name ] = function( speed, easing, callback ) { + return speed == null || typeof speed === "boolean" ? + cssFn.apply( this, arguments ) : + this.animate( genFx( name, true ), speed, easing, callback ); + }; +} ); + +// Generate shortcuts for custom animations +jQuery.each( { + slideDown: genFx( "show" ), + slideUp: genFx( "hide" ), + slideToggle: genFx( "toggle" ), + fadeIn: { opacity: "show" }, + fadeOut: { opacity: "hide" }, + fadeToggle: { opacity: "toggle" } +}, function( name, props ) { + jQuery.fn[ name ] = function( speed, easing, callback ) { + return this.animate( props, speed, easing, callback ); + }; +} ); + +jQuery.timers = []; +jQuery.fx.tick = function() { + var timer, + i = 0, + timers = jQuery.timers; + + fxNow = Date.now(); + + for ( ; i < timers.length; i++ ) { + timer = timers[ i ]; + + // Run the timer and safely remove it when done (allowing for external removal) + if ( !timer() && timers[ i ] === timer ) { + timers.splice( i--, 1 ); + } + } + + if ( !timers.length ) { + jQuery.fx.stop(); + } + fxNow = undefined; +}; + +jQuery.fx.timer = function( timer ) { + jQuery.timers.push( timer ); + jQuery.fx.start(); +}; + +jQuery.fx.interval = 13; +jQuery.fx.start = function() { + if ( inProgress ) { + return; + } + + inProgress = true; + schedule(); +}; + +jQuery.fx.stop = function() { + inProgress = null; +}; + +jQuery.fx.speeds = { + slow: 600, + fast: 200, + + // Default speed + _default: 400 +}; + + +// Based off of the plugin by Clint Helfers, with permission. +// https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/ +jQuery.fn.delay = function( time, type ) { + time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time; + type = type || "fx"; + + return this.queue( type, function( next, hooks ) { + var timeout = window.setTimeout( next, time ); + hooks.stop = function() { + window.clearTimeout( timeout ); + }; + } ); +}; + + +( function() { + var input = document.createElement( "input" ), + select = document.createElement( "select" ), + opt = select.appendChild( document.createElement( "option" ) ); + + input.type = "checkbox"; + + // Support: Android <=4.3 only + // Default value for a checkbox should be "on" + support.checkOn = input.value !== ""; + + // Support: IE <=11 only + // Must access selectedIndex to make default options select + support.optSelected = opt.selected; + + // Support: IE <=11 only + // An input loses its value after becoming a radio + input = document.createElement( "input" ); + input.value = "t"; + input.type = "radio"; + support.radioValue = input.value === "t"; +} )(); + + +var boolHook, + attrHandle = jQuery.expr.attrHandle; + +jQuery.fn.extend( { + attr: function( name, value ) { + return access( this, jQuery.attr, name, value, arguments.length > 1 ); + }, + + removeAttr: function( name ) { + return this.each( function() { + jQuery.removeAttr( this, name ); + } ); + } +} ); + +jQuery.extend( { + attr: function( elem, name, value ) { + var ret, hooks, + nType = elem.nodeType; + + // Don't get/set attributes on text, comment and attribute nodes + if ( nType === 3 || nType === 8 || nType === 2 ) { + return; + } + + // Fallback to prop when attributes are not supported + if ( typeof elem.getAttribute === "undefined" ) { + return jQuery.prop( elem, name, value ); + } + + // Attribute hooks are determined by the lowercase version + // Grab necessary hook if one is defined + if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { + hooks = jQuery.attrHooks[ name.toLowerCase() ] || + ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined ); + } + + if ( value !== undefined ) { + if ( value === null ) { + jQuery.removeAttr( elem, name ); + return; + } + + if ( hooks && "set" in hooks && + ( ret = hooks.set( elem, value, name ) ) !== undefined ) { + return ret; + } + + elem.setAttribute( name, value + "" ); + return value; + } + + if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) { + return ret; + } + + ret = jQuery.find.attr( elem, name ); + + // Non-existent attributes return null, we normalize to undefined + return ret == null ? undefined : ret; + }, + + attrHooks: { + type: { + set: function( elem, value ) { + if ( !support.radioValue && value === "radio" && + nodeName( elem, "input" ) ) { + var val = elem.value; + elem.setAttribute( "type", value ); + if ( val ) { + elem.value = val; + } + return value; + } + } + } + }, + + removeAttr: function( elem, value ) { + var name, + i = 0, + + // Attribute names can contain non-HTML whitespace characters + // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2 + attrNames = value && value.match( rnothtmlwhite ); + + if ( attrNames && elem.nodeType === 1 ) { + while ( ( name = attrNames[ i++ ] ) ) { + elem.removeAttribute( name ); + } + } + } +} ); + +// Hooks for boolean attributes +boolHook = { + set: function( elem, value, name ) { + if ( value === false ) { + + // Remove boolean attributes when set to false + jQuery.removeAttr( elem, name ); + } else { + elem.setAttribute( name, name ); + } + return name; + } +}; + +jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( _i, name ) { + var getter = attrHandle[ name ] || jQuery.find.attr; + + attrHandle[ name ] = function( elem, name, isXML ) { + var ret, handle, + lowercaseName = name.toLowerCase(); + + if ( !isXML ) { + + // Avoid an infinite loop by temporarily removing this function from the getter + handle = attrHandle[ lowercaseName ]; + attrHandle[ lowercaseName ] = ret; + ret = getter( elem, name, isXML ) != null ? + lowercaseName : + null; + attrHandle[ lowercaseName ] = handle; + } + return ret; + }; +} ); + + + + +var rfocusable = /^(?:input|select|textarea|button)$/i, + rclickable = /^(?:a|area)$/i; + +jQuery.fn.extend( { + prop: function( name, value ) { + return access( this, jQuery.prop, name, value, arguments.length > 1 ); + }, + + removeProp: function( name ) { + return this.each( function() { + delete this[ jQuery.propFix[ name ] || name ]; + } ); + } +} ); + +jQuery.extend( { + prop: function( elem, name, value ) { + var ret, hooks, + nType = elem.nodeType; + + // Don't get/set properties on text, comment and attribute nodes + if ( nType === 3 || nType === 8 || nType === 2 ) { + return; + } + + if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) { + + // Fix name and attach hooks + name = jQuery.propFix[ name ] || name; + hooks = jQuery.propHooks[ name ]; + } + + if ( value !== undefined ) { + if ( hooks && "set" in hooks && + ( ret = hooks.set( elem, value, name ) ) !== undefined ) { + return ret; + } + + return ( elem[ name ] = value ); + } + + if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) { + return ret; + } + + return elem[ name ]; + }, + + propHooks: { + tabIndex: { + get: function( elem ) { + + // Support: IE <=9 - 11 only + // elem.tabIndex doesn't always return the + // correct value when it hasn't been explicitly set + // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ + // Use proper attribute retrieval(#12072) + var tabindex = jQuery.find.attr( elem, "tabindex" ); + + if ( tabindex ) { + return parseInt( tabindex, 10 ); + } + + if ( + rfocusable.test( elem.nodeName ) || + rclickable.test( elem.nodeName ) && + elem.href + ) { + return 0; + } + + return -1; + } + } + }, + + propFix: { + "for": "htmlFor", + "class": "className" + } +} ); + +// Support: IE <=11 only +// Accessing the selectedIndex property +// forces the browser to respect setting selected +// on the option +// The getter ensures a default option is selected +// when in an optgroup +// eslint rule "no-unused-expressions" is disabled for this code +// since it considers such accessions noop +if ( !support.optSelected ) { + jQuery.propHooks.selected = { + get: function( elem ) { + + /* eslint no-unused-expressions: "off" */ + + var parent = elem.parentNode; + if ( parent && parent.parentNode ) { + parent.parentNode.selectedIndex; + } + return null; + }, + set: function( elem ) { + + /* eslint no-unused-expressions: "off" */ + + var parent = elem.parentNode; + if ( parent ) { + parent.selectedIndex; + + if ( parent.parentNode ) { + parent.parentNode.selectedIndex; + } + } + } + }; +} + +jQuery.each( [ + "tabIndex", + "readOnly", + "maxLength", + "cellSpacing", + "cellPadding", + "rowSpan", + "colSpan", + "useMap", + "frameBorder", + "contentEditable" +], function() { + jQuery.propFix[ this.toLowerCase() ] = this; +} ); + + + + + // Strip and collapse whitespace according to HTML spec + // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace + function stripAndCollapse( value ) { + var tokens = value.match( rnothtmlwhite ) || []; + return tokens.join( " " ); + } + + +function getClass( elem ) { + return elem.getAttribute && elem.getAttribute( "class" ) || ""; +} + +function classesToArray( value ) { + if ( Array.isArray( value ) ) { + return value; + } + if ( typeof value === "string" ) { + return value.match( rnothtmlwhite ) || []; + } + return []; +} + +jQuery.fn.extend( { + addClass: function( value ) { + var classes, elem, cur, curValue, clazz, j, finalValue, + i = 0; + + if ( isFunction( value ) ) { + return this.each( function( j ) { + jQuery( this ).addClass( value.call( this, j, getClass( this ) ) ); + } ); + } + + classes = classesToArray( value ); + + if ( classes.length ) { + while ( ( elem = this[ i++ ] ) ) { + curValue = getClass( elem ); + cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " ); + + if ( cur ) { + j = 0; + while ( ( clazz = classes[ j++ ] ) ) { + if ( cur.indexOf( " " + clazz + " " ) < 0 ) { + cur += clazz + " "; + } + } + + // Only assign if different to avoid unneeded rendering. + finalValue = stripAndCollapse( cur ); + if ( curValue !== finalValue ) { + elem.setAttribute( "class", finalValue ); + } + } + } + } + + return this; + }, + + removeClass: function( value ) { + var classes, elem, cur, curValue, clazz, j, finalValue, + i = 0; + + if ( isFunction( value ) ) { + return this.each( function( j ) { + jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) ); + } ); + } + + if ( !arguments.length ) { + return this.attr( "class", "" ); + } + + classes = classesToArray( value ); + + if ( classes.length ) { + while ( ( elem = this[ i++ ] ) ) { + curValue = getClass( elem ); + + // This expression is here for better compressibility (see addClass) + cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " ); + + if ( cur ) { + j = 0; + while ( ( clazz = classes[ j++ ] ) ) { + + // Remove *all* instances + while ( cur.indexOf( " " + clazz + " " ) > -1 ) { + cur = cur.replace( " " + clazz + " ", " " ); + } + } + + // Only assign if different to avoid unneeded rendering. + finalValue = stripAndCollapse( cur ); + if ( curValue !== finalValue ) { + elem.setAttribute( "class", finalValue ); + } + } + } + } + + return this; + }, + + toggleClass: function( value, stateVal ) { + var type = typeof value, + isValidValue = type === "string" || Array.isArray( value ); + + if ( typeof stateVal === "boolean" && isValidValue ) { + return stateVal ? this.addClass( value ) : this.removeClass( value ); + } + + if ( isFunction( value ) ) { + return this.each( function( i ) { + jQuery( this ).toggleClass( + value.call( this, i, getClass( this ), stateVal ), + stateVal + ); + } ); + } + + return this.each( function() { + var className, i, self, classNames; + + if ( isValidValue ) { + + // Toggle individual class names + i = 0; + self = jQuery( this ); + classNames = classesToArray( value ); + + while ( ( className = classNames[ i++ ] ) ) { + + // Check each className given, space separated list + if ( self.hasClass( className ) ) { + self.removeClass( className ); + } else { + self.addClass( className ); + } + } + + // Toggle whole class name + } else if ( value === undefined || type === "boolean" ) { + className = getClass( this ); + if ( className ) { + + // Store className if set + dataPriv.set( this, "__className__", className ); + } + + // If the element has a class name or if we're passed `false`, + // then remove the whole classname (if there was one, the above saved it). + // Otherwise bring back whatever was previously saved (if anything), + // falling back to the empty string if nothing was stored. + if ( this.setAttribute ) { + this.setAttribute( "class", + className || value === false ? + "" : + dataPriv.get( this, "__className__" ) || "" + ); + } + } + } ); + }, + + hasClass: function( selector ) { + var className, elem, + i = 0; + + className = " " + selector + " "; + while ( ( elem = this[ i++ ] ) ) { + if ( elem.nodeType === 1 && + ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) { + return true; + } + } + + return false; + } +} ); + + + + +var rreturn = /\r/g; + +jQuery.fn.extend( { + val: function( value ) { + var hooks, ret, valueIsFunction, + elem = this[ 0 ]; + + if ( !arguments.length ) { + if ( elem ) { + hooks = jQuery.valHooks[ elem.type ] || + jQuery.valHooks[ elem.nodeName.toLowerCase() ]; + + if ( hooks && + "get" in hooks && + ( ret = hooks.get( elem, "value" ) ) !== undefined + ) { + return ret; + } + + ret = elem.value; + + // Handle most common string cases + if ( typeof ret === "string" ) { + return ret.replace( rreturn, "" ); + } + + // Handle cases where value is null/undef or number + return ret == null ? "" : ret; + } + + return; + } + + valueIsFunction = isFunction( value ); + + return this.each( function( i ) { + var val; + + if ( this.nodeType !== 1 ) { + return; + } + + if ( valueIsFunction ) { + val = value.call( this, i, jQuery( this ).val() ); + } else { + val = value; + } + + // Treat null/undefined as ""; convert numbers to string + if ( val == null ) { + val = ""; + + } else if ( typeof val === "number" ) { + val += ""; + + } else if ( Array.isArray( val ) ) { + val = jQuery.map( val, function( value ) { + return value == null ? "" : value + ""; + } ); + } + + hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ]; + + // If set returns undefined, fall back to normal setting + if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) { + this.value = val; + } + } ); + } +} ); + +jQuery.extend( { + valHooks: { + option: { + get: function( elem ) { + + var val = jQuery.find.attr( elem, "value" ); + return val != null ? + val : + + // Support: IE <=10 - 11 only + // option.text throws exceptions (#14686, #14858) + // Strip and collapse whitespace + // https://html.spec.whatwg.org/#strip-and-collapse-whitespace + stripAndCollapse( jQuery.text( elem ) ); + } + }, + select: { + get: function( elem ) { + var value, option, i, + options = elem.options, + index = elem.selectedIndex, + one = elem.type === "select-one", + values = one ? null : [], + max = one ? index + 1 : options.length; + + if ( index < 0 ) { + i = max; + + } else { + i = one ? index : 0; + } + + // Loop through all the selected options + for ( ; i < max; i++ ) { + option = options[ i ]; + + // Support: IE <=9 only + // IE8-9 doesn't update selected after form reset (#2551) + if ( ( option.selected || i === index ) && + + // Don't return options that are disabled or in a disabled optgroup + !option.disabled && + ( !option.parentNode.disabled || + !nodeName( option.parentNode, "optgroup" ) ) ) { + + // Get the specific value for the option + value = jQuery( option ).val(); + + // We don't need an array for one selects + if ( one ) { + return value; + } + + // Multi-Selects return an array + values.push( value ); + } + } + + return values; + }, + + set: function( elem, value ) { + var optionSet, option, + options = elem.options, + values = jQuery.makeArray( value ), + i = options.length; + + while ( i-- ) { + option = options[ i ]; + + /* eslint-disable no-cond-assign */ + + if ( option.selected = + jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1 + ) { + optionSet = true; + } + + /* eslint-enable no-cond-assign */ + } + + // Force browsers to behave consistently when non-matching value is set + if ( !optionSet ) { + elem.selectedIndex = -1; + } + return values; + } + } + } +} ); + +// Radios and checkboxes getter/setter +jQuery.each( [ "radio", "checkbox" ], function() { + jQuery.valHooks[ this ] = { + set: function( elem, value ) { + if ( Array.isArray( value ) ) { + return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 ); + } + } + }; + if ( !support.checkOn ) { + jQuery.valHooks[ this ].get = function( elem ) { + return elem.getAttribute( "value" ) === null ? "on" : elem.value; + }; + } +} ); + + + + +// Return jQuery for attributes-only inclusion + + +support.focusin = "onfocusin" in window; + + +var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, + stopPropagationCallback = function( e ) { + e.stopPropagation(); + }; + +jQuery.extend( jQuery.event, { + + trigger: function( event, data, elem, onlyHandlers ) { + + var i, cur, tmp, bubbleType, ontype, handle, special, lastElement, + eventPath = [ elem || document ], + type = hasOwn.call( event, "type" ) ? event.type : event, + namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : []; + + cur = lastElement = tmp = elem = elem || document; + + // Don't do events on text and comment nodes + if ( elem.nodeType === 3 || elem.nodeType === 8 ) { + return; + } + + // focus/blur morphs to focusin/out; ensure we're not firing them right now + if ( rfocusMorph.test( type + jQuery.event.triggered ) ) { + return; + } + + if ( type.indexOf( "." ) > -1 ) { + + // Namespaced trigger; create a regexp to match event type in handle() + namespaces = type.split( "." ); + type = namespaces.shift(); + namespaces.sort(); + } + ontype = type.indexOf( ":" ) < 0 && "on" + type; + + // Caller can pass in a jQuery.Event object, Object, or just an event type string + event = event[ jQuery.expando ] ? + event : + new jQuery.Event( type, typeof event === "object" && event ); + + // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true) + event.isTrigger = onlyHandlers ? 2 : 3; + event.namespace = namespaces.join( "." ); + event.rnamespace = event.namespace ? + new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) : + null; + + // Clean up the event in case it is being reused + event.result = undefined; + if ( !event.target ) { + event.target = elem; + } + + // Clone any incoming data and prepend the event, creating the handler arg list + data = data == null ? + [ event ] : + jQuery.makeArray( data, [ event ] ); + + // Allow special events to draw outside the lines + special = jQuery.event.special[ type ] || {}; + if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) { + return; + } + + // Determine event propagation path in advance, per W3C events spec (#9951) + // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) + if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) { + + bubbleType = special.delegateType || type; + if ( !rfocusMorph.test( bubbleType + type ) ) { + cur = cur.parentNode; + } + for ( ; cur; cur = cur.parentNode ) { + eventPath.push( cur ); + tmp = cur; + } + + // Only add window if we got to document (e.g., not plain obj or detached DOM) + if ( tmp === ( elem.ownerDocument || document ) ) { + eventPath.push( tmp.defaultView || tmp.parentWindow || window ); + } + } + + // Fire handlers on the event path + i = 0; + while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) { + lastElement = cur; + event.type = i > 1 ? + bubbleType : + special.bindType || type; + + // jQuery handler + handle = ( dataPriv.get( cur, "events" ) || Object.create( null ) )[ event.type ] && + dataPriv.get( cur, "handle" ); + if ( handle ) { + handle.apply( cur, data ); + } + + // Native handler + handle = ontype && cur[ ontype ]; + if ( handle && handle.apply && acceptData( cur ) ) { + event.result = handle.apply( cur, data ); + if ( event.result === false ) { + event.preventDefault(); + } + } + } + event.type = type; + + // If nobody prevented the default action, do it now + if ( !onlyHandlers && !event.isDefaultPrevented() ) { + + if ( ( !special._default || + special._default.apply( eventPath.pop(), data ) === false ) && + acceptData( elem ) ) { + + // Call a native DOM method on the target with the same name as the event. + // Don't do default actions on window, that's where global variables be (#6170) + if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) { + + // Don't re-trigger an onFOO event when we call its FOO() method + tmp = elem[ ontype ]; + + if ( tmp ) { + elem[ ontype ] = null; + } + + // Prevent re-triggering of the same event, since we already bubbled it above + jQuery.event.triggered = type; + + if ( event.isPropagationStopped() ) { + lastElement.addEventListener( type, stopPropagationCallback ); + } + + elem[ type ](); + + if ( event.isPropagationStopped() ) { + lastElement.removeEventListener( type, stopPropagationCallback ); + } + + jQuery.event.triggered = undefined; + + if ( tmp ) { + elem[ ontype ] = tmp; + } + } + } + } + + return event.result; + }, + + // Piggyback on a donor event to simulate a different one + // Used only for `focus(in | out)` events + simulate: function( type, elem, event ) { + var e = jQuery.extend( + new jQuery.Event(), + event, + { + type: type, + isSimulated: true + } + ); + + jQuery.event.trigger( e, null, elem ); + } + +} ); + +jQuery.fn.extend( { + + trigger: function( type, data ) { + return this.each( function() { + jQuery.event.trigger( type, data, this ); + } ); + }, + triggerHandler: function( type, data ) { + var elem = this[ 0 ]; + if ( elem ) { + return jQuery.event.trigger( type, data, elem, true ); + } + } +} ); + + +// Support: Firefox <=44 +// Firefox doesn't have focus(in | out) events +// Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787 +// +// Support: Chrome <=48 - 49, Safari <=9.0 - 9.1 +// focus(in | out) events fire after focus & blur events, +// which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order +// Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857 +if ( !support.focusin ) { + jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) { + + // Attach a single capturing handler on the document while someone wants focusin/focusout + var handler = function( event ) { + jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) ); + }; + + jQuery.event.special[ fix ] = { + setup: function() { + + // Handle: regular nodes (via `this.ownerDocument`), window + // (via `this.document`) & document (via `this`). + var doc = this.ownerDocument || this.document || this, + attaches = dataPriv.access( doc, fix ); + + if ( !attaches ) { + doc.addEventListener( orig, handler, true ); + } + dataPriv.access( doc, fix, ( attaches || 0 ) + 1 ); + }, + teardown: function() { + var doc = this.ownerDocument || this.document || this, + attaches = dataPriv.access( doc, fix ) - 1; + + if ( !attaches ) { + doc.removeEventListener( orig, handler, true ); + dataPriv.remove( doc, fix ); + + } else { + dataPriv.access( doc, fix, attaches ); + } + } + }; + } ); +} +var location = window.location; + +var nonce = { guid: Date.now() }; + +var rquery = ( /\?/ ); + + + +// Cross-browser xml parsing +jQuery.parseXML = function( data ) { + var xml, parserErrorElem; + if ( !data || typeof data !== "string" ) { + return null; + } + + // Support: IE 9 - 11 only + // IE throws on parseFromString with invalid input. + try { + xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" ); + } catch ( e ) {} + + parserErrorElem = xml && xml.getElementsByTagName( "parsererror" )[ 0 ]; + if ( !xml || parserErrorElem ) { + jQuery.error( "Invalid XML: " + ( + parserErrorElem ? + jQuery.map( parserErrorElem.childNodes, function( el ) { + return el.textContent; + } ).join( "\n" ) : + data + ) ); + } + return xml; +}; + + +var + rbracket = /\[\]$/, + rCRLF = /\r?\n/g, + rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i, + rsubmittable = /^(?:input|select|textarea|keygen)/i; + +function buildParams( prefix, obj, traditional, add ) { + var name; + + if ( Array.isArray( obj ) ) { + + // Serialize array item. + jQuery.each( obj, function( i, v ) { + if ( traditional || rbracket.test( prefix ) ) { + + // Treat each array item as a scalar. + add( prefix, v ); + + } else { + + // Item is non-scalar (array or object), encode its numeric index. + buildParams( + prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]", + v, + traditional, + add + ); + } + } ); + + } else if ( !traditional && toType( obj ) === "object" ) { + + // Serialize object item. + for ( name in obj ) { + buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add ); + } + + } else { + + // Serialize scalar item. + add( prefix, obj ); + } +} + +// Serialize an array of form elements or a set of +// key/values into a query string +jQuery.param = function( a, traditional ) { + var prefix, + s = [], + add = function( key, valueOrFunction ) { + + // If value is a function, invoke it and use its return value + var value = isFunction( valueOrFunction ) ? + valueOrFunction() : + valueOrFunction; + + s[ s.length ] = encodeURIComponent( key ) + "=" + + encodeURIComponent( value == null ? "" : value ); + }; + + if ( a == null ) { + return ""; + } + + // If an array was passed in, assume that it is an array of form elements. + if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) { + + // Serialize the form elements + jQuery.each( a, function() { + add( this.name, this.value ); + } ); + + } else { + + // If traditional, encode the "old" way (the way 1.3.2 or older + // did it), otherwise encode params recursively. + for ( prefix in a ) { + buildParams( prefix, a[ prefix ], traditional, add ); + } + } + + // Return the resulting serialization + return s.join( "&" ); +}; + +jQuery.fn.extend( { + serialize: function() { + return jQuery.param( this.serializeArray() ); + }, + serializeArray: function() { + return this.map( function() { + + // Can add propHook for "elements" to filter or add form elements + var elements = jQuery.prop( this, "elements" ); + return elements ? jQuery.makeArray( elements ) : this; + } ).filter( function() { + var type = this.type; + + // Use .is( ":disabled" ) so that fieldset[disabled] works + return this.name && !jQuery( this ).is( ":disabled" ) && + rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) && + ( this.checked || !rcheckableType.test( type ) ); + } ).map( function( _i, elem ) { + var val = jQuery( this ).val(); + + if ( val == null ) { + return null; + } + + if ( Array.isArray( val ) ) { + return jQuery.map( val, function( val ) { + return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; + } ); + } + + return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; + } ).get(); + } +} ); + + +var + r20 = /%20/g, + rhash = /#.*$/, + rantiCache = /([?&])_=[^&]*/, + rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg, + + // #7653, #8125, #8152: local protocol detection + rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/, + rnoContent = /^(?:GET|HEAD)$/, + rprotocol = /^\/\//, + + /* Prefilters + * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example) + * 2) These are called: + * - BEFORE asking for a transport + * - AFTER param serialization (s.data is a string if s.processData is true) + * 3) key is the dataType + * 4) the catchall symbol "*" can be used + * 5) execution will start with transport dataType and THEN continue down to "*" if needed + */ + prefilters = {}, + + /* Transports bindings + * 1) key is the dataType + * 2) the catchall symbol "*" can be used + * 3) selection will start with transport dataType and THEN go to "*" if needed + */ + transports = {}, + + // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression + allTypes = "*/".concat( "*" ), + + // Anchor tag for parsing the document origin + originAnchor = document.createElement( "a" ); + +originAnchor.href = location.href; + +// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport +function addToPrefiltersOrTransports( structure ) { + + // dataTypeExpression is optional and defaults to "*" + return function( dataTypeExpression, func ) { + + if ( typeof dataTypeExpression !== "string" ) { + func = dataTypeExpression; + dataTypeExpression = "*"; + } + + var dataType, + i = 0, + dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || []; + + if ( isFunction( func ) ) { + + // For each dataType in the dataTypeExpression + while ( ( dataType = dataTypes[ i++ ] ) ) { + + // Prepend if requested + if ( dataType[ 0 ] === "+" ) { + dataType = dataType.slice( 1 ) || "*"; + ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func ); + + // Otherwise append + } else { + ( structure[ dataType ] = structure[ dataType ] || [] ).push( func ); + } + } + } + }; +} + +// Base inspection function for prefilters and transports +function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) { + + var inspected = {}, + seekingTransport = ( structure === transports ); + + function inspect( dataType ) { + var selected; + inspected[ dataType ] = true; + jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) { + var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR ); + if ( typeof dataTypeOrTransport === "string" && + !seekingTransport && !inspected[ dataTypeOrTransport ] ) { + + options.dataTypes.unshift( dataTypeOrTransport ); + inspect( dataTypeOrTransport ); + return false; + } else if ( seekingTransport ) { + return !( selected = dataTypeOrTransport ); + } + } ); + return selected; + } + + return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" ); +} + +// A special extend for ajax options +// that takes "flat" options (not to be deep extended) +// Fixes #9887 +function ajaxExtend( target, src ) { + var key, deep, + flatOptions = jQuery.ajaxSettings.flatOptions || {}; + + for ( key in src ) { + if ( src[ key ] !== undefined ) { + ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ]; + } + } + if ( deep ) { + jQuery.extend( true, target, deep ); + } + + return target; +} + +/* Handles responses to an ajax request: + * - finds the right dataType (mediates between content-type and expected dataType) + * - returns the corresponding response + */ +function ajaxHandleResponses( s, jqXHR, responses ) { + + var ct, type, finalDataType, firstDataType, + contents = s.contents, + dataTypes = s.dataTypes; + + // Remove auto dataType and get content-type in the process + while ( dataTypes[ 0 ] === "*" ) { + dataTypes.shift(); + if ( ct === undefined ) { + ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" ); + } + } + + // Check if we're dealing with a known content-type + if ( ct ) { + for ( type in contents ) { + if ( contents[ type ] && contents[ type ].test( ct ) ) { + dataTypes.unshift( type ); + break; + } + } + } + + // Check to see if we have a response for the expected dataType + if ( dataTypes[ 0 ] in responses ) { + finalDataType = dataTypes[ 0 ]; + } else { + + // Try convertible dataTypes + for ( type in responses ) { + if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) { + finalDataType = type; + break; + } + if ( !firstDataType ) { + firstDataType = type; + } + } + + // Or just use first one + finalDataType = finalDataType || firstDataType; + } + + // If we found a dataType + // We add the dataType to the list if needed + // and return the corresponding response + if ( finalDataType ) { + if ( finalDataType !== dataTypes[ 0 ] ) { + dataTypes.unshift( finalDataType ); + } + return responses[ finalDataType ]; + } +} + +/* Chain conversions given the request and the original response + * Also sets the responseXXX fields on the jqXHR instance + */ +function ajaxConvert( s, response, jqXHR, isSuccess ) { + var conv2, current, conv, tmp, prev, + converters = {}, + + // Work with a copy of dataTypes in case we need to modify it for conversion + dataTypes = s.dataTypes.slice(); + + // Create converters map with lowercased keys + if ( dataTypes[ 1 ] ) { + for ( conv in s.converters ) { + converters[ conv.toLowerCase() ] = s.converters[ conv ]; + } + } + + current = dataTypes.shift(); + + // Convert to each sequential dataType + while ( current ) { + + if ( s.responseFields[ current ] ) { + jqXHR[ s.responseFields[ current ] ] = response; + } + + // Apply the dataFilter if provided + if ( !prev && isSuccess && s.dataFilter ) { + response = s.dataFilter( response, s.dataType ); + } + + prev = current; + current = dataTypes.shift(); + + if ( current ) { + + // There's only work to do if current dataType is non-auto + if ( current === "*" ) { + + current = prev; + + // Convert response if prev dataType is non-auto and differs from current + } else if ( prev !== "*" && prev !== current ) { + + // Seek a direct converter + conv = converters[ prev + " " + current ] || converters[ "* " + current ]; + + // If none found, seek a pair + if ( !conv ) { + for ( conv2 in converters ) { + + // If conv2 outputs current + tmp = conv2.split( " " ); + if ( tmp[ 1 ] === current ) { + + // If prev can be converted to accepted input + conv = converters[ prev + " " + tmp[ 0 ] ] || + converters[ "* " + tmp[ 0 ] ]; + if ( conv ) { + + // Condense equivalence converters + if ( conv === true ) { + conv = converters[ conv2 ]; + + // Otherwise, insert the intermediate dataType + } else if ( converters[ conv2 ] !== true ) { + current = tmp[ 0 ]; + dataTypes.unshift( tmp[ 1 ] ); + } + break; + } + } + } + } + + // Apply converter (if not an equivalence) + if ( conv !== true ) { + + // Unless errors are allowed to bubble, catch and return them + if ( conv && s.throws ) { + response = conv( response ); + } else { + try { + response = conv( response ); + } catch ( e ) { + return { + state: "parsererror", + error: conv ? e : "No conversion from " + prev + " to " + current + }; + } + } + } + } + } + } + + return { state: "success", data: response }; +} + +jQuery.extend( { + + // Counter for holding the number of active queries + active: 0, + + // Last-Modified header cache for next request + lastModified: {}, + etag: {}, + + ajaxSettings: { + url: location.href, + type: "GET", + isLocal: rlocalProtocol.test( location.protocol ), + global: true, + processData: true, + async: true, + contentType: "application/x-www-form-urlencoded; charset=UTF-8", + + /* + timeout: 0, + data: null, + dataType: null, + username: null, + password: null, + cache: null, + throws: false, + traditional: false, + headers: {}, + */ + + accepts: { + "*": allTypes, + text: "text/plain", + html: "text/html", + xml: "application/xml, text/xml", + json: "application/json, text/javascript" + }, + + contents: { + xml: /\bxml\b/, + html: /\bhtml/, + json: /\bjson\b/ + }, + + responseFields: { + xml: "responseXML", + text: "responseText", + json: "responseJSON" + }, + + // Data converters + // Keys separate source (or catchall "*") and destination types with a single space + converters: { + + // Convert anything to text + "* text": String, + + // Text to html (true = no transformation) + "text html": true, + + // Evaluate text as a json expression + "text json": JSON.parse, + + // Parse text as xml + "text xml": jQuery.parseXML + }, + + // For options that shouldn't be deep extended: + // you can add your own custom options here if + // and when you create one that shouldn't be + // deep extended (see ajaxExtend) + flatOptions: { + url: true, + context: true + } + }, + + // Creates a full fledged settings object into target + // with both ajaxSettings and settings fields. + // If target is omitted, writes into ajaxSettings. + ajaxSetup: function( target, settings ) { + return settings ? + + // Building a settings object + ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) : + + // Extending ajaxSettings + ajaxExtend( jQuery.ajaxSettings, target ); + }, + + ajaxPrefilter: addToPrefiltersOrTransports( prefilters ), + ajaxTransport: addToPrefiltersOrTransports( transports ), + + // Main method + ajax: function( url, options ) { + + // If url is an object, simulate pre-1.5 signature + if ( typeof url === "object" ) { + options = url; + url = undefined; + } + + // Force options to be an object + options = options || {}; + + var transport, + + // URL without anti-cache param + cacheURL, + + // Response headers + responseHeadersString, + responseHeaders, + + // timeout handle + timeoutTimer, + + // Url cleanup var + urlAnchor, + + // Request state (becomes false upon send and true upon completion) + completed, + + // To know if global events are to be dispatched + fireGlobals, + + // Loop variable + i, + + // uncached part of the url + uncached, + + // Create the final options object + s = jQuery.ajaxSetup( {}, options ), + + // Callbacks context + callbackContext = s.context || s, + + // Context for global events is callbackContext if it is a DOM node or jQuery collection + globalEventContext = s.context && + ( callbackContext.nodeType || callbackContext.jquery ) ? + jQuery( callbackContext ) : + jQuery.event, + + // Deferreds + deferred = jQuery.Deferred(), + completeDeferred = jQuery.Callbacks( "once memory" ), + + // Status-dependent callbacks + statusCode = s.statusCode || {}, + + // Headers (they are sent all at once) + requestHeaders = {}, + requestHeadersNames = {}, + + // Default abort message + strAbort = "canceled", + + // Fake xhr + jqXHR = { + readyState: 0, + + // Builds headers hashtable if needed + getResponseHeader: function( key ) { + var match; + if ( completed ) { + if ( !responseHeaders ) { + responseHeaders = {}; + while ( ( match = rheaders.exec( responseHeadersString ) ) ) { + responseHeaders[ match[ 1 ].toLowerCase() + " " ] = + ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] ) + .concat( match[ 2 ] ); + } + } + match = responseHeaders[ key.toLowerCase() + " " ]; + } + return match == null ? null : match.join( ", " ); + }, + + // Raw string + getAllResponseHeaders: function() { + return completed ? responseHeadersString : null; + }, + + // Caches the header + setRequestHeader: function( name, value ) { + if ( completed == null ) { + name = requestHeadersNames[ name.toLowerCase() ] = + requestHeadersNames[ name.toLowerCase() ] || name; + requestHeaders[ name ] = value; + } + return this; + }, + + // Overrides response content-type header + overrideMimeType: function( type ) { + if ( completed == null ) { + s.mimeType = type; + } + return this; + }, + + // Status-dependent callbacks + statusCode: function( map ) { + var code; + if ( map ) { + if ( completed ) { + + // Execute the appropriate callbacks + jqXHR.always( map[ jqXHR.status ] ); + } else { + + // Lazy-add the new callbacks in a way that preserves old ones + for ( code in map ) { + statusCode[ code ] = [ statusCode[ code ], map[ code ] ]; + } + } + } + return this; + }, + + // Cancel the request + abort: function( statusText ) { + var finalText = statusText || strAbort; + if ( transport ) { + transport.abort( finalText ); + } + done( 0, finalText ); + return this; + } + }; + + // Attach deferreds + deferred.promise( jqXHR ); + + // Add protocol if not provided (prefilters might expect it) + // Handle falsy url in the settings object (#10093: consistency with old signature) + // We also use the url parameter if available + s.url = ( ( url || s.url || location.href ) + "" ) + .replace( rprotocol, location.protocol + "//" ); + + // Alias method option to type as per ticket #12004 + s.type = options.method || options.type || s.method || s.type; + + // Extract dataTypes list + s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ]; + + // A cross-domain request is in order when the origin doesn't match the current origin. + if ( s.crossDomain == null ) { + urlAnchor = document.createElement( "a" ); + + // Support: IE <=8 - 11, Edge 12 - 15 + // IE throws exception on accessing the href property if url is malformed, + // e.g. http://example.com:80x/ + try { + urlAnchor.href = s.url; + + // Support: IE <=8 - 11 only + // Anchor's host property isn't correctly set when s.url is relative + urlAnchor.href = urlAnchor.href; + s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !== + urlAnchor.protocol + "//" + urlAnchor.host; + } catch ( e ) { + + // If there is an error parsing the URL, assume it is crossDomain, + // it can be rejected by the transport if it is invalid + s.crossDomain = true; + } + } + + // Convert data if not already a string + if ( s.data && s.processData && typeof s.data !== "string" ) { + s.data = jQuery.param( s.data, s.traditional ); + } + + // Apply prefilters + inspectPrefiltersOrTransports( prefilters, s, options, jqXHR ); + + // If request was aborted inside a prefilter, stop there + if ( completed ) { + return jqXHR; + } + + // We can fire global events as of now if asked to + // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118) + fireGlobals = jQuery.event && s.global; + + // Watch for a new set of requests + if ( fireGlobals && jQuery.active++ === 0 ) { + jQuery.event.trigger( "ajaxStart" ); + } + + // Uppercase the type + s.type = s.type.toUpperCase(); + + // Determine if request has content + s.hasContent = !rnoContent.test( s.type ); + + // Save the URL in case we're toying with the If-Modified-Since + // and/or If-None-Match header later on + // Remove hash to simplify url manipulation + cacheURL = s.url.replace( rhash, "" ); + + // More options handling for requests with no content + if ( !s.hasContent ) { + + // Remember the hash so we can put it back + uncached = s.url.slice( cacheURL.length ); + + // If data is available and should be processed, append data to url + if ( s.data && ( s.processData || typeof s.data === "string" ) ) { + cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data; + + // #9682: remove data so that it's not used in an eventual retry + delete s.data; + } + + // Add or update anti-cache param if needed + if ( s.cache === false ) { + cacheURL = cacheURL.replace( rantiCache, "$1" ); + uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce.guid++ ) + + uncached; + } + + // Put hash and anti-cache on the URL that will be requested (gh-1732) + s.url = cacheURL + uncached; + + // Change '%20' to '+' if this is encoded form body content (gh-2658) + } else if ( s.data && s.processData && + ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) { + s.data = s.data.replace( r20, "+" ); + } + + // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. + if ( s.ifModified ) { + if ( jQuery.lastModified[ cacheURL ] ) { + jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] ); + } + if ( jQuery.etag[ cacheURL ] ) { + jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] ); + } + } + + // Set the correct header, if data is being sent + if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) { + jqXHR.setRequestHeader( "Content-Type", s.contentType ); + } + + // Set the Accepts header for the server, depending on the dataType + jqXHR.setRequestHeader( + "Accept", + s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ? + s.accepts[ s.dataTypes[ 0 ] ] + + ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) : + s.accepts[ "*" ] + ); + + // Check for headers option + for ( i in s.headers ) { + jqXHR.setRequestHeader( i, s.headers[ i ] ); + } + + // Allow custom headers/mimetypes and early abort + if ( s.beforeSend && + ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) { + + // Abort if not done already and return + return jqXHR.abort(); + } + + // Aborting is no longer a cancellation + strAbort = "abort"; + + // Install callbacks on deferreds + completeDeferred.add( s.complete ); + jqXHR.done( s.success ); + jqXHR.fail( s.error ); + + // Get transport + transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR ); + + // If no transport, we auto-abort + if ( !transport ) { + done( -1, "No Transport" ); + } else { + jqXHR.readyState = 1; + + // Send global event + if ( fireGlobals ) { + globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] ); + } + + // If request was aborted inside ajaxSend, stop there + if ( completed ) { + return jqXHR; + } + + // Timeout + if ( s.async && s.timeout > 0 ) { + timeoutTimer = window.setTimeout( function() { + jqXHR.abort( "timeout" ); + }, s.timeout ); + } + + try { + completed = false; + transport.send( requestHeaders, done ); + } catch ( e ) { + + // Rethrow post-completion exceptions + if ( completed ) { + throw e; + } + + // Propagate others as results + done( -1, e ); + } + } + + // Callback for when everything is done + function done( status, nativeStatusText, responses, headers ) { + var isSuccess, success, error, response, modified, + statusText = nativeStatusText; + + // Ignore repeat invocations + if ( completed ) { + return; + } + + completed = true; + + // Clear timeout if it exists + if ( timeoutTimer ) { + window.clearTimeout( timeoutTimer ); + } + + // Dereference transport for early garbage collection + // (no matter how long the jqXHR object will be used) + transport = undefined; + + // Cache response headers + responseHeadersString = headers || ""; + + // Set readyState + jqXHR.readyState = status > 0 ? 4 : 0; + + // Determine if successful + isSuccess = status >= 200 && status < 300 || status === 304; + + // Get response data + if ( responses ) { + response = ajaxHandleResponses( s, jqXHR, responses ); + } + + // Use a noop converter for missing script but not if jsonp + if ( !isSuccess && + jQuery.inArray( "script", s.dataTypes ) > -1 && + jQuery.inArray( "json", s.dataTypes ) < 0 ) { + s.converters[ "text script" ] = function() {}; + } + + // Convert no matter what (that way responseXXX fields are always set) + response = ajaxConvert( s, response, jqXHR, isSuccess ); + + // If successful, handle type chaining + if ( isSuccess ) { + + // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode. + if ( s.ifModified ) { + modified = jqXHR.getResponseHeader( "Last-Modified" ); + if ( modified ) { + jQuery.lastModified[ cacheURL ] = modified; + } + modified = jqXHR.getResponseHeader( "etag" ); + if ( modified ) { + jQuery.etag[ cacheURL ] = modified; + } + } + + // if no content + if ( status === 204 || s.type === "HEAD" ) { + statusText = "nocontent"; + + // if not modified + } else if ( status === 304 ) { + statusText = "notmodified"; + + // If we have data, let's convert it + } else { + statusText = response.state; + success = response.data; + error = response.error; + isSuccess = !error; + } + } else { + + // Extract error from statusText and normalize for non-aborts + error = statusText; + if ( status || !statusText ) { + statusText = "error"; + if ( status < 0 ) { + status = 0; + } + } + } + + // Set data for the fake xhr object + jqXHR.status = status; + jqXHR.statusText = ( nativeStatusText || statusText ) + ""; + + // Success/Error + if ( isSuccess ) { + deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] ); + } else { + deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] ); + } + + // Status-dependent callbacks + jqXHR.statusCode( statusCode ); + statusCode = undefined; + + if ( fireGlobals ) { + globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError", + [ jqXHR, s, isSuccess ? success : error ] ); + } + + // Complete + completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] ); + + if ( fireGlobals ) { + globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] ); + + // Handle the global AJAX counter + if ( !( --jQuery.active ) ) { + jQuery.event.trigger( "ajaxStop" ); + } + } + } + + return jqXHR; + }, + + getJSON: function( url, data, callback ) { + return jQuery.get( url, data, callback, "json" ); + }, + + getScript: function( url, callback ) { + return jQuery.get( url, undefined, callback, "script" ); + } +} ); + +jQuery.each( [ "get", "post" ], function( _i, method ) { + jQuery[ method ] = function( url, data, callback, type ) { + + // Shift arguments if data argument was omitted + if ( isFunction( data ) ) { + type = type || callback; + callback = data; + data = undefined; + } + + // The url can be an options object (which then must have .url) + return jQuery.ajax( jQuery.extend( { + url: url, + type: method, + dataType: type, + data: data, + success: callback + }, jQuery.isPlainObject( url ) && url ) ); + }; +} ); + +jQuery.ajaxPrefilter( function( s ) { + var i; + for ( i in s.headers ) { + if ( i.toLowerCase() === "content-type" ) { + s.contentType = s.headers[ i ] || ""; + } + } +} ); + + +jQuery._evalUrl = function( url, options, doc ) { + return jQuery.ajax( { + url: url, + + // Make this explicit, since user can override this through ajaxSetup (#11264) + type: "GET", + dataType: "script", + cache: true, + async: false, + global: false, + + // Only evaluate the response if it is successful (gh-4126) + // dataFilter is not invoked for failure responses, so using it instead + // of the default converter is kludgy but it works. + converters: { + "text script": function() {} + }, + dataFilter: function( response ) { + jQuery.globalEval( response, options, doc ); + } + } ); +}; + + +jQuery.fn.extend( { + wrapAll: function( html ) { + var wrap; + + if ( this[ 0 ] ) { + if ( isFunction( html ) ) { + html = html.call( this[ 0 ] ); + } + + // The elements to wrap the target around + wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true ); + + if ( this[ 0 ].parentNode ) { + wrap.insertBefore( this[ 0 ] ); + } + + wrap.map( function() { + var elem = this; + + while ( elem.firstElementChild ) { + elem = elem.firstElementChild; + } + + return elem; + } ).append( this ); + } + + return this; + }, + + wrapInner: function( html ) { + if ( isFunction( html ) ) { + return this.each( function( i ) { + jQuery( this ).wrapInner( html.call( this, i ) ); + } ); + } + + return this.each( function() { + var self = jQuery( this ), + contents = self.contents(); + + if ( contents.length ) { + contents.wrapAll( html ); + + } else { + self.append( html ); + } + } ); + }, + + wrap: function( html ) { + var htmlIsFunction = isFunction( html ); + + return this.each( function( i ) { + jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html ); + } ); + }, + + unwrap: function( selector ) { + this.parent( selector ).not( "body" ).each( function() { + jQuery( this ).replaceWith( this.childNodes ); + } ); + return this; + } +} ); + + +jQuery.expr.pseudos.hidden = function( elem ) { + return !jQuery.expr.pseudos.visible( elem ); +}; +jQuery.expr.pseudos.visible = function( elem ) { + return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length ); +}; + + + + +jQuery.ajaxSettings.xhr = function() { + try { + return new window.XMLHttpRequest(); + } catch ( e ) {} +}; + +var xhrSuccessStatus = { + + // File protocol always yields status code 0, assume 200 + 0: 200, + + // Support: IE <=9 only + // #1450: sometimes IE returns 1223 when it should be 204 + 1223: 204 + }, + xhrSupported = jQuery.ajaxSettings.xhr(); + +support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported ); +support.ajax = xhrSupported = !!xhrSupported; + +jQuery.ajaxTransport( function( options ) { + var callback, errorCallback; + + // Cross domain only allowed if supported through XMLHttpRequest + if ( support.cors || xhrSupported && !options.crossDomain ) { + return { + send: function( headers, complete ) { + var i, + xhr = options.xhr(); + + xhr.open( + options.type, + options.url, + options.async, + options.username, + options.password + ); + + // Apply custom fields if provided + if ( options.xhrFields ) { + for ( i in options.xhrFields ) { + xhr[ i ] = options.xhrFields[ i ]; + } + } + + // Override mime type if needed + if ( options.mimeType && xhr.overrideMimeType ) { + xhr.overrideMimeType( options.mimeType ); + } + + // X-Requested-With header + // For cross-domain requests, seeing as conditions for a preflight are + // akin to a jigsaw puzzle, we simply never set it to be sure. + // (it can always be set on a per-request basis or even using ajaxSetup) + // For same-domain requests, won't change header if already provided. + if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) { + headers[ "X-Requested-With" ] = "XMLHttpRequest"; + } + + // Set headers + for ( i in headers ) { + xhr.setRequestHeader( i, headers[ i ] ); + } + + // Callback + callback = function( type ) { + return function() { + if ( callback ) { + callback = errorCallback = xhr.onload = + xhr.onerror = xhr.onabort = xhr.ontimeout = + xhr.onreadystatechange = null; + + if ( type === "abort" ) { + xhr.abort(); + } else if ( type === "error" ) { + + // Support: IE <=9 only + // On a manual native abort, IE9 throws + // errors on any property access that is not readyState + if ( typeof xhr.status !== "number" ) { + complete( 0, "error" ); + } else { + complete( + + // File: protocol always yields status 0; see #8605, #14207 + xhr.status, + xhr.statusText + ); + } + } else { + complete( + xhrSuccessStatus[ xhr.status ] || xhr.status, + xhr.statusText, + + // Support: IE <=9 only + // IE9 has no XHR2 but throws on binary (trac-11426) + // For XHR2 non-text, let the caller handle it (gh-2498) + ( xhr.responseType || "text" ) !== "text" || + typeof xhr.responseText !== "string" ? + { binary: xhr.response } : + { text: xhr.responseText }, + xhr.getAllResponseHeaders() + ); + } + } + }; + }; + + // Listen to events + xhr.onload = callback(); + errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" ); + + // Support: IE 9 only + // Use onreadystatechange to replace onabort + // to handle uncaught aborts + if ( xhr.onabort !== undefined ) { + xhr.onabort = errorCallback; + } else { + xhr.onreadystatechange = function() { + + // Check readyState before timeout as it changes + if ( xhr.readyState === 4 ) { + + // Allow onerror to be called first, + // but that will not handle a native abort + // Also, save errorCallback to a variable + // as xhr.onerror cannot be accessed + window.setTimeout( function() { + if ( callback ) { + errorCallback(); + } + } ); + } + }; + } + + // Create the abort callback + callback = callback( "abort" ); + + try { + + // Do send the request (this may raise an exception) + xhr.send( options.hasContent && options.data || null ); + } catch ( e ) { + + // #14683: Only rethrow if this hasn't been notified as an error yet + if ( callback ) { + throw e; + } + } + }, + + abort: function() { + if ( callback ) { + callback(); + } + } + }; + } +} ); + + + + +// Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432) +jQuery.ajaxPrefilter( function( s ) { + if ( s.crossDomain ) { + s.contents.script = false; + } +} ); + +// Install script dataType +jQuery.ajaxSetup( { + accepts: { + script: "text/javascript, application/javascript, " + + "application/ecmascript, application/x-ecmascript" + }, + contents: { + script: /\b(?:java|ecma)script\b/ + }, + converters: { + "text script": function( text ) { + jQuery.globalEval( text ); + return text; + } + } +} ); + +// Handle cache's special case and crossDomain +jQuery.ajaxPrefilter( "script", function( s ) { + if ( s.cache === undefined ) { + s.cache = false; + } + if ( s.crossDomain ) { + s.type = "GET"; + } +} ); + +// Bind script tag hack transport +jQuery.ajaxTransport( "script", function( s ) { + + // This transport only deals with cross domain or forced-by-attrs requests + if ( s.crossDomain || s.scriptAttrs ) { + var script, callback; + return { + send: function( _, complete ) { + script = jQuery( " + + + \ No newline at end of file diff --git a/PSC.Blazor.Components.MarkdownEditor/Enums/MarkdownAction.cs b/PSC.Blazor.Components.MarkdownEditor/Enums/MarkdownAction.cs new file mode 100644 index 0000000..8fbb356 --- /dev/null +++ b/PSC.Blazor.Components.MarkdownEditor/Enums/MarkdownAction.cs @@ -0,0 +1,97 @@ +namespace PSC.Blazor.Components.MarkdownEditor.Enums +{ + /// + /// Markdown toolbar actions. + /// + public enum MarkdownAction + { + /// + /// The bold + /// + Bold, + /// + /// The italic + /// + Italic, + /// + /// The strikethrough + /// + Strikethrough, + /// + /// The heading + /// + Heading, + /// + /// The heading smaller + /// + HeadingSmaller, + /// + /// The heading bigger + /// + HeadingBigger, + /// + /// The heading1 + /// + Heading1, + /// + /// The heading2 + /// + Heading2, + /// + /// The heading3 + /// + Heading3, + /// + /// The code + /// + Code, + /// + /// The quote + /// + Quote, + /// + /// The unordered list + /// + UnorderedList, + /// + /// The ordered list + /// + OrderedList, + /// + /// The clean block + /// + CleanBlock, + /// + /// The link + /// + Link, + /// + /// The image + /// + Image, + /// + /// The table + /// + Table, + /// + /// The horizontal rule + /// + HorizontalRule, + /// + /// The preview + /// + Preview, + /// + /// The side by side + /// + SideBySide, + /// + /// The fullscreen + /// + Fullscreen, + /// + /// The guide + /// + Guide + } +} diff --git a/PSC.Blazor.Components.MarkdownEditor/EventsArgs/FileChangedEventArgs.cs b/PSC.Blazor.Components.MarkdownEditor/EventsArgs/FileChangedEventArgs.cs new file mode 100644 index 0000000..9924375 --- /dev/null +++ b/PSC.Blazor.Components.MarkdownEditor/EventsArgs/FileChangedEventArgs.cs @@ -0,0 +1,22 @@ +namespace PSC.Blazor.Components.MarkdownEditor.EventsArgs +{ + /// + /// Supplies the information about the selected files ready to be uploaded. + /// + public class FileChangedEventArgs : EventArgs + { + /// + /// A default constructor. + /// + /// List of files. + public FileChangedEventArgs(params FileEntry[] files) + { + Files = files; + } + + /// + /// Gets the list of selected files. + /// + public FileEntry[] Files { get; } + } +} \ No newline at end of file diff --git a/PSC.Blazor.Components.MarkdownEditor/EventsArgs/FileEndedEventArgs.cs b/PSC.Blazor.Components.MarkdownEditor/EventsArgs/FileEndedEventArgs.cs new file mode 100644 index 0000000..97846ee --- /dev/null +++ b/PSC.Blazor.Components.MarkdownEditor/EventsArgs/FileEndedEventArgs.cs @@ -0,0 +1,36 @@ +namespace PSC.Blazor.Components.MarkdownEditor.EventsArgs +{ + /// + /// Provides the information about the file ended uploading. + /// + public class FileEndedEventArgs : EventArgs + { + /// + /// A default constructor. + /// + /// File that is ended. + /// Result of file end upload. + /// Reason for file failure. + public FileEndedEventArgs(FileEntry file, bool success, string fileInvalidReason) + { + File = file; + Success = success; + FileInvalidReason = fileInvalidReason; + } + + /// + /// Gets the file currently being uploaded. + /// + public FileEntry File { get; } + + /// + /// Gets the value indicating if file has finished successfully. + /// + public bool Success { get; } + + /// + /// Provides information about the invalid file. + /// + public string FileInvalidReason { get; set; } + } +} diff --git a/PSC.Blazor.Components.MarkdownEditor/EventsArgs/FileProgressedEventArgs.cs b/PSC.Blazor.Components.MarkdownEditor/EventsArgs/FileProgressedEventArgs.cs new file mode 100644 index 0000000..cadc270 --- /dev/null +++ b/PSC.Blazor.Components.MarkdownEditor/EventsArgs/FileProgressedEventArgs.cs @@ -0,0 +1,34 @@ +namespace PSC.Blazor.Components.MarkdownEditor.EventsArgs +{ + /// + /// Provides the progress state of uploaded file. + /// + public class FileProgressedEventArgs : EventArgs + { + /// + /// A default constructor. + /// + /// File that is being processed. + /// Percentage of file upload process. + public FileProgressedEventArgs(FileEntry file, double progress) + { + File = file; + Progress = progress; + } + + /// + /// Gets the file currently being uploaded. + /// + public FileEntry File { get; } + + /// + /// Gets the total progress in the range from 0 to 1. + /// + public double Progress { get; } + + /// + /// Gets the total progress in the range from 0 to 100. + /// + public double Percentage => Progress * 100d; + } +} \ No newline at end of file diff --git a/PSC.Blazor.Components.MarkdownEditor/EventsArgs/FileStartedEventArgs.cs b/PSC.Blazor.Components.MarkdownEditor/EventsArgs/FileStartedEventArgs.cs new file mode 100644 index 0000000..6cd813b --- /dev/null +++ b/PSC.Blazor.Components.MarkdownEditor/EventsArgs/FileStartedEventArgs.cs @@ -0,0 +1,22 @@ +namespace PSC.Blazor.Components.MarkdownEditor.EventsArgs +{ + /// + /// Provides the information about the file started to be uploaded. + /// + public class FileStartedEventArgs : EventArgs + { + /// + /// A default constructor. + /// + /// File that is started with upload. + public FileStartedEventArgs(FileEntry file) + { + File = file; + } + + /// + /// Gets the file currently being uploaded. + /// + public FileEntry File { get; } + } +} \ No newline at end of file diff --git a/PSC.Blazor.Components.MarkdownEditor/EventsArgs/FileWrittenEventArgs.cs b/PSC.Blazor.Components.MarkdownEditor/EventsArgs/FileWrittenEventArgs.cs new file mode 100644 index 0000000..a611932 --- /dev/null +++ b/PSC.Blazor.Components.MarkdownEditor/EventsArgs/FileWrittenEventArgs.cs @@ -0,0 +1,36 @@ +namespace PSC.Blazor.Components.MarkdownEditor.EventsArgs +{ + /// + /// Supplies the information about the data being written while uploading. + /// + public class FileWrittenEventArgs : EventArgs + { + /// + /// A default constructor. + /// + /// File that is being read. + /// Read offset in bytes within the file. + /// Bytes that are being read. + public FileWrittenEventArgs(FileEntry file, long position, byte[] data) + { + File = file; + Position = position; + Data = data; + } + + /// + /// Gets the file currently being uploaded. + /// + public FileEntry File { get; } + + /// + /// Gets the current position offset based on the original data source. + /// + public long Position { get; } + + /// + /// Gets the data buffer. + /// + public byte[] Data { get; } + } +} \ No newline at end of file diff --git a/PSC.Blazor.Components.MarkdownEditor/EventsArgs/MarkdownButtonEventArgs.cs b/PSC.Blazor.Components.MarkdownEditor/EventsArgs/MarkdownButtonEventArgs.cs new file mode 100644 index 0000000..2d374c7 --- /dev/null +++ b/PSC.Blazor.Components.MarkdownEditor/EventsArgs/MarkdownButtonEventArgs.cs @@ -0,0 +1,29 @@ +namespace PSC.Blazor.Components.MarkdownEditor.EventsArgs +{ + /// + /// Supplies the information about the markdown button click event. + /// + public class MarkdownButtonEventArgs : EventArgs + { + /// + /// A default constructor. + /// + /// Button action name. + /// Button value. + public MarkdownButtonEventArgs(string name, object value) + { + Name = name; + Value = value; + } + + /// + /// Gets the button action name. + /// + public string Name { get; } + + /// + /// Gets the button action value. + /// + public object Value { get; } + } +} diff --git a/PSC.Blazor.Components.MarkdownEditor/GlobalUsing.cs b/PSC.Blazor.Components.MarkdownEditor/GlobalUsing.cs new file mode 100644 index 0000000..7045509 --- /dev/null +++ b/PSC.Blazor.Components.MarkdownEditor/GlobalUsing.cs @@ -0,0 +1,12 @@ +global using Markdig; +global using Microsoft.AspNetCore.Components; +global using Microsoft.JSInterop; +global using PSC.Blazor.Components.MarkdownEditor.Enums; +global using PSC.Blazor.Components.MarkdownEditor.EventsArgs; +global using PSC.Blazor.Components.MarkdownEditor.Models; +global using System; +global using System.Collections.Generic; +global using System.IO; +global using System.Net.Http; +global using System.Net.Http.Headers; +global using System.Threading.Tasks; \ No newline at end of file diff --git a/PSC.Blazor.Components.MarkdownEditor/Interfaces/IFileEntry.cs b/PSC.Blazor.Components.MarkdownEditor/Interfaces/IFileEntry.cs new file mode 100644 index 0000000..7e94ff6 --- /dev/null +++ b/PSC.Blazor.Components.MarkdownEditor/Interfaces/IFileEntry.cs @@ -0,0 +1,81 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace PSC.Blazor.Components.MarkdownEditor.Interfaces +{ + /// + /// Defines the upload file. + /// + public interface IFileEntry + { + /// + /// Gets the file-entry id. + /// + public int Id { get; } + + /// + /// Returns the last modified time of the file. + /// + DateTime LastModified { get; } + + /// + /// Returns the name of the file. + /// + string Name { get; } + + /// + /// Returns the size of the file in bytes. + /// + long Size { get; } + + /// + /// Returns the MIME type of the file. + /// + string Type { get; } + + /// + /// Provides a way to tell the location of the uploaded file or image. + /// + string UploadUrl { get; set; } + + /// + /// Provides a way to tell if any error happened. + /// + string ErrorMessage { get; set; } + + /// + /// Provides the access to the underline file through the stream. + /// + /// Stream to which the upload process if writing. + /// + Task WriteToStreamAsync(Stream stream); + + /// + /// Opens the stream for reading the uploaded file. + /// + /// + /// The maximum number of bytes that can be supplied by the Stream. Defaults to 500 KB. + /// + /// Calling + /// will throw if the file's size, as specified by is larger than + /// . By default, if the user supplies a file larger than 500 KB, this method will throw an exception. + /// + /// + /// It is valuable to choose a size limit that corresponds to your use case. If you allow excessively large files, this + /// may result in excessive consumption of memory or disk/database space, depending on what your code does + /// with the supplied . + /// + /// + /// For Blazor Server in particular, beware of reading the entire stream into a memory buffer unless you have + /// passed a suitably low size limit, since you will be consuming that memory on the server. + /// + /// + /// A cancellation token to signal the cancellation of streaming file data. + /// Thrown if the file's length exceeds the value. + Stream OpenReadStream(long maxAllowedSize = 512000, CancellationToken cancellationToken = default); + } +} diff --git a/PSC.Blazor.Components.MarkdownEditor/JSMarkdownInterop.cs b/PSC.Blazor.Components.MarkdownEditor/JSMarkdownInterop.cs new file mode 100644 index 0000000..0114e67 --- /dev/null +++ b/PSC.Blazor.Components.MarkdownEditor/JSMarkdownInterop.cs @@ -0,0 +1,90 @@ +namespace PSC.Blazor.Components.MarkdownEditor +{ + /// + /// JSMarkdownInterop class + /// + public class JSMarkdownInterop + { + /// + /// The js runtime + /// + IJSRuntime jsRuntime; + + /// + /// Initializes a new instance of the class. + /// + /// The js runtime. + public JSMarkdownInterop(IJSRuntime JSRuntime) + { + this.jsRuntime = JSRuntime; + } + + /// + /// Initializes the specified dot net object reference. + /// + /// The dotnet object reference. + /// The element reference. + /// The element identifier. + /// The options. + /// + public async ValueTask Initialize(DotNetObjectReference dotNetObjectRef, ElementReference elementRef, + string elementId, object options) + { + await jsRuntime.InvokeVoidAsync("initialize", dotNetObjectRef, elementRef, elementId, options); + } + + /// + /// Destroys the specified element reference. + /// + /// The element reference. + /// The element identifier. + /// + public async ValueTask Destroy(ElementReference elementRef, string elementId) + { + await jsRuntime.InvokeVoidAsync("destroy", elementRef, elementId); + } + + /// + /// Sets the value. + /// + /// The element identifier. + /// The value. + /// + public async ValueTask SetValue(string elementId, string value) + { + await jsRuntime.InvokeVoidAsync("setValue", elementId, value); + } + + /// + /// Gets the value. + /// + /// The element identifier. + /// + public async ValueTask GetValue(string elementId) + { + return await jsRuntime.InvokeAsync("getValue", elementId); + } + + /// + /// Notifies the image upload success. + /// + /// The element identifier. + /// The image URL. + /// + public async ValueTask NotifyImageUploadSuccess(string elementId, string imageUrl) + { + await jsRuntime.InvokeVoidAsync("notifyImageUploadSuccess", elementId, imageUrl); + } + + /// + /// Notifies the image upload error. + /// + /// The element identifier. + /// The error message. + /// + public async ValueTask NotifyImageUploadError(string elementId, string errorMessage) + { + await jsRuntime.InvokeVoidAsync("notifyImageUploadError", elementId, errorMessage); + } + } +} \ No newline at end of file diff --git a/PSC.Blazor.Components.MarkdownEditor/MarkdownActionProvider.cs b/PSC.Blazor.Components.MarkdownEditor/MarkdownActionProvider.cs new file mode 100644 index 0000000..09b5900 --- /dev/null +++ b/PSC.Blazor.Components.MarkdownEditor/MarkdownActionProvider.cs @@ -0,0 +1,134 @@ +namespace PSC.Blazor.Components.MarkdownEditor +{ + /// + /// Provider for the . + /// + internal static class MarkdownActionProvider + { + /// + /// Gets the Markdown class for the specified action. + /// + public static string Class(MarkdownAction? action, string name) + { + if (!string.IsNullOrWhiteSpace(name)) + return name; + + return action switch + { + MarkdownAction.Bold => "bold", + MarkdownAction.Italic => "italic", + MarkdownAction.Strikethrough => "strikethrough", + MarkdownAction.Heading => "heading", + MarkdownAction.HeadingSmaller => "heading-smaller", + MarkdownAction.HeadingBigger => "heading-bigger", + MarkdownAction.Heading1 => "heading-1", + MarkdownAction.Heading2 => "heading-2", + MarkdownAction.Heading3 => "heading-3", + MarkdownAction.Code => "code", + MarkdownAction.Quote => "quote", + MarkdownAction.UnorderedList => "unordered-list", + MarkdownAction.OrderedList => "ordered-list", + MarkdownAction.CleanBlock => "clean-block", + MarkdownAction.Link => "link", + MarkdownAction.Image => "image", + MarkdownAction.Table => "table", + MarkdownAction.HorizontalRule => "horizontal-rule", + MarkdownAction.Preview => "preview", + MarkdownAction.SideBySide => "side-by-side", + MarkdownAction.Fullscreen => "fullscreen", + MarkdownAction.Guide => "guide", + _ => name + }; + } + + /// + /// Gets the Markdown event name for the specified action. + /// + public static string Event(MarkdownAction? action) => + action switch + { + MarkdownAction.Bold => "toggleBold", + MarkdownAction.Italic => "toggleItalic", + MarkdownAction.Strikethrough => "toggleStrikethrough", + MarkdownAction.Heading => "toggleHeadingSmaller", + MarkdownAction.HeadingSmaller => "toggleHeadingSmaller", + MarkdownAction.HeadingBigger => "toggleHeadingBigger", + MarkdownAction.Heading1 => "toggleHeading1", + MarkdownAction.Heading2 => "toggleHeading2", + MarkdownAction.Heading3 => "toggleHeading3", + MarkdownAction.Code => "toggleCodeBlock", + MarkdownAction.Quote => "toggleBlockquote", + MarkdownAction.UnorderedList => "toggleUnorderedList", + MarkdownAction.OrderedList => "toggleOrderedList", + MarkdownAction.CleanBlock => "cleanBlock", + MarkdownAction.Link => "drawLink", + MarkdownAction.Image => "drawImage", + MarkdownAction.Table => "drawTable", + MarkdownAction.HorizontalRule => "drawHorizontalRule", + MarkdownAction.Preview => "togglePreview", + MarkdownAction.SideBySide => "toggleSideBySide", + MarkdownAction.Fullscreen => "toggleFullScreen", + MarkdownAction.Guide => "https://www.markdownguide.org/basic-syntax/", + _ => null + }; + + /// + /// Gets the Markdown icon class name for the specified action. + /// + public static string IconClass(MarkdownAction? action, string icon) + { + if (!string.IsNullOrWhiteSpace(icon)) + return icon; + + return action switch + { + MarkdownAction.Bold => "fa fa-bold", + MarkdownAction.Italic => "fa fa-italic", + MarkdownAction.Strikethrough => "fa fa-strikethrough", + MarkdownAction.Heading => "fa fa-header", + MarkdownAction.HeadingSmaller => "fa fa-header", + MarkdownAction.HeadingBigger => "fa fa-lg fa-header", + MarkdownAction.Heading1 => "fa fa-header header-1", + MarkdownAction.Heading2 => "fa fa-header header-2", + MarkdownAction.Heading3 => "fa fa-header header-3", + MarkdownAction.Code => "fa fa-code", + MarkdownAction.Quote => "fa fa-quote-left", + MarkdownAction.UnorderedList => "fa fa-list-ul", + MarkdownAction.OrderedList => "fa fa-list-ol", + MarkdownAction.CleanBlock => "fa fa-eraser", + MarkdownAction.Link => "fa fa-link", + MarkdownAction.Image => "fa fa-picture-o", + MarkdownAction.Table => "fa fa-table", + MarkdownAction.HorizontalRule => "fa fa-minus", + MarkdownAction.Preview => "fa fa-eye no-disable", + MarkdownAction.SideBySide => "fa fa-columns no-disable no-mobile", + MarkdownAction.Fullscreen => "fa fa-arrows-alt no-disable no-mobile", + MarkdownAction.Guide => "fa fa-question-circle", + _ => icon + }; + } + + /// + /// Serializes the specified buttons. + /// + /// The buttons. + /// + public static IEnumerable Serialize(List buttons) + { + foreach (var button in buttons) + { + if (button.Separator) + yield return "|"; + + yield return new + { + Name = Class(button.Action, button.Name), + Value = button.Value, + Action = Event(button.Action), + ClassName = IconClass(button.Action, button.Icon), + Title = button.Title, + }; + } + } + } +} \ No newline at end of file diff --git a/PSC.Blazor.Components.MarkdownEditor/MarkdownEditor.razor b/PSC.Blazor.Components.MarkdownEditor/MarkdownEditor.razor index e002810..09a127d 100644 --- a/PSC.Blazor.Components.MarkdownEditor/MarkdownEditor.razor +++ b/PSC.Blazor.Components.MarkdownEditor/MarkdownEditor.razor @@ -1,148 +1,10 @@ -@using System.Linq.Expressions - -
- - -
- @if (isWriteActive) - { -
- - Learn more about MarkDown - here. - - @if (showHelp) - { - - } -
- } - else - { -
- @((MarkupString)_previewText) -
- } -
-
- -@code { - [Parameter] - public string Value { get; set; } - - [Parameter] - public EventCallback ValueChanged { get; set; } - - [Parameter] - public Expression> ValueExpression { get; set; } - - [Parameter] - public bool EnableToolbar { get; set; } = true; - - [Parameter] - public string id { get; set; } - - [CascadingParameter] - private EditContext CascadedEditContext { get; set; } - - private bool isWriteActive = true; - - private string _previewText = ""; - private int _rows = 6; - private bool showHelp = false; - private FieldIdentifier _fieldIdentifier; - private string _fieldCssClasses => CascadedEditContext?.FieldCssClass(_fieldIdentifier) ?? ""; - - protected override void OnInitialized() - { - _fieldIdentifier = FieldIdentifier.Create(ValueExpression); - } - - private void CalculateSize(string value) - { - _rows = Math.Max(value.Split('\n').Length, value.Split('\r').Length); - _rows = Math.Max(_rows, 6); - } - - private void HandleHelpClick() - { - showHelp = true; - } - - private void HandleCloseHelpClick() - { - showHelp = false; - } - - private async Task HandleInput(ChangeEventArgs args) - { - CalculateSize(args.Value.ToString()); - - await ValueChanged.InvokeAsync(args.Value.ToString()); - - CascadedEditContext?.NotifyFieldChanged(_fieldIdentifier); - _previewText = MarkdownParser.Parse(args.Value.ToString()); - } - - private void UpdatePreview() - { - _previewText = MarkdownParser.Parse(Value.ToString()); - } - - private void HandleBoldClick() - { - Value = $"{Value} **(Bolded Text Here)**"; - UpdatePreview(); - } - - private void HandleItalicClick() - { - Value = $"{Value} *(Italic Text Here)*"; - UpdatePreview(); - } - - private void HandleListClick() - { - Value = $"{Value} \n - List Item"; - UpdatePreview(); - } - - private void HandleWriteClick() - { - isWriteActive = true; - } - - private void HandlePreviewClick() - { - isWriteActive = false; - } -} \ No newline at end of file +@inject IJSRuntime JSRuntime + + + + \ No newline at end of file diff --git a/PSC.Blazor.Components.MarkdownEditor/MarkdownEditor.razor.cs b/PSC.Blazor.Components.MarkdownEditor/MarkdownEditor.razor.cs new file mode 100644 index 0000000..fb6aa97 --- /dev/null +++ b/PSC.Blazor.Components.MarkdownEditor/MarkdownEditor.razor.cs @@ -0,0 +1,730 @@ +namespace PSC.Blazor.Components.MarkdownEditor +{ + /// + /// Markdown Editor + /// + /// + public partial class MarkdownEditor + { + #region Inject and JavaScript + + /// + /// The dotnet object reference + /// + private DotNetObjectReference dotNetObjectRef; + + /// + /// Gets or sets the HTTP client. + /// + /// + /// The HTTP client. + /// + [Inject] + public HttpClient _httpClient { get; set; } + + /// + /// Gets or sets the instance. + /// + protected JSMarkdownInterop JSModule { get; private set; } + #endregion Inject and JavaScript + + #region Element references + + /// + /// Gets or sets the element identifier. + /// + /// + /// The element identifier. + /// + private string ElementId { get; set; } + + /// + /// Gets or sets the element reference. + /// + /// + /// The element reference. + /// + private ElementReference ElementRef { get; set; } + + #endregion Element references + + #region Local variable + + /// + /// Percentage of the current file-read status. + /// + protected double Progress; + + /// + /// Number of processed bytes in current file. + /// + protected long ProgressProgress; + + /// + /// Total number of bytes in currently processed file. + /// + protected long ProgressTotal; + + /// + /// The toolbar buttons + /// + private List toolbarButtons; + /// + /// Indicates if markdown editor is properly initialized. + /// + protected bool Initialized { get; set; } + + /// + protected bool ShouldAutoGenerateId => true; + #endregion Local variable + + #region AutoSave + + /// + /// Gets or sets the automatic save delay. + /// Delay between saves, in milliseconds. Defaults to 10000 (10s). + /// + /// + /// The automatic save delay. + /// + [Parameter] + public int AutoSaveDelay { get; set; } = 10000; + + /// + /// Gets or sets the setting for the auto save. + /// Saves the text that's being written and will load it back in the future. + /// It will forget the text when the form it's contained in is submitted. + /// Recommended to choose a unique ID for the Markdown Editor. + /// + /// + /// true if the automatic save is enabled; otherwise, false. + /// + [Parameter] + public bool AutoSaveEnabled { get; set; } + + /// + /// Gets or sets the automatic save identifier. + /// You must set a unique string identifier so that EasyMDE can autosave. + /// Something that separates this from other instances of EasyMDE elsewhere on your website. + /// + /// + /// The automatic save identifier. + /// + [Parameter] + public string AutoSaveId { get; set; } + /// + /// Gets or sets the automatic save submit delay. + /// Delay before assuming that submit of the form failed and saving the text, in milliseconds. + /// + /// + /// The automatic save submit delay. + /// + [Parameter] + public int AutoSaveSubmitDelay { get; set; } = 5000; + + /// + /// Gets or sets the automatic save text. + /// + /// + /// The automatic save text. + /// + [Parameter] + public string AutoSaveText { get; set; } = "Autosaved: "; + + /// + /// Gets or sets the automatic save time format day. + /// + /// + /// The automatic save time format day. + /// + [Parameter] + public string AutoSaveTimeFormatDay { get; set; } = "2-digit"; + + /// + /// Gets or sets the automatic save time format hour. + /// + /// + /// The automatic save time format hour. + /// + [Parameter] + public string AutoSaveTimeFormatHour { get; set; } = "2-digit"; + + /// + /// Gets or sets the automatic save time format locale. + /// + /// + /// The automatic save time format locale. + /// + [Parameter] + public string AutoSaveTimeFormatLocale { get; set; } = "en-US"; + + /// + /// Gets or sets the automatic save time format minute. + /// + /// + /// The automatic save time format m inute. + /// + [Parameter] + public string AutoSaveTimeFormatMinute { get; set; } = "2-digit"; + + /// + /// Gets or sets the automatic save time format month. + /// + /// + /// The automatic save time format month. + /// + [Parameter] + public string AutoSaveTimeFormatMonth { get; set; } = "long"; + + /// + /// Gets or sets the automatic save time format year. + /// + /// + /// The automatic save time format year. + /// + [Parameter] + public string AutoSaveTimeFormatYear { get; set; } = "numeric"; + #endregion AutoSave + + #region Event Callback + + /// + /// Occurs after the custom toolbar button is clicked. + /// + [Parameter] + public EventCallback CustomButtonClicked { get; set; } + + /// + /// An event that occurs after the markdown value has changed. + /// + [Parameter] + public EventCallback ValueChanged { get; set; } + + /// + /// An event that occurs after the markdown value has changed and return the HTML from the Markdown + /// + [Parameter] + public EventCallback ValueHTMLChanged { get; set; } + #endregion Event Callback + + #region Parameters + + /// + /// If set to true, force downloads Font Awesome (used for icons). If set to false, prevents downloading. + /// + [Parameter] + public bool? AutoDownloadFontAwesome { get; set; } + + /// + /// rtl or ltr. Changes text direction to support right-to-left languages. Defaults to ltr. + /// + [Parameter] + public string Direction { get; set; } = "ltr"; + + /// + /// A callback function used to define how to display an error message. Defaults to (errorMessage) => alert(errorMessage). + /// + [Parameter] + public Func ErrorCallback { get; set; } + + /// + /// Errors displayed to the user, using the errorCallback option, where #image_name#, #image_size# + /// and #image_max_size# will replaced by their respective values, that can be used for customization + /// or internationalization. + /// + [Parameter] + public MarkdownErrorMessages ErrorMessages { get; set; } + + /// + /// An array of icon names to hide. Can be used to hide specific icons shown by default without + /// completely customizing the toolbar. + /// + [Parameter] + public string[] HideIcons { get; set; } = new[] { "side-by-side", "fullscreen" }; + + /// + /// A comma-separated list of mime-types used to check image type before upload (note: never trust client, always + /// check file types at server-side). Defaults to image/png, image/jpeg. + /// + [Parameter] + public string ImageAccept { get; set; } = "image/png, image/jpeg, image/jpg, image.gif"; + + /// + /// CSRF token to include with AJAX call to upload image. For instance used with Django backend. + /// + [Parameter] + public string ImageCSRFToken { get; set; } + + /// + /// Maximum image size in bytes, checked before upload (note: never trust client, always check image + /// size at server-side). Defaults to 1024*1024*2 (2Mb). + /// + [Parameter] + public long ImageMaxSize { get; set; } = 1024 * 1024 * 2; + + /// + /// If set to true, will treat imageUrl from imageUploadFunction and filePath returned from imageUploadEndpoint as + /// an absolute rather than relative path, i.e. not prepend window.location.origin to it. + /// + [Parameter] + public string ImagePathAbsolute { get; set; } + + /// + /// Texts displayed to the user (mainly on the status bar) for the import image feature, where + /// #image_name#, #image_size# and #image_max_size# will replaced by their respective values, that + /// can be used for customization or internationalization. + /// + [Parameter] + public MarkdownImageTexts ImageTexts { get; set; } + + /// + /// Occurs every time the selected image has changed. + /// + [Parameter] + public Func ImageUploadChanged { get; set; } + + /// + /// Occurs when an individual image upload has ended. + /// + [Parameter] + public Func ImageUploadEnded { get; set; } + + /// + /// The endpoint where the images data will be sent, via an asynchronous POST request. The server is supposed to + /// save this image, and return a json response. + /// + [Parameter] + public string ImageUploadEndpoint { get; set; } + + /// + /// Gets or sets the image upload authentication schema (for example Bearer) + /// + /// + /// The image upload authentication schema by default is empty + /// + [Parameter] + public string ImageUploadAuthenticationSchema { get; set; } + + /// + /// Gets or sets the image upload authentication token. + /// + /// + /// The image upload authentication token by default is empty + /// + [Parameter] + public string ImageUploadAuthenticationToken { get; set; } + + /// + /// Notifies the progress of image being written to the destination stream. + /// + [Parameter] + public Func ImageUploadProgressed { get; set; } + + /// + /// Occurs when an individual image upload has started. + /// + [Parameter] + public Func ImageUploadStarted { get; set; } + + /// + /// If set to true, enables line numbers in the editor. + /// + [Parameter] + public bool LineNumbers { get; set; } + + /// + /// If set to false, disable line wrapping. Defaults to true. + /// + [Parameter] + public bool LineWrapping { get; set; } = true; + + /// + /// Sets fixed height for the composition area. minHeight option will be ignored. + /// Should be a string containing a valid CSS value like "500px". Defaults to undefined. + /// + [Parameter] + public string MaxHeight { get; set; } + + /// + /// Gets or sets the max chunk size when uploading the file. + /// + [Parameter] + public int MaxUploadImageChunkSize { get; set; } = 20 * 1024; + + /// + /// Sets the minimum height for the composition area, before it starts auto-growing. + /// Should be a string containing a valid CSS value like "500px". Defaults to "300px". + /// + [Parameter] + public string MinHeight { get; set; } = "300px"; + + /// + /// If set, displays a custom placeholder message. + /// + [Parameter] + public string Placeholder { get; set; } + + /// + /// Gets or sets the Segment Fetch Timeout when uploading the file. + /// + [Parameter] + public TimeSpan SegmentFetchTimeout { get; set; } = TimeSpan.FromMinutes(1); + + /// + /// An array of icon names to show. Can be used to show specific icons hidden by default without + /// completely customizing the toolbar. + /// + [Parameter] + public string[] ShowIcons { get; set; } = new[] { "code", "table" }; + + /// + /// If set, customize the tab size. Defaults to 2. + /// + [Parameter] + public int TabSize { get; set; } = 2; + + /// + /// Override the theme. Defaults to easymde. + /// + [Parameter] + public string Theme { get; set; } = "easymde"; + + /// + /// [Optional] Gets or sets the content of the toolbar. + /// + [Parameter] + public RenderFragment Toolbar { get; set; } + + /// + /// If set to false, disable toolbar button tips. Defaults to true. + /// + [Parameter] + public bool ToolbarTips { get; set; } = true; + + /// + /// If set to true, enables the image upload functionality, which can be triggered by drag-drop, + /// copy-paste and through the browse-file window (opened when the user click on the upload-image icon). + /// Defaults to false. + /// + [Parameter] + public bool UploadImage { get; set; } + + /// + /// Gets or sets the markdown value. + /// + [Parameter] + public string Value { get; set; } + + /// + /// Gets or sets the HTML from markdown value. + /// + [Parameter] + public string ValueHTML { get; set; } + #endregion Parameters + + /// + /// Gets the markdown value. + /// + /// Markdown value. + public async Task GetValueAsync() + { + if (!Initialized) + return null; + return await JSModule.GetValue(ElementId); + } + + /// + /// Notifies the error message. + /// + /// The error message. + /// + [JSInvokable] + public Task NotifyErrorMessage(string errorMessage) + { + if (ErrorCallback is not null) + return ErrorCallback.Invoke(errorMessage); + + return Task.CompletedTask; + } + + /// + /// Notifies the component that file input value has changed. + /// + /// Changed file. + /// A task that represents the asynchronous operation. + [JSInvokable] + public async Task NotifyImageUpload(FileEntry file) + { + if (ImageUploadChanged is not null) + await ImageUploadChanged.Invoke(new(file)); + + if (string.IsNullOrEmpty(ImageUploadEndpoint)) + await JSModule.NotifyImageUploadError(ElementId, $"The property ImageUploadEndpoint is not specified."); + + await InvokeAsync(StateHasChanged); + } + + /// + /// Sets the markdown value. + /// + /// Value to set. + /// A task that represents the asynchronous operation. + public async Task SetValueAsync(string value) + { + if (!Initialized) + return; + await JSModule.SetValue(ElementId, value); + } + + /// + /// Updates the file ended asynchronous. + /// + /// The file entry. + /// if set to true [success]. + /// The file invalid reason. + public async Task UpdateFileEndedAsync(FileEntry fileEntry, bool success, string fileInvalidReason) + { + if (ImageUploadEnded is not null) + await ImageUploadEnded.Invoke(new(fileEntry, success, fileInvalidReason)); + + if (success) + await JSModule.NotifyImageUploadSuccess(ElementId, fileEntry.UploadUrl); + else + await JSModule.NotifyImageUploadError(ElementId, fileEntry.ErrorMessage); + } + + /// + /// Updates the file progress asynchronous. + /// + /// The file entry. + /// The progress progress. + /// + public Task UpdateFileProgressAsync(FileEntry fileEntry, long progressProgress) + { + ProgressProgress += progressProgress; + + var progress = Math.Round((double)ProgressProgress / ProgressTotal, 3); + + if (Math.Abs(progress - Progress) > double.Epsilon) + { + Progress = progress; + + if (ImageUploadProgressed is not null) + return ImageUploadProgressed.Invoke(new(fileEntry, Progress)); + } + + return Task.CompletedTask; + } + + /// + /// Updates the file started asynchronous. + /// + /// The file entry. + /// + public Task UpdateFileStartedAsync(FileEntry fileEntry) + { + // reset all + ProgressProgress = 0; + ProgressTotal = 100; + Progress = 0; + + if (ImageUploadStarted is not null) + return ImageUploadStarted.Invoke(new(fileEntry)); + + return Task.CompletedTask; + } + + /// + /// Updates the internal markdown value. This method should only be called internally! + /// + /// New value. + /// A task that represents the asynchronous operation. + [JSInvokable] + public Task UpdateInternalValue(string value) + { + Value = value; + + var pipeline = new MarkdownPipelineBuilder().UseAdvancedExtensions().Build(); + ValueHTML = Markdown.ToHtml(value ?? string.Empty, pipeline); + + ValueHTMLChanged.InvokeAsync(ValueHTML); + return ValueChanged.InvokeAsync(Value); + } + + /// + /// Uploads the file. + /// + /// The file information. + [JSInvokable] + public async Task UploadFile(FileEntry fileInfo) + { + if (fileInfo is null || string.IsNullOrEmpty(fileInfo.ContentBase64)) + await JSModule.NotifyImageUploadError(ElementId, $"Can't upload an empty file"); + + if(string.IsNullOrEmpty(ImageUploadEndpoint)) + await JSModule.NotifyImageUploadError(ElementId, $"The property ImageUploadEndpoint is not specified."); + + await ImageUploadStarted.Invoke(new(fileInfo)); + + HttpResponseMessage responseMessage; + using (HttpClient httpClient = new HttpClient()) + { + if (!string.IsNullOrWhiteSpace(ImageUploadAuthenticationSchema) && !string.IsNullOrWhiteSpace(ImageUploadAuthenticationToken)) + httpClient.DefaultRequestHeaders.Authorization = + new AuthenticationHeaderValue(ImageUploadAuthenticationSchema, ImageUploadAuthenticationToken); + + byte[] file = Convert.FromBase64String(fileInfo.ContentBase64); + + await ImageUploadProgressed.Invoke(new(fileInfo, 25.0)); + + using var form = new MultipartFormDataContent(); + using var fileContent = new ByteArrayContent(file); + fileContent.Headers.ContentType = MediaTypeHeaderValue.Parse("multipart/form-data"); + + form.Add(fileContent, "file", fileInfo.Name); + + await ImageUploadProgressed.Invoke(new(fileInfo, 50.0)); + + bool success = false; + try + { + var response = await _httpClient.PostAsync(ImageUploadEndpoint, form); + response.EnsureSuccessStatusCode(); + + await ImageUploadProgressed.Invoke(new(fileInfo, 100)); + + if (response.IsSuccessStatusCode) + { + var result = await response.Content.ReadAsStringAsync(); + fileInfo.UploadUrl = result; + success = true; + } + else + fileInfo.ErrorMessage = $"Error uploading the file {fileInfo.Name}"; + } + catch (Exception ex) + { + fileInfo.ErrorMessage = $"Bad request uploading the file {fileInfo.Name}"; + } + + await UpdateFileEndedAsync(fileInfo, success, fileInfo.ErrorMessage); + } + } + + /// + /// Adds the custom toolbar button. + /// + /// Button instance. + protected internal void AddMarkdownToolbarButton(MarkdownToolbarButton toolbarButton) + { + toolbarButtons ??= new(); + toolbarButtons.Add(toolbarButton); + } + + /// + /// Removes the custom toolbar button. + /// + /// Button instance. + protected internal void RemoveMarkdownToolbarButton(MarkdownToolbarButton toolbarButton) + { + toolbarButtons.Remove(toolbarButton); + } + + /// + /// Method invoked after each time the component has been rendered. Note that the component does + /// not automatically re-render after the completion of any returned , because + /// that would cause an infinite render loop. + /// + /// Set to true if this is the first time has been invoked + /// on this component instance; otherwise false. + /// + /// The and lifecycle methods + /// are useful for performing interop, or interacting with values received from @ref. + /// Use the parameter to ensure that initialization work is only performed + /// once. + /// + protected override async Task OnAfterRenderAsync(bool firstRender) + { + await base.OnAfterRenderAsync(firstRender); + + if (firstRender) + { + dotNetObjectRef ??= DotNetObjectReference.Create(this); + + await JSModule.Initialize(dotNetObjectRef, ElementRef, ElementId, new + { + AutoSave = new + { + enabled = AutoSaveEnabled, + uniqueId = AutoSaveId, + delay = AutoSaveDelay, + submit_delay = AutoSaveSubmitDelay, + timeFormat = new + { + locale = AutoSaveTimeFormatLocale, + format = new + { + year = AutoSaveTimeFormatYear, + month = AutoSaveTimeFormatMonth, + day = AutoSaveTimeFormatDay, + hour = AutoSaveTimeFormatHour, + minute = AutoSaveTimeFormatMinute + }, + }, + text = AutoSaveText + }, + Value, + AutoDownloadFontAwesome, + HideIcons, + ShowIcons, + LineNumbers, + LineWrapping, + MinHeight, + MaxHeight, + Placeholder, + TabSize, + Theme, + Direction, + Toolbar = Toolbar != null && toolbarButtons?.Count > 0 ? MarkdownActionProvider.Serialize(toolbarButtons) : null, + ToolbarTips, + UploadImage, + ImageMaxSize, + ImageAccept, + ImageUploadEndpoint, + ImagePathAbsolute, + ImageCSRFToken, + ImageTexts = ImageTexts == null ? null : new + { + SbInit = ImageTexts.Init, + SbOnDragEnter = ImageTexts.OnDragEnter, + SbOnDrop = ImageTexts.OnDrop, + SbProgress = ImageTexts.Progress, + SbOnUploaded = ImageTexts.OnUploaded, + ImageTexts.SizeUnits, + }, + ErrorMessages, + }); + + Initialized = true; + } + } + + /// + /// Method invoked when the component is ready to start, having received its + /// initial parameters from its parent in the render tree. + /// + protected override void OnInitialized() + { + if (JSModule == null) + { + JSModule = new JSMarkdownInterop(JSRuntime); + } + + ElementId = $"markdown-{Guid.NewGuid()}"; + if (string.IsNullOrEmpty(AutoSaveId)) + AutoSaveId = ElementId; + + base.OnInitialized(); + } + } +} \ No newline at end of file diff --git a/PSC.Blazor.Components.MarkdownEditor/MarkdownEditor.razor.css b/PSC.Blazor.Components.MarkdownEditor/MarkdownEditor.razor.css index c6afca4..8bea286 100644 --- a/PSC.Blazor.Components.MarkdownEditor/MarkdownEditor.razor.css +++ b/PSC.Blazor.Components.MarkdownEditor/MarkdownEditor.razor.css @@ -1,6 +1,4 @@ -.my-component { - border: 2px dashed red; - padding: 1em; - margin: 1em 0; - background-image: url('background.png'); -} +img +{ + max-width: 100%; +} \ No newline at end of file diff --git a/PSC.Blazor.Components.MarkdownEditor/MarkdownErrorMessages.cs b/PSC.Blazor.Components.MarkdownEditor/MarkdownErrorMessages.cs new file mode 100644 index 0000000..4d5203d --- /dev/null +++ b/PSC.Blazor.Components.MarkdownEditor/MarkdownErrorMessages.cs @@ -0,0 +1,30 @@ +namespace PSC.Blazor.Components.MarkdownEditor +{ + /// + /// Markdown Error Messages + /// + public class MarkdownErrorMessages + { + /// + /// The server did not receive any file from the user. Defaults to You must select a file. + /// + public string NoFileGiven { get; set; } + + /// + /// The user send a file type which doesn't match the imageAccept list, or the server returned this error code. + /// Defaults to This image type is not allowed. + /// + public string TypeNotAllowed { get; set; } + + /// + /// The size of the image being imported is bigger than the imageMaxSize, or if the server returned this error code. + /// Defaults to Image #image_name# is too big (#image_size#).\nMaximum file size is #image_max_size#. + /// + public string FileTooLarge { get; set; } + + /// + /// An unexpected error occurred when uploading the image. Defaults to Something went wrong when uploading the image #image_name#. + /// + public string ImportError { get; set; } + } +} \ No newline at end of file diff --git a/PSC.Blazor.Components.MarkdownEditor/MarkdownImageTexts.cs b/PSC.Blazor.Components.MarkdownEditor/MarkdownImageTexts.cs new file mode 100644 index 0000000..80258b1 --- /dev/null +++ b/PSC.Blazor.Components.MarkdownEditor/MarkdownImageTexts.cs @@ -0,0 +1,40 @@ +namespace PSC.Blazor.Components.MarkdownEditor +{ + /// + /// Markdown Image Texts + /// + public class MarkdownImageTexts + { + /// + /// Status message displayed initially if uploadImage is set to true. Defaults to Attach files by drag + /// and dropping or pasting from clipboard. + /// + public string Init { get; set; } + + /// + /// Status message displayed when the user drags a file to the text area. Defaults to Drop image to upload it. + /// + public string OnDragEnter { get; set; } + + /// + /// Status message displayed when the user drops a file in the text area. Defaults to Uploading images #images_names#. + /// + public string OnDrop { get; set; } + + /// + /// Status message displayed to show uploading progress. Defaults to Uploading #file_name#: #progress#%. + /// + public string Progress { get; set; } + + /// + /// Status message displayed when the image has been uploaded. Defaults to Uploaded #image_name#. + /// + public string OnUploaded { get; set; } + + /// + /// A comma-separated list of units used to display messages with human-readable file sizes. Defaults + /// to B, KB, MB (example: 218 KB). You can use B,KB,MB instead if you prefer without whitespaces (218KB). + /// + public string SizeUnits { get; set; } + } +} \ No newline at end of file diff --git a/PSC.Blazor.Components.MarkdownEditor/MarkdownToolbarButton.razor b/PSC.Blazor.Components.MarkdownEditor/MarkdownToolbarButton.razor new file mode 100644 index 0000000..e02abfc --- /dev/null +++ b/PSC.Blazor.Components.MarkdownEditor/MarkdownToolbarButton.razor @@ -0,0 +1 @@ + diff --git a/PSC.Blazor.Components.MarkdownEditor/MarkdownToolbarButton.razor.cs b/PSC.Blazor.Components.MarkdownEditor/MarkdownToolbarButton.razor.cs new file mode 100644 index 0000000..035b33a --- /dev/null +++ b/PSC.Blazor.Components.MarkdownEditor/MarkdownToolbarButton.razor.cs @@ -0,0 +1,81 @@ +namespace PSC.Blazor.Components.MarkdownEditor +{ + /// + /// Markdown Toolbar Button + /// + /// + /// + public partial class MarkdownToolbarButton : IDisposable + { + /// + /// Gets or sets the custom name corresponding to the action. + /// + [Parameter] + public string Name { get; set; } + + /// + /// Gets or sets the custom value corresponding to the action. + /// + [Parameter] + public object Value { get; set; } + + /// + /// Gets or sets the custom icon name corresponding to the action. + /// + [Parameter] + public string Icon { get; set; } + + /// + /// Gets or sets the small tooltip that appears via the title="" attribute. + /// + [Parameter] + public string Title { get; set; } + + /// + /// If true, separator will be placed before the button. + /// + [Parameter] + public bool Separator { get; set; } + + /// + /// Gets or sets the parent markdown instance. + /// + [CascadingParameter] + protected MarkdownEditor ParentMarkdown { get; set; } + + /// + /// The toolbar action. + /// + private MarkdownAction? action; + protected override void OnInitialized() + { + if (ParentMarkdown is not null) + { + ParentMarkdown.AddMarkdownToolbarButton(this); + } + + base.OnInitialized(); + } + + public void Dispose() + { + if (ParentMarkdown is not null) + { + ParentMarkdown.RemoveMarkdownToolbarButton(this); + } + } + + /// + /// Gets or sets the predefined toolbar action. If undefined will be used. + /// + [Parameter] + public MarkdownAction? Action + { + get => action; + set + { + action = value; + } + } + } +} \ No newline at end of file diff --git a/PSC.Blazor.Components.MarkdownEditor/Models/FileEntry.cs b/PSC.Blazor.Components.MarkdownEditor/Models/FileEntry.cs new file mode 100644 index 0000000..0bd441c --- /dev/null +++ b/PSC.Blazor.Components.MarkdownEditor/Models/FileEntry.cs @@ -0,0 +1,48 @@ +namespace PSC.Blazor.Components.MarkdownEditor.Models +{ + /// + /// File Entry model + /// + public class FileEntry + { + /// + /// Gets the file-entry id. + /// + public int Id { get; } + + /// + /// Returns the last modified time of the file. + /// + public DateTime LastModified { get; set; } + + /// + /// Returns the name of the file. + /// + public string Name { get; set; } + + /// + /// Returns the size of the file in bytes. + /// + public long Size { get; set; } + + /// + /// Returns the MIME type of the file. + /// + public string Type { get; set; } + + /// + /// Provides a way to tell the location of the uploaded file or image. + /// + public string UploadUrl { get; set; } + + /// + /// Provides a way to tell if any error happened. + /// + public string ErrorMessage { get; set; } + + /// + /// Gets or sets the content base64. + /// + public string ContentBase64 { get; set; } + } +} \ No newline at end of file diff --git a/PSC.Blazor.Components.MarkdownEditor/PSC.Blazor.Components.MarkdownEditor.csproj b/PSC.Blazor.Components.MarkdownEditor/PSC.Blazor.Components.MarkdownEditor.csproj index 60addf6..a3867f8 100644 --- a/PSC.Blazor.Components.MarkdownEditor/PSC.Blazor.Components.MarkdownEditor.csproj +++ b/PSC.Blazor.Components.MarkdownEditor/PSC.Blazor.Components.MarkdownEditor.csproj @@ -1,7 +1,7 @@ - net5.0 + net6.0 psc_logo.ico true psc_logo.png @@ -13,6 +13,7 @@ git blazor, blazor-webassembly, blazor-server Simple Markdown editor with preview + README.md @@ -22,18 +23,19 @@ - + + + + True + \ + True - - - - diff --git a/PSC.Blazor.Components.MarkdownEditor/ProgressiveStreamContent.cs b/PSC.Blazor.Components.MarkdownEditor/ProgressiveStreamContent.cs new file mode 100644 index 0000000..712068b --- /dev/null +++ b/PSC.Blazor.Components.MarkdownEditor/ProgressiveStreamContent.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Text; +using System.Threading.Tasks; + +namespace PSC.Blazor.Components.MarkdownEditor +{ + public class ProgressiveStreamContent : StreamContent + { + // Define the variables which is the stream that represents the file + private readonly Stream _fileStream; + // Maximum amount of bytes to send per packet + private readonly int _maxBuffer = 1024 * 4; + + public ProgressiveStreamContent(Stream stream, int maxBuffer, Action onProgress) : base(stream) + { + _fileStream = stream; + _maxBuffer = maxBuffer; + OnProgress += onProgress; + } + + /// + /// Event that we can subscribe to which will be triggered everytime after part of the file gets uploaded. + /// It passes the total amount of uploaded bytes and the percentage as well + /// + public event Action OnProgress; + + // Override the SerialzeToStreamAsync method which provides us with the stream that we can write our chunks into it + protected async override Task SerializeToStreamAsync(Stream stream, TransportContext context) + { + // Define an array of bytes with the the length of the maximum amount of bytes to be pushed per time + var buffer = new byte[_maxBuffer]; + var totalLength = _fileStream.Length; + + // Variable that holds the amount of uploaded bytes + long uploaded = 0; + + // Create an while loop that we will break it internally when all bytes uploaded to the server + while (true) + { + using (_fileStream) + { + // In this part of code here in every loop we read a chunk of bytes and write them to the stream of the HttpContent + var length = await _fileStream.ReadAsync(buffer, 0, _maxBuffer); + // Check if the amount of bytes read recently, if there is no bytes read break the loop + if (length <= 0) + { + break; + } + + // Add the amount of read bytes to uploaded variable + uploaded += length; + // Calculate the percntage of the uploaded bytes out of the total remaining + var percentage = Convert.ToDouble(uploaded * 100 / _fileStream.Length); + + // Write the bytes to the HttpContent stream + await stream.WriteAsync(buffer); + + // Fire the event of OnProgress to notify the client about progress so far + OnProgress?.Invoke(uploaded, percentage); + + // Add this delay over here just to simulate to notice the progress, because locally it's going to be so fast that you can barely notice it + await Task.Delay(250); + } + } + } + } +} \ No newline at end of file diff --git a/PSC.Blazor.Components.MarkdownEditor/_Imports.razor b/PSC.Blazor.Components.MarkdownEditor/_Imports.razor index 9a8450f..8698e18 100644 --- a/PSC.Blazor.Components.MarkdownEditor/_Imports.razor +++ b/PSC.Blazor.Components.MarkdownEditor/_Imports.razor @@ -1,3 +1,2 @@ @using Microsoft.AspNetCore.Components.Web -@using Microsoft.AspNetCore.Components.Forms -@using PSC.Blazor.Components.MarkdownEditor.Services \ No newline at end of file +@using Microsoft.AspNetCore.Components.Forms \ No newline at end of file diff --git a/PSC.Blazor.Components.MarkdownEditor/libman.json b/PSC.Blazor.Components.MarkdownEditor/libman.json new file mode 100644 index 0000000..d647a6d --- /dev/null +++ b/PSC.Blazor.Components.MarkdownEditor/libman.json @@ -0,0 +1,15 @@ +{ + "version": "1.0", + "defaultProvider": "jsdelivr", + "libraries": [ + { + "library": "easymde@2.15.0", + "destination": "wwwroot/easymde/" + }, + { + "provider": "cdnjs", + "library": "simplemde@1.11.2", + "destination": "wwwroot/lib/simplemde/" + } + ] +} \ No newline at end of file diff --git a/PSC.Blazor.Components.MarkdownEditor/wwwroot/css/easymde.min.css b/PSC.Blazor.Components.MarkdownEditor/wwwroot/css/easymde.min.css new file mode 100644 index 0000000..453d7b5 --- /dev/null +++ b/PSC.Blazor.Components.MarkdownEditor/wwwroot/css/easymde.min.css @@ -0,0 +1,7 @@ +/** + * easymde v2.15.0 + * Copyright Jeroen Akkerman + * @link https://github.com/ionaru/easy-markdown-editor + * @license MIT + */ +.CodeMirror{font-family:monospace;height:300px;color:#000;direction:ltr}.CodeMirror-lines{padding:4px 0}.CodeMirror pre.CodeMirror-line,.CodeMirror pre.CodeMirror-line-like{padding:0 4px}.CodeMirror-gutter-filler,.CodeMirror-scrollbar-filler{background-color:#fff}.CodeMirror-gutters{border-right:1px solid #ddd;background-color:#f7f7f7;white-space:nowrap}.CodeMirror-linenumber{padding:0 3px 0 5px;min-width:20px;text-align:right;color:#999;white-space:nowrap}.CodeMirror-guttermarker{color:#000}.CodeMirror-guttermarker-subtle{color:#999}.CodeMirror-cursor{border-left:1px solid #000;border-right:none;width:0}.CodeMirror div.CodeMirror-secondarycursor{border-left:1px solid silver}.cm-fat-cursor .CodeMirror-cursor{width:auto;border:0!important;background:#7e7}.cm-fat-cursor div.CodeMirror-cursors{z-index:1}.cm-fat-cursor-mark{background-color:rgba(20,255,20,.5);-webkit-animation:blink 1.06s steps(1) infinite;-moz-animation:blink 1.06s steps(1) infinite;animation:blink 1.06s steps(1) infinite}.cm-animate-fat-cursor{width:auto;border:0;-webkit-animation:blink 1.06s steps(1) infinite;-moz-animation:blink 1.06s steps(1) infinite;animation:blink 1.06s steps(1) infinite;background-color:#7e7}@-moz-keyframes blink{50%{background-color:transparent}}@-webkit-keyframes blink{50%{background-color:transparent}}@keyframes blink{50%{background-color:transparent}}.cm-tab{display:inline-block;text-decoration:inherit}.CodeMirror-rulers{position:absolute;left:0;right:0;top:-50px;bottom:0;overflow:hidden}.CodeMirror-ruler{border-left:1px solid #ccc;top:0;bottom:0;position:absolute}.cm-s-default .cm-header{color:#00f}.cm-s-default .cm-quote{color:#090}.cm-negative{color:#d44}.cm-positive{color:#292}.cm-header,.cm-strong{font-weight:700}.cm-em{font-style:italic}.cm-link{text-decoration:underline}.cm-strikethrough{text-decoration:line-through}.cm-s-default .cm-keyword{color:#708}.cm-s-default .cm-atom{color:#219}.cm-s-default .cm-number{color:#164}.cm-s-default .cm-def{color:#00f}.cm-s-default .cm-variable-2{color:#05a}.cm-s-default .cm-type,.cm-s-default .cm-variable-3{color:#085}.cm-s-default .cm-comment{color:#a50}.cm-s-default .cm-string{color:#a11}.cm-s-default .cm-string-2{color:#f50}.cm-s-default .cm-meta{color:#555}.cm-s-default .cm-qualifier{color:#555}.cm-s-default .cm-builtin{color:#30a}.cm-s-default .cm-bracket{color:#997}.cm-s-default .cm-tag{color:#170}.cm-s-default .cm-attribute{color:#00c}.cm-s-default .cm-hr{color:#999}.cm-s-default .cm-link{color:#00c}.cm-s-default .cm-error{color:red}.cm-invalidchar{color:red}.CodeMirror-composing{border-bottom:2px solid}div.CodeMirror span.CodeMirror-matchingbracket{color:#0b0}div.CodeMirror span.CodeMirror-nonmatchingbracket{color:#a22}.CodeMirror-matchingtag{background:rgba(255,150,0,.3)}.CodeMirror-activeline-background{background:#e8f2ff}.CodeMirror{position:relative;overflow:hidden;background:#fff}.CodeMirror-scroll{overflow:scroll!important;margin-bottom:-50px;margin-right:-50px;padding-bottom:50px;height:100%;outline:0;position:relative}.CodeMirror-sizer{position:relative;border-right:50px solid transparent}.CodeMirror-gutter-filler,.CodeMirror-hscrollbar,.CodeMirror-scrollbar-filler,.CodeMirror-vscrollbar{position:absolute;z-index:6;display:none;outline:0}.CodeMirror-vscrollbar{right:0;top:0;overflow-x:hidden;overflow-y:scroll}.CodeMirror-hscrollbar{bottom:0;left:0;overflow-y:hidden;overflow-x:scroll}.CodeMirror-scrollbar-filler{right:0;bottom:0}.CodeMirror-gutter-filler{left:0;bottom:0}.CodeMirror-gutters{position:absolute;left:0;top:0;min-height:100%;z-index:3}.CodeMirror-gutter{white-space:normal;height:100%;display:inline-block;vertical-align:top;margin-bottom:-50px}.CodeMirror-gutter-wrapper{position:absolute;z-index:4;background:0 0!important;border:none!important}.CodeMirror-gutter-background{position:absolute;top:0;bottom:0;z-index:4}.CodeMirror-gutter-elt{position:absolute;cursor:default;z-index:4}.CodeMirror-gutter-wrapper ::selection{background-color:transparent}.CodeMirror-gutter-wrapper ::-moz-selection{background-color:transparent}.CodeMirror-lines{cursor:text;min-height:1px}.CodeMirror pre.CodeMirror-line,.CodeMirror pre.CodeMirror-line-like{-moz-border-radius:0;-webkit-border-radius:0;border-radius:0;border-width:0;background:0 0;font-family:inherit;font-size:inherit;margin:0;white-space:pre;word-wrap:normal;line-height:inherit;color:inherit;z-index:2;position:relative;overflow:visible;-webkit-tap-highlight-color:transparent;-webkit-font-variant-ligatures:contextual;font-variant-ligatures:contextual}.CodeMirror-wrap pre.CodeMirror-line,.CodeMirror-wrap pre.CodeMirror-line-like{word-wrap:break-word;white-space:pre-wrap;word-break:normal}.CodeMirror-linebackground{position:absolute;left:0;right:0;top:0;bottom:0;z-index:0}.CodeMirror-linewidget{position:relative;z-index:2;padding:.1px}.CodeMirror-rtl pre{direction:rtl}.CodeMirror-code{outline:0}.CodeMirror-gutter,.CodeMirror-gutters,.CodeMirror-linenumber,.CodeMirror-scroll,.CodeMirror-sizer{-moz-box-sizing:content-box;box-sizing:content-box}.CodeMirror-measure{position:absolute;width:100%;height:0;overflow:hidden;visibility:hidden}.CodeMirror-cursor{position:absolute;pointer-events:none}.CodeMirror-measure pre{position:static}div.CodeMirror-cursors{visibility:hidden;position:relative;z-index:3}div.CodeMirror-dragcursors{visibility:visible}.CodeMirror-focused div.CodeMirror-cursors{visibility:visible}.CodeMirror-selected{background:#d9d9d9}.CodeMirror-focused .CodeMirror-selected{background:#d7d4f0}.CodeMirror-crosshair{cursor:crosshair}.CodeMirror-line::selection,.CodeMirror-line>span::selection,.CodeMirror-line>span>span::selection{background:#d7d4f0}.CodeMirror-line::-moz-selection,.CodeMirror-line>span::-moz-selection,.CodeMirror-line>span>span::-moz-selection{background:#d7d4f0}.cm-searching{background-color:#ffa;background-color:rgba(255,255,0,.4)}.cm-force-border{padding-right:.1px}@media print{.CodeMirror div.CodeMirror-cursors{visibility:hidden}}.cm-tab-wrap-hack:after{content:''}span.CodeMirror-selectedtext{background:0 0}.EasyMDEContainer{display:block}.EasyMDEContainer.sided--no-fullscreen{display:flex;flex-direction:row;flex-wrap:wrap}.EasyMDEContainer .CodeMirror{box-sizing:border-box;height:auto;border:1px solid #ddd;border-bottom-left-radius:4px;border-bottom-right-radius:4px;padding:10px;font:inherit;z-index:0;word-wrap:break-word}.EasyMDEContainer .CodeMirror-scroll{cursor:text}.EasyMDEContainer .CodeMirror-fullscreen{background:#fff;position:fixed!important;top:50px;left:0;right:0;bottom:0;height:auto;z-index:8;border-right:none!important;border-bottom-right-radius:0!important}.EasyMDEContainer .CodeMirror-sided{width:50%!important}.EasyMDEContainer.sided--no-fullscreen .CodeMirror-sided{border-right:none!important;border-bottom-right-radius:0;position:relative;flex:1 1 auto}.EasyMDEContainer .CodeMirror-placeholder{opacity:.5}.EasyMDEContainer .CodeMirror-focused .CodeMirror-selected{background:#d9d9d9}.editor-toolbar{position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none;padding:9px 10px;border-top:1px solid #bbb;border-left:1px solid #bbb;border-right:1px solid #bbb;border-top-left-radius:4px;border-top-right-radius:4px}.editor-toolbar.fullscreen{width:100%;height:50px;padding-top:10px;padding-bottom:10px;box-sizing:border-box;background:#fff;border:0;position:fixed;top:0;left:0;opacity:1;z-index:9}.editor-toolbar.fullscreen::before{width:20px;height:50px;background:-moz-linear-gradient(left,#fff 0,rgba(255,255,255,0) 100%);background:-webkit-gradient(linear,left top,right top,color-stop(0,#fff),color-stop(100%,rgba(255,255,255,0)));background:-webkit-linear-gradient(left,#fff 0,rgba(255,255,255,0) 100%);background:-o-linear-gradient(left,#fff 0,rgba(255,255,255,0) 100%);background:-ms-linear-gradient(left,#fff 0,rgba(255,255,255,0) 100%);background:linear-gradient(to right,#fff 0,rgba(255,255,255,0) 100%);position:fixed;top:0;left:0;margin:0;padding:0}.editor-toolbar.fullscreen::after{width:20px;height:50px;background:-moz-linear-gradient(left,rgba(255,255,255,0) 0,#fff 100%);background:-webkit-gradient(linear,left top,right top,color-stop(0,rgba(255,255,255,0)),color-stop(100%,#fff));background:-webkit-linear-gradient(left,rgba(255,255,255,0) 0,#fff 100%);background:-o-linear-gradient(left,rgba(255,255,255,0) 0,#fff 100%);background:-ms-linear-gradient(left,rgba(255,255,255,0) 0,#fff 100%);background:linear-gradient(to right,rgba(255,255,255,0) 0,#fff 100%);position:fixed;top:0;right:0;margin:0;padding:0}.EasyMDEContainer.sided--no-fullscreen .editor-toolbar{width:100%}.editor-toolbar .easymde-dropdown,.editor-toolbar button{background:0 0;display:inline-block;text-align:center;text-decoration:none!important;height:30px;margin:0;padding:0;border:1px solid transparent;border-radius:3px;cursor:pointer}.editor-toolbar button{width:30px}.editor-toolbar button.active,.editor-toolbar button:hover{background:#fcfcfc;border-color:#95a5a6}.editor-toolbar i.separator{display:inline-block;width:0;border-left:1px solid #d9d9d9;border-right:1px solid #fff;color:transparent;text-indent:-10px;margin:0 6px}.editor-toolbar button:after{font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;font-size:65%;vertical-align:text-bottom;position:relative;top:2px}.editor-toolbar button.heading-1:after{content:"1"}.editor-toolbar button.heading-2:after{content:"2"}.editor-toolbar button.heading-3:after{content:"3"}.editor-toolbar button.heading-bigger:after{content:"▲"}.editor-toolbar button.heading-smaller:after{content:"▼"}.editor-toolbar.disabled-for-preview button:not(.no-disable){opacity:.6;pointer-events:none}@media only screen and (max-width:700px){.editor-toolbar i.no-mobile{display:none}}.editor-statusbar{padding:8px 10px;font-size:12px;color:#959694;text-align:right}.EasyMDEContainer.sided--no-fullscreen .editor-statusbar{width:100%}.editor-statusbar span{display:inline-block;min-width:4em;margin-left:1em}.editor-statusbar .lines:before{content:'lines: '}.editor-statusbar .words:before{content:'words: '}.editor-statusbar .characters:before{content:'characters: '}.editor-preview-full{position:absolute;width:100%;height:100%;top:0;left:0;z-index:7;overflow:auto;display:none;box-sizing:border-box}.editor-preview-side{position:fixed;bottom:0;width:50%;top:50px;right:0;z-index:9;overflow:auto;display:none;box-sizing:border-box;border:1px solid #ddd;word-wrap:break-word}.editor-preview-active-side{display:block}.EasyMDEContainer.sided--no-fullscreen .editor-preview-active-side{flex:1 1 auto;height:auto;position:static}.editor-preview-active{display:block}.editor-preview{padding:10px;background:#fafafa}.editor-preview>p{margin-top:0}.editor-preview pre{background:#eee;margin-bottom:10px}.editor-preview table td,.editor-preview table th{border:1px solid #ddd;padding:5px}.cm-s-easymde .cm-tag{color:#63a35c}.cm-s-easymde .cm-attribute{color:#795da3}.cm-s-easymde .cm-string{color:#183691}.cm-s-easymde .cm-header-1{font-size:200%;line-height:200%}.cm-s-easymde .cm-header-2{font-size:160%;line-height:160%}.cm-s-easymde .cm-header-3{font-size:125%;line-height:125%}.cm-s-easymde .cm-header-4{font-size:110%;line-height:110%}.cm-s-easymde .cm-comment{background:rgba(0,0,0,.05);border-radius:2px}.cm-s-easymde .cm-link{color:#7f8c8d}.cm-s-easymde .cm-url{color:#aab2b3}.cm-s-easymde .cm-quote{color:#7f8c8d;font-style:italic}.editor-toolbar .easymde-dropdown{position:relative;background:linear-gradient(to bottom right,#fff 0,#fff 84%,#333 50%,#333 100%);border-radius:0;border:1px solid #fff}.editor-toolbar .easymde-dropdown:hover{background:linear-gradient(to bottom right,#fff 0,#fff 84%,#333 50%,#333 100%)}.easymde-dropdown-content{display:block;visibility:hidden;position:absolute;background-color:#f9f9f9;box-shadow:0 8px 16px 0 rgba(0,0,0,.2);padding:8px;z-index:2;top:30px}.easymde-dropdown:active .easymde-dropdown-content,.easymde-dropdown:focus .easymde-dropdown-content{visibility:visible}span[data-img-src]::after{content:'';background-image:var(--bg-image);display:block;max-height:100%;max-width:100%;background-size:contain;height:0;padding-top:var(--height);width:var(--width);background-repeat:no-repeat}.CodeMirror .cm-spell-error:not(.cm-url):not(.cm-comment):not(.cm-tag):not(.cm-word){background:rgba(255,0,0,.15)} \ No newline at end of file diff --git a/PSC.Blazor.Components.MarkdownEditor/wwwroot/easymde/CHANGELOG.md b/PSC.Blazor.Components.MarkdownEditor/wwwroot/easymde/CHANGELOG.md new file mode 100644 index 0000000..85ef777 --- /dev/null +++ b/PSC.Blazor.Components.MarkdownEditor/wwwroot/easymde/CHANGELOG.md @@ -0,0 +1,339 @@ +# EasyMDE Changelog +All notable changes to easymde will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +[comment]: <> (## [Unreleased]) +## [2.15.0] - 2021-04-22 +### Added +- `imagePathAbsolute` option to return the absolute path when uploading an image (Thanks to [@wwsalmon], [#313]). + +### Fixed +- `ToolbarIcon` typings, added `icon` (Thanks to [@ChronosMasterOfAllTime], [#308]). +- Image link extension when it was not the last part of the URL (Thanks to [@deerboy], [#311]). +- Preview mode did not stay enabled when toggling to fullscreen (Thanks to [@smundro], [#316]). +- Required typings not being included in `dependencies` (Thanks to [@marekdedic], [#322]). + +## [2.14.0] - 2021-02-14 +### Added +- The `scrollbarStyle` option to change the style of the scrollbar (Thanks to [@danice], [#250]). + +### Fixed +- Issues with images not displaying correctly in the preview screen (Thanks to [@ivictbor], [#253]). +- An error when both `sideBySideFullscreen` and `status` were set to `false` (Thanks to [@joahim], [#272]). +- Editor trying to display non-image files (Thanks to [@Juupaa], [#277]) +- Unneeded call to `window.removeEventListener` (Thanks to [@emirotin], [#280]) +- Spell checker (Thanks to [@Fanvadar], [#284]). +- Focus issues with toolbar dropdown menus (Thanks to [@Situphen], [#285]). +- Interaction between the `sideBySideFullscreen` and the preview state (Thanks to [@smundro], [#286]) +- Refactored strange method of padding the toolbar into regular padding (Thanks to [@sn3p], [#293]). +- Security issue in `marked` dependency (Thanks to [@dependabot], [#298]). + +## [2.13.0] - 2020-11-11 +### Added +- CodeMirror autorefresh plugin and autoRefresh option (Thanks to [@mbolli], [#249]). +- `lineNumbers` option to display line numbers in the editor (Thanks to [@nhymxu], [#267]). + +### Fixed +- CSS scoping issues when the editor is used in combination with other CodeMirror instances ([#252]). + +## [2.12.1] - 2020-10-06 +### Changed +- Set `previewImagesInEditor` option to `false` by default ([#251]). + +## [2.12.0] - 2020-09-29 +### Added +- `this` context in imageUploadFunction (Thanks to [@JoshuaLicense], [#225]). +- `previewImagesInEditor` option to display images in editor mode (Thanks to [@ivictbor], [#235]). +- `overlayMode` options to supply an additional codemirror mode (Thanks to [@czynskee], [#244]). + +### Fixed +- Corrected default size units from `b,Kb,Mb` to ` B, KB, MB` ([#239]). +- Max height less than min height (Thanks to [@nick-denry], [#222]). +- toTextArea issue (Thanks to [@nick-denry], [#223]). +- Error when updateStatusBar was called during image upload, but the status bar is disabled (Thanks to [@JoshuaLicense], [#224]). + +## [2.11.0] - 2020-07-16 +### Added +- Support for Node.js 14. +- Preview without fullscreen (Thanks to [@nick-denry], [#196]). + +### Fixed +- Fix cursor displayed position on activity (Thanks to [@firm1], [#184]). +- Checkboxes always have bullets in front of them ([#136]). +- Save the text only when modifying the content of the easymde instance (Thanks to [@firm1], [#181]). + +## [2.10.1] - 2020-04-06 +### Fixed +- Typescript error when entering certain strings for toolbar buttons ([#178]). + +## [2.10.0] - 2020-04-02 +### Added +- `inputStyle` and `nativeSpellcheck` options to manage the native language of the browser (Thanks to [@firm1], [#143]). +- Group buttons in drop-down lists by adding a sub-option `children` for the items in the toolbar (Thanks to [@firm1], [#141]). +- `sanitizerFunction` option to allow custom HTML sanitizing in the markdown preview (Thanks to [@adamb70], [#147]). +- Time formatting and custom text options for the autosave message (Thanks to [@dima-bzz], [#170]). +### Changed +- Delay before assuming that submit of the form as failed is `autosave.submit_delay` instead of `autosave.delay` (Thanks to [@Situphen], [#139]). +- Add `watch` task for gulp (Thanks to [@A-312], [#150]). +### Fixed +- Issue with Marked when using IE11 and webpack (Thanks to [@felipefdl], [#169]). +- Updated codemirror to version 5.52.2 (Thanks to [@A-312], [#173]). +- Editor displaying on top of other elements on a webpage (Thanks to [@StefKors], [#175]). + +## [2.9.0] - 2020-01-13 +### Added +- Missing minHeight option in type definition (Thanks to [@t49tran], [#123]). +- Other missing type definitions ([#126]). + +### Changed +- The editor will remove its saved contents when the editor is emptied, allowing to reload a default value (Thanks to [@Situphen], [#132]). + +## [2.8.0] - 2019-08-20 +### Added +- Upload images functionality (Thanks to [@roipoussiere] and [@JeroenvO], [#71], [#101]). +- Allow custom image upload function (Thanks to [@sperezp], [#106]). +- More polish to the upload images functionality (Thanks to [@jfly], [#109]). +- Improved React compatibility (Thanks to [@richtera], [#97]). + +### Fixed +- Missing link in dist file header. + +## [2.7.0] - 2019-07-13 +### Added +- `previewClass` option for overwriting the preview screen class ([#99]). + +### Fixed +- Updated dependencies to resolve potential security issue. +- Resolved small code style issues shown by new eslint rules. + +## [2.6.1] - 2019-06-17 +### Fixed +- Error when toggling between ordered and unordered lists (Thanks to [@roryok], [#93]). +- Keyboard shortcuts for custom actions not working (Thanks to [@ysykzheng], [#75]). + +## [2.6.0] - 2019-04-15 +### Added +- Contributing guide (Thanks to [@roipoussiere], [#54]). +- Issue templates. +- Standardized changelog file. + +### Changed +- Finish rewrite of README (Thanks to [@roipoussiere], [#54]). +- Image and link prompt fill with "https://" by default. +- Link to markdown guide to . + +### Fixed +- Backwards compatibility in the API with SimpleMDE 1.0.0 ([#41]). +- Automatic publish of master branch to `@next` + +### Removed +- Distribution files from source-control. + +## [2.5.1] - 2019-01-17 +### Fixed +- `role="button"` needed to be `type="button"` ([#45]). + +## [2.5.0] - 2019-01-17 +### Added +- Typescript support (Thanks to [@FranklinWhale], [#44]). +- `role="button"` to toolbar buttons ([#38]). + +### Fixed +- Eraser icon not working with FontAwesome 5. + +## [2.4.2] - 2018-11-09 +### Added +- Node.js 11 support. + +### Fixed +- Header button icons not showing sub-icons with FontAwesome 5. +- Inconsistent autosave behaviour when submitting a form (Thanks to [@Furgas] and [@adamb70], [#31]). + +## [2.4.1] - 2018-10-15 +### Added +- `fa-redo` class to redo button for FA5 compatibility (Thanks to [@Summon528], [#27]). + +## [2.4.0] - 2018-10-15 +### Added +- Theming support (Thanks to [@LeviticusMB], [#17]). +- onToggleFullscreen event hook (Thanks to [@n-3-0], [#16]). + +### Fixed +- Fullscreen not working with `toolbar: false` (Thanks to [@aphitiel], [#19]). + +## [2.2.2] - 2019-07-03 +### Fixed +- Automatic publish only publishing tags. + +## [2.2.1] - 2019-06-29 +### Changed +- Attempt automatic publish `@next` version on npm. +- Links in the preview window will open in a new tab by default. + +### Fixed +- Multi-text select issue by disabling multi-select in the editor ([#10]). +- `main` file in package.json (Thanks to [@sne11ius], [#11]). + +## [2.0.1] - 2018-05-13 +### Changed +- Rewrote part of the documentation for EasyMDE. +- Updated gulp to version 4.0.0. + +### Fixed +- Icons for `heading-smaller`, `heading-bigger`, `heading-1`, `heading-2` and `heading-3` not showing ([#9]). + +## [2.0.0] - 2018-04-23 +Project forked from [SimpleMDE](https://github.com/sparksuite/simplemde-markdown-editor) + +### BREAKING CHANGES +- Dropped Bower support. +- Dropped support for older Node.js versions. + +### Added +- FontAwesome 5 support. +- Support for newer Node.js versions. + +### Changed +- Packages are now version-locked. +- Simplified build script. +- Markdown guide button is no longer disabled in preview mode. + +### Fixed +- Cursor not always showing in "text" mode over the edit field + + +[#252]: https://github.com/Ionaru/easy-markdown-editor/issues/252 +[#251]: https://github.com/Ionaru/easy-markdown-editor/issues/251 +[#239]: https://github.com/Ionaru/easy-markdown-editor/issues/239 +[#178]: https://github.com/Ionaru/easy-markdown-editor/issues/178 +[#136]: https://github.com/Ionaru/easy-markdown-editor/issues/136 +[#126]: https://github.com/Ionaru/easy-markdown-editor/issues/126 +[#99]: https://github.com/Ionaru/easy-markdown-editor/issues/99 +[#45]: https://github.com/Ionaru/easy-markdown-editor/issues/45 +[#44]: https://github.com/Ionaru/easy-markdown-editor/issues/44 +[#41]: https://github.com/Ionaru/easy-markdown-editor/issues/41 +[#38]: https://github.com/Ionaru/easy-markdown-editor/issues/38 +[#17]: https://github.com/Ionaru/easy-markdown-editor/issues/17 +[#16]: https://github.com/Ionaru/easy-markdown-editor/issues/16 +[#11]: https://github.com/Ionaru/easy-markdown-editor/issues/11 +[#10]: https://github.com/Ionaru/easy-markdown-editor/issues/10 +[#9]: https://github.com/Ionaru/easy-markdown-editor/issues/9 + + +[#322]: https://github.com/Ionaru/easy-markdown-editor/pull/322 +[#316]: https://github.com/Ionaru/easy-markdown-editor/pull/316 +[#313]: https://github.com/Ionaru/easy-markdown-editor/pull/313 +[#311]: https://github.com/Ionaru/easy-markdown-editor/pull/311 +[#308]: https://github.com/Ionaru/easy-markdown-editor/pull/308 +[#298]: https://github.com/Ionaru/easy-markdown-editor/pull/298 +[#293]: https://github.com/Ionaru/easy-markdown-editor/pull/293 +[#286]: https://github.com/Ionaru/easy-markdown-editor/pull/286 +[#285]: https://github.com/Ionaru/easy-markdown-editor/pull/285 +[#284]: https://github.com/Ionaru/easy-markdown-editor/pull/284 +[#280]: https://github.com/Ionaru/easy-markdown-editor/pull/280 +[#277]: https://github.com/Ionaru/easy-markdown-editor/pull/277 +[#272]: https://github.com/Ionaru/easy-markdown-editor/pull/272 +[#267]: https://github.com/Ionaru/easy-markdown-editor/pull/267 +[#253]: https://github.com/Ionaru/easy-markdown-editor/pull/253 +[#250]: https://github.com/Ionaru/easy-markdown-editor/pull/250 +[#249]: https://github.com/Ionaru/easy-markdown-editor/pull/249 +[#244]: https://github.com/Ionaru/easy-markdown-editor/pull/244 +[#235]: https://github.com/Ionaru/easy-markdown-editor/pull/235 +[#225]: https://github.com/Ionaru/easy-markdown-editor/pull/225 +[#224]: https://github.com/Ionaru/easy-markdown-editor/pull/224 +[#223]: https://github.com/Ionaru/easy-markdown-editor/pull/223 +[#222]: https://github.com/Ionaru/easy-markdown-editor/pull/222 +[#196]: https://github.com/Ionaru/easy-markdown-editor/pull/196 +[#184]: https://github.com/Ionaru/easy-markdown-editor/pull/184 +[#181]: https://github.com/Ionaru/easy-markdown-editor/pull/181 +[#175]: https://github.com/Ionaru/easy-markdown-editor/pull/175 +[#173]: https://github.com/Ionaru/easy-markdown-editor/pull/173 +[#170]: https://github.com/Ionaru/easy-markdown-editor/pull/170 +[#169]: https://github.com/Ionaru/easy-markdown-editor/pull/169 +[#150]: https://github.com/Ionaru/easy-markdown-editor/pull/150 +[#147]: https://github.com/Ionaru/easy-markdown-editor/pull/147 +[#143]: https://github.com/Ionaru/easy-markdown-editor/pull/143 +[#141]: https://github.com/Ionaru/easy-markdown-editor/pull/141 +[#139]: https://github.com/Ionaru/easy-markdown-editor/pull/139 +[#132]: https://github.com/Ionaru/easy-markdown-editor/pull/132 +[#123]: https://github.com/Ionaru/easy-markdown-editor/pull/123 +[#109]: https://github.com/Ionaru/easy-markdown-editor/pull/109 +[#106]: https://github.com/Ionaru/easy-markdown-editor/pull/106 +[#101]: https://github.com/Ionaru/easy-markdown-editor/pull/101 +[#97]: https://github.com/Ionaru/easy-markdown-editor/pull/97 +[#93]: https://github.com/Ionaru/easy-markdown-editor/pull/93 +[#75]: https://github.com/Ionaru/easy-markdown-editor/pull/75 +[#71]: https://github.com/Ionaru/easy-markdown-editor/pull/71 +[#54]: https://github.com/Ionaru/easy-markdown-editor/pull/54 +[#31]: https://github.com/Ionaru/easy-markdown-editor/pull/31 +[#27]: https://github.com/Ionaru/easy-markdown-editor/pull/27 +[#19]: https://github.com/Ionaru/easy-markdown-editor/pull/19 + + +[@dependabot]: https://github.com/dependabot +[@wwsalmon]: https://github.com/wwsalmon +[@ChronosMasterOfAllTime]: https://github.com/ChronosMasterOfAllTime +[@deerboy]: https://github.com/deerboy +[@marekdedic]: https://github.com/marekdedic +[@emirotin]: https://github.com/emirotin +[@smundro]: https://github.com/smundro +[@Juupaa]: https://github.com/Juupaa +[@Fanvadar]: https://github.com/Fanvadar +[@danice]: https://github.com/danice +[@joahim]: https://github.com/joahim +[@nhymxu]: https://github.com/nhymxu +[@mbolli]: https://github.com/mbolli +[@ivictbor]: https://github.com/ivictbor +[@JoshuaLicense]: https://github.com/JoshuaLicense +[@czynskee]: https://github.com/czynskee +[@nick-denry]: https://github.com/nick-denry +[@StefKors]: https://github.com/StefKors +[@felipefdl]: https://github.com/felipefdl +[@A-312]: https://github.com/A-312 +[@dima-bzz]: https://github.com/dima-bzz +[@firm1]: https://github.com/firm1 +[@Situphen]: https://github.com/Situphen +[@t49tran]: https://github.com/t49tran +[@richtera]: https://github.com/richtera +[@jfly]: https://github.com/jfly +[@sperezp]: https://github.com/sperezp +[@JeroenvO]: https://github.com/JeroenvO +[@sn3p]: https://github.com/sn3p +[@roryok]: https://github.com/roryok +[@ysykzheng]: https://github.com/ysykzheng +[@roipoussiere]: https://github.com/roipoussiere +[@FranklinWhale]: https://github.com/FranklinWhale +[@Furgas]: https://github.com/Furgas +[@adamb70]: https://github.com/adamb70 +[@Summon528]: https://github.com/Summon528 +[@LeviticusMB]: https://github.com/LeviticusMB +[@n-3-0]: https://github.com/n-3-0 +[@aphitiel]: https://github.com/aphitiel +[@sne11ius]: https://github.com/sne11ius + + +[Unreleased]: https://github.com/Ionaru/easy-markdown-editor/compare/2.15.0...HEAD +[2.15.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.14.0...2.15.0 +[2.14.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.13.0...2.14.0 +[2.13.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.12.1...2.13.0 +[2.12.1]: https://github.com/Ionaru/easy-markdown-editor/compare/2.12.0...2.12.1 +[2.12.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.11.0...2.12.0 +[2.11.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.10.1...2.11.0 +[2.10.1]: https://github.com/Ionaru/easy-markdown-editor/compare/2.10.0...2.10.1 +[2.10.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.9.0...2.10.0 +[2.9.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.8.0...2.9.0 +[2.8.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.7.0...2.8.0 +[2.7.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.6.1...2.7.0 +[2.6.1]: https://github.com/Ionaru/easy-markdown-editor/compare/2.6.0...2.6.1 +[2.6.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.5.1...2.6.0 +[2.5.1]: https://github.com/Ionaru/easy-markdown-editor/compare/2.5.0...2.5.1 +[2.5.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.4.2...2.5.0 +[2.4.2]: https://github.com/Ionaru/easy-markdown-editor/compare/2.4.1...2.4.2 +[2.4.1]: https://github.com/Ionaru/easy-markdown-editor/compare/2.4.0...2.4.1 +[2.4.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.2.2...2.4.0 +[2.2.2]: https://github.com/Ionaru/easy-markdown-editor/compare/2.2.1...2.2.2 +[2.2.1]: https://github.com/Ionaru/easy-markdown-editor/compare/2.0.1...2.2.1 +[2.0.1]: https://github.com/Ionaru/easy-markdown-editor/compare/2.0.0...2.0.1 +[2.0.0]: https://github.com/Ionaru/easy-markdown-editor/compare/1.11.2...2.0.0 diff --git a/PSC.Blazor.Components.MarkdownEditor/wwwroot/easymde/LICENSE b/PSC.Blazor.Components.MarkdownEditor/wwwroot/easymde/LICENSE new file mode 100644 index 0000000..da66b5a --- /dev/null +++ b/PSC.Blazor.Components.MarkdownEditor/wwwroot/easymde/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2015 Sparksuite, Inc. +Copyright (c) 2017 Jeroen Akkerman. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/PSC.Blazor.Components.MarkdownEditor/wwwroot/easymde/README.md b/PSC.Blazor.Components.MarkdownEditor/wwwroot/easymde/README.md new file mode 100644 index 0000000..f418fd5 --- /dev/null +++ b/PSC.Blazor.Components.MarkdownEditor/wwwroot/easymde/README.md @@ -0,0 +1,546 @@ +# EasyMDE - Markdown Editor + +[![npm version](https://img.shields.io/npm/v/easymde.svg?style=for-the-badge)](https://www.npmjs.com/package/easymde) +[![npm version](https://img.shields.io/npm/v/easymde/next.svg?style=for-the-badge)](https://www.npmjs.com/package/easymde/v/next) +[![Build Status](https://img.shields.io/travis/Ionaru/easy-markdown-editor/master.svg?style=for-the-badge)](https://travis-ci.org/Ionaru/easy-markdown-editor) + +> This repository is a fork of +[SimpleMDE, made by Sparksuite](https://github.com/sparksuite/simplemde-markdown-editor/). +Go to the [dedicated section](#simplemde-fork) for more information. + +A drop-in JavaScript text area replacement for writing beautiful and understandable Markdown. +EasyMDE allows users who may be less experienced with Markdown to use familiar toolbar buttons and shortcuts. + +In addition, the syntax is rendered while editing to clearly show the expected result. Headings are larger, emphasized words are italicized, links are underlined, etc. + +EasyMDE also features both built-in auto saving and spell checking. +The editor is entirely customizable, from theming to toolbar buttons and javascript hooks. + +[**Try the demo**](https://easy-markdown-editor.tk/) + +[![Preview](https://user-images.githubusercontent.com/3472373/51319377-26fe6e00-1a5d-11e9-8cc6-3137a566796d.png)](https://easy-markdown-editor.tk/) + + +## Quick access + +- [EasyMDE - Markdown Editor](#easymde---markdown-editor) + - [Quick access](#quick-access) + - [Install EasyMDE](#install-easymde) + - [How to use](#how-to-use) + - [Loading the editor](#loading-the-editor) + - [Editor functions](#editor-functions) + - [Configuration](#configuration) + - [Options list](#options-list) + - [Options example](#options-example) + - [Toolbar icons](#toolbar-icons) + - [Toolbar customization](#toolbar-customization) + - [Keyboard shortcuts](#keyboard-shortcuts) + - [Advanced use](#advanced-use) + - [Event handling](#event-handling) + - [Removing EasyMDE from text area](#removing-easymde-from-text-area) + - [Useful methods](#useful-methods) + - [How it works](#how-it-works) + - [SimpleMDE fork](#simplemde-fork) + - [Hacking EasyMDE](#hacking-easymde) + - [Contributing](#contributing) + - [License](#license) + + +## Install EasyMDE + +Via [npm](https://www.npmjs.com/package/easymde): + +``` +npm install easymde --save +``` + +Via the *UNPKG* CDN: + +```html + + +``` + + +## How to use + +### Loading the editor + +After installing and/or importing the module, you can load EasyMDE onto the first TextArea on the web page: + +```html + + +``` + +Alternatively you can select a specific TextArea, via Javascript: + +```html + + +``` + +Or via jQuery: + +```html + + +``` + + +### Editor functions + +Use EasyMDE.value() to get the content of the editor: + +```html + +``` + +Use EasyMDE.value(val) to set the content of the editor: + +```html + +``` + + +## Configuration + +### Options list + +- **autoDownloadFontAwesome**: If set to `true`, force downloads Font Awesome (used for icons). If set to `false`, prevents downloading. Defaults to `undefined`, which will intelligently check whether Font Awesome has already been included, then download accordingly. +- **autofocus**: If set to `true`, focuses the editor automatically. Defaults to `false`. +- **autosave**: *Saves the text that's being written and will load it back in the future. It will forget the text when the form it's contained in is submitted.* + - **enabled**: If set to `true`, saves the text automatically. Defaults to `false`. + - **delay**: Delay between saves, in milliseconds. Defaults to `10000` (10s). + - **submit_delay**: Delay before assuming that submit of the form failed and saving the text, in milliseconds. Defaults to `autosave.delay` or `10000` (10s). + - **uniqueId**: You must set a unique string identifier so that EasyMDE can autosave. Something that separates this from other instances of EasyMDE elsewhere on your website. + - **timeFormat**: Set DateTimeFormat. More information see [DateTimeFormat instances](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat). Default `locale: en-US, format: hour:minute`. + - **text**: Set text for autosave. +- **autoRefresh**: Useful, when initializing the editor in a hidden DOM node. If set to `{ delay: 300 }`, it will check every 300 ms if the editor is visible and if positive, call CodeMirror's [`refresh()`](https://codemirror.net/doc/manual.html#refresh). +- **blockStyles**: Customize how certain buttons that style blocks of text behave. + - **bold**: Can be set to `**` or `__`. Defaults to `**`. + - **code**: Can be set to ```` ``` ```` or `~~~`. Defaults to ```` ``` ````. + - **italic**: Can be set to `*` or `_`. Defaults to `*`. +- **scrollbarStyle**: Chooses a scrollbar implementation. The default is "native", showing native scrollbars. The core library also provides the "null" style, which completely hides the scrollbars. Addons can implement additional scrollbar models. +- **element**: The DOM element for the TextArea to use. Defaults to the first TextArea on the page. +- **forceSync**: If set to `true`, force text changes made in EasyMDE to be immediately stored in original text area. Defaults to `false`. +- **hideIcons**: An array of icon names to hide. Can be used to hide specific icons shown by default without completely customizing the toolbar. +- **indentWithTabs**: If set to `false`, indent using spaces instead of tabs. Defaults to `true`. +- **initialValue**: If set, will customize the initial value of the editor. +- **previewImagesInEditor**: - EasyMDE will show preview of images, `false` by default, preview for images will appear only for images on separate lines. +- **insertTexts**: Customize how certain buttons that insert text behave. Takes an array with two elements. The first element will be the text inserted before the cursor or highlight, and the second element will be inserted after. For example, this is the default link value: `["[", "](http://)"]`. + - horizontalRule + - image + - link + - table +- **lineNumbers**: If set to `true`, enables line numbers in the editor. +- **lineWrapping**: If set to `false`, disable line wrapping. Defaults to `true`. +- **minHeight**: Sets the minimum height for the composition area, before it starts auto-growing. Should be a string containing a valid CSS value like `"500px"`. Defaults to `"300px"`. +- **maxHeight**: Sets fixed height for the composition area. `minHeight` option will be ignored. Should be a string containing a valid CSS value like `"500px"`. Defaults to `undefined`. +- **onToggleFullScreen**: A function that gets called when the editor's full screen mode is toggled. The function will be passed a boolean as parameter, `true` when the editor is currently going into full screen mode, or `false`. +- **parsingConfig**: Adjust settings for parsing the Markdown during editing (not previewing). + - **allowAtxHeaderWithoutSpace**: If set to `true`, will render headers without a space after the `#`. Defaults to `false`. + - **strikethrough**: If set to `false`, will not process GFM strikethrough syntax. Defaults to `true`. + - **underscoresBreakWords**: If set to `true`, let underscores be a delimiter for separating words. Defaults to `false`. +- **overlayMode**: Pass a custom codemirror [overlay mode](https://codemirror.net/doc/manual.html#modeapi) to parse and style the Markdown during editing. + - **mode**: A codemirror mode object. + - **combine**: If set to `false`, will *replace* CSS classes returned by the default Markdown mode. Otherwise the classes returned by the custom mode will be combined with the classes returned by the default mode. Defaults to `true`. +- **placeholder**: If set, displays a custom placeholder message. +- **previewClass**: A string or array of strings that will be applied to the preview screen when activated. Defaults to `"editor-preview"`. +- **previewRender**: Custom function for parsing the plaintext Markdown and returning HTML. Used when user previews. +- **promptURLs**: If set to `true`, a JS alert window appears asking for the link or image URL. Defaults to `false`. +- **promptTexts**: Customize the text used to prompt for URLs. + - **image**: The text to use when prompting for an image's URL. Defaults to `URL of the image:`. + - **link**: The text to use when prompting for a link's URL. Defaults to `URL for the link:`. +- **uploadImage**: If set to `true`, enables the image upload functionality, which can be triggered by drag&drop, copy-paste and through the browse-file window (opened when the user click on the *upload-image* icon). Defaults to `false`. +- **imageMaxSize**: Maximum image size in bytes, checked before upload (note: never trust client, always check image size at server-side). Defaults to `1024*1024*2` (2Mb). +- **imageAccept**: A comma-separated list of mime-types used to check image type before upload (note: never trust client, always check file types at server-side). Defaults to `image/png, image/jpeg`. +- **imageUploadFunction**: A custom function for handling the image upload. Using this function will render the options `imageMaxSize`, `imageAccept`, `imageUploadEndpoint` and `imageCSRFToken` ineffective. + - The function gets a file and onSuccess and onError callback functions as parameters. `onSuccess(imageUrl: string)` and `onError(errorMessage: string)` +- **imageUploadEndpoint**: The endpoint where the images data will be sent, via an asynchronous *POST* request. The server is supposed to save this image, and return a json response. + - if the request was successfully processed (HTTP 200-OK): `{"data": {"filePath": ""}}` where *filePath* is the path of the image (absolute if `imagePathAbsolute` is set to true, relative if otherwise); + - otherwise: `{"error": ""}`, where *errorCode* can be `noFileGiven` (HTTP 400), `typeNotAllowed` (HTTP 415), `fileTooLarge` (HTTP 413) or `importError` (see *errorMessages* below). If *errorCode* is not one of the *errorMessages*, it is alerted unchanged to the user. This allows for server side error messages. + No default value. +- **imagePathAbsolute**: If set to `true`, will treat `imageUrl` from `imageUploadFunction` and *filePath* returned from `imageUploadEndpoint` as an absolute rather than relative path, i.e. not prepend `window.location.origin` to it. +- **imageCSRFToken**: CSRF token to include with AJAX call to upload image. For instance used with Django backend. +- **imageTexts**: Texts displayed to the user (mainly on the status bar) for the import image feature, where `#image_name#`, `#image_size#` and `#image_max_size#` will replaced by their respective values, that can be used for customization or internationalization: + - **sbInit**: Status message displayed initially if `uploadImage` is set to `true`. Defaults to `Attach files by drag and dropping or pasting from clipboard.`. + - **sbOnDragEnter**: Status message displayed when the user drags a file to the text area. Defaults to `Drop image to upload it.`. + - **sbOnDrop**: Status message displayed when the user drops a file in the text area. Defaults to `Uploading images #images_names#`. + - **sbProgress**: Status message displayed to show uploading progress. Defaults to `Uploading #file_name#: #progress#%`. + - **sbOnUploaded**: Status message displayed when the image has been uploaded. Defaults to `Uploaded #image_name#`. + - **sizeUnits**: A comma-separated list of units used to display messages with human-readable file sizes. Defaults to ` B, KB, MB` (example: `218 KB`). You can use `B,KB,MB` instead if you prefer without whitespaces (`218KB`). +- **errorMessages**: Errors displayed to the user, using the `errorCallback` option, where `#image_name#`, `#image_size#` and `#image_max_size#` will replaced by their respective values, that can be used for customization or internationalization: + - **noFileGiven**: The server did not receive any file from the user. Defaults to `You must select a file.`. + - **typeNotAllowed**: The user send a file type which doesn't match the `imageAccept` list, or the server returned this error code. Defaults to `This image type is not allowed.`. + - **fileTooLarge**: The size of the image being imported is bigger than the `imageMaxSize`, or if the server returned this error code. Defaults to `Image #image_name# is too big (#image_size#).\nMaximum file size is #image_max_size#.`. + - **importError**: An unexpected error occurred when uploading the image. Defaults to `Something went wrong when uploading the image #image_name#.`. +- **errorCallback**: A callback function used to define how to display an error message. Defaults to `function(errorMessage) {alert(errorMessage);};`. +- **renderingConfig**: Adjust settings for parsing the Markdown during previewing (not editing). + - **codeSyntaxHighlighting**: If set to `true`, will highlight using [highlight.js](https://github.com/isagalaev/highlight.js). Defaults to `false`. To use this feature you must include highlight.js on your page or pass in using the `hljs` option. For example, include the script and the CSS files like:
``
`` + - **hljs**: An injectible instance of [highlight.js](https://github.com/isagalaev/highlight.js). If you don't want to rely on the global namespace (`window.hljs`), you can provide an instance here. Defaults to `undefined`. + - **markedOptions**: Set the internal Markdown renderer's [options](https://marked.js.org/#/USING_ADVANCED.md#options). Other `renderingConfig` options will take precedence. + - **singleLineBreaks**: If set to `false`, disable parsing GFM single line breaks. Defaults to `true`. + - **sanitizerFunction**: Custom function for sanitizing the HTML output of markdown renderer. +- **shortcuts**: Keyboard shortcuts associated with this instance. Defaults to the [array of shortcuts](#keyboard-shortcuts). +- **showIcons**: An array of icon names to show. Can be used to show specific icons hidden by default without completely customizing the toolbar. +- **spellChecker**: If set to `false`, disable the spell checker. Defaults to `true`. +- **inputStyle**: `textarea` or `contenteditable`. Defaults to `textarea` for desktop and `contenteditable` for mobile. `contenteditable` option is necessary to enable nativeSpellcheck. +- **nativeSpellcheck**: If set to `false`, disable native spell checker. Defaults to `true`. +- **sideBySideFullscreen**: If set to `false`, allows side-by-side editing without going into fullscreen. Defaults to `true`. +- **status**: If set to `false`, hide the status bar. Defaults to the array of built-in status bar items. + - Optionally, you can set an array of status bar items to include, and in what order. You can even define your own custom status bar items. +- **styleSelectedText**: If set to `false`, remove the `CodeMirror-selectedtext` class from selected lines. Defaults to `true`. +- **syncSideBySidePreviewScroll**: If set to `false`, disable syncing scroll in side by side mode. Defaults to `true`. +- **tabSize**: If set, customize the tab size. Defaults to `2`. +- **theme**: Override the theme. Defaults to `easymde`. +- **toolbar**: If set to `false`, hide the toolbar. Defaults to the [array of icons](#toolbar-icons). +- **toolbarTips**: If set to `false`, disable toolbar button tips. Defaults to `true`. + + +### Options example + +Most options demonstrate the non-default behavior: + +```JavaScript +var editor = new EasyMDE({ + autofocus: true, + autosave: { + enabled: true, + uniqueId: "MyUniqueID", + delay: 1000, + submit_delay: 5000, + timeFormat: { + locale: 'en-US', + format: { + year: 'numeric', + month: 'long', + day: '2-digit', + hour: '2-digit', + minute: '2-digit', + }, + }, + text: "Autosaved: " + }, + blockStyles: { + bold: "__", + italic: "_", + }, + element: document.getElementById("MyID"), + forceSync: true, + hideIcons: ["guide", "heading"], + indentWithTabs: false, + initialValue: "Hello world!", + insertTexts: { + horizontalRule: ["", "\n\n-----\n\n"], + image: ["![](http://", ")"], + link: ["[", "](http://)"], + table: ["", "\n\n| Column 1 | Column 2 | Column 3 |\n| -------- | -------- | -------- |\n| Text | Text | Text |\n\n"], + }, + lineWrapping: false, + minHeight: "500px", + parsingConfig: { + allowAtxHeaderWithoutSpace: true, + strikethrough: false, + underscoresBreakWords: true, + }, + placeholder: "Type here...", + + previewClass: "my-custom-styling", + previewClass: ["my-custom-styling", "more-custom-styling"], + + previewRender: function(plainText) { + return customMarkdownParser(plainText); // Returns HTML from a custom parser + }, + previewRender: function(plainText, preview) { // Async method + setTimeout(function(){ + preview.innerHTML = customMarkdownParser(plainText); + }, 250); + + return "Loading..."; + }, + promptURLs: true, + promptTexts: { + image: "Custom prompt for URL:", + link: "Custom prompt for URL:", + }, + renderingConfig: { + singleLineBreaks: false, + codeSyntaxHighlighting: true, + sanitizerFunction: function(renderedHTML) { + // Using DOMPurify and only allowing tags + return DOMPurify.sanitize(renderedHTML, {ALLOWED_TAGS: ['b']}) + }, + }, + shortcuts: { + drawTable: "Cmd-Alt-T" + }, + showIcons: ["code", "table"], + spellChecker: false, + status: false, + status: ["autosave", "lines", "words", "cursor"], // Optional usage + status: ["autosave", "lines", "words", "cursor", { + className: "keystrokes", + defaultValue: function(el) { + this.keystrokes = 0; + el.innerHTML = "0 Keystrokes"; + }, + onUpdate: function(el) { + el.innerHTML = ++this.keystrokes + " Keystrokes"; + }, + }], // Another optional usage, with a custom status bar item that counts keystrokes + styleSelectedText: false, + sideBySideFullscreen: false, + syncSideBySidePreviewScroll: false, + tabSize: 4, + toolbar: false, + toolbarTips: false, +}); +``` + + +### Toolbar icons + +Below are the built-in toolbar icons (only some of which are enabled by default), which can be reorganized however you like. "Name" is the name of the icon, referenced in the JS. "Action" is either a function or a URL to open. "Class" is the class given to the icon. "Tooltip" is the small tooltip that appears via the `title=""` attribute. Note that shortcut hints are added automatically and reflect the specified action if it has a key bind assigned to it (i.e. with the value of `action` set to `bold` and that of `tooltip` set to `Bold`, the final text the user will see would be "Bold (Ctrl-B)"). + +Additionally, you can add a separator between any icons by adding `"|"` to the toolbar array. + +Name | Action | Tooltip
Class +:--- | :----- | :-------------- +bold | toggleBold | Bold
fa fa-bold +italic | toggleItalic | Italic
fa fa-italic +strikethrough | toggleStrikethrough | Strikethrough
fa fa-strikethrough +heading | toggleHeadingSmaller | Heading
fa fa-header +heading-smaller | toggleHeadingSmaller | Smaller Heading
fa fa-header +heading-bigger | toggleHeadingBigger | Bigger Heading
fa fa-lg fa-header +heading-1 | toggleHeading1 | Big Heading
fa fa-header header-1 +heading-2 | toggleHeading2 | Medium Heading
fa fa-header header-2 +heading-3 | toggleHeading3 | Small Heading
fa fa-header header-3 +code | toggleCodeBlock | Code
fa fa-code +quote | toggleBlockquote | Quote
fa fa-quote-left +unordered-list | toggleUnorderedList | Generic List
fa fa-list-ul +ordered-list | toggleOrderedList | Numbered List
fa fa-list-ol +clean-block | cleanBlock | Clean block
fa fa-eraser +link | drawLink | Create Link
fa fa-link +image | drawImage | Insert Image
fa fa-picture-o +table | drawTable | Insert Table
fa fa-table +horizontal-rule | drawHorizontalRule | Insert Horizontal Line
fa fa-minus +preview | togglePreview | Toggle Preview
fa fa-eye no-disable +side-by-side | toggleSideBySide | Toggle Side by Side
fa fa-columns no-disable no-mobile +fullscreen | toggleFullScreen | Toggle Fullscreen
fa fa-arrows-alt no-disable no-mobile +guide | [This link](https://www.markdownguide.org/basic-syntax/) | Markdown Guide
fa fa-question-circle + + +### Toolbar customization + +Customize the toolbar using the `toolbar` option. + +Only the order of existing buttons: + +```JavaScript +var easyMDE = new EasyMDE({ + toolbar: ["bold", "italic", "heading", "|", "quote"] +}); +``` + +All information and/or add your own icons + +```Javascript +var easyMDE = new EasyMDE({ + toolbar: [{ + name: "bold", + action: EasyMDE.toggleBold, + className: "fa fa-bold", + title: "Bold", + }, + { + name: "custom", + action: function customFunction(editor){ + // Add your own code + }, + className: "fa fa-star", + title: "Custom Button", + }, + "|" // Separator + // [, ...] + ] +}); +``` + +Put some buttons on dropdown menu + +```Javascript +var easyMDE = new EasyMDE({ + toolbar: [{ + name: "heading", + action: EasyMDE.toggleHeadingSmaller, + className: "fa fa-header", + title: "Headers", + }, + "|", + { + name: "others", + className: "fa fa-blind", + title: "others buttons", + children: [ + { + name: "image", + action: EasyMDE.drawImage, + className: "fa fa-picture-o", + title: "Image", + }, + { + name: "quote", + action: EasyMDE.toggleBlockquote, + className: "fa fa-percent", + title: "Quote", + }, + { + name: "link", + action: EasyMDE.drawLink, + className: "fa fa-link", + title: "Link", + } + ] + }, + // [, ...] + ] +}); +``` + +### Keyboard shortcuts + +EasyMDE comes with an array of predefined keyboard shortcuts, but they can be altered with a configuration option. The list of default ones is as follows: + +Shortcut (Windows / Linux) | Shortcut (macOS) | Action +:--- | :--- | :--- +*Ctrl-'* | *Cmd-'* | "toggleBlockquote" +*Ctrl-B* | *Cmd-B* | "toggleBold" +*Ctrl-E* | *Cmd-E* | "cleanBlock" +*Ctrl-H* | *Cmd-H* | "toggleHeadingSmaller" +*Ctrl-I* | *Cmd-I* | "toggleItalic" +*Ctrl-K* | *Cmd-K* | "drawLink" +*Ctrl-L* | *Cmd-L* | "toggleUnorderedList" +*Ctrl-P* | *Cmd-P* | "togglePreview" +*Ctrl-Alt-C* | *Cmd-Alt-C* | "toggleCodeBlock" +*Ctrl-Alt-I* | *Cmd-Alt-I* | "drawImage" +*Ctrl-Alt-L* | *Cmd-Alt-L* | "toggleOrderedList" +*Shift-Ctrl-H* | *Shift-Cmd-H* | "toggleHeadingBigger" +*F9* | *F9* | "toggleSideBySide" +*F11* | *F11* | "toggleFullScreen" + +Here is how you can change a few, while leaving others untouched: + +```JavaScript +var editor = new EasyMDE({ + shortcuts: { + "toggleOrderedList": "Ctrl-Alt-K", // alter the shortcut for toggleOrderedList + "toggleCodeBlock": null, // unbind Ctrl-Alt-C + "drawTable": "Cmd-Alt-T", // bind Cmd-Alt-T to drawTable action, which doesn't come with a default shortcut + } +}); +``` + +Shortcuts are automatically converted between platforms. If you define a shortcut as "Cmd-B", on PC that shortcut will be changed to "Ctrl-B". Conversely, a shortcut defined as "Ctrl-B" will become "Cmd-B" for Mac users. + +The list of actions that can be bound is the same as the list of built-in actions available for [toolbar buttons](#toolbar-icons). + + +## Advanced use + +### Event handling + +You can catch the following list of events: https://codemirror.net/doc/manual.html#events + +```JavaScript +var easyMDE = new EasyMDE(); +easyMDE.codemirror.on("change", function(){ + console.log(easyMDE.value()); +}); +``` + + +### Removing EasyMDE from text area + +You can revert to the initial text area by calling the `toTextArea` method. Note that this clears up the autosave (if enabled) associated with it. The text area will retain any text from the destroyed EasyMDE instance. + +```JavaScript +var easyMDE = new EasyMDE(); +// ... +easyMDE.toTextArea(); +easyMDE = null; +``` + +If you need to remove installed listeners (when editor not needed anymore), call `easyMDE.cleanup()` + + +### Useful methods + +The following self-explanatory methods may be of use while developing with EasyMDE. + +```js +var easyMDE = new EasyMDE(); +easyMDE.isPreviewActive(); // returns boolean +easyMDE.isSideBySideActive(); // returns boolean +easyMDE.isFullscreenActive(); // returns boolean +easyMDE.clearAutosavedValue(); // no returned value +``` + + +## How it works + +EasyMDE is a continuation of SimpleMDE. + +SimpleMDE began as an improvement of [lepture's Editor project](https://github.com/lepture/editor), but has now taken on an identity of its own. It is bundled with [CodeMirror](https://github.com/codemirror/codemirror) and depends on [Font Awesome](http://fontawesome.io). + +CodeMirror is the backbone of the project and parses much of the Markdown syntax as it's being written. This allows us to add styles to the Markdown that's being written. Additionally, a toolbar and status bar have been added to the top and bottom, respectively. Previews are rendered by [Marked](https://github.com/chjj/marked) using GFM. + + +## SimpleMDE fork + +I originally made this fork to implement FontAwesome 5 compatibility into SimpleMDE. When that was done I submitted a [pull request](https://github.com/sparksuite/simplemde-markdown-editor/pull/666), which has not been accepted yet. This, and the project being inactive since May 2017, triggered me to make more changes and try to put new life into the project. + +Changes include: +* FontAwesome 5 compatibility +* Guide button works when editor is in preview mode +* Links are now `https://` by default +* Small styling changes +* Support for Node 8 and beyond +* Lots of refactored code +* Links in preview will open in a new tab by default +* Typescript support + +My intention is to continue development on this project, improving it and keeping it alive. + + +## Hacking EasyMDE + +You may want to edit this library to adapt its behavior to your needs. This can be done in some quick steps: + +1. Follow the [prerequisites](./CONTRIBUTING.md#prerequisites) and [installation](./CONTRIBUTING.md#installation) instructions in the contribution guide; +2. Do your changes; +3. Run `gulp` command, which will generate files: `dist/easymde.min.css` and `dist/easymde.min.js`; +4. Copy-paste those files to your code base, and you are done. + + +## Contributing + +Want to contribute to EasyMDE? Thank you! We have a [contribution guide](./CONTRIBUTING.md) just for you! + + +## License + +This project is released under the [MIT License](./LICENSE). + +- Copyright (c) 2015 Sparksuite, Inc. +- Copyright (c) 2017 Jeroen Akkerman. diff --git a/PSC.Blazor.Components.MarkdownEditor/wwwroot/easymde/dist/easymde.min.css b/PSC.Blazor.Components.MarkdownEditor/wwwroot/easymde/dist/easymde.min.css new file mode 100644 index 0000000..453d7b5 --- /dev/null +++ b/PSC.Blazor.Components.MarkdownEditor/wwwroot/easymde/dist/easymde.min.css @@ -0,0 +1,7 @@ +/** + * easymde v2.15.0 + * Copyright Jeroen Akkerman + * @link https://github.com/ionaru/easy-markdown-editor + * @license MIT + */ +.CodeMirror{font-family:monospace;height:300px;color:#000;direction:ltr}.CodeMirror-lines{padding:4px 0}.CodeMirror pre.CodeMirror-line,.CodeMirror pre.CodeMirror-line-like{padding:0 4px}.CodeMirror-gutter-filler,.CodeMirror-scrollbar-filler{background-color:#fff}.CodeMirror-gutters{border-right:1px solid #ddd;background-color:#f7f7f7;white-space:nowrap}.CodeMirror-linenumber{padding:0 3px 0 5px;min-width:20px;text-align:right;color:#999;white-space:nowrap}.CodeMirror-guttermarker{color:#000}.CodeMirror-guttermarker-subtle{color:#999}.CodeMirror-cursor{border-left:1px solid #000;border-right:none;width:0}.CodeMirror div.CodeMirror-secondarycursor{border-left:1px solid silver}.cm-fat-cursor .CodeMirror-cursor{width:auto;border:0!important;background:#7e7}.cm-fat-cursor div.CodeMirror-cursors{z-index:1}.cm-fat-cursor-mark{background-color:rgba(20,255,20,.5);-webkit-animation:blink 1.06s steps(1) infinite;-moz-animation:blink 1.06s steps(1) infinite;animation:blink 1.06s steps(1) infinite}.cm-animate-fat-cursor{width:auto;border:0;-webkit-animation:blink 1.06s steps(1) infinite;-moz-animation:blink 1.06s steps(1) infinite;animation:blink 1.06s steps(1) infinite;background-color:#7e7}@-moz-keyframes blink{50%{background-color:transparent}}@-webkit-keyframes blink{50%{background-color:transparent}}@keyframes blink{50%{background-color:transparent}}.cm-tab{display:inline-block;text-decoration:inherit}.CodeMirror-rulers{position:absolute;left:0;right:0;top:-50px;bottom:0;overflow:hidden}.CodeMirror-ruler{border-left:1px solid #ccc;top:0;bottom:0;position:absolute}.cm-s-default .cm-header{color:#00f}.cm-s-default .cm-quote{color:#090}.cm-negative{color:#d44}.cm-positive{color:#292}.cm-header,.cm-strong{font-weight:700}.cm-em{font-style:italic}.cm-link{text-decoration:underline}.cm-strikethrough{text-decoration:line-through}.cm-s-default .cm-keyword{color:#708}.cm-s-default .cm-atom{color:#219}.cm-s-default .cm-number{color:#164}.cm-s-default .cm-def{color:#00f}.cm-s-default .cm-variable-2{color:#05a}.cm-s-default .cm-type,.cm-s-default .cm-variable-3{color:#085}.cm-s-default .cm-comment{color:#a50}.cm-s-default .cm-string{color:#a11}.cm-s-default .cm-string-2{color:#f50}.cm-s-default .cm-meta{color:#555}.cm-s-default .cm-qualifier{color:#555}.cm-s-default .cm-builtin{color:#30a}.cm-s-default .cm-bracket{color:#997}.cm-s-default .cm-tag{color:#170}.cm-s-default .cm-attribute{color:#00c}.cm-s-default .cm-hr{color:#999}.cm-s-default .cm-link{color:#00c}.cm-s-default .cm-error{color:red}.cm-invalidchar{color:red}.CodeMirror-composing{border-bottom:2px solid}div.CodeMirror span.CodeMirror-matchingbracket{color:#0b0}div.CodeMirror span.CodeMirror-nonmatchingbracket{color:#a22}.CodeMirror-matchingtag{background:rgba(255,150,0,.3)}.CodeMirror-activeline-background{background:#e8f2ff}.CodeMirror{position:relative;overflow:hidden;background:#fff}.CodeMirror-scroll{overflow:scroll!important;margin-bottom:-50px;margin-right:-50px;padding-bottom:50px;height:100%;outline:0;position:relative}.CodeMirror-sizer{position:relative;border-right:50px solid transparent}.CodeMirror-gutter-filler,.CodeMirror-hscrollbar,.CodeMirror-scrollbar-filler,.CodeMirror-vscrollbar{position:absolute;z-index:6;display:none;outline:0}.CodeMirror-vscrollbar{right:0;top:0;overflow-x:hidden;overflow-y:scroll}.CodeMirror-hscrollbar{bottom:0;left:0;overflow-y:hidden;overflow-x:scroll}.CodeMirror-scrollbar-filler{right:0;bottom:0}.CodeMirror-gutter-filler{left:0;bottom:0}.CodeMirror-gutters{position:absolute;left:0;top:0;min-height:100%;z-index:3}.CodeMirror-gutter{white-space:normal;height:100%;display:inline-block;vertical-align:top;margin-bottom:-50px}.CodeMirror-gutter-wrapper{position:absolute;z-index:4;background:0 0!important;border:none!important}.CodeMirror-gutter-background{position:absolute;top:0;bottom:0;z-index:4}.CodeMirror-gutter-elt{position:absolute;cursor:default;z-index:4}.CodeMirror-gutter-wrapper ::selection{background-color:transparent}.CodeMirror-gutter-wrapper ::-moz-selection{background-color:transparent}.CodeMirror-lines{cursor:text;min-height:1px}.CodeMirror pre.CodeMirror-line,.CodeMirror pre.CodeMirror-line-like{-moz-border-radius:0;-webkit-border-radius:0;border-radius:0;border-width:0;background:0 0;font-family:inherit;font-size:inherit;margin:0;white-space:pre;word-wrap:normal;line-height:inherit;color:inherit;z-index:2;position:relative;overflow:visible;-webkit-tap-highlight-color:transparent;-webkit-font-variant-ligatures:contextual;font-variant-ligatures:contextual}.CodeMirror-wrap pre.CodeMirror-line,.CodeMirror-wrap pre.CodeMirror-line-like{word-wrap:break-word;white-space:pre-wrap;word-break:normal}.CodeMirror-linebackground{position:absolute;left:0;right:0;top:0;bottom:0;z-index:0}.CodeMirror-linewidget{position:relative;z-index:2;padding:.1px}.CodeMirror-rtl pre{direction:rtl}.CodeMirror-code{outline:0}.CodeMirror-gutter,.CodeMirror-gutters,.CodeMirror-linenumber,.CodeMirror-scroll,.CodeMirror-sizer{-moz-box-sizing:content-box;box-sizing:content-box}.CodeMirror-measure{position:absolute;width:100%;height:0;overflow:hidden;visibility:hidden}.CodeMirror-cursor{position:absolute;pointer-events:none}.CodeMirror-measure pre{position:static}div.CodeMirror-cursors{visibility:hidden;position:relative;z-index:3}div.CodeMirror-dragcursors{visibility:visible}.CodeMirror-focused div.CodeMirror-cursors{visibility:visible}.CodeMirror-selected{background:#d9d9d9}.CodeMirror-focused .CodeMirror-selected{background:#d7d4f0}.CodeMirror-crosshair{cursor:crosshair}.CodeMirror-line::selection,.CodeMirror-line>span::selection,.CodeMirror-line>span>span::selection{background:#d7d4f0}.CodeMirror-line::-moz-selection,.CodeMirror-line>span::-moz-selection,.CodeMirror-line>span>span::-moz-selection{background:#d7d4f0}.cm-searching{background-color:#ffa;background-color:rgba(255,255,0,.4)}.cm-force-border{padding-right:.1px}@media print{.CodeMirror div.CodeMirror-cursors{visibility:hidden}}.cm-tab-wrap-hack:after{content:''}span.CodeMirror-selectedtext{background:0 0}.EasyMDEContainer{display:block}.EasyMDEContainer.sided--no-fullscreen{display:flex;flex-direction:row;flex-wrap:wrap}.EasyMDEContainer .CodeMirror{box-sizing:border-box;height:auto;border:1px solid #ddd;border-bottom-left-radius:4px;border-bottom-right-radius:4px;padding:10px;font:inherit;z-index:0;word-wrap:break-word}.EasyMDEContainer .CodeMirror-scroll{cursor:text}.EasyMDEContainer .CodeMirror-fullscreen{background:#fff;position:fixed!important;top:50px;left:0;right:0;bottom:0;height:auto;z-index:8;border-right:none!important;border-bottom-right-radius:0!important}.EasyMDEContainer .CodeMirror-sided{width:50%!important}.EasyMDEContainer.sided--no-fullscreen .CodeMirror-sided{border-right:none!important;border-bottom-right-radius:0;position:relative;flex:1 1 auto}.EasyMDEContainer .CodeMirror-placeholder{opacity:.5}.EasyMDEContainer .CodeMirror-focused .CodeMirror-selected{background:#d9d9d9}.editor-toolbar{position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none;padding:9px 10px;border-top:1px solid #bbb;border-left:1px solid #bbb;border-right:1px solid #bbb;border-top-left-radius:4px;border-top-right-radius:4px}.editor-toolbar.fullscreen{width:100%;height:50px;padding-top:10px;padding-bottom:10px;box-sizing:border-box;background:#fff;border:0;position:fixed;top:0;left:0;opacity:1;z-index:9}.editor-toolbar.fullscreen::before{width:20px;height:50px;background:-moz-linear-gradient(left,#fff 0,rgba(255,255,255,0) 100%);background:-webkit-gradient(linear,left top,right top,color-stop(0,#fff),color-stop(100%,rgba(255,255,255,0)));background:-webkit-linear-gradient(left,#fff 0,rgba(255,255,255,0) 100%);background:-o-linear-gradient(left,#fff 0,rgba(255,255,255,0) 100%);background:-ms-linear-gradient(left,#fff 0,rgba(255,255,255,0) 100%);background:linear-gradient(to right,#fff 0,rgba(255,255,255,0) 100%);position:fixed;top:0;left:0;margin:0;padding:0}.editor-toolbar.fullscreen::after{width:20px;height:50px;background:-moz-linear-gradient(left,rgba(255,255,255,0) 0,#fff 100%);background:-webkit-gradient(linear,left top,right top,color-stop(0,rgba(255,255,255,0)),color-stop(100%,#fff));background:-webkit-linear-gradient(left,rgba(255,255,255,0) 0,#fff 100%);background:-o-linear-gradient(left,rgba(255,255,255,0) 0,#fff 100%);background:-ms-linear-gradient(left,rgba(255,255,255,0) 0,#fff 100%);background:linear-gradient(to right,rgba(255,255,255,0) 0,#fff 100%);position:fixed;top:0;right:0;margin:0;padding:0}.EasyMDEContainer.sided--no-fullscreen .editor-toolbar{width:100%}.editor-toolbar .easymde-dropdown,.editor-toolbar button{background:0 0;display:inline-block;text-align:center;text-decoration:none!important;height:30px;margin:0;padding:0;border:1px solid transparent;border-radius:3px;cursor:pointer}.editor-toolbar button{width:30px}.editor-toolbar button.active,.editor-toolbar button:hover{background:#fcfcfc;border-color:#95a5a6}.editor-toolbar i.separator{display:inline-block;width:0;border-left:1px solid #d9d9d9;border-right:1px solid #fff;color:transparent;text-indent:-10px;margin:0 6px}.editor-toolbar button:after{font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;font-size:65%;vertical-align:text-bottom;position:relative;top:2px}.editor-toolbar button.heading-1:after{content:"1"}.editor-toolbar button.heading-2:after{content:"2"}.editor-toolbar button.heading-3:after{content:"3"}.editor-toolbar button.heading-bigger:after{content:"▲"}.editor-toolbar button.heading-smaller:after{content:"▼"}.editor-toolbar.disabled-for-preview button:not(.no-disable){opacity:.6;pointer-events:none}@media only screen and (max-width:700px){.editor-toolbar i.no-mobile{display:none}}.editor-statusbar{padding:8px 10px;font-size:12px;color:#959694;text-align:right}.EasyMDEContainer.sided--no-fullscreen .editor-statusbar{width:100%}.editor-statusbar span{display:inline-block;min-width:4em;margin-left:1em}.editor-statusbar .lines:before{content:'lines: '}.editor-statusbar .words:before{content:'words: '}.editor-statusbar .characters:before{content:'characters: '}.editor-preview-full{position:absolute;width:100%;height:100%;top:0;left:0;z-index:7;overflow:auto;display:none;box-sizing:border-box}.editor-preview-side{position:fixed;bottom:0;width:50%;top:50px;right:0;z-index:9;overflow:auto;display:none;box-sizing:border-box;border:1px solid #ddd;word-wrap:break-word}.editor-preview-active-side{display:block}.EasyMDEContainer.sided--no-fullscreen .editor-preview-active-side{flex:1 1 auto;height:auto;position:static}.editor-preview-active{display:block}.editor-preview{padding:10px;background:#fafafa}.editor-preview>p{margin-top:0}.editor-preview pre{background:#eee;margin-bottom:10px}.editor-preview table td,.editor-preview table th{border:1px solid #ddd;padding:5px}.cm-s-easymde .cm-tag{color:#63a35c}.cm-s-easymde .cm-attribute{color:#795da3}.cm-s-easymde .cm-string{color:#183691}.cm-s-easymde .cm-header-1{font-size:200%;line-height:200%}.cm-s-easymde .cm-header-2{font-size:160%;line-height:160%}.cm-s-easymde .cm-header-3{font-size:125%;line-height:125%}.cm-s-easymde .cm-header-4{font-size:110%;line-height:110%}.cm-s-easymde .cm-comment{background:rgba(0,0,0,.05);border-radius:2px}.cm-s-easymde .cm-link{color:#7f8c8d}.cm-s-easymde .cm-url{color:#aab2b3}.cm-s-easymde .cm-quote{color:#7f8c8d;font-style:italic}.editor-toolbar .easymde-dropdown{position:relative;background:linear-gradient(to bottom right,#fff 0,#fff 84%,#333 50%,#333 100%);border-radius:0;border:1px solid #fff}.editor-toolbar .easymde-dropdown:hover{background:linear-gradient(to bottom right,#fff 0,#fff 84%,#333 50%,#333 100%)}.easymde-dropdown-content{display:block;visibility:hidden;position:absolute;background-color:#f9f9f9;box-shadow:0 8px 16px 0 rgba(0,0,0,.2);padding:8px;z-index:2;top:30px}.easymde-dropdown:active .easymde-dropdown-content,.easymde-dropdown:focus .easymde-dropdown-content{visibility:visible}span[data-img-src]::after{content:'';background-image:var(--bg-image);display:block;max-height:100%;max-width:100%;background-size:contain;height:0;padding-top:var(--height);width:var(--width);background-repeat:no-repeat}.CodeMirror .cm-spell-error:not(.cm-url):not(.cm-comment):not(.cm-tag):not(.cm-word){background:rgba(255,0,0,.15)} \ No newline at end of file diff --git a/PSC.Blazor.Components.MarkdownEditor/wwwroot/easymde/dist/easymde.min.js b/PSC.Blazor.Components.MarkdownEditor/wwwroot/easymde/dist/easymde.min.js new file mode 100644 index 0000000..455399f --- /dev/null +++ b/PSC.Blazor.Components.MarkdownEditor/wwwroot/easymde/dist/easymde.min.js @@ -0,0 +1,7 @@ +/** + * easymde v2.15.0 + * Copyright Jeroen Akkerman + * @link https://github.com/ionaru/easy-markdown-editor + * @license MIT + */ +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).EasyMDE=e()}}((function(){return function e(t,n,r){function i(a,l){if(!n[a]){if(!t[a]){var s="function"==typeof require&&require;if(!l&&s)return s(a,!0);if(o)return o(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var c=n[a]={exports:{}};t[a][0].call(c.exports,(function(e){return i(t[a][1][e]||e)}),c,c.exports,e,t,n,r)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;a[> ]*|[*+-] \[[x ]\]\s|[*+-]\s|(\d+)([.)]))(\s*)/,n=/^(\s*)(>[> ]*|[*+-] \[[x ]\]|[*+-]|(\d+)[.)])(\s*)$/,r=/[*+-]\s/;function i(e,n){var r=n.line,i=0,o=0,a=t.exec(e.getLine(r)),l=a[1];do{var s=r+(i+=1),u=e.getLine(s),c=t.exec(u);if(c){var d=c[1],h=parseInt(a[3],10)+i-o,f=parseInt(c[3],10),p=f;if(l!==d||isNaN(f)){if(l.length>d.length)return;if(l.lengthf&&(p=h+1),e.replaceRange(u.replace(t,d+p+c[4]+c[5]),{line:s,ch:0},{line:s,ch:u.length})}}while(c)}e.commands.newlineAndIndentContinueMarkdownList=function(o){if(o.getOption("disableInput"))return e.Pass;for(var a=o.listSelections(),l=[],s=0;s\s*$/.test(p),x=!/>\s*$/.test(p);(v||x)&&o.replaceRange("",{line:u.line,ch:0},{line:u.line,ch:u.ch+1}),l[s]="\n"}else{var y=m[1],b=m[5],D=!(r.test(m[2])||m[2].indexOf(">")>=0),C=D?parseInt(m[3],10)+1+m[4]:m[2].replace("x"," ");l[s]="\n"+y+C+b,D&&i(o,u)}}o.replaceSelections(l)}})("object"==typeof n&&"object"==typeof t?e("../../lib/codemirror"):CodeMirror)},{"../../lib/codemirror":10}],7:[function(e,t,n){(function(e){"use strict";e.overlayMode=function(t,n,r){return{startState:function(){return{base:e.startState(t),overlay:e.startState(n),basePos:0,baseCur:null,overlayPos:0,overlayCur:null,streamSeen:null}},copyState:function(r){return{base:e.copyState(t,r.base),overlay:e.copyState(n,r.overlay),basePos:r.basePos,baseCur:null,overlayPos:r.overlayPos,overlayCur:null}},token:function(e,i){return(e!=i.streamSeen||Math.min(i.basePos,i.overlayPos)c);d++){var h=e.getLine(u++);l=null==l?h:l+"\n"+h}s*=2,t.lastIndex=n.ch;var f=t.exec(l);if(f){var p=l.slice(0,f.index).split("\n"),m=f[0].split("\n"),g=n.line+p.length-1,v=p[p.length-1].length;return{from:r(g,v),to:r(g+m.length-1,1==m.length?v+m[0].length:m[m.length-1].length),match:f}}}}function s(e,t,n){for(var r,i=0;i<=e.length;){t.lastIndex=i;var o=t.exec(e);if(!o)break;var a=o.index+o[0].length;if(a>e.length-n)break;(!r||a>r.index+r[0].length)&&(r=o),i=o.index+1}return r}function u(e,t,n){t=i(t,"g");for(var o=n.line,a=n.ch,l=e.firstLine();o>=l;o--,a=-1){var u=e.getLine(o),c=s(u,t,a<0?0:u.length-a);if(c)return{from:r(o,c.index),to:r(o,c.index+c[0].length),match:c}}}function c(e,t,n){if(!o(t))return u(e,t,n);t=i(t,"gm");for(var a,l=1,c=e.getLine(n.line).length-n.ch,d=n.line,h=e.firstLine();d>=h;){for(var f=0;f=h;f++){var p=e.getLine(d--);a=null==a?p:p+"\n"+a}l*=2;var m=s(a,t,c);if(m){var g=a.slice(0,m.index).split("\n"),v=m[0].split("\n"),x=d+g.length,y=g[g.length-1].length;return{from:r(x,y),to:r(x+v.length-1,1==v.length?y+v[0].length:v[v.length-1].length),match:m}}}}function d(e,t,n,r){if(e.length==t.length)return n;for(var i=0,o=n+Math.max(0,e.length-t.length);;){if(i==o)return i;var a=i+o>>1,l=r(e.slice(0,a)).length;if(l==n)return a;l>n?o=a:i=a+1}}function h(e,i,o,a){if(!i.length)return null;var l=a?t:n,s=l(i).split(/\r|\n\r?/);e:for(var u=o.line,c=o.ch,h=e.lastLine()+1-s.length;u<=h;u++,c=0){var f=e.getLine(u).slice(c),p=l(f);if(1==s.length){var m=p.indexOf(s[0]);if(-1==m)continue e;return o=d(f,p,m,l)+c,{from:r(u,d(f,p,m,l)+c),to:r(u,d(f,p,m+s[0].length,l)+c)}}var g=p.length-s[0].length;if(p.slice(g)==s[0]){for(var v=1;v=h;u--,c=-1){var f=e.getLine(u);c>-1&&(f=f.slice(0,c));var p=l(f);if(1==s.length){var m=p.lastIndexOf(s[0]);if(-1==m)continue e;return{from:r(u,d(f,p,m,l)),to:r(u,d(f,p,m+s[0].length,l))}}var g=s[s.length-1];if(p.slice(0,g.length)==g){var v=1;for(o=u-s.length+1;v0);)r.push({anchor:i.from(),head:i.to()});r.length&&this.setSelections(r,0)}))})("object"==typeof n&&"object"==typeof t?e("../../lib/codemirror"):CodeMirror)},{"../../lib/codemirror":10}],9:[function(e,t,n){(function(e){"use strict";function t(e){e.state.markedSelection&&e.operation((function(){!function(e){if(!e.somethingSelected())return a(e);if(e.listSelections().length>1)return l(e);var t=e.getCursor("start"),n=e.getCursor("end"),r=e.state.markedSelection;if(!r.length)return o(e,t,n);var s=r[0].find(),u=r[r.length-1].find();if(!s||!u||n.line-t.line<=8||i(t,u.to)>=0||i(n,s.from)<=0)return l(e);for(;i(t,s.from)>0;)r.shift().clear(),s=r[0].find();for(i(t,s.from)<0&&(s.to.line-t.line<8?(r.shift().clear(),o(e,t,s.to,0)):o(e,t,s.from,0));i(n,u.to)<0;)r.pop().clear(),u=r[r.length-1].find();i(n,u.to)>0&&(n.line-u.from.line<8?(r.pop().clear(),o(e,u.from,n)):o(e,u.to,n))}(e)}))}function n(e){e.state.markedSelection&&e.state.markedSelection.length&&e.operation((function(){a(e)}))}e.defineOption("styleSelectedText",!1,(function(r,i,o){var s=o&&o!=e.Init;i&&!s?(r.state.markedSelection=[],r.state.markedSelectionStyle="string"==typeof i?i:"CodeMirror-selectedtext",l(r),r.on("cursorActivity",t),r.on("change",n)):!i&&s&&(r.off("cursorActivity",t),r.off("change",n),a(r),r.state.markedSelection=r.state.markedSelectionStyle=null)}));var r=e.Pos,i=e.cmpPos;function o(e,t,n,o){if(0!=i(t,n))for(var a=e.state.markedSelection,l=e.state.markedSelectionStyle,s=t.line;;){var u=s==t.line?t:r(s,0),c=s+8,d=c>=n.line,h=d?n:r(c,0),f=e.markText(u,h,{className:l});if(null==o?a.push(f):a.splice(o++,0,f),d)break;s=c}}function a(e){for(var t=e.state.markedSelection,n=0;n2),g=/Android/.test(e),v=m||g||/webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(e),x=m||/Mac/.test(t),y=/\bCrOS\b/.test(e),b=/win/i.test(t),D=d&&e.match(/Version\/(\d*\.\d*)/);D&&(D=Number(D[1])),D&&D>=15&&(d=!1,s=!0);var C=x&&(u||d&&(null==D||D<12.11)),w=n||a&&l>=9;function k(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}var S,F=function(e,t){var n=e.className,r=k(t).exec(n);if(r){var i=n.slice(r.index+r[0].length);e.className=n.slice(0,r.index)+(i?r[1]+i:"")}};function A(e){for(var t=e.childNodes.length;t>0;--t)e.removeChild(e.firstChild);return e}function E(e,t){return A(e).appendChild(t)}function T(e,t,n,r){var i=document.createElement(e);if(n&&(i.className=n),r&&(i.style.cssText=r),"string"==typeof t)i.appendChild(document.createTextNode(t));else if(t)for(var o=0;o=t)return a+(t-o);a+=l-o,a+=n-a%n,o=l+1}}m?I=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:a&&(I=function(e){try{e.select()}catch(e){}});var P=function(){this.id=null,this.f=null,this.time=0,this.handler=z(this.onTimeout,this)};function _(e,t){for(var n=0;n=t)return r+Math.min(a,t-i);if(i+=o-r,r=o+1,(i+=n-i%n)>=t)return r}}var G=[""];function V(e){for(;G.length<=e;)G.push(K(G)+" ");return G[e]}function K(e){return e[e.length-1]}function X(e,t){for(var n=[],r=0;r"€"&&(e.toUpperCase()!=e.toLowerCase()||Q.test(e))}function ee(e,t){return t?!!(t.source.indexOf("\\w")>-1&&J(e))||t.test(e):J(e)}function te(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}var ne=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\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\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\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\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;function re(e){return e.charCodeAt(0)>=768&&ne.test(e)}function ie(e,t,n){for(;(n<0?t>0:tn?-1:1;;){if(t==n)return t;var i=(t+n)/2,o=r<0?Math.ceil(i):Math.floor(i);if(o==t)return e(o)?t:n;e(o)?n=o:t=o+r}}var ae=null;function le(e,t,n){var r;ae=null;for(var i=0;it)return i;o.to==t&&(o.from!=o.to&&"before"==n?r=i:ae=i),o.from==t&&(o.from!=o.to&&"before"!=n?r=i:ae=i)}return null!=r?r:ae}var se=function(){var e=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,t=/[stwN]/,n=/[LRr]/,r=/[Lb1n]/,i=/[1n]/;function o(e,t,n){this.level=e,this.from=t,this.to=n}return function(a,l){var s="ltr"==l?"L":"R";if(0==a.length||"ltr"==l&&!e.test(a))return!1;for(var u,c=a.length,d=[],h=0;h-1&&(r[t]=i.slice(0,o).concat(i.slice(o+1)))}}}function pe(e,t){var n=he(e,t);if(n.length)for(var r=Array.prototype.slice.call(arguments,2),i=0;i0}function xe(e){e.prototype.on=function(e,t){de(this,e,t)},e.prototype.off=function(e,t){fe(this,e,t)}}function ye(e){e.preventDefault?e.preventDefault():e.returnValue=!1}function be(e){e.stopPropagation?e.stopPropagation():e.cancelBubble=!0}function De(e){return null!=e.defaultPrevented?e.defaultPrevented:0==e.returnValue}function Ce(e){ye(e),be(e)}function we(e){return e.target||e.srcElement}function ke(e){var t=e.which;return null==t&&(1&e.button?t=1:2&e.button?t=3:4&e.button&&(t=2)),x&&e.ctrlKey&&1==t&&(t=3),t}var Se,Fe,Ae=function(){if(a&&l<9)return!1;var e=T("div");return"draggable"in e||"dragDrop"in e}();function Ee(e){if(null==Se){var t=T("span","​");E(e,T("span",[t,document.createTextNode("x")])),0!=e.firstChild.offsetHeight&&(Se=t.offsetWidth<=1&&t.offsetHeight>2&&!(a&&l<8))}var n=Se?T("span","​"):T("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return n.setAttribute("cm-text",""),n}function Te(e){if(null!=Fe)return Fe;var t=E(e,document.createTextNode("AخA")),n=S(t,0,1).getBoundingClientRect(),r=S(t,1,2).getBoundingClientRect();return A(e),!(!n||n.left==n.right)&&(Fe=r.right-n.right<3)}var Le,Me=3!="\n\nb".split(/\n/).length?function(e){for(var t=0,n=[],r=e.length;t<=r;){var i=e.indexOf("\n",t);-1==i&&(i=e.length);var o=e.slice(t,"\r"==e.charAt(i-1)?i-1:i),a=o.indexOf("\r");-1!=a?(n.push(o.slice(0,a)),t+=a+1):(n.push(o),t=i+1)}return n}:function(e){return e.split(/\r\n?|\n/)},Be=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(e){return!1}}:function(e){var t;try{t=e.ownerDocument.selection.createRange()}catch(e){}return!(!t||t.parentElement()!=e)&&0!=t.compareEndPoints("StartToEnd",t)},Ne="oncopy"in(Le=T("div"))||(Le.setAttribute("oncopy","return;"),"function"==typeof Le.oncopy),Oe=null;var Ie={},ze={};function He(e,t){arguments.length>2&&(t.dependencies=Array.prototype.slice.call(arguments,2)),Ie[e]=t}function Re(e){if("string"==typeof e&&ze.hasOwnProperty(e))e=ze[e];else if(e&&"string"==typeof e.name&&ze.hasOwnProperty(e.name)){var t=ze[e.name];"string"==typeof t&&(t={name:t}),(e=Y(t,e)).name=t.name}else{if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return Re("application/xml");if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+json$/.test(e))return Re("application/json")}return"string"==typeof e?{name:e}:e||{name:"null"}}function Pe(e,t){t=Re(t);var n=Ie[t.name];if(!n)return Pe(e,"text/plain");var r=n(e,t);if(_e.hasOwnProperty(t.name)){var i=_e[t.name];for(var o in i)i.hasOwnProperty(o)&&(r.hasOwnProperty(o)&&(r["_"+o]=r[o]),r[o]=i[o])}if(r.name=t.name,t.helperType&&(r.helperType=t.helperType),t.modeProps)for(var a in t.modeProps)r[a]=t.modeProps[a];return r}var _e={};function We(e,t){H(t,_e.hasOwnProperty(e)?_e[e]:_e[e]={})}function je(e,t){if(!0===t)return t;if(e.copyState)return e.copyState(t);var n={};for(var r in t){var i=t[r];i instanceof Array&&(i=i.concat([])),n[r]=i}return n}function qe(e,t){for(var n;e.innerMode&&(n=e.innerMode(t))&&n.mode!=e;)t=n.state,e=n.mode;return n||{mode:e,state:t}}function Ue(e,t,n){return!e.startState||e.startState(t,n)}var $e=function(e,t,n){this.pos=this.start=0,this.string=e,this.tabSize=t||8,this.lastColumnPos=this.lastColumnValue=0,this.lineStart=0,this.lineOracle=n};function Ge(e,t){if((t-=e.first)<0||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var n=e;!n.lines;)for(var r=0;;++r){var i=n.children[r],o=i.chunkSize();if(t=e.first&&tn?et(n,Ge(e,n).text.length):function(e,t){var n=e.ch;return null==n||n>t?et(e.line,t):n<0?et(e.line,0):e}(t,Ge(e,t.line).text.length)}function st(e,t){for(var n=[],r=0;r=this.string.length},$e.prototype.sol=function(){return this.pos==this.lineStart},$e.prototype.peek=function(){return this.string.charAt(this.pos)||void 0},$e.prototype.next=function(){if(this.post},$e.prototype.eatSpace=function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},$e.prototype.skipToEnd=function(){this.pos=this.string.length},$e.prototype.skipTo=function(e){var t=this.string.indexOf(e,this.pos);if(t>-1)return this.pos=t,!0},$e.prototype.backUp=function(e){this.pos-=e},$e.prototype.column=function(){return this.lastColumnPos0?null:(r&&!1!==t&&(this.pos+=r[0].length),r)}var i=function(e){return n?e.toLowerCase():e};if(i(this.string.substr(this.pos,e.length))==i(e))return!1!==t&&(this.pos+=e.length),!0},$e.prototype.current=function(){return this.string.slice(this.start,this.pos)},$e.prototype.hideFirstChars=function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}},$e.prototype.lookAhead=function(e){var t=this.lineOracle;return t&&t.lookAhead(e)},$e.prototype.baseToken=function(){var e=this.lineOracle;return e&&e.baseToken(this.pos)};var ut=function(e,t){this.state=e,this.lookAhead=t},ct=function(e,t,n,r){this.state=t,this.doc=e,this.line=n,this.maxLookAhead=r||0,this.baseTokens=null,this.baseTokenPos=1};function dt(e,t,n,r){var i=[e.state.modeGen],o={};bt(e,t.text,e.doc.mode,n,(function(e,t){return i.push(e,t)}),o,r);for(var a=n.state,l=function(r){n.baseTokens=i;var l=e.state.overlays[r],s=1,u=0;n.state=!0,bt(e,t.text,l.mode,n,(function(e,t){for(var n=s;ue&&i.splice(s,1,e,i[s+1],r),s+=2,u=Math.min(e,r)}if(t)if(l.opaque)i.splice(n,s-n,e,"overlay "+t),s=n+2;else for(;ne.options.maxHighlightLength&&je(e.doc.mode,r.state),o=dt(e,t,r);i&&(r.state=i),t.stateAfter=r.save(!i),t.styles=o.styles,o.classes?t.styleClasses=o.classes:t.styleClasses&&(t.styleClasses=null),n===e.doc.highlightFrontier&&(e.doc.modeFrontier=Math.max(e.doc.modeFrontier,++e.doc.highlightFrontier))}return t.styles}function ft(e,t,n){var r=e.doc,i=e.display;if(!r.mode.startState)return new ct(r,!0,t);var o=function(e,t,n){for(var r,i,o=e.doc,a=n?-1:t-(e.doc.mode.innerMode?1e3:100),l=t;l>a;--l){if(l<=o.first)return o.first;var s=Ge(o,l-1),u=s.stateAfter;if(u&&(!n||l+(u instanceof ut?u.lookAhead:0)<=o.modeFrontier))return l;var c=R(s.text,null,e.options.tabSize);(null==i||r>c)&&(i=l-1,r=c)}return i}(e,t,n),a=o>r.first&&Ge(r,o-1).stateAfter,l=a?ct.fromSaved(r,a,o):new ct(r,Ue(r.mode),o);return r.iter(o,t,(function(n){pt(e,n.text,l);var r=l.line;n.stateAfter=r==t-1||r%5==0||r>=i.viewFrom&&rt.start)return o}throw new Error("Mode "+e.name+" failed to advance stream.")}ct.prototype.lookAhead=function(e){var t=this.doc.getLine(this.line+e);return null!=t&&e>this.maxLookAhead&&(this.maxLookAhead=e),t},ct.prototype.baseToken=function(e){if(!this.baseTokens)return null;for(;this.baseTokens[this.baseTokenPos]<=e;)this.baseTokenPos+=2;var t=this.baseTokens[this.baseTokenPos+1];return{type:t&&t.replace(/( |^)overlay .*/,""),size:this.baseTokens[this.baseTokenPos]-e}},ct.prototype.nextLine=function(){this.line++,this.maxLookAhead>0&&this.maxLookAhead--},ct.fromSaved=function(e,t,n){return t instanceof ut?new ct(e,je(e.mode,t.state),n,t.lookAhead):new ct(e,je(e.mode,t),n)},ct.prototype.save=function(e){var t=!1!==e?je(this.doc.mode,this.state):this.state;return this.maxLookAhead>0?new ut(t,this.maxLookAhead):t};var vt=function(e,t,n){this.start=e.start,this.end=e.pos,this.string=e.current(),this.type=t||null,this.state=n};function xt(e,t,n,r){var i,o,a=e.doc,l=a.mode,s=Ge(a,(t=lt(a,t)).line),u=ft(e,t.line,n),c=new $e(s.text,e.options.tabSize,u);for(r&&(o=[]);(r||c.pose.options.maxHighlightLength?(l=!1,a&&pt(e,t,r,d.pos),d.pos=t.length,s=null):s=yt(gt(n,d,r.state,h),o),h){var f=h[0].name;f&&(s="m-"+(s?f+" "+s:f))}if(!l||c!=s){for(;u=t:o.to>t);(r||(r=[])).push(new wt(a,o.from,l?null:o.to))}}return r}(n,i,a),s=function(e,t,n){var r;if(e)for(var i=0;i=t:o.to>t)||o.from==t&&"bookmark"==a.type&&(!n||o.marker.insertLeft)){var l=null==o.from||(a.inclusiveLeft?o.from<=t:o.from0&&l)for(var y=0;yt)&&(!n||Bt(n,o.marker)<0)&&(n=o.marker)}return n}function Ht(e,t,n,r,i){var o=Ge(e,t),a=Ct&&o.markedSpans;if(a)for(var l=0;l=0&&d<=0||c<=0&&d>=0)&&(c<=0&&(s.marker.inclusiveRight&&i.inclusiveLeft?tt(u.to,n)>=0:tt(u.to,n)>0)||c>=0&&(s.marker.inclusiveRight&&i.inclusiveLeft?tt(u.from,r)<=0:tt(u.from,r)<0)))return!0}}}function Rt(e){for(var t;t=Ot(e);)e=t.find(-1,!0).line;return e}function Pt(e,t){var n=Ge(e,t),r=Rt(n);return n==r?t:Ze(r)}function _t(e,t){if(t>e.lastLine())return t;var n,r=Ge(e,t);if(!Wt(e,r))return t;for(;n=It(r);)r=n.find(1,!0).line;return Ze(r)+1}function Wt(e,t){var n=Ct&&t.markedSpans;if(n)for(var r=void 0,i=0;it.maxLineLength&&(t.maxLineLength=n,t.maxLine=e)}))}var Gt=function(e,t,n){this.text=e,Tt(this,t),this.height=n?n(this):1};function Vt(e){e.parent=null,Et(e)}Gt.prototype.lineNo=function(){return Ze(this)},xe(Gt);var Kt={},Xt={};function Zt(e,t){if(!e||/^\s*$/.test(e))return null;var n=t.addModeClass?Xt:Kt;return n[e]||(n[e]=e.replace(/\S+/g,"cm-$&"))}function Yt(e,t){var n=L("span",null,null,s?"padding-right: .1px":null),r={pre:L("pre",[n],"CodeMirror-line"),content:n,col:0,pos:0,cm:e,trailingSpace:!1,splitSpaces:e.getOption("lineWrapping")};t.measure={};for(var i=0;i<=(t.rest?t.rest.length:0);i++){var o=i?t.rest[i-1]:t.line,a=void 0;r.pos=0,r.addToken=Jt,Te(e.display.measure)&&(a=ue(o,e.doc.direction))&&(r.addToken=en(r.addToken,a)),r.map=[],nn(o,r,ht(e,o,t!=e.display.externalMeasured&&Ze(o))),o.styleClasses&&(o.styleClasses.bgClass&&(r.bgClass=O(o.styleClasses.bgClass,r.bgClass||"")),o.styleClasses.textClass&&(r.textClass=O(o.styleClasses.textClass,r.textClass||""))),0==r.map.length&&r.map.push(0,0,r.content.appendChild(Ee(e.display.measure))),0==i?(t.measure.map=r.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(r.map),(t.measure.caches||(t.measure.caches=[])).push({}))}if(s){var l=r.content.lastChild;(/\bcm-tab\b/.test(l.className)||l.querySelector&&l.querySelector(".cm-tab"))&&(r.content.className="cm-tab-wrap-hack")}return pe(e,"renderLine",e,t.line,r.pre),r.pre.className&&(r.textClass=O(r.pre.className,r.textClass||"")),r}function Qt(e){var t=T("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function Jt(e,t,n,r,i,o,s){if(t){var u,c=e.splitSpaces?function(e,t){if(e.length>1&&!/ /.test(e))return e;for(var n=t,r="",i=0;iu&&d.from<=u);h++);if(d.to>=c)return e(n,r,i,o,a,l,s);e(n,r.slice(0,d.to-u),i,o,null,l,s),o=null,r=r.slice(d.to-u),u=d.to}}}function tn(e,t,n,r){var i=!r&&n.widgetNode;i&&e.map.push(e.pos,e.pos+t,i),!r&&e.cm.display.input.needsContentAttribute&&(i||(i=e.content.appendChild(document.createElement("span"))),i.setAttribute("cm-marker",n.id)),i&&(e.cm.display.input.setUneditable(i),e.content.appendChild(i)),e.pos+=t,e.trailingSpace=!1}function nn(e,t,n){var r=e.markedSpans,i=e.text,o=0;if(r)for(var a,l,s,u,c,d,h,f=i.length,p=0,m=1,g="",v=0;;){if(v==p){s=u=c=l="",h=null,d=null,v=1/0;for(var x=[],y=void 0,b=0;bp||C.collapsed&&D.to==p&&D.from==p)){if(null!=D.to&&D.to!=p&&v>D.to&&(v=D.to,u=""),C.className&&(s+=" "+C.className),C.css&&(l=(l?l+";":"")+C.css),C.startStyle&&D.from==p&&(c+=" "+C.startStyle),C.endStyle&&D.to==v&&(y||(y=[])).push(C.endStyle,D.to),C.title&&((h||(h={})).title=C.title),C.attributes)for(var w in C.attributes)(h||(h={}))[w]=C.attributes[w];C.collapsed&&(!d||Bt(d.marker,C)<0)&&(d=D)}else D.from>p&&v>D.from&&(v=D.from)}if(y)for(var k=0;k=f)break;for(var F=Math.min(f,v);;){if(g){var A=p+g.length;if(!d){var E=A>F?g.slice(0,F-p):g;t.addToken(t,E,a?a+s:s,c,p+E.length==v?u:"",l,h)}if(A>=F){g=g.slice(F-p),p=F;break}p=A,c=""}g=i.slice(o,o=n[m++]),a=Zt(n[m++],t.cm.options)}}else for(var T=1;Tn)return{map:e.measure.maps[i],cache:e.measure.caches[i],before:!0}}function Ln(e,t,n,r){return Nn(e,Bn(e,t),n,r)}function Mn(e,t){if(t>=e.display.viewFrom&&t=n.lineN&&t2&&o.push((s.bottom+u.top)/2-n.top)}}o.push(n.bottom-n.top)}}(e,t.view,t.rect),t.hasHeights=!0),(o=function(e,t,n,r){var i,o=zn(t.map,n,r),s=o.node,u=o.start,c=o.end,d=o.collapse;if(3==s.nodeType){for(var h=0;h<4;h++){for(;u&&re(t.line.text.charAt(o.coverStart+u));)--u;for(;o.coverStart+c1}(e))return t;var n=screen.logicalXDPI/screen.deviceXDPI,r=screen.logicalYDPI/screen.deviceYDPI;return{left:t.left*n,right:t.right*n,top:t.top*r,bottom:t.bottom*r}}(e.display.measure,i))}else{var f;u>0&&(d=r="right"),i=e.options.lineWrapping&&(f=s.getClientRects()).length>1?f["right"==r?f.length-1:0]:s.getBoundingClientRect()}if(a&&l<9&&!u&&(!i||!i.left&&!i.right)){var p=s.parentNode.getClientRects()[0];i=p?{left:p.left,right:p.left+ir(e.display),top:p.top,bottom:p.bottom}:In}for(var m=i.top-t.rect.top,g=i.bottom-t.rect.top,v=(m+g)/2,x=t.view.measure.heights,y=0;yt)&&(i=(o=s-l)-1,t>=s&&(a="right")),null!=i){if(r=e[u+2],l==s&&n==(r.insertLeft?"left":"right")&&(a=n),"left"==n&&0==i)for(;u&&e[u-2]==e[u-3]&&e[u-1].insertLeft;)r=e[2+(u-=3)],a="left";if("right"==n&&i==s-l)for(;u=0&&(n=e[i]).left==n.right;i--);return n}function Rn(e){if(e.measure&&(e.measure.cache={},e.measure.heights=null,e.rest))for(var t=0;t=r.text.length?(s=r.text.length,u="before"):s<=0&&(s=0,u="after"),!l)return a("before"==u?s-1:s,"before"==u);function c(e,t,n){return a(n?e-1:e,1==l[t].level!=n)}var d=le(l,s,u),h=ae,f=c(s,d,"before"==u);return null!=h&&(f.other=c(s,h,"before"!=u)),f}function Kn(e,t){var n=0;t=lt(e.doc,t),e.options.lineWrapping||(n=ir(e.display)*t.ch);var r=Ge(e.doc,t.line),i=qt(r)+wn(e.display);return{left:n,right:n,top:i,bottom:i+r.height}}function Xn(e,t,n,r,i){var o=et(e,t,n);return o.xRel=i,r&&(o.outside=r),o}function Zn(e,t,n){var r=e.doc;if((n+=e.display.viewOffset)<0)return Xn(r.first,0,null,-1,-1);var i=Ye(r,n),o=r.first+r.size-1;if(i>o)return Xn(r.first+r.size-1,Ge(r,o).text.length,null,1,1);t<0&&(t=0);for(var a=Ge(r,i);;){var l=er(e,a,i,t,n),s=zt(a,l.ch+(l.xRel>0||l.outside>0?1:0));if(!s)return l;var u=s.find(1);if(u.line==i)return u;a=Ge(r,i=u.line)}}function Yn(e,t,n,r){r-=qn(t);var i=t.text.length,o=oe((function(t){return Nn(e,n,t-1).bottom<=r}),i,0);return{begin:o,end:i=oe((function(t){return Nn(e,n,t).top>r}),o,i)}}function Qn(e,t,n,r){return n||(n=Bn(e,t)),Yn(e,t,n,Un(e,t,Nn(e,n,r),"line").top)}function Jn(e,t,n,r){return!(e.bottom<=n)&&(e.top>n||(r?e.left:e.right)>t)}function er(e,t,n,r,i){i-=qt(t);var o=Bn(e,t),a=qn(t),l=0,s=t.text.length,u=!0,c=ue(t,e.doc.direction);if(c){var d=(e.options.lineWrapping?nr:tr)(e,t,n,o,c,r,i);l=(u=1!=d.level)?d.from:d.to-1,s=u?d.to:d.from-1}var h,f,p=null,m=null,g=oe((function(t){var n=Nn(e,o,t);return n.top+=a,n.bottom+=a,!!Jn(n,r,i,!1)&&(n.top<=i&&n.left<=r&&(p=t,m=n),!0)}),l,s),v=!1;if(m){var x=r-m.left=b.bottom?1:0}return Xn(n,g=ie(t.text,g,1),f,v,r-h)}function tr(e,t,n,r,i,o,a){var l=oe((function(l){var s=i[l],u=1!=s.level;return Jn(Vn(e,et(n,u?s.to:s.from,u?"before":"after"),"line",t,r),o,a,!0)}),0,i.length-1),s=i[l];if(l>0){var u=1!=s.level,c=Vn(e,et(n,u?s.from:s.to,u?"after":"before"),"line",t,r);Jn(c,o,a,!0)&&c.top>a&&(s=i[l-1])}return s}function nr(e,t,n,r,i,o,a){var l=Yn(e,t,r,a),s=l.begin,u=l.end;/\s/.test(t.text.charAt(u-1))&&u--;for(var c=null,d=null,h=0;h=u||f.to<=s)){var p=Nn(e,r,1!=f.level?Math.min(u,f.to)-1:Math.max(s,f.from)).right,m=pm)&&(c=f,d=m)}}return c||(c=i[i.length-1]),c.fromu&&(c={from:c.from,to:u,level:c.level}),c}function rr(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==On){On=T("pre",null,"CodeMirror-line-like");for(var t=0;t<49;++t)On.appendChild(document.createTextNode("x")),On.appendChild(T("br"));On.appendChild(document.createTextNode("x"))}E(e.measure,On);var n=On.offsetHeight/50;return n>3&&(e.cachedTextHeight=n),A(e.measure),n||1}function ir(e){if(null!=e.cachedCharWidth)return e.cachedCharWidth;var t=T("span","xxxxxxxxxx"),n=T("pre",[t],"CodeMirror-line-like");E(e.measure,n);var r=t.getBoundingClientRect(),i=(r.right-r.left)/10;return i>2&&(e.cachedCharWidth=i),i||10}function or(e){for(var t=e.display,n={},r={},i=t.gutters.clientLeft,o=t.gutters.firstChild,a=0;o;o=o.nextSibling,++a){var l=e.display.gutterSpecs[a].className;n[l]=o.offsetLeft+o.clientLeft+i,r[l]=o.clientWidth}return{fixedPos:ar(t),gutterTotalWidth:t.gutters.offsetWidth,gutterLeft:n,gutterWidth:r,wrapperWidth:t.wrapper.clientWidth}}function ar(e){return e.scroller.getBoundingClientRect().left-e.sizer.getBoundingClientRect().left}function lr(e){var t=rr(e.display),n=e.options.lineWrapping,r=n&&Math.max(5,e.display.scroller.clientWidth/ir(e.display)-3);return function(i){if(Wt(e.doc,i))return 0;var o=0;if(i.widgets)for(var a=0;a0&&(s=Ge(e.doc,u.line).text).length==u.ch){var c=R(s,s.length,e.options.tabSize)-s.length;u=et(u.line,Math.max(0,Math.round((o-Sn(e.display).left)/ir(e.display))-c))}return u}function cr(e,t){if(t>=e.display.viewTo)return null;if((t-=e.display.viewFrom)<0)return null;for(var n=e.display.view,r=0;rt)&&(i.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=i.viewTo)Ct&&Pt(e.doc,t)i.viewFrom?fr(e):(i.viewFrom+=r,i.viewTo+=r);else if(t<=i.viewFrom&&n>=i.viewTo)fr(e);else if(t<=i.viewFrom){var o=pr(e,n,n+r,1);o?(i.view=i.view.slice(o.index),i.viewFrom=o.lineN,i.viewTo+=r):fr(e)}else if(n>=i.viewTo){var a=pr(e,t,t,-1);a?(i.view=i.view.slice(0,a.index),i.viewTo=a.lineN):fr(e)}else{var l=pr(e,t,t,-1),s=pr(e,n,n+r,1);l&&s?(i.view=i.view.slice(0,l.index).concat(on(e,l.lineN,s.lineN)).concat(i.view.slice(s.index)),i.viewTo+=r):fr(e)}var u=i.externalMeasured;u&&(n=i.lineN&&t=r.viewTo)){var o=r.view[cr(e,t)];if(null!=o.node){var a=o.changes||(o.changes=[]);-1==_(a,n)&&a.push(n)}}}function fr(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function pr(e,t,n,r){var i,o=cr(e,t),a=e.display.view;if(!Ct||n==e.doc.first+e.doc.size)return{index:o,lineN:n};for(var l=e.display.viewFrom,s=0;s0){if(o==a.length-1)return null;i=l+a[o].size-t,o++}else i=l-t;t+=i,n+=i}for(;Pt(e.doc,n)!=n;){if(o==(r<0?0:a.length-1))return null;n+=r*a[o-(r<0?1:0)].size,o+=r}return{index:o,lineN:n}}function mr(e){for(var t=e.display.view,n=0,r=0;r=e.display.viewTo||l.to().linet||t==n&&a.to==t)&&(r(Math.max(a.from,t),Math.min(a.to,n),1==a.level?"rtl":"ltr",o),i=!0)}i||r(t,n,"ltr")}(m,n||0,null==r?h:r,(function(e,t,i,d){var g="ltr"==i,v=f(e,g?"left":"right"),x=f(t-1,g?"right":"left"),y=null==n&&0==e,b=null==r&&t==h,D=0==d,C=!m||d==m.length-1;if(x.top-v.top<=3){var w=(u?b:y)&&C,k=(u?y:b)&&D?l:(g?v:x).left,S=w?s:(g?x:v).right;c(k,v.top,S-k,v.bottom)}else{var F,A,E,T;g?(F=u&&y&&D?l:v.left,A=u?s:p(e,i,"before"),E=u?l:p(t,i,"after"),T=u&&b&&C?s:x.right):(F=u?p(e,i,"before"):l,A=!u&&y&&D?s:v.right,E=!u&&b&&C?l:x.left,T=u?p(t,i,"after"):s),c(F,v.top,A-F,v.bottom),v.bottom0?t.blinker=setInterval((function(){e.hasFocus()||Sr(e),t.cursorDiv.style.visibility=(n=!n)?"":"hidden"}),e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}}function Cr(e){e.hasFocus()||(e.display.input.focus(),e.state.focused||kr(e))}function wr(e){e.state.delayingBlurEvent=!0,setTimeout((function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,e.state.focused&&Sr(e))}),100)}function kr(e,t){e.state.delayingBlurEvent&&!e.state.draggingText&&(e.state.delayingBlurEvent=!1),"nocursor"!=e.options.readOnly&&(e.state.focused||(pe(e,"focus",e,t),e.state.focused=!0,N(e.display.wrapper,"CodeMirror-focused"),e.curOp||e.display.selForContextMenu==e.doc.sel||(e.display.input.reset(),s&&setTimeout((function(){return e.display.input.reset(!0)}),20)),e.display.input.receivedFocus()),Dr(e))}function Sr(e,t){e.state.delayingBlurEvent||(e.state.focused&&(pe(e,"blur",e,t),e.state.focused=!1,F(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout((function(){e.state.focused||(e.display.shift=!1)}),150))}function Fr(e){for(var t=e.display,n=t.lineDiv.offsetTop,r=0;r.005||h<-.005)&&(Xe(i.line,s),Ar(i.line),i.rest))for(var f=0;fe.display.sizerWidth){var p=Math.ceil(u/ir(e.display));p>e.display.maxLineLength&&(e.display.maxLineLength=p,e.display.maxLine=i.line,e.display.maxLineChanged=!0)}}}}function Ar(e){if(e.widgets)for(var t=0;t=a&&(o=Ye(t,qt(Ge(t,s))-e.wrapper.clientHeight),a=s)}return{from:o,to:Math.max(a,o+1)}}function Tr(e,t){var n=e.display,r=rr(e.display);t.top<0&&(t.top=0);var i=e.curOp&&null!=e.curOp.scrollTop?e.curOp.scrollTop:n.scroller.scrollTop,o=En(e),a={};t.bottom-t.top>o&&(t.bottom=t.top+o);var l=e.doc.height+kn(n),s=t.topl-r;if(t.topi+o){var c=Math.min(t.top,(u?l:t.bottom)-o);c!=i&&(a.scrollTop=c)}var d=e.options.fixedGutter?0:n.gutters.offsetWidth,h=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:n.scroller.scrollLeft-d,f=An(e)-n.gutters.offsetWidth,p=t.right-t.left>f;return p&&(t.right=t.left+f),t.left<10?a.scrollLeft=0:t.leftf+h-3&&(a.scrollLeft=t.right+(p?0:10)-f),a}function Lr(e,t){null!=t&&(Nr(e),e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+t)}function Mr(e){Nr(e);var t=e.getCursor();e.curOp.scrollToPos={from:t,to:t,margin:e.options.cursorScrollMargin}}function Br(e,t,n){null==t&&null==n||Nr(e),null!=t&&(e.curOp.scrollLeft=t),null!=n&&(e.curOp.scrollTop=n)}function Nr(e){var t=e.curOp.scrollToPos;t&&(e.curOp.scrollToPos=null,Or(e,Kn(e,t.from),Kn(e,t.to),t.margin))}function Or(e,t,n,r){var i=Tr(e,{left:Math.min(t.left,n.left),top:Math.min(t.top,n.top)-r,right:Math.max(t.right,n.right),bottom:Math.max(t.bottom,n.bottom)+r});Br(e,i.scrollLeft,i.scrollTop)}function Ir(e,t){Math.abs(e.doc.scrollTop-t)<2||(n||si(e,{top:t}),zr(e,t,!0),n&&si(e),ri(e,100))}function zr(e,t,n){t=Math.max(0,Math.min(e.display.scroller.scrollHeight-e.display.scroller.clientHeight,t)),(e.display.scroller.scrollTop!=t||n)&&(e.doc.scrollTop=t,e.display.scrollbars.setScrollTop(t),e.display.scroller.scrollTop!=t&&(e.display.scroller.scrollTop=t))}function Hr(e,t,n,r){t=Math.max(0,Math.min(t,e.display.scroller.scrollWidth-e.display.scroller.clientWidth)),(n?t==e.doc.scrollLeft:Math.abs(e.doc.scrollLeft-t)<2)&&!r||(e.doc.scrollLeft=t,di(e),e.display.scroller.scrollLeft!=t&&(e.display.scroller.scrollLeft=t),e.display.scrollbars.setScrollLeft(t))}function Rr(e){var t=e.display,n=t.gutters.offsetWidth,r=Math.round(e.doc.height+kn(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?n:0,docHeight:r,scrollHeight:r+Fn(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:n}}var Pr=function(e,t,n){this.cm=n;var r=this.vert=T("div",[T("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),i=this.horiz=T("div",[T("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");r.tabIndex=i.tabIndex=-1,e(r),e(i),de(r,"scroll",(function(){r.clientHeight&&t(r.scrollTop,"vertical")})),de(i,"scroll",(function(){i.clientWidth&&t(i.scrollLeft,"horizontal")})),this.checkedZeroWidth=!1,a&&l<8&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")};Pr.prototype.update=function(e){var t=e.scrollWidth>e.clientWidth+1,n=e.scrollHeight>e.clientHeight+1,r=e.nativeBarWidth;if(n){this.vert.style.display="block",this.vert.style.bottom=t?r+"px":"0";var i=e.viewHeight-(t?r:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+i)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=n?r+"px":"0",this.horiz.style.left=e.barLeft+"px";var o=e.viewWidth-e.barLeft-(n?r:0);this.horiz.firstChild.style.width=Math.max(0,e.scrollWidth-e.clientWidth+o)+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&e.clientHeight>0&&(0==r&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:n?r:0,bottom:t?r:0}},Pr.prototype.setScrollLeft=function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz,"horiz")},Pr.prototype.setScrollTop=function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert,"vert")},Pr.prototype.zeroWidthHack=function(){var e=x&&!f?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new P,this.disableVert=new P},Pr.prototype.enableZeroWidthBar=function(e,t,n){e.style.pointerEvents="auto",t.set(1e3,(function r(){var i=e.getBoundingClientRect();("vert"==n?document.elementFromPoint(i.right-1,(i.top+i.bottom)/2):document.elementFromPoint((i.right+i.left)/2,i.bottom-1))!=e?e.style.pointerEvents="none":t.set(1e3,r)}))},Pr.prototype.clear=function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)};var _r=function(){};function Wr(e,t){t||(t=Rr(e));var n=e.display.barWidth,r=e.display.barHeight;jr(e,t);for(var i=0;i<4&&n!=e.display.barWidth||r!=e.display.barHeight;i++)n!=e.display.barWidth&&e.options.lineWrapping&&Fr(e),jr(e,Rr(e)),n=e.display.barWidth,r=e.display.barHeight}function jr(e,t){var n=e.display,r=n.scrollbars.update(t);n.sizer.style.paddingRight=(n.barWidth=r.right)+"px",n.sizer.style.paddingBottom=(n.barHeight=r.bottom)+"px",n.heightForcer.style.borderBottom=r.bottom+"px solid transparent",r.right&&r.bottom?(n.scrollbarFiller.style.display="block",n.scrollbarFiller.style.height=r.bottom+"px",n.scrollbarFiller.style.width=r.right+"px"):n.scrollbarFiller.style.display="",r.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(n.gutterFiller.style.display="block",n.gutterFiller.style.height=r.bottom+"px",n.gutterFiller.style.width=t.gutterWidth+"px"):n.gutterFiller.style.display=""}_r.prototype.update=function(){return{bottom:0,right:0}},_r.prototype.setScrollLeft=function(){},_r.prototype.setScrollTop=function(){},_r.prototype.clear=function(){};var qr={native:Pr,null:_r};function Ur(e){e.display.scrollbars&&(e.display.scrollbars.clear(),e.display.scrollbars.addClass&&F(e.display.wrapper,e.display.scrollbars.addClass)),e.display.scrollbars=new qr[e.options.scrollbarStyle]((function(t){e.display.wrapper.insertBefore(t,e.display.scrollbarFiller),de(t,"mousedown",(function(){e.state.focused&&setTimeout((function(){return e.display.input.focus()}),0)})),t.setAttribute("cm-not-content","true")}),(function(t,n){"horizontal"==n?Hr(e,t):Ir(e,t)}),e),e.display.scrollbars.addClass&&N(e.display.wrapper,e.display.scrollbars.addClass)}var $r=0;function Gr(e){var t;e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:0,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++$r},t=e.curOp,an?an.ops.push(t):t.ownsGroup=an={ops:[t],delayedCallbacks:[]}}function Vr(e){var t=e.curOp;t&&function(e,t){var n=e.ownsGroup;if(n)try{!function(e){var t=e.delayedCallbacks,n=0;do{for(;n=n.viewTo)||n.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new oi(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function Xr(e){e.updatedDisplay=e.mustUpdate&&ai(e.cm,e.update)}function Zr(e){var t=e.cm,n=t.display;e.updatedDisplay&&Fr(t),e.barMeasure=Rr(t),n.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=Ln(t,n.maxLine,n.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(n.scroller.clientWidth,n.sizer.offsetLeft+e.adjustWidthTo+Fn(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,n.sizer.offsetLeft+e.adjustWidthTo-An(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=n.input.prepareSelection())}function Yr(e){var t=e.cm;null!=e.adjustWidthTo&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLeft(window.innerHeight||document.documentElement.clientHeight)&&(i=!1),null!=i&&!p){var o=T("div","​",null,"position: absolute;\n top: "+(t.top-n.viewOffset-wn(e.display))+"px;\n height: "+(t.bottom-t.top+Fn(e)+n.barHeight)+"px;\n left: "+t.left+"px; width: "+Math.max(2,t.right-t.left)+"px;");e.display.lineSpace.appendChild(o),o.scrollIntoView(i),e.display.lineSpace.removeChild(o)}}}(t,function(e,t,n,r){var i;null==r&&(r=0),e.options.lineWrapping||t!=n||(n="before"==(t=t.ch?et(t.line,"before"==t.sticky?t.ch-1:t.ch,"after"):t).sticky?et(t.line,t.ch+1,"before"):t);for(var o=0;o<5;o++){var a=!1,l=Vn(e,t),s=n&&n!=t?Vn(e,n):l,u=Tr(e,i={left:Math.min(l.left,s.left),top:Math.min(l.top,s.top)-r,right:Math.max(l.left,s.left),bottom:Math.max(l.bottom,s.bottom)+r}),c=e.doc.scrollTop,d=e.doc.scrollLeft;if(null!=u.scrollTop&&(Ir(e,u.scrollTop),Math.abs(e.doc.scrollTop-c)>1&&(a=!0)),null!=u.scrollLeft&&(Hr(e,u.scrollLeft),Math.abs(e.doc.scrollLeft-d)>1&&(a=!0)),!a)break}return i}(t,lt(r,e.scrollToPos.from),lt(r,e.scrollToPos.to),e.scrollToPos.margin));var i=e.maybeHiddenMarkers,o=e.maybeUnhiddenMarkers;if(i)for(var a=0;a=e.display.viewTo)){var n=+new Date+e.options.workTime,r=ft(e,t.highlightFrontier),i=[];t.iter(r.line,Math.min(t.first+t.size,e.display.viewTo+500),(function(o){if(r.line>=e.display.viewFrom){var a=o.styles,l=o.text.length>e.options.maxHighlightLength?je(t.mode,r.state):null,s=dt(e,o,r,!0);l&&(r.state=l),o.styles=s.styles;var u=o.styleClasses,c=s.classes;c?o.styleClasses=c:u&&(o.styleClasses=null);for(var d=!a||a.length!=o.styles.length||u!=c&&(!u||!c||u.bgClass!=c.bgClass||u.textClass!=c.textClass),h=0;!d&&hn)return ri(e,e.options.workDelay),!0})),t.highlightFrontier=r.line,t.modeFrontier=Math.max(t.modeFrontier,r.line),i.length&&Jr(e,(function(){for(var t=0;t=n.viewFrom&&t.visible.to<=n.viewTo&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo)&&n.renderedView==n.view&&0==mr(e))return!1;hi(e)&&(fr(e),t.dims=or(e));var i=r.first+r.size,o=Math.max(t.visible.from-e.options.viewportMargin,r.first),a=Math.min(i,t.visible.to+e.options.viewportMargin);n.viewFroma&&n.viewTo-a<20&&(a=Math.min(i,n.viewTo)),Ct&&(o=Pt(e.doc,o),a=_t(e.doc,a));var l=o!=n.viewFrom||a!=n.viewTo||n.lastWrapHeight!=t.wrapperHeight||n.lastWrapWidth!=t.wrapperWidth;!function(e,t,n){var r=e.display;0==r.view.length||t>=r.viewTo||n<=r.viewFrom?(r.view=on(e,t,n),r.viewFrom=t):(r.viewFrom>t?r.view=on(e,t,r.viewFrom).concat(r.view):r.viewFromn&&(r.view=r.view.slice(0,cr(e,n)))),r.viewTo=n}(e,o,a),n.viewOffset=qt(Ge(e.doc,n.viewFrom)),e.display.mover.style.top=n.viewOffset+"px";var u=mr(e);if(!l&&0==u&&!t.force&&n.renderedView==n.view&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo))return!1;var c=function(e){if(e.hasFocus())return null;var t=B();if(!t||!M(e.display.lineDiv,t))return null;var n={activeElt:t};if(window.getSelection){var r=window.getSelection();r.anchorNode&&r.extend&&M(e.display.lineDiv,r.anchorNode)&&(n.anchorNode=r.anchorNode,n.anchorOffset=r.anchorOffset,n.focusNode=r.focusNode,n.focusOffset=r.focusOffset)}return n}(e);return u>4&&(n.lineDiv.style.display="none"),function(e,t,n){var r=e.display,i=e.options.lineNumbers,o=r.lineDiv,a=o.firstChild;function l(t){var n=t.nextSibling;return s&&x&&e.display.currentWheelTarget==t?t.style.display="none":t.parentNode.removeChild(t),n}for(var u=r.view,c=r.viewFrom,d=0;d-1&&(f=!1),cn(e,h,c,n)),f&&(A(h.lineNumber),h.lineNumber.appendChild(document.createTextNode(Je(e.options,c)))),a=h.node.nextSibling}else{var p=vn(e,h,c,n);o.insertBefore(p,a)}c+=h.size}for(;a;)a=l(a)}(e,n.updateLineNumbers,t.dims),u>4&&(n.lineDiv.style.display=""),n.renderedView=n.view,function(e){if(e&&e.activeElt&&e.activeElt!=B()&&(e.activeElt.focus(),!/^(INPUT|TEXTAREA)$/.test(e.activeElt.nodeName)&&e.anchorNode&&M(document.body,e.anchorNode)&&M(document.body,e.focusNode))){var t=window.getSelection(),n=document.createRange();n.setEnd(e.anchorNode,e.anchorOffset),n.collapse(!1),t.removeAllRanges(),t.addRange(n),t.extend(e.focusNode,e.focusOffset)}}(c),A(n.cursorDiv),A(n.selectionDiv),n.gutters.style.height=n.sizer.style.minHeight=0,l&&(n.lastWrapHeight=t.wrapperHeight,n.lastWrapWidth=t.wrapperWidth,ri(e,400)),n.updateLineNumbers=null,!0}function li(e,t){for(var n=t.viewport,r=!0;;r=!1){if(r&&e.options.lineWrapping&&t.oldDisplayWidth!=An(e))r&&(t.visible=Er(e.display,e.doc,n));else if(n&&null!=n.top&&(n={top:Math.min(e.doc.height+kn(e.display)-En(e),n.top)}),t.visible=Er(e.display,e.doc,n),t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)break;if(!ai(e,t))break;Fr(e);var i=Rr(e);gr(e),Wr(e,i),ci(e,i),t.force=!1}t.signal(e,"update",e),e.display.viewFrom==e.display.reportedViewFrom&&e.display.viewTo==e.display.reportedViewTo||(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function si(e,t){var n=new oi(e,t);if(ai(e,n)){Fr(e),li(e,n);var r=Rr(e);gr(e),Wr(e,r),ci(e,r),n.finish()}}function ui(e){var t=e.gutters.offsetWidth;e.sizer.style.marginLeft=t+"px",sn(e,"gutterChanged",e)}function ci(e,t){e.display.sizer.style.minHeight=t.docHeight+"px",e.display.heightForcer.style.top=t.docHeight+"px",e.display.gutters.style.height=t.docHeight+e.display.barHeight+Fn(e)+"px"}function di(e){var t=e.display,n=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var r=ar(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,o=r+"px",a=0;al.clientWidth,c=l.scrollHeight>l.clientHeight;if(i&&u||o&&c){if(o&&x&&s)e:for(var h=t.target,f=a.view;h!=l;h=h.parentNode)for(var p=0;p=0&&tt(e,r.to())<=0)return n}return-1};var wi=function(e,t){this.anchor=e,this.head=t};function ki(e,t,n){var r=e&&e.options.selectionsMayTouch,i=t[n];t.sort((function(e,t){return tt(e.from(),t.from())})),n=_(t,i);for(var o=1;o0:s>=0){var u=ot(l.from(),a.from()),c=it(l.to(),a.to()),d=l.empty()?a.from()==a.head:l.from()==l.head;o<=n&&--n,t.splice(--o,2,new wi(d?c:u,d?u:c))}}return new Ci(t,n)}function Si(e,t){return new Ci([new wi(e,t||e)],0)}function Fi(e){return e.text?et(e.from.line+e.text.length-1,K(e.text).length+(1==e.text.length?e.from.ch:0)):e.to}function Ai(e,t){if(tt(e,t.from)<0)return e;if(tt(e,t.to)<=0)return Fi(t);var n=e.line+t.text.length-(t.to.line-t.from.line)-1,r=e.ch;return e.line==t.to.line&&(r+=Fi(t).ch-t.to.ch),et(n,r)}function Ei(e,t){for(var n=[],r=0;r1&&e.remove(l.line+1,p-1),e.insert(l.line+1,v)}sn(e,"change",e,t)}function Oi(e,t,n){!function e(r,i,o){if(r.linked)for(var a=0;al-(e.cm?e.cm.options.historyEventDelay:500)||"*"==t.origin.charAt(0)))&&(o=function(e,t){return t?(Pi(e.done),K(e.done)):e.done.length&&!K(e.done).ranges?K(e.done):e.done.length>1&&!e.done[e.done.length-2].ranges?(e.done.pop(),K(e.done)):void 0}(i,i.lastOp==r)))a=K(o.changes),0==tt(t.from,t.to)&&0==tt(t.from,a.to)?a.to=Fi(t):o.changes.push(Ri(e,t));else{var s=K(i.done);for(s&&s.ranges||ji(e.sel,i.done),o={changes:[Ri(e,t)],generation:i.generation},i.done.push(o);i.done.length>i.undoDepth;)i.done.shift(),i.done[0].ranges||i.done.shift()}i.done.push(n),i.generation=++i.maxGeneration,i.lastModTime=i.lastSelTime=l,i.lastOp=i.lastSelOp=r,i.lastOrigin=i.lastSelOrigin=t.origin,a||pe(e,"historyAdded")}function Wi(e,t,n,r){var i=e.history,o=r&&r.origin;n==i.lastSelOp||o&&i.lastSelOrigin==o&&(i.lastModTime==i.lastSelTime&&i.lastOrigin==o||function(e,t,n,r){var i=t.charAt(0);return"*"==i||"+"==i&&n.ranges.length==r.ranges.length&&n.somethingSelected()==r.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}(e,o,K(i.done),t))?i.done[i.done.length-1]=t:ji(t,i.done),i.lastSelTime=+new Date,i.lastSelOrigin=o,i.lastSelOp=n,r&&!1!==r.clearRedo&&Pi(i.undone)}function ji(e,t){var n=K(t);n&&n.ranges&&n.equals(e)||t.push(e)}function qi(e,t,n,r){var i=t["spans_"+e.id],o=0;e.iter(Math.max(e.first,n),Math.min(e.first+e.size,r),(function(n){n.markedSpans&&((i||(i=t["spans_"+e.id]={}))[o]=n.markedSpans),++o}))}function Ui(e){if(!e)return null;for(var t,n=0;n-1&&(K(l)[d]=u[d],delete u[d])}}}return r}function Vi(e,t,n,r){if(r){var i=e.anchor;if(n){var o=tt(t,i)<0;o!=tt(n,i)<0?(i=t,t=n):o!=tt(t,n)<0&&(t=n)}return new wi(i,t)}return new wi(n||t,t)}function Ki(e,t,n,r,i){null==i&&(i=e.cm&&(e.cm.display.shift||e.extend)),Ji(e,new Ci([Vi(e.sel.primary(),t,n,i)],0),r)}function Xi(e,t,n){for(var r=[],i=e.cm&&(e.cm.display.shift||e.extend),o=0;o=t.ch:l.to>t.ch))){if(i&&(pe(s,"beforeCursorEnter"),s.explicitlyCleared)){if(o.markedSpans){--a;continue}break}if(!s.atomic)continue;if(n){var d=s.find(r<0?1:-1),h=void 0;if((r<0?c:u)&&(d=ao(e,d,-r,d&&d.line==t.line?o:null)),d&&d.line==t.line&&(h=tt(d,n))&&(r<0?h<0:h>0))return io(e,d,t,r,i)}var f=s.find(r<0?-1:1);return(r<0?u:c)&&(f=ao(e,f,r,f.line==t.line?o:null)),f?io(e,f,t,r,i):null}}return t}function oo(e,t,n,r,i){var o=r||1,a=io(e,t,n,o,i)||!i&&io(e,t,n,o,!0)||io(e,t,n,-o,i)||!i&&io(e,t,n,-o,!0);return a||(e.cantEdit=!0,et(e.first,0))}function ao(e,t,n,r){return n<0&&0==t.ch?t.line>e.first?lt(e,et(t.line-1)):null:n>0&&t.ch==(r||Ge(e,t.line)).text.length?t.line0)){var c=[s,1],d=tt(u.from,l.from),h=tt(u.to,l.to);(d<0||!a.inclusiveLeft&&!d)&&c.push({from:u.from,to:l.from}),(h>0||!a.inclusiveRight&&!h)&&c.push({from:l.to,to:u.to}),i.splice.apply(i,c),s+=c.length-3}}return i}(e,t.from,t.to);if(r)for(var i=r.length-1;i>=0;--i)co(e,{from:r[i].from,to:r[i].to,text:i?[""]:t.text,origin:t.origin});else co(e,t)}}function co(e,t){if(1!=t.text.length||""!=t.text[0]||0!=tt(t.from,t.to)){var n=Ei(e,t);_i(e,t,n,e.cm?e.cm.curOp.id:NaN),po(e,t,n,Ft(e,t));var r=[];Oi(e,(function(e,n){n||-1!=_(r,e.history)||(xo(e.history,t),r.push(e.history)),po(e,t,null,Ft(e,t))}))}}function ho(e,t,n){var r=e.cm&&e.cm.state.suppressEdits;if(!r||n){for(var i,o=e.history,a=e.sel,l="undo"==t?o.done:o.undone,s="undo"==t?o.undone:o.done,u=0;u=0;--f){var p=h(f);if(p)return p.v}}}}function fo(e,t){if(0!=t&&(e.first+=t,e.sel=new Ci(X(e.sel.ranges,(function(e){return new wi(et(e.anchor.line+t,e.anchor.ch),et(e.head.line+t,e.head.ch))})),e.sel.primIndex),e.cm)){dr(e.cm,e.first,e.first-t,t);for(var n=e.cm.display,r=n.viewFrom;re.lastLine())){if(t.from.lineo&&(t={from:t.from,to:et(o,Ge(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=Ve(e,t.from,t.to),n||(n=Ei(e,t)),e.cm?function(e,t,n){var r=e.doc,i=e.display,o=t.from,a=t.to,l=!1,s=o.line;e.options.lineWrapping||(s=Ze(Rt(Ge(r,o.line))),r.iter(s,a.line+1,(function(e){if(e==i.maxLine)return l=!0,!0})));r.sel.contains(t.from,t.to)>-1&&ge(e);Ni(r,t,n,lr(e)),e.options.lineWrapping||(r.iter(s,o.line+t.text.length,(function(e){var t=Ut(e);t>i.maxLineLength&&(i.maxLine=e,i.maxLineLength=t,i.maxLineChanged=!0,l=!1)})),l&&(e.curOp.updateMaxLine=!0));(function(e,t){if(e.modeFrontier=Math.min(e.modeFrontier,t),!(e.highlightFrontiern;r--){var i=Ge(e,r).stateAfter;if(i&&(!(i instanceof ut)||r+i.lookAhead1||!(this.children[0]instanceof bo))){var l=[];this.collapse(l),this.children=[new bo(l)],this.children[0].parent=this}},collapse:function(e){for(var t=0;t50){for(var a=i.lines.length%25+25,l=a;l10);e.parent.maybeSpill()}},iterN:function(e,t,n){for(var r=0;r0||0==a&&!1!==o.clearWhenEmpty)return o;if(o.replacedWith&&(o.collapsed=!0,o.widgetNode=L("span",[o.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||o.widgetNode.setAttribute("cm-ignore-events","true"),r.insertLeft&&(o.widgetNode.insertLeft=!0)),o.collapsed){if(Ht(e,t.line,t,n,o)||t.line!=n.line&&Ht(e,n.line,t,n,o))throw new Error("Inserting collapsed marker partially overlapping an existing one");Ct=!0}o.addToHistory&&_i(e,{from:t,to:n,origin:"markText"},e.sel,NaN);var l,s=t.line,u=e.cm;if(e.iter(s,n.line+1,(function(e){u&&o.collapsed&&!u.options.lineWrapping&&Rt(e)==u.display.maxLine&&(l=!0),o.collapsed&&s!=t.line&&Xe(e,0),function(e,t){e.markedSpans=e.markedSpans?e.markedSpans.concat([t]):[t],t.marker.attachLine(e)}(e,new wt(o,s==t.line?t.ch:null,s==n.line?n.ch:null)),++s})),o.collapsed&&e.iter(t.line,n.line+1,(function(t){Wt(e,t)&&Xe(t,0)})),o.clearOnEnter&&de(o,"beforeCursorEnter",(function(){return o.clear()})),o.readOnly&&(Dt=!0,(e.history.done.length||e.history.undone.length)&&e.clearHistory()),o.collapsed&&(o.id=++ko,o.atomic=!0),u){if(l&&(u.curOp.updateMaxLine=!0),o.collapsed)dr(u,t.line,n.line+1);else if(o.className||o.startStyle||o.endStyle||o.css||o.attributes||o.title)for(var c=t.line;c<=n.line;c++)hr(u,c,"text");o.atomic&&no(u.doc),sn(u,"markerAdded",u,o)}return o}So.prototype.clear=function(){if(!this.explicitlyCleared){var e=this.doc.cm,t=e&&!e.curOp;if(t&&Gr(e),ve(this,"clear")){var n=this.find();n&&sn(this,"clear",n.from,n.to)}for(var r=null,i=null,o=0;oe.display.maxLineLength&&(e.display.maxLine=u,e.display.maxLineLength=c,e.display.maxLineChanged=!0)}null!=r&&e&&this.collapsed&&dr(e,r,i+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&no(e.doc)),e&&sn(e,"markerCleared",e,this,r,i),t&&Vr(e),this.parent&&this.parent.clear()}},So.prototype.find=function(e,t){var n,r;null==e&&"bookmark"==this.type&&(e=1);for(var i=0;i=0;s--)uo(this,r[s]);l?Qi(this,l):this.cm&&Mr(this.cm)})),undo:ni((function(){ho(this,"undo")})),redo:ni((function(){ho(this,"redo")})),undoSelection:ni((function(){ho(this,"undo",!0)})),redoSelection:ni((function(){ho(this,"redo",!0)})),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){for(var e=this.history,t=0,n=0,r=0;r=e.ch)&&t.push(i.marker.parent||i.marker)}return t},findMarks:function(e,t,n){e=lt(this,e),t=lt(this,t);var r=[],i=e.line;return this.iter(e.line,t.line+1,(function(o){var a=o.markedSpans;if(a)for(var l=0;l=s.to||null==s.from&&i!=e.line||null!=s.from&&i==t.line&&s.from>=t.ch||n&&!n(s.marker)||r.push(s.marker.parent||s.marker)}++i})),r},getAllMarks:function(){var e=[];return this.iter((function(t){var n=t.markedSpans;if(n)for(var r=0;re)return t=e,!0;e-=o,++n})),lt(this,et(n,t))},indexFromPos:function(e){var t=(e=lt(this,e)).ch;if(e.linet&&(t=e.from),null!=e.to&&e.to-1)return t.state.draggingText(e),void setTimeout((function(){return t.display.input.focus()}),20);try{var d=e.dataTransfer.getData("Text");if(d){var h;if(t.state.draggingText&&!t.state.draggingText.copy&&(h=t.listSelections()),eo(t.doc,Si(n,n)),h)for(var f=0;f=0;t--)mo(e.doc,"",r[t].from,r[t].to,"+delete");Mr(e)}))}function Qo(e,t,n){var r=ie(e.text,t+n,n);return r<0||r>e.text.length?null:r}function Jo(e,t,n){var r=Qo(e,t.ch,n);return null==r?null:new et(t.line,r,n<0?"after":"before")}function ea(e,t,n,r,i){if(e){"rtl"==t.doc.direction&&(i=-i);var o=ue(n,t.doc.direction);if(o){var a,l=i<0?K(o):o[0],s=i<0==(1==l.level)?"after":"before";if(l.level>0||"rtl"==t.doc.direction){var u=Bn(t,n);a=i<0?n.text.length-1:0;var c=Nn(t,u,a).top;a=oe((function(e){return Nn(t,u,e).top==c}),i<0==(1==l.level)?l.from:l.to-1,a),"before"==s&&(a=Qo(n,a,1))}else a=i<0?l.to:l.from;return new et(r,a,s)}}return new et(r,i<0?n.text.length:0,i<0?"before":"after")}qo.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},qo.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},qo.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars","Ctrl-O":"openLine"},qo.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},qo.default=x?qo.macDefault:qo.pcDefault;var ta={selectAll:lo,singleSelection:function(e){return e.setSelection(e.getCursor("anchor"),e.getCursor("head"),j)},killLine:function(e){return Yo(e,(function(t){if(t.empty()){var n=Ge(e.doc,t.head.line).text.length;return t.head.ch==n&&t.head.line0)i=new et(i.line,i.ch+1),e.replaceRange(o.charAt(i.ch-1)+o.charAt(i.ch-2),et(i.line,i.ch-2),i,"+transpose");else if(i.line>e.doc.first){var a=Ge(e.doc,i.line-1).text;a&&(i=new et(i.line,1),e.replaceRange(o.charAt(0)+e.doc.lineSeparator()+a.charAt(a.length-1),et(i.line-1,a.length-1),i,"+transpose"))}n.push(new wi(i,i))}e.setSelections(n)}))},newlineAndIndent:function(e){return Jr(e,(function(){for(var t=e.listSelections(),n=t.length-1;n>=0;n--)e.replaceRange(e.doc.lineSeparator(),t[n].anchor,t[n].head,"+input");t=e.listSelections();for(var r=0;r-1&&(tt((i=u.ranges[i]).from(),t)<0||t.xRel>0)&&(tt(i.to(),t)>0||t.xRel<0)?function(e,t,n,r){var i=e.display,o=!1,u=ei(e,(function(t){s&&(i.scroller.draggable=!1),e.state.draggingText=!1,e.state.delayingBlurEvent&&(e.hasFocus()?e.state.delayingBlurEvent=!1:wr(e)),fe(i.wrapper.ownerDocument,"mouseup",u),fe(i.wrapper.ownerDocument,"mousemove",c),fe(i.scroller,"dragstart",d),fe(i.scroller,"drop",u),o||(ye(t),r.addNew||Ki(e.doc,n,null,null,r.extend),s&&!h||a&&9==l?setTimeout((function(){i.wrapper.ownerDocument.body.focus({preventScroll:!0}),i.input.focus()}),20):i.input.focus())})),c=function(e){o=o||Math.abs(t.clientX-e.clientX)+Math.abs(t.clientY-e.clientY)>=10},d=function(){return o=!0};s&&(i.scroller.draggable=!0);e.state.draggingText=u,u.copy=!r.moveOnDrag,de(i.wrapper.ownerDocument,"mouseup",u),de(i.wrapper.ownerDocument,"mousemove",c),de(i.scroller,"dragstart",d),de(i.scroller,"drop",u),e.state.delayingBlurEvent=!0,setTimeout((function(){return i.input.focus()}),20),i.scroller.dragDrop&&i.scroller.dragDrop()}(e,r,t,o):function(e,t,n,r){a&&wr(e);var i=e.display,o=e.doc;ye(t);var l,s,u=o.sel,c=u.ranges;r.addNew&&!r.extend?(s=o.sel.contains(n),l=s>-1?c[s]:new wi(n,n)):(l=o.sel.primary(),s=o.sel.primIndex);if("rectangle"==r.unit)r.addNew||(l=new wi(n,n)),n=ur(e,t,!0,!0),s=-1;else{var d=va(e,n,r.unit);l=r.extend?Vi(l,d.anchor,d.head,r.extend):d}r.addNew?-1==s?(s=c.length,Ji(o,ki(e,c.concat([l]),s),{scroll:!1,origin:"*mouse"})):c.length>1&&c[s].empty()&&"char"==r.unit&&!r.extend?(Ji(o,ki(e,c.slice(0,s).concat(c.slice(s+1)),0),{scroll:!1,origin:"*mouse"}),u=o.sel):Zi(o,s,l,q):(s=0,Ji(o,new Ci([l],0),q),u=o.sel);var h=n;function f(t){if(0!=tt(h,t))if(h=t,"rectangle"==r.unit){for(var i=[],a=e.options.tabSize,c=R(Ge(o,n.line).text,n.ch,a),d=R(Ge(o,t.line).text,t.ch,a),f=Math.min(c,d),p=Math.max(c,d),m=Math.min(n.line,t.line),g=Math.min(e.lastLine(),Math.max(n.line,t.line));m<=g;m++){var v=Ge(o,m).text,x=$(v,f,a);f==p?i.push(new wi(et(m,x),et(m,x))):v.length>x&&i.push(new wi(et(m,x),et(m,$(v,p,a))))}i.length||i.push(new wi(n,n)),Ji(o,ki(e,u.ranges.slice(0,s).concat(i),s),{origin:"*mouse",scroll:!1}),e.scrollIntoView(t)}else{var y,b=l,D=va(e,t,r.unit),C=b.anchor;tt(D.anchor,C)>0?(y=D.head,C=ot(b.from(),D.anchor)):(y=D.anchor,C=it(b.to(),D.head));var w=u.ranges.slice(0);w[s]=function(e,t){var n=t.anchor,r=t.head,i=Ge(e.doc,n.line);if(0==tt(n,r)&&n.sticky==r.sticky)return t;var o=ue(i);if(!o)return t;var a=le(o,n.ch,n.sticky),l=o[a];if(l.from!=n.ch&&l.to!=n.ch)return t;var s,u=a+(l.from==n.ch==(1!=l.level)?0:1);if(0==u||u==o.length)return t;if(r.line!=n.line)s=(r.line-n.line)*("ltr"==e.doc.direction?1:-1)>0;else{var c=le(o,r.ch,r.sticky),d=c-a||(r.ch-n.ch)*(1==l.level?-1:1);s=c==u-1||c==u?d<0:d>0}var h=o[u+(s?-1:0)],f=s==(1==h.level),p=f?h.from:h.to,m=f?"after":"before";return n.ch==p&&n.sticky==m?t:new wi(new et(n.line,p,m),r)}(e,new wi(lt(o,C),y)),Ji(o,ki(e,w,s),q)}}var p=i.wrapper.getBoundingClientRect(),m=0;function g(t){var n=++m,a=ur(e,t,!0,"rectangle"==r.unit);if(a)if(0!=tt(a,h)){e.curOp.focus=B(),f(a);var l=Er(i,o);(a.line>=l.to||a.linep.bottom?20:0;s&&setTimeout(ei(e,(function(){m==n&&(i.scroller.scrollTop+=s,g(t))})),50)}}function v(t){e.state.selectingText=!1,m=1/0,t&&(ye(t),i.input.focus()),fe(i.wrapper.ownerDocument,"mousemove",x),fe(i.wrapper.ownerDocument,"mouseup",y),o.history.lastSelOrigin=null}var x=ei(e,(function(e){0!==e.buttons&&ke(e)?g(e):v(e)})),y=ei(e,v);e.state.selectingText=y,de(i.wrapper.ownerDocument,"mousemove",x),de(i.wrapper.ownerDocument,"mouseup",y)}(e,r,t,o)}(t,r,o,e):we(e)==n.scroller&&ye(e):2==i?(r&&Ki(t.doc,r),setTimeout((function(){return n.input.focus()}),20)):3==i&&(w?t.display.input.onContextMenu(e):wr(t)))}}function va(e,t,n){if("char"==n)return new wi(t,t);if("word"==n)return e.findWordAt(t);if("line"==n)return new wi(et(t.line,0),lt(e.doc,et(t.line+1,0)));var r=n(e,t);return new wi(r.from,r.to)}function xa(e,t,n,r){var i,o;if(t.touches)i=t.touches[0].clientX,o=t.touches[0].clientY;else try{i=t.clientX,o=t.clientY}catch(e){return!1}if(i>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&ye(t);var a=e.display,l=a.lineDiv.getBoundingClientRect();if(o>l.bottom||!ve(e,n))return De(t);o-=l.top-a.viewOffset;for(var s=0;s=i)return pe(e,n,e,Ye(e.doc,o),e.display.gutterSpecs[s].className,t),De(t)}}function ya(e,t){return xa(e,t,"gutterClick",!0)}function ba(e,t){Cn(e.display,t)||function(e,t){if(!ve(e,"gutterContextMenu"))return!1;return xa(e,t,"gutterContextMenu",!1)}(e,t)||me(e,t,"contextmenu")||w||e.display.input.onContextMenu(t)}function Da(e){e.display.wrapper.className=e.display.wrapper.className.replace(/\s*cm-s-\S+/g,"")+e.options.theme.replace(/(^|\s)\s*/g," cm-s-"),_n(e)}ma.prototype.compare=function(e,t,n){return this.time+400>e&&0==tt(t,this.pos)&&n==this.button};var Ca={toString:function(){return"CodeMirror.Init"}},wa={},ka={};function Sa(e,t,n){if(!t!=!(n&&n!=Ca)){var r=e.display.dragFunctions,i=t?de:fe;i(e.display.scroller,"dragstart",r.start),i(e.display.scroller,"dragenter",r.enter),i(e.display.scroller,"dragover",r.over),i(e.display.scroller,"dragleave",r.leave),i(e.display.scroller,"drop",r.drop)}}function Fa(e){e.options.lineWrapping?(N(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(F(e.display.wrapper,"CodeMirror-wrap"),$t(e)),sr(e),dr(e),_n(e),setTimeout((function(){return Wr(e)}),100)}function Aa(e,t){var n=this;if(!(this instanceof Aa))return new Aa(e,t);this.options=t=t?H(t):{},H(wa,t,!1);var r=t.value;"string"==typeof r?r=new Mo(r,t.mode,null,t.lineSeparator,t.direction):t.mode&&(r.modeOption=t.mode),this.doc=r;var i=new Aa.inputStyles[t.inputStyle](this),o=this.display=new gi(e,r,i,t);for(var u in o.wrapper.CodeMirror=this,Da(this),t.lineWrapping&&(this.display.wrapper.className+=" CodeMirror-wrap"),Ur(this),this.state={keyMaps:[],overlays:[],modeGen:0,overwrite:!1,delayingBlurEvent:!1,focused:!1,suppressEdits:!1,pasteIncoming:-1,cutIncoming:-1,selectingText:!1,draggingText:!1,highlight:new P,keySeq:null,specialChars:null},t.autofocus&&!v&&o.input.focus(),a&&l<11&&setTimeout((function(){return n.display.input.reset(!0)}),20),function(e){var t=e.display;de(t.scroller,"mousedown",ei(e,ga)),de(t.scroller,"dblclick",a&&l<11?ei(e,(function(t){if(!me(e,t)){var n=ur(e,t);if(n&&!ya(e,t)&&!Cn(e.display,t)){ye(t);var r=e.findWordAt(n);Ki(e.doc,r.anchor,r.head)}}})):function(t){return me(e,t)||ye(t)});de(t.scroller,"contextmenu",(function(t){return ba(e,t)})),de(t.input.getField(),"contextmenu",(function(n){t.scroller.contains(n.target)||ba(e,n)}));var n,r={end:0};function i(){t.activeTouch&&(n=setTimeout((function(){return t.activeTouch=null}),1e3),(r=t.activeTouch).end=+new Date)}function o(e){if(1!=e.touches.length)return!1;var t=e.touches[0];return t.radiusX<=1&&t.radiusY<=1}function s(e,t){if(null==t.left)return!0;var n=t.left-e.left,r=t.top-e.top;return n*n+r*r>400}de(t.scroller,"touchstart",(function(i){if(!me(e,i)&&!o(i)&&!ya(e,i)){t.input.ensurePolled(),clearTimeout(n);var a=+new Date;t.activeTouch={start:a,moved:!1,prev:a-r.end<=300?r:null},1==i.touches.length&&(t.activeTouch.left=i.touches[0].pageX,t.activeTouch.top=i.touches[0].pageY)}})),de(t.scroller,"touchmove",(function(){t.activeTouch&&(t.activeTouch.moved=!0)})),de(t.scroller,"touchend",(function(n){var r=t.activeTouch;if(r&&!Cn(t,n)&&null!=r.left&&!r.moved&&new Date-r.start<300){var o,a=e.coordsChar(t.activeTouch,"page");o=!r.prev||s(r,r.prev)?new wi(a,a):!r.prev.prev||s(r,r.prev.prev)?e.findWordAt(a):new wi(et(a.line,0),lt(e.doc,et(a.line+1,0))),e.setSelection(o.anchor,o.head),e.focus(),ye(n)}i()})),de(t.scroller,"touchcancel",i),de(t.scroller,"scroll",(function(){t.scroller.clientHeight&&(Ir(e,t.scroller.scrollTop),Hr(e,t.scroller.scrollLeft,!0),pe(e,"scroll",e))})),de(t.scroller,"mousewheel",(function(t){return Di(e,t)})),de(t.scroller,"DOMMouseScroll",(function(t){return Di(e,t)})),de(t.wrapper,"scroll",(function(){return t.wrapper.scrollTop=t.wrapper.scrollLeft=0})),t.dragFunctions={enter:function(t){me(e,t)||Ce(t)},over:function(t){me(e,t)||(!function(e,t){var n=ur(e,t);if(n){var r=document.createDocumentFragment();xr(e,n,r),e.display.dragCursor||(e.display.dragCursor=T("div",null,"CodeMirror-cursors CodeMirror-dragcursors"),e.display.lineSpace.insertBefore(e.display.dragCursor,e.display.cursorDiv)),E(e.display.dragCursor,r)}}(e,t),Ce(t))},start:function(t){return function(e,t){if(a&&(!e.state.draggingText||+new Date-Bo<100))Ce(t);else if(!me(e,t)&&!Cn(e.display,t)&&(t.dataTransfer.setData("Text",e.getSelection()),t.dataTransfer.effectAllowed="copyMove",t.dataTransfer.setDragImage&&!h)){var n=T("img",null,null,"position: fixed; left: 0; top: 0;");n.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",d&&(n.width=n.height=1,e.display.wrapper.appendChild(n),n._top=n.offsetTop),t.dataTransfer.setDragImage(n,0,0),d&&n.parentNode.removeChild(n)}}(e,t)},drop:ei(e,No),leave:function(t){me(e,t)||Oo(e)}};var u=t.input.getField();de(u,"keyup",(function(t){return da.call(e,t)})),de(u,"keydown",ei(e,ca)),de(u,"keypress",ei(e,ha)),de(u,"focus",(function(t){return kr(e,t)})),de(u,"blur",(function(t){return Sr(e,t)}))}(this),Ho(),Gr(this),this.curOp.forceUpdate=!0,Ii(this,r),t.autofocus&&!v||this.hasFocus()?setTimeout((function(){n.hasFocus()&&!n.state.focused&&kr(n)}),20):Sr(this),ka)ka.hasOwnProperty(u)&&ka[u](this,t[u],Ca);hi(this),t.finishInit&&t.finishInit(this);for(var c=0;c150)){if(!r)return;n="prev"}}else u=0,n="not";"prev"==n?u=t>o.first?R(Ge(o,t-1).text,null,a):0:"add"==n?u=s+e.options.indentUnit:"subtract"==n?u=s-e.options.indentUnit:"number"==typeof n&&(u=s+n),u=Math.max(0,u);var d="",h=0;if(e.options.indentWithTabs)for(var f=Math.floor(u/a);f;--f)h+=a,d+="\t";if(ha,s=Me(t),u=null;if(l&&r.ranges.length>1)if(La&&La.text.join("\n")==t){if(r.ranges.length%La.text.length==0){u=[];for(var c=0;c=0;h--){var f=r.ranges[h],p=f.from(),m=f.to();f.empty()&&(n&&n>0?p=et(p.line,p.ch-n):e.state.overwrite&&!l?m=et(m.line,Math.min(Ge(o,m.line).text.length,m.ch+K(s).length)):l&&La&&La.lineWise&&La.text.join("\n")==s.join("\n")&&(p=m=et(p.line,0)));var g={from:p,to:m,text:u?u[h%u.length]:s,origin:i||(l?"paste":e.state.cutIncoming>a?"cut":"+input")};uo(e.doc,g),sn(e,"inputRead",e,g)}t&&!l&&Oa(e,t),Mr(e),e.curOp.updateInput<2&&(e.curOp.updateInput=d),e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=-1}function Na(e,t){var n=e.clipboardData&&e.clipboardData.getData("Text");if(n)return e.preventDefault(),t.isReadOnly()||t.options.disableInput||Jr(t,(function(){return Ba(t,n,0,null,"paste")})),!0}function Oa(e,t){if(e.options.electricChars&&e.options.smartIndent)for(var n=e.doc.sel,r=n.ranges.length-1;r>=0;r--){var i=n.ranges[r];if(!(i.head.ch>100||r&&n.ranges[r-1].head.line==i.head.line)){var o=e.getModeAt(i.head),a=!1;if(o.electricChars){for(var l=0;l-1){a=Ta(e,i.head.line,"smart");break}}else o.electricInput&&o.electricInput.test(Ge(e.doc,i.head.line).text.slice(0,i.head.ch))&&(a=Ta(e,i.head.line,"smart"));a&&sn(e,"electricInput",e,i.head.line)}}}function Ia(e){for(var t=[],n=[],r=0;r0?0:-1));if(isNaN(c))a=null;else{var d=n>0?c>=55296&&c<56320:c>=56320&&c<57343;a=new et(t.line,Math.max(0,Math.min(l.text.length,t.ch+n*(d?2:1))),-n)}}else a=i?function(e,t,n,r){var i=ue(t,e.doc.direction);if(!i)return Jo(t,n,r);n.ch>=t.text.length?(n.ch=t.text.length,n.sticky="before"):n.ch<=0&&(n.ch=0,n.sticky="after");var o=le(i,n.ch,n.sticky),a=i[o];if("ltr"==e.doc.direction&&a.level%2==0&&(r>0?a.to>n.ch:a.from=a.from&&h>=c.begin)){var f=d?"before":"after";return new et(n.line,h,f)}}var p=function(e,t,r){for(var o=function(e,t){return t?new et(n.line,s(e,1),"before"):new et(n.line,e,"after")};e>=0&&e0==(1!=a.level),u=l?r.begin:s(r.end,-1);if(a.from<=u&&u0?c.end:s(c.begin,-1);return null==g||r>0&&g==t.text.length||!(m=p(r>0?0:i.length-1,r,u(g)))?null:m}(e.cm,l,t,n):Jo(l,t,n);if(null==a){if(o||(u=t.line+s)=e.first+e.size||(t=new et(u,t.ch,t.sticky),!(l=Ge(e,u))))return!1;t=ea(i,e.cm,l,t.line,s)}else t=a;return!0}if("char"==r||"codepoint"==r)u();else if("column"==r)u(!0);else if("word"==r||"group"==r)for(var c=null,d="group"==r,h=e.cm&&e.cm.getHelper(t,"wordChars"),f=!0;!(n<0)||u(!f);f=!1){var p=l.text.charAt(t.ch)||"\n",m=ee(p,h)?"w":d&&"\n"==p?"n":!d||/\s/.test(p)?null:"p";if(!d||f||m||(m="s"),c&&c!=m){n<0&&(n=1,u(),t.sticky="after");break}if(m&&(c=m),n>0&&!u(!f))break}var g=oo(e,t,o,a,!0);return nt(o,g)&&(g.hitSide=!0),g}function Pa(e,t,n,r){var i,o,a=e.doc,l=t.left;if("page"==r){var s=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight),u=Math.max(s-.5*rr(e.display),3);i=(n>0?t.bottom:t.top)+n*u}else"line"==r&&(i=n>0?t.bottom+3:t.top-3);for(;(o=Zn(e,l,i)).outside;){if(n<0?i<=0:i>=a.height){o.hitSide=!0;break}i+=5*n}return o}var _a=function(e){this.cm=e,this.lastAnchorNode=this.lastAnchorOffset=this.lastFocusNode=this.lastFocusOffset=null,this.polling=new P,this.composing=null,this.gracePeriod=!1,this.readDOMTimeout=null};function Wa(e,t){var n=Mn(e,t.line);if(!n||n.hidden)return null;var r=Ge(e.doc,t.line),i=Tn(n,r,t.line),o=ue(r,e.doc.direction),a="left";o&&(a=le(o,t.ch)%2?"right":"left");var l=zn(i.map,t.ch,a);return l.offset="right"==l.collapse?l.end:l.start,l}function ja(e,t){return t&&(e.bad=!0),e}function qa(e,t,n){var r;if(t==e.display.lineDiv){if(!(r=e.display.lineDiv.childNodes[n]))return ja(e.clipPos(et(e.display.viewTo-1)),!0);t=null,n=0}else for(r=t;;r=r.parentNode){if(!r||r==e.display.lineDiv)return null;if(r.parentNode&&r.parentNode==e.display.lineDiv)break}for(var i=0;i=t.display.viewTo||o.line=t.display.viewFrom&&Wa(t,i)||{node:s[0].measure.map[2],offset:0},c=o.liner.firstLine()&&(a=et(a.line-1,Ge(r.doc,a.line-1).length)),l.ch==Ge(r.doc,l.line).text.length&&l.linei.viewTo-1)return!1;a.line==i.viewFrom||0==(e=cr(r,a.line))?(t=Ze(i.view[0].line),n=i.view[0].node):(t=Ze(i.view[e].line),n=i.view[e-1].node.nextSibling);var s,u,c=cr(r,l.line);if(c==i.view.length-1?(s=i.viewTo-1,u=i.lineDiv.lastChild):(s=Ze(i.view[c+1].line)-1,u=i.view[c+1].node.previousSibling),!n)return!1;for(var d=r.doc.splitLines(function(e,t,n,r,i){var o="",a=!1,l=e.doc.lineSeparator(),s=!1;function u(e){return function(t){return t.id==e}}function c(){a&&(o+=l,s&&(o+=l),a=s=!1)}function d(e){e&&(c(),o+=e)}function h(t){if(1==t.nodeType){var n=t.getAttribute("cm-text");if(n)return void d(n);var o,f=t.getAttribute("cm-marker");if(f){var p=e.findMarks(et(r,0),et(i+1,0),u(+f));return void(p.length&&(o=p[0].find(0))&&d(Ve(e.doc,o.from,o.to).join(l)))}if("false"==t.getAttribute("contenteditable"))return;var m=/^(pre|div|p|li|table|br)$/i.test(t.nodeName);if(!/^br$/i.test(t.nodeName)&&0==t.textContent.length)return;m&&c();for(var g=0;g1&&h.length>1;)if(K(d)==K(h))d.pop(),h.pop(),s--;else{if(d[0]!=h[0])break;d.shift(),h.shift(),t++}for(var f=0,p=0,m=d[0],g=h[0],v=Math.min(m.length,g.length);fa.ch&&x.charCodeAt(x.length-p-1)==y.charCodeAt(y.length-p-1);)f--,p++;d[d.length-1]=x.slice(0,x.length-p).replace(/^\u200b+/,""),d[0]=d[0].slice(f).replace(/\u200b+$/,"");var D=et(t,f),C=et(s,h.length?K(h).length-p:0);return d.length>1||d[0]||tt(D,C)?(mo(r.doc,d,D,C,"+input"),!0):void 0},_a.prototype.ensurePolled=function(){this.forceCompositionEnd()},_a.prototype.reset=function(){this.forceCompositionEnd()},_a.prototype.forceCompositionEnd=function(){this.composing&&(clearTimeout(this.readDOMTimeout),this.composing=null,this.updateFromDOM(),this.div.blur(),this.div.focus())},_a.prototype.readFromDOMSoon=function(){var e=this;null==this.readDOMTimeout&&(this.readDOMTimeout=setTimeout((function(){if(e.readDOMTimeout=null,e.composing){if(!e.composing.done)return;e.composing=null}e.updateFromDOM()}),80))},_a.prototype.updateFromDOM=function(){var e=this;!this.cm.isReadOnly()&&this.pollContent()||Jr(this.cm,(function(){return dr(e.cm)}))},_a.prototype.setUneditable=function(e){e.contentEditable="false"},_a.prototype.onKeyPress=function(e){0==e.charCode||this.composing||(e.preventDefault(),this.cm.isReadOnly()||ei(this.cm,Ba)(this.cm,String.fromCharCode(null==e.charCode?e.keyCode:e.charCode),0))},_a.prototype.readOnlyChanged=function(e){this.div.contentEditable=String("nocursor"!=e)},_a.prototype.onContextMenu=function(){},_a.prototype.resetPosition=function(){},_a.prototype.needsContentAttribute=!0;var $a=function(e){this.cm=e,this.prevInput="",this.pollingFast=!1,this.polling=new P,this.hasSelection=!1,this.composing=null};$a.prototype.init=function(e){var t=this,n=this,r=this.cm;this.createField(e);var i=this.textarea;function o(e){if(!me(r,e)){if(r.somethingSelected())Ma({lineWise:!1,text:r.getSelections()});else{if(!r.options.lineWiseCopyCut)return;var t=Ia(r);Ma({lineWise:!0,text:t.text}),"cut"==e.type?r.setSelections(t.ranges,null,j):(n.prevInput="",i.value=t.text.join("\n"),I(i))}"cut"==e.type&&(r.state.cutIncoming=+new Date)}}e.wrapper.insertBefore(this.wrapper,e.wrapper.firstChild),m&&(i.style.width="0px"),de(i,"input",(function(){a&&l>=9&&t.hasSelection&&(t.hasSelection=null),n.poll()})),de(i,"paste",(function(e){me(r,e)||Na(e,r)||(r.state.pasteIncoming=+new Date,n.fastPoll())})),de(i,"cut",o),de(i,"copy",o),de(e.scroller,"paste",(function(t){if(!Cn(e,t)&&!me(r,t)){if(!i.dispatchEvent)return r.state.pasteIncoming=+new Date,void n.focus();var o=new Event("paste");o.clipboardData=t.clipboardData,i.dispatchEvent(o)}})),de(e.lineSpace,"selectstart",(function(t){Cn(e,t)||ye(t)})),de(i,"compositionstart",(function(){var e=r.getCursor("from");n.composing&&n.composing.range.clear(),n.composing={start:e,range:r.markText(e,r.getCursor("to"),{className:"CodeMirror-composing"})}})),de(i,"compositionend",(function(){n.composing&&(n.poll(),n.composing.range.clear(),n.composing=null)}))},$a.prototype.createField=function(e){this.wrapper=Ha(),this.textarea=this.wrapper.firstChild},$a.prototype.screenReaderLabelChanged=function(e){e?this.textarea.setAttribute("aria-label",e):this.textarea.removeAttribute("aria-label")},$a.prototype.prepareSelection=function(){var e=this.cm,t=e.display,n=e.doc,r=vr(e);if(e.options.moveInputWithCursor){var i=Vn(e,n.sel.primary().head,"div"),o=t.wrapper.getBoundingClientRect(),a=t.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,i.top+a.top-o.top)),r.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,i.left+a.left-o.left))}return r},$a.prototype.showSelection=function(e){var t=this.cm.display;E(t.cursorDiv,e.cursors),E(t.selectionDiv,e.selection),null!=e.teTop&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},$a.prototype.reset=function(e){if(!this.contextMenuPending&&!this.composing){var t=this.cm;if(t.somethingSelected()){this.prevInput="";var n=t.getSelection();this.textarea.value=n,t.state.focused&&I(this.textarea),a&&l>=9&&(this.hasSelection=n)}else e||(this.prevInput=this.textarea.value="",a&&l>=9&&(this.hasSelection=null))}},$a.prototype.getField=function(){return this.textarea},$a.prototype.supportsTouch=function(){return!1},$a.prototype.focus=function(){if("nocursor"!=this.cm.options.readOnly&&(!v||B()!=this.textarea))try{this.textarea.focus()}catch(e){}},$a.prototype.blur=function(){this.textarea.blur()},$a.prototype.resetPosition=function(){this.wrapper.style.top=this.wrapper.style.left=0},$a.prototype.receivedFocus=function(){this.slowPoll()},$a.prototype.slowPoll=function(){var e=this;this.pollingFast||this.polling.set(this.cm.options.pollInterval,(function(){e.poll(),e.cm.state.focused&&e.slowPoll()}))},$a.prototype.fastPoll=function(){var e=!1,t=this;t.pollingFast=!0,t.polling.set(20,(function n(){t.poll()||e?(t.pollingFast=!1,t.slowPoll()):(e=!0,t.polling.set(60,n))}))},$a.prototype.poll=function(){var e=this,t=this.cm,n=this.textarea,r=this.prevInput;if(this.contextMenuPending||!t.state.focused||Be(n)&&!r&&!this.composing||t.isReadOnly()||t.options.disableInput||t.state.keySeq)return!1;var i=n.value;if(i==r&&!t.somethingSelected())return!1;if(a&&l>=9&&this.hasSelection===i||x&&/[\uf700-\uf7ff]/.test(i))return t.display.input.reset(),!1;if(t.doc.sel==t.display.selForContextMenu){var o=i.charCodeAt(0);if(8203!=o||r||(r="​"),8666==o)return this.reset(),this.cm.execCommand("undo")}for(var s=0,u=Math.min(r.length,i.length);s1e3||i.indexOf("\n")>-1?n.value=e.prevInput="":e.prevInput=i,e.composing&&(e.composing.range.clear(),e.composing.range=t.markText(e.composing.start,t.getCursor("to"),{className:"CodeMirror-composing"}))})),!0},$a.prototype.ensurePolled=function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},$a.prototype.onKeyPress=function(){a&&l>=9&&(this.hasSelection=null),this.fastPoll()},$a.prototype.onContextMenu=function(e){var t=this,n=t.cm,r=n.display,i=t.textarea;t.contextMenuPending&&t.contextMenuPending();var o=ur(n,e),u=r.scroller.scrollTop;if(o&&!d){n.options.resetSelectionOnContextMenu&&-1==n.doc.sel.contains(o)&&ei(n,Ji)(n.doc,Si(o),j);var c,h=i.style.cssText,f=t.wrapper.style.cssText,p=t.wrapper.offsetParent.getBoundingClientRect();if(t.wrapper.style.cssText="position: static",i.style.cssText="position: absolute; width: 30px; height: 30px;\n top: "+(e.clientY-p.top-5)+"px; left: "+(e.clientX-p.left-5)+"px;\n z-index: 1000; background: "+(a?"rgba(255, 255, 255, .05)":"transparent")+";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);",s&&(c=window.scrollY),r.input.focus(),s&&window.scrollTo(null,c),r.input.reset(),n.somethingSelected()||(i.value=t.prevInput=" "),t.contextMenuPending=v,r.selForContextMenu=n.doc.sel,clearTimeout(r.detectingSelectAll),a&&l>=9&&g(),w){Ce(e);var m=function(){fe(window,"mouseup",m),setTimeout(v,20)};de(window,"mouseup",m)}else setTimeout(v,50)}function g(){if(null!=i.selectionStart){var e=n.somethingSelected(),o="​"+(e?i.value:"");i.value="⇚",i.value=o,t.prevInput=e?"":"​",i.selectionStart=1,i.selectionEnd=o.length,r.selForContextMenu=n.doc.sel}}function v(){if(t.contextMenuPending==v&&(t.contextMenuPending=!1,t.wrapper.style.cssText=f,i.style.cssText=h,a&&l<9&&r.scrollbars.setScrollTop(r.scroller.scrollTop=u),null!=i.selectionStart)){(!a||a&&l<9)&&g();var e=0,o=function(){r.selForContextMenu==n.doc.sel&&0==i.selectionStart&&i.selectionEnd>0&&"​"==t.prevInput?ei(n,lo)(n):e++<10?r.detectingSelectAll=setTimeout(o,500):(r.selForContextMenu=null,r.input.reset())};r.detectingSelectAll=setTimeout(o,200)}}},$a.prototype.readOnlyChanged=function(e){e||this.reset(),this.textarea.disabled="nocursor"==e,this.textarea.readOnly=!!e},$a.prototype.setUneditable=function(){},$a.prototype.needsContentAttribute=!1,function(e){var t=e.optionHandlers;function n(n,r,i,o){e.defaults[n]=r,i&&(t[n]=o?function(e,t,n){n!=Ca&&i(e,t,n)}:i)}e.defineOption=n,e.Init=Ca,n("value","",(function(e,t){return e.setValue(t)}),!0),n("mode",null,(function(e,t){e.doc.modeOption=t,Li(e)}),!0),n("indentUnit",2,Li,!0),n("indentWithTabs",!1),n("smartIndent",!0),n("tabSize",4,(function(e){Mi(e),_n(e),dr(e)}),!0),n("lineSeparator",null,(function(e,t){if(e.doc.lineSep=t,t){var n=[],r=e.doc.first;e.doc.iter((function(e){for(var i=0;;){var o=e.text.indexOf(t,i);if(-1==o)break;i=o+t.length,n.push(et(r,o))}r++}));for(var i=n.length-1;i>=0;i--)mo(e.doc,t,n[i],et(n[i].line,n[i].ch+t.length))}})),n("specialChars",/[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g,(function(e,t,n){e.state.specialChars=new RegExp(t.source+(t.test("\t")?"":"|\t"),"g"),n!=Ca&&e.refresh()})),n("specialCharPlaceholder",Qt,(function(e){return e.refresh()}),!0),n("electricChars",!0),n("inputStyle",v?"contenteditable":"textarea",(function(){throw new Error("inputStyle can not (yet) be changed in a running editor")}),!0),n("spellcheck",!1,(function(e,t){return e.getInputField().spellcheck=t}),!0),n("autocorrect",!1,(function(e,t){return e.getInputField().autocorrect=t}),!0),n("autocapitalize",!1,(function(e,t){return e.getInputField().autocapitalize=t}),!0),n("rtlMoveVisually",!b),n("wholeLineUpdateBefore",!0),n("theme","default",(function(e){Da(e),mi(e)}),!0),n("keyMap","default",(function(e,t,n){var r=Zo(t),i=n!=Ca&&Zo(n);i&&i.detach&&i.detach(e,r),r.attach&&r.attach(e,i||null)})),n("extraKeys",null),n("configureMouse",null),n("lineWrapping",!1,Fa,!0),n("gutters",[],(function(e,t){e.display.gutterSpecs=fi(t,e.options.lineNumbers),mi(e)}),!0),n("fixedGutter",!0,(function(e,t){e.display.gutters.style.left=t?ar(e.display)+"px":"0",e.refresh()}),!0),n("coverGutterNextToScrollbar",!1,(function(e){return Wr(e)}),!0),n("scrollbarStyle","native",(function(e){Ur(e),Wr(e),e.display.scrollbars.setScrollTop(e.doc.scrollTop),e.display.scrollbars.setScrollLeft(e.doc.scrollLeft)}),!0),n("lineNumbers",!1,(function(e,t){e.display.gutterSpecs=fi(e.options.gutters,t),mi(e)}),!0),n("firstLineNumber",1,mi,!0),n("lineNumberFormatter",(function(e){return e}),mi,!0),n("showCursorWhenSelecting",!1,gr,!0),n("resetSelectionOnContextMenu",!0),n("lineWiseCopyCut",!0),n("pasteLinesPerSelection",!0),n("selectionsMayTouch",!1),n("readOnly",!1,(function(e,t){"nocursor"==t&&(Sr(e),e.display.input.blur()),e.display.input.readOnlyChanged(t)})),n("screenReaderLabel",null,(function(e,t){t=""===t?null:t,e.display.input.screenReaderLabelChanged(t)})),n("disableInput",!1,(function(e,t){t||e.display.input.reset()}),!0),n("dragDrop",!0,Sa),n("allowDropFileTypes",null),n("cursorBlinkRate",530),n("cursorScrollMargin",0),n("cursorHeight",1,gr,!0),n("singleCursorHeightPerLine",!0,gr,!0),n("workTime",100),n("workDelay",100),n("flattenSpans",!0,Mi,!0),n("addModeClass",!1,Mi,!0),n("pollInterval",100),n("undoDepth",200,(function(e,t){return e.doc.history.undoDepth=t})),n("historyEventDelay",1250),n("viewportMargin",10,(function(e){return e.refresh()}),!0),n("maxHighlightLength",1e4,Mi,!0),n("moveInputWithCursor",!0,(function(e,t){t||e.display.input.resetPosition()})),n("tabindex",null,(function(e,t){return e.display.input.getField().tabIndex=t||""})),n("autofocus",null),n("direction","ltr",(function(e,t){return e.doc.setDirection(t)}),!0),n("phrases",null)}(Aa),function(e){var t=e.optionHandlers,n=e.helpers={};e.prototype={constructor:e,focus:function(){window.focus(),this.display.input.focus()},setOption:function(e,n){var r=this.options,i=r[e];r[e]==n&&"mode"!=e||(r[e]=n,t.hasOwnProperty(e)&&ei(this,t[e])(this,n,i),pe(this,"optionChange",this,e))},getOption:function(e){return this.options[e]},getDoc:function(){return this.doc},addKeyMap:function(e,t){this.state.keyMaps[t?"push":"unshift"](Zo(e))},removeKeyMap:function(e){for(var t=this.state.keyMaps,n=0;nn&&(Ta(this,i.head.line,e,!0),n=i.head.line,r==this.doc.sel.primIndex&&Mr(this));else{var o=i.from(),a=i.to(),l=Math.max(n,o.line);n=Math.min(this.lastLine(),a.line-(a.ch?0:1))+1;for(var s=l;s0&&Zi(this.doc,r,new wi(o,u[r].to()),j)}}})),getTokenAt:function(e,t){return xt(this,e,t)},getLineTokens:function(e,t){return xt(this,et(e),t,!0)},getTokenTypeAt:function(e){e=lt(this.doc,e);var t,n=ht(this,Ge(this.doc,e.line)),r=0,i=(n.length-1)/2,o=e.ch;if(0==o)t=n[2];else for(;;){var a=r+i>>1;if((a?n[2*a-1]:0)>=o)i=a;else{if(!(n[2*a+1]o&&(e=o,i=!0),r=Ge(this.doc,e)}else r=e;return Un(this,r,{top:0,left:0},t||"page",n||i).top+(i?this.doc.height-qt(r):0)},defaultTextHeight:function(){return rr(this.display)},defaultCharWidth:function(){return ir(this.display)},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(e,t,n,r,i){var o,a,l,s=this.display,u=(e=Vn(this,lt(this.doc,e))).bottom,c=e.left;if(t.style.position="absolute",t.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(t),s.sizer.appendChild(t),"over"==r)u=e.top;else if("above"==r||"near"==r){var d=Math.max(s.wrapper.clientHeight,this.doc.height),h=Math.max(s.sizer.clientWidth,s.lineSpace.clientWidth);("above"==r||e.bottom+t.offsetHeight>d)&&e.top>t.offsetHeight?u=e.top-t.offsetHeight:e.bottom+t.offsetHeight<=d&&(u=e.bottom),c+t.offsetWidth>h&&(c=h-t.offsetWidth)}t.style.top=u+"px",t.style.left=t.style.right="","right"==i?(c=s.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):("left"==i?c=0:"middle"==i&&(c=(s.sizer.clientWidth-t.offsetWidth)/2),t.style.left=c+"px"),n&&(o=this,a={left:c,top:u,right:c+t.offsetWidth,bottom:u+t.offsetHeight},null!=(l=Tr(o,a)).scrollTop&&Ir(o,l.scrollTop),null!=l.scrollLeft&&Hr(o,l.scrollLeft))},triggerOnKeyDown:ti(ca),triggerOnKeyPress:ti(ha),triggerOnKeyUp:da,triggerOnMouseDown:ti(ga),execCommand:function(e){if(ta.hasOwnProperty(e))return ta[e].call(null,this)},triggerElectric:ti((function(e){Oa(this,e)})),findPosH:function(e,t,n,r){var i=1;t<0&&(i=-1,t=-t);for(var o=lt(this.doc,e),a=0;a0&&a(t.charAt(n-1));)--n;for(;r.5||this.options.lineWrapping)&&sr(this),pe(this,"refresh",this)})),swapDoc:ti((function(e){var t=this.doc;return t.cm=null,this.state.selectingText&&this.state.selectingText(),Ii(this,e),_n(this),this.display.input.reset(),Br(this,e.scrollLeft,e.scrollTop),this.curOp.forceScroll=!0,sn(this,"swapDoc",this,t),t})),phrase:function(e){var t=this.options.phrases;return t&&Object.prototype.hasOwnProperty.call(t,e)?t[e]:e},getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},xe(e),e.registerHelper=function(t,r,i){n.hasOwnProperty(t)||(n[t]=e[t]={_global:[]}),n[t][r]=i},e.registerGlobalHelper=function(t,r,i,o){e.registerHelper(t,r,o),n[t]._global.push({pred:i,val:o})}}(Aa);var Ga="iter insert remove copy getEditor constructor".split(" ");for(var Va in Mo.prototype)Mo.prototype.hasOwnProperty(Va)&&_(Ga,Va)<0&&(Aa.prototype[Va]=function(e){return function(){return e.apply(this.doc,arguments)}}(Mo.prototype[Va]));return xe(Mo),Aa.inputStyles={textarea:$a,contenteditable:_a},Aa.defineMode=function(e){Aa.defaults.mode||"null"==e||(Aa.defaults.mode=e),He.apply(this,arguments)},Aa.defineMIME=function(e,t){ze[e]=t},Aa.defineMode("null",(function(){return{token:function(e){return e.skipToEnd()}}})),Aa.defineMIME("text/plain","null"),Aa.defineExtension=function(e,t){Aa.prototype[e]=t},Aa.defineDocExtension=function(e,t){Mo.prototype[e]=t},Aa.fromTextArea=function(e,t){if((t=t?H(t):{}).value=e.value,!t.tabindex&&e.tabIndex&&(t.tabindex=e.tabIndex),!t.placeholder&&e.placeholder&&(t.placeholder=e.placeholder),null==t.autofocus){var n=B();t.autofocus=n==e||null!=e.getAttribute("autofocus")&&n==document.body}function r(){e.value=l.getValue()}var i;if(e.form&&(de(e.form,"submit",r),!t.leaveSubmitMethodAlone)){var o=e.form;i=o.submit;try{var a=o.submit=function(){r(),o.submit=i,o.submit(),o.submit=a}}catch(e){}}t.finishInit=function(n){n.save=r,n.getTextArea=function(){return e},n.toTextArea=function(){n.toTextArea=isNaN,r(),e.parentNode.removeChild(n.getWrapperElement()),e.style.display="",e.form&&(fe(e.form,"submit",r),t.leaveSubmitMethodAlone||"function"!=typeof e.form.submit||(e.form.submit=i))}},e.style.display="none";var l=Aa((function(t){return e.parentNode.insertBefore(t,e.nextSibling)}),t);return l},function(e){e.off=fe,e.on=de,e.wheelEventPixels=bi,e.Doc=Mo,e.splitLines=Me,e.countColumn=R,e.findColumn=$,e.isWordChar=J,e.Pass=W,e.signal=pe,e.Line=Gt,e.changeEnd=Fi,e.scrollbarModel=qr,e.Pos=et,e.cmpPos=tt,e.modes=Ie,e.mimeModes=ze,e.resolveMode=Re,e.getMode=Pe,e.modeExtensions=_e,e.extendMode=We,e.copyState=je,e.startState=Ue,e.innerMode=qe,e.commands=ta,e.keyMap=qo,e.keyName=Xo,e.isModifierKey=Vo,e.lookupKey=Go,e.normalizeKeyMap=$o,e.StringStream=$e,e.SharedTextMarker=Ao,e.TextMarker=So,e.LineWidget=Co,e.e_preventDefault=ye,e.e_stopPropagation=be,e.e_stop=Ce,e.addClass=N,e.contains=M,e.rmClass=F,e.keyNames=Po}(Aa),Aa.version="5.61.0",Aa}))},{}],11:[function(e,t,n){var r;r=function(e){"use strict";var t=/^((?:(?:aaas?|about|acap|adiumxtra|af[ps]|aim|apt|attachment|aw|beshare|bitcoin|bolo|callto|cap|chrome(?:-extension)?|cid|coap|com-eventbrite-attendee|content|crid|cvs|data|dav|dict|dlna-(?:playcontainer|playsingle)|dns|doi|dtn|dvb|ed2k|facetime|feed|file|finger|fish|ftp|geo|gg|git|gizmoproject|go|gopher|gtalk|h323|hcp|https?|iax|icap|icon|im|imap|info|ipn|ipp|irc[6s]?|iris(?:\.beep|\.lwz|\.xpc|\.xpcs)?|itms|jar|javascript|jms|keyparc|lastfm|ldaps?|magnet|mailto|maps|market|message|mid|mms|ms-help|msnim|msrps?|mtqp|mumble|mupdate|mvn|news|nfs|nih?|nntp|notes|oid|opaquelocktoken|palm|paparazzi|platform|pop|pres|proxy|psyc|query|res(?:ource)?|rmi|rsync|rtmp|rtsp|secondlife|service|session|sftp|sgn|shttp|sieve|sips?|skype|sm[bs]|snmp|soap\.beeps?|soldat|spotify|ssh|steam|svn|tag|teamspeak|tel(?:net)?|tftp|things|thismessage|tip|tn3270|tv|udp|unreal|urn|ut2004|vemmi|ventrilo|view-source|webcal|wss?|wtai|wyciwyg|xcon(?:-userid)?|xfire|xmlrpc\.beeps?|xmpp|xri|ymsgr|z39\.50[rs]?):(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]|\([^\s()<>]*\))+(?:\([^\s()<>]*\)|[^\s`*!()\[\]{};:'".,<>?«»“”‘’]))/i;e.defineMode("gfm",(function(n,r){var i=0,o={startState:function(){return{code:!1,codeBlock:!1,ateSpace:!1}},copyState:function(e){return{code:e.code,codeBlock:e.codeBlock,ateSpace:e.ateSpace}},token:function(e,n){if(n.combineTokens=null,n.codeBlock)return e.match(/^```+/)?(n.codeBlock=!1,null):(e.skipToEnd(),null);if(e.sol()&&(n.code=!1),e.sol()&&e.match(/^```+/))return e.skipToEnd(),n.codeBlock=!0,null;if("`"===e.peek()){e.next();var o=e.pos;e.eatWhile("`");var a=1+e.pos-o;return n.code?a===i&&(n.code=!1):(i=a,n.code=!0),null}if(n.code)return e.next(),null;if(e.eatSpace())return n.ateSpace=!0,null;if((e.sol()||n.ateSpace)&&(n.ateSpace=!1,!1!==r.gitHubSpice)){if(e.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+@)?(?=.{0,6}\d)(?:[a-f0-9]{7,40}\b)/))return n.combineTokens=!0,"link";if(e.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+)?#[0-9]+\b/))return n.combineTokens=!0,"link"}return e.match(t)&&"]("!=e.string.slice(e.start-2,e.start)&&(0==e.start||/\W/.test(e.string.charAt(e.start-1)))?(n.combineTokens=!0,"link"):(e.next(),null)},blankLine:function(e){return e.code=!1,null}},a={taskLists:!0,strikethrough:!0,emoji:!0};for(var l in r)a[l]=r[l];return a.name="markdown",e.overlayMode(e.getMode(n,a),o)}),"markdown"),e.defineMIME("text/x-gfm","gfm")},"object"==typeof n&&"object"==typeof t?r(e("../../lib/codemirror"),e("../markdown/markdown"),e("../../addon/mode/overlay")):r(CodeMirror)},{"../../addon/mode/overlay":7,"../../lib/codemirror":10,"../markdown/markdown":12}],12:[function(e,t,n){var r;r=function(e){"use strict";e.defineMode("markdown",(function(t,n){var r=e.getMode(t,"text/html"),i="null"==r.name;void 0===n.highlightFormatting&&(n.highlightFormatting=!1),void 0===n.maxBlockquoteDepth&&(n.maxBlockquoteDepth=0),void 0===n.taskLists&&(n.taskLists=!1),void 0===n.strikethrough&&(n.strikethrough=!1),void 0===n.emoji&&(n.emoji=!1),void 0===n.fencedCodeBlockHighlighting&&(n.fencedCodeBlockHighlighting=!0),void 0===n.fencedCodeBlockDefaultMode&&(n.fencedCodeBlockDefaultMode="text/plain"),void 0===n.xml&&(n.xml=!0),void 0===n.tokenTypeOverrides&&(n.tokenTypeOverrides={});var o={header:"header",code:"comment",quote:"quote",list1:"variable-2",list2:"variable-3",list3:"keyword",hr:"hr",image:"image",imageAltText:"image-alt-text",imageMarker:"image-marker",formatting:"formatting",linkInline:"link",linkEmail:"link",linkText:"link",linkHref:"string",em:"em",strong:"strong",strikethrough:"strikethrough",emoji:"builtin"};for(var a in o)o.hasOwnProperty(a)&&n.tokenTypeOverrides[a]&&(o[a]=n.tokenTypeOverrides[a]);var l=/^([*\-_])(?:\s*\1){2,}\s*$/,s=/^(?:[*\-+]|^[0-9]+([.)]))\s+/,u=/^\[(x| )\](?=\s)/i,c=n.allowAtxHeaderWithoutSpace?/^(#+)/:/^(#+)(?: |$)/,d=/^ {0,3}(?:\={1,}|-{2,})\s*$/,h=/^[^#!\[\]*_\\<>` "'(~:]+/,f=/^(~~~+|```+)[ \t]*([\w\/+#-]*)[^\n`]*$/,p=/^\s*\[[^\]]+?\]:.*$/,m=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E42\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]/;function g(e,t,n){return t.f=t.inline=n,n(e,t)}function v(e,t,n){return t.f=t.block=n,n(e,t)}function x(t){if(t.linkTitle=!1,t.linkHref=!1,t.linkText=!1,t.em=!1,t.strong=!1,t.strikethrough=!1,t.quote=0,t.indentedCode=!1,t.f==b){var n=i;if(!n){var o=e.innerMode(r,t.htmlState);n="xml"==o.mode.name&&null===o.state.tagStart&&!o.state.context&&o.state.tokenize.isInText}n&&(t.f=k,t.block=y,t.htmlState=null)}return t.trailingSpace=0,t.trailingSpaceNewLine=!1,t.prevLine=t.thisLine,t.thisLine={stream:null},null}function y(r,i){var a,h=r.column()===i.indentation,m=!(a=i.prevLine.stream)||!/\S/.test(a.string),v=i.indentedCode,x=i.prevLine.hr,y=!1!==i.list,b=(i.listStack[i.listStack.length-1]||0)+3;i.indentedCode=!1;var w=i.indentation;if(null===i.indentationDiff&&(i.indentationDiff=i.indentation,y)){for(i.list=null;w=4&&(v||i.prevLine.fencedCodeEnd||i.prevLine.header||m))return r.skipToEnd(),i.indentedCode=!0,o.code;if(r.eatSpace())return null;if(h&&i.indentation<=b&&(F=r.match(c))&&F[1].length<=6)return i.quote=0,i.header=F[1].length,i.thisLine.header=!0,n.highlightFormatting&&(i.formatting="header"),i.f=i.inline,C(i);if(i.indentation<=b&&r.eat(">"))return i.quote=h?1:i.quote+1,n.highlightFormatting&&(i.formatting="quote"),r.eatSpace(),C(i);if(!S&&!i.setext&&h&&i.indentation<=b&&(F=r.match(s))){var A=F[1]?"ol":"ul";return i.indentation=w+r.current().length,i.list=!0,i.quote=0,i.listStack.push(i.indentation),i.em=!1,i.strong=!1,i.code=!1,i.strikethrough=!1,n.taskLists&&r.match(u,!1)&&(i.taskList=!0),i.f=i.inline,n.highlightFormatting&&(i.formatting=["list","list-"+A]),C(i)}return h&&i.indentation<=b&&(F=r.match(f,!0))?(i.quote=0,i.fencedEndRE=new RegExp(F[1]+"+ *$"),i.localMode=n.fencedCodeBlockHighlighting&&function(n){if(e.findModeByName){var r=e.findModeByName(n);r&&(n=r.mime||r.mimes[0])}var i=e.getMode(t,n);return"null"==i.name?null:i}(F[2]||n.fencedCodeBlockDefaultMode),i.localMode&&(i.localState=e.startState(i.localMode)),i.f=i.block=D,n.highlightFormatting&&(i.formatting="code-block"),i.code=-1,C(i)):i.setext||!(k&&y||i.quote||!1!==i.list||i.code||S||p.test(r.string))&&(F=r.lookAhead(1))&&(F=F.match(d))?(i.setext?(i.header=i.setext,i.setext=0,r.skipToEnd(),n.highlightFormatting&&(i.formatting="header")):(i.header="="==F[0].charAt(0)?1:2,i.setext=i.header),i.thisLine.header=!0,i.f=i.inline,C(i)):S?(r.skipToEnd(),i.hr=!0,i.thisLine.hr=!0,o.hr):"["===r.peek()?g(r,i,E):g(r,i,i.inline)}function b(t,n){var o=r.token(t,n.htmlState);if(!i){var a=e.innerMode(r,n.htmlState);("xml"==a.mode.name&&null===a.state.tagStart&&!a.state.context&&a.state.tokenize.isInText||n.md_inside&&t.current().indexOf(">")>-1)&&(n.f=k,n.block=y,n.htmlState=null)}return o}function D(e,t){var r,i=t.listStack[t.listStack.length-1]||0,a=t.indentation=e.quote?t.push(o.formatting+"-"+e.formatting[r]+"-"+e.quote):t.push("error"))}if(e.taskOpen)return t.push("meta"),t.length?t.join(" "):null;if(e.taskClosed)return t.push("property"),t.length?t.join(" "):null;if(e.linkHref?t.push(o.linkHref,"url"):(e.strong&&t.push(o.strong),e.em&&t.push(o.em),e.strikethrough&&t.push(o.strikethrough),e.emoji&&t.push(o.emoji),e.linkText&&t.push(o.linkText),e.code&&t.push(o.code),e.image&&t.push(o.image),e.imageAltText&&t.push(o.imageAltText,"link"),e.imageMarker&&t.push(o.imageMarker)),e.header&&t.push(o.header,o.header+"-"+e.header),e.quote&&(t.push(o.quote),!n.maxBlockquoteDepth||n.maxBlockquoteDepth>=e.quote?t.push(o.quote+"-"+e.quote):t.push(o.quote+"-"+n.maxBlockquoteDepth)),!1!==e.list){var i=(e.listStack.length-1)%3;i?1===i?t.push(o.list2):t.push(o.list3):t.push(o.list1)}return e.trailingSpaceNewLine?t.push("trailing-space-new-line"):e.trailingSpace&&t.push("trailing-space-"+(e.trailingSpace%2?"a":"b")),t.length?t.join(" "):null}function w(e,t){if(e.match(h,!0))return C(t)}function k(t,i){var a=i.text(t,i);if(void 0!==a)return a;if(i.list)return i.list=null,C(i);if(i.taskList)return" "===t.match(u,!0)[1]?i.taskOpen=!0:i.taskClosed=!0,n.highlightFormatting&&(i.formatting="task"),i.taskList=!1,C(i);if(i.taskOpen=!1,i.taskClosed=!1,i.header&&t.match(/^#+$/,!0))return n.highlightFormatting&&(i.formatting="header"),C(i);var l=t.next();if(i.linkTitle){i.linkTitle=!1;var s=l;"("===l&&(s=")");var c="^\\s*(?:[^"+(s=(s+"").replace(/([.?*+^\[\]\\(){}|-])/g,"\\$1"))+"\\\\]+|\\\\\\\\|\\\\.)"+s;if(t.match(new RegExp(c),!0))return o.linkHref}if("`"===l){var d=i.formatting;n.highlightFormatting&&(i.formatting="code"),t.eatWhile("`");var h=t.current().length;if(0!=i.code||i.quote&&1!=h){if(h==i.code){var f=C(i);return i.code=0,f}return i.formatting=d,C(i)}return i.code=h,C(i)}if(i.code)return C(i);if("\\"===l&&(t.next(),n.highlightFormatting)){var p=C(i),g=o.formatting+"-escape";return p?p+" "+g:g}if("!"===l&&t.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))return i.imageMarker=!0,i.image=!0,n.highlightFormatting&&(i.formatting="image"),C(i);if("["===l&&i.imageMarker&&t.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/,!1))return i.imageMarker=!1,i.imageAltText=!0,n.highlightFormatting&&(i.formatting="image"),C(i);if("]"===l&&i.imageAltText){n.highlightFormatting&&(i.formatting="image");var p=C(i);return i.imageAltText=!1,i.image=!1,i.inline=i.f=F,p}if("["===l&&!i.image)return i.linkText&&t.match(/^.*?\]/)||(i.linkText=!0,n.highlightFormatting&&(i.formatting="link")),C(i);if("]"===l&&i.linkText){n.highlightFormatting&&(i.formatting="link");var p=C(i);return i.linkText=!1,i.inline=i.f=t.match(/\(.*?\)| ?\[.*?\]/,!1)?F:k,p}if("<"===l&&t.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1))return i.f=i.inline=S,n.highlightFormatting&&(i.formatting="link"),(p=C(i))?p+=" ":p="",p+o.linkInline;if("<"===l&&t.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1))return i.f=i.inline=S,n.highlightFormatting&&(i.formatting="link"),(p=C(i))?p+=" ":p="",p+o.linkEmail;if(n.xml&&"<"===l&&t.match(/^(!--|\?|!\[CDATA\[|[a-z][a-z0-9-]*(?:\s+[a-z_:.\-]+(?:\s*=\s*[^>]+)?)*\s*(?:>|$))/i,!1)){var x=t.string.indexOf(">",t.pos);if(-1!=x){var y=t.string.substring(t.start,x);/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(y)&&(i.md_inside=!0)}return t.backUp(1),i.htmlState=e.startState(r),v(t,i,b)}if(n.xml&&"<"===l&&t.match(/^\/\w*?>/))return i.md_inside=!1,"tag";if("*"===l||"_"===l){for(var D=1,w=1==t.pos?" ":t.string.charAt(t.pos-2);D<3&&t.eat(l);)D++;var A=t.peek()||" ",E=!/\s/.test(A)&&(!m.test(A)||/\s/.test(w)||m.test(w)),T=!/\s/.test(w)&&(!m.test(w)||/\s/.test(A)||m.test(A)),L=null,M=null;if(D%2&&(i.em||!E||"*"!==l&&T&&!m.test(w)?i.em!=l||!T||"*"!==l&&E&&!m.test(A)||(L=!1):L=!0),D>1&&(i.strong||!E||"*"!==l&&T&&!m.test(w)?i.strong!=l||!T||"*"!==l&&E&&!m.test(A)||(M=!1):M=!0),null!=M||null!=L)return n.highlightFormatting&&(i.formatting=null==L?"strong":null==M?"em":"strong em"),!0===L&&(i.em=l),!0===M&&(i.strong=l),f=C(i),!1===L&&(i.em=!1),!1===M&&(i.strong=!1),f}else if(" "===l&&(t.eat("*")||t.eat("_"))){if(" "===t.peek())return C(i);t.backUp(1)}if(n.strikethrough)if("~"===l&&t.eatWhile(l)){if(i.strikethrough)return n.highlightFormatting&&(i.formatting="strikethrough"),f=C(i),i.strikethrough=!1,f;if(t.match(/^[^\s]/,!1))return i.strikethrough=!0,n.highlightFormatting&&(i.formatting="strikethrough"),C(i)}else if(" "===l&&t.match("~~",!0)){if(" "===t.peek())return C(i);t.backUp(2)}if(n.emoji&&":"===l&&t.match(/^(?:[a-z_\d+][a-z_\d+-]*|\-[a-z_\d+][a-z_\d+-]*):/)){i.emoji=!0,n.highlightFormatting&&(i.formatting="emoji");var B=C(i);return i.emoji=!1,B}return" "===l&&(t.match(/^ +$/,!1)?i.trailingSpace++:i.trailingSpace&&(i.trailingSpaceNewLine=!0)),C(i)}function S(e,t){if(">"===e.next()){t.f=t.inline=k,n.highlightFormatting&&(t.formatting="link");var r=C(t);return r?r+=" ":r="",r+o.linkInline}return e.match(/^[^>]+/,!0),o.linkInline}function F(e,t){if(e.eatSpace())return null;var r,i=e.next();return"("===i||"["===i?(t.f=t.inline=(r="("===i?")":"]",function(e,t){if(e.next()===r){t.f=t.inline=k,n.highlightFormatting&&(t.formatting="link-string");var i=C(t);return t.linkHref=!1,i}return e.match(A[r]),t.linkHref=!0,C(t)}),n.highlightFormatting&&(t.formatting="link-string"),t.linkHref=!0,C(t)):"error"}var A={")":/^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,"]":/^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\]]|\\.)*\])*?(?=\])/};function E(e,t){return e.match(/^([^\]\\]|\\.)*\]:/,!1)?(t.f=T,e.next(),n.highlightFormatting&&(t.formatting="link"),t.linkText=!0,C(t)):g(e,t,k)}function T(e,t){if(e.match("]:",!0)){t.f=t.inline=L,n.highlightFormatting&&(t.formatting="link");var r=C(t);return t.linkText=!1,r}return e.match(/^([^\]\\]|\\.)+/,!0),o.linkText}function L(e,t){return e.eatSpace()?null:(e.match(/^[^\s]+/,!0),void 0===e.peek()?t.linkTitle=!0:e.match(/^(?:\s+(?:"(?:[^"\\]|\\.)+"|'(?:[^'\\]|\\.)+'|\((?:[^)\\]|\\.)+\)))?/,!0),t.f=t.inline=k,o.linkHref+" url")}var M={startState:function(){return{f:y,prevLine:{stream:null},thisLine:{stream:null},block:y,htmlState:null,indentation:0,inline:k,text:w,formatting:!1,linkText:!1,linkHref:!1,linkTitle:!1,code:0,em:!1,strong:!1,header:0,setext:0,hr:!1,taskList:!1,list:!1,listStack:[],quote:0,trailingSpace:0,trailingSpaceNewLine:!1,strikethrough:!1,emoji:!1,fencedEndRE:null}},copyState:function(t){return{f:t.f,prevLine:t.prevLine,thisLine:t.thisLine,block:t.block,htmlState:t.htmlState&&e.copyState(r,t.htmlState),indentation:t.indentation,localMode:t.localMode,localState:t.localMode?e.copyState(t.localMode,t.localState):null,inline:t.inline,text:t.text,formatting:!1,linkText:t.linkText,linkTitle:t.linkTitle,linkHref:t.linkHref,code:t.code,em:t.em,strong:t.strong,strikethrough:t.strikethrough,emoji:t.emoji,header:t.header,setext:t.setext,hr:t.hr,taskList:t.taskList,list:t.list,listStack:t.listStack.slice(0),quote:t.quote,indentedCode:t.indentedCode,trailingSpace:t.trailingSpace,trailingSpaceNewLine:t.trailingSpaceNewLine,md_inside:t.md_inside,fencedEndRE:t.fencedEndRE}},token:function(e,t){if(t.formatting=!1,e!=t.thisLine.stream){if(t.header=0,t.hr=!1,e.match(/^\s*$/,!0))return x(t),null;if(t.prevLine=t.thisLine,t.thisLine={stream:e},t.taskList=!1,t.trailingSpace=0,t.trailingSpaceNewLine=!1,!t.localState&&(t.f=t.block,t.f!=b)){var n=e.match(/^\s*/,!0)[0].replace(/\t/g," ").length;if(t.indentation=n,t.indentationDiff=null,n>0)return null}}return t.f(e,t)},innerMode:function(e){return e.block==b?{state:e.htmlState,mode:r}:e.localState?{state:e.localState,mode:e.localMode}:{state:e,mode:M}},indent:function(t,n,i){return t.block==b&&r.indent?r.indent(t.htmlState,n,i):t.localState&&t.localMode.indent?t.localMode.indent(t.localState,n,i):e.Pass},blankLine:x,getType:C,blockCommentStart:"\x3c!--",blockCommentEnd:"--\x3e",closeBrackets:"()[]{}''\"\"``",fold:"markdown"};return M}),"xml"),e.defineMIME("text/markdown","markdown"),e.defineMIME("text/x-markdown","markdown")},"object"==typeof n&&"object"==typeof t?r(e("../../lib/codemirror"),e("../xml/xml"),e("../meta")):r(CodeMirror)},{"../../lib/codemirror":10,"../meta":13,"../xml/xml":14}],13:[function(e,t,n){(function(e){"use strict";e.modeInfo=[{name:"APL",mime:"text/apl",mode:"apl",ext:["dyalog","apl"]},{name:"PGP",mimes:["application/pgp","application/pgp-encrypted","application/pgp-keys","application/pgp-signature"],mode:"asciiarmor",ext:["asc","pgp","sig"]},{name:"ASN.1",mime:"text/x-ttcn-asn",mode:"asn.1",ext:["asn","asn1"]},{name:"Asterisk",mime:"text/x-asterisk",mode:"asterisk",file:/^extensions\.conf$/i},{name:"Brainfuck",mime:"text/x-brainfuck",mode:"brainfuck",ext:["b","bf"]},{name:"C",mime:"text/x-csrc",mode:"clike",ext:["c","h","ino"]},{name:"C++",mime:"text/x-c++src",mode:"clike",ext:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],alias:["cpp"]},{name:"Cobol",mime:"text/x-cobol",mode:"cobol",ext:["cob","cpy"]},{name:"C#",mime:"text/x-csharp",mode:"clike",ext:["cs"],alias:["csharp","cs"]},{name:"Clojure",mime:"text/x-clojure",mode:"clojure",ext:["clj","cljc","cljx"]},{name:"ClojureScript",mime:"text/x-clojurescript",mode:"clojure",ext:["cljs"]},{name:"Closure Stylesheets (GSS)",mime:"text/x-gss",mode:"css",ext:["gss"]},{name:"CMake",mime:"text/x-cmake",mode:"cmake",ext:["cmake","cmake.in"],file:/^CMakeLists\.txt$/},{name:"CoffeeScript",mimes:["application/vnd.coffeescript","text/coffeescript","text/x-coffeescript"],mode:"coffeescript",ext:["coffee"],alias:["coffee","coffee-script"]},{name:"Common Lisp",mime:"text/x-common-lisp",mode:"commonlisp",ext:["cl","lisp","el"],alias:["lisp"]},{name:"Cypher",mime:"application/x-cypher-query",mode:"cypher",ext:["cyp","cypher"]},{name:"Cython",mime:"text/x-cython",mode:"python",ext:["pyx","pxd","pxi"]},{name:"Crystal",mime:"text/x-crystal",mode:"crystal",ext:["cr"]},{name:"CSS",mime:"text/css",mode:"css",ext:["css"]},{name:"CQL",mime:"text/x-cassandra",mode:"sql",ext:["cql"]},{name:"D",mime:"text/x-d",mode:"d",ext:["d"]},{name:"Dart",mimes:["application/dart","text/x-dart"],mode:"dart",ext:["dart"]},{name:"diff",mime:"text/x-diff",mode:"diff",ext:["diff","patch"]},{name:"Django",mime:"text/x-django",mode:"django"},{name:"Dockerfile",mime:"text/x-dockerfile",mode:"dockerfile",file:/^Dockerfile$/},{name:"DTD",mime:"application/xml-dtd",mode:"dtd",ext:["dtd"]},{name:"Dylan",mime:"text/x-dylan",mode:"dylan",ext:["dylan","dyl","intr"]},{name:"EBNF",mime:"text/x-ebnf",mode:"ebnf"},{name:"ECL",mime:"text/x-ecl",mode:"ecl",ext:["ecl"]},{name:"edn",mime:"application/edn",mode:"clojure",ext:["edn"]},{name:"Eiffel",mime:"text/x-eiffel",mode:"eiffel",ext:["e"]},{name:"Elm",mime:"text/x-elm",mode:"elm",ext:["elm"]},{name:"Embedded JavaScript",mime:"application/x-ejs",mode:"htmlembedded",ext:["ejs"]},{name:"Embedded Ruby",mime:"application/x-erb",mode:"htmlembedded",ext:["erb"]},{name:"Erlang",mime:"text/x-erlang",mode:"erlang",ext:["erl"]},{name:"Esper",mime:"text/x-esper",mode:"sql"},{name:"Factor",mime:"text/x-factor",mode:"factor",ext:["factor"]},{name:"FCL",mime:"text/x-fcl",mode:"fcl"},{name:"Forth",mime:"text/x-forth",mode:"forth",ext:["forth","fth","4th"]},{name:"Fortran",mime:"text/x-fortran",mode:"fortran",ext:["f","for","f77","f90","f95"]},{name:"F#",mime:"text/x-fsharp",mode:"mllike",ext:["fs"],alias:["fsharp"]},{name:"Gas",mime:"text/x-gas",mode:"gas",ext:["s"]},{name:"Gherkin",mime:"text/x-feature",mode:"gherkin",ext:["feature"]},{name:"GitHub Flavored Markdown",mime:"text/x-gfm",mode:"gfm",file:/^(readme|contributing|history)\.md$/i},{name:"Go",mime:"text/x-go",mode:"go",ext:["go"]},{name:"Groovy",mime:"text/x-groovy",mode:"groovy",ext:["groovy","gradle"],file:/^Jenkinsfile$/},{name:"HAML",mime:"text/x-haml",mode:"haml",ext:["haml"]},{name:"Haskell",mime:"text/x-haskell",mode:"haskell",ext:["hs"]},{name:"Haskell (Literate)",mime:"text/x-literate-haskell",mode:"haskell-literate",ext:["lhs"]},{name:"Haxe",mime:"text/x-haxe",mode:"haxe",ext:["hx"]},{name:"HXML",mime:"text/x-hxml",mode:"haxe",ext:["hxml"]},{name:"ASP.NET",mime:"application/x-aspx",mode:"htmlembedded",ext:["aspx"],alias:["asp","aspx"]},{name:"HTML",mime:"text/html",mode:"htmlmixed",ext:["html","htm","handlebars","hbs"],alias:["xhtml"]},{name:"HTTP",mime:"message/http",mode:"http"},{name:"IDL",mime:"text/x-idl",mode:"idl",ext:["pro"]},{name:"Pug",mime:"text/x-pug",mode:"pug",ext:["jade","pug"],alias:["jade"]},{name:"Java",mime:"text/x-java",mode:"clike",ext:["java"]},{name:"Java Server Pages",mime:"application/x-jsp",mode:"htmlembedded",ext:["jsp"],alias:["jsp"]},{name:"JavaScript",mimes:["text/javascript","text/ecmascript","application/javascript","application/x-javascript","application/ecmascript"],mode:"javascript",ext:["js"],alias:["ecmascript","js","node"]},{name:"JSON",mimes:["application/json","application/x-json"],mode:"javascript",ext:["json","map"],alias:["json5"]},{name:"JSON-LD",mime:"application/ld+json",mode:"javascript",ext:["jsonld"],alias:["jsonld"]},{name:"JSX",mime:"text/jsx",mode:"jsx",ext:["jsx"]},{name:"Jinja2",mime:"text/jinja2",mode:"jinja2",ext:["j2","jinja","jinja2"]},{name:"Julia",mime:"text/x-julia",mode:"julia",ext:["jl"],alias:["jl"]},{name:"Kotlin",mime:"text/x-kotlin",mode:"clike",ext:["kt"]},{name:"LESS",mime:"text/x-less",mode:"css",ext:["less"]},{name:"LiveScript",mime:"text/x-livescript",mode:"livescript",ext:["ls"],alias:["ls"]},{name:"Lua",mime:"text/x-lua",mode:"lua",ext:["lua"]},{name:"Markdown",mime:"text/x-markdown",mode:"markdown",ext:["markdown","md","mkd"]},{name:"mIRC",mime:"text/mirc",mode:"mirc"},{name:"MariaDB SQL",mime:"text/x-mariadb",mode:"sql"},{name:"Mathematica",mime:"text/x-mathematica",mode:"mathematica",ext:["m","nb","wl","wls"]},{name:"Modelica",mime:"text/x-modelica",mode:"modelica",ext:["mo"]},{name:"MUMPS",mime:"text/x-mumps",mode:"mumps",ext:["mps"]},{name:"MS SQL",mime:"text/x-mssql",mode:"sql"},{name:"mbox",mime:"application/mbox",mode:"mbox",ext:["mbox"]},{name:"MySQL",mime:"text/x-mysql",mode:"sql"},{name:"Nginx",mime:"text/x-nginx-conf",mode:"nginx",file:/nginx.*\.conf$/i},{name:"NSIS",mime:"text/x-nsis",mode:"nsis",ext:["nsh","nsi"]},{name:"NTriples",mimes:["application/n-triples","application/n-quads","text/n-triples"],mode:"ntriples",ext:["nt","nq"]},{name:"Objective-C",mime:"text/x-objectivec",mode:"clike",ext:["m"],alias:["objective-c","objc"]},{name:"Objective-C++",mime:"text/x-objectivec++",mode:"clike",ext:["mm"],alias:["objective-c++","objc++"]},{name:"OCaml",mime:"text/x-ocaml",mode:"mllike",ext:["ml","mli","mll","mly"]},{name:"Octave",mime:"text/x-octave",mode:"octave",ext:["m"]},{name:"Oz",mime:"text/x-oz",mode:"oz",ext:["oz"]},{name:"Pascal",mime:"text/x-pascal",mode:"pascal",ext:["p","pas"]},{name:"PEG.js",mime:"null",mode:"pegjs",ext:["jsonld"]},{name:"Perl",mime:"text/x-perl",mode:"perl",ext:["pl","pm"]},{name:"PHP",mimes:["text/x-php","application/x-httpd-php","application/x-httpd-php-open"],mode:"php",ext:["php","php3","php4","php5","php7","phtml"]},{name:"Pig",mime:"text/x-pig",mode:"pig",ext:["pig"]},{name:"Plain Text",mime:"text/plain",mode:"null",ext:["txt","text","conf","def","list","log"]},{name:"PLSQL",mime:"text/x-plsql",mode:"sql",ext:["pls"]},{name:"PostgreSQL",mime:"text/x-pgsql",mode:"sql"},{name:"PowerShell",mime:"application/x-powershell",mode:"powershell",ext:["ps1","psd1","psm1"]},{name:"Properties files",mime:"text/x-properties",mode:"properties",ext:["properties","ini","in"],alias:["ini","properties"]},{name:"ProtoBuf",mime:"text/x-protobuf",mode:"protobuf",ext:["proto"]},{name:"Python",mime:"text/x-python",mode:"python",ext:["BUILD","bzl","py","pyw"],file:/^(BUCK|BUILD)$/},{name:"Puppet",mime:"text/x-puppet",mode:"puppet",ext:["pp"]},{name:"Q",mime:"text/x-q",mode:"q",ext:["q"]},{name:"R",mime:"text/x-rsrc",mode:"r",ext:["r","R"],alias:["rscript"]},{name:"reStructuredText",mime:"text/x-rst",mode:"rst",ext:["rst"],alias:["rst"]},{name:"RPM Changes",mime:"text/x-rpm-changes",mode:"rpm"},{name:"RPM Spec",mime:"text/x-rpm-spec",mode:"rpm",ext:["spec"]},{name:"Ruby",mime:"text/x-ruby",mode:"ruby",ext:["rb"],alias:["jruby","macruby","rake","rb","rbx"]},{name:"Rust",mime:"text/x-rustsrc",mode:"rust",ext:["rs"]},{name:"SAS",mime:"text/x-sas",mode:"sas",ext:["sas"]},{name:"Sass",mime:"text/x-sass",mode:"sass",ext:["sass"]},{name:"Scala",mime:"text/x-scala",mode:"clike",ext:["scala"]},{name:"Scheme",mime:"text/x-scheme",mode:"scheme",ext:["scm","ss"]},{name:"SCSS",mime:"text/x-scss",mode:"css",ext:["scss"]},{name:"Shell",mimes:["text/x-sh","application/x-sh"],mode:"shell",ext:["sh","ksh","bash"],alias:["bash","sh","zsh"],file:/^PKGBUILD$/},{name:"Sieve",mime:"application/sieve",mode:"sieve",ext:["siv","sieve"]},{name:"Slim",mimes:["text/x-slim","application/x-slim"],mode:"slim",ext:["slim"]},{name:"Smalltalk",mime:"text/x-stsrc",mode:"smalltalk",ext:["st"]},{name:"Smarty",mime:"text/x-smarty",mode:"smarty",ext:["tpl"]},{name:"Solr",mime:"text/x-solr",mode:"solr"},{name:"SML",mime:"text/x-sml",mode:"mllike",ext:["sml","sig","fun","smackspec"]},{name:"Soy",mime:"text/x-soy",mode:"soy",ext:["soy"],alias:["closure template"]},{name:"SPARQL",mime:"application/sparql-query",mode:"sparql",ext:["rq","sparql"],alias:["sparul"]},{name:"Spreadsheet",mime:"text/x-spreadsheet",mode:"spreadsheet",alias:["excel","formula"]},{name:"SQL",mime:"text/x-sql",mode:"sql",ext:["sql"]},{name:"SQLite",mime:"text/x-sqlite",mode:"sql"},{name:"Squirrel",mime:"text/x-squirrel",mode:"clike",ext:["nut"]},{name:"Stylus",mime:"text/x-styl",mode:"stylus",ext:["styl"]},{name:"Swift",mime:"text/x-swift",mode:"swift",ext:["swift"]},{name:"sTeX",mime:"text/x-stex",mode:"stex"},{name:"LaTeX",mime:"text/x-latex",mode:"stex",ext:["text","ltx","tex"],alias:["tex"]},{name:"SystemVerilog",mime:"text/x-systemverilog",mode:"verilog",ext:["v","sv","svh"]},{name:"Tcl",mime:"text/x-tcl",mode:"tcl",ext:["tcl"]},{name:"Textile",mime:"text/x-textile",mode:"textile",ext:["textile"]},{name:"TiddlyWiki",mime:"text/x-tiddlywiki",mode:"tiddlywiki"},{name:"Tiki wiki",mime:"text/tiki",mode:"tiki"},{name:"TOML",mime:"text/x-toml",mode:"toml",ext:["toml"]},{name:"Tornado",mime:"text/x-tornado",mode:"tornado"},{name:"troff",mime:"text/troff",mode:"troff",ext:["1","2","3","4","5","6","7","8","9"]},{name:"TTCN",mime:"text/x-ttcn",mode:"ttcn",ext:["ttcn","ttcn3","ttcnpp"]},{name:"TTCN_CFG",mime:"text/x-ttcn-cfg",mode:"ttcn-cfg",ext:["cfg"]},{name:"Turtle",mime:"text/turtle",mode:"turtle",ext:["ttl"]},{name:"TypeScript",mime:"application/typescript",mode:"javascript",ext:["ts"],alias:["ts"]},{name:"TypeScript-JSX",mime:"text/typescript-jsx",mode:"jsx",ext:["tsx"],alias:["tsx"]},{name:"Twig",mime:"text/x-twig",mode:"twig"},{name:"Web IDL",mime:"text/x-webidl",mode:"webidl",ext:["webidl"]},{name:"VB.NET",mime:"text/x-vb",mode:"vb",ext:["vb"]},{name:"VBScript",mime:"text/vbscript",mode:"vbscript",ext:["vbs"]},{name:"Velocity",mime:"text/velocity",mode:"velocity",ext:["vtl"]},{name:"Verilog",mime:"text/x-verilog",mode:"verilog",ext:["v"]},{name:"VHDL",mime:"text/x-vhdl",mode:"vhdl",ext:["vhd","vhdl"]},{name:"Vue.js Component",mimes:["script/x-vue","text/x-vue"],mode:"vue",ext:["vue"]},{name:"XML",mimes:["application/xml","text/xml"],mode:"xml",ext:["xml","xsl","xsd","svg"],alias:["rss","wsdl","xsd"]},{name:"XQuery",mime:"application/xquery",mode:"xquery",ext:["xy","xquery"]},{name:"Yacas",mime:"text/x-yacas",mode:"yacas",ext:["ys"]},{name:"YAML",mimes:["text/x-yaml","text/yaml"],mode:"yaml",ext:["yaml","yml"],alias:["yml"]},{name:"Z80",mime:"text/x-z80",mode:"z80",ext:["z80"]},{name:"mscgen",mime:"text/x-mscgen",mode:"mscgen",ext:["mscgen","mscin","msc"]},{name:"xu",mime:"text/x-xu",mode:"mscgen",ext:["xu"]},{name:"msgenny",mime:"text/x-msgenny",mode:"mscgen",ext:["msgenny"]},{name:"WebAssembly",mime:"text/webassembly",mode:"wast",ext:["wat","wast"]}];for(var t=0;t-1&&t.substring(i+1,t.length);if(o)return e.findModeByExtension(o)},e.findModeByName=function(t){t=t.toLowerCase();for(var n=0;n")):null:e.match("--")?n(f("comment","--\x3e")):e.match("DOCTYPE",!0,!0)?(e.eatWhile(/[\w\._\-]/),n(p(1))):null:e.eat("?")?(e.eatWhile(/[\w\._\-]/),t.tokenize=f("meta","?>"),"meta"):(o=e.eat("/")?"closeTag":"openTag",t.tokenize=h,"tag bracket"):"&"==r?(e.eat("#")?e.eat("x")?e.eatWhile(/[a-fA-F\d]/)&&e.eat(";"):e.eatWhile(/[\d]/)&&e.eat(";"):e.eatWhile(/[\w\.\-:]/)&&e.eat(";"))?"atom":"error":(e.eatWhile(/[^&<]/),null)}function h(e,t){var n,r,i=e.next();if(">"==i||"/"==i&&e.eat(">"))return t.tokenize=d,o=">"==i?"endTag":"selfcloseTag","tag bracket";if("="==i)return o="equals",null;if("<"==i){t.tokenize=d,t.state=x,t.tagName=t.tagStart=null;var a=t.tokenize(e,t);return a?a+" tag error":"tag error"}return/[\'\"]/.test(i)?(t.tokenize=(n=i,(r=function(e,t){for(;!e.eol();)if(e.next()==n){t.tokenize=h;break}return"string"}).isInAttribute=!0,r),t.stringStartCol=e.column(),t.tokenize(e,t)):(e.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function f(e,t){return function(n,r){for(;!n.eol();){if(n.match(t)){r.tokenize=d;break}n.next()}return e}}function p(e){return function(t,n){for(var r;null!=(r=t.next());){if("<"==r)return n.tokenize=p(e+1),n.tokenize(t,n);if(">"==r){if(1==e){n.tokenize=d;break}return n.tokenize=p(e-1),n.tokenize(t,n)}}return"meta"}}function m(e,t,n){this.prev=e.context,this.tagName=t||"",this.indent=e.indented,this.startOfLine=n,(s.doNotIndent.hasOwnProperty(t)||e.context&&e.context.noIndent)&&(this.noIndent=!0)}function g(e){e.context&&(e.context=e.context.prev)}function v(e,t){for(var n;;){if(!e.context)return;if(n=e.context.tagName,!s.contextGrabbers.hasOwnProperty(n)||!s.contextGrabbers[n].hasOwnProperty(t))return;g(e)}}function x(e,t,n){return"openTag"==e?(n.tagStart=t.column(),y):"closeTag"==e?b:x}function y(e,t,n){return"word"==e?(n.tagName=t.current(),a="tag",w):s.allowMissingTagName&&"endTag"==e?(a="tag bracket",w(e,0,n)):(a="error",y)}function b(e,t,n){if("word"==e){var r=t.current();return n.context&&n.context.tagName!=r&&s.implicitlyClosed.hasOwnProperty(n.context.tagName)&&g(n),n.context&&n.context.tagName==r||!1===s.matchClosing?(a="tag",D):(a="tag error",C)}return s.allowMissingTagName&&"endTag"==e?(a="tag bracket",D(e,0,n)):(a="error",C)}function D(e,t,n){return"endTag"!=e?(a="error",D):(g(n),x)}function C(e,t,n){return a="error",D(e,0,n)}function w(e,t,n){if("word"==e)return a="attribute",k;if("endTag"==e||"selfcloseTag"==e){var r=n.tagName,i=n.tagStart;return n.tagName=n.tagStart=null,"selfcloseTag"==e||s.autoSelfClosers.hasOwnProperty(r)?v(n,r):(v(n,r),n.context=new m(n,r,i==n.indented)),x}return a="error",w}function k(e,t,n){return"equals"==e?S:(s.allowMissing||(a="error"),w(e,0,n))}function S(e,t,n){return"string"==e?F:"word"==e&&s.allowUnquoted?(a="string",w):(a="error",w(e,0,n))}function F(e,t,n){return"string"==e?F:w(e,0,n)}return d.isInText=!0,{startState:function(e){var t={tokenize:d,state:x,indented:e||0,tagName:null,tagStart:null,context:null};return null!=e&&(t.baseIndent=e),t},token:function(e,t){if(!t.tagName&&e.sol()&&(t.indented=e.indentation()),e.eatSpace())return null;o=null;var n=t.tokenize(e,t);return(n||o)&&"comment"!=n&&(a=null,t.state=t.state(o||n,e,t),a&&(n="error"==a?n+" error":a)),n},indent:function(t,n,r){var i=t.context;if(t.tokenize.isInAttribute)return t.tagStart==t.indented?t.stringStartCol+1:t.indented+l;if(i&&i.noIndent)return e.Pass;if(t.tokenize!=h&&t.tokenize!=d)return r?r.match(/^(\s*)/)[0].length:0;if(t.tagName)return!1!==s.multilineTagIndentPastTag?t.tagStart+t.tagName.length+2:t.tagStart+l*(s.multilineTagIndentFactor||1);if(s.alignCDATA&&/$/,blockCommentStart:"\x3c!--",blockCommentEnd:"--\x3e",configuration:s.htmlMode?"html":"xml",helperType:s.htmlMode?"html":"xml",skipAttribute:function(e){e.state==S&&(e.state=w)},xmlCurrentTag:function(e){return e.tagName?{name:e.tagName,close:"closeTag"==e.type}:null},xmlCurrentContext:function(e){for(var t=[],n=e.context;n;n=n.prev)t.push(n.tagName);return t.reverse()}}})),e.defineMIME("text/xml","xml"),e.defineMIME("application/xml","xml"),e.mimeModes.hasOwnProperty("text/html")||e.defineMIME("text/html",{name:"xml",htmlMode:!0})})("object"==typeof n&&"object"==typeof t?e("../../lib/codemirror"):CodeMirror)},{"../../lib/codemirror":10}],15:[function(e,t,n){!function(e,r){"object"==typeof n&&void 0!==t?t.exports=r():(e="undefined"!=typeof globalThis?globalThis:e||self).marked=r()}(this,(function(){"use strict";function e(e,t){for(var n=0;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(r=e[Symbol.iterator]()).next.bind(r)}var r=function(e){var t={exports:{}};return e(t,t.exports),t.exports}((function(e){function t(){return{baseUrl:null,breaks:!1,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1}}e.exports={defaults:{baseUrl:null,breaks:!1,gfm:!0,headerIds:!0,headerPrefix:"",highlight:null,langPrefix:"language-",mangle:!0,pedantic:!1,renderer:null,sanitize:!1,sanitizer:null,silent:!1,smartLists:!1,smartypants:!1,tokenizer:null,walkTokens:null,xhtml:!1},getDefaults:t,changeDefaults:function(t){e.exports.defaults=t}}})),i=/[&<>"']/,o=/[&<>"']/g,a=/[<>"']|&(?!#?\w+;)/,l=/[<>"']|&(?!#?\w+;)/g,s={"&":"&","<":"<",">":">",'"':""","'":"'"},u=function(e){return s[e]};var c=/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi;function d(e){return e.replace(c,(function(e,t){return"colon"===(t=t.toLowerCase())?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""}))}var h=/(^|[^\[])\^/g;var f=/[^\w:]/g,p=/^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;var m={},g=/^[^:]+:\/*[^/]*$/,v=/^([^:]+:)[\s\S]*$/,x=/^([^:]+:\/*[^/]*)[\s\S]*$/;function y(e,t){m[" "+e]||(g.test(e)?m[" "+e]=e+"/":m[" "+e]=b(e,"/",!0));var n=-1===(e=m[" "+e]).indexOf(":");return"//"===t.substring(0,2)?n?t:e.replace(v,"$1")+t:"/"===t.charAt(0)?n?t:e.replace(x,"$1")+t:e+t}function b(e,t,n){var r=e.length;if(0===r)return"";for(var i=0;i=0&&"\\"===n[i];)r=!r;return r?"|":" |"})).split(/ \|/),r=0;if(n.length>t)n.splice(t);else for(;n.length1;)1&t&&(n+=e),t>>=1,e+=e;return n+e},B=r.defaults,N=E,O=A,I=D,z=T;function H(e,t,n){var r=t.href,i=t.title?I(t.title):null,o=e[1].replace(/\\([\[\]])/g,"$1");return"!"!==e[0].charAt(0)?{type:"link",raw:n,href:r,title:i,text:o}:{type:"image",raw:n,href:r,title:i,text:I(o)}}var R=function(){function e(e){this.options=e||B}var t=e.prototype;return t.space=function(e){var t=this.rules.block.newline.exec(e);if(t)return t[0].length>1?{type:"space",raw:t[0]}:{raw:"\n"}},t.code=function(e){var t=this.rules.block.code.exec(e);if(t){var n=t[0].replace(/^ {1,4}/gm,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?n:N(n,"\n")}}},t.fences=function(e){var t=this.rules.block.fences.exec(e);if(t){var n=t[0],r=function(e,t){var n=e.match(/^(\s+)(?:```)/);if(null===n)return t;var r=n[1];return t.split("\n").map((function(e){var t=e.match(/^\s+/);return null===t?e:t[0].length>=r.length?e.slice(r.length):e})).join("\n")}(n,t[3]||"");return{type:"code",raw:n,lang:t[2]?t[2].trim():t[2],text:r}}},t.heading=function(e){var t=this.rules.block.heading.exec(e);if(t){var n=t[2].trim();if(/#$/.test(n)){var r=N(n,"#");this.options.pedantic?n=r.trim():r&&!/ $/.test(r)||(n=r.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:n}}},t.nptable=function(e){var t=this.rules.block.nptable.exec(e);if(t){var n={type:"table",header:O(t[1].replace(/^ *| *\| *$/g,"")),align:t[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:t[3]?t[3].replace(/\n$/,"").split("\n"):[],raw:t[0]};if(n.header.length===n.align.length){var r,i=n.align.length;for(r=0;r ?/gm,"");return{type:"blockquote",raw:t[0],text:n}}},t.list=function(e){var t=this.rules.block.list.exec(e);if(t){var n,r,i,o,a,l,s,u,c,d=t[0],h=t[2],f=h.length>1,p={type:"list",raw:d,ordered:f,start:f?+h.slice(0,-1):"",loose:!1,items:[]},m=t[0].match(this.rules.block.item),g=!1,v=m.length;i=this.rules.block.listItemStart.exec(m[0]);for(var x=0;xi[1].length:o[1].length>=i[0].length||o[1].length>3){m.splice(x,2,m[x]+(!this.options.pedantic&&o[1].length/i.test(r[0])&&(t=!1),!n&&/^<(pre|code|kbd|script)(\s|>)/i.test(r[0])?n=!0:n&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(r[0])&&(n=!1),{type:this.options.sanitize?"text":"html",raw:r[0],inLink:t,inRawBlock:n,text:this.options.sanitize?this.options.sanitizer?this.options.sanitizer(r[0]):I(r[0]):r[0]}},t.link=function(e){var t=this.rules.inline.link.exec(e);if(t){var n=t[2].trim();if(!this.options.pedantic&&/^$/.test(n))return;var r=N(n.slice(0,-1),"\\");if((n.length-r.length)%2==0)return}else{var i=z(t[2],"()");if(i>-1){var o=(0===t[0].indexOf("!")?5:4)+t[1].length+i;t[2]=t[2].substring(0,i),t[0]=t[0].substring(0,o).trim(),t[3]=""}}var a=t[2],l="";if(this.options.pedantic){var s=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(a);s&&(a=s[1],l=s[3])}else l=t[3]?t[3].slice(1,-1):"";return a=a.trim(),/^$/.test(n)?a.slice(1):a.slice(1,-1)),H(t,{href:a?a.replace(this.rules.inline._escapes,"$1"):a,title:l?l.replace(this.rules.inline._escapes,"$1"):l},t[0])}},t.reflink=function(e,t){var n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){var r=(n[2]||n[1]).replace(/\s+/g," ");if(!(r=t[r.toLowerCase()])||!r.href){var i=n[0].charAt(0);return{type:"text",raw:i,text:i}}return H(n,r,n[0])}},t.emStrong=function(e,t,n){void 0===n&&(n="");var r=this.rules.inline.emStrong.lDelim.exec(e);if(r&&(!r[3]||!n.match(/(?:[0-9A-Za-z\xAA\xB2\xB3\xB5\xB9\xBA\xBC-\xBE\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u0660-\u0669\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07C0-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0966-\u096F\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09E6-\u09F1\u09F4-\u09F9\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A66-\u0A6F\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AE6-\u0AEF\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B66-\u0B6F\u0B71-\u0B77\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0BE6-\u0BF2\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C66-\u0C6F\u0C78-\u0C7E\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CE6-\u0CEF\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D58-\u0D61\u0D66-\u0D78\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DE6-\u0DEF\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F20-\u0F33\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F-\u1049\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u1090-\u1099\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1369-\u137C\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A16\u1A20-\u1A54\u1A80-\u1A89\u1A90-\u1A99\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B50-\u1B59\u1B83-\u1BA0\u1BAE-\u1BE5\u1C00-\u1C23\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2070\u2071\u2074-\u2079\u207F-\u2089\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2150-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2CFD\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u3192-\u3195\u31A0-\u31BF\u31F0-\u31FF\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA830-\uA835\uA840-\uA873\uA882-\uA8B3\uA8D0-\uA8D9\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA900-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF-\uA9D9\uA9E0-\uA9E4\uA9E6-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA50-\uAA59\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDE80-\uDE9C\uDEA0-\uDED0\uDEE1-\uDEFB\uDF00-\uDF23\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC58-\uDC76\uDC79-\uDC9E\uDCA7-\uDCAF\uDCE0-\uDCF2\uDCF4\uDCF5\uDCFB-\uDD1B\uDD20-\uDD39\uDD80-\uDDB7\uDDBC-\uDDCF\uDDD2-\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE40-\uDE48\uDE60-\uDE7E\uDE80-\uDE9F\uDEC0-\uDEC7\uDEC9-\uDEE4\uDEEB-\uDEEF\uDF00-\uDF35\uDF40-\uDF55\uDF58-\uDF72\uDF78-\uDF91\uDFA9-\uDFAF]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDCFA-\uDD23\uDD30-\uDD39\uDE60-\uDE7E\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF27\uDF30-\uDF45\uDF51-\uDF54\uDFB0-\uDFCB\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC52-\uDC6F\uDC83-\uDCAF\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD03-\uDD26\uDD36-\uDD3F\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDD0-\uDDDA\uDDDC\uDDE1-\uDDF4\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDEF0-\uDEF9\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC50-\uDC59\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE50-\uDE59\uDE80-\uDEAA\uDEB8\uDEC0-\uDEC9\uDF00-\uDF1A\uDF30-\uDF3B]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCF2\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDD50-\uDD59\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC50-\uDC6C\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD50-\uDD59\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDDA0-\uDDA9\uDEE0-\uDEF2\uDFB0\uDFC0-\uDFD4]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF50-\uDF59\uDF5B-\uDF61\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE96\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD40-\uDD49\uDD4E\uDEC0-\uDEEB\uDEF0-\uDEF9]|\uD83A[\uDC00-\uDCC4\uDCC7-\uDCCF\uDD00-\uDD43\uDD4B\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/))){var i=r[1]||r[2]||"";if(!i||i&&(""===n||this.rules.inline.punctuation.exec(n))){var o,a,l=r[0].length-1,s=l,u=0,c="*"===r[0][0]?this.rules.inline.emStrong.rDelimAst:this.rules.inline.emStrong.rDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+l);null!=(r=c.exec(t));)if(o=r[1]||r[2]||r[3]||r[4]||r[5]||r[6])if(a=o.length,r[3]||r[4])s+=a;else if(!((r[5]||r[6])&&l%3)||(l+a)%3){if(!((s-=a)>0)){if(s+u-a<=0&&!t.slice(c.lastIndex).match(c)&&(a=Math.min(a,a+s+u)),Math.min(l,a)%2)return{type:"em",raw:e.slice(0,l+r.index+a+1),text:e.slice(1,l+r.index+a)};if(Math.min(l,a)%2==0)return{type:"strong",raw:e.slice(0,l+r.index+a+1),text:e.slice(2,l+r.index+a-1)}}}else u+=a}}},t.codespan=function(e){var t=this.rules.inline.code.exec(e);if(t){var n=t[2].replace(/\n/g," "),r=/[^ ]/.test(n),i=/^ /.test(n)&&/ $/.test(n);return r&&i&&(n=n.substring(1,n.length-1)),n=I(n,!0),{type:"codespan",raw:t[0],text:n}}},t.br=function(e){var t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}},t.del=function(e){var t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2]}},t.autolink=function(e,t){var n,r,i=this.rules.inline.autolink.exec(e);if(i)return r="@"===i[2]?"mailto:"+(n=I(this.options.mangle?t(i[1]):i[1])):n=I(i[1]),{type:"link",raw:i[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}},t.url=function(e,t){var n;if(n=this.rules.inline.url.exec(e)){var r,i;if("@"===n[2])i="mailto:"+(r=I(this.options.mangle?t(n[0]):n[0]));else{var o;do{o=n[0],n[0]=this.rules.inline._backpedal.exec(n[0])[0]}while(o!==n[0]);r=I(n[0]),i="www."===n[1]?"http://"+r:r}return{type:"link",raw:n[0],text:r,href:i,tokens:[{type:"text",raw:r,text:r}]}}},t.inlineText=function(e,t,n){var r,i=this.rules.inline.text.exec(e);if(i)return r=t?this.options.sanitize?this.options.sanitizer?this.options.sanitizer(i[0]):I(i[0]):i[0]:I(this.options.smartypants?n(i[0]):i[0]),{type:"text",raw:i[0],text:r}},e}(),P=S,_=w,W=F,j={newline:/^(?: *(?:\n|$))+/,code:/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,fences:/^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,hr:/^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,blockquote:/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,list:/^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?! {0,3}bull )\n*|\s*$)/,html:"^ {0,3}(?:<(script|pre|style)[\\s>][\\s\\S]*?(?:[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|\\n*|$)|\\n*|$)|)[\\s\\S]*?(?:\\n{2,}|$)|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)|(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$))",def:/^ {0,3}\[(label)\]: *\n? *]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,nptable:P,table:P,lheading:/^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/,_paragraph:/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html| +\n)[^\n]+)*)/,text:/^[^\n]+/,_label:/(?!\s*\])(?:\\[\[\]]|[^\[\]])+/,_title:/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/};j.def=_(j.def).replace("label",j._label).replace("title",j._title).getRegex(),j.bullet=/(?:[*+-]|\d{1,9}[.)])/,j.item=/^( *)(bull) ?[^\n]*(?:\n(?! *bull ?)[^\n]*)*/,j.item=_(j.item,"gm").replace(/bull/g,j.bullet).getRegex(),j.listItemStart=_(/^( *)(bull) */).replace("bull",j.bullet).getRegex(),j.list=_(j.list).replace(/bull/g,j.bullet).replace("hr","\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def","\\n+(?="+j.def.source+")").getRegex(),j._tag="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",j._comment=/|$)/,j.html=_(j.html,"i").replace("comment",j._comment).replace("tag",j._tag).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),j.paragraph=_(j._paragraph).replace("hr",j.hr).replace("heading"," {0,3}#{1,6} ").replace("|lheading","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|!--)").replace("tag",j._tag).getRegex(),j.blockquote=_(j.blockquote).replace("paragraph",j.paragraph).getRegex(),j.normal=W({},j),j.gfm=W({},j.normal,{nptable:"^ *([^|\\n ].*\\|.*)\\n {0,3}([-:]+ *\\|[-| :]*)(?:\\n((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)",table:"^ *\\|(.+)\\n {0,3}\\|?( *[-:]+[-| :]*)(?:\\n *((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)"}),j.gfm.nptable=_(j.gfm.nptable).replace("hr",j.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|!--)").replace("tag",j._tag).getRegex(),j.gfm.table=_(j.gfm.table).replace("hr",j.hr).replace("heading"," {0,3}#{1,6} ").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|!--)").replace("tag",j._tag).getRegex(),j.pedantic=W({},j.normal,{html:_("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+? *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",j._comment).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:P,paragraph:_(j.normal._paragraph).replace("hr",j.hr).replace("heading"," *#{1,6} *[^\n]").replace("lheading",j.lheading).replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").getRegex()});var q={escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,autolink:/^<(scheme:[^\s\x00-\x1f<>]*|email)>/,url:P,tag:"^comment|^|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^|^",link:/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/,reflink:/^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,nolink:/^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,reflinkSearch:"reflink|nolink(?!\\()",emStrong:{lDelim:/^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/,rDelimAst:/\_\_[^_]*?\*[^_]*?\_\_|[punct_](\*+)(?=[\s]|$)|[^punct*_\s](\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|[^punct*_\s](\*+)(?=[^punct*_\s])/,rDelimUnd:/\*\*[^*]*?\_[^*]*?\*\*|[punct*](\_+)(?=[\s]|$)|[^punct*_\s](\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/},code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,br:/^( {2,}|\\)\n(?!\s*$)/,del:P,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\?@\\[\\]`^{|}~"};q.punctuation=_(q.punctuation).replace(/punctuation/g,q._punctuation).getRegex(),q.blockSkip=/\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g,q.escapedEmSt=/\\\*|\\_/g,q._comment=_(j._comment).replace("(?:--\x3e|$)","--\x3e").getRegex(),q.emStrong.lDelim=_(q.emStrong.lDelim).replace(/punct/g,q._punctuation).getRegex(),q.emStrong.rDelimAst=_(q.emStrong.rDelimAst,"g").replace(/punct/g,q._punctuation).getRegex(),q.emStrong.rDelimUnd=_(q.emStrong.rDelimUnd,"g").replace(/punct/g,q._punctuation).getRegex(),q._escapes=/\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g,q._scheme=/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/,q._email=/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/,q.autolink=_(q.autolink).replace("scheme",q._scheme).replace("email",q._email).getRegex(),q._attribute=/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/,q.tag=_(q.tag).replace("comment",q._comment).replace("attribute",q._attribute).getRegex(),q._label=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,q._href=/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/,q._title=/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/,q.link=_(q.link).replace("label",q._label).replace("href",q._href).replace("title",q._title).getRegex(),q.reflink=_(q.reflink).replace("label",q._label).getRegex(),q.reflinkSearch=_(q.reflinkSearch,"g").replace("reflink",q.reflink).replace("nolink",q.nolink).getRegex(),q.normal=W({},q),q.pedantic=W({},q.normal,{strong:{start:/^__|\*\*/,middle:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,endAst:/\*\*(?!\*)/g,endUnd:/__(?!_)/g},em:{start:/^_|\*/,middle:/^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/,endAst:/\*(?!\*)/g,endUnd:/_(?!_)/g},link:_(/^!?\[(label)\]\((.*?)\)/).replace("label",q._label).getRegex(),reflink:_(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",q._label).getRegex()}),q.gfm=W({},q.normal,{escape:_(q.escape).replace("])","~|])").getRegex(),_extended_email:/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,url:/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,_backpedal:/(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\.5&&(n="x"+n.toString(16)),r+="&#"+n+";";return r}var Y=function(){function t(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||$,this.options.tokenizer=this.options.tokenizer||new R,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options;var t={block:G.normal,inline:V.normal};this.options.pedantic?(t.block=G.pedantic,t.inline=V.pedantic):this.options.gfm&&(t.block=G.gfm,this.options.breaks?t.inline=V.breaks:t.inline=V.gfm),this.tokenizer.rules=t}t.lex=function(e,n){return new t(n).lex(e)},t.lexInline=function(e,n){return new t(n).inlineTokens(e)};var n,r,i,o=t.prototype;return o.lex=function(e){return e=e.replace(/\r\n|\r/g,"\n").replace(/\t/g," "),this.blockTokens(e,this.tokens,!0),this.inline(this.tokens),this.tokens},o.blockTokens=function(e,t,n){var r,i,o,a;for(void 0===t&&(t=[]),void 0===n&&(n=!0),this.options.pedantic&&(e=e.replace(/^ +$/gm,""));e;)if(r=this.tokenizer.space(e))e=e.substring(r.raw.length),r.type&&t.push(r);else if(r=this.tokenizer.code(e))e=e.substring(r.raw.length),(a=t[t.length-1])&&"paragraph"===a.type?(a.raw+="\n"+r.raw,a.text+="\n"+r.text):t.push(r);else if(r=this.tokenizer.fences(e))e=e.substring(r.raw.length),t.push(r);else if(r=this.tokenizer.heading(e))e=e.substring(r.raw.length),t.push(r);else if(r=this.tokenizer.nptable(e))e=e.substring(r.raw.length),t.push(r);else if(r=this.tokenizer.hr(e))e=e.substring(r.raw.length),t.push(r);else if(r=this.tokenizer.blockquote(e))e=e.substring(r.raw.length),r.tokens=this.blockTokens(r.text,[],n),t.push(r);else if(r=this.tokenizer.list(e)){for(e=e.substring(r.raw.length),o=r.items.length,i=0;i0)for(;null!=(a=this.tokenizer.rules.inline.reflinkSearch.exec(u));)c.includes(a[0].slice(a[0].lastIndexOf("[")+1,-1))&&(u=u.slice(0,a.index)+"["+K("a",a[0].length-2)+"]"+u.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(a=this.tokenizer.rules.inline.blockSkip.exec(u));)u=u.slice(0,a.index)+"["+K("a",a[0].length-2)+"]"+u.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);for(;null!=(a=this.tokenizer.rules.inline.escapedEmSt.exec(u));)u=u.slice(0,a.index)+"++"+u.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex);for(;e;)if(l||(s=""),l=!1,i=this.tokenizer.escape(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.tag(e,n,r)){e=e.substring(i.raw.length),n=i.inLink,r=i.inRawBlock;var d=t[t.length-1];d&&"text"===i.type&&"text"===d.type?(d.raw+=i.raw,d.text+=i.text):t.push(i)}else if(i=this.tokenizer.link(e))e=e.substring(i.raw.length),"link"===i.type&&(i.tokens=this.inlineTokens(i.text,[],!0,r)),t.push(i);else if(i=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(i.raw.length);var h=t[t.length-1];"link"===i.type?(i.tokens=this.inlineTokens(i.text,[],!0,r),t.push(i)):h&&"text"===i.type&&"text"===h.type?(h.raw+=i.raw,h.text+=i.text):t.push(i)}else if(i=this.tokenizer.emStrong(e,u,s))e=e.substring(i.raw.length),i.tokens=this.inlineTokens(i.text,[],n,r),t.push(i);else if(i=this.tokenizer.codespan(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.br(e))e=e.substring(i.raw.length),t.push(i);else if(i=this.tokenizer.del(e))e=e.substring(i.raw.length),i.tokens=this.inlineTokens(i.text,[],n,r),t.push(i);else if(i=this.tokenizer.autolink(e,Z))e=e.substring(i.raw.length),t.push(i);else if(n||!(i=this.tokenizer.url(e,Z))){if(i=this.tokenizer.inlineText(e,r,X))e=e.substring(i.raw.length),"_"!==i.raw.slice(-1)&&(s=i.raw.slice(-1)),l=!0,(o=t[t.length-1])&&"text"===o.type?(o.raw+=i.raw,o.text+=i.text):t.push(i);else if(e){var f="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(f);break}throw new Error(f)}}else e=e.substring(i.raw.length),t.push(i);return t},n=t,i=[{key:"rules",get:function(){return{block:G,inline:V}}}],(r=null)&&e(n.prototype,r),i&&e(n,i),t}(),Q=r.defaults,J=k,ee=D,te=function(){function e(e){this.options=e||Q}var t=e.prototype;return t.code=function(e,t,n){var r=(t||"").match(/\S*/)[0];if(this.options.highlight){var i=this.options.highlight(e,r);null!=i&&i!==e&&(n=!0,e=i)}return e=e.replace(/\n$/,"")+"\n",r?'
'+(n?e:ee(e,!0))+"
\n":"
"+(n?e:ee(e,!0))+"
\n"},t.blockquote=function(e){return"
\n"+e+"
\n"},t.html=function(e){return e},t.heading=function(e,t,n,r){return this.options.headerIds?"'+e+"\n":""+e+"\n"},t.hr=function(){return this.options.xhtml?"
\n":"
\n"},t.list=function(e,t,n){var r=t?"ol":"ul";return"<"+r+(t&&1!==n?' start="'+n+'"':"")+">\n"+e+"\n"},t.listitem=function(e){return"
  • "+e+"
  • \n"},t.checkbox=function(e){return" "},t.paragraph=function(e){return"

    "+e+"

    \n"},t.table=function(e,t){return t&&(t=""+t+""),"\n\n"+e+"\n"+t+"
    \n"},t.tablerow=function(e){return"\n"+e+"\n"},t.tablecell=function(e,t){var n=t.header?"th":"td";return(t.align?"<"+n+' align="'+t.align+'">':"<"+n+">")+e+"\n"},t.strong=function(e){return""+e+""},t.em=function(e){return""+e+""},t.codespan=function(e){return""+e+""},t.br=function(){return this.options.xhtml?"
    ":"
    "},t.del=function(e){return""+e+""},t.link=function(e,t,n){if(null===(e=J(this.options.sanitize,this.options.baseUrl,e)))return n;var r='"},t.image=function(e,t,n){if(null===(e=J(this.options.sanitize,this.options.baseUrl,e)))return n;var r=''+n+'":">"},t.text=function(e){return e},e}(),ne=function(){function e(){}var t=e.prototype;return t.strong=function(e){return e},t.em=function(e){return e},t.codespan=function(e){return e},t.del=function(e){return e},t.html=function(e){return e},t.text=function(e){return e},t.link=function(e,t,n){return""+n},t.image=function(e,t,n){return""+n},t.br=function(){return""},e}(),re=function(){function e(){this.seen={}}var t=e.prototype;return t.serialize=function(e){return e.toLowerCase().trim().replace(/<[!\/a-z].*?>/gi,"").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g,"").replace(/\s/g,"-")},t.getNextSafeSlug=function(e,t){var n=e,r=0;if(this.seen.hasOwnProperty(n)){r=this.seen[e];do{n=e+"-"+ ++r}while(this.seen.hasOwnProperty(n))}return t||(this.seen[e]=r,this.seen[n]=0),n},t.slug=function(e,t){void 0===t&&(t={});var n=this.serialize(e);return this.getNextSafeSlug(n,t.dryrun)},e}(),ie=r.defaults,oe=C,ae=function(){function e(e){this.options=e||ie,this.options.renderer=this.options.renderer||new te,this.renderer=this.options.renderer,this.renderer.options=this.options,this.textRenderer=new ne,this.slugger=new re}e.parse=function(t,n){return new e(n).parse(t)},e.parseInline=function(t,n){return new e(n).parseInline(t)};var t=e.prototype;return t.parse=function(e,t){void 0===t&&(t=!0);var n,r,i,o,a,l,s,u,c,d,h,f,p,m,g,v,x,y,b="",D=e.length;for(n=0;n0&&"text"===g.tokens[0].type?(g.tokens[0].text=y+" "+g.tokens[0].text,g.tokens[0].tokens&&g.tokens[0].tokens.length>0&&"text"===g.tokens[0].tokens[0].type&&(g.tokens[0].tokens[0].text=y+" "+g.tokens[0].tokens[0].text)):g.tokens.unshift({type:"text",text:y}):m+=y),m+=this.parse(g.tokens,p),c+=this.renderer.listitem(m,x,v);b+=this.renderer.list(c,h,f);continue;case"html":b+=this.renderer.html(d.text);continue;case"paragraph":b+=this.renderer.paragraph(this.parseInline(d.tokens));continue;case"text":for(c=d.tokens?this.parseInline(d.tokens):d.text;n+1An error occurred:

    "+ue(e.message+"",!0)+"
    ";throw e}}return fe.options=fe.setOptions=function(e){return le(fe.defaults,e),de(fe.defaults),fe},fe.getDefaults=ce,fe.defaults=he,fe.use=function(e){var t=le({},e);if(e.renderer&&function(){var n=fe.defaults.renderer||new te,r=function(t){var r=n[t];n[t]=function(){for(var i=arguments.length,o=new Array(i),a=0;aAn error occurred:

    "+ue(e.message+"",!0)+"
    ";throw e}},fe.Parser=ae,fe.parser=ae.parse,fe.Renderer=te,fe.TextRenderer=ne,fe.Lexer=Y,fe.lexer=Y.lex,fe.Tokenizer=R,fe.Slugger=re,fe.parse=fe,fe}))},{}],16:[function(e,t,n){(function(n){(function(){var r;!function(){"use strict";(r=function(e,t,r,i){i=i||{},this.dictionary=null,this.rules={},this.dictionaryTable={},this.compoundRules=[],this.compoundRuleCodes={},this.replacementTable=[],this.flags=i.flags||{},this.memoized={},this.loaded=!1;var o,a,l,s,u,c=this;function d(e,t){var n=c._readFile(e,null,i.asyncLoad);i.asyncLoad?n.then((function(e){t(e)})):t(n)}function h(e){t=e,r&&p()}function f(e){r=e,t&&p()}function p(){for(c.rules=c._parseAFF(t),c.compoundRuleCodes={},a=0,s=c.compoundRules.length;a0&&(b.continuationClasses=x),"."!==y&&(b.match="SFX"===d?new RegExp(y+"$"):new RegExp("^"+y)),"0"!=m&&(b.remove="SFX"===d?new RegExp(m+"$"):m),p.push(b)}s[h]={type:d,combineable:"Y"==f,entries:p},i+=n}else if("COMPOUNDRULE"===d){for(o=i+1,l=i+1+(n=parseInt(c[1],10));o0&&(null===n[e]&&(n[e]=[]),n[e].push(t))}for(var i=1,o=t.length;i1){var u=this.parseRuleCodes(l[1]);"NEEDAFFIX"in this.flags&&-1!=u.indexOf(this.flags.NEEDAFFIX)||r(s,u);for(var c=0,d=u.length;c=this.flags.COMPOUNDMIN)for(t=0,n=this.compoundRules.length;t1&&c[1][1]!==c[1][0]&&(o=c[0]+c[1][1]+c[1][0]+c[1].substring(2),t&&!l.check(o)||(o in a?a[o]+=1:a[o]=1)),c[1]){var d=c[1].substring(0,1).toUpperCase()===c[1].substring(0,1)?"uppercase":"lowercase";for(r=0;rr?1:t[0].localeCompare(e[0])})).reverse();var u=[],c="lowercase";e.toUpperCase()===e?c="uppercase":e.substr(0,1).toUpperCase()+e.substr(1).toLowerCase()===e&&(c="capitalized");var d=t;for(n=0;n)+?/g),s={toggleBold:C,toggleItalic:w,drawLink:I,toggleHeadingSmaller:A,toggleHeadingBigger:E,drawImage:z,toggleBlockquote:F,toggleOrderedList:N,toggleUnorderedList:B,toggleCodeBlock:S,togglePreview:U,toggleStrikethrough:k,toggleHeading1:T,toggleHeading2:L,toggleHeading3:M,cleanBlock:O,drawTable:P,drawHorizontalRule:_,undo:W,redo:j,toggleSideBySide:q,toggleFullScreen:D},u={toggleBold:"Cmd-B",toggleItalic:"Cmd-I",drawLink:"Cmd-K",toggleHeadingSmaller:"Cmd-H",toggleHeadingBigger:"Shift-Cmd-H",cleanBlock:"Cmd-E",drawImage:"Cmd-Alt-I",toggleBlockquote:"Cmd-'",toggleOrderedList:"Cmd-Alt-L",toggleUnorderedList:"Cmd-L",toggleCodeBlock:"Cmd-Alt-C",togglePreview:"Cmd-P",toggleSideBySide:"F9",toggleFullScreen:"F11"},c=function(){var e,t=!1;return e=navigator.userAgent||navigator.vendor||window.opera,(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(e.substr(0,4)))&&(t=!0),t};function d(e){return e=a?e.replace("Ctrl","Cmd"):e.replace("Cmd","Ctrl")}var h={};function f(e){return h[e]||(h[e]=new RegExp("\\s*"+e+"(\\s*)","g"))}function p(e,t){if(e&&t){var n=f(t);e.className.match(n)||(e.className+=" "+t)}}function m(e,t){if(e&&t){var n=f(t);e.className.match(n)&&(e.className=e.className.replace(n,"$1"))}}function g(e,t,n,r){var i=v(e,!1,t,n,"button",r);i.className+=" easymde-dropdown";var o=document.createElement("div");o.className="easymde-dropdown-content";for(var a=0;a=0&&!n(h=s.getLineHandle(o));o--);var g,v,x,y,b=r(s.getTokenAt({line:o,ch:1})).fencedChars;n(s.getLineHandle(u.line))?(g="",v=u.line):n(s.getLineHandle(u.line-1))?(g="",v=u.line-1):(g=b+"\n",v=u.line),n(s.getLineHandle(c.line))?(x="",y=c.line,0===c.ch&&(y+=1)):0!==c.ch&&n(s.getLineHandle(c.line+1))?(x="",y=c.line+1):(x=b+"\n",y=c.line+1),0===c.ch&&(y-=1),s.operation((function(){s.replaceRange(x,{line:y,ch:0},{line:y+(x?0:1),ch:0}),s.replaceRange(g,{line:v,ch:0},{line:v+(g?0:1),ch:0})})),s.setSelection({line:v+(g?1:0),ch:0},{line:y+(g?1:-1),ch:0}),s.focus()}else{var D=u.line;if(n(s.getLineHandle(u.line))&&("fenced"===i(s,u.line+1)?(o=u.line,D=u.line+1):(a=u.line,D=u.line-1)),void 0===o)for(o=D;o>=0&&!n(h=s.getLineHandle(o));o--);if(void 0===a)for(l=s.lineCount(),a=D;a=0;o--)if(!(h=s.getLineHandle(o)).text.match(/^\s*$/)&&"indented"!==i(s,o,h)){o+=1;break}for(l=s.lineCount(),a=u.line;a ]+|[0-9]+(.|\)))[ ]*/,""),e.replaceRange(t,{line:i,ch:0},{line:i,ch:99999999999999})}(e.codemirror)}function I(e){var t=e.codemirror,n=y(t),r=e.options,i="https://";if(r.promptURLs&&!(i=prompt(r.promptTexts.link,"https://")))return!1;$(t,n.link,r.insertTexts.link,i)}function z(e){var t=e.codemirror,n=y(t),r=e.options,i="https://";if(r.promptURLs&&!(i=prompt(r.promptTexts.image,"https://")))return!1;$(t,n.image,r.insertTexts.image,i)}function H(e){e.openBrowseFileWindow()}function R(e,t){var n=e.codemirror,r=y(n),i=e.options,o=t.substr(t.lastIndexOf("/")+1),a=o.substring(o.lastIndexOf(".")+1).replace(/\?.*$/,"");if(["png","jpg","jpeg","gif","svg"].includes(a))$(n,r.image,i.insertTexts.uploadedImage,t);else{var l=i.insertTexts.link;l[0]="["+o,$(n,r.link,l,t)}e.updateStatusBar("upload-image",e.options.imageTexts.sbOnUploaded.replace("#image_name#",o)),setTimeout((function(){e.updateStatusBar("upload-image",e.options.imageTexts.sbInit)}),1e3)}function P(e){var t=e.codemirror,n=y(t),r=e.options;$(t,n.table,r.insertTexts.table)}function _(e){var t=e.codemirror,n=y(t),r=e.options;$(t,n.image,r.insertTexts.horizontalRule)}function W(e){var t=e.codemirror;t.undo(),t.focus()}function j(e){var t=e.codemirror;t.redo(),t.focus()}function q(e){var t=e.codemirror,n=t.getWrapperElement(),r=n.nextSibling,i=e.toolbarElements&&e.toolbarElements["side-by-side"],o=!1,a=n.parentNode;/editor-preview-active-side/.test(r.className)?(!1===e.options.sideBySideFullscreen&&m(a,"sided--no-fullscreen"),r.className=r.className.replace(/\s*editor-preview-active-side\s*/g,""),i&&(i.className=i.className.replace(/\s*active\s*/g,"")),n.className=n.className.replace(/\s*CodeMirror-sided\s*/g," ")):(setTimeout((function(){t.getOption("fullScreen")||(!1===e.options.sideBySideFullscreen?p(a,"sided--no-fullscreen"):D(e)),r.className+=" editor-preview-active-side"}),1),i&&(i.className+=" active"),n.className+=" CodeMirror-sided",o=!0);var l=n.lastChild;if(/editor-preview-active/.test(l.className)){l.className=l.className.replace(/\s*editor-preview-active\s*/g,"");var s=e.toolbarElements.preview,u=e.toolbar_div;s.className=s.className.replace(/\s*active\s*/g,""),u.className=u.className.replace(/\s*disabled-for-preview*/g,"")}if(t.sideBySideRenderingFunction||(t.sideBySideRenderingFunction=function(){var t=e.options.previewRender(e.value(),r);null!=t&&(r.innerHTML=t)}),o){var c=e.options.previewRender(e.value(),r);null!=c&&(r.innerHTML=c),t.on("update",t.sideBySideRenderingFunction)}else t.off("update",t.sideBySideRenderingFunction);t.refresh()}function U(e){var t=e.codemirror,n=t.getWrapperElement(),r=e.toolbar_div,i=!!e.options.toolbar&&e.toolbarElements.preview,o=n.lastChild,a=t.getWrapperElement().nextSibling;if(/editor-preview-active-side/.test(a.className)&&q(e),!o||!/editor-preview-full/.test(o.className)){if((o=document.createElement("div")).className="editor-preview-full",e.options.previewClass)if(Array.isArray(e.options.previewClass))for(var l=0;l\s+/,"unordered-list":n,"ordered-list":n},s=function(e,t,i){var o=n.exec(t),a=function(e,t){return{quote:">","unordered-list":"*","ordered-list":"%%i."}[e].replace("%%i",t)}(e,u);return null!==o?(function(e,t){var n=new RegExp({quote:">","unordered-list":"*","ordered-list":"\\d+."}[e]);return t&&n.test(t)}(e,o[2])&&(a=""),t=o[1]+a+o[3]+t.replace(r,"").replace(l[e],"$1")):0==i&&(t=a+" "+t),t},u=1,c=o.line;c<=a.line;c++)!function(n){var r=e.getLine(n);i[t]?r=r.replace(l[t],"$1"):("unordered-list"==t&&(r=s("ordered-list",r,!0)),r=s(t,r,!1),u+=1),e.replaceRange(r,{line:n,ch:0},{line:n,ch:99999999999999})}(c);e.focus()}}function K(e,t,n,r){if(!/editor-preview-active/.test(e.codemirror.getWrapperElement().lastChild.className)){r=void 0===r?n:r;var i,o=e.codemirror,a=y(o),l=n,s=r,u=o.getCursor("start"),c=o.getCursor("end");a[t]?(l=(i=o.getLine(u.line)).slice(0,u.ch),s=i.slice(u.ch),"bold"==t?(l=l.replace(/(\*\*|__)(?![\s\S]*(\*\*|__))/,""),s=s.replace(/(\*\*|__)/,"")):"italic"==t?(l=l.replace(/(\*|_)(?![\s\S]*(\*|_))/,""),s=s.replace(/(\*|_)/,"")):"strikethrough"==t&&(l=l.replace(/(\*\*|~~)(?![\s\S]*(\*\*|~~))/,""),s=s.replace(/(\*\*|~~)/,"")),o.replaceRange(l+s,{line:u.line,ch:0},{line:u.line,ch:99999999999999}),"bold"==t||"strikethrough"==t?(u.ch-=2,u!==c&&(c.ch-=2)):"italic"==t&&(u.ch-=1,u!==c&&(c.ch-=1))):(i=o.getSelection(),"bold"==t?i=(i=i.split("**").join("")).split("__").join(""):"italic"==t?i=(i=i.split("*").join("")).split("_").join(""):"strikethrough"==t&&(i=i.split("~~").join("")),o.replaceSelection(l+i+s),u.ch+=n.length,c.ch=u.ch+i.length),o.setSelection(u,c),o.focus()}}function X(e,t){if(Math.abs(e)<1024)return""+e+t[0];var n=0;do{e/=1024,++n}while(Math.abs(e)>=1024&&n=19968?n+=t[r].length:n+=1;return n}var J={bold:{name:"bold",action:C,className:"fa fa-bold",title:"Bold",default:!0},italic:{name:"italic",action:w,className:"fa fa-italic",title:"Italic",default:!0},strikethrough:{name:"strikethrough",action:k,className:"fa fa-strikethrough",title:"Strikethrough"},heading:{name:"heading",action:A,className:"fa fa-header fa-heading",title:"Heading",default:!0},"heading-smaller":{name:"heading-smaller",action:A,className:"fa fa-header fa-heading header-smaller",title:"Smaller Heading"},"heading-bigger":{name:"heading-bigger",action:E,className:"fa fa-header fa-heading header-bigger",title:"Bigger Heading"},"heading-1":{name:"heading-1",action:T,className:"fa fa-header fa-heading header-1",title:"Big Heading"},"heading-2":{name:"heading-2",action:L,className:"fa fa-header fa-heading header-2",title:"Medium Heading"},"heading-3":{name:"heading-3",action:M,className:"fa fa-header fa-heading header-3",title:"Small Heading"},"separator-1":{name:"separator-1"},code:{name:"code",action:S,className:"fa fa-code",title:"Code"},quote:{name:"quote",action:F,className:"fa fa-quote-left",title:"Quote",default:!0},"unordered-list":{name:"unordered-list",action:B,className:"fa fa-list-ul",title:"Generic List",default:!0},"ordered-list":{name:"ordered-list",action:N,className:"fa fa-list-ol",title:"Numbered List",default:!0},"clean-block":{name:"clean-block",action:O,className:"fa fa-eraser",title:"Clean block"},"separator-2":{name:"separator-2"},link:{name:"link",action:I,className:"fa fa-link",title:"Create Link",default:!0},image:{name:"image",action:z,className:"fa fa-image",title:"Insert Image",default:!0},"upload-image":{name:"upload-image",action:H,className:"fa fa-image",title:"Import an image"},table:{name:"table",action:P,className:"fa fa-table",title:"Insert Table"},"horizontal-rule":{name:"horizontal-rule",action:_,className:"fa fa-minus",title:"Insert Horizontal Line"},"separator-3":{name:"separator-3"},preview:{name:"preview",action:U,className:"fa fa-eye",noDisable:!0,title:"Toggle Preview",default:!0},"side-by-side":{name:"side-by-side",action:q,className:"fa fa-columns",noDisable:!0,noMobile:!0,title:"Toggle Side by Side",default:!0},fullscreen:{name:"fullscreen",action:D,className:"fa fa-arrows-alt",noDisable:!0,noMobile:!0,title:"Toggle Fullscreen",default:!0},"separator-4":{name:"separator-4"},guide:{name:"guide",action:"https://www.markdownguide.org/basic-syntax/",className:"fa fa-question-circle",noDisable:!0,title:"Markdown Guide",default:!0},"separator-5":{name:"separator-5"},undo:{name:"undo",action:W,className:"fa fa-undo",noDisable:!0,title:"Undo"},redo:{name:"redo",action:j,className:"fa fa-repeat fa-redo",noDisable:!0,title:"Redo"}},ee={link:["[","](#url#)"],image:["![](","#url#)"],uploadedImage:["![](#url#)",""],table:["","\n\n| Column 1 | Column 2 | Column 3 |\n| -------- | -------- | -------- |\n| Text | Text | Text |\n\n"],horizontalRule:["","\n\n-----\n\n"]},te={link:"URL for the link:",image:"URL of the image:"},ne={locale:"en-US",format:{hour:"2-digit",minute:"2-digit"}},re={bold:"**",code:"```",italic:"*"},ie={sbInit:"Attach files by drag and dropping or pasting from clipboard.",sbOnDragEnter:"Drop image to upload it.",sbOnDrop:"Uploading image #images_names#...",sbProgress:"Uploading #file_name#: #progress#%",sbOnUploaded:"Uploaded #image_name#",sizeUnits:" B, KB, MB"},oe={noFileGiven:"You must select a file.",typeNotAllowed:"This image type is not allowed.",fileTooLarge:"Image #image_name# is too big (#image_size#).\nMaximum file size is #image_max_size#.",importError:"Something went wrong when uploading the image #image_name#."};function ae(e){(e=e||{}).parent=this;var t=!0;if(!1===e.autoDownloadFontAwesome&&(t=!1),!0!==e.autoDownloadFontAwesome)for(var n=document.styleSheets,r=0;r-1&&(t=!1);if(t){var i=document.createElement("link");i.rel="stylesheet",i.href="https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css",document.getElementsByTagName("head")[0].appendChild(i)}if(e.element)this.element=e.element;else if(null===e.element)return void console.log("EasyMDE: Error. No element was found.");if(void 0===e.toolbar)for(var o in e.toolbar=[],J)Object.prototype.hasOwnProperty.call(J,o)&&(-1!=o.indexOf("separator-")&&e.toolbar.push("|"),(!0===J[o].default||e.showIcons&&e.showIcons.constructor===Array&&-1!=e.showIcons.indexOf(o))&&e.toolbar.push(o));if(Object.prototype.hasOwnProperty.call(e,"previewClass")||(e.previewClass="editor-preview"),Object.prototype.hasOwnProperty.call(e,"status")||(e.status=["autosave","lines","words","cursor"],e.uploadImage&&e.status.unshift("upload-image")),e.previewRender||(e.previewRender=function(e){return this.parent.markdown(e)}),e.parsingConfig=Y({highlightFormatting:!0},e.parsingConfig||{}),e.insertTexts=Y({},ee,e.insertTexts||{}),e.promptTexts=Y({},te,e.promptTexts||{}),e.blockStyles=Y({},re,e.blockStyles||{}),null!=e.autosave&&(e.autosave.timeFormat=Y({},ne,e.autosave.timeFormat||{})),e.shortcuts=Y({},u,e.shortcuts||{}),e.maxHeight=e.maxHeight||void 0,void 0!==e.maxHeight?e.minHeight=e.maxHeight:e.minHeight=e.minHeight||"300px",e.errorCallback=e.errorCallback||function(e){alert(e)},e.uploadImage=e.uploadImage||!1,e.imageMaxSize=e.imageMaxSize||2097152,e.imageAccept=e.imageAccept||"image/png, image/jpeg",e.imageTexts=Y({},ie,e.imageTexts||{}),e.errorMessages=Y({},oe,e.errorMessages||{}),null!=e.autosave&&null!=e.autosave.unique_id&&""!=e.autosave.unique_id&&(e.autosave.uniqueId=e.autosave.unique_id),e.overlayMode&&void 0===e.overlayMode.combine&&(e.overlayMode.combine=!0),this.options=e,this.render(),!e.initialValue||this.options.autosave&&!0===this.options.autosave.foundSavedValue||this.value(e.initialValue),e.uploadImage){var a=this;this.codemirror.on("dragenter",(function(e,t){a.updateStatusBar("upload-image",a.options.imageTexts.sbOnDragEnter),t.stopPropagation(),t.preventDefault()})),this.codemirror.on("dragend",(function(e,t){a.updateStatusBar("upload-image",a.options.imageTexts.sbInit),t.stopPropagation(),t.preventDefault()})),this.codemirror.on("dragleave",(function(e,t){a.updateStatusBar("upload-image",a.options.imageTexts.sbInit),t.stopPropagation(),t.preventDefault()})),this.codemirror.on("dragover",(function(e,t){a.updateStatusBar("upload-image",a.options.imageTexts.sbOnDragEnter),t.stopPropagation(),t.preventDefault()})),this.codemirror.on("drop",(function(t,n){n.stopPropagation(),n.preventDefault(),e.imageUploadFunction?a.uploadImagesUsingCustomFunction(e.imageUploadFunction,n.dataTransfer.files):a.uploadImages(n.dataTransfer.files)})),this.codemirror.on("paste",(function(t,n){e.imageUploadFunction?a.uploadImagesUsingCustomFunction(e.imageUploadFunction,n.clipboardData.files):a.uploadImages(n.clipboardData.files)}))}}function le(){if("object"!=typeof localStorage)return!1;try{localStorage.setItem("smde_localStorage",1),localStorage.removeItem("smde_localStorage")}catch(e){return!1}return!0}ae.prototype.uploadImages=function(e,t,n){if(0!==e.length){for(var r=[],i=0;i$/,' target="_blank">');e=e.replace(n,r)}}return e}(r))}},ae.prototype.render=function(e){if(e||(e=this.element||document.getElementsByTagName("textarea")[0]),!this._rendered||this._rendered!==e){this.element=e;var t,n,o=this.options,a=this,l={};for(var u in o.shortcuts)null!==o.shortcuts[u]&&null!==s[u]&&function(e){l[d(o.shortcuts[e])]=function(){var t=s[e];"function"==typeof t?t(a):"string"==typeof t&&window.open(t,"_blank")}}(u);if(l.Enter="newlineAndIndentContinueMarkdownList",l.Tab="tabAndIndentMarkdownList",l["Shift-Tab"]="shiftTabAndUnindentMarkdownList",l.Esc=function(e){e.getOption("fullScreen")&&D(a)},this.documentOnKeyDown=function(e){27==(e=e||window.event).keyCode&&a.codemirror.getOption("fullScreen")&&D(a)},document.addEventListener("keydown",this.documentOnKeyDown,!1),o.overlayMode?(r.defineMode("overlay-mode",(function(e){return r.overlayMode(r.getMode(e,!1!==o.spellChecker?"spell-checker":"gfm"),o.overlayMode.mode,o.overlayMode.combine)})),t="overlay-mode",(n=o.parsingConfig).gitHubSpice=!1):((t=o.parsingConfig).name="gfm",t.gitHubSpice=!1),!1!==o.spellChecker&&(t="spell-checker",(n=o.parsingConfig).name="gfm",n.gitHubSpice=!1,i({codeMirrorInstance:r})),this.codemirror=r.fromTextArea(e,{mode:t,backdrop:n,theme:null!=o.theme?o.theme:"easymde",tabSize:null!=o.tabSize?o.tabSize:2,indentUnit:null!=o.tabSize?o.tabSize:2,indentWithTabs:!1!==o.indentWithTabs,lineNumbers:!0===o.lineNumbers,autofocus:!0===o.autofocus,extraKeys:l,lineWrapping:!1!==o.lineWrapping,allowDropFileTypes:["text/plain"],placeholder:o.placeholder||e.getAttribute("placeholder")||"",styleSelectedText:null!=o.styleSelectedText?o.styleSelectedText:!c(),scrollbarStyle:null!=o.scrollbarStyle?o.scrollbarStyle:"native",configureMouse:function(e,t,n){return{addNew:!1}},inputStyle:null!=o.inputStyle?o.inputStyle:c()?"contenteditable":"textarea",spellcheck:null==o.nativeSpellcheck||o.nativeSpellcheck,autoRefresh:null!=o.autoRefresh&&o.autoRefresh}),this.codemirror.getScrollerElement().style.minHeight=o.minHeight,void 0!==o.maxHeight&&(this.codemirror.getScrollerElement().style.height=o.maxHeight),!0===o.forceSync){var h=this.codemirror;h.on("change",(function(){h.save()}))}this.gui={};var f=document.createElement("div");f.classList.add("EasyMDEContainer");var p=this.codemirror.getWrapperElement();p.parentNode.insertBefore(f,p),f.appendChild(p),!1!==o.toolbar&&(this.gui.toolbar=this.createToolbar()),!1!==o.status&&(this.gui.statusbar=this.createStatusbar()),null!=o.autosave&&!0===o.autosave.enabled&&(this.autosave(),this.codemirror.on("change",(function(){clearTimeout(a._autosave_timeout),a._autosave_timeout=setTimeout((function(){a.autosave()}),a.options.autosave.submit_delay||a.options.autosave.delay||1e3)})));var m=this;this.codemirror.on("update",(function(){o.previewImagesInEditor&&f.querySelectorAll(".cm-image-marker").forEach((function(e){var t=e.parentElement;if(t.innerText.match(/^!\[.*?\]\(.*\)/g)&&!t.hasAttribute("data-img-src")){var n=t.innerText.match("\\((.*)\\)");if(window.EMDEimagesCache||(window.EMDEimagesCache={}),n&&n.length>=2){var r=n[1];if(window.EMDEimagesCache[r])v(t,window.EMDEimagesCache[r]);else{var i=document.createElement("img");i.onload=function(){window.EMDEimagesCache[r]={naturalWidth:i.naturalWidth,naturalHeight:i.naturalHeight,url:r},v(t,window.EMDEimagesCache[r])},i.src=r}}}}))})),this.gui.sideBySide=this.createSideBySide(),this._rendered=this.element;var g=this.codemirror;setTimeout(function(){g.refresh()}.bind(g),0)}function v(e,t){var n,r;e.setAttribute("data-img-src",t.url),e.setAttribute("style","--bg-image:url("+t.url+");--width:"+t.naturalWidth+"px;--height:"+(n=t.naturalWidth,r=t.naturalHeight,nthis.options.imageMaxSize)i(o(this.options.errorMessages.fileTooLarge));else{var a=new FormData;a.append("image",e),r.options.imageCSRFToken&&a.append("csrfmiddlewaretoken",r.options.imageCSRFToken);var l=new XMLHttpRequest;l.upload.onprogress=function(t){if(t.lengthComputable){var n=""+Math.round(100*t.loaded/t.total);r.updateStatusBar("upload-image",r.options.imageTexts.sbProgress.replace("#file_name#",e.name).replace("#progress#",n))}},l.open("POST",this.options.imageUploadEndpoint),l.onload=function(){try{var e=JSON.parse(this.responseText)}catch(e){return console.error("EasyMDE: The server did not return a valid json."),void i(o(r.options.errorMessages.importError))}200===this.status&&e&&!e.error&&e.data&&e.data.filePath?t((r.options.imagePathAbsolute?"":window.location.origin+"/")+e.data.filePath):e.error&&e.error in r.options.errorMessages?i(o(r.options.errorMessages[e.error])):e.error?i(o(e.error)):(console.error("EasyMDE: Received an unexpected response after uploading the image."+this.status+" ("+this.statusText+")"),i(o(r.options.errorMessages.importError)))},l.onerror=function(e){console.error("EasyMDE: An unexpected error occurred when trying to upload the image."+e.target.status+" ("+e.target.statusText+")"),i(r.options.errorMessages.importError)},l.send(a)}},ae.prototype.uploadImageUsingCustomFunction=function(e,t){var n=this;e.apply(this,[t,function(e){R(n,e)},function(e){var r=function(e){var r=n.options.imageTexts.sizeUnits.split(",");return e.replace("#image_name#",t.name).replace("#image_size#",X(t.size,r)).replace("#image_max_size#",X(n.options.imageMaxSize,r))}(e);n.updateStatusBar("upload-image",r),setTimeout((function(){n.updateStatusBar("upload-image",n.options.imageTexts.sbInit)}),1e4),n.options.errorCallback(r)}])},ae.prototype.setPreviewMaxHeight=function(){var e=this.codemirror.getWrapperElement(),t=e.nextSibling,n=parseInt(window.getComputedStyle(e).paddingTop),r=parseInt(window.getComputedStyle(e).borderTopWidth),i=(parseInt(this.options.maxHeight)+2*n+2*r).toString()+"px";t.style.height=i},ae.prototype.createSideBySide=function(){var e=this.codemirror,t=e.getWrapperElement(),n=t.nextSibling;if(!n||!/editor-preview-side/.test(n.className)){if((n=document.createElement("div")).className="editor-preview-side",this.options.previewClass)if(Array.isArray(this.options.previewClass))for(var r=0;r p { + margin-top: 0 +} + +.editor-preview pre { + background: #eee; + margin-bottom: 10px; +} + +.editor-preview table td, +.editor-preview table th { + border: 1px solid #ddd; + padding: 5px; +} + +.cm-s-easymde .cm-tag { + color: #63a35c; +} + +.cm-s-easymde .cm-attribute { + color: #795da3; +} + +.cm-s-easymde .cm-string { + color: #183691; +} + +.cm-s-easymde .cm-header-1 { + font-size: 200%; + line-height: 200%; +} + +.cm-s-easymde .cm-header-2 { + font-size: 160%; + line-height: 160%; +} + +.cm-s-easymde .cm-header-3 { + font-size: 125%; + line-height: 125%; +} + +.cm-s-easymde .cm-header-4 { + font-size: 110%; + line-height: 110%; +} + +.cm-s-easymde .cm-comment { + background: rgba(0, 0, 0, .05); + border-radius: 2px; +} + +.cm-s-easymde .cm-link { + color: #7f8c8d; +} + +.cm-s-easymde .cm-url { + color: #aab2b3; +} + +.cm-s-easymde .cm-quote { + color: #7f8c8d; + font-style: italic; +} + +.editor-toolbar .easymde-dropdown { + position: relative; + background: linear-gradient(to bottom right, #fff 0%, #fff 84%, #333 50%, #333 100%); + border-radius: 0; + border: 1px solid #fff; +} + +.editor-toolbar .easymde-dropdown:hover { + background: linear-gradient(to bottom right, #fff 0%, #fff 84%, #333 50%, #333 100%); +} + +.easymde-dropdown-content { + display: block; + visibility: hidden; + position: absolute; + background-color: #f9f9f9; + box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2); + padding: 8px; + z-index: 2; + top: 30px; +} + +.easymde-dropdown:active .easymde-dropdown-content, +.easymde-dropdown:focus .easymde-dropdown-content { + visibility: visible; +} + +span[data-img-src]::after{ + content: ''; + background-image: var(--bg-image); + display: block; + max-height: 100%; + max-width: 100%; + background-size: contain; + height: 0; + padding-top: var(--height); + width: var(--width); + background-repeat: no-repeat; +} diff --git a/PSC.Blazor.Components.MarkdownEditor/wwwroot/easymde/src/css/easymde.min.css b/PSC.Blazor.Components.MarkdownEditor/wwwroot/easymde/src/css/easymde.min.css new file mode 100644 index 0000000..452d417 --- /dev/null +++ b/PSC.Blazor.Components.MarkdownEditor/wwwroot/easymde/src/css/easymde.min.css @@ -0,0 +1,8 @@ +/** + * Minified by jsDelivr using clean-css v4.2.3. + * Original file: /npm/easymde@2.15.0/src/css/easymde.css + * + * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files + */ +.EasyMDEContainer{display:block}.EasyMDEContainer.sided--no-fullscreen{display:flex;flex-direction:row;flex-wrap:wrap}.EasyMDEContainer .CodeMirror{box-sizing:border-box;height:auto;border:1px solid #ddd;border-bottom-left-radius:4px;border-bottom-right-radius:4px;padding:10px;font:inherit;z-index:0;word-wrap:break-word}.EasyMDEContainer .CodeMirror-scroll{cursor:text}.EasyMDEContainer .CodeMirror-fullscreen{background:#fff;position:fixed!important;top:50px;left:0;right:0;bottom:0;height:auto;z-index:8;border-right:none!important;border-bottom-right-radius:0!important}.EasyMDEContainer .CodeMirror-sided{width:50%!important}.EasyMDEContainer.sided--no-fullscreen .CodeMirror-sided{border-right:none!important;border-bottom-right-radius:0;position:relative;flex:1 1 auto}.EasyMDEContainer .CodeMirror-placeholder{opacity:.5}.EasyMDEContainer .CodeMirror-focused .CodeMirror-selected{background:#d9d9d9}.editor-toolbar{position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none;padding:9px 10px;border-top:1px solid #bbb;border-left:1px solid #bbb;border-right:1px solid #bbb;border-top-left-radius:4px;border-top-right-radius:4px}.editor-toolbar.fullscreen{width:100%;height:50px;padding-top:10px;padding-bottom:10px;box-sizing:border-box;background:#fff;border:0;position:fixed;top:0;left:0;opacity:1;z-index:9}.editor-toolbar.fullscreen::before{width:20px;height:50px;background:-moz-linear-gradient(left,#fff 0,rgba(255,255,255,0) 100%);background:-webkit-gradient(linear,left top,right top,color-stop(0,#fff),color-stop(100%,rgba(255,255,255,0)));background:-webkit-linear-gradient(left,#fff 0,rgba(255,255,255,0) 100%);background:-o-linear-gradient(left,#fff 0,rgba(255,255,255,0) 100%);background:-ms-linear-gradient(left,#fff 0,rgba(255,255,255,0) 100%);background:linear-gradient(to right,#fff 0,rgba(255,255,255,0) 100%);position:fixed;top:0;left:0;margin:0;padding:0}.editor-toolbar.fullscreen::after{width:20px;height:50px;background:-moz-linear-gradient(left,rgba(255,255,255,0) 0,#fff 100%);background:-webkit-gradient(linear,left top,right top,color-stop(0,rgba(255,255,255,0)),color-stop(100%,#fff));background:-webkit-linear-gradient(left,rgba(255,255,255,0) 0,#fff 100%);background:-o-linear-gradient(left,rgba(255,255,255,0) 0,#fff 100%);background:-ms-linear-gradient(left,rgba(255,255,255,0) 0,#fff 100%);background:linear-gradient(to right,rgba(255,255,255,0) 0,#fff 100%);position:fixed;top:0;right:0;margin:0;padding:0}.EasyMDEContainer.sided--no-fullscreen .editor-toolbar{width:100%}.editor-toolbar .easymde-dropdown,.editor-toolbar button{background:0 0;display:inline-block;text-align:center;text-decoration:none!important;height:30px;margin:0;padding:0;border:1px solid transparent;border-radius:3px;cursor:pointer}.editor-toolbar button{width:30px}.editor-toolbar button.active,.editor-toolbar button:hover{background:#fcfcfc;border-color:#95a5a6}.editor-toolbar i.separator{display:inline-block;width:0;border-left:1px solid #d9d9d9;border-right:1px solid #fff;color:transparent;text-indent:-10px;margin:0 6px}.editor-toolbar button:after{font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;font-size:65%;vertical-align:text-bottom;position:relative;top:2px}.editor-toolbar button.heading-1:after{content:"1"}.editor-toolbar button.heading-2:after{content:"2"}.editor-toolbar button.heading-3:after{content:"3"}.editor-toolbar button.heading-bigger:after{content:"▲"}.editor-toolbar button.heading-smaller:after{content:"▼"}.editor-toolbar.disabled-for-preview button:not(.no-disable){opacity:.6;pointer-events:none}@media only screen and (max-width:700px){.editor-toolbar i.no-mobile{display:none}}.editor-statusbar{padding:8px 10px;font-size:12px;color:#959694;text-align:right}.EasyMDEContainer.sided--no-fullscreen .editor-statusbar{width:100%}.editor-statusbar span{display:inline-block;min-width:4em;margin-left:1em}.editor-statusbar .lines:before{content:'lines: '}.editor-statusbar .words:before{content:'words: '}.editor-statusbar .characters:before{content:'characters: '}.editor-preview-full{position:absolute;width:100%;height:100%;top:0;left:0;z-index:7;overflow:auto;display:none;box-sizing:border-box}.editor-preview-side{position:fixed;bottom:0;width:50%;top:50px;right:0;z-index:9;overflow:auto;display:none;box-sizing:border-box;border:1px solid #ddd;word-wrap:break-word}.editor-preview-active-side{display:block}.EasyMDEContainer.sided--no-fullscreen .editor-preview-active-side{flex:1 1 auto;height:auto;position:static}.editor-preview-active{display:block}.editor-preview{padding:10px;background:#fafafa}.editor-preview>p{margin-top:0}.editor-preview pre{background:#eee;margin-bottom:10px}.editor-preview table td,.editor-preview table th{border:1px solid #ddd;padding:5px}.cm-s-easymde .cm-tag{color:#63a35c}.cm-s-easymde .cm-attribute{color:#795da3}.cm-s-easymde .cm-string{color:#183691}.cm-s-easymde .cm-header-1{font-size:200%;line-height:200%}.cm-s-easymde .cm-header-2{font-size:160%;line-height:160%}.cm-s-easymde .cm-header-3{font-size:125%;line-height:125%}.cm-s-easymde .cm-header-4{font-size:110%;line-height:110%}.cm-s-easymde .cm-comment{background:rgba(0,0,0,.05);border-radius:2px}.cm-s-easymde .cm-link{color:#7f8c8d}.cm-s-easymde .cm-url{color:#aab2b3}.cm-s-easymde .cm-quote{color:#7f8c8d;font-style:italic}.editor-toolbar .easymde-dropdown{position:relative;background:linear-gradient(to bottom right,#fff 0,#fff 84%,#333 50%,#333 100%);border-radius:0;border:1px solid #fff}.editor-toolbar .easymde-dropdown:hover{background:linear-gradient(to bottom right,#fff 0,#fff 84%,#333 50%,#333 100%)}.easymde-dropdown-content{display:block;visibility:hidden;position:absolute;background-color:#f9f9f9;box-shadow:0 8px 16px 0 rgba(0,0,0,.2);padding:8px;z-index:2;top:30px}.easymde-dropdown:active .easymde-dropdown-content,.easymde-dropdown:focus .easymde-dropdown-content{visibility:visible}span[data-img-src]::after{content:'';background-image:var(--bg-image);display:block;max-height:100%;max-width:100%;background-size:contain;height:0;padding-top:var(--height);width:var(--width);background-repeat:no-repeat} +/*# sourceMappingURL=/sm/0bff12e2dac1caf4299bcfbcb619982f507d29903047caee8bc7c975b9efccc5.map */ \ No newline at end of file diff --git a/PSC.Blazor.Components.MarkdownEditor/wwwroot/easymde/src/js/codemirror/tablist.js b/PSC.Blazor.Components.MarkdownEditor/wwwroot/easymde/src/js/codemirror/tablist.js new file mode 100644 index 0000000..0ec9c8d --- /dev/null +++ b/PSC.Blazor.Components.MarkdownEditor/wwwroot/easymde/src/js/codemirror/tablist.js @@ -0,0 +1,44 @@ +// CodeMirror, copyright (c) by Marijn Haverbeke and others +// Distributed under an MIT license: http://codemirror.net/LICENSE + +var CodeMirror = require('codemirror'); + +CodeMirror.commands.tabAndIndentMarkdownList = function (cm) { + var ranges = cm.listSelections(); + var pos = ranges[0].head; + var eolState = cm.getStateAfter(pos.line); + var inList = eolState.list !== false; + + if (inList) { + cm.execCommand('indentMore'); + return; + } + + if (cm.options.indentWithTabs) { + cm.execCommand('insertTab'); + } + else { + var spaces = Array(cm.options.tabSize + 1).join(' '); + cm.replaceSelection(spaces); + } +}; + +CodeMirror.commands.shiftTabAndUnindentMarkdownList = function (cm) { + var ranges = cm.listSelections(); + var pos = ranges[0].head; + var eolState = cm.getStateAfter(pos.line); + var inList = eolState.list !== false; + + if (inList) { + cm.execCommand('indentLess'); + return; + } + + if (cm.options.indentWithTabs) { + cm.execCommand('insertTab'); + } + else { + var spaces = Array(cm.options.tabSize + 1).join(' '); + cm.replaceSelection(spaces); + } +}; diff --git a/PSC.Blazor.Components.MarkdownEditor/wwwroot/easymde/src/js/codemirror/tablist.min.js b/PSC.Blazor.Components.MarkdownEditor/wwwroot/easymde/src/js/codemirror/tablist.min.js new file mode 100644 index 0000000..2deabdb --- /dev/null +++ b/PSC.Blazor.Components.MarkdownEditor/wwwroot/easymde/src/js/codemirror/tablist.min.js @@ -0,0 +1,8 @@ +/** + * Minified by jsDelivr using Terser v5.10.0. + * Original file: /npm/easymde@2.15.0/src/js/codemirror/tablist.js + * + * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files + */ +var CodeMirror=require("codemirror");CodeMirror.commands.tabAndIndentMarkdownList=function(e){var i=e.listSelections()[0].head;if(!1!==e.getStateAfter(i.line).list)e.execCommand("indentMore");else if(e.options.indentWithTabs)e.execCommand("insertTab");else{var n=Array(e.options.tabSize+1).join(" ");e.replaceSelection(n)}},CodeMirror.commands.shiftTabAndUnindentMarkdownList=function(e){var i=e.listSelections()[0].head;if(!1!==e.getStateAfter(i.line).list)e.execCommand("indentLess");else if(e.options.indentWithTabs)e.execCommand("insertTab");else{var n=Array(e.options.tabSize+1).join(" ");e.replaceSelection(n)}}; +//# sourceMappingURL=/sm/f6ac54b3965030b92f68bab8cdcff68beee26fb8d9e479675b0254f1e0679040.map \ No newline at end of file diff --git a/PSC.Blazor.Components.MarkdownEditor/wwwroot/easymde/src/js/easymde.js b/PSC.Blazor.Components.MarkdownEditor/wwwroot/easymde/src/js/easymde.js new file mode 100644 index 0000000..f7c1e46 --- /dev/null +++ b/PSC.Blazor.Components.MarkdownEditor/wwwroot/easymde/src/js/easymde.js @@ -0,0 +1,2917 @@ +'use strict'; +var CodeMirror = require('codemirror'); +require('codemirror/addon/edit/continuelist.js'); +require('./codemirror/tablist'); +require('codemirror/addon/display/fullscreen.js'); +require('codemirror/mode/markdown/markdown.js'); +require('codemirror/addon/mode/overlay.js'); +require('codemirror/addon/display/placeholder.js'); +require('codemirror/addon/display/autorefresh.js'); +require('codemirror/addon/selection/mark-selection.js'); +require('codemirror/addon/search/searchcursor.js'); +require('codemirror/mode/gfm/gfm.js'); +require('codemirror/mode/xml/xml.js'); +var CodeMirrorSpellChecker = require('codemirror-spell-checker'); +var marked = require('marked/lib/marked'); + + +// Some variables +var isMac = /Mac/.test(navigator.platform); +var anchorToExternalRegex = new RegExp(/()+?/g); + +// Mapping of actions that can be bound to keyboard shortcuts or toolbar buttons +var bindings = { + 'toggleBold': toggleBold, + 'toggleItalic': toggleItalic, + 'drawLink': drawLink, + 'toggleHeadingSmaller': toggleHeadingSmaller, + 'toggleHeadingBigger': toggleHeadingBigger, + 'drawImage': drawImage, + 'toggleBlockquote': toggleBlockquote, + 'toggleOrderedList': toggleOrderedList, + 'toggleUnorderedList': toggleUnorderedList, + 'toggleCodeBlock': toggleCodeBlock, + 'togglePreview': togglePreview, + 'toggleStrikethrough': toggleStrikethrough, + 'toggleHeading1': toggleHeading1, + 'toggleHeading2': toggleHeading2, + 'toggleHeading3': toggleHeading3, + 'cleanBlock': cleanBlock, + 'drawTable': drawTable, + 'drawHorizontalRule': drawHorizontalRule, + 'undo': undo, + 'redo': redo, + 'toggleSideBySide': toggleSideBySide, + 'toggleFullScreen': toggleFullScreen, +}; + +var shortcuts = { + 'toggleBold': 'Cmd-B', + 'toggleItalic': 'Cmd-I', + 'drawLink': 'Cmd-K', + 'toggleHeadingSmaller': 'Cmd-H', + 'toggleHeadingBigger': 'Shift-Cmd-H', + 'cleanBlock': 'Cmd-E', + 'drawImage': 'Cmd-Alt-I', + 'toggleBlockquote': 'Cmd-\'', + 'toggleOrderedList': 'Cmd-Alt-L', + 'toggleUnorderedList': 'Cmd-L', + 'toggleCodeBlock': 'Cmd-Alt-C', + 'togglePreview': 'Cmd-P', + 'toggleSideBySide': 'F9', + 'toggleFullScreen': 'F11', +}; + +var getBindingName = function (f) { + for (var key in bindings) { + if (bindings[key] === f) { + return key; + } + } + return null; +}; + +var isMobile = function () { + var check = false; + (function (a) { + if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(a.substr(0, 4))) check = true; + })(navigator.userAgent || navigator.vendor || window.opera); + return check; +}; + +/** + * Modify HTML to add 'target="_blank"' to links so they open in new tabs by default. + * @param {string} htmlText - HTML to be modified. + * @return {string} The modified HTML text. + */ +function addAnchorTargetBlank(htmlText) { + var match; + while ((match = anchorToExternalRegex.exec(htmlText)) !== null) { + // With only one capture group in the RegExp, we can safely take the first index from the match. + var linkString = match[0]; + + if (linkString.indexOf('target=') === -1) { + var fixedLinkString = linkString.replace(/>$/, ' target="_blank">'); + htmlText = htmlText.replace(linkString, fixedLinkString); + } + } + return htmlText; +} + +/** + * Modify HTML to remove the list-style when rendering checkboxes. + * @param {string} htmlText - HTML to be modified. + * @return {string} The modified HTML text. + */ +function removeListStyleWhenCheckbox(htmlText) { + + var parser = new DOMParser(); + var htmlDoc = parser.parseFromString(htmlText, 'text/html'); + var listItems = htmlDoc.getElementsByTagName('li'); + + for (var i = 0; i < listItems.length; i++) { + var listItem = listItems[i]; + + for (var j = 0; j < listItem.children.length; j++) { + var listItemChild = listItem.children[j]; + + if (listItemChild instanceof HTMLInputElement && listItemChild.type === 'checkbox') { + // From Github: margin: 0 .2em .25em -1.6em; + listItem.style.marginLeft = '-1.5em'; + listItem.style.listStyleType = 'none'; + } + } + } + + return htmlDoc.documentElement.innerHTML; +} + +/** + * Fix shortcut. Mac use Command, others use Ctrl. + */ +function fixShortcut(name) { + if (isMac) { + name = name.replace('Ctrl', 'Cmd'); + } else { + name = name.replace('Cmd', 'Ctrl'); + } + return name; +} + +/** + * Class handling utility methods. + */ +var CLASS_REGEX = {}; + +/** + * Convert a className string into a regex for matching (and cache). + * Note that the RegExp includes trailing spaces for replacement + * (to ensure that removing a class from the middle of the string will retain + * spacing between other classes.) + * @param {String} className Class name to convert to regex for matching. + * @returns {RegExp} Regular expression option that will match className. + */ +function getClassRegex (className) { + return CLASS_REGEX[className] || (CLASS_REGEX[className] = new RegExp('\\s*' + className + '(\\s*)', 'g')); +} + +/** + * Add a class string to an element. + * @param {Element} el DOM element on which to add className. + * @param {String} className Class string to apply + * @returns {void} + */ +function addClass (el, className) { + if (!el || !className) return; + var classRegex = getClassRegex(className); + if (el.className.match(classRegex)) return; // already applied + el.className += ' ' + className; +} + +/** + * Remove a class string from an element. + * @param {Element} el DOM element from which to remove className. + * @param {String} className Class string to remove + * @returns {void} + */ + function removeClass (el, className) { + if (!el || !className) return; + var classRegex = getClassRegex(className); + if (!el.className.match(classRegex)) return; // not available to remove + el.className = el.className.replace(classRegex, '$1'); +} + + +/** + * Create dropdown block + */ +function createToolbarDropdown(options, enableTooltips, shortcuts, parent) { + var el = createToolbarButton(options, false, enableTooltips, shortcuts, 'button', parent); + el.className += ' easymde-dropdown'; + var content = document.createElement('div'); + content.className = 'easymde-dropdown-content'; + for (var childrenIndex = 0; childrenIndex < options.children.length; childrenIndex++) { + + var child = options.children[childrenIndex]; + var childElement; + + if (typeof child === 'string' && child in toolbarBuiltInButtons) { + childElement = createToolbarButton(toolbarBuiltInButtons[child], true, enableTooltips, shortcuts, 'button', parent); + } else { + childElement = createToolbarButton(child, true, enableTooltips, shortcuts, 'button', parent); + } + + content.appendChild(childElement); + } + el.appendChild(content); + return el; +} + +/** + * Create button element for toolbar. + */ +function createToolbarButton(options, enableActions, enableTooltips, shortcuts, markup, parent) { + options = options || {}; + var el = document.createElement(markup); + el.className = options.name; + el.setAttribute('type', markup); + enableTooltips = (enableTooltips == undefined) ? true : enableTooltips; + + // Properly hande custom shortcuts + if (options.name && options.name in shortcuts) { + bindings[options.name] = options.action; + } + + if (options.title && enableTooltips) { + el.title = createTooltip(options.title, options.action, shortcuts); + + if (isMac) { + el.title = el.title.replace('Ctrl', '⌘'); + el.title = el.title.replace('Alt', '⌥'); + } + } + + if (options.noDisable) { + el.classList.add('no-disable'); + } + + if (options.noMobile) { + el.classList.add('no-mobile'); + } + + // Prevent errors if there is no class name in custom options + var classNameParts = []; + if(typeof options.className !== 'undefined') { + classNameParts = options.className.split(' '); + } + + // Provide backwards compatibility with simple-markdown-editor by adding custom classes to the button. + var iconClasses = []; + for (var classNameIndex = 0; classNameIndex < classNameParts.length; classNameIndex++) { + var classNamePart = classNameParts[classNameIndex]; + // Split icon classes from the button. + // Regex will detect "fa", "fas", "fa-something" and "fa-some-icon-1", but not "fanfare". + if (classNamePart.match(/^fa([srlb]|(-[\w-]*)|$)/)) { + iconClasses.push(classNamePart); + } else { + el.classList.add(classNamePart); + } + } + + el.tabIndex = -1; + + // Create icon element and append as a child to the button + var icon = document.createElement('i'); + for (var iconClassIndex = 0; iconClassIndex < iconClasses.length; iconClassIndex++) { + var iconClass = iconClasses[iconClassIndex]; + icon.classList.add(iconClass); + } + el.appendChild(icon); + + // If there is a custom icon markup set, use that + if (typeof options.icon !== 'undefined') { + el.innerHTML = options.icon; + } + + if (options.action && enableActions) { + if (typeof options.action === 'function') { + el.onclick = function (e) { + e.preventDefault(); + options.action(parent); + }; + } else if (typeof options.action === 'string') { + el.onclick = function (e) { + e.preventDefault(); + window.open(options.action, '_blank'); + }; + } + } + + return el; +} + +function createSep() { + var el = document.createElement('i'); + el.className = 'separator'; + el.innerHTML = '|'; + return el; +} + +function createTooltip(title, action, shortcuts) { + var actionName; + var tooltip = title; + + if (action) { + actionName = getBindingName(action); + if (shortcuts[actionName]) { + tooltip += ' (' + fixShortcut(shortcuts[actionName]) + ')'; + } + } + + return tooltip; +} + +/** + * The state of CodeMirror at the given position. + */ +function getState(cm, pos) { + pos = pos || cm.getCursor('start'); + var stat = cm.getTokenAt(pos); + if (!stat.type) return {}; + + var types = stat.type.split(' '); + + var ret = {}, + data, text; + for (var i = 0; i < types.length; i++) { + data = types[i]; + if (data === 'strong') { + ret.bold = true; + } else if (data === 'variable-2') { + text = cm.getLine(pos.line); + if (/^\s*\d+\.\s/.test(text)) { + ret['ordered-list'] = true; + } else { + ret['unordered-list'] = true; + } + } else if (data === 'atom') { + ret.quote = true; + } else if (data === 'em') { + ret.italic = true; + } else if (data === 'quote') { + ret.quote = true; + } else if (data === 'strikethrough') { + ret.strikethrough = true; + } else if (data === 'comment') { + ret.code = true; + } else if (data === 'link') { + ret.link = true; + } else if (data === 'tag') { + ret.image = true; + } else if (data.match(/^header(-[1-6])?$/)) { + ret[data.replace('header', 'heading')] = true; + } + } + return ret; +} + + +// Saved overflow setting +var saved_overflow = ''; + +/** + * Toggle full screen of the editor. + */ +function toggleFullScreen(editor) { + // Set fullscreen + var cm = editor.codemirror; + cm.setOption('fullScreen', !cm.getOption('fullScreen')); + + + // Prevent scrolling on body during fullscreen active + if (cm.getOption('fullScreen')) { + saved_overflow = document.body.style.overflow; + document.body.style.overflow = 'hidden'; + } else { + document.body.style.overflow = saved_overflow; + } + + var wrapper = cm.getWrapperElement(); + var sidebyside = wrapper.nextSibling; + + if (/editor-preview-active-side/.test(sidebyside.className)) { + if (editor.options.sideBySideFullscreen === false) { + // if side-by-side not-fullscreen ok, apply classes as needed + var easyMDEContainer = wrapper.parentNode; + if (cm.getOption('fullScreen')) { + removeClass(easyMDEContainer, 'sided--no-fullscreen'); + } else { + addClass(easyMDEContainer, 'sided--no-fullscreen'); + } + } else { + toggleSideBySide(editor); + } + } + + if (editor.options.onToggleFullScreen) { + editor.options.onToggleFullScreen(cm.getOption('fullScreen') || false); + } + + // Remove or set maxHeight + if (typeof editor.options.maxHeight !== 'undefined') { + if (cm.getOption('fullScreen')) { + cm.getScrollerElement().style.removeProperty('height'); + sidebyside.style.removeProperty('height'); + } else { + cm.getScrollerElement().style.height = editor.options.maxHeight; + editor.setPreviewMaxHeight(); + } + } + + + // Update toolbar class + if (!/fullscreen/.test(editor.toolbar_div.className)) { + editor.toolbar_div.className += ' fullscreen'; + } else { + editor.toolbar_div.className = editor.toolbar_div.className.replace(/\s*fullscreen\b/, ''); + } + + + // Update toolbar button + if (editor.toolbarElements && editor.toolbarElements.fullscreen) { + var toolbarButton = editor.toolbarElements.fullscreen; + + if (!/active/.test(toolbarButton.className)) { + toolbarButton.className += ' active'; + } else { + toolbarButton.className = toolbarButton.className.replace(/\s*active\s*/g, ''); + } + } +} + + +/** + * Action for toggling bold. + */ +function toggleBold(editor) { + _toggleBlock(editor, 'bold', editor.options.blockStyles.bold); +} + + +/** + * Action for toggling italic. + */ +function toggleItalic(editor) { + _toggleBlock(editor, 'italic', editor.options.blockStyles.italic); +} + + +/** + * Action for toggling strikethrough. + */ +function toggleStrikethrough(editor) { + _toggleBlock(editor, 'strikethrough', '~~'); +} + +/** + * Action for toggling code block. + */ +function toggleCodeBlock(editor) { + var fenceCharsToInsert = editor.options.blockStyles.code; + + function fencing_line(line) { + /* return true, if this is a ``` or ~~~ line */ + if (typeof line !== 'object') { + throw 'fencing_line() takes a \'line\' object (not a line number, or line text). Got: ' + typeof line + ': ' + line; + } + return line.styles && line.styles[2] && line.styles[2].indexOf('formatting-code-block') !== -1; + } + + function token_state(token) { + // base goes an extra level deep when mode backdrops are used, e.g. spellchecker on + return token.state.base.base || token.state.base; + } + + function code_type(cm, line_num, line, firstTok, lastTok) { + /* + * Return "single", "indented", "fenced" or false + * + * cm and line_num are required. Others are optional for efficiency + * To check in the middle of a line, pass in firstTok yourself. + */ + line = line || cm.getLineHandle(line_num); + firstTok = firstTok || cm.getTokenAt({ + line: line_num, + ch: 1, + }); + lastTok = lastTok || (!!line.text && cm.getTokenAt({ + line: line_num, + ch: line.text.length - 1, + })); + var types = firstTok.type ? firstTok.type.split(' ') : []; + if (lastTok && token_state(lastTok).indentedCode) { + // have to check last char, since first chars of first line aren"t marked as indented + return 'indented'; + } else if (types.indexOf('comment') === -1) { + // has to be after "indented" check, since first chars of first indented line aren"t marked as such + return false; + } else if (token_state(firstTok).fencedChars || token_state(lastTok).fencedChars || fencing_line(line)) { + return 'fenced'; + } else { + return 'single'; + } + } + + function insertFencingAtSelection(cm, cur_start, cur_end, fenceCharsToInsert) { + var start_line_sel = cur_start.line + 1, + end_line_sel = cur_end.line + 1, + sel_multi = cur_start.line !== cur_end.line, + repl_start = fenceCharsToInsert + '\n', + repl_end = '\n' + fenceCharsToInsert; + if (sel_multi) { + end_line_sel++; + } + // handle last char including \n or not + if (sel_multi && cur_end.ch === 0) { + repl_end = fenceCharsToInsert + '\n'; + end_line_sel--; + } + _replaceSelection(cm, false, [repl_start, repl_end]); + cm.setSelection({ + line: start_line_sel, + ch: 0, + }, { + line: end_line_sel, + ch: 0, + }); + } + + var cm = editor.codemirror, + cur_start = cm.getCursor('start'), + cur_end = cm.getCursor('end'), + tok = cm.getTokenAt({ + line: cur_start.line, + ch: cur_start.ch || 1, + }), // avoid ch 0 which is a cursor pos but not token + line = cm.getLineHandle(cur_start.line), + is_code = code_type(cm, cur_start.line, line, tok); + var block_start, block_end, lineCount; + + if (is_code === 'single') { + // similar to some EasyMDE _toggleBlock logic + var start = line.text.slice(0, cur_start.ch).replace('`', ''), + end = line.text.slice(cur_start.ch).replace('`', ''); + cm.replaceRange(start + end, { + line: cur_start.line, + ch: 0, + }, { + line: cur_start.line, + ch: 99999999999999, + }); + cur_start.ch--; + if (cur_start !== cur_end) { + cur_end.ch--; + } + cm.setSelection(cur_start, cur_end); + cm.focus(); + } else if (is_code === 'fenced') { + if (cur_start.line !== cur_end.line || cur_start.ch !== cur_end.ch) { + // use selection + + // find the fenced line so we know what type it is (tilde, backticks, number of them) + for (block_start = cur_start.line; block_start >= 0; block_start--) { + line = cm.getLineHandle(block_start); + if (fencing_line(line)) { + break; + } + } + var fencedTok = cm.getTokenAt({ + line: block_start, + ch: 1, + }); + var fence_chars = token_state(fencedTok).fencedChars; + var start_text, start_line; + var end_text, end_line; + // check for selection going up against fenced lines, in which case we don't want to add more fencing + if (fencing_line(cm.getLineHandle(cur_start.line))) { + start_text = ''; + start_line = cur_start.line; + } else if (fencing_line(cm.getLineHandle(cur_start.line - 1))) { + start_text = ''; + start_line = cur_start.line - 1; + } else { + start_text = fence_chars + '\n'; + start_line = cur_start.line; + } + if (fencing_line(cm.getLineHandle(cur_end.line))) { + end_text = ''; + end_line = cur_end.line; + if (cur_end.ch === 0) { + end_line += 1; + } + } else if (cur_end.ch !== 0 && fencing_line(cm.getLineHandle(cur_end.line + 1))) { + end_text = ''; + end_line = cur_end.line + 1; + } else { + end_text = fence_chars + '\n'; + end_line = cur_end.line + 1; + } + if (cur_end.ch === 0) { + // full last line selected, putting cursor at beginning of next + end_line -= 1; + } + cm.operation(function () { + // end line first, so that line numbers don't change + cm.replaceRange(end_text, { + line: end_line, + ch: 0, + }, { + line: end_line + (end_text ? 0 : 1), + ch: 0, + }); + cm.replaceRange(start_text, { + line: start_line, + ch: 0, + }, { + line: start_line + (start_text ? 0 : 1), + ch: 0, + }); + }); + cm.setSelection({ + line: start_line + (start_text ? 1 : 0), + ch: 0, + }, { + line: end_line + (start_text ? 1 : -1), + ch: 0, + }); + cm.focus(); + } else { + // no selection, search for ends of this fenced block + var search_from = cur_start.line; + if (fencing_line(cm.getLineHandle(cur_start.line))) { // gets a little tricky if cursor is right on a fenced line + if (code_type(cm, cur_start.line + 1) === 'fenced') { + block_start = cur_start.line; + search_from = cur_start.line + 1; // for searching for "end" + } else { + block_end = cur_start.line; + search_from = cur_start.line - 1; // for searching for "start" + } + } + if (block_start === undefined) { + for (block_start = search_from; block_start >= 0; block_start--) { + line = cm.getLineHandle(block_start); + if (fencing_line(line)) { + break; + } + } + } + if (block_end === undefined) { + lineCount = cm.lineCount(); + for (block_end = search_from; block_end < lineCount; block_end++) { + line = cm.getLineHandle(block_end); + if (fencing_line(line)) { + break; + } + } + } + cm.operation(function () { + cm.replaceRange('', { + line: block_start, + ch: 0, + }, { + line: block_start + 1, + ch: 0, + }); + cm.replaceRange('', { + line: block_end - 1, + ch: 0, + }, { + line: block_end, + ch: 0, + }); + }); + cm.focus(); + } + } else if (is_code === 'indented') { + if (cur_start.line !== cur_end.line || cur_start.ch !== cur_end.ch) { + // use selection + block_start = cur_start.line; + block_end = cur_end.line; + if (cur_end.ch === 0) { + block_end--; + } + } else { + // no selection, search for ends of this indented block + for (block_start = cur_start.line; block_start >= 0; block_start--) { + line = cm.getLineHandle(block_start); + if (line.text.match(/^\s*$/)) { + // empty or all whitespace - keep going + continue; + } else { + if (code_type(cm, block_start, line) !== 'indented') { + block_start += 1; + break; + } + } + } + lineCount = cm.lineCount(); + for (block_end = cur_start.line; block_end < lineCount; block_end++) { + line = cm.getLineHandle(block_end); + if (line.text.match(/^\s*$/)) { + // empty or all whitespace - keep going + continue; + } else { + if (code_type(cm, block_end, line) !== 'indented') { + block_end -= 1; + break; + } + } + } + } + // if we are going to un-indent based on a selected set of lines, and the next line is indented too, we need to + // insert a blank line so that the next line(s) continue to be indented code + var next_line = cm.getLineHandle(block_end + 1), + next_line_last_tok = next_line && cm.getTokenAt({ + line: block_end + 1, + ch: next_line.text.length - 1, + }), + next_line_indented = next_line_last_tok && token_state(next_line_last_tok).indentedCode; + if (next_line_indented) { + cm.replaceRange('\n', { + line: block_end + 1, + ch: 0, + }); + } + + for (var i = block_start; i <= block_end; i++) { + cm.indentLine(i, 'subtract'); // TODO: this doesn't get tracked in the history, so can't be undone :( + } + cm.focus(); + } else { + // insert code formatting + var no_sel_and_starting_of_line = (cur_start.line === cur_end.line && cur_start.ch === cur_end.ch && cur_start.ch === 0); + var sel_multi = cur_start.line !== cur_end.line; + if (no_sel_and_starting_of_line || sel_multi) { + insertFencingAtSelection(cm, cur_start, cur_end, fenceCharsToInsert); + } else { + _replaceSelection(cm, false, ['`', '`']); + } + } +} + +/** + * Action for toggling blockquote. + */ +function toggleBlockquote(editor) { + var cm = editor.codemirror; + _toggleLine(cm, 'quote'); +} + +/** + * Action for toggling heading size: normal -> h1 -> h2 -> h3 -> h4 -> h5 -> h6 -> normal + */ +function toggleHeadingSmaller(editor) { + var cm = editor.codemirror; + _toggleHeading(cm, 'smaller'); +} + +/** + * Action for toggling heading size: normal -> h6 -> h5 -> h4 -> h3 -> h2 -> h1 -> normal + */ +function toggleHeadingBigger(editor) { + var cm = editor.codemirror; + _toggleHeading(cm, 'bigger'); +} + +/** + * Action for toggling heading size 1 + */ +function toggleHeading1(editor) { + var cm = editor.codemirror; + _toggleHeading(cm, undefined, 1); +} + +/** + * Action for toggling heading size 2 + */ +function toggleHeading2(editor) { + var cm = editor.codemirror; + _toggleHeading(cm, undefined, 2); +} + +/** + * Action for toggling heading size 3 + */ +function toggleHeading3(editor) { + var cm = editor.codemirror; + _toggleHeading(cm, undefined, 3); +} + + +/** + * Action for toggling ul. + */ +function toggleUnorderedList(editor) { + var cm = editor.codemirror; + _toggleLine(cm, 'unordered-list'); +} + + +/** + * Action for toggling ol. + */ +function toggleOrderedList(editor) { + var cm = editor.codemirror; + _toggleLine(cm, 'ordered-list'); +} + +/** + * Action for clean block (remove headline, list, blockquote code, markers) + */ +function cleanBlock(editor) { + var cm = editor.codemirror; + _cleanBlock(cm); +} + +/** + * Action for drawing a link. + */ +function drawLink(editor) { + var cm = editor.codemirror; + var stat = getState(cm); + var options = editor.options; + var url = 'https://'; + if (options.promptURLs) { + url = prompt(options.promptTexts.link, 'https://'); + if (!url) { + return false; + } + } + _replaceSelection(cm, stat.link, options.insertTexts.link, url); +} + +/** + * Action for drawing an img. + */ +function drawImage(editor) { + var cm = editor.codemirror; + var stat = getState(cm); + var options = editor.options; + var url = 'https://'; + if (options.promptURLs) { + url = prompt(options.promptTexts.image, 'https://'); + if (!url) { + return false; + } + } + _replaceSelection(cm, stat.image, options.insertTexts.image, url); +} + +/** + * Action for opening the browse-file window to upload an image to a server. + * @param editor {EasyMDE} The EasyMDE object + */ +function drawUploadedImage(editor) { + // TODO: Draw the image template with a fake url? ie: '![](importing foo.png...)' + editor.openBrowseFileWindow(); +} + +/** + * Action executed after an image have been successfully imported on the server. + * @param editor {EasyMDE} The EasyMDE object + * @param url {string} The url of the uploaded image + */ +function afterImageUploaded(editor, url) { + var cm = editor.codemirror; + var stat = getState(cm); + var options = editor.options; + var imageName = url.substr(url.lastIndexOf('/') + 1); + var ext = imageName.substring(imageName.lastIndexOf('.') + 1).replace(/\?.*$/, ''); + + // Check if media is an image + if (['png', 'jpg', 'jpeg', 'gif', 'svg'].includes(ext)) { + _replaceSelection(cm, stat.image, options.insertTexts.uploadedImage, url); + } else { + var text_link = options.insertTexts.link; + text_link[0] = '[' + imageName; + _replaceSelection(cm, stat.link, text_link, url); + } + + // show uploaded image filename for 1000ms + editor.updateStatusBar('upload-image', editor.options.imageTexts.sbOnUploaded.replace('#image_name#', imageName)); + setTimeout(function () { + editor.updateStatusBar('upload-image', editor.options.imageTexts.sbInit); + }, 1000); +} + +/** + * Action for drawing a table. + */ +function drawTable(editor) { + var cm = editor.codemirror; + var stat = getState(cm); + var options = editor.options; + _replaceSelection(cm, stat.table, options.insertTexts.table); +} + +/** + * Action for drawing a horizontal rule. + */ +function drawHorizontalRule(editor) { + var cm = editor.codemirror; + var stat = getState(cm); + var options = editor.options; + _replaceSelection(cm, stat.image, options.insertTexts.horizontalRule); +} + + +/** + * Undo action. + */ +function undo(editor) { + var cm = editor.codemirror; + cm.undo(); + cm.focus(); +} + + +/** + * Redo action. + */ +function redo(editor) { + var cm = editor.codemirror; + cm.redo(); + cm.focus(); +} + + +/** + * Toggle side by side preview + */ +function toggleSideBySide(editor) { + var cm = editor.codemirror; + var wrapper = cm.getWrapperElement(); + var preview = wrapper.nextSibling; + var toolbarButton = editor.toolbarElements && editor.toolbarElements['side-by-side']; + var useSideBySideListener = false; + + var easyMDEContainer = wrapper.parentNode; + + if (/editor-preview-active-side/.test(preview.className)) { + if (editor.options.sideBySideFullscreen === false) { + // if side-by-side not-fullscreen ok, remove classes when hiding side + removeClass(easyMDEContainer, 'sided--no-fullscreen'); + } + preview.className = preview.className.replace( + /\s*editor-preview-active-side\s*/g, '' + ); + if (toolbarButton) toolbarButton.className = toolbarButton.className.replace(/\s*active\s*/g, ''); + wrapper.className = wrapper.className.replace(/\s*CodeMirror-sided\s*/g, ' '); + } else { + // When the preview button is clicked for the first time, + // give some time for the transition from editor.css to fire and the view to slide from right to left, + // instead of just appearing. + setTimeout(function () { + if (!cm.getOption('fullScreen')) { + if (editor.options.sideBySideFullscreen === false) { + // if side-by-side not-fullscreen ok, add classes when not fullscreen and showing side + addClass(easyMDEContainer, 'sided--no-fullscreen'); + } else { + toggleFullScreen(editor); + } + } + preview.className += ' editor-preview-active-side'; + }, 1); + if (toolbarButton) toolbarButton.className += ' active'; + wrapper.className += ' CodeMirror-sided'; + useSideBySideListener = true; + } + + // Hide normal preview if active + var previewNormal = wrapper.lastChild; + if (/editor-preview-active/.test(previewNormal.className)) { + previewNormal.className = previewNormal.className.replace( + /\s*editor-preview-active\s*/g, '' + ); + var toolbar = editor.toolbarElements.preview; + var toolbar_div = editor.toolbar_div; + toolbar.className = toolbar.className.replace(/\s*active\s*/g, ''); + toolbar_div.className = toolbar_div.className.replace(/\s*disabled-for-preview*/g, ''); + } + + var sideBySideRenderingFunction = function () { + var newValue = editor.options.previewRender(editor.value(), preview); + if (newValue != null) { + preview.innerHTML = newValue; + } + }; + + if (!cm.sideBySideRenderingFunction) { + cm.sideBySideRenderingFunction = sideBySideRenderingFunction; + } + + if (useSideBySideListener) { + var newValue = editor.options.previewRender(editor.value(), preview); + if (newValue != null) { + preview.innerHTML = newValue; + } + cm.on('update', cm.sideBySideRenderingFunction); + } else { + cm.off('update', cm.sideBySideRenderingFunction); + } + + // Refresh to fix selection being off (#309) + cm.refresh(); +} + + +/** + * Preview action. + */ +function togglePreview(editor) { + var cm = editor.codemirror; + var wrapper = cm.getWrapperElement(); + var toolbar_div = editor.toolbar_div; + var toolbar = editor.options.toolbar ? editor.toolbarElements.preview : false; + var preview = wrapper.lastChild; + + // Turn off side by side if needed + var sidebyside = cm.getWrapperElement().nextSibling; + if (/editor-preview-active-side/.test(sidebyside.className)) + toggleSideBySide(editor); + + if (!preview || !/editor-preview-full/.test(preview.className)) { + + preview = document.createElement('div'); + preview.className = 'editor-preview-full'; + + if (editor.options.previewClass) { + + if (Array.isArray(editor.options.previewClass)) { + for (var i = 0; i < editor.options.previewClass.length; i++) { + preview.className += (' ' + editor.options.previewClass[i]); + } + + } else if (typeof editor.options.previewClass === 'string') { + preview.className += (' ' + editor.options.previewClass); + } + } + + wrapper.appendChild(preview); + } + + if (/editor-preview-active/.test(preview.className)) { + preview.className = preview.className.replace( + /\s*editor-preview-active\s*/g, '' + ); + if (toolbar) { + toolbar.className = toolbar.className.replace(/\s*active\s*/g, ''); + toolbar_div.className = toolbar_div.className.replace(/\s*disabled-for-preview*/g, ''); + } + } else { + // When the preview button is clicked for the first time, + // give some time for the transition from editor.css to fire and the view to slide from right to left, + // instead of just appearing. + setTimeout(function () { + preview.className += ' editor-preview-active'; + }, 1); + if (toolbar) { + toolbar.className += ' active'; + toolbar_div.className += ' disabled-for-preview'; + } + } + preview.innerHTML = editor.options.previewRender(editor.value(), preview); + +} + +function _replaceSelection(cm, active, startEnd, url) { + if (/editor-preview-active/.test(cm.getWrapperElement().lastChild.className)) + return; + + var text; + var start = startEnd[0]; + var end = startEnd[1]; + var startPoint = {}, + endPoint = {}; + Object.assign(startPoint, cm.getCursor('start')); + Object.assign(endPoint, cm.getCursor('end')); + if (url) { + start = start.replace('#url#', url); // url is in start for upload-image + end = end.replace('#url#', url); + } + if (active) { + text = cm.getLine(startPoint.line); + start = text.slice(0, startPoint.ch); + end = text.slice(startPoint.ch); + cm.replaceRange(start + end, { + line: startPoint.line, + ch: 0, + }); + } else { + text = cm.getSelection(); + cm.replaceSelection(start + text + end); + + startPoint.ch += start.length; + if (startPoint !== endPoint) { + endPoint.ch += start.length; + } + } + cm.setSelection(startPoint, endPoint); + cm.focus(); +} + + +function _toggleHeading(cm, direction, size) { + if (/editor-preview-active/.test(cm.getWrapperElement().lastChild.className)) + return; + + var startPoint = cm.getCursor('start'); + var endPoint = cm.getCursor('end'); + for (var i = startPoint.line; i <= endPoint.line; i++) { + (function (i) { + var text = cm.getLine(i); + var currHeadingLevel = text.search(/[^#]/); + + if (direction !== undefined) { + if (currHeadingLevel <= 0) { + if (direction == 'bigger') { + text = '###### ' + text; + } else { + text = '# ' + text; + } + } else if (currHeadingLevel == 6 && direction == 'smaller') { + text = text.substr(7); + } else if (currHeadingLevel == 1 && direction == 'bigger') { + text = text.substr(2); + } else { + if (direction == 'bigger') { + text = text.substr(1); + } else { + text = '#' + text; + } + } + } else { + if (size == 1) { + if (currHeadingLevel <= 0) { + text = '# ' + text; + } else if (currHeadingLevel == size) { + text = text.substr(currHeadingLevel + 1); + } else { + text = '# ' + text.substr(currHeadingLevel + 1); + } + } else if (size == 2) { + if (currHeadingLevel <= 0) { + text = '## ' + text; + } else if (currHeadingLevel == size) { + text = text.substr(currHeadingLevel + 1); + } else { + text = '## ' + text.substr(currHeadingLevel + 1); + } + } else { + if (currHeadingLevel <= 0) { + text = '### ' + text; + } else if (currHeadingLevel == size) { + text = text.substr(currHeadingLevel + 1); + } else { + text = '### ' + text.substr(currHeadingLevel + 1); + } + } + } + + cm.replaceRange(text, { + line: i, + ch: 0, + }, { + line: i, + ch: 99999999999999, + }); + })(i); + } + cm.focus(); +} + + +function _toggleLine(cm, name) { + if (/editor-preview-active/.test(cm.getWrapperElement().lastChild.className)) + return; + + var listRegexp = /^(\s*)(\*|-|\+|\d*\.)(\s+)/; + var whitespacesRegexp = /^\s*/; + + var stat = getState(cm); + var startPoint = cm.getCursor('start'); + var endPoint = cm.getCursor('end'); + var repl = { + 'quote': /^(\s*)>\s+/, + 'unordered-list': listRegexp, + 'ordered-list': listRegexp, + }; + + var _getChar = function (name, i) { + var map = { + 'quote': '>', + 'unordered-list': '*', + 'ordered-list': '%%i.', + }; + + return map[name].replace('%%i', i); + }; + + var _checkChar = function (name, char) { + var map = { + 'quote': '>', + 'unordered-list': '*', + 'ordered-list': '\\d+.', + }; + var rt = new RegExp(map[name]); + + return char && rt.test(char); + }; + + var _toggle = function (name, text, untoggleOnly) { + var arr = listRegexp.exec(text); + var char = _getChar(name, line); + if (arr !== null) { + if (_checkChar(name, arr[2])) { + char = ''; + } + text = arr[1] + char + arr[3] + text.replace(whitespacesRegexp, '').replace(repl[name], '$1'); + } else if (untoggleOnly == false) { + text = char + ' ' + text; + } + return text; + }; + + var line = 1; + for (var i = startPoint.line; i <= endPoint.line; i++) { + (function (i) { + var text = cm.getLine(i); + if (stat[name]) { + text = text.replace(repl[name], '$1'); + } else { + // If we're toggling unordered-list formatting, check if the current line + // is part of an ordered-list, and if so, untoggle that first. + // Workaround for https://github.com/Ionaru/easy-markdown-editor/issues/92 + if (name == 'unordered-list') { + text = _toggle('ordered-list', text, true); + } + text = _toggle(name, text, false); + line += 1; + } + cm.replaceRange(text, { + line: i, + ch: 0, + }, { + line: i, + ch: 99999999999999, + }); + })(i); + } + cm.focus(); +} + +function _toggleBlock(editor, type, start_chars, end_chars) { + if (/editor-preview-active/.test(editor.codemirror.getWrapperElement().lastChild.className)) + return; + + end_chars = (typeof end_chars === 'undefined') ? start_chars : end_chars; + var cm = editor.codemirror; + var stat = getState(cm); + + var text; + var start = start_chars; + var end = end_chars; + + var startPoint = cm.getCursor('start'); + var endPoint = cm.getCursor('end'); + + if (stat[type]) { + text = cm.getLine(startPoint.line); + start = text.slice(0, startPoint.ch); + end = text.slice(startPoint.ch); + if (type == 'bold') { + start = start.replace(/(\*\*|__)(?![\s\S]*(\*\*|__))/, ''); + end = end.replace(/(\*\*|__)/, ''); + } else if (type == 'italic') { + start = start.replace(/(\*|_)(?![\s\S]*(\*|_))/, ''); + end = end.replace(/(\*|_)/, ''); + } else if (type == 'strikethrough') { + start = start.replace(/(\*\*|~~)(?![\s\S]*(\*\*|~~))/, ''); + end = end.replace(/(\*\*|~~)/, ''); + } + cm.replaceRange(start + end, { + line: startPoint.line, + ch: 0, + }, { + line: startPoint.line, + ch: 99999999999999, + }); + + if (type == 'bold' || type == 'strikethrough') { + startPoint.ch -= 2; + if (startPoint !== endPoint) { + endPoint.ch -= 2; + } + } else if (type == 'italic') { + startPoint.ch -= 1; + if (startPoint !== endPoint) { + endPoint.ch -= 1; + } + } + } else { + text = cm.getSelection(); + if (type == 'bold') { + text = text.split('**').join(''); + text = text.split('__').join(''); + } else if (type == 'italic') { + text = text.split('*').join(''); + text = text.split('_').join(''); + } else if (type == 'strikethrough') { + text = text.split('~~').join(''); + } + cm.replaceSelection(start + text + end); + + startPoint.ch += start_chars.length; + endPoint.ch = startPoint.ch + text.length; + } + + cm.setSelection(startPoint, endPoint); + cm.focus(); +} + +function _cleanBlock(cm) { + if (/editor-preview-active/.test(cm.getWrapperElement().lastChild.className)) + return; + + var startPoint = cm.getCursor('start'); + var endPoint = cm.getCursor('end'); + var text; + + for (var line = startPoint.line; line <= endPoint.line; line++) { + text = cm.getLine(line); + text = text.replace(/^[ ]*([# ]+|\*|-|[> ]+|[0-9]+(.|\)))[ ]*/, ''); + + cm.replaceRange(text, { + line: line, + ch: 0, + }, { + line: line, + ch: 99999999999999, + }); + } +} + +/** + * Convert a number of bytes to a human-readable file size. If you desire + * to add a space between the value and the unit, you need to add this space + * to the given units. + * @param bytes {integer} A number of bytes, as integer. Ex: 421137 + * @param units {number[]} An array of human-readable units, ie. [' B', ' K', ' MB'] + * @returns string A human-readable file size. Ex: '412 KB' + */ +function humanFileSize(bytes, units) { + if (Math.abs(bytes) < 1024) { + return '' + bytes + units[0]; + } + var u = 0; + do { + bytes /= 1024; + ++u; + } while (Math.abs(bytes) >= 1024 && u < units.length); + return '' + bytes.toFixed(1) + units[u]; +} + +// Merge the properties of one object into another. +function _mergeProperties(target, source) { + for (var property in source) { + if (Object.prototype.hasOwnProperty.call(source, property)) { + if (source[property] instanceof Array) { + target[property] = source[property].concat(target[property] instanceof Array ? target[property] : []); + } else if ( + source[property] !== null && + typeof source[property] === 'object' && + source[property].constructor === Object + ) { + target[property] = _mergeProperties(target[property] || {}, source[property]); + } else { + target[property] = source[property]; + } + } + } + + return target; +} + +// Merge an arbitrary number of objects into one. +function extend(target) { + for (var i = 1; i < arguments.length; i++) { + target = _mergeProperties(target, arguments[i]); + } + + return target; +} + +/* The right word count in respect for CJK. */ +function wordCount(data) { + var pattern = /[a-zA-Z0-9_\u00A0-\u02AF\u0392-\u03c9\u0410-\u04F9]+|[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af]+/g; + var m = data.match(pattern); + var count = 0; + if (m === null) return count; + for (var i = 0; i < m.length; i++) { + if (m[i].charCodeAt(0) >= 0x4E00) { + count += m[i].length; + } else { + count += 1; + } + } + return count; +} + +var toolbarBuiltInButtons = { + 'bold': { + name: 'bold', + action: toggleBold, + className: 'fa fa-bold', + title: 'Bold', + default: true, + }, + 'italic': { + name: 'italic', + action: toggleItalic, + className: 'fa fa-italic', + title: 'Italic', + default: true, + }, + 'strikethrough': { + name: 'strikethrough', + action: toggleStrikethrough, + className: 'fa fa-strikethrough', + title: 'Strikethrough', + }, + 'heading': { + name: 'heading', + action: toggleHeadingSmaller, + className: 'fa fa-header fa-heading', + title: 'Heading', + default: true, + }, + 'heading-smaller': { + name: 'heading-smaller', + action: toggleHeadingSmaller, + className: 'fa fa-header fa-heading header-smaller', + title: 'Smaller Heading', + }, + 'heading-bigger': { + name: 'heading-bigger', + action: toggleHeadingBigger, + className: 'fa fa-header fa-heading header-bigger', + title: 'Bigger Heading', + }, + 'heading-1': { + name: 'heading-1', + action: toggleHeading1, + className: 'fa fa-header fa-heading header-1', + title: 'Big Heading', + }, + 'heading-2': { + name: 'heading-2', + action: toggleHeading2, + className: 'fa fa-header fa-heading header-2', + title: 'Medium Heading', + }, + 'heading-3': { + name: 'heading-3', + action: toggleHeading3, + className: 'fa fa-header fa-heading header-3', + title: 'Small Heading', + }, + 'separator-1': { + name: 'separator-1', + }, + 'code': { + name: 'code', + action: toggleCodeBlock, + className: 'fa fa-code', + title: 'Code', + }, + 'quote': { + name: 'quote', + action: toggleBlockquote, + className: 'fa fa-quote-left', + title: 'Quote', + default: true, + }, + 'unordered-list': { + name: 'unordered-list', + action: toggleUnorderedList, + className: 'fa fa-list-ul', + title: 'Generic List', + default: true, + }, + 'ordered-list': { + name: 'ordered-list', + action: toggleOrderedList, + className: 'fa fa-list-ol', + title: 'Numbered List', + default: true, + }, + 'clean-block': { + name: 'clean-block', + action: cleanBlock, + className: 'fa fa-eraser', + title: 'Clean block', + }, + 'separator-2': { + name: 'separator-2', + }, + 'link': { + name: 'link', + action: drawLink, + className: 'fa fa-link', + title: 'Create Link', + default: true, + }, + 'image': { + name: 'image', + action: drawImage, + className: 'fa fa-image', + title: 'Insert Image', + default: true, + }, + 'upload-image': { + name: 'upload-image', + action: drawUploadedImage, + className: 'fa fa-image', + title: 'Import an image', + }, + 'table': { + name: 'table', + action: drawTable, + className: 'fa fa-table', + title: 'Insert Table', + }, + 'horizontal-rule': { + name: 'horizontal-rule', + action: drawHorizontalRule, + className: 'fa fa-minus', + title: 'Insert Horizontal Line', + }, + 'separator-3': { + name: 'separator-3', + }, + 'preview': { + name: 'preview', + action: togglePreview, + className: 'fa fa-eye', + noDisable: true, + title: 'Toggle Preview', + default: true, + }, + 'side-by-side': { + name: 'side-by-side', + action: toggleSideBySide, + className: 'fa fa-columns', + noDisable: true, + noMobile: true, + title: 'Toggle Side by Side', + default: true, + }, + 'fullscreen': { + name: 'fullscreen', + action: toggleFullScreen, + className: 'fa fa-arrows-alt', + noDisable: true, + noMobile: true, + title: 'Toggle Fullscreen', + default: true, + }, + 'separator-4': { + name: 'separator-4', + }, + 'guide': { + name: 'guide', + action: 'https://www.markdownguide.org/basic-syntax/', + className: 'fa fa-question-circle', + noDisable: true, + title: 'Markdown Guide', + default: true, + }, + 'separator-5': { + name: 'separator-5', + }, + 'undo': { + name: 'undo', + action: undo, + className: 'fa fa-undo', + noDisable: true, + title: 'Undo', + }, + 'redo': { + name: 'redo', + action: redo, + className: 'fa fa-repeat fa-redo', + noDisable: true, + title: 'Redo', + }, +}; + +var insertTexts = { + link: ['[', '](#url#)'], + image: ['![](', '#url#)'], + uploadedImage: ['![](#url#)', ''], + // uploadedImage: ['![](#url#)\n', ''], // TODO: New line insertion doesn't work here. + table: ['', '\n\n| Column 1 | Column 2 | Column 3 |\n| -------- | -------- | -------- |\n| Text | Text | Text |\n\n'], + horizontalRule: ['', '\n\n-----\n\n'], +}; + +var promptTexts = { + link: 'URL for the link:', + image: 'URL of the image:', +}; + +var timeFormat = { + locale: 'en-US', + format: { + hour: '2-digit', + minute: '2-digit', + }, +}; + +var blockStyles = { + 'bold': '**', + 'code': '```', + 'italic': '*', +}; + +/** + * Texts displayed to the user (mainly on the status bar) for the import image + * feature. Can be used for customization or internationalization. + */ +var imageTexts = { + sbInit: 'Attach files by drag and dropping or pasting from clipboard.', + sbOnDragEnter: 'Drop image to upload it.', + sbOnDrop: 'Uploading image #images_names#...', + sbProgress: 'Uploading #file_name#: #progress#%', + sbOnUploaded: 'Uploaded #image_name#', + sizeUnits: ' B, KB, MB', +}; + +/** + * Errors displayed to the user, using the `errorCallback` option. Can be used for + * customization or internationalization. + */ +var errorMessages = { + noFileGiven: 'You must select a file.', + typeNotAllowed: 'This image type is not allowed.', + fileTooLarge: 'Image #image_name# is too big (#image_size#).\n' + + 'Maximum file size is #image_max_size#.', + importError: 'Something went wrong when uploading the image #image_name#.', +}; + +/** + * Interface of EasyMDE. + */ +function EasyMDE(options) { + // Handle options parameter + options = options || {}; + + // Used later to refer to it"s parent + options.parent = this; + + // Check if Font Awesome needs to be auto downloaded + var autoDownloadFA = true; + + if (options.autoDownloadFontAwesome === false) { + autoDownloadFA = false; + } + + if (options.autoDownloadFontAwesome !== true) { + var styleSheets = document.styleSheets; + for (var i = 0; i < styleSheets.length; i++) { + if (!styleSheets[i].href) + continue; + + if (styleSheets[i].href.indexOf('//maxcdn.bootstrapcdn.com/font-awesome/') > -1) { + autoDownloadFA = false; + } + } + } + + if (autoDownloadFA) { + var link = document.createElement('link'); + link.rel = 'stylesheet'; + link.href = 'https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css'; + document.getElementsByTagName('head')[0].appendChild(link); + } + + + // Find the textarea to use + if (options.element) { + this.element = options.element; + } else if (options.element === null) { + // This means that the element option was specified, but no element was found + console.log('EasyMDE: Error. No element was found.'); + return; + } + + + // Handle toolbar + if (options.toolbar === undefined) { + // Initialize + options.toolbar = []; + + + // Loop over the built in buttons, to get the preferred order + for (var key in toolbarBuiltInButtons) { + if (Object.prototype.hasOwnProperty.call(toolbarBuiltInButtons, key)) { + if (key.indexOf('separator-') != -1) { + options.toolbar.push('|'); + } + + if (toolbarBuiltInButtons[key].default === true || (options.showIcons && options.showIcons.constructor === Array && options.showIcons.indexOf(key) != -1)) { + options.toolbar.push(key); + } + } + } + } + + // Editor preview styling class. + if (!Object.prototype.hasOwnProperty.call(options, 'previewClass')) { + options.previewClass = 'editor-preview'; + } + + // Handle status bar + if (!Object.prototype.hasOwnProperty.call(options, 'status')) { + options.status = ['autosave', 'lines', 'words', 'cursor']; + + if (options.uploadImage) { + options.status.unshift('upload-image'); + } + } + + + // Add default preview rendering function + if (!options.previewRender) { + options.previewRender = function (plainText) { + // Note: "this" refers to the options object + return this.parent.markdown(plainText); + }; + } + + + // Set default options for parsing config + options.parsingConfig = extend({ + highlightFormatting: true, // needed for toggleCodeBlock to detect types of code + }, options.parsingConfig || {}); + + + // Merging the insertTexts, with the given options + options.insertTexts = extend({}, insertTexts, options.insertTexts || {}); + + + // Merging the promptTexts, with the given options + options.promptTexts = extend({}, promptTexts, options.promptTexts || {}); + + + // Merging the blockStyles, with the given options + options.blockStyles = extend({}, blockStyles, options.blockStyles || {}); + + + if (options.autosave != undefined) { + // Merging the Autosave timeFormat, with the given options + options.autosave.timeFormat = extend({}, timeFormat, options.autosave.timeFormat || {}); + } + + + // Merging the shortcuts, with the given options + options.shortcuts = extend({}, shortcuts, options.shortcuts || {}); + + options.maxHeight = options.maxHeight || undefined; + + if (typeof options.maxHeight !== 'undefined') { + // Min and max height are equal if maxHeight is set + options.minHeight = options.maxHeight; + } else { + options.minHeight = options.minHeight || '300px'; + } + + options.errorCallback = options.errorCallback || function (errorMessage) { + alert(errorMessage); + }; + + // Import-image default configuration + options.uploadImage = options.uploadImage || false; + options.imageMaxSize = options.imageMaxSize || 2097152; // 1024 * 1024 * 2 + options.imageAccept = options.imageAccept || 'image/png, image/jpeg'; + options.imageTexts = extend({}, imageTexts, options.imageTexts || {}); + options.errorMessages = extend({}, errorMessages, options.errorMessages || {}); + + + // Change unique_id to uniqueId for backwards compatibility + if (options.autosave != undefined && options.autosave.unique_id != undefined && options.autosave.unique_id != '') + options.autosave.uniqueId = options.autosave.unique_id; + + // If overlay mode is specified and combine is not provided, default it to true + if (options.overlayMode && options.overlayMode.combine === undefined) { + options.overlayMode.combine = true; + } + + // Update this options + this.options = options; + + + // Auto render + this.render(); + + + // The codemirror component is only available after rendering + // so, the setter for the initialValue can only run after + // the element has been rendered + if (options.initialValue && (!this.options.autosave || this.options.autosave.foundSavedValue !== true)) { + this.value(options.initialValue); + } + + if (options.uploadImage) { + var self = this; + + this.codemirror.on('dragenter', function (cm, event) { + self.updateStatusBar('upload-image', self.options.imageTexts.sbOnDragEnter); + event.stopPropagation(); + event.preventDefault(); + }); + this.codemirror.on('dragend', function (cm, event) { + self.updateStatusBar('upload-image', self.options.imageTexts.sbInit); + event.stopPropagation(); + event.preventDefault(); + }); + this.codemirror.on('dragleave', function (cm, event) { + self.updateStatusBar('upload-image', self.options.imageTexts.sbInit); + event.stopPropagation(); + event.preventDefault(); + }); + + this.codemirror.on('dragover', function (cm, event) { + self.updateStatusBar('upload-image', self.options.imageTexts.sbOnDragEnter); + event.stopPropagation(); + event.preventDefault(); + }); + + this.codemirror.on('drop', function (cm, event) { + event.stopPropagation(); + event.preventDefault(); + if (options.imageUploadFunction) { + self.uploadImagesUsingCustomFunction(options.imageUploadFunction, event.dataTransfer.files); + } else { + self.uploadImages(event.dataTransfer.files); + } + }); + + this.codemirror.on('paste', function (cm, event) { + if (options.imageUploadFunction) { + self.uploadImagesUsingCustomFunction(options.imageUploadFunction, event.clipboardData.files); + } else { + self.uploadImages(event.clipboardData.files); + } + }); + } +} + +/** + * Upload asynchronously a list of images to a server. + * + * Can be triggered by: + * - drag&drop; + * - copy-paste; + * - the browse-file window (opened when the user clicks on the *upload-image* icon). + * @param {FileList} files The files to upload the the server. + * @param [onSuccess] {function} see EasyMDE.prototype.uploadImage + * @param [onError] {function} see EasyMDE.prototype.uploadImage + */ +EasyMDE.prototype.uploadImages = function (files, onSuccess, onError) { + if (files.length === 0) { + return; + } + var names = []; + for (var i = 0; i < files.length; i++) { + names.push(files[i].name); + this.uploadImage(files[i], onSuccess, onError); + } + this.updateStatusBar('upload-image', this.options.imageTexts.sbOnDrop.replace('#images_names#', names.join(', '))); +}; + +/** + * Upload asynchronously a list of images to a server. + * + * Can be triggered by: + * - drag&drop; + * - copy-paste; + * - the browse-file window (opened when the user clicks on the *upload-image* icon). + * @param imageUploadFunction {Function} The custom function to upload the image passed in options. + * @param {FileList} files The files to upload the the server. + */ +EasyMDE.prototype.uploadImagesUsingCustomFunction = function (imageUploadFunction, files) { + if (files.length === 0) { + return; + } + var names = []; + for (var i = 0; i < files.length; i++) { + names.push(files[i].name); + this.uploadImageUsingCustomFunction(imageUploadFunction, files[i]); + } + this.updateStatusBar('upload-image', this.options.imageTexts.sbOnDrop.replace('#images_names#', names.join(', '))); +}; + +/** + * Update an item in the status bar. + * @param itemName {string} The name of the item to update (ie. 'upload-image', 'autosave', etc.). + * @param content {string} the new content of the item to write in the status bar. + */ +EasyMDE.prototype.updateStatusBar = function (itemName, content) { + if (!this.gui.statusbar) { + return; + } + + var matchingClasses = this.gui.statusbar.getElementsByClassName(itemName); + if (matchingClasses.length === 1) { + this.gui.statusbar.getElementsByClassName(itemName)[0].textContent = content; + } else if (matchingClasses.length === 0) { + console.log('EasyMDE: status bar item ' + itemName + ' was not found.'); + } else { + console.log('EasyMDE: Several status bar items named ' + itemName + ' was found.'); + } +}; + +/** + * Default markdown render. + */ +EasyMDE.prototype.markdown = function (text) { + if (marked) { + // Initialize + var markedOptions; + if (this.options && this.options.renderingConfig && this.options.renderingConfig.markedOptions) { + markedOptions = this.options.renderingConfig.markedOptions; + } else { + markedOptions = {}; + } + + // Update options + if (this.options && this.options.renderingConfig && this.options.renderingConfig.singleLineBreaks === false) { + markedOptions.breaks = false; + } else { + markedOptions.breaks = true; + } + + if (this.options && this.options.renderingConfig && this.options.renderingConfig.codeSyntaxHighlighting === true) { + + /* Get HLJS from config or window */ + var hljs = this.options.renderingConfig.hljs || window.hljs; + + /* Check if HLJS loaded */ + if (hljs) { + markedOptions.highlight = function (code, language) { + if (language && hljs.getLanguage(language)) { + return hljs.highlight(language, code).value; + } else { + return hljs.highlightAuto(code).value; + } + }; + } + } + + // Set options + marked.setOptions(markedOptions); + + // Convert the markdown to HTML + var htmlText = marked(text); + + // Sanitize HTML + if (this.options.renderingConfig && typeof this.options.renderingConfig.sanitizerFunction === 'function') { + htmlText = this.options.renderingConfig.sanitizerFunction.call(this, htmlText); + } + + // Edit the HTML anchors to add 'target="_blank"' by default. + htmlText = addAnchorTargetBlank(htmlText); + + // Remove list-style when rendering checkboxes + htmlText = removeListStyleWhenCheckbox(htmlText); + + return htmlText; + } +}; + +/** + * Render editor to the given element. + */ +EasyMDE.prototype.render = function (el) { + if (!el) { + el = this.element || document.getElementsByTagName('textarea')[0]; + } + + if (this._rendered && this._rendered === el) { + // Already rendered. + return; + } + + this.element = el; + var options = this.options; + + var self = this; + var keyMaps = {}; + + for (var key in options.shortcuts) { + // null stands for "do not bind this command" + if (options.shortcuts[key] !== null && bindings[key] !== null) { + (function (key) { + keyMaps[fixShortcut(options.shortcuts[key])] = function () { + var action = bindings[key]; + if (typeof action === 'function') { + action(self); + } else if (typeof action === 'string') { + window.open(action, '_blank'); + } + }; + })(key); + } + } + + keyMaps['Enter'] = 'newlineAndIndentContinueMarkdownList'; + keyMaps['Tab'] = 'tabAndIndentMarkdownList'; + keyMaps['Shift-Tab'] = 'shiftTabAndUnindentMarkdownList'; + keyMaps['Esc'] = function (cm) { + if (cm.getOption('fullScreen')) toggleFullScreen(self); + }; + + this.documentOnKeyDown = function (e) { + e = e || window.event; + + if (e.keyCode == 27) { + if (self.codemirror.getOption('fullScreen')) toggleFullScreen(self); + } + }; + document.addEventListener('keydown', this.documentOnKeyDown, false); + + var mode, backdrop; + + // CodeMirror overlay mode + if (options.overlayMode) { + CodeMirror.defineMode('overlay-mode', function(config) { + return CodeMirror.overlayMode(CodeMirror.getMode(config, options.spellChecker !== false ? 'spell-checker' : 'gfm'), options.overlayMode.mode, options.overlayMode.combine); + }); + + mode = 'overlay-mode'; + backdrop = options.parsingConfig; + backdrop.gitHubSpice = false; + } else { + mode = options.parsingConfig; + mode.name = 'gfm'; + mode.gitHubSpice = false; + } + if (options.spellChecker !== false) { + mode = 'spell-checker'; + backdrop = options.parsingConfig; + backdrop.name = 'gfm'; + backdrop.gitHubSpice = false; + + CodeMirrorSpellChecker({ + codeMirrorInstance: CodeMirror, + }); + } + + // eslint-disable-next-line no-unused-vars + function configureMouse(cm, repeat, event) { + return { + addNew: false, + }; + } + + this.codemirror = CodeMirror.fromTextArea(el, { + mode: mode, + backdrop: backdrop, + theme: (options.theme != undefined) ? options.theme : 'easymde', + tabSize: (options.tabSize != undefined) ? options.tabSize : 2, + indentUnit: (options.tabSize != undefined) ? options.tabSize : 2, + indentWithTabs: (options.indentWithTabs === false) ? false : true, + lineNumbers: (options.lineNumbers === true) ? true : false, + autofocus: (options.autofocus === true) ? true : false, + extraKeys: keyMaps, + lineWrapping: (options.lineWrapping === false) ? false : true, + allowDropFileTypes: ['text/plain'], + placeholder: options.placeholder || el.getAttribute('placeholder') || '', + styleSelectedText: (options.styleSelectedText != undefined) ? options.styleSelectedText : !isMobile(), + scrollbarStyle: (options.scrollbarStyle != undefined) ? options.scrollbarStyle : 'native', + configureMouse: configureMouse, + inputStyle: (options.inputStyle != undefined) ? options.inputStyle : isMobile() ? 'contenteditable' : 'textarea', + spellcheck: (options.nativeSpellcheck != undefined) ? options.nativeSpellcheck : true, + autoRefresh: (options.autoRefresh != undefined) ? options.autoRefresh : false, + }); + + this.codemirror.getScrollerElement().style.minHeight = options.minHeight; + + if (typeof options.maxHeight !== 'undefined') { + this.codemirror.getScrollerElement().style.height = options.maxHeight; + } + + if (options.forceSync === true) { + var cm = this.codemirror; + cm.on('change', function () { + cm.save(); + }); + } + + this.gui = {}; + + // Wrap Codemirror with container before create toolbar, etc, + // to use with sideBySideFullscreen option. + var easyMDEContainer = document.createElement('div'); + easyMDEContainer.classList.add('EasyMDEContainer'); + var cmWrapper = this.codemirror.getWrapperElement(); + cmWrapper.parentNode.insertBefore(easyMDEContainer, cmWrapper); + easyMDEContainer.appendChild(cmWrapper); + + if (options.toolbar !== false) { + this.gui.toolbar = this.createToolbar(); + } + if (options.status !== false) { + this.gui.statusbar = this.createStatusbar(); + } + if (options.autosave != undefined && options.autosave.enabled === true) { + this.autosave(); // use to load localstorage content + this.codemirror.on('change', function () { + clearTimeout(self._autosave_timeout); + self._autosave_timeout = setTimeout(function () { + self.autosave(); + }, self.options.autosave.submit_delay || self.options.autosave.delay || 1000); + }); + } + + function calcHeight(naturalWidth, naturalHeight) { + var height; + var viewportWidth = window.getComputedStyle(document.querySelector('.CodeMirror-sizer')).width.replace('px', ''); + if (naturalWidth < viewportWidth) { + height = naturalHeight + 'px'; + } else { + height = (naturalHeight / naturalWidth * 100) + '%'; + } + return height; + } + + var _vm = this; + + + function assignImageBlockAttributes(parentEl, img) { + parentEl.setAttribute('data-img-src', img.url); + parentEl.setAttribute('style', '--bg-image:url('+img.url+');--width:'+img.naturalWidth+'px;--height:'+calcHeight(img.naturalWidth, img.naturalHeight)); + _vm.codemirror.setSize(); + } + + function handleImages() { + if (!options.previewImagesInEditor) { + return; + } + + easyMDEContainer.querySelectorAll('.cm-image-marker').forEach(function(e) { + var parentEl = e.parentElement; + if (!parentEl.innerText.match(/^!\[.*?\]\(.*\)/g)) { + // if img pasted on the same line with other text, don't preview, preview only images on separate line + return; + } + if (!parentEl.hasAttribute('data-img-src')) { + var srcAttr = parentEl.innerText.match('\\((.*)\\)'); // might require better parsing according to markdown spec + if (!window.EMDEimagesCache) { + window.EMDEimagesCache = {}; + } + + if (srcAttr && srcAttr.length >= 2) { + var keySrc = srcAttr[1]; + + if (! window.EMDEimagesCache[keySrc]) { + var img = document.createElement('img'); + img.onload = function() { + window.EMDEimagesCache[keySrc] = { + naturalWidth: img.naturalWidth, + naturalHeight: img.naturalHeight, + url: keySrc, + }; + assignImageBlockAttributes(parentEl, window.EMDEimagesCache[keySrc]); + }; + img.src = keySrc; + } else { + assignImageBlockAttributes(parentEl, window.EMDEimagesCache[keySrc]); + } + } + } + }); + } + this.codemirror.on('update', function () { + handleImages(); + }); + + this.gui.sideBySide = this.createSideBySide(); + this._rendered = this.element; + + // Fixes CodeMirror bug (#344) + var temp_cm = this.codemirror; + setTimeout(function () { + temp_cm.refresh(); + }.bind(temp_cm), 0); +}; + +EasyMDE.prototype.cleanup = function () { + document.removeEventListener('keydown', this.documentOnKeyDown); +}; + +// Safari, in Private Browsing Mode, looks like it supports localStorage but all calls to setItem throw QuotaExceededError. We're going to detect this and set a variable accordingly. +function isLocalStorageAvailable() { + if (typeof localStorage === 'object') { + try { + localStorage.setItem('smde_localStorage', 1); + localStorage.removeItem('smde_localStorage'); + } catch (e) { + return false; + } + } else { + return false; + } + + return true; +} + +EasyMDE.prototype.autosave = function () { + if (isLocalStorageAvailable()) { + var easyMDE = this; + + if (this.options.autosave.uniqueId == undefined || this.options.autosave.uniqueId == '') { + console.log('EasyMDE: You must set a uniqueId to use the autosave feature'); + return; + } + + if (this.options.autosave.binded !== true) { + if (easyMDE.element.form != null && easyMDE.element.form != undefined) { + easyMDE.element.form.addEventListener('submit', function () { + clearTimeout(easyMDE.autosaveTimeoutId); + easyMDE.autosaveTimeoutId = undefined; + + localStorage.removeItem('smde_' + easyMDE.options.autosave.uniqueId); + }); + } + + this.options.autosave.binded = true; + } + + if (this.options.autosave.loaded !== true) { + if (typeof localStorage.getItem('smde_' + this.options.autosave.uniqueId) == 'string' && localStorage.getItem('smde_' + this.options.autosave.uniqueId) != '') { + this.codemirror.setValue(localStorage.getItem('smde_' + this.options.autosave.uniqueId)); + this.options.autosave.foundSavedValue = true; + } + + this.options.autosave.loaded = true; + } + + var value = easyMDE.value(); + if (value !== '') { + localStorage.setItem('smde_' + this.options.autosave.uniqueId, value); + } else { + localStorage.removeItem('smde_' + this.options.autosave.uniqueId); + } + + var el = document.getElementById('autosaved'); + if (el != null && el != undefined && el != '') { + var d = new Date(); + var dd = new Intl.DateTimeFormat([this.options.autosave.timeFormat.locale, 'en-US'], this.options.autosave.timeFormat.format).format(d); + var save = this.options.autosave.text == undefined ? 'Autosaved: ' : this.options.autosave.text; + + el.innerHTML = save + dd; + } + } else { + console.log('EasyMDE: localStorage not available, cannot autosave'); + } +}; + +EasyMDE.prototype.clearAutosavedValue = function () { + if (isLocalStorageAvailable()) { + if (this.options.autosave == undefined || this.options.autosave.uniqueId == undefined || this.options.autosave.uniqueId == '') { + console.log('EasyMDE: You must set a uniqueId to clear the autosave value'); + return; + } + + localStorage.removeItem('smde_' + this.options.autosave.uniqueId); + } else { + console.log('EasyMDE: localStorage not available, cannot autosave'); + } +}; + +/** + * Open the browse-file window to upload an image to a server. + * @param [onSuccess] {function} see EasyMDE.prototype.uploadImage + * @param [onError] {function} see EasyMDE.prototype.uploadImage + */ +EasyMDE.prototype.openBrowseFileWindow = function (onSuccess, onError) { + var self = this; + var imageInput = this.gui.toolbar.getElementsByClassName('imageInput')[0]; + imageInput.click(); //dispatchEvent(new MouseEvent('click')); // replaced with click() for IE11 compatibility. + function onChange(event) { + if (self.options.imageUploadFunction) { + self.uploadImagesUsingCustomFunction(self.options.imageUploadFunction, event.target.files); + } else { + self.uploadImages(event.target.files, onSuccess, onError); + } + imageInput.removeEventListener('change', onChange); + } + + imageInput.addEventListener('change', onChange); +}; + +/** + * Upload an image to the server. + * + * @param file {File} The image to upload, as a HTML5 File object (https://developer.mozilla.org/en-US/docs/Web/API/File) + * @param [onSuccess] {function} A callback function to execute after the image has been successfully uploaded, with one parameter: + * - url (string): The URL of the uploaded image. + * @param [onError] {function} A callback function to execute when the image upload fails, with one parameter: + * - error (string): the detailed error to display to the user (based on messages from options.errorMessages). + */ +EasyMDE.prototype.uploadImage = function (file, onSuccess, onError) { + var self = this; + onSuccess = onSuccess || function onSuccess(imageUrl) { + afterImageUploaded(self, imageUrl); + }; + + function onErrorSup(errorMessage) { + // show error on status bar and reset after 10000ms + self.updateStatusBar('upload-image', errorMessage); + + setTimeout(function () { + self.updateStatusBar('upload-image', self.options.imageTexts.sbInit); + }, 10000); + + // run custom error handler + if (onError && typeof onError === 'function') { + onError(errorMessage); + } + // run error handler from options, this alerts the message. + self.options.errorCallback(errorMessage); + } + + function fillErrorMessage(errorMessage) { + var units = self.options.imageTexts.sizeUnits.split(','); + return errorMessage + .replace('#image_name#', file.name) + .replace('#image_size#', humanFileSize(file.size, units)) + .replace('#image_max_size#', humanFileSize(self.options.imageMaxSize, units)); + } + + if (file.size > this.options.imageMaxSize) { + onErrorSup(fillErrorMessage(this.options.errorMessages.fileTooLarge)); + return; + } + + var formData = new FormData(); + formData.append('image', file); + + // insert CSRF token if provided in config. + if (self.options.imageCSRFToken) { + formData.append('csrfmiddlewaretoken', self.options.imageCSRFToken); + } + var request = new XMLHttpRequest(); + request.upload.onprogress = function (event) { + if (event.lengthComputable) { + var progress = '' + Math.round((event.loaded * 100) / event.total); + self.updateStatusBar('upload-image', self.options.imageTexts.sbProgress.replace('#file_name#', file.name).replace('#progress#', progress)); + } + }; + request.open('POST', this.options.imageUploadEndpoint); + + request.onload = function () { + try { + var response = JSON.parse(this.responseText); + } catch (error) { + console.error('EasyMDE: The server did not return a valid json.'); + onErrorSup(fillErrorMessage(self.options.errorMessages.importError)); + return; + } + if (this.status === 200 && response && !response.error && response.data && response.data.filePath) { + onSuccess((self.options.imagePathAbsolute ? '' : (window.location.origin + '/')) + response.data.filePath); + } else { + if (response.error && response.error in self.options.errorMessages) { // preformatted error message + onErrorSup(fillErrorMessage(self.options.errorMessages[response.error])); + } else if (response.error) { // server side generated error message + onErrorSup(fillErrorMessage(response.error)); + } else { //unknown error + console.error('EasyMDE: Received an unexpected response after uploading the image.' + + this.status + ' (' + this.statusText + ')'); + onErrorSup(fillErrorMessage(self.options.errorMessages.importError)); + } + } + }; + + request.onerror = function (event) { + console.error('EasyMDE: An unexpected error occurred when trying to upload the image.' + + event.target.status + ' (' + event.target.statusText + ')'); + onErrorSup(self.options.errorMessages.importError); + }; + + request.send(formData); + +}; + +/** + * Upload an image to the server using a custom upload function. + * + * @param imageUploadFunction {Function} The custom function to upload the image passed in options + * @param file {File} The image to upload, as a HTML5 File object (https://developer.mozilla.org/en-US/docs/Web/API/File). + */ +EasyMDE.prototype.uploadImageUsingCustomFunction = function(imageUploadFunction, file) { + var self = this; + function onSuccess(imageUrl) { + afterImageUploaded(self, imageUrl); + } + + function onError(errorMessage) { + var filledErrorMessage = fillErrorMessage(errorMessage); + // show error on status bar and reset after 10000ms + self.updateStatusBar('upload-image', filledErrorMessage); + + setTimeout(function () { + self.updateStatusBar('upload-image', self.options.imageTexts.sbInit); + }, 10000); + + // run error handler from options, this alerts the message. + self.options.errorCallback(filledErrorMessage); + } + + function fillErrorMessage(errorMessage) { + var units = self.options.imageTexts.sizeUnits.split(','); + return errorMessage + .replace('#image_name#', file.name) + .replace('#image_size#', humanFileSize(file.size, units)) + .replace('#image_max_size#', humanFileSize(self.options.imageMaxSize, units)); + } + + imageUploadFunction.apply(this, [file, onSuccess, onError]); +}; + +EasyMDE.prototype.setPreviewMaxHeight = function () { + var cm = this.codemirror; + var wrapper = cm.getWrapperElement(); + var preview = wrapper.nextSibling; + + // Calc preview max height + var paddingTop = parseInt(window.getComputedStyle(wrapper).paddingTop); + var borderTopWidth = parseInt(window.getComputedStyle(wrapper).borderTopWidth); + var optionsMaxHeight = parseInt(this.options.maxHeight); + var wrapperMaxHeight = optionsMaxHeight + paddingTop * 2 + borderTopWidth * 2; + var previewMaxHeight = wrapperMaxHeight.toString() + 'px'; + + preview.style.height = previewMaxHeight; +}; + +EasyMDE.prototype.createSideBySide = function () { + var cm = this.codemirror; + var wrapper = cm.getWrapperElement(); + var preview = wrapper.nextSibling; + + if (!preview || !/editor-preview-side/.test(preview.className)) { + preview = document.createElement('div'); + preview.className = 'editor-preview-side'; + + if (this.options.previewClass) { + + if (Array.isArray(this.options.previewClass)) { + for (var i = 0; i < this.options.previewClass.length; i++) { + preview.className += (' ' + this.options.previewClass[i]); + } + + } else if (typeof this.options.previewClass === 'string') { + preview.className += (' ' + this.options.previewClass); + } + } + + wrapper.parentNode.insertBefore(preview, wrapper.nextSibling); + } + + if (typeof this.options.maxHeight !== 'undefined') { + this.setPreviewMaxHeight(); + } + + if (this.options.syncSideBySidePreviewScroll === false) return preview; + // Syncs scroll editor -> preview + var cScroll = false; + var pScroll = false; + cm.on('scroll', function (v) { + if (cScroll) { + cScroll = false; + return; + } + pScroll = true; + var height = v.getScrollInfo().height - v.getScrollInfo().clientHeight; + var ratio = parseFloat(v.getScrollInfo().top) / height; + var move = (preview.scrollHeight - preview.clientHeight) * ratio; + preview.scrollTop = move; + }); + + // Syncs scroll preview -> editor + preview.onscroll = function () { + if (pScroll) { + pScroll = false; + return; + } + cScroll = true; + var height = preview.scrollHeight - preview.clientHeight; + var ratio = parseFloat(preview.scrollTop) / height; + var move = (cm.getScrollInfo().height - cm.getScrollInfo().clientHeight) * ratio; + cm.scrollTo(0, move); + }; + return preview; +}; + +EasyMDE.prototype.createToolbar = function (items) { + items = items || this.options.toolbar; + + if (!items || items.length === 0) { + return; + } + var i; + for (i = 0; i < items.length; i++) { + if (toolbarBuiltInButtons[items[i]] != undefined) { + items[i] = toolbarBuiltInButtons[items[i]]; + } + } + + var bar = document.createElement('div'); + bar.className = 'editor-toolbar'; + + var self = this; + + var toolbarData = {}; + self.toolbar = items; + + for (i = 0; i < items.length; i++) { + if (items[i].name == 'guide' && self.options.toolbarGuideIcon === false) + continue; + + if (self.options.hideIcons && self.options.hideIcons.indexOf(items[i].name) != -1) + continue; + + // Fullscreen does not work well on mobile devices (even tablets) + // In the future, hopefully this can be resolved + if ((items[i].name == 'fullscreen' || items[i].name == 'side-by-side') && isMobile()) + continue; + + + // Don't include trailing separators + if (items[i] === '|') { + var nonSeparatorIconsFollow = false; + + for (var x = (i + 1); x < items.length; x++) { + if (items[x] !== '|' && (!self.options.hideIcons || self.options.hideIcons.indexOf(items[x].name) == -1)) { + nonSeparatorIconsFollow = true; + } + } + + if (!nonSeparatorIconsFollow) + continue; + } + + + // Create the icon and append to the toolbar + (function (item) { + var el; + if (item === '|') { + el = createSep(); + } else if (item.children) { + el = createToolbarDropdown(item, self.options.toolbarTips, self.options.shortcuts, self); + } else { + el = createToolbarButton(item, true, self.options.toolbarTips, self.options.shortcuts, 'button', self); + } + + + toolbarData[item.name || item] = el; + bar.appendChild(el); + + // Create the input element (ie. ), used among + // with the 'import-image' icon to open the browse-file window. + if (item.name === 'upload-image') { + var imageInput = document.createElement('input'); + imageInput.className = 'imageInput'; + imageInput.type = 'file'; + imageInput.multiple = true; + imageInput.name = 'image'; + imageInput.accept = self.options.imageAccept; + imageInput.style.display = 'none'; + imageInput.style.opacity = 0; + bar.appendChild(imageInput); + } + })(items[i]); + } + + self.toolbar_div = bar; + self.toolbarElements = toolbarData; + + var cm = this.codemirror; + cm.on('cursorActivity', function () { + var stat = getState(cm); + + for (var key in toolbarData) { + (function (key) { + var el = toolbarData[key]; + if (stat[key]) { + el.className += ' active'; + } else if (key != 'fullscreen' && key != 'side-by-side') { + el.className = el.className.replace(/\s*active\s*/g, ''); + } + })(key); + } + }); + + var cmWrapper = cm.getWrapperElement(); + cmWrapper.parentNode.insertBefore(bar, cmWrapper); + return bar; +}; + +EasyMDE.prototype.createStatusbar = function (status) { + // Initialize + status = status || this.options.status; + var options = this.options; + var cm = this.codemirror; + + // Make sure the status variable is valid + if (!status || status.length === 0) { + return; + } + + // Set up the built-in items + var items = []; + var i, onUpdate, onActivity, defaultValue; + + for (i = 0; i < status.length; i++) { + // Reset some values + onUpdate = undefined; + onActivity = undefined; + defaultValue = undefined; + + + // Handle if custom or not + if (typeof status[i] === 'object') { + items.push({ + className: status[i].className, + defaultValue: status[i].defaultValue, + onUpdate: status[i].onUpdate, + onActivity: status[i].onActivity, + }); + } else { + var name = status[i]; + + if (name === 'words') { + defaultValue = function (el) { + el.innerHTML = wordCount(cm.getValue()); + }; + onUpdate = function (el) { + el.innerHTML = wordCount(cm.getValue()); + }; + } else if (name === 'lines') { + defaultValue = function (el) { + el.innerHTML = cm.lineCount(); + }; + onUpdate = function (el) { + el.innerHTML = cm.lineCount(); + }; + } else if (name === 'cursor') { + defaultValue = function (el) { + el.innerHTML = '0:0'; + }; + onActivity = function (el) { + var pos = cm.getCursor(); + el.innerHTML = pos.line + ':' + pos.ch; + }; + } else if (name === 'autosave') { + defaultValue = function (el) { + if (options.autosave != undefined && options.autosave.enabled === true) { + el.setAttribute('id', 'autosaved'); + } + }; + } else if (name === 'upload-image') { + defaultValue = function (el) { + el.innerHTML = options.imageTexts.sbInit; + }; + } + + items.push({ + className: name, + defaultValue: defaultValue, + onUpdate: onUpdate, + onActivity: onActivity, + }); + } + } + + + // Create element for the status bar + var bar = document.createElement('div'); + bar.className = 'editor-statusbar'; + + + // Create a new span for each item + for (i = 0; i < items.length; i++) { + // Store in temporary variable + var item = items[i]; + + + // Create span element + var el = document.createElement('span'); + el.className = item.className; + + + // Ensure the defaultValue is a function + if (typeof item.defaultValue === 'function') { + item.defaultValue(el); + } + + + // Ensure the onUpdate is a function + if (typeof item.onUpdate === 'function') { + // Create a closure around the span of the current action, then execute the onUpdate handler + this.codemirror.on('update', (function (el, item) { + return function () { + item.onUpdate(el); + }; + }(el, item))); + } + if (typeof item.onActivity === 'function') { + // Create a closure around the span of the current action, then execute the onActivity handler + this.codemirror.on('cursorActivity', (function (el, item) { + return function () { + item.onActivity(el); + }; + }(el, item))); + } + + + // Append the item to the status bar + bar.appendChild(el); + } + + + // Insert the status bar into the DOM + var cmWrapper = this.codemirror.getWrapperElement(); + cmWrapper.parentNode.insertBefore(bar, cmWrapper.nextSibling); + return bar; +}; + +/** + * Get or set the text content. + */ +EasyMDE.prototype.value = function (val) { + var cm = this.codemirror; + if (val === undefined) { + return cm.getValue(); + } else { + cm.getDoc().setValue(val); + if (this.isPreviewActive()) { + var wrapper = cm.getWrapperElement(); + var preview = wrapper.lastChild; + preview.innerHTML = this.options.previewRender(val, preview); + } + return this; + } +}; + + +/** + * Bind static methods for exports. + */ +EasyMDE.toggleBold = toggleBold; +EasyMDE.toggleItalic = toggleItalic; +EasyMDE.toggleStrikethrough = toggleStrikethrough; +EasyMDE.toggleBlockquote = toggleBlockquote; +EasyMDE.toggleHeadingSmaller = toggleHeadingSmaller; +EasyMDE.toggleHeadingBigger = toggleHeadingBigger; +EasyMDE.toggleHeading1 = toggleHeading1; +EasyMDE.toggleHeading2 = toggleHeading2; +EasyMDE.toggleHeading3 = toggleHeading3; +EasyMDE.toggleCodeBlock = toggleCodeBlock; +EasyMDE.toggleUnorderedList = toggleUnorderedList; +EasyMDE.toggleOrderedList = toggleOrderedList; +EasyMDE.cleanBlock = cleanBlock; +EasyMDE.drawLink = drawLink; +EasyMDE.drawImage = drawImage; +EasyMDE.drawUploadedImage = drawUploadedImage; +EasyMDE.drawTable = drawTable; +EasyMDE.drawHorizontalRule = drawHorizontalRule; +EasyMDE.undo = undo; +EasyMDE.redo = redo; +EasyMDE.togglePreview = togglePreview; +EasyMDE.toggleSideBySide = toggleSideBySide; +EasyMDE.toggleFullScreen = toggleFullScreen; + +/** + * Bind instance methods for exports. + */ +EasyMDE.prototype.toggleBold = function () { + toggleBold(this); +}; +EasyMDE.prototype.toggleItalic = function () { + toggleItalic(this); +}; +EasyMDE.prototype.toggleStrikethrough = function () { + toggleStrikethrough(this); +}; +EasyMDE.prototype.toggleBlockquote = function () { + toggleBlockquote(this); +}; +EasyMDE.prototype.toggleHeadingSmaller = function () { + toggleHeadingSmaller(this); +}; +EasyMDE.prototype.toggleHeadingBigger = function () { + toggleHeadingBigger(this); +}; +EasyMDE.prototype.toggleHeading1 = function () { + toggleHeading1(this); +}; +EasyMDE.prototype.toggleHeading2 = function () { + toggleHeading2(this); +}; +EasyMDE.prototype.toggleHeading3 = function () { + toggleHeading3(this); +}; +EasyMDE.prototype.toggleCodeBlock = function () { + toggleCodeBlock(this); +}; +EasyMDE.prototype.toggleUnorderedList = function () { + toggleUnorderedList(this); +}; +EasyMDE.prototype.toggleOrderedList = function () { + toggleOrderedList(this); +}; +EasyMDE.prototype.cleanBlock = function () { + cleanBlock(this); +}; +EasyMDE.prototype.drawLink = function () { + drawLink(this); +}; +EasyMDE.prototype.drawImage = function () { + drawImage(this); +}; +EasyMDE.prototype.drawUploadedImage = function () { + drawUploadedImage(this); +}; +EasyMDE.prototype.drawTable = function () { + drawTable(this); +}; +EasyMDE.prototype.drawHorizontalRule = function () { + drawHorizontalRule(this); +}; +EasyMDE.prototype.undo = function () { + undo(this); +}; +EasyMDE.prototype.redo = function () { + redo(this); +}; +EasyMDE.prototype.togglePreview = function () { + togglePreview(this); +}; +EasyMDE.prototype.toggleSideBySide = function () { + toggleSideBySide(this); +}; +EasyMDE.prototype.toggleFullScreen = function () { + toggleFullScreen(this); +}; + +EasyMDE.prototype.isPreviewActive = function () { + var cm = this.codemirror; + var wrapper = cm.getWrapperElement(); + var preview = wrapper.lastChild; + + return /editor-preview-active/.test(preview.className); +}; + +EasyMDE.prototype.isSideBySideActive = function () { + var cm = this.codemirror; + var wrapper = cm.getWrapperElement(); + var preview = wrapper.nextSibling; + + return /editor-preview-active-side/.test(preview.className); +}; + +EasyMDE.prototype.isFullscreenActive = function () { + var cm = this.codemirror; + + return cm.getOption('fullScreen'); +}; + +EasyMDE.prototype.getState = function () { + var cm = this.codemirror; + + return getState(cm); +}; + +EasyMDE.prototype.toTextArea = function () { + var cm = this.codemirror; + var wrapper = cm.getWrapperElement(); + var easyMDEContainer = wrapper.parentNode; + + if (easyMDEContainer) { + if (this.gui.toolbar) { + easyMDEContainer.removeChild(this.gui.toolbar); + } + if (this.gui.statusbar) { + easyMDEContainer.removeChild(this.gui.statusbar); + } + if (this.gui.sideBySide) { + easyMDEContainer.removeChild(this.gui.sideBySide); + } + } + + // Unwrap easyMDEcontainer before codemirror toTextArea() call + easyMDEContainer.parentNode.insertBefore(wrapper, easyMDEContainer); + easyMDEContainer.remove(); + + cm.toTextArea(); + + if (this.autosaveTimeoutId) { + clearTimeout(this.autosaveTimeoutId); + this.autosaveTimeoutId = undefined; + this.clearAutosavedValue(); + } +}; + +module.exports = EasyMDE; diff --git a/PSC.Blazor.Components.MarkdownEditor/wwwroot/easymde/src/js/easymde.min.js b/PSC.Blazor.Components.MarkdownEditor/wwwroot/easymde/src/js/easymde.min.js new file mode 100644 index 0000000..a394874 --- /dev/null +++ b/PSC.Blazor.Components.MarkdownEditor/wwwroot/easymde/src/js/easymde.min.js @@ -0,0 +1,8 @@ +/** + * Minified by jsDelivr using Terser v5.3.5. + * Original file: /npm/easymde@2.15.0/src/js/easymde.js + * + * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files + */ +"use strict";var CodeMirror=require("codemirror");require("codemirror/addon/edit/continuelist.js"),require("./codemirror/tablist"),require("codemirror/addon/display/fullscreen.js"),require("codemirror/mode/markdown/markdown.js"),require("codemirror/addon/mode/overlay.js"),require("codemirror/addon/display/placeholder.js"),require("codemirror/addon/display/autorefresh.js"),require("codemirror/addon/selection/mark-selection.js"),require("codemirror/addon/search/searchcursor.js"),require("codemirror/mode/gfm/gfm.js"),require("codemirror/mode/xml/xml.js");var CodeMirrorSpellChecker=require("codemirror-spell-checker"),marked=require("marked/lib/marked"),isMac=/Mac/.test(navigator.platform),anchorToExternalRegex=new RegExp(/()+?/g),bindings={toggleBold:toggleBold,toggleItalic:toggleItalic,drawLink:drawLink,toggleHeadingSmaller:toggleHeadingSmaller,toggleHeadingBigger:toggleHeadingBigger,drawImage:drawImage,toggleBlockquote:toggleBlockquote,toggleOrderedList:toggleOrderedList,toggleUnorderedList:toggleUnorderedList,toggleCodeBlock:toggleCodeBlock,togglePreview:togglePreview,toggleStrikethrough:toggleStrikethrough,toggleHeading1:toggleHeading1,toggleHeading2:toggleHeading2,toggleHeading3:toggleHeading3,cleanBlock:cleanBlock,drawTable:drawTable,drawHorizontalRule:drawHorizontalRule,undo:undo,redo:redo,toggleSideBySide:toggleSideBySide,toggleFullScreen:toggleFullScreen},shortcuts={toggleBold:"Cmd-B",toggleItalic:"Cmd-I",drawLink:"Cmd-K",toggleHeadingSmaller:"Cmd-H",toggleHeadingBigger:"Shift-Cmd-H",cleanBlock:"Cmd-E",drawImage:"Cmd-Alt-I",toggleBlockquote:"Cmd-'",toggleOrderedList:"Cmd-Alt-L",toggleUnorderedList:"Cmd-L",toggleCodeBlock:"Cmd-Alt-C",togglePreview:"Cmd-P",toggleSideBySide:"F9",toggleFullScreen:"F11"},getBindingName=function(e){for(var t in bindings)if(bindings[t]===e)return t;return null},isMobile=function(){var e,t=!1;return e=navigator.userAgent||navigator.vendor||window.opera,(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(e.substr(0,4)))&&(t=!0),t};function addAnchorTargetBlank(e){for(var t;null!==(t=anchorToExternalRegex.exec(e));){var o=t[0];if(-1===o.indexOf("target=")){var i=o.replace(/>$/,' target="_blank">');e=e.replace(o,i)}}return e}function removeListStyleWhenCheckbox(e){for(var t=(new DOMParser).parseFromString(e,"text/html"),o=t.getElementsByTagName("li"),i=0;i=0&&!o(u=s.getLineHandle(n));n--);var f,v,y,b,E=i(s.getTokenAt({line:n,ch:1})).fencedChars;o(s.getLineHandle(d.line))?(f="",v=d.line):o(s.getLineHandle(d.line-1))?(f="",v=d.line-1):(f=E+"\n",v=d.line),o(s.getLineHandle(c.line))?(y="",b=c.line,0===c.ch&&(b+=1)):0!==c.ch&&o(s.getLineHandle(c.line+1))?(y="",b=c.line+1):(y=E+"\n",b=c.line+1),0===c.ch&&(b-=1),s.operation((function(){s.replaceRange(y,{line:b,ch:0},{line:b+(y?0:1),ch:0}),s.replaceRange(f,{line:v,ch:0},{line:v+(f?0:1),ch:0})})),s.setSelection({line:v+(f?1:0),ch:0},{line:b+(f?1:-1),ch:0}),s.focus()}else{var w=d.line;if(o(s.getLineHandle(d.line))&&("fenced"===a(s,d.line+1)?(n=d.line,w=d.line+1):(r=d.line,w=d.line-1)),void 0===n)for(n=w;n>=0&&!o(u=s.getLineHandle(n));n--);if(void 0===r)for(l=s.lineCount(),r=w;r=0;n--)if(!(u=s.getLineHandle(n)).text.match(/^\s*$/)&&"indented"!==a(s,n,u)){n+=1;break}for(l=s.lineCount(),r=d.line;r\s+/,"unordered-list":o,"ordered-list":o},s=function(e,t,a){var n=o.exec(t),r=function(e,t){return{quote:">","unordered-list":"*","ordered-list":"%%i."}[e].replace("%%i",t)}(e,d);return null!==n?(function(e,t){var o=new RegExp({quote:">","unordered-list":"*","ordered-list":"\\d+."}[e]);return t&&o.test(t)}(e,n[2])&&(r=""),t=n[1]+r+n[3]+t.replace(i,"").replace(l[e],"$1")):0==a&&(t=r+" "+t),t},d=1,c=n.line;c<=r.line;c++)!function(o){var i=e.getLine(o);a[t]?i=i.replace(l[t],"$1"):("unordered-list"==t&&(i=s("ordered-list",i,!0)),i=s(t,i,!1),d+=1),e.replaceRange(i,{line:o,ch:0},{line:o,ch:99999999999999})}(c);e.focus()}}function _toggleBlock(e,t,o,i){if(!/editor-preview-active/.test(e.codemirror.getWrapperElement().lastChild.className)){i=void 0===i?o:i;var a,n=e.codemirror,r=getState(n),l=o,s=i,d=n.getCursor("start"),c=n.getCursor("end");r[t]?(l=(a=n.getLine(d.line)).slice(0,d.ch),s=a.slice(d.ch),"bold"==t?(l=l.replace(/(\*\*|__)(?![\s\S]*(\*\*|__))/,""),s=s.replace(/(\*\*|__)/,"")):"italic"==t?(l=l.replace(/(\*|_)(?![\s\S]*(\*|_))/,""),s=s.replace(/(\*|_)/,"")):"strikethrough"==t&&(l=l.replace(/(\*\*|~~)(?![\s\S]*(\*\*|~~))/,""),s=s.replace(/(\*\*|~~)/,"")),n.replaceRange(l+s,{line:d.line,ch:0},{line:d.line,ch:99999999999999}),"bold"==t||"strikethrough"==t?(d.ch-=2,d!==c&&(c.ch-=2)):"italic"==t&&(d.ch-=1,d!==c&&(c.ch-=1))):(a=n.getSelection(),"bold"==t?a=(a=a.split("**").join("")).split("__").join(""):"italic"==t?a=(a=a.split("*").join("")).split("_").join(""):"strikethrough"==t&&(a=a.split("~~").join("")),n.replaceSelection(l+a+s),d.ch+=o.length,c.ch=d.ch+a.length),n.setSelection(d,c),n.focus()}}function _cleanBlock(e){if(!/editor-preview-active/.test(e.getWrapperElement().lastChild.className))for(var t,o=e.getCursor("start"),i=e.getCursor("end"),a=o.line;a<=i.line;a++)t=(t=e.getLine(a)).replace(/^[ ]*([# ]+|\*|-|[> ]+|[0-9]+(.|\)))[ ]*/,""),e.replaceRange(t,{line:a,ch:0},{line:a,ch:99999999999999})}function humanFileSize(e,t){if(Math.abs(e)<1024)return""+e+t[0];var o=0;do{e/=1024,++o}while(Math.abs(e)>=1024&&o=19968?o+=t[i].length:o+=1;return o}var toolbarBuiltInButtons={bold:{name:"bold",action:toggleBold,className:"fa fa-bold",title:"Bold",default:!0},italic:{name:"italic",action:toggleItalic,className:"fa fa-italic",title:"Italic",default:!0},strikethrough:{name:"strikethrough",action:toggleStrikethrough,className:"fa fa-strikethrough",title:"Strikethrough"},heading:{name:"heading",action:toggleHeadingSmaller,className:"fa fa-header fa-heading",title:"Heading",default:!0},"heading-smaller":{name:"heading-smaller",action:toggleHeadingSmaller,className:"fa fa-header fa-heading header-smaller",title:"Smaller Heading"},"heading-bigger":{name:"heading-bigger",action:toggleHeadingBigger,className:"fa fa-header fa-heading header-bigger",title:"Bigger Heading"},"heading-1":{name:"heading-1",action:toggleHeading1,className:"fa fa-header fa-heading header-1",title:"Big Heading"},"heading-2":{name:"heading-2",action:toggleHeading2,className:"fa fa-header fa-heading header-2",title:"Medium Heading"},"heading-3":{name:"heading-3",action:toggleHeading3,className:"fa fa-header fa-heading header-3",title:"Small Heading"},"separator-1":{name:"separator-1"},code:{name:"code",action:toggleCodeBlock,className:"fa fa-code",title:"Code"},quote:{name:"quote",action:toggleBlockquote,className:"fa fa-quote-left",title:"Quote",default:!0},"unordered-list":{name:"unordered-list",action:toggleUnorderedList,className:"fa fa-list-ul",title:"Generic List",default:!0},"ordered-list":{name:"ordered-list",action:toggleOrderedList,className:"fa fa-list-ol",title:"Numbered List",default:!0},"clean-block":{name:"clean-block",action:cleanBlock,className:"fa fa-eraser",title:"Clean block"},"separator-2":{name:"separator-2"},link:{name:"link",action:drawLink,className:"fa fa-link",title:"Create Link",default:!0},image:{name:"image",action:drawImage,className:"fa fa-image",title:"Insert Image",default:!0},"upload-image":{name:"upload-image",action:drawUploadedImage,className:"fa fa-image",title:"Import an image"},table:{name:"table",action:drawTable,className:"fa fa-table",title:"Insert Table"},"horizontal-rule":{name:"horizontal-rule",action:drawHorizontalRule,className:"fa fa-minus",title:"Insert Horizontal Line"},"separator-3":{name:"separator-3"},preview:{name:"preview",action:togglePreview,className:"fa fa-eye",noDisable:!0,title:"Toggle Preview",default:!0},"side-by-side":{name:"side-by-side",action:toggleSideBySide,className:"fa fa-columns",noDisable:!0,noMobile:!0,title:"Toggle Side by Side",default:!0},fullscreen:{name:"fullscreen",action:toggleFullScreen,className:"fa fa-arrows-alt",noDisable:!0,noMobile:!0,title:"Toggle Fullscreen",default:!0},"separator-4":{name:"separator-4"},guide:{name:"guide",action:"https://www.markdownguide.org/basic-syntax/",className:"fa fa-question-circle",noDisable:!0,title:"Markdown Guide",default:!0},"separator-5":{name:"separator-5"},undo:{name:"undo",action:undo,className:"fa fa-undo",noDisable:!0,title:"Undo"},redo:{name:"redo",action:redo,className:"fa fa-repeat fa-redo",noDisable:!0,title:"Redo"}},insertTexts={link:["[","](#url#)"],image:["![](","#url#)"],uploadedImage:["![](#url#)",""],table:["","\n\n| Column 1 | Column 2 | Column 3 |\n| -------- | -------- | -------- |\n| Text | Text | Text |\n\n"],horizontalRule:["","\n\n-----\n\n"]},promptTexts={link:"URL for the link:",image:"URL of the image:"},timeFormat={locale:"en-US",format:{hour:"2-digit",minute:"2-digit"}},blockStyles={bold:"**",code:"```",italic:"*"},imageTexts={sbInit:"Attach files by drag and dropping or pasting from clipboard.",sbOnDragEnter:"Drop image to upload it.",sbOnDrop:"Uploading image #images_names#...",sbProgress:"Uploading #file_name#: #progress#%",sbOnUploaded:"Uploaded #image_name#",sizeUnits:" B, KB, MB"},errorMessages={noFileGiven:"You must select a file.",typeNotAllowed:"This image type is not allowed.",fileTooLarge:"Image #image_name# is too big (#image_size#).\nMaximum file size is #image_max_size#.",importError:"Something went wrong when uploading the image #image_name#."};function EasyMDE(e){(e=e||{}).parent=this;var t=!0;if(!1===e.autoDownloadFontAwesome&&(t=!1),!0!==e.autoDownloadFontAwesome)for(var o=document.styleSheets,i=0;i-1&&(t=!1);if(t){var a=document.createElement("link");a.rel="stylesheet",a.href="https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css",document.getElementsByTagName("head")[0].appendChild(a)}if(e.element)this.element=e.element;else if(null===e.element)return void console.log("EasyMDE: Error. No element was found.");if(void 0===e.toolbar)for(var n in e.toolbar=[],toolbarBuiltInButtons)Object.prototype.hasOwnProperty.call(toolbarBuiltInButtons,n)&&(-1!=n.indexOf("separator-")&&e.toolbar.push("|"),(!0===toolbarBuiltInButtons[n].default||e.showIcons&&e.showIcons.constructor===Array&&-1!=e.showIcons.indexOf(n))&&e.toolbar.push(n));if(Object.prototype.hasOwnProperty.call(e,"previewClass")||(e.previewClass="editor-preview"),Object.prototype.hasOwnProperty.call(e,"status")||(e.status=["autosave","lines","words","cursor"],e.uploadImage&&e.status.unshift("upload-image")),e.previewRender||(e.previewRender=function(e){return this.parent.markdown(e)}),e.parsingConfig=extend({highlightFormatting:!0},e.parsingConfig||{}),e.insertTexts=extend({},insertTexts,e.insertTexts||{}),e.promptTexts=extend({},promptTexts,e.promptTexts||{}),e.blockStyles=extend({},blockStyles,e.blockStyles||{}),null!=e.autosave&&(e.autosave.timeFormat=extend({},timeFormat,e.autosave.timeFormat||{})),e.shortcuts=extend({},shortcuts,e.shortcuts||{}),e.maxHeight=e.maxHeight||void 0,void 0!==e.maxHeight?e.minHeight=e.maxHeight:e.minHeight=e.minHeight||"300px",e.errorCallback=e.errorCallback||function(e){alert(e)},e.uploadImage=e.uploadImage||!1,e.imageMaxSize=e.imageMaxSize||2097152,e.imageAccept=e.imageAccept||"image/png, image/jpeg",e.imageTexts=extend({},imageTexts,e.imageTexts||{}),e.errorMessages=extend({},errorMessages,e.errorMessages||{}),null!=e.autosave&&null!=e.autosave.unique_id&&""!=e.autosave.unique_id&&(e.autosave.uniqueId=e.autosave.unique_id),e.overlayMode&&void 0===e.overlayMode.combine&&(e.overlayMode.combine=!0),this.options=e,this.render(),!e.initialValue||this.options.autosave&&!0===this.options.autosave.foundSavedValue||this.value(e.initialValue),e.uploadImage){var r=this;this.codemirror.on("dragenter",(function(e,t){r.updateStatusBar("upload-image",r.options.imageTexts.sbOnDragEnter),t.stopPropagation(),t.preventDefault()})),this.codemirror.on("dragend",(function(e,t){r.updateStatusBar("upload-image",r.options.imageTexts.sbInit),t.stopPropagation(),t.preventDefault()})),this.codemirror.on("dragleave",(function(e,t){r.updateStatusBar("upload-image",r.options.imageTexts.sbInit),t.stopPropagation(),t.preventDefault()})),this.codemirror.on("dragover",(function(e,t){r.updateStatusBar("upload-image",r.options.imageTexts.sbOnDragEnter),t.stopPropagation(),t.preventDefault()})),this.codemirror.on("drop",(function(t,o){o.stopPropagation(),o.preventDefault(),e.imageUploadFunction?r.uploadImagesUsingCustomFunction(e.imageUploadFunction,o.dataTransfer.files):r.uploadImages(o.dataTransfer.files)})),this.codemirror.on("paste",(function(t,o){e.imageUploadFunction?r.uploadImagesUsingCustomFunction(e.imageUploadFunction,o.clipboardData.files):r.uploadImages(o.clipboardData.files)}))}}function isLocalStorageAvailable(){if("object"!=typeof localStorage)return!1;try{localStorage.setItem("smde_localStorage",1),localStorage.removeItem("smde_localStorage")}catch(e){return!1}return!0}EasyMDE.prototype.uploadImages=function(e,t,o){if(0!==e.length){for(var i=[],a=0;a=2){var i=o[1];if(window.EMDEimagesCache[i])u(t,window.EMDEimagesCache[i]);else{var a=document.createElement("img");a.onload=function(){window.EMDEimagesCache[i]={naturalWidth:a.naturalWidth,naturalHeight:a.naturalHeight,url:i},u(t,window.EMDEimagesCache[i])},a.src=i}}}}))})),this.gui.sideBySide=this.createSideBySide(),this._rendered=this.element;var g=this.codemirror;setTimeout(function(){g.refresh()}.bind(g),0)}function u(e,t){var o,i;e.setAttribute("data-img-src",t.url),e.setAttribute("style","--bg-image:url("+t.url+");--width:"+t.naturalWidth+"px;--height:"+(o=t.naturalWidth,i=t.naturalHeight,othis.options.imageMaxSize)a(n(this.options.errorMessages.fileTooLarge));else{var r=new FormData;r.append("image",e),i.options.imageCSRFToken&&r.append("csrfmiddlewaretoken",i.options.imageCSRFToken);var l=new XMLHttpRequest;l.upload.onprogress=function(t){if(t.lengthComputable){var o=""+Math.round(100*t.loaded/t.total);i.updateStatusBar("upload-image",i.options.imageTexts.sbProgress.replace("#file_name#",e.name).replace("#progress#",o))}},l.open("POST",this.options.imageUploadEndpoint),l.onload=function(){try{var e=JSON.parse(this.responseText)}catch(e){return console.error("EasyMDE: The server did not return a valid json."),void a(n(i.options.errorMessages.importError))}200===this.status&&e&&!e.error&&e.data&&e.data.filePath?t((i.options.imagePathAbsolute?"":window.location.origin+"/")+e.data.filePath):e.error&&e.error in i.options.errorMessages?a(n(i.options.errorMessages[e.error])):e.error?a(n(e.error)):(console.error("EasyMDE: Received an unexpected response after uploading the image."+this.status+" ("+this.statusText+")"),a(n(i.options.errorMessages.importError)))},l.onerror=function(e){console.error("EasyMDE: An unexpected error occurred when trying to upload the image."+e.target.status+" ("+e.target.statusText+")"),a(i.options.errorMessages.importError)},l.send(r)}},EasyMDE.prototype.uploadImageUsingCustomFunction=function(e,t){var o=this;e.apply(this,[t,function(e){afterImageUploaded(o,e)},function(e){var i=function(e){var i=o.options.imageTexts.sizeUnits.split(",");return e.replace("#image_name#",t.name).replace("#image_size#",humanFileSize(t.size,i)).replace("#image_max_size#",humanFileSize(o.options.imageMaxSize,i))}(e);o.updateStatusBar("upload-image",i),setTimeout((function(){o.updateStatusBar("upload-image",o.options.imageTexts.sbInit)}),1e4),o.options.errorCallback(i)}])},EasyMDE.prototype.setPreviewMaxHeight=function(){var e=this.codemirror.getWrapperElement(),t=e.nextSibling,o=parseInt(window.getComputedStyle(e).paddingTop),i=parseInt(window.getComputedStyle(e).borderTopWidth),a=(parseInt(this.options.maxHeight)+2*o+2*i).toString()+"px";t.style.height=a},EasyMDE.prototype.createSideBySide=function(){var e=this.codemirror,t=e.getWrapperElement(),o=t.nextSibling;if(!o||!/editor-preview-side/.test(o.className)){if((o=document.createElement("div")).className="editor-preview-side",this.options.previewClass)if(Array.isArray(this.options.previewClass))for(var i=0;i and licensed under the MIT license: +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +/// +/// + +interface ArrayOneOrMore extends Array { + 0: T +} + +type ToolbarButton = + 'bold' + | 'italic' + | 'quote' + | 'unordered-list' + | 'ordered-list' + | 'link' + | 'image' + | 'strikethrough' + | 'code' + | 'table' + | 'redo' + | 'heading' + | 'undo' + | 'heading-bigger' + | 'heading-smaller' + | 'heading-1' + | 'heading-2' + | 'heading-3' + | 'clean-block' + | 'horizontal-rule' + | 'preview' + | 'side-by-side' + | 'fullscreen' + | 'guide'; + +declare namespace EasyMDE { + + interface TimeFormatOptions { + locale?: string | string[]; + format?: Intl.DateTimeFormatOptions; + } + + interface AutoSaveOptions { + enabled?: boolean; + delay?: number; + submit_delay?: number; + uniqueId: string; + timeFormat?: TimeFormatOptions; + text?: string; + } + + interface BlockStyleOptions { + bold?: string; + code?: string; + italic?: string; + } + + interface InsertTextOptions { + horizontalRule?: ReadonlyArray; + image?: ReadonlyArray; + link?: ReadonlyArray; + table?: ReadonlyArray; + } + + interface ParsingOptions { + allowAtxHeaderWithoutSpace?: boolean; + strikethrough?: boolean; + underscoresBreakWords?: boolean; + } + + interface PromptTexts { + image?: string; + link?: string; + } + + interface RenderingOptions { + codeSyntaxHighlighting?: boolean; + hljs?: any; + markedOptions?: marked.MarkedOptions; + sanitizerFunction?: (html: string) => string; + singleLineBreaks?: boolean; + } + + interface Shortcuts { + [action: string]: string | undefined | null; + + toggleBlockquote?: string | null; + toggleBold?: string | null; + cleanBlock?: string | null; + toggleHeadingSmaller?: string | null; + toggleItalic?: string | null; + drawLink?: string | null; + toggleUnorderedList?: string | null; + togglePreview?: string | null; + toggleCodeBlock?: string | null; + drawImage?: string | null; + toggleOrderedList?: string | null; + toggleHeadingBigger?: string | null; + toggleSideBySide?: string | null; + toggleFullScreen?: string | null; + } + + interface StatusBarItem { + className: string; + defaultValue: (element: HTMLElement) => void; + onUpdate: (element: HTMLElement) => void; + } + + interface ToolbarDropdownIcon { + name: string; + children: ArrayOneOrMore; + className: string; + title: string; + noDisable?: boolean; + noMobile?: boolean; + } + + interface ToolbarIcon { + name: string; + action: string | ((editor: EasyMDE) => void); + className: string; + title: string; + noDisable?: boolean; + noMobile?: boolean; + icon?: string; + } + + interface ImageTextsOptions { + sbInit?: string; + sbOnDragEnter?: string; + sbOnDrop?: string; + sbProgress?: string; + sbOnUploaded?: string; + sizeUnits?: string; + } + + interface ImageErrorTextsOptions { + noFileGiven?: string; + typeNotAllowed?: string; + fileTooLarge?: string; + importError?: string; + } + + interface OverlayModeOptions { + mode: CodeMirror.Mode + combine?: boolean + } + + interface Options { + autoDownloadFontAwesome?: boolean; + autofocus?: boolean; + autosave?: AutoSaveOptions; + autoRefresh?: boolean | { delay: number }; + blockStyles?: BlockStyleOptions; + element?: HTMLElement; + forceSync?: boolean; + hideIcons?: ReadonlyArray; + indentWithTabs?: boolean; + initialValue?: string; + insertTexts?: InsertTextOptions; + lineNumbers?: boolean; + lineWrapping?: boolean; + minHeight?: string; + maxHeight?: string; + parsingConfig?: ParsingOptions; + placeholder?: string; + previewClass?: string | ReadonlyArray; + previewImagesInEditor?: boolean; + previewRender?: (markdownPlaintext: string, previewElement: HTMLElement) => string; + promptURLs?: boolean; + renderingConfig?: RenderingOptions; + shortcuts?: Shortcuts; + showIcons?: ReadonlyArray; + spellChecker?: boolean; + inputStyle?: 'textarea' | 'contenteditable'; + nativeSpellcheck?: boolean; + sideBySideFullscreen?: boolean; + status?: boolean | ReadonlyArray; + styleSelectedText?: boolean; + tabSize?: number; + toolbar?: boolean | ReadonlyArray<'|' | ToolbarButton | ToolbarIcon | ToolbarDropdownIcon>; + toolbarTips?: boolean; + onToggleFullScreen?: (goingIntoFullScreen: boolean) => void; + theme?: string; + scrollbarStyle?: string; + + uploadImage?: boolean; + imageMaxSize?: number; + imageAccept?: string; + imageUploadFunction?: (file: File, onSuccess: (url: string) => void, onError: (error: string) => void) => void; + imageUploadEndpoint?: string; + imagePathAbsolute?: boolean; + imageCSRFToken?: string; + imageTexts?: ImageTextsOptions; + errorMessages?: ImageErrorTextsOptions; + errorCallback?: (errorMessage: string) => void; + + promptTexts?: PromptTexts; + syncSideBySidePreviewScroll?: boolean; + + overlayMode?: OverlayModeOptions + } +} + +declare class EasyMDE { + constructor(options?: EasyMDE.Options); + + value(): string; + value(val: string): void; + + codemirror: CodeMirror.Editor; + + toTextArea(): void; + + isPreviewActive(): boolean; + + isSideBySideActive(): boolean; + + isFullscreenActive(): boolean; + + clearAutosavedValue(): void; + + static toggleBold: (editor: EasyMDE) => void; + static toggleItalic: (editor: EasyMDE) => void; + static toggleStrikethrough: (editor: EasyMDE) => void; + static toggleHeadingSmaller: (editor: EasyMDE) => void; + static toggleHeadingBigger: (editor: EasyMDE) => void; + static toggleHeading1: (editor: EasyMDE) => void; + static toggleHeading2: (editor: EasyMDE) => void; + static toggleHeading3: (editor: EasyMDE) => void; + static toggleCodeBlock: (editor: EasyMDE) => void; + static toggleBlockquote: (editor: EasyMDE) => void; + static toggleUnorderedList: (editor: EasyMDE) => void; + static toggleOrderedList: (editor: EasyMDE) => void; + static cleanBlock: (editor: EasyMDE) => void; + static drawLink: (editor: EasyMDE) => void; + static drawImage: (editor: EasyMDE) => void; + static drawUploadedImage: (editor: EasyMDE) => void; + static drawTable: (editor: EasyMDE) => void; + static drawHorizontalRule: (editor: EasyMDE) => void; + static togglePreview: (editor: EasyMDE) => void; + static toggleSideBySide: (editor: EasyMDE) => void; + static toggleFullScreen: (editor: EasyMDE) => void; + static undo: (editor: EasyMDE) => void; + static redo: (editor: EasyMDE) => void; +} + +export as namespace EasyMDE; +export = EasyMDE; diff --git a/PSC.Blazor.Components.MarkdownEditor/wwwroot/js/easymde.min.js b/PSC.Blazor.Components.MarkdownEditor/wwwroot/js/easymde.min.js new file mode 100644 index 0000000..180ed1c --- /dev/null +++ b/PSC.Blazor.Components.MarkdownEditor/wwwroot/js/easymde.min.js @@ -0,0 +1,7 @@ +/** + * easymde v2.15.0 + * Copyright Jeroen Akkerman + * @link https://github.com/ionaru/easy-markdown-editor + * @license MIT + */ +!function (e) { if ("object" == typeof exports && "undefined" != typeof module) module.exports = e(); else if ("function" == typeof define && define.amd) define([], e); else { ("undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self ? self : this).EasyMDE = e() } }((function () { return function e(t, n, r) { function i(a, l) { if (!n[a]) { if (!t[a]) { var s = "function" == typeof require && require; if (!l && s) return s(a, !0); if (o) return o(a, !0); var u = new Error("Cannot find module '" + a + "'"); throw u.code = "MODULE_NOT_FOUND", u } var c = n[a] = { exports: {} }; t[a][0].call(c.exports, (function (e) { return i(t[a][1][e] || e) }), c, c.exports, e, t, n, r) } return n[a].exports } for (var o = "function" == typeof require && require, a = 0; a < r.length; a++)i(r[a]); return i }({ 1: [function (e, t, n) { }, {}], 2: [function (e, t, n) { "use strict"; var r = e("typo-js"); function i(e) { "function" == typeof (e = e || {}).codeMirrorInstance && "function" == typeof e.codeMirrorInstance.defineMode ? (String.prototype.includes || (String.prototype.includes = function () { return -1 !== String.prototype.indexOf.apply(this, arguments) }), e.codeMirrorInstance.defineMode("spell-checker", (function (t) { if (!i.aff_loading) { i.aff_loading = !0; var n = new XMLHttpRequest; n.open("GET", "https://cdn.jsdelivr.net/codemirror.spell-checker/latest/en_US.aff", !0), n.onload = function () { 4 === n.readyState && 200 === n.status && (i.aff_data = n.responseText, i.num_loaded++, 2 == i.num_loaded && (i.typo = new r("en_US", i.aff_data, i.dic_data, { platform: "any" }))) }, n.send(null) } if (!i.dic_loading) { i.dic_loading = !0; var o = new XMLHttpRequest; o.open("GET", "https://cdn.jsdelivr.net/codemirror.spell-checker/latest/en_US.dic", !0), o.onload = function () { 4 === o.readyState && 200 === o.status && (i.dic_data = o.responseText, i.num_loaded++, 2 == i.num_loaded && (i.typo = new r("en_US", i.aff_data, i.dic_data, { platform: "any" }))) }, o.send(null) } var a = '!"#$%&()*+,-./:;<=>?@[\\]^_`{|}~ ', l = { token: function (e) { var t = e.peek(), n = ""; if (a.includes(t)) return e.next(), null; for (; null != (t = e.peek()) && !a.includes(t);)n += t, e.next(); return i.typo && !i.typo.check(n) ? "spell-error" : null } }, s = e.codeMirrorInstance.getMode(t, t.backdrop || "text/plain"); return e.codeMirrorInstance.overlayMode(s, l, !0) }))) : console.log("CodeMirror Spell Checker: You must provide an instance of CodeMirror via the option `codeMirrorInstance`") } i.num_loaded = 0, i.aff_loading = !1, i.dic_loading = !1, i.aff_data = "", i.dic_data = "", i.typo, t.exports = i }, { "typo-js": 16 }], 3: [function (e, t, n) { (function (e) { "use strict"; function t(t, n) { clearTimeout(n.timeout), e.off(window, "mouseup", n.hurry), e.off(window, "keyup", n.hurry) } e.defineOption("autoRefresh", !1, (function (n, r) { n.state.autoRefresh && (t(0, n.state.autoRefresh), n.state.autoRefresh = null), r && 0 == n.display.wrapper.offsetHeight && function (n, r) { function i() { n.display.wrapper.offsetHeight ? (t(0, r), n.display.lastWrapHeight != n.display.wrapper.clientHeight && n.refresh()) : r.timeout = setTimeout(i, r.delay) } r.timeout = setTimeout(i, r.delay), r.hurry = function () { clearTimeout(r.timeout), r.timeout = setTimeout(i, 50) }, e.on(window, "mouseup", r.hurry), e.on(window, "keyup", r.hurry) }(n, n.state.autoRefresh = { delay: r.delay || 250 }) })) })("object" == typeof n && "object" == typeof t ? e("../../lib/codemirror") : CodeMirror) }, { "../../lib/codemirror": 10 }], 4: [function (e, t, n) { (function (e) { "use strict"; e.defineOption("fullScreen", !1, (function (t, n, r) { r == e.Init && (r = !1), !r != !n && (n ? function (e) { var t = e.getWrapperElement(); e.state.fullScreenRestore = { scrollTop: window.pageYOffset, scrollLeft: window.pageXOffset, width: t.style.width, height: t.style.height }, t.style.width = "", t.style.height = "auto", t.className += " CodeMirror-fullscreen", document.documentElement.style.overflow = "hidden", e.refresh() }(t) : function (e) { var t = e.getWrapperElement(); t.className = t.className.replace(/\s*CodeMirror-fullscreen\b/, ""), document.documentElement.style.overflow = ""; var n = e.state.fullScreenRestore; t.style.width = n.width, t.style.height = n.height, window.scrollTo(n.scrollLeft, n.scrollTop), e.refresh() }(t)) })) })("object" == typeof n && "object" == typeof t ? e("../../lib/codemirror") : CodeMirror) }, { "../../lib/codemirror": 10 }], 5: [function (e, t, n) { (function (e) { function t(e) { e.state.placeholder && (e.state.placeholder.parentNode.removeChild(e.state.placeholder), e.state.placeholder = null) } function n(e) { t(e); var n = e.state.placeholder = document.createElement("pre"); n.style.cssText = "height: 0; overflow: visible", n.style.direction = e.getOption("direction"), n.className = "CodeMirror-placeholder CodeMirror-line-like"; var r = e.getOption("placeholder"); "string" == typeof r && (r = document.createTextNode(r)), n.appendChild(r), e.display.lineSpace.insertBefore(n, e.display.lineSpace.firstChild) } function r(e) { o(e) && n(e) } function i(e) { var r = e.getWrapperElement(), i = o(e); r.className = r.className.replace(" CodeMirror-empty", "") + (i ? " CodeMirror-empty" : ""), i ? n(e) : t(e) } function o(e) { return 1 === e.lineCount() && "" === e.getLine(0) } e.defineOption("placeholder", "", (function (o, a, l) { var s = l && l != e.Init; if (a && !s) o.on("blur", r), o.on("change", i), o.on("swapDoc", i), e.on(o.getInputField(), "compositionupdate", o.state.placeholderCompose = function () { !function (e) { setTimeout((function () { var r = !1; if (1 == e.lineCount()) { var i = e.getInputField(); r = "TEXTAREA" == i.nodeName ? !e.getLine(0).length : !/[^\u200b]/.test(i.querySelector(".CodeMirror-line").textContent) } r ? n(e) : t(e) }), 20) }(o) }), i(o); else if (!a && s) { o.off("blur", r), o.off("change", i), o.off("swapDoc", i), e.off(o.getInputField(), "compositionupdate", o.state.placeholderCompose), t(o); var u = o.getWrapperElement(); u.className = u.className.replace(" CodeMirror-empty", "") } a && !o.hasFocus() && r(o) })) })("object" == typeof n && "object" == typeof t ? e("../../lib/codemirror") : CodeMirror) }, { "../../lib/codemirror": 10 }], 6: [function (e, t, n) { (function (e) { "use strict"; var t = /^(\s*)(>[> ]*|[*+-] \[[x ]\]\s|[*+-]\s|(\d+)([.)]))(\s*)/, n = /^(\s*)(>[> ]*|[*+-] \[[x ]\]|[*+-]|(\d+)[.)])(\s*)$/, r = /[*+-]\s/; function i(e, n) { var r = n.line, i = 0, o = 0, a = t.exec(e.getLine(r)), l = a[1]; do { var s = r + (i += 1), u = e.getLine(s), c = t.exec(u); if (c) { var d = c[1], h = parseInt(a[3], 10) + i - o, f = parseInt(c[3], 10), p = f; if (l !== d || isNaN(f)) { if (l.length > d.length) return; if (l.length < d.length && 1 === i) return; o += 1 } else h === f && (p = f + 1), h > f && (p = h + 1), e.replaceRange(u.replace(t, d + p + c[4] + c[5]), { line: s, ch: 0 }, { line: s, ch: u.length }) } } while (c) } e.commands.newlineAndIndentContinueMarkdownList = function (o) { if (o.getOption("disableInput")) return e.Pass; for (var a = o.listSelections(), l = [], s = 0; s < a.length; s++) { var u = a[s].head, c = o.getStateAfter(u.line), d = e.innerMode(o.getMode(), c); if ("markdown" !== d.mode.name) return void o.execCommand("newlineAndIndent"); var h = !1 !== (c = d.state).list, f = 0 !== c.quote, p = o.getLine(u.line), m = t.exec(p), g = /^\s*$/.test(p.slice(0, u.ch)); if (!a[s].empty() || !h && !f || !m || g) return void o.execCommand("newlineAndIndent"); if (n.test(p)) { var v = f && />\s*$/.test(p), x = !/>\s*$/.test(p); (v || x) && o.replaceRange("", { line: u.line, ch: 0 }, { line: u.line, ch: u.ch + 1 }), l[s] = "\n" } else { var y = m[1], b = m[5], D = !(r.test(m[2]) || m[2].indexOf(">") >= 0), C = D ? parseInt(m[3], 10) + 1 + m[4] : m[2].replace("x", " "); l[s] = "\n" + y + C + b, D && i(o, u) } } o.replaceSelections(l) } })("object" == typeof n && "object" == typeof t ? e("../../lib/codemirror") : CodeMirror) }, { "../../lib/codemirror": 10 }], 7: [function (e, t, n) { (function (e) { "use strict"; e.overlayMode = function (t, n, r) { return { startState: function () { return { base: e.startState(t), overlay: e.startState(n), basePos: 0, baseCur: null, overlayPos: 0, overlayCur: null, streamSeen: null } }, copyState: function (r) { return { base: e.copyState(t, r.base), overlay: e.copyState(n, r.overlay), basePos: r.basePos, baseCur: null, overlayPos: r.overlayPos, overlayCur: null } }, token: function (e, i) { return (e != i.streamSeen || Math.min(i.basePos, i.overlayPos) < e.start) && (i.streamSeen = e, i.basePos = i.overlayPos = e.start), e.start == i.basePos && (i.baseCur = t.token(e, i.base), i.basePos = e.pos), e.start == i.overlayPos && (e.pos = e.start, i.overlayCur = n.token(e, i.overlay), i.overlayPos = e.pos), e.pos = Math.min(i.basePos, i.overlayPos), null == i.overlayCur ? i.baseCur : null != i.baseCur && i.overlay.combineTokens || r && null == i.overlay.combineTokens ? i.baseCur + " " + i.overlayCur : i.overlayCur }, indent: t.indent && function (e, n, r) { return t.indent(e.base, n, r) }, electricChars: t.electricChars, innerMode: function (e) { return { state: e.base, mode: t } }, blankLine: function (e) { var i, o; return t.blankLine && (i = t.blankLine(e.base)), n.blankLine && (o = n.blankLine(e.overlay)), null == o ? i : r && null != i ? i + " " + o : o } } } })("object" == typeof n && "object" == typeof t ? e("../../lib/codemirror") : CodeMirror) }, { "../../lib/codemirror": 10 }], 8: [function (e, t, n) { (function (e) { "use strict"; var t, n, r = e.Pos; function i(e, t) { for (var n = function (e) { var t = e.flags; return null != t ? t : (e.ignoreCase ? "i" : "") + (e.global ? "g" : "") + (e.multiline ? "m" : "") }(e), r = n, i = 0; i < t.length; i++)-1 == r.indexOf(t.charAt(i)) && (r += t.charAt(i)); return n == r ? e : new RegExp(e.source, r) } function o(e) { return /\\s|\\n|\n|\\W|\\D|\[\^/.test(e.source) } function a(e, t, n) { t = i(t, "g"); for (var o = n.line, a = n.ch, l = e.lastLine(); o <= l; o++, a = 0) { t.lastIndex = a; var s = e.getLine(o), u = t.exec(s); if (u) return { from: r(o, u.index), to: r(o, u.index + u[0].length), match: u } } } function l(e, t, n) { if (!o(t)) return a(e, t, n); t = i(t, "gm"); for (var l, s = 1, u = n.line, c = e.lastLine(); u <= c;) { for (var d = 0; d < s && !(u > c); d++) { var h = e.getLine(u++); l = null == l ? h : l + "\n" + h } s *= 2, t.lastIndex = n.ch; var f = t.exec(l); if (f) { var p = l.slice(0, f.index).split("\n"), m = f[0].split("\n"), g = n.line + p.length - 1, v = p[p.length - 1].length; return { from: r(g, v), to: r(g + m.length - 1, 1 == m.length ? v + m[0].length : m[m.length - 1].length), match: f } } } } function s(e, t, n) { for (var r, i = 0; i <= e.length;) { t.lastIndex = i; var o = t.exec(e); if (!o) break; var a = o.index + o[0].length; if (a > e.length - n) break; (!r || a > r.index + r[0].length) && (r = o), i = o.index + 1 } return r } function u(e, t, n) { t = i(t, "g"); for (var o = n.line, a = n.ch, l = e.firstLine(); o >= l; o--, a = -1) { var u = e.getLine(o), c = s(u, t, a < 0 ? 0 : u.length - a); if (c) return { from: r(o, c.index), to: r(o, c.index + c[0].length), match: c } } } function c(e, t, n) { if (!o(t)) return u(e, t, n); t = i(t, "gm"); for (var a, l = 1, c = e.getLine(n.line).length - n.ch, d = n.line, h = e.firstLine(); d >= h;) { for (var f = 0; f < l && d >= h; f++) { var p = e.getLine(d--); a = null == a ? p : p + "\n" + a } l *= 2; var m = s(a, t, c); if (m) { var g = a.slice(0, m.index).split("\n"), v = m[0].split("\n"), x = d + g.length, y = g[g.length - 1].length; return { from: r(x, y), to: r(x + v.length - 1, 1 == v.length ? y + v[0].length : v[v.length - 1].length), match: m } } } } function d(e, t, n, r) { if (e.length == t.length) return n; for (var i = 0, o = n + Math.max(0, e.length - t.length); ;) { if (i == o) return i; var a = i + o >> 1, l = r(e.slice(0, a)).length; if (l == n) return a; l > n ? o = a : i = a + 1 } } function h(e, i, o, a) { if (!i.length) return null; var l = a ? t : n, s = l(i).split(/\r|\n\r?/); e: for (var u = o.line, c = o.ch, h = e.lastLine() + 1 - s.length; u <= h; u++, c = 0) { var f = e.getLine(u).slice(c), p = l(f); if (1 == s.length) { var m = p.indexOf(s[0]); if (-1 == m) continue e; return o = d(f, p, m, l) + c, { from: r(u, d(f, p, m, l) + c), to: r(u, d(f, p, m + s[0].length, l) + c) } } var g = p.length - s[0].length; if (p.slice(g) == s[0]) { for (var v = 1; v < s.length - 1; v++)if (l(e.getLine(u + v)) != s[v]) continue e; var x = e.getLine(u + s.length - 1), y = l(x), b = s[s.length - 1]; if (y.slice(0, b.length) == b) return { from: r(u, d(f, p, g, l) + c), to: r(u + s.length - 1, d(x, y, b.length, l)) } } } } function f(e, i, o, a) { if (!i.length) return null; var l = a ? t : n, s = l(i).split(/\r|\n\r?/); e: for (var u = o.line, c = o.ch, h = e.firstLine() - 1 + s.length; u >= h; u--, c = -1) { var f = e.getLine(u); c > -1 && (f = f.slice(0, c)); var p = l(f); if (1 == s.length) { var m = p.lastIndexOf(s[0]); if (-1 == m) continue e; return { from: r(u, d(f, p, m, l)), to: r(u, d(f, p, m + s[0].length, l)) } } var g = s[s.length - 1]; if (p.slice(0, g.length) == g) { var v = 1; for (o = u - s.length + 1; v < s.length - 1; v++)if (l(e.getLine(o + v)) != s[v]) continue e; var x = e.getLine(u + 1 - s.length), y = l(x); if (y.slice(y.length - s[0].length) == s[0]) return { from: r(u + 1 - s.length, d(x, y, x.length - s[0].length, l)), to: r(u, d(f, p, g.length, l)) } } } } function p(e, t, n, o) { var s; this.atOccurrence = !1, this.doc = e, n = n ? e.clipPos(n) : r(0, 0), this.pos = { from: n, to: n }, "object" == typeof o ? s = o.caseFold : (s = o, o = null), "string" == typeof t ? (null == s && (s = !1), this.matches = function (n, r) { return (n ? f : h)(e, t, r, s) }) : (t = i(t, "gm"), o && !1 === o.multiline ? this.matches = function (n, r) { return (n ? u : a)(e, t, r) } : this.matches = function (n, r) { return (n ? c : l)(e, t, r) }) } String.prototype.normalize ? (t = function (e) { return e.normalize("NFD").toLowerCase() }, n = function (e) { return e.normalize("NFD") }) : (t = function (e) { return e.toLowerCase() }, n = function (e) { return e }), p.prototype = { findNext: function () { return this.find(!1) }, findPrevious: function () { return this.find(!0) }, find: function (t) { for (var n = this.matches(t, this.doc.clipPos(t ? this.pos.from : this.pos.to)); n && 0 == e.cmpPos(n.from, n.to);)t ? n.from.ch ? n.from = r(n.from.line, n.from.ch - 1) : n = n.from.line == this.doc.firstLine() ? null : this.matches(t, this.doc.clipPos(r(n.from.line - 1))) : n.to.ch < this.doc.getLine(n.to.line).length ? n.to = r(n.to.line, n.to.ch + 1) : n = n.to.line == this.doc.lastLine() ? null : this.matches(t, r(n.to.line + 1, 0)); if (n) return this.pos = n, this.atOccurrence = !0, this.pos.match || !0; var i = r(t ? this.doc.firstLine() : this.doc.lastLine() + 1, 0); return this.pos = { from: i, to: i }, this.atOccurrence = !1 }, from: function () { if (this.atOccurrence) return this.pos.from }, to: function () { if (this.atOccurrence) return this.pos.to }, replace: function (t, n) { if (this.atOccurrence) { var i = e.splitLines(t); this.doc.replaceRange(i, this.pos.from, this.pos.to, n), this.pos.to = r(this.pos.from.line + i.length - 1, i[i.length - 1].length + (1 == i.length ? this.pos.from.ch : 0)) } } }, e.defineExtension("getSearchCursor", (function (e, t, n) { return new p(this.doc, e, t, n) })), e.defineDocExtension("getSearchCursor", (function (e, t, n) { return new p(this, e, t, n) })), e.defineExtension("selectMatches", (function (t, n) { for (var r = [], i = this.getSearchCursor(t, this.getCursor("from"), n); i.findNext() && !(e.cmpPos(i.to(), this.getCursor("to")) > 0);)r.push({ anchor: i.from(), head: i.to() }); r.length && this.setSelections(r, 0) })) })("object" == typeof n && "object" == typeof t ? e("../../lib/codemirror") : CodeMirror) }, { "../../lib/codemirror": 10 }], 9: [function (e, t, n) { (function (e) { "use strict"; function t(e) { e.state.markedSelection && e.operation((function () { !function (e) { if (!e.somethingSelected()) return a(e); if (e.listSelections().length > 1) return l(e); var t = e.getCursor("start"), n = e.getCursor("end"), r = e.state.markedSelection; if (!r.length) return o(e, t, n); var s = r[0].find(), u = r[r.length - 1].find(); if (!s || !u || n.line - t.line <= 8 || i(t, u.to) >= 0 || i(n, s.from) <= 0) return l(e); for (; i(t, s.from) > 0;)r.shift().clear(), s = r[0].find(); for (i(t, s.from) < 0 && (s.to.line - t.line < 8 ? (r.shift().clear(), o(e, t, s.to, 0)) : o(e, t, s.from, 0)); i(n, u.to) < 0;)r.pop().clear(), u = r[r.length - 1].find(); i(n, u.to) > 0 && (n.line - u.from.line < 8 ? (r.pop().clear(), o(e, u.from, n)) : o(e, u.to, n)) }(e) })) } function n(e) { e.state.markedSelection && e.state.markedSelection.length && e.operation((function () { a(e) })) } e.defineOption("styleSelectedText", !1, (function (r, i, o) { var s = o && o != e.Init; i && !s ? (r.state.markedSelection = [], r.state.markedSelectionStyle = "string" == typeof i ? i : "CodeMirror-selectedtext", l(r), r.on("cursorActivity", t), r.on("change", n)) : !i && s && (r.off("cursorActivity", t), r.off("change", n), a(r), r.state.markedSelection = r.state.markedSelectionStyle = null) })); var r = e.Pos, i = e.cmpPos; function o(e, t, n, o) { if (0 != i(t, n)) for (var a = e.state.markedSelection, l = e.state.markedSelectionStyle, s = t.line; ;) { var u = s == t.line ? t : r(s, 0), c = s + 8, d = c >= n.line, h = d ? n : r(c, 0), f = e.markText(u, h, { className: l }); if (null == o ? a.push(f) : a.splice(o++, 0, f), d) break; s = c } } function a(e) { for (var t = e.state.markedSelection, n = 0; n < t.length; ++n)t[n].clear(); t.length = 0 } function l(e) { a(e); for (var t = e.listSelections(), n = 0; n < t.length; n++)o(e, t[n].from(), t[n].to()) } })("object" == typeof n && "object" == typeof t ? e("../../lib/codemirror") : CodeMirror) }, { "../../lib/codemirror": 10 }], 10: [function (e, t, n) { !function (e, r) { "object" == typeof n && void 0 !== t ? t.exports = r() : (e = e || self).CodeMirror = r() }(this, (function () { "use strict"; var e = navigator.userAgent, t = navigator.platform, n = /gecko\/\d/i.test(e), r = /MSIE \d/.test(e), i = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(e), o = /Edge\/(\d+)/.exec(e), a = r || i || o, l = a && (r ? document.documentMode || 6 : +(o || i)[1]), s = !o && /WebKit\//.test(e), u = s && /Qt\/\d+\.\d+/.test(e), c = !o && /Chrome\//.test(e), d = /Opera\//.test(e), h = /Apple Computer/.test(navigator.vendor), f = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(e), p = /PhantomJS/.test(e), m = h && (/Mobile\/\w+/.test(e) || navigator.maxTouchPoints > 2), g = /Android/.test(e), v = m || g || /webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(e), x = m || /Mac/.test(t), y = /\bCrOS\b/.test(e), b = /win/i.test(t), D = d && e.match(/Version\/(\d*\.\d*)/); D && (D = Number(D[1])), D && D >= 15 && (d = !1, s = !0); var C = x && (u || d && (null == D || D < 12.11)), w = n || a && l >= 9; function k(e) { return new RegExp("(^|\\s)" + e + "(?:$|\\s)\\s*") } var S, F = function (e, t) { var n = e.className, r = k(t).exec(n); if (r) { var i = n.slice(r.index + r[0].length); e.className = n.slice(0, r.index) + (i ? r[1] + i : "") } }; function A(e) { for (var t = e.childNodes.length; t > 0; --t)e.removeChild(e.firstChild); return e } function E(e, t) { return A(e).appendChild(t) } function T(e, t, n, r) { var i = document.createElement(e); if (n && (i.className = n), r && (i.style.cssText = r), "string" == typeof t) i.appendChild(document.createTextNode(t)); else if (t) for (var o = 0; o < t.length; ++o)i.appendChild(t[o]); return i } function L(e, t, n, r) { var i = T(e, t, n, r); return i.setAttribute("role", "presentation"), i } function M(e, t) { if (3 == t.nodeType && (t = t.parentNode), e.contains) return e.contains(t); do { if (11 == t.nodeType && (t = t.host), t == e) return !0 } while (t = t.parentNode) } function B() { var e; try { e = document.activeElement } catch (t) { e = document.body || null } for (; e && e.shadowRoot && e.shadowRoot.activeElement;)e = e.shadowRoot.activeElement; return e } function N(e, t) { var n = e.className; k(t).test(n) || (e.className += (n ? " " : "") + t) } function O(e, t) { for (var n = e.split(" "), r = 0; r < n.length; r++)n[r] && !k(n[r]).test(t) && (t += " " + n[r]); return t } S = document.createRange ? function (e, t, n, r) { var i = document.createRange(); return i.setEnd(r || e, n), i.setStart(e, t), i } : function (e, t, n) { var r = document.body.createTextRange(); try { r.moveToElementText(e.parentNode) } catch (e) { return r } return r.collapse(!0), r.moveEnd("character", n), r.moveStart("character", t), r }; var I = function (e) { e.select() }; function z(e) { var t = Array.prototype.slice.call(arguments, 1); return function () { return e.apply(null, t) } } function H(e, t, n) { for (var r in t || (t = {}), e) !e.hasOwnProperty(r) || !1 === n && t.hasOwnProperty(r) || (t[r] = e[r]); return t } function R(e, t, n, r, i) { null == t && -1 == (t = e.search(/[^\s\u00a0]/)) && (t = e.length); for (var o = r || 0, a = i || 0; ;) { var l = e.indexOf("\t", o); if (l < 0 || l >= t) return a + (t - o); a += l - o, a += n - a % n, o = l + 1 } } m ? I = function (e) { e.selectionStart = 0, e.selectionEnd = e.value.length } : a && (I = function (e) { try { e.select() } catch (e) { } }); var P = function () { this.id = null, this.f = null, this.time = 0, this.handler = z(this.onTimeout, this) }; function _(e, t) { for (var n = 0; n < e.length; ++n)if (e[n] == t) return n; return -1 } P.prototype.onTimeout = function (e) { e.id = 0, e.time <= +new Date ? e.f() : setTimeout(e.handler, e.time - +new Date) }, P.prototype.set = function (e, t) { this.f = t; var n = +new Date + e; (!this.id || n < this.time) && (clearTimeout(this.id), this.id = setTimeout(this.handler, e), this.time = n) }; var W = { toString: function () { return "CodeMirror.Pass" } }, j = { scroll: !1 }, q = { origin: "*mouse" }, U = { origin: "+move" }; function $(e, t, n) { for (var r = 0, i = 0; ;) { var o = e.indexOf("\t", r); -1 == o && (o = e.length); var a = o - r; if (o == e.length || i + a >= t) return r + Math.min(a, t - i); if (i += o - r, r = o + 1, (i += n - i % n) >= t) return r } } var G = [""]; function V(e) { for (; G.length <= e;)G.push(K(G) + " "); return G[e] } function K(e) { return e[e.length - 1] } function X(e, t) { for (var n = [], r = 0; r < e.length; r++)n[r] = t(e[r], r); return n } function Z() { } function Y(e, t) { var n; return Object.create ? n = Object.create(e) : (Z.prototype = e, n = new Z), t && H(t, n), n } var Q = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/; function J(e) { return /\w/.test(e) || e > "€" && (e.toUpperCase() != e.toLowerCase() || Q.test(e)) } function ee(e, t) { return t ? !!(t.source.indexOf("\\w") > -1 && J(e)) || t.test(e) : J(e) } function te(e) { for (var t in e) if (e.hasOwnProperty(t) && e[t]) return !1; return !0 } var ne = /[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\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\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\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\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/; function re(e) { return e.charCodeAt(0) >= 768 && ne.test(e) } function ie(e, t, n) { for (; (n < 0 ? t > 0 : t < e.length) && re(e.charAt(t));)t += n; return t } function oe(e, t, n) { for (var r = t > n ? -1 : 1; ;) { if (t == n) return t; var i = (t + n) / 2, o = r < 0 ? Math.ceil(i) : Math.floor(i); if (o == t) return e(o) ? t : n; e(o) ? n = o : t = o + r } } var ae = null; function le(e, t, n) { var r; ae = null; for (var i = 0; i < e.length; ++i) { var o = e[i]; if (o.from < t && o.to > t) return i; o.to == t && (o.from != o.to && "before" == n ? r = i : ae = i), o.from == t && (o.from != o.to && "before" != n ? r = i : ae = i) } return null != r ? r : ae } var se = function () { var e = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/, t = /[stwN]/, n = /[LRr]/, r = /[Lb1n]/, i = /[1n]/; function o(e, t, n) { this.level = e, this.from = t, this.to = n } return function (a, l) { var s = "ltr" == l ? "L" : "R"; if (0 == a.length || "ltr" == l && !e.test(a)) return !1; for (var u, c = a.length, d = [], h = 0; h < c; ++h)d.push((u = a.charCodeAt(h)) <= 247 ? "bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN".charAt(u) : 1424 <= u && u <= 1524 ? "R" : 1536 <= u && u <= 1785 ? "nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111".charAt(u - 1536) : 1774 <= u && u <= 2220 ? "r" : 8192 <= u && u <= 8203 ? "w" : 8204 == u ? "b" : "L"); for (var f = 0, p = s; f < c; ++f) { var m = d[f]; "m" == m ? d[f] = p : p = m } for (var g = 0, v = s; g < c; ++g) { var x = d[g]; "1" == x && "r" == v ? d[g] = "n" : n.test(x) && (v = x, "r" == x && (d[g] = "R")) } for (var y = 1, b = d[0]; y < c - 1; ++y) { var D = d[y]; "+" == D && "1" == b && "1" == d[y + 1] ? d[y] = "1" : "," != D || b != d[y + 1] || "1" != b && "n" != b || (d[y] = b), b = D } for (var C = 0; C < c; ++C) { var w = d[C]; if ("," == w) d[C] = "N"; else if ("%" == w) { var k = void 0; for (k = C + 1; k < c && "%" == d[k]; ++k); for (var S = C && "!" == d[C - 1] || k < c && "1" == d[k] ? "1" : "N", F = C; F < k; ++F)d[F] = S; C = k - 1 } } for (var A = 0, E = s; A < c; ++A) { var T = d[A]; "L" == E && "1" == T ? d[A] = "L" : n.test(T) && (E = T) } for (var L = 0; L < c; ++L)if (t.test(d[L])) { var M = void 0; for (M = L + 1; M < c && t.test(d[M]); ++M); for (var B = "L" == (L ? d[L - 1] : s), N = B == ("L" == (M < c ? d[M] : s)) ? B ? "L" : "R" : s, O = L; O < M; ++O)d[O] = N; L = M - 1 } for (var I, z = [], H = 0; H < c;)if (r.test(d[H])) { var R = H; for (++H; H < c && r.test(d[H]); ++H); z.push(new o(0, R, H)) } else { var P = H, _ = z.length, W = "rtl" == l ? 1 : 0; for (++H; H < c && "L" != d[H]; ++H); for (var j = P; j < H;)if (i.test(d[j])) { P < j && (z.splice(_, 0, new o(1, P, j)), _ += W); var q = j; for (++j; j < H && i.test(d[j]); ++j); z.splice(_, 0, new o(2, q, j)), _ += W, P = j } else ++j; P < H && z.splice(_, 0, new o(1, P, H)) } return "ltr" == l && (1 == z[0].level && (I = a.match(/^\s+/)) && (z[0].from = I[0].length, z.unshift(new o(0, 0, I[0].length))), 1 == K(z).level && (I = a.match(/\s+$/)) && (K(z).to -= I[0].length, z.push(new o(0, c - I[0].length, c)))), "rtl" == l ? z.reverse() : z } }(); function ue(e, t) { var n = e.order; return null == n && (n = e.order = se(e.text, t)), n } var ce = [], de = function (e, t, n) { if (e.addEventListener) e.addEventListener(t, n, !1); else if (e.attachEvent) e.attachEvent("on" + t, n); else { var r = e._handlers || (e._handlers = {}); r[t] = (r[t] || ce).concat(n) } }; function he(e, t) { return e._handlers && e._handlers[t] || ce } function fe(e, t, n) { if (e.removeEventListener) e.removeEventListener(t, n, !1); else if (e.detachEvent) e.detachEvent("on" + t, n); else { var r = e._handlers, i = r && r[t]; if (i) { var o = _(i, n); o > -1 && (r[t] = i.slice(0, o).concat(i.slice(o + 1))) } } } function pe(e, t) { var n = he(e, t); if (n.length) for (var r = Array.prototype.slice.call(arguments, 2), i = 0; i < n.length; ++i)n[i].apply(null, r) } function me(e, t, n) { return "string" == typeof t && (t = { type: t, preventDefault: function () { this.defaultPrevented = !0 } }), pe(e, n || t.type, e, t), De(t) || t.codemirrorIgnore } function ge(e) { var t = e._handlers && e._handlers.cursorActivity; if (t) for (var n = e.curOp.cursorActivityHandlers || (e.curOp.cursorActivityHandlers = []), r = 0; r < t.length; ++r)-1 == _(n, t[r]) && n.push(t[r]) } function ve(e, t) { return he(e, t).length > 0 } function xe(e) { e.prototype.on = function (e, t) { de(this, e, t) }, e.prototype.off = function (e, t) { fe(this, e, t) } } function ye(e) { e.preventDefault ? e.preventDefault() : e.returnValue = !1 } function be(e) { e.stopPropagation ? e.stopPropagation() : e.cancelBubble = !0 } function De(e) { return null != e.defaultPrevented ? e.defaultPrevented : 0 == e.returnValue } function Ce(e) { ye(e), be(e) } function we(e) { return e.target || e.srcElement } function ke(e) { var t = e.which; return null == t && (1 & e.button ? t = 1 : 2 & e.button ? t = 3 : 4 & e.button && (t = 2)), x && e.ctrlKey && 1 == t && (t = 3), t } var Se, Fe, Ae = function () { if (a && l < 9) return !1; var e = T("div"); return "draggable" in e || "dragDrop" in e }(); function Ee(e) { if (null == Se) { var t = T("span", "​"); E(e, T("span", [t, document.createTextNode("x")])), 0 != e.firstChild.offsetHeight && (Se = t.offsetWidth <= 1 && t.offsetHeight > 2 && !(a && l < 8)) } var n = Se ? T("span", "​") : T("span", " ", null, "display: inline-block; width: 1px; margin-right: -1px"); return n.setAttribute("cm-text", ""), n } function Te(e) { if (null != Fe) return Fe; var t = E(e, document.createTextNode("AخA")), n = S(t, 0, 1).getBoundingClientRect(), r = S(t, 1, 2).getBoundingClientRect(); return A(e), !(!n || n.left == n.right) && (Fe = r.right - n.right < 3) } var Le, Me = 3 != "\n\nb".split(/\n/).length ? function (e) { for (var t = 0, n = [], r = e.length; t <= r;) { var i = e.indexOf("\n", t); -1 == i && (i = e.length); var o = e.slice(t, "\r" == e.charAt(i - 1) ? i - 1 : i), a = o.indexOf("\r"); -1 != a ? (n.push(o.slice(0, a)), t += a + 1) : (n.push(o), t = i + 1) } return n } : function (e) { return e.split(/\r\n?|\n/) }, Be = window.getSelection ? function (e) { try { return e.selectionStart != e.selectionEnd } catch (e) { return !1 } } : function (e) { var t; try { t = e.ownerDocument.selection.createRange() } catch (e) { } return !(!t || t.parentElement() != e) && 0 != t.compareEndPoints("StartToEnd", t) }, Ne = "oncopy" in (Le = T("div")) || (Le.setAttribute("oncopy", "return;"), "function" == typeof Le.oncopy), Oe = null; var Ie = {}, ze = {}; function He(e, t) { arguments.length > 2 && (t.dependencies = Array.prototype.slice.call(arguments, 2)), Ie[e] = t } function Re(e) { if ("string" == typeof e && ze.hasOwnProperty(e)) e = ze[e]; else if (e && "string" == typeof e.name && ze.hasOwnProperty(e.name)) { var t = ze[e.name]; "string" == typeof t && (t = { name: t }), (e = Y(t, e)).name = t.name } else { if ("string" == typeof e && /^[\w\-]+\/[\w\-]+\+xml$/.test(e)) return Re("application/xml"); if ("string" == typeof e && /^[\w\-]+\/[\w\-]+\+json$/.test(e)) return Re("application/json") } return "string" == typeof e ? { name: e } : e || { name: "null" } } function Pe(e, t) { t = Re(t); var n = Ie[t.name]; if (!n) return Pe(e, "text/plain"); var r = n(e, t); if (_e.hasOwnProperty(t.name)) { var i = _e[t.name]; for (var o in i) i.hasOwnProperty(o) && (r.hasOwnProperty(o) && (r["_" + o] = r[o]), r[o] = i[o]) } if (r.name = t.name, t.helperType && (r.helperType = t.helperType), t.modeProps) for (var a in t.modeProps) r[a] = t.modeProps[a]; return r } var _e = {}; function We(e, t) { H(t, _e.hasOwnProperty(e) ? _e[e] : _e[e] = {}) } function je(e, t) { if (!0 === t) return t; if (e.copyState) return e.copyState(t); var n = {}; for (var r in t) { var i = t[r]; i instanceof Array && (i = i.concat([])), n[r] = i } return n } function qe(e, t) { for (var n; e.innerMode && (n = e.innerMode(t)) && n.mode != e;)t = n.state, e = n.mode; return n || { mode: e, state: t } } function Ue(e, t, n) { return !e.startState || e.startState(t, n) } var $e = function (e, t, n) { this.pos = this.start = 0, this.string = e, this.tabSize = t || 8, this.lastColumnPos = this.lastColumnValue = 0, this.lineStart = 0, this.lineOracle = n }; function Ge(e, t) { if ((t -= e.first) < 0 || t >= e.size) throw new Error("There is no line " + (t + e.first) + " in the document."); for (var n = e; !n.lines;)for (var r = 0; ; ++r) { var i = n.children[r], o = i.chunkSize(); if (t < o) { n = i; break } t -= o } return n.lines[t] } function Ve(e, t, n) { var r = [], i = t.line; return e.iter(t.line, n.line + 1, (function (e) { var o = e.text; i == n.line && (o = o.slice(0, n.ch)), i == t.line && (o = o.slice(t.ch)), r.push(o), ++i })), r } function Ke(e, t, n) { var r = []; return e.iter(t, n, (function (e) { r.push(e.text) })), r } function Xe(e, t) { var n = t - e.height; if (n) for (var r = e; r; r = r.parent)r.height += n } function Ze(e) { if (null == e.parent) return null; for (var t = e.parent, n = _(t.lines, e), r = t.parent; r; t = r, r = r.parent)for (var i = 0; r.children[i] != t; ++i)n += r.children[i].chunkSize(); return n + t.first } function Ye(e, t) { var n = e.first; e: do { for (var r = 0; r < e.children.length; ++r) { var i = e.children[r], o = i.height; if (t < o) { e = i; continue e } t -= o, n += i.chunkSize() } return n } while (!e.lines); for (var a = 0; a < e.lines.length; ++a) { var l = e.lines[a].height; if (t < l) break; t -= l } return n + a } function Qe(e, t) { return t >= e.first && t < e.first + e.size } function Je(e, t) { return String(e.lineNumberFormatter(t + e.firstLineNumber)) } function et(e, t, n) { if (void 0 === n && (n = null), !(this instanceof et)) return new et(e, t, n); this.line = e, this.ch = t, this.sticky = n } function tt(e, t) { return e.line - t.line || e.ch - t.ch } function nt(e, t) { return e.sticky == t.sticky && 0 == tt(e, t) } function rt(e) { return et(e.line, e.ch) } function it(e, t) { return tt(e, t) < 0 ? t : e } function ot(e, t) { return tt(e, t) < 0 ? e : t } function at(e, t) { return Math.max(e.first, Math.min(t, e.first + e.size - 1)) } function lt(e, t) { if (t.line < e.first) return et(e.first, 0); var n = e.first + e.size - 1; return t.line > n ? et(n, Ge(e, n).text.length) : function (e, t) { var n = e.ch; return null == n || n > t ? et(e.line, t) : n < 0 ? et(e.line, 0) : e }(t, Ge(e, t.line).text.length) } function st(e, t) { for (var n = [], r = 0; r < t.length; r++)n[r] = lt(e, t[r]); return n } $e.prototype.eol = function () { return this.pos >= this.string.length }, $e.prototype.sol = function () { return this.pos == this.lineStart }, $e.prototype.peek = function () { return this.string.charAt(this.pos) || void 0 }, $e.prototype.next = function () { if (this.pos < this.string.length) return this.string.charAt(this.pos++) }, $e.prototype.eat = function (e) { var t = this.string.charAt(this.pos); if ("string" == typeof e ? t == e : t && (e.test ? e.test(t) : e(t))) return ++this.pos, t }, $e.prototype.eatWhile = function (e) { for (var t = this.pos; this.eat(e);); return this.pos > t }, $e.prototype.eatSpace = function () { for (var e = this.pos; /[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos; return this.pos > e }, $e.prototype.skipToEnd = function () { this.pos = this.string.length }, $e.prototype.skipTo = function (e) { var t = this.string.indexOf(e, this.pos); if (t > -1) return this.pos = t, !0 }, $e.prototype.backUp = function (e) { this.pos -= e }, $e.prototype.column = function () { return this.lastColumnPos < this.start && (this.lastColumnValue = R(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue), this.lastColumnPos = this.start), this.lastColumnValue - (this.lineStart ? R(this.string, this.lineStart, this.tabSize) : 0) }, $e.prototype.indentation = function () { return R(this.string, null, this.tabSize) - (this.lineStart ? R(this.string, this.lineStart, this.tabSize) : 0) }, $e.prototype.match = function (e, t, n) { if ("string" != typeof e) { var r = this.string.slice(this.pos).match(e); return r && r.index > 0 ? null : (r && !1 !== t && (this.pos += r[0].length), r) } var i = function (e) { return n ? e.toLowerCase() : e }; if (i(this.string.substr(this.pos, e.length)) == i(e)) return !1 !== t && (this.pos += e.length), !0 }, $e.prototype.current = function () { return this.string.slice(this.start, this.pos) }, $e.prototype.hideFirstChars = function (e, t) { this.lineStart += e; try { return t() } finally { this.lineStart -= e } }, $e.prototype.lookAhead = function (e) { var t = this.lineOracle; return t && t.lookAhead(e) }, $e.prototype.baseToken = function () { var e = this.lineOracle; return e && e.baseToken(this.pos) }; var ut = function (e, t) { this.state = e, this.lookAhead = t }, ct = function (e, t, n, r) { this.state = t, this.doc = e, this.line = n, this.maxLookAhead = r || 0, this.baseTokens = null, this.baseTokenPos = 1 }; function dt(e, t, n, r) { var i = [e.state.modeGen], o = {}; bt(e, t.text, e.doc.mode, n, (function (e, t) { return i.push(e, t) }), o, r); for (var a = n.state, l = function (r) { n.baseTokens = i; var l = e.state.overlays[r], s = 1, u = 0; n.state = !0, bt(e, t.text, l.mode, n, (function (e, t) { for (var n = s; u < e;) { var r = i[s]; r > e && i.splice(s, 1, e, i[s + 1], r), s += 2, u = Math.min(e, r) } if (t) if (l.opaque) i.splice(n, s - n, e, "overlay " + t), s = n + 2; else for (; n < s; n += 2) { var o = i[n + 1]; i[n + 1] = (o ? o + " " : "") + "overlay " + t } }), o), n.state = a, n.baseTokens = null, n.baseTokenPos = 1 }, s = 0; s < e.state.overlays.length; ++s)l(s); return { styles: i, classes: o.bgClass || o.textClass ? o : null } } function ht(e, t, n) { if (!t.styles || t.styles[0] != e.state.modeGen) { var r = ft(e, Ze(t)), i = t.text.length > e.options.maxHighlightLength && je(e.doc.mode, r.state), o = dt(e, t, r); i && (r.state = i), t.stateAfter = r.save(!i), t.styles = o.styles, o.classes ? t.styleClasses = o.classes : t.styleClasses && (t.styleClasses = null), n === e.doc.highlightFrontier && (e.doc.modeFrontier = Math.max(e.doc.modeFrontier, ++e.doc.highlightFrontier)) } return t.styles } function ft(e, t, n) { var r = e.doc, i = e.display; if (!r.mode.startState) return new ct(r, !0, t); var o = function (e, t, n) { for (var r, i, o = e.doc, a = n ? -1 : t - (e.doc.mode.innerMode ? 1e3 : 100), l = t; l > a; --l) { if (l <= o.first) return o.first; var s = Ge(o, l - 1), u = s.stateAfter; if (u && (!n || l + (u instanceof ut ? u.lookAhead : 0) <= o.modeFrontier)) return l; var c = R(s.text, null, e.options.tabSize); (null == i || r > c) && (i = l - 1, r = c) } return i }(e, t, n), a = o > r.first && Ge(r, o - 1).stateAfter, l = a ? ct.fromSaved(r, a, o) : new ct(r, Ue(r.mode), o); return r.iter(o, t, (function (n) { pt(e, n.text, l); var r = l.line; n.stateAfter = r == t - 1 || r % 5 == 0 || r >= i.viewFrom && r < i.viewTo ? l.save() : null, l.nextLine() })), n && (r.modeFrontier = l.line), l } function pt(e, t, n, r) { var i = e.doc.mode, o = new $e(t, e.options.tabSize, n); for (o.start = o.pos = r || 0, "" == t && mt(i, n.state); !o.eol();)gt(i, o, n.state), o.start = o.pos } function mt(e, t) { if (e.blankLine) return e.blankLine(t); if (e.innerMode) { var n = qe(e, t); return n.mode.blankLine ? n.mode.blankLine(n.state) : void 0 } } function gt(e, t, n, r) { for (var i = 0; i < 10; i++) { r && (r[0] = qe(e, n).mode); var o = e.token(t, n); if (t.pos > t.start) return o } throw new Error("Mode " + e.name + " failed to advance stream.") } ct.prototype.lookAhead = function (e) { var t = this.doc.getLine(this.line + e); return null != t && e > this.maxLookAhead && (this.maxLookAhead = e), t }, ct.prototype.baseToken = function (e) { if (!this.baseTokens) return null; for (; this.baseTokens[this.baseTokenPos] <= e;)this.baseTokenPos += 2; var t = this.baseTokens[this.baseTokenPos + 1]; return { type: t && t.replace(/( |^)overlay .*/, ""), size: this.baseTokens[this.baseTokenPos] - e } }, ct.prototype.nextLine = function () { this.line++, this.maxLookAhead > 0 && this.maxLookAhead-- }, ct.fromSaved = function (e, t, n) { return t instanceof ut ? new ct(e, je(e.mode, t.state), n, t.lookAhead) : new ct(e, je(e.mode, t), n) }, ct.prototype.save = function (e) { var t = !1 !== e ? je(this.doc.mode, this.state) : this.state; return this.maxLookAhead > 0 ? new ut(t, this.maxLookAhead) : t }; var vt = function (e, t, n) { this.start = e.start, this.end = e.pos, this.string = e.current(), this.type = t || null, this.state = n }; function xt(e, t, n, r) { var i, o, a = e.doc, l = a.mode, s = Ge(a, (t = lt(a, t)).line), u = ft(e, t.line, n), c = new $e(s.text, e.options.tabSize, u); for (r && (o = []); (r || c.pos < t.ch) && !c.eol();)c.start = c.pos, i = gt(l, c, u.state), r && o.push(new vt(c, i, je(a.mode, u.state))); return r ? o : new vt(c, i, u.state) } function yt(e, t) { if (e) for (; ;) { var n = e.match(/(?:^|\s+)line-(background-)?(\S+)/); if (!n) break; e = e.slice(0, n.index) + e.slice(n.index + n[0].length); var r = n[1] ? "bgClass" : "textClass"; null == t[r] ? t[r] = n[2] : new RegExp("(?:^|\\s)" + n[2] + "(?:$|\\s)").test(t[r]) || (t[r] += " " + n[2]) } return e } function bt(e, t, n, r, i, o, a) { var l = n.flattenSpans; null == l && (l = e.options.flattenSpans); var s, u = 0, c = null, d = new $e(t, e.options.tabSize, r), h = e.options.addModeClass && [null]; for ("" == t && yt(mt(n, r.state), o); !d.eol();) { if (d.pos > e.options.maxHighlightLength ? (l = !1, a && pt(e, t, r, d.pos), d.pos = t.length, s = null) : s = yt(gt(n, d, r.state, h), o), h) { var f = h[0].name; f && (s = "m-" + (s ? f + " " + s : f)) } if (!l || c != s) { for (; u < d.start;)i(u = Math.min(d.start, u + 5e3), c); c = s } d.start = d.pos } for (; u < d.pos;) { var p = Math.min(d.pos, u + 5e3); i(p, c), u = p } } var Dt = !1, Ct = !1; function wt(e, t, n) { this.marker = e, this.from = t, this.to = n } function kt(e, t) { if (e) for (var n = 0; n < e.length; ++n) { var r = e[n]; if (r.marker == t) return r } } function St(e, t) { for (var n, r = 0; r < e.length; ++r)e[r] != t && (n || (n = [])).push(e[r]); return n } function Ft(e, t) { if (t.full) return null; var n = Qe(e, t.from.line) && Ge(e, t.from.line).markedSpans, r = Qe(e, t.to.line) && Ge(e, t.to.line).markedSpans; if (!n && !r) return null; var i = t.from.ch, o = t.to.ch, a = 0 == tt(t.from, t.to), l = function (e, t, n) { var r; if (e) for (var i = 0; i < e.length; ++i) { var o = e[i], a = o.marker; if (null == o.from || (a.inclusiveLeft ? o.from <= t : o.from < t) || o.from == t && "bookmark" == a.type && (!n || !o.marker.insertLeft)) { var l = null == o.to || (a.inclusiveRight ? o.to >= t : o.to > t); (r || (r = [])).push(new wt(a, o.from, l ? null : o.to)) } } return r }(n, i, a), s = function (e, t, n) { var r; if (e) for (var i = 0; i < e.length; ++i) { var o = e[i], a = o.marker; if (null == o.to || (a.inclusiveRight ? o.to >= t : o.to > t) || o.from == t && "bookmark" == a.type && (!n || o.marker.insertLeft)) { var l = null == o.from || (a.inclusiveLeft ? o.from <= t : o.from < t); (r || (r = [])).push(new wt(a, l ? null : o.from - t, null == o.to ? null : o.to - t)) } } return r }(r, o, a), u = 1 == t.text.length, c = K(t.text).length + (u ? i : 0); if (l) for (var d = 0; d < l.length; ++d) { var h = l[d]; if (null == h.to) { var f = kt(s, h.marker); f ? u && (h.to = null == f.to ? null : f.to + c) : h.to = i } } if (s) for (var p = 0; p < s.length; ++p) { var m = s[p]; if (null != m.to && (m.to += c), null == m.from) kt(l, m.marker) || (m.from = c, u && (l || (l = [])).push(m)); else m.from += c, u && (l || (l = [])).push(m) } l && (l = At(l)), s && s != l && (s = At(s)); var g = [l]; if (!u) { var v, x = t.text.length - 2; if (x > 0 && l) for (var y = 0; y < l.length; ++y)null == l[y].to && (v || (v = [])).push(new wt(l[y].marker, null, null)); for (var b = 0; b < x; ++b)g.push(v); g.push(s) } return g } function At(e) { for (var t = 0; t < e.length; ++t) { var n = e[t]; null != n.from && n.from == n.to && !1 !== n.marker.clearWhenEmpty && e.splice(t--, 1) } return e.length ? e : null } function Et(e) { var t = e.markedSpans; if (t) { for (var n = 0; n < t.length; ++n)t[n].marker.detachLine(e); e.markedSpans = null } } function Tt(e, t) { if (t) { for (var n = 0; n < t.length; ++n)t[n].marker.attachLine(e); e.markedSpans = t } } function Lt(e) { return e.inclusiveLeft ? -1 : 0 } function Mt(e) { return e.inclusiveRight ? 1 : 0 } function Bt(e, t) { var n = e.lines.length - t.lines.length; if (0 != n) return n; var r = e.find(), i = t.find(), o = tt(r.from, i.from) || Lt(e) - Lt(t); if (o) return -o; var a = tt(r.to, i.to) || Mt(e) - Mt(t); return a || t.id - e.id } function Nt(e, t) { var n, r = Ct && e.markedSpans; if (r) for (var i = void 0, o = 0; o < r.length; ++o)(i = r[o]).marker.collapsed && null == (t ? i.from : i.to) && (!n || Bt(n, i.marker) < 0) && (n = i.marker); return n } function Ot(e) { return Nt(e, !0) } function It(e) { return Nt(e, !1) } function zt(e, t) { var n, r = Ct && e.markedSpans; if (r) for (var i = 0; i < r.length; ++i) { var o = r[i]; o.marker.collapsed && (null == o.from || o.from < t) && (null == o.to || o.to > t) && (!n || Bt(n, o.marker) < 0) && (n = o.marker) } return n } function Ht(e, t, n, r, i) { var o = Ge(e, t), a = Ct && o.markedSpans; if (a) for (var l = 0; l < a.length; ++l) { var s = a[l]; if (s.marker.collapsed) { var u = s.marker.find(0), c = tt(u.from, n) || Lt(s.marker) - Lt(i), d = tt(u.to, r) || Mt(s.marker) - Mt(i); if (!(c >= 0 && d <= 0 || c <= 0 && d >= 0) && (c <= 0 && (s.marker.inclusiveRight && i.inclusiveLeft ? tt(u.to, n) >= 0 : tt(u.to, n) > 0) || c >= 0 && (s.marker.inclusiveRight && i.inclusiveLeft ? tt(u.from, r) <= 0 : tt(u.from, r) < 0))) return !0 } } } function Rt(e) { for (var t; t = Ot(e);)e = t.find(-1, !0).line; return e } function Pt(e, t) { var n = Ge(e, t), r = Rt(n); return n == r ? t : Ze(r) } function _t(e, t) { if (t > e.lastLine()) return t; var n, r = Ge(e, t); if (!Wt(e, r)) return t; for (; n = It(r);)r = n.find(1, !0).line; return Ze(r) + 1 } function Wt(e, t) { var n = Ct && t.markedSpans; if (n) for (var r = void 0, i = 0; i < n.length; ++i)if ((r = n[i]).marker.collapsed) { if (null == r.from) return !0; if (!r.marker.widgetNode && 0 == r.from && r.marker.inclusiveLeft && jt(e, t, r)) return !0 } } function jt(e, t, n) { if (null == n.to) { var r = n.marker.find(1, !0); return jt(e, r.line, kt(r.line.markedSpans, n.marker)) } if (n.marker.inclusiveRight && n.to == t.text.length) return !0; for (var i = void 0, o = 0; o < t.markedSpans.length; ++o)if ((i = t.markedSpans[o]).marker.collapsed && !i.marker.widgetNode && i.from == n.to && (null == i.to || i.to != n.from) && (i.marker.inclusiveLeft || n.marker.inclusiveRight) && jt(e, t, i)) return !0 } function qt(e) { for (var t = 0, n = (e = Rt(e)).parent, r = 0; r < n.lines.length; ++r) { var i = n.lines[r]; if (i == e) break; t += i.height } for (var o = n.parent; o; o = (n = o).parent)for (var a = 0; a < o.children.length; ++a) { var l = o.children[a]; if (l == n) break; t += l.height } return t } function Ut(e) { if (0 == e.height) return 0; for (var t, n = e.text.length, r = e; t = Ot(r);) { var i = t.find(0, !0); r = i.from.line, n += i.from.ch - i.to.ch } for (r = e; t = It(r);) { var o = t.find(0, !0); n -= r.text.length - o.from.ch, n += (r = o.to.line).text.length - o.to.ch } return n } function $t(e) { var t = e.display, n = e.doc; t.maxLine = Ge(n, n.first), t.maxLineLength = Ut(t.maxLine), t.maxLineChanged = !0, n.iter((function (e) { var n = Ut(e); n > t.maxLineLength && (t.maxLineLength = n, t.maxLine = e) })) } var Gt = function (e, t, n) { this.text = e, Tt(this, t), this.height = n ? n(this) : 1 }; function Vt(e) { e.parent = null, Et(e) } Gt.prototype.lineNo = function () { return Ze(this) }, xe(Gt); var Kt = {}, Xt = {}; function Zt(e, t) { if (!e || /^\s*$/.test(e)) return null; var n = t.addModeClass ? Xt : Kt; return n[e] || (n[e] = e.replace(/\S+/g, "cm-$&")) } function Yt(e, t) { var n = L("span", null, null, s ? "padding-right: .1px" : null), r = { pre: L("pre", [n], "CodeMirror-line"), content: n, col: 0, pos: 0, cm: e, trailingSpace: !1, splitSpaces: e.getOption("lineWrapping") }; t.measure = {}; for (var i = 0; i <= (t.rest ? t.rest.length : 0); i++) { var o = i ? t.rest[i - 1] : t.line, a = void 0; r.pos = 0, r.addToken = Jt, Te(e.display.measure) && (a = ue(o, e.doc.direction)) && (r.addToken = en(r.addToken, a)), r.map = [], nn(o, r, ht(e, o, t != e.display.externalMeasured && Ze(o))), o.styleClasses && (o.styleClasses.bgClass && (r.bgClass = O(o.styleClasses.bgClass, r.bgClass || "")), o.styleClasses.textClass && (r.textClass = O(o.styleClasses.textClass, r.textClass || ""))), 0 == r.map.length && r.map.push(0, 0, r.content.appendChild(Ee(e.display.measure))), 0 == i ? (t.measure.map = r.map, t.measure.cache = {}) : ((t.measure.maps || (t.measure.maps = [])).push(r.map), (t.measure.caches || (t.measure.caches = [])).push({})) } if (s) { var l = r.content.lastChild; (/\bcm-tab\b/.test(l.className) || l.querySelector && l.querySelector(".cm-tab")) && (r.content.className = "cm-tab-wrap-hack") } return pe(e, "renderLine", e, t.line, r.pre), r.pre.className && (r.textClass = O(r.pre.className, r.textClass || "")), r } function Qt(e) { var t = T("span", "•", "cm-invalidchar"); return t.title = "\\u" + e.charCodeAt(0).toString(16), t.setAttribute("aria-label", t.title), t } function Jt(e, t, n, r, i, o, s) { if (t) { var u, c = e.splitSpaces ? function (e, t) { if (e.length > 1 && !/ /.test(e)) return e; for (var n = t, r = "", i = 0; i < e.length; i++) { var o = e.charAt(i); " " != o || !n || i != e.length - 1 && 32 != e.charCodeAt(i + 1) || (o = " "), r += o, n = " " == o } return r }(t, e.trailingSpace) : t, d = e.cm.state.specialChars, h = !1; if (d.test(t)) { u = document.createDocumentFragment(); for (var f = 0; ;) { d.lastIndex = f; var p = d.exec(t), m = p ? p.index - f : t.length - f; if (m) { var g = document.createTextNode(c.slice(f, f + m)); a && l < 9 ? u.appendChild(T("span", [g])) : u.appendChild(g), e.map.push(e.pos, e.pos + m, g), e.col += m, e.pos += m } if (!p) break; f += m + 1; var v = void 0; if ("\t" == p[0]) { var x = e.cm.options.tabSize, y = x - e.col % x; (v = u.appendChild(T("span", V(y), "cm-tab"))).setAttribute("role", "presentation"), v.setAttribute("cm-text", "\t"), e.col += y } else "\r" == p[0] || "\n" == p[0] ? ((v = u.appendChild(T("span", "\r" == p[0] ? "␍" : "␤", "cm-invalidchar"))).setAttribute("cm-text", p[0]), e.col += 1) : ((v = e.cm.options.specialCharPlaceholder(p[0])).setAttribute("cm-text", p[0]), a && l < 9 ? u.appendChild(T("span", [v])) : u.appendChild(v), e.col += 1); e.map.push(e.pos, e.pos + 1, v), e.pos++ } } else e.col += t.length, u = document.createTextNode(c), e.map.push(e.pos, e.pos + t.length, u), a && l < 9 && (h = !0), e.pos += t.length; if (e.trailingSpace = 32 == c.charCodeAt(t.length - 1), n || r || i || h || o || s) { var b = n || ""; r && (b += r), i && (b += i); var D = T("span", [u], b, o); if (s) for (var C in s) s.hasOwnProperty(C) && "style" != C && "class" != C && D.setAttribute(C, s[C]); return e.content.appendChild(D) } e.content.appendChild(u) } } function en(e, t) { return function (n, r, i, o, a, l, s) { i = i ? i + " cm-force-border" : "cm-force-border"; for (var u = n.pos, c = u + r.length; ;) { for (var d = void 0, h = 0; h < t.length && !((d = t[h]).to > u && d.from <= u); h++); if (d.to >= c) return e(n, r, i, o, a, l, s); e(n, r.slice(0, d.to - u), i, o, null, l, s), o = null, r = r.slice(d.to - u), u = d.to } } } function tn(e, t, n, r) { var i = !r && n.widgetNode; i && e.map.push(e.pos, e.pos + t, i), !r && e.cm.display.input.needsContentAttribute && (i || (i = e.content.appendChild(document.createElement("span"))), i.setAttribute("cm-marker", n.id)), i && (e.cm.display.input.setUneditable(i), e.content.appendChild(i)), e.pos += t, e.trailingSpace = !1 } function nn(e, t, n) { var r = e.markedSpans, i = e.text, o = 0; if (r) for (var a, l, s, u, c, d, h, f = i.length, p = 0, m = 1, g = "", v = 0; ;) { if (v == p) { s = u = c = l = "", h = null, d = null, v = 1 / 0; for (var x = [], y = void 0, b = 0; b < r.length; ++b) { var D = r[b], C = D.marker; if ("bookmark" == C.type && D.from == p && C.widgetNode) x.push(C); else if (D.from <= p && (null == D.to || D.to > p || C.collapsed && D.to == p && D.from == p)) { if (null != D.to && D.to != p && v > D.to && (v = D.to, u = ""), C.className && (s += " " + C.className), C.css && (l = (l ? l + ";" : "") + C.css), C.startStyle && D.from == p && (c += " " + C.startStyle), C.endStyle && D.to == v && (y || (y = [])).push(C.endStyle, D.to), C.title && ((h || (h = {})).title = C.title), C.attributes) for (var w in C.attributes) (h || (h = {}))[w] = C.attributes[w]; C.collapsed && (!d || Bt(d.marker, C) < 0) && (d = D) } else D.from > p && v > D.from && (v = D.from) } if (y) for (var k = 0; k < y.length; k += 2)y[k + 1] == v && (u += " " + y[k]); if (!d || d.from == p) for (var S = 0; S < x.length; ++S)tn(t, 0, x[S]); if (d && (d.from || 0) == p) { if (tn(t, (null == d.to ? f + 1 : d.to) - p, d.marker, null == d.from), null == d.to) return; d.to == p && (d = !1) } } if (p >= f) break; for (var F = Math.min(f, v); ;) { if (g) { var A = p + g.length; if (!d) { var E = A > F ? g.slice(0, F - p) : g; t.addToken(t, E, a ? a + s : s, c, p + E.length == v ? u : "", l, h) } if (A >= F) { g = g.slice(F - p), p = F; break } p = A, c = "" } g = i.slice(o, o = n[m++]), a = Zt(n[m++], t.cm.options) } } else for (var T = 1; T < n.length; T += 2)t.addToken(t, i.slice(o, o = n[T]), Zt(n[T + 1], t.cm.options)) } function rn(e, t, n) { this.line = t, this.rest = function (e) { for (var t, n; t = It(e);)e = t.find(1, !0).line, (n || (n = [])).push(e); return n }(t), this.size = this.rest ? Ze(K(this.rest)) - n + 1 : 1, this.node = this.text = null, this.hidden = Wt(e, t) } function on(e, t, n) { for (var r, i = [], o = t; o < n; o = r) { var a = new rn(e.doc, Ge(e.doc, o), o); r = o + a.size, i.push(a) } return i } var an = null; var ln = null; function sn(e, t) { var n = he(e, t); if (n.length) { var r, i = Array.prototype.slice.call(arguments, 2); an ? r = an.delayedCallbacks : ln ? r = ln : (r = ln = [], setTimeout(un, 0)); for (var o = function (e) { r.push((function () { return n[e].apply(null, i) })) }, a = 0; a < n.length; ++a)o(a) } } function un() { var e = ln; ln = null; for (var t = 0; t < e.length; ++t)e[t]() } function cn(e, t, n, r) { for (var i = 0; i < t.changes.length; i++) { var o = t.changes[i]; "text" == o ? fn(e, t) : "gutter" == o ? mn(e, t, n, r) : "class" == o ? pn(e, t) : "widget" == o && gn(e, t, r) } t.changes = null } function dn(e) { return e.node == e.text && (e.node = T("div", null, null, "position: relative"), e.text.parentNode && e.text.parentNode.replaceChild(e.node, e.text), e.node.appendChild(e.text), a && l < 8 && (e.node.style.zIndex = 2)), e.node } function hn(e, t) { var n = e.display.externalMeasured; return n && n.line == t.line ? (e.display.externalMeasured = null, t.measure = n.measure, n.built) : Yt(e, t) } function fn(e, t) { var n = t.text.className, r = hn(e, t); t.text == t.node && (t.node = r.pre), t.text.parentNode.replaceChild(r.pre, t.text), t.text = r.pre, r.bgClass != t.bgClass || r.textClass != t.textClass ? (t.bgClass = r.bgClass, t.textClass = r.textClass, pn(e, t)) : n && (t.text.className = n) } function pn(e, t) { !function (e, t) { var n = t.bgClass ? t.bgClass + " " + (t.line.bgClass || "") : t.line.bgClass; if (n && (n += " CodeMirror-linebackground"), t.background) n ? t.background.className = n : (t.background.parentNode.removeChild(t.background), t.background = null); else if (n) { var r = dn(t); t.background = r.insertBefore(T("div", null, n), r.firstChild), e.display.input.setUneditable(t.background) } }(e, t), t.line.wrapClass ? dn(t).className = t.line.wrapClass : t.node != t.text && (t.node.className = ""); var n = t.textClass ? t.textClass + " " + (t.line.textClass || "") : t.line.textClass; t.text.className = n || "" } function mn(e, t, n, r) { if (t.gutter && (t.node.removeChild(t.gutter), t.gutter = null), t.gutterBackground && (t.node.removeChild(t.gutterBackground), t.gutterBackground = null), t.line.gutterClass) { var i = dn(t); t.gutterBackground = T("div", null, "CodeMirror-gutter-background " + t.line.gutterClass, "left: " + (e.options.fixedGutter ? r.fixedPos : -r.gutterTotalWidth) + "px; width: " + r.gutterTotalWidth + "px"), e.display.input.setUneditable(t.gutterBackground), i.insertBefore(t.gutterBackground, t.text) } var o = t.line.gutterMarkers; if (e.options.lineNumbers || o) { var a = dn(t), l = t.gutter = T("div", null, "CodeMirror-gutter-wrapper", "left: " + (e.options.fixedGutter ? r.fixedPos : -r.gutterTotalWidth) + "px"); if (l.setAttribute("aria-hidden", "true"), e.display.input.setUneditable(l), a.insertBefore(l, t.text), t.line.gutterClass && (l.className += " " + t.line.gutterClass), !e.options.lineNumbers || o && o["CodeMirror-linenumbers"] || (t.lineNumber = l.appendChild(T("div", Je(e.options, n), "CodeMirror-linenumber CodeMirror-gutter-elt", "left: " + r.gutterLeft["CodeMirror-linenumbers"] + "px; width: " + e.display.lineNumInnerWidth + "px"))), o) for (var s = 0; s < e.display.gutterSpecs.length; ++s) { var u = e.display.gutterSpecs[s].className, c = o.hasOwnProperty(u) && o[u]; c && l.appendChild(T("div", [c], "CodeMirror-gutter-elt", "left: " + r.gutterLeft[u] + "px; width: " + r.gutterWidth[u] + "px")) } } } function gn(e, t, n) { t.alignable && (t.alignable = null); for (var r = k("CodeMirror-linewidget"), i = t.node.firstChild, o = void 0; i; i = o)o = i.nextSibling, r.test(i.className) && t.node.removeChild(i); xn(e, t, n) } function vn(e, t, n, r) { var i = hn(e, t); return t.text = t.node = i.pre, i.bgClass && (t.bgClass = i.bgClass), i.textClass && (t.textClass = i.textClass), pn(e, t), mn(e, t, n, r), xn(e, t, r), t.node } function xn(e, t, n) { if (yn(e, t.line, t, n, !0), t.rest) for (var r = 0; r < t.rest.length; r++)yn(e, t.rest[r], t, n, !1) } function yn(e, t, n, r, i) { if (t.widgets) for (var o = dn(n), a = 0, l = t.widgets; a < l.length; ++a) { var s = l[a], u = T("div", [s.node], "CodeMirror-linewidget" + (s.className ? " " + s.className : "")); s.handleMouseEvents || u.setAttribute("cm-ignore-events", "true"), bn(s, u, n, r), e.display.input.setUneditable(u), i && s.above ? o.insertBefore(u, n.gutter || n.text) : o.appendChild(u), sn(s, "redraw") } } function bn(e, t, n, r) { if (e.noHScroll) { (n.alignable || (n.alignable = [])).push(t); var i = r.wrapperWidth; t.style.left = r.fixedPos + "px", e.coverGutter || (i -= r.gutterTotalWidth, t.style.paddingLeft = r.gutterTotalWidth + "px"), t.style.width = i + "px" } e.coverGutter && (t.style.zIndex = 5, t.style.position = "relative", e.noHScroll || (t.style.marginLeft = -r.gutterTotalWidth + "px")) } function Dn(e) { if (null != e.height) return e.height; var t = e.doc.cm; if (!t) return 0; if (!M(document.body, e.node)) { var n = "position: relative;"; e.coverGutter && (n += "margin-left: -" + t.display.gutters.offsetWidth + "px;"), e.noHScroll && (n += "width: " + t.display.wrapper.clientWidth + "px;"), E(t.display.measure, T("div", [e.node], null, n)) } return e.height = e.node.parentNode.offsetHeight } function Cn(e, t) { for (var n = we(t); n != e.wrapper; n = n.parentNode)if (!n || 1 == n.nodeType && "true" == n.getAttribute("cm-ignore-events") || n.parentNode == e.sizer && n != e.mover) return !0 } function wn(e) { return e.lineSpace.offsetTop } function kn(e) { return e.mover.offsetHeight - e.lineSpace.offsetHeight } function Sn(e) { if (e.cachedPaddingH) return e.cachedPaddingH; var t = E(e.measure, T("pre", "x", "CodeMirror-line-like")), n = window.getComputedStyle ? window.getComputedStyle(t) : t.currentStyle, r = { left: parseInt(n.paddingLeft), right: parseInt(n.paddingRight) }; return isNaN(r.left) || isNaN(r.right) || (e.cachedPaddingH = r), r } function Fn(e) { return 50 - e.display.nativeBarWidth } function An(e) { return e.display.scroller.clientWidth - Fn(e) - e.display.barWidth } function En(e) { return e.display.scroller.clientHeight - Fn(e) - e.display.barHeight } function Tn(e, t, n) { if (e.line == t) return { map: e.measure.map, cache: e.measure.cache }; for (var r = 0; r < e.rest.length; r++)if (e.rest[r] == t) return { map: e.measure.maps[r], cache: e.measure.caches[r] }; for (var i = 0; i < e.rest.length; i++)if (Ze(e.rest[i]) > n) return { map: e.measure.maps[i], cache: e.measure.caches[i], before: !0 } } function Ln(e, t, n, r) { return Nn(e, Bn(e, t), n, r) } function Mn(e, t) { if (t >= e.display.viewFrom && t < e.display.viewTo) return e.display.view[cr(e, t)]; var n = e.display.externalMeasured; return n && t >= n.lineN && t < n.lineN + n.size ? n : void 0 } function Bn(e, t) { var n = Ze(t), r = Mn(e, n); r && !r.text ? r = null : r && r.changes && (cn(e, r, n, or(e)), e.curOp.forceUpdate = !0), r || (r = function (e, t) { var n = Ze(t = Rt(t)), r = e.display.externalMeasured = new rn(e.doc, t, n); r.lineN = n; var i = r.built = Yt(e, r); return r.text = i.pre, E(e.display.lineMeasure, i.pre), r }(e, t)); var i = Tn(r, t, n); return { line: t, view: r, rect: null, map: i.map, cache: i.cache, before: i.before, hasHeights: !1 } } function Nn(e, t, n, r, i) { t.before && (n = -1); var o, s = n + (r || ""); return t.cache.hasOwnProperty(s) ? o = t.cache[s] : (t.rect || (t.rect = t.view.text.getBoundingClientRect()), t.hasHeights || (!function (e, t, n) { var r = e.options.lineWrapping, i = r && An(e); if (!t.measure.heights || r && t.measure.width != i) { var o = t.measure.heights = []; if (r) { t.measure.width = i; for (var a = t.text.firstChild.getClientRects(), l = 0; l < a.length - 1; l++) { var s = a[l], u = a[l + 1]; Math.abs(s.bottom - u.bottom) > 2 && o.push((s.bottom + u.top) / 2 - n.top) } } o.push(n.bottom - n.top) } }(e, t.view, t.rect), t.hasHeights = !0), (o = function (e, t, n, r) { var i, o = zn(t.map, n, r), s = o.node, u = o.start, c = o.end, d = o.collapse; if (3 == s.nodeType) { for (var h = 0; h < 4; h++) { for (; u && re(t.line.text.charAt(o.coverStart + u));)--u; for (; o.coverStart + c < o.coverEnd && re(t.line.text.charAt(o.coverStart + c));)++c; if ((i = a && l < 9 && 0 == u && c == o.coverEnd - o.coverStart ? s.parentNode.getBoundingClientRect() : Hn(S(s, u, c).getClientRects(), r)).left || i.right || 0 == u) break; c = u, u -= 1, d = "right" } a && l < 11 && (i = function (e, t) { if (!window.screen || null == screen.logicalXDPI || screen.logicalXDPI == screen.deviceXDPI || !function (e) { if (null != Oe) return Oe; var t = E(e, T("span", "x")), n = t.getBoundingClientRect(), r = S(t, 0, 1).getBoundingClientRect(); return Oe = Math.abs(n.left - r.left) > 1 }(e)) return t; var n = screen.logicalXDPI / screen.deviceXDPI, r = screen.logicalYDPI / screen.deviceYDPI; return { left: t.left * n, right: t.right * n, top: t.top * r, bottom: t.bottom * r } }(e.display.measure, i)) } else { var f; u > 0 && (d = r = "right"), i = e.options.lineWrapping && (f = s.getClientRects()).length > 1 ? f["right" == r ? f.length - 1 : 0] : s.getBoundingClientRect() } if (a && l < 9 && !u && (!i || !i.left && !i.right)) { var p = s.parentNode.getClientRects()[0]; i = p ? { left: p.left, right: p.left + ir(e.display), top: p.top, bottom: p.bottom } : In } for (var m = i.top - t.rect.top, g = i.bottom - t.rect.top, v = (m + g) / 2, x = t.view.measure.heights, y = 0; y < x.length - 1 && !(v < x[y]); y++); var b = y ? x[y - 1] : 0, D = x[y], C = { left: ("right" == d ? i.right : i.left) - t.rect.left, right: ("left" == d ? i.left : i.right) - t.rect.left, top: b, bottom: D }; i.left || i.right || (C.bogus = !0); e.options.singleCursorHeightPerLine || (C.rtop = m, C.rbottom = g); return C }(e, t, n, r)).bogus || (t.cache[s] = o)), { left: o.left, right: o.right, top: i ? o.rtop : o.top, bottom: i ? o.rbottom : o.bottom } } var On, In = { left: 0, right: 0, top: 0, bottom: 0 }; function zn(e, t, n) { for (var r, i, o, a, l, s, u = 0; u < e.length; u += 3)if (l = e[u], s = e[u + 1], t < l ? (i = 0, o = 1, a = "left") : t < s ? o = (i = t - l) + 1 : (u == e.length - 3 || t == s && e[u + 3] > t) && (i = (o = s - l) - 1, t >= s && (a = "right")), null != i) { if (r = e[u + 2], l == s && n == (r.insertLeft ? "left" : "right") && (a = n), "left" == n && 0 == i) for (; u && e[u - 2] == e[u - 3] && e[u - 1].insertLeft;)r = e[2 + (u -= 3)], a = "left"; if ("right" == n && i == s - l) for (; u < e.length - 3 && e[u + 3] == e[u + 4] && !e[u + 5].insertLeft;)r = e[(u += 3) + 2], a = "right"; break } return { node: r, start: i, end: o, collapse: a, coverStart: l, coverEnd: s } } function Hn(e, t) { var n = In; if ("left" == t) for (var r = 0; r < e.length && (n = e[r]).left == n.right; r++); else for (var i = e.length - 1; i >= 0 && (n = e[i]).left == n.right; i--); return n } function Rn(e) { if (e.measure && (e.measure.cache = {}, e.measure.heights = null, e.rest)) for (var t = 0; t < e.rest.length; t++)e.measure.caches[t] = {} } function Pn(e) { e.display.externalMeasure = null, A(e.display.lineMeasure); for (var t = 0; t < e.display.view.length; t++)Rn(e.display.view[t]) } function _n(e) { Pn(e), e.display.cachedCharWidth = e.display.cachedTextHeight = e.display.cachedPaddingH = null, e.options.lineWrapping || (e.display.maxLineChanged = !0), e.display.lineNumChars = null } function Wn() { return c && g ? -(document.body.getBoundingClientRect().left - parseInt(getComputedStyle(document.body).marginLeft)) : window.pageXOffset || (document.documentElement || document.body).scrollLeft } function jn() { return c && g ? -(document.body.getBoundingClientRect().top - parseInt(getComputedStyle(document.body).marginTop)) : window.pageYOffset || (document.documentElement || document.body).scrollTop } function qn(e) { var t = 0; if (e.widgets) for (var n = 0; n < e.widgets.length; ++n)e.widgets[n].above && (t += Dn(e.widgets[n])); return t } function Un(e, t, n, r, i) { if (!i) { var o = qn(t); n.top += o, n.bottom += o } if ("line" == r) return n; r || (r = "local"); var a = qt(t); if ("local" == r ? a += wn(e.display) : a -= e.display.viewOffset, "page" == r || "window" == r) { var l = e.display.lineSpace.getBoundingClientRect(); a += l.top + ("window" == r ? 0 : jn()); var s = l.left + ("window" == r ? 0 : Wn()); n.left += s, n.right += s } return n.top += a, n.bottom += a, n } function $n(e, t, n) { if ("div" == n) return t; var r = t.left, i = t.top; if ("page" == n) r -= Wn(), i -= jn(); else if ("local" == n || !n) { var o = e.display.sizer.getBoundingClientRect(); r += o.left, i += o.top } var a = e.display.lineSpace.getBoundingClientRect(); return { left: r - a.left, top: i - a.top } } function Gn(e, t, n, r, i) { return r || (r = Ge(e.doc, t.line)), Un(e, r, Ln(e, r, t.ch, i), n) } function Vn(e, t, n, r, i, o) { function a(t, a) { var l = Nn(e, i, t, a ? "right" : "left", o); return a ? l.left = l.right : l.right = l.left, Un(e, r, l, n) } r = r || Ge(e.doc, t.line), i || (i = Bn(e, r)); var l = ue(r, e.doc.direction), s = t.ch, u = t.sticky; if (s >= r.text.length ? (s = r.text.length, u = "before") : s <= 0 && (s = 0, u = "after"), !l) return a("before" == u ? s - 1 : s, "before" == u); function c(e, t, n) { return a(n ? e - 1 : e, 1 == l[t].level != n) } var d = le(l, s, u), h = ae, f = c(s, d, "before" == u); return null != h && (f.other = c(s, h, "before" != u)), f } function Kn(e, t) { var n = 0; t = lt(e.doc, t), e.options.lineWrapping || (n = ir(e.display) * t.ch); var r = Ge(e.doc, t.line), i = qt(r) + wn(e.display); return { left: n, right: n, top: i, bottom: i + r.height } } function Xn(e, t, n, r, i) { var o = et(e, t, n); return o.xRel = i, r && (o.outside = r), o } function Zn(e, t, n) { var r = e.doc; if ((n += e.display.viewOffset) < 0) return Xn(r.first, 0, null, -1, -1); var i = Ye(r, n), o = r.first + r.size - 1; if (i > o) return Xn(r.first + r.size - 1, Ge(r, o).text.length, null, 1, 1); t < 0 && (t = 0); for (var a = Ge(r, i); ;) { var l = er(e, a, i, t, n), s = zt(a, l.ch + (l.xRel > 0 || l.outside > 0 ? 1 : 0)); if (!s) return l; var u = s.find(1); if (u.line == i) return u; a = Ge(r, i = u.line) } } function Yn(e, t, n, r) { r -= qn(t); var i = t.text.length, o = oe((function (t) { return Nn(e, n, t - 1).bottom <= r }), i, 0); return { begin: o, end: i = oe((function (t) { return Nn(e, n, t).top > r }), o, i) } } function Qn(e, t, n, r) { return n || (n = Bn(e, t)), Yn(e, t, n, Un(e, t, Nn(e, n, r), "line").top) } function Jn(e, t, n, r) { return !(e.bottom <= n) && (e.top > n || (r ? e.left : e.right) > t) } function er(e, t, n, r, i) { i -= qt(t); var o = Bn(e, t), a = qn(t), l = 0, s = t.text.length, u = !0, c = ue(t, e.doc.direction); if (c) { var d = (e.options.lineWrapping ? nr : tr)(e, t, n, o, c, r, i); l = (u = 1 != d.level) ? d.from : d.to - 1, s = u ? d.to : d.from - 1 } var h, f, p = null, m = null, g = oe((function (t) { var n = Nn(e, o, t); return n.top += a, n.bottom += a, !!Jn(n, r, i, !1) && (n.top <= i && n.left <= r && (p = t, m = n), !0) }), l, s), v = !1; if (m) { var x = r - m.left < m.right - r, y = x == u; g = p + (y ? 0 : 1), f = y ? "after" : "before", h = x ? m.left : m.right } else { u || g != s && g != l || g++, f = 0 == g ? "after" : g == t.text.length ? "before" : Nn(e, o, g - (u ? 1 : 0)).bottom + a <= i == u ? "after" : "before"; var b = Vn(e, et(n, g, f), "line", t, o); h = b.left, v = i < b.top ? -1 : i >= b.bottom ? 1 : 0 } return Xn(n, g = ie(t.text, g, 1), f, v, r - h) } function tr(e, t, n, r, i, o, a) { var l = oe((function (l) { var s = i[l], u = 1 != s.level; return Jn(Vn(e, et(n, u ? s.to : s.from, u ? "before" : "after"), "line", t, r), o, a, !0) }), 0, i.length - 1), s = i[l]; if (l > 0) { var u = 1 != s.level, c = Vn(e, et(n, u ? s.from : s.to, u ? "after" : "before"), "line", t, r); Jn(c, o, a, !0) && c.top > a && (s = i[l - 1]) } return s } function nr(e, t, n, r, i, o, a) { var l = Yn(e, t, r, a), s = l.begin, u = l.end; /\s/.test(t.text.charAt(u - 1)) && u--; for (var c = null, d = null, h = 0; h < i.length; h++) { var f = i[h]; if (!(f.from >= u || f.to <= s)) { var p = Nn(e, r, 1 != f.level ? Math.min(u, f.to) - 1 : Math.max(s, f.from)).right, m = p < o ? o - p + 1e9 : p - o; (!c || d > m) && (c = f, d = m) } } return c || (c = i[i.length - 1]), c.from < s && (c = { from: s, to: c.to, level: c.level }), c.to > u && (c = { from: c.from, to: u, level: c.level }), c } function rr(e) { if (null != e.cachedTextHeight) return e.cachedTextHeight; if (null == On) { On = T("pre", null, "CodeMirror-line-like"); for (var t = 0; t < 49; ++t)On.appendChild(document.createTextNode("x")), On.appendChild(T("br")); On.appendChild(document.createTextNode("x")) } E(e.measure, On); var n = On.offsetHeight / 50; return n > 3 && (e.cachedTextHeight = n), A(e.measure), n || 1 } function ir(e) { if (null != e.cachedCharWidth) return e.cachedCharWidth; var t = T("span", "xxxxxxxxxx"), n = T("pre", [t], "CodeMirror-line-like"); E(e.measure, n); var r = t.getBoundingClientRect(), i = (r.right - r.left) / 10; return i > 2 && (e.cachedCharWidth = i), i || 10 } function or(e) { for (var t = e.display, n = {}, r = {}, i = t.gutters.clientLeft, o = t.gutters.firstChild, a = 0; o; o = o.nextSibling, ++a) { var l = e.display.gutterSpecs[a].className; n[l] = o.offsetLeft + o.clientLeft + i, r[l] = o.clientWidth } return { fixedPos: ar(t), gutterTotalWidth: t.gutters.offsetWidth, gutterLeft: n, gutterWidth: r, wrapperWidth: t.wrapper.clientWidth } } function ar(e) { return e.scroller.getBoundingClientRect().left - e.sizer.getBoundingClientRect().left } function lr(e) { var t = rr(e.display), n = e.options.lineWrapping, r = n && Math.max(5, e.display.scroller.clientWidth / ir(e.display) - 3); return function (i) { if (Wt(e.doc, i)) return 0; var o = 0; if (i.widgets) for (var a = 0; a < i.widgets.length; a++)i.widgets[a].height && (o += i.widgets[a].height); return n ? o + (Math.ceil(i.text.length / r) || 1) * t : o + t } } function sr(e) { var t = e.doc, n = lr(e); t.iter((function (e) { var t = n(e); t != e.height && Xe(e, t) })) } function ur(e, t, n, r) { var i = e.display; if (!n && "true" == we(t).getAttribute("cm-not-content")) return null; var o, a, l = i.lineSpace.getBoundingClientRect(); try { o = t.clientX - l.left, a = t.clientY - l.top } catch (e) { return null } var s, u = Zn(e, o, a); if (r && u.xRel > 0 && (s = Ge(e.doc, u.line).text).length == u.ch) { var c = R(s, s.length, e.options.tabSize) - s.length; u = et(u.line, Math.max(0, Math.round((o - Sn(e.display).left) / ir(e.display)) - c)) } return u } function cr(e, t) { if (t >= e.display.viewTo) return null; if ((t -= e.display.viewFrom) < 0) return null; for (var n = e.display.view, r = 0; r < n.length; r++)if ((t -= n[r].size) < 0) return r } function dr(e, t, n, r) { null == t && (t = e.doc.first), null == n && (n = e.doc.first + e.doc.size), r || (r = 0); var i = e.display; if (r && n < i.viewTo && (null == i.updateLineNumbers || i.updateLineNumbers > t) && (i.updateLineNumbers = t), e.curOp.viewChanged = !0, t >= i.viewTo) Ct && Pt(e.doc, t) < i.viewTo && fr(e); else if (n <= i.viewFrom) Ct && _t(e.doc, n + r) > i.viewFrom ? fr(e) : (i.viewFrom += r, i.viewTo += r); else if (t <= i.viewFrom && n >= i.viewTo) fr(e); else if (t <= i.viewFrom) { var o = pr(e, n, n + r, 1); o ? (i.view = i.view.slice(o.index), i.viewFrom = o.lineN, i.viewTo += r) : fr(e) } else if (n >= i.viewTo) { var a = pr(e, t, t, -1); a ? (i.view = i.view.slice(0, a.index), i.viewTo = a.lineN) : fr(e) } else { var l = pr(e, t, t, -1), s = pr(e, n, n + r, 1); l && s ? (i.view = i.view.slice(0, l.index).concat(on(e, l.lineN, s.lineN)).concat(i.view.slice(s.index)), i.viewTo += r) : fr(e) } var u = i.externalMeasured; u && (n < u.lineN ? u.lineN += r : t < u.lineN + u.size && (i.externalMeasured = null)) } function hr(e, t, n) { e.curOp.viewChanged = !0; var r = e.display, i = e.display.externalMeasured; if (i && t >= i.lineN && t < i.lineN + i.size && (r.externalMeasured = null), !(t < r.viewFrom || t >= r.viewTo)) { var o = r.view[cr(e, t)]; if (null != o.node) { var a = o.changes || (o.changes = []); -1 == _(a, n) && a.push(n) } } } function fr(e) { e.display.viewFrom = e.display.viewTo = e.doc.first, e.display.view = [], e.display.viewOffset = 0 } function pr(e, t, n, r) { var i, o = cr(e, t), a = e.display.view; if (!Ct || n == e.doc.first + e.doc.size) return { index: o, lineN: n }; for (var l = e.display.viewFrom, s = 0; s < o; s++)l += a[s].size; if (l != t) { if (r > 0) { if (o == a.length - 1) return null; i = l + a[o].size - t, o++ } else i = l - t; t += i, n += i } for (; Pt(e.doc, n) != n;) { if (o == (r < 0 ? 0 : a.length - 1)) return null; n += r * a[o - (r < 0 ? 1 : 0)].size, o += r } return { index: o, lineN: n } } function mr(e) { for (var t = e.display.view, n = 0, r = 0; r < t.length; r++) { var i = t[r]; i.hidden || i.node && !i.changes || ++n } return n } function gr(e) { e.display.input.showSelection(e.display.input.prepareSelection()) } function vr(e, t) { void 0 === t && (t = !0); for (var n = e.doc, r = {}, i = r.cursors = document.createDocumentFragment(), o = r.selection = document.createDocumentFragment(), a = 0; a < n.sel.ranges.length; a++)if (t || a != n.sel.primIndex) { var l = n.sel.ranges[a]; if (!(l.from().line >= e.display.viewTo || l.to().line < e.display.viewFrom)) { var s = l.empty(); (s || e.options.showCursorWhenSelecting) && xr(e, l.head, i), s || br(e, l, o) } } return r } function xr(e, t, n) { var r = Vn(e, t, "div", null, null, !e.options.singleCursorHeightPerLine), i = n.appendChild(T("div", " ", "CodeMirror-cursor")); if (i.style.left = r.left + "px", i.style.top = r.top + "px", i.style.height = Math.max(0, r.bottom - r.top) * e.options.cursorHeight + "px", r.other) { var o = n.appendChild(T("div", " ", "CodeMirror-cursor CodeMirror-secondarycursor")); o.style.display = "", o.style.left = r.other.left + "px", o.style.top = r.other.top + "px", o.style.height = .85 * (r.other.bottom - r.other.top) + "px" } } function yr(e, t) { return e.top - t.top || e.left - t.left } function br(e, t, n) { var r = e.display, i = e.doc, o = document.createDocumentFragment(), a = Sn(e.display), l = a.left, s = Math.max(r.sizerWidth, An(e) - r.sizer.offsetLeft) - a.right, u = "ltr" == i.direction; function c(e, t, n, r) { t < 0 && (t = 0), t = Math.round(t), r = Math.round(r), o.appendChild(T("div", null, "CodeMirror-selected", "position: absolute; left: " + e + "px;\n top: " + t + "px; width: " + (null == n ? s - e : n) + "px;\n height: " + (r - t) + "px")) } function d(t, n, r) { var o, a, d = Ge(i, t), h = d.text.length; function f(n, r) { return Gn(e, et(t, n), "div", d, r) } function p(t, n, r) { var i = Qn(e, d, null, t), o = "ltr" == n == ("after" == r) ? "left" : "right"; return f("after" == r ? i.begin : i.end - (/\s/.test(d.text.charAt(i.end - 1)) ? 2 : 1), o)[o] } var m = ue(d, i.direction); return function (e, t, n, r) { if (!e) return r(t, n, "ltr", 0); for (var i = !1, o = 0; o < e.length; ++o) { var a = e[o]; (a.from < n && a.to > t || t == n && a.to == t) && (r(Math.max(a.from, t), Math.min(a.to, n), 1 == a.level ? "rtl" : "ltr", o), i = !0) } i || r(t, n, "ltr") }(m, n || 0, null == r ? h : r, (function (e, t, i, d) { var g = "ltr" == i, v = f(e, g ? "left" : "right"), x = f(t - 1, g ? "right" : "left"), y = null == n && 0 == e, b = null == r && t == h, D = 0 == d, C = !m || d == m.length - 1; if (x.top - v.top <= 3) { var w = (u ? b : y) && C, k = (u ? y : b) && D ? l : (g ? v : x).left, S = w ? s : (g ? x : v).right; c(k, v.top, S - k, v.bottom) } else { var F, A, E, T; g ? (F = u && y && D ? l : v.left, A = u ? s : p(e, i, "before"), E = u ? l : p(t, i, "after"), T = u && b && C ? s : x.right) : (F = u ? p(e, i, "before") : l, A = !u && y && D ? s : v.right, E = !u && b && C ? l : x.left, T = u ? p(t, i, "after") : s), c(F, v.top, A - F, v.bottom), v.bottom < x.top && c(l, v.bottom, null, x.top), c(E, x.top, T - E, x.bottom) } (!o || yr(v, o) < 0) && (o = v), yr(x, o) < 0 && (o = x), (!a || yr(v, a) < 0) && (a = v), yr(x, a) < 0 && (a = x) })), { start: o, end: a } } var h = t.from(), f = t.to(); if (h.line == f.line) d(h.line, h.ch, f.ch); else { var p = Ge(i, h.line), m = Ge(i, f.line), g = Rt(p) == Rt(m), v = d(h.line, h.ch, g ? p.text.length + 1 : null).end, x = d(f.line, g ? 0 : null, f.ch).start; g && (v.top < x.top - 2 ? (c(v.right, v.top, null, v.bottom), c(l, x.top, x.left, x.bottom)) : c(v.right, v.top, x.left - v.right, v.bottom)), v.bottom < x.top && c(l, v.bottom, null, x.top) } n.appendChild(o) } function Dr(e) { if (e.state.focused) { var t = e.display; clearInterval(t.blinker); var n = !0; t.cursorDiv.style.visibility = "", e.options.cursorBlinkRate > 0 ? t.blinker = setInterval((function () { e.hasFocus() || Sr(e), t.cursorDiv.style.visibility = (n = !n) ? "" : "hidden" }), e.options.cursorBlinkRate) : e.options.cursorBlinkRate < 0 && (t.cursorDiv.style.visibility = "hidden") } } function Cr(e) { e.hasFocus() || (e.display.input.focus(), e.state.focused || kr(e)) } function wr(e) { e.state.delayingBlurEvent = !0, setTimeout((function () { e.state.delayingBlurEvent && (e.state.delayingBlurEvent = !1, e.state.focused && Sr(e)) }), 100) } function kr(e, t) { e.state.delayingBlurEvent && !e.state.draggingText && (e.state.delayingBlurEvent = !1), "nocursor" != e.options.readOnly && (e.state.focused || (pe(e, "focus", e, t), e.state.focused = !0, N(e.display.wrapper, "CodeMirror-focused"), e.curOp || e.display.selForContextMenu == e.doc.sel || (e.display.input.reset(), s && setTimeout((function () { return e.display.input.reset(!0) }), 20)), e.display.input.receivedFocus()), Dr(e)) } function Sr(e, t) { e.state.delayingBlurEvent || (e.state.focused && (pe(e, "blur", e, t), e.state.focused = !1, F(e.display.wrapper, "CodeMirror-focused")), clearInterval(e.display.blinker), setTimeout((function () { e.state.focused || (e.display.shift = !1) }), 150)) } function Fr(e) { for (var t = e.display, n = t.lineDiv.offsetTop, r = 0; r < t.view.length; r++) { var i = t.view[r], o = e.options.lineWrapping, s = void 0, u = 0; if (!i.hidden) { if (a && l < 8) { var c = i.node.offsetTop + i.node.offsetHeight; s = c - n, n = c } else { var d = i.node.getBoundingClientRect(); s = d.bottom - d.top, !o && i.text.firstChild && (u = i.text.firstChild.getBoundingClientRect().right - d.left - 1) } var h = i.line.height - s; if ((h > .005 || h < -.005) && (Xe(i.line, s), Ar(i.line), i.rest)) for (var f = 0; f < i.rest.length; f++)Ar(i.rest[f]); if (u > e.display.sizerWidth) { var p = Math.ceil(u / ir(e.display)); p > e.display.maxLineLength && (e.display.maxLineLength = p, e.display.maxLine = i.line, e.display.maxLineChanged = !0) } } } } function Ar(e) { if (e.widgets) for (var t = 0; t < e.widgets.length; ++t) { var n = e.widgets[t], r = n.node.parentNode; r && (n.height = r.offsetHeight) } } function Er(e, t, n) { var r = n && null != n.top ? Math.max(0, n.top) : e.scroller.scrollTop; r = Math.floor(r - wn(e)); var i = n && null != n.bottom ? n.bottom : r + e.wrapper.clientHeight, o = Ye(t, r), a = Ye(t, i); if (n && n.ensure) { var l = n.ensure.from.line, s = n.ensure.to.line; l < o ? (o = l, a = Ye(t, qt(Ge(t, l)) + e.wrapper.clientHeight)) : Math.min(s, t.lastLine()) >= a && (o = Ye(t, qt(Ge(t, s)) - e.wrapper.clientHeight), a = s) } return { from: o, to: Math.max(a, o + 1) } } function Tr(e, t) { var n = e.display, r = rr(e.display); t.top < 0 && (t.top = 0); var i = e.curOp && null != e.curOp.scrollTop ? e.curOp.scrollTop : n.scroller.scrollTop, o = En(e), a = {}; t.bottom - t.top > o && (t.bottom = t.top + o); var l = e.doc.height + kn(n), s = t.top < r, u = t.bottom > l - r; if (t.top < i) a.scrollTop = s ? 0 : t.top; else if (t.bottom > i + o) { var c = Math.min(t.top, (u ? l : t.bottom) - o); c != i && (a.scrollTop = c) } var d = e.options.fixedGutter ? 0 : n.gutters.offsetWidth, h = e.curOp && null != e.curOp.scrollLeft ? e.curOp.scrollLeft : n.scroller.scrollLeft - d, f = An(e) - n.gutters.offsetWidth, p = t.right - t.left > f; return p && (t.right = t.left + f), t.left < 10 ? a.scrollLeft = 0 : t.left < h ? a.scrollLeft = Math.max(0, t.left + d - (p ? 0 : 10)) : t.right > f + h - 3 && (a.scrollLeft = t.right + (p ? 0 : 10) - f), a } function Lr(e, t) { null != t && (Nr(e), e.curOp.scrollTop = (null == e.curOp.scrollTop ? e.doc.scrollTop : e.curOp.scrollTop) + t) } function Mr(e) { Nr(e); var t = e.getCursor(); e.curOp.scrollToPos = { from: t, to: t, margin: e.options.cursorScrollMargin } } function Br(e, t, n) { null == t && null == n || Nr(e), null != t && (e.curOp.scrollLeft = t), null != n && (e.curOp.scrollTop = n) } function Nr(e) { var t = e.curOp.scrollToPos; t && (e.curOp.scrollToPos = null, Or(e, Kn(e, t.from), Kn(e, t.to), t.margin)) } function Or(e, t, n, r) { var i = Tr(e, { left: Math.min(t.left, n.left), top: Math.min(t.top, n.top) - r, right: Math.max(t.right, n.right), bottom: Math.max(t.bottom, n.bottom) + r }); Br(e, i.scrollLeft, i.scrollTop) } function Ir(e, t) { Math.abs(e.doc.scrollTop - t) < 2 || (n || si(e, { top: t }), zr(e, t, !0), n && si(e), ri(e, 100)) } function zr(e, t, n) { t = Math.max(0, Math.min(e.display.scroller.scrollHeight - e.display.scroller.clientHeight, t)), (e.display.scroller.scrollTop != t || n) && (e.doc.scrollTop = t, e.display.scrollbars.setScrollTop(t), e.display.scroller.scrollTop != t && (e.display.scroller.scrollTop = t)) } function Hr(e, t, n, r) { t = Math.max(0, Math.min(t, e.display.scroller.scrollWidth - e.display.scroller.clientWidth)), (n ? t == e.doc.scrollLeft : Math.abs(e.doc.scrollLeft - t) < 2) && !r || (e.doc.scrollLeft = t, di(e), e.display.scroller.scrollLeft != t && (e.display.scroller.scrollLeft = t), e.display.scrollbars.setScrollLeft(t)) } function Rr(e) { var t = e.display, n = t.gutters.offsetWidth, r = Math.round(e.doc.height + kn(e.display)); return { clientHeight: t.scroller.clientHeight, viewHeight: t.wrapper.clientHeight, scrollWidth: t.scroller.scrollWidth, clientWidth: t.scroller.clientWidth, viewWidth: t.wrapper.clientWidth, barLeft: e.options.fixedGutter ? n : 0, docHeight: r, scrollHeight: r + Fn(e) + t.barHeight, nativeBarWidth: t.nativeBarWidth, gutterWidth: n } } var Pr = function (e, t, n) { this.cm = n; var r = this.vert = T("div", [T("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar"), i = this.horiz = T("div", [T("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar"); r.tabIndex = i.tabIndex = -1, e(r), e(i), de(r, "scroll", (function () { r.clientHeight && t(r.scrollTop, "vertical") })), de(i, "scroll", (function () { i.clientWidth && t(i.scrollLeft, "horizontal") })), this.checkedZeroWidth = !1, a && l < 8 && (this.horiz.style.minHeight = this.vert.style.minWidth = "18px") }; Pr.prototype.update = function (e) { var t = e.scrollWidth > e.clientWidth + 1, n = e.scrollHeight > e.clientHeight + 1, r = e.nativeBarWidth; if (n) { this.vert.style.display = "block", this.vert.style.bottom = t ? r + "px" : "0"; var i = e.viewHeight - (t ? r : 0); this.vert.firstChild.style.height = Math.max(0, e.scrollHeight - e.clientHeight + i) + "px" } else this.vert.style.display = "", this.vert.firstChild.style.height = "0"; if (t) { this.horiz.style.display = "block", this.horiz.style.right = n ? r + "px" : "0", this.horiz.style.left = e.barLeft + "px"; var o = e.viewWidth - e.barLeft - (n ? r : 0); this.horiz.firstChild.style.width = Math.max(0, e.scrollWidth - e.clientWidth + o) + "px" } else this.horiz.style.display = "", this.horiz.firstChild.style.width = "0"; return !this.checkedZeroWidth && e.clientHeight > 0 && (0 == r && this.zeroWidthHack(), this.checkedZeroWidth = !0), { right: n ? r : 0, bottom: t ? r : 0 } }, Pr.prototype.setScrollLeft = function (e) { this.horiz.scrollLeft != e && (this.horiz.scrollLeft = e), this.disableHoriz && this.enableZeroWidthBar(this.horiz, this.disableHoriz, "horiz") }, Pr.prototype.setScrollTop = function (e) { this.vert.scrollTop != e && (this.vert.scrollTop = e), this.disableVert && this.enableZeroWidthBar(this.vert, this.disableVert, "vert") }, Pr.prototype.zeroWidthHack = function () { var e = x && !f ? "12px" : "18px"; this.horiz.style.height = this.vert.style.width = e, this.horiz.style.pointerEvents = this.vert.style.pointerEvents = "none", this.disableHoriz = new P, this.disableVert = new P }, Pr.prototype.enableZeroWidthBar = function (e, t, n) { e.style.pointerEvents = "auto", t.set(1e3, (function r() { var i = e.getBoundingClientRect(); ("vert" == n ? document.elementFromPoint(i.right - 1, (i.top + i.bottom) / 2) : document.elementFromPoint((i.right + i.left) / 2, i.bottom - 1)) != e ? e.style.pointerEvents = "none" : t.set(1e3, r) })) }, Pr.prototype.clear = function () { var e = this.horiz.parentNode; e.removeChild(this.horiz), e.removeChild(this.vert) }; var _r = function () { }; function Wr(e, t) { t || (t = Rr(e)); var n = e.display.barWidth, r = e.display.barHeight; jr(e, t); for (var i = 0; i < 4 && n != e.display.barWidth || r != e.display.barHeight; i++)n != e.display.barWidth && e.options.lineWrapping && Fr(e), jr(e, Rr(e)), n = e.display.barWidth, r = e.display.barHeight } function jr(e, t) { var n = e.display, r = n.scrollbars.update(t); n.sizer.style.paddingRight = (n.barWidth = r.right) + "px", n.sizer.style.paddingBottom = (n.barHeight = r.bottom) + "px", n.heightForcer.style.borderBottom = r.bottom + "px solid transparent", r.right && r.bottom ? (n.scrollbarFiller.style.display = "block", n.scrollbarFiller.style.height = r.bottom + "px", n.scrollbarFiller.style.width = r.right + "px") : n.scrollbarFiller.style.display = "", r.bottom && e.options.coverGutterNextToScrollbar && e.options.fixedGutter ? (n.gutterFiller.style.display = "block", n.gutterFiller.style.height = r.bottom + "px", n.gutterFiller.style.width = t.gutterWidth + "px") : n.gutterFiller.style.display = "" } _r.prototype.update = function () { return { bottom: 0, right: 0 } }, _r.prototype.setScrollLeft = function () { }, _r.prototype.setScrollTop = function () { }, _r.prototype.clear = function () { }; var qr = { native: Pr, null: _r }; function Ur(e) { e.display.scrollbars && (e.display.scrollbars.clear(), e.display.scrollbars.addClass && F(e.display.wrapper, e.display.scrollbars.addClass)), e.display.scrollbars = new qr[e.options.scrollbarStyle]((function (t) { e.display.wrapper.insertBefore(t, e.display.scrollbarFiller), de(t, "mousedown", (function () { e.state.focused && setTimeout((function () { return e.display.input.focus() }), 0) })), t.setAttribute("cm-not-content", "true") }), (function (t, n) { "horizontal" == n ? Hr(e, t) : Ir(e, t) }), e), e.display.scrollbars.addClass && N(e.display.wrapper, e.display.scrollbars.addClass) } var $r = 0; function Gr(e) { var t; e.curOp = { cm: e, viewChanged: !1, startHeight: e.doc.height, forceUpdate: !1, updateInput: 0, typing: !1, changeObjs: null, cursorActivityHandlers: null, cursorActivityCalled: 0, selectionChanged: !1, updateMaxLine: !1, scrollLeft: null, scrollTop: null, scrollToPos: null, focus: !1, id: ++$r }, t = e.curOp, an ? an.ops.push(t) : t.ownsGroup = an = { ops: [t], delayedCallbacks: [] } } function Vr(e) { var t = e.curOp; t && function (e, t) { var n = e.ownsGroup; if (n) try { !function (e) { var t = e.delayedCallbacks, n = 0; do { for (; n < t.length; n++)t[n].call(null); for (var r = 0; r < e.ops.length; r++) { var i = e.ops[r]; if (i.cursorActivityHandlers) for (; i.cursorActivityCalled < i.cursorActivityHandlers.length;)i.cursorActivityHandlers[i.cursorActivityCalled++].call(null, i.cm) } } while (n < t.length) }(n) } finally { an = null, t(n) } }(t, (function (e) { for (var t = 0; t < e.ops.length; t++)e.ops[t].cm.curOp = null; !function (e) { for (var t = e.ops, n = 0; n < t.length; n++)Kr(t[n]); for (var r = 0; r < t.length; r++)Xr(t[r]); for (var i = 0; i < t.length; i++)Zr(t[i]); for (var o = 0; o < t.length; o++)Yr(t[o]); for (var a = 0; a < t.length; a++)Qr(t[a]) }(e) })) } function Kr(e) { var t = e.cm, n = t.display; !function (e) { var t = e.display; !t.scrollbarsClipped && t.scroller.offsetWidth && (t.nativeBarWidth = t.scroller.offsetWidth - t.scroller.clientWidth, t.heightForcer.style.height = Fn(e) + "px", t.sizer.style.marginBottom = -t.nativeBarWidth + "px", t.sizer.style.borderRightWidth = Fn(e) + "px", t.scrollbarsClipped = !0) }(t), e.updateMaxLine && $t(t), e.mustUpdate = e.viewChanged || e.forceUpdate || null != e.scrollTop || e.scrollToPos && (e.scrollToPos.from.line < n.viewFrom || e.scrollToPos.to.line >= n.viewTo) || n.maxLineChanged && t.options.lineWrapping, e.update = e.mustUpdate && new oi(t, e.mustUpdate && { top: e.scrollTop, ensure: e.scrollToPos }, e.forceUpdate) } function Xr(e) { e.updatedDisplay = e.mustUpdate && ai(e.cm, e.update) } function Zr(e) { var t = e.cm, n = t.display; e.updatedDisplay && Fr(t), e.barMeasure = Rr(t), n.maxLineChanged && !t.options.lineWrapping && (e.adjustWidthTo = Ln(t, n.maxLine, n.maxLine.text.length).left + 3, t.display.sizerWidth = e.adjustWidthTo, e.barMeasure.scrollWidth = Math.max(n.scroller.clientWidth, n.sizer.offsetLeft + e.adjustWidthTo + Fn(t) + t.display.barWidth), e.maxScrollLeft = Math.max(0, n.sizer.offsetLeft + e.adjustWidthTo - An(t))), (e.updatedDisplay || e.selectionChanged) && (e.preparedSelection = n.input.prepareSelection()) } function Yr(e) { var t = e.cm; null != e.adjustWidthTo && (t.display.sizer.style.minWidth = e.adjustWidthTo + "px", e.maxScrollLeft < t.doc.scrollLeft && Hr(t, Math.min(t.display.scroller.scrollLeft, e.maxScrollLeft), !0), t.display.maxLineChanged = !1); var n = e.focus && e.focus == B(); e.preparedSelection && t.display.input.showSelection(e.preparedSelection, n), (e.updatedDisplay || e.startHeight != t.doc.height) && Wr(t, e.barMeasure), e.updatedDisplay && ci(t, e.barMeasure), e.selectionChanged && Dr(t), t.state.focused && e.updateInput && t.display.input.reset(e.typing), n && Cr(e.cm) } function Qr(e) { var t = e.cm, n = t.display, r = t.doc; (e.updatedDisplay && li(t, e.update), null == n.wheelStartX || null == e.scrollTop && null == e.scrollLeft && !e.scrollToPos || (n.wheelStartX = n.wheelStartY = null), null != e.scrollTop && zr(t, e.scrollTop, e.forceScroll), null != e.scrollLeft && Hr(t, e.scrollLeft, !0, !0), e.scrollToPos) && function (e, t) { if (!me(e, "scrollCursorIntoView")) { var n = e.display, r = n.sizer.getBoundingClientRect(), i = null; if (t.top + r.top < 0 ? i = !0 : t.bottom + r.top > (window.innerHeight || document.documentElement.clientHeight) && (i = !1), null != i && !p) { var o = T("div", "​", null, "position: absolute;\n top: " + (t.top - n.viewOffset - wn(e.display)) + "px;\n height: " + (t.bottom - t.top + Fn(e) + n.barHeight) + "px;\n left: " + t.left + "px; width: " + Math.max(2, t.right - t.left) + "px;"); e.display.lineSpace.appendChild(o), o.scrollIntoView(i), e.display.lineSpace.removeChild(o) } } }(t, function (e, t, n, r) { var i; null == r && (r = 0), e.options.lineWrapping || t != n || (n = "before" == (t = t.ch ? et(t.line, "before" == t.sticky ? t.ch - 1 : t.ch, "after") : t).sticky ? et(t.line, t.ch + 1, "before") : t); for (var o = 0; o < 5; o++) { var a = !1, l = Vn(e, t), s = n && n != t ? Vn(e, n) : l, u = Tr(e, i = { left: Math.min(l.left, s.left), top: Math.min(l.top, s.top) - r, right: Math.max(l.left, s.left), bottom: Math.max(l.bottom, s.bottom) + r }), c = e.doc.scrollTop, d = e.doc.scrollLeft; if (null != u.scrollTop && (Ir(e, u.scrollTop), Math.abs(e.doc.scrollTop - c) > 1 && (a = !0)), null != u.scrollLeft && (Hr(e, u.scrollLeft), Math.abs(e.doc.scrollLeft - d) > 1 && (a = !0)), !a) break } return i }(t, lt(r, e.scrollToPos.from), lt(r, e.scrollToPos.to), e.scrollToPos.margin)); var i = e.maybeHiddenMarkers, o = e.maybeUnhiddenMarkers; if (i) for (var a = 0; a < i.length; ++a)i[a].lines.length || pe(i[a], "hide"); if (o) for (var l = 0; l < o.length; ++l)o[l].lines.length && pe(o[l], "unhide"); n.wrapper.offsetHeight && (r.scrollTop = t.display.scroller.scrollTop), e.changeObjs && pe(t, "changes", t, e.changeObjs), e.update && e.update.finish() } function Jr(e, t) { if (e.curOp) return t(); Gr(e); try { return t() } finally { Vr(e) } } function ei(e, t) { return function () { if (e.curOp) return t.apply(e, arguments); Gr(e); try { return t.apply(e, arguments) } finally { Vr(e) } } } function ti(e) { return function () { if (this.curOp) return e.apply(this, arguments); Gr(this); try { return e.apply(this, arguments) } finally { Vr(this) } } } function ni(e) { return function () { var t = this.cm; if (!t || t.curOp) return e.apply(this, arguments); Gr(t); try { return e.apply(this, arguments) } finally { Vr(t) } } } function ri(e, t) { e.doc.highlightFrontier < e.display.viewTo && e.state.highlight.set(t, z(ii, e)) } function ii(e) { var t = e.doc; if (!(t.highlightFrontier >= e.display.viewTo)) { var n = +new Date + e.options.workTime, r = ft(e, t.highlightFrontier), i = []; t.iter(r.line, Math.min(t.first + t.size, e.display.viewTo + 500), (function (o) { if (r.line >= e.display.viewFrom) { var a = o.styles, l = o.text.length > e.options.maxHighlightLength ? je(t.mode, r.state) : null, s = dt(e, o, r, !0); l && (r.state = l), o.styles = s.styles; var u = o.styleClasses, c = s.classes; c ? o.styleClasses = c : u && (o.styleClasses = null); for (var d = !a || a.length != o.styles.length || u != c && (!u || !c || u.bgClass != c.bgClass || u.textClass != c.textClass), h = 0; !d && h < a.length; ++h)d = a[h] != o.styles[h]; d && i.push(r.line), o.stateAfter = r.save(), r.nextLine() } else o.text.length <= e.options.maxHighlightLength && pt(e, o.text, r), o.stateAfter = r.line % 5 == 0 ? r.save() : null, r.nextLine(); if (+new Date > n) return ri(e, e.options.workDelay), !0 })), t.highlightFrontier = r.line, t.modeFrontier = Math.max(t.modeFrontier, r.line), i.length && Jr(e, (function () { for (var t = 0; t < i.length; t++)hr(e, i[t], "text") })) } } var oi = function (e, t, n) { var r = e.display; this.viewport = t, this.visible = Er(r, e.doc, t), this.editorIsHidden = !r.wrapper.offsetWidth, this.wrapperHeight = r.wrapper.clientHeight, this.wrapperWidth = r.wrapper.clientWidth, this.oldDisplayWidth = An(e), this.force = n, this.dims = or(e), this.events = [] }; function ai(e, t) { var n = e.display, r = e.doc; if (t.editorIsHidden) return fr(e), !1; if (!t.force && t.visible.from >= n.viewFrom && t.visible.to <= n.viewTo && (null == n.updateLineNumbers || n.updateLineNumbers >= n.viewTo) && n.renderedView == n.view && 0 == mr(e)) return !1; hi(e) && (fr(e), t.dims = or(e)); var i = r.first + r.size, o = Math.max(t.visible.from - e.options.viewportMargin, r.first), a = Math.min(i, t.visible.to + e.options.viewportMargin); n.viewFrom < o && o - n.viewFrom < 20 && (o = Math.max(r.first, n.viewFrom)), n.viewTo > a && n.viewTo - a < 20 && (a = Math.min(i, n.viewTo)), Ct && (o = Pt(e.doc, o), a = _t(e.doc, a)); var l = o != n.viewFrom || a != n.viewTo || n.lastWrapHeight != t.wrapperHeight || n.lastWrapWidth != t.wrapperWidth; !function (e, t, n) { var r = e.display; 0 == r.view.length || t >= r.viewTo || n <= r.viewFrom ? (r.view = on(e, t, n), r.viewFrom = t) : (r.viewFrom > t ? r.view = on(e, t, r.viewFrom).concat(r.view) : r.viewFrom < t && (r.view = r.view.slice(cr(e, t))), r.viewFrom = t, r.viewTo < n ? r.view = r.view.concat(on(e, r.viewTo, n)) : r.viewTo > n && (r.view = r.view.slice(0, cr(e, n)))), r.viewTo = n }(e, o, a), n.viewOffset = qt(Ge(e.doc, n.viewFrom)), e.display.mover.style.top = n.viewOffset + "px"; var u = mr(e); if (!l && 0 == u && !t.force && n.renderedView == n.view && (null == n.updateLineNumbers || n.updateLineNumbers >= n.viewTo)) return !1; var c = function (e) { if (e.hasFocus()) return null; var t = B(); if (!t || !M(e.display.lineDiv, t)) return null; var n = { activeElt: t }; if (window.getSelection) { var r = window.getSelection(); r.anchorNode && r.extend && M(e.display.lineDiv, r.anchorNode) && (n.anchorNode = r.anchorNode, n.anchorOffset = r.anchorOffset, n.focusNode = r.focusNode, n.focusOffset = r.focusOffset) } return n }(e); return u > 4 && (n.lineDiv.style.display = "none"), function (e, t, n) { var r = e.display, i = e.options.lineNumbers, o = r.lineDiv, a = o.firstChild; function l(t) { var n = t.nextSibling; return s && x && e.display.currentWheelTarget == t ? t.style.display = "none" : t.parentNode.removeChild(t), n } for (var u = r.view, c = r.viewFrom, d = 0; d < u.length; d++) { var h = u[d]; if (h.hidden); else if (h.node && h.node.parentNode == o) { for (; a != h.node;)a = l(a); var f = i && null != t && t <= c && h.lineNumber; h.changes && (_(h.changes, "gutter") > -1 && (f = !1), cn(e, h, c, n)), f && (A(h.lineNumber), h.lineNumber.appendChild(document.createTextNode(Je(e.options, c)))), a = h.node.nextSibling } else { var p = vn(e, h, c, n); o.insertBefore(p, a) } c += h.size } for (; a;)a = l(a) }(e, n.updateLineNumbers, t.dims), u > 4 && (n.lineDiv.style.display = ""), n.renderedView = n.view, function (e) { if (e && e.activeElt && e.activeElt != B() && (e.activeElt.focus(), !/^(INPUT|TEXTAREA)$/.test(e.activeElt.nodeName) && e.anchorNode && M(document.body, e.anchorNode) && M(document.body, e.focusNode))) { var t = window.getSelection(), n = document.createRange(); n.setEnd(e.anchorNode, e.anchorOffset), n.collapse(!1), t.removeAllRanges(), t.addRange(n), t.extend(e.focusNode, e.focusOffset) } }(c), A(n.cursorDiv), A(n.selectionDiv), n.gutters.style.height = n.sizer.style.minHeight = 0, l && (n.lastWrapHeight = t.wrapperHeight, n.lastWrapWidth = t.wrapperWidth, ri(e, 400)), n.updateLineNumbers = null, !0 } function li(e, t) { for (var n = t.viewport, r = !0; ; r = !1) { if (r && e.options.lineWrapping && t.oldDisplayWidth != An(e)) r && (t.visible = Er(e.display, e.doc, n)); else if (n && null != n.top && (n = { top: Math.min(e.doc.height + kn(e.display) - En(e), n.top) }), t.visible = Er(e.display, e.doc, n), t.visible.from >= e.display.viewFrom && t.visible.to <= e.display.viewTo) break; if (!ai(e, t)) break; Fr(e); var i = Rr(e); gr(e), Wr(e, i), ci(e, i), t.force = !1 } t.signal(e, "update", e), e.display.viewFrom == e.display.reportedViewFrom && e.display.viewTo == e.display.reportedViewTo || (t.signal(e, "viewportChange", e, e.display.viewFrom, e.display.viewTo), e.display.reportedViewFrom = e.display.viewFrom, e.display.reportedViewTo = e.display.viewTo) } function si(e, t) { var n = new oi(e, t); if (ai(e, n)) { Fr(e), li(e, n); var r = Rr(e); gr(e), Wr(e, r), ci(e, r), n.finish() } } function ui(e) { var t = e.gutters.offsetWidth; e.sizer.style.marginLeft = t + "px", sn(e, "gutterChanged", e) } function ci(e, t) { e.display.sizer.style.minHeight = t.docHeight + "px", e.display.heightForcer.style.top = t.docHeight + "px", e.display.gutters.style.height = t.docHeight + e.display.barHeight + Fn(e) + "px" } function di(e) { var t = e.display, n = t.view; if (t.alignWidgets || t.gutters.firstChild && e.options.fixedGutter) { for (var r = ar(t) - t.scroller.scrollLeft + e.doc.scrollLeft, i = t.gutters.offsetWidth, o = r + "px", a = 0; a < n.length; a++)if (!n[a].hidden) { e.options.fixedGutter && (n[a].gutter && (n[a].gutter.style.left = o), n[a].gutterBackground && (n[a].gutterBackground.style.left = o)); var l = n[a].alignable; if (l) for (var s = 0; s < l.length; s++)l[s].style.left = o } e.options.fixedGutter && (t.gutters.style.left = r + i + "px") } } function hi(e) { if (!e.options.lineNumbers) return !1; var t = e.doc, n = Je(e.options, t.first + t.size - 1), r = e.display; if (n.length != r.lineNumChars) { var i = r.measure.appendChild(T("div", [T("div", n)], "CodeMirror-linenumber CodeMirror-gutter-elt")), o = i.firstChild.offsetWidth, a = i.offsetWidth - o; return r.lineGutter.style.width = "", r.lineNumInnerWidth = Math.max(o, r.lineGutter.offsetWidth - a) + 1, r.lineNumWidth = r.lineNumInnerWidth + a, r.lineNumChars = r.lineNumInnerWidth ? n.length : -1, r.lineGutter.style.width = r.lineNumWidth + "px", ui(e.display), !0 } return !1 } function fi(e, t) { for (var n = [], r = !1, i = 0; i < e.length; i++) { var o = e[i], a = null; if ("string" != typeof o && (a = o.style, o = o.className), "CodeMirror-linenumbers" == o) { if (!t) continue; r = !0 } n.push({ className: o, style: a }) } return t && !r && n.push({ className: "CodeMirror-linenumbers", style: null }), n } function pi(e) { var t = e.gutters, n = e.gutterSpecs; A(t), e.lineGutter = null; for (var r = 0; r < n.length; ++r) { var i = n[r], o = i.className, a = i.style, l = t.appendChild(T("div", null, "CodeMirror-gutter " + o)); a && (l.style.cssText = a), "CodeMirror-linenumbers" == o && (e.lineGutter = l, l.style.width = (e.lineNumWidth || 1) + "px") } t.style.display = n.length ? "" : "none", ui(e) } function mi(e) { pi(e.display), dr(e), di(e) } function gi(e, t, r, i) { var o = this; this.input = r, o.scrollbarFiller = T("div", null, "CodeMirror-scrollbar-filler"), o.scrollbarFiller.setAttribute("cm-not-content", "true"), o.gutterFiller = T("div", null, "CodeMirror-gutter-filler"), o.gutterFiller.setAttribute("cm-not-content", "true"), o.lineDiv = L("div", null, "CodeMirror-code"), o.selectionDiv = T("div", null, null, "position: relative; z-index: 1"), o.cursorDiv = T("div", null, "CodeMirror-cursors"), o.measure = T("div", null, "CodeMirror-measure"), o.lineMeasure = T("div", null, "CodeMirror-measure"), o.lineSpace = L("div", [o.measure, o.lineMeasure, o.selectionDiv, o.cursorDiv, o.lineDiv], null, "position: relative; outline: none"); var u = L("div", [o.lineSpace], "CodeMirror-lines"); o.mover = T("div", [u], null, "position: relative"), o.sizer = T("div", [o.mover], "CodeMirror-sizer"), o.sizerWidth = null, o.heightForcer = T("div", null, null, "position: absolute; height: 50px; width: 1px;"), o.gutters = T("div", null, "CodeMirror-gutters"), o.lineGutter = null, o.scroller = T("div", [o.sizer, o.heightForcer, o.gutters], "CodeMirror-scroll"), o.scroller.setAttribute("tabIndex", "-1"), o.wrapper = T("div", [o.scrollbarFiller, o.gutterFiller, o.scroller], "CodeMirror"), a && l < 8 && (o.gutters.style.zIndex = -1, o.scroller.style.paddingRight = 0), s || n && v || (o.scroller.draggable = !0), e && (e.appendChild ? e.appendChild(o.wrapper) : e(o.wrapper)), o.viewFrom = o.viewTo = t.first, o.reportedViewFrom = o.reportedViewTo = t.first, o.view = [], o.renderedView = null, o.externalMeasured = null, o.viewOffset = 0, o.lastWrapHeight = o.lastWrapWidth = 0, o.updateLineNumbers = null, o.nativeBarWidth = o.barHeight = o.barWidth = 0, o.scrollbarsClipped = !1, o.lineNumWidth = o.lineNumInnerWidth = o.lineNumChars = null, o.alignWidgets = !1, o.cachedCharWidth = o.cachedTextHeight = o.cachedPaddingH = null, o.maxLine = null, o.maxLineLength = 0, o.maxLineChanged = !1, o.wheelDX = o.wheelDY = o.wheelStartX = o.wheelStartY = null, o.shift = !1, o.selForContextMenu = null, o.activeTouch = null, o.gutterSpecs = fi(i.gutters, i.lineNumbers), pi(o), r.init(o) } oi.prototype.signal = function (e, t) { ve(e, t) && this.events.push(arguments) }, oi.prototype.finish = function () { for (var e = 0; e < this.events.length; e++)pe.apply(null, this.events[e]) }; var vi = 0, xi = null; function yi(e) { var t = e.wheelDeltaX, n = e.wheelDeltaY; return null == t && e.detail && e.axis == e.HORIZONTAL_AXIS && (t = e.detail), null == n && e.detail && e.axis == e.VERTICAL_AXIS ? n = e.detail : null == n && (n = e.wheelDelta), { x: t, y: n } } function bi(e) { var t = yi(e); return t.x *= xi, t.y *= xi, t } function Di(e, t) { var r = yi(t), i = r.x, o = r.y, a = e.display, l = a.scroller, u = l.scrollWidth > l.clientWidth, c = l.scrollHeight > l.clientHeight; if (i && u || o && c) { if (o && x && s) e: for (var h = t.target, f = a.view; h != l; h = h.parentNode)for (var p = 0; p < f.length; p++)if (f[p].node == h) { e.display.currentWheelTarget = h; break e } if (i && !n && !d && null != xi) return o && c && Ir(e, Math.max(0, l.scrollTop + o * xi)), Hr(e, Math.max(0, l.scrollLeft + i * xi)), (!o || o && c) && ye(t), void (a.wheelStartX = null); if (o && null != xi) { var m = o * xi, g = e.doc.scrollTop, v = g + a.wrapper.clientHeight; m < 0 ? g = Math.max(0, g + m - 50) : v = Math.min(e.doc.height, v + m + 50), si(e, { top: g, bottom: v }) } vi < 20 && (null == a.wheelStartX ? (a.wheelStartX = l.scrollLeft, a.wheelStartY = l.scrollTop, a.wheelDX = i, a.wheelDY = o, setTimeout((function () { if (null != a.wheelStartX) { var e = l.scrollLeft - a.wheelStartX, t = l.scrollTop - a.wheelStartY, n = t && a.wheelDY && t / a.wheelDY || e && a.wheelDX && e / a.wheelDX; a.wheelStartX = a.wheelStartY = null, n && (xi = (xi * vi + n) / (vi + 1), ++vi) } }), 200)) : (a.wheelDX += i, a.wheelDY += o)) } } a ? xi = -.53 : n ? xi = 15 : c ? xi = -.7 : h && (xi = -1 / 3); var Ci = function (e, t) { this.ranges = e, this.primIndex = t }; Ci.prototype.primary = function () { return this.ranges[this.primIndex] }, Ci.prototype.equals = function (e) { if (e == this) return !0; if (e.primIndex != this.primIndex || e.ranges.length != this.ranges.length) return !1; for (var t = 0; t < this.ranges.length; t++) { var n = this.ranges[t], r = e.ranges[t]; if (!nt(n.anchor, r.anchor) || !nt(n.head, r.head)) return !1 } return !0 }, Ci.prototype.deepCopy = function () { for (var e = [], t = 0; t < this.ranges.length; t++)e[t] = new wi(rt(this.ranges[t].anchor), rt(this.ranges[t].head)); return new Ci(e, this.primIndex) }, Ci.prototype.somethingSelected = function () { for (var e = 0; e < this.ranges.length; e++)if (!this.ranges[e].empty()) return !0; return !1 }, Ci.prototype.contains = function (e, t) { t || (t = e); for (var n = 0; n < this.ranges.length; n++) { var r = this.ranges[n]; if (tt(t, r.from()) >= 0 && tt(e, r.to()) <= 0) return n } return -1 }; var wi = function (e, t) { this.anchor = e, this.head = t }; function ki(e, t, n) { var r = e && e.options.selectionsMayTouch, i = t[n]; t.sort((function (e, t) { return tt(e.from(), t.from()) })), n = _(t, i); for (var o = 1; o < t.length; o++) { var a = t[o], l = t[o - 1], s = tt(l.to(), a.from()); if (r && !a.empty() ? s > 0 : s >= 0) { var u = ot(l.from(), a.from()), c = it(l.to(), a.to()), d = l.empty() ? a.from() == a.head : l.from() == l.head; o <= n && --n, t.splice(--o, 2, new wi(d ? c : u, d ? u : c)) } } return new Ci(t, n) } function Si(e, t) { return new Ci([new wi(e, t || e)], 0) } function Fi(e) { return e.text ? et(e.from.line + e.text.length - 1, K(e.text).length + (1 == e.text.length ? e.from.ch : 0)) : e.to } function Ai(e, t) { if (tt(e, t.from) < 0) return e; if (tt(e, t.to) <= 0) return Fi(t); var n = e.line + t.text.length - (t.to.line - t.from.line) - 1, r = e.ch; return e.line == t.to.line && (r += Fi(t).ch - t.to.ch), et(n, r) } function Ei(e, t) { for (var n = [], r = 0; r < e.sel.ranges.length; r++) { var i = e.sel.ranges[r]; n.push(new wi(Ai(i.anchor, t), Ai(i.head, t))) } return ki(e.cm, n, e.sel.primIndex) } function Ti(e, t, n) { return e.line == t.line ? et(n.line, e.ch - t.ch + n.ch) : et(n.line + (e.line - t.line), e.ch) } function Li(e) { e.doc.mode = Pe(e.options, e.doc.modeOption), Mi(e) } function Mi(e) { e.doc.iter((function (e) { e.stateAfter && (e.stateAfter = null), e.styles && (e.styles = null) })), e.doc.modeFrontier = e.doc.highlightFrontier = e.doc.first, ri(e, 100), e.state.modeGen++, e.curOp && dr(e) } function Bi(e, t) { return 0 == t.from.ch && 0 == t.to.ch && "" == K(t.text) && (!e.cm || e.cm.options.wholeLineUpdateBefore) } function Ni(e, t, n, r) { function i(e) { return n ? n[e] : null } function o(e, n, i) { !function (e, t, n, r) { e.text = t, e.stateAfter && (e.stateAfter = null), e.styles && (e.styles = null), null != e.order && (e.order = null), Et(e), Tt(e, n); var i = r ? r(e) : 1; i != e.height && Xe(e, i) }(e, n, i, r), sn(e, "change", e, t) } function a(e, t) { for (var n = [], o = e; o < t; ++o)n.push(new Gt(u[o], i(o), r)); return n } var l = t.from, s = t.to, u = t.text, c = Ge(e, l.line), d = Ge(e, s.line), h = K(u), f = i(u.length - 1), p = s.line - l.line; if (t.full) e.insert(0, a(0, u.length)), e.remove(u.length, e.size - u.length); else if (Bi(e, t)) { var m = a(0, u.length - 1); o(d, d.text, f), p && e.remove(l.line, p), m.length && e.insert(l.line, m) } else if (c == d) if (1 == u.length) o(c, c.text.slice(0, l.ch) + h + c.text.slice(s.ch), f); else { var g = a(1, u.length - 1); g.push(new Gt(h + c.text.slice(s.ch), f, r)), o(c, c.text.slice(0, l.ch) + u[0], i(0)), e.insert(l.line + 1, g) } else if (1 == u.length) o(c, c.text.slice(0, l.ch) + u[0] + d.text.slice(s.ch), i(0)), e.remove(l.line + 1, p); else { o(c, c.text.slice(0, l.ch) + u[0], i(0)), o(d, h + d.text.slice(s.ch), f); var v = a(1, u.length - 1); p > 1 && e.remove(l.line + 1, p - 1), e.insert(l.line + 1, v) } sn(e, "change", e, t) } function Oi(e, t, n) { !function e(r, i, o) { if (r.linked) for (var a = 0; a < r.linked.length; ++a) { var l = r.linked[a]; if (l.doc != i) { var s = o && l.sharedHist; n && !s || (t(l.doc, s), e(l.doc, r, s)) } } }(e, null, !0) } function Ii(e, t) { if (t.cm) throw new Error("This document is already in use."); e.doc = t, t.cm = e, sr(e), Li(e), zi(e), e.options.lineWrapping || $t(e), e.options.mode = t.modeOption, dr(e) } function zi(e) { ("rtl" == e.doc.direction ? N : F)(e.display.lineDiv, "CodeMirror-rtl") } function Hi(e) { this.done = [], this.undone = [], this.undoDepth = e ? e.undoDepth : 1 / 0, this.lastModTime = this.lastSelTime = 0, this.lastOp = this.lastSelOp = null, this.lastOrigin = this.lastSelOrigin = null, this.generation = this.maxGeneration = e ? e.maxGeneration : 1 } function Ri(e, t) { var n = { from: rt(t.from), to: Fi(t), text: Ve(e, t.from, t.to) }; return qi(e, n, t.from.line, t.to.line + 1), Oi(e, (function (e) { return qi(e, n, t.from.line, t.to.line + 1) }), !0), n } function Pi(e) { for (; e.length;) { if (!K(e).ranges) break; e.pop() } } function _i(e, t, n, r) { var i = e.history; i.undone.length = 0; var o, a, l = +new Date; if ((i.lastOp == r || i.lastOrigin == t.origin && t.origin && ("+" == t.origin.charAt(0) && i.lastModTime > l - (e.cm ? e.cm.options.historyEventDelay : 500) || "*" == t.origin.charAt(0))) && (o = function (e, t) { return t ? (Pi(e.done), K(e.done)) : e.done.length && !K(e.done).ranges ? K(e.done) : e.done.length > 1 && !e.done[e.done.length - 2].ranges ? (e.done.pop(), K(e.done)) : void 0 }(i, i.lastOp == r))) a = K(o.changes), 0 == tt(t.from, t.to) && 0 == tt(t.from, a.to) ? a.to = Fi(t) : o.changes.push(Ri(e, t)); else { var s = K(i.done); for (s && s.ranges || ji(e.sel, i.done), o = { changes: [Ri(e, t)], generation: i.generation }, i.done.push(o); i.done.length > i.undoDepth;)i.done.shift(), i.done[0].ranges || i.done.shift() } i.done.push(n), i.generation = ++i.maxGeneration, i.lastModTime = i.lastSelTime = l, i.lastOp = i.lastSelOp = r, i.lastOrigin = i.lastSelOrigin = t.origin, a || pe(e, "historyAdded") } function Wi(e, t, n, r) { var i = e.history, o = r && r.origin; n == i.lastSelOp || o && i.lastSelOrigin == o && (i.lastModTime == i.lastSelTime && i.lastOrigin == o || function (e, t, n, r) { var i = t.charAt(0); return "*" == i || "+" == i && n.ranges.length == r.ranges.length && n.somethingSelected() == r.somethingSelected() && new Date - e.history.lastSelTime <= (e.cm ? e.cm.options.historyEventDelay : 500) }(e, o, K(i.done), t)) ? i.done[i.done.length - 1] = t : ji(t, i.done), i.lastSelTime = +new Date, i.lastSelOrigin = o, i.lastSelOp = n, r && !1 !== r.clearRedo && Pi(i.undone) } function ji(e, t) { var n = K(t); n && n.ranges && n.equals(e) || t.push(e) } function qi(e, t, n, r) { var i = t["spans_" + e.id], o = 0; e.iter(Math.max(e.first, n), Math.min(e.first + e.size, r), (function (n) { n.markedSpans && ((i || (i = t["spans_" + e.id] = {}))[o] = n.markedSpans), ++o })) } function Ui(e) { if (!e) return null; for (var t, n = 0; n < e.length; ++n)e[n].marker.explicitlyCleared ? t || (t = e.slice(0, n)) : t && t.push(e[n]); return t ? t.length ? t : null : e } function $i(e, t) { var n = function (e, t) { var n = t["spans_" + e.id]; if (!n) return null; for (var r = [], i = 0; i < t.text.length; ++i)r.push(Ui(n[i])); return r }(e, t), r = Ft(e, t); if (!n) return r; if (!r) return n; for (var i = 0; i < n.length; ++i) { var o = n[i], a = r[i]; if (o && a) e: for (var l = 0; l < a.length; ++l) { for (var s = a[l], u = 0; u < o.length; ++u)if (o[u].marker == s.marker) continue e; o.push(s) } else a && (n[i] = a) } return n } function Gi(e, t, n) { for (var r = [], i = 0; i < e.length; ++i) { var o = e[i]; if (o.ranges) r.push(n ? Ci.prototype.deepCopy.call(o) : o); else { var a = o.changes, l = []; r.push({ changes: l }); for (var s = 0; s < a.length; ++s) { var u = a[s], c = void 0; if (l.push({ from: u.from, to: u.to, text: u.text }), t) for (var d in u) (c = d.match(/^spans_(\d+)$/)) && _(t, Number(c[1])) > -1 && (K(l)[d] = u[d], delete u[d]) } } } return r } function Vi(e, t, n, r) { if (r) { var i = e.anchor; if (n) { var o = tt(t, i) < 0; o != tt(n, i) < 0 ? (i = t, t = n) : o != tt(t, n) < 0 && (t = n) } return new wi(i, t) } return new wi(n || t, t) } function Ki(e, t, n, r, i) { null == i && (i = e.cm && (e.cm.display.shift || e.extend)), Ji(e, new Ci([Vi(e.sel.primary(), t, n, i)], 0), r) } function Xi(e, t, n) { for (var r = [], i = e.cm && (e.cm.display.shift || e.extend), o = 0; o < e.sel.ranges.length; o++)r[o] = Vi(e.sel.ranges[o], t[o], null, i); Ji(e, ki(e.cm, r, e.sel.primIndex), n) } function Zi(e, t, n, r) { var i = e.sel.ranges.slice(0); i[t] = n, Ji(e, ki(e.cm, i, e.sel.primIndex), r) } function Yi(e, t, n, r) { Ji(e, Si(t, n), r) } function Qi(e, t, n) { var r = e.history.done, i = K(r); i && i.ranges ? (r[r.length - 1] = t, eo(e, t, n)) : Ji(e, t, n) } function Ji(e, t, n) { eo(e, t, n), Wi(e, e.sel, e.cm ? e.cm.curOp.id : NaN, n) } function eo(e, t, n) { (ve(e, "beforeSelectionChange") || e.cm && ve(e.cm, "beforeSelectionChange")) && (t = function (e, t, n) { var r = { ranges: t.ranges, update: function (t) { this.ranges = []; for (var n = 0; n < t.length; n++)this.ranges[n] = new wi(lt(e, t[n].anchor), lt(e, t[n].head)) }, origin: n && n.origin }; return pe(e, "beforeSelectionChange", e, r), e.cm && pe(e.cm, "beforeSelectionChange", e.cm, r), r.ranges != t.ranges ? ki(e.cm, r.ranges, r.ranges.length - 1) : t }(e, t, n)); var r = n && n.bias || (tt(t.primary().head, e.sel.primary().head) < 0 ? -1 : 1); to(e, ro(e, t, r, !0)), n && !1 === n.scroll || !e.cm || "nocursor" == e.cm.getOption("readOnly") || Mr(e.cm) } function to(e, t) { t.equals(e.sel) || (e.sel = t, e.cm && (e.cm.curOp.updateInput = 1, e.cm.curOp.selectionChanged = !0, ge(e.cm)), sn(e, "cursorActivity", e)) } function no(e) { to(e, ro(e, e.sel, null, !1)) } function ro(e, t, n, r) { for (var i, o = 0; o < t.ranges.length; o++) { var a = t.ranges[o], l = t.ranges.length == e.sel.ranges.length && e.sel.ranges[o], s = oo(e, a.anchor, l && l.anchor, n, r), u = oo(e, a.head, l && l.head, n, r); (i || s != a.anchor || u != a.head) && (i || (i = t.ranges.slice(0, o)), i[o] = new wi(s, u)) } return i ? ki(e.cm, i, t.primIndex) : t } function io(e, t, n, r, i) { var o = Ge(e, t.line); if (o.markedSpans) for (var a = 0; a < o.markedSpans.length; ++a) { var l = o.markedSpans[a], s = l.marker, u = "selectLeft" in s ? !s.selectLeft : s.inclusiveLeft, c = "selectRight" in s ? !s.selectRight : s.inclusiveRight; if ((null == l.from || (u ? l.from <= t.ch : l.from < t.ch)) && (null == l.to || (c ? l.to >= t.ch : l.to > t.ch))) { if (i && (pe(s, "beforeCursorEnter"), s.explicitlyCleared)) { if (o.markedSpans) { --a; continue } break } if (!s.atomic) continue; if (n) { var d = s.find(r < 0 ? 1 : -1), h = void 0; if ((r < 0 ? c : u) && (d = ao(e, d, -r, d && d.line == t.line ? o : null)), d && d.line == t.line && (h = tt(d, n)) && (r < 0 ? h < 0 : h > 0)) return io(e, d, t, r, i) } var f = s.find(r < 0 ? -1 : 1); return (r < 0 ? u : c) && (f = ao(e, f, r, f.line == t.line ? o : null)), f ? io(e, f, t, r, i) : null } } return t } function oo(e, t, n, r, i) { var o = r || 1, a = io(e, t, n, o, i) || !i && io(e, t, n, o, !0) || io(e, t, n, -o, i) || !i && io(e, t, n, -o, !0); return a || (e.cantEdit = !0, et(e.first, 0)) } function ao(e, t, n, r) { return n < 0 && 0 == t.ch ? t.line > e.first ? lt(e, et(t.line - 1)) : null : n > 0 && t.ch == (r || Ge(e, t.line)).text.length ? t.line < e.first + e.size - 1 ? et(t.line + 1, 0) : null : new et(t.line, t.ch + n) } function lo(e) { e.setSelection(et(e.firstLine(), 0), et(e.lastLine()), j) } function so(e, t, n) { var r = { canceled: !1, from: t.from, to: t.to, text: t.text, origin: t.origin, cancel: function () { return r.canceled = !0 } }; return n && (r.update = function (t, n, i, o) { t && (r.from = lt(e, t)), n && (r.to = lt(e, n)), i && (r.text = i), void 0 !== o && (r.origin = o) }), pe(e, "beforeChange", e, r), e.cm && pe(e.cm, "beforeChange", e.cm, r), r.canceled ? (e.cm && (e.cm.curOp.updateInput = 2), null) : { from: r.from, to: r.to, text: r.text, origin: r.origin } } function uo(e, t, n) { if (e.cm) { if (!e.cm.curOp) return ei(e.cm, uo)(e, t, n); if (e.cm.state.suppressEdits) return } if (!(ve(e, "beforeChange") || e.cm && ve(e.cm, "beforeChange")) || (t = so(e, t, !0))) { var r = Dt && !n && function (e, t, n) { var r = null; if (e.iter(t.line, n.line + 1, (function (e) { if (e.markedSpans) for (var t = 0; t < e.markedSpans.length; ++t) { var n = e.markedSpans[t].marker; !n.readOnly || r && -1 != _(r, n) || (r || (r = [])).push(n) } })), !r) return null; for (var i = [{ from: t, to: n }], o = 0; o < r.length; ++o)for (var a = r[o], l = a.find(0), s = 0; s < i.length; ++s) { var u = i[s]; if (!(tt(u.to, l.from) < 0 || tt(u.from, l.to) > 0)) { var c = [s, 1], d = tt(u.from, l.from), h = tt(u.to, l.to); (d < 0 || !a.inclusiveLeft && !d) && c.push({ from: u.from, to: l.from }), (h > 0 || !a.inclusiveRight && !h) && c.push({ from: l.to, to: u.to }), i.splice.apply(i, c), s += c.length - 3 } } return i }(e, t.from, t.to); if (r) for (var i = r.length - 1; i >= 0; --i)co(e, { from: r[i].from, to: r[i].to, text: i ? [""] : t.text, origin: t.origin }); else co(e, t) } } function co(e, t) { if (1 != t.text.length || "" != t.text[0] || 0 != tt(t.from, t.to)) { var n = Ei(e, t); _i(e, t, n, e.cm ? e.cm.curOp.id : NaN), po(e, t, n, Ft(e, t)); var r = []; Oi(e, (function (e, n) { n || -1 != _(r, e.history) || (xo(e.history, t), r.push(e.history)), po(e, t, null, Ft(e, t)) })) } } function ho(e, t, n) { var r = e.cm && e.cm.state.suppressEdits; if (!r || n) { for (var i, o = e.history, a = e.sel, l = "undo" == t ? o.done : o.undone, s = "undo" == t ? o.undone : o.done, u = 0; u < l.length && (i = l[u], n ? !i.ranges || i.equals(e.sel) : i.ranges); u++); if (u != l.length) { for (o.lastOrigin = o.lastSelOrigin = null; ;) { if (!(i = l.pop()).ranges) { if (r) return void l.push(i); break } if (ji(i, s), n && !i.equals(e.sel)) return void Ji(e, i, { clearRedo: !1 }); a = i } var c = []; ji(a, s), s.push({ changes: c, generation: o.generation }), o.generation = i.generation || ++o.maxGeneration; for (var d = ve(e, "beforeChange") || e.cm && ve(e.cm, "beforeChange"), h = function (n) { var r = i.changes[n]; if (r.origin = t, d && !so(e, r, !1)) return l.length = 0, {}; c.push(Ri(e, r)); var o = n ? Ei(e, r) : K(l); po(e, r, o, $i(e, r)), !n && e.cm && e.cm.scrollIntoView({ from: r.from, to: Fi(r) }); var a = []; Oi(e, (function (e, t) { t || -1 != _(a, e.history) || (xo(e.history, r), a.push(e.history)), po(e, r, null, $i(e, r)) })) }, f = i.changes.length - 1; f >= 0; --f) { var p = h(f); if (p) return p.v } } } } function fo(e, t) { if (0 != t && (e.first += t, e.sel = new Ci(X(e.sel.ranges, (function (e) { return new wi(et(e.anchor.line + t, e.anchor.ch), et(e.head.line + t, e.head.ch)) })), e.sel.primIndex), e.cm)) { dr(e.cm, e.first, e.first - t, t); for (var n = e.cm.display, r = n.viewFrom; r < n.viewTo; r++)hr(e.cm, r, "gutter") } } function po(e, t, n, r) { if (e.cm && !e.cm.curOp) return ei(e.cm, po)(e, t, n, r); if (t.to.line < e.first) fo(e, t.text.length - 1 - (t.to.line - t.from.line)); else if (!(t.from.line > e.lastLine())) { if (t.from.line < e.first) { var i = t.text.length - 1 - (e.first - t.from.line); fo(e, i), t = { from: et(e.first, 0), to: et(t.to.line + i, t.to.ch), text: [K(t.text)], origin: t.origin } } var o = e.lastLine(); t.to.line > o && (t = { from: t.from, to: et(o, Ge(e, o).text.length), text: [t.text[0]], origin: t.origin }), t.removed = Ve(e, t.from, t.to), n || (n = Ei(e, t)), e.cm ? function (e, t, n) { var r = e.doc, i = e.display, o = t.from, a = t.to, l = !1, s = o.line; e.options.lineWrapping || (s = Ze(Rt(Ge(r, o.line))), r.iter(s, a.line + 1, (function (e) { if (e == i.maxLine) return l = !0, !0 }))); r.sel.contains(t.from, t.to) > -1 && ge(e); Ni(r, t, n, lr(e)), e.options.lineWrapping || (r.iter(s, o.line + t.text.length, (function (e) { var t = Ut(e); t > i.maxLineLength && (i.maxLine = e, i.maxLineLength = t, i.maxLineChanged = !0, l = !1) })), l && (e.curOp.updateMaxLine = !0)); (function (e, t) { if (e.modeFrontier = Math.min(e.modeFrontier, t), !(e.highlightFrontier < t - 10)) { for (var n = e.first, r = t - 1; r > n; r--) { var i = Ge(e, r).stateAfter; if (i && (!(i instanceof ut) || r + i.lookAhead < t)) { n = r + 1; break } } e.highlightFrontier = Math.min(e.highlightFrontier, n) } })(r, o.line), ri(e, 400); var u = t.text.length - (a.line - o.line) - 1; t.full ? dr(e) : o.line != a.line || 1 != t.text.length || Bi(e.doc, t) ? dr(e, o.line, a.line + 1, u) : hr(e, o.line, "text"); var c = ve(e, "changes"), d = ve(e, "change"); if (d || c) { var h = { from: o, to: a, text: t.text, removed: t.removed, origin: t.origin }; d && sn(e, "change", e, h), c && (e.curOp.changeObjs || (e.curOp.changeObjs = [])).push(h) } e.display.selForContextMenu = null }(e.cm, t, r) : Ni(e, t, r), eo(e, n, j), e.cantEdit && oo(e, et(e.firstLine(), 0)) && (e.cantEdit = !1) } } function mo(e, t, n, r, i) { var o; r || (r = n), tt(r, n) < 0 && (n = (o = [r, n])[0], r = o[1]), "string" == typeof t && (t = e.splitLines(t)), uo(e, { from: n, to: r, text: t, origin: i }) } function go(e, t, n, r) { n < e.line ? e.line += r : t < e.line && (e.line = t, e.ch = 0) } function vo(e, t, n, r) { for (var i = 0; i < e.length; ++i) { var o = e[i], a = !0; if (o.ranges) { o.copied || ((o = e[i] = o.deepCopy()).copied = !0); for (var l = 0; l < o.ranges.length; l++)go(o.ranges[l].anchor, t, n, r), go(o.ranges[l].head, t, n, r) } else { for (var s = 0; s < o.changes.length; ++s) { var u = o.changes[s]; if (n < u.from.line) u.from = et(u.from.line + r, u.from.ch), u.to = et(u.to.line + r, u.to.ch); else if (t <= u.to.line) { a = !1; break } } a || (e.splice(0, i + 1), i = 0) } } } function xo(e, t) { var n = t.from.line, r = t.to.line, i = t.text.length - (r - n) - 1; vo(e.done, n, r, i), vo(e.undone, n, r, i) } function yo(e, t, n, r) { var i = t, o = t; return "number" == typeof t ? o = Ge(e, at(e, t)) : i = Ze(t), null == i ? null : (r(o, i) && e.cm && hr(e.cm, i, n), o) } function bo(e) { this.lines = e, this.parent = null; for (var t = 0, n = 0; n < e.length; ++n)e[n].parent = this, t += e[n].height; this.height = t } function Do(e) { this.children = e; for (var t = 0, n = 0, r = 0; r < e.length; ++r) { var i = e[r]; t += i.chunkSize(), n += i.height, i.parent = this } this.size = t, this.height = n, this.parent = null } wi.prototype.from = function () { return ot(this.anchor, this.head) }, wi.prototype.to = function () { return it(this.anchor, this.head) }, wi.prototype.empty = function () { return this.head.line == this.anchor.line && this.head.ch == this.anchor.ch }, bo.prototype = { chunkSize: function () { return this.lines.length }, removeInner: function (e, t) { for (var n = e, r = e + t; n < r; ++n) { var i = this.lines[n]; this.height -= i.height, Vt(i), sn(i, "delete") } this.lines.splice(e, t) }, collapse: function (e) { e.push.apply(e, this.lines) }, insertInner: function (e, t, n) { this.height += n, this.lines = this.lines.slice(0, e).concat(t).concat(this.lines.slice(e)); for (var r = 0; r < t.length; ++r)t[r].parent = this }, iterN: function (e, t, n) { for (var r = e + t; e < r; ++e)if (n(this.lines[e])) return !0 } }, Do.prototype = { chunkSize: function () { return this.size }, removeInner: function (e, t) { this.size -= t; for (var n = 0; n < this.children.length; ++n) { var r = this.children[n], i = r.chunkSize(); if (e < i) { var o = Math.min(t, i - e), a = r.height; if (r.removeInner(e, o), this.height -= a - r.height, i == o && (this.children.splice(n--, 1), r.parent = null), 0 == (t -= o)) break; e = 0 } else e -= i } if (this.size - t < 25 && (this.children.length > 1 || !(this.children[0] instanceof bo))) { var l = []; this.collapse(l), this.children = [new bo(l)], this.children[0].parent = this } }, collapse: function (e) { for (var t = 0; t < this.children.length; ++t)this.children[t].collapse(e) }, insertInner: function (e, t, n) { this.size += t.length, this.height += n; for (var r = 0; r < this.children.length; ++r) { var i = this.children[r], o = i.chunkSize(); if (e <= o) { if (i.insertInner(e, t, n), i.lines && i.lines.length > 50) { for (var a = i.lines.length % 25 + 25, l = a; l < i.lines.length;) { var s = new bo(i.lines.slice(l, l += 25)); i.height -= s.height, this.children.splice(++r, 0, s), s.parent = this } i.lines = i.lines.slice(0, a), this.maybeSpill() } break } e -= o } }, maybeSpill: function () { if (!(this.children.length <= 10)) { var e = this; do { var t = new Do(e.children.splice(e.children.length - 5, 5)); if (e.parent) { e.size -= t.size, e.height -= t.height; var n = _(e.parent.children, e); e.parent.children.splice(n + 1, 0, t) } else { var r = new Do(e.children); r.parent = e, e.children = [r, t], e = r } t.parent = e.parent } while (e.children.length > 10); e.parent.maybeSpill() } }, iterN: function (e, t, n) { for (var r = 0; r < this.children.length; ++r) { var i = this.children[r], o = i.chunkSize(); if (e < o) { var a = Math.min(t, o - e); if (i.iterN(e, a, n)) return !0; if (0 == (t -= a)) break; e = 0 } else e -= o } } }; var Co = function (e, t, n) { if (n) for (var r in n) n.hasOwnProperty(r) && (this[r] = n[r]); this.doc = e, this.node = t }; function wo(e, t, n) { qt(t) < (e.curOp && e.curOp.scrollTop || e.doc.scrollTop) && Lr(e, n) } Co.prototype.clear = function () { var e = this.doc.cm, t = this.line.widgets, n = this.line, r = Ze(n); if (null != r && t) { for (var i = 0; i < t.length; ++i)t[i] == this && t.splice(i--, 1); t.length || (n.widgets = null); var o = Dn(this); Xe(n, Math.max(0, n.height - o)), e && (Jr(e, (function () { wo(e, n, -o), hr(e, r, "widget") })), sn(e, "lineWidgetCleared", e, this, r)) } }, Co.prototype.changed = function () { var e = this, t = this.height, n = this.doc.cm, r = this.line; this.height = null; var i = Dn(this) - t; i && (Wt(this.doc, r) || Xe(r, r.height + i), n && Jr(n, (function () { n.curOp.forceUpdate = !0, wo(n, r, i), sn(n, "lineWidgetChanged", n, e, Ze(r)) }))) }, xe(Co); var ko = 0, So = function (e, t) { this.lines = [], this.type = t, this.doc = e, this.id = ++ko }; function Fo(e, t, n, r, i) { if (r && r.shared) return function (e, t, n, r, i) { (r = H(r)).shared = !1; var o = [Fo(e, t, n, r, i)], a = o[0], l = r.widgetNode; return Oi(e, (function (e) { l && (r.widgetNode = l.cloneNode(!0)), o.push(Fo(e, lt(e, t), lt(e, n), r, i)); for (var s = 0; s < e.linked.length; ++s)if (e.linked[s].isParent) return; a = K(o) })), new Ao(o, a) }(e, t, n, r, i); if (e.cm && !e.cm.curOp) return ei(e.cm, Fo)(e, t, n, r, i); var o = new So(e, i), a = tt(t, n); if (r && H(r, o, !1), a > 0 || 0 == a && !1 !== o.clearWhenEmpty) return o; if (o.replacedWith && (o.collapsed = !0, o.widgetNode = L("span", [o.replacedWith], "CodeMirror-widget"), r.handleMouseEvents || o.widgetNode.setAttribute("cm-ignore-events", "true"), r.insertLeft && (o.widgetNode.insertLeft = !0)), o.collapsed) { if (Ht(e, t.line, t, n, o) || t.line != n.line && Ht(e, n.line, t, n, o)) throw new Error("Inserting collapsed marker partially overlapping an existing one"); Ct = !0 } o.addToHistory && _i(e, { from: t, to: n, origin: "markText" }, e.sel, NaN); var l, s = t.line, u = e.cm; if (e.iter(s, n.line + 1, (function (e) { u && o.collapsed && !u.options.lineWrapping && Rt(e) == u.display.maxLine && (l = !0), o.collapsed && s != t.line && Xe(e, 0), function (e, t) { e.markedSpans = e.markedSpans ? e.markedSpans.concat([t]) : [t], t.marker.attachLine(e) }(e, new wt(o, s == t.line ? t.ch : null, s == n.line ? n.ch : null)), ++s })), o.collapsed && e.iter(t.line, n.line + 1, (function (t) { Wt(e, t) && Xe(t, 0) })), o.clearOnEnter && de(o, "beforeCursorEnter", (function () { return o.clear() })), o.readOnly && (Dt = !0, (e.history.done.length || e.history.undone.length) && e.clearHistory()), o.collapsed && (o.id = ++ko, o.atomic = !0), u) { if (l && (u.curOp.updateMaxLine = !0), o.collapsed) dr(u, t.line, n.line + 1); else if (o.className || o.startStyle || o.endStyle || o.css || o.attributes || o.title) for (var c = t.line; c <= n.line; c++)hr(u, c, "text"); o.atomic && no(u.doc), sn(u, "markerAdded", u, o) } return o } So.prototype.clear = function () { if (!this.explicitlyCleared) { var e = this.doc.cm, t = e && !e.curOp; if (t && Gr(e), ve(this, "clear")) { var n = this.find(); n && sn(this, "clear", n.from, n.to) } for (var r = null, i = null, o = 0; o < this.lines.length; ++o) { var a = this.lines[o], l = kt(a.markedSpans, this); e && !this.collapsed ? hr(e, Ze(a), "text") : e && (null != l.to && (i = Ze(a)), null != l.from && (r = Ze(a))), a.markedSpans = St(a.markedSpans, l), null == l.from && this.collapsed && !Wt(this.doc, a) && e && Xe(a, rr(e.display)) } if (e && this.collapsed && !e.options.lineWrapping) for (var s = 0; s < this.lines.length; ++s) { var u = Rt(this.lines[s]), c = Ut(u); c > e.display.maxLineLength && (e.display.maxLine = u, e.display.maxLineLength = c, e.display.maxLineChanged = !0) } null != r && e && this.collapsed && dr(e, r, i + 1), this.lines.length = 0, this.explicitlyCleared = !0, this.atomic && this.doc.cantEdit && (this.doc.cantEdit = !1, e && no(e.doc)), e && sn(e, "markerCleared", e, this, r, i), t && Vr(e), this.parent && this.parent.clear() } }, So.prototype.find = function (e, t) { var n, r; null == e && "bookmark" == this.type && (e = 1); for (var i = 0; i < this.lines.length; ++i) { var o = this.lines[i], a = kt(o.markedSpans, this); if (null != a.from && (n = et(t ? o : Ze(o), a.from), -1 == e)) return n; if (null != a.to && (r = et(t ? o : Ze(o), a.to), 1 == e)) return r } return n && { from: n, to: r } }, So.prototype.changed = function () { var e = this, t = this.find(-1, !0), n = this, r = this.doc.cm; t && r && Jr(r, (function () { var i = t.line, o = Ze(t.line), a = Mn(r, o); if (a && (Rn(a), r.curOp.selectionChanged = r.curOp.forceUpdate = !0), r.curOp.updateMaxLine = !0, !Wt(n.doc, i) && null != n.height) { var l = n.height; n.height = null; var s = Dn(n) - l; s && Xe(i, i.height + s) } sn(r, "markerChanged", r, e) })) }, So.prototype.attachLine = function (e) { if (!this.lines.length && this.doc.cm) { var t = this.doc.cm.curOp; t.maybeHiddenMarkers && -1 != _(t.maybeHiddenMarkers, this) || (t.maybeUnhiddenMarkers || (t.maybeUnhiddenMarkers = [])).push(this) } this.lines.push(e) }, So.prototype.detachLine = function (e) { if (this.lines.splice(_(this.lines, e), 1), !this.lines.length && this.doc.cm) { var t = this.doc.cm.curOp; (t.maybeHiddenMarkers || (t.maybeHiddenMarkers = [])).push(this) } }, xe(So); var Ao = function (e, t) { this.markers = e, this.primary = t; for (var n = 0; n < e.length; ++n)e[n].parent = this }; function Eo(e) { return e.findMarks(et(e.first, 0), e.clipPos(et(e.lastLine())), (function (e) { return e.parent })) } function To(e) { for (var t = function (t) { var n = e[t], r = [n.primary.doc]; Oi(n.primary.doc, (function (e) { return r.push(e) })); for (var i = 0; i < n.markers.length; i++) { var o = n.markers[i]; -1 == _(r, o.doc) && (o.parent = null, n.markers.splice(i--, 1)) } }, n = 0; n < e.length; n++)t(n) } Ao.prototype.clear = function () { if (!this.explicitlyCleared) { this.explicitlyCleared = !0; for (var e = 0; e < this.markers.length; ++e)this.markers[e].clear(); sn(this, "clear") } }, Ao.prototype.find = function (e, t) { return this.primary.find(e, t) }, xe(Ao); var Lo = 0, Mo = function (e, t, n, r, i) { if (!(this instanceof Mo)) return new Mo(e, t, n, r, i); null == n && (n = 0), Do.call(this, [new bo([new Gt("", null)])]), this.first = n, this.scrollTop = this.scrollLeft = 0, this.cantEdit = !1, this.cleanGeneration = 1, this.modeFrontier = this.highlightFrontier = n; var o = et(n, 0); this.sel = Si(o), this.history = new Hi(null), this.id = ++Lo, this.modeOption = t, this.lineSep = r, this.direction = "rtl" == i ? "rtl" : "ltr", this.extend = !1, "string" == typeof e && (e = this.splitLines(e)), Ni(this, { from: o, to: o, text: e }), Ji(this, Si(o), j) }; Mo.prototype = Y(Do.prototype, { constructor: Mo, iter: function (e, t, n) { n ? this.iterN(e - this.first, t - e, n) : this.iterN(this.first, this.first + this.size, e) }, insert: function (e, t) { for (var n = 0, r = 0; r < t.length; ++r)n += t[r].height; this.insertInner(e - this.first, t, n) }, remove: function (e, t) { this.removeInner(e - this.first, t) }, getValue: function (e) { var t = Ke(this, this.first, this.first + this.size); return !1 === e ? t : t.join(e || this.lineSeparator()) }, setValue: ni((function (e) { var t = et(this.first, 0), n = this.first + this.size - 1; uo(this, { from: t, to: et(n, Ge(this, n).text.length), text: this.splitLines(e), origin: "setValue", full: !0 }, !0), this.cm && Br(this.cm, 0, 0), Ji(this, Si(t), j) })), replaceRange: function (e, t, n, r) { mo(this, e, t = lt(this, t), n = n ? lt(this, n) : t, r) }, getRange: function (e, t, n) { var r = Ve(this, lt(this, e), lt(this, t)); return !1 === n ? r : r.join(n || this.lineSeparator()) }, getLine: function (e) { var t = this.getLineHandle(e); return t && t.text }, getLineHandle: function (e) { if (Qe(this, e)) return Ge(this, e) }, getLineNumber: function (e) { return Ze(e) }, getLineHandleVisualStart: function (e) { return "number" == typeof e && (e = Ge(this, e)), Rt(e) }, lineCount: function () { return this.size }, firstLine: function () { return this.first }, lastLine: function () { return this.first + this.size - 1 }, clipPos: function (e) { return lt(this, e) }, getCursor: function (e) { var t = this.sel.primary(); return null == e || "head" == e ? t.head : "anchor" == e ? t.anchor : "end" == e || "to" == e || !1 === e ? t.to() : t.from() }, listSelections: function () { return this.sel.ranges }, somethingSelected: function () { return this.sel.somethingSelected() }, setCursor: ni((function (e, t, n) { Yi(this, lt(this, "number" == typeof e ? et(e, t || 0) : e), null, n) })), setSelection: ni((function (e, t, n) { Yi(this, lt(this, e), lt(this, t || e), n) })), extendSelection: ni((function (e, t, n) { Ki(this, lt(this, e), t && lt(this, t), n) })), extendSelections: ni((function (e, t) { Xi(this, st(this, e), t) })), extendSelectionsBy: ni((function (e, t) { Xi(this, st(this, X(this.sel.ranges, e)), t) })), setSelections: ni((function (e, t, n) { if (e.length) { for (var r = [], i = 0; i < e.length; i++)r[i] = new wi(lt(this, e[i].anchor), lt(this, e[i].head || e[i].anchor)); null == t && (t = Math.min(e.length - 1, this.sel.primIndex)), Ji(this, ki(this.cm, r, t), n) } })), addSelection: ni((function (e, t, n) { var r = this.sel.ranges.slice(0); r.push(new wi(lt(this, e), lt(this, t || e))), Ji(this, ki(this.cm, r, r.length - 1), n) })), getSelection: function (e) { for (var t, n = this.sel.ranges, r = 0; r < n.length; r++) { var i = Ve(this, n[r].from(), n[r].to()); t = t ? t.concat(i) : i } return !1 === e ? t : t.join(e || this.lineSeparator()) }, getSelections: function (e) { for (var t = [], n = this.sel.ranges, r = 0; r < n.length; r++) { var i = Ve(this, n[r].from(), n[r].to()); !1 !== e && (i = i.join(e || this.lineSeparator())), t[r] = i } return t }, replaceSelection: function (e, t, n) { for (var r = [], i = 0; i < this.sel.ranges.length; i++)r[i] = e; this.replaceSelections(r, t, n || "+input") }, replaceSelections: ni((function (e, t, n) { for (var r = [], i = this.sel, o = 0; o < i.ranges.length; o++) { var a = i.ranges[o]; r[o] = { from: a.from(), to: a.to(), text: this.splitLines(e[o]), origin: n } } for (var l = t && "end" != t && function (e, t, n) { for (var r = [], i = et(e.first, 0), o = i, a = 0; a < t.length; a++) { var l = t[a], s = Ti(l.from, i, o), u = Ti(Fi(l), i, o); if (i = l.to, o = u, "around" == n) { var c = e.sel.ranges[a], d = tt(c.head, c.anchor) < 0; r[a] = new wi(d ? u : s, d ? s : u) } else r[a] = new wi(s, s) } return new Ci(r, e.sel.primIndex) }(this, r, t), s = r.length - 1; s >= 0; s--)uo(this, r[s]); l ? Qi(this, l) : this.cm && Mr(this.cm) })), undo: ni((function () { ho(this, "undo") })), redo: ni((function () { ho(this, "redo") })), undoSelection: ni((function () { ho(this, "undo", !0) })), redoSelection: ni((function () { ho(this, "redo", !0) })), setExtending: function (e) { this.extend = e }, getExtending: function () { return this.extend }, historySize: function () { for (var e = this.history, t = 0, n = 0, r = 0; r < e.done.length; r++)e.done[r].ranges || ++t; for (var i = 0; i < e.undone.length; i++)e.undone[i].ranges || ++n; return { undo: t, redo: n } }, clearHistory: function () { var e = this; this.history = new Hi(this.history), Oi(this, (function (t) { return t.history = e.history }), !0) }, markClean: function () { this.cleanGeneration = this.changeGeneration(!0) }, changeGeneration: function (e) { return e && (this.history.lastOp = this.history.lastSelOp = this.history.lastOrigin = null), this.history.generation }, isClean: function (e) { return this.history.generation == (e || this.cleanGeneration) }, getHistory: function () { return { done: Gi(this.history.done), undone: Gi(this.history.undone) } }, setHistory: function (e) { var t = this.history = new Hi(this.history); t.done = Gi(e.done.slice(0), null, !0), t.undone = Gi(e.undone.slice(0), null, !0) }, setGutterMarker: ni((function (e, t, n) { return yo(this, e, "gutter", (function (e) { var r = e.gutterMarkers || (e.gutterMarkers = {}); return r[t] = n, !n && te(r) && (e.gutterMarkers = null), !0 })) })), clearGutter: ni((function (e) { var t = this; this.iter((function (n) { n.gutterMarkers && n.gutterMarkers[e] && yo(t, n, "gutter", (function () { return n.gutterMarkers[e] = null, te(n.gutterMarkers) && (n.gutterMarkers = null), !0 })) })) })), lineInfo: function (e) { var t; if ("number" == typeof e) { if (!Qe(this, e)) return null; if (t = e, !(e = Ge(this, e))) return null } else if (null == (t = Ze(e))) return null; return { line: t, handle: e, text: e.text, gutterMarkers: e.gutterMarkers, textClass: e.textClass, bgClass: e.bgClass, wrapClass: e.wrapClass, widgets: e.widgets } }, addLineClass: ni((function (e, t, n) { return yo(this, e, "gutter" == t ? "gutter" : "class", (function (e) { var r = "text" == t ? "textClass" : "background" == t ? "bgClass" : "gutter" == t ? "gutterClass" : "wrapClass"; if (e[r]) { if (k(n).test(e[r])) return !1; e[r] += " " + n } else e[r] = n; return !0 })) })), removeLineClass: ni((function (e, t, n) { return yo(this, e, "gutter" == t ? "gutter" : "class", (function (e) { var r = "text" == t ? "textClass" : "background" == t ? "bgClass" : "gutter" == t ? "gutterClass" : "wrapClass", i = e[r]; if (!i) return !1; if (null == n) e[r] = null; else { var o = i.match(k(n)); if (!o) return !1; var a = o.index + o[0].length; e[r] = i.slice(0, o.index) + (o.index && a != i.length ? " " : "") + i.slice(a) || null } return !0 })) })), addLineWidget: ni((function (e, t, n) { return function (e, t, n, r) { var i = new Co(e, n, r), o = e.cm; return o && i.noHScroll && (o.display.alignWidgets = !0), yo(e, t, "widget", (function (t) { var n = t.widgets || (t.widgets = []); if (null == i.insertAt ? n.push(i) : n.splice(Math.min(n.length, Math.max(0, i.insertAt)), 0, i), i.line = t, o && !Wt(e, t)) { var r = qt(t) < e.scrollTop; Xe(t, t.height + Dn(i)), r && Lr(o, i.height), o.curOp.forceUpdate = !0 } return !0 })), o && sn(o, "lineWidgetAdded", o, i, "number" == typeof t ? t : Ze(t)), i }(this, e, t, n) })), removeLineWidget: function (e) { e.clear() }, markText: function (e, t, n) { return Fo(this, lt(this, e), lt(this, t), n, n && n.type || "range") }, setBookmark: function (e, t) { var n = { replacedWith: t && (null == t.nodeType ? t.widget : t), insertLeft: t && t.insertLeft, clearWhenEmpty: !1, shared: t && t.shared, handleMouseEvents: t && t.handleMouseEvents }; return Fo(this, e = lt(this, e), e, n, "bookmark") }, findMarksAt: function (e) { var t = [], n = Ge(this, (e = lt(this, e)).line).markedSpans; if (n) for (var r = 0; r < n.length; ++r) { var i = n[r]; (null == i.from || i.from <= e.ch) && (null == i.to || i.to >= e.ch) && t.push(i.marker.parent || i.marker) } return t }, findMarks: function (e, t, n) { e = lt(this, e), t = lt(this, t); var r = [], i = e.line; return this.iter(e.line, t.line + 1, (function (o) { var a = o.markedSpans; if (a) for (var l = 0; l < a.length; l++) { var s = a[l]; null != s.to && i == e.line && e.ch >= s.to || null == s.from && i != e.line || null != s.from && i == t.line && s.from >= t.ch || n && !n(s.marker) || r.push(s.marker.parent || s.marker) } ++i })), r }, getAllMarks: function () { var e = []; return this.iter((function (t) { var n = t.markedSpans; if (n) for (var r = 0; r < n.length; ++r)null != n[r].from && e.push(n[r].marker) })), e }, posFromIndex: function (e) { var t, n = this.first, r = this.lineSeparator().length; return this.iter((function (i) { var o = i.text.length + r; if (o > e) return t = e, !0; e -= o, ++n })), lt(this, et(n, t)) }, indexFromPos: function (e) { var t = (e = lt(this, e)).ch; if (e.line < this.first || e.ch < 0) return 0; var n = this.lineSeparator().length; return this.iter(this.first, e.line, (function (e) { t += e.text.length + n })), t }, copy: function (e) { var t = new Mo(Ke(this, this.first, this.first + this.size), this.modeOption, this.first, this.lineSep, this.direction); return t.scrollTop = this.scrollTop, t.scrollLeft = this.scrollLeft, t.sel = this.sel, t.extend = !1, e && (t.history.undoDepth = this.history.undoDepth, t.setHistory(this.getHistory())), t }, linkedDoc: function (e) { e || (e = {}); var t = this.first, n = this.first + this.size; null != e.from && e.from > t && (t = e.from), null != e.to && e.to < n && (n = e.to); var r = new Mo(Ke(this, t, n), e.mode || this.modeOption, t, this.lineSep, this.direction); return e.sharedHist && (r.history = this.history), (this.linked || (this.linked = [])).push({ doc: r, sharedHist: e.sharedHist }), r.linked = [{ doc: this, isParent: !0, sharedHist: e.sharedHist }], function (e, t) { for (var n = 0; n < t.length; n++) { var r = t[n], i = r.find(), o = e.clipPos(i.from), a = e.clipPos(i.to); if (tt(o, a)) { var l = Fo(e, o, a, r.primary, r.primary.type); r.markers.push(l), l.parent = r } } }(r, Eo(this)), r }, unlinkDoc: function (e) { if (e instanceof Aa && (e = e.doc), this.linked) for (var t = 0; t < this.linked.length; ++t) { if (this.linked[t].doc == e) { this.linked.splice(t, 1), e.unlinkDoc(this), To(Eo(this)); break } } if (e.history == this.history) { var n = [e.id]; Oi(e, (function (e) { return n.push(e.id) }), !0), e.history = new Hi(null), e.history.done = Gi(this.history.done, n), e.history.undone = Gi(this.history.undone, n) } }, iterLinkedDocs: function (e) { Oi(this, e) }, getMode: function () { return this.mode }, getEditor: function () { return this.cm }, splitLines: function (e) { return this.lineSep ? e.split(this.lineSep) : Me(e) }, lineSeparator: function () { return this.lineSep || "\n" }, setDirection: ni((function (e) { var t; ("rtl" != e && (e = "ltr"), e != this.direction) && (this.direction = e, this.iter((function (e) { return e.order = null })), this.cm && Jr(t = this.cm, (function () { zi(t), dr(t) }))) })) }), Mo.prototype.eachLine = Mo.prototype.iter; var Bo = 0; function No(e) { var t = this; if (Oo(t), !me(t, e) && !Cn(t.display, e)) { ye(e), a && (Bo = +new Date); var n = ur(t, e, !0), r = e.dataTransfer.files; if (n && !t.isReadOnly()) if (r && r.length && window.FileReader && window.File) for (var i = r.length, o = Array(i), l = 0, s = function () { ++l == i && ei(t, (function () { var e = { from: n = lt(t.doc, n), to: n, text: t.doc.splitLines(o.filter((function (e) { return null != e })).join(t.doc.lineSeparator())), origin: "paste" }; uo(t.doc, e), Qi(t.doc, Si(lt(t.doc, n), lt(t.doc, Fi(e)))) }))() }, u = function (e, n) { if (t.options.allowDropFileTypes && -1 == _(t.options.allowDropFileTypes, e.type)) s(); else { var r = new FileReader; r.onerror = function () { return s() }, r.onload = function () { var e = r.result; /[\x00-\x08\x0e-\x1f]{2}/.test(e) || (o[n] = e), s() }, r.readAsText(e) } }, c = 0; c < r.length; c++)u(r[c], c); else { if (t.state.draggingText && t.doc.sel.contains(n) > -1) return t.state.draggingText(e), void setTimeout((function () { return t.display.input.focus() }), 20); try { var d = e.dataTransfer.getData("Text"); if (d) { var h; if (t.state.draggingText && !t.state.draggingText.copy && (h = t.listSelections()), eo(t.doc, Si(n, n)), h) for (var f = 0; f < h.length; ++f)mo(t.doc, "", h[f].anchor, h[f].head, "drag"); t.replaceSelection(d, "around", "paste"), t.display.input.focus() } } catch (e) { } } } } function Oo(e) { e.display.dragCursor && (e.display.lineSpace.removeChild(e.display.dragCursor), e.display.dragCursor = null) } function Io(e) { if (document.getElementsByClassName) { for (var t = document.getElementsByClassName("CodeMirror"), n = [], r = 0; r < t.length; r++) { var i = t[r].CodeMirror; i && n.push(i) } n.length && n[0].operation((function () { for (var t = 0; t < n.length; t++)e(n[t]) })) } } var zo = !1; function Ho() { var e; zo || (de(window, "resize", (function () { null == e && (e = setTimeout((function () { e = null, Io(Ro) }), 100)) })), de(window, "blur", (function () { return Io(Sr) })), zo = !0) } function Ro(e) { var t = e.display; t.cachedCharWidth = t.cachedTextHeight = t.cachedPaddingH = null, t.scrollbarsClipped = !1, e.setSize() } for (var Po = { 3: "Pause", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt", 19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End", 36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert", 46: "Delete", 59: ";", 61: "=", 91: "Mod", 92: "Mod", 93: "Mod", 106: "*", 107: "=", 109: "-", 110: ".", 111: "/", 145: "ScrollLock", 173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\", 221: "]", 222: "'", 224: "Mod", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete", 63273: "Home", 63275: "End", 63276: "PageUp", 63277: "PageDown", 63302: "Insert" }, _o = 0; _o < 10; _o++)Po[_o + 48] = Po[_o + 96] = String(_o); for (var Wo = 65; Wo <= 90; Wo++)Po[Wo] = String.fromCharCode(Wo); for (var jo = 1; jo <= 12; jo++)Po[jo + 111] = Po[jo + 63235] = "F" + jo; var qo = {}; function Uo(e) { var t, n, r, i, o = e.split(/-(?!$)/); e = o[o.length - 1]; for (var a = 0; a < o.length - 1; a++) { var l = o[a]; if (/^(cmd|meta|m)$/i.test(l)) i = !0; else if (/^a(lt)?$/i.test(l)) t = !0; else if (/^(c|ctrl|control)$/i.test(l)) n = !0; else { if (!/^s(hift)?$/i.test(l)) throw new Error("Unrecognized modifier name: " + l); r = !0 } } return t && (e = "Alt-" + e), n && (e = "Ctrl-" + e), i && (e = "Cmd-" + e), r && (e = "Shift-" + e), e } function $o(e) { var t = {}; for (var n in e) if (e.hasOwnProperty(n)) { var r = e[n]; if (/^(name|fallthrough|(de|at)tach)$/.test(n)) continue; if ("..." == r) { delete e[n]; continue } for (var i = X(n.split(" "), Uo), o = 0; o < i.length; o++) { var a = void 0, l = void 0; o == i.length - 1 ? (l = i.join(" "), a = r) : (l = i.slice(0, o + 1).join(" "), a = "..."); var s = t[l]; if (s) { if (s != a) throw new Error("Inconsistent bindings for " + l) } else t[l] = a } delete e[n] } for (var u in t) e[u] = t[u]; return e } function Go(e, t, n, r) { var i = (t = Zo(t)).call ? t.call(e, r) : t[e]; if (!1 === i) return "nothing"; if ("..." === i) return "multi"; if (null != i && n(i)) return "handled"; if (t.fallthrough) { if ("[object Array]" != Object.prototype.toString.call(t.fallthrough)) return Go(e, t.fallthrough, n, r); for (var o = 0; o < t.fallthrough.length; o++) { var a = Go(e, t.fallthrough[o], n, r); if (a) return a } } } function Vo(e) { var t = "string" == typeof e ? e : Po[e.keyCode]; return "Ctrl" == t || "Alt" == t || "Shift" == t || "Mod" == t } function Ko(e, t, n) { var r = e; return t.altKey && "Alt" != r && (e = "Alt-" + e), (C ? t.metaKey : t.ctrlKey) && "Ctrl" != r && (e = "Ctrl-" + e), (C ? t.ctrlKey : t.metaKey) && "Mod" != r && (e = "Cmd-" + e), !n && t.shiftKey && "Shift" != r && (e = "Shift-" + e), e } function Xo(e, t) { if (d && 34 == e.keyCode && e.char) return !1; var n = Po[e.keyCode]; return null != n && !e.altGraphKey && (3 == e.keyCode && e.code && (n = e.code), Ko(n, e, t)) } function Zo(e) { return "string" == typeof e ? qo[e] : e } function Yo(e, t) { for (var n = e.doc.sel.ranges, r = [], i = 0; i < n.length; i++) { for (var o = t(n[i]); r.length && tt(o.from, K(r).to) <= 0;) { var a = r.pop(); if (tt(a.from, o.from) < 0) { o.from = a.from; break } } r.push(o) } Jr(e, (function () { for (var t = r.length - 1; t >= 0; t--)mo(e.doc, "", r[t].from, r[t].to, "+delete"); Mr(e) })) } function Qo(e, t, n) { var r = ie(e.text, t + n, n); return r < 0 || r > e.text.length ? null : r } function Jo(e, t, n) { var r = Qo(e, t.ch, n); return null == r ? null : new et(t.line, r, n < 0 ? "after" : "before") } function ea(e, t, n, r, i) { if (e) { "rtl" == t.doc.direction && (i = -i); var o = ue(n, t.doc.direction); if (o) { var a, l = i < 0 ? K(o) : o[0], s = i < 0 == (1 == l.level) ? "after" : "before"; if (l.level > 0 || "rtl" == t.doc.direction) { var u = Bn(t, n); a = i < 0 ? n.text.length - 1 : 0; var c = Nn(t, u, a).top; a = oe((function (e) { return Nn(t, u, e).top == c }), i < 0 == (1 == l.level) ? l.from : l.to - 1, a), "before" == s && (a = Qo(n, a, 1)) } else a = i < 0 ? l.to : l.from; return new et(r, a, s) } } return new et(r, i < 0 ? n.text.length : 0, i < 0 ? "before" : "after") } qo.basic = { Left: "goCharLeft", Right: "goCharRight", Up: "goLineUp", Down: "goLineDown", End: "goLineEnd", Home: "goLineStartSmart", PageUp: "goPageUp", PageDown: "goPageDown", Delete: "delCharAfter", Backspace: "delCharBefore", "Shift-Backspace": "delCharBefore", Tab: "defaultTab", "Shift-Tab": "indentAuto", Enter: "newlineAndIndent", Insert: "toggleOverwrite", Esc: "singleSelection" }, qo.pcDefault = { "Ctrl-A": "selectAll", "Ctrl-D": "deleteLine", "Ctrl-Z": "undo", "Shift-Ctrl-Z": "redo", "Ctrl-Y": "redo", "Ctrl-Home": "goDocStart", "Ctrl-End": "goDocEnd", "Ctrl-Up": "goLineUp", "Ctrl-Down": "goLineDown", "Ctrl-Left": "goGroupLeft", "Ctrl-Right": "goGroupRight", "Alt-Left": "goLineStart", "Alt-Right": "goLineEnd", "Ctrl-Backspace": "delGroupBefore", "Ctrl-Delete": "delGroupAfter", "Ctrl-S": "save", "Ctrl-F": "find", "Ctrl-G": "findNext", "Shift-Ctrl-G": "findPrev", "Shift-Ctrl-F": "replace", "Shift-Ctrl-R": "replaceAll", "Ctrl-[": "indentLess", "Ctrl-]": "indentMore", "Ctrl-U": "undoSelection", "Shift-Ctrl-U": "redoSelection", "Alt-U": "redoSelection", fallthrough: "basic" }, qo.emacsy = { "Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd", "Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp", "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars", "Ctrl-O": "openLine" }, qo.macDefault = { "Cmd-A": "selectAll", "Cmd-D": "deleteLine", "Cmd-Z": "undo", "Shift-Cmd-Z": "redo", "Cmd-Y": "redo", "Cmd-Home": "goDocStart", "Cmd-Up": "goDocStart", "Cmd-End": "goDocEnd", "Cmd-Down": "goDocEnd", "Alt-Left": "goGroupLeft", "Alt-Right": "goGroupRight", "Cmd-Left": "goLineLeft", "Cmd-Right": "goLineRight", "Alt-Backspace": "delGroupBefore", "Ctrl-Alt-Backspace": "delGroupAfter", "Alt-Delete": "delGroupAfter", "Cmd-S": "save", "Cmd-F": "find", "Cmd-G": "findNext", "Shift-Cmd-G": "findPrev", "Cmd-Alt-F": "replace", "Shift-Cmd-Alt-F": "replaceAll", "Cmd-[": "indentLess", "Cmd-]": "indentMore", "Cmd-Backspace": "delWrappedLineLeft", "Cmd-Delete": "delWrappedLineRight", "Cmd-U": "undoSelection", "Shift-Cmd-U": "redoSelection", "Ctrl-Up": "goDocStart", "Ctrl-Down": "goDocEnd", fallthrough: ["basic", "emacsy"] }, qo.default = x ? qo.macDefault : qo.pcDefault; var ta = { selectAll: lo, singleSelection: function (e) { return e.setSelection(e.getCursor("anchor"), e.getCursor("head"), j) }, killLine: function (e) { return Yo(e, (function (t) { if (t.empty()) { var n = Ge(e.doc, t.head.line).text.length; return t.head.ch == n && t.head.line < e.lastLine() ? { from: t.head, to: et(t.head.line + 1, 0) } : { from: t.head, to: et(t.head.line, n) } } return { from: t.from(), to: t.to() } })) }, deleteLine: function (e) { return Yo(e, (function (t) { return { from: et(t.from().line, 0), to: lt(e.doc, et(t.to().line + 1, 0)) } })) }, delLineLeft: function (e) { return Yo(e, (function (e) { return { from: et(e.from().line, 0), to: e.from() } })) }, delWrappedLineLeft: function (e) { return Yo(e, (function (t) { var n = e.charCoords(t.head, "div").top + 5; return { from: e.coordsChar({ left: 0, top: n }, "div"), to: t.from() } })) }, delWrappedLineRight: function (e) { return Yo(e, (function (t) { var n = e.charCoords(t.head, "div").top + 5, r = e.coordsChar({ left: e.display.lineDiv.offsetWidth + 100, top: n }, "div"); return { from: t.from(), to: r } })) }, undo: function (e) { return e.undo() }, redo: function (e) { return e.redo() }, undoSelection: function (e) { return e.undoSelection() }, redoSelection: function (e) { return e.redoSelection() }, goDocStart: function (e) { return e.extendSelection(et(e.firstLine(), 0)) }, goDocEnd: function (e) { return e.extendSelection(et(e.lastLine())) }, goLineStart: function (e) { return e.extendSelectionsBy((function (t) { return na(e, t.head.line) }), { origin: "+move", bias: 1 }) }, goLineStartSmart: function (e) { return e.extendSelectionsBy((function (t) { return ra(e, t.head) }), { origin: "+move", bias: 1 }) }, goLineEnd: function (e) { return e.extendSelectionsBy((function (t) { return function (e, t) { var n = Ge(e.doc, t), r = function (e) { for (var t; t = It(e);)e = t.find(1, !0).line; return e }(n); r != n && (t = Ze(r)); return ea(!0, e, n, t, -1) }(e, t.head.line) }), { origin: "+move", bias: -1 }) }, goLineRight: function (e) { return e.extendSelectionsBy((function (t) { var n = e.cursorCoords(t.head, "div").top + 5; return e.coordsChar({ left: e.display.lineDiv.offsetWidth + 100, top: n }, "div") }), U) }, goLineLeft: function (e) { return e.extendSelectionsBy((function (t) { var n = e.cursorCoords(t.head, "div").top + 5; return e.coordsChar({ left: 0, top: n }, "div") }), U) }, goLineLeftSmart: function (e) { return e.extendSelectionsBy((function (t) { var n = e.cursorCoords(t.head, "div").top + 5, r = e.coordsChar({ left: 0, top: n }, "div"); return r.ch < e.getLine(r.line).search(/\S/) ? ra(e, t.head) : r }), U) }, goLineUp: function (e) { return e.moveV(-1, "line") }, goLineDown: function (e) { return e.moveV(1, "line") }, goPageUp: function (e) { return e.moveV(-1, "page") }, goPageDown: function (e) { return e.moveV(1, "page") }, goCharLeft: function (e) { return e.moveH(-1, "char") }, goCharRight: function (e) { return e.moveH(1, "char") }, goColumnLeft: function (e) { return e.moveH(-1, "column") }, goColumnRight: function (e) { return e.moveH(1, "column") }, goWordLeft: function (e) { return e.moveH(-1, "word") }, goGroupRight: function (e) { return e.moveH(1, "group") }, goGroupLeft: function (e) { return e.moveH(-1, "group") }, goWordRight: function (e) { return e.moveH(1, "word") }, delCharBefore: function (e) { return e.deleteH(-1, "codepoint") }, delCharAfter: function (e) { return e.deleteH(1, "char") }, delWordBefore: function (e) { return e.deleteH(-1, "word") }, delWordAfter: function (e) { return e.deleteH(1, "word") }, delGroupBefore: function (e) { return e.deleteH(-1, "group") }, delGroupAfter: function (e) { return e.deleteH(1, "group") }, indentAuto: function (e) { return e.indentSelection("smart") }, indentMore: function (e) { return e.indentSelection("add") }, indentLess: function (e) { return e.indentSelection("subtract") }, insertTab: function (e) { return e.replaceSelection("\t") }, insertSoftTab: function (e) { for (var t = [], n = e.listSelections(), r = e.options.tabSize, i = 0; i < n.length; i++) { var o = n[i].from(), a = R(e.getLine(o.line), o.ch, r); t.push(V(r - a % r)) } e.replaceSelections(t) }, defaultTab: function (e) { e.somethingSelected() ? e.indentSelection("add") : e.execCommand("insertTab") }, transposeChars: function (e) { return Jr(e, (function () { for (var t = e.listSelections(), n = [], r = 0; r < t.length; r++)if (t[r].empty()) { var i = t[r].head, o = Ge(e.doc, i.line).text; if (o) if (i.ch == o.length && (i = new et(i.line, i.ch - 1)), i.ch > 0) i = new et(i.line, i.ch + 1), e.replaceRange(o.charAt(i.ch - 1) + o.charAt(i.ch - 2), et(i.line, i.ch - 2), i, "+transpose"); else if (i.line > e.doc.first) { var a = Ge(e.doc, i.line - 1).text; a && (i = new et(i.line, 1), e.replaceRange(o.charAt(0) + e.doc.lineSeparator() + a.charAt(a.length - 1), et(i.line - 1, a.length - 1), i, "+transpose")) } n.push(new wi(i, i)) } e.setSelections(n) })) }, newlineAndIndent: function (e) { return Jr(e, (function () { for (var t = e.listSelections(), n = t.length - 1; n >= 0; n--)e.replaceRange(e.doc.lineSeparator(), t[n].anchor, t[n].head, "+input"); t = e.listSelections(); for (var r = 0; r < t.length; r++)e.indentLine(t[r].from().line, null, !0); Mr(e) })) }, openLine: function (e) { return e.replaceSelection("\n", "start") }, toggleOverwrite: function (e) { return e.toggleOverwrite() } }; function na(e, t) { var n = Ge(e.doc, t), r = Rt(n); return r != n && (t = Ze(r)), ea(!0, e, r, t, 1) } function ra(e, t) { var n = na(e, t.line), r = Ge(e.doc, n.line), i = ue(r, e.doc.direction); if (!i || 0 == i[0].level) { var o = Math.max(n.ch, r.text.search(/\S/)), a = t.line == n.line && t.ch <= o && t.ch; return et(n.line, a ? 0 : o, n.sticky) } return n } function ia(e, t, n) { if ("string" == typeof t && !(t = ta[t])) return !1; e.display.input.ensurePolled(); var r = e.display.shift, i = !1; try { e.isReadOnly() && (e.state.suppressEdits = !0), n && (e.display.shift = !1), i = t(e) != W } finally { e.display.shift = r, e.state.suppressEdits = !1 } return i } var oa = new P; function aa(e, t, n, r) { var i = e.state.keySeq; if (i) { if (Vo(t)) return "handled"; if (/\'$/.test(t) ? e.state.keySeq = null : oa.set(50, (function () { e.state.keySeq == i && (e.state.keySeq = null, e.display.input.reset()) })), la(e, i + " " + t, n, r)) return !0 } return la(e, t, n, r) } function la(e, t, n, r) { var i = function (e, t, n) { for (var r = 0; r < e.state.keyMaps.length; r++) { var i = Go(t, e.state.keyMaps[r], n, e); if (i) return i } return e.options.extraKeys && Go(t, e.options.extraKeys, n, e) || Go(t, e.options.keyMap, n, e) }(e, t, r); return "multi" == i && (e.state.keySeq = t), "handled" == i && sn(e, "keyHandled", e, t, n), "handled" != i && "multi" != i || (ye(n), Dr(e)), !!i } function sa(e, t) { var n = Xo(t, !0); return !!n && (t.shiftKey && !e.state.keySeq ? aa(e, "Shift-" + n, t, (function (t) { return ia(e, t, !0) })) || aa(e, n, t, (function (t) { if ("string" == typeof t ? /^go[A-Z]/.test(t) : t.motion) return ia(e, t) })) : aa(e, n, t, (function (t) { return ia(e, t) }))) } var ua = null; function ca(e) { var t = this; if (!(e.target && e.target != t.display.input.getField() || (t.curOp.focus = B(), me(t, e)))) { a && l < 11 && 27 == e.keyCode && (e.returnValue = !1); var r = e.keyCode; t.display.shift = 16 == r || e.shiftKey; var i = sa(t, e); d && (ua = i ? r : null, i || 88 != r || Ne || !(x ? e.metaKey : e.ctrlKey) || t.replaceSelection("", null, "cut")), n && !x && !i && 46 == r && e.shiftKey && !e.ctrlKey && document.execCommand && document.execCommand("cut"), 18 != r || /\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className) || function (e) { var t = e.display.lineDiv; function n(e) { 18 != e.keyCode && e.altKey || (F(t, "CodeMirror-crosshair"), fe(document, "keyup", n), fe(document, "mouseover", n)) } N(t, "CodeMirror-crosshair"), de(document, "keyup", n), de(document, "mouseover", n) }(t) } } function da(e) { 16 == e.keyCode && (this.doc.sel.shift = !1), me(this, e) } function ha(e) { var t = this; if (!(e.target && e.target != t.display.input.getField() || Cn(t.display, e) || me(t, e) || e.ctrlKey && !e.altKey || x && e.metaKey)) { var n = e.keyCode, r = e.charCode; if (d && n == ua) return ua = null, void ye(e); if (!d || e.which && !(e.which < 10) || !sa(t, e)) { var i = String.fromCharCode(null == r ? n : r); "\b" != i && (function (e, t, n) { return aa(e, "'" + n + "'", t, (function (t) { return ia(e, t, !0) })) }(t, e, i) || t.display.input.onKeyPress(e)) } } } var fa, pa, ma = function (e, t, n) { this.time = e, this.pos = t, this.button = n }; function ga(e) { var t = this, n = t.display; if (!(me(t, e) || n.activeTouch && n.input.supportsTouch())) if (n.input.ensurePolled(), n.shift = e.shiftKey, Cn(n, e)) s || (n.scroller.draggable = !1, setTimeout((function () { return n.scroller.draggable = !0 }), 100)); else if (!ya(t, e)) { var r = ur(t, e), i = ke(e), o = r ? function (e, t) { var n = +new Date; return pa && pa.compare(n, e, t) ? (fa = pa = null, "triple") : fa && fa.compare(n, e, t) ? (pa = new ma(n, e, t), fa = null, "double") : (fa = new ma(n, e, t), pa = null, "single") }(r, i) : "single"; window.focus(), 1 == i && t.state.selectingText && t.state.selectingText(e), r && function (e, t, n, r, i) { var o = "Click"; "double" == r ? o = "Double" + o : "triple" == r && (o = "Triple" + o); return aa(e, Ko(o = (1 == t ? "Left" : 2 == t ? "Middle" : "Right") + o, i), i, (function (t) { if ("string" == typeof t && (t = ta[t]), !t) return !1; var r = !1; try { e.isReadOnly() && (e.state.suppressEdits = !0), r = t(e, n) != W } finally { e.state.suppressEdits = !1 } return r })) }(t, i, r, o, e) || (1 == i ? r ? function (e, t, n, r) { a ? setTimeout(z(Cr, e), 0) : e.curOp.focus = B(); var i, o = function (e, t, n) { var r = e.getOption("configureMouse"), i = r ? r(e, t, n) : {}; if (null == i.unit) { var o = y ? n.shiftKey && n.metaKey : n.altKey; i.unit = o ? "rectangle" : "single" == t ? "char" : "double" == t ? "word" : "line" } (null == i.extend || e.doc.extend) && (i.extend = e.doc.extend || n.shiftKey); null == i.addNew && (i.addNew = x ? n.metaKey : n.ctrlKey); null == i.moveOnDrag && (i.moveOnDrag = !(x ? n.altKey : n.ctrlKey)); return i }(e, n, r), u = e.doc.sel; e.options.dragDrop && Ae && !e.isReadOnly() && "single" == n && (i = u.contains(t)) > -1 && (tt((i = u.ranges[i]).from(), t) < 0 || t.xRel > 0) && (tt(i.to(), t) > 0 || t.xRel < 0) ? function (e, t, n, r) { var i = e.display, o = !1, u = ei(e, (function (t) { s && (i.scroller.draggable = !1), e.state.draggingText = !1, e.state.delayingBlurEvent && (e.hasFocus() ? e.state.delayingBlurEvent = !1 : wr(e)), fe(i.wrapper.ownerDocument, "mouseup", u), fe(i.wrapper.ownerDocument, "mousemove", c), fe(i.scroller, "dragstart", d), fe(i.scroller, "drop", u), o || (ye(t), r.addNew || Ki(e.doc, n, null, null, r.extend), s && !h || a && 9 == l ? setTimeout((function () { i.wrapper.ownerDocument.body.focus({ preventScroll: !0 }), i.input.focus() }), 20) : i.input.focus()) })), c = function (e) { o = o || Math.abs(t.clientX - e.clientX) + Math.abs(t.clientY - e.clientY) >= 10 }, d = function () { return o = !0 }; s && (i.scroller.draggable = !0); e.state.draggingText = u, u.copy = !r.moveOnDrag, de(i.wrapper.ownerDocument, "mouseup", u), de(i.wrapper.ownerDocument, "mousemove", c), de(i.scroller, "dragstart", d), de(i.scroller, "drop", u), e.state.delayingBlurEvent = !0, setTimeout((function () { return i.input.focus() }), 20), i.scroller.dragDrop && i.scroller.dragDrop() }(e, r, t, o) : function (e, t, n, r) { a && wr(e); var i = e.display, o = e.doc; ye(t); var l, s, u = o.sel, c = u.ranges; r.addNew && !r.extend ? (s = o.sel.contains(n), l = s > -1 ? c[s] : new wi(n, n)) : (l = o.sel.primary(), s = o.sel.primIndex); if ("rectangle" == r.unit) r.addNew || (l = new wi(n, n)), n = ur(e, t, !0, !0), s = -1; else { var d = va(e, n, r.unit); l = r.extend ? Vi(l, d.anchor, d.head, r.extend) : d } r.addNew ? -1 == s ? (s = c.length, Ji(o, ki(e, c.concat([l]), s), { scroll: !1, origin: "*mouse" })) : c.length > 1 && c[s].empty() && "char" == r.unit && !r.extend ? (Ji(o, ki(e, c.slice(0, s).concat(c.slice(s + 1)), 0), { scroll: !1, origin: "*mouse" }), u = o.sel) : Zi(o, s, l, q) : (s = 0, Ji(o, new Ci([l], 0), q), u = o.sel); var h = n; function f(t) { if (0 != tt(h, t)) if (h = t, "rectangle" == r.unit) { for (var i = [], a = e.options.tabSize, c = R(Ge(o, n.line).text, n.ch, a), d = R(Ge(o, t.line).text, t.ch, a), f = Math.min(c, d), p = Math.max(c, d), m = Math.min(n.line, t.line), g = Math.min(e.lastLine(), Math.max(n.line, t.line)); m <= g; m++) { var v = Ge(o, m).text, x = $(v, f, a); f == p ? i.push(new wi(et(m, x), et(m, x))) : v.length > x && i.push(new wi(et(m, x), et(m, $(v, p, a)))) } i.length || i.push(new wi(n, n)), Ji(o, ki(e, u.ranges.slice(0, s).concat(i), s), { origin: "*mouse", scroll: !1 }), e.scrollIntoView(t) } else { var y, b = l, D = va(e, t, r.unit), C = b.anchor; tt(D.anchor, C) > 0 ? (y = D.head, C = ot(b.from(), D.anchor)) : (y = D.anchor, C = it(b.to(), D.head)); var w = u.ranges.slice(0); w[s] = function (e, t) { var n = t.anchor, r = t.head, i = Ge(e.doc, n.line); if (0 == tt(n, r) && n.sticky == r.sticky) return t; var o = ue(i); if (!o) return t; var a = le(o, n.ch, n.sticky), l = o[a]; if (l.from != n.ch && l.to != n.ch) return t; var s, u = a + (l.from == n.ch == (1 != l.level) ? 0 : 1); if (0 == u || u == o.length) return t; if (r.line != n.line) s = (r.line - n.line) * ("ltr" == e.doc.direction ? 1 : -1) > 0; else { var c = le(o, r.ch, r.sticky), d = c - a || (r.ch - n.ch) * (1 == l.level ? -1 : 1); s = c == u - 1 || c == u ? d < 0 : d > 0 } var h = o[u + (s ? -1 : 0)], f = s == (1 == h.level), p = f ? h.from : h.to, m = f ? "after" : "before"; return n.ch == p && n.sticky == m ? t : new wi(new et(n.line, p, m), r) }(e, new wi(lt(o, C), y)), Ji(o, ki(e, w, s), q) } } var p = i.wrapper.getBoundingClientRect(), m = 0; function g(t) { var n = ++m, a = ur(e, t, !0, "rectangle" == r.unit); if (a) if (0 != tt(a, h)) { e.curOp.focus = B(), f(a); var l = Er(i, o); (a.line >= l.to || a.line < l.from) && setTimeout(ei(e, (function () { m == n && g(t) })), 150) } else { var s = t.clientY < p.top ? -20 : t.clientY > p.bottom ? 20 : 0; s && setTimeout(ei(e, (function () { m == n && (i.scroller.scrollTop += s, g(t)) })), 50) } } function v(t) { e.state.selectingText = !1, m = 1 / 0, t && (ye(t), i.input.focus()), fe(i.wrapper.ownerDocument, "mousemove", x), fe(i.wrapper.ownerDocument, "mouseup", y), o.history.lastSelOrigin = null } var x = ei(e, (function (e) { 0 !== e.buttons && ke(e) ? g(e) : v(e) })), y = ei(e, v); e.state.selectingText = y, de(i.wrapper.ownerDocument, "mousemove", x), de(i.wrapper.ownerDocument, "mouseup", y) }(e, r, t, o) }(t, r, o, e) : we(e) == n.scroller && ye(e) : 2 == i ? (r && Ki(t.doc, r), setTimeout((function () { return n.input.focus() }), 20)) : 3 == i && (w ? t.display.input.onContextMenu(e) : wr(t))) } } function va(e, t, n) { if ("char" == n) return new wi(t, t); if ("word" == n) return e.findWordAt(t); if ("line" == n) return new wi(et(t.line, 0), lt(e.doc, et(t.line + 1, 0))); var r = n(e, t); return new wi(r.from, r.to) } function xa(e, t, n, r) { var i, o; if (t.touches) i = t.touches[0].clientX, o = t.touches[0].clientY; else try { i = t.clientX, o = t.clientY } catch (e) { return !1 } if (i >= Math.floor(e.display.gutters.getBoundingClientRect().right)) return !1; r && ye(t); var a = e.display, l = a.lineDiv.getBoundingClientRect(); if (o > l.bottom || !ve(e, n)) return De(t); o -= l.top - a.viewOffset; for (var s = 0; s < e.display.gutterSpecs.length; ++s) { var u = a.gutters.childNodes[s]; if (u && u.getBoundingClientRect().right >= i) return pe(e, n, e, Ye(e.doc, o), e.display.gutterSpecs[s].className, t), De(t) } } function ya(e, t) { return xa(e, t, "gutterClick", !0) } function ba(e, t) { Cn(e.display, t) || function (e, t) { if (!ve(e, "gutterContextMenu")) return !1; return xa(e, t, "gutterContextMenu", !1) }(e, t) || me(e, t, "contextmenu") || w || e.display.input.onContextMenu(t) } function Da(e) { e.display.wrapper.className = e.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") + e.options.theme.replace(/(^|\s)\s*/g, " cm-s-"), _n(e) } ma.prototype.compare = function (e, t, n) { return this.time + 400 > e && 0 == tt(t, this.pos) && n == this.button }; var Ca = { toString: function () { return "CodeMirror.Init" } }, wa = {}, ka = {}; function Sa(e, t, n) { if (!t != !(n && n != Ca)) { var r = e.display.dragFunctions, i = t ? de : fe; i(e.display.scroller, "dragstart", r.start), i(e.display.scroller, "dragenter", r.enter), i(e.display.scroller, "dragover", r.over), i(e.display.scroller, "dragleave", r.leave), i(e.display.scroller, "drop", r.drop) } } function Fa(e) { e.options.lineWrapping ? (N(e.display.wrapper, "CodeMirror-wrap"), e.display.sizer.style.minWidth = "", e.display.sizerWidth = null) : (F(e.display.wrapper, "CodeMirror-wrap"), $t(e)), sr(e), dr(e), _n(e), setTimeout((function () { return Wr(e) }), 100) } function Aa(e, t) { var n = this; if (!(this instanceof Aa)) return new Aa(e, t); this.options = t = t ? H(t) : {}, H(wa, t, !1); var r = t.value; "string" == typeof r ? r = new Mo(r, t.mode, null, t.lineSeparator, t.direction) : t.mode && (r.modeOption = t.mode), this.doc = r; var i = new Aa.inputStyles[t.inputStyle](this), o = this.display = new gi(e, r, i, t); for (var u in o.wrapper.CodeMirror = this, Da(this), t.lineWrapping && (this.display.wrapper.className += " CodeMirror-wrap"), Ur(this), this.state = { keyMaps: [], overlays: [], modeGen: 0, overwrite: !1, delayingBlurEvent: !1, focused: !1, suppressEdits: !1, pasteIncoming: -1, cutIncoming: -1, selectingText: !1, draggingText: !1, highlight: new P, keySeq: null, specialChars: null }, t.autofocus && !v && o.input.focus(), a && l < 11 && setTimeout((function () { return n.display.input.reset(!0) }), 20), function (e) { var t = e.display; de(t.scroller, "mousedown", ei(e, ga)), de(t.scroller, "dblclick", a && l < 11 ? ei(e, (function (t) { if (!me(e, t)) { var n = ur(e, t); if (n && !ya(e, t) && !Cn(e.display, t)) { ye(t); var r = e.findWordAt(n); Ki(e.doc, r.anchor, r.head) } } })) : function (t) { return me(e, t) || ye(t) }); de(t.scroller, "contextmenu", (function (t) { return ba(e, t) })), de(t.input.getField(), "contextmenu", (function (n) { t.scroller.contains(n.target) || ba(e, n) })); var n, r = { end: 0 }; function i() { t.activeTouch && (n = setTimeout((function () { return t.activeTouch = null }), 1e3), (r = t.activeTouch).end = +new Date) } function o(e) { if (1 != e.touches.length) return !1; var t = e.touches[0]; return t.radiusX <= 1 && t.radiusY <= 1 } function s(e, t) { if (null == t.left) return !0; var n = t.left - e.left, r = t.top - e.top; return n * n + r * r > 400 } de(t.scroller, "touchstart", (function (i) { if (!me(e, i) && !o(i) && !ya(e, i)) { t.input.ensurePolled(), clearTimeout(n); var a = +new Date; t.activeTouch = { start: a, moved: !1, prev: a - r.end <= 300 ? r : null }, 1 == i.touches.length && (t.activeTouch.left = i.touches[0].pageX, t.activeTouch.top = i.touches[0].pageY) } })), de(t.scroller, "touchmove", (function () { t.activeTouch && (t.activeTouch.moved = !0) })), de(t.scroller, "touchend", (function (n) { var r = t.activeTouch; if (r && !Cn(t, n) && null != r.left && !r.moved && new Date - r.start < 300) { var o, a = e.coordsChar(t.activeTouch, "page"); o = !r.prev || s(r, r.prev) ? new wi(a, a) : !r.prev.prev || s(r, r.prev.prev) ? e.findWordAt(a) : new wi(et(a.line, 0), lt(e.doc, et(a.line + 1, 0))), e.setSelection(o.anchor, o.head), e.focus(), ye(n) } i() })), de(t.scroller, "touchcancel", i), de(t.scroller, "scroll", (function () { t.scroller.clientHeight && (Ir(e, t.scroller.scrollTop), Hr(e, t.scroller.scrollLeft, !0), pe(e, "scroll", e)) })), de(t.scroller, "mousewheel", (function (t) { return Di(e, t) })), de(t.scroller, "DOMMouseScroll", (function (t) { return Di(e, t) })), de(t.wrapper, "scroll", (function () { return t.wrapper.scrollTop = t.wrapper.scrollLeft = 0 })), t.dragFunctions = { enter: function (t) { me(e, t) || Ce(t) }, over: function (t) { me(e, t) || (!function (e, t) { var n = ur(e, t); if (n) { var r = document.createDocumentFragment(); xr(e, n, r), e.display.dragCursor || (e.display.dragCursor = T("div", null, "CodeMirror-cursors CodeMirror-dragcursors"), e.display.lineSpace.insertBefore(e.display.dragCursor, e.display.cursorDiv)), E(e.display.dragCursor, r) } }(e, t), Ce(t)) }, start: function (t) { return function (e, t) { if (a && (!e.state.draggingText || +new Date - Bo < 100)) Ce(t); else if (!me(e, t) && !Cn(e.display, t) && (t.dataTransfer.setData("Text", e.getSelection()), t.dataTransfer.effectAllowed = "copyMove", t.dataTransfer.setDragImage && !h)) { var n = T("img", null, null, "position: fixed; left: 0; top: 0;"); n.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==", d && (n.width = n.height = 1, e.display.wrapper.appendChild(n), n._top = n.offsetTop), t.dataTransfer.setDragImage(n, 0, 0), d && n.parentNode.removeChild(n) } }(e, t) }, drop: ei(e, No), leave: function (t) { me(e, t) || Oo(e) } }; var u = t.input.getField(); de(u, "keyup", (function (t) { return da.call(e, t) })), de(u, "keydown", ei(e, ca)), de(u, "keypress", ei(e, ha)), de(u, "focus", (function (t) { return kr(e, t) })), de(u, "blur", (function (t) { return Sr(e, t) })) }(this), Ho(), Gr(this), this.curOp.forceUpdate = !0, Ii(this, r), t.autofocus && !v || this.hasFocus() ? setTimeout((function () { n.hasFocus() && !n.state.focused && kr(n) }), 20) : Sr(this), ka) ka.hasOwnProperty(u) && ka[u](this, t[u], Ca); hi(this), t.finishInit && t.finishInit(this); for (var c = 0; c < Ea.length; ++c)Ea[c](this); Vr(this), s && t.lineWrapping && "optimizelegibility" == getComputedStyle(o.lineDiv).textRendering && (o.lineDiv.style.textRendering = "auto") } Aa.defaults = wa, Aa.optionHandlers = ka; var Ea = []; function Ta(e, t, n, r) { var i, o = e.doc; null == n && (n = "add"), "smart" == n && (o.mode.indent ? i = ft(e, t).state : n = "prev"); var a = e.options.tabSize, l = Ge(o, t), s = R(l.text, null, a); l.stateAfter && (l.stateAfter = null); var u, c = l.text.match(/^\s*/)[0]; if (r || /\S/.test(l.text)) { if ("smart" == n && ((u = o.mode.indent(i, l.text.slice(c.length), l.text)) == W || u > 150)) { if (!r) return; n = "prev" } } else u = 0, n = "not"; "prev" == n ? u = t > o.first ? R(Ge(o, t - 1).text, null, a) : 0 : "add" == n ? u = s + e.options.indentUnit : "subtract" == n ? u = s - e.options.indentUnit : "number" == typeof n && (u = s + n), u = Math.max(0, u); var d = "", h = 0; if (e.options.indentWithTabs) for (var f = Math.floor(u / a); f; --f)h += a, d += "\t"; if (h < u && (d += V(u - h)), d != c) return mo(o, d, et(t, 0), et(t, c.length), "+input"), l.stateAfter = null, !0; for (var p = 0; p < o.sel.ranges.length; p++) { var m = o.sel.ranges[p]; if (m.head.line == t && m.head.ch < c.length) { var g = et(t, c.length); Zi(o, p, new wi(g, g)); break } } } Aa.defineInitHook = function (e) { return Ea.push(e) }; var La = null; function Ma(e) { La = e } function Ba(e, t, n, r, i) { var o = e.doc; e.display.shift = !1, r || (r = o.sel); var a = +new Date - 200, l = "paste" == i || e.state.pasteIncoming > a, s = Me(t), u = null; if (l && r.ranges.length > 1) if (La && La.text.join("\n") == t) { if (r.ranges.length % La.text.length == 0) { u = []; for (var c = 0; c < La.text.length; c++)u.push(o.splitLines(La.text[c])) } } else s.length == r.ranges.length && e.options.pasteLinesPerSelection && (u = X(s, (function (e) { return [e] }))); for (var d = e.curOp.updateInput, h = r.ranges.length - 1; h >= 0; h--) { var f = r.ranges[h], p = f.from(), m = f.to(); f.empty() && (n && n > 0 ? p = et(p.line, p.ch - n) : e.state.overwrite && !l ? m = et(m.line, Math.min(Ge(o, m.line).text.length, m.ch + K(s).length)) : l && La && La.lineWise && La.text.join("\n") == s.join("\n") && (p = m = et(p.line, 0))); var g = { from: p, to: m, text: u ? u[h % u.length] : s, origin: i || (l ? "paste" : e.state.cutIncoming > a ? "cut" : "+input") }; uo(e.doc, g), sn(e, "inputRead", e, g) } t && !l && Oa(e, t), Mr(e), e.curOp.updateInput < 2 && (e.curOp.updateInput = d), e.curOp.typing = !0, e.state.pasteIncoming = e.state.cutIncoming = -1 } function Na(e, t) { var n = e.clipboardData && e.clipboardData.getData("Text"); if (n) return e.preventDefault(), t.isReadOnly() || t.options.disableInput || Jr(t, (function () { return Ba(t, n, 0, null, "paste") })), !0 } function Oa(e, t) { if (e.options.electricChars && e.options.smartIndent) for (var n = e.doc.sel, r = n.ranges.length - 1; r >= 0; r--) { var i = n.ranges[r]; if (!(i.head.ch > 100 || r && n.ranges[r - 1].head.line == i.head.line)) { var o = e.getModeAt(i.head), a = !1; if (o.electricChars) { for (var l = 0; l < o.electricChars.length; l++)if (t.indexOf(o.electricChars.charAt(l)) > -1) { a = Ta(e, i.head.line, "smart"); break } } else o.electricInput && o.electricInput.test(Ge(e.doc, i.head.line).text.slice(0, i.head.ch)) && (a = Ta(e, i.head.line, "smart")); a && sn(e, "electricInput", e, i.head.line) } } } function Ia(e) { for (var t = [], n = [], r = 0; r < e.doc.sel.ranges.length; r++) { var i = e.doc.sel.ranges[r].head.line, o = { anchor: et(i, 0), head: et(i + 1, 0) }; n.push(o), t.push(e.getRange(o.anchor, o.head)) } return { text: t, ranges: n } } function za(e, t, n, r) { e.setAttribute("autocorrect", n ? "" : "off"), e.setAttribute("autocapitalize", r ? "" : "off"), e.setAttribute("spellcheck", !!t) } function Ha() { var e = T("textarea", null, null, "position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none"), t = T("div", [e], null, "overflow: hidden; position: relative; width: 3px; height: 0px;"); return s ? e.style.width = "1000px" : e.setAttribute("wrap", "off"), m && (e.style.border = "1px solid black"), za(e), t } function Ra(e, t, n, r, i) { var o = t, a = n, l = Ge(e, t.line), s = i && "rtl" == e.direction ? -n : n; function u(o) { var a, u; if ("codepoint" == r) { var c = l.text.charCodeAt(t.ch + (n > 0 ? 0 : -1)); if (isNaN(c)) a = null; else { var d = n > 0 ? c >= 55296 && c < 56320 : c >= 56320 && c < 57343; a = new et(t.line, Math.max(0, Math.min(l.text.length, t.ch + n * (d ? 2 : 1))), -n) } } else a = i ? function (e, t, n, r) { var i = ue(t, e.doc.direction); if (!i) return Jo(t, n, r); n.ch >= t.text.length ? (n.ch = t.text.length, n.sticky = "before") : n.ch <= 0 && (n.ch = 0, n.sticky = "after"); var o = le(i, n.ch, n.sticky), a = i[o]; if ("ltr" == e.doc.direction && a.level % 2 == 0 && (r > 0 ? a.to > n.ch : a.from < n.ch)) return Jo(t, n, r); var l, s = function (e, n) { return Qo(t, e instanceof et ? e.ch : e, n) }, u = function (n) { return e.options.lineWrapping ? (l = l || Bn(e, t), Qn(e, t, l, n)) : { begin: 0, end: t.text.length } }, c = u("before" == n.sticky ? s(n, -1) : n.ch); if ("rtl" == e.doc.direction || 1 == a.level) { var d = 1 == a.level == r < 0, h = s(n, d ? 1 : -1); if (null != h && (d ? h <= a.to && h <= c.end : h >= a.from && h >= c.begin)) { var f = d ? "before" : "after"; return new et(n.line, h, f) } } var p = function (e, t, r) { for (var o = function (e, t) { return t ? new et(n.line, s(e, 1), "before") : new et(n.line, e, "after") }; e >= 0 && e < i.length; e += t) { var a = i[e], l = t > 0 == (1 != a.level), u = l ? r.begin : s(r.end, -1); if (a.from <= u && u < a.to) return o(u, l); if (u = l ? a.from : s(a.to, -1), r.begin <= u && u < r.end) return o(u, l) } }, m = p(o + r, r, c); if (m) return m; var g = r > 0 ? c.end : s(c.begin, -1); return null == g || r > 0 && g == t.text.length || !(m = p(r > 0 ? 0 : i.length - 1, r, u(g))) ? null : m }(e.cm, l, t, n) : Jo(l, t, n); if (null == a) { if (o || (u = t.line + s) < e.first || u >= e.first + e.size || (t = new et(u, t.ch, t.sticky), !(l = Ge(e, u)))) return !1; t = ea(i, e.cm, l, t.line, s) } else t = a; return !0 } if ("char" == r || "codepoint" == r) u(); else if ("column" == r) u(!0); else if ("word" == r || "group" == r) for (var c = null, d = "group" == r, h = e.cm && e.cm.getHelper(t, "wordChars"), f = !0; !(n < 0) || u(!f); f = !1) { var p = l.text.charAt(t.ch) || "\n", m = ee(p, h) ? "w" : d && "\n" == p ? "n" : !d || /\s/.test(p) ? null : "p"; if (!d || f || m || (m = "s"), c && c != m) { n < 0 && (n = 1, u(), t.sticky = "after"); break } if (m && (c = m), n > 0 && !u(!f)) break } var g = oo(e, t, o, a, !0); return nt(o, g) && (g.hitSide = !0), g } function Pa(e, t, n, r) { var i, o, a = e.doc, l = t.left; if ("page" == r) { var s = Math.min(e.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight), u = Math.max(s - .5 * rr(e.display), 3); i = (n > 0 ? t.bottom : t.top) + n * u } else "line" == r && (i = n > 0 ? t.bottom + 3 : t.top - 3); for (; (o = Zn(e, l, i)).outside;) { if (n < 0 ? i <= 0 : i >= a.height) { o.hitSide = !0; break } i += 5 * n } return o } var _a = function (e) { this.cm = e, this.lastAnchorNode = this.lastAnchorOffset = this.lastFocusNode = this.lastFocusOffset = null, this.polling = new P, this.composing = null, this.gracePeriod = !1, this.readDOMTimeout = null }; function Wa(e, t) { var n = Mn(e, t.line); if (!n || n.hidden) return null; var r = Ge(e.doc, t.line), i = Tn(n, r, t.line), o = ue(r, e.doc.direction), a = "left"; o && (a = le(o, t.ch) % 2 ? "right" : "left"); var l = zn(i.map, t.ch, a); return l.offset = "right" == l.collapse ? l.end : l.start, l } function ja(e, t) { return t && (e.bad = !0), e } function qa(e, t, n) { var r; if (t == e.display.lineDiv) { if (!(r = e.display.lineDiv.childNodes[n])) return ja(e.clipPos(et(e.display.viewTo - 1)), !0); t = null, n = 0 } else for (r = t; ; r = r.parentNode) { if (!r || r == e.display.lineDiv) return null; if (r.parentNode && r.parentNode == e.display.lineDiv) break } for (var i = 0; i < e.display.view.length; i++) { var o = e.display.view[i]; if (o.node == r) return Ua(o, t, n) } } function Ua(e, t, n) { var r = e.text.firstChild, i = !1; if (!t || !M(r, t)) return ja(et(Ze(e.line), 0), !0); if (t == r && (i = !0, t = r.childNodes[n], n = 0, !t)) { var o = e.rest ? K(e.rest) : e.line; return ja(et(Ze(o), o.text.length), i) } var a = 3 == t.nodeType ? t : null, l = t; for (a || 1 != t.childNodes.length || 3 != t.firstChild.nodeType || (a = t.firstChild, n && (n = a.nodeValue.length)); l.parentNode != r;)l = l.parentNode; var s = e.measure, u = s.maps; function c(t, n, r) { for (var i = -1; i < (u ? u.length : 0); i++)for (var o = i < 0 ? s.map : u[i], a = 0; a < o.length; a += 3) { var l = o[a + 2]; if (l == t || l == n) { var c = Ze(i < 0 ? e.line : e.rest[i]), d = o[a] + r; return (r < 0 || l != t) && (d = o[a + (r ? 1 : 0)]), et(c, d) } } } var d = c(a, l, n); if (d) return ja(d, i); for (var h = l.nextSibling, f = a ? a.nodeValue.length - n : 0; h; h = h.nextSibling) { if (d = c(h, h.firstChild, 0)) return ja(et(d.line, d.ch - f), i); f += h.textContent.length } for (var p = l.previousSibling, m = n; p; p = p.previousSibling) { if (d = c(p, p.firstChild, -1)) return ja(et(d.line, d.ch + m), i); m += p.textContent.length } } _a.prototype.init = function (e) { var t = this, n = this, r = n.cm, i = n.div = e.lineDiv; function o(e) { for (var t = e.target; t; t = t.parentNode) { if (t == i) return !0; if (/\bCodeMirror-(?:line)?widget\b/.test(t.className)) break } return !1 } function a(e) { if (o(e) && !me(r, e)) { if (r.somethingSelected()) Ma({ lineWise: !1, text: r.getSelections() }), "cut" == e.type && r.replaceSelection("", null, "cut"); else { if (!r.options.lineWiseCopyCut) return; var t = Ia(r); Ma({ lineWise: !0, text: t.text }), "cut" == e.type && r.operation((function () { r.setSelections(t.ranges, 0, j), r.replaceSelection("", null, "cut") })) } if (e.clipboardData) { e.clipboardData.clearData(); var a = La.text.join("\n"); if (e.clipboardData.setData("Text", a), e.clipboardData.getData("Text") == a) return void e.preventDefault() } var l = Ha(), s = l.firstChild; r.display.lineSpace.insertBefore(l, r.display.lineSpace.firstChild), s.value = La.text.join("\n"); var u = B(); I(s), setTimeout((function () { r.display.lineSpace.removeChild(l), u.focus(), u == i && n.showPrimarySelection() }), 50) } } i.contentEditable = !0, za(i, r.options.spellcheck, r.options.autocorrect, r.options.autocapitalize), de(i, "paste", (function (e) { !o(e) || me(r, e) || Na(e, r) || l <= 11 && setTimeout(ei(r, (function () { return t.updateFromDOM() })), 20) })), de(i, "compositionstart", (function (e) { t.composing = { data: e.data, done: !1 } })), de(i, "compositionupdate", (function (e) { t.composing || (t.composing = { data: e.data, done: !1 }) })), de(i, "compositionend", (function (e) { t.composing && (e.data != t.composing.data && t.readFromDOMSoon(), t.composing.done = !0) })), de(i, "touchstart", (function () { return n.forceCompositionEnd() })), de(i, "input", (function () { t.composing || t.readFromDOMSoon() })), de(i, "copy", a), de(i, "cut", a) }, _a.prototype.screenReaderLabelChanged = function (e) { e ? this.div.setAttribute("aria-label", e) : this.div.removeAttribute("aria-label") }, _a.prototype.prepareSelection = function () { var e = vr(this.cm, !1); return e.focus = B() == this.div, e }, _a.prototype.showSelection = function (e, t) { e && this.cm.display.view.length && ((e.focus || t) && this.showPrimarySelection(), this.showMultipleSelections(e)) }, _a.prototype.getSelection = function () { return this.cm.display.wrapper.ownerDocument.getSelection() }, _a.prototype.showPrimarySelection = function () { var e = this.getSelection(), t = this.cm, r = t.doc.sel.primary(), i = r.from(), o = r.to(); if (t.display.viewTo == t.display.viewFrom || i.line >= t.display.viewTo || o.line < t.display.viewFrom) e.removeAllRanges(); else { var a = qa(t, e.anchorNode, e.anchorOffset), l = qa(t, e.focusNode, e.focusOffset); if (!a || a.bad || !l || l.bad || 0 != tt(ot(a, l), i) || 0 != tt(it(a, l), o)) { var s = t.display.view, u = i.line >= t.display.viewFrom && Wa(t, i) || { node: s[0].measure.map[2], offset: 0 }, c = o.line < t.display.viewTo && Wa(t, o); if (!c) { var d = s[s.length - 1].measure, h = d.maps ? d.maps[d.maps.length - 1] : d.map; c = { node: h[h.length - 1], offset: h[h.length - 2] - h[h.length - 3] } } if (u && c) { var f, p = e.rangeCount && e.getRangeAt(0); try { f = S(u.node, u.offset, c.offset, c.node) } catch (e) { } f && (!n && t.state.focused ? (e.collapse(u.node, u.offset), f.collapsed || (e.removeAllRanges(), e.addRange(f))) : (e.removeAllRanges(), e.addRange(f)), p && null == e.anchorNode ? e.addRange(p) : n && this.startGracePeriod()), this.rememberSelection() } else e.removeAllRanges() } } }, _a.prototype.startGracePeriod = function () { var e = this; clearTimeout(this.gracePeriod), this.gracePeriod = setTimeout((function () { e.gracePeriod = !1, e.selectionChanged() && e.cm.operation((function () { return e.cm.curOp.selectionChanged = !0 })) }), 20) }, _a.prototype.showMultipleSelections = function (e) { E(this.cm.display.cursorDiv, e.cursors), E(this.cm.display.selectionDiv, e.selection) }, _a.prototype.rememberSelection = function () { var e = this.getSelection(); this.lastAnchorNode = e.anchorNode, this.lastAnchorOffset = e.anchorOffset, this.lastFocusNode = e.focusNode, this.lastFocusOffset = e.focusOffset }, _a.prototype.selectionInEditor = function () { var e = this.getSelection(); if (!e.rangeCount) return !1; var t = e.getRangeAt(0).commonAncestorContainer; return M(this.div, t) }, _a.prototype.focus = function () { "nocursor" != this.cm.options.readOnly && (this.selectionInEditor() && B() == this.div || this.showSelection(this.prepareSelection(), !0), this.div.focus()) }, _a.prototype.blur = function () { this.div.blur() }, _a.prototype.getField = function () { return this.div }, _a.prototype.supportsTouch = function () { return !0 }, _a.prototype.receivedFocus = function () { var e = this; this.selectionInEditor() ? this.pollSelection() : Jr(this.cm, (function () { return e.cm.curOp.selectionChanged = !0 })), this.polling.set(this.cm.options.pollInterval, (function t() { e.cm.state.focused && (e.pollSelection(), e.polling.set(e.cm.options.pollInterval, t)) })) }, _a.prototype.selectionChanged = function () { var e = this.getSelection(); return e.anchorNode != this.lastAnchorNode || e.anchorOffset != this.lastAnchorOffset || e.focusNode != this.lastFocusNode || e.focusOffset != this.lastFocusOffset }, _a.prototype.pollSelection = function () { if (null == this.readDOMTimeout && !this.gracePeriod && this.selectionChanged()) { var e = this.getSelection(), t = this.cm; if (g && c && this.cm.display.gutterSpecs.length && function (e) { for (var t = e; t; t = t.parentNode)if (/CodeMirror-gutter-wrapper/.test(t.className)) return !0; return !1 }(e.anchorNode)) return this.cm.triggerOnKeyDown({ type: "keydown", keyCode: 8, preventDefault: Math.abs }), this.blur(), void this.focus(); if (!this.composing) { this.rememberSelection(); var n = qa(t, e.anchorNode, e.anchorOffset), r = qa(t, e.focusNode, e.focusOffset); n && r && Jr(t, (function () { Ji(t.doc, Si(n, r), j), (n.bad || r.bad) && (t.curOp.selectionChanged = !0) })) } } }, _a.prototype.pollContent = function () { null != this.readDOMTimeout && (clearTimeout(this.readDOMTimeout), this.readDOMTimeout = null); var e, t, n, r = this.cm, i = r.display, o = r.doc.sel.primary(), a = o.from(), l = o.to(); if (0 == a.ch && a.line > r.firstLine() && (a = et(a.line - 1, Ge(r.doc, a.line - 1).length)), l.ch == Ge(r.doc, l.line).text.length && l.line < r.lastLine() && (l = et(l.line + 1, 0)), a.line < i.viewFrom || l.line > i.viewTo - 1) return !1; a.line == i.viewFrom || 0 == (e = cr(r, a.line)) ? (t = Ze(i.view[0].line), n = i.view[0].node) : (t = Ze(i.view[e].line), n = i.view[e - 1].node.nextSibling); var s, u, c = cr(r, l.line); if (c == i.view.length - 1 ? (s = i.viewTo - 1, u = i.lineDiv.lastChild) : (s = Ze(i.view[c + 1].line) - 1, u = i.view[c + 1].node.previousSibling), !n) return !1; for (var d = r.doc.splitLines(function (e, t, n, r, i) { var o = "", a = !1, l = e.doc.lineSeparator(), s = !1; function u(e) { return function (t) { return t.id == e } } function c() { a && (o += l, s && (o += l), a = s = !1) } function d(e) { e && (c(), o += e) } function h(t) { if (1 == t.nodeType) { var n = t.getAttribute("cm-text"); if (n) return void d(n); var o, f = t.getAttribute("cm-marker"); if (f) { var p = e.findMarks(et(r, 0), et(i + 1, 0), u(+f)); return void (p.length && (o = p[0].find(0)) && d(Ve(e.doc, o.from, o.to).join(l))) } if ("false" == t.getAttribute("contenteditable")) return; var m = /^(pre|div|p|li|table|br)$/i.test(t.nodeName); if (!/^br$/i.test(t.nodeName) && 0 == t.textContent.length) return; m && c(); for (var g = 0; g < t.childNodes.length; g++)h(t.childNodes[g]); /^(pre|p)$/i.test(t.nodeName) && (s = !0), m && (a = !0) } else 3 == t.nodeType && d(t.nodeValue.replace(/\u200b/g, "").replace(/\u00a0/g, " ")) } for (; h(t), t != n;)t = t.nextSibling, s = !1; return o }(r, n, u, t, s)), h = Ve(r.doc, et(t, 0), et(s, Ge(r.doc, s).text.length)); d.length > 1 && h.length > 1;)if (K(d) == K(h)) d.pop(), h.pop(), s--; else { if (d[0] != h[0]) break; d.shift(), h.shift(), t++ } for (var f = 0, p = 0, m = d[0], g = h[0], v = Math.min(m.length, g.length); f < v && m.charCodeAt(f) == g.charCodeAt(f);)++f; for (var x = K(d), y = K(h), b = Math.min(x.length - (1 == d.length ? f : 0), y.length - (1 == h.length ? f : 0)); p < b && x.charCodeAt(x.length - p - 1) == y.charCodeAt(y.length - p - 1);)++p; if (1 == d.length && 1 == h.length && t == a.line) for (; f && f > a.ch && x.charCodeAt(x.length - p - 1) == y.charCodeAt(y.length - p - 1);)f--, p++; d[d.length - 1] = x.slice(0, x.length - p).replace(/^\u200b+/, ""), d[0] = d[0].slice(f).replace(/\u200b+$/, ""); var D = et(t, f), C = et(s, h.length ? K(h).length - p : 0); return d.length > 1 || d[0] || tt(D, C) ? (mo(r.doc, d, D, C, "+input"), !0) : void 0 }, _a.prototype.ensurePolled = function () { this.forceCompositionEnd() }, _a.prototype.reset = function () { this.forceCompositionEnd() }, _a.prototype.forceCompositionEnd = function () { this.composing && (clearTimeout(this.readDOMTimeout), this.composing = null, this.updateFromDOM(), this.div.blur(), this.div.focus()) }, _a.prototype.readFromDOMSoon = function () { var e = this; null == this.readDOMTimeout && (this.readDOMTimeout = setTimeout((function () { if (e.readDOMTimeout = null, e.composing) { if (!e.composing.done) return; e.composing = null } e.updateFromDOM() }), 80)) }, _a.prototype.updateFromDOM = function () { var e = this; !this.cm.isReadOnly() && this.pollContent() || Jr(this.cm, (function () { return dr(e.cm) })) }, _a.prototype.setUneditable = function (e) { e.contentEditable = "false" }, _a.prototype.onKeyPress = function (e) { 0 == e.charCode || this.composing || (e.preventDefault(), this.cm.isReadOnly() || ei(this.cm, Ba)(this.cm, String.fromCharCode(null == e.charCode ? e.keyCode : e.charCode), 0)) }, _a.prototype.readOnlyChanged = function (e) { this.div.contentEditable = String("nocursor" != e) }, _a.prototype.onContextMenu = function () { }, _a.prototype.resetPosition = function () { }, _a.prototype.needsContentAttribute = !0; var $a = function (e) { this.cm = e, this.prevInput = "", this.pollingFast = !1, this.polling = new P, this.hasSelection = !1, this.composing = null }; $a.prototype.init = function (e) { var t = this, n = this, r = this.cm; this.createField(e); var i = this.textarea; function o(e) { if (!me(r, e)) { if (r.somethingSelected()) Ma({ lineWise: !1, text: r.getSelections() }); else { if (!r.options.lineWiseCopyCut) return; var t = Ia(r); Ma({ lineWise: !0, text: t.text }), "cut" == e.type ? r.setSelections(t.ranges, null, j) : (n.prevInput = "", i.value = t.text.join("\n"), I(i)) } "cut" == e.type && (r.state.cutIncoming = +new Date) } } e.wrapper.insertBefore(this.wrapper, e.wrapper.firstChild), m && (i.style.width = "0px"), de(i, "input", (function () { a && l >= 9 && t.hasSelection && (t.hasSelection = null), n.poll() })), de(i, "paste", (function (e) { me(r, e) || Na(e, r) || (r.state.pasteIncoming = +new Date, n.fastPoll()) })), de(i, "cut", o), de(i, "copy", o), de(e.scroller, "paste", (function (t) { if (!Cn(e, t) && !me(r, t)) { if (!i.dispatchEvent) return r.state.pasteIncoming = +new Date, void n.focus(); var o = new Event("paste"); o.clipboardData = t.clipboardData, i.dispatchEvent(o) } })), de(e.lineSpace, "selectstart", (function (t) { Cn(e, t) || ye(t) })), de(i, "compositionstart", (function () { var e = r.getCursor("from"); n.composing && n.composing.range.clear(), n.composing = { start: e, range: r.markText(e, r.getCursor("to"), { className: "CodeMirror-composing" }) } })), de(i, "compositionend", (function () { n.composing && (n.poll(), n.composing.range.clear(), n.composing = null) })) }, $a.prototype.createField = function (e) { this.wrapper = Ha(), this.textarea = this.wrapper.firstChild }, $a.prototype.screenReaderLabelChanged = function (e) { e ? this.textarea.setAttribute("aria-label", e) : this.textarea.removeAttribute("aria-label") }, $a.prototype.prepareSelection = function () { var e = this.cm, t = e.display, n = e.doc, r = vr(e); if (e.options.moveInputWithCursor) { var i = Vn(e, n.sel.primary().head, "div"), o = t.wrapper.getBoundingClientRect(), a = t.lineDiv.getBoundingClientRect(); r.teTop = Math.max(0, Math.min(t.wrapper.clientHeight - 10, i.top + a.top - o.top)), r.teLeft = Math.max(0, Math.min(t.wrapper.clientWidth - 10, i.left + a.left - o.left)) } return r }, $a.prototype.showSelection = function (e) { var t = this.cm.display; E(t.cursorDiv, e.cursors), E(t.selectionDiv, e.selection), null != e.teTop && (this.wrapper.style.top = e.teTop + "px", this.wrapper.style.left = e.teLeft + "px") }, $a.prototype.reset = function (e) { if (!this.contextMenuPending && !this.composing) { var t = this.cm; if (t.somethingSelected()) { this.prevInput = ""; var n = t.getSelection(); this.textarea.value = n, t.state.focused && I(this.textarea), a && l >= 9 && (this.hasSelection = n) } else e || (this.prevInput = this.textarea.value = "", a && l >= 9 && (this.hasSelection = null)) } }, $a.prototype.getField = function () { return this.textarea }, $a.prototype.supportsTouch = function () { return !1 }, $a.prototype.focus = function () { if ("nocursor" != this.cm.options.readOnly && (!v || B() != this.textarea)) try { this.textarea.focus() } catch (e) { } }, $a.prototype.blur = function () { this.textarea.blur() }, $a.prototype.resetPosition = function () { this.wrapper.style.top = this.wrapper.style.left = 0 }, $a.prototype.receivedFocus = function () { this.slowPoll() }, $a.prototype.slowPoll = function () { var e = this; this.pollingFast || this.polling.set(this.cm.options.pollInterval, (function () { e.poll(), e.cm.state.focused && e.slowPoll() })) }, $a.prototype.fastPoll = function () { var e = !1, t = this; t.pollingFast = !0, t.polling.set(20, (function n() { t.poll() || e ? (t.pollingFast = !1, t.slowPoll()) : (e = !0, t.polling.set(60, n)) })) }, $a.prototype.poll = function () { var e = this, t = this.cm, n = this.textarea, r = this.prevInput; if (this.contextMenuPending || !t.state.focused || Be(n) && !r && !this.composing || t.isReadOnly() || t.options.disableInput || t.state.keySeq) return !1; var i = n.value; if (i == r && !t.somethingSelected()) return !1; if (a && l >= 9 && this.hasSelection === i || x && /[\uf700-\uf7ff]/.test(i)) return t.display.input.reset(), !1; if (t.doc.sel == t.display.selForContextMenu) { var o = i.charCodeAt(0); if (8203 != o || r || (r = "​"), 8666 == o) return this.reset(), this.cm.execCommand("undo") } for (var s = 0, u = Math.min(r.length, i.length); s < u && r.charCodeAt(s) == i.charCodeAt(s);)++s; return Jr(t, (function () { Ba(t, i.slice(s), r.length - s, null, e.composing ? "*compose" : null), i.length > 1e3 || i.indexOf("\n") > -1 ? n.value = e.prevInput = "" : e.prevInput = i, e.composing && (e.composing.range.clear(), e.composing.range = t.markText(e.composing.start, t.getCursor("to"), { className: "CodeMirror-composing" })) })), !0 }, $a.prototype.ensurePolled = function () { this.pollingFast && this.poll() && (this.pollingFast = !1) }, $a.prototype.onKeyPress = function () { a && l >= 9 && (this.hasSelection = null), this.fastPoll() }, $a.prototype.onContextMenu = function (e) { var t = this, n = t.cm, r = n.display, i = t.textarea; t.contextMenuPending && t.contextMenuPending(); var o = ur(n, e), u = r.scroller.scrollTop; if (o && !d) { n.options.resetSelectionOnContextMenu && -1 == n.doc.sel.contains(o) && ei(n, Ji)(n.doc, Si(o), j); var c, h = i.style.cssText, f = t.wrapper.style.cssText, p = t.wrapper.offsetParent.getBoundingClientRect(); if (t.wrapper.style.cssText = "position: static", i.style.cssText = "position: absolute; width: 30px; height: 30px;\n top: " + (e.clientY - p.top - 5) + "px; left: " + (e.clientX - p.left - 5) + "px;\n z-index: 1000; background: " + (a ? "rgba(255, 255, 255, .05)" : "transparent") + ";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);", s && (c = window.scrollY), r.input.focus(), s && window.scrollTo(null, c), r.input.reset(), n.somethingSelected() || (i.value = t.prevInput = " "), t.contextMenuPending = v, r.selForContextMenu = n.doc.sel, clearTimeout(r.detectingSelectAll), a && l >= 9 && g(), w) { Ce(e); var m = function () { fe(window, "mouseup", m), setTimeout(v, 20) }; de(window, "mouseup", m) } else setTimeout(v, 50) } function g() { if (null != i.selectionStart) { var e = n.somethingSelected(), o = "​" + (e ? i.value : ""); i.value = "⇚", i.value = o, t.prevInput = e ? "" : "​", i.selectionStart = 1, i.selectionEnd = o.length, r.selForContextMenu = n.doc.sel } } function v() { if (t.contextMenuPending == v && (t.contextMenuPending = !1, t.wrapper.style.cssText = f, i.style.cssText = h, a && l < 9 && r.scrollbars.setScrollTop(r.scroller.scrollTop = u), null != i.selectionStart)) { (!a || a && l < 9) && g(); var e = 0, o = function () { r.selForContextMenu == n.doc.sel && 0 == i.selectionStart && i.selectionEnd > 0 && "​" == t.prevInput ? ei(n, lo)(n) : e++ < 10 ? r.detectingSelectAll = setTimeout(o, 500) : (r.selForContextMenu = null, r.input.reset()) }; r.detectingSelectAll = setTimeout(o, 200) } } }, $a.prototype.readOnlyChanged = function (e) { e || this.reset(), this.textarea.disabled = "nocursor" == e, this.textarea.readOnly = !!e }, $a.prototype.setUneditable = function () { }, $a.prototype.needsContentAttribute = !1, function (e) { var t = e.optionHandlers; function n(n, r, i, o) { e.defaults[n] = r, i && (t[n] = o ? function (e, t, n) { n != Ca && i(e, t, n) } : i) } e.defineOption = n, e.Init = Ca, n("value", "", (function (e, t) { return e.setValue(t) }), !0), n("mode", null, (function (e, t) { e.doc.modeOption = t, Li(e) }), !0), n("indentUnit", 2, Li, !0), n("indentWithTabs", !1), n("smartIndent", !0), n("tabSize", 4, (function (e) { Mi(e), _n(e), dr(e) }), !0), n("lineSeparator", null, (function (e, t) { if (e.doc.lineSep = t, t) { var n = [], r = e.doc.first; e.doc.iter((function (e) { for (var i = 0; ;) { var o = e.text.indexOf(t, i); if (-1 == o) break; i = o + t.length, n.push(et(r, o)) } r++ })); for (var i = n.length - 1; i >= 0; i--)mo(e.doc, t, n[i], et(n[i].line, n[i].ch + t.length)) } })), n("specialChars", /[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b\u200e\u200f\u2028\u2029\ufeff\ufff9-\ufffc]/g, (function (e, t, n) { e.state.specialChars = new RegExp(t.source + (t.test("\t") ? "" : "|\t"), "g"), n != Ca && e.refresh() })), n("specialCharPlaceholder", Qt, (function (e) { return e.refresh() }), !0), n("electricChars", !0), n("inputStyle", v ? "contenteditable" : "textarea", (function () { throw new Error("inputStyle can not (yet) be changed in a running editor") }), !0), n("spellcheck", !1, (function (e, t) { return e.getInputField().spellcheck = t }), !0), n("autocorrect", !1, (function (e, t) { return e.getInputField().autocorrect = t }), !0), n("autocapitalize", !1, (function (e, t) { return e.getInputField().autocapitalize = t }), !0), n("rtlMoveVisually", !b), n("wholeLineUpdateBefore", !0), n("theme", "default", (function (e) { Da(e), mi(e) }), !0), n("keyMap", "default", (function (e, t, n) { var r = Zo(t), i = n != Ca && Zo(n); i && i.detach && i.detach(e, r), r.attach && r.attach(e, i || null) })), n("extraKeys", null), n("configureMouse", null), n("lineWrapping", !1, Fa, !0), n("gutters", [], (function (e, t) { e.display.gutterSpecs = fi(t, e.options.lineNumbers), mi(e) }), !0), n("fixedGutter", !0, (function (e, t) { e.display.gutters.style.left = t ? ar(e.display) + "px" : "0", e.refresh() }), !0), n("coverGutterNextToScrollbar", !1, (function (e) { return Wr(e) }), !0), n("scrollbarStyle", "native", (function (e) { Ur(e), Wr(e), e.display.scrollbars.setScrollTop(e.doc.scrollTop), e.display.scrollbars.setScrollLeft(e.doc.scrollLeft) }), !0), n("lineNumbers", !1, (function (e, t) { e.display.gutterSpecs = fi(e.options.gutters, t), mi(e) }), !0), n("firstLineNumber", 1, mi, !0), n("lineNumberFormatter", (function (e) { return e }), mi, !0), n("showCursorWhenSelecting", !1, gr, !0), n("resetSelectionOnContextMenu", !0), n("lineWiseCopyCut", !0), n("pasteLinesPerSelection", !0), n("selectionsMayTouch", !1), n("readOnly", !1, (function (e, t) { "nocursor" == t && (Sr(e), e.display.input.blur()), e.display.input.readOnlyChanged(t) })), n("screenReaderLabel", null, (function (e, t) { t = "" === t ? null : t, e.display.input.screenReaderLabelChanged(t) })), n("disableInput", !1, (function (e, t) { t || e.display.input.reset() }), !0), n("dragDrop", !0, Sa), n("allowDropFileTypes", null), n("cursorBlinkRate", 530), n("cursorScrollMargin", 0), n("cursorHeight", 1, gr, !0), n("singleCursorHeightPerLine", !0, gr, !0), n("workTime", 100), n("workDelay", 100), n("flattenSpans", !0, Mi, !0), n("addModeClass", !1, Mi, !0), n("pollInterval", 100), n("undoDepth", 200, (function (e, t) { return e.doc.history.undoDepth = t })), n("historyEventDelay", 1250), n("viewportMargin", 10, (function (e) { return e.refresh() }), !0), n("maxHighlightLength", 1e4, Mi, !0), n("moveInputWithCursor", !0, (function (e, t) { t || e.display.input.resetPosition() })), n("tabindex", null, (function (e, t) { return e.display.input.getField().tabIndex = t || "" })), n("autofocus", null), n("direction", "ltr", (function (e, t) { return e.doc.setDirection(t) }), !0), n("phrases", null) }(Aa), function (e) { var t = e.optionHandlers, n = e.helpers = {}; e.prototype = { constructor: e, focus: function () { window.focus(), this.display.input.focus() }, setOption: function (e, n) { var r = this.options, i = r[e]; r[e] == n && "mode" != e || (r[e] = n, t.hasOwnProperty(e) && ei(this, t[e])(this, n, i), pe(this, "optionChange", this, e)) }, getOption: function (e) { return this.options[e] }, getDoc: function () { return this.doc }, addKeyMap: function (e, t) { this.state.keyMaps[t ? "push" : "unshift"](Zo(e)) }, removeKeyMap: function (e) { for (var t = this.state.keyMaps, n = 0; n < t.length; ++n)if (t[n] == e || t[n].name == e) return t.splice(n, 1), !0 }, addOverlay: ti((function (t, n) { var r = t.token ? t : e.getMode(this.options, t); if (r.startState) throw new Error("Overlays may not be stateful."); !function (e, t, n) { for (var r = 0, i = n(t); r < e.length && n(e[r]) <= i;)r++; e.splice(r, 0, t) }(this.state.overlays, { mode: r, modeSpec: t, opaque: n && n.opaque, priority: n && n.priority || 0 }, (function (e) { return e.priority })), this.state.modeGen++, dr(this) })), removeOverlay: ti((function (e) { for (var t = this.state.overlays, n = 0; n < t.length; ++n) { var r = t[n].modeSpec; if (r == e || "string" == typeof e && r.name == e) return t.splice(n, 1), this.state.modeGen++, void dr(this) } })), indentLine: ti((function (e, t, n) { "string" != typeof t && "number" != typeof t && (t = null == t ? this.options.smartIndent ? "smart" : "prev" : t ? "add" : "subtract"), Qe(this.doc, e) && Ta(this, e, t, n) })), indentSelection: ti((function (e) { for (var t = this.doc.sel.ranges, n = -1, r = 0; r < t.length; r++) { var i = t[r]; if (i.empty()) i.head.line > n && (Ta(this, i.head.line, e, !0), n = i.head.line, r == this.doc.sel.primIndex && Mr(this)); else { var o = i.from(), a = i.to(), l = Math.max(n, o.line); n = Math.min(this.lastLine(), a.line - (a.ch ? 0 : 1)) + 1; for (var s = l; s < n; ++s)Ta(this, s, e); var u = this.doc.sel.ranges; 0 == o.ch && t.length == u.length && u[r].from().ch > 0 && Zi(this.doc, r, new wi(o, u[r].to()), j) } } })), getTokenAt: function (e, t) { return xt(this, e, t) }, getLineTokens: function (e, t) { return xt(this, et(e), t, !0) }, getTokenTypeAt: function (e) { e = lt(this.doc, e); var t, n = ht(this, Ge(this.doc, e.line)), r = 0, i = (n.length - 1) / 2, o = e.ch; if (0 == o) t = n[2]; else for (; ;) { var a = r + i >> 1; if ((a ? n[2 * a - 1] : 0) >= o) i = a; else { if (!(n[2 * a + 1] < o)) { t = n[2 * a + 2]; break } r = a + 1 } } var l = t ? t.indexOf("overlay ") : -1; return l < 0 ? t : 0 == l ? null : t.slice(0, l - 1) }, getModeAt: function (t) { var n = this.doc.mode; return n.innerMode ? e.innerMode(n, this.getTokenAt(t).state).mode : n }, getHelper: function (e, t) { return this.getHelpers(e, t)[0] }, getHelpers: function (e, t) { var r = []; if (!n.hasOwnProperty(t)) return r; var i = n[t], o = this.getModeAt(e); if ("string" == typeof o[t]) i[o[t]] && r.push(i[o[t]]); else if (o[t]) for (var a = 0; a < o[t].length; a++) { var l = i[o[t][a]]; l && r.push(l) } else o.helperType && i[o.helperType] ? r.push(i[o.helperType]) : i[o.name] && r.push(i[o.name]); for (var s = 0; s < i._global.length; s++) { var u = i._global[s]; u.pred(o, this) && -1 == _(r, u.val) && r.push(u.val) } return r }, getStateAfter: function (e, t) { var n = this.doc; return ft(this, (e = at(n, null == e ? n.first + n.size - 1 : e)) + 1, t).state }, cursorCoords: function (e, t) { var n = this.doc.sel.primary(); return Vn(this, null == e ? n.head : "object" == typeof e ? lt(this.doc, e) : e ? n.from() : n.to(), t || "page") }, charCoords: function (e, t) { return Gn(this, lt(this.doc, e), t || "page") }, coordsChar: function (e, t) { return Zn(this, (e = $n(this, e, t || "page")).left, e.top) }, lineAtHeight: function (e, t) { return e = $n(this, { top: e, left: 0 }, t || "page").top, Ye(this.doc, e + this.display.viewOffset) }, heightAtLine: function (e, t, n) { var r, i = !1; if ("number" == typeof e) { var o = this.doc.first + this.doc.size - 1; e < this.doc.first ? e = this.doc.first : e > o && (e = o, i = !0), r = Ge(this.doc, e) } else r = e; return Un(this, r, { top: 0, left: 0 }, t || "page", n || i).top + (i ? this.doc.height - qt(r) : 0) }, defaultTextHeight: function () { return rr(this.display) }, defaultCharWidth: function () { return ir(this.display) }, getViewport: function () { return { from: this.display.viewFrom, to: this.display.viewTo } }, addWidget: function (e, t, n, r, i) { var o, a, l, s = this.display, u = (e = Vn(this, lt(this.doc, e))).bottom, c = e.left; if (t.style.position = "absolute", t.setAttribute("cm-ignore-events", "true"), this.display.input.setUneditable(t), s.sizer.appendChild(t), "over" == r) u = e.top; else if ("above" == r || "near" == r) { var d = Math.max(s.wrapper.clientHeight, this.doc.height), h = Math.max(s.sizer.clientWidth, s.lineSpace.clientWidth); ("above" == r || e.bottom + t.offsetHeight > d) && e.top > t.offsetHeight ? u = e.top - t.offsetHeight : e.bottom + t.offsetHeight <= d && (u = e.bottom), c + t.offsetWidth > h && (c = h - t.offsetWidth) } t.style.top = u + "px", t.style.left = t.style.right = "", "right" == i ? (c = s.sizer.clientWidth - t.offsetWidth, t.style.right = "0px") : ("left" == i ? c = 0 : "middle" == i && (c = (s.sizer.clientWidth - t.offsetWidth) / 2), t.style.left = c + "px"), n && (o = this, a = { left: c, top: u, right: c + t.offsetWidth, bottom: u + t.offsetHeight }, null != (l = Tr(o, a)).scrollTop && Ir(o, l.scrollTop), null != l.scrollLeft && Hr(o, l.scrollLeft)) }, triggerOnKeyDown: ti(ca), triggerOnKeyPress: ti(ha), triggerOnKeyUp: da, triggerOnMouseDown: ti(ga), execCommand: function (e) { if (ta.hasOwnProperty(e)) return ta[e].call(null, this) }, triggerElectric: ti((function (e) { Oa(this, e) })), findPosH: function (e, t, n, r) { var i = 1; t < 0 && (i = -1, t = -t); for (var o = lt(this.doc, e), a = 0; a < t && !(o = Ra(this.doc, o, i, n, r)).hitSide; ++a); return o }, moveH: ti((function (e, t) { var n = this; this.extendSelectionsBy((function (r) { return n.display.shift || n.doc.extend || r.empty() ? Ra(n.doc, r.head, e, t, n.options.rtlMoveVisually) : e < 0 ? r.from() : r.to() }), U) })), deleteH: ti((function (e, t) { var n = this.doc.sel, r = this.doc; n.somethingSelected() ? r.replaceSelection("", null, "+delete") : Yo(this, (function (n) { var i = Ra(r, n.head, e, t, !1); return e < 0 ? { from: i, to: n.head } : { from: n.head, to: i } })) })), findPosV: function (e, t, n, r) { var i = 1, o = r; t < 0 && (i = -1, t = -t); for (var a = lt(this.doc, e), l = 0; l < t; ++l) { var s = Vn(this, a, "div"); if (null == o ? o = s.left : s.left = o, (a = Pa(this, s, i, n)).hitSide) break } return a }, moveV: ti((function (e, t) { var n = this, r = this.doc, i = [], o = !this.display.shift && !r.extend && r.sel.somethingSelected(); if (r.extendSelectionsBy((function (a) { if (o) return e < 0 ? a.from() : a.to(); var l = Vn(n, a.head, "div"); null != a.goalColumn && (l.left = a.goalColumn), i.push(l.left); var s = Pa(n, l, e, t); return "page" == t && a == r.sel.primary() && Lr(n, Gn(n, s, "div").top - l.top), s }), U), i.length) for (var a = 0; a < r.sel.ranges.length; a++)r.sel.ranges[a].goalColumn = i[a] })), findWordAt: function (e) { var t = Ge(this.doc, e.line).text, n = e.ch, r = e.ch; if (t) { var i = this.getHelper(e, "wordChars"); "before" != e.sticky && r != t.length || !n ? ++r : --n; for (var o = t.charAt(n), a = ee(o, i) ? function (e) { return ee(e, i) } : /\s/.test(o) ? function (e) { return /\s/.test(e) } : function (e) { return !/\s/.test(e) && !ee(e) }; n > 0 && a(t.charAt(n - 1));)--n; for (; r < t.length && a(t.charAt(r));)++r } return new wi(et(e.line, n), et(e.line, r)) }, toggleOverwrite: function (e) { null != e && e == this.state.overwrite || ((this.state.overwrite = !this.state.overwrite) ? N(this.display.cursorDiv, "CodeMirror-overwrite") : F(this.display.cursorDiv, "CodeMirror-overwrite"), pe(this, "overwriteToggle", this, this.state.overwrite)) }, hasFocus: function () { return this.display.input.getField() == B() }, isReadOnly: function () { return !(!this.options.readOnly && !this.doc.cantEdit) }, scrollTo: ti((function (e, t) { Br(this, e, t) })), getScrollInfo: function () { var e = this.display.scroller; return { left: e.scrollLeft, top: e.scrollTop, height: e.scrollHeight - Fn(this) - this.display.barHeight, width: e.scrollWidth - Fn(this) - this.display.barWidth, clientHeight: En(this), clientWidth: An(this) } }, scrollIntoView: ti((function (e, t) { null == e ? (e = { from: this.doc.sel.primary().head, to: null }, null == t && (t = this.options.cursorScrollMargin)) : "number" == typeof e ? e = { from: et(e, 0), to: null } : null == e.from && (e = { from: e, to: null }), e.to || (e.to = e.from), e.margin = t || 0, null != e.from.line ? function (e, t) { Nr(e), e.curOp.scrollToPos = t }(this, e) : Or(this, e.from, e.to, e.margin) })), setSize: ti((function (e, t) { var n = this, r = function (e) { return "number" == typeof e || /^\d+$/.test(String(e)) ? e + "px" : e }; null != e && (this.display.wrapper.style.width = r(e)), null != t && (this.display.wrapper.style.height = r(t)), this.options.lineWrapping && Pn(this); var i = this.display.viewFrom; this.doc.iter(i, this.display.viewTo, (function (e) { if (e.widgets) for (var t = 0; t < e.widgets.length; t++)if (e.widgets[t].noHScroll) { hr(n, i, "widget"); break } ++i })), this.curOp.forceUpdate = !0, pe(this, "refresh", this) })), operation: function (e) { return Jr(this, e) }, startOperation: function () { return Gr(this) }, endOperation: function () { return Vr(this) }, refresh: ti((function () { var e = this.display.cachedTextHeight; dr(this), this.curOp.forceUpdate = !0, _n(this), Br(this, this.doc.scrollLeft, this.doc.scrollTop), ui(this.display), (null == e || Math.abs(e - rr(this.display)) > .5 || this.options.lineWrapping) && sr(this), pe(this, "refresh", this) })), swapDoc: ti((function (e) { var t = this.doc; return t.cm = null, this.state.selectingText && this.state.selectingText(), Ii(this, e), _n(this), this.display.input.reset(), Br(this, e.scrollLeft, e.scrollTop), this.curOp.forceScroll = !0, sn(this, "swapDoc", this, t), t })), phrase: function (e) { var t = this.options.phrases; return t && Object.prototype.hasOwnProperty.call(t, e) ? t[e] : e }, getInputField: function () { return this.display.input.getField() }, getWrapperElement: function () { return this.display.wrapper }, getScrollerElement: function () { return this.display.scroller }, getGutterElement: function () { return this.display.gutters } }, xe(e), e.registerHelper = function (t, r, i) { n.hasOwnProperty(t) || (n[t] = e[t] = { _global: [] }), n[t][r] = i }, e.registerGlobalHelper = function (t, r, i, o) { e.registerHelper(t, r, o), n[t]._global.push({ pred: i, val: o }) } }(Aa); var Ga = "iter insert remove copy getEditor constructor".split(" "); for (var Va in Mo.prototype) Mo.prototype.hasOwnProperty(Va) && _(Ga, Va) < 0 && (Aa.prototype[Va] = function (e) { return function () { return e.apply(this.doc, arguments) } }(Mo.prototype[Va])); return xe(Mo), Aa.inputStyles = { textarea: $a, contenteditable: _a }, Aa.defineMode = function (e) { Aa.defaults.mode || "null" == e || (Aa.defaults.mode = e), He.apply(this, arguments) }, Aa.defineMIME = function (e, t) { ze[e] = t }, Aa.defineMode("null", (function () { return { token: function (e) { return e.skipToEnd() } } })), Aa.defineMIME("text/plain", "null"), Aa.defineExtension = function (e, t) { Aa.prototype[e] = t }, Aa.defineDocExtension = function (e, t) { Mo.prototype[e] = t }, Aa.fromTextArea = function (e, t) { if ((t = t ? H(t) : {}).value = e.value, !t.tabindex && e.tabIndex && (t.tabindex = e.tabIndex), !t.placeholder && e.placeholder && (t.placeholder = e.placeholder), null == t.autofocus) { var n = B(); t.autofocus = n == e || null != e.getAttribute("autofocus") && n == document.body } function r() { e.value = l.getValue() } var i; if (e.form && (de(e.form, "submit", r), !t.leaveSubmitMethodAlone)) { var o = e.form; i = o.submit; try { var a = o.submit = function () { r(), o.submit = i, o.submit(), o.submit = a } } catch (e) { } } t.finishInit = function (n) { n.save = r, n.getTextArea = function () { return e }, n.toTextArea = function () { n.toTextArea = isNaN, r(), e.parentNode.removeChild(n.getWrapperElement()), e.style.display = "", e.form && (fe(e.form, "submit", r), t.leaveSubmitMethodAlone || "function" != typeof e.form.submit || (e.form.submit = i)) } }, e.style.display = "none"; var l = Aa((function (t) { return e.parentNode.insertBefore(t, e.nextSibling) }), t); return l }, function (e) { e.off = fe, e.on = de, e.wheelEventPixels = bi, e.Doc = Mo, e.splitLines = Me, e.countColumn = R, e.findColumn = $, e.isWordChar = J, e.Pass = W, e.signal = pe, e.Line = Gt, e.changeEnd = Fi, e.scrollbarModel = qr, e.Pos = et, e.cmpPos = tt, e.modes = Ie, e.mimeModes = ze, e.resolveMode = Re, e.getMode = Pe, e.modeExtensions = _e, e.extendMode = We, e.copyState = je, e.startState = Ue, e.innerMode = qe, e.commands = ta, e.keyMap = qo, e.keyName = Xo, e.isModifierKey = Vo, e.lookupKey = Go, e.normalizeKeyMap = $o, e.StringStream = $e, e.SharedTextMarker = Ao, e.TextMarker = So, e.LineWidget = Co, e.e_preventDefault = ye, e.e_stopPropagation = be, e.e_stop = Ce, e.addClass = N, e.contains = M, e.rmClass = F, e.keyNames = Po }(Aa), Aa.version = "5.61.0", Aa })) }, {}], 11: [function (e, t, n) { var r; r = function (e) { "use strict"; var t = /^((?:(?:aaas?|about|acap|adiumxtra|af[ps]|aim|apt|attachment|aw|beshare|bitcoin|bolo|callto|cap|chrome(?:-extension)?|cid|coap|com-eventbrite-attendee|content|crid|cvs|data|dav|dict|dlna-(?:playcontainer|playsingle)|dns|doi|dtn|dvb|ed2k|facetime|feed|file|finger|fish|ftp|geo|gg|git|gizmoproject|go|gopher|gtalk|h323|hcp|https?|iax|icap|icon|im|imap|info|ipn|ipp|irc[6s]?|iris(?:\.beep|\.lwz|\.xpc|\.xpcs)?|itms|jar|javascript|jms|keyparc|lastfm|ldaps?|magnet|mailto|maps|market|message|mid|mms|ms-help|msnim|msrps?|mtqp|mumble|mupdate|mvn|news|nfs|nih?|nntp|notes|oid|opaquelocktoken|palm|paparazzi|platform|pop|pres|proxy|psyc|query|res(?:ource)?|rmi|rsync|rtmp|rtsp|secondlife|service|session|sftp|sgn|shttp|sieve|sips?|skype|sm[bs]|snmp|soap\.beeps?|soldat|spotify|ssh|steam|svn|tag|teamspeak|tel(?:net)?|tftp|things|thismessage|tip|tn3270|tv|udp|unreal|urn|ut2004|vemmi|ventrilo|view-source|webcal|wss?|wtai|wyciwyg|xcon(?:-userid)?|xfire|xmlrpc\.beeps?|xmpp|xri|ymsgr|z39\.50[rs]?):(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]|\([^\s()<>]*\))+(?:\([^\s()<>]*\)|[^\s`*!()\[\]{};:'".,<>?«»“”‘’]))/i; e.defineMode("gfm", (function (n, r) { var i = 0, o = { startState: function () { return { code: !1, codeBlock: !1, ateSpace: !1 } }, copyState: function (e) { return { code: e.code, codeBlock: e.codeBlock, ateSpace: e.ateSpace } }, token: function (e, n) { if (n.combineTokens = null, n.codeBlock) return e.match(/^```+/) ? (n.codeBlock = !1, null) : (e.skipToEnd(), null); if (e.sol() && (n.code = !1), e.sol() && e.match(/^```+/)) return e.skipToEnd(), n.codeBlock = !0, null; if ("`" === e.peek()) { e.next(); var o = e.pos; e.eatWhile("`"); var a = 1 + e.pos - o; return n.code ? a === i && (n.code = !1) : (i = a, n.code = !0), null } if (n.code) return e.next(), null; if (e.eatSpace()) return n.ateSpace = !0, null; if ((e.sol() || n.ateSpace) && (n.ateSpace = !1, !1 !== r.gitHubSpice)) { if (e.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+@)?(?=.{0,6}\d)(?:[a-f0-9]{7,40}\b)/)) return n.combineTokens = !0, "link"; if (e.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+)?#[0-9]+\b/)) return n.combineTokens = !0, "link" } return e.match(t) && "](" != e.string.slice(e.start - 2, e.start) && (0 == e.start || /\W/.test(e.string.charAt(e.start - 1))) ? (n.combineTokens = !0, "link") : (e.next(), null) }, blankLine: function (e) { return e.code = !1, null } }, a = { taskLists: !0, strikethrough: !0, emoji: !0 }; for (var l in r) a[l] = r[l]; return a.name = "markdown", e.overlayMode(e.getMode(n, a), o) }), "markdown"), e.defineMIME("text/x-gfm", "gfm") }, "object" == typeof n && "object" == typeof t ? r(e("../../lib/codemirror"), e("../markdown/markdown"), e("../../addon/mode/overlay")) : r(CodeMirror) }, { "../../addon/mode/overlay": 7, "../../lib/codemirror": 10, "../markdown/markdown": 12 }], 12: [function (e, t, n) { var r; r = function (e) { "use strict"; e.defineMode("markdown", (function (t, n) { var r = e.getMode(t, "text/html"), i = "null" == r.name; void 0 === n.highlightFormatting && (n.highlightFormatting = !1), void 0 === n.maxBlockquoteDepth && (n.maxBlockquoteDepth = 0), void 0 === n.taskLists && (n.taskLists = !1), void 0 === n.strikethrough && (n.strikethrough = !1), void 0 === n.emoji && (n.emoji = !1), void 0 === n.fencedCodeBlockHighlighting && (n.fencedCodeBlockHighlighting = !0), void 0 === n.fencedCodeBlockDefaultMode && (n.fencedCodeBlockDefaultMode = "text/plain"), void 0 === n.xml && (n.xml = !0), void 0 === n.tokenTypeOverrides && (n.tokenTypeOverrides = {}); var o = { header: "header", code: "comment", quote: "quote", list1: "variable-2", list2: "variable-3", list3: "keyword", hr: "hr", image: "image", imageAltText: "image-alt-text", imageMarker: "image-marker", formatting: "formatting", linkInline: "link", linkEmail: "link", linkText: "link", linkHref: "string", em: "em", strong: "strong", strikethrough: "strikethrough", emoji: "builtin" }; for (var a in o) o.hasOwnProperty(a) && n.tokenTypeOverrides[a] && (o[a] = n.tokenTypeOverrides[a]); var l = /^([*\-_])(?:\s*\1){2,}\s*$/, s = /^(?:[*\-+]|^[0-9]+([.)]))\s+/, u = /^\[(x| )\](?=\s)/i, c = n.allowAtxHeaderWithoutSpace ? /^(#+)/ : /^(#+)(?: |$)/, d = /^ {0,3}(?:\={1,}|-{2,})\s*$/, h = /^[^#!\[\]*_\\<>` "'(~:]+/, f = /^(~~~+|```+)[ \t]*([\w\/+#-]*)[^\n`]*$/, p = /^\s*\[[^\]]+?\]:.*$/, m = /[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E42\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]/; function g(e, t, n) { return t.f = t.inline = n, n(e, t) } function v(e, t, n) { return t.f = t.block = n, n(e, t) } function x(t) { if (t.linkTitle = !1, t.linkHref = !1, t.linkText = !1, t.em = !1, t.strong = !1, t.strikethrough = !1, t.quote = 0, t.indentedCode = !1, t.f == b) { var n = i; if (!n) { var o = e.innerMode(r, t.htmlState); n = "xml" == o.mode.name && null === o.state.tagStart && !o.state.context && o.state.tokenize.isInText } n && (t.f = k, t.block = y, t.htmlState = null) } return t.trailingSpace = 0, t.trailingSpaceNewLine = !1, t.prevLine = t.thisLine, t.thisLine = { stream: null }, null } function y(r, i) { var a, h = r.column() === i.indentation, m = !(a = i.prevLine.stream) || !/\S/.test(a.string), v = i.indentedCode, x = i.prevLine.hr, y = !1 !== i.list, b = (i.listStack[i.listStack.length - 1] || 0) + 3; i.indentedCode = !1; var w = i.indentation; if (null === i.indentationDiff && (i.indentationDiff = i.indentation, y)) { for (i.list = null; w < i.listStack[i.listStack.length - 1];)i.listStack.pop(), i.listStack.length ? i.indentation = i.listStack[i.listStack.length - 1] : i.list = !1; !1 !== i.list && (i.indentationDiff = w - i.listStack[i.listStack.length - 1]) } var k = !(m || x || i.prevLine.header || y && v || i.prevLine.fencedCodeEnd), S = (!1 === i.list || x || m) && i.indentation <= b && r.match(l), F = null; if (i.indentationDiff >= 4 && (v || i.prevLine.fencedCodeEnd || i.prevLine.header || m)) return r.skipToEnd(), i.indentedCode = !0, o.code; if (r.eatSpace()) return null; if (h && i.indentation <= b && (F = r.match(c)) && F[1].length <= 6) return i.quote = 0, i.header = F[1].length, i.thisLine.header = !0, n.highlightFormatting && (i.formatting = "header"), i.f = i.inline, C(i); if (i.indentation <= b && r.eat(">")) return i.quote = h ? 1 : i.quote + 1, n.highlightFormatting && (i.formatting = "quote"), r.eatSpace(), C(i); if (!S && !i.setext && h && i.indentation <= b && (F = r.match(s))) { var A = F[1] ? "ol" : "ul"; return i.indentation = w + r.current().length, i.list = !0, i.quote = 0, i.listStack.push(i.indentation), i.em = !1, i.strong = !1, i.code = !1, i.strikethrough = !1, n.taskLists && r.match(u, !1) && (i.taskList = !0), i.f = i.inline, n.highlightFormatting && (i.formatting = ["list", "list-" + A]), C(i) } return h && i.indentation <= b && (F = r.match(f, !0)) ? (i.quote = 0, i.fencedEndRE = new RegExp(F[1] + "+ *$"), i.localMode = n.fencedCodeBlockHighlighting && function (n) { if (e.findModeByName) { var r = e.findModeByName(n); r && (n = r.mime || r.mimes[0]) } var i = e.getMode(t, n); return "null" == i.name ? null : i }(F[2] || n.fencedCodeBlockDefaultMode), i.localMode && (i.localState = e.startState(i.localMode)), i.f = i.block = D, n.highlightFormatting && (i.formatting = "code-block"), i.code = -1, C(i)) : i.setext || !(k && y || i.quote || !1 !== i.list || i.code || S || p.test(r.string)) && (F = r.lookAhead(1)) && (F = F.match(d)) ? (i.setext ? (i.header = i.setext, i.setext = 0, r.skipToEnd(), n.highlightFormatting && (i.formatting = "header")) : (i.header = "=" == F[0].charAt(0) ? 1 : 2, i.setext = i.header), i.thisLine.header = !0, i.f = i.inline, C(i)) : S ? (r.skipToEnd(), i.hr = !0, i.thisLine.hr = !0, o.hr) : "[" === r.peek() ? g(r, i, E) : g(r, i, i.inline) } function b(t, n) { var o = r.token(t, n.htmlState); if (!i) { var a = e.innerMode(r, n.htmlState); ("xml" == a.mode.name && null === a.state.tagStart && !a.state.context && a.state.tokenize.isInText || n.md_inside && t.current().indexOf(">") > -1) && (n.f = k, n.block = y, n.htmlState = null) } return o } function D(e, t) { var r, i = t.listStack[t.listStack.length - 1] || 0, a = t.indentation < i, l = i + 3; return t.fencedEndRE && t.indentation <= l && (a || e.match(t.fencedEndRE)) ? (n.highlightFormatting && (t.formatting = "code-block"), a || (r = C(t)), t.localMode = t.localState = null, t.block = y, t.f = k, t.fencedEndRE = null, t.code = 0, t.thisLine.fencedCodeEnd = !0, a ? v(e, t, t.block) : r) : t.localMode ? t.localMode.token(e, t.localState) : (e.skipToEnd(), o.code) } function C(e) { var t = []; if (e.formatting) { t.push(o.formatting), "string" == typeof e.formatting && (e.formatting = [e.formatting]); for (var r = 0; r < e.formatting.length; r++)t.push(o.formatting + "-" + e.formatting[r]), "header" === e.formatting[r] && t.push(o.formatting + "-" + e.formatting[r] + "-" + e.header), "quote" === e.formatting[r] && (!n.maxBlockquoteDepth || n.maxBlockquoteDepth >= e.quote ? t.push(o.formatting + "-" + e.formatting[r] + "-" + e.quote) : t.push("error")) } if (e.taskOpen) return t.push("meta"), t.length ? t.join(" ") : null; if (e.taskClosed) return t.push("property"), t.length ? t.join(" ") : null; if (e.linkHref ? t.push(o.linkHref, "url") : (e.strong && t.push(o.strong), e.em && t.push(o.em), e.strikethrough && t.push(o.strikethrough), e.emoji && t.push(o.emoji), e.linkText && t.push(o.linkText), e.code && t.push(o.code), e.image && t.push(o.image), e.imageAltText && t.push(o.imageAltText, "link"), e.imageMarker && t.push(o.imageMarker)), e.header && t.push(o.header, o.header + "-" + e.header), e.quote && (t.push(o.quote), !n.maxBlockquoteDepth || n.maxBlockquoteDepth >= e.quote ? t.push(o.quote + "-" + e.quote) : t.push(o.quote + "-" + n.maxBlockquoteDepth)), !1 !== e.list) { var i = (e.listStack.length - 1) % 3; i ? 1 === i ? t.push(o.list2) : t.push(o.list3) : t.push(o.list1) } return e.trailingSpaceNewLine ? t.push("trailing-space-new-line") : e.trailingSpace && t.push("trailing-space-" + (e.trailingSpace % 2 ? "a" : "b")), t.length ? t.join(" ") : null } function w(e, t) { if (e.match(h, !0)) return C(t) } function k(t, i) { var a = i.text(t, i); if (void 0 !== a) return a; if (i.list) return i.list = null, C(i); if (i.taskList) return " " === t.match(u, !0)[1] ? i.taskOpen = !0 : i.taskClosed = !0, n.highlightFormatting && (i.formatting = "task"), i.taskList = !1, C(i); if (i.taskOpen = !1, i.taskClosed = !1, i.header && t.match(/^#+$/, !0)) return n.highlightFormatting && (i.formatting = "header"), C(i); var l = t.next(); if (i.linkTitle) { i.linkTitle = !1; var s = l; "(" === l && (s = ")"); var c = "^\\s*(?:[^" + (s = (s + "").replace(/([.?*+^\[\]\\(){}|-])/g, "\\$1")) + "\\\\]+|\\\\\\\\|\\\\.)" + s; if (t.match(new RegExp(c), !0)) return o.linkHref } if ("`" === l) { var d = i.formatting; n.highlightFormatting && (i.formatting = "code"), t.eatWhile("`"); var h = t.current().length; if (0 != i.code || i.quote && 1 != h) { if (h == i.code) { var f = C(i); return i.code = 0, f } return i.formatting = d, C(i) } return i.code = h, C(i) } if (i.code) return C(i); if ("\\" === l && (t.next(), n.highlightFormatting)) { var p = C(i), g = o.formatting + "-escape"; return p ? p + " " + g : g } if ("!" === l && t.match(/\[[^\]]*\] ?(?:\(|\[)/, !1)) return i.imageMarker = !0, i.image = !0, n.highlightFormatting && (i.formatting = "image"), C(i); if ("[" === l && i.imageMarker && t.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/, !1)) return i.imageMarker = !1, i.imageAltText = !0, n.highlightFormatting && (i.formatting = "image"), C(i); if ("]" === l && i.imageAltText) { n.highlightFormatting && (i.formatting = "image"); var p = C(i); return i.imageAltText = !1, i.image = !1, i.inline = i.f = F, p } if ("[" === l && !i.image) return i.linkText && t.match(/^.*?\]/) || (i.linkText = !0, n.highlightFormatting && (i.formatting = "link")), C(i); if ("]" === l && i.linkText) { n.highlightFormatting && (i.formatting = "link"); var p = C(i); return i.linkText = !1, i.inline = i.f = t.match(/\(.*?\)| ?\[.*?\]/, !1) ? F : k, p } if ("<" === l && t.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/, !1)) return i.f = i.inline = S, n.highlightFormatting && (i.formatting = "link"), (p = C(i)) ? p += " " : p = "", p + o.linkInline; if ("<" === l && t.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/, !1)) return i.f = i.inline = S, n.highlightFormatting && (i.formatting = "link"), (p = C(i)) ? p += " " : p = "", p + o.linkEmail; if (n.xml && "<" === l && t.match(/^(!--|\?|!\[CDATA\[|[a-z][a-z0-9-]*(?:\s+[a-z_:.\-]+(?:\s*=\s*[^>]+)?)*\s*(?:>|$))/i, !1)) { var x = t.string.indexOf(">", t.pos); if (-1 != x) { var y = t.string.substring(t.start, x); /markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(y) && (i.md_inside = !0) } return t.backUp(1), i.htmlState = e.startState(r), v(t, i, b) } if (n.xml && "<" === l && t.match(/^\/\w*?>/)) return i.md_inside = !1, "tag"; if ("*" === l || "_" === l) { for (var D = 1, w = 1 == t.pos ? " " : t.string.charAt(t.pos - 2); D < 3 && t.eat(l);)D++; var A = t.peek() || " ", E = !/\s/.test(A) && (!m.test(A) || /\s/.test(w) || m.test(w)), T = !/\s/.test(w) && (!m.test(w) || /\s/.test(A) || m.test(A)), L = null, M = null; if (D % 2 && (i.em || !E || "*" !== l && T && !m.test(w) ? i.em != l || !T || "*" !== l && E && !m.test(A) || (L = !1) : L = !0), D > 1 && (i.strong || !E || "*" !== l && T && !m.test(w) ? i.strong != l || !T || "*" !== l && E && !m.test(A) || (M = !1) : M = !0), null != M || null != L) return n.highlightFormatting && (i.formatting = null == L ? "strong" : null == M ? "em" : "strong em"), !0 === L && (i.em = l), !0 === M && (i.strong = l), f = C(i), !1 === L && (i.em = !1), !1 === M && (i.strong = !1), f } else if (" " === l && (t.eat("*") || t.eat("_"))) { if (" " === t.peek()) return C(i); t.backUp(1) } if (n.strikethrough) if ("~" === l && t.eatWhile(l)) { if (i.strikethrough) return n.highlightFormatting && (i.formatting = "strikethrough"), f = C(i), i.strikethrough = !1, f; if (t.match(/^[^\s]/, !1)) return i.strikethrough = !0, n.highlightFormatting && (i.formatting = "strikethrough"), C(i) } else if (" " === l && t.match("~~", !0)) { if (" " === t.peek()) return C(i); t.backUp(2) } if (n.emoji && ":" === l && t.match(/^(?:[a-z_\d+][a-z_\d+-]*|\-[a-z_\d+][a-z_\d+-]*):/)) { i.emoji = !0, n.highlightFormatting && (i.formatting = "emoji"); var B = C(i); return i.emoji = !1, B } return " " === l && (t.match(/^ +$/, !1) ? i.trailingSpace++ : i.trailingSpace && (i.trailingSpaceNewLine = !0)), C(i) } function S(e, t) { if (">" === e.next()) { t.f = t.inline = k, n.highlightFormatting && (t.formatting = "link"); var r = C(t); return r ? r += " " : r = "", r + o.linkInline } return e.match(/^[^>]+/, !0), o.linkInline } function F(e, t) { if (e.eatSpace()) return null; var r, i = e.next(); return "(" === i || "[" === i ? (t.f = t.inline = (r = "(" === i ? ")" : "]", function (e, t) { if (e.next() === r) { t.f = t.inline = k, n.highlightFormatting && (t.formatting = "link-string"); var i = C(t); return t.linkHref = !1, i } return e.match(A[r]), t.linkHref = !0, C(t) }), n.highlightFormatting && (t.formatting = "link-string"), t.linkHref = !0, C(t)) : "error" } var A = { ")": /^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/, "]": /^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\]]|\\.)*\])*?(?=\])/ }; function E(e, t) { return e.match(/^([^\]\\]|\\.)*\]:/, !1) ? (t.f = T, e.next(), n.highlightFormatting && (t.formatting = "link"), t.linkText = !0, C(t)) : g(e, t, k) } function T(e, t) { if (e.match("]:", !0)) { t.f = t.inline = L, n.highlightFormatting && (t.formatting = "link"); var r = C(t); return t.linkText = !1, r } return e.match(/^([^\]\\]|\\.)+/, !0), o.linkText } function L(e, t) { return e.eatSpace() ? null : (e.match(/^[^\s]+/, !0), void 0 === e.peek() ? t.linkTitle = !0 : e.match(/^(?:\s+(?:"(?:[^"\\]|\\.)+"|'(?:[^'\\]|\\.)+'|\((?:[^)\\]|\\.)+\)))?/, !0), t.f = t.inline = k, o.linkHref + " url") } var M = { startState: function () { return { f: y, prevLine: { stream: null }, thisLine: { stream: null }, block: y, htmlState: null, indentation: 0, inline: k, text: w, formatting: !1, linkText: !1, linkHref: !1, linkTitle: !1, code: 0, em: !1, strong: !1, header: 0, setext: 0, hr: !1, taskList: !1, list: !1, listStack: [], quote: 0, trailingSpace: 0, trailingSpaceNewLine: !1, strikethrough: !1, emoji: !1, fencedEndRE: null } }, copyState: function (t) { return { f: t.f, prevLine: t.prevLine, thisLine: t.thisLine, block: t.block, htmlState: t.htmlState && e.copyState(r, t.htmlState), indentation: t.indentation, localMode: t.localMode, localState: t.localMode ? e.copyState(t.localMode, t.localState) : null, inline: t.inline, text: t.text, formatting: !1, linkText: t.linkText, linkTitle: t.linkTitle, linkHref: t.linkHref, code: t.code, em: t.em, strong: t.strong, strikethrough: t.strikethrough, emoji: t.emoji, header: t.header, setext: t.setext, hr: t.hr, taskList: t.taskList, list: t.list, listStack: t.listStack.slice(0), quote: t.quote, indentedCode: t.indentedCode, trailingSpace: t.trailingSpace, trailingSpaceNewLine: t.trailingSpaceNewLine, md_inside: t.md_inside, fencedEndRE: t.fencedEndRE } }, token: function (e, t) { if (t.formatting = !1, e != t.thisLine.stream) { if (t.header = 0, t.hr = !1, e.match(/^\s*$/, !0)) return x(t), null; if (t.prevLine = t.thisLine, t.thisLine = { stream: e }, t.taskList = !1, t.trailingSpace = 0, t.trailingSpaceNewLine = !1, !t.localState && (t.f = t.block, t.f != b)) { var n = e.match(/^\s*/, !0)[0].replace(/\t/g, " ").length; if (t.indentation = n, t.indentationDiff = null, n > 0) return null } } return t.f(e, t) }, innerMode: function (e) { return e.block == b ? { state: e.htmlState, mode: r } : e.localState ? { state: e.localState, mode: e.localMode } : { state: e, mode: M } }, indent: function (t, n, i) { return t.block == b && r.indent ? r.indent(t.htmlState, n, i) : t.localState && t.localMode.indent ? t.localMode.indent(t.localState, n, i) : e.Pass }, blankLine: x, getType: C, blockCommentStart: "\x3c!--", blockCommentEnd: "--\x3e", closeBrackets: "()[]{}''\"\"``", fold: "markdown" }; return M }), "xml"), e.defineMIME("text/markdown", "markdown"), e.defineMIME("text/x-markdown", "markdown") }, "object" == typeof n && "object" == typeof t ? r(e("../../lib/codemirror"), e("../xml/xml"), e("../meta")) : r(CodeMirror) }, { "../../lib/codemirror": 10, "../meta": 13, "../xml/xml": 14 }], 13: [function (e, t, n) { (function (e) { "use strict"; e.modeInfo = [{ name: "APL", mime: "text/apl", mode: "apl", ext: ["dyalog", "apl"] }, { name: "PGP", mimes: ["application/pgp", "application/pgp-encrypted", "application/pgp-keys", "application/pgp-signature"], mode: "asciiarmor", ext: ["asc", "pgp", "sig"] }, { name: "ASN.1", mime: "text/x-ttcn-asn", mode: "asn.1", ext: ["asn", "asn1"] }, { name: "Asterisk", mime: "text/x-asterisk", mode: "asterisk", file: /^extensions\.conf$/i }, { name: "Brainfuck", mime: "text/x-brainfuck", mode: "brainfuck", ext: ["b", "bf"] }, { name: "C", mime: "text/x-csrc", mode: "clike", ext: ["c", "h", "ino"] }, { name: "C++", mime: "text/x-c++src", mode: "clike", ext: ["cpp", "c++", "cc", "cxx", "hpp", "h++", "hh", "hxx"], alias: ["cpp"] }, { name: "Cobol", mime: "text/x-cobol", mode: "cobol", ext: ["cob", "cpy"] }, { name: "C#", mime: "text/x-csharp", mode: "clike", ext: ["cs"], alias: ["csharp", "cs"] }, { name: "Clojure", mime: "text/x-clojure", mode: "clojure", ext: ["clj", "cljc", "cljx"] }, { name: "ClojureScript", mime: "text/x-clojurescript", mode: "clojure", ext: ["cljs"] }, { name: "Closure Stylesheets (GSS)", mime: "text/x-gss", mode: "css", ext: ["gss"] }, { name: "CMake", mime: "text/x-cmake", mode: "cmake", ext: ["cmake", "cmake.in"], file: /^CMakeLists\.txt$/ }, { name: "CoffeeScript", mimes: ["application/vnd.coffeescript", "text/coffeescript", "text/x-coffeescript"], mode: "coffeescript", ext: ["coffee"], alias: ["coffee", "coffee-script"] }, { name: "Common Lisp", mime: "text/x-common-lisp", mode: "commonlisp", ext: ["cl", "lisp", "el"], alias: ["lisp"] }, { name: "Cypher", mime: "application/x-cypher-query", mode: "cypher", ext: ["cyp", "cypher"] }, { name: "Cython", mime: "text/x-cython", mode: "python", ext: ["pyx", "pxd", "pxi"] }, { name: "Crystal", mime: "text/x-crystal", mode: "crystal", ext: ["cr"] }, { name: "CSS", mime: "text/css", mode: "css", ext: ["css"] }, { name: "CQL", mime: "text/x-cassandra", mode: "sql", ext: ["cql"] }, { name: "D", mime: "text/x-d", mode: "d", ext: ["d"] }, { name: "Dart", mimes: ["application/dart", "text/x-dart"], mode: "dart", ext: ["dart"] }, { name: "diff", mime: "text/x-diff", mode: "diff", ext: ["diff", "patch"] }, { name: "Django", mime: "text/x-django", mode: "django" }, { name: "Dockerfile", mime: "text/x-dockerfile", mode: "dockerfile", file: /^Dockerfile$/ }, { name: "DTD", mime: "application/xml-dtd", mode: "dtd", ext: ["dtd"] }, { name: "Dylan", mime: "text/x-dylan", mode: "dylan", ext: ["dylan", "dyl", "intr"] }, { name: "EBNF", mime: "text/x-ebnf", mode: "ebnf" }, { name: "ECL", mime: "text/x-ecl", mode: "ecl", ext: ["ecl"] }, { name: "edn", mime: "application/edn", mode: "clojure", ext: ["edn"] }, { name: "Eiffel", mime: "text/x-eiffel", mode: "eiffel", ext: ["e"] }, { name: "Elm", mime: "text/x-elm", mode: "elm", ext: ["elm"] }, { name: "Embedded JavaScript", mime: "application/x-ejs", mode: "htmlembedded", ext: ["ejs"] }, { name: "Embedded Ruby", mime: "application/x-erb", mode: "htmlembedded", ext: ["erb"] }, { name: "Erlang", mime: "text/x-erlang", mode: "erlang", ext: ["erl"] }, { name: "Esper", mime: "text/x-esper", mode: "sql" }, { name: "Factor", mime: "text/x-factor", mode: "factor", ext: ["factor"] }, { name: "FCL", mime: "text/x-fcl", mode: "fcl" }, { name: "Forth", mime: "text/x-forth", mode: "forth", ext: ["forth", "fth", "4th"] }, { name: "Fortran", mime: "text/x-fortran", mode: "fortran", ext: ["f", "for", "f77", "f90", "f95"] }, { name: "F#", mime: "text/x-fsharp", mode: "mllike", ext: ["fs"], alias: ["fsharp"] }, { name: "Gas", mime: "text/x-gas", mode: "gas", ext: ["s"] }, { name: "Gherkin", mime: "text/x-feature", mode: "gherkin", ext: ["feature"] }, { name: "GitHub Flavored Markdown", mime: "text/x-gfm", mode: "gfm", file: /^(readme|contributing|history)\.md$/i }, { name: "Go", mime: "text/x-go", mode: "go", ext: ["go"] }, { name: "Groovy", mime: "text/x-groovy", mode: "groovy", ext: ["groovy", "gradle"], file: /^Jenkinsfile$/ }, { name: "HAML", mime: "text/x-haml", mode: "haml", ext: ["haml"] }, { name: "Haskell", mime: "text/x-haskell", mode: "haskell", ext: ["hs"] }, { name: "Haskell (Literate)", mime: "text/x-literate-haskell", mode: "haskell-literate", ext: ["lhs"] }, { name: "Haxe", mime: "text/x-haxe", mode: "haxe", ext: ["hx"] }, { name: "HXML", mime: "text/x-hxml", mode: "haxe", ext: ["hxml"] }, { name: "ASP.NET", mime: "application/x-aspx", mode: "htmlembedded", ext: ["aspx"], alias: ["asp", "aspx"] }, { name: "HTML", mime: "text/html", mode: "htmlmixed", ext: ["html", "htm", "handlebars", "hbs"], alias: ["xhtml"] }, { name: "HTTP", mime: "message/http", mode: "http" }, { name: "IDL", mime: "text/x-idl", mode: "idl", ext: ["pro"] }, { name: "Pug", mime: "text/x-pug", mode: "pug", ext: ["jade", "pug"], alias: ["jade"] }, { name: "Java", mime: "text/x-java", mode: "clike", ext: ["java"] }, { name: "Java Server Pages", mime: "application/x-jsp", mode: "htmlembedded", ext: ["jsp"], alias: ["jsp"] }, { name: "JavaScript", mimes: ["text/javascript", "text/ecmascript", "application/javascript", "application/x-javascript", "application/ecmascript"], mode: "javascript", ext: ["js"], alias: ["ecmascript", "js", "node"] }, { name: "JSON", mimes: ["application/json", "application/x-json"], mode: "javascript", ext: ["json", "map"], alias: ["json5"] }, { name: "JSON-LD", mime: "application/ld+json", mode: "javascript", ext: ["jsonld"], alias: ["jsonld"] }, { name: "JSX", mime: "text/jsx", mode: "jsx", ext: ["jsx"] }, { name: "Jinja2", mime: "text/jinja2", mode: "jinja2", ext: ["j2", "jinja", "jinja2"] }, { name: "Julia", mime: "text/x-julia", mode: "julia", ext: ["jl"], alias: ["jl"] }, { name: "Kotlin", mime: "text/x-kotlin", mode: "clike", ext: ["kt"] }, { name: "LESS", mime: "text/x-less", mode: "css", ext: ["less"] }, { name: "LiveScript", mime: "text/x-livescript", mode: "livescript", ext: ["ls"], alias: ["ls"] }, { name: "Lua", mime: "text/x-lua", mode: "lua", ext: ["lua"] }, { name: "Markdown", mime: "text/x-markdown", mode: "markdown", ext: ["markdown", "md", "mkd"] }, { name: "mIRC", mime: "text/mirc", mode: "mirc" }, { name: "MariaDB SQL", mime: "text/x-mariadb", mode: "sql" }, { name: "Mathematica", mime: "text/x-mathematica", mode: "mathematica", ext: ["m", "nb", "wl", "wls"] }, { name: "Modelica", mime: "text/x-modelica", mode: "modelica", ext: ["mo"] }, { name: "MUMPS", mime: "text/x-mumps", mode: "mumps", ext: ["mps"] }, { name: "MS SQL", mime: "text/x-mssql", mode: "sql" }, { name: "mbox", mime: "application/mbox", mode: "mbox", ext: ["mbox"] }, { name: "MySQL", mime: "text/x-mysql", mode: "sql" }, { name: "Nginx", mime: "text/x-nginx-conf", mode: "nginx", file: /nginx.*\.conf$/i }, { name: "NSIS", mime: "text/x-nsis", mode: "nsis", ext: ["nsh", "nsi"] }, { name: "NTriples", mimes: ["application/n-triples", "application/n-quads", "text/n-triples"], mode: "ntriples", ext: ["nt", "nq"] }, { name: "Objective-C", mime: "text/x-objectivec", mode: "clike", ext: ["m"], alias: ["objective-c", "objc"] }, { name: "Objective-C++", mime: "text/x-objectivec++", mode: "clike", ext: ["mm"], alias: ["objective-c++", "objc++"] }, { name: "OCaml", mime: "text/x-ocaml", mode: "mllike", ext: ["ml", "mli", "mll", "mly"] }, { name: "Octave", mime: "text/x-octave", mode: "octave", ext: ["m"] }, { name: "Oz", mime: "text/x-oz", mode: "oz", ext: ["oz"] }, { name: "Pascal", mime: "text/x-pascal", mode: "pascal", ext: ["p", "pas"] }, { name: "PEG.js", mime: "null", mode: "pegjs", ext: ["jsonld"] }, { name: "Perl", mime: "text/x-perl", mode: "perl", ext: ["pl", "pm"] }, { name: "PHP", mimes: ["text/x-php", "application/x-httpd-php", "application/x-httpd-php-open"], mode: "php", ext: ["php", "php3", "php4", "php5", "php7", "phtml"] }, { name: "Pig", mime: "text/x-pig", mode: "pig", ext: ["pig"] }, { name: "Plain Text", mime: "text/plain", mode: "null", ext: ["txt", "text", "conf", "def", "list", "log"] }, { name: "PLSQL", mime: "text/x-plsql", mode: "sql", ext: ["pls"] }, { name: "PostgreSQL", mime: "text/x-pgsql", mode: "sql" }, { name: "PowerShell", mime: "application/x-powershell", mode: "powershell", ext: ["ps1", "psd1", "psm1"] }, { name: "Properties files", mime: "text/x-properties", mode: "properties", ext: ["properties", "ini", "in"], alias: ["ini", "properties"] }, { name: "ProtoBuf", mime: "text/x-protobuf", mode: "protobuf", ext: ["proto"] }, { name: "Python", mime: "text/x-python", mode: "python", ext: ["BUILD", "bzl", "py", "pyw"], file: /^(BUCK|BUILD)$/ }, { name: "Puppet", mime: "text/x-puppet", mode: "puppet", ext: ["pp"] }, { name: "Q", mime: "text/x-q", mode: "q", ext: ["q"] }, { name: "R", mime: "text/x-rsrc", mode: "r", ext: ["r", "R"], alias: ["rscript"] }, { name: "reStructuredText", mime: "text/x-rst", mode: "rst", ext: ["rst"], alias: ["rst"] }, { name: "RPM Changes", mime: "text/x-rpm-changes", mode: "rpm" }, { name: "RPM Spec", mime: "text/x-rpm-spec", mode: "rpm", ext: ["spec"] }, { name: "Ruby", mime: "text/x-ruby", mode: "ruby", ext: ["rb"], alias: ["jruby", "macruby", "rake", "rb", "rbx"] }, { name: "Rust", mime: "text/x-rustsrc", mode: "rust", ext: ["rs"] }, { name: "SAS", mime: "text/x-sas", mode: "sas", ext: ["sas"] }, { name: "Sass", mime: "text/x-sass", mode: "sass", ext: ["sass"] }, { name: "Scala", mime: "text/x-scala", mode: "clike", ext: ["scala"] }, { name: "Scheme", mime: "text/x-scheme", mode: "scheme", ext: ["scm", "ss"] }, { name: "SCSS", mime: "text/x-scss", mode: "css", ext: ["scss"] }, { name: "Shell", mimes: ["text/x-sh", "application/x-sh"], mode: "shell", ext: ["sh", "ksh", "bash"], alias: ["bash", "sh", "zsh"], file: /^PKGBUILD$/ }, { name: "Sieve", mime: "application/sieve", mode: "sieve", ext: ["siv", "sieve"] }, { name: "Slim", mimes: ["text/x-slim", "application/x-slim"], mode: "slim", ext: ["slim"] }, { name: "Smalltalk", mime: "text/x-stsrc", mode: "smalltalk", ext: ["st"] }, { name: "Smarty", mime: "text/x-smarty", mode: "smarty", ext: ["tpl"] }, { name: "Solr", mime: "text/x-solr", mode: "solr" }, { name: "SML", mime: "text/x-sml", mode: "mllike", ext: ["sml", "sig", "fun", "smackspec"] }, { name: "Soy", mime: "text/x-soy", mode: "soy", ext: ["soy"], alias: ["closure template"] }, { name: "SPARQL", mime: "application/sparql-query", mode: "sparql", ext: ["rq", "sparql"], alias: ["sparul"] }, { name: "Spreadsheet", mime: "text/x-spreadsheet", mode: "spreadsheet", alias: ["excel", "formula"] }, { name: "SQL", mime: "text/x-sql", mode: "sql", ext: ["sql"] }, { name: "SQLite", mime: "text/x-sqlite", mode: "sql" }, { name: "Squirrel", mime: "text/x-squirrel", mode: "clike", ext: ["nut"] }, { name: "Stylus", mime: "text/x-styl", mode: "stylus", ext: ["styl"] }, { name: "Swift", mime: "text/x-swift", mode: "swift", ext: ["swift"] }, { name: "sTeX", mime: "text/x-stex", mode: "stex" }, { name: "LaTeX", mime: "text/x-latex", mode: "stex", ext: ["text", "ltx", "tex"], alias: ["tex"] }, { name: "SystemVerilog", mime: "text/x-systemverilog", mode: "verilog", ext: ["v", "sv", "svh"] }, { name: "Tcl", mime: "text/x-tcl", mode: "tcl", ext: ["tcl"] }, { name: "Textile", mime: "text/x-textile", mode: "textile", ext: ["textile"] }, { name: "TiddlyWiki", mime: "text/x-tiddlywiki", mode: "tiddlywiki" }, { name: "Tiki wiki", mime: "text/tiki", mode: "tiki" }, { name: "TOML", mime: "text/x-toml", mode: "toml", ext: ["toml"] }, { name: "Tornado", mime: "text/x-tornado", mode: "tornado" }, { name: "troff", mime: "text/troff", mode: "troff", ext: ["1", "2", "3", "4", "5", "6", "7", "8", "9"] }, { name: "TTCN", mime: "text/x-ttcn", mode: "ttcn", ext: ["ttcn", "ttcn3", "ttcnpp"] }, { name: "TTCN_CFG", mime: "text/x-ttcn-cfg", mode: "ttcn-cfg", ext: ["cfg"] }, { name: "Turtle", mime: "text/turtle", mode: "turtle", ext: ["ttl"] }, { name: "TypeScript", mime: "application/typescript", mode: "javascript", ext: ["ts"], alias: ["ts"] }, { name: "TypeScript-JSX", mime: "text/typescript-jsx", mode: "jsx", ext: ["tsx"], alias: ["tsx"] }, { name: "Twig", mime: "text/x-twig", mode: "twig" }, { name: "Web IDL", mime: "text/x-webidl", mode: "webidl", ext: ["webidl"] }, { name: "VB.NET", mime: "text/x-vb", mode: "vb", ext: ["vb"] }, { name: "VBScript", mime: "text/vbscript", mode: "vbscript", ext: ["vbs"] }, { name: "Velocity", mime: "text/velocity", mode: "velocity", ext: ["vtl"] }, { name: "Verilog", mime: "text/x-verilog", mode: "verilog", ext: ["v"] }, { name: "VHDL", mime: "text/x-vhdl", mode: "vhdl", ext: ["vhd", "vhdl"] }, { name: "Vue.js Component", mimes: ["script/x-vue", "text/x-vue"], mode: "vue", ext: ["vue"] }, { name: "XML", mimes: ["application/xml", "text/xml"], mode: "xml", ext: ["xml", "xsl", "xsd", "svg"], alias: ["rss", "wsdl", "xsd"] }, { name: "XQuery", mime: "application/xquery", mode: "xquery", ext: ["xy", "xquery"] }, { name: "Yacas", mime: "text/x-yacas", mode: "yacas", ext: ["ys"] }, { name: "YAML", mimes: ["text/x-yaml", "text/yaml"], mode: "yaml", ext: ["yaml", "yml"], alias: ["yml"] }, { name: "Z80", mime: "text/x-z80", mode: "z80", ext: ["z80"] }, { name: "mscgen", mime: "text/x-mscgen", mode: "mscgen", ext: ["mscgen", "mscin", "msc"] }, { name: "xu", mime: "text/x-xu", mode: "mscgen", ext: ["xu"] }, { name: "msgenny", mime: "text/x-msgenny", mode: "mscgen", ext: ["msgenny"] }, { name: "WebAssembly", mime: "text/webassembly", mode: "wast", ext: ["wat", "wast"] }]; for (var t = 0; t < e.modeInfo.length; t++) { var n = e.modeInfo[t]; n.mimes && (n.mime = n.mimes[0]) } e.findModeByMIME = function (t) { t = t.toLowerCase(); for (var n = 0; n < e.modeInfo.length; n++) { var r = e.modeInfo[n]; if (r.mime == t) return r; if (r.mimes) for (var i = 0; i < r.mimes.length; i++)if (r.mimes[i] == t) return r } return /\+xml$/.test(t) ? e.findModeByMIME("application/xml") : /\+json$/.test(t) ? e.findModeByMIME("application/json") : void 0 }, e.findModeByExtension = function (t) { t = t.toLowerCase(); for (var n = 0; n < e.modeInfo.length; n++) { var r = e.modeInfo[n]; if (r.ext) for (var i = 0; i < r.ext.length; i++)if (r.ext[i] == t) return r } }, e.findModeByFileName = function (t) { for (var n = 0; n < e.modeInfo.length; n++) { var r = e.modeInfo[n]; if (r.file && r.file.test(t)) return r } var i = t.lastIndexOf("."), o = i > -1 && t.substring(i + 1, t.length); if (o) return e.findModeByExtension(o) }, e.findModeByName = function (t) { t = t.toLowerCase(); for (var n = 0; n < e.modeInfo.length; n++) { var r = e.modeInfo[n]; if (r.name.toLowerCase() == t) return r; if (r.alias) for (var i = 0; i < r.alias.length; i++)if (r.alias[i].toLowerCase() == t) return r } } })("object" == typeof n && "object" == typeof t ? e("../lib/codemirror") : CodeMirror) }, { "../lib/codemirror": 10 }], 14: [function (e, t, n) { (function (e) { "use strict"; var t = { autoSelfClosers: { area: !0, base: !0, br: !0, col: !0, command: !0, embed: !0, frame: !0, hr: !0, img: !0, input: !0, keygen: !0, link: !0, meta: !0, param: !0, source: !0, track: !0, wbr: !0, menuitem: !0 }, implicitlyClosed: { dd: !0, li: !0, optgroup: !0, option: !0, p: !0, rp: !0, rt: !0, tbody: !0, td: !0, tfoot: !0, th: !0, tr: !0 }, contextGrabbers: { dd: { dd: !0, dt: !0 }, dt: { dd: !0, dt: !0 }, li: { li: !0 }, option: { option: !0, optgroup: !0 }, optgroup: { optgroup: !0 }, p: { address: !0, article: !0, aside: !0, blockquote: !0, dir: !0, div: !0, dl: !0, fieldset: !0, footer: !0, form: !0, h1: !0, h2: !0, h3: !0, h4: !0, h5: !0, h6: !0, header: !0, hgroup: !0, hr: !0, menu: !0, nav: !0, ol: !0, p: !0, pre: !0, section: !0, table: !0, ul: !0 }, rp: { rp: !0, rt: !0 }, rt: { rp: !0, rt: !0 }, tbody: { tbody: !0, tfoot: !0 }, td: { td: !0, th: !0 }, tfoot: { tbody: !0 }, th: { td: !0, th: !0 }, thead: { tbody: !0, tfoot: !0 }, tr: { tr: !0 } }, doNotIndent: { pre: !0 }, allowUnquoted: !0, allowMissing: !0, caseFold: !0 }, n = { autoSelfClosers: {}, implicitlyClosed: {}, contextGrabbers: {}, doNotIndent: {}, allowUnquoted: !1, allowMissing: !1, allowMissingTagName: !1, caseFold: !1 }; e.defineMode("xml", (function (r, i) { var o, a, l = r.indentUnit, s = {}, u = i.htmlMode ? t : n; for (var c in u) s[c] = u[c]; for (var c in i) s[c] = i[c]; function d(e, t) { function n(n) { return t.tokenize = n, n(e, t) } var r = e.next(); return "<" == r ? e.eat("!") ? e.eat("[") ? e.match("CDATA[") ? n(f("atom", "]]>")) : null : e.match("--") ? n(f("comment", "--\x3e")) : e.match("DOCTYPE", !0, !0) ? (e.eatWhile(/[\w\._\-]/), n(p(1))) : null : e.eat("?") ? (e.eatWhile(/[\w\._\-]/), t.tokenize = f("meta", "?>"), "meta") : (o = e.eat("/") ? "closeTag" : "openTag", t.tokenize = h, "tag bracket") : "&" == r ? (e.eat("#") ? e.eat("x") ? e.eatWhile(/[a-fA-F\d]/) && e.eat(";") : e.eatWhile(/[\d]/) && e.eat(";") : e.eatWhile(/[\w\.\-:]/) && e.eat(";")) ? "atom" : "error" : (e.eatWhile(/[^&<]/), null) } function h(e, t) { var n, r, i = e.next(); if (">" == i || "/" == i && e.eat(">")) return t.tokenize = d, o = ">" == i ? "endTag" : "selfcloseTag", "tag bracket"; if ("=" == i) return o = "equals", null; if ("<" == i) { t.tokenize = d, t.state = x, t.tagName = t.tagStart = null; var a = t.tokenize(e, t); return a ? a + " tag error" : "tag error" } return /[\'\"]/.test(i) ? (t.tokenize = (n = i, (r = function (e, t) { for (; !e.eol();)if (e.next() == n) { t.tokenize = h; break } return "string" }).isInAttribute = !0, r), t.stringStartCol = e.column(), t.tokenize(e, t)) : (e.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/), "word") } function f(e, t) { return function (n, r) { for (; !n.eol();) { if (n.match(t)) { r.tokenize = d; break } n.next() } return e } } function p(e) { return function (t, n) { for (var r; null != (r = t.next());) { if ("<" == r) return n.tokenize = p(e + 1), n.tokenize(t, n); if (">" == r) { if (1 == e) { n.tokenize = d; break } return n.tokenize = p(e - 1), n.tokenize(t, n) } } return "meta" } } function m(e, t, n) { this.prev = e.context, this.tagName = t || "", this.indent = e.indented, this.startOfLine = n, (s.doNotIndent.hasOwnProperty(t) || e.context && e.context.noIndent) && (this.noIndent = !0) } function g(e) { e.context && (e.context = e.context.prev) } function v(e, t) { for (var n; ;) { if (!e.context) return; if (n = e.context.tagName, !s.contextGrabbers.hasOwnProperty(n) || !s.contextGrabbers[n].hasOwnProperty(t)) return; g(e) } } function x(e, t, n) { return "openTag" == e ? (n.tagStart = t.column(), y) : "closeTag" == e ? b : x } function y(e, t, n) { return "word" == e ? (n.tagName = t.current(), a = "tag", w) : s.allowMissingTagName && "endTag" == e ? (a = "tag bracket", w(e, 0, n)) : (a = "error", y) } function b(e, t, n) { if ("word" == e) { var r = t.current(); return n.context && n.context.tagName != r && s.implicitlyClosed.hasOwnProperty(n.context.tagName) && g(n), n.context && n.context.tagName == r || !1 === s.matchClosing ? (a = "tag", D) : (a = "tag error", C) } return s.allowMissingTagName && "endTag" == e ? (a = "tag bracket", D(e, 0, n)) : (a = "error", C) } function D(e, t, n) { return "endTag" != e ? (a = "error", D) : (g(n), x) } function C(e, t, n) { return a = "error", D(e, 0, n) } function w(e, t, n) { if ("word" == e) return a = "attribute", k; if ("endTag" == e || "selfcloseTag" == e) { var r = n.tagName, i = n.tagStart; return n.tagName = n.tagStart = null, "selfcloseTag" == e || s.autoSelfClosers.hasOwnProperty(r) ? v(n, r) : (v(n, r), n.context = new m(n, r, i == n.indented)), x } return a = "error", w } function k(e, t, n) { return "equals" == e ? S : (s.allowMissing || (a = "error"), w(e, 0, n)) } function S(e, t, n) { return "string" == e ? F : "word" == e && s.allowUnquoted ? (a = "string", w) : (a = "error", w(e, 0, n)) } function F(e, t, n) { return "string" == e ? F : w(e, 0, n) } return d.isInText = !0, { startState: function (e) { var t = { tokenize: d, state: x, indented: e || 0, tagName: null, tagStart: null, context: null }; return null != e && (t.baseIndent = e), t }, token: function (e, t) { if (!t.tagName && e.sol() && (t.indented = e.indentation()), e.eatSpace()) return null; o = null; var n = t.tokenize(e, t); return (n || o) && "comment" != n && (a = null, t.state = t.state(o || n, e, t), a && (n = "error" == a ? n + " error" : a)), n }, indent: function (t, n, r) { var i = t.context; if (t.tokenize.isInAttribute) return t.tagStart == t.indented ? t.stringStartCol + 1 : t.indented + l; if (i && i.noIndent) return e.Pass; if (t.tokenize != h && t.tokenize != d) return r ? r.match(/^(\s*)/)[0].length : 0; if (t.tagName) return !1 !== s.multilineTagIndentPastTag ? t.tagStart + t.tagName.length + 2 : t.tagStart + l * (s.multilineTagIndentFactor || 1); if (s.alignCDATA && /$/, blockCommentStart: "\x3c!--", blockCommentEnd: "--\x3e", configuration: s.htmlMode ? "html" : "xml", helperType: s.htmlMode ? "html" : "xml", skipAttribute: function (e) { e.state == S && (e.state = w) }, xmlCurrentTag: function (e) { return e.tagName ? { name: e.tagName, close: "closeTag" == e.type } : null }, xmlCurrentContext: function (e) { for (var t = [], n = e.context; n; n = n.prev)t.push(n.tagName); return t.reverse() } } })), e.defineMIME("text/xml", "xml"), e.defineMIME("application/xml", "xml"), e.mimeModes.hasOwnProperty("text/html") || e.defineMIME("text/html", { name: "xml", htmlMode: !0 }) })("object" == typeof n && "object" == typeof t ? e("../../lib/codemirror") : CodeMirror) }, { "../../lib/codemirror": 10 }], 15: [function (e, t, n) { !function (e, r) { "object" == typeof n && void 0 !== t ? t.exports = r() : (e = "undefined" != typeof globalThis ? globalThis : e || self).marked = r() }(this, (function () { "use strict"; function e(e, t) { for (var n = 0; n < t.length; n++) { var r = t[n]; r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(e, r.key, r) } } function t(e, t) { (null == t || t > e.length) && (t = e.length); for (var n = 0, r = new Array(t); n < t; n++)r[n] = e[n]; return r } function n(e, n) { var r; if ("undefined" == typeof Symbol || null == e[Symbol.iterator]) { if (Array.isArray(e) || (r = function (e, n) { if (e) { if ("string" == typeof e) return t(e, n); var r = Object.prototype.toString.call(e).slice(8, -1); return "Object" === r && e.constructor && (r = e.constructor.name), "Map" === r || "Set" === r ? Array.from(e) : "Arguments" === r || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r) ? t(e, n) : void 0 } }(e)) || n && e && "number" == typeof e.length) { r && (e = r); var i = 0; return function () { return i >= e.length ? { done: !0 } : { done: !1, value: e[i++] } } } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.") } return (r = e[Symbol.iterator]()).next.bind(r) } var r = function (e) { var t = { exports: {} }; return e(t, t.exports), t.exports }((function (e) { function t() { return { baseUrl: null, breaks: !1, gfm: !0, headerIds: !0, headerPrefix: "", highlight: null, langPrefix: "language-", mangle: !0, pedantic: !1, renderer: null, sanitize: !1, sanitizer: null, silent: !1, smartLists: !1, smartypants: !1, tokenizer: null, walkTokens: null, xhtml: !1 } } e.exports = { defaults: { baseUrl: null, breaks: !1, gfm: !0, headerIds: !0, headerPrefix: "", highlight: null, langPrefix: "language-", mangle: !0, pedantic: !1, renderer: null, sanitize: !1, sanitizer: null, silent: !1, smartLists: !1, smartypants: !1, tokenizer: null, walkTokens: null, xhtml: !1 }, getDefaults: t, changeDefaults: function (t) { e.exports.defaults = t } } })), i = /[&<>"']/, o = /[&<>"']/g, a = /[<>"']|&(?!#?\w+;)/, l = /[<>"']|&(?!#?\w+;)/g, s = { "&": "&", "<": "<", ">": ">", '"': """, "'": "'" }, u = function (e) { return s[e] }; var c = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi; function d(e) { return e.replace(c, (function (e, t) { return "colon" === (t = t.toLowerCase()) ? ":" : "#" === t.charAt(0) ? "x" === t.charAt(1) ? String.fromCharCode(parseInt(t.substring(2), 16)) : String.fromCharCode(+t.substring(1)) : "" })) } var h = /(^|[^\[])\^/g; var f = /[^\w:]/g, p = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i; var m = {}, g = /^[^:]+:\/*[^/]*$/, v = /^([^:]+:)[\s\S]*$/, x = /^([^:]+:\/*[^/]*)[\s\S]*$/; function y(e, t) { m[" " + e] || (g.test(e) ? m[" " + e] = e + "/" : m[" " + e] = b(e, "/", !0)); var n = -1 === (e = m[" " + e]).indexOf(":"); return "//" === t.substring(0, 2) ? n ? t : e.replace(v, "$1") + t : "/" === t.charAt(0) ? n ? t : e.replace(x, "$1") + t : e + t } function b(e, t, n) { var r = e.length; if (0 === r) return ""; for (var i = 0; i < r;) { var o = e.charAt(r - i - 1); if (o !== t || n) { if (o === t || !n) break; i++ } else i++ } return e.substr(0, r - i) } var D = function (e, t) { if (t) { if (i.test(e)) return e.replace(o, u) } else if (a.test(e)) return e.replace(l, u); return e }, C = d, w = function (e, t) { e = e.source || e, t = t || ""; var n = { replace: function (t, r) { return r = (r = r.source || r).replace(h, "$1"), e = e.replace(t, r), n }, getRegex: function () { return new RegExp(e, t) } }; return n }, k = function (e, t, n) { if (e) { var r; try { r = decodeURIComponent(d(n)).replace(f, "").toLowerCase() } catch (e) { return null } if (0 === r.indexOf("javascript:") || 0 === r.indexOf("vbscript:") || 0 === r.indexOf("data:")) return null } t && !p.test(n) && (n = y(t, n)); try { n = encodeURI(n).replace(/%25/g, "%") } catch (e) { return null } return n }, S = { exec: function () { } }, F = function (e) { for (var t, n, r = 1; r < arguments.length; r++)for (n in t = arguments[r]) Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]); return e }, A = function (e, t) { var n = e.replace(/\|/g, (function (e, t, n) { for (var r = !1, i = t; --i >= 0 && "\\" === n[i];)r = !r; return r ? "|" : " |" })).split(/ \|/), r = 0; if (n.length > t) n.splice(t); else for (; n.length < t;)n.push(""); for (; r < n.length; r++)n[r] = n[r].trim().replace(/\\\|/g, "|"); return n }, E = b, T = function (e, t) { if (-1 === e.indexOf(t[1])) return -1; for (var n = e.length, r = 0, i = 0; i < n; i++)if ("\\" === e[i]) i++; else if (e[i] === t[0]) r++; else if (e[i] === t[1] && --r < 0) return i; return -1 }, L = function (e) { e && e.sanitize && !e.silent && console.warn("marked(): sanitize and sanitizer parameters are deprecated since version 0.7.0, should not be used and will be removed in the future. Read more here: https://marked.js.org/#/USING_ADVANCED.md#options") }, M = function (e, t) { if (t < 1) return ""; for (var n = ""; t > 1;)1 & t && (n += e), t >>= 1, e += e; return n + e }, B = r.defaults, N = E, O = A, I = D, z = T; function H(e, t, n) { var r = t.href, i = t.title ? I(t.title) : null, o = e[1].replace(/\\([\[\]])/g, "$1"); return "!" !== e[0].charAt(0) ? { type: "link", raw: n, href: r, title: i, text: o } : { type: "image", raw: n, href: r, title: i, text: I(o) } } var R = function () { function e(e) { this.options = e || B } var t = e.prototype; return t.space = function (e) { var t = this.rules.block.newline.exec(e); if (t) return t[0].length > 1 ? { type: "space", raw: t[0] } : { raw: "\n" } }, t.code = function (e) { var t = this.rules.block.code.exec(e); if (t) { var n = t[0].replace(/^ {1,4}/gm, ""); return { type: "code", raw: t[0], codeBlockStyle: "indented", text: this.options.pedantic ? n : N(n, "\n") } } }, t.fences = function (e) { var t = this.rules.block.fences.exec(e); if (t) { var n = t[0], r = function (e, t) { var n = e.match(/^(\s+)(?:```)/); if (null === n) return t; var r = n[1]; return t.split("\n").map((function (e) { var t = e.match(/^\s+/); return null === t ? e : t[0].length >= r.length ? e.slice(r.length) : e })).join("\n") }(n, t[3] || ""); return { type: "code", raw: n, lang: t[2] ? t[2].trim() : t[2], text: r } } }, t.heading = function (e) { var t = this.rules.block.heading.exec(e); if (t) { var n = t[2].trim(); if (/#$/.test(n)) { var r = N(n, "#"); this.options.pedantic ? n = r.trim() : r && !/ $/.test(r) || (n = r.trim()) } return { type: "heading", raw: t[0], depth: t[1].length, text: n } } }, t.nptable = function (e) { var t = this.rules.block.nptable.exec(e); if (t) { var n = { type: "table", header: O(t[1].replace(/^ *| *\| *$/g, "")), align: t[2].replace(/^ *|\| *$/g, "").split(/ *\| */), cells: t[3] ? t[3].replace(/\n$/, "").split("\n") : [], raw: t[0] }; if (n.header.length === n.align.length) { var r, i = n.align.length; for (r = 0; r < i; r++)/^ *-+: *$/.test(n.align[r]) ? n.align[r] = "right" : /^ *:-+: *$/.test(n.align[r]) ? n.align[r] = "center" : /^ *:-+ *$/.test(n.align[r]) ? n.align[r] = "left" : n.align[r] = null; for (i = n.cells.length, r = 0; r < i; r++)n.cells[r] = O(n.cells[r], n.header.length); return n } } }, t.hr = function (e) { var t = this.rules.block.hr.exec(e); if (t) return { type: "hr", raw: t[0] } }, t.blockquote = function (e) { var t = this.rules.block.blockquote.exec(e); if (t) { var n = t[0].replace(/^ *> ?/gm, ""); return { type: "blockquote", raw: t[0], text: n } } }, t.list = function (e) { var t = this.rules.block.list.exec(e); if (t) { var n, r, i, o, a, l, s, u, c, d = t[0], h = t[2], f = h.length > 1, p = { type: "list", raw: d, ordered: f, start: f ? +h.slice(0, -1) : "", loose: !1, items: [] }, m = t[0].match(this.rules.block.item), g = !1, v = m.length; i = this.rules.block.listItemStart.exec(m[0]); for (var x = 0; x < v; x++) { if (d = n = m[x], this.options.pedantic || (c = n.match(new RegExp("\\n\\s*\\n {0," + (i[0].length - 1) + "}\\S"))) && (a = n.length - c.index + m.slice(x + 1).join("\n").length, p.raw = p.raw.substring(0, p.raw.length - a), d = n = n.substring(0, c.index), v = x + 1), x !== v - 1) { if (o = this.rules.block.listItemStart.exec(m[x + 1]), this.options.pedantic ? o[1].length > i[1].length : o[1].length >= i[0].length || o[1].length > 3) { m.splice(x, 2, m[x] + (!this.options.pedantic && o[1].length < i[0].length && !m[x].match(/\n$/) ? "" : "\n") + m[x + 1]), x--, v--; continue } (!this.options.pedantic || this.options.smartLists ? o[2][o[2].length - 1] !== h[h.length - 1] : f === (1 === o[2].length)) && (a = m.slice(x + 1).join("\n").length, p.raw = p.raw.substring(0, p.raw.length - a), x = v - 1), i = o } r = n.length, ~(n = n.replace(/^ *([*+-]|\d+[.)]) ?/, "")).indexOf("\n ") && (r -= n.length, n = this.options.pedantic ? n.replace(/^ {1,4}/gm, "") : n.replace(new RegExp("^ {1," + r + "}", "gm"), "")), n = N(n, "\n"), x !== v - 1 && (d += "\n"), l = g || /\n\n(?!\s*$)/.test(d), x !== v - 1 && (g = "\n\n" === d.slice(-2), l || (l = g)), l && (p.loose = !0), this.options.gfm && (u = void 0, (s = /^\[[ xX]\] /.test(n)) && (u = " " !== n[1], n = n.replace(/^\[[ xX]\] +/, ""))), p.items.push({ type: "list_item", raw: d, task: s, checked: u, loose: l, text: n }) } return p } }, t.html = function (e) { var t = this.rules.block.html.exec(e); if (t) return { type: this.options.sanitize ? "paragraph" : "html", raw: t[0], pre: !this.options.sanitizer && ("pre" === t[1] || "script" === t[1] || "style" === t[1]), text: this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(t[0]) : I(t[0]) : t[0] } }, t.def = function (e) { var t = this.rules.block.def.exec(e); if (t) return t[3] && (t[3] = t[3].substring(1, t[3].length - 1)), { type: "def", tag: t[1].toLowerCase().replace(/\s+/g, " "), raw: t[0], href: t[2], title: t[3] } }, t.table = function (e) { var t = this.rules.block.table.exec(e); if (t) { var n = { type: "table", header: O(t[1].replace(/^ *| *\| *$/g, "")), align: t[2].replace(/^ *|\| *$/g, "").split(/ *\| */), cells: t[3] ? t[3].replace(/\n$/, "").split("\n") : [] }; if (n.header.length === n.align.length) { n.raw = t[0]; var r, i = n.align.length; for (r = 0; r < i; r++)/^ *-+: *$/.test(n.align[r]) ? n.align[r] = "right" : /^ *:-+: *$/.test(n.align[r]) ? n.align[r] = "center" : /^ *:-+ *$/.test(n.align[r]) ? n.align[r] = "left" : n.align[r] = null; for (i = n.cells.length, r = 0; r < i; r++)n.cells[r] = O(n.cells[r].replace(/^ *\| *| *\| *$/g, ""), n.header.length); return n } } }, t.lheading = function (e) { var t = this.rules.block.lheading.exec(e); if (t) return { type: "heading", raw: t[0], depth: "=" === t[2].charAt(0) ? 1 : 2, text: t[1] } }, t.paragraph = function (e) { var t = this.rules.block.paragraph.exec(e); if (t) return { type: "paragraph", raw: t[0], text: "\n" === t[1].charAt(t[1].length - 1) ? t[1].slice(0, -1) : t[1] } }, t.text = function (e) { var t = this.rules.block.text.exec(e); if (t) return { type: "text", raw: t[0], text: t[0] } }, t.escape = function (e) { var t = this.rules.inline.escape.exec(e); if (t) return { type: "escape", raw: t[0], text: I(t[1]) } }, t.tag = function (e, t, n) { var r = this.rules.inline.tag.exec(e); if (r) return !t && /^
    /i.test(r[0]) && (t = !1), !n && /^<(pre|code|kbd|script)(\s|>)/i.test(r[0]) ? n = !0 : n && /^<\/(pre|code|kbd|script)(\s|>)/i.test(r[0]) && (n = !1), { type: this.options.sanitize ? "text" : "html", raw: r[0], inLink: t, inRawBlock: n, text: this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(r[0]) : I(r[0]) : r[0] } }, t.link = function (e) { var t = this.rules.inline.link.exec(e); if (t) { var n = t[2].trim(); if (!this.options.pedantic && /^$/.test(n)) return; var r = N(n.slice(0, -1), "\\"); if ((n.length - r.length) % 2 == 0) return } else { var i = z(t[2], "()"); if (i > -1) { var o = (0 === t[0].indexOf("!") ? 5 : 4) + t[1].length + i; t[2] = t[2].substring(0, i), t[0] = t[0].substring(0, o).trim(), t[3] = "" } } var a = t[2], l = ""; if (this.options.pedantic) { var s = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(a); s && (a = s[1], l = s[3]) } else l = t[3] ? t[3].slice(1, -1) : ""; return a = a.trim(), /^$/.test(n) ? a.slice(1) : a.slice(1, -1)), H(t, { href: a ? a.replace(this.rules.inline._escapes, "$1") : a, title: l ? l.replace(this.rules.inline._escapes, "$1") : l }, t[0]) } }, t.reflink = function (e, t) { var n; if ((n = this.rules.inline.reflink.exec(e)) || (n = this.rules.inline.nolink.exec(e))) { var r = (n[2] || n[1]).replace(/\s+/g, " "); if (!(r = t[r.toLowerCase()]) || !r.href) { var i = n[0].charAt(0); return { type: "text", raw: i, text: i } } return H(n, r, n[0]) } }, t.emStrong = function (e, t, n) { void 0 === n && (n = ""); var r = this.rules.inline.emStrong.lDelim.exec(e); if (r && (!r[3] || !n.match(/(?:[0-9A-Za-z\xAA\xB2\xB3\xB5\xB9\xBA\xBC-\xBE\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u0660-\u0669\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07C0-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0966-\u096F\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09E6-\u09F1\u09F4-\u09F9\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A66-\u0A6F\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AE6-\u0AEF\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B66-\u0B6F\u0B71-\u0B77\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0BE6-\u0BF2\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C66-\u0C6F\u0C78-\u0C7E\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CE6-\u0CEF\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D58-\u0D61\u0D66-\u0D78\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DE6-\u0DEF\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F20-\u0F33\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F-\u1049\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u1090-\u1099\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1369-\u137C\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A16\u1A20-\u1A54\u1A80-\u1A89\u1A90-\u1A99\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B50-\u1B59\u1B83-\u1BA0\u1BAE-\u1BE5\u1C00-\u1C23\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2070\u2071\u2074-\u2079\u207F-\u2089\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2150-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2CFD\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u3192-\u3195\u31A0-\u31BF\u31F0-\u31FF\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA830-\uA835\uA840-\uA873\uA882-\uA8B3\uA8D0-\uA8D9\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA900-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF-\uA9D9\uA9E0-\uA9E4\uA9E6-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA50-\uAA59\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDE80-\uDE9C\uDEA0-\uDED0\uDEE1-\uDEFB\uDF00-\uDF23\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC58-\uDC76\uDC79-\uDC9E\uDCA7-\uDCAF\uDCE0-\uDCF2\uDCF4\uDCF5\uDCFB-\uDD1B\uDD20-\uDD39\uDD80-\uDDB7\uDDBC-\uDDCF\uDDD2-\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE40-\uDE48\uDE60-\uDE7E\uDE80-\uDE9F\uDEC0-\uDEC7\uDEC9-\uDEE4\uDEEB-\uDEEF\uDF00-\uDF35\uDF40-\uDF55\uDF58-\uDF72\uDF78-\uDF91\uDFA9-\uDFAF]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDCFA-\uDD23\uDD30-\uDD39\uDE60-\uDE7E\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF27\uDF30-\uDF45\uDF51-\uDF54\uDFB0-\uDFCB\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC52-\uDC6F\uDC83-\uDCAF\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD03-\uDD26\uDD36-\uDD3F\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDD0-\uDDDA\uDDDC\uDDE1-\uDDF4\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDEF0-\uDEF9\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC50-\uDC59\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE50-\uDE59\uDE80-\uDEAA\uDEB8\uDEC0-\uDEC9\uDF00-\uDF1A\uDF30-\uDF3B]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCF2\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDD50-\uDD59\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC50-\uDC6C\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD50-\uDD59\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDDA0-\uDDA9\uDEE0-\uDEF2\uDFB0\uDFC0-\uDFD4]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF50-\uDF59\uDF5B-\uDF61\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE96\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD40-\uDD49\uDD4E\uDEC0-\uDEEB\uDEF0-\uDEF9]|\uD83A[\uDC00-\uDCC4\uDCC7-\uDCCF\uDD00-\uDD43\uDD4B\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/))) { var i = r[1] || r[2] || ""; if (!i || i && ("" === n || this.rules.inline.punctuation.exec(n))) { var o, a, l = r[0].length - 1, s = l, u = 0, c = "*" === r[0][0] ? this.rules.inline.emStrong.rDelimAst : this.rules.inline.emStrong.rDelimUnd; for (c.lastIndex = 0, t = t.slice(-1 * e.length + l); null != (r = c.exec(t));)if (o = r[1] || r[2] || r[3] || r[4] || r[5] || r[6]) if (a = o.length, r[3] || r[4]) s += a; else if (!((r[5] || r[6]) && l % 3) || (l + a) % 3) { if (!((s -= a) > 0)) { if (s + u - a <= 0 && !t.slice(c.lastIndex).match(c) && (a = Math.min(a, a + s + u)), Math.min(l, a) % 2) return { type: "em", raw: e.slice(0, l + r.index + a + 1), text: e.slice(1, l + r.index + a) }; if (Math.min(l, a) % 2 == 0) return { type: "strong", raw: e.slice(0, l + r.index + a + 1), text: e.slice(2, l + r.index + a - 1) } } } else u += a } } }, t.codespan = function (e) { var t = this.rules.inline.code.exec(e); if (t) { var n = t[2].replace(/\n/g, " "), r = /[^ ]/.test(n), i = /^ /.test(n) && / $/.test(n); return r && i && (n = n.substring(1, n.length - 1)), n = I(n, !0), { type: "codespan", raw: t[0], text: n } } }, t.br = function (e) { var t = this.rules.inline.br.exec(e); if (t) return { type: "br", raw: t[0] } }, t.del = function (e) { var t = this.rules.inline.del.exec(e); if (t) return { type: "del", raw: t[0], text: t[2] } }, t.autolink = function (e, t) { var n, r, i = this.rules.inline.autolink.exec(e); if (i) return r = "@" === i[2] ? "mailto:" + (n = I(this.options.mangle ? t(i[1]) : i[1])) : n = I(i[1]), { type: "link", raw: i[0], text: n, href: r, tokens: [{ type: "text", raw: n, text: n }] } }, t.url = function (e, t) { var n; if (n = this.rules.inline.url.exec(e)) { var r, i; if ("@" === n[2]) i = "mailto:" + (r = I(this.options.mangle ? t(n[0]) : n[0])); else { var o; do { o = n[0], n[0] = this.rules.inline._backpedal.exec(n[0])[0] } while (o !== n[0]); r = I(n[0]), i = "www." === n[1] ? "http://" + r : r } return { type: "link", raw: n[0], text: r, href: i, tokens: [{ type: "text", raw: r, text: r }] } } }, t.inlineText = function (e, t, n) { var r, i = this.rules.inline.text.exec(e); if (i) return r = t ? this.options.sanitize ? this.options.sanitizer ? this.options.sanitizer(i[0]) : I(i[0]) : i[0] : I(this.options.smartypants ? n(i[0]) : i[0]), { type: "text", raw: i[0], text: r } }, e }(), P = S, _ = w, W = F, j = { newline: /^(?: *(?:\n|$))+/, code: /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/, fences: /^ {0,3}(`{3,}(?=[^`\n]*\n)|~{3,})([^\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/, hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/, heading: /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/, blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/, list: /^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?! {0,3}bull )\n*|\s*$)/, html: "^ {0,3}(?:<(script|pre|style)[\\s>][\\s\\S]*?(?:[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|\\n*|$)|\\n*|$)|)[\\s\\S]*?(?:\\n{2,}|$)|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)|(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$))", def: /^ {0,3}\[(label)\]: *\n? *]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/, nptable: P, table: P, lheading: /^([^\n]+)\n {0,3}(=+|-+) *(?:\n+|$)/, _paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html| +\n)[^\n]+)*)/, text: /^[^\n]+/, _label: /(?!\s*\])(?:\\[\[\]]|[^\[\]])+/, _title: /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/ }; j.def = _(j.def).replace("label", j._label).replace("title", j._title).getRegex(), j.bullet = /(?:[*+-]|\d{1,9}[.)])/, j.item = /^( *)(bull) ?[^\n]*(?:\n(?! *bull ?)[^\n]*)*/, j.item = _(j.item, "gm").replace(/bull/g, j.bullet).getRegex(), j.listItemStart = _(/^( *)(bull) */).replace("bull", j.bullet).getRegex(), j.list = _(j.list).replace(/bull/g, j.bullet).replace("hr", "\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))").replace("def", "\\n+(?=" + j.def.source + ")").getRegex(), j._tag = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul", j._comment = /|$)/, j.html = _(j.html, "i").replace("comment", j._comment).replace("tag", j._tag).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(), j.paragraph = _(j._paragraph).replace("hr", j.hr).replace("heading", " {0,3}#{1,6} ").replace("|lheading", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", ")|<(?:script|pre|style|!--)").replace("tag", j._tag).getRegex(), j.blockquote = _(j.blockquote).replace("paragraph", j.paragraph).getRegex(), j.normal = W({}, j), j.gfm = W({}, j.normal, { nptable: "^ *([^|\\n ].*\\|.*)\\n {0,3}([-:]+ *\\|[-| :]*)(?:\\n((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)", table: "^ *\\|(.+)\\n {0,3}\\|?( *[-:]+[-| :]*)(?:\\n *((?:(?!\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)" }), j.gfm.nptable = _(j.gfm.nptable).replace("hr", j.hr).replace("heading", " {0,3}#{1,6} ").replace("blockquote", " {0,3}>").replace("code", " {4}[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", ")|<(?:script|pre|style|!--)").replace("tag", j._tag).getRegex(), j.gfm.table = _(j.gfm.table).replace("hr", j.hr).replace("heading", " {0,3}#{1,6} ").replace("blockquote", " {0,3}>").replace("code", " {4}[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", ")|<(?:script|pre|style|!--)").replace("tag", j._tag).getRegex(), j.pedantic = W({}, j.normal, { html: _("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+? *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment", j._comment).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(), def: /^ *\[([^\]]+)\]: *]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/, heading: /^(#{1,6})(.*)(?:\n+|$)/, fences: P, paragraph: _(j.normal._paragraph).replace("hr", j.hr).replace("heading", " *#{1,6} *[^\n]").replace("lheading", j.lheading).replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").getRegex() }); var q = { escape: /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/, autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/, url: P, tag: "^comment|^|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^|^", link: /^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/, reflink: /^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/, nolink: /^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/, reflinkSearch: "reflink|nolink(?!\\()", emStrong: { lDelim: /^(?:\*+(?:([punct_])|[^\s*]))|^_+(?:([punct*])|([^\s_]))/, rDelimAst: /\_\_[^_]*?\*[^_]*?\_\_|[punct_](\*+)(?=[\s]|$)|[^punct*_\s](\*+)(?=[punct_\s]|$)|[punct_\s](\*+)(?=[^punct*_\s])|[\s](\*+)(?=[punct_])|[punct_](\*+)(?=[punct_])|[^punct*_\s](\*+)(?=[^punct*_\s])/, rDelimUnd: /\*\*[^*]*?\_[^*]*?\*\*|[punct*](\_+)(?=[\s]|$)|[^punct*_\s](\_+)(?=[punct*\s]|$)|[punct*\s](\_+)(?=[^punct*_\s])|[\s](\_+)(?=[punct*])|[punct*](\_+)(?=[punct*])/ }, code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/, br: /^( {2,}|\\)\n(?!\s*$)/, del: P, text: /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\?@\\[\\]`^{|}~" }; q.punctuation = _(q.punctuation).replace(/punctuation/g, q._punctuation).getRegex(), q.blockSkip = /\[[^\]]*?\]\([^\)]*?\)|`[^`]*?`|<[^>]*?>/g, q.escapedEmSt = /\\\*|\\_/g, q._comment = _(j._comment).replace("(?:--\x3e|$)", "--\x3e").getRegex(), q.emStrong.lDelim = _(q.emStrong.lDelim).replace(/punct/g, q._punctuation).getRegex(), q.emStrong.rDelimAst = _(q.emStrong.rDelimAst, "g").replace(/punct/g, q._punctuation).getRegex(), q.emStrong.rDelimUnd = _(q.emStrong.rDelimUnd, "g").replace(/punct/g, q._punctuation).getRegex(), q._escapes = /\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g, q._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/, q._email = /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/, q.autolink = _(q.autolink).replace("scheme", q._scheme).replace("email", q._email).getRegex(), q._attribute = /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/, q.tag = _(q.tag).replace("comment", q._comment).replace("attribute", q._attribute).getRegex(), q._label = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/, q._href = /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/, q._title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/, q.link = _(q.link).replace("label", q._label).replace("href", q._href).replace("title", q._title).getRegex(), q.reflink = _(q.reflink).replace("label", q._label).getRegex(), q.reflinkSearch = _(q.reflinkSearch, "g").replace("reflink", q.reflink).replace("nolink", q.nolink).getRegex(), q.normal = W({}, q), q.pedantic = W({}, q.normal, { strong: { start: /^__|\*\*/, middle: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/, endAst: /\*\*(?!\*)/g, endUnd: /__(?!_)/g }, em: { start: /^_|\*/, middle: /^()\*(?=\S)([\s\S]*?\S)\*(?!\*)|^_(?=\S)([\s\S]*?\S)_(?!_)/, endAst: /\*(?!\*)/g, endUnd: /_(?!_)/g }, link: _(/^!?\[(label)\]\((.*?)\)/).replace("label", q._label).getRegex(), reflink: _(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", q._label).getRegex() }), q.gfm = W({}, q.normal, { escape: _(q.escape).replace("])", "~|])").getRegex(), _extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/, url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, _backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/, del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/, text: /^([`~]+|[^`~])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\ .5 && (n = "x" + n.toString(16)), r += "&#" + n + ";"; return r } var Y = function () { function t(e) { this.tokens = [], this.tokens.links = Object.create(null), this.options = e || $, this.options.tokenizer = this.options.tokenizer || new R, this.tokenizer = this.options.tokenizer, this.tokenizer.options = this.options; var t = { block: G.normal, inline: V.normal }; this.options.pedantic ? (t.block = G.pedantic, t.inline = V.pedantic) : this.options.gfm && (t.block = G.gfm, this.options.breaks ? t.inline = V.breaks : t.inline = V.gfm), this.tokenizer.rules = t } t.lex = function (e, n) { return new t(n).lex(e) }, t.lexInline = function (e, n) { return new t(n).inlineTokens(e) }; var n, r, i, o = t.prototype; return o.lex = function (e) { return e = e.replace(/\r\n|\r/g, "\n").replace(/\t/g, " "), this.blockTokens(e, this.tokens, !0), this.inline(this.tokens), this.tokens }, o.blockTokens = function (e, t, n) { var r, i, o, a; for (void 0 === t && (t = []), void 0 === n && (n = !0), this.options.pedantic && (e = e.replace(/^ +$/gm, "")); e;)if (r = this.tokenizer.space(e)) e = e.substring(r.raw.length), r.type && t.push(r); else if (r = this.tokenizer.code(e)) e = e.substring(r.raw.length), (a = t[t.length - 1]) && "paragraph" === a.type ? (a.raw += "\n" + r.raw, a.text += "\n" + r.text) : t.push(r); else if (r = this.tokenizer.fences(e)) e = e.substring(r.raw.length), t.push(r); else if (r = this.tokenizer.heading(e)) e = e.substring(r.raw.length), t.push(r); else if (r = this.tokenizer.nptable(e)) e = e.substring(r.raw.length), t.push(r); else if (r = this.tokenizer.hr(e)) e = e.substring(r.raw.length), t.push(r); else if (r = this.tokenizer.blockquote(e)) e = e.substring(r.raw.length), r.tokens = this.blockTokens(r.text, [], n), t.push(r); else if (r = this.tokenizer.list(e)) { for (e = e.substring(r.raw.length), o = r.items.length, i = 0; i < o; i++)r.items[i].tokens = this.blockTokens(r.items[i].text, [], !1); t.push(r) } else if (r = this.tokenizer.html(e)) e = e.substring(r.raw.length), t.push(r); else if (n && (r = this.tokenizer.def(e))) e = e.substring(r.raw.length), this.tokens.links[r.tag] || (this.tokens.links[r.tag] = { href: r.href, title: r.title }); else if (r = this.tokenizer.table(e)) e = e.substring(r.raw.length), t.push(r); else if (r = this.tokenizer.lheading(e)) e = e.substring(r.raw.length), t.push(r); else if (n && (r = this.tokenizer.paragraph(e))) e = e.substring(r.raw.length), t.push(r); else if (r = this.tokenizer.text(e)) e = e.substring(r.raw.length), (a = t[t.length - 1]) && "text" === a.type ? (a.raw += "\n" + r.raw, a.text += "\n" + r.text) : t.push(r); else if (e) { var l = "Infinite loop on byte: " + e.charCodeAt(0); if (this.options.silent) { console.error(l); break } throw new Error(l) } return t }, o.inline = function (e) { var t, n, r, i, o, a, l = e.length; for (t = 0; t < l; t++)switch ((a = e[t]).type) { case "paragraph": case "text": case "heading": a.tokens = [], this.inlineTokens(a.text, a.tokens); break; case "table": for (a.tokens = { header: [], cells: [] }, i = a.header.length, n = 0; n < i; n++)a.tokens.header[n] = [], this.inlineTokens(a.header[n], a.tokens.header[n]); for (i = a.cells.length, n = 0; n < i; n++)for (o = a.cells[n], a.tokens.cells[n] = [], r = 0; r < o.length; r++)a.tokens.cells[n][r] = [], this.inlineTokens(o[r], a.tokens.cells[n][r]); break; case "blockquote": this.inline(a.tokens); break; case "list": for (i = a.items.length, n = 0; n < i; n++)this.inline(a.items[n].tokens) }return e }, o.inlineTokens = function (e, t, n, r) { var i, o; void 0 === t && (t = []), void 0 === n && (n = !1), void 0 === r && (r = !1); var a, l, s, u = e; if (this.tokens.links) { var c = Object.keys(this.tokens.links); if (c.length > 0) for (; null != (a = this.tokenizer.rules.inline.reflinkSearch.exec(u));)c.includes(a[0].slice(a[0].lastIndexOf("[") + 1, -1)) && (u = u.slice(0, a.index) + "[" + K("a", a[0].length - 2) + "]" + u.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex)) } for (; null != (a = this.tokenizer.rules.inline.blockSkip.exec(u));)u = u.slice(0, a.index) + "[" + K("a", a[0].length - 2) + "]" + u.slice(this.tokenizer.rules.inline.blockSkip.lastIndex); for (; null != (a = this.tokenizer.rules.inline.escapedEmSt.exec(u));)u = u.slice(0, a.index) + "++" + u.slice(this.tokenizer.rules.inline.escapedEmSt.lastIndex); for (; e;)if (l || (s = ""), l = !1, i = this.tokenizer.escape(e)) e = e.substring(i.raw.length), t.push(i); else if (i = this.tokenizer.tag(e, n, r)) { e = e.substring(i.raw.length), n = i.inLink, r = i.inRawBlock; var d = t[t.length - 1]; d && "text" === i.type && "text" === d.type ? (d.raw += i.raw, d.text += i.text) : t.push(i) } else if (i = this.tokenizer.link(e)) e = e.substring(i.raw.length), "link" === i.type && (i.tokens = this.inlineTokens(i.text, [], !0, r)), t.push(i); else if (i = this.tokenizer.reflink(e, this.tokens.links)) { e = e.substring(i.raw.length); var h = t[t.length - 1]; "link" === i.type ? (i.tokens = this.inlineTokens(i.text, [], !0, r), t.push(i)) : h && "text" === i.type && "text" === h.type ? (h.raw += i.raw, h.text += i.text) : t.push(i) } else if (i = this.tokenizer.emStrong(e, u, s)) e = e.substring(i.raw.length), i.tokens = this.inlineTokens(i.text, [], n, r), t.push(i); else if (i = this.tokenizer.codespan(e)) e = e.substring(i.raw.length), t.push(i); else if (i = this.tokenizer.br(e)) e = e.substring(i.raw.length), t.push(i); else if (i = this.tokenizer.del(e)) e = e.substring(i.raw.length), i.tokens = this.inlineTokens(i.text, [], n, r), t.push(i); else if (i = this.tokenizer.autolink(e, Z)) e = e.substring(i.raw.length), t.push(i); else if (n || !(i = this.tokenizer.url(e, Z))) { if (i = this.tokenizer.inlineText(e, r, X)) e = e.substring(i.raw.length), "_" !== i.raw.slice(-1) && (s = i.raw.slice(-1)), l = !0, (o = t[t.length - 1]) && "text" === o.type ? (o.raw += i.raw, o.text += i.text) : t.push(i); else if (e) { var f = "Infinite loop on byte: " + e.charCodeAt(0); if (this.options.silent) { console.error(f); break } throw new Error(f) } } else e = e.substring(i.raw.length), t.push(i); return t }, n = t, i = [{ key: "rules", get: function () { return { block: G, inline: V } } }], (r = null) && e(n.prototype, r), i && e(n, i), t }(), Q = r.defaults, J = k, ee = D, te = function () { function e(e) { this.options = e || Q } var t = e.prototype; return t.code = function (e, t, n) { var r = (t || "").match(/\S*/)[0]; if (this.options.highlight) { var i = this.options.highlight(e, r); null != i && i !== e && (n = !0, e = i) } return e = e.replace(/\n$/, "") + "\n", r ? '
    ' + (n ? e : ee(e, !0)) + "
    \n" : "
    " + (n ? e : ee(e, !0)) + "
    \n" }, t.blockquote = function (e) { return "
    \n" + e + "
    \n" }, t.html = function (e) { return e }, t.heading = function (e, t, n, r) { return this.options.headerIds ? "' + e + "\n" : "" + e + "\n" }, t.hr = function () { return this.options.xhtml ? "
    \n" : "
    \n" }, t.list = function (e, t, n) { var r = t ? "ol" : "ul"; return "<" + r + (t && 1 !== n ? ' start="' + n + '"' : "") + ">\n" + e + "\n" }, t.listitem = function (e) { return "
  • " + e + "
  • \n" }, t.checkbox = function (e) { return " " }, t.paragraph = function (e) { return "

    " + e + "

    \n" }, t.table = function (e, t) { return t && (t = "" + t + ""), "\n\n" + e + "\n" + t + "
    \n" }, t.tablerow = function (e) { return "\n" + e + "\n" }, t.tablecell = function (e, t) { var n = t.header ? "th" : "td"; return (t.align ? "<" + n + ' align="' + t.align + '">' : "<" + n + ">") + e + "\n" }, t.strong = function (e) { return "" + e + "" }, t.em = function (e) { return "" + e + "" }, t.codespan = function (e) { return "" + e + "" }, t.br = function () { return this.options.xhtml ? "
    " : "
    " }, t.del = function (e) { return "" + e + "" }, t.link = function (e, t, n) { if (null === (e = J(this.options.sanitize, this.options.baseUrl, e))) return n; var r = '
    " }, t.image = function (e, t, n) { if (null === (e = J(this.options.sanitize, this.options.baseUrl, e))) return n; var r = '' + n + '" : ">" }, t.text = function (e) { return e }, e }(), ne = function () { function e() { } var t = e.prototype; return t.strong = function (e) { return e }, t.em = function (e) { return e }, t.codespan = function (e) { return e }, t.del = function (e) { return e }, t.html = function (e) { return e }, t.text = function (e) { return e }, t.link = function (e, t, n) { return "" + n }, t.image = function (e, t, n) { return "" + n }, t.br = function () { return "" }, e }(), re = function () { function e() { this.seen = {} } var t = e.prototype; return t.serialize = function (e) { return e.toLowerCase().trim().replace(/<[!\/a-z].*?>/gi, "").replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, "").replace(/\s/g, "-") }, t.getNextSafeSlug = function (e, t) { var n = e, r = 0; if (this.seen.hasOwnProperty(n)) { r = this.seen[e]; do { n = e + "-" + ++r } while (this.seen.hasOwnProperty(n)) } return t || (this.seen[e] = r, this.seen[n] = 0), n }, t.slug = function (e, t) { void 0 === t && (t = {}); var n = this.serialize(e); return this.getNextSafeSlug(n, t.dryrun) }, e }(), ie = r.defaults, oe = C, ae = function () { function e(e) { this.options = e || ie, this.options.renderer = this.options.renderer || new te, this.renderer = this.options.renderer, this.renderer.options = this.options, this.textRenderer = new ne, this.slugger = new re } e.parse = function (t, n) { return new e(n).parse(t) }, e.parseInline = function (t, n) { return new e(n).parseInline(t) }; var t = e.prototype; return t.parse = function (e, t) { void 0 === t && (t = !0); var n, r, i, o, a, l, s, u, c, d, h, f, p, m, g, v, x, y, b = "", D = e.length; for (n = 0; n < D; n++)switch ((d = e[n]).type) { case "space": continue; case "hr": b += this.renderer.hr(); continue; case "heading": b += this.renderer.heading(this.parseInline(d.tokens), d.depth, oe(this.parseInline(d.tokens, this.textRenderer)), this.slugger); continue; case "code": b += this.renderer.code(d.text, d.lang, d.escaped); continue; case "table": for (u = "", s = "", o = d.header.length, r = 0; r < o; r++)s += this.renderer.tablecell(this.parseInline(d.tokens.header[r]), { header: !0, align: d.align[r] }); for (u += this.renderer.tablerow(s), c = "", o = d.cells.length, r = 0; r < o; r++) { for (s = "", a = (l = d.tokens.cells[r]).length, i = 0; i < a; i++)s += this.renderer.tablecell(this.parseInline(l[i]), { header: !1, align: d.align[i] }); c += this.renderer.tablerow(s) } b += this.renderer.table(u, c); continue; case "blockquote": c = this.parse(d.tokens), b += this.renderer.blockquote(c); continue; case "list": for (h = d.ordered, f = d.start, p = d.loose, o = d.items.length, c = "", r = 0; r < o; r++)v = (g = d.items[r]).checked, x = g.task, m = "", g.task && (y = this.renderer.checkbox(v), p ? g.tokens.length > 0 && "text" === g.tokens[0].type ? (g.tokens[0].text = y + " " + g.tokens[0].text, g.tokens[0].tokens && g.tokens[0].tokens.length > 0 && "text" === g.tokens[0].tokens[0].type && (g.tokens[0].tokens[0].text = y + " " + g.tokens[0].tokens[0].text)) : g.tokens.unshift({ type: "text", text: y }) : m += y), m += this.parse(g.tokens, p), c += this.renderer.listitem(m, x, v); b += this.renderer.list(c, h, f); continue; case "html": b += this.renderer.html(d.text); continue; case "paragraph": b += this.renderer.paragraph(this.parseInline(d.tokens)); continue; case "text": for (c = d.tokens ? this.parseInline(d.tokens) : d.text; n + 1 < D && "text" === e[n + 1].type;)c += "\n" + ((d = e[++n]).tokens ? this.parseInline(d.tokens) : d.text); b += t ? this.renderer.paragraph(c) : c; continue; default: var C = 'Token with "' + d.type + '" type was not found.'; if (this.options.silent) return void console.error(C); throw new Error(C) }return b }, t.parseInline = function (e, t) { t = t || this.renderer; var n, r, i = "", o = e.length; for (n = 0; n < o; n++)switch ((r = e[n]).type) { case "escape": i += t.text(r.text); break; case "html": i += t.html(r.text); break; case "link": i += t.link(r.href, r.title, this.parseInline(r.tokens, t)); break; case "image": i += t.image(r.href, r.title, r.text); break; case "strong": i += t.strong(this.parseInline(r.tokens, t)); break; case "em": i += t.em(this.parseInline(r.tokens, t)); break; case "codespan": i += t.codespan(r.text); break; case "br": i += t.br(); break; case "del": i += t.del(this.parseInline(r.tokens, t)); break; case "text": i += t.text(r.text); break; default: var a = 'Token with "' + r.type + '" type was not found.'; if (this.options.silent) return void console.error(a); throw new Error(a) }return i }, e }(), le = F, se = L, ue = D, ce = r.getDefaults, de = r.changeDefaults, he = r.defaults; function fe(e, t, n) { if (null == e) throw new Error("marked(): input parameter is undefined or null"); if ("string" != typeof e) throw new Error("marked(): input parameter is of type " + Object.prototype.toString.call(e) + ", string expected"); if ("function" == typeof t && (n = t, t = null), t = le({}, fe.defaults, t || {}), se(t), n) { var r, i = t.highlight; try { r = Y.lex(e, t) } catch (e) { return n(e) } var o = function (e) { var o; if (!e) try { o = ae.parse(r, t) } catch (t) { e = t } return t.highlight = i, e ? n(e) : n(null, o) }; if (!i || i.length < 3) return o(); if (delete t.highlight, !r.length) return o(); var a = 0; return fe.walkTokens(r, (function (e) { "code" === e.type && (a++, setTimeout((function () { i(e.text, e.lang, (function (t, n) { if (t) return o(t); null != n && n !== e.text && (e.text = n, e.escaped = !0), 0 === --a && o() })) }), 0)) })), void (0 === a && o()) } try { var l = Y.lex(e, t); return t.walkTokens && fe.walkTokens(l, t.walkTokens), ae.parse(l, t) } catch (e) { if (e.message += "\nPlease report this to https://github.com/markedjs/marked.", t.silent) return "

    An error occurred:

    " + ue(e.message + "", !0) + "
    "; throw e } } return fe.options = fe.setOptions = function (e) { return le(fe.defaults, e), de(fe.defaults), fe }, fe.getDefaults = ce, fe.defaults = he, fe.use = function (e) { var t = le({}, e); if (e.renderer && function () { var n = fe.defaults.renderer || new te, r = function (t) { var r = n[t]; n[t] = function () { for (var i = arguments.length, o = new Array(i), a = 0; a < i; a++)o[a] = arguments[a]; var l = e.renderer[t].apply(n, o); return !1 === l && (l = r.apply(n, o)), l } }; for (var i in e.renderer) r(i); t.renderer = n }(), e.tokenizer && function () { var n = fe.defaults.tokenizer || new R, r = function (t) { var r = n[t]; n[t] = function () { for (var i = arguments.length, o = new Array(i), a = 0; a < i; a++)o[a] = arguments[a]; var l = e.tokenizer[t].apply(n, o); return !1 === l && (l = r.apply(n, o)), l } }; for (var i in e.tokenizer) r(i); t.tokenizer = n }(), e.walkTokens) { var n = fe.defaults.walkTokens; t.walkTokens = function (t) { e.walkTokens(t), n && n(t) } } fe.setOptions(t) }, fe.walkTokens = function (e, t) { for (var r, i = n(e); !(r = i()).done;) { var o = r.value; switch (t(o), o.type) { case "table": for (var a, l = n(o.tokens.header); !(a = l()).done;) { var s = a.value; fe.walkTokens(s, t) } for (var u, c = n(o.tokens.cells); !(u = c()).done;)for (var d, h = n(u.value); !(d = h()).done;) { var f = d.value; fe.walkTokens(f, t) } break; case "list": fe.walkTokens(o.items, t); break; default: o.tokens && fe.walkTokens(o.tokens, t) } } }, fe.parseInline = function (e, t) { if (null == e) throw new Error("marked.parseInline(): input parameter is undefined or null"); if ("string" != typeof e) throw new Error("marked.parseInline(): input parameter is of type " + Object.prototype.toString.call(e) + ", string expected"); t = le({}, fe.defaults, t || {}), se(t); try { var n = Y.lexInline(e, t); return t.walkTokens && fe.walkTokens(n, t.walkTokens), ae.parseInline(n, t) } catch (e) { if (e.message += "\nPlease report this to https://github.com/markedjs/marked.", t.silent) return "

    An error occurred:

    " + ue(e.message + "", !0) + "
    "; throw e } }, fe.Parser = ae, fe.parser = ae.parse, fe.Renderer = te, fe.TextRenderer = ne, fe.Lexer = Y, fe.lexer = Y.lex, fe.Tokenizer = R, fe.Slugger = re, fe.parse = fe, fe })) }, {}], 16: [function (e, t, n) { (function (n) { (function () { var r; !function () { "use strict"; (r = function (e, t, r, i) { i = i || {}, this.dictionary = null, this.rules = {}, this.dictionaryTable = {}, this.compoundRules = [], this.compoundRuleCodes = {}, this.replacementTable = [], this.flags = i.flags || {}, this.memoized = {}, this.loaded = !1; var o, a, l, s, u, c = this; function d(e, t) { var n = c._readFile(e, null, i.asyncLoad); i.asyncLoad ? n.then((function (e) { t(e) })) : t(n) } function h(e) { t = e, r && p() } function f(e) { r = e, t && p() } function p() { for (c.rules = c._parseAFF(t), c.compoundRuleCodes = {}, a = 0, s = c.compoundRules.length; a < s; a++) { var e = c.compoundRules[a]; for (l = 0, u = e.length; l < u; l++)c.compoundRuleCodes[e[l]] = [] } for (a in "ONLYINCOMPOUND" in c.flags && (c.compoundRuleCodes[c.flags.ONLYINCOMPOUND] = []), c.dictionaryTable = c._parseDIC(r), c.compoundRuleCodes) 0 === c.compoundRuleCodes[a].length && delete c.compoundRuleCodes[a]; for (a = 0, s = c.compoundRules.length; a < s; a++) { var n = c.compoundRules[a], o = ""; for (l = 0, u = n.length; l < u; l++) { var d = n[l]; d in c.compoundRuleCodes ? o += "(" + c.compoundRuleCodes[d].join("|") + ")" : o += d } c.compoundRules[a] = new RegExp(o, "i") } c.loaded = !0, i.asyncLoad && i.loadedCallback && i.loadedCallback(c) } return e && (c.dictionary = e, t && r ? p() : "undefined" != typeof window && "chrome" in window && "extension" in window.chrome && "getURL" in window.chrome.extension ? (o = i.dictionaryPath ? i.dictionaryPath : "typo/dictionaries", t || d(chrome.extension.getURL(o + "/" + e + "/" + e + ".aff"), h), r || d(chrome.extension.getURL(o + "/" + e + "/" + e + ".dic"), f)) : (o = i.dictionaryPath ? i.dictionaryPath : void 0 !== n ? n + "/dictionaries" : "./dictionaries", t || d(o + "/" + e + "/" + e + ".aff", h), r || d(o + "/" + e + "/" + e + ".dic", f))), this }).prototype = { load: function (e) { for (var t in e) e.hasOwnProperty(t) && (this[t] = e[t]); return this }, _readFile: function (t, n, r) { if (n = n || "utf8", "undefined" != typeof XMLHttpRequest) { var i, o = new XMLHttpRequest; return o.open("GET", t, r), r && (i = new Promise((function (e, t) { o.onload = function () { 200 === o.status ? e(o.responseText) : t(o.statusText) }, o.onerror = function () { t(o.statusText) } }))), o.overrideMimeType && o.overrideMimeType("text/plain; charset=" + n), o.send(null), r ? i : o.responseText } if (void 0 !== e) { var a = e("fs"); try { if (a.existsSync(t)) return a.readFileSync(t, n); console.log("Path " + t + " does not exist.") } catch (e) { return console.log(e), "" } } }, _parseAFF: function (e) { var t, n, r, i, o, a, l, s = {}, u = (e = this._removeAffixComments(e)).split(/\r?\n/); for (i = 0, a = u.length; i < a; i++) { var c = (t = u[i]).split(/\s+/), d = c[0]; if ("PFX" == d || "SFX" == d) { var h = c[1], f = c[2], p = []; for (o = i + 1, l = i + 1 + (n = parseInt(c[3], 10)); o < l; o++) { var m = (r = u[o].split(/\s+/))[2], g = r[3].split("/"), v = g[0]; "0" === v && (v = ""); var x = this.parseRuleCodes(g[1]), y = r[4], b = {}; b.add = v, x.length > 0 && (b.continuationClasses = x), "." !== y && (b.match = "SFX" === d ? new RegExp(y + "$") : new RegExp("^" + y)), "0" != m && (b.remove = "SFX" === d ? new RegExp(m + "$") : m), p.push(b) } s[h] = { type: d, combineable: "Y" == f, entries: p }, i += n } else if ("COMPOUNDRULE" === d) { for (o = i + 1, l = i + 1 + (n = parseInt(c[1], 10)); o < l; o++)r = (t = u[o]).split(/\s+/), this.compoundRules.push(r[1]); i += n } else "REP" === d ? 3 === (r = t.split(/\s+/)).length && this.replacementTable.push([r[1], r[2]]) : this.flags[d] = c[1] } return s }, _removeAffixComments: function (e) { return e = (e = (e = (e = e.replace(/^\s*#.*$/gm, "")).replace(/^\s\s*/m, "").replace(/\s\s*$/m, "")).replace(/\n{2,}/g, "\n")).replace(/^\s\s*/, "").replace(/\s\s*$/, "") }, _parseDIC: function (e) { var t = (e = this._removeDicComments(e)).split(/\r?\n/), n = {}; function r(e, t) { n.hasOwnProperty(e) || (n[e] = null), t.length > 0 && (null === n[e] && (n[e] = []), n[e].push(t)) } for (var i = 1, o = t.length; i < o; i++) { var a = t[i]; if (a) { var l = a.split("/", 2), s = l[0]; if (l.length > 1) { var u = this.parseRuleCodes(l[1]); "NEEDAFFIX" in this.flags && -1 != u.indexOf(this.flags.NEEDAFFIX) || r(s, u); for (var c = 0, d = u.length; c < d; c++) { var h = u[c], f = this.rules[h]; if (f) for (var p = this._applyRule(s, f), m = 0, g = p.length; m < g; m++) { var v = p[m]; if (r(v, []), f.combineable) for (var x = c + 1; x < d; x++) { var y = u[x], b = this.rules[y]; if (b && b.combineable && f.type != b.type) for (var D = this._applyRule(v, b), C = 0, w = D.length; C < w; C++) { r(D[C], []) } } } h in this.compoundRuleCodes && this.compoundRuleCodes[h].push(s) } } else r(s.trim(), []) } } return n }, _removeDicComments: function (e) { return e = e.replace(/^\t.*$/gm, "") }, parseRuleCodes: function (e) { if (!e) return []; if (!("FLAG" in this.flags)) return e.split(""); if ("long" === this.flags.FLAG) { for (var t = [], n = 0, r = e.length; n < r; n += 2)t.push(e.substr(n, 2)); return t } return "num" === this.flags.FLAG ? e.split(",") : void 0 }, _applyRule: function (e, t) { for (var n = t.entries, r = [], i = 0, o = n.length; i < o; i++) { var a = n[i]; if (!a.match || e.match(a.match)) { var l = e; if (a.remove && (l = l.replace(a.remove, "")), "SFX" === t.type ? l += a.add : l = a.add + l, r.push(l), "continuationClasses" in a) for (var s = 0, u = a.continuationClasses.length; s < u; s++) { var c = this.rules[a.continuationClasses[s]]; c && (r = r.concat(this._applyRule(l, c))) } } } return r }, check: function (e) { if (!this.loaded) throw "Dictionary not loaded."; var t = e.replace(/^\s\s*/, "").replace(/\s\s*$/, ""); if (this.checkExact(t)) return !0; if (t.toUpperCase() === t) { var n = t[0] + t.substring(1).toLowerCase(); if (this.hasFlag(n, "KEEPCASE")) return !1; if (this.checkExact(n)) return !0; if (this.checkExact(t.toLowerCase())) return !0 } var r = t[0].toLowerCase() + t.substring(1); if (r !== t) { if (this.hasFlag(r, "KEEPCASE")) return !1; if (this.checkExact(r)) return !0 } return !1 }, checkExact: function (e) { if (!this.loaded) throw "Dictionary not loaded."; var t, n, r = this.dictionaryTable[e]; if (void 0 === r) { if ("COMPOUNDMIN" in this.flags && e.length >= this.flags.COMPOUNDMIN) for (t = 0, n = this.compoundRules.length; t < n; t++)if (e.match(this.compoundRules[t])) return !0 } else { if (null === r) return !0; if ("object" == typeof r) for (t = 0, n = r.length; t < n; t++)if (!this.hasFlag(e, "ONLYINCOMPOUND", r[t])) return !0 } return !1 }, hasFlag: function (e, t, n) { if (!this.loaded) throw "Dictionary not loaded."; return !(!(t in this.flags) || (void 0 === n && (n = Array.prototype.concat.apply([], this.dictionaryTable[e])), !n || -1 === n.indexOf(this.flags[t]))) }, alphabet: "", suggest: function (e, t) { if (!this.loaded) throw "Dictionary not loaded."; if (t = t || 5, this.memoized.hasOwnProperty(e)) { var n = this.memoized[e].limit; if (t <= n || this.memoized[e].suggestions.length < n) return this.memoized[e].suggestions.slice(0, t) } if (this.check(e)) return []; for (var r = 0, i = this.replacementTable.length; r < i; r++) { var o = this.replacementTable[r]; if (-1 !== e.indexOf(o[0])) { var a = e.replace(o[0], o[1]); if (this.check(a)) return [a] } } var l = this; function s(e, t) { var n, r, i, o, a = {}, s = l.alphabet.length; if ("string" == typeof e) { var u = e; (e = {})[u] = !0 } for (var u in e) for (n = 0, i = u.length + 1; n < i; n++) { var c = [u.substring(0, n), u.substring(n)]; if (c[1] && (o = c[0] + c[1].substring(1), t && !l.check(o) || (o in a ? a[o] += 1 : a[o] = 1)), c[1].length > 1 && c[1][1] !== c[1][0] && (o = c[0] + c[1][1] + c[1][0] + c[1].substring(2), t && !l.check(o) || (o in a ? a[o] += 1 : a[o] = 1)), c[1]) { var d = c[1].substring(0, 1).toUpperCase() === c[1].substring(0, 1) ? "uppercase" : "lowercase"; for (r = 0; r < s; r++) { var h = l.alphabet[r]; "uppercase" === d && (h = h.toUpperCase()), h != c[1].substring(0, 1) && (o = c[0] + h + c[1].substring(1), t && !l.check(o) || (o in a ? a[o] += 1 : a[o] = 1)) } } if (c[1]) for (r = 0; r < s; r++) { d = c[0].substring(-1).toUpperCase() === c[0].substring(-1) && c[1].substring(0, 1).toUpperCase() === c[1].substring(0, 1) ? "uppercase" : "lowercase", h = l.alphabet[r]; "uppercase" === d && (h = h.toUpperCase()), o = c[0] + h + c[1], t && !l.check(o) || (o in a ? a[o] += 1 : a[o] = 1) } } return a } return l.alphabet = "abcdefghijklmnopqrstuvwxyz", this.memoized[e] = { suggestions: function (e) { var n, r = s(e), i = s(r, !0); for (var o in r) l.check(o) && (o in i ? i[o] += r[o] : i[o] = r[o]); var a = []; for (n in i) i.hasOwnProperty(n) && a.push([n, i[n]]); a.sort((function (e, t) { var n = e[1], r = t[1]; return n < r ? -1 : n > r ? 1 : t[0].localeCompare(e[0]) })).reverse(); var u = [], c = "lowercase"; e.toUpperCase() === e ? c = "uppercase" : e.substr(0, 1).toUpperCase() + e.substr(1).toLowerCase() === e && (c = "capitalized"); var d = t; for (n = 0; n < Math.min(d, a.length); n++)"uppercase" === c ? a[n][0] = a[n][0].toUpperCase() : "capitalized" === c && (a[n][0] = a[n][0].substr(0, 1).toUpperCase() + a[n][0].substr(1)), l.hasFlag(a[n][0], "NOSUGGEST") || -1 != u.indexOf(a[n][0]) ? d++ : u.push(a[n][0]); return u }(e), limit: t }, this.memoized[e].suggestions } } }(), void 0 !== t && (t.exports = r) }).call(this) }).call(this, "/node_modules/typo-js") }, { fs: 1 }], 17: [function (e, t, n) { var r = e("codemirror"); r.commands.tabAndIndentMarkdownList = function (e) { var t = e.listSelections()[0].head; if (!1 !== e.getStateAfter(t.line).list) e.execCommand("indentMore"); else if (e.options.indentWithTabs) e.execCommand("insertTab"); else { var n = Array(e.options.tabSize + 1).join(" "); e.replaceSelection(n) } }, r.commands.shiftTabAndUnindentMarkdownList = function (e) { var t = e.listSelections()[0].head; if (!1 !== e.getStateAfter(t.line).list) e.execCommand("indentLess"); else if (e.options.indentWithTabs) e.execCommand("insertTab"); else { var n = Array(e.options.tabSize + 1).join(" "); e.replaceSelection(n) } } }, { codemirror: 10 }], 18: [function (e, t, n) { "use strict"; var r = e("codemirror"); e("codemirror/addon/edit/continuelist.js"), e("./codemirror/tablist"), e("codemirror/addon/display/fullscreen.js"), e("codemirror/mode/markdown/markdown.js"), e("codemirror/addon/mode/overlay.js"), e("codemirror/addon/display/placeholder.js"), e("codemirror/addon/display/autorefresh.js"), e("codemirror/addon/selection/mark-selection.js"), e("codemirror/addon/search/searchcursor.js"), e("codemirror/mode/gfm/gfm.js"), e("codemirror/mode/xml/xml.js"); var i = e("codemirror-spell-checker"), o = e("marked/lib/marked"), a = /Mac/.test(navigator.platform), l = new RegExp(/()+?/g), s = { toggleBold: C, toggleItalic: w, drawLink: I, toggleHeadingSmaller: A, toggleHeadingBigger: E, drawImage: z, toggleBlockquote: F, toggleOrderedList: N, toggleUnorderedList: B, toggleCodeBlock: S, togglePreview: U, toggleStrikethrough: k, toggleHeading1: T, toggleHeading2: L, toggleHeading3: M, cleanBlock: O, drawTable: P, drawHorizontalRule: _, undo: W, redo: j, toggleSideBySide: q, toggleFullScreen: D }, u = { toggleBold: "Cmd-B", toggleItalic: "Cmd-I", drawLink: "Cmd-K", toggleHeadingSmaller: "Cmd-H", toggleHeadingBigger: "Shift-Cmd-H", cleanBlock: "Cmd-E", drawImage: "Cmd-Alt-I", toggleBlockquote: "Cmd-'", toggleOrderedList: "Cmd-Alt-L", toggleUnorderedList: "Cmd-L", toggleCodeBlock: "Cmd-Alt-C", togglePreview: "Cmd-P", toggleSideBySide: "F9", toggleFullScreen: "F11" }, c = function () { var e, t = !1; return e = navigator.userAgent || navigator.vendor || window.opera, (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(e) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55\/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk\/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i.test(e.substr(0, 4))) && (t = !0), t }; function d(e) { return e = a ? e.replace("Ctrl", "Cmd") : e.replace("Cmd", "Ctrl") } var h = {}; function f(e) { return h[e] || (h[e] = new RegExp("\\s*" + e + "(\\s*)", "g")) } function p(e, t) { if (e && t) { var n = f(t); e.className.match(n) || (e.className += " " + t) } } function m(e, t) { if (e && t) { var n = f(t); e.className.match(n) && (e.className = e.className.replace(n, "$1")) } } function g(e, t, n, r) { var i = v(e, !1, t, n, "button", r); i.className += " easymde-dropdown"; var o = document.createElement("div"); o.className = "easymde-dropdown-content"; for (var a = 0; a < e.children.length; a++) { var l, s = e.children[a]; l = v("string" == typeof s && s in J ? J[s] : s, !0, t, n, "button", r), o.appendChild(l) } return i.appendChild(o), i } function v(e, t, n, r, i, o) { e = e || {}; var l = document.createElement(i); l.className = e.name, l.setAttribute("type", i), n = null == n || n, e.name && e.name in r && (s[e.name] = e.action), e.title && n && (l.title = function (e, t, n) { var r, i = e; t && n[r = function (e) { for (var t in s) if (s[t] === e) return t; return null }(t)] && (i += " (" + d(n[r]) + ")"); return i }(e.title, e.action, r), a && (l.title = l.title.replace("Ctrl", "⌘"), l.title = l.title.replace("Alt", "⌥"))), e.noDisable && l.classList.add("no-disable"), e.noMobile && l.classList.add("no-mobile"); var u = []; void 0 !== e.className && (u = e.className.split(" ")); for (var c = [], h = 0; h < u.length; h++) { var f = u[h]; f.match(/^fa([srlb]|(-[\w-]*)|$)/) ? c.push(f) : l.classList.add(f) } l.tabIndex = -1; for (var p = document.createElement("i"), m = 0; m < c.length; m++) { var g = c[m]; p.classList.add(g) } return l.appendChild(p), void 0 !== e.icon && (l.innerHTML = e.icon), e.action && t && ("function" == typeof e.action ? l.onclick = function (t) { t.preventDefault(), e.action(o) } : "string" == typeof e.action && (l.onclick = function (t) { t.preventDefault(), window.open(e.action, "_blank") })), l } function x() { var e = document.createElement("i"); return e.className = "separator", e.innerHTML = "|", e } function y(e, t) { t = t || e.getCursor("start"); var n = e.getTokenAt(t); if (!n.type) return {}; for (var r, i, o = n.type.split(" "), a = {}, l = 0; l < o.length; l++)"strong" === (r = o[l]) ? a.bold = !0 : "variable-2" === r ? (i = e.getLine(t.line), /^\s*\d+\.\s/.test(i) ? a["ordered-list"] = !0 : a["unordered-list"] = !0) : "atom" === r ? a.quote = !0 : "em" === r ? a.italic = !0 : "quote" === r ? a.quote = !0 : "strikethrough" === r ? a.strikethrough = !0 : "comment" === r ? a.code = !0 : "link" === r ? a.link = !0 : "tag" === r ? a.image = !0 : r.match(/^header(-[1-6])?$/) && (a[r.replace("header", "heading")] = !0); return a } var b = ""; function D(e) { var t = e.codemirror; t.setOption("fullScreen", !t.getOption("fullScreen")), t.getOption("fullScreen") ? (b = document.body.style.overflow, document.body.style.overflow = "hidden") : document.body.style.overflow = b; var n = t.getWrapperElement(), r = n.nextSibling; if (/editor-preview-active-side/.test(r.className)) if (!1 === e.options.sideBySideFullscreen) { var i = n.parentNode; t.getOption("fullScreen") ? m(i, "sided--no-fullscreen") : p(i, "sided--no-fullscreen") } else q(e); if (e.options.onToggleFullScreen && e.options.onToggleFullScreen(t.getOption("fullScreen") || !1), void 0 !== e.options.maxHeight && (t.getOption("fullScreen") ? (t.getScrollerElement().style.removeProperty("height"), r.style.removeProperty("height")) : (t.getScrollerElement().style.height = e.options.maxHeight, e.setPreviewMaxHeight())), /fullscreen/.test(e.toolbar_div.className) ? e.toolbar_div.className = e.toolbar_div.className.replace(/\s*fullscreen\b/, "") : e.toolbar_div.className += " fullscreen", e.toolbarElements && e.toolbarElements.fullscreen) { var o = e.toolbarElements.fullscreen; /active/.test(o.className) ? o.className = o.className.replace(/\s*active\s*/g, "") : o.className += " active" } } function C(e) { K(e, "bold", e.options.blockStyles.bold) } function w(e) { K(e, "italic", e.options.blockStyles.italic) } function k(e) { K(e, "strikethrough", "~~") } function S(e) { var t = e.options.blockStyles.code; function n(e) { if ("object" != typeof e) throw "fencing_line() takes a 'line' object (not a line number, or line text). Got: " + typeof e + ": " + e; return e.styles && e.styles[2] && -1 !== e.styles[2].indexOf("formatting-code-block") } function r(e) { return e.state.base.base || e.state.base } function i(e, t, i, o, a) { i = i || e.getLineHandle(t), o = o || e.getTokenAt({ line: t, ch: 1 }), a = a || !!i.text && e.getTokenAt({ line: t, ch: i.text.length - 1 }); var l = o.type ? o.type.split(" ") : []; return a && r(a).indentedCode ? "indented" : -1 !== l.indexOf("comment") && (r(o).fencedChars || r(a).fencedChars || n(i) ? "fenced" : "single") } var o, a, l, s = e.codemirror, u = s.getCursor("start"), c = s.getCursor("end"), d = s.getTokenAt({ line: u.line, ch: u.ch || 1 }), h = s.getLineHandle(u.line), f = i(s, u.line, h, d); if ("single" === f) { var p = h.text.slice(0, u.ch).replace("`", ""), m = h.text.slice(u.ch).replace("`", ""); s.replaceRange(p + m, { line: u.line, ch: 0 }, { line: u.line, ch: 99999999999999 }), u.ch--, u !== c && c.ch--, s.setSelection(u, c), s.focus() } else if ("fenced" === f) if (u.line !== c.line || u.ch !== c.ch) { for (o = u.line; o >= 0 && !n(h = s.getLineHandle(o)); o--); var g, v, x, y, b = r(s.getTokenAt({ line: o, ch: 1 })).fencedChars; n(s.getLineHandle(u.line)) ? (g = "", v = u.line) : n(s.getLineHandle(u.line - 1)) ? (g = "", v = u.line - 1) : (g = b + "\n", v = u.line), n(s.getLineHandle(c.line)) ? (x = "", y = c.line, 0 === c.ch && (y += 1)) : 0 !== c.ch && n(s.getLineHandle(c.line + 1)) ? (x = "", y = c.line + 1) : (x = b + "\n", y = c.line + 1), 0 === c.ch && (y -= 1), s.operation((function () { s.replaceRange(x, { line: y, ch: 0 }, { line: y + (x ? 0 : 1), ch: 0 }), s.replaceRange(g, { line: v, ch: 0 }, { line: v + (g ? 0 : 1), ch: 0 }) })), s.setSelection({ line: v + (g ? 1 : 0), ch: 0 }, { line: y + (g ? 1 : -1), ch: 0 }), s.focus() } else { var D = u.line; if (n(s.getLineHandle(u.line)) && ("fenced" === i(s, u.line + 1) ? (o = u.line, D = u.line + 1) : (a = u.line, D = u.line - 1)), void 0 === o) for (o = D; o >= 0 && !n(h = s.getLineHandle(o)); o--); if (void 0 === a) for (l = s.lineCount(), a = D; a < l && !n(h = s.getLineHandle(a)); a++); s.operation((function () { s.replaceRange("", { line: o, ch: 0 }, { line: o + 1, ch: 0 }), s.replaceRange("", { line: a - 1, ch: 0 }, { line: a, ch: 0 }) })), s.focus() } else if ("indented" === f) { if (u.line !== c.line || u.ch !== c.ch) o = u.line, a = c.line, 0 === c.ch && a--; else { for (o = u.line; o >= 0; o--)if (!(h = s.getLineHandle(o)).text.match(/^\s*$/) && "indented" !== i(s, o, h)) { o += 1; break } for (l = s.lineCount(), a = u.line; a < l; a++)if (!(h = s.getLineHandle(a)).text.match(/^\s*$/) && "indented" !== i(s, a, h)) { a -= 1; break } } var C = s.getLineHandle(a + 1), w = C && s.getTokenAt({ line: a + 1, ch: C.text.length - 1 }); w && r(w).indentedCode && s.replaceRange("\n", { line: a + 1, ch: 0 }); for (var k = o; k <= a; k++)s.indentLine(k, "subtract"); s.focus() } else { var S = u.line === c.line && u.ch === c.ch && 0 === u.ch, F = u.line !== c.line; S || F ? function (e, t, n, r) { var i = t.line + 1, o = n.line + 1, a = t.line !== n.line, l = r + "\n", s = "\n" + r; a && o++, a && 0 === n.ch && (s = r + "\n", o--), $(e, !1, [l, s]), e.setSelection({ line: i, ch: 0 }, { line: o, ch: 0 }) }(s, u, c, t) : $(s, !1, ["`", "`"]) } } function F(e) { V(e.codemirror, "quote") } function A(e) { G(e.codemirror, "smaller") } function E(e) { G(e.codemirror, "bigger") } function T(e) { G(e.codemirror, void 0, 1) } function L(e) { G(e.codemirror, void 0, 2) } function M(e) { G(e.codemirror, void 0, 3) } function B(e) { V(e.codemirror, "unordered-list") } function N(e) { V(e.codemirror, "ordered-list") } function O(e) { !function (e) { if (/editor-preview-active/.test(e.getWrapperElement().lastChild.className)) return; for (var t, n = e.getCursor("start"), r = e.getCursor("end"), i = n.line; i <= r.line; i++)t = (t = e.getLine(i)).replace(/^[ ]*([# ]+|\*|-|[> ]+|[0-9]+(.|\)))[ ]*/, ""), e.replaceRange(t, { line: i, ch: 0 }, { line: i, ch: 99999999999999 }) }(e.codemirror) } function I(e) { var t = e.codemirror, n = y(t), r = e.options, i = "https://"; if (r.promptURLs && !(i = prompt(r.promptTexts.link, "https://"))) return !1; $(t, n.link, r.insertTexts.link, i) } function z(e) { var t = e.codemirror, n = y(t), r = e.options, i = "https://"; if (r.promptURLs && !(i = prompt(r.promptTexts.image, "https://"))) return !1; $(t, n.image, r.insertTexts.image, i) } function H(e) { e.openBrowseFileWindow() } function R(e, t) { var n = e.codemirror, r = y(n), i = e.options, o = t.substr(t.lastIndexOf("/") + 1), a = o.substring(o.lastIndexOf(".") + 1).replace(/\?.*$/, ""); if (["png", "jpg", "jpeg", "gif", "svg"].includes(a)) $(n, r.image, i.insertTexts.uploadedImage, t); else { var l = i.insertTexts.link; l[0] = "[" + o, $(n, r.link, l, t) } e.updateStatusBar("upload-image", e.options.imageTexts.sbOnUploaded.replace("#image_name#", o)), setTimeout((function () { e.updateStatusBar("upload-image", e.options.imageTexts.sbInit) }), 1e3) } function P(e) { var t = e.codemirror, n = y(t), r = e.options; $(t, n.table, r.insertTexts.table) } function _(e) { var t = e.codemirror, n = y(t), r = e.options; $(t, n.image, r.insertTexts.horizontalRule) } function W(e) { var t = e.codemirror; t.undo(), t.focus() } function j(e) { var t = e.codemirror; t.redo(), t.focus() } function q(e) { var t = e.codemirror, n = t.getWrapperElement(), r = n.nextSibling, i = e.toolbarElements && e.toolbarElements["side-by-side"], o = !1, a = n.parentNode; /editor-preview-active-side/.test(r.className) ? (!1 === e.options.sideBySideFullscreen && m(a, "sided--no-fullscreen"), r.className = r.className.replace(/\s*editor-preview-active-side\s*/g, ""), i && (i.className = i.className.replace(/\s*active\s*/g, "")), n.className = n.className.replace(/\s*CodeMirror-sided\s*/g, " ")) : (setTimeout((function () { t.getOption("fullScreen") || (!1 === e.options.sideBySideFullscreen ? p(a, "sided--no-fullscreen") : D(e)), r.className += " editor-preview-active-side" }), 1), i && (i.className += " active"), n.className += " CodeMirror-sided", o = !0); var l = n.lastChild; if (/editor-preview-active/.test(l.className)) { l.className = l.className.replace(/\s*editor-preview-active\s*/g, ""); var s = e.toolbarElements.preview, u = e.toolbar_div; s.className = s.className.replace(/\s*active\s*/g, ""), u.className = u.className.replace(/\s*disabled-for-preview*/g, "") } if (t.sideBySideRenderingFunction || (t.sideBySideRenderingFunction = function () { var t = e.options.previewRender(e.value(), r); null != t && (r.innerHTML = t) }), o) { var c = e.options.previewRender(e.value(), r); null != c && (r.innerHTML = c), t.on("update", t.sideBySideRenderingFunction) } else t.off("update", t.sideBySideRenderingFunction); t.refresh() } function U(e) { var t = e.codemirror, n = t.getWrapperElement(), r = e.toolbar_div, i = !!e.options.toolbar && e.toolbarElements.preview, o = n.lastChild, a = t.getWrapperElement().nextSibling; if (/editor-preview-active-side/.test(a.className) && q(e), !o || !/editor-preview-full/.test(o.className)) { if ((o = document.createElement("div")).className = "editor-preview-full", e.options.previewClass) if (Array.isArray(e.options.previewClass)) for (var l = 0; l < e.options.previewClass.length; l++)o.className += " " + e.options.previewClass[l]; else "string" == typeof e.options.previewClass && (o.className += " " + e.options.previewClass); n.appendChild(o) } /editor-preview-active/.test(o.className) ? (o.className = o.className.replace(/\s*editor-preview-active\s*/g, ""), i && (i.className = i.className.replace(/\s*active\s*/g, ""), r.className = r.className.replace(/\s*disabled-for-preview*/g, ""))) : (setTimeout((function () { o.className += " editor-preview-active" }), 1), i && (i.className += " active", r.className += " disabled-for-preview")), o.innerHTML = e.options.previewRender(e.value(), o) } function $(e, t, n, r) { if (!/editor-preview-active/.test(e.getWrapperElement().lastChild.className)) { var i, o = n[0], a = n[1], l = {}, s = {}; Object.assign(l, e.getCursor("start")), Object.assign(s, e.getCursor("end")), r && (o = o.replace("#url#", r), a = a.replace("#url#", r)), t ? (o = (i = e.getLine(l.line)).slice(0, l.ch), a = i.slice(l.ch), e.replaceRange(o + a, { line: l.line, ch: 0 })) : (i = e.getSelection(), e.replaceSelection(o + i + a), l.ch += o.length, l !== s && (s.ch += o.length)), e.setSelection(l, s), e.focus() } } function G(e, t, n) { if (!/editor-preview-active/.test(e.getWrapperElement().lastChild.className)) { for (var r = e.getCursor("start"), i = e.getCursor("end"), o = r.line; o <= i.line; o++)!function (r) { var i = e.getLine(r), o = i.search(/[^#]/); i = void 0 !== t ? o <= 0 ? "bigger" == t ? "###### " + i : "# " + i : 6 == o && "smaller" == t ? i.substr(7) : 1 == o && "bigger" == t ? i.substr(2) : "bigger" == t ? i.substr(1) : "#" + i : 1 == n ? o <= 0 ? "# " + i : o == n ? i.substr(o + 1) : "# " + i.substr(o + 1) : 2 == n ? o <= 0 ? "## " + i : o == n ? i.substr(o + 1) : "## " + i.substr(o + 1) : o <= 0 ? "### " + i : o == n ? i.substr(o + 1) : "### " + i.substr(o + 1), e.replaceRange(i, { line: r, ch: 0 }, { line: r, ch: 99999999999999 }) }(o); e.focus() } } function V(e, t) { if (!/editor-preview-active/.test(e.getWrapperElement().lastChild.className)) { for (var n = /^(\s*)(\*|-|\+|\d*\.)(\s+)/, r = /^\s*/, i = y(e), o = e.getCursor("start"), a = e.getCursor("end"), l = { quote: /^(\s*)>\s+/, "unordered-list": n, "ordered-list": n }, s = function (e, t, i) { var o = n.exec(t), a = function (e, t) { return { quote: ">", "unordered-list": "*", "ordered-list": "%%i." }[e].replace("%%i", t) }(e, u); return null !== o ? (function (e, t) { var n = new RegExp({ quote: ">", "unordered-list": "*", "ordered-list": "\\d+." }[e]); return t && n.test(t) }(e, o[2]) && (a = ""), t = o[1] + a + o[3] + t.replace(r, "").replace(l[e], "$1")) : 0 == i && (t = a + " " + t), t }, u = 1, c = o.line; c <= a.line; c++)!function (n) { var r = e.getLine(n); i[t] ? r = r.replace(l[t], "$1") : ("unordered-list" == t && (r = s("ordered-list", r, !0)), r = s(t, r, !1), u += 1), e.replaceRange(r, { line: n, ch: 0 }, { line: n, ch: 99999999999999 }) }(c); e.focus() } } function K(e, t, n, r) { if (!/editor-preview-active/.test(e.codemirror.getWrapperElement().lastChild.className)) { r = void 0 === r ? n : r; var i, o = e.codemirror, a = y(o), l = n, s = r, u = o.getCursor("start"), c = o.getCursor("end"); a[t] ? (l = (i = o.getLine(u.line)).slice(0, u.ch), s = i.slice(u.ch), "bold" == t ? (l = l.replace(/(\*\*|__)(?![\s\S]*(\*\*|__))/, ""), s = s.replace(/(\*\*|__)/, "")) : "italic" == t ? (l = l.replace(/(\*|_)(?![\s\S]*(\*|_))/, ""), s = s.replace(/(\*|_)/, "")) : "strikethrough" == t && (l = l.replace(/(\*\*|~~)(?![\s\S]*(\*\*|~~))/, ""), s = s.replace(/(\*\*|~~)/, "")), o.replaceRange(l + s, { line: u.line, ch: 0 }, { line: u.line, ch: 99999999999999 }), "bold" == t || "strikethrough" == t ? (u.ch -= 2, u !== c && (c.ch -= 2)) : "italic" == t && (u.ch -= 1, u !== c && (c.ch -= 1))) : (i = o.getSelection(), "bold" == t ? i = (i = i.split("**").join("")).split("__").join("") : "italic" == t ? i = (i = i.split("*").join("")).split("_").join("") : "strikethrough" == t && (i = i.split("~~").join("")), o.replaceSelection(l + i + s), u.ch += n.length, c.ch = u.ch + i.length), o.setSelection(u, c), o.focus() } } function X(e, t) { if (Math.abs(e) < 1024) return "" + e + t[0]; var n = 0; do { e /= 1024, ++n } while (Math.abs(e) >= 1024 && n < t.length); return "" + e.toFixed(1) + t[n] } function Z(e, t) { for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && (t[n] instanceof Array ? e[n] = t[n].concat(e[n] instanceof Array ? e[n] : []) : null !== t[n] && "object" == typeof t[n] && t[n].constructor === Object ? e[n] = Z(e[n] || {}, t[n]) : e[n] = t[n]); return e } function Y(e) { for (var t = 1; t < arguments.length; t++)e = Z(e, arguments[t]); return e } function Q(e) { var t = e.match(/[a-zA-Z0-9_\u00A0-\u02AF\u0392-\u03c9\u0410-\u04F9]+|[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af]+/g), n = 0; if (null === t) return n; for (var r = 0; r < t.length; r++)t[r].charCodeAt(0) >= 19968 ? n += t[r].length : n += 1; return n } var J = { bold: { name: "bold", action: C, className: "fa fa-bold", title: "Bold", default: !0 }, italic: { name: "italic", action: w, className: "fa fa-italic", title: "Italic", default: !0 }, strikethrough: { name: "strikethrough", action: k, className: "fa fa-strikethrough", title: "Strikethrough" }, heading: { name: "heading", action: A, className: "fa fa-header fa-heading", title: "Heading", default: !0 }, "heading-smaller": { name: "heading-smaller", action: A, className: "fa fa-header fa-heading header-smaller", title: "Smaller Heading" }, "heading-bigger": { name: "heading-bigger", action: E, className: "fa fa-header fa-heading header-bigger", title: "Bigger Heading" }, "heading-1": { name: "heading-1", action: T, className: "fa fa-header fa-heading header-1", title: "Big Heading" }, "heading-2": { name: "heading-2", action: L, className: "fa fa-header fa-heading header-2", title: "Medium Heading" }, "heading-3": { name: "heading-3", action: M, className: "fa fa-header fa-heading header-3", title: "Small Heading" }, "separator-1": { name: "separator-1" }, code: { name: "code", action: S, className: "fa fa-code", title: "Code" }, quote: { name: "quote", action: F, className: "fa fa-quote-left", title: "Quote", default: !0 }, "unordered-list": { name: "unordered-list", action: B, className: "fa fa-list-ul", title: "Generic List", default: !0 }, "ordered-list": { name: "ordered-list", action: N, className: "fa fa-list-ol", title: "Numbered List", default: !0 }, "clean-block": { name: "clean-block", action: O, className: "fa fa-eraser", title: "Clean block" }, "separator-2": { name: "separator-2" }, link: { name: "link", action: I, className: "fa fa-link", title: "Create Link", default: !0 }, image: { name: "image", action: z, className: "fa fa-image", title: "Insert Image", default: !0 }, "upload-image": { name: "upload-image", action: H, className: "fa fa-image", title: "Import an image" }, table: { name: "table", action: P, className: "fa fa-table", title: "Insert Table" }, "horizontal-rule": { name: "horizontal-rule", action: _, className: "fa fa-minus", title: "Insert Horizontal Line" }, "separator-3": { name: "separator-3" }, preview: { name: "preview", action: U, className: "fa fa-eye", noDisable: !0, title: "Toggle Preview", default: !0 }, "side-by-side": { name: "side-by-side", action: q, className: "fa fa-columns", noDisable: !0, noMobile: !0, title: "Toggle Side by Side", default: !0 }, fullscreen: { name: "fullscreen", action: D, className: "fa fa-arrows-alt", noDisable: !0, noMobile: !0, title: "Toggle Fullscreen", default: !0 }, "separator-4": { name: "separator-4" }, guide: { name: "guide", action: "https://www.markdownguide.org/basic-syntax/", className: "fa fa-question-circle", noDisable: !0, title: "Markdown Guide", default: !0 }, "separator-5": { name: "separator-5" }, undo: { name: "undo", action: W, className: "fa fa-undo", noDisable: !0, title: "Undo" }, redo: { name: "redo", action: j, className: "fa fa-repeat fa-redo", noDisable: !0, title: "Redo" } }, ee = { link: ["[", "](#url#)"], image: ["![](", "#url#)"], uploadedImage: ["![](#url#)", ""], table: ["", "\n\n| Column 1 | Column 2 | Column 3 |\n| -------- | -------- | -------- |\n| Text | Text | Text |\n\n"], horizontalRule: ["", "\n\n-----\n\n"] }, te = { link: "URL for the link:", image: "URL of the image:" }, ne = { locale: "en-US", format: { hour: "2-digit", minute: "2-digit" } }, re = { bold: "**", code: "```", italic: "*" }, ie = { sbInit: "Attach files by drag and dropping or pasting from clipboard.", sbOnDragEnter: "Drop image to upload it.", sbOnDrop: "Uploading image #images_names#...", sbProgress: "Uploading #file_name#: #progress#%", sbOnUploaded: "Uploaded #image_name#", sizeUnits: " B, KB, MB" }, oe = { noFileGiven: "You must select a file.", typeNotAllowed: "This image type is not allowed.", fileTooLarge: "Image #image_name# is too big (#image_size#).\nMaximum file size is #image_max_size#.", importError: "Something went wrong when uploading the image #image_name#." }; function ae(e) { (e = e || {}).parent = this; var t = !0; if (!1 === e.autoDownloadFontAwesome && (t = !1), !0 !== e.autoDownloadFontAwesome) for (var n = document.styleSheets, r = 0; r < n.length; r++)n[r].href && n[r].href.indexOf("//maxcdn.bootstrapcdn.com/font-awesome/") > -1 && (t = !1); if (t) { var i = document.createElement("link"); i.rel = "stylesheet", i.href = "https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css", document.getElementsByTagName("head")[0].appendChild(i) } if (e.element) this.element = e.element; else if (null === e.element) return void console.log("EasyMDE: Error. No element was found."); if (void 0 === e.toolbar) for (var o in e.toolbar = [], J) Object.prototype.hasOwnProperty.call(J, o) && (-1 != o.indexOf("separator-") && e.toolbar.push("|"), (!0 === J[o].default || e.showIcons && e.showIcons.constructor === Array && -1 != e.showIcons.indexOf(o)) && e.toolbar.push(o)); if (Object.prototype.hasOwnProperty.call(e, "previewClass") || (e.previewClass = "editor-preview"), Object.prototype.hasOwnProperty.call(e, "status") || (e.status = ["autosave", "lines", "words", "cursor"], e.uploadImage && e.status.unshift("upload-image")), e.previewRender || (e.previewRender = function (e) { return this.parent.markdown(e) }), e.parsingConfig = Y({ highlightFormatting: !0 }, e.parsingConfig || {}), e.insertTexts = Y({}, ee, e.insertTexts || {}), e.promptTexts = Y({}, te, e.promptTexts || {}), e.blockStyles = Y({}, re, e.blockStyles || {}), null != e.autosave && (e.autosave.timeFormat = Y({}, ne, e.autosave.timeFormat || {})), e.shortcuts = Y({}, u, e.shortcuts || {}), e.maxHeight = e.maxHeight || void 0, void 0 !== e.maxHeight ? e.minHeight = e.maxHeight : e.minHeight = e.minHeight || "300px", e.errorCallback = e.errorCallback || function (e) { alert(e) }, e.uploadImage = e.uploadImage || !1, e.imageMaxSize = e.imageMaxSize || 2097152, e.imageAccept = e.imageAccept || "image/png, image/jpeg", e.imageTexts = Y({}, ie, e.imageTexts || {}), e.errorMessages = Y({}, oe, e.errorMessages || {}), null != e.autosave && null != e.autosave.unique_id && "" != e.autosave.unique_id && (e.autosave.uniqueId = e.autosave.unique_id), e.overlayMode && void 0 === e.overlayMode.combine && (e.overlayMode.combine = !0), this.options = e, this.render(), !e.initialValue || this.options.autosave && !0 === this.options.autosave.foundSavedValue || this.value(e.initialValue), e.uploadImage) { var a = this; this.codemirror.on("dragenter", (function (e, t) { a.updateStatusBar("upload-image", a.options.imageTexts.sbOnDragEnter), t.stopPropagation(), t.preventDefault() })), this.codemirror.on("dragend", (function (e, t) { a.updateStatusBar("upload-image", a.options.imageTexts.sbInit), t.stopPropagation(), t.preventDefault() })), this.codemirror.on("dragleave", (function (e, t) { a.updateStatusBar("upload-image", a.options.imageTexts.sbInit), t.stopPropagation(), t.preventDefault() })), this.codemirror.on("dragover", (function (e, t) { a.updateStatusBar("upload-image", a.options.imageTexts.sbOnDragEnter), t.stopPropagation(), t.preventDefault() })), this.codemirror.on("drop", (function (t, n) { n.stopPropagation(), n.preventDefault(), e.imageUploadFunction ? a.uploadImagesUsingCustomFunction(e.imageUploadFunction, n.dataTransfer.files) : a.uploadImages(n.dataTransfer.files) })), this.codemirror.on("paste", (function (t, n) { e.imageUploadFunction ? a.uploadImagesUsingCustomFunction(e.imageUploadFunction, n.clipboardData.files) : a.uploadImages(n.clipboardData.files) })) } } function le() { if ("object" != typeof localStorage) return !1; try { localStorage.setItem("smde_localStorage", 1), localStorage.removeItem("smde_localStorage") } catch (e) { return !1 } return !0 } ae.prototype.uploadImages = function (e, t, n) { if (0 !== e.length) { for (var r = [], i = 0; i < e.length; i++)r.push(e[i].name), this.uploadImage(e[i], t, n); this.updateStatusBar("upload-image", this.options.imageTexts.sbOnDrop.replace("#images_names#", r.join(", "))) } }, ae.prototype.uploadImagesUsingCustomFunction = function (e, t) { if (0 !== t.length) { for (var n = [], r = 0; r < t.length; r++)n.push(t[r].name), this.uploadImageUsingCustomFunction(e, t[r]); this.updateStatusBar("upload-image", this.options.imageTexts.sbOnDrop.replace("#images_names#", n.join(", "))) } }, ae.prototype.updateStatusBar = function (e, t) { if (this.gui.statusbar) { var n = this.gui.statusbar.getElementsByClassName(e); 1 === n.length ? this.gui.statusbar.getElementsByClassName(e)[0].textContent = t : 0 === n.length ? console.log("EasyMDE: status bar item " + e + " was not found.") : console.log("EasyMDE: Several status bar items named " + e + " was found.") } }, ae.prototype.markdown = function (e) { if (o) { var t; if (t = this.options && this.options.renderingConfig && this.options.renderingConfig.markedOptions ? this.options.renderingConfig.markedOptions : {}, this.options && this.options.renderingConfig && !1 === this.options.renderingConfig.singleLineBreaks ? t.breaks = !1 : t.breaks = !0, this.options && this.options.renderingConfig && !0 === this.options.renderingConfig.codeSyntaxHighlighting) { var n = this.options.renderingConfig.hljs || window.hljs; n && (t.highlight = function (e, t) { return t && n.getLanguage(t) ? n.highlight(t, e).value : n.highlightAuto(e).value }) } o.setOptions(t); var r = o(e); return this.options.renderingConfig && "function" == typeof this.options.renderingConfig.sanitizerFunction && (r = this.options.renderingConfig.sanitizerFunction.call(this, r)), r = function (e) { for (var t = (new DOMParser).parseFromString(e, "text/html"), n = t.getElementsByTagName("li"), r = 0; r < n.length; r++)for (var i = n[r], o = 0; o < i.children.length; o++) { var a = i.children[o]; a instanceof HTMLInputElement && "checkbox" === a.type && (i.style.marginLeft = "-1.5em", i.style.listStyleType = "none") } return t.documentElement.innerHTML }(r = function (e) { for (var t; null !== (t = l.exec(e));) { var n = t[0]; if (-1 === n.indexOf("target=")) { var r = n.replace(/>$/, ' target="_blank">'); e = e.replace(n, r) } } return e }(r)) } }, ae.prototype.render = function (e) { if (e || (e = this.element || document.getElementsByTagName("textarea")[0]), !this._rendered || this._rendered !== e) { this.element = e; var t, n, o = this.options, a = this, l = {}; for (var u in o.shortcuts) null !== o.shortcuts[u] && null !== s[u] && function (e) { l[d(o.shortcuts[e])] = function () { var t = s[e]; "function" == typeof t ? t(a) : "string" == typeof t && window.open(t, "_blank") } }(u); if (l.Enter = "newlineAndIndentContinueMarkdownList", l.Tab = "tabAndIndentMarkdownList", l["Shift-Tab"] = "shiftTabAndUnindentMarkdownList", l.Esc = function (e) { e.getOption("fullScreen") && D(a) }, this.documentOnKeyDown = function (e) { 27 == (e = e || window.event).keyCode && a.codemirror.getOption("fullScreen") && D(a) }, document.addEventListener("keydown", this.documentOnKeyDown, !1), o.overlayMode ? (r.defineMode("overlay-mode", (function (e) { return r.overlayMode(r.getMode(e, !1 !== o.spellChecker ? "spell-checker" : "gfm"), o.overlayMode.mode, o.overlayMode.combine) })), t = "overlay-mode", (n = o.parsingConfig).gitHubSpice = !1) : ((t = o.parsingConfig).name = "gfm", t.gitHubSpice = !1), !1 !== o.spellChecker && (t = "spell-checker", (n = o.parsingConfig).name = "gfm", n.gitHubSpice = !1, i({ codeMirrorInstance: r })), this.codemirror = r.fromTextArea(e, { mode: t, backdrop: n, theme: null != o.theme ? o.theme : "easymde", tabSize: null != o.tabSize ? o.tabSize : 2, indentUnit: null != o.tabSize ? o.tabSize : 2, indentWithTabs: !1 !== o.indentWithTabs, lineNumbers: !0 === o.lineNumbers, autofocus: !0 === o.autofocus, extraKeys: l, lineWrapping: !1 !== o.lineWrapping, allowDropFileTypes: ["text/plain"], placeholder: o.placeholder || e.getAttribute("placeholder") || "", styleSelectedText: null != o.styleSelectedText ? o.styleSelectedText : !c(), scrollbarStyle: null != o.scrollbarStyle ? o.scrollbarStyle : "native", configureMouse: function (e, t, n) { return { addNew: !1 } }, inputStyle: null != o.inputStyle ? o.inputStyle : c() ? "contenteditable" : "textarea", spellcheck: null == o.nativeSpellcheck || o.nativeSpellcheck, autoRefresh: null != o.autoRefresh && o.autoRefresh }), this.codemirror.getScrollerElement().style.minHeight = o.minHeight, void 0 !== o.maxHeight && (this.codemirror.getScrollerElement().style.height = o.maxHeight), !0 === o.forceSync) { var h = this.codemirror; h.on("change", (function () { h.save() })) } this.gui = {}; var f = document.createElement("div"); f.classList.add("EasyMDEContainer"); var p = this.codemirror.getWrapperElement(); p.parentNode.insertBefore(f, p), f.appendChild(p), !1 !== o.toolbar && (this.gui.toolbar = this.createToolbar()), !1 !== o.status && (this.gui.statusbar = this.createStatusbar()), null != o.autosave && !0 === o.autosave.enabled && (this.autosave(), this.codemirror.on("change", (function () { clearTimeout(a._autosave_timeout), a._autosave_timeout = setTimeout((function () { a.autosave() }), a.options.autosave.submit_delay || a.options.autosave.delay || 1e3) }))); var m = this; this.codemirror.on("update", (function () { o.previewImagesInEditor && f.querySelectorAll(".cm-image-marker").forEach((function (e) { var t = e.parentElement; if (t.innerText.match(/^!\[.*?\]\(.*\)/g) && !t.hasAttribute("data-img-src")) { var n = t.innerText.match("\\((.*)\\)"); if (window.EMDEimagesCache || (window.EMDEimagesCache = {}), n && n.length >= 2) { var r = n[1]; if (window.EMDEimagesCache[r]) v(t, window.EMDEimagesCache[r]); else { var i = document.createElement("img"); i.onload = function () { window.EMDEimagesCache[r] = { naturalWidth: i.naturalWidth, naturalHeight: i.naturalHeight, url: r }, v(t, window.EMDEimagesCache[r]) }, i.src = r } } } })) })), this.gui.sideBySide = this.createSideBySide(), this._rendered = this.element; var g = this.codemirror; setTimeout(function () { g.refresh() }.bind(g), 0) } function v(e, t) { var n, r; e.setAttribute("data-img-src", t.url), e.setAttribute("style", "--bg-image:url(" + t.url + ");--width:" + t.naturalWidth + "px;--height:" + (n = t.naturalWidth, r = t.naturalHeight, n < window.getComputedStyle(document.querySelector(".CodeMirror-sizer")).width.replace("px", "") ? r + "px" : r / n * 100 + "%")), m.codemirror.setSize() } }, ae.prototype.cleanup = function () { document.removeEventListener("keydown", this.documentOnKeyDown) }, ae.prototype.autosave = function () { if (le()) { var e = this; if (null == this.options.autosave.uniqueId || "" == this.options.autosave.uniqueId) return void console.log("EasyMDE: You must set a uniqueId to use the autosave feature"); !0 !== this.options.autosave.binded && (null != e.element.form && null != e.element.form && e.element.form.addEventListener("submit", (function () { clearTimeout(e.autosaveTimeoutId), e.autosaveTimeoutId = void 0, localStorage.removeItem("smde_" + e.options.autosave.uniqueId) })), this.options.autosave.binded = !0), !0 !== this.options.autosave.loaded && ("string" == typeof localStorage.getItem("smde_" + this.options.autosave.uniqueId) && "" != localStorage.getItem("smde_" + this.options.autosave.uniqueId) && (this.codemirror.setValue(localStorage.getItem("smde_" + this.options.autosave.uniqueId)), this.options.autosave.foundSavedValue = !0), this.options.autosave.loaded = !0); var t = e.value(); "" !== t ? localStorage.setItem("smde_" + this.options.autosave.uniqueId, t) : localStorage.removeItem("smde_" + this.options.autosave.uniqueId); var n = document.getElementById("autosaved"); if (null != n && null != n && "" != n) { var r = new Date, i = new Intl.DateTimeFormat([this.options.autosave.timeFormat.locale, "en-US"], this.options.autosave.timeFormat.format).format(r), o = null == this.options.autosave.text ? "Autosaved: " : this.options.autosave.text; n.innerHTML = o + i } } else console.log("EasyMDE: localStorage not available, cannot autosave") }, ae.prototype.clearAutosavedValue = function () { if (le()) { if (null == this.options.autosave || null == this.options.autosave.uniqueId || "" == this.options.autosave.uniqueId) return void console.log("EasyMDE: You must set a uniqueId to clear the autosave value"); localStorage.removeItem("smde_" + this.options.autosave.uniqueId) } else console.log("EasyMDE: localStorage not available, cannot autosave") }, ae.prototype.openBrowseFileWindow = function (e, t) { var n = this, r = this.gui.toolbar.getElementsByClassName("imageInput")[0]; r.click(), r.addEventListener("change", (function i(o) { n.options.imageUploadFunction ? n.uploadImagesUsingCustomFunction(n.options.imageUploadFunction, o.target.files) : n.uploadImages(o.target.files, e, t), r.removeEventListener("change", i) })) }, ae.prototype.uploadImage = function (e, t, n) { var r = this; function i(e) { r.updateStatusBar("upload-image", e), setTimeout((function () { r.updateStatusBar("upload-image", r.options.imageTexts.sbInit) }), 1e4), n && "function" == typeof n && n(e), r.options.errorCallback(e) } function o(t) { var n = r.options.imageTexts.sizeUnits.split(","); return t.replace("#image_name#", e.name).replace("#image_size#", X(e.size, n)).replace("#image_max_size#", X(r.options.imageMaxSize, n)) } if (t = t || function (e) { R(r, e) }, e.size > this.options.imageMaxSize) i(o(this.options.errorMessages.fileTooLarge)); else { var a = new FormData; a.append("image", e), r.options.imageCSRFToken && a.append("csrfmiddlewaretoken", r.options.imageCSRFToken); var l = new XMLHttpRequest; l.upload.onprogress = function (t) { if (t.lengthComputable) { var n = "" + Math.round(100 * t.loaded / t.total); r.updateStatusBar("upload-image", r.options.imageTexts.sbProgress.replace("#file_name#", e.name).replace("#progress#", n)) } }, l.open("POST", this.options.imageUploadEndpoint), l.onload = function () { try { var e = JSON.parse(this.responseText) } catch (e) { return console.error("EasyMDE: The server did not return a valid json."), void i(o(r.options.errorMessages.importError)) } 200 === this.status && e && !e.error && e.data && e.data.filePath ? t((r.options.imagePathAbsolute ? "" : window.location.origin + "/") + e.data.filePath) : e.error && e.error in r.options.errorMessages ? i(o(r.options.errorMessages[e.error])) : e.error ? i(o(e.error)) : (console.error("EasyMDE: Received an unexpected response after uploading the image." + this.status + " (" + this.statusText + ")"), i(o(r.options.errorMessages.importError))) }, l.onerror = function (e) { console.error("EasyMDE: An unexpected error occurred when trying to upload the image." + e.target.status + " (" + e.target.statusText + ")"), i(r.options.errorMessages.importError) }, l.send(a) } }, ae.prototype.uploadImageUsingCustomFunction = function (e, t) { var n = this; e.apply(this, [t, function (e) { R(n, e) }, function (e) { var r = function (e) { var r = n.options.imageTexts.sizeUnits.split(","); return e.replace("#image_name#", t.name).replace("#image_size#", X(t.size, r)).replace("#image_max_size#", X(n.options.imageMaxSize, r)) }(e); n.updateStatusBar("upload-image", r), setTimeout((function () { n.updateStatusBar("upload-image", n.options.imageTexts.sbInit) }), 1e4), n.options.errorCallback(r) }]) }, ae.prototype.setPreviewMaxHeight = function () { var e = this.codemirror.getWrapperElement(), t = e.nextSibling, n = parseInt(window.getComputedStyle(e).paddingTop), r = parseInt(window.getComputedStyle(e).borderTopWidth), i = (parseInt(this.options.maxHeight) + 2 * n + 2 * r).toString() + "px"; t.style.height = i }, ae.prototype.createSideBySide = function () { var e = this.codemirror, t = e.getWrapperElement(), n = t.nextSibling; if (!n || !/editor-preview-side/.test(n.className)) { if ((n = document.createElement("div")).className = "editor-preview-side", this.options.previewClass) if (Array.isArray(this.options.previewClass)) for (var r = 0; r < this.options.previewClass.length; r++)n.className += " " + this.options.previewClass[r]; else "string" == typeof this.options.previewClass && (n.className += " " + this.options.previewClass); t.parentNode.insertBefore(n, t.nextSibling) } if (void 0 !== this.options.maxHeight && this.setPreviewMaxHeight(), !1 === this.options.syncSideBySidePreviewScroll) return n; var i = !1, o = !1; return e.on("scroll", (function (e) { if (i) i = !1; else { o = !0; var t = e.getScrollInfo().height - e.getScrollInfo().clientHeight, r = parseFloat(e.getScrollInfo().top) / t, a = (n.scrollHeight - n.clientHeight) * r; n.scrollTop = a } })), n.onscroll = function () { if (o) o = !1; else { i = !0; var t = n.scrollHeight - n.clientHeight, r = parseFloat(n.scrollTop) / t, a = (e.getScrollInfo().height - e.getScrollInfo().clientHeight) * r; e.scrollTo(0, a) } }, n }, ae.prototype.createToolbar = function (e) { if ((e = e || this.options.toolbar) && 0 !== e.length) { var t; for (t = 0; t < e.length; t++)null != J[e[t]] && (e[t] = J[e[t]]); var n = document.createElement("div"); n.className = "editor-toolbar"; var r = this, i = {}; for (r.toolbar = e, t = 0; t < e.length; t++)if (("guide" != e[t].name || !1 !== r.options.toolbarGuideIcon) && !(r.options.hideIcons && -1 != r.options.hideIcons.indexOf(e[t].name) || ("fullscreen" == e[t].name || "side-by-side" == e[t].name) && c())) { if ("|" === e[t]) { for (var o = !1, a = t + 1; a < e.length; a++)"|" === e[a] || r.options.hideIcons && -1 != r.options.hideIcons.indexOf(e[a].name) || (o = !0); if (!o) continue } !function (e) { var t; if (t = "|" === e ? x() : e.children ? g(e, r.options.toolbarTips, r.options.shortcuts, r) : v(e, !0, r.options.toolbarTips, r.options.shortcuts, "button", r), i[e.name || e] = t, n.appendChild(t), "upload-image" === e.name) { var o = document.createElement("input"); o.className = "imageInput", o.type = "file", o.multiple = !0, o.name = "image", o.accept = r.options.imageAccept, o.style.display = "none", o.style.opacity = 0, n.appendChild(o) } }(e[t]) } r.toolbar_div = n, r.toolbarElements = i; var l = this.codemirror; l.on("cursorActivity", (function () { var e = y(l); for (var t in i) !function (t) { var n = i[t]; e[t] ? n.className += " active" : "fullscreen" != t && "side-by-side" != t && (n.className = n.className.replace(/\s*active\s*/g, "")) }(t) })); var s = l.getWrapperElement(); return s.parentNode.insertBefore(n, s), n } }, ae.prototype.createStatusbar = function (e) { e = e || this.options.status; var t = this.options, n = this.codemirror; if (e && 0 !== e.length) { var r, i, o, a, l = []; for (r = 0; r < e.length; r++)if (i = void 0, o = void 0, a = void 0, "object" == typeof e[r]) l.push({ className: e[r].className, defaultValue: e[r].defaultValue, onUpdate: e[r].onUpdate, onActivity: e[r].onActivity }); else { var s = e[r]; "words" === s ? (a = function (e) { e.innerHTML = Q(n.getValue()) }, i = function (e) { e.innerHTML = Q(n.getValue()) }) : "lines" === s ? (a = function (e) { e.innerHTML = n.lineCount() }, i = function (e) { e.innerHTML = n.lineCount() }) : "cursor" === s ? (a = function (e) { e.innerHTML = "0:0" }, o = function (e) { var t = n.getCursor(); e.innerHTML = t.line + ":" + t.ch }) : "autosave" === s ? a = function (e) { null != t.autosave && !0 === t.autosave.enabled && e.setAttribute("id", "autosaved") } : "upload-image" === s && (a = function (e) { e.innerHTML = t.imageTexts.sbInit }), l.push({ className: s, defaultValue: a, onUpdate: i, onActivity: o }) } var u = document.createElement("div"); for (u.className = "editor-statusbar", r = 0; r < l.length; r++) { var c = l[r], d = document.createElement("span"); d.className = c.className, "function" == typeof c.defaultValue && c.defaultValue(d), "function" == typeof c.onUpdate && this.codemirror.on("update", function (e, t) { return function () { t.onUpdate(e) } }(d, c)), "function" == typeof c.onActivity && this.codemirror.on("cursorActivity", function (e, t) { return function () { t.onActivity(e) } }(d, c)), u.appendChild(d) } var h = this.codemirror.getWrapperElement(); return h.parentNode.insertBefore(u, h.nextSibling), u } }, ae.prototype.value = function (e) { var t = this.codemirror; if (void 0 === e) return t.getValue(); if (t.getDoc().setValue(e), this.isPreviewActive()) { var n = t.getWrapperElement().lastChild; n.innerHTML = this.options.previewRender(e, n) } return this }, ae.toggleBold = C, ae.toggleItalic = w, ae.toggleStrikethrough = k, ae.toggleBlockquote = F, ae.toggleHeadingSmaller = A, ae.toggleHeadingBigger = E, ae.toggleHeading1 = T, ae.toggleHeading2 = L, ae.toggleHeading3 = M, ae.toggleCodeBlock = S, ae.toggleUnorderedList = B, ae.toggleOrderedList = N, ae.cleanBlock = O, ae.drawLink = I, ae.drawImage = z, ae.drawUploadedImage = H, ae.drawTable = P, ae.drawHorizontalRule = _, ae.undo = W, ae.redo = j, ae.togglePreview = U, ae.toggleSideBySide = q, ae.toggleFullScreen = D, ae.prototype.toggleBold = function () { C(this) }, ae.prototype.toggleItalic = function () { w(this) }, ae.prototype.toggleStrikethrough = function () { k(this) }, ae.prototype.toggleBlockquote = function () { F(this) }, ae.prototype.toggleHeadingSmaller = function () { A(this) }, ae.prototype.toggleHeadingBigger = function () { E(this) }, ae.prototype.toggleHeading1 = function () { T(this) }, ae.prototype.toggleHeading2 = function () { L(this) }, ae.prototype.toggleHeading3 = function () { M(this) }, ae.prototype.toggleCodeBlock = function () { S(this) }, ae.prototype.toggleUnorderedList = function () { B(this) }, ae.prototype.toggleOrderedList = function () { N(this) }, ae.prototype.cleanBlock = function () { O(this) }, ae.prototype.drawLink = function () { I(this) }, ae.prototype.drawImage = function () { z(this) }, ae.prototype.drawUploadedImage = function () { H(this) }, ae.prototype.drawTable = function () { P(this) }, ae.prototype.drawHorizontalRule = function () { _(this) }, ae.prototype.undo = function () { W(this) }, ae.prototype.redo = function () { j(this) }, ae.prototype.togglePreview = function () { U(this) }, ae.prototype.toggleSideBySide = function () { q(this) }, ae.prototype.toggleFullScreen = function () { D(this) }, ae.prototype.isPreviewActive = function () { var e = this.codemirror.getWrapperElement().lastChild; return /editor-preview-active/.test(e.className) }, ae.prototype.isSideBySideActive = function () { var e = this.codemirror.getWrapperElement().nextSibling; return /editor-preview-active-side/.test(e.className) }, ae.prototype.isFullscreenActive = function () { return this.codemirror.getOption("fullScreen") }, ae.prototype.getState = function () { return y(this.codemirror) }, ae.prototype.toTextArea = function () { var e = this.codemirror, t = e.getWrapperElement(), n = t.parentNode; n && (this.gui.toolbar && n.removeChild(this.gui.toolbar), this.gui.statusbar && n.removeChild(this.gui.statusbar), this.gui.sideBySide && n.removeChild(this.gui.sideBySide)), n.parentNode.insertBefore(t, n), n.remove(), e.toTextArea(), this.autosaveTimeoutId && (clearTimeout(this.autosaveTimeoutId), this.autosaveTimeoutId = void 0, this.clearAutosavedValue()) }, t.exports = ae }, { "./codemirror/tablist": 17, codemirror: 10, "codemirror-spell-checker": 2, "codemirror/addon/display/autorefresh.js": 3, "codemirror/addon/display/fullscreen.js": 4, "codemirror/addon/display/placeholder.js": 5, "codemirror/addon/edit/continuelist.js": 6, "codemirror/addon/mode/overlay.js": 7, "codemirror/addon/search/searchcursor.js": 8, "codemirror/addon/selection/mark-selection.js": 9, "codemirror/mode/gfm/gfm.js": 11, "codemirror/mode/markdown/markdown.js": 12, "codemirror/mode/xml/xml.js": 14, "marked/lib/marked": 15 }] }, {}, [18])(18) })); \ No newline at end of file diff --git a/PSC.Blazor.Components.MarkdownEditor/wwwroot/js/markdownEditor.js b/PSC.Blazor.Components.MarkdownEditor/wwwroot/js/markdownEditor.js new file mode 100644 index 0000000..4da5864 --- /dev/null +++ b/PSC.Blazor.Components.MarkdownEditor/wwwroot/js/markdownEditor.js @@ -0,0 +1,177 @@ +const _instances = []; + +function initialize(dotNetObjectRef, element, elementId, options) { + const instances = _instances; + + if (!options.toolbar) { + // remove empty toolbar so that we can fallback to the default items + delete options.toolbar; + } + else if (options.toolbar && options.toolbar.length > 0) { + // map any named action with a real action from EasyMDE + options.toolbar.forEach(button => { + // make sure we don't operate on separators + if (button !== "|") { + if (button.action) { + if (!button.action.startsWith("http")) { + button.action = EasyMDE[button.action]; + } + } + else { + if (button.name && button.name.startsWith("http")) { + button.action = button.name; + } + else { + // custom action is used so we need to trigger custom event on click + button.action = (editor) => { + dotNetObjectRef.invokeMethodAsync('NotifyCustomButtonClicked', button.name, button.value).then(null, function (err) { + throw new Error(err); + }); + } + } + } + + // button without icon is not allowed + if (!button.className) { + button.className = "fa fa-question"; + } + } + }); + } + + let nextFileId = 0; + let imageUploadNotifier = { + onSuccess: (e) => { }, + onError: (e) => { } + }; + + const easyMDE = new EasyMDE({ + element: document.getElementById(elementId), + hideIcons: options.hideIcons, + showIcons: options.showIcons, + renderingConfig: { + singleLineBreaks: false, + codeSyntaxHighlighting: true + }, + initialValue: options.value, + sideBySideFullscreen: false, + autoDownloadFontAwesome: options.autoDownloadFontAwesome, + lineNumbers: options.lineNumbers, + lineWrapping: options.lineWrapping, + minHeight: options.minHeight, + maxHeight: options.maxHeight, + placeholder: options.placeholder, + tabSize: options.tabSize, + theme: options.theme, + direction: options.direction, + toolbar: options.toolbar, + toolbarTips: options.toolbarTips, + + autosave: options.autoSave, + + uploadImage: options.uploadImage, + imageMaxSize: options.imageMaxSize, + imageAccept: options.imageAccept, + imageUploadEndpoint: options.imageUploadEndpoint, + imagePathAbsolute: options.imagePathAbsolute, + imageCSRFToken: options.imageCSRFToken, + imageTexts: options.imageTexts, + imageUploadFunction: (file, onSuccess, onError) => { + imageUploadNotifier.onSuccess = onSuccess; + imageUploadNotifier.onError = onError; + + NotifyUploadImage(elementId, file, dotNetObjectRef); + }, + + errorMessages: options.errorMessages, + errorCallback: (errorMessage) => { + dotNetObjectRef.invokeMethodAsync("NotifyErrorMessage", errorMessage); + } + }); + + easyMDE.codemirror.on("change", function () { + dotNetObjectRef.invokeMethodAsync("UpdateInternalValue", easyMDE.value()); + }); + + instances[elementId] = { + dotNetObjectRef: dotNetObjectRef, + elementId: elementId, + editor: easyMDE, + imageUploadNotifier: imageUploadNotifier + }; +} + +function destroy(element, elementId) { + const instances = _instances || {}; + delete instances[elementId]; +} + +function setValue(elementId, value) { + const instance = _instances[elementId]; + + if (instance) { + instance.editor.value(value); + } +} + +function getValue(elementId) { + const instance = _instances[elementId]; + + if (instance) { + return instance.editor.value(); + } + + return null; +} + +function notifyImageUploadSuccess(elementId, imageUrl) { + const instance = _instances[elementId]; + + if (instance) { + return instance.imageUploadNotifier.onSuccess(imageUrl); + } +} + +function notifyImageUploadError(elementId, errorMessage) { + const instance = _instances[elementId]; + + if (instance) { + return instance.imageUploadNotifier.onError(errorMessage); + } +} + +function _arrayBufferToBase64(buffer) { + var binary = ''; + var bytes = new Uint8Array(buffer); + var len = bytes.byteLength; + for (var i = 0; i < len; i++) { + binary += String.fromCharCode(bytes[i]); + } + return window.btoa(binary); +} + +async function NotifyUploadImage(elementId, file, dotNetObjectRef) { + var arrBuffer = await file.arrayBuffer(); + + const a = await arrBuffer; + var arrBf = _arrayBufferToBase64(a); + + var fileEntry = { + lastModified: new Date(file.lastModified).toISOString(), + name: file.name, + size: file.size, + type: file.type, + contentbase64: arrBf + }; + + dotNetObjectRef.invokeMethodAsync('NotifyImageUpload', fileEntry).then(null, function (err) { + throw new Error(err); + }); + + dotNetObjectRef.invokeMethodAsync('UploadFile', fileEntry).then(r => { + if (!r || r.length === 0) + notifyImageUploadError(elementId, "Upload error"); + else + notifyImageUploadSuccess(elementId, r); + }); +} \ No newline at end of file diff --git a/PSC.Blazor.Components.MarkdownEditor/wwwroot/lib/simplemde/simplemde.min.css b/PSC.Blazor.Components.MarkdownEditor/wwwroot/lib/simplemde/simplemde.min.css new file mode 100644 index 0000000..d62f4d7 --- /dev/null +++ b/PSC.Blazor.Components.MarkdownEditor/wwwroot/lib/simplemde/simplemde.min.css @@ -0,0 +1,7 @@ +/** + * simplemde v1.11.2 + * Copyright Next Step Webs, Inc. + * @link https://github.com/NextStepWebs/simplemde-markdown-editor + * @license MIT + */ +.CodeMirror{color:#000}.CodeMirror-lines{padding:4px 0}.CodeMirror pre{padding:0 4px}.CodeMirror-gutter-filler,.CodeMirror-scrollbar-filler{background-color:#fff}.CodeMirror-gutters{border-right:1px solid #ddd;background-color:#f7f7f7;white-space:nowrap}.CodeMirror-linenumber{padding:0 3px 0 5px;min-width:20px;text-align:right;color:#999;white-space:nowrap}.CodeMirror-guttermarker{color:#000}.CodeMirror-guttermarker-subtle{color:#999}.CodeMirror-cursor{border-left:1px solid #000;border-right:none;width:0}.CodeMirror div.CodeMirror-secondarycursor{border-left:1px solid silver}.cm-fat-cursor .CodeMirror-cursor{width:auto;border:0!important;background:#7e7}.cm-fat-cursor div.CodeMirror-cursors{z-index:1}.cm-animate-fat-cursor{width:auto;border:0;-webkit-animation:blink 1.06s steps(1) infinite;-moz-animation:blink 1.06s steps(1) infinite;animation:blink 1.06s steps(1) infinite;background-color:#7e7}@-moz-keyframes blink{50%{background-color:transparent}}@-webkit-keyframes blink{50%{background-color:transparent}}@keyframes blink{50%{background-color:transparent}}.cm-tab{display:inline-block;text-decoration:inherit}.CodeMirror-ruler{border-left:1px solid #ccc;position:absolute}.cm-s-default .cm-header{color:#00f}.cm-s-default .cm-quote{color:#090}.cm-negative{color:#d44}.cm-positive{color:#292}.cm-header,.cm-strong{font-weight:700}.cm-em{font-style:italic}.cm-link{text-decoration:underline}.cm-strikethrough{text-decoration:line-through}.cm-s-default .cm-keyword{color:#708}.cm-s-default .cm-atom{color:#219}.cm-s-default .cm-number{color:#164}.cm-s-default .cm-def{color:#00f}.cm-s-default .cm-variable-2{color:#05a}.cm-s-default .cm-variable-3{color:#085}.cm-s-default .cm-comment{color:#a50}.cm-s-default .cm-string{color:#a11}.cm-s-default .cm-string-2{color:#f50}.cm-s-default .cm-meta,.cm-s-default .cm-qualifier{color:#555}.cm-s-default .cm-builtin{color:#30a}.cm-s-default .cm-bracket{color:#997}.cm-s-default .cm-tag{color:#170}.cm-s-default .cm-attribute{color:#00c}.cm-s-default .cm-hr{color:#999}.cm-s-default .cm-link{color:#00c}.cm-invalidchar,.cm-s-default .cm-error{color:red}.CodeMirror-composing{border-bottom:2px solid}div.CodeMirror span.CodeMirror-matchingbracket{color:#0f0}div.CodeMirror span.CodeMirror-nonmatchingbracket{color:#f22}.CodeMirror-matchingtag{background:rgba(255,150,0,.3)}.CodeMirror-activeline-background{background:#e8f2ff}.CodeMirror{position:relative;overflow:hidden;background:#fff}.CodeMirror-scroll{overflow:scroll!important;margin-bottom:-30px;margin-right:-30px;padding-bottom:30px;height:100%;outline:0;position:relative}.CodeMirror-sizer{position:relative;border-right:30px solid transparent}.CodeMirror-gutter-filler,.CodeMirror-hscrollbar,.CodeMirror-scrollbar-filler,.CodeMirror-vscrollbar{position:absolute;z-index:6;display:none}.CodeMirror-vscrollbar{right:0;top:0;overflow-x:hidden;overflow-y:scroll}.CodeMirror-hscrollbar{bottom:0;left:0;overflow-y:hidden;overflow-x:scroll}.CodeMirror-scrollbar-filler{right:0;bottom:0}.CodeMirror-gutter-filler{left:0;bottom:0}.CodeMirror-gutters{position:absolute;left:0;top:0;min-height:100%;z-index:3}.CodeMirror-gutter{white-space:normal;height:100%;display:inline-block;vertical-align:top;margin-bottom:-30px}.CodeMirror-gutter-wrapper{position:absolute;z-index:4;background:0 0!important;border:none!important;-webkit-user-select:none;-moz-user-select:none;user-select:none}.CodeMirror-gutter-background{position:absolute;top:0;bottom:0;z-index:4}.CodeMirror-gutter-elt{position:absolute;cursor:default;z-index:4}.CodeMirror-lines{cursor:text;min-height:1px}.CodeMirror pre{-moz-border-radius:0;-webkit-border-radius:0;border-radius:0;border-width:0;background:0 0;font-family:inherit;font-size:inherit;margin:0;white-space:pre;word-wrap:normal;line-height:inherit;color:inherit;z-index:2;position:relative;overflow:visible;-webkit-tap-highlight-color:transparent;-webkit-font-variant-ligatures:none;font-variant-ligatures:none}.CodeMirror-wrap pre{word-wrap:break-word;white-space:pre-wrap;word-break:normal}.CodeMirror-linebackground{position:absolute;left:0;right:0;top:0;bottom:0;z-index:0}.CodeMirror-linewidget{position:relative;z-index:2;overflow:auto}.CodeMirror-code{outline:0}.CodeMirror-gutter,.CodeMirror-gutters,.CodeMirror-linenumber,.CodeMirror-scroll,.CodeMirror-sizer{-moz-box-sizing:content-box;box-sizing:content-box}.CodeMirror-measure{position:absolute;width:100%;height:0;overflow:hidden;visibility:hidden}.CodeMirror-cursor{position:absolute}.CodeMirror-measure pre{position:static}div.CodeMirror-cursors{visibility:hidden;position:relative;z-index:3}.CodeMirror-focused div.CodeMirror-cursors,div.CodeMirror-dragcursors{visibility:visible}.CodeMirror-selected{background:#d9d9d9}.CodeMirror-focused .CodeMirror-selected,.CodeMirror-line::selection,.CodeMirror-line>span::selection,.CodeMirror-line>span>span::selection{background:#d7d4f0}.CodeMirror-crosshair{cursor:crosshair}.CodeMirror-line::-moz-selection,.CodeMirror-line>span::-moz-selection,.CodeMirror-line>span>span::-moz-selection{background:#d7d4f0}.cm-searching{background:#ffa;background:rgba(255,255,0,.4)}.cm-force-border{padding-right:.1px}@media print{.CodeMirror div.CodeMirror-cursors{visibility:hidden}}.cm-tab-wrap-hack:after{content:''}span.CodeMirror-selectedtext{background:0 0}.CodeMirror{height:auto;min-height:300px;border:1px solid #ddd;border-bottom-left-radius:4px;border-bottom-right-radius:4px;padding:10px;font:inherit;z-index:1}.CodeMirror-scroll{min-height:300px}.CodeMirror-fullscreen{background:#fff;position:fixed!important;top:50px;left:0;right:0;bottom:0;height:auto;z-index:9}.CodeMirror-sided{width:50%!important}.editor-toolbar{position:relative;opacity:.6;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none;padding:0 10px;border-top:1px solid #bbb;border-left:1px solid #bbb;border-right:1px solid #bbb;border-top-left-radius:4px;border-top-right-radius:4px}.editor-toolbar:after,.editor-toolbar:before{display:block;content:' ';height:1px}.editor-toolbar:before{margin-bottom:8px}.editor-toolbar:after{margin-top:8px}.editor-toolbar:hover,.editor-wrapper input.title:focus,.editor-wrapper input.title:hover{opacity:.8}.editor-toolbar.fullscreen{width:100%;height:50px;overflow-x:auto;overflow-y:hidden;white-space:nowrap;padding-top:10px;padding-bottom:10px;box-sizing:border-box;background:#fff;border:0;position:fixed;top:0;left:0;opacity:1;z-index:9}.editor-toolbar.fullscreen::before{width:20px;height:50px;background:-moz-linear-gradient(left,rgba(255,255,255,1) 0,rgba(255,255,255,0) 100%);background:-webkit-gradient(linear,left top,right top,color-stop(0,rgba(255,255,255,1)),color-stop(100%,rgba(255,255,255,0)));background:-webkit-linear-gradient(left,rgba(255,255,255,1) 0,rgba(255,255,255,0) 100%);background:-o-linear-gradient(left,rgba(255,255,255,1) 0,rgba(255,255,255,0) 100%);background:-ms-linear-gradient(left,rgba(255,255,255,1) 0,rgba(255,255,255,0) 100%);background:linear-gradient(to right,rgba(255,255,255,1) 0,rgba(255,255,255,0) 100%);position:fixed;top:0;left:0;margin:0;padding:0}.editor-toolbar.fullscreen::after{width:20px;height:50px;background:-moz-linear-gradient(left,rgba(255,255,255,0) 0,rgba(255,255,255,1) 100%);background:-webkit-gradient(linear,left top,right top,color-stop(0,rgba(255,255,255,0)),color-stop(100%,rgba(255,255,255,1)));background:-webkit-linear-gradient(left,rgba(255,255,255,0) 0,rgba(255,255,255,1) 100%);background:-o-linear-gradient(left,rgba(255,255,255,0) 0,rgba(255,255,255,1) 100%);background:-ms-linear-gradient(left,rgba(255,255,255,0) 0,rgba(255,255,255,1) 100%);background:linear-gradient(to right,rgba(255,255,255,0) 0,rgba(255,255,255,1) 100%);position:fixed;top:0;right:0;margin:0;padding:0}.editor-toolbar a{display:inline-block;text-align:center;text-decoration:none!important;color:#2c3e50!important;width:30px;height:30px;margin:0;border:1px solid transparent;border-radius:3px;cursor:pointer}.editor-toolbar a.active,.editor-toolbar a:hover{background:#fcfcfc;border-color:#95a5a6}.editor-toolbar a:before{line-height:30px}.editor-toolbar i.separator{display:inline-block;width:0;border-left:1px solid #d9d9d9;border-right:1px solid #fff;color:transparent;text-indent:-10px;margin:0 6px}.editor-toolbar a.fa-header-x:after{font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;font-size:65%;vertical-align:text-bottom;position:relative;top:2px}.editor-toolbar a.fa-header-1:after{content:"1"}.editor-toolbar a.fa-header-2:after{content:"2"}.editor-toolbar a.fa-header-3:after{content:"3"}.editor-toolbar a.fa-header-bigger:after{content:"▲"}.editor-toolbar a.fa-header-smaller:after{content:"▼"}.editor-toolbar.disabled-for-preview a:not(.no-disable){pointer-events:none;background:#fff;border-color:transparent;text-shadow:inherit}@media only screen and (max-width:700px){.editor-toolbar a.no-mobile{display:none}}.editor-statusbar{padding:8px 10px;font-size:12px;color:#959694;text-align:right}.editor-statusbar span{display:inline-block;min-width:4em;margin-left:1em}.editor-preview,.editor-preview-side{padding:10px;background:#fafafa;overflow:auto;display:none;box-sizing:border-box}.editor-statusbar .lines:before{content:'lines: '}.editor-statusbar .words:before{content:'words: '}.editor-statusbar .characters:before{content:'characters: '}.editor-preview{position:absolute;width:100%;height:100%;top:0;left:0;z-index:7}.editor-preview-side{position:fixed;bottom:0;width:50%;top:50px;right:0;z-index:9;border:1px solid #ddd}.editor-preview-active,.editor-preview-active-side{display:block}.editor-preview-side>p,.editor-preview>p{margin-top:0}.editor-preview pre,.editor-preview-side pre{background:#eee;margin-bottom:10px}.editor-preview table td,.editor-preview table th,.editor-preview-side table td,.editor-preview-side table th{border:1px solid #ddd;padding:5px}.CodeMirror .CodeMirror-code .cm-tag{color:#63a35c}.CodeMirror .CodeMirror-code .cm-attribute{color:#795da3}.CodeMirror .CodeMirror-code .cm-string{color:#183691}.CodeMirror .CodeMirror-selected{background:#d9d9d9}.CodeMirror .CodeMirror-code .cm-header-1{font-size:200%;line-height:200%}.CodeMirror .CodeMirror-code .cm-header-2{font-size:160%;line-height:160%}.CodeMirror .CodeMirror-code .cm-header-3{font-size:125%;line-height:125%}.CodeMirror .CodeMirror-code .cm-header-4{font-size:110%;line-height:110%}.CodeMirror .CodeMirror-code .cm-comment{background:rgba(0,0,0,.05);border-radius:2px}.CodeMirror .CodeMirror-code .cm-link{color:#7f8c8d}.CodeMirror .CodeMirror-code .cm-url{color:#aab2b3}.CodeMirror .CodeMirror-code .cm-strikethrough{text-decoration:line-through}.CodeMirror .CodeMirror-placeholder{opacity:.5}.CodeMirror .cm-spell-error:not(.cm-url):not(.cm-comment):not(.cm-tag):not(.cm-word){background:rgba(255,0,0,.15)} \ No newline at end of file diff --git a/PSC.Blazor.Components.MarkdownEditor/wwwroot/lib/simplemde/simplemde.min.js b/PSC.Blazor.Components.MarkdownEditor/wwwroot/lib/simplemde/simplemde.min.js new file mode 100644 index 0000000..50c624f --- /dev/null +++ b/PSC.Blazor.Components.MarkdownEditor/wwwroot/lib/simplemde/simplemde.min.js @@ -0,0 +1,15 @@ +/** + * simplemde v1.11.2 + * Copyright Next Step Webs, Inc. + * @link https://github.com/NextStepWebs/simplemde-markdown-editor + * @license MIT + */ +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.SimpleMDE=e()}}(function(){var e;return function t(e,n,r){function i(a,l){if(!n[a]){if(!e[a]){var s="function"==typeof require&&require;if(!l&&s)return s(a,!0);if(o)return o(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var u=n[a]={exports:{}};e[a][0].call(u.exports,function(t){var n=e[a][1][t];return i(n?n:t)},u,u.exports,t,e,n,r)}return n[a].exports}for(var o="function"==typeof require&&require,a=0;at;++t)s[t]=e[t],c[e.charCodeAt(t)]=t;c["-".charCodeAt(0)]=62,c["_".charCodeAt(0)]=63}function i(e){var t,n,r,i,o,a,l=e.length;if(l%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[l-2]?2:"="===e[l-1]?1:0,a=new u(3*l/4-o),r=o>0?l-4:l;var s=0;for(t=0,n=0;r>t;t+=4,n+=3)i=c[e.charCodeAt(t)]<<18|c[e.charCodeAt(t+1)]<<12|c[e.charCodeAt(t+2)]<<6|c[e.charCodeAt(t+3)],a[s++]=i>>16&255,a[s++]=i>>8&255,a[s++]=255&i;return 2===o?(i=c[e.charCodeAt(t)]<<2|c[e.charCodeAt(t+1)]>>4,a[s++]=255&i):1===o&&(i=c[e.charCodeAt(t)]<<10|c[e.charCodeAt(t+1)]<<4|c[e.charCodeAt(t+2)]>>2,a[s++]=i>>8&255,a[s++]=255&i),a}function o(e){return s[e>>18&63]+s[e>>12&63]+s[e>>6&63]+s[63&e]}function a(e,t,n){for(var r,i=[],a=t;n>a;a+=3)r=(e[a]<<16)+(e[a+1]<<8)+e[a+2],i.push(o(r));return i.join("")}function l(e){for(var t,n=e.length,r=n%3,i="",o=[],l=16383,c=0,u=n-r;u>c;c+=l)o.push(a(e,c,c+l>u?u:c+l));return 1===r?(t=e[n-1],i+=s[t>>2],i+=s[t<<4&63],i+="=="):2===r&&(t=(e[n-2]<<8)+e[n-1],i+=s[t>>10],i+=s[t>>4&63],i+=s[t<<2&63],i+="="),o.push(i),o.join("")}n.toByteArray=i,n.fromByteArray=l;var s=[],c=[],u="undefined"!=typeof Uint8Array?Uint8Array:Array;r()},{}],2:[function(e,t,n){},{}],3:[function(e,t,n){(function(t){"use strict";function r(){try{var e=new Uint8Array(1);return e.foo=function(){return 42},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(t){return!1}}function i(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function o(e,t){if(i()=t?o(e,t):void 0!==n?"string"==typeof r?o(e,t).fill(n,r):o(e,t).fill(n):o(e,t)}function u(e,t){if(s(t),e=o(e,0>t?0:0|m(t)),!a.TYPED_ARRAY_SUPPORT)for(var n=0;t>n;n++)e[n]=0;return e}function f(e,t,n){if("string"==typeof n&&""!==n||(n="utf8"),!a.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|v(t,n);return e=o(e,r),e.write(t,n),e}function h(e,t){var n=0|m(t.length);e=o(e,n);for(var r=0;n>r;r+=1)e[r]=255&t[r];return e}function d(e,t,n,r){if(t.byteLength,0>n||t.byteLength=i())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i().toString(16)+" bytes");return 0|e}function g(e){return+e!=e&&(e=0),a.alloc(+e)}function v(e,t){if(a.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"binary":case"raw":case"raws":return n;case"utf8":case"utf-8":case void 0:return q(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return $(e).length;default:if(r)return q(e).length;t=(""+t).toLowerCase(),r=!0}}function y(e,t,n){var r=!1;if((void 0===t||0>t)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),0>=n)return"";if(n>>>=0,t>>>=0,t>=n)return"";for(e||(e="utf8");;)switch(e){case"hex":return I(this,t,n);case"utf8":case"utf-8":return N(this,t,n);case"ascii":return E(this,t,n);case"binary":return O(this,t,n);case"base64":return M(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function x(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function b(e,t,n,r){function i(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}var o=1,a=e.length,l=t.length;if(void 0!==r&&(r=String(r).toLowerCase(),"ucs2"===r||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;o=2,a/=2,l/=2,n/=2}for(var s=-1,c=0;a>n+c;c++)if(i(e,n+c)===i(t,-1===s?0:c-s)){if(-1===s&&(s=c),c-s+1===l)return(n+s)*o}else-1!==s&&(c-=c-s),s=-1;return-1}function w(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r),r>i&&(r=i)):r=i;var o=t.length;if(o%2!==0)throw new Error("Invalid hex string");r>o/2&&(r=o/2);for(var a=0;r>a;a++){var l=parseInt(t.substr(2*a,2),16);if(isNaN(l))return a;e[n+a]=l}return a}function k(e,t,n,r){return V(q(t,e.length-n),e,n,r)}function S(e,t,n,r){return V(G(t),e,n,r)}function C(e,t,n,r){return S(e,t,n,r)}function L(e,t,n,r){return V($(t),e,n,r)}function T(e,t,n,r){return V(Y(t,e.length-n),e,n,r)}function M(e,t,n){return 0===t&&n===e.length?X.fromByteArray(e):X.fromByteArray(e.slice(t,n))}function N(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;n>i;){var o=e[i],a=null,l=o>239?4:o>223?3:o>191?2:1;if(n>=i+l){var s,c,u,f;switch(l){case 1:128>o&&(a=o);break;case 2:s=e[i+1],128===(192&s)&&(f=(31&o)<<6|63&s,f>127&&(a=f));break;case 3:s=e[i+1],c=e[i+2],128===(192&s)&&128===(192&c)&&(f=(15&o)<<12|(63&s)<<6|63&c,f>2047&&(55296>f||f>57343)&&(a=f));break;case 4:s=e[i+1],c=e[i+2],u=e[i+3],128===(192&s)&&128===(192&c)&&128===(192&u)&&(f=(15&o)<<18|(63&s)<<12|(63&c)<<6|63&u,f>65535&&1114112>f&&(a=f))}}null===a?(a=65533,l=1):a>65535&&(a-=65536,r.push(a>>>10&1023|55296),a=56320|1023&a),r.push(a),i+=l}return A(r)}function A(e){var t=e.length;if(Q>=t)return String.fromCharCode.apply(String,e);for(var n="",r=0;t>r;)n+=String.fromCharCode.apply(String,e.slice(r,r+=Q));return n}function E(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;n>i;i++)r+=String.fromCharCode(127&e[i]);return r}function O(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;n>i;i++)r+=String.fromCharCode(e[i]);return r}function I(e,t,n){var r=e.length;(!t||0>t)&&(t=0),(!n||0>n||n>r)&&(n=r);for(var i="",o=t;n>o;o++)i+=U(e[o]);return i}function P(e,t,n){for(var r=e.slice(t,n),i="",o=0;oe)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function D(e,t,n,r,i,o){if(!a.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||o>t)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function H(e,t,n,r){0>t&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-n,2);o>i;i++)e[n+i]=(t&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function W(e,t,n,r){0>t&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-n,4);o>i;i++)e[n+i]=t>>>8*(r?i:3-i)&255}function B(e,t,n,r,i,o){if(n+r>e.length)throw new RangeError("Index out of range");if(0>n)throw new RangeError("Index out of range")}function _(e,t,n,r,i){return i||B(e,t,n,4,3.4028234663852886e38,-3.4028234663852886e38),Z.write(e,t,n,r,23,4),n+4}function F(e,t,n,r,i){return i||B(e,t,n,8,1.7976931348623157e308,-1.7976931348623157e308),Z.write(e,t,n,r,52,8),n+8}function z(e){if(e=j(e).replace(ee,""),e.length<2)return"";for(;e.length%4!==0;)e+="=";return e}function j(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function U(e){return 16>e?"0"+e.toString(16):e.toString(16)}function q(e,t){t=t||1/0;for(var n,r=e.length,i=null,o=[],a=0;r>a;a++){if(n=e.charCodeAt(a),n>55295&&57344>n){if(!i){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(a+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(56320>n){(t-=3)>-1&&o.push(239,191,189),i=n;continue}n=(i-55296<<10|n-56320)+65536}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,128>n){if((t-=1)<0)break;o.push(n)}else if(2048>n){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(65536>n){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(1114112>n))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function G(e){for(var t=[],n=0;n>8,i=n%256,o.push(i),o.push(r);return o}function $(e){return X.toByteArray(z(e))}function V(e,t,n,r){for(var i=0;r>i&&!(i+n>=t.length||i>=e.length);i++)t[i+n]=e[i];return i}function K(e){return e!==e}var X=e("base64-js"),Z=e("ieee754"),J=e("isarray");n.Buffer=a,n.SlowBuffer=g,n.INSPECT_MAX_BYTES=50,a.TYPED_ARRAY_SUPPORT=void 0!==t.TYPED_ARRAY_SUPPORT?t.TYPED_ARRAY_SUPPORT:r(),n.kMaxLength=i(),a.poolSize=8192,a._augment=function(e){return e.__proto__=a.prototype,e},a.from=function(e,t,n){return l(null,e,t,n)},a.TYPED_ARRAY_SUPPORT&&(a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&a[Symbol.species]===a&&Object.defineProperty(a,Symbol.species,{value:null,configurable:!0})),a.alloc=function(e,t,n){return c(null,e,t,n)},a.allocUnsafe=function(e){return u(null,e)},a.allocUnsafeSlow=function(e){return u(null,e)},a.isBuffer=function(e){return!(null==e||!e._isBuffer)},a.compare=function(e,t){if(!a.isBuffer(e)||!a.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,i=0,o=Math.min(n,r);o>i;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return r>n?-1:n>r?1:0},a.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(e,t){if(!J(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return a.alloc(0);var n;if(void 0===t)for(t=0,n=0;nt;t+=2)x(this,t,t+1);return this},a.prototype.swap32=function(){var e=this.length;if(e%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;e>t;t+=4)x(this,t,t+3),x(this,t+1,t+2);return this},a.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?N(this,0,e):y.apply(this,arguments)},a.prototype.equals=function(e){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e?!0:0===a.compare(this,e)},a.prototype.inspect=function(){var e="",t=n.INSPECT_MAX_BYTES;return this.length>0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),""},a.prototype.compare=function(e,t,n,r,i){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),0>t||n>e.length||0>r||i>this.length)throw new RangeError("out of range index");if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,r>>>=0,i>>>=0,this===e)return 0;for(var o=i-r,l=n-t,s=Math.min(o,l),c=this.slice(r,i),u=e.slice(t,n),f=0;s>f;++f)if(c[f]!==u[f]){o=c[f],l=u[f];break}return l>o?-1:o>l?1:0},a.prototype.indexOf=function(e,t,n){if("string"==typeof t?(n=t,t=0):t>2147483647?t=2147483647:-2147483648>t&&(t=-2147483648),t>>=0,0===this.length)return-1;if(t>=this.length)return-1;if(0>t&&(t=Math.max(this.length+t,0)),"string"==typeof e&&(e=a.from(e,n)),a.isBuffer(e))return 0===e.length?-1:b(this,e,t,n);if("number"==typeof e)return a.TYPED_ARRAY_SUPPORT&&"function"===Uint8Array.prototype.indexOf?Uint8Array.prototype.indexOf.call(this,e,t):b(this,[e],t,n);throw new TypeError("val must be string, number or Buffer")},a.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},a.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t=0|t,isFinite(n)?(n=0|n,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-t;if((void 0===n||n>i)&&(n=i),e.length>0&&(0>n||0>t)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return w(this,e,t,n);case"utf8":case"utf-8":return k(this,e,t,n);case"ascii":return S(this,e,t,n);case"binary":return C(this,e,t,n);case"base64":return L(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return T(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var Q=4096;a.prototype.slice=function(e,t){var n=this.length;e=~~e,t=void 0===t?n:~~t,0>e?(e+=n,0>e&&(e=0)):e>n&&(e=n),0>t?(t+=n,0>t&&(t=0)):t>n&&(t=n),e>t&&(t=e);var r;if(a.TYPED_ARRAY_SUPPORT)r=this.subarray(e,t),r.__proto__=a.prototype;else{var i=t-e;r=new a(i,void 0);for(var o=0;i>o;o++)r[o]=this[o+e]}return r},a.prototype.readUIntLE=function(e,t,n){e=0|e,t=0|t,n||R(e,t,this.length);for(var r=this[e],i=1,o=0;++o0&&(i*=256);)r+=this[e+--t]*i;return r},a.prototype.readUInt8=function(e,t){return t||R(e,1,this.length),this[e]},a.prototype.readUInt16LE=function(e,t){return t||R(e,2,this.length),this[e]|this[e+1]<<8},a.prototype.readUInt16BE=function(e,t){return t||R(e,2,this.length),this[e]<<8|this[e+1]},a.prototype.readUInt32LE=function(e,t){return t||R(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},a.prototype.readUInt32BE=function(e,t){return t||R(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},a.prototype.readIntLE=function(e,t,n){e=0|e,t=0|t,n||R(e,t,this.length);for(var r=this[e],i=1,o=0;++o=i&&(r-=Math.pow(2,8*t)),r},a.prototype.readIntBE=function(e,t,n){e=0|e,t=0|t,n||R(e,t,this.length);for(var r=t,i=1,o=this[e+--r];r>0&&(i*=256);)o+=this[e+--r]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*t)),o},a.prototype.readInt8=function(e,t){return t||R(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},a.prototype.readInt16LE=function(e,t){t||R(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},a.prototype.readInt16BE=function(e,t){t||R(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},a.prototype.readInt32LE=function(e,t){return t||R(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},a.prototype.readInt32BE=function(e,t){return t||R(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},a.prototype.readFloatLE=function(e,t){return t||R(e,4,this.length),Z.read(this,e,!0,23,4)},a.prototype.readFloatBE=function(e,t){return t||R(e,4,this.length),Z.read(this,e,!1,23,4)},a.prototype.readDoubleLE=function(e,t){return t||R(e,8,this.length),Z.read(this,e,!0,52,8)},a.prototype.readDoubleBE=function(e,t){return t||R(e,8,this.length),Z.read(this,e,!1,52,8)},a.prototype.writeUIntLE=function(e,t,n,r){if(e=+e,t=0|t,n=0|n,!r){var i=Math.pow(2,8*n)-1;D(this,e,t,n,i,0)}var o=1,a=0;for(this[t]=255&e;++a=0&&(a*=256);)this[t+o]=e/a&255;return t+n},a.prototype.writeUInt8=function(e,t,n){return e=+e,t=0|t,n||D(this,e,t,1,255,0),a.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},a.prototype.writeUInt16LE=function(e,t,n){return e=+e,t=0|t,n||D(this,e,t,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):H(this,e,t,!0),t+2},a.prototype.writeUInt16BE=function(e,t,n){return e=+e,t=0|t,n||D(this,e,t,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):H(this,e,t,!1),t+2},a.prototype.writeUInt32LE=function(e,t,n){return e=+e,t=0|t,n||D(this,e,t,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):W(this,e,t,!0),t+4},a.prototype.writeUInt32BE=function(e,t,n){return e=+e,t=0|t,n||D(this,e,t,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):W(this,e,t,!1),t+4},a.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t=0|t,!r){var i=Math.pow(2,8*n-1);D(this,e,t,n,i-1,-i)}var o=0,a=1,l=0;for(this[t]=255&e;++oe&&0===l&&0!==this[t+o-1]&&(l=1),this[t+o]=(e/a>>0)-l&255;return t+n},a.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t=0|t,!r){var i=Math.pow(2,8*n-1);D(this,e,t,n,i-1,-i)}var o=n-1,a=1,l=0;for(this[t+o]=255&e;--o>=0&&(a*=256);)0>e&&0===l&&0!==this[t+o+1]&&(l=1),this[t+o]=(e/a>>0)-l&255;return t+n},a.prototype.writeInt8=function(e,t,n){return e=+e,t=0|t,n||D(this,e,t,1,127,-128),a.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),0>e&&(e=255+e+1),this[t]=255&e,t+1},a.prototype.writeInt16LE=function(e,t,n){return e=+e,t=0|t,n||D(this,e,t,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):H(this,e,t,!0),t+2},a.prototype.writeInt16BE=function(e,t,n){return e=+e,t=0|t,n||D(this,e,t,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):H(this,e,t,!1),t+2},a.prototype.writeInt32LE=function(e,t,n){return e=+e,t=0|t,n||D(this,e,t,4,2147483647,-2147483648),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):W(this,e,t,!0),t+4},a.prototype.writeInt32BE=function(e,t,n){return e=+e,t=0|t,n||D(this,e,t,4,2147483647,-2147483648),0>e&&(e=4294967295+e+1),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):W(this,e,t,!1),t+4},a.prototype.writeFloatLE=function(e,t,n){return _(this,e,t,!0,n)},a.prototype.writeFloatBE=function(e,t,n){return _(this,e,t,!1,n)},a.prototype.writeDoubleLE=function(e,t,n){return F(this,e,t,!0,n)},a.prototype.writeDoubleBE=function(e,t,n){return F(this,e,t,!1,n)},a.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&n>r&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(0>t)throw new RangeError("targetStart out of bounds");if(0>n||n>=this.length)throw new RangeError("sourceStart out of bounds");if(0>r)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-tn&&r>t)for(i=o-1;i>=0;i--)e[i+t]=this[i+n];else if(1e3>o||!a.TYPED_ARRAY_SUPPORT)for(i=0;o>i;i++)e[i+t]=this[i+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+o),t);return o},a.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var i=e.charCodeAt(0);256>i&&(e=i)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!a.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e=255&e);if(0>t||this.length=n)return this;t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0);var o;if("number"==typeof e)for(o=t;n>o;o++)this[o]=e;else{var l=a.isBuffer(e)?e:q(new a(e,r).toString()),s=l.length;for(o=0;n-t>o;o++)this[o+t]=l[o%s]}return this};var ee=/[^+\/0-9A-Za-z-_]/g}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"base64-js":1,ieee754:15,isarray:16}],4:[function(e,t,n){"use strict";function r(e){return e=e||{},"function"!=typeof e.codeMirrorInstance||"function"!=typeof e.codeMirrorInstance.defineMode?void console.log("CodeMirror Spell Checker: You must provide an instance of CodeMirror via the option `codeMirrorInstance`"):(String.prototype.includes||(String.prototype.includes=function(){return-1!==String.prototype.indexOf.apply(this,arguments)}),void e.codeMirrorInstance.defineMode("spell-checker",function(t){if(!r.aff_loading){r.aff_loading=!0;var n=new XMLHttpRequest;n.open("GET","https://cdn.jsdelivr.net/codemirror.spell-checker/latest/en_US.aff",!0),n.onload=function(){4===n.readyState&&200===n.status&&(r.aff_data=n.responseText,r.num_loaded++,2==r.num_loaded&&(r.typo=new i("en_US",r.aff_data,r.dic_data,{platform:"any"})))},n.send(null)}if(!r.dic_loading){r.dic_loading=!0;var o=new XMLHttpRequest;o.open("GET","https://cdn.jsdelivr.net/codemirror.spell-checker/latest/en_US.dic",!0),o.onload=function(){4===o.readyState&&200===o.status&&(r.dic_data=o.responseText,r.num_loaded++,2==r.num_loaded&&(r.typo=new i("en_US",r.aff_data,r.dic_data,{platform:"any"})))},o.send(null)}var a='!"#$%&()*+,-./:;<=>?@[\\]^_`{|}~ ',l={token:function(e){var t=e.peek(),n="";if(a.includes(t))return e.next(),null;for(;null!=(t=e.peek())&&!a.includes(t);)n+=t,e.next();return r.typo&&!r.typo.check(n)?"spell-error":null}},s=e.codeMirrorInstance.getMode(t,t.backdrop||"text/plain");return e.codeMirrorInstance.overlayMode(s,l,!0)}))}var i=e("typo-js");r.num_loaded=0,r.aff_loading=!1,r.dic_loading=!1,r.aff_data="",r.dic_data="",r.typo,t.exports=r},{"typo-js":18}],5:[function(t,n,r){!function(i){"object"==typeof r&&"object"==typeof n?i(t("../../lib/codemirror")):"function"==typeof e&&e.amd?e(["../../lib/codemirror"],i):i(CodeMirror)}(function(e){"use strict";function t(e){var t=e.getWrapperElement();e.state.fullScreenRestore={scrollTop:window.pageYOffset,scrollLeft:window.pageXOffset,width:t.style.width,height:t.style.height},t.style.width="",t.style.height="auto",t.className+=" CodeMirror-fullscreen",document.documentElement.style.overflow="hidden",e.refresh()}function n(e){var t=e.getWrapperElement();t.className=t.className.replace(/\s*CodeMirror-fullscreen\b/,""),document.documentElement.style.overflow="";var n=e.state.fullScreenRestore;t.style.width=n.width,t.style.height=n.height,window.scrollTo(n.scrollLeft,n.scrollTop),e.refresh()}e.defineOption("fullScreen",!1,function(r,i,o){o==e.Init&&(o=!1),!o!=!i&&(i?t(r):n(r))})})},{"../../lib/codemirror":10}],6:[function(t,n,r){!function(i){"object"==typeof r&&"object"==typeof n?i(t("../../lib/codemirror")):"function"==typeof e&&e.amd?e(["../../lib/codemirror"],i):i(CodeMirror)}(function(e){function t(e){e.state.placeholder&&(e.state.placeholder.parentNode.removeChild(e.state.placeholder),e.state.placeholder=null)}function n(e){t(e);var n=e.state.placeholder=document.createElement("pre");n.style.cssText="height: 0; overflow: visible",n.className="CodeMirror-placeholder";var r=e.getOption("placeholder");"string"==typeof r&&(r=document.createTextNode(r)),n.appendChild(r),e.display.lineSpace.insertBefore(n,e.display.lineSpace.firstChild)}function r(e){o(e)&&n(e)}function i(e){var r=e.getWrapperElement(),i=o(e);r.className=r.className.replace(" CodeMirror-empty","")+(i?" CodeMirror-empty":""),i?n(e):t(e)}function o(e){return 1===e.lineCount()&&""===e.getLine(0)}e.defineOption("placeholder","",function(n,o,a){var l=a&&a!=e.Init;if(o&&!l)n.on("blur",r),n.on("change",i),n.on("swapDoc",i),i(n);else if(!o&&l){n.off("blur",r),n.off("change",i),n.off("swapDoc",i),t(n);var s=n.getWrapperElement();s.className=s.className.replace(" CodeMirror-empty","")}o&&!n.hasFocus()&&r(n)})})},{"../../lib/codemirror":10}],7:[function(t,n,r){!function(i){"object"==typeof r&&"object"==typeof n?i(t("../../lib/codemirror")):"function"==typeof e&&e.amd?e(["../../lib/codemirror"],i):i(CodeMirror)}(function(e){"use strict";var t=/^(\s*)(>[> ]*|[*+-]\s|(\d+)([.)]))(\s*)/,n=/^(\s*)(>[> ]*|[*+-]|(\d+)[.)])(\s*)$/,r=/[*+-]\s/;e.commands.newlineAndIndentContinueMarkdownList=function(i){if(i.getOption("disableInput"))return e.Pass;for(var o=i.listSelections(),a=[],l=0;l")>=0?d[2]:parseInt(d[3],10)+1+d[4];a[l]="\n"+p+g+m}}i.replaceSelections(a)}})},{"../../lib/codemirror":10}],8:[function(t,n,r){!function(i){"object"==typeof r&&"object"==typeof n?i(t("../../lib/codemirror")):"function"==typeof e&&e.amd?e(["../../lib/codemirror"],i):i(CodeMirror)}(function(e){"use strict";e.overlayMode=function(t,n,r){return{startState:function(){return{base:e.startState(t),overlay:e.startState(n),basePos:0,baseCur:null,overlayPos:0,overlayCur:null,streamSeen:null}},copyState:function(r){return{base:e.copyState(t,r.base),overlay:e.copyState(n,r.overlay),basePos:r.basePos,baseCur:null,overlayPos:r.overlayPos,overlayCur:null}},token:function(e,i){return(e!=i.streamSeen||Math.min(i.basePos,i.overlayPos)=n.line,d=h?n:s(f,0),p=e.markText(u,d,{className:o});if(null==r?i.push(p):i.splice(r++,0,p),h)break;a=f}}function i(e){for(var t=e.state.markedSelection,n=0;n1)return o(e);var t=e.getCursor("start"),n=e.getCursor("end"),a=e.state.markedSelection;if(!a.length)return r(e,t,n);var s=a[0].find(),u=a[a.length-1].find();if(!s||!u||n.line-t.line=0||c(n,s.from)<=0)return o(e);for(;c(t,s.from)>0;)a.shift().clear(),s=a[0].find();for(c(t,s.from)<0&&(s.to.line-t.line0&&(n.line-u.from.linebo&&setTimeout(function(){s.display.input.reset(!0)},20),jt(this),Ki(),bt(this),this.curOp.forceUpdate=!0,Xr(this,i),r.autofocus&&!Ao||s.hasFocus()?setTimeout(Bi(vn,this),20):yn(this);for(var u in ta)ta.hasOwnProperty(u)&&ta[u](this,r[u],na);k(this),r.finishInit&&r.finishInit(this);for(var f=0;fbo&&(r.gutters.style.zIndex=-1,r.scroller.style.paddingRight=0),wo||go&&Ao||(r.scroller.draggable=!0),e&&(e.appendChild?e.appendChild(r.wrapper):e(r.wrapper)),r.viewFrom=r.viewTo=t.first,r.reportedViewFrom=r.reportedViewTo=t.first,r.view=[],r.renderedView=null,r.externalMeasured=null,r.viewOffset=0,r.lastWrapHeight=r.lastWrapWidth=0,r.updateLineNumbers=null,r.nativeBarWidth=r.barHeight=r.barWidth=0,r.scrollbarsClipped=!1,r.lineNumWidth=r.lineNumInnerWidth=r.lineNumChars=null,r.alignWidgets=!1,r.cachedCharWidth=r.cachedTextHeight=r.cachedPaddingH=null, +r.maxLine=null,r.maxLineLength=0,r.maxLineChanged=!1,r.wheelDX=r.wheelDY=r.wheelStartX=r.wheelStartY=null,r.shift=!1,r.selForContextMenu=null,r.activeTouch=null,n.init(r)}function n(t){t.doc.mode=e.getMode(t.options,t.doc.modeOption),r(t)}function r(e){e.doc.iter(function(e){e.stateAfter&&(e.stateAfter=null),e.styles&&(e.styles=null)}),e.doc.frontier=e.doc.first,_e(e,100),e.state.modeGen++,e.curOp&&Dt(e)}function i(e){e.options.lineWrapping?(Ja(e.display.wrapper,"CodeMirror-wrap"),e.display.sizer.style.minWidth="",e.display.sizerWidth=null):(Za(e.display.wrapper,"CodeMirror-wrap"),h(e)),a(e),Dt(e),lt(e),setTimeout(function(){y(e)},100)}function o(e){var t=yt(e.display),n=e.options.lineWrapping,r=n&&Math.max(5,e.display.scroller.clientWidth/xt(e.display)-3);return function(i){if(kr(e.doc,i))return 0;var o=0;if(i.widgets)for(var a=0;at.maxLineLength&&(t.maxLineLength=n,t.maxLine=e)})}function d(e){var t=Pi(e.gutters,"CodeMirror-linenumbers");-1==t&&e.lineNumbers?e.gutters=e.gutters.concat(["CodeMirror-linenumbers"]):t>-1&&!e.lineNumbers&&(e.gutters=e.gutters.slice(0),e.gutters.splice(t,1))}function p(e){var t=e.display,n=t.gutters.offsetWidth,r=Math.round(e.doc.height+qe(e.display));return{clientHeight:t.scroller.clientHeight,viewHeight:t.wrapper.clientHeight,scrollWidth:t.scroller.scrollWidth,clientWidth:t.scroller.clientWidth,viewWidth:t.wrapper.clientWidth,barLeft:e.options.fixedGutter?n:0,docHeight:r,scrollHeight:r+Ye(e)+t.barHeight,nativeBarWidth:t.nativeBarWidth,gutterWidth:n}}function m(e,t,n){this.cm=n;var r=this.vert=ji("div",[ji("div",null,null,"min-width: 1px")],"CodeMirror-vscrollbar"),i=this.horiz=ji("div",[ji("div",null,null,"height: 100%; min-height: 1px")],"CodeMirror-hscrollbar");e(r),e(i),Ea(r,"scroll",function(){r.clientHeight&&t(r.scrollTop,"vertical")}),Ea(i,"scroll",function(){i.clientWidth&&t(i.scrollLeft,"horizontal")}),this.checkedZeroWidth=!1,xo&&8>bo&&(this.horiz.style.minHeight=this.vert.style.minWidth="18px")}function g(){}function v(t){t.display.scrollbars&&(t.display.scrollbars.clear(),t.display.scrollbars.addClass&&Za(t.display.wrapper,t.display.scrollbars.addClass)),t.display.scrollbars=new e.scrollbarModel[t.options.scrollbarStyle](function(e){t.display.wrapper.insertBefore(e,t.display.scrollbarFiller),Ea(e,"mousedown",function(){t.state.focused&&setTimeout(function(){t.display.input.focus()},0)}),e.setAttribute("cm-not-content","true")},function(e,n){"horizontal"==n?on(t,e):rn(t,e)},t),t.display.scrollbars.addClass&&Ja(t.display.wrapper,t.display.scrollbars.addClass)}function y(e,t){t||(t=p(e));var n=e.display.barWidth,r=e.display.barHeight;x(e,t);for(var i=0;4>i&&n!=e.display.barWidth||r!=e.display.barHeight;i++)n!=e.display.barWidth&&e.options.lineWrapping&&O(e),x(e,p(e)),n=e.display.barWidth,r=e.display.barHeight}function x(e,t){var n=e.display,r=n.scrollbars.update(t);n.sizer.style.paddingRight=(n.barWidth=r.right)+"px",n.sizer.style.paddingBottom=(n.barHeight=r.bottom)+"px",n.heightForcer.style.borderBottom=r.bottom+"px solid transparent",r.right&&r.bottom?(n.scrollbarFiller.style.display="block",n.scrollbarFiller.style.height=r.bottom+"px",n.scrollbarFiller.style.width=r.right+"px"):n.scrollbarFiller.style.display="",r.bottom&&e.options.coverGutterNextToScrollbar&&e.options.fixedGutter?(n.gutterFiller.style.display="block",n.gutterFiller.style.height=r.bottom+"px",n.gutterFiller.style.width=t.gutterWidth+"px"):n.gutterFiller.style.display=""}function b(e,t,n){var r=n&&null!=n.top?Math.max(0,n.top):e.scroller.scrollTop;r=Math.floor(r-Ue(e));var i=n&&null!=n.bottom?n.bottom:r+e.wrapper.clientHeight,o=ni(t,r),a=ni(t,i);if(n&&n.ensure){var l=n.ensure.from.line,s=n.ensure.to.line;o>l?(o=l,a=ni(t,ri(Zr(t,l))+e.wrapper.clientHeight)):Math.min(s,t.lastLine())>=a&&(o=ni(t,ri(Zr(t,s))-e.wrapper.clientHeight),a=s)}return{from:o,to:Math.max(a,o+1)}}function w(e){var t=e.display,n=t.view;if(t.alignWidgets||t.gutters.firstChild&&e.options.fixedGutter){for(var r=C(t)-t.scroller.scrollLeft+e.doc.scrollLeft,i=t.gutters.offsetWidth,o=r+"px",a=0;a=n.viewFrom&&t.visible.to<=n.viewTo&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo)&&n.renderedView==n.view&&0==zt(e))return!1;k(e)&&(Wt(e),t.dims=P(e));var i=r.first+r.size,o=Math.max(t.visible.from-e.options.viewportMargin,r.first),a=Math.min(i,t.visible.to+e.options.viewportMargin);n.viewFroma&&n.viewTo-a<20&&(a=Math.min(i,n.viewTo)),Wo&&(o=br(e.doc,o),a=wr(e.doc,a));var l=o!=n.viewFrom||a!=n.viewTo||n.lastWrapHeight!=t.wrapperHeight||n.lastWrapWidth!=t.wrapperWidth;Ft(e,o,a),n.viewOffset=ri(Zr(e.doc,n.viewFrom)),e.display.mover.style.top=n.viewOffset+"px";var s=zt(e);if(!l&&0==s&&!t.force&&n.renderedView==n.view&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo))return!1;var c=Gi();return s>4&&(n.lineDiv.style.display="none"),R(e,n.updateLineNumbers,t.dims),s>4&&(n.lineDiv.style.display=""),n.renderedView=n.view,c&&Gi()!=c&&c.offsetHeight&&c.focus(),Ui(n.cursorDiv),Ui(n.selectionDiv),n.gutters.style.height=n.sizer.style.minHeight=0,l&&(n.lastWrapHeight=t.wrapperHeight,n.lastWrapWidth=t.wrapperWidth,_e(e,400)),n.updateLineNumbers=null,!0}function N(e,t){for(var n=t.viewport,r=!0;(r&&e.options.lineWrapping&&t.oldDisplayWidth!=$e(e)||(n&&null!=n.top&&(n={top:Math.min(e.doc.height+qe(e.display)-Ve(e),n.top)}),t.visible=b(e.display,e.doc,n),!(t.visible.from>=e.display.viewFrom&&t.visible.to<=e.display.viewTo)))&&M(e,t);r=!1){O(e);var i=p(e);Re(e),y(e,i),E(e,i)}t.signal(e,"update",e),e.display.viewFrom==e.display.reportedViewFrom&&e.display.viewTo==e.display.reportedViewTo||(t.signal(e,"viewportChange",e,e.display.viewFrom,e.display.viewTo),e.display.reportedViewFrom=e.display.viewFrom,e.display.reportedViewTo=e.display.viewTo)}function A(e,t){var n=new L(e,t);if(M(e,n)){O(e),N(e,n);var r=p(e);Re(e),y(e,r),E(e,r),n.finish()}}function E(e,t){e.display.sizer.style.minHeight=t.docHeight+"px",e.display.heightForcer.style.top=t.docHeight+"px",e.display.gutters.style.height=t.docHeight+e.display.barHeight+Ye(e)+"px"}function O(e){for(var t=e.display,n=t.lineDiv.offsetTop,r=0;rbo){var a=o.node.offsetTop+o.node.offsetHeight;i=a-n,n=a}else{var l=o.node.getBoundingClientRect();i=l.bottom-l.top}var s=o.line.height-i;if(2>i&&(i=yt(t)),(s>.001||-.001>s)&&(ei(o.line,i),I(o.line),o.rest))for(var c=0;c=t&&f.lineNumber;f.changes&&(Pi(f.changes,"gutter")>-1&&(h=!1),D(e,f,c,n)),h&&(Ui(f.lineNumber),f.lineNumber.appendChild(document.createTextNode(S(e.options,c)))),l=f.node.nextSibling}else{var d=U(e,f,c,n);a.insertBefore(d,l)}c+=f.size}for(;l;)l=r(l)}function D(e,t,n,r){for(var i=0;ibo&&(e.node.style.zIndex=2)),e.node}function W(e){var t=e.bgClass?e.bgClass+" "+(e.line.bgClass||""):e.line.bgClass;if(t&&(t+=" CodeMirror-linebackground"),e.background)t?e.background.className=t:(e.background.parentNode.removeChild(e.background),e.background=null);else if(t){var n=H(e);e.background=n.insertBefore(ji("div",null,t),n.firstChild)}}function B(e,t){var n=e.display.externalMeasured;return n&&n.line==t.line?(e.display.externalMeasured=null,t.measure=n.measure,n.built):Br(e,t)}function _(e,t){var n=t.text.className,r=B(e,t);t.text==t.node&&(t.node=r.pre),t.text.parentNode.replaceChild(r.pre,t.text),t.text=r.pre,r.bgClass!=t.bgClass||r.textClass!=t.textClass?(t.bgClass=r.bgClass,t.textClass=r.textClass,F(t)):n&&(t.text.className=n)}function F(e){W(e),e.line.wrapClass?H(e).className=e.line.wrapClass:e.node!=e.text&&(e.node.className="");var t=e.textClass?e.textClass+" "+(e.line.textClass||""):e.line.textClass;e.text.className=t||""}function z(e,t,n,r){if(t.gutter&&(t.node.removeChild(t.gutter),t.gutter=null),t.gutterBackground&&(t.node.removeChild(t.gutterBackground),t.gutterBackground=null),t.line.gutterClass){var i=H(t);t.gutterBackground=ji("div",null,"CodeMirror-gutter-background "+t.line.gutterClass,"left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px; width: "+r.gutterTotalWidth+"px"),i.insertBefore(t.gutterBackground,t.text)}var o=t.line.gutterMarkers;if(e.options.lineNumbers||o){var i=H(t),a=t.gutter=ji("div",null,"CodeMirror-gutter-wrapper","left: "+(e.options.fixedGutter?r.fixedPos:-r.gutterTotalWidth)+"px");if(e.display.input.setUneditable(a),i.insertBefore(a,t.text),t.line.gutterClass&&(a.className+=" "+t.line.gutterClass),!e.options.lineNumbers||o&&o["CodeMirror-linenumbers"]||(t.lineNumber=a.appendChild(ji("div",S(e.options,n),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+r.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+e.display.lineNumInnerWidth+"px"))),o)for(var l=0;l1)if(Fo&&Fo.text.join("\n")==t){if(r.ranges.length%Fo.text.length==0){s=[];for(var c=0;c=0;c--){var u=r.ranges[c],f=u.from(),h=u.to();u.empty()&&(n&&n>0?f=Bo(f.line,f.ch-n):e.state.overwrite&&!a?h=Bo(h.line,Math.min(Zr(o,h.line).text.length,h.ch+Ii(l).length)):Fo&&Fo.lineWise&&Fo.text.join("\n")==t&&(f=h=Bo(f.line,0)));var d=e.curOp.updateInput,p={from:f,to:h,text:s?s[c%s.length]:l,origin:i||(a?"paste":e.state.cutIncoming?"cut":"+input")};Tn(e.doc,p),Ci(e,"inputRead",e,p)}t&&!a&&Q(e,t),Bn(e),e.curOp.updateInput=d,e.curOp.typing=!0,e.state.pasteIncoming=e.state.cutIncoming=!1}function J(e,t){var n=e.clipboardData&&e.clipboardData.getData("text/plain");return n?(e.preventDefault(),t.isReadOnly()||t.options.disableInput||At(t,function(){Z(t,n,0,null,"paste")}),!0):void 0}function Q(e,t){if(e.options.electricChars&&e.options.smartIndent)for(var n=e.doc.sel,r=n.ranges.length-1;r>=0;r--){var i=n.ranges[r];if(!(i.head.ch>100||r&&n.ranges[r-1].head.line==i.head.line)){var o=e.getModeAt(i.head),a=!1;if(o.electricChars){for(var l=0;l-1){a=Fn(e,i.head.line,"smart");break}}else o.electricInput&&o.electricInput.test(Zr(e.doc,i.head.line).text.slice(0,i.head.ch))&&(a=Fn(e,i.head.line,"smart"));a&&Ci(e,"electricInput",e,i.head.line)}}}function ee(e){for(var t=[],n=[],r=0;ri?c.map:u[i],a=0;ai?e.line:e.rest[i]),f=o[a]+r;return(0>r||l!=t)&&(f=o[a+(r?1:0)]),Bo(s,f)}}}var i=e.text.firstChild,o=!1;if(!t||!Va(i,t))return ae(Bo(ti(e.line),0),!0);if(t==i&&(o=!0,t=i.childNodes[n],n=0,!t)){var a=e.rest?Ii(e.rest):e.line;return ae(Bo(ti(a),a.text.length),o)}var l=3==t.nodeType?t:null,s=t;for(l||1!=t.childNodes.length||3!=t.firstChild.nodeType||(l=t.firstChild,n&&(n=l.nodeValue.length));s.parentNode!=i;)s=s.parentNode;var c=e.measure,u=c.maps,f=r(l,s,n);if(f)return ae(f,o);for(var h=s.nextSibling,d=l?l.nodeValue.length-n:0;h;h=h.nextSibling){if(f=r(h,h.firstChild,0))return ae(Bo(f.line,f.ch-d),o);d+=h.textContent.length}for(var p=s.previousSibling,d=n;p;p=p.previousSibling){if(f=r(p,p.firstChild,-1))return ae(Bo(f.line,f.ch+d),o);d+=h.textContent.length}}function ce(e,t,n,r,i){function o(e){return function(t){return t.id==e}}function a(t){if(1==t.nodeType){var n=t.getAttribute("cm-text");if(null!=n)return""==n&&(n=t.textContent.replace(/\u200b/g,"")),void(l+=n);var u,f=t.getAttribute("cm-marker");if(f){var h=e.findMarks(Bo(r,0),Bo(i+1,0),o(+f));return void(h.length&&(u=h[0].find())&&(l+=Jr(e.doc,u.from,u.to).join(c)))}if("false"==t.getAttribute("contenteditable"))return;for(var d=0;d=0){var a=K(o.from(),i.from()),l=V(o.to(),i.to()),s=o.empty()?i.from()==i.head:o.from()==o.head;t>=r&&--t,e.splice(--r,2,new fe(s?l:a,s?a:l))}}return new ue(e,t)}function de(e,t){return new ue([new fe(e,t||e)],0)}function pe(e,t){return Math.max(e.first,Math.min(t,e.first+e.size-1))}function me(e,t){if(t.linen?Bo(n,Zr(e,n).text.length):ge(t,Zr(e,t.line).text.length)}function ge(e,t){var n=e.ch;return null==n||n>t?Bo(e.line,t):0>n?Bo(e.line,0):e}function ve(e,t){return t>=e.first&&t=t.ch:l.to>t.ch))){if(i&&(Pa(s,"beforeCursorEnter"),s.explicitlyCleared)){if(o.markedSpans){--a;continue}break}if(!s.atomic)continue;if(n){var c,u=s.find(0>r?1:-1);if((0>r?s.inclusiveRight:s.inclusiveLeft)&&(u=Pe(e,u,-r,u&&u.line==t.line?o:null)),u&&u.line==t.line&&(c=_o(u,n))&&(0>r?0>c:c>0))return Oe(e,u,t,r,i)}var f=s.find(0>r?-1:1);return(0>r?s.inclusiveLeft:s.inclusiveRight)&&(f=Pe(e,f,r,f.line==t.line?o:null)),f?Oe(e,f,t,r,i):null}}return t}function Ie(e,t,n,r,i){var o=r||1,a=Oe(e,t,n,o,i)||!i&&Oe(e,t,n,o,!0)||Oe(e,t,n,-o,i)||!i&&Oe(e,t,n,-o,!0);return a?a:(e.cantEdit=!0,Bo(e.first,0))}function Pe(e,t,n,r){return 0>n&&0==t.ch?t.line>e.first?me(e,Bo(t.line-1)):null:n>0&&t.ch==(r||Zr(e,t.line)).text.length?t.line=e.display.viewTo||l.to().linet&&(t=0),t=Math.round(t),r=Math.round(r),l.appendChild(ji("div",null,"CodeMirror-selected","position: absolute; left: "+e+"px; top: "+t+"px; width: "+(null==n?u-e:n)+"px; height: "+(r-t)+"px"))}function i(t,n,i){function o(n,r){return ht(e,Bo(t,n),"div",f,r)}var l,s,f=Zr(a,t),h=f.text.length;return eo(ii(f),n||0,null==i?h:i,function(e,t,a){var f,d,p,m=o(e,"left");if(e==t)f=m,d=p=m.left;else{if(f=o(t-1,"right"),"rtl"==a){var g=m;m=f,f=g}d=m.left,p=f.right}null==n&&0==e&&(d=c),f.top-m.top>3&&(r(d,m.top,null,m.bottom),d=c,m.bottoms.bottom||f.bottom==s.bottom&&f.right>s.right)&&(s=f),c+1>d&&(d=c),r(d,f.top,p-d,f.bottom)}),{start:l,end:s}}var o=e.display,a=e.doc,l=document.createDocumentFragment(),s=Ge(e.display),c=s.left,u=Math.max(o.sizerWidth,$e(e)-o.sizer.offsetLeft)-s.right,f=t.from(),h=t.to();if(f.line==h.line)i(f.line,f.ch,h.ch);else{var d=Zr(a,f.line),p=Zr(a,h.line),m=yr(d)==yr(p),g=i(f.line,f.ch,m?d.text.length+1:null).end,v=i(h.line,m?0:null,h.ch).start;m&&(g.top0?t.blinker=setInterval(function(){t.cursorDiv.style.visibility=(n=!n)?"":"hidden"},e.options.cursorBlinkRate):e.options.cursorBlinkRate<0&&(t.cursorDiv.style.visibility="hidden")}}function _e(e,t){e.doc.mode.startState&&e.doc.frontier=e.display.viewTo)){var n=+new Date+e.options.workTime,r=sa(t.mode,je(e,t.frontier)),i=[];t.iter(t.frontier,Math.min(t.first+t.size,e.display.viewTo+500),function(o){if(t.frontier>=e.display.viewFrom){var a=o.styles,l=o.text.length>e.options.maxHighlightLength,s=Rr(e,o,l?sa(t.mode,r):r,!0);o.styles=s.styles;var c=o.styleClasses,u=s.classes;u?o.styleClasses=u:c&&(o.styleClasses=null);for(var f=!a||a.length!=o.styles.length||c!=u&&(!c||!u||c.bgClass!=u.bgClass||c.textClass!=u.textClass),h=0;!f&&hn?(_e(e,e.options.workDelay),!0):void 0}),i.length&&At(e,function(){for(var t=0;ta;--l){if(l<=o.first)return o.first;var s=Zr(o,l-1);if(s.stateAfter&&(!n||l<=o.frontier))return l;var c=Fa(s.text,null,e.options.tabSize);(null==i||r>c)&&(i=l-1,r=c)}return i}function je(e,t,n){var r=e.doc,i=e.display;if(!r.mode.startState)return!0;var o=ze(e,t,n),a=o>r.first&&Zr(r,o-1).stateAfter;return a=a?sa(r.mode,a):ca(r.mode),r.iter(o,t,function(n){Hr(e,n.text,a);var l=o==t-1||o%5==0||o>=i.viewFrom&&o2&&o.push((s.bottom+c.top)/2-n.top)}}o.push(n.bottom-n.top)}}function Xe(e,t,n){if(e.line==t)return{map:e.measure.map,cache:e.measure.cache};for(var r=0;rn)return{map:e.measure.maps[r],cache:e.measure.caches[r],before:!0}}function Ze(e,t){t=yr(t);var n=ti(t),r=e.display.externalMeasured=new Pt(e.doc,t,n);r.lineN=n;var i=r.built=Br(e,r);return r.text=i.pre,qi(e.display.lineMeasure,i.pre),r}function Je(e,t,n,r){return tt(e,et(e,t),n,r)}function Qe(e,t){if(t>=e.display.viewFrom&&t=n.lineN&&tt?(i=0,o=1,a="left"):c>t?(i=t-s,o=i+1):(l==e.length-3||t==c&&e[l+3]>t)&&(o=c-s,i=o-1,t>=c&&(a="right")),null!=i){if(r=e[l+2],s==c&&n==(r.insertLeft?"left":"right")&&(a=n),"left"==n&&0==i)for(;l&&e[l-2]==e[l-3]&&e[l-1].insertLeft;)r=e[(l-=3)+2],a="left";if("right"==n&&i==c-s)for(;lu;u++){for(;l&&zi(t.line.text.charAt(o.coverStart+l));)--l;for(;o.coverStart+sbo&&0==l&&s==o.coverEnd-o.coverStart)i=a.parentNode.getBoundingClientRect();else if(xo&&e.options.lineWrapping){var f=qa(a,l,s).getClientRects();i=f.length?f["right"==r?f.length-1:0]:qo}else i=qa(a,l,s).getBoundingClientRect()||qo;if(i.left||i.right||0==l)break;s=l,l-=1,c="right"}xo&&11>bo&&(i=it(e.display.measure,i))}else{l>0&&(c=r="right");var f;i=e.options.lineWrapping&&(f=a.getClientRects()).length>1?f["right"==r?f.length-1:0]:a.getBoundingClientRect()}if(xo&&9>bo&&!l&&(!i||!i.left&&!i.right)){var h=a.parentNode.getClientRects()[0];i=h?{left:h.left,right:h.left+xt(e.display),top:h.top,bottom:h.bottom}:qo}for(var d=i.top-t.rect.top,p=i.bottom-t.rect.top,m=(d+p)/2,g=t.view.measure.heights,u=0;un.from?a(e-1):a(e,r)}r=r||Zr(e.doc,t.line),i||(i=et(e,r));var s=ii(r),c=t.ch;if(!s)return a(c);var u=co(s,c),f=l(c,u);return null!=al&&(f.other=l(c,al)),f}function pt(e,t){var n=0,t=me(e.doc,t);e.options.lineWrapping||(n=xt(e.display)*t.ch);var r=Zr(e.doc,t.line),i=ri(r)+Ue(e.display);return{left:n,right:n,top:i,bottom:i+r.height}}function mt(e,t,n,r){var i=Bo(e,t);return i.xRel=r,n&&(i.outside=!0),i}function gt(e,t,n){var r=e.doc;if(n+=e.display.viewOffset,0>n)return mt(r.first,0,!0,-1);var i=ni(r,n),o=r.first+r.size-1;if(i>o)return mt(r.first+r.size-1,Zr(r,o).text.length,!0,1);0>t&&(t=0);for(var a=Zr(r,i);;){var l=vt(e,a,i,t,n),s=gr(a),c=s&&s.find(0,!0);if(!s||!(l.ch>c.from.ch||l.ch==c.from.ch&&l.xRel>0))return l;i=ti(a=c.to.line)}}function vt(e,t,n,r,i){function o(r){var i=dt(e,Bo(n,r),"line",t,c);return l=!0,a>i.bottom?i.left-s:ag)return mt(n,d,v,1);for(;;){if(u?d==h||d==fo(t,h,1):1>=d-h){for(var y=p>r||g-r>=r-p?h:d,x=r-(y==h?p:g);zi(t.text.charAt(y));)++y;var b=mt(n,y,y==h?m:v,-1>x?-1:x>1?1:0);return b}var w=Math.ceil(f/2),k=h+w;if(u){k=h;for(var S=0;w>S;++S)k=fo(t,k,1)}var C=o(k);C>r?(d=k,g=C,(v=l)&&(g+=1e3),f=w):(h=k,p=C,m=l,f-=w)}}function yt(e){if(null!=e.cachedTextHeight)return e.cachedTextHeight;if(null==zo){zo=ji("pre");for(var t=0;49>t;++t)zo.appendChild(document.createTextNode("x")),zo.appendChild(ji("br"));zo.appendChild(document.createTextNode("x"))}qi(e.measure,zo);var n=zo.offsetHeight/50;return n>3&&(e.cachedTextHeight=n),Ui(e.measure),n||1}function xt(e){if(null!=e.cachedCharWidth)return e.cachedCharWidth;var t=ji("span","xxxxxxxxxx"),n=ji("pre",[t]);qi(e.measure,n);var r=t.getBoundingClientRect(),i=(r.right-r.left)/10;return i>2&&(e.cachedCharWidth=i),i||10}function bt(e){e.curOp={cm:e,viewChanged:!1,startHeight:e.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,focus:!1,id:++Yo},Go?Go.ops.push(e.curOp):e.curOp.ownsGroup=Go={ops:[e.curOp],delayedCallbacks:[]}}function wt(e){var t=e.delayedCallbacks,n=0;do{for(;n=n.viewTo)||n.maxLineChanged&&t.options.lineWrapping,e.update=e.mustUpdate&&new L(t,e.mustUpdate&&{top:e.scrollTop,ensure:e.scrollToPos},e.forceUpdate)}function Lt(e){e.updatedDisplay=e.mustUpdate&&M(e.cm,e.update)}function Tt(e){var t=e.cm,n=t.display;e.updatedDisplay&&O(t),e.barMeasure=p(t),n.maxLineChanged&&!t.options.lineWrapping&&(e.adjustWidthTo=Je(t,n.maxLine,n.maxLine.text.length).left+3,t.display.sizerWidth=e.adjustWidthTo,e.barMeasure.scrollWidth=Math.max(n.scroller.clientWidth,n.sizer.offsetLeft+e.adjustWidthTo+Ye(t)+t.display.barWidth),e.maxScrollLeft=Math.max(0,n.sizer.offsetLeft+e.adjustWidthTo-$e(t))),(e.updatedDisplay||e.selectionChanged)&&(e.preparedSelection=n.input.prepareSelection(e.focus))}function Mt(e){var t=e.cm;null!=e.adjustWidthTo&&(t.display.sizer.style.minWidth=e.adjustWidthTo+"px",e.maxScrollLefto;o=r){var a=new Pt(e.doc,Zr(e.doc,o),o);r=o+a.size,i.push(a)}return i}function Dt(e,t,n,r){null==t&&(t=e.doc.first),null==n&&(n=e.doc.first+e.doc.size),r||(r=0);var i=e.display;if(r&&nt)&&(i.updateLineNumbers=t),e.curOp.viewChanged=!0,t>=i.viewTo)Wo&&br(e.doc,t)i.viewFrom?Wt(e):(i.viewFrom+=r,i.viewTo+=r);else if(t<=i.viewFrom&&n>=i.viewTo)Wt(e);else if(t<=i.viewFrom){var o=_t(e,n,n+r,1);o?(i.view=i.view.slice(o.index),i.viewFrom=o.lineN,i.viewTo+=r):Wt(e)}else if(n>=i.viewTo){var o=_t(e,t,t,-1);o?(i.view=i.view.slice(0,o.index),i.viewTo=o.lineN):Wt(e)}else{var a=_t(e,t,t,-1),l=_t(e,n,n+r,1);a&&l?(i.view=i.view.slice(0,a.index).concat(Rt(e,a.lineN,l.lineN)).concat(i.view.slice(l.index)),i.viewTo+=r):Wt(e)}var s=i.externalMeasured;s&&(n=i.lineN&&t=r.viewTo)){var o=r.view[Bt(e,t)];if(null!=o.node){var a=o.changes||(o.changes=[]);-1==Pi(a,n)&&a.push(n)}}}function Wt(e){e.display.viewFrom=e.display.viewTo=e.doc.first,e.display.view=[],e.display.viewOffset=0}function Bt(e,t){if(t>=e.display.viewTo)return null;if(t-=e.display.viewFrom,0>t)return null;for(var n=e.display.view,r=0;rt)return r}function _t(e,t,n,r){var i,o=Bt(e,t),a=e.display.view;if(!Wo||n==e.doc.first+e.doc.size)return{index:o,lineN:n};for(var l=0,s=e.display.viewFrom;o>l;l++)s+=a[l].size;if(s!=t){if(r>0){if(o==a.length-1)return null;i=s+a[o].size-t,o++}else i=s-t;t+=i,n+=i}for(;br(e.doc,n)!=n;){if(o==(0>r?0:a.length-1))return null;n+=r*a[o-(0>r?1:0)].size,o+=r}return{index:o,lineN:n}}function Ft(e,t,n){var r=e.display,i=r.view;0==i.length||t>=r.viewTo||n<=r.viewFrom?(r.view=Rt(e,t,n),r.viewFrom=t):(r.viewFrom>t?r.view=Rt(e,t,r.viewFrom).concat(r.view):r.viewFromn&&(r.view=r.view.slice(0,Bt(e,n)))),r.viewTo=n}function zt(e){for(var t=e.display.view,n=0,r=0;r400}var i=e.display;Ea(i.scroller,"mousedown",Et(e,$t)),xo&&11>bo?Ea(i.scroller,"dblclick",Et(e,function(t){if(!Ti(e,t)){var n=Yt(e,t);if(n&&!Jt(e,t)&&!Gt(e.display,t)){Ma(t);var r=e.findWordAt(n);be(e.doc,r.anchor,r.head)}}})):Ea(i.scroller,"dblclick",function(t){Ti(e,t)||Ma(t)}),Do||Ea(i.scroller,"contextmenu",function(t){xn(e,t)});var o,a={end:0};Ea(i.scroller,"touchstart",function(t){if(!Ti(e,t)&&!n(t)){clearTimeout(o);var r=+new Date;i.activeTouch={start:r,moved:!1,prev:r-a.end<=300?a:null},1==t.touches.length&&(i.activeTouch.left=t.touches[0].pageX,i.activeTouch.top=t.touches[0].pageY)}}),Ea(i.scroller,"touchmove",function(){i.activeTouch&&(i.activeTouch.moved=!0)}),Ea(i.scroller,"touchend",function(n){var o=i.activeTouch;if(o&&!Gt(i,n)&&null!=o.left&&!o.moved&&new Date-o.start<300){var a,l=e.coordsChar(i.activeTouch,"page");a=!o.prev||r(o,o.prev)?new fe(l,l):!o.prev.prev||r(o,o.prev.prev)?e.findWordAt(l):new fe(Bo(l.line,0),me(e.doc,Bo(l.line+1,0))),e.setSelection(a.anchor,a.head),e.focus(),Ma(n)}t()}),Ea(i.scroller,"touchcancel",t),Ea(i.scroller,"scroll",function(){i.scroller.clientHeight&&(rn(e,i.scroller.scrollTop),on(e,i.scroller.scrollLeft,!0),Pa(e,"scroll",e))}),Ea(i.scroller,"mousewheel",function(t){an(e,t)}),Ea(i.scroller,"DOMMouseScroll",function(t){an(e,t)}),Ea(i.wrapper,"scroll",function(){i.wrapper.scrollTop=i.wrapper.scrollLeft=0}),i.dragFunctions={enter:function(t){Ti(e,t)||Aa(t)},over:function(t){Ti(e,t)||(tn(e,t),Aa(t))},start:function(t){en(e,t)},drop:Et(e,Qt),leave:function(t){Ti(e,t)||nn(e)}};var l=i.input.getField();Ea(l,"keyup",function(t){pn.call(e,t)}),Ea(l,"keydown",Et(e,hn)),Ea(l,"keypress",Et(e,mn)),Ea(l,"focus",Bi(vn,e)),Ea(l,"blur",Bi(yn,e))}function Ut(t,n,r){var i=r&&r!=e.Init;if(!n!=!i){var o=t.display.dragFunctions,a=n?Ea:Ia;a(t.display.scroller,"dragstart",o.start),a(t.display.scroller,"dragenter",o.enter),a(t.display.scroller,"dragover",o.over),a(t.display.scroller,"dragleave",o.leave),a(t.display.scroller,"drop",o.drop)}}function qt(e){var t=e.display;t.lastWrapHeight==t.wrapper.clientHeight&&t.lastWrapWidth==t.wrapper.clientWidth||(t.cachedCharWidth=t.cachedTextHeight=t.cachedPaddingH=null,t.scrollbarsClipped=!1,e.setSize())}function Gt(e,t){for(var n=wi(t);n!=e.wrapper;n=n.parentNode)if(!n||1==n.nodeType&&"true"==n.getAttribute("cm-ignore-events")||n.parentNode==e.sizer&&n!=e.mover)return!0}function Yt(e,t,n,r){var i=e.display;if(!n&&"true"==wi(t).getAttribute("cm-not-content"))return null;var o,a,l=i.lineSpace.getBoundingClientRect();try{o=t.clientX-l.left,a=t.clientY-l.top}catch(t){return null}var s,c=gt(e,o,a);if(r&&1==c.xRel&&(s=Zr(e.doc,c.line).text).length==c.ch){var u=Fa(s,s.length,e.options.tabSize)-s.length;c=Bo(c.line,Math.max(0,Math.round((o-Ge(e.display).left)/xt(e.display))-u))}return c}function $t(e){var t=this,n=t.display;if(!(Ti(t,e)||n.activeTouch&&n.input.supportsTouch())){if(n.shift=e.shiftKey,Gt(n,e))return void(wo||(n.scroller.draggable=!1,setTimeout(function(){n.scroller.draggable=!0},100)));if(!Jt(t,e)){var r=Yt(t,e);switch(window.focus(),ki(e)){case 1:t.state.selectingText?t.state.selectingText(e):r?Vt(t,e,r):wi(e)==n.scroller&&Ma(e);break;case 2:wo&&(t.state.lastMiddleDown=+new Date),r&&be(t.doc,r),setTimeout(function(){n.input.focus()},20),Ma(e);break;case 3:Do?xn(t,e):gn(t)}}}}function Vt(e,t,n){xo?setTimeout(Bi(X,e),0):e.curOp.focus=Gi();var r,i=+new Date;Uo&&Uo.time>i-400&&0==_o(Uo.pos,n)?r="triple":jo&&jo.time>i-400&&0==_o(jo.pos,n)?(r="double",Uo={time:i,pos:n}):(r="single",jo={time:i,pos:n});var o,a=e.doc.sel,l=Eo?t.metaKey:t.ctrlKey;e.options.dragDrop&&el&&!e.isReadOnly()&&"single"==r&&(o=a.contains(n))>-1&&(_o((o=a.ranges[o]).from(),n)<0||n.xRel>0)&&(_o(o.to(),n)>0||n.xRel<0)?Kt(e,t,n,l):Xt(e,t,n,r,l)}function Kt(e,t,n,r){var i=e.display,o=+new Date,a=Et(e,function(l){wo&&(i.scroller.draggable=!1),e.state.draggingText=!1,Ia(document,"mouseup",a),Ia(i.scroller,"drop",a),Math.abs(t.clientX-l.clientX)+Math.abs(t.clientY-l.clientY)<10&&(Ma(l),!r&&+new Date-200=p;p++){var v=Zr(c,p).text,y=za(v,s,o);s==d?i.push(new fe(Bo(p,y),Bo(p,y))):v.length>y&&i.push(new fe(Bo(p,y),Bo(p,za(v,d,o))))}i.length||i.push(new fe(n,n)),Te(c,he(h.ranges.slice(0,f).concat(i),f),{origin:"*mouse",scroll:!1}),e.scrollIntoView(t)}else{var x=u,b=x.anchor,w=t;if("single"!=r){if("double"==r)var k=e.findWordAt(t);else var k=new fe(Bo(t.line,0),me(c,Bo(t.line+1,0)));_o(k.anchor,b)>0?(w=k.head,b=K(x.from(),k.anchor)):(w=k.anchor,b=V(x.to(),k.head))}var i=h.ranges.slice(0);i[f]=new fe(me(c,b),w),Te(c,he(i,f),Ba)}}function a(t){var n=++y,i=Yt(e,t,!0,"rect"==r);if(i)if(0!=_o(i,g)){e.curOp.focus=Gi(),o(i);var l=b(s,c);(i.line>=l.to||i.linev.bottom?20:0;u&&setTimeout(Et(e,function(){y==n&&(s.scroller.scrollTop+=u,a(t))}),50)}}function l(t){e.state.selectingText=!1,y=1/0,Ma(t),s.input.focus(),Ia(document,"mousemove",x),Ia(document,"mouseup",w),c.history.lastSelOrigin=null}var s=e.display,c=e.doc;Ma(t);var u,f,h=c.sel,d=h.ranges;if(i&&!t.shiftKey?(f=c.sel.contains(n),u=f>-1?d[f]:new fe(n,n)):(u=c.sel.primary(),f=c.sel.primIndex),Oo?t.shiftKey&&t.metaKey:t.altKey)r="rect",i||(u=new fe(n,n)),n=Yt(e,t,!0,!0),f=-1;else if("double"==r){var p=e.findWordAt(n);u=e.display.shift||c.extend?xe(c,u,p.anchor,p.head):p}else if("triple"==r){var m=new fe(Bo(n.line,0),me(c,Bo(n.line+1,0)));u=e.display.shift||c.extend?xe(c,u,m.anchor,m.head):m}else u=xe(c,u,n);i?-1==f?(f=d.length,Te(c,he(d.concat([u]),f),{scroll:!1,origin:"*mouse"})):d.length>1&&d[f].empty()&&"single"==r&&!t.shiftKey?(Te(c,he(d.slice(0,f).concat(d.slice(f+1)),0),{scroll:!1,origin:"*mouse"}),h=c.sel):ke(c,f,u,Ba):(f=0,Te(c,new ue([u],0),Ba),h=c.sel);var g=n,v=s.wrapper.getBoundingClientRect(),y=0,x=Et(e,function(e){ki(e)?a(e):l(e)}),w=Et(e,l);e.state.selectingText=w,Ea(document,"mousemove",x),Ea(document,"mouseup",w)}function Zt(e,t,n,r){try{var i=t.clientX,o=t.clientY}catch(t){return!1}if(i>=Math.floor(e.display.gutters.getBoundingClientRect().right))return!1;r&&Ma(t);var a=e.display,l=a.lineDiv.getBoundingClientRect();if(o>l.bottom||!Ni(e,n))return bi(t);o-=l.top-a.viewOffset;for(var s=0;s=i){var u=ni(e.doc,o),f=e.options.gutters[s];return Pa(e,n,e,u,f,t),bi(t)}}}function Jt(e,t){return Zt(e,t,"gutterClick",!0)}function Qt(e){var t=this;if(nn(t),!Ti(t,e)&&!Gt(t.display,e)){Ma(e),xo&&($o=+new Date);var n=Yt(t,e,!0),r=e.dataTransfer.files;if(n&&!t.isReadOnly())if(r&&r.length&&window.FileReader&&window.File)for(var i=r.length,o=Array(i),a=0,l=function(e,r){if(!t.options.allowDropFileTypes||-1!=Pi(t.options.allowDropFileTypes,e.type)){var l=new FileReader;l.onload=Et(t,function(){var e=l.result;if(/[\x00-\x08\x0e-\x1f]{2}/.test(e)&&(e=""),o[r]=e,++a==i){n=me(t.doc,n);var s={from:n,to:n,text:t.doc.splitLines(o.join(t.doc.lineSeparator())),origin:"paste"};Tn(t.doc,s),Le(t.doc,de(n,Qo(s)))}}),l.readAsText(e)}},s=0;i>s;++s)l(r[s],s);else{if(t.state.draggingText&&t.doc.sel.contains(n)>-1)return t.state.draggingText(e),void setTimeout(function(){t.display.input.focus()},20);try{var o=e.dataTransfer.getData("Text");if(o){if(t.state.draggingText&&!(Eo?e.altKey:e.ctrlKey))var c=t.listSelections();if(Me(t.doc,de(n,n)),c)for(var s=0;sa.clientWidth,s=a.scrollHeight>a.clientHeight;if(r&&l||i&&s){if(i&&Eo&&wo)e:for(var c=t.target,u=o.view;c!=a;c=c.parentNode)for(var f=0;fh?d=Math.max(0,d+h-50):p=Math.min(e.doc.height,p+h+50),A(e,{top:d,bottom:p})}20>Vo&&(null==o.wheelStartX?(o.wheelStartX=a.scrollLeft,o.wheelStartY=a.scrollTop,o.wheelDX=r,o.wheelDY=i,setTimeout(function(){if(null!=o.wheelStartX){var e=a.scrollLeft-o.wheelStartX,t=a.scrollTop-o.wheelStartY,n=t&&o.wheelDY&&t/o.wheelDY||e&&o.wheelDX&&e/o.wheelDX;o.wheelStartX=o.wheelStartY=null,n&&(Ko=(Ko*Vo+n)/(Vo+1),++Vo)}},200)):(o.wheelDX+=r,o.wheelDY+=i))}}function ln(e,t,n){if("string"==typeof t&&(t=ua[t],!t))return!1;e.display.input.ensurePolled();var r=e.display.shift,i=!1;try{e.isReadOnly()&&(e.state.suppressEdits=!0),n&&(e.display.shift=!1),i=t(e)!=Ha}finally{e.display.shift=r,e.state.suppressEdits=!1}return i}function sn(e,t,n){for(var r=0;rbo&&27==e.keyCode&&(e.returnValue=!1);var n=e.keyCode;t.display.shift=16==n||e.shiftKey;var r=un(t,e);Co&&(Jo=r?n:null,!r&&88==n&&!rl&&(Eo?e.metaKey:e.ctrlKey)&&t.replaceSelection("",null,"cut")),18!=n||/\bCodeMirror-crosshair\b/.test(t.display.lineDiv.className)||dn(t)}}function dn(e){function t(e){18!=e.keyCode&&e.altKey||(Za(n,"CodeMirror-crosshair"),Ia(document,"keyup",t),Ia(document,"mouseover",t))}var n=e.display.lineDiv;Ja(n,"CodeMirror-crosshair"),Ea(document,"keyup",t),Ea(document,"mouseover",t)}function pn(e){16==e.keyCode&&(this.doc.sel.shift=!1),Ti(this,e)}function mn(e){var t=this;if(!(Gt(t.display,e)||Ti(t,e)||e.ctrlKey&&!e.altKey||Eo&&e.metaKey)){var n=e.keyCode,r=e.charCode;if(Co&&n==Jo)return Jo=null,void Ma(e);if(!Co||e.which&&!(e.which<10)||!un(t,e)){var i=String.fromCharCode(null==r?n:r);fn(t,e,i)||t.display.input.onKeyPress(e)}}}function gn(e){e.state.delayingBlurEvent=!0,setTimeout(function(){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1,yn(e))},100)}function vn(e){e.state.delayingBlurEvent&&(e.state.delayingBlurEvent=!1),"nocursor"!=e.options.readOnly&&(e.state.focused||(Pa(e,"focus",e),e.state.focused=!0,Ja(e.display.wrapper,"CodeMirror-focused"),e.curOp||e.display.selForContextMenu==e.doc.sel||(e.display.input.reset(),wo&&setTimeout(function(){e.display.input.reset(!0)},20)),e.display.input.receivedFocus()),Be(e))}function yn(e){e.state.delayingBlurEvent||(e.state.focused&&(Pa(e,"blur",e),e.state.focused=!1,Za(e.display.wrapper,"CodeMirror-focused")),clearInterval(e.display.blinker),setTimeout(function(){e.state.focused||(e.display.shift=!1)},150))}function xn(e,t){Gt(e.display,t)||bn(e,t)||Ti(e,t,"contextmenu")||e.display.input.onContextMenu(t)}function bn(e,t){return Ni(e,"gutterContextMenu")?Zt(e,t,"gutterContextMenu",!1):!1}function wn(e,t){if(_o(e,t.from)<0)return e;if(_o(e,t.to)<=0)return Qo(t);var n=e.line+t.text.length-(t.to.line-t.from.line)-1,r=e.ch;return e.line==t.to.line&&(r+=Qo(t).ch-t.to.ch),Bo(n,r)}function kn(e,t){for(var n=[],r=0;r=0;--i)Mn(e,{from:r[i].from,to:r[i].to,text:i?[""]:t.text});else Mn(e,t)}}function Mn(e,t){if(1!=t.text.length||""!=t.text[0]||0!=_o(t.from,t.to)){var n=kn(e,t);ci(e,t,n,e.cm?e.cm.curOp.id:NaN),En(e,t,n,or(e,t));var r=[];Kr(e,function(e,n){n||-1!=Pi(r,e.history)||(xi(e.history,t),r.push(e.history)),En(e,t,null,or(e,t))})}}function Nn(e,t,n){if(!e.cm||!e.cm.state.suppressEdits){for(var r,i=e.history,o=e.sel,a="undo"==t?i.done:i.undone,l="undo"==t?i.undone:i.done,s=0;s=0;--s){var f=r.changes[s];if(f.origin=t,u&&!Ln(e,f,!1))return void(a.length=0);c.push(ai(e,f));var h=s?kn(e,f):Ii(a);En(e,f,h,lr(e,f)),!s&&e.cm&&e.cm.scrollIntoView({from:f.from,to:Qo(f)});var d=[];Kr(e,function(e,t){t||-1!=Pi(d,e.history)||(xi(e.history,f),d.push(e.history)),En(e,f,null,lr(e,f))})}}}}function An(e,t){if(0!=t&&(e.first+=t,e.sel=new ue(Ri(e.sel.ranges,function(e){return new fe(Bo(e.anchor.line+t,e.anchor.ch),Bo(e.head.line+t,e.head.ch))}),e.sel.primIndex),e.cm)){Dt(e.cm,e.first,e.first-t,t);for(var n=e.cm.display,r=n.viewFrom;re.lastLine())){if(t.from.lineo&&(t={from:t.from,to:Bo(o,Zr(e,o).text.length),text:[t.text[0]],origin:t.origin}),t.removed=Jr(e,t.from,t.to),n||(n=kn(e,t)),e.cm?On(e.cm,t,r):Yr(e,t,r),Me(e,n,Wa)}}function On(e,t,n){var r=e.doc,i=e.display,a=t.from,l=t.to,s=!1,c=a.line;e.options.lineWrapping||(c=ti(yr(Zr(r,a.line))),r.iter(c,l.line+1,function(e){return e==i.maxLine?(s=!0,!0):void 0})),r.sel.contains(t.from,t.to)>-1&&Mi(e),Yr(r,t,n,o(e)),e.options.lineWrapping||(r.iter(c,a.line+t.text.length,function(e){var t=f(e);t>i.maxLineLength&&(i.maxLine=e,i.maxLineLength=t,i.maxLineChanged=!0,s=!1)}),s&&(e.curOp.updateMaxLine=!0)),r.frontier=Math.min(r.frontier,a.line),_e(e,400);var u=t.text.length-(l.line-a.line)-1;t.full?Dt(e):a.line!=l.line||1!=t.text.length||Gr(e.doc,t)?Dt(e,a.line,l.line+1,u):Ht(e,a.line,"text");var h=Ni(e,"changes"),d=Ni(e,"change");if(d||h){var p={from:a,to:l,text:t.text,removed:t.removed,origin:t.origin};d&&Ci(e,"change",e,p),h&&(e.curOp.changeObjs||(e.curOp.changeObjs=[])).push(p)}e.display.selForContextMenu=null}function In(e,t,n,r,i){if(r||(r=n),_o(r,n)<0){var o=r;r=n,n=o}"string"==typeof t&&(t=e.splitLines(t)),Tn(e,{from:n,to:r,text:t,origin:i})}function Pn(e,t){if(!Ti(e,"scrollCursorIntoView")){var n=e.display,r=n.sizer.getBoundingClientRect(),i=null;if(t.top+r.top<0?i=!0:t.bottom+r.top>(window.innerHeight||document.documentElement.clientHeight)&&(i=!1),null!=i&&!Mo){var o=ji("div","​",null,"position: absolute; top: "+(t.top-n.viewOffset-Ue(e.display))+"px; height: "+(t.bottom-t.top+Ye(e)+n.barHeight)+"px; left: "+t.left+"px; width: 2px;");e.display.lineSpace.appendChild(o),o.scrollIntoView(i),e.display.lineSpace.removeChild(o)}}}function Rn(e,t,n,r){null==r&&(r=0);for(var i=0;5>i;i++){var o=!1,a=dt(e,t),l=n&&n!=t?dt(e,n):a,s=Hn(e,Math.min(a.left,l.left),Math.min(a.top,l.top)-r,Math.max(a.left,l.left),Math.max(a.bottom,l.bottom)+r),c=e.doc.scrollTop,u=e.doc.scrollLeft;if(null!=s.scrollTop&&(rn(e,s.scrollTop),Math.abs(e.doc.scrollTop-c)>1&&(o=!0)),null!=s.scrollLeft&&(on(e,s.scrollLeft),Math.abs(e.doc.scrollLeft-u)>1&&(o=!0)),!o)break}return a}function Dn(e,t,n,r,i){var o=Hn(e,t,n,r,i);null!=o.scrollTop&&rn(e,o.scrollTop),null!=o.scrollLeft&&on(e,o.scrollLeft)}function Hn(e,t,n,r,i){var o=e.display,a=yt(e.display);0>n&&(n=0);var l=e.curOp&&null!=e.curOp.scrollTop?e.curOp.scrollTop:o.scroller.scrollTop,s=Ve(e),c={};i-n>s&&(i=n+s);var u=e.doc.height+qe(o),f=a>n,h=i>u-a;if(l>n)c.scrollTop=f?0:n;else if(i>l+s){var d=Math.min(n,(h?u:i)-s);d!=l&&(c.scrollTop=d)}var p=e.curOp&&null!=e.curOp.scrollLeft?e.curOp.scrollLeft:o.scroller.scrollLeft,m=$e(e)-(e.options.fixedGutter?o.gutters.offsetWidth:0),g=r-t>m;return g&&(r=t+m),10>t?c.scrollLeft=0:p>t?c.scrollLeft=Math.max(0,t-(g?0:10)):r>m+p-3&&(c.scrollLeft=r+(g?0:10)-m),c}function Wn(e,t,n){null==t&&null==n||_n(e),null!=t&&(e.curOp.scrollLeft=(null==e.curOp.scrollLeft?e.doc.scrollLeft:e.curOp.scrollLeft)+t),null!=n&&(e.curOp.scrollTop=(null==e.curOp.scrollTop?e.doc.scrollTop:e.curOp.scrollTop)+n)}function Bn(e){_n(e);var t=e.getCursor(),n=t,r=t;e.options.lineWrapping||(n=t.ch?Bo(t.line,t.ch-1):t,r=Bo(t.line,t.ch+1)),e.curOp.scrollToPos={from:n,to:r,margin:e.options.cursorScrollMargin,isCursor:!0}}function _n(e){var t=e.curOp.scrollToPos;if(t){e.curOp.scrollToPos=null;var n=pt(e,t.from),r=pt(e,t.to),i=Hn(e,Math.min(n.left,r.left),Math.min(n.top,r.top)-t.margin,Math.max(n.right,r.right),Math.max(n.bottom,r.bottom)+t.margin);e.scrollTo(i.scrollLeft,i.scrollTop)}}function Fn(e,t,n,r){var i,o=e.doc;null==n&&(n="add"),"smart"==n&&(o.mode.indent?i=je(e,t):n="prev");var a=e.options.tabSize,l=Zr(o,t),s=Fa(l.text,null,a);l.stateAfter&&(l.stateAfter=null);var c,u=l.text.match(/^\s*/)[0];if(r||/\S/.test(l.text)){if("smart"==n&&(c=o.mode.indent(i,l.text.slice(u.length),l.text),c==Ha||c>150)){if(!r)return;n="prev"}}else c=0,n="not";"prev"==n?c=t>o.first?Fa(Zr(o,t-1).text,null,a):0:"add"==n?c=s+e.options.indentUnit:"subtract"==n?c=s-e.options.indentUnit:"number"==typeof n&&(c=s+n),c=Math.max(0,c);var f="",h=0;if(e.options.indentWithTabs)for(var d=Math.floor(c/a);d;--d)h+=a,f+=" ";if(c>h&&(f+=Oi(c-h)),f!=u)return In(o,f,Bo(t,0),Bo(t,u.length),"+input"),l.stateAfter=null,!0;for(var d=0;d=0;t--)In(e.doc,"",r[t].from,r[t].to,"+delete");Bn(e)})}function Un(e,t,n,r,i){function o(){var t=l+n;return t=e.first+e.size?!1:(l=t,u=Zr(e,t))}function a(e){var t=(i?fo:ho)(u,s,n,!0);if(null==t){if(e||!o())return!1;s=i?(0>n?io:ro)(u):0>n?u.text.length:0}else s=t;return!0}var l=t.line,s=t.ch,c=n,u=Zr(e,l);if("char"==r)a();else if("column"==r)a(!0);else if("word"==r||"group"==r)for(var f=null,h="group"==r,d=e.cm&&e.cm.getHelper(t,"wordChars"),p=!0;!(0>n)||a(!p);p=!1){var m=u.text.charAt(s)||"\n",g=_i(m,d)?"w":h&&"\n"==m?"n":!h||/\s/.test(m)?null:"p";if(!h||p||g||(g="s"),f&&f!=g){0>n&&(n=1,a());break}if(g&&(f=g),n>0&&!a(!p))break}var v=Ie(e,Bo(l,s),t,c,!0);return _o(t,v)||(v.hitSide=!0),v}function qn(e,t,n,r){var i,o=e.doc,a=t.left;if("page"==r){var l=Math.min(e.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight);i=t.top+n*(l-(0>n?1.5:.5)*yt(e.display))}else"line"==r&&(i=n>0?t.bottom+3:t.top-3);for(;;){var s=gt(e,a,i);if(!s.outside)break;if(0>n?0>=i:i>=o.height){s.hitSide=!0;break}i+=5*n}return s}function Gn(t,n,r,i){e.defaults[t]=n,r&&(ta[t]=i?function(e,t,n){n!=na&&r(e,t,n)}:r)}function Yn(e){for(var t,n,r,i,o=e.split(/-(?!$)/),e=o[o.length-1],a=0;a0||0==a&&o.clearWhenEmpty!==!1)return o;if(o.replacedWith&&(o.collapsed=!0,o.widgetNode=ji("span",[o.replacedWith],"CodeMirror-widget"),r.handleMouseEvents||o.widgetNode.setAttribute("cm-ignore-events","true"),r.insertLeft&&(o.widgetNode.insertLeft=!0)),o.collapsed){if(vr(e,t.line,t,n,o)||t.line!=n.line&&vr(e,n.line,t,n,o))throw new Error("Inserting collapsed marker partially overlapping an existing one");Wo=!0}o.addToHistory&&ci(e,{from:t,to:n,origin:"markText"},e.sel,NaN);var l,s=t.line,c=e.cm;if(e.iter(s,n.line+1,function(e){c&&o.collapsed&&!c.options.lineWrapping&&yr(e)==c.display.maxLine&&(l=!0),o.collapsed&&s!=t.line&&ei(e,0),nr(e,new Qn(o,s==t.line?t.ch:null,s==n.line?n.ch:null)),++s}),o.collapsed&&e.iter(t.line,n.line+1,function(t){kr(e,t)&&ei(t,0)}),o.clearOnEnter&&Ea(o,"beforeCursorEnter",function(){o.clear()}),o.readOnly&&(Ho=!0,(e.history.done.length||e.history.undone.length)&&e.clearHistory()),o.collapsed&&(o.id=++ga,o.atomic=!0),c){if(l&&(c.curOp.updateMaxLine=!0),o.collapsed)Dt(c,t.line,n.line+1);else if(o.className||o.title||o.startStyle||o.endStyle||o.css)for(var u=t.line;u<=n.line;u++)Ht(c,u,"text");o.atomic&&Ae(c.doc),Ci(c,"markerAdded",c,o)}return o}function Kn(e,t,n,r,i){r=Wi(r),r.shared=!1;var o=[Vn(e,t,n,r,i)],a=o[0],l=r.widgetNode;return Kr(e,function(e){l&&(r.widgetNode=l.cloneNode(!0)),o.push(Vn(e,me(e,t),me(e,n),r,i));for(var s=0;s=t:o.to>t);(r||(r=[])).push(new Qn(a,o.from,s?null:o.to))}}return r}function ir(e,t,n){if(e)for(var r,i=0;i=t:o.to>t);if(l||o.from==t&&"bookmark"==a.type&&(!n||o.marker.insertLeft)){var s=null==o.from||(a.inclusiveLeft?o.from<=t:o.from0&&l)for(var f=0;ff;++f)p.push(m);p.push(s)}return p}function ar(e){for(var t=0;t0)){var u=[s,1],f=_o(c.from,l.from),h=_o(c.to,l.to);(0>f||!a.inclusiveLeft&&!f)&&u.push({from:c.from,to:l.from}),(h>0||!a.inclusiveRight&&!h)&&u.push({from:l.to,to:c.to}),i.splice.apply(i,u),s+=u.length-1}}return i}function cr(e){var t=e.markedSpans;if(t){for(var n=0;n=0&&0>=f||0>=u&&f>=0)&&(0>=u&&(s.marker.inclusiveRight&&i.inclusiveLeft?_o(c.to,n)>=0:_o(c.to,n)>0)||u>=0&&(s.marker.inclusiveRight&&i.inclusiveLeft?_o(c.from,r)<=0:_o(c.from,r)<0)))return!0}}}function yr(e){for(var t;t=mr(e);)e=t.find(-1,!0).line;return e}function xr(e){for(var t,n;t=gr(e);)e=t.find(1,!0).line,(n||(n=[])).push(e);return n}function br(e,t){var n=Zr(e,t),r=yr(n);return n==r?t:ti(r)}function wr(e,t){if(t>e.lastLine())return t;var n,r=Zr(e,t);if(!kr(e,r))return t;for(;n=gr(r);)r=n.find(1,!0).line;return ti(r)+1}function kr(e,t){var n=Wo&&t.markedSpans;if(n)for(var r,i=0;io;o++){i&&(i[0]=e.innerMode(t,r).mode);var a=t.token(n,r);if(n.pos>n.start)return a}throw new Error("Mode "+t.name+" failed to advance stream.")}function Ir(e,t,n,r){function i(e){return{start:f.start,end:f.pos,string:f.current(),type:o||null,state:e?sa(a.mode,u):u}}var o,a=e.doc,l=a.mode;t=me(a,t);var s,c=Zr(a,t.line),u=je(e,t.line,n),f=new ma(c.text,e.options.tabSize);for(r&&(s=[]);(r||f.pose.options.maxHighlightLength?(l=!1,a&&Hr(e,t,r,f.pos),f.pos=t.length,s=null):s=Ar(Or(n,f,r,h),o),h){var d=h[0].name;d&&(s="m-"+(s?d+" "+s:d))}if(!l||u!=s){for(;cc;){var r=i[s];r>e&&i.splice(s,1,e,i[s+1],r),s+=2,c=Math.min(e,r)}if(t)if(l.opaque)i.splice(n,s-n,e,"cm-overlay "+t),s=n+2;else for(;s>n;n+=2){var o=i[n+1];i[n+1]=(o?o+" ":"")+"cm-overlay "+t}},o)}return{styles:i,classes:o.bgClass||o.textClass?o:null}}function Dr(e,t,n){if(!t.styles||t.styles[0]!=e.state.modeGen){var r=je(e,ti(t)),i=Rr(e,t,t.text.length>e.options.maxHighlightLength?sa(e.doc.mode,r):r);t.stateAfter=r,t.styles=i.styles,i.classes?t.styleClasses=i.classes:t.styleClasses&&(t.styleClasses=null),n===e.doc.frontier&&e.doc.frontier++}return t.styles}function Hr(e,t,n,r){var i=e.doc.mode,o=new ma(t,e.options.tabSize);for(o.start=o.pos=r||0,""==t&&Er(i,n);!o.eol();)Or(i,o,n),o.start=o.pos}function Wr(e,t){if(!e||/^\s*$/.test(e))return null;var n=t.addModeClass?ka:wa;return n[e]||(n[e]=e.replace(/\S+/g,"cm-$&"))}function Br(e,t){var n=ji("span",null,null,wo?"padding-right: .1px":null),r={pre:ji("pre",[n],"CodeMirror-line"),content:n,col:0,pos:0,cm:e,splitSpaces:(xo||wo)&&e.getOption("lineWrapping")};t.measure={};for(var i=0;i<=(t.rest?t.rest.length:0);i++){var o,a=i?t.rest[i-1]:t.line;r.pos=0,r.addToken=Fr,Ji(e.display.measure)&&(o=ii(a))&&(r.addToken=jr(r.addToken,o)),r.map=[];var l=t!=e.display.externalMeasured&&ti(a);qr(a,r,Dr(e,a,l)),a.styleClasses&&(a.styleClasses.bgClass&&(r.bgClass=$i(a.styleClasses.bgClass,r.bgClass||"")),a.styleClasses.textClass&&(r.textClass=$i(a.styleClasses.textClass,r.textClass||""))),0==r.map.length&&r.map.push(0,0,r.content.appendChild(Zi(e.display.measure))),0==i?(t.measure.map=r.map,t.measure.cache={}):((t.measure.maps||(t.measure.maps=[])).push(r.map),(t.measure.caches||(t.measure.caches=[])).push({}))}if(wo){var s=r.content.lastChild;(/\bcm-tab\b/.test(s.className)||s.querySelector&&s.querySelector(".cm-tab"))&&(r.content.className="cm-tab-wrap-hack")}return Pa(e,"renderLine",e,t.line,r.pre),r.pre.className&&(r.textClass=$i(r.pre.className,r.textClass||"")),r}function _r(e){var t=ji("span","•","cm-invalidchar");return t.title="\\u"+e.charCodeAt(0).toString(16),t.setAttribute("aria-label",t.title),t}function Fr(e,t,n,r,i,o,a){if(t){var l=e.splitSpaces?t.replace(/ {3,}/g,zr):t,s=e.cm.state.specialChars,c=!1;if(s.test(t))for(var u=document.createDocumentFragment(),f=0;;){s.lastIndex=f;var h=s.exec(t),d=h?h.index-f:t.length-f;if(d){var p=document.createTextNode(l.slice(f,f+d));xo&&9>bo?u.appendChild(ji("span",[p])):u.appendChild(p),e.map.push(e.pos,e.pos+d,p),e.col+=d,e.pos+=d}if(!h)break;if(f+=d+1," "==h[0]){var m=e.cm.options.tabSize,g=m-e.col%m,p=u.appendChild(ji("span",Oi(g),"cm-tab"));p.setAttribute("role","presentation"),p.setAttribute("cm-text"," "),e.col+=g}else if("\r"==h[0]||"\n"==h[0]){var p=u.appendChild(ji("span","\r"==h[0]?"␍":"␤","cm-invalidchar"));p.setAttribute("cm-text",h[0]),e.col+=1}else{var p=e.cm.options.specialCharPlaceholder(h[0]);p.setAttribute("cm-text",h[0]),xo&&9>bo?u.appendChild(ji("span",[p])):u.appendChild(p),e.col+=1}e.map.push(e.pos,e.pos+1,p),e.pos++}else{e.col+=t.length;var u=document.createTextNode(l);e.map.push(e.pos,e.pos+t.length,u),xo&&9>bo&&(c=!0),e.pos+=t.length}if(n||r||i||c||a){var v=n||"";r&&(v+=r),i&&(v+=i);var y=ji("span",[u],v,a);return o&&(y.title=o),e.content.appendChild(y)}e.content.appendChild(u)}}function zr(e){for(var t=" ",n=0;nc&&h.from<=c)break}if(h.to>=u)return e(n,r,i,o,a,l,s);e(n,r.slice(0,h.to-c),i,o,null,l,s),o=null,r=r.slice(h.to-c),c=h.to}}}function Ur(e,t,n,r){var i=!r&&n.widgetNode;i&&e.map.push(e.pos,e.pos+t,i),!r&&e.cm.display.input.needsContentAttribute&&(i||(i=e.content.appendChild(document.createElement("span"))),i.setAttribute("cm-marker",n.id)),i&&(e.cm.display.input.setUneditable(i),e.content.appendChild(i)),e.pos+=t}function qr(e,t,n){var r=e.markedSpans,i=e.text,o=0;if(r)for(var a,l,s,c,u,f,h,d=i.length,p=0,m=1,g="",v=0;;){if(v==p){s=c=u=f=l="",h=null,v=1/0;for(var y,x=[],b=0;bp||k.collapsed&&w.to==p&&w.from==p)?(null!=w.to&&w.to!=p&&v>w.to&&(v=w.to,c=""),k.className&&(s+=" "+k.className),k.css&&(l=(l?l+";":"")+k.css),k.startStyle&&w.from==p&&(u+=" "+k.startStyle),k.endStyle&&w.to==v&&(y||(y=[])).push(k.endStyle,w.to),k.title&&!f&&(f=k.title),k.collapsed&&(!h||dr(h.marker,k)<0)&&(h=w)):w.from>p&&v>w.from&&(v=w.from)}if(y)for(var b=0;b=d)break;for(var S=Math.min(d,v);;){if(g){var C=p+g.length;if(!h){var L=C>S?g.slice(0,S-p):g;t.addToken(t,L,a?a+s:s,u,p+L.length==v?c:"",f,l)}if(C>=S){g=g.slice(S-p),p=S;break}p=C,u=""}g=i.slice(o,o=n[m++]),a=Wr(n[m++],t.cm.options)}}else for(var m=1;mn;++n)o.push(new ba(c[n],i(n),r));return o}var l=t.from,s=t.to,c=t.text,u=Zr(e,l.line),f=Zr(e,s.line),h=Ii(c),d=i(c.length-1),p=s.line-l.line;if(t.full)e.insert(0,a(0,c.length)),e.remove(c.length,e.size-c.length);else if(Gr(e,t)){var m=a(0,c.length-1);o(f,f.text,d),p&&e.remove(l.line,p),m.length&&e.insert(l.line,m)}else if(u==f)if(1==c.length)o(u,u.text.slice(0,l.ch)+h+u.text.slice(s.ch),d);else{var m=a(1,c.length-1);m.push(new ba(h+u.text.slice(s.ch),d,r)),o(u,u.text.slice(0,l.ch)+c[0],i(0)),e.insert(l.line+1,m)}else if(1==c.length)o(u,u.text.slice(0,l.ch)+c[0]+f.text.slice(s.ch),i(0)),e.remove(l.line+1,p);else{o(u,u.text.slice(0,l.ch)+c[0],i(0)),o(f,h+f.text.slice(s.ch),d);var m=a(1,c.length-1);p>1&&e.remove(l.line+1,p-1),e.insert(l.line+1,m)}Ci(e,"change",e,t)}function $r(e){this.lines=e,this.parent=null;for(var t=0,n=0;tt||t>=e.size)throw new Error("There is no line "+(t+e.first)+" in the document.");for(var n=e;!n.lines;)for(var r=0;;++r){var i=n.children[r],o=i.chunkSize();if(o>t){n=i;break}t-=o}return n.lines[t]}function Jr(e,t,n){var r=[],i=t.line;return e.iter(t.line,n.line+1,function(e){var o=e.text;i==n.line&&(o=o.slice(0,n.ch)),i==t.line&&(o=o.slice(t.ch)),r.push(o),++i}),r}function Qr(e,t,n){var r=[];return e.iter(t,n,function(e){r.push(e.text)}),r}function ei(e,t){var n=t-e.height;if(n)for(var r=e;r;r=r.parent)r.height+=n}function ti(e){if(null==e.parent)return null;for(var t=e.parent,n=Pi(t.lines,e),r=t.parent;r;t=r,r=r.parent)for(var i=0;r.children[i]!=t;++i)n+=r.children[i].chunkSize();return n+t.first}function ni(e,t){var n=e.first;e:do{for(var r=0;rt){e=i;continue e}t-=o,n+=i.chunkSize()}return n}while(!e.lines);for(var r=0;rt)break;t-=l}return n+r}function ri(e){e=yr(e);for(var t=0,n=e.parent,r=0;r1&&!e.done[e.done.length-2].ranges?(e.done.pop(),Ii(e.done)):void 0}function ci(e,t,n,r){var i=e.history;i.undone.length=0;var o,a=+new Date;if((i.lastOp==r||i.lastOrigin==t.origin&&t.origin&&("+"==t.origin.charAt(0)&&e.cm&&i.lastModTime>a-e.cm.options.historyEventDelay||"*"==t.origin.charAt(0)))&&(o=si(i,i.lastOp==r))){var l=Ii(o.changes);0==_o(t.from,t.to)&&0==_o(t.from,l.to)?l.to=Qo(t):o.changes.push(ai(e,t))}else{var s=Ii(i.done);for(s&&s.ranges||hi(e.sel,i.done),o={changes:[ai(e,t)],generation:i.generation},i.done.push(o);i.done.length>i.undoDepth;)i.done.shift(),i.done[0].ranges||i.done.shift()}i.done.push(n),i.generation=++i.maxGeneration,i.lastModTime=i.lastSelTime=a,i.lastOp=i.lastSelOp=r,i.lastOrigin=i.lastSelOrigin=t.origin,l||Pa(e,"historyAdded")}function ui(e,t,n,r){var i=t.charAt(0);return"*"==i||"+"==i&&n.ranges.length==r.ranges.length&&n.somethingSelected()==r.somethingSelected()&&new Date-e.history.lastSelTime<=(e.cm?e.cm.options.historyEventDelay:500)}function fi(e,t,n,r){var i=e.history,o=r&&r.origin;n==i.lastSelOp||o&&i.lastSelOrigin==o&&(i.lastModTime==i.lastSelTime&&i.lastOrigin==o||ui(e,o,Ii(i.done),t))?i.done[i.done.length-1]=t:hi(t,i.done),i.lastSelTime=+new Date,i.lastSelOrigin=o,i.lastSelOp=n,r&&r.clearRedo!==!1&&li(i.undone)}function hi(e,t){var n=Ii(t);n&&n.ranges&&n.equals(e)||t.push(e)}function di(e,t,n,r){var i=t["spans_"+e.id],o=0;e.iter(Math.max(e.first,n),Math.min(e.first+e.size,r),function(n){n.markedSpans&&((i||(i=t["spans_"+e.id]={}))[o]=n.markedSpans),++o})}function pi(e){if(!e)return null;for(var t,n=0;n-1&&(Ii(l)[f]=u[f],delete u[f])}}}return i}function vi(e,t,n,r){n0?r.slice():Oa:r||Oa}function Ci(e,t){function n(e){return function(){e.apply(null,o)}}var r=Si(e,t,!1);if(r.length){var i,o=Array.prototype.slice.call(arguments,2);Go?i=Go.delayedCallbacks:Ra?i=Ra:(i=Ra=[],setTimeout(Li,0));for(var a=0;a0}function Ai(e){e.prototype.on=function(e,t){Ea(this,e,t)},e.prototype.off=function(e,t){Ia(this,e,t)}}function Ei(){this.id=null}function Oi(e){for(;ja.length<=e;)ja.push(Ii(ja)+" ");return ja[e]}function Ii(e){return e[e.length-1]}function Pi(e,t){for(var n=0;n-1&&Ya(e)?!0:t.test(e):Ya(e)}function Fi(e){for(var t in e)if(e.hasOwnProperty(t)&&e[t])return!1;return!0}function zi(e){return e.charCodeAt(0)>=768&&$a.test(e)}function ji(e,t,n,r){var i=document.createElement(e);if(n&&(i.className=n),r&&(i.style.cssText=r),"string"==typeof t)i.appendChild(document.createTextNode(t));else if(t)for(var o=0;o0;--t)e.removeChild(e.firstChild);return e}function qi(e,t){return Ui(e).appendChild(t)}function Gi(){for(var e=document.activeElement;e&&e.root&&e.root.activeElement;)e=e.root.activeElement;return e}function Yi(e){return new RegExp("(^|\\s)"+e+"(?:$|\\s)\\s*")}function $i(e,t){for(var n=e.split(" "),r=0;r2&&!(xo&&8>bo))}var n=Ka?ji("span","​"):ji("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px");return n.setAttribute("cm-text",""),n}function Ji(e){if(null!=Xa)return Xa;var t=qi(e,document.createTextNode("AخA")),n=qa(t,0,1).getBoundingClientRect();if(!n||n.left==n.right)return!1;var r=qa(t,1,2).getBoundingClientRect();return Xa=r.right-n.right<3}function Qi(e){if(null!=il)return il;var t=qi(e,ji("span","x")),n=t.getBoundingClientRect(),r=qa(t,0,1).getBoundingClientRect();return il=Math.abs(n.left-r.left)>1}function eo(e,t,n,r){if(!e)return r(t,n,"ltr");for(var i=!1,o=0;ot||t==n&&a.to==t)&&(r(Math.max(a.from,t),Math.min(a.to,n),1==a.level?"rtl":"ltr"),i=!0)}i||r(t,n,"ltr")}function to(e){return e.level%2?e.to:e.from}function no(e){return e.level%2?e.from:e.to}function ro(e){var t=ii(e);return t?to(t[0]):0}function io(e){var t=ii(e);return t?no(Ii(t)):e.text.length}function oo(e,t){var n=Zr(e.doc,t),r=yr(n);r!=n&&(t=ti(r));var i=ii(r),o=i?i[0].level%2?io(r):ro(r):0;return Bo(t,o)}function ao(e,t){for(var n,r=Zr(e.doc,t);n=gr(r);)r=n.find(1,!0).line,t=null;var i=ii(r),o=i?i[0].level%2?ro(r):io(r):r.text.length;return Bo(null==t?ti(r):t,o)}function lo(e,t){var n=oo(e,t.line),r=Zr(e.doc,n.line),i=ii(r);if(!i||0==i[0].level){var o=Math.max(0,r.text.search(/\S/)),a=t.line==n.line&&t.ch<=o&&t.ch;return Bo(n.line,a?0:o)}return n}function so(e,t,n){var r=e[0].level;return t==r?!0:n==r?!1:n>t}function co(e,t){al=null;for(var n,r=0;rt)return r;if(i.from==t||i.to==t){if(null!=n)return so(e,i.level,e[n].level)?(i.from!=i.to&&(al=n),r):(i.from!=i.to&&(al=r),n);n=r}}return n}function uo(e,t,n,r){if(!r)return t+n;do t+=n;while(t>0&&zi(e.text.charAt(t)));return t}function fo(e,t,n,r){var i=ii(e);if(!i)return ho(e,t,n,r);for(var o=co(i,t),a=i[o],l=uo(e,t,a.level%2?-n:n,r);;){if(l>a.from&&l0==a.level%2?a.to:a.from);if(a=i[o+=n],!a)return null;l=n>0==a.level%2?uo(e,a.to,-1,r):uo(e,a.from,1,r)}}function ho(e,t,n,r){var i=t+n;if(r)for(;i>0&&zi(e.text.charAt(i));)i+=n;return 0>i||i>e.text.length?null:i}var po=navigator.userAgent,mo=navigator.platform,go=/gecko\/\d/i.test(po),vo=/MSIE \d/.test(po),yo=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(po),xo=vo||yo,bo=xo&&(vo?document.documentMode||6:yo[1]),wo=/WebKit\//.test(po),ko=wo&&/Qt\/\d+\.\d+/.test(po),So=/Chrome\//.test(po),Co=/Opera\//.test(po),Lo=/Apple Computer/.test(navigator.vendor),To=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(po),Mo=/PhantomJS/.test(po),No=/AppleWebKit/.test(po)&&/Mobile\/\w+/.test(po),Ao=No||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(po),Eo=No||/Mac/.test(mo),Oo=/\bCrOS\b/.test(po),Io=/win/i.test(mo),Po=Co&&po.match(/Version\/(\d*\.\d*)/);Po&&(Po=Number(Po[1])),Po&&Po>=15&&(Co=!1,wo=!0);var Ro=Eo&&(ko||Co&&(null==Po||12.11>Po)),Do=go||xo&&bo>=9,Ho=!1,Wo=!1;m.prototype=Wi({update:function(e){var t=e.scrollWidth>e.clientWidth+1,n=e.scrollHeight>e.clientHeight+1,r=e.nativeBarWidth;if(n){this.vert.style.display="block",this.vert.style.bottom=t?r+"px":"0";var i=e.viewHeight-(t?r:0);this.vert.firstChild.style.height=Math.max(0,e.scrollHeight-e.clientHeight+i)+"px"}else this.vert.style.display="",this.vert.firstChild.style.height="0";if(t){this.horiz.style.display="block",this.horiz.style.right=n?r+"px":"0",this.horiz.style.left=e.barLeft+"px";var o=e.viewWidth-e.barLeft-(n?r:0);this.horiz.firstChild.style.width=e.scrollWidth-e.clientWidth+o+"px"}else this.horiz.style.display="",this.horiz.firstChild.style.width="0";return!this.checkedZeroWidth&&e.clientHeight>0&&(0==r&&this.zeroWidthHack(),this.checkedZeroWidth=!0),{right:n?r:0,bottom:t?r:0}},setScrollLeft:function(e){this.horiz.scrollLeft!=e&&(this.horiz.scrollLeft=e),this.disableHoriz&&this.enableZeroWidthBar(this.horiz,this.disableHoriz)},setScrollTop:function(e){this.vert.scrollTop!=e&&(this.vert.scrollTop=e),this.disableVert&&this.enableZeroWidthBar(this.vert,this.disableVert)},zeroWidthHack:function(){var e=Eo&&!To?"12px":"18px";this.horiz.style.height=this.vert.style.width=e,this.horiz.style.pointerEvents=this.vert.style.pointerEvents="none",this.disableHoriz=new Ei,this.disableVert=new Ei},enableZeroWidthBar:function(e,t){function n(){var r=e.getBoundingClientRect(),i=document.elementFromPoint(r.left+1,r.bottom-1);i!=e?e.style.pointerEvents="none":t.set(1e3,n)}e.style.pointerEvents="auto",t.set(1e3,n)},clear:function(){var e=this.horiz.parentNode;e.removeChild(this.horiz),e.removeChild(this.vert)}},m.prototype),g.prototype=Wi({update:function(){return{bottom:0,right:0}},setScrollLeft:function(){},setScrollTop:function(){},clear:function(){}},g.prototype),e.scrollbarModel={"native":m,"null":g},L.prototype.signal=function(e,t){Ni(e,t)&&this.events.push(arguments)},L.prototype.finish=function(){for(var e=0;e=9&&n.hasSelection&&(n.hasSelection=null),n.poll()}),Ea(o,"paste",function(e){Ti(r,e)||J(e,r)||(r.state.pasteIncoming=!0,n.fastPoll())}),Ea(o,"cut",t),Ea(o,"copy",t),Ea(e.scroller,"paste",function(t){Gt(e,t)||Ti(r,t)||(r.state.pasteIncoming=!0,n.focus())}),Ea(e.lineSpace,"selectstart",function(t){Gt(e,t)||Ma(t)}),Ea(o,"compositionstart",function(){var e=r.getCursor("from");n.composing&&n.composing.range.clear(),n.composing={start:e,range:r.markText(e,r.getCursor("to"),{className:"CodeMirror-composing"})}}),Ea(o,"compositionend",function(){n.composing&&(n.poll(),n.composing.range.clear(),n.composing=null)})},prepareSelection:function(){var e=this.cm,t=e.display,n=e.doc,r=De(e);if(e.options.moveInputWithCursor){var i=dt(e,n.sel.primary().head,"div"),o=t.wrapper.getBoundingClientRect(),a=t.lineDiv.getBoundingClientRect();r.teTop=Math.max(0,Math.min(t.wrapper.clientHeight-10,i.top+a.top-o.top)),r.teLeft=Math.max(0,Math.min(t.wrapper.clientWidth-10,i.left+a.left-o.left))}return r},showSelection:function(e){var t=this.cm,n=t.display;qi(n.cursorDiv,e.cursors),qi(n.selectionDiv,e.selection),null!=e.teTop&&(this.wrapper.style.top=e.teTop+"px",this.wrapper.style.left=e.teLeft+"px")},reset:function(e){if(!this.contextMenuPending){var t,n,r=this.cm,i=r.doc;if(r.somethingSelected()){this.prevInput="";var o=i.sel.primary();t=rl&&(o.to().line-o.from().line>100||(n=r.getSelection()).length>1e3);var a=t?"-":n||r.getSelection();this.textarea.value=a,r.state.focused&&Ua(this.textarea),xo&&bo>=9&&(this.hasSelection=a)}else e||(this.prevInput=this.textarea.value="",xo&&bo>=9&&(this.hasSelection=null));this.inaccurateSelection=t}},getField:function(){return this.textarea},supportsTouch:function(){return!1},focus:function(){if("nocursor"!=this.cm.options.readOnly&&(!Ao||Gi()!=this.textarea))try{this.textarea.focus()}catch(e){}},blur:function(){this.textarea.blur()},resetPosition:function(){this.wrapper.style.top=this.wrapper.style.left=0; +},receivedFocus:function(){this.slowPoll()},slowPoll:function(){var e=this;e.pollingFast||e.polling.set(this.cm.options.pollInterval,function(){e.poll(),e.cm.state.focused&&e.slowPoll()})},fastPoll:function(){function e(){var r=n.poll();r||t?(n.pollingFast=!1,n.slowPoll()):(t=!0,n.polling.set(60,e))}var t=!1,n=this;n.pollingFast=!0,n.polling.set(20,e)},poll:function(){var e=this.cm,t=this.textarea,n=this.prevInput;if(this.contextMenuPending||!e.state.focused||nl(t)&&!n&&!this.composing||e.isReadOnly()||e.options.disableInput||e.state.keySeq)return!1;var r=t.value;if(r==n&&!e.somethingSelected())return!1;if(xo&&bo>=9&&this.hasSelection===r||Eo&&/[\uf700-\uf7ff]/.test(r))return e.display.input.reset(),!1;if(e.doc.sel==e.display.selForContextMenu){var i=r.charCodeAt(0);if(8203!=i||n||(n="​"),8666==i)return this.reset(),this.cm.execCommand("undo")}for(var o=0,a=Math.min(n.length,r.length);a>o&&n.charCodeAt(o)==r.charCodeAt(o);)++o;var l=this;return At(e,function(){Z(e,r.slice(o),n.length-o,null,l.composing?"*compose":null),r.length>1e3||r.indexOf("\n")>-1?t.value=l.prevInput="":l.prevInput=r,l.composing&&(l.composing.range.clear(),l.composing.range=e.markText(l.composing.start,e.getCursor("to"),{className:"CodeMirror-composing"}))}),!0},ensurePolled:function(){this.pollingFast&&this.poll()&&(this.pollingFast=!1)},onKeyPress:function(){xo&&bo>=9&&(this.hasSelection=null),this.fastPoll()},onContextMenu:function(e){function t(){if(null!=a.selectionStart){var e=i.somethingSelected(),t="​"+(e?a.value:"");a.value="⇚",a.value=t,r.prevInput=e?"":"​",a.selectionStart=1,a.selectionEnd=t.length,o.selForContextMenu=i.doc.sel}}function n(){if(r.contextMenuPending=!1,r.wrapper.style.cssText=f,a.style.cssText=u,xo&&9>bo&&o.scrollbars.setScrollTop(o.scroller.scrollTop=s),null!=a.selectionStart){(!xo||xo&&9>bo)&&t();var e=0,n=function(){o.selForContextMenu==i.doc.sel&&0==a.selectionStart&&a.selectionEnd>0&&"​"==r.prevInput?Et(i,ua.selectAll)(i):e++<10?o.detectingSelectAll=setTimeout(n,500):o.input.reset()};o.detectingSelectAll=setTimeout(n,200)}}var r=this,i=r.cm,o=i.display,a=r.textarea,l=Yt(i,e),s=o.scroller.scrollTop;if(l&&!Co){var c=i.options.resetSelectionOnContextMenu;c&&-1==i.doc.sel.contains(l)&&Et(i,Te)(i.doc,de(l),Wa);var u=a.style.cssText,f=r.wrapper.style.cssText;r.wrapper.style.cssText="position: absolute";var h=r.wrapper.getBoundingClientRect();if(a.style.cssText="position: absolute; width: 30px; height: 30px; top: "+(e.clientY-h.top-5)+"px; left: "+(e.clientX-h.left-5)+"px; z-index: 1000; background: "+(xo?"rgba(255, 255, 255, .05)":"transparent")+"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);",wo)var d=window.scrollY;if(o.input.focus(),wo&&window.scrollTo(null,d),o.input.reset(),i.somethingSelected()||(a.value=r.prevInput=" "),r.contextMenuPending=!0,o.selForContextMenu=i.doc.sel,clearTimeout(o.detectingSelectAll),xo&&bo>=9&&t(),Do){Aa(e);var p=function(){Ia(window,"mouseup",p),setTimeout(n,20)};Ea(window,"mouseup",p)}else setTimeout(n,50)}},readOnlyChanged:function(e){e||this.reset()},setUneditable:Di,needsContentAttribute:!1},ne.prototype),ie.prototype=Wi({init:function(e){function t(e){if(!Ti(r,e)){if(r.somethingSelected())Fo={lineWise:!1,text:r.getSelections()},"cut"==e.type&&r.replaceSelection("",null,"cut");else{if(!r.options.lineWiseCopyCut)return;var t=ee(r);Fo={lineWise:!0,text:t.text},"cut"==e.type&&r.operation(function(){r.setSelections(t.ranges,0,Wa),r.replaceSelection("",null,"cut")})}if(e.clipboardData&&!No)e.preventDefault(),e.clipboardData.clearData(),e.clipboardData.setData("text/plain",Fo.text.join("\n"));else{var n=re(),i=n.firstChild;r.display.lineSpace.insertBefore(n,r.display.lineSpace.firstChild),i.value=Fo.text.join("\n");var o=document.activeElement;Ua(i),setTimeout(function(){r.display.lineSpace.removeChild(n),o.focus()},50)}}}var n=this,r=n.cm,i=n.div=e.lineDiv;te(i),Ea(i,"paste",function(e){Ti(r,e)||J(e,r)}),Ea(i,"compositionstart",function(e){var t=e.data;if(n.composing={sel:r.doc.sel,data:t,startData:t},t){var i=r.doc.sel.primary(),o=r.getLine(i.head.line),a=o.indexOf(t,Math.max(0,i.head.ch-t.length));a>-1&&a<=i.head.ch&&(n.composing.sel=de(Bo(i.head.line,a),Bo(i.head.line,a+t.length)))}}),Ea(i,"compositionupdate",function(e){n.composing.data=e.data}),Ea(i,"compositionend",function(e){var t=n.composing;t&&(e.data==t.startData||/\u200b/.test(e.data)||(t.data=e.data),setTimeout(function(){t.handled||n.applyComposition(t),n.composing==t&&(n.composing=null)},50))}),Ea(i,"touchstart",function(){n.forceCompositionEnd()}),Ea(i,"input",function(){n.composing||!r.isReadOnly()&&n.pollContent()||At(n.cm,function(){Dt(r)})}),Ea(i,"copy",t),Ea(i,"cut",t)},prepareSelection:function(){var e=De(this.cm,!1);return e.focus=this.cm.state.focused,e},showSelection:function(e,t){e&&this.cm.display.view.length&&((e.focus||t)&&this.showPrimarySelection(),this.showMultipleSelections(e))},showPrimarySelection:function(){var e=window.getSelection(),t=this.cm.doc.sel.primary(),n=le(this.cm,e.anchorNode,e.anchorOffset),r=le(this.cm,e.focusNode,e.focusOffset);if(!n||n.bad||!r||r.bad||0!=_o(K(n,r),t.from())||0!=_o(V(n,r),t.to())){var i=oe(this.cm,t.from()),o=oe(this.cm,t.to());if(i||o){var a=this.cm.display.view,l=e.rangeCount&&e.getRangeAt(0);if(i){if(!o){var s=a[a.length-1].measure,c=s.maps?s.maps[s.maps.length-1]:s.map;o={node:c[c.length-1],offset:c[c.length-2]-c[c.length-3]}}}else i={node:a[0].measure.map[2],offset:0};try{var u=qa(i.node,i.offset,o.offset,o.node)}catch(f){}u&&(!go&&this.cm.state.focused?(e.collapse(i.node,i.offset),u.collapsed||e.addRange(u)):(e.removeAllRanges(),e.addRange(u)),l&&null==e.anchorNode?e.addRange(l):go&&this.startGracePeriod()),this.rememberSelection()}}},startGracePeriod:function(){var e=this;clearTimeout(this.gracePeriod),this.gracePeriod=setTimeout(function(){e.gracePeriod=!1,e.selectionChanged()&&e.cm.operation(function(){e.cm.curOp.selectionChanged=!0})},20)},showMultipleSelections:function(e){qi(this.cm.display.cursorDiv,e.cursors),qi(this.cm.display.selectionDiv,e.selection)},rememberSelection:function(){var e=window.getSelection();this.lastAnchorNode=e.anchorNode,this.lastAnchorOffset=e.anchorOffset,this.lastFocusNode=e.focusNode,this.lastFocusOffset=e.focusOffset},selectionInEditor:function(){var e=window.getSelection();if(!e.rangeCount)return!1;var t=e.getRangeAt(0).commonAncestorContainer;return Va(this.div,t)},focus:function(){"nocursor"!=this.cm.options.readOnly&&this.div.focus()},blur:function(){this.div.blur()},getField:function(){return this.div},supportsTouch:function(){return!0},receivedFocus:function(){function e(){t.cm.state.focused&&(t.pollSelection(),t.polling.set(t.cm.options.pollInterval,e))}var t=this;this.selectionInEditor()?this.pollSelection():At(this.cm,function(){t.cm.curOp.selectionChanged=!0}),this.polling.set(this.cm.options.pollInterval,e)},selectionChanged:function(){var e=window.getSelection();return e.anchorNode!=this.lastAnchorNode||e.anchorOffset!=this.lastAnchorOffset||e.focusNode!=this.lastFocusNode||e.focusOffset!=this.lastFocusOffset},pollSelection:function(){if(!this.composing&&!this.gracePeriod&&this.selectionChanged()){var e=window.getSelection(),t=this.cm;this.rememberSelection();var n=le(t,e.anchorNode,e.anchorOffset),r=le(t,e.focusNode,e.focusOffset);n&&r&&At(t,function(){Te(t.doc,de(n,r),Wa),(n.bad||r.bad)&&(t.curOp.selectionChanged=!0)})}},pollContent:function(){var e=this.cm,t=e.display,n=e.doc.sel.primary(),r=n.from(),i=n.to();if(r.linet.viewTo-1)return!1;var o;if(r.line==t.viewFrom||0==(o=Bt(e,r.line)))var a=ti(t.view[0].line),l=t.view[0].node;else var a=ti(t.view[o].line),l=t.view[o-1].node.nextSibling;var s=Bt(e,i.line);if(s==t.view.length-1)var c=t.viewTo-1,u=t.lineDiv.lastChild;else var c=ti(t.view[s+1].line)-1,u=t.view[s+1].node.previousSibling;for(var f=e.doc.splitLines(ce(e,l,u,a,c)),h=Jr(e.doc,Bo(a,0),Bo(c,Zr(e.doc,c).text.length));f.length>1&&h.length>1;)if(Ii(f)==Ii(h))f.pop(),h.pop(),c--;else{if(f[0]!=h[0])break;f.shift(),h.shift(),a++}for(var d=0,p=0,m=f[0],g=h[0],v=Math.min(m.length,g.length);v>d&&m.charCodeAt(d)==g.charCodeAt(d);)++d;for(var y=Ii(f),x=Ii(h),b=Math.min(y.length-(1==f.length?d:0),x.length-(1==h.length?d:0));b>p&&y.charCodeAt(y.length-p-1)==x.charCodeAt(x.length-p-1);)++p;f[f.length-1]=y.slice(0,y.length-p),f[0]=f[0].slice(d);var w=Bo(a,d),k=Bo(c,h.length?Ii(h).length-p:0);return f.length>1||f[0]||_o(w,k)?(In(e.doc,f,w,k,"+input"),!0):void 0},ensurePolled:function(){this.forceCompositionEnd()},reset:function(){this.forceCompositionEnd()},forceCompositionEnd:function(){this.composing&&!this.composing.handled&&(this.applyComposition(this.composing),this.composing.handled=!0,this.div.blur(),this.div.focus())},applyComposition:function(e){this.cm.isReadOnly()?Et(this.cm,Dt)(this.cm):e.data&&e.data!=e.startData&&Et(this.cm,Z)(this.cm,e.data,0,e.sel)},setUneditable:function(e){e.contentEditable="false"},onKeyPress:function(e){e.preventDefault(),this.cm.isReadOnly()||Et(this.cm,Z)(this.cm,String.fromCharCode(null==e.charCode?e.keyCode:e.charCode),0)},readOnlyChanged:function(e){this.div.contentEditable=String("nocursor"!=e)},onContextMenu:Di,resetPosition:Di,needsContentAttribute:!0},ie.prototype),e.inputStyles={textarea:ne,contenteditable:ie},ue.prototype={primary:function(){return this.ranges[this.primIndex]},equals:function(e){if(e==this)return!0;if(e.primIndex!=this.primIndex||e.ranges.length!=this.ranges.length)return!1;for(var t=0;t=0&&_o(e,r.to())<=0)return n}return-1}},fe.prototype={from:function(){return K(this.anchor,this.head)},to:function(){return V(this.anchor,this.head)},empty:function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}};var zo,jo,Uo,qo={left:0,right:0,top:0,bottom:0},Go=null,Yo=0,$o=0,Vo=0,Ko=null;xo?Ko=-.53:go?Ko=15:So?Ko=-.7:Lo&&(Ko=-1/3);var Xo=function(e){var t=e.wheelDeltaX,n=e.wheelDeltaY;return null==t&&e.detail&&e.axis==e.HORIZONTAL_AXIS&&(t=e.detail),null==n&&e.detail&&e.axis==e.VERTICAL_AXIS?n=e.detail:null==n&&(n=e.wheelDelta),{x:t,y:n}};e.wheelEventPixels=function(e){var t=Xo(e);return t.x*=Ko,t.y*=Ko,t};var Zo=new Ei,Jo=null,Qo=e.changeEnd=function(e){return e.text?Bo(e.from.line+e.text.length-1,Ii(e.text).length+(1==e.text.length?e.from.ch:0)):e.to};e.prototype={constructor:e,focus:function(){window.focus(),this.display.input.focus()},setOption:function(e,t){var n=this.options,r=n[e];n[e]==t&&"mode"!=e||(n[e]=t,ta.hasOwnProperty(e)&&Et(this,ta[e])(this,t,r))},getOption:function(e){return this.options[e]},getDoc:function(){return this.doc},addKeyMap:function(e,t){this.state.keyMaps[t?"push":"unshift"]($n(e))},removeKeyMap:function(e){for(var t=this.state.keyMaps,n=0;nn&&(Fn(this,i.head.line,e,!0),n=i.head.line,r==this.doc.sel.primIndex&&Bn(this));else{var o=i.from(),a=i.to(),l=Math.max(n,o.line);n=Math.min(this.lastLine(),a.line-(a.ch?0:1))+1;for(var s=l;n>s;++s)Fn(this,s,e);var c=this.doc.sel.ranges;0==o.ch&&t.length==c.length&&c[r].from().ch>0&&ke(this.doc,r,new fe(o,c[r].to()),Wa)}}}),getTokenAt:function(e,t){return Ir(this,e,t)},getLineTokens:function(e,t){return Ir(this,Bo(e),t,!0)},getTokenTypeAt:function(e){e=me(this.doc,e);var t,n=Dr(this,Zr(this.doc,e.line)),r=0,i=(n.length-1)/2,o=e.ch;if(0==o)t=n[2];else for(;;){var a=r+i>>1;if((a?n[2*a-1]:0)>=o)i=a;else{if(!(n[2*a+1]l?t:0==l?null:t.slice(0,l-1)},getModeAt:function(t){var n=this.doc.mode;return n.innerMode?e.innerMode(n,this.getTokenAt(t).state).mode:n},getHelper:function(e,t){return this.getHelpers(e,t)[0]},getHelpers:function(e,t){var n=[];if(!la.hasOwnProperty(t))return n;var r=la[t],i=this.getModeAt(e);if("string"==typeof i[t])r[i[t]]&&n.push(r[i[t]]);else if(i[t])for(var o=0;oi&&(e=i,r=!0),n=Zr(this.doc,e)}else n=e;return ut(this,n,{top:0,left:0},t||"page").top+(r?this.doc.height-ri(n):0)},defaultTextHeight:function(){return yt(this.display)},defaultCharWidth:function(){return xt(this.display)},setGutterMarker:Ot(function(e,t,n){return zn(this.doc,e,"gutter",function(e){var r=e.gutterMarkers||(e.gutterMarkers={});return r[t]=n,!n&&Fi(r)&&(e.gutterMarkers=null),!0})}),clearGutter:Ot(function(e){var t=this,n=t.doc,r=n.first;n.iter(function(n){n.gutterMarkers&&n.gutterMarkers[e]&&(n.gutterMarkers[e]=null,Ht(t,r,"gutter"),Fi(n.gutterMarkers)&&(n.gutterMarkers=null)),++r})}),lineInfo:function(e){if("number"==typeof e){if(!ve(this.doc,e))return null;var t=e;if(e=Zr(this.doc,e),!e)return null}else{var t=ti(e);if(null==t)return null}return{line:t,handle:e,text:e.text,gutterMarkers:e.gutterMarkers,textClass:e.textClass,bgClass:e.bgClass,wrapClass:e.wrapClass,widgets:e.widgets}},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(e,t,n,r,i){var o=this.display;e=dt(this,me(this.doc,e));var a=e.bottom,l=e.left;if(t.style.position="absolute",t.setAttribute("cm-ignore-events","true"),this.display.input.setUneditable(t),o.sizer.appendChild(t),"over"==r)a=e.top;else if("above"==r||"near"==r){var s=Math.max(o.wrapper.clientHeight,this.doc.height),c=Math.max(o.sizer.clientWidth,o.lineSpace.clientWidth);("above"==r||e.bottom+t.offsetHeight>s)&&e.top>t.offsetHeight?a=e.top-t.offsetHeight:e.bottom+t.offsetHeight<=s&&(a=e.bottom),l+t.offsetWidth>c&&(l=c-t.offsetWidth)}t.style.top=a+"px",t.style.left=t.style.right="","right"==i?(l=o.sizer.clientWidth-t.offsetWidth,t.style.right="0px"):("left"==i?l=0:"middle"==i&&(l=(o.sizer.clientWidth-t.offsetWidth)/2),t.style.left=l+"px"),n&&Dn(this,l,a,l+t.offsetWidth,a+t.offsetHeight)},triggerOnKeyDown:Ot(hn),triggerOnKeyPress:Ot(mn),triggerOnKeyUp:pn,execCommand:function(e){return ua.hasOwnProperty(e)?ua[e].call(null,this):void 0},triggerElectric:Ot(function(e){Q(this,e)}),findPosH:function(e,t,n,r){var i=1;0>t&&(i=-1,t=-t);for(var o=0,a=me(this.doc,e);t>o&&(a=Un(this.doc,a,i,n,r),!a.hitSide);++o);return a},moveH:Ot(function(e,t){var n=this;n.extendSelectionsBy(function(r){return n.display.shift||n.doc.extend||r.empty()?Un(n.doc,r.head,e,t,n.options.rtlMoveVisually):0>e?r.from():r.to()},_a)}),deleteH:Ot(function(e,t){var n=this.doc.sel,r=this.doc;n.somethingSelected()?r.replaceSelection("",null,"+delete"):jn(this,function(n){var i=Un(r,n.head,e,t,!1);return 0>e?{from:i,to:n.head}:{from:n.head,to:i}})}),findPosV:function(e,t,n,r){var i=1,o=r;0>t&&(i=-1,t=-t);for(var a=0,l=me(this.doc,e);t>a;++a){var s=dt(this,l,"div");if(null==o?o=s.left:s.left=o,l=qn(this,s,i,n),l.hitSide)break}return l},moveV:Ot(function(e,t){var n=this,r=this.doc,i=[],o=!n.display.shift&&!r.extend&&r.sel.somethingSelected();if(r.extendSelectionsBy(function(a){if(o)return 0>e?a.from():a.to();var l=dt(n,a.head,"div");null!=a.goalColumn&&(l.left=a.goalColumn),i.push(l.left);var s=qn(n,l,e,t);return"page"==t&&a==r.sel.primary()&&Wn(n,null,ht(n,s,"div").top-l.top),s},_a),i.length)for(var a=0;a0&&l(n.charAt(r-1));)--r;for(;i.5)&&a(this),Pa(this,"refresh",this)}),swapDoc:Ot(function(e){var t=this.doc;return t.cm=null,Xr(this,e),lt(this),this.display.input.reset(),this.scrollTo(e.scrollLeft,e.scrollTop),this.curOp.forceScroll=!0,Ci(this,"swapDoc",this,t),t}),getInputField:function(){return this.display.input.getField()},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},Ai(e);var ea=e.defaults={},ta=e.optionHandlers={},na=e.Init={toString:function(){return"CodeMirror.Init"}};Gn("value","",function(e,t){e.setValue(t)},!0),Gn("mode",null,function(e,t){e.doc.modeOption=t,n(e)},!0),Gn("indentUnit",2,n,!0),Gn("indentWithTabs",!1),Gn("smartIndent",!0),Gn("tabSize",4,function(e){r(e),lt(e),Dt(e)},!0),Gn("lineSeparator",null,function(e,t){if(e.doc.lineSep=t,t){var n=[],r=e.doc.first;e.doc.iter(function(e){for(var i=0;;){var o=e.text.indexOf(t,i);if(-1==o)break;i=o+t.length,n.push(Bo(r,o))}r++});for(var i=n.length-1;i>=0;i--)In(e.doc,t,n[i],Bo(n[i].line,n[i].ch+t.length))}}),Gn("specialChars",/[\u0000-\u001f\u007f\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g,function(t,n,r){t.state.specialChars=new RegExp(n.source+(n.test(" ")?"":"| "),"g"),r!=e.Init&&t.refresh()}),Gn("specialCharPlaceholder",_r,function(e){e.refresh()},!0),Gn("electricChars",!0),Gn("inputStyle",Ao?"contenteditable":"textarea",function(){throw new Error("inputStyle can not (yet) be changed in a running editor")},!0),Gn("rtlMoveVisually",!Io),Gn("wholeLineUpdateBefore",!0),Gn("theme","default",function(e){l(e),s(e)},!0),Gn("keyMap","default",function(t,n,r){var i=$n(n),o=r!=e.Init&&$n(r);o&&o.detach&&o.detach(t,i),i.attach&&i.attach(t,o||null)}),Gn("extraKeys",null),Gn("lineWrapping",!1,i,!0),Gn("gutters",[],function(e){d(e.options),s(e)},!0),Gn("fixedGutter",!0,function(e,t){e.display.gutters.style.left=t?C(e.display)+"px":"0",e.refresh()},!0),Gn("coverGutterNextToScrollbar",!1,function(e){y(e)},!0),Gn("scrollbarStyle","native",function(e){v(e),y(e),e.display.scrollbars.setScrollTop(e.doc.scrollTop),e.display.scrollbars.setScrollLeft(e.doc.scrollLeft)},!0),Gn("lineNumbers",!1,function(e){d(e.options),s(e)},!0),Gn("firstLineNumber",1,s,!0),Gn("lineNumberFormatter",function(e){return e},s,!0),Gn("showCursorWhenSelecting",!1,Re,!0),Gn("resetSelectionOnContextMenu",!0),Gn("lineWiseCopyCut",!0),Gn("readOnly",!1,function(e,t){"nocursor"==t?(yn(e),e.display.input.blur(),e.display.disabled=!0):e.display.disabled=!1,e.display.input.readOnlyChanged(t)}),Gn("disableInput",!1,function(e,t){t||e.display.input.reset()},!0),Gn("dragDrop",!0,Ut),Gn("allowDropFileTypes",null),Gn("cursorBlinkRate",530),Gn("cursorScrollMargin",0),Gn("cursorHeight",1,Re,!0),Gn("singleCursorHeightPerLine",!0,Re,!0),Gn("workTime",100),Gn("workDelay",100),Gn("flattenSpans",!0,r,!0),Gn("addModeClass",!1,r,!0),Gn("pollInterval",100),Gn("undoDepth",200,function(e,t){e.doc.history.undoDepth=t}),Gn("historyEventDelay",1250),Gn("viewportMargin",10,function(e){e.refresh()},!0),Gn("maxHighlightLength",1e4,r,!0),Gn("moveInputWithCursor",!0,function(e,t){t||e.display.input.resetPosition()}),Gn("tabindex",null,function(e,t){e.display.input.getField().tabIndex=t||""}),Gn("autofocus",null);var ra=e.modes={},ia=e.mimeModes={};e.defineMode=function(t,n){e.defaults.mode||"null"==t||(e.defaults.mode=t),arguments.length>2&&(n.dependencies=Array.prototype.slice.call(arguments,2)),ra[t]=n},e.defineMIME=function(e,t){ia[e]=t},e.resolveMode=function(t){if("string"==typeof t&&ia.hasOwnProperty(t))t=ia[t];else if(t&&"string"==typeof t.name&&ia.hasOwnProperty(t.name)){var n=ia[t.name];"string"==typeof n&&(n={name:n}),t=Hi(n,t),t.name=n.name}else if("string"==typeof t&&/^[\w\-]+\/[\w\-]+\+xml$/.test(t))return e.resolveMode("application/xml");return"string"==typeof t?{name:t}:t||{name:"null"}},e.getMode=function(t,n){var n=e.resolveMode(n),r=ra[n.name];if(!r)return e.getMode(t,"text/plain");var i=r(t,n);if(oa.hasOwnProperty(n.name)){var o=oa[n.name];for(var a in o)o.hasOwnProperty(a)&&(i.hasOwnProperty(a)&&(i["_"+a]=i[a]),i[a]=o[a])}if(i.name=n.name,n.helperType&&(i.helperType=n.helperType),n.modeProps)for(var a in n.modeProps)i[a]=n.modeProps[a];return i},e.defineMode("null",function(){return{token:function(e){e.skipToEnd()}}}),e.defineMIME("text/plain","null");var oa=e.modeExtensions={};e.extendMode=function(e,t){var n=oa.hasOwnProperty(e)?oa[e]:oa[e]={};Wi(t,n)},e.defineExtension=function(t,n){e.prototype[t]=n},e.defineDocExtension=function(e,t){Ca.prototype[e]=t},e.defineOption=Gn;var aa=[];e.defineInitHook=function(e){aa.push(e)};var la=e.helpers={};e.registerHelper=function(t,n,r){la.hasOwnProperty(t)||(la[t]=e[t]={_global:[]}),la[t][n]=r},e.registerGlobalHelper=function(t,n,r,i){e.registerHelper(t,n,i),la[t]._global.push({pred:r,val:i})};var sa=e.copyState=function(e,t){if(t===!0)return t;if(e.copyState)return e.copyState(t);var n={};for(var r in t){var i=t[r];i instanceof Array&&(i=i.concat([])),n[r]=i}return n},ca=e.startState=function(e,t,n){return e.startState?e.startState(t,n):!0};e.innerMode=function(e,t){for(;e.innerMode;){var n=e.innerMode(t);if(!n||n.mode==e)break;t=n.state,e=n.mode}return n||{mode:e,state:t}};var ua=e.commands={selectAll:function(e){e.setSelection(Bo(e.firstLine(),0),Bo(e.lastLine()),Wa)},singleSelection:function(e){e.setSelection(e.getCursor("anchor"),e.getCursor("head"),Wa)},killLine:function(e){jn(e,function(t){if(t.empty()){var n=Zr(e.doc,t.head.line).text.length;return t.head.ch==n&&t.head.line0)i=new Bo(i.line,i.ch+1),e.replaceRange(o.charAt(i.ch-1)+o.charAt(i.ch-2),Bo(i.line,i.ch-2),i,"+transpose");else if(i.line>e.doc.first){var a=Zr(e.doc,i.line-1).text;a&&e.replaceRange(o.charAt(0)+e.doc.lineSeparator()+a.charAt(a.length-1),Bo(i.line-1,a.length-1),Bo(i.line,1),"+transpose")}n.push(new fe(i,i))}e.setSelections(n)})},newlineAndIndent:function(e){At(e,function(){for(var t=e.listSelections().length,n=0;t>n;n++){var r=e.listSelections()[n];e.replaceRange(e.doc.lineSeparator(),r.anchor,r.head,"+input"),e.indentLine(r.from().line+1,null,!0)}Bn(e)})},openLine:function(e){e.replaceSelection("\n","start")},toggleOverwrite:function(e){e.toggleOverwrite()}},fa=e.keyMap={};fa.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},fa.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},fa.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars","Ctrl-O":"openLine"},fa.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},fa["default"]=Eo?fa.macDefault:fa.pcDefault,e.normalizeKeyMap=function(e){var t={};for(var n in e)if(e.hasOwnProperty(n)){var r=e[n];if(/^(name|fallthrough|(de|at)tach)$/.test(n))continue;if("..."==r){delete e[n];continue}for(var i=Ri(n.split(" "),Yn),o=0;o=this.string.length},sol:function(){return this.pos==this.lineStart},peek:function(){return this.string.charAt(this.pos)||void 0},next:function(){return this.post},eatSpace:function(){for(var e=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>e},skipToEnd:function(){this.pos=this.string.length},skipTo:function(e){var t=this.string.indexOf(e,this.pos);return t>-1?(this.pos=t,!0):void 0},backUp:function(e){this.pos-=e},column:function(){return this.lastColumnPos0?null:(r&&t!==!1&&(this.pos+=r[0].length),r)}var i=function(e){return n?e.toLowerCase():e},o=this.string.substr(this.pos,e.length);return i(o)==i(e)?(t!==!1&&(this.pos+=e.length),!0):void 0},current:function(){return this.string.slice(this.start,this.pos)},hideFirstChars:function(e,t){this.lineStart+=e;try{return t()}finally{this.lineStart-=e}}};var ga=0,va=e.TextMarker=function(e,t){this.lines=[],this.type=t,this.doc=e,this.id=++ga};Ai(va),va.prototype.clear=function(){if(!this.explicitlyCleared){var e=this.doc.cm,t=e&&!e.curOp;if(t&&bt(e),Ni(this,"clear")){var n=this.find();n&&Ci(this,"clear",n.from,n.to)}for(var r=null,i=null,o=0;oe.display.maxLineLength&&(e.display.maxLine=s,e.display.maxLineLength=c,e.display.maxLineChanged=!0)}null!=r&&e&&this.collapsed&&Dt(e,r,i+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,e&&Ae(e.doc)),e&&Ci(e,"markerCleared",e,this),t&&kt(e),this.parent&&this.parent.clear()}},va.prototype.find=function(e,t){null==e&&"bookmark"==this.type&&(e=1);for(var n,r,i=0;in;++n){var i=this.lines[n];this.height-=i.height,Nr(i),Ci(i,"delete")}this.lines.splice(e,t)},collapse:function(e){e.push.apply(e,this.lines)},insertInner:function(e,t,n){this.height+=n,this.lines=this.lines.slice(0,e).concat(t).concat(this.lines.slice(e));for(var r=0;re;++e)if(n(this.lines[e]))return!0}},Vr.prototype={chunkSize:function(){return this.size},removeInner:function(e,t){this.size-=t;for(var n=0;ne){var o=Math.min(t,i-e),a=r.height;if(r.removeInner(e,o),this.height-=a-r.height,i==o&&(this.children.splice(n--,1),r.parent=null),0==(t-=o))break;e=0}else e-=i}if(this.size-t<25&&(this.children.length>1||!(this.children[0]instanceof $r))){var l=[];this.collapse(l),this.children=[new $r(l)],this.children[0].parent=this}},collapse:function(e){for(var t=0;t=e){if(i.insertInner(e,t,n),i.lines&&i.lines.length>50){for(var a=i.lines.length%25+25,l=a;l10);e.parent.maybeSpill()}},iterN:function(e,t,n){for(var r=0;re){var a=Math.min(t,o-e);if(i.iterN(e,a,n))return!0;if(0==(t-=a))break;e=0}else e-=o}}};var Sa=0,Ca=e.Doc=function(e,t,n,r){if(!(this instanceof Ca))return new Ca(e,t,n,r);null==n&&(n=0),Vr.call(this,[new $r([new ba("",null)])]),this.first=n,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.frontier=n;var i=Bo(n,0);this.sel=de(i),this.history=new oi(null),this.id=++Sa,this.modeOption=t,this.lineSep=r,this.extend=!1,"string"==typeof e&&(e=this.splitLines(e)),Yr(this,{from:i,to:i,text:e}),Te(this,de(i),Wa)};Ca.prototype=Hi(Vr.prototype,{constructor:Ca,iter:function(e,t,n){n?this.iterN(e-this.first,t-e,n):this.iterN(this.first,this.first+this.size,e)},insert:function(e,t){for(var n=0,r=0;r=0;o--)Tn(this,r[o]);l?Le(this,l):this.cm&&Bn(this.cm)}),undo:It(function(){Nn(this,"undo")}),redo:It(function(){Nn(this,"redo")}),undoSelection:It(function(){Nn(this,"undo",!0)}),redoSelection:It(function(){Nn(this,"redo",!0)}),setExtending:function(e){this.extend=e},getExtending:function(){return this.extend},historySize:function(){for(var e=this.history,t=0,n=0,r=0;r=e.ch)&&t.push(i.marker.parent||i.marker)}return t},findMarks:function(e,t,n){e=me(this,e),t=me(this,t);var r=[],i=e.line;return this.iter(e.line,t.line+1,function(o){var a=o.markedSpans;if(a)for(var l=0;l=s.to||null==s.from&&i!=e.line||null!=s.from&&i==t.line&&s.from>=t.ch||n&&!n(s.marker)||r.push(s.marker.parent||s.marker)}++i}),r},getAllMarks:function(){var e=[];return this.iter(function(t){var n=t.markedSpans;if(n)for(var r=0;re?(t=e,!0):(e-=o,void++n)}),me(this,Bo(n,t))},indexFromPos:function(e){e=me(this,e);var t=e.ch;if(e.linet&&(t=e.from),null!=e.to&&e.tol||l>=t)return a+(t-o);a+=l-o,a+=n-a%n,o=l+1}},za=e.findColumn=function(e,t,n){for(var r=0,i=0;;){var o=e.indexOf(" ",r);-1==o&&(o=e.length);var a=o-r;if(o==e.length||i+a>=t)return r+Math.min(a,t-i);if(i+=o-r,i+=n-i%n,r=o+1,i>=t)return r}},ja=[""],Ua=function(e){e.select()};No?Ua=function(e){e.selectionStart=0,e.selectionEnd=e.value.length}:xo&&(Ua=function(e){try{e.select()}catch(t){}});var qa,Ga=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,Ya=e.isWordChar=function(e){return/\w/.test(e)||e>"€"&&(e.toUpperCase()!=e.toLowerCase()||Ga.test(e))},$a=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\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\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\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\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;qa=document.createRange?function(e,t,n,r){var i=document.createRange();return i.setEnd(r||e,n),i.setStart(e,t),i}:function(e,t,n){var r=document.body.createTextRange();try{r.moveToElementText(e.parentNode)}catch(i){return r}return r.collapse(!0),r.moveEnd("character",n),r.moveStart("character",t),r};var Va=e.contains=function(e,t){if(3==t.nodeType&&(t=t.parentNode),e.contains)return e.contains(t);do if(11==t.nodeType&&(t=t.host),t==e)return!0;while(t=t.parentNode)};xo&&11>bo&&(Gi=function(){try{return document.activeElement}catch(e){return document.body}});var Ka,Xa,Za=e.rmClass=function(e,t){var n=e.className,r=Yi(t).exec(n);if(r){var i=n.slice(r.index+r[0].length);e.className=n.slice(0,r.index)+(i?r[1]+i:"")}},Ja=e.addClass=function(e,t){var n=e.className;Yi(t).test(n)||(e.className+=(n?" ":"")+t)},Qa=!1,el=function(){if(xo&&9>bo)return!1;var e=ji("div");return"draggable"in e||"dragDrop"in e}(),tl=e.splitLines=3!="\n\nb".split(/\n/).length?function(e){for(var t=0,n=[],r=e.length;r>=t;){var i=e.indexOf("\n",t);-1==i&&(i=e.length);var o=e.slice(t,"\r"==e.charAt(i-1)?i-1:i),a=o.indexOf("\r");-1!=a?(n.push(o.slice(0,a)),t+=a+1):(n.push(o),t=i+1)}return n}:function(e){return e.split(/\r\n?|\n/)},nl=window.getSelection?function(e){try{return e.selectionStart!=e.selectionEnd}catch(t){return!1}}:function(e){try{var t=e.ownerDocument.selection.createRange()}catch(n){}return t&&t.parentElement()==e?0!=t.compareEndPoints("StartToEnd",t):!1},rl=function(){var e=ji("div");return"oncopy"in e?!0:(e.setAttribute("oncopy","return;"),"function"==typeof e.oncopy)}(),il=null,ol=e.keyNames={3:"Enter",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",106:"*",107:"=",109:"-",110:".",111:"/",127:"Delete",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"};!function(){for(var e=0;10>e;e++)ol[e+48]=ol[e+96]=String(e);for(var e=65;90>=e;e++)ol[e]=String.fromCharCode(e);for(var e=1;12>=e;e++)ol[e+111]=ol[e+63235]="F"+e}();var al,ll=function(){function e(e){return 247>=e?n.charAt(e):e>=1424&&1524>=e?"R":e>=1536&&1773>=e?r.charAt(e-1536):e>=1774&&2220>=e?"r":e>=8192&&8203>=e?"w":8204==e?"b":"L"}function t(e,t,n){this.level=e,this.from=t,this.to=n}var n="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",r="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm",i=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,o=/[stwN]/,a=/[LRr]/,l=/[Lb1n]/,s=/[1n]/,c="L";return function(n){if(!i.test(n))return!1;for(var r,u=n.length,f=[],h=0;u>h;++h)f.push(r=e(n.charCodeAt(h)));for(var h=0,d=c;u>h;++h){var r=f[h];"m"==r?f[h]=d:d=r}for(var h=0,p=c;u>h;++h){var r=f[h];"1"==r&&"r"==p?f[h]="n":a.test(r)&&(p=r,"r"==r&&(f[h]="R"))}for(var h=1,d=f[0];u-1>h;++h){var r=f[h];"+"==r&&"1"==d&&"1"==f[h+1]?f[h]="1":","!=r||d!=f[h+1]||"1"!=d&&"n"!=d||(f[h]=d),d=r}for(var h=0;u>h;++h){var r=f[h];if(","==r)f[h]="N";else if("%"==r){for(var m=h+1;u>m&&"%"==f[m];++m);for(var g=h&&"!"==f[h-1]||u>m&&"1"==f[m]?"1":"N",v=h;m>v;++v)f[v]=g;h=m-1}}for(var h=0,p=c;u>h;++h){var r=f[h];"L"==p&&"1"==r?f[h]="L":a.test(r)&&(p=r)}for(var h=0;u>h;++h)if(o.test(f[h])){for(var m=h+1;u>m&&o.test(f[m]);++m);for(var y="L"==(h?f[h-1]:c),x="L"==(u>m?f[m]:c),g=y||x?"L":"R",v=h;m>v;++v)f[v]=g;h=m-1}for(var b,w=[],h=0;u>h;)if(l.test(f[h])){var k=h;for(++h;u>h&&l.test(f[h]);++h);w.push(new t(0,k,h))}else{var S=h,C=w.length;for(++h;u>h&&"L"!=f[h];++h);for(var v=S;h>v;)if(s.test(f[v])){v>S&&w.splice(C,0,new t(1,S,v));var L=v;for(++v;h>v&&s.test(f[v]);++v);w.splice(C,0,new t(2,L,v)),S=v}else++v;h>S&&w.splice(C,0,new t(1,S,h))}return 1==w[0].level&&(b=n.match(/^\s+/))&&(w[0].from=b[0].length,w.unshift(new t(0,0,b[0].length))),1==Ii(w).level&&(b=n.match(/\s+$/))&&(Ii(w).to-=b[0].length,w.push(new t(0,u-b[0].length,u))),2==w[0].level&&w.unshift(new t(1,w[0].to,w[0].to)),w[0].level!=Ii(w).level&&w.push(new t(w[0].level,u,u)),w}}();return e.version="5.15.2",e})},{}],11:[function(t,n,r){!function(i){"object"==typeof r&&"object"==typeof n?i(t("../../lib/codemirror"),t("../markdown/markdown"),t("../../addon/mode/overlay")):"function"==typeof e&&e.amd?e(["../../lib/codemirror","../markdown/markdown","../../addon/mode/overlay"],i):i(CodeMirror)}(function(e){"use strict";var t=/^((?:(?:aaas?|about|acap|adiumxtra|af[ps]|aim|apt|attachment|aw|beshare|bitcoin|bolo|callto|cap|chrome(?:-extension)?|cid|coap|com-eventbrite-attendee|content|crid|cvs|data|dav|dict|dlna-(?:playcontainer|playsingle)|dns|doi|dtn|dvb|ed2k|facetime|feed|file|finger|fish|ftp|geo|gg|git|gizmoproject|go|gopher|gtalk|h323|hcp|https?|iax|icap|icon|im|imap|info|ipn|ipp|irc[6s]?|iris(?:\.beep|\.lwz|\.xpc|\.xpcs)?|itms|jar|javascript|jms|keyparc|lastfm|ldaps?|magnet|mailto|maps|market|message|mid|mms|ms-help|msnim|msrps?|mtqp|mumble|mupdate|mvn|news|nfs|nih?|nntp|notes|oid|opaquelocktoken|palm|paparazzi|platform|pop|pres|proxy|psyc|query|res(?:ource)?|rmi|rsync|rtmp|rtsp|secondlife|service|session|sftp|sgn|shttp|sieve|sips?|skype|sm[bs]|snmp|soap\.beeps?|soldat|spotify|ssh|steam|svn|tag|teamspeak|tel(?:net)?|tftp|things|thismessage|tip|tn3270|tv|udp|unreal|urn|ut2004|vemmi|ventrilo|view-source|webcal|wss?|wtai|wyciwyg|xcon(?:-userid)?|xfire|xmlrpc\.beeps?|xmpp|xri|ymsgr|z39\.50[rs]?):(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]|\([^\s()<>]*\))+(?:\([^\s()<>]*\)|[^\s`*!()\[\]{};:'".,<>?«»“”‘’]))/i;e.defineMode("gfm",function(n,r){function i(e){return e.code=!1,null}var o=0,a={startState:function(){return{code:!1,codeBlock:!1,ateSpace:!1}},copyState:function(e){return{code:e.code,codeBlock:e.codeBlock,ateSpace:e.ateSpace}},token:function(e,n){if(n.combineTokens=null,n.codeBlock)return e.match(/^```+/)?(n.codeBlock=!1,null):(e.skipToEnd(),null);if(e.sol()&&(n.code=!1),e.sol()&&e.match(/^```+/))return e.skipToEnd(),n.codeBlock=!0,null;if("`"===e.peek()){e.next();var i=e.pos;e.eatWhile("`");var a=1+e.pos-i;return n.code?a===o&&(n.code=!1):(o=a,n.code=!0),null}if(n.code)return e.next(),null;if(e.eatSpace())return n.ateSpace=!0,null;if((e.sol()||n.ateSpace)&&(n.ateSpace=!1,r.gitHubSpice!==!1)){if(e.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+@)?(?:[a-f0-9]{7,40}\b)/))return n.combineTokens=!0,"link";if(e.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+)?#[0-9]+\b/))return n.combineTokens=!0,"link"}return e.match(t)&&"]("!=e.string.slice(e.start-2,e.start)&&(0==e.start||/\W/.test(e.string.charAt(e.start-1)))?(n.combineTokens=!0,"link"):(e.next(),null)},blankLine:i},l={underscoresBreakWords:!1,taskLists:!0,fencedCodeBlocks:"```",strikethrough:!0};for(var s in r)l[s]=r[s];return l.name="markdown",e.overlayMode(e.getMode(n,l),a)},"markdown"),e.defineMIME("text/x-gfm","gfm")})},{"../../addon/mode/overlay":8,"../../lib/codemirror":10,"../markdown/markdown":12}],12:[function(t,n,r){!function(i){"object"==typeof r&&"object"==typeof n?i(t("../../lib/codemirror"),t("../xml/xml"),t("../meta")):"function"==typeof e&&e.amd?e(["../../lib/codemirror","../xml/xml","../meta"],i):i(CodeMirror)}(function(e){"use strict";e.defineMode("markdown",function(t,n){function r(n){if(e.findModeByName){var r=e.findModeByName(n);r&&(n=r.mime||r.mimes[0])}var i=e.getMode(t,n);return"null"==i.name?null:i}function i(e,t,n){return t.f=t.inline=n,n(e,t)}function o(e,t,n){return t.f=t.block=n,n(e,t)}function a(e){return!e||!/\S/.test(e.string)}function l(e){return e.linkTitle=!1,e.em=!1,e.strong=!1,e.strikethrough=!1,e.quote=0,e.indentedCode=!1,k&&e.f==c&&(e.f=p,e.block=s),e.trailingSpace=0,e.trailingSpaceNewLine=!1,e.prevLine=e.thisLine,e.thisLine=null,null}function s(t,o){var l=t.sol(),s=o.list!==!1,c=o.indentedCode;o.indentedCode=!1,s&&(o.indentationDiff>=0?(o.indentationDiff<4&&(o.indentation-=o.indentationDiff),o.list=null):o.indentation>0?o.list=null:o.list=!1);var f=null;if(o.indentationDiff>=4)return t.skipToEnd(),c||a(o.prevLine)?(o.indentation-=4,o.indentedCode=!0,S.code):null;if(t.eatSpace())return null;if((f=t.match(A))&&f[1].length<=6)return o.header=f[1].length,n.highlightFormatting&&(o.formatting="header"),o.f=o.inline,h(o);if(!(a(o.prevLine)||o.quote||s||c)&&(f=t.match(E)))return o.header="="==f[0].charAt(0)?1:2,n.highlightFormatting&&(o.formatting="header"),o.f=o.inline,h(o);if(t.eat(">"))return o.quote=l?1:o.quote+1,n.highlightFormatting&&(o.formatting="quote"),t.eatSpace(),h(o);if("["===t.peek())return i(t,o,y);if(t.match(L,!0))return o.hr=!0,S.hr;if((a(o.prevLine)||s)&&(t.match(T,!1)||t.match(M,!1))){var d=null;for(t.match(T,!0)?d="ul":(t.match(M,!0),d="ol"),o.indentation=t.column()+t.current().length,o.list=!0;o.listStack&&t.column()")>-1)&&(n.f=p,n.block=s,n.htmlState=null)}return r}function u(e,t){return t.fencedChars&&e.match(t.fencedChars,!1)?(t.localMode=t.localState=null,t.f=t.block=f,null):t.localMode?t.localMode.token(e,t.localState):(e.skipToEnd(),S.code)}function f(e,t){e.match(t.fencedChars),t.block=s,t.f=p,t.fencedChars=null,n.highlightFormatting&&(t.formatting="code-block"),t.code=1;var r=h(t);return t.code=0,r}function h(e){var t=[];if(e.formatting){t.push(S.formatting),"string"==typeof e.formatting&&(e.formatting=[e.formatting]);for(var r=0;r=e.quote?t.push(S.formatting+"-"+e.formatting[r]+"-"+e.quote):t.push("error"))}if(e.taskOpen)return t.push("meta"),t.length?t.join(" "):null;if(e.taskClosed)return t.push("property"),t.length?t.join(" "):null;if(e.linkHref?t.push(S.linkHref,"url"):(e.strong&&t.push(S.strong),e.em&&t.push(S.em),e.strikethrough&&t.push(S.strikethrough),e.linkText&&t.push(S.linkText),e.code&&t.push(S.code)),e.header&&t.push(S.header,S.header+"-"+e.header),e.quote&&(t.push(S.quote),!n.maxBlockquoteDepth||n.maxBlockquoteDepth>=e.quote?t.push(S.quote+"-"+e.quote):t.push(S.quote+"-"+n.maxBlockquoteDepth)),e.list!==!1){var i=(e.listStack.length-1)%3;i?1===i?t.push(S.list2):t.push(S.list3):t.push(S.list1)}return e.trailingSpaceNewLine?t.push("trailing-space-new-line"):e.trailingSpace&&t.push("trailing-space-"+(e.trailingSpace%2?"a":"b")),t.length?t.join(" "):null}function d(e,t){return e.match(O,!0)?h(t):void 0}function p(t,r){var i=r.text(t,r);if("undefined"!=typeof i)return i;if(r.list)return r.list=null,h(r);if(r.taskList){var a="x"!==t.match(N,!0)[1];return a?r.taskOpen=!0:r.taskClosed=!0,n.highlightFormatting&&(r.formatting="task"),r.taskList=!1,h(r)}if(r.taskOpen=!1,r.taskClosed=!1,r.header&&t.match(/^#+$/,!0))return n.highlightFormatting&&(r.formatting="header"), +h(r);var l=t.sol(),s=t.next();if(r.linkTitle){r.linkTitle=!1;var u=s;"("===s&&(u=")"),u=(u+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1");var f="^\\s*(?:[^"+u+"\\\\]+|\\\\\\\\|\\\\.)"+u;if(t.match(new RegExp(f),!0))return S.linkHref}if("`"===s){var d=r.formatting;n.highlightFormatting&&(r.formatting="code"),t.eatWhile("`");var p=t.current().length;if(0==r.code)return r.code=p,h(r);if(p==r.code){var v=h(r);return r.code=0,v}return r.formatting=d,h(r)}if(r.code)return h(r);if("\\"===s&&(t.next(),n.highlightFormatting)){var y=h(r),x=S.formatting+"-escape";return y?y+" "+x:x}if("!"===s&&t.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))return t.match(/\[[^\]]*\]/),r.inline=r.f=g,S.image;if("["===s&&t.match(/[^\]]*\](\(.*\)| ?\[.*?\])/,!1))return r.linkText=!0,n.highlightFormatting&&(r.formatting="link"),h(r);if("]"===s&&r.linkText&&t.match(/\(.*?\)| ?\[.*?\]/,!1)){n.highlightFormatting&&(r.formatting="link");var y=h(r);return r.linkText=!1,r.inline=r.f=g,y}if("<"===s&&t.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1)){r.f=r.inline=m,n.highlightFormatting&&(r.formatting="link");var y=h(r);return y?y+=" ":y="",y+S.linkInline}if("<"===s&&t.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1)){r.f=r.inline=m,n.highlightFormatting&&(r.formatting="link");var y=h(r);return y?y+=" ":y="",y+S.linkEmail}if("<"===s&&t.match(/^(!--|\w)/,!1)){var b=t.string.indexOf(">",t.pos);if(-1!=b){var k=t.string.substring(t.start,b);/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(k)&&(r.md_inside=!0)}return t.backUp(1),r.htmlState=e.startState(w),o(t,r,c)}if("<"===s&&t.match(/^\/\w*?>/))return r.md_inside=!1,"tag";var C=!1;if(!n.underscoresBreakWords&&"_"===s&&"_"!==t.peek()&&t.match(/(\w)/,!1)){var L=t.pos-2;if(L>=0){var T=t.string.charAt(L);"_"!==T&&T.match(/(\w)/,!1)&&(C=!0)}}if("*"===s||"_"===s&&!C)if(l&&" "===t.peek());else{if(r.strong===s&&t.eat(s)){n.highlightFormatting&&(r.formatting="strong");var v=h(r);return r.strong=!1,v}if(!r.strong&&t.eat(s))return r.strong=s,n.highlightFormatting&&(r.formatting="strong"),h(r);if(r.em===s){n.highlightFormatting&&(r.formatting="em");var v=h(r);return r.em=!1,v}if(!r.em)return r.em=s,n.highlightFormatting&&(r.formatting="em"),h(r)}else if(" "===s&&(t.eat("*")||t.eat("_"))){if(" "===t.peek())return h(r);t.backUp(1)}if(n.strikethrough)if("~"===s&&t.eatWhile(s)){if(r.strikethrough){n.highlightFormatting&&(r.formatting="strikethrough");var v=h(r);return r.strikethrough=!1,v}if(t.match(/^[^\s]/,!1))return r.strikethrough=!0,n.highlightFormatting&&(r.formatting="strikethrough"),h(r)}else if(" "===s&&t.match(/^~~/,!0)){if(" "===t.peek())return h(r);t.backUp(2)}return" "===s&&(t.match(/ +$/,!1)?r.trailingSpace++:r.trailingSpace&&(r.trailingSpaceNewLine=!0)),h(r)}function m(e,t){var r=e.next();if(">"===r){t.f=t.inline=p,n.highlightFormatting&&(t.formatting="link");var i=h(t);return i?i+=" ":i="",i+S.linkInline}return e.match(/^[^>]+/,!0),S.linkInline}function g(e,t){if(e.eatSpace())return null;var r=e.next();return"("===r||"["===r?(t.f=t.inline=v("("===r?")":"]",0),n.highlightFormatting&&(t.formatting="link-string"),t.linkHref=!0,h(t)):"error"}function v(e){return function(t,r){var i=t.next();if(i===e){r.f=r.inline=p,n.highlightFormatting&&(r.formatting="link-string");var o=h(r);return r.linkHref=!1,o}return t.match(P[e]),r.linkHref=!0,h(r)}}function y(e,t){return e.match(/^([^\]\\]|\\.)*\]:/,!1)?(t.f=x,e.next(),n.highlightFormatting&&(t.formatting="link"),t.linkText=!0,h(t)):i(e,t,p)}function x(e,t){if(e.match(/^\]:/,!0)){t.f=t.inline=b,n.highlightFormatting&&(t.formatting="link");var r=h(t);return t.linkText=!1,r}return e.match(/^([^\]\\]|\\.)+/,!0),S.linkText}function b(e,t){return e.eatSpace()?null:(e.match(/^[^\s]+/,!0),void 0===e.peek()?t.linkTitle=!0:e.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/,!0),t.f=t.inline=p,S.linkHref+" url")}var w=e.getMode(t,"text/html"),k="null"==w.name;void 0===n.highlightFormatting&&(n.highlightFormatting=!1),void 0===n.maxBlockquoteDepth&&(n.maxBlockquoteDepth=0),void 0===n.underscoresBreakWords&&(n.underscoresBreakWords=!0),void 0===n.taskLists&&(n.taskLists=!1),void 0===n.strikethrough&&(n.strikethrough=!1),void 0===n.tokenTypeOverrides&&(n.tokenTypeOverrides={});var S={header:"header",code:"comment",quote:"quote",list1:"variable-2",list2:"variable-3",list3:"keyword",hr:"hr",image:"tag",formatting:"formatting",linkInline:"link",linkEmail:"link",linkText:"link",linkHref:"string",em:"em",strong:"strong",strikethrough:"strikethrough"};for(var C in S)S.hasOwnProperty(C)&&n.tokenTypeOverrides[C]&&(S[C]=n.tokenTypeOverrides[C]);var L=/^([*\-_])(?:\s*\1){2,}\s*$/,T=/^[*\-+]\s+/,M=/^[0-9]+([.)])\s+/,N=/^\[(x| )\](?=\s)/,A=n.allowAtxHeaderWithoutSpace?/^(#+)/:/^(#+)(?: |$)/,E=/^ *(?:\={1,}|-{1,})\s*$/,O=/^[^#!\[\]*_\\<>` "'(~]+/,I=new RegExp("^("+(n.fencedCodeBlocks===!0?"~~~+|```+":n.fencedCodeBlocks)+")[ \\t]*([\\w+#-]*)"),P={")":/^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,"]":/^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\\]]|\\.)*\])*?(?=\])/},R={startState:function(){return{f:s,prevLine:null,thisLine:null,block:s,htmlState:null,indentation:0,inline:p,text:d,formatting:!1,linkText:!1,linkHref:!1,linkTitle:!1,code:0,em:!1,strong:!1,header:0,hr:!1,taskList:!1,list:!1,listStack:[],quote:0,trailingSpace:0,trailingSpaceNewLine:!1,strikethrough:!1,fencedChars:null}},copyState:function(t){return{f:t.f,prevLine:t.prevLine,thisLine:t.thisLine,block:t.block,htmlState:t.htmlState&&e.copyState(w,t.htmlState),indentation:t.indentation,localMode:t.localMode,localState:t.localMode?e.copyState(t.localMode,t.localState):null,inline:t.inline,text:t.text,formatting:!1,linkTitle:t.linkTitle,code:t.code,em:t.em,strong:t.strong,strikethrough:t.strikethrough,header:t.header,hr:t.hr,taskList:t.taskList,list:t.list,listStack:t.listStack.slice(0),quote:t.quote,indentedCode:t.indentedCode,trailingSpace:t.trailingSpace,trailingSpaceNewLine:t.trailingSpaceNewLine,md_inside:t.md_inside,fencedChars:t.fencedChars}},token:function(e,t){if(t.formatting=!1,e!=t.thisLine){var n=t.header||t.hr;if(t.header=0,t.hr=!1,e.match(/^\s*$/,!0)||n){if(l(t),!n)return null;t.prevLine=null}t.prevLine=t.thisLine,t.thisLine=e,t.taskList=!1,t.trailingSpace=0,t.trailingSpaceNewLine=!1,t.f=t.block;var r=e.match(/^\s*/,!0)[0].replace(/\t/g," ").length;if(t.indentationDiff=Math.min(r-t.indentation,4),t.indentation=t.indentation+t.indentationDiff,r>0)return null}return t.f(e,t)},innerMode:function(e){return e.block==c?{state:e.htmlState,mode:w}:e.localState?{state:e.localState,mode:e.localMode}:{state:e,mode:R}},blankLine:l,getType:h,fold:"markdown"};return R},"xml"),e.defineMIME("text/x-markdown","markdown")})},{"../../lib/codemirror":10,"../meta":13,"../xml/xml":14}],13:[function(t,n,r){!function(i){"object"==typeof r&&"object"==typeof n?i(t("../lib/codemirror")):"function"==typeof e&&e.amd?e(["../lib/codemirror"],i):i(CodeMirror)}(function(e){"use strict";e.modeInfo=[{name:"APL",mime:"text/apl",mode:"apl",ext:["dyalog","apl"]},{name:"PGP",mimes:["application/pgp","application/pgp-keys","application/pgp-signature"],mode:"asciiarmor",ext:["pgp"]},{name:"ASN.1",mime:"text/x-ttcn-asn",mode:"asn.1",ext:["asn","asn1"]},{name:"Asterisk",mime:"text/x-asterisk",mode:"asterisk",file:/^extensions\.conf$/i},{name:"Brainfuck",mime:"text/x-brainfuck",mode:"brainfuck",ext:["b","bf"]},{name:"C",mime:"text/x-csrc",mode:"clike",ext:["c","h"]},{name:"C++",mime:"text/x-c++src",mode:"clike",ext:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],alias:["cpp"]},{name:"Cobol",mime:"text/x-cobol",mode:"cobol",ext:["cob","cpy"]},{name:"C#",mime:"text/x-csharp",mode:"clike",ext:["cs"],alias:["csharp"]},{name:"Clojure",mime:"text/x-clojure",mode:"clojure",ext:["clj","cljc","cljx"]},{name:"ClojureScript",mime:"text/x-clojurescript",mode:"clojure",ext:["cljs"]},{name:"Closure Stylesheets (GSS)",mime:"text/x-gss",mode:"css",ext:["gss"]},{name:"CMake",mime:"text/x-cmake",mode:"cmake",ext:["cmake","cmake.in"],file:/^CMakeLists.txt$/},{name:"CoffeeScript",mime:"text/x-coffeescript",mode:"coffeescript",ext:["coffee"],alias:["coffee","coffee-script"]},{name:"Common Lisp",mime:"text/x-common-lisp",mode:"commonlisp",ext:["cl","lisp","el"],alias:["lisp"]},{name:"Cypher",mime:"application/x-cypher-query",mode:"cypher",ext:["cyp","cypher"]},{name:"Cython",mime:"text/x-cython",mode:"python",ext:["pyx","pxd","pxi"]},{name:"Crystal",mime:"text/x-crystal",mode:"crystal",ext:["cr"]},{name:"CSS",mime:"text/css",mode:"css",ext:["css"]},{name:"CQL",mime:"text/x-cassandra",mode:"sql",ext:["cql"]},{name:"D",mime:"text/x-d",mode:"d",ext:["d"]},{name:"Dart",mimes:["application/dart","text/x-dart"],mode:"dart",ext:["dart"]},{name:"diff",mime:"text/x-diff",mode:"diff",ext:["diff","patch"]},{name:"Django",mime:"text/x-django",mode:"django"},{name:"Dockerfile",mime:"text/x-dockerfile",mode:"dockerfile",file:/^Dockerfile$/},{name:"DTD",mime:"application/xml-dtd",mode:"dtd",ext:["dtd"]},{name:"Dylan",mime:"text/x-dylan",mode:"dylan",ext:["dylan","dyl","intr"]},{name:"EBNF",mime:"text/x-ebnf",mode:"ebnf"},{name:"ECL",mime:"text/x-ecl",mode:"ecl",ext:["ecl"]},{name:"edn",mime:"application/edn",mode:"clojure",ext:["edn"]},{name:"Eiffel",mime:"text/x-eiffel",mode:"eiffel",ext:["e"]},{name:"Elm",mime:"text/x-elm",mode:"elm",ext:["elm"]},{name:"Embedded Javascript",mime:"application/x-ejs",mode:"htmlembedded",ext:["ejs"]},{name:"Embedded Ruby",mime:"application/x-erb",mode:"htmlembedded",ext:["erb"]},{name:"Erlang",mime:"text/x-erlang",mode:"erlang",ext:["erl"]},{name:"Factor",mime:"text/x-factor",mode:"factor",ext:["factor"]},{name:"FCL",mime:"text/x-fcl",mode:"fcl"},{name:"Forth",mime:"text/x-forth",mode:"forth",ext:["forth","fth","4th"]},{name:"Fortran",mime:"text/x-fortran",mode:"fortran",ext:["f","for","f77","f90"]},{name:"F#",mime:"text/x-fsharp",mode:"mllike",ext:["fs"],alias:["fsharp"]},{name:"Gas",mime:"text/x-gas",mode:"gas",ext:["s"]},{name:"Gherkin",mime:"text/x-feature",mode:"gherkin",ext:["feature"]},{name:"GitHub Flavored Markdown",mime:"text/x-gfm",mode:"gfm",file:/^(readme|contributing|history).md$/i},{name:"Go",mime:"text/x-go",mode:"go",ext:["go"]},{name:"Groovy",mime:"text/x-groovy",mode:"groovy",ext:["groovy","gradle"]},{name:"HAML",mime:"text/x-haml",mode:"haml",ext:["haml"]},{name:"Haskell",mime:"text/x-haskell",mode:"haskell",ext:["hs"]},{name:"Haskell (Literate)",mime:"text/x-literate-haskell",mode:"haskell-literate",ext:["lhs"]},{name:"Haxe",mime:"text/x-haxe",mode:"haxe",ext:["hx"]},{name:"HXML",mime:"text/x-hxml",mode:"haxe",ext:["hxml"]},{name:"ASP.NET",mime:"application/x-aspx",mode:"htmlembedded",ext:["aspx"],alias:["asp","aspx"]},{name:"HTML",mime:"text/html",mode:"htmlmixed",ext:["html","htm"],alias:["xhtml"]},{name:"HTTP",mime:"message/http",mode:"http"},{name:"IDL",mime:"text/x-idl",mode:"idl",ext:["pro"]},{name:"Jade",mime:"text/x-jade",mode:"jade",ext:["jade"]},{name:"Java",mime:"text/x-java",mode:"clike",ext:["java"]},{name:"Java Server Pages",mime:"application/x-jsp",mode:"htmlembedded",ext:["jsp"],alias:["jsp"]},{name:"JavaScript",mimes:["text/javascript","text/ecmascript","application/javascript","application/x-javascript","application/ecmascript"],mode:"javascript",ext:["js"],alias:["ecmascript","js","node"]},{name:"JSON",mimes:["application/json","application/x-json"],mode:"javascript",ext:["json","map"],alias:["json5"]},{name:"JSON-LD",mime:"application/ld+json",mode:"javascript",ext:["jsonld"],alias:["jsonld"]},{name:"JSX",mime:"text/jsx",mode:"jsx",ext:["jsx"]},{name:"Jinja2",mime:"null",mode:"jinja2"},{name:"Julia",mime:"text/x-julia",mode:"julia",ext:["jl"]},{name:"Kotlin",mime:"text/x-kotlin",mode:"clike",ext:["kt"]},{name:"LESS",mime:"text/x-less",mode:"css",ext:["less"]},{name:"LiveScript",mime:"text/x-livescript",mode:"livescript",ext:["ls"],alias:["ls"]},{name:"Lua",mime:"text/x-lua",mode:"lua",ext:["lua"]},{name:"Markdown",mime:"text/x-markdown",mode:"markdown",ext:["markdown","md","mkd"]},{name:"mIRC",mime:"text/mirc",mode:"mirc"},{name:"MariaDB SQL",mime:"text/x-mariadb",mode:"sql"},{name:"Mathematica",mime:"text/x-mathematica",mode:"mathematica",ext:["m","nb"]},{name:"Modelica",mime:"text/x-modelica",mode:"modelica",ext:["mo"]},{name:"MUMPS",mime:"text/x-mumps",mode:"mumps",ext:["mps"]},{name:"MS SQL",mime:"text/x-mssql",mode:"sql"},{name:"mbox",mime:"application/mbox",mode:"mbox",ext:["mbox"]},{name:"MySQL",mime:"text/x-mysql",mode:"sql"},{name:"Nginx",mime:"text/x-nginx-conf",mode:"nginx",file:/nginx.*\.conf$/i},{name:"NSIS",mime:"text/x-nsis",mode:"nsis",ext:["nsh","nsi"]},{name:"NTriples",mime:"text/n-triples",mode:"ntriples",ext:["nt"]},{name:"Objective C",mime:"text/x-objectivec",mode:"clike",ext:["m","mm"],alias:["objective-c","objc"]},{name:"OCaml",mime:"text/x-ocaml",mode:"mllike",ext:["ml","mli","mll","mly"]},{name:"Octave",mime:"text/x-octave",mode:"octave",ext:["m"]},{name:"Oz",mime:"text/x-oz",mode:"oz",ext:["oz"]},{name:"Pascal",mime:"text/x-pascal",mode:"pascal",ext:["p","pas"]},{name:"PEG.js",mime:"null",mode:"pegjs",ext:["jsonld"]},{name:"Perl",mime:"text/x-perl",mode:"perl",ext:["pl","pm"]},{name:"PHP",mime:"application/x-httpd-php",mode:"php",ext:["php","php3","php4","php5","phtml"]},{name:"Pig",mime:"text/x-pig",mode:"pig",ext:["pig"]},{name:"Plain Text",mime:"text/plain",mode:"null",ext:["txt","text","conf","def","list","log"]},{name:"PLSQL",mime:"text/x-plsql",mode:"sql",ext:["pls"]},{name:"PowerShell",mime:"application/x-powershell",mode:"powershell",ext:["ps1","psd1","psm1"]},{name:"Properties files",mime:"text/x-properties",mode:"properties",ext:["properties","ini","in"],alias:["ini","properties"]},{name:"ProtoBuf",mime:"text/x-protobuf",mode:"protobuf",ext:["proto"]},{name:"Python",mime:"text/x-python",mode:"python",ext:["BUILD","bzl","py","pyw"],file:/^(BUCK|BUILD)$/},{name:"Puppet",mime:"text/x-puppet",mode:"puppet",ext:["pp"]},{name:"Q",mime:"text/x-q",mode:"q",ext:["q"]},{name:"R",mime:"text/x-rsrc",mode:"r",ext:["r"],alias:["rscript"]},{name:"reStructuredText",mime:"text/x-rst",mode:"rst",ext:["rst"],alias:["rst"]},{name:"RPM Changes",mime:"text/x-rpm-changes",mode:"rpm"},{name:"RPM Spec",mime:"text/x-rpm-spec",mode:"rpm",ext:["spec"]},{name:"Ruby",mime:"text/x-ruby",mode:"ruby",ext:["rb"],alias:["jruby","macruby","rake","rb","rbx"]},{name:"Rust",mime:"text/x-rustsrc",mode:"rust",ext:["rs"]},{name:"SAS",mime:"text/x-sas",mode:"sas",ext:["sas"]},{name:"Sass",mime:"text/x-sass",mode:"sass",ext:["sass"]},{name:"Scala",mime:"text/x-scala",mode:"clike",ext:["scala"]},{name:"Scheme",mime:"text/x-scheme",mode:"scheme",ext:["scm","ss"]},{name:"SCSS",mime:"text/x-scss",mode:"css",ext:["scss"]},{name:"Shell",mime:"text/x-sh",mode:"shell",ext:["sh","ksh","bash"],alias:["bash","sh","zsh"],file:/^PKGBUILD$/},{name:"Sieve",mime:"application/sieve",mode:"sieve",ext:["siv","sieve"]},{name:"Slim",mimes:["text/x-slim","application/x-slim"],mode:"slim",ext:["slim"]},{name:"Smalltalk",mime:"text/x-stsrc",mode:"smalltalk",ext:["st"]},{name:"Smarty",mime:"text/x-smarty",mode:"smarty",ext:["tpl"]},{name:"Solr",mime:"text/x-solr",mode:"solr"},{name:"Soy",mime:"text/x-soy",mode:"soy",ext:["soy"],alias:["closure template"]},{name:"SPARQL",mime:"application/sparql-query",mode:"sparql",ext:["rq","sparql"],alias:["sparul"]},{name:"Spreadsheet",mime:"text/x-spreadsheet",mode:"spreadsheet",alias:["excel","formula"]},{name:"SQL",mime:"text/x-sql",mode:"sql",ext:["sql"]},{name:"Squirrel",mime:"text/x-squirrel",mode:"clike",ext:["nut"]},{name:"Swift",mime:"text/x-swift",mode:"swift",ext:["swift"]},{name:"sTeX",mime:"text/x-stex",mode:"stex"},{name:"LaTeX",mime:"text/x-latex",mode:"stex",ext:["text","ltx"],alias:["tex"]},{name:"SystemVerilog",mime:"text/x-systemverilog",mode:"verilog",ext:["v"]},{name:"Tcl",mime:"text/x-tcl",mode:"tcl",ext:["tcl"]},{name:"Textile",mime:"text/x-textile",mode:"textile",ext:["textile"]},{name:"TiddlyWiki ",mime:"text/x-tiddlywiki",mode:"tiddlywiki"},{name:"Tiki wiki",mime:"text/tiki",mode:"tiki"},{name:"TOML",mime:"text/x-toml",mode:"toml",ext:["toml"]},{name:"Tornado",mime:"text/x-tornado",mode:"tornado"},{name:"troff",mime:"text/troff",mode:"troff",ext:["1","2","3","4","5","6","7","8","9"]},{name:"TTCN",mime:"text/x-ttcn",mode:"ttcn",ext:["ttcn","ttcn3","ttcnpp"]},{name:"TTCN_CFG",mime:"text/x-ttcn-cfg",mode:"ttcn-cfg",ext:["cfg"]},{name:"Turtle",mime:"text/turtle",mode:"turtle",ext:["ttl"]},{name:"TypeScript",mime:"application/typescript",mode:"javascript",ext:["ts"],alias:["ts"]},{name:"Twig",mime:"text/x-twig",mode:"twig"},{name:"Web IDL",mime:"text/x-webidl",mode:"webidl",ext:["webidl"]},{name:"VB.NET",mime:"text/x-vb",mode:"vb",ext:["vb"]},{name:"VBScript",mime:"text/vbscript",mode:"vbscript",ext:["vbs"]},{name:"Velocity",mime:"text/velocity",mode:"velocity",ext:["vtl"]},{name:"Verilog",mime:"text/x-verilog",mode:"verilog",ext:["v"]},{name:"VHDL",mime:"text/x-vhdl",mode:"vhdl",ext:["vhd","vhdl"]},{name:"XML",mimes:["application/xml","text/xml"],mode:"xml",ext:["xml","xsl","xsd"],alias:["rss","wsdl","xsd"]},{name:"XQuery",mime:"application/xquery",mode:"xquery",ext:["xy","xquery"]},{name:"Yacas",mime:"text/x-yacas",mode:"yacas",ext:["ys"]},{name:"YAML",mime:"text/x-yaml",mode:"yaml",ext:["yaml","yml"],alias:["yml"]},{name:"Z80",mime:"text/x-z80",mode:"z80",ext:["z80"]},{name:"mscgen",mime:"text/x-mscgen",mode:"mscgen",ext:["mscgen","mscin","msc"]},{name:"xu",mime:"text/x-xu",mode:"mscgen",ext:["xu"]},{name:"msgenny",mime:"text/x-msgenny",mode:"mscgen",ext:["msgenny"]}];for(var t=0;t-1&&t.substring(i+1,t.length);return o?e.findModeByExtension(o):void 0},e.findModeByName=function(t){t=t.toLowerCase();for(var n=0;n")):null:e.match("--")?n(s("comment","-->")):e.match("DOCTYPE",!0,!0)?(e.eatWhile(/[\w\._\-]/),n(c(1))):null:e.eat("?")?(e.eatWhile(/[\w\._\-]/),t.tokenize=s("meta","?>"),"meta"):(T=e.eat("/")?"closeTag":"openTag",t.tokenize=a,"tag bracket");if("&"==r){var i;return i=e.eat("#")?e.eat("x")?e.eatWhile(/[a-fA-F\d]/)&&e.eat(";"):e.eatWhile(/[\d]/)&&e.eat(";"):e.eatWhile(/[\w\.\-:]/)&&e.eat(";"),i?"atom":"error"}return e.eatWhile(/[^&<]/),null}function a(e,t){var n=e.next();if(">"==n||"/"==n&&e.eat(">"))return t.tokenize=o,T=">"==n?"endTag":"selfcloseTag","tag bracket";if("="==n)return T="equals",null;if("<"==n){t.tokenize=o,t.state=d,t.tagName=t.tagStart=null;var r=t.tokenize(e,t);return r?r+" tag error":"tag error"}return/[\'\"]/.test(n)?(t.tokenize=l(n),t.stringStartCol=e.column(),t.tokenize(e,t)):(e.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function l(e){var t=function(t,n){for(;!t.eol();)if(t.next()==e){n.tokenize=a;break}return"string"};return t.isInAttribute=!0,t}function s(e,t){return function(n,r){for(;!n.eol();){if(n.match(t)){r.tokenize=o;break}n.next()}return e}}function c(e){return function(t,n){for(var r;null!=(r=t.next());){if("<"==r)return n.tokenize=c(e+1),n.tokenize(t,n);if(">"==r){if(1==e){n.tokenize=o;break}return n.tokenize=c(e-1),n.tokenize(t,n)}}return"meta"}}function u(e,t,n){this.prev=e.context,this.tagName=t,this.indent=e.indented,this.startOfLine=n,(S.doNotIndent.hasOwnProperty(t)||e.context&&e.context.noIndent)&&(this.noIndent=!0)}function f(e){e.context&&(e.context=e.context.prev)}function h(e,t){for(var n;;){if(!e.context)return;if(n=e.context.tagName,!S.contextGrabbers.hasOwnProperty(n)||!S.contextGrabbers[n].hasOwnProperty(t))return;f(e)}}function d(e,t,n){return"openTag"==e?(n.tagStart=t.column(),p):"closeTag"==e?m:d}function p(e,t,n){return"word"==e?(n.tagName=t.current(),M="tag",y):(M="error",p)}function m(e,t,n){if("word"==e){var r=t.current();return n.context&&n.context.tagName!=r&&S.implicitlyClosed.hasOwnProperty(n.context.tagName)&&f(n),n.context&&n.context.tagName==r||S.matchClosing===!1?(M="tag",g):(M="tag error",v)}return M="error",v}function g(e,t,n){return"endTag"!=e?(M="error",g):(f(n),d)}function v(e,t,n){return M="error",g(e,t,n)}function y(e,t,n){if("word"==e)return M="attribute",x;if("endTag"==e||"selfcloseTag"==e){var r=n.tagName,i=n.tagStart;return n.tagName=n.tagStart=null,"selfcloseTag"==e||S.autoSelfClosers.hasOwnProperty(r)?h(n,r):(h(n,r),n.context=new u(n,r,i==n.indented)),d}return M="error",y}function x(e,t,n){return"equals"==e?b:(S.allowMissing||(M="error"),y(e,t,n))}function b(e,t,n){return"string"==e?w:"word"==e&&S.allowUnquoted?(M="string",y):(M="error",y(e,t,n))}function w(e,t,n){return"string"==e?w:y(e,t,n)}var k=r.indentUnit,S={},C=i.htmlMode?t:n;for(var L in C)S[L]=C[L];for(var L in i)S[L]=i[L];var T,M;return o.isInText=!0,{startState:function(e){var t={tokenize:o,state:d,indented:e||0,tagName:null,tagStart:null,context:null};return null!=e&&(t.baseIndent=e),t},token:function(e,t){if(!t.tagName&&e.sol()&&(t.indented=e.indentation()),e.eatSpace())return null;T=null;var n=t.tokenize(e,t);return(n||T)&&"comment"!=n&&(M=null,t.state=t.state(T||n,e,t),M&&(n="error"==M?n+" error":M)),n},indent:function(t,n,r){var i=t.context;if(t.tokenize.isInAttribute)return t.tagStart==t.indented?t.stringStartCol+1:t.indented+k;if(i&&i.noIndent)return e.Pass;if(t.tokenize!=a&&t.tokenize!=o)return r?r.match(/^(\s*)/)[0].length:0;if(t.tagName)return S.multilineTagIndentPastTag!==!1?t.tagStart+t.tagName.length+2:t.tagStart+k*(S.multilineTagIndentFactor||1);if(S.alignCDATA&&/$/,blockCommentStart:"",configuration:S.htmlMode?"html":"xml",helperType:S.htmlMode?"html":"xml",skipAttribute:function(e){e.state==b&&(e.state=y)}}}),e.defineMIME("text/xml","xml"),e.defineMIME("application/xml","xml"),e.mimeModes.hasOwnProperty("text/html")||e.defineMIME("text/html",{name:"xml",htmlMode:!0})})},{"../../lib/codemirror":10}],15:[function(e,t,n){n.read=function(e,t,n,r,i){var o,a,l=8*i-r-1,s=(1<>1,u=-7,f=n?i-1:0,h=n?-1:1,d=e[t+f];for(f+=h,o=d&(1<<-u)-1,d>>=-u,u+=l;u>0;o=256*o+e[t+f],f+=h,u-=8);for(a=o&(1<<-u)-1,o>>=-u,u+=r;u>0;a=256*a+e[t+f],f+=h,u-=8);if(0===o)o=1-c;else{if(o===s)return a?NaN:(d?-1:1)*(1/0);a+=Math.pow(2,r),o-=c}return(d?-1:1)*a*Math.pow(2,o-r)},n.write=function(e,t,n,r,i,o){var a,l,s,c=8*o-i-1,u=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:o-1,p=r?1:-1,m=0>t||0===t&&0>1/t?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(l=isNaN(t)?1:0,a=u):(a=Math.floor(Math.log(t)/Math.LN2),t*(s=Math.pow(2,-a))<1&&(a--,s*=2),t+=a+f>=1?h/s:h*Math.pow(2,1-f),t*s>=2&&(a++,s/=2),a+f>=u?(l=0,a=u):a+f>=1?(l=(t*s-1)*Math.pow(2,i),a+=f):(l=t*Math.pow(2,f-1)*Math.pow(2,i),a=0));i>=8;e[n+d]=255&l,d+=p,l/=256,i-=8);for(a=a<0;e[n+d]=255&a,d+=p,a/=256,c-=8);e[n+d-p]|=128*m}},{}],16:[function(e,t,n){var r={}.toString;t.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},{}],17:[function(t,n,r){(function(t){(function(){function t(e){this.tokens=[],this.tokens.links={},this.options=e||h.defaults,this.rules=d.normal,this.options.gfm&&(this.options.tables?this.rules=d.tables:this.rules=d.gfm)}function i(e,t){if(this.options=t||h.defaults,this.links=e,this.rules=p.normal,this.renderer=this.options.renderer||new o,this.renderer.options=this.options,!this.links)throw new Error("Tokens array requires a `links` property.");this.options.gfm?this.options.breaks?this.rules=p.breaks:this.rules=p.gfm:this.options.pedantic&&(this.rules=p.pedantic)}function o(e){this.options=e||{}}function a(e){this.tokens=[],this.token=null,this.options=e||h.defaults,this.options.renderer=this.options.renderer||new o,this.renderer=this.options.renderer,this.renderer.options=this.options}function l(e,t){return e.replace(t?/&/g:/&(?!#?\w+;)/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function s(e){return e.replace(/&([#\w]+);/g,function(e,t){return t=t.toLowerCase(),"colon"===t?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""})}function c(e,t){return e=e.source,t=t||"",function n(r,i){return r?(i=i.source||i,i=i.replace(/(^|[^\[])\^/g,"$1"),e=e.replace(r,i),n):new RegExp(e,t)}}function u(){}function f(e){for(var t,n,r=1;rAn error occured:

    "+l(u.message+"",!0)+"
    ";throw u}}var d={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:u,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:u,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,blockquote:/^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,def:/^ *\[([^\]]+)\]: *]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:u,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/};d.bullet=/(?:[*+-]|\d+\.)/,d.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/,d.item=c(d.item,"gm")(/bull/g,d.bullet)(),d.list=c(d.list)(/bull/g,d.bullet)("hr","\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def","\\n+(?="+d.def.source+")")(),d.blockquote=c(d.blockquote)("def",d.def)(),d._tag="(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b",d.html=c(d.html)("comment",//)("closed",/<(tag)[\s\S]+?<\/\1>/)("closing",/])*?>/)(/tag/g,d._tag)(),d.paragraph=c(d.paragraph)("hr",d.hr)("heading",d.heading)("lheading",d.lheading)("blockquote",d.blockquote)("tag","<"+d._tag)("def",d.def)(),d.normal=f({},d),d.gfm=f({},d.normal,{fences:/^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\s*\1 *(?:\n+|$)/,paragraph:/^/,heading:/^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/}),d.gfm.paragraph=c(d.paragraph)("(?!","(?!"+d.gfm.fences.source.replace("\\1","\\2")+"|"+d.list.source.replace("\\1","\\3")+"|")(),d.tables=f({},d.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/}),t.rules=d,t.lex=function(e,n){var r=new t(n);return r.lex(e)},t.prototype.lex=function(e){return e=e.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n"),this.token(e,!0)},t.prototype.token=function(e,t,n){for(var r,i,o,a,l,s,c,u,f,e=e.replace(/^ +$/gm,"");e;)if((o=this.rules.newline.exec(e))&&(e=e.substring(o[0].length),o[0].length>1&&this.tokens.push({type:"space"})),o=this.rules.code.exec(e))e=e.substring(o[0].length),o=o[0].replace(/^ {4}/gm,""),this.tokens.push({type:"code",text:this.options.pedantic?o:o.replace(/\n+$/,"")});else if(o=this.rules.fences.exec(e))e=e.substring(o[0].length),this.tokens.push({type:"code",lang:o[2],text:o[3]||""});else if(o=this.rules.heading.exec(e))e=e.substring(o[0].length),this.tokens.push({type:"heading",depth:o[1].length,text:o[2]});else if(t&&(o=this.rules.nptable.exec(e))){for(e=e.substring(o[0].length),s={type:"table",header:o[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:o[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:o[3].replace(/\n$/,"").split("\n")},u=0;u ?/gm,""),this.token(o,t,!0),this.tokens.push({type:"blockquote_end"});else if(o=this.rules.list.exec(e)){for(e=e.substring(o[0].length),a=o[2],this.tokens.push({type:"list_start",ordered:a.length>1}),o=o[0].match(this.rules.item),r=!1,f=o.length,u=0;f>u;u++)s=o[u],c=s.length,s=s.replace(/^ *([*+-]|\d+\.) +/,""),~s.indexOf("\n ")&&(c-=s.length,s=this.options.pedantic?s.replace(/^ {1,4}/gm,""):s.replace(new RegExp("^ {1,"+c+"}","gm"),"")),this.options.smartLists&&u!==f-1&&(l=d.bullet.exec(o[u+1])[0],a===l||a.length>1&&l.length>1||(e=o.slice(u+1).join("\n")+e,u=f-1)),i=r||/\n\n(?!\s*$)/.test(s),u!==f-1&&(r="\n"===s.charAt(s.length-1),i||(i=r)),this.tokens.push({type:i?"loose_item_start":"list_item_start"}),this.token(s,!1,n),this.tokens.push({type:"list_item_end"});this.tokens.push({type:"list_end"})}else if(o=this.rules.html.exec(e))e=e.substring(o[0].length),this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:!this.options.sanitizer&&("pre"===o[1]||"script"===o[1]||"style"===o[1]),text:o[0]});else if(!n&&t&&(o=this.rules.def.exec(e)))e=e.substring(o[0].length),this.tokens.links[o[1].toLowerCase()]={href:o[2],title:o[3]};else if(t&&(o=this.rules.table.exec(e))){for(e=e.substring(o[0].length),s={type:"table", +header:o[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:o[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:o[3].replace(/(?: *\| *)?\n$/,"").split("\n")},u=0;u])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:u,tag:/^|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^\b_((?:[^_]|__)+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,code:/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:u,text:/^[\s\S]+?(?=[\\?(?:\s+['"]([\s\S]*?)['"])?\s*/,p.link=c(p.link)("inside",p._inside)("href",p._href)(),p.reflink=c(p.reflink)("inside",p._inside)(),p.normal=f({},p),p.pedantic=f({},p.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/}),p.gfm=f({},p.normal,{escape:c(p.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:c(p.text)("]|","~]|")("|","|https?://|")()}),p.breaks=f({},p.gfm,{br:c(p.br)("{2,}","*")(),text:c(p.gfm.text)("{2,}","*")()}),i.rules=p,i.output=function(e,t,n){var r=new i(t,n);return r.output(e)},i.prototype.output=function(e){for(var t,n,r,i,o="";e;)if(i=this.rules.escape.exec(e))e=e.substring(i[0].length),o+=i[1];else if(i=this.rules.autolink.exec(e))e=e.substring(i[0].length),"@"===i[2]?(n=":"===i[1].charAt(6)?this.mangle(i[1].substring(7)):this.mangle(i[1]),r=this.mangle("mailto:")+n):(n=l(i[1]),r=n),o+=this.renderer.link(r,null,n);else if(this.inLink||!(i=this.rules.url.exec(e))){if(i=this.rules.tag.exec(e))!this.inLink&&/^
    /i.test(i[0])&&(this.inLink=!1),e=e.substring(i[0].length),o+=this.options.sanitize?this.options.sanitizer?this.options.sanitizer(i[0]):l(i[0]):i[0];else if(i=this.rules.link.exec(e))e=e.substring(i[0].length),this.inLink=!0,o+=this.outputLink(i,{href:i[2],title:i[3]}),this.inLink=!1;else if((i=this.rules.reflink.exec(e))||(i=this.rules.nolink.exec(e))){if(e=e.substring(i[0].length),t=(i[2]||i[1]).replace(/\s+/g," "),t=this.links[t.toLowerCase()],!t||!t.href){o+=i[0].charAt(0),e=i[0].substring(1)+e;continue}this.inLink=!0,o+=this.outputLink(i,t),this.inLink=!1}else if(i=this.rules.strong.exec(e))e=e.substring(i[0].length),o+=this.renderer.strong(this.output(i[2]||i[1]));else if(i=this.rules.em.exec(e))e=e.substring(i[0].length),o+=this.renderer.em(this.output(i[2]||i[1]));else if(i=this.rules.code.exec(e))e=e.substring(i[0].length),o+=this.renderer.codespan(l(i[2],!0));else if(i=this.rules.br.exec(e))e=e.substring(i[0].length),o+=this.renderer.br();else if(i=this.rules.del.exec(e))e=e.substring(i[0].length),o+=this.renderer.del(this.output(i[1]));else if(i=this.rules.text.exec(e))e=e.substring(i[0].length),o+=this.renderer.text(l(this.smartypants(i[0])));else if(e)throw new Error("Infinite loop on byte: "+e.charCodeAt(0))}else e=e.substring(i[0].length),n=l(i[1]),r=n,o+=this.renderer.link(r,null,n);return o},i.prototype.outputLink=function(e,t){var n=l(t.href),r=t.title?l(t.title):null;return"!"!==e[0].charAt(0)?this.renderer.link(n,r,this.output(e[1])):this.renderer.image(n,r,l(e[1]))},i.prototype.smartypants=function(e){return this.options.smartypants?e.replace(/---/g,"—").replace(/--/g,"–").replace(/(^|[-\u2014\/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014\/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…"):e},i.prototype.mangle=function(e){if(!this.options.mangle)return e;for(var t,n="",r=e.length,i=0;r>i;i++)t=e.charCodeAt(i),Math.random()>.5&&(t="x"+t.toString(16)),n+="&#"+t+";";return n},o.prototype.code=function(e,t,n){if(this.options.highlight){var r=this.options.highlight(e,t);null!=r&&r!==e&&(n=!0,e=r)}return t?'
    '+(n?e:l(e,!0))+"\n
    \n":"
    "+(n?e:l(e,!0))+"\n
    "},o.prototype.blockquote=function(e){return"
    \n"+e+"
    \n"},o.prototype.html=function(e){return e},o.prototype.heading=function(e,t,n){return"'+e+"\n"},o.prototype.hr=function(){return this.options.xhtml?"
    \n":"
    \n"},o.prototype.list=function(e,t){var n=t?"ol":"ul";return"<"+n+">\n"+e+"\n"},o.prototype.listitem=function(e){return"
  • "+e+"
  • \n"},o.prototype.paragraph=function(e){return"

    "+e+"

    \n"},o.prototype.table=function(e,t){return"\n\n"+e+"\n\n"+t+"\n
    \n"},o.prototype.tablerow=function(e){return"\n"+e+"\n"},o.prototype.tablecell=function(e,t){var n=t.header?"th":"td",r=t.align?"<"+n+' style="text-align:'+t.align+'">':"<"+n+">";return r+e+"\n"},o.prototype.strong=function(e){return""+e+""},o.prototype.em=function(e){return""+e+""},o.prototype.codespan=function(e){return""+e+""},o.prototype.br=function(){return this.options.xhtml?"
    ":"
    "},o.prototype.del=function(e){return""+e+""},o.prototype.link=function(e,t,n){if(this.options.sanitize){try{var r=decodeURIComponent(s(e)).replace(/[^\w:]/g,"").toLowerCase()}catch(i){return""}if(0===r.indexOf("javascript:")||0===r.indexOf("vbscript:"))return""}var o='
    "},o.prototype.image=function(e,t,n){var r=''+n+'":">"},o.prototype.text=function(e){return e},a.parse=function(e,t,n){var r=new a(t,n);return r.parse(e)},a.prototype.parse=function(e){this.inline=new i(e.links,this.options,this.renderer),this.tokens=e.reverse();for(var t="";this.next();)t+=this.tok();return t},a.prototype.next=function(){return this.token=this.tokens.pop()},a.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0},a.prototype.parseText=function(){for(var e=this.token.text;"text"===this.peek().type;)e+="\n"+this.next().text;return this.inline.output(e)},a.prototype.tok=function(){switch(this.token.type){case"space":return"";case"hr":return this.renderer.hr();case"heading":return this.renderer.heading(this.inline.output(this.token.text),this.token.depth,this.token.text);case"code":return this.renderer.code(this.token.text,this.token.lang,this.token.escaped);case"table":var e,t,n,r,i,o="",a="";for(n="",e=0;ea;a++)for(var s=this.compoundRules[a],c=0,u=s.length;u>c;c++)this.compoundRuleCodes[s[c]]=[];"ONLYINCOMPOUND"in this.flags&&(this.compoundRuleCodes[this.flags.ONLYINCOMPOUND]=[]),this.dictionaryTable=this._parseDIC(n);for(var a in this.compoundRuleCodes)0==this.compoundRuleCodes[a].length&&delete this.compoundRuleCodes[a];for(var a=0,l=this.compoundRules.length;l>a;a++){for(var f=this.compoundRules[a],h="",c=0,u=f.length;u>c;c++){var d=f[c];h+=d in this.compoundRuleCodes?"("+this.compoundRuleCodes[d].join("|")+")":d}this.compoundRules[a]=new RegExp(h,"i")}}return this};i.prototype={load:function(e){for(var t in e)this[t]=e[t];return this},_readFile:function(t,r){if(r||(r="utf8"),"undefined"!=typeof XMLHttpRequest){var i=new XMLHttpRequest;return i.open("GET",t,!1),i.overrideMimeType&&i.overrideMimeType("text/plain; charset="+r),i.send(null),i.responseText}if("undefined"!=typeof e){var o=e("fs");try{if(o.existsSync(t)){var a=o.statSync(t),l=o.openSync(t,"r"),s=new n(a.size);return o.readSync(l,s,0,s.length,null),s.toString(r,0,s.length)}console.log("Path "+t+" does not exist.")}catch(c){return console.log(c),""}}},_parseAFF:function(e){var t={};e=this._removeAffixComments(e);for(var n=e.split("\n"),r=0,i=n.length;i>r;r++){var o=n[r],a=o.split(/\s+/),l=a[0];if("PFX"==l||"SFX"==l){for(var s=a[1],c=a[2],u=parseInt(a[3],10),f=[],h=r+1,d=r+1+u;d>h;h++){var o=n[h],p=o.split(/\s+/),m=p[2],g=p[3].split("/"),v=g[0];"0"===v&&(v="");var y=this.parseRuleCodes(g[1]),x=p[4],b={};b.add=v,y.length>0&&(b.continuationClasses=y),"."!==x&&("SFX"===l?b.match=new RegExp(x+"$"):b.match=new RegExp("^"+x)),"0"!=m&&("SFX"===l?b.remove=new RegExp(m+"$"):b.remove=m),f.push(b)}t[s]={type:l,combineable:"Y"==c,entries:f},r+=u}else if("COMPOUNDRULE"===l){for(var u=parseInt(a[1],10),h=r+1,d=r+1+u;d>h;h++){var o=n[h],p=o.split(/\s+/);this.compoundRules.push(p[1])}r+=u}else if("REP"===l){var p=o.split(/\s+/);3===p.length&&this.replacementTable.push([p[1],p[2]])}else this.flags[l]=a[1]}return t},_removeAffixComments:function(e){return e=e.replace(/#.*$/gm,""),e=e.replace(/^\s\s*/m,"").replace(/\s\s*$/m,""),e=e.replace(/\n{2,}/g,"\n"),e=e.replace(/^\s\s*/,"").replace(/\s\s*$/,"")},_parseDIC:function(e){function t(e,t){e in r&&"object"==typeof r[e]||(r[e]=[]),r[e].push(t)}e=this._removeDicComments(e);for(var n=e.split("\n"),r={},i=1,o=n.length;o>i;i++){var a=n[i],l=a.split("/",2),s=l[0];if(l.length>1){var c=this.parseRuleCodes(l[1]);"NEEDAFFIX"in this.flags&&-1!=c.indexOf(this.flags.NEEDAFFIX)||t(s,c);for(var u=0,f=c.length;f>u;u++){var h=c[u],d=this.rules[h];if(d)for(var p=this._applyRule(s,d),m=0,g=p.length;g>m;m++){var v=p[m];if(t(v,[]),d.combineable)for(var y=u+1;f>y;y++){var x=c[y],b=this.rules[x];if(b&&b.combineable&&d.type!=b.type)for(var w=this._applyRule(v,b),k=0,S=w.length;S>k;k++){var C=w[k];t(C,[])}}}h in this.compoundRuleCodes&&this.compoundRuleCodes[h].push(s)}}else t(s.trim(),[])}return r},_removeDicComments:function(e){return e=e.replace(/^\t.*$/gm,"")},parseRuleCodes:function(e){if(!e)return[];if(!("FLAG"in this.flags))return e.split("");if("long"===this.flags.FLAG){for(var t=[],n=0,r=e.length;r>n;n+=2)t.push(e.substr(n,2));return t}return"num"===this.flags.FLAG?textCode.split(","):void 0},_applyRule:function(e,t){for(var n=t.entries,r=[],i=0,o=n.length;o>i;i++){var a=n[i];if(!a.match||e.match(a.match)){var l=e;if(a.remove&&(l=l.replace(a.remove,"")),"SFX"===t.type?l+=a.add:l=a.add+l,r.push(l),"continuationClasses"in a)for(var s=0,c=a.continuationClasses.length;c>s;s++){var u=this.rules[a.continuationClasses[s]];u&&(r=r.concat(this._applyRule(l,u)))}}}return r},check:function(e){var t=e.replace(/^\s\s*/,"").replace(/\s\s*$/,"");if(this.checkExact(t))return!0;if(t.toUpperCase()===t){var n=t[0]+t.substring(1).toLowerCase();if(this.hasFlag(n,"KEEPCASE"))return!1;if(this.checkExact(n))return!0}var r=t.toLowerCase();if(r!==t){if(this.hasFlag(r,"KEEPCASE"))return!1;if(this.checkExact(r))return!0}return!1},checkExact:function(e){var t=this.dictionaryTable[e];if("undefined"==typeof t){if("COMPOUNDMIN"in this.flags&&e.length>=this.flags.COMPOUNDMIN)for(var n=0,r=this.compoundRules.length;r>n;n++)if(e.match(this.compoundRules[n]))return!0;return!1}if("object"==typeof t){for(var n=0,r=t.length;r>n;n++)if(!this.hasFlag(e,"ONLYINCOMPOUND",t[n]))return!0;return!1}},hasFlag:function(e,t,n){if(t in this.flags){if("undefined"==typeof n)var n=Array.prototype.concat.apply([],this.dictionaryTable[e]);if(n&&-1!==n.indexOf(this.flags[t]))return!0}return!1},alphabet:"",suggest:function(e,t){function n(e){for(var t=[],n=0,r=e.length;r>n;n++){for(var i=e[n],o=[],a=0,l=i.length+1;l>a;a++)o.push([i.substring(0,a),i.substring(a,i.length)]);for(var s=[],a=0,l=o.length;l>a;a++){var u=o[a];u[1]&&s.push(u[0]+u[1].substring(1))}for(var f=[],a=0,l=o.length;l>a;a++){var u=o[a];u[1].length>1&&f.push(u[0]+u[1][1]+u[1][0]+u[1].substring(2))}for(var h=[],a=0,l=o.length;l>a;a++){var u=o[a];if(u[1])for(var d=0,p=c.alphabet.length;p>d;d++)h.push(u[0]+c.alphabet[d]+u[1].substring(1))}for(var m=[],a=0,l=o.length;l>a;a++){var u=o[a];if(u[1])for(var d=0,p=c.alphabet.length;p>d;d++)h.push(u[0]+c.alphabet[d]+u[1])}t=t.concat(s),t=t.concat(f),t=t.concat(h),t=t.concat(m)}return t}function r(e){for(var t=[],n=0;nu;u++)l[u]in s?s[l[u]]+=1:s[l[u]]=1;var h=[];for(var u in s)h.push([u,s[u]]);h.sort(i).reverse();for(var d=[],u=0,f=Math.min(t,h.length);f>u;u++)c.hasFlag(h[u][0],"NOSUGGEST")||d.push(h[u][0]);return d}if(t||(t=5),this.check(e))return[];for(var o=0,a=this.replacementTable.length;a>o;o++){var l=this.replacementTable[o];if(-1!==e.indexOf(l[0])){var s=e.replace(l[0],l[1]);if(this.check(s))return[s]}}var c=this;return c.alphabet="abcdefghijklmnopqrstuvwxyz",i(e)}},"undefined"!=typeof t&&(t.exports=i)}).call(this,e("buffer").Buffer,"/node_modules/typo-js")},{buffer:3,fs:2}],19:[function(e,t,n){var r=e("codemirror");r.commands.tabAndIndentMarkdownList=function(e){var t=e.listSelections(),n=t[0].head,r=e.getStateAfter(n.line),i=r.list!==!1;if(i)return void e.execCommand("indentMore");if(e.options.indentWithTabs)e.execCommand("insertTab");else{var o=Array(e.options.tabSize+1).join(" ");e.replaceSelection(o)}},r.commands.shiftTabAndUnindentMarkdownList=function(e){var t=e.listSelections(),n=t[0].head,r=e.getStateAfter(n.line),i=r.list!==!1;if(i)return void e.execCommand("indentLess");if(e.options.indentWithTabs)e.execCommand("insertTab");else{var o=Array(e.options.tabSize+1).join(" ");e.replaceSelection(o)}}},{codemirror:10}],20:[function(e,t,n){"use strict";function r(e){return e=U?e.replace("Ctrl","Cmd"):e.replace("Cmd","Ctrl")}function i(e,t,n){e=e||{};var r=document.createElement("a");return t=void 0==t?!0:t,e.title&&t&&(r.title=a(e.title,e.action,n),U&&(r.title=r.title.replace("Ctrl","⌘"),r.title=r.title.replace("Alt","⌥"))),r.tabIndex=-1,r.className=e.className,r}function o(){var e=document.createElement("i");return e.className="separator",e.innerHTML="|",e}function a(e,t,n){var i,o=e;return t&&(i=Y(t),n[i]&&(o+=" ("+r(n[i])+")")),o}function l(e,t){t=t||e.getCursor("start");var n=e.getTokenAt(t);if(!n.type)return{};for(var r,i,o=n.type.split(" "),a={},l=0;l=0&&(d=c.getLineHandle(o),!t(d));o--);var v,y,x,b,w=c.getTokenAt({line:o,ch:1}),k=n(w).fencedChars;t(c.getLineHandle(u.line))?(v="",y=u.line):t(c.getLineHandle(u.line-1))?(v="",y=u.line-1):(v=k+"\n",y=u.line),t(c.getLineHandle(f.line))?(x="",b=f.line,0===f.ch&&(b+=1)):0!==f.ch&&t(c.getLineHandle(f.line+1))?(x="",b=f.line+1):(x=k+"\n",b=f.line+1),0===f.ch&&(b-=1),c.operation(function(){c.replaceRange(x,{line:b,ch:0},{line:b+(x?0:1),ch:0}),c.replaceRange(v,{line:y,ch:0},{line:y+(v?0:1),ch:0})}),c.setSelection({line:y+(v?1:0),ch:0},{line:b+(v?1:-1),ch:0}),c.focus()}else{var S=u.line;if(t(c.getLineHandle(u.line))&&("fenced"===r(c,u.line+1)?(o=u.line,S=u.line+1):(a=u.line,S=u.line-1)),void 0===o)for(o=S;o>=0&&(d=c.getLineHandle(o),!t(d));o--);if(void 0===a)for(l=c.lineCount(),a=S;l>a&&(d=c.getLineHandle(a),!t(d));a++);c.operation(function(){c.replaceRange("",{line:o,ch:0},{line:o+1,ch:0}),c.replaceRange("",{line:a-1,ch:0},{line:a,ch:0})}),c.focus()}else if("indented"===p){if(u.line!==f.line||u.ch!==f.ch)o=u.line,a=f.line,0===f.ch&&a--;else{for(o=u.line;o>=0;o--)if(d=c.getLineHandle(o),!d.text.match(/^\s*$/)&&"indented"!==r(c,o,d)){o+=1;break}for(l=c.lineCount(),a=u.line;l>a;a++)if(d=c.getLineHandle(a),!d.text.match(/^\s*$/)&&"indented"!==r(c,a,d)){a-=1;break}}var C=c.getLineHandle(a+1),L=C&&c.getTokenAt({line:a+1,ch:C.text.length-1}),T=L&&n(L).indentedCode;T&&c.replaceRange("\n",{line:a+1,ch:0});for(var M=o;a>=M;M++)c.indentLine(M,"subtract");c.focus()}else{var N=u.line===f.line&&u.ch===f.ch&&0===u.ch,A=u.line!==f.line;N||A?i(c,u,f,s):E(c,!1,["`","`"])}}function d(e){var t=e.codemirror;I(t,"quote")}function p(e){var t=e.codemirror;O(t,"smaller")}function m(e){var t=e.codemirror;O(t,"bigger")}function g(e){var t=e.codemirror;O(t,void 0,1)}function v(e){var t=e.codemirror;O(t,void 0,2)}function y(e){var t=e.codemirror;O(t,void 0,3)}function x(e){var t=e.codemirror;I(t,"unordered-list")}function b(e){var t=e.codemirror;I(t,"ordered-list")}function w(e){var t=e.codemirror;R(t)}function k(e){var t=e.codemirror,n=l(t),r=e.options,i="http://";return r.promptURLs&&(i=prompt(r.promptTexts.link),!i)?!1:void E(t,n.link,r.insertTexts.link,i)}function S(e){var t=e.codemirror,n=l(t),r=e.options,i="http://";return r.promptURLs&&(i=prompt(r.promptTexts.image),!i)?!1:void E(t,n.image,r.insertTexts.image,i)}function C(e){var t=e.codemirror,n=l(t),r=e.options;E(t,n.table,r.insertTexts.table)}function L(e){var t=e.codemirror,n=l(t),r=e.options;E(t,n.image,r.insertTexts.horizontalRule)}function T(e){var t=e.codemirror;t.undo(),t.focus()}function M(e){var t=e.codemirror;t.redo(),t.focus()}function N(e){var t=e.codemirror,n=t.getWrapperElement(),r=n.nextSibling,i=e.toolbarElements["side-by-side"],o=!1;/editor-preview-active-side/.test(r.className)?(r.className=r.className.replace(/\s*editor-preview-active-side\s*/g,""),i.className=i.className.replace(/\s*active\s*/g,""),n.className=n.className.replace(/\s*CodeMirror-sided\s*/g," ")):(setTimeout(function(){t.getOption("fullScreen")||s(e),r.className+=" editor-preview-active-side"},1),i.className+=" active",n.className+=" CodeMirror-sided",o=!0);var a=n.lastChild;if(/editor-preview-active/.test(a.className)){a.className=a.className.replace(/\s*editor-preview-active\s*/g,"");var l=e.toolbarElements.preview,c=n.previousSibling;l.className=l.className.replace(/\s*active\s*/g,""),c.className=c.className.replace(/\s*disabled-for-preview*/g,"")}var u=function(){r.innerHTML=e.options.previewRender(e.value(),r)};t.sideBySideRenderingFunction||(t.sideBySideRenderingFunction=u),o?(r.innerHTML=e.options.previewRender(e.value(),r),t.on("update",t.sideBySideRenderingFunction)):t.off("update",t.sideBySideRenderingFunction),t.refresh()}function A(e){var t=e.codemirror,n=t.getWrapperElement(),r=n.previousSibling,i=e.options.toolbar?e.toolbarElements.preview:!1,o=n.lastChild;o&&/editor-preview/.test(o.className)||(o=document.createElement("div"),o.className="editor-preview",n.appendChild(o)),/editor-preview-active/.test(o.className)?(o.className=o.className.replace(/\s*editor-preview-active\s*/g,""),i&&(i.className=i.className.replace(/\s*active\s*/g,""),r.className=r.className.replace(/\s*disabled-for-preview*/g,""))):(setTimeout(function(){o.className+=" editor-preview-active"},1),i&&(i.className+=" active",r.className+=" disabled-for-preview")),o.innerHTML=e.options.previewRender(e.value(),o);var a=t.getWrapperElement().nextSibling;/editor-preview-active-side/.test(a.className)&&N(e)}function E(e,t,n,r){if(!/editor-preview-active/.test(e.getWrapperElement().lastChild.className)){var i,o=n[0],a=n[1],l=e.getCursor("start"),s=e.getCursor("end");r&&(a=a.replace("#url#",r)),t?(i=e.getLine(l.line),o=i.slice(0,l.ch),a=i.slice(l.ch),e.replaceRange(o+a,{line:l.line,ch:0})):(i=e.getSelection(),e.replaceSelection(o+i+a),l.ch+=o.length,l!==s&&(s.ch+=o.length)),e.setSelection(l,s),e.focus()}}function O(e,t,n){if(!/editor-preview-active/.test(e.getWrapperElement().lastChild.className)){for(var r=e.getCursor("start"),i=e.getCursor("end"),o=r.line;o<=i.line;o++)!function(r){var i=e.getLine(r),o=i.search(/[^#]/);i=void 0!==t?0>=o?"bigger"==t?"###### "+i:"# "+i:6==o&&"smaller"==t?i.substr(7):1==o&&"bigger"==t?i.substr(2):"bigger"==t?i.substr(1):"#"+i:1==n?0>=o?"# "+i:o==n?i.substr(o+1):"# "+i.substr(o+1):2==n?0>=o?"## "+i:o==n?i.substr(o+1):"## "+i.substr(o+1):0>=o?"### "+i:o==n?i.substr(o+1):"### "+i.substr(o+1),e.replaceRange(i,{line:r,ch:0},{line:r,ch:99999999999999})}(o);e.focus()}}function I(e,t){if(!/editor-preview-active/.test(e.getWrapperElement().lastChild.className)){for(var n=l(e),r=e.getCursor("start"),i=e.getCursor("end"),o={quote:/^(\s*)\>\s+/,"unordered-list":/^(\s*)(\*|\-|\+)\s+/,"ordered-list":/^(\s*)\d+\.\s+/},a={quote:"> ","unordered-list":"* ","ordered-list":"1. "},s=r.line;s<=i.line;s++)!function(r){var i=e.getLine(r);i=n[t]?i.replace(o[t],"$1"):a[t]+i,e.replaceRange(i,{line:r,ch:0},{line:r,ch:99999999999999})}(s);e.focus()}}function P(e,t,n,r){if(!/editor-preview-active/.test(e.codemirror.getWrapperElement().lastChild.className)){r="undefined"==typeof r?n:r;var i,o=e.codemirror,a=l(o),s=n,c=r,u=o.getCursor("start"),f=o.getCursor("end");a[t]?(i=o.getLine(u.line),s=i.slice(0,u.ch),c=i.slice(u.ch),"bold"==t?(s=s.replace(/(\*\*|__)(?![\s\S]*(\*\*|__))/,""),c=c.replace(/(\*\*|__)/,"")):"italic"==t?(s=s.replace(/(\*|_)(?![\s\S]*(\*|_))/,""),c=c.replace(/(\*|_)/,"")):"strikethrough"==t&&(s=s.replace(/(\*\*|~~)(?![\s\S]*(\*\*|~~))/,""),c=c.replace(/(\*\*|~~)/,"")),o.replaceRange(s+c,{line:u.line,ch:0},{line:u.line,ch:99999999999999}),"bold"==t||"strikethrough"==t?(u.ch-=2,u!==f&&(f.ch-=2)):"italic"==t&&(u.ch-=1,u!==f&&(f.ch-=1))):(i=o.getSelection(),"bold"==t?(i=i.split("**").join(""),i=i.split("__").join("")):"italic"==t?(i=i.split("*").join(""),i=i.split("_").join("")):"strikethrough"==t&&(i=i.split("~~").join("")),o.replaceSelection(s+i+c),u.ch+=n.length,f.ch=u.ch+i.length),o.setSelection(u,f),o.focus()}}function R(e){if(!/editor-preview-active/.test(e.getWrapperElement().lastChild.className))for(var t,n=e.getCursor("start"),r=e.getCursor("end"),i=n.line;i<=r.line;i++)t=e.getLine(i),t=t.replace(/^[ ]*([# ]+|\*|\-|[> ]+|[0-9]+(.|\)))[ ]*/,""),e.replaceRange(t,{line:i,ch:0},{line:i,ch:99999999999999})}function D(e,t){for(var n in t)t.hasOwnProperty(n)&&(t[n]instanceof Array?e[n]=t[n].concat(e[n]instanceof Array?e[n]:[]):null!==t[n]&&"object"==typeof t[n]&&t[n].constructor===Object?e[n]=D(e[n]||{},t[n]):e[n]=t[n]);return e}function H(e){for(var t=1;t=19968?n[i].length:1;return r}function B(e){e=e||{},e.parent=this;var t=!0;if(e.autoDownloadFontAwesome===!1&&(t=!1),e.autoDownloadFontAwesome!==!0)for(var n=document.styleSheets,r=0;r-1&&(t=!1);if(t){var i=document.createElement("link");i.rel="stylesheet",i.href="https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css",document.getElementsByTagName("head")[0].appendChild(i)}if(e.element)this.element=e.element;else if(null===e.element)return void console.log("SimpleMDE: Error. No element was found.");if(void 0===e.toolbar){e.toolbar=[];for(var o in K)K.hasOwnProperty(o)&&(-1!=o.indexOf("separator-")&&e.toolbar.push("|"),(K[o]["default"]===!0||e.showIcons&&e.showIcons.constructor===Array&&-1!=e.showIcons.indexOf(o))&&e.toolbar.push(o))}e.hasOwnProperty("status")||(e.status=["autosave","lines","words","cursor"]),e.previewRender||(e.previewRender=function(e){return this.parent.markdown(e)}),e.parsingConfig=H({highlightFormatting:!0},e.parsingConfig||{}),e.insertTexts=H({},X,e.insertTexts||{}),e.promptTexts=Z,e.blockStyles=H({},J,e.blockStyles||{}),e.shortcuts=H({},G,e.shortcuts||{}),void 0!=e.autosave&&void 0!=e.autosave.unique_id&&""!=e.autosave.unique_id&&(e.autosave.uniqueId=e.autosave.unique_id),this.options=e,this.render(),!e.initialValue||this.options.autosave&&this.options.autosave.foundSavedValue===!0||this.value(e.initialValue)}function _(){if("object"!=typeof localStorage)return!1;try{localStorage.setItem("smde_localStorage",1),localStorage.removeItem("smde_localStorage")}catch(e){return!1}return!0}var F=e("codemirror");e("codemirror/addon/edit/continuelist.js"),e("./codemirror/tablist"),e("codemirror/addon/display/fullscreen.js"),e("codemirror/mode/markdown/markdown.js"),e("codemirror/addon/mode/overlay.js"),e("codemirror/addon/display/placeholder.js"),e("codemirror/addon/selection/mark-selection.js"),e("codemirror/mode/gfm/gfm.js"),e("codemirror/mode/xml/xml.js");var z=e("codemirror-spell-checker"),j=e("marked"),U=/Mac/.test(navigator.platform),q={toggleBold:c,toggleItalic:u,drawLink:k,toggleHeadingSmaller:p,toggleHeadingBigger:m,drawImage:S,toggleBlockquote:d,toggleOrderedList:b,toggleUnorderedList:x,toggleCodeBlock:h,togglePreview:A,toggleStrikethrough:f,toggleHeading1:g,toggleHeading2:v,toggleHeading3:y,cleanBlock:w,drawTable:C,drawHorizontalRule:L,undo:T,redo:M,toggleSideBySide:N,toggleFullScreen:s},G={toggleBold:"Cmd-B",toggleItalic:"Cmd-I",drawLink:"Cmd-K",toggleHeadingSmaller:"Cmd-H",toggleHeadingBigger:"Shift-Cmd-H",cleanBlock:"Cmd-E",drawImage:"Cmd-Alt-I",toggleBlockquote:"Cmd-'",toggleOrderedList:"Cmd-Alt-L",toggleUnorderedList:"Cmd-L",toggleCodeBlock:"Cmd-Alt-C",togglePreview:"Cmd-P",toggleSideBySide:"F9",toggleFullScreen:"F11"},Y=function(e){for(var t in q)if(q[t]===e)return t;return null},$=function(){var e=!1;return function(t){(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(t)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0,4)))&&(e=!0); +}(navigator.userAgent||navigator.vendor||window.opera),e},V="",K={bold:{name:"bold",action:c,className:"fa fa-bold",title:"Bold","default":!0},italic:{name:"italic",action:u,className:"fa fa-italic",title:"Italic","default":!0},strikethrough:{name:"strikethrough",action:f,className:"fa fa-strikethrough",title:"Strikethrough"},heading:{name:"heading",action:p,className:"fa fa-header",title:"Heading","default":!0},"heading-smaller":{name:"heading-smaller",action:p,className:"fa fa-header fa-header-x fa-header-smaller",title:"Smaller Heading"},"heading-bigger":{name:"heading-bigger",action:m,className:"fa fa-header fa-header-x fa-header-bigger",title:"Bigger Heading"},"heading-1":{name:"heading-1",action:g,className:"fa fa-header fa-header-x fa-header-1",title:"Big Heading"},"heading-2":{name:"heading-2",action:v,className:"fa fa-header fa-header-x fa-header-2",title:"Medium Heading"},"heading-3":{name:"heading-3",action:y,className:"fa fa-header fa-header-x fa-header-3",title:"Small Heading"},"separator-1":{name:"separator-1"},code:{name:"code",action:h,className:"fa fa-code",title:"Code"},quote:{name:"quote",action:d,className:"fa fa-quote-left",title:"Quote","default":!0},"unordered-list":{name:"unordered-list",action:x,className:"fa fa-list-ul",title:"Generic List","default":!0},"ordered-list":{name:"ordered-list",action:b,className:"fa fa-list-ol",title:"Numbered List","default":!0},"clean-block":{name:"clean-block",action:w,className:"fa fa-eraser fa-clean-block",title:"Clean block"},"separator-2":{name:"separator-2"},link:{name:"link",action:k,className:"fa fa-link",title:"Create Link","default":!0},image:{name:"image",action:S,className:"fa fa-picture-o",title:"Insert Image","default":!0},table:{name:"table",action:C,className:"fa fa-table",title:"Insert Table"},"horizontal-rule":{name:"horizontal-rule",action:L,className:"fa fa-minus",title:"Insert Horizontal Line"},"separator-3":{name:"separator-3"},preview:{name:"preview",action:A,className:"fa fa-eye no-disable",title:"Toggle Preview","default":!0},"side-by-side":{name:"side-by-side",action:N,className:"fa fa-columns no-disable no-mobile",title:"Toggle Side by Side","default":!0},fullscreen:{name:"fullscreen",action:s,className:"fa fa-arrows-alt no-disable no-mobile",title:"Toggle Fullscreen","default":!0},"separator-4":{name:"separator-4"},guide:{name:"guide",action:"https://simplemde.com/markdown-guide",className:"fa fa-question-circle",title:"Markdown Guide","default":!0},"separator-5":{name:"separator-5"},undo:{name:"undo",action:T,className:"fa fa-undo no-disable",title:"Undo"},redo:{name:"redo",action:M,className:"fa fa-repeat no-disable",title:"Redo"}},X={link:["[","](#url#)"],image:["![](","#url#)"],table:["","\n\n| Column 1 | Column 2 | Column 3 |\n| -------- | -------- | -------- |\n| Text | Text | Text |\n\n"],horizontalRule:["","\n\n-----\n\n"]},Z={link:"URL for the link:",image:"URL of the image:"},J={bold:"**",code:"```",italic:"*"};B.prototype.markdown=function(e){if(j){var t={};return this.options&&this.options.renderingConfig&&this.options.renderingConfig.singleLineBreaks===!1?t.breaks=!1:t.breaks=!0,this.options&&this.options.renderingConfig&&this.options.renderingConfig.codeSyntaxHighlighting===!0&&window.hljs&&(t.highlight=function(e){return window.hljs.highlightAuto(e).value}),j.setOptions(t),j(e)}},B.prototype.render=function(e){if(e||(e=this.element||document.getElementsByTagName("textarea")[0]),!this._rendered||this._rendered!==e){this.element=e;var t=this.options,n=this,i={};for(var o in t.shortcuts)null!==t.shortcuts[o]&&null!==q[o]&&!function(e){i[r(t.shortcuts[e])]=function(){q[e](n)}}(o);i.Enter="newlineAndIndentContinueMarkdownList",i.Tab="tabAndIndentMarkdownList",i["Shift-Tab"]="shiftTabAndUnindentMarkdownList",i.Esc=function(e){e.getOption("fullScreen")&&s(n)},document.addEventListener("keydown",function(e){e=e||window.event,27==e.keyCode&&n.codemirror.getOption("fullScreen")&&s(n)},!1);var a,l;if(t.spellChecker!==!1?(a="spell-checker",l=t.parsingConfig,l.name="gfm",l.gitHubSpice=!1,z({codeMirrorInstance:F})):(a=t.parsingConfig,a.name="gfm",a.gitHubSpice=!1),this.codemirror=F.fromTextArea(e,{mode:a,backdrop:l,theme:"paper",tabSize:void 0!=t.tabSize?t.tabSize:2,indentUnit:void 0!=t.tabSize?t.tabSize:2,indentWithTabs:t.indentWithTabs!==!1,lineNumbers:!1,autofocus:t.autofocus===!0,extraKeys:i,lineWrapping:t.lineWrapping!==!1,allowDropFileTypes:["text/plain"],placeholder:t.placeholder||e.getAttribute("placeholder")||"",styleSelectedText:void 0!=t.styleSelectedText?t.styleSelectedText:!0}),t.forceSync===!0){var c=this.codemirror;c.on("change",function(){c.save()})}this.gui={},t.toolbar!==!1&&(this.gui.toolbar=this.createToolbar()),t.status!==!1&&(this.gui.statusbar=this.createStatusbar()),void 0!=t.autosave&&t.autosave.enabled===!0&&this.autosave(),this.gui.sideBySide=this.createSideBySide(),this._rendered=this.element;var u=this.codemirror;setTimeout(function(){u.refresh()}.bind(u),0)}},B.prototype.autosave=function(){if(_()){var e=this;if(void 0==this.options.autosave.uniqueId||""==this.options.autosave.uniqueId)return void console.log("SimpleMDE: You must set a uniqueId to use the autosave feature");null!=e.element.form&&void 0!=e.element.form&&e.element.form.addEventListener("submit",function(){localStorage.removeItem("smde_"+e.options.autosave.uniqueId)}),this.options.autosave.loaded!==!0&&("string"==typeof localStorage.getItem("smde_"+this.options.autosave.uniqueId)&&""!=localStorage.getItem("smde_"+this.options.autosave.uniqueId)&&(this.codemirror.setValue(localStorage.getItem("smde_"+this.options.autosave.uniqueId)),this.options.autosave.foundSavedValue=!0),this.options.autosave.loaded=!0),localStorage.setItem("smde_"+this.options.autosave.uniqueId,e.value());var t=document.getElementById("autosaved");if(null!=t&&void 0!=t&&""!=t){var n=new Date,r=n.getHours(),i=n.getMinutes(),o="am",a=r;a>=12&&(a=r-12,o="pm"),0==a&&(a=12),i=10>i?"0"+i:i,t.innerHTML="Autosaved: "+a+":"+i+" "+o}this.autosaveTimeoutId=setTimeout(function(){e.autosave()},this.options.autosave.delay||1e4)}else console.log("SimpleMDE: localStorage not available, cannot autosave")},B.prototype.clearAutosavedValue=function(){if(_()){if(void 0==this.options.autosave||void 0==this.options.autosave.uniqueId||""==this.options.autosave.uniqueId)return void console.log("SimpleMDE: You must set a uniqueId to clear the autosave value");localStorage.removeItem("smde_"+this.options.autosave.uniqueId)}else console.log("SimpleMDE: localStorage not available, cannot autosave")},B.prototype.createSideBySide=function(){var e=this.codemirror,t=e.getWrapperElement(),n=t.nextSibling;n&&/editor-preview-side/.test(n.className)||(n=document.createElement("div"),n.className="editor-preview-side",t.parentNode.insertBefore(n,t.nextSibling));var r=!1,i=!1;return e.on("scroll",function(e){if(r)return void(r=!1);i=!0;var t=e.getScrollInfo().height-e.getScrollInfo().clientHeight,o=parseFloat(e.getScrollInfo().top)/t,a=(n.scrollHeight-n.clientHeight)*o;n.scrollTop=a}),n.onscroll=function(){if(i)return void(i=!1);r=!0;var t=n.scrollHeight-n.clientHeight,o=parseFloat(n.scrollTop)/t,a=(e.getScrollInfo().height-e.getScrollInfo().clientHeight)*o;e.scrollTo(0,a)},n},B.prototype.createToolbar=function(e){if(e=e||this.options.toolbar,e&&0!==e.length){var t;for(t=0;t - - + + + + +``` + +Remember that `jQuery` is also required. The component cointains the [EasyMDE](https://easy-markdown-editor.tk/) script version 2.15.0. Obviously, you can add this script in your project but if you use the script in the component, you are sure it works fine and all functionalities are tested. + +### Add MarkdownEditor in a page + +In a `Razor` page, we can add the component with these lines + +``` +
    + + +
    + +

    Result

    + @((MarkupString)markdownHtml) +
    + +@code { + string markdownValue = "#Markdown Editor\nThis is a test"; + string markdownHtml; + + protected override void OnInitialized() + { + markdownHtml = Markdig.Markdown.ToHtml(markdownValue ?? string.Empty); + base.OnInitialized(); + } + + Task OnMarkdownValueChanged(string value) + { + return Task.CompletedTask; + } + + Task OnMarkdownValueHTMLChanged(string value) + { + markdownHtml = value; + return Task.CompletedTask; + } +} ``` -The editor binds the markdown text, not parsed HTML. +The result is a nice Markdown Editor like in the following screenshot. This is a screenshot from the demo in this repository. + +![markdown-editor-example](https://user-images.githubusercontent.com/9497415/148641050-653f6101-7099-4d76-9a59-45a44e32a275.gif) + +## Documentation +The Markdown Editor for Blazor has a estensive collection of properties to map all the functionalities in the JavaScript version. In this repository, there are 2 projects: +- **MarkdownEditorDemo** is a Blazor Web Assembly project that contains 2 pages: `Index.razor` where I show how to use the component with the basic functions and `Upload.razor` that shows how to cope with the image upload. To test the upload, the project `MarkdownEditorDemo.Api` must run +- **MarkdownEditorDemo.Api** this is an ASP.NET Core WebApi (.NET6) how to implement a proper API for uploading images. For more details, I wrote a post about [Uploading image with .NET](https://www.puresourcecode.com/dotnet/net6/upload-download-files-using-httpclient/). + +### Properties +|Name|Description|Type|Default| +|--- |--- |--- |--- | +|AutoSaveEnabled|Gets or sets the setting for the auto save. Saves the text that's being written and will load it back in the future. It will forget the text when the form it's contained in is submitted. Recommended to choose a unique ID for the Markdown Editor.|bool|false| +|AutoSaveId|Gets or sets the automatic save identifier. You must set a unique string identifier so that the component can autosave. Something that separates this from other instances of the component elsewhere on your website.|string|Default value| +|AutoSaveDelay|Delay between saves, in milliseconds. Defaults to 10000 (10s).|int|10000 (10s)| +|AutoSaveSubmitDelay|Delay before assuming that submit of the form failed and saving the text, in milliseconds.|int|5000 (5s)| +|AutoSaveText|Text for autosave|string|Autosaved:| +|AutoSaveTimeFormatLocale|Set the format for the datetime to display. For more info, see the JavaScript documentation [DateTimeFormat instances](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat)|string|en-US| +|AutoSaveTimeFormatYear|Set the format for the year|string|numeric| +|AutoSaveTimeFormatMonth|Set the format for the month|string|long| +|AutoSaveTimeFormatDay|Set the format for the day|string|2-digit| +|AutoSaveTimeFormatHour|Set the format for the hour|string|2-digit| +|AutoSaveTimeFormatMinute|Set the format for the minute|string|2-digit| +|AutoDownloadFontAwesome|If set to true, force downloads Font Awesome (used for icons). If set to false, prevents downloading.|bool?|null| +|CustomButtonClicked|Occurs after the custom toolbar button is clicked.|EventCallback|| +|Direction|rtl or ltr. Changes text direction to support right-to-left languages. Defaults to ltr.|string|ltr| +|ErrorMessages|Errors displayed to the user, using the errorCallback option, where _image_name_, _image_size_ and _image_max_size_ will be replaced by their respective values, that can be used for customization or internationalization.|MarkdownErrorMessages|| +|HideIcons|An array of icon names to hide. Can be used to hide specific icons shown by default without completely customizing the toolbar.|string[]|'side-by-side', 'fullscreen'| +|ImageAccept|A comma-separated list of mime-types used to check image type before upload (note: never trust client, always check file types at server-side). Defaults to image/png, image/jpeg, image/jpg, image.gif.|string|image/png, image/jpeg, image/jpg, image.gif| +|ImageCSRFToken|CSRF token to include with AJAX call to upload image. For instance, used with Django backend.|string|| +|ImageMaxSize|Maximum image size in bytes, checked before upload (note: never trust client, always check image size at server-side). Defaults to 1024 * 1024 * 2 (2Mb).|long|1024 * 1024 * 2 (2Mb)| +|ImagePathAbsolute|If set to true, will treat _imageUrl_ from _imageUploadFunction_ and _filePath_ returned from _imageUploadEndpoint_ as an absolute rather than relative path, i.e. not prepend window.location.origin to it.|string|| +|ImageTexts|Texts displayed to the user (mainly on the status bar) for the import image feature, where _image_name_, _image_size_ and _image_max_size_ will be replaced by their respective values, that can be used for customization or internationalization.|MarkdownImageTexts|null| +|ImageUploadAuthenticationSchema|If an authentication for the API is required, assign to this property the schema to use. `Bearer` is the common one.|string|empty| +|ImageUploadAuthenticationToken|If an authentication for the API is required, assign to this property the token|string|empty| +|LineNumbers|If set to true, enables line numbers in the editor.|bool|false| +|LineWrapping|If set to false, disable line wrapping. Defaults to true.|bool|false| +|MaxHeight|Sets fixed height for the composition area. minHeight option will be ignored. Should be a string containing a valid CSS value like "500px". Defaults to undefined.|string|| +|MaxUploadImageMessageSize|Gets or sets the max message size when uploading the file.|long|20 * 1024| +|MinHeight|Sets the minimum height for the composition area, before it starts auto-growing. Should be a string containing a valid CSS value like "500px". Defaults to "300px".|string|300px| +|Placeholder|If set, displays a custom placeholder message.|string|null| +|SegmentFetchTimeout|Gets or sets the Segment Fetch Timeout when uploading the file.|TimeSpan|1 min| +|ShowIcons|An array of icon names to show. Can be used to show specific icons hidden by default without completely customizing the toolbar.|string[]|'code', 'table'| +|TabSize|If set, customize the tab size. Defaults to 2.|int|2| +|Theme|Override the theme. Defaults to easymde.|string|easymde| +|Toolbar|[Optional] Gets or sets the content of the toolbar.|RenderFragment|| +|ToolbarTips|If set to false, disable toolbar button tips. Defaults to true.|bool|true| +|UploadImage|If set to true, enables the image upload functionality, which can be triggered by drag-drop, copy-paste and through the browse-file window (opened when the user clicks on the upload-image icon). Defaults to false.|bool|false| +|Value|Gets or sets the markdown value.|string|null| +|ValueHTML|Gets the HTML from the markdown value.|string|null| + +### Events +|Name|Description|Type| +|--- |--- |--- | +|ErrorCallback|A callback function used to define how to display an error message. Defaults to (errorMessage) => alert(errorMessage).|Func| +|ImageUploadChanged|Occurs every time the selected image has changed.|Func| +|ImageUploadEnded|Occurs when an individual image upload has ended.|Func| +|ImageUploadEndpoint|The endpoint where the images data will be sent, via an asynchronous POST request. The server is supposed to save this image, and return a json response.|string| +|ImageUploadProgressed|Notifies the progress of image being written to the destination stream.|Func| +|ImageUploadStarted|Occurs when an individual image upload has started.|Func| +|ValueChanged|An event that occurs after the markdown value has changed.|EventCallback| +|ValueHTMLChanged|An event that occurs after the markdown value has changed and the new HTML code is available.|EventCallback| + +## Upload file +The Markdown Editor for Blazor can take care of uploading a file and add the relative Markdown code in the editor. For that, the property `UploadImage` has to set to `true`. Also, the upload API must be specified in the property `ImageUploadEndpoint`. +In some cases, the API requires an authentication. The properties `ImageUploadAuthenticationSchema` and `ImageUploadAuthenticationToken` allow you to pass the correct schema and token to use in the call. + +Those values will be added to the `HttpClient` `POST` request in the header. Only if both properties are not null, they will be added to the header. + +![markdown-editor-upload-image](https://user-images.githubusercontent.com/9497415/148955032-1d3dc558-f308-4134-b3fd-6d43a0e4e37a.gif) + +If you want to understand better how to create the API for the upload, I have created a specific [post](https://www.puresourcecode.com/dotnet/net6/upload-download-files-using-httpclient/) on [PureSourceCode](https://www.puresourcecode.com/). + +## Toolbar icons + +Below are the built-in toolbar icons (only some of which are enabled by default), which can be reorganized however you like. "Name" is the name of the icon, referenced in the JS. "Action" is either a function or a URL to open. "Class" is the class given to the icon. "Tooltip" is the small tooltip that appears via the `title=""` attribute. Note that shortcut hints are added automatically and reflect the specified action if it has a key bind assigned to it (i.e. with the value of `action` set to `bold` and that of `tooltip` set to `Bold`, the final text the user will see would be "Bold (Ctrl-B)"). + +Additionally, you can add a separator between any icons by adding `"|"` to the toolbar array. + +Name | Action | Tooltip
    Class +:--- | :----- | :-------------- +bold | toggleBold | Bold
    fa fa-bold +italic | toggleItalic | Italic
    fa fa-italic +strikethrough | toggleStrikethrough | Strikethrough
    fa fa-strikethrough +heading | toggleHeadingSmaller | Heading
    fa fa-header +heading-smaller | toggleHeadingSmaller | Smaller Heading
    fa fa-header +heading-bigger | toggleHeadingBigger | Bigger Heading
    fa fa-lg fa-header +heading-1 | toggleHeading1 | Big Heading
    fa fa-header header-1 +heading-2 | toggleHeading2 | Medium Heading
    fa fa-header header-2 +heading-3 | toggleHeading3 | Small Heading
    fa fa-header header-3 +code | toggleCodeBlock | Code
    fa fa-code +quote | toggleBlockquote | Quote
    fa fa-quote-left +unordered-list | toggleUnorderedList | Generic List
    fa fa-list-ul +ordered-list | toggleOrderedList | Numbered List
    fa fa-list-ol +clean-block | cleanBlock | Clean block
    fa fa-eraser +link | drawLink | Create Link
    fa fa-link +image | drawImage | Insert Image
    fa fa-picture-o +table | drawTable | Insert Table
    fa fa-table +horizontal-rule | drawHorizontalRule | Insert Horizontal Line
    fa fa-minus +preview | togglePreview | Toggle Preview
    fa fa-eye no-disable +side-by-side | toggleSideBySide | Toggle Side by Side
    fa fa-columns no-disable no-mobile +fullscreen | toggleFullScreen | Toggle Fullscreen
    fa fa-arrows-alt no-disable no-mobile +guide | [This link](https://www.markdownguide.org/basic-syntax/) | Markdown Guide
    fa fa-question-circle + +## Keyboard shortcuts + +EasyMDE comes with an array of predefined keyboard shortcuts, but they can be altered with a configuration option. The list of default ones is as follows: -The toolbar is added by default. You can disable this by passing `EnableToolbar="false"` into the component. +Shortcut (Windows / Linux) | Shortcut (macOS) | Action +:--- | :--- | :--- +*Ctrl-'* | *Cmd-'* | "toggleBlockquote" +*Ctrl-B* | *Cmd-B* | "toggleBold" +*Ctrl-E* | *Cmd-E* | "cleanBlock" +*Ctrl-H* | *Cmd-H* | "toggleHeadingSmaller" +*Ctrl-I* | *Cmd-I* | "toggleItalic" +*Ctrl-K* | *Cmd-K* | "drawLink" +*Ctrl-L* | *Cmd-L* | "toggleUnorderedList" +*Ctrl-P* | *Cmd-P* | "togglePreview" +*Ctrl-Alt-C* | *Cmd-Alt-C* | "toggleCodeBlock" +*Ctrl-Alt-I* | *Cmd-Alt-I* | "drawImage" +*Ctrl-Alt-L* | *Cmd-Alt-L* | "toggleOrderedList" +*Shift-Ctrl-H* | *Shift-Cmd-H* | "toggleHeadingBigger" +*F9* | *F9* | "toggleSideBySide" +*F11* | *F11* | "toggleFullScreen" -### Screenshot +--- -**Write Markdown text** -![image](https://user-images.githubusercontent.com/9497415/140496482-719e6b90-dcee-4547-b6b1-e5a4c7836e77.png) +## Other Blazor components +- [DataTable for Blazor](https://www.puresourcecode.com/dotnet/net-core/datatable-component-for-blazor/): DataTable component for Blazor WebAssembly and Blazor Server +- [Markdown editor for Blazor](https://www.puresourcecode.com/dotnet/blazor/markdown-editor-with-blazor/): This is a Markdown Editor for use in Blazor. It contains a live preview as well as an embeded help guide for users. +- [Modal dialog for Blazor](https://www.puresourcecode.com/dotnet/blazor/modal-dialog-component-for-blazor/): Simple Modal Dialog for Blazor WebAssembly +- [PSC.Extensions](https://www.puresourcecode.com/dotnet/net-core/a-lot-of-functions-for-net5/): A lot of functions for .NET6 in a NuGet package that you can download for free. We collected in this package functions for everyday work to help you with claim, strings, enums, date and time, expressions… +- [Quill for Blazor](https://www.puresourcecode.com/dotnet/blazor/create-a-blazor-component-for-quill/): Quill Component is a custom reusable control that allows us to easily consume Quill and place multiple instances of it on a single page in our Blazor application +- [Segment for Blazor](https://www.puresourcecode.com/dotnet/blazor/segment-control-for-blazor/): This is a Segment component for Blazor Web Assembly and Blazor Server +- [Tabs for Blazor](https://www.puresourcecode.com/dotnet/blazor/tabs-control-for-blazor/): This is a Tabs component for Blazor Web Assembly and Blazor Server -**Preview** -![image](https://user-images.githubusercontent.com/9497415/140496580-47569d20-ff3f-4f57-bd03-98e3ac0906ba.png) +## More examples and documentation +* [Write a reusable Blazor component](https://www.puresourcecode.com/dotnet/blazor/write-a-reusable-blazor-component/) +* [Getting Started With C# And Blazor](https://www.puresourcecode.com/dotnet/net-core/getting-started-with-c-and-blazor/) +* [Setting Up A Blazor WebAssembly Application](https://www.puresourcecode.com/dotnet/blazor/setting-up-a-blazor-webassembly-application/) +* [Working With Blazor Component Model](https://www.puresourcecode.com/dotnet/blazor/working-with-blazors-component-model/) +* [Secure Blazor WebAssembly With IdentityServer4](https://www.puresourcecode.com/dotnet/blazor/secure-blazor-webassembly-with-identityserver4/) +* [Blazor Using HttpClient With Authentication](https://www.puresourcecode.com/dotnet/blazor/blazor-using-httpclient-with-authentication/) +* [InputSelect component for enumerations in Blazor](https://www.puresourcecode.com/dotnet/blazor/inputselect-component-for-enumerations-in-blazor/) +* [Use LocalStorage with Blazor WebAssembly](https://www.puresourcecode.com/dotnet/blazor/use-localstorage-with-blazor-webassembly/) +* [Modal Dialog component for Blazor](https://www.puresourcecode.com/dotnet/blazor/modal-dialog-component-for-blazor/) +* [Create Tooltip component for Blazor](https://www.puresourcecode.com/dotnet/blazor/create-tooltip-component-for-blazor/) +* [Consume ASP.NET Core Razor components from Razor class libraries | Microsoft Docs](https://docs.microsoft.com/en-us/aspnet/core/blazor/components/class-libraries?view=aspnetcore-5.0&tabs=visual-studio)