diff --git a/minoteaur.nimble b/minoteaur.nimble index 3857fe5..3094d5c 100644 --- a/minoteaur.nimble +++ b/minoteaur.nimble @@ -18,5 +18,4 @@ requires "https://github.com/osmarks/nim-cmark-gfm" #requires "cmark >= 0.1.0" requires "regex >= 0.18.0" # seemingly much faster than standard library Levenshtein distance module -requires "nimlevenshtein >= 0.1.0" -#requires "gara >= 0.2.0" \ No newline at end of file +requires "nimlevenshtein >= 0.1.0" \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 5bbaf99..29dac06 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,8 @@ { - "requires": true, + "name": "minoteaur-nim", + "version": "1.0.0", "lockfileVersion": 1, + "requires": true, "dependencies": { "anymatch": { "version": "3.1.1", @@ -45,9 +47,9 @@ "integrity": "sha512-ZEhqxUtEZeGgg9eHNSOAJ8O9xqSgiJdrL0lzSSfMF54x6KXWJiOH/xntSJ9YomJPrYH/p08t6gWjGWq1SDJlSA==" }, "esbuild": { - "version": "0.8.39", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.8.39.tgz", - "integrity": "sha512-/do5H74a5ChyeKRWfkDh3EpICXpsz6dWTtFFbotb7BlIHvWqnRrZYDb8IBubOHdEtKzuiksilRO19aBtp3/HHQ==" + "version": "0.8.53", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.8.53.tgz", + "integrity": "sha512-GIaYGdMukH58hu+lf07XWAeESBYFAsz8fXnrylHDCbBXKOSNtFmoYA8PhSeSF+3/qzeJ0VjzV9AkLURo5yfu3g==" }, "fill-range": { "version": "7.0.1", @@ -58,9 +60,9 @@ } }, "fsevents": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.1.tgz", - "integrity": "sha512-YR47Eg4hChJGAB1O3yEAOkGO+rlzutoICGqGo9EZ4lKWokzZRSyIW1QmTzqjtw8MJdj9srP869CuWw/hyzSiBw==", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", "optional": true }, "glob-parent": { @@ -126,9 +128,9 @@ } }, "sass": { - "version": "1.32.6", - "resolved": "https://registry.npmjs.org/sass/-/sass-1.32.6.tgz", - "integrity": "sha512-1bcDHDcSqeFtMr0JXI3xc/CXX6c4p0wHHivJdru8W7waM7a1WjKMm4m/Z5sY7CbVw4Whi2Chpcw6DFfSWwGLzQ==", + "version": "1.32.8", + "resolved": "https://registry.npmjs.org/sass/-/sass-1.32.8.tgz", + "integrity": "sha512-Sl6mIeGpzjIUZqvKnKETfMf0iDAswD9TNlv13A7aAF3XZlRPMq4VvJWBC2N2DXbp94MQVdNSFG6LfF/iOXrPHQ==", "requires": { "chokidar": ">=2.0.0 <4.0.0" } diff --git a/package.json b/package.json new file mode 100644 index 0000000..f4d418e --- /dev/null +++ b/package.json @@ -0,0 +1,11 @@ +{ + "name": "minoteaur-nim", + "version": "1.0.0", + "dependencies": { + "date-fns": "^2.17.0", + "esbuild": "^0.8.53", + "idb": "^6.0.0", + "mithril": "^2.0.4", + "sass": "^1.32.8" + } +} diff --git a/src/client.js b/src/client.js index 976c0b3..faf2587 100644 --- a/src/client.js +++ b/src/client.js @@ -1,3 +1,6 @@ +// Minoteaur clientside code (runs editor enhancements, file upload, search, keyboard shortcuts) +// It may be worth rewriting this in Nim for codesharing, but I think the interaction with e.g. IndexedDB may be trickier + import m from "mithril" import { openDB } from "idb" import { lightFormat } from "date-fns" @@ -11,6 +14,14 @@ const dbPromise = openDB("minoteaur", 1, { // debugging thing dbPromise.then(x => { window.idb = x }) +const debounce = (fn, timeout = 250) => { + let timer; + return (...args) => { + clearTimeout(timer) + timer = setTimeout(fn, timeout, ...args) + } +} + const searchState = { showingSearchDialog: false, searchResults: [], @@ -37,6 +48,7 @@ const handleHTTPError = e => { searchState.searchError = x } +// handle input in search box const onsearch = ev => { const query = ev.target.value searchState.searchQuery = query @@ -44,7 +56,7 @@ const onsearch = ev => { url: "/api/search", params: { q: query } }).then(x => { - if (typeof x === "string") { // error from server + if (typeof x === "string") { // in case of error from server, show it but keep the existing results shown console.warn(x) searchState.searchError = x } else { @@ -55,10 +67,11 @@ const onsearch = ev => { } const currentPage = slugToPage(decodeURIComponent(/^\/([^/]+)/.exec(location.pathname)[1]).replace(/\+/g, " ")) +if (currentPage === "Login") { return } const searchKeyHandler = ev => { if (ev.code === "Enter") { // enter key - // not very useful to just navigate to the same page + // navigate to the first page (excluding the current one) in results const otherResults = searchState.searchResults.filter(r => r.page !== currentPage) if (otherResults[0]) { location.href = urlForPage(otherResults[0].page) } } @@ -109,14 +122,6 @@ document.body.addEventListener("keydown", e => { } }) -const debounce = (fn, timeout = 250) => { - let timer; - return () => { - clearTimeout(timer) - timer = setTimeout(fn, timeout) - } -} - const dispDateTime = dt => lightFormat(dt, "yyyy-MM-dd HH:mm:ss") const wordCount = s => { @@ -128,11 +133,15 @@ const wordCount = s => { } const lineCount = s => s.split("\n").length +// edit-page UI const editor = document.querySelector(".edit-form textarea") if (editor) { + // most of the state for the edit page UI + // this excludes the text area autoresize logic, as well as the actual editor textarea content const editorUIState = { keypresses: 0, - draftSelected: false + draftSelected: false, + pendingFiles: new Map() } const mountpoint = document.createElement("div") document.querySelector(".sidebar").appendChild(mountpoint) @@ -143,9 +152,10 @@ if (editor) { const resize = () => { const scrolltop = document.body.scrollTop const targetHeight = editor.scrollHeight + 2 + //console.log(targetHeight, editor.scrollHeight) if (targetHeight != editor.style.height.slice(0, -2) || lengthWas > editor.value.length) { - editor.style.height = 0 - editor.style.height = editor.scrollHeight + 2 + editor.style.height = `0px` + editor.style.height = `${Math.max(editor.scrollHeight + 2, 100)}px` document.body.scrollTop = scrolltop } lengthWas = editor.value.length @@ -154,6 +164,8 @@ if (editor) { // retrieve last edit timestamp from field const lastEditTime = parseInt(document.querySelector("input[name=last-edit]").value) const serverValue = editor.value + const associatedFiles = JSON.parse(document.querySelector("input[name=associated-files]").value) + .map(({ filename, mimeType }) => ({ file: { name: filename, type: mimeType, state: "uploaded" }, state: "preexisting" })) // load in the initially loaded draft const swapInDraft = () => { @@ -173,9 +185,9 @@ if (editor) { dbPromise.then(db => db.get("drafts", currentPage)).then(draft => { editorUIState.initialDraft = draft - console.log("loaded memetic/beemetic entity ", draft) + console.log("found draft ", draft) // if the draft is newer than the server page, load it in (the user can override this) - if (draft.ts > lastEditTime) { + if (draft && draft.ts > lastEditTime) { swapInDraft() } m.redraw() @@ -188,8 +200,34 @@ if (editor) { ] } + // Prompt the user to upload file(s) + const uploadFile = () => { + // create a fake and click it, because JavaScript + const input = document.createElement("input") + input.type = "file" + input.multiple = true + input.click() + input.oninput = ev => { + for (const file of ev.target.files) { + editorUIState.pendingFiles.set(file.name, { file, state: "pending" }) + window.file = file + } + if (ev.target.files.length > 0) { m.redraw() } + } + } + + const File = { + view: ({ attrs }) => m("li.file", [ + m("", attrs.file.name), + m("", attrs.state) + ]) + } + const EditorUIApp = { view: () => [ + m("button.upload", { onclick: uploadFile }, "Upload"), + m("ul.files", associatedFiles.concat(Array.from(editorUIState.pendingFiles.values())) + .map(file => m(File, { ...file, key: file.file.name }))), m("", `${editorUIState.chars} chars`), m("", `${editorUIState.words} words`), m("", `${editorUIState.lines} lines`), @@ -198,6 +236,7 @@ if (editor) { ] } + // Update the sidebar word/line/char counts const updateCounts = text => { editorUIState.words = wordCount(text) editorUIState.lines = lineCount(text) diff --git a/src/domain.nim b/src/domain.nim index 6d3acea..77a55e7 100644 --- a/src/domain.nim +++ b/src/domain.nim @@ -13,7 +13,7 @@ import sugar import unicode import math -import util +import ./util from ./md import parsePage let migrations = @[ @@ -72,12 +72,19 @@ CREATE TABLE files ( metadata TEXT NOT NULL, uploadedTime INTEGER NOT NULL, UNIQUE (page, filename) +); + """, + """ +CREATE TABLE sessions ( + sid INTEGER PRIMARY KEY, + timestamp INTEGER NOT NULL, + data TEXT NOT NULL ); """ ] type - Encoding* {.pure} = enum + Encoding* {.pure.} = enum Plain = 0, Zstd = 1 RevisionType* {.pure.} = enum NewContent = 0 @@ -101,18 +108,20 @@ type uid*: int64 Backlink* = object fromPage*, text*, context*: string - -var logger = newConsoleLogger() + FileInfo* = object + filename*, mimeType*: string + uploadedTime*: Time + metadata*: JsonNode proc migrate*(db: DbConn) = let currentVersion = fromDbValue(get db.value("PRAGMA user_version"), int) for mid in (currentVersion + 1) .. migrations.len: db.transaction: - logger.log(lvlInfo, "Migrating to schema " & $mid) + logger().log(lvlInfo, "Migrating to schema " & $mid) db.execScript migrations[mid - 1] # for some reason this pragma does not work using normal parameter binding db.exec("PRAGMA user_version = " & $mid) - logger.log(lvlDebug, "DB ready") + logger().log(lvlDebug, "DB ready") proc parse*(s: string, T: typedesc): T = fromJson(result, parseJSON(s), Joptions(allowExtraKeys: true, allowMissingKeys: true)) @@ -235,4 +244,12 @@ proc processSearchRow(row: ResultRow): SearchResult = SearchResult(page: page, rank: log10(-rank * 1e7), snippet: snips.filter(x => len(x[1]) > 0)) proc search*(db: DbConn, query: string): seq[SearchResult] = - db.all("SELECT page, rank, snippet(pages_fts, 1, '', '', ' ... ', 32) FROM pages_fts WHERE pages_fts MATCH ? AND rank MATCH 'bm25(5.0, 1.0)' ORDER BY rank", query).map(processSearchRow) \ No newline at end of file + db.all("SELECT page, rank, snippet(pages_fts, 1, '', '', ' ... ', 32) FROM pages_fts WHERE pages_fts MATCH ? AND rank MATCH 'bm25(5.0, 1.0)' ORDER BY rank", query).map(processSearchRow) + +proc getBasicFileInfo*(db: DbConn, page, filename: string): Option[(string, string)] = + db.one("SELECT storagePath, mimeType FROM files WHERE page = ? AND filename = ?", page, filename).map(proc (r: ResultRow): (string, string) = r.unpack((string, string))) + +proc getPageFiles*(db: DbConn, page: string): seq[FileInfo] = + db.all("SELECT filename, mimeType, uploadedTime, metadata FROM files WHERE page = ?", page).map(proc (r: ResultRow): FileInfo = + let (filename, mime, upload, meta) = r.unpack((string, string, Time, string)) + FileInfo(filename: filename, mimetype: mime, uploadedTime: upload, metadata: parse(meta, JsonNode))) \ No newline at end of file diff --git a/src/generate_password_hash.py b/src/generate_password_hash.py new file mode 100755 index 0000000..025c18e --- /dev/null +++ b/src/generate_password_hash.py @@ -0,0 +1,6 @@ +#!/usr/bin/env python3 + +import getpass +import argon2 + +print(argon2.hash_password(getpass.getpass().encode("utf-8")).decode("utf-8")) \ No newline at end of file diff --git a/src/md.nim b/src/md.nim index d3b3f5e..6dd8726 100644 --- a/src/md.nim +++ b/src/md.nim @@ -171,7 +171,7 @@ proc linkContext(str: string, startPos: int, endPos: int, lookaround: int): stri earlierToks[max(earlierToks.len - bdlook + laterToks.len, 0)..^1].join(" ") & linkText & laterToks.join(" ") # mirrored version of previous case elif earlierToks.len < lookaround and laterToks.len >= lookaround: - earlierToks.join(" ") & linkText & laterToks[0..<(bdlook - earlierToks.len)].join(" ") + earlierToks.join(" ") & linkText & laterToks[0.." & $vnode + +proc openDBConnection(): DbConn = + logger().log(lvlInfo, "Opening database connection") + let conn = openDatabase(dbPath) + conn.exec("PRAGMA foreign_keys = ON") + return conn + +autoInitializedThreadvar(db, DbConn, openDBConnection()) block: - let db = openDatabase("./minoteaur.sqlite3") + let db = openDatabase(dbPath) domain.migrate(db) - close(db) - -type - AppContext = ref object of Context - db: DbConn - -# store thread's DB connection -var db {.threadvar.}: Option[DbConn] + close(db()) proc dbMiddleware(): HandlerAsync = - # horrible accursed hack to make exitproc work - result = proc(ctx: AppContext) {.async.} = - # open new DB connection for thread if there isn't one - if db.isNone: - echo "Opening database connection" - var conn = openDatabase("./minoteaur.sqlite3") - conn.exec("PRAGMA foreign_keys = ON") - db = some conn - ctx.db = get db + result = proc(ctx: AppContext) {.async.} = + ctx.db = db() await switch(ctx) proc headersMiddleware(): HandlerAsync = @@ -78,6 +73,17 @@ proc headersMiddleware(): HandlerAsync = ctx.response.setHeader("Content-Security-Policy", "default-src 'self' 'unsafe-inline'; img-src * data:; media-src * data:; form-action 'self'; frame-ancestors 'self'") ctx.response.setHeader("Referrer-Policy", "origin-when-cross-origin") +proc requireLoginMiddleware(): HandlerAsync = + result = proc(ctx: AppContext) {.async.} = + let loginURL = ctx.urlFor("login-page") + let authed = ctx.session.getOrDefault("authed", "f") + let path = ctx.request.path + if authed == "t" or path == loginURL or path.startsWith("/static"): + await switch(ctx) + else: + let loginRedirectURL = ctx.urlFor("login-page", queryParams={ "redirect": path }) + resp redirect(loginRedirectURL, Http303) + proc displayTime(t: Time): string = t.format("uuuu-MM-dd HH:mm:ss", utc()) func pageUrlFor(ctx: AppContext, route: string, page: string, query: openArray[(string, string)] = @[]): string = ctx.urlFor(route, { "page": encodeUrl(pageToSlug(page)) }, query) @@ -90,11 +96,14 @@ proc edit(ctx: AppContext) {.async.} = # autocomplete=off disables some sort of session history caching mechanism which interferes with draft handling buildHtml(form(`method`="post", class="edit-form", id="edit-form", autocomplete="off")): textarea(name="content"): text pageData.map(p => p.content).get("") + # pass inputs to JS-side editor code as hidden input fields + # TODO: this is somewhat horrible, do another thing input(`type`="hidden", value=pageData.map(p => timestampToStr(p.updated)).get("0"), name="last-edit") + input(`type`="hidden", value= $toJson(domain.getPageFiles(ctx.db, page)), name="associated-files") let sidebar = buildHtml(tdiv): input(`type`="submit", value="Save", name="action", class="save", form="edit-form") let verb = if pageData.isSome: "Editing " else: "Creating " - resp base(verb & page, @[pageButton(ctx, "view-page", page, "View"), pageButton(ctx, "page-revisions", page, "Revisions")], html, some(sidebar)) + resp base(verb & page, @[searchButton(), pageButton(ctx, "view-page", page, "View"), pageButton(ctx, "page-revisions", page, "Revisions")], html, some(sidebar)) proc revisions(ctx: AppContext) {.async.} = let page = slugToPage(decodeUrl(ctx.getPathParams("page"))) @@ -114,19 +123,34 @@ proc revisions(ctx: AppContext) {.async.} = td: text rev.meta.editDistance.map(x => $x).get("") td: text rev.meta.size.map(x => formatSize(x)).get("") td: text rev.meta.words.map(x => $x).get("") - resp base("Revisions of " & page, @[pageButton(ctx, "view-page", page, "View"), pageButton(ctx, "edit-page", page, "Edit")], html) + resp base("Revisions of " & page, @[searchButton(), pageButton(ctx, "view-page", page, "View"), pageButton(ctx, "edit-page", page, "Edit")], html) proc handleEdit(ctx: AppContext) {.async.} = let page = slugToPage(decodeUrl(ctx.getPathParams("page"))) - domain.updatePage(ctx.db, page, ctx.getFormParams("content")) - resp redirect(pageUrlFor(ctx, "view-page", page), Http303) + # file upload instead of content change + if "file" in ctx.request.formParams.data: + let file = ctx.request.formParams["file"] + echo $file + await ctx.respond(Http204, "") + else: + domain.updatePage(ctx.db, page, ctx.getFormParams("content")) + resp redirect(pageUrlFor(ctx, "view-page", page), Http303) proc sendAttachedFile(ctx: AppContext) {.async.} = let page = slugToPage(decodeUrl(ctx.getPathParams("page"))) - echo "orbital bee strike → you" - resp "TODO" + let filename = decodeUrl(ctx.getPathParams("filename")) + let filedata = domain.getBasicFileInfo(ctx.db, page, filename) + if filedata.isSome: + let (path, mime) = get filedata + await ctx.staticFileResponse(path, "", mimetype = mime) + else: + resp error404() proc view(ctx: AppContext) {.async.} = + try: + ctx.session["counter"] = $(parseInt(ctx.session["counter"]) + 1) + except: + ctx.session["counter"] = "2" let page = slugToPage(decodeUrl(ctx.getPathParams("page"))) let rawRevision = ctx.getQueryParams("ts") let viewSource = ctx.getQueryParams("source") != "" @@ -159,7 +183,7 @@ proc view(ctx: AppContext) {.async.} = tdiv: a(class="wikilink", href=pageUrlFor(ctx, "view-page", backlink.fromPage)): text backlink.fromPage tdiv: text backlink.context - resp base(page, @[pageButton(ctx, "edit-page", page, "Edit"), pageButton(ctx, "page-revisions", page, "Revisions")], html) + resp base(page, @[searchButton(), pageButton(ctx, "edit-page", page, "Edit"), pageButton(ctx, "page-revisions", page, "Revisions")], html) else: # old revision @@ -171,7 +195,7 @@ proc view(ctx: AppContext) {.async.} = text "As of " text displayTime(rts) tdiv(class="md"): mainBody - var buttons = @[pageButton(ctx, "edit-page", page, "Edit"), pageButton(ctx, "page-revisions", page, "Revisions"), pageButton(ctx, "view-page", page, "Latest")] + var buttons = @[searchButton(), pageButton(ctx, "edit-page", page, "Edit"), pageButton(ctx, "page-revisions", page, "Revisions"), pageButton(ctx, "view-page", page, "Latest")] if next.isSome: buttons.add(pageButton(ctx, "next-page", page, "Next", { "ts": timestampToStr (get next).time })) if prev.isSome: buttons.add(pageButton(ctx, "prev-page", page, "Previous", { "ts": timestampToStr (get prev).time })) @@ -187,13 +211,54 @@ proc search(ctx: AppContext) {.async.} = return resp jsonResponse toJson(results) +proc loginPage(ctx: AppContext) {.async.} = + let options = @["I forgot my password", "I remembered it, but then bees stole it", "I am actively unable to remember anything", "I know it, but can't enter it", "I know it, but won't enter it", + "I know it, but am not alive/existent enough to enter it", "I remembered my password", "I forgot my password", "My password was retroactively erased/altered", "All of the above", + "My password contains anomalous Unicode I cannot type", "I forgot my keyboard", "My password is unrepresentable within Unicode", "My password is unrepresentable within reality", + "I am not actually the intended user and I don't know the password", "I'm bored and clicking on random options", "Contingency λ-8288 is to be initiated", "One of the above, but username instead", + "The box is too small", "The box is too big", "There's not even a username option", "I cannot type (in general)", "I want backdoor access", "I forgot to forget my password", + "I forgot my username", "I remembered a password, but the wrong one", "My password cannot safely be entered", "My password's length exceeds available memory", + "I don't know the password but can get it if I can log in now", "I'm bored and clicking on nondeterministic options", "I dislike these options", "I like these options", + "I remembered to forget my password", "I don't like my password", "My password cannot be reused due to linear types", "I would like to forget my password but I am incapable of doing so", + "My password is sapient and refuses to be typed", "My password anomalously causes refusal of authentication", "I cannot legally provide my password", "I lack required insurance", + "I am aware of all information in the universe except my password", "I am unable to read", "My password is infohazardous", "My password might be infohazardous", "I forgot your password", + "My password anomalously refuses changes", "My password cannot be trusted", "My password forgot me", "My password has been garbage-collected", "I don't trust the site with my password", + "My identity was forcefully separated from my password", "My issue defies characterization", "I cannot send HTTP POST requests", "My password contains my password", + "I am legally required to enter my password but engaging in rebellion", "My password is the nontrivial zeros of the Riemann zeta function", "My password is the string of bytes required to crash this webserver", + "My password is my password only when preceded by my password", "Someone is watching me enter my password", "I am legally required to click this option", "My password takes infinite time to evaluate", + "I neither remembered nor forgot my password", "I forgot the concept of passwords", "I reject the concept of passwords"] + let html = buildHtml(tdiv): + form(`method`="post", class="login"): + input(`type`="password", placeholder="Password") + input(`type`="submit", class="login", value="Login") + + h2: text "Extra login options" + ul: + for option in options: + li: a(href=""): text option + resp base("Login", @[], html) + +proc handleLogin(ctx: AppContext) {.async.} = + let success = true + # TODO: This does allow off-site redirects. Fix this. + # Also TODO: rate limiting + if success: + logger().log(lvlInfo, "Successful login") + ctx.session["authed"] = "t" + resp redirect(ctx.request.queryParams.getOrDefault("redirect", "/"), Http303) + else: + logger().log(lvlInfo, "Unsuccessful login") + resp redirect(ctx.urlFor("login-page"), Http303) + proc favicon(ctx: Context) {.async.} = resp error404() -proc index(ctx: Context) {.async.} = resp "bee(s)" +proc index(ctx: Context) {.async.} = resp "TODO" var app = newApp(settings = settings) -app.use(@[staticFileMiddleware("static"), sessionMiddleware(settings), extendContextMiddleware(AppContext), dbMiddleware(), headersMiddleware()]) +app.use(@[staticFileMiddleware("static"), extendContextMiddleware(AppContext), dbMiddleware(), sessionMiddleware(settings, db), requireLoginMiddleware(), headersMiddleware()]) app.get("/", index) app.get("/favicon.ico", favicon) +app.get("/login", loginPage, name="login-page") +app.post("/login", handleLogin, name="handle-login") app.get("/api/search", search, name="search") app.get("/{page}/edit", edit, name="edit-page") app.get("/{page}/revisions", revisions, name="page-revisions") diff --git a/src/sqlitesession.nim b/src/sqlitesession.nim new file mode 100644 index 0000000..29fbddd --- /dev/null +++ b/src/sqlitesession.nim @@ -0,0 +1,77 @@ +# based on https://github.com/planety/prologue/blob/devel/src/prologue/middlewares/sessions/redissession.nim +# SQLite session storage adapter + +import std/[options, strtabs, asyncdispatch] + +from prologue/core/types import len, Session, newSession, loads, dumps +from prologue/core/context import Context, HandlerAsync, getCookie, setCookie, deleteCookie +from prologue/core/response import addHeader +from prologue/core/middlewaresbase import switch +from prologue/core/nativesettings import Settings +from cookiejar import SameSite +from strutils import parseBiggestInt +import tiny_sqlite +import times + +import ./util + +proc sessionMiddleware*( + settings: Settings, + getDB: (proc(): DbConn), + sessionName = "session", + maxAge: int = 14 * 24 * 60 * 60, # 14 days, in seconds + domain = "", + sameSite = Lax, + httpOnly = false +): HandlerAsync = + return proc(ctx: Context) {.async.} = + # TODO: this may be invoking dark gods slightly (fix?) + # the proc only accesses the DB threadvar, but it itself is GC memory + {.gcsafe.}: + let db = getDB() + var sessionIDString = ctx.getCookie(sessionName) + + # no session ID results in sessionIDString being empty, which will also result in a parse failure + # this will cause a new session ID to be generated + var sessionID: int64 = -1 + try: + sessionID = int64(parseBiggestInt sessionIDString) + except ValueError: discard + + var sessionTS = getTime() + + if sessionID != -1: + # fetch session from database + let info = db.one("SELECT * FROM sessions WHERE sid = ?", sessionID) + if info.isSome: + let (sid, ts, data) = info.get().unpack((int64, Time, string)) + sessionTS = ts + ctx.session = newSession(data = newStringTable(modeCaseSensitive)) + ctx.session.loads(data) + else: + ctx.session = newSession(data = newStringTable(modeCaseSensitive)) + else: + ctx.session = newSession(data = newStringTable(modeCaseSensitive)) + + sessionID = snowflake() + ctx.setCookie(sessionName, $sessionID, maxAge = some(maxAge), domain = domain, sameSite = sameSite, httpOnly = httpOnly) + + await switch(ctx) + + if ctx.session.len == 0: # empty or modified (del or clear) + if ctx.session.modified: # modified + db.exec("DELETE FROM sessions WHERE sid = ?", sessionID) + ctx.deleteCookie(sessionName, domain = domain) # delete session data in cookie + return + + if ctx.session.accessed: + ctx.response.addHeader("Vary", "Cookie") + + if ctx.session.modified: + let serializedSessionData = ctx.session.dumps() + db.exec("INSERT OR REPLACE INTO sessions VALUES (?, ?, ?)", sessionID, sessionTS, serializedSessionData) + # garbage collect old sessions + # TODO: consider checking elsewhere, as not doing so leads to a bit of an exploit where + # old session IDs can be used for a while + let oldSessionThreshold = getTime() + initDuration(seconds = -maxAge) + db.exec("DELETE FROM sessions WHERE timestamp < ?", oldSessionThreshold) \ No newline at end of file diff --git a/src/style.sass b/src/style.sass index adf24e9..5317fb9 100755 --- a/src/style.sass +++ b/src/style.sass @@ -7,8 +7,7 @@ html body font-family: "Fira Sans", "Noto Sans", "Segoe UI", Verdana, sans-serif font-weight: 300 - margin: 0 0 1em 0 - //min-height: 100vh + margin: 0 0 0 0 display: flex flex-wrap: wrap justify-content: space-around @@ -98,6 +97,7 @@ a.wikilink .link-button, button, input[type=submit] border: none + border-radius: 0 padding: 0.75em background: gray text-align: center @@ -123,11 +123,16 @@ a.wikilink background-color: #bc13fe &.search background-color: #fac205 + &.upload + background-color: #49759c + &.login + background-color: #02ab2e -input[type=search], input[type=text] +input[type=search], input[type=text], input[type=password] border: 1px solid gray padding: 0.75em width: 100% + border-radius: 0 .edit-form textarea @@ -148,4 +153,7 @@ input[type=search], input[type=text] .flex-space display: flex - justify-content: space-between \ No newline at end of file + justify-content: space-between + +.login + display: flex \ No newline at end of file diff --git a/src/util.nim b/src/util.nim index 0560f20..e3840fb 100644 --- a/src/util.nim +++ b/src/util.nim @@ -7,6 +7,11 @@ import random import math import times import options +import json +from os import `/`, existsOrCreateDir +import md5 +import prologue +import logging func lowercaseFirstLetter(s: string): string = if len(s) == 0: @@ -22,6 +27,7 @@ func slugToPage*(slug: string): string = slug.split({'_', ' '}).map(capitalize). func timeToTimestamp*(t: Time): int64 = toUnix(t) * 1000 + (nanosecond(t) div 1000000) func timestampToTime*(ts: int64): Time = initTime(ts div 1000, (ts mod 1000) * 1000000) func timestampToStr*(t: Time): string = intToStr(int(timeToTimestamp(t))) +proc toJsonHook(t: Time): JsonNode = newJInt(timeToTimestamp(t)) # store time as milliseconds proc toDbValue*(t: Time): DbValue = DbValue(kind: sqliteInteger, intVal: timeToTimestamp(t)) @@ -29,7 +35,7 @@ proc fromDbValue*(value: DbValue, T: typedesc[Time]): Time = timestampToTime(val template autoInitializedThreadvar*(name: untyped, typ: typedesc, initialize: typed): untyped = var data* {.threadvar.}: Option[typ] - proc `name`(): typ = + proc `name`*(): typ = if isSome(data): result = get data else: result = initialize @@ -53,4 +59,32 @@ proc snowflake*(): int64 = var ts = int64((now - SIMPLEFLAKE_EPOCH) * 1000) let randomBits = int64(rng.rand(2 ^ SIMPLEFLAKE_RANDOM_LENGTH)) - return ts shl SIMPLEFLAKE_RANDOM_LENGTH or randomBits \ No newline at end of file + return ts shl SIMPLEFLAKE_RANDOM_LENGTH or randomBits + +# remove any unsafe characters from a filename, by only allowing bytes [a-zA-Z._ -] +proc normalizeFilename(s: string): string = + for byte in s: + if byte in {' ', 'a'..'z', 'A'..'Z', '-', '_', '.'}: + result.add(byte) + else: + result.add('_') + +proc makeFilePath*(basepath, page, filename: string): string = + # putting tons of things into one directory may cause issues, so "shard" it into 256 subdirs deterministically + let pageHash = getMD5(page) + let hashdir = pageHash[0..1] + # it is possible that for some horrible reason someone could make two files/pages which normalize to the same thing + # but are nevertheless different files + # thus, put the hash of the ORIGINAL file/pagename before the normalized version + let pagedir = pageHash[2..31] & "-" & normalizeFilename(page) + let filenameHash = getMD5(filename) + discard existsOrCreateDir(basepath / hashdir) + discard existsOrCreateDir(basepath / hashdir / pagedir) + # saved file path should not include the basedir for file storage, as this may be moved around/reconfigured + hashdir / pagedir / (filenameHash & "-" & normalizeFilename(filename)) + +autoInitializedThreadvar(logger, ConsoleLogger, newConsoleLogger()) + +type + AppContext* = ref object of Context + db*: DbConn \ No newline at end of file diff --git a/static/client.js b/static/client.js index 1469395..ce3ff2d 100644 --- a/static/client.js +++ b/static/client.js @@ -1,12 +1,12 @@ -(()=>{var br=Object.create,Ue=Object.defineProperty,xr=Object.getPrototypeOf,Er=Object.prototype.hasOwnProperty,Dr=Object.getOwnPropertyNames,Tr=Object.getOwnPropertyDescriptor;var qr=e=>Ue(e,"__esModule",{value:!0});var O=(e,n)=>()=>(n||(n={exports:{}},e(n.exports,n)),n.exports);var Cr=(e,n,a)=>{if(qr(e),n&&typeof n=="object"||typeof n=="function")for(let f of Dr(n))!Er.call(e,f)&&f!=="default"&&Ue(e,f,{get:()=>n[f],enumerable:!(a=Tr(n,f))||a.enumerable});return e},Sr=e=>e&&e.__esModule?e:Cr(Ue(e!=null?br(xr(e)):{},"default",{value:e,enumerable:!0}),e);var te=O((Sn,ht)=>{"use strict";function ae(e,n,a,f,m,h){return{tag:e,key:n,attrs:a,children:f,text:m,dom:h,domSize:void 0,state:void 0,events:void 0,instance:void 0}}ae.normalize=function(e){return Array.isArray(e)?ae("[",void 0,void 0,ae.normalizeChildren(e),void 0,void 0):e==null||typeof e=="boolean"?null:typeof e=="object"?e:ae("#",void 0,void 0,String(e),void 0,void 0)};ae.normalizeChildren=function(e){var n=[];if(e.length){for(var a=e[0]!=null&&e[0].key!=null,f=1;f{"use strict";var jr=te();pt.exports=function(){var e=arguments[this],n=this+1,a;if(e==null?e={}:(typeof e!="object"||e.tag!=null||Array.isArray(e))&&(e={},n=this),arguments.length===n+1)a=arguments[n],Array.isArray(a)||(a=[a]);else for(a=[];n{"use strict";var gt=te(),Ir=Be(),Pr=/(?:(^|#|\.)([^#\.\[\]]+))|(\[(.+?)(?:\s*=\s*("|'|)((?:\\["'\]]|.)*?)\5)?\])/g,dt={},le={}.hasOwnProperty;function yt(e){for(var n in e)if(le.call(e,n))return!1;return!0}function Nr(e){for(var n,a="div",f=[],m={};n=Pr.exec(e);){var h=n[1],c=n[2];if(h===""&&c!=="")a=c;else if(h==="#")m.id=c;else if(h===".")f.push(c);else if(n[3][0]==="["){var o=n[6];o&&(o=o.replace(/\\(["'])/g,"$1").replace(/\\\\/g,"\\")),n[4]==="class"?f.push(o):m[n[4]]=o===""?o:o||!0}}return f.length>0&&(m.className=f.join(" ")),dt[e]={tag:a,attrs:m}}function Ar(e,n){var a=n.attrs,f=gt.normalizeChildren(n.children),m=le.call(a,"class"),h=m?a.class:a.className;if(n.tag=e.tag,n.attrs=null,n.children=void 0,!yt(e.attrs)&&!yt(a)){var c={};for(var o in a)le.call(a,o)&&(c[o]=a[o]);a=c}for(var o in e.attrs)le.call(e.attrs,o)&&o!=="className"&&!le.call(a,o)&&(a[o]=e.attrs[o]);(h!=null||e.attrs.className!=null)&&(a.className=h!=null?e.attrs.className!=null?String(e.attrs.className)+" "+String(h):h:e.attrs.className!=null?e.attrs.className:null),m&&(a.class=null);for(var o in a)if(le.call(a,o)&&o!=="key"){n.attrs=a;break}return Array.isArray(f)&&f.length===1&&f[0]!=null&&f[0].tag==="#"?n.text=f[0].children:n.children=f,n}function Mr(e){if(e==null||typeof e!="string"&&typeof e!="function"&&typeof e.view!="function")throw Error("The selector must be either a string or a component.");var n=Ir.apply(1,arguments);return typeof e=="string"&&(n.children=gt.normalizeChildren(n.children),e!=="[")?Ar(dt[e]||Nr(e),n):(n.tag=e,n)}mt.exports=Mr});var bt=O((Pn,wt)=>{"use strict";var vr=te();wt.exports=function(e){return e==null&&(e=""),vr("<",void 0,void 0,e,void 0,void 0)}});var Et=O((Nn,xt)=>{"use strict";var Or=te(),Lr=Be();xt.exports=function(){var e=Lr.apply(0,arguments);return e.tag="[",e.children=Or.normalizeChildren(e.children),e}});var Tt=O((An,Dt)=>{"use strict";var Fe=He();Fe.trust=bt();Fe.fragment=Et();Dt.exports=Fe});var $e=O((Mn,qt)=>{"use strict";var U=function(e){if(!(this instanceof U))throw new Error("Promise must be called with `new`");if(typeof e!="function")throw new TypeError("executor must be a function");var n=this,a=[],f=[],m=u(a,!0),h=u(f,!1),c=n._instance={resolvers:a,rejectors:f},o=typeof setImmediate=="function"?setImmediate:setTimeout;function u(w,b){return function g(p){var E;try{if(b&&p!=null&&(typeof p=="object"||typeof p=="function")&&typeof(E=p.then)=="function"){if(p===n)throw new TypeError("Promise can't be resolved w/ itself");y(E.bind(p))}else o(function(){!b&&w.length===0&&console.error("Possible unhandled promise rejection:",p);for(var x=0;x0||E(x)}}var p=g(h);try{w(g(m),p)}catch(E){p(E)}}y(e)};U.prototype.then=function(e,n){var a=this,f=a._instance;function m(u,y,w,b){y.push(function(g){if(typeof u!="function")w(g);else try{h(u(g))}catch(p){c&&c(p)}}),typeof f.retry=="function"&&b===f.state&&f.retry()}var h,c,o=new U(function(u,y){h=u,c=y});return m(e,f.resolvers,h,!0),m(n,f.rejectors,c,!1),o};U.prototype.catch=function(e){return this.then(null,e)};U.prototype.finally=function(e){return this.then(function(n){return U.resolve(e()).then(function(){return n})},function(n){return U.resolve(e()).then(function(){return U.reject(n)})})};U.resolve=function(e){return e instanceof U?e:new U(function(n){n(e)})};U.reject=function(e){return new U(function(n,a){a(e)})};U.all=function(e){return new U(function(n,a){var f=e.length,m=0,h=[];if(e.length===0)n([]);else for(var c=0;c{"use strict";var he=$e();typeof window!="undefined"?(typeof window.Promise=="undefined"?window.Promise=he:window.Promise.prototype.finally||(window.Promise.prototype.finally=he.prototype.finally),be.exports=window.Promise):typeof global!="undefined"?(typeof global.Promise=="undefined"?global.Promise=he:global.Promise.prototype.finally||(global.Promise.prototype.finally=he.prototype.finally),be.exports=global.Promise):be.exports=he});var St=O((On,Ct)=>{"use strict";var ue=te();Ct.exports=function(e){var n=e&&e.document,a,f={svg:"http://www.w3.org/2000/svg",math:"http://www.w3.org/1998/Math/MathML"};function m(r){return r.attrs&&r.attrs.xmlns||f[r.tag]}function h(r,t){if(r.state!==t)throw new Error("`vnode.state` must not be modified")}function c(r){var t=r.state;try{return this.apply(t,arguments)}finally{h(r,t)}}function o(){try{return n.activeElement}catch(r){return null}}function u(r,t,i,s,l,d,C){for(var j=i;j'+t.children+"",d=d.firstChild):d.innerHTML=t.children,t.dom=d.firstChild,t.domSize=d.childNodes.length,t.instance=[];for(var C=n.createDocumentFragment(),j;j=d.firstChild;)t.instance.push(j),C.appendChild(j);ne(r,C,s)}function p(r,t,i,s,l){var d=n.createDocumentFragment();if(t.children!=null){var C=t.children;u(d,C,0,C.length,i,null,s)}t.dom=d.firstChild,t.domSize=d.childNodes.length,ne(r,d,l)}function E(r,t,i,s,l){var d=t.tag,C=t.attrs,j=C&&C.is;s=m(t)||s;var D=s?j?n.createElementNS(s,d,{is:j}):n.createElementNS(s,d):j?n.createElement(d,{is:j}):n.createElement(d);if(t.dom=D,C!=null&&cr(t,C,s),ne(r,D,l),!ie(t)&&(t.text!=null&&(t.text!==""?D.textContent=t.text:t.children=[ue("#",void 0,void 0,t.text,void 0,void 0)]),t.children!=null)){var I=t.children;u(D,I,0,I.length,i,null,s),t.tag==="select"&&C!=null&&hr(t,C)}}function x(r,t){var i;if(typeof r.tag.view=="function"){if(r.state=Object.create(r.tag),i=r.state.view,i.$$reentrantLock$$!=null)return;i.$$reentrantLock$$=!0}else{if(r.state=void 0,i=r.tag,i.$$reentrantLock$$!=null)return;i.$$reentrantLock$$=!0,r.state=r.tag.prototype!=null&&typeof r.tag.prototype.view=="function"?new r.tag(r):r.tag(r)}if(Ae(r.state,r,t),r.attrs!=null&&Ae(r.attrs,r,t),r.instance=ue.normalize(c.call(r.state.view,r)),r.instance===r)throw Error("A view cannot return the vnode it received as argument");i.$$reentrantLock$$=null}function q(r,t,i,s,l){x(t,i),t.instance!=null?(y(r,t.instance,i,s,l),t.dom=t.instance.dom,t.domSize=t.dom!=null?t.instance.domSize:0):t.domSize=0}function S(r,t,i,s,l,d){if(!(t===i||t==null&&i==null))if(t==null||t.length===0)u(r,i,0,i.length,s,l,d);else if(i==null||i.length===0)Z(r,t,0,t.length);else{var C=t[0]!=null&&t[0].key!=null,j=i[0]!=null&&i[0].key!=null,D=0,I=0;if(!C)for(;I=I&&_>=D&&(H=t[$],M=i[_],H.key===M.key);)H!==M&&v(r,H,M,s,l,d),M.dom!=null&&(l=M.dom),$--,_--;for(;$>=I&&_>=D&&(V=t[I],z=i[D],V.key===z.key);)I++,D++,V!==z&&v(r,V,z,s,J(t,I,l),d);for(;$>=I&&_>=D&&!(D===_||V.key!==M.key||H.key!==z.key);)Oe=J(t,I,l),k(r,H,Oe),H!==z&&v(r,H,z,s,Oe,d),++D<=--_&&k(r,V,l),V!==M&&v(r,V,M,s,l,d),M.dom!=null&&(l=M.dom),I++,$--,H=t[$],M=i[_],V=t[I],z=i[D];for(;$>=I&&_>=D&&H.key===M.key;)H!==M&&v(r,H,M,s,l,d),M.dom!=null&&(l=M.dom),$--,_--,H=t[$],M=i[_];if(D>_)Z(r,t,I,$+1);else if(I>$)u(r,i,D,_+1,s,l,d);else{var wr=l,ot=_-D+1,oe=new Array(ot),Le=0,L=0,ze=2147483647,Re=0,we,_e;for(L=0;L=D;L--){we==null&&(we=G(t,I,$+1)),M=i[L];var fe=we[M.key];fe!=null&&(ze=fe=D;L--)z=i[L],oe[L-D]===-1?y(r,z,s,d,l):_e[Le]===L-D?Le--:k(r,z,l),z.dom!=null&&(l=i[L].dom);else for(L=_;L>=D;L--)z=i[L],oe[L-D]===-1&&y(r,z,s,d,l),z.dom!=null&&(l=i[L].dom)}}else{var ve=t.lengthve&&Z(r,t,D,t.length),i.length>ve&&u(r,i,D,i.length,s,l,d)}}}function v(r,t,i,s,l,d){var C=t.tag,j=i.tag;if(C===j){if(i.state=t.state,i.events=t.events,yr(i,t))return;if(typeof C=="string")switch(i.attrs!=null&&Me(i.attrs,i,s),C){case"#":A(t,i);break;case"<":W(r,t,i,d,l);break;case"[":R(r,t,i,s,l,d);break;default:P(t,i,s,d)}else B(r,t,i,s,l,d)}else de(r,t),y(r,i,s,d,l)}function A(r,t){r.children.toString()!==t.children.toString()&&(r.dom.nodeValue=t.children),t.dom=r.dom}function W(r,t,i,s,l){t.children!==i.children?(ft(r,t),g(r,i,s,l)):(i.dom=t.dom,i.domSize=t.domSize,i.instance=t.instance)}function R(r,t,i,s,l,d){S(r,t.children,i.children,s,l,d);var C=0,j=i.children;if(i.dom=null,j!=null){for(var D=0;D>>1)+(s>>>1)+(i&s&1);r[t[j]]0&&(Q[l]=t[i-1]),t[i]=l)}for(i=t.length,s=t[i-1];i-- >0;)t[i]=s,s=Q[s];return Q.length=0,t}function J(r,t,i){for(;t-1||r.attrs!=null&&r.attrs.is||t!=="href"&&t!=="list"&&t!=="form"&&t!=="width"&&t!=="height")&&t in r.dom}var gr=/[A-Z]/g;function dr(r){return"-"+r.toLowerCase()}function Pe(r){return r[0]==="-"&&r[1]==="-"?r:r==="cssFloat"?"float":r.replace(gr,dr)}function ut(r,t,i){if(t!==i)if(i==null)r.style.cssText="";else if(typeof i!="object")r.style.cssText=i;else if(t==null||typeof t!="object"){r.style.cssText="";for(var s in i){var l=i[s];l!=null&&r.style.setProperty(Pe(s),String(l))}}else{for(var s in i){var l=i[s];l!=null&&(l=String(l))!==String(t[s])&&r.style.setProperty(Pe(s),l)}for(var s in t)t[s]!=null&&i[s]==null&&r.style.removeProperty(Pe(s))}}function Ne(){this._=a}Ne.prototype=Object.create(null),Ne.prototype.handleEvent=function(r){var t=this["on"+r.type],i;typeof t=="function"?i=t.call(r.currentTarget,r):typeof t.handleEvent=="function"&&t.handleEvent(r),this._&&r.redraw!==!1&&(0,this._)(),i===!1&&(r.preventDefault(),r.stopPropagation())};function ct(r,t,i){if(r.events!=null){if(r.events[t]===i)return;i!=null&&(typeof i=="function"||typeof i=="object")?(r.events[t]==null&&r.dom.addEventListener(t.slice(2),r.events,!1),r.events[t]=i):(r.events[t]!=null&&r.dom.removeEventListener(t.slice(2),r.events,!1),r.events[t]=void 0)}else i!=null&&(typeof i=="function"||typeof i=="object")&&(r.events=new Ne,r.dom.addEventListener(t.slice(2),r.events,!1),r.events[t]=i)}function Ae(r,t,i){typeof r.oninit=="function"&&c.call(r.oninit,t),typeof r.oncreate=="function"&&i.push(c.bind(r.oncreate,t))}function Me(r,t,i){typeof r.onupdate=="function"&&i.push(c.bind(r.onupdate,t))}function yr(r,t){do{if(r.attrs!=null&&typeof r.attrs.onbeforeupdate=="function"){var i=c.call(r.attrs.onbeforeupdate,r,t);if(i!==void 0&&!i)break}if(typeof r.tag!="string"&&typeof r.state.onbeforeupdate=="function"){var i=c.call(r.state.onbeforeupdate,r,t);if(i!==void 0&&!i)break}return!1}while(!1);return r.dom=t.dom,r.domSize=t.domSize,r.instance=t.instance,r.attrs=t.attrs,r.children=t.children,r.text=t.text,!0}return function(r,t,i){if(!r)throw new TypeError("Ensure the DOM element being passed to m.route/m.mount/m.render is not undefined.");var s=[],l=o(),d=r.namespaceURI;r.vnodes==null&&(r.textContent=""),t=ue.normalizeChildren(Array.isArray(t)?t:[t]);var C=a;try{a=typeof i=="function"?i:void 0,S(r,r.vnodes,t,s,null,d==="http://www.w3.org/1999/xhtml"?void 0:d)}finally{a=C}r.vnodes=t,l!=null&&o()!==l&&typeof l.focus=="function"&&l.focus();for(var j=0;j{"use strict";jt.exports=St()(window)});var Nt=O((zn,It)=>{"use strict";var Pt=te();It.exports=function(e,n,a){var f=[],m=!1,h=!1;function c(){if(m)throw new Error("Nested m.redraw.sync() call");m=!0;for(var y=0;y=0&&(f.splice(b,2),e(y,[],o)),w!=null&&(f.push(y,w),e(y,Pt(w),o))}return{mount:u,redraw:o}}});var xe=O((Rn,At)=>{"use strict";var zr=Ke();At.exports=Nt()(zr,requestAnimationFrame,console)});var Qe=O((_n,Mt)=>{"use strict";Mt.exports=function(e){if(Object.prototype.toString.call(e)!=="[object Object]")return"";var n=[];for(var a in e)f(a,e[a]);return n.join("&");function f(m,h){if(Array.isArray(h))for(var c=0;c{"use strict";vt.exports=Object.assign||function(e,n){n&&Object.keys(n).forEach(function(a){e[a]=n[a]})}});var Ee=O((Bn,Ot)=>{"use strict";var Rr=Qe(),_r=ke();Ot.exports=function(e,n){if(/:([^\/\.-]+)(\.{3})?:/.test(e))throw new SyntaxError("Template parameter names *must* be separated");if(n==null)return e;var a=e.indexOf("?"),f=e.indexOf("#"),m=f<0?e.length:f,h=a<0?m:a,c=e.slice(0,h),o={};_r(o,n);var u=c.replace(/:([^\/\.-]+)(\.{3})?/g,function(x,q,S){return delete o[q],n[q]==null?x:S?n[q]:encodeURIComponent(String(n[q]))}),y=u.indexOf("?"),w=u.indexOf("#"),b=w<0?u.length:w,g=y<0?b:y,p=u.slice(0,g);a>=0&&(p+=e.slice(a,m)),y>=0&&(p+=(a<0?"?":"&")+u.slice(y,b));var E=Rr(o);return E&&(p+=(a<0&&y<0?"?":"&")+E),f>=0&&(p+=e.slice(f)),w>=0&&(p+=(f<0?"":"&")+u.slice(w)),p}});var zt=O((Hn,Lt)=>{"use strict";var Ur=Ee();Lt.exports=function(e,n,a){var f=0;function m(o){return new n(o)}m.prototype=n.prototype,m.__proto__=n;function h(o){return function(u,y){typeof u!="string"?(y=u,u=u.url):y==null&&(y={});var w=new n(function(E,x){o(Ur(u,y.params),y,function(q){if(typeof y.type=="function")if(Array.isArray(q))for(var S=0;S=200&&R.target.status<300||R.target.status===304||/^file:\/\//i.test(o),B=R.target.response,G;if(E==="json"?!R.target.responseType&&typeof u.extract!="function"&&(B=JSON.parse(R.target.responseText)):(!E||E==="text")&&B==null&&(B=R.target.responseText),typeof u.extract=="function"?(B=u.extract(R.target,u),P=!0):typeof u.deserialize=="function"&&(B=u.deserialize(B)),P)y(B);else{try{G=R.target.responseText}catch(re){G=B}var Q=new Error(G);Q.code=R.target.status,Q.response=B,w(Q)}}catch(re){w(re)}},typeof u.config=="function"&&(x=u.config(x,u,o)||x,x!==S&&(v=x.abort,x.abort=function(){q=!0,v.call(this)})),g==null?x.send():typeof u.serialize=="function"?x.send(u.serialize(g)):g instanceof e.FormData?x.send(g):x.send(JSON.stringify(g))}),jsonp:h(function(o,u,y,w){var b=u.callbackName||"_mithril_"+Math.round(Math.random()*1e16)+"_"+f++,g=e.document.createElement("script");e[b]=function(p){delete e[b],g.parentNode.removeChild(g),y(p)},g.onerror=function(){delete e[b],g.parentNode.removeChild(g),w(new Error("JSONP request failed"))},g.src=o+(o.indexOf("?")<0?"?":"&")+encodeURIComponent(u.callbackKey||"callback")+"="+encodeURIComponent(b),e.document.documentElement.appendChild(g)})}}});var _t=O((Fn,Rt)=>{"use strict";var Br=Ve(),Hr=xe();Rt.exports=zt()(window,Br,Hr.redraw)});var We=O(($n,Ut)=>{"use strict";Ut.exports=function(e){if(e===""||e==null)return{};e.charAt(0)==="?"&&(e=e.slice(1));for(var n=e.split("&"),a={},f={},m=0;m-1&&u.pop();for(var w=0;w{"use strict";var Fr=We();Bt.exports=function(e){var n=e.indexOf("?"),a=e.indexOf("#"),f=a<0?e.length:a,m=n<0?f:n,h=e.slice(0,m).replace(/\/{2,}/g,"/");return h?(h[0]!=="/"&&(h="/"+h),h.length>1&&h[h.length-1]==="/"&&(h=h.slice(0,-1))):h="/",{path:h,params:n<0?{}:Fr(e.slice(n+1,f))}}});var Ft=O((Kn,Ht)=>{"use strict";var $r=De();Ht.exports=function(e){var n=$r(e),a=Object.keys(n.params),f=[],m=new RegExp("^"+n.path.replace(/:([^\/.-]+)(\.{3}|\.(?!\.)|-)?|[\\^$*+.()|\[\]{}]/g,function(h,c,o){return c==null?"\\"+h:(f.push({k:c,r:o==="..."}),o==="..."?"(.*)":o==="."?"([^/]+)\\.":"([^/]+)"+(o||""))})+"$");return function(h){for(var c=0;c{"use strict";var Vr=te(),Kr=He(),Qr=Ve(),kr=Ee(),Vt=De(),Wr=Ft(),Kt=ke(),Je={};$t.exports=function(e,n){var a;function f(b,g,p){if(b=kr(b,g),a!=null){a();var E=p?p.state:null,x=p?p.title:null;p&&p.replace?e.history.replaceState(E,x,w.prefix+b):e.history.pushState(E,x,w.prefix+b)}else e.location.href=w.prefix+b}var m=Je,h,c,o,u,y=w.SKIP={};function w(b,g,p){if(b==null)throw new Error("Ensure the DOM element that was passed to `m.route` is not undefined");var E=0,x=Object.keys(p).map(function(P){if(P[0]!=="/")throw new SyntaxError("Routes must start with a `/`");if(/:([^\/\.-]+)(\.{3})?:/.test(P))throw new SyntaxError("Route parameter names must be separated with either `/`, `.`, or `-`");return{route:P,component:p[P],check:Wr(P)}}),q=typeof setImmediate=="function"?setImmediate:setTimeout,S=Qr.resolve(),v=!1,A;if(a=null,g!=null){var W=Vt(g);if(!x.some(function(P){return P.check(W)}))throw new ReferenceError("Default route doesn't match any known routes")}function R(){v=!1;var P=e.location.hash;w.prefix[0]!=="#"&&(P=e.location.search+P,w.prefix[0]!=="?"&&(P=e.location.pathname+P,P[0]!=="/"&&(P="/"+P)));var B=P.concat().replace(/(?:%[a-f89][a-f0-9])+/gim,decodeURIComponent).slice(w.prefix.length),G=Vt(B);Kt(G.params,e.history.state);function Q(){if(B===g)throw new Error("Could not resolve default route "+g);f(g,null,{replace:!0})}re(0);function re(J){for(;J{"use strict";var Jr=xe();kt.exports=Qt()(window,Jr)});var Gt=O((Wn,Jt)=>{"use strict";var Te=Tt(),Zt=_t(),Yt=xe(),F=function(){return Te.apply(this,arguments)};F.m=Te;F.trust=Te.trust;F.fragment=Te.fragment;F.mount=Yt.mount;F.route=Wt();F.render=Ke();F.redraw=Yt.redraw;F.request=Zt.request;F.jsonp=Zt.jsonp;F.parseQueryString=We();F.buildQueryString=Qe();F.parsePathname=De();F.buildPathname=Ee();F.vnode=te();F.PromisePolyfill=$e();Jt.exports=F});var N=Sr(Gt());var Zr=(e,n)=>n.some(a=>e instanceof a),Xt,er;function Yr(){return Xt||(Xt=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Gr(){return er||(er=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var tr=new WeakMap,Ze=new WeakMap,rr=new WeakMap,Ye=new WeakMap,Ge=new WeakMap;function Xr(e){let n=new Promise((a,f)=>{let m=()=>{e.removeEventListener("success",h),e.removeEventListener("error",c)},h=()=>{a(X(e.result)),m()},c=()=>{f(e.error),m()};e.addEventListener("success",h),e.addEventListener("error",c)});return n.then(a=>{a instanceof IDBCursor&&tr.set(a,e)}).catch(()=>{}),Ge.set(n,e),n}function en(e){if(Ze.has(e))return;let n=new Promise((a,f)=>{let m=()=>{e.removeEventListener("complete",h),e.removeEventListener("error",c),e.removeEventListener("abort",c)},h=()=>{a(),m()},c=()=>{f(e.error||new DOMException("AbortError","AbortError")),m()};e.addEventListener("complete",h),e.addEventListener("error",c),e.addEventListener("abort",c)});Ze.set(e,n)}var Xe={get(e,n,a){if(e instanceof IDBTransaction){if(n==="done")return Ze.get(e);if(n==="objectStoreNames")return e.objectStoreNames||rr.get(e);if(n==="store")return a.objectStoreNames[1]?void 0:a.objectStore(a.objectStoreNames[0])}return X(e[n])},set(e,n,a){return e[n]=a,!0},has(e,n){return e instanceof IDBTransaction&&(n==="done"||n==="store")?!0:n in e}};function nr(e){Xe=e(Xe)}function tn(e){return e===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(n,...a){let f=e.call(qe(this),n,...a);return rr.set(f,n.sort?n.sort():[n]),X(f)}:Gr().includes(e)?function(...n){return e.apply(qe(this),n),X(tr.get(this))}:function(...n){return X(e.apply(qe(this),n))}}function rn(e){return typeof e=="function"?tn(e):(e instanceof IDBTransaction&&en(e),Zr(e,Yr())?new Proxy(e,Xe):e)}function X(e){if(e instanceof IDBRequest)return Xr(e);if(Ye.has(e))return Ye.get(e);let n=rn(e);return n!==e&&(Ye.set(e,n),Ge.set(n,e)),n}var qe=e=>Ge.get(e);function ir(e,n,{blocked:a,upgrade:f,blocking:m,terminated:h}={}){let c=indexedDB.open(e,n),o=X(c);return f&&c.addEventListener("upgradeneeded",u=>{f(X(c.result),u.oldVersion,u.newVersion,X(c.transaction))}),a&&c.addEventListener("blocked",()=>a()),o.then(u=>{h&&u.addEventListener("close",()=>h()),m&&u.addEventListener("versionchange",()=>m())}).catch(()=>{}),o}var nn=["get","getKey","getAll","getAllKeys","count"],an=["put","add","delete","clear"],et=new Map;function ar(e,n){if(!(e instanceof IDBDatabase&&!(n in e)&&typeof n=="string"))return;if(et.get(n))return et.get(n);let a=n.replace(/FromIndex$/,""),f=n!==a,m=an.includes(a);if(!(a in(f?IDBIndex:IDBObjectStore).prototype)||!(m||nn.includes(a)))return;let h=async function(c,...o){let u=this.transaction(c,m?"readwrite":"readonly"),y=u.store;return f&&(y=y.index(o.shift())),(await Promise.all([y[a](...o),m&&u.done]))[0]};return et.set(n,h),h}nr(e=>({...e,get:(n,a,f)=>ar(n,a)||e.get(n,a,f),has:(n,a)=>!!ar(n,a)||e.has(n,a)}));function pe(e){if(e===null||e===!0||e===!1)return NaN;var n=Number(e);return isNaN(n)?n:n<0?Math.ceil(n):Math.floor(n)}function Y(e,n){if(n.length1?"s":"")+" required, but only "+n.length+" present")}function se(e){Y(1,arguments);var n=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&n==="[object Date]"?new Date(e.getTime()):typeof e=="number"||n==="[object Number]"?new Date(e):((typeof e=="string"||n==="[object String]")&&typeof console!="undefined"&&(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://git.io/fjule"),console.warn(new Error().stack)),new Date(NaN))}function tt(e,n){Y(2,arguments);var a=se(e).getTime(),f=pe(n);return new Date(a+f)}var Ce=6e4;function sr(e){return e.getTime()%Ce}function rt(e){var n=new Date(e.getTime()),a=Math.ceil(n.getTimezoneOffset());n.setSeconds(0,0);var f=a>0,m=f?(Ce+sr(n))%Ce:sr(n);return a*Ce+m}function nt(e){Y(1,arguments);var n=se(e);return!isNaN(n)}function it(e,n){Y(2,arguments);var a=pe(n);return tt(e,-a)}function ee(e,n){for(var a=e<0?"-":"",f=Math.abs(e).toString();f.length0?a:1-a;return ee(n==="yy"?f%100:f,n.length)},M:function(e,n){var a=e.getUTCMonth();return n==="M"?String(a+1):ee(a+1,2)},d:function(e,n){return ee(e.getUTCDate(),n.length)},a:function(e,n){var a=e.getUTCHours()/12>=1?"pm":"am";switch(n){case"a":case"aa":return a.toUpperCase();case"aaa":return a;case"aaaaa":return a[0];case"aaaa":default:return a==="am"?"a.m.":"p.m."}},h:function(e,n){return ee(e.getUTCHours()%12||12,n.length)},H:function(e,n){return ee(e.getUTCHours(),n.length)},m:function(e,n){return ee(e.getUTCMinutes(),n.length)},s:function(e,n){return ee(e.getUTCSeconds(),n.length)},S:function(e,n){var a=n.length,f=e.getUTCMilliseconds(),m=Math.floor(f*Math.pow(10,a-3));return ee(m,n.length)}},fr=sn;var fn=/(\w)\1*|''|'(''|[^'])+('|$)|./g,ln=/^'([^]*?)'?$/,un=/''/g,cn=/[a-zA-Z]/;function at(e,n){Y(2,arguments);var a=String(n),f=se(e);if(!nt(f))throw new RangeError("Invalid time value");var m=rt(f),h=it(f,m),c=a.match(fn).map(function(o){if(o==="''")return"'";var u=o[0];if(u==="'")return on(o);var y=fr[u];if(y)return y(h,o,null,{});if(u.match(cn))throw new RangeError("Format string contains an unescaped latin alphabet character `"+u+"`");return o}).join("");return c}function on(e){return e.match(ln)[1].replace(un,"'")}var st=ir("minoteaur",1,{upgrade:(e,n)=>{n<1&&e.createObjectStore("drafts")},blocking:()=>{window.location.reload()}});st.then(e=>{window.idb=e});var K={showingSearchDialog:!1,searchResults:[],searchError:null,searchQuery:""},hn=([e,...n])=>e.toLowerCase()+n.join(""),pn=([e,...n])=>e.toUpperCase()+n.join(""),mn=e=>e.split(/[ _]/).map(hn).join("_"),gn=e=>e.split(/[ _]/).map(pn).join(" "),me=(e,n)=>{let a=`/${encodeURIComponent(mn(e))}`;return n&&(a+="/"+n),a},dn=e=>{window.lastError=e,console.warn(e);let n=`HTTP error ${e.code}`;e.message!==null&&(n+=" "+e.message),K.searchError=n},yn=e=>{let n=e.target.value;K.searchQuery=n,N.default.request({url:"/api/search",params:{q:n}}).then(a=>{typeof a=="string"?(console.warn(a),K.searchError=a):(K.searchResults=a,K.searchError=null)},dn)},ce=gn(decodeURIComponent(/^\/([^/]+)/.exec(location.pathname)[1]).replace(/\+/g," ")),wn=e=>{if(e.code==="Enter"){let n=K.searchResults.filter(a=>a.page!==ce);n[0]&&(location.href=me(n[0].page))}},bn={view:()=>N.default(".dialog.search",[N.default("h1","Search"),N.default("input[type=search]",{placeholder:"Query",oninput:yn,onkeydown:wn,value:K.searchQuery,oncreate:({dom:e})=>e.focus()}),K.searchError&&N.default(".error",K.searchError),N.default("ul",K.searchResults.map(e=>N.default("li",[N.default(".flex-space",[N.default("a.wikilink",{href:me(e.page)},e.page),N.default("",e.rank.toFixed(3))]),N.default("",e.snippet.map(n=>n[0]?N.default("span.highlight",n[1]):n[1]))])))])},xn={view:()=>N.default("",K.showingSearchDialog?N.default(bn):null)},lr=document.createElement("div");document.querySelector("main").insertBefore(lr,document.querySelector(".header"));N.default.mount(lr,xn);var En=document.querySelector("nav .search");En.addEventListener("click",e=>{K.showingSearchDialog=!K.showingSearchDialog,e.preventDefault(),N.default.redraw()});document.body.addEventListener("keydown",e=>{e.target===document.body&&(e.key==="e"?location.pathname=me(ce,"edit"):e.key==="v"?location.pathname=me(ce):e.key==="r"?location.pathname=me(ce,"revisions"):e.key==="/"&&(K.showingSearchDialog=!K.showingSearchDialog,e.preventDefault(),N.default.redraw()))});var Dn=(e,n=250)=>{let a;return()=>{clearTimeout(a),a=setTimeout(e,n)}},ur=e=>at(e,"yyyy-MM-dd HH:mm:ss"),Tn=e=>{let n=0;for(let a of e.split(/\s+/))/[^#*+>|`-]/.test(a)&&(n+=1);return n},qn=e=>e.split(` -`).length,T=document.querySelector(".edit-form textarea");if(T){let e={keypresses:0,draftSelected:!1},n=document.createElement("div");document.querySelector(".sidebar").appendChild(n);let a=Infinity,f=()=>{let g=document.body.scrollTop;(T.scrollHeight+2!=T.style.height.slice(0,-2)||a>T.value.length)&&(T.style.height=0,T.style.height=T.scrollHeight+2,document.body.scrollTop=g),a=T.value.length},m=parseInt(document.querySelector("input[name=last-edit]").value),h=T.value,c=()=>{!e.initialDraft||(e.draftSelected=!0,T.value=e.initialDraft.text,f())},o=()=>{console.log("server value swapped in, allegedly?"),e.draftSelected=!1,console.log(T.value,h),T.value=h,f()};st.then(g=>g.get("drafts",ce)).then(g=>{e.initialDraft=g,console.log("loaded memetic/beemetic entity ",g),g.ts>m&&c(),N.default.redraw()});let u={view:()=>e.initialDraft==null?"No draft":[N.default(e.draftSelected?".selected":"",{onclick:c},`Draft from ${ur(e.initialDraft.ts)}`),m>0&&N.default(e.draftSelected?"":".selected",{onclick:o},`Page from ${ur(m)}`)]},y={view:()=>[N.default("",`${e.chars} chars`),N.default("",`${e.words} words`),N.default("",`${e.lines} lines`),N.default("",`${e.keypresses} keypresses`),N.default(u)]},w=g=>{e.words=Tn(g),e.lines=qn(g),e.chars=g.length};w(T.value),N.default.mount(n,y),T.addEventListener("keypress",g=>{let p=T.selectionStart,E=T.selectionEnd;if(p!==E)return;let x=` -`+T.value.substr(0,p),q=x.lastIndexOf(` -`)+1,S=p+(T.value.substr(p)+` +(()=>{var xr=Object.create,_e=Object.defineProperty,Er=Object.getPrototypeOf,Dr=Object.prototype.hasOwnProperty,Tr=Object.getOwnPropertyNames,qr=Object.getOwnPropertyDescriptor;var Cr=e=>_e(e,"__esModule",{value:!0});var M=(e,n)=>()=>(n||(n={exports:{}},e(n.exports,n)),n.exports);var Sr=(e,n,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let l of Tr(n))!Dr.call(e,l)&&l!=="default"&&_e(e,l,{get:()=>n[l],enumerable:!(a=qr(n,l))||a.enumerable});return e},jr=e=>e&&e.__esModule?e:Sr(Cr(_e(e!=null?xr(Er(e)):{},"default",{value:e,enumerable:!0})),e);var te=M((jn,pt)=>{"use strict";function ae(e,n,a,l,m,h){return{tag:e,key:n,attrs:a,children:l,text:m,dom:h,domSize:void 0,state:void 0,events:void 0,instance:void 0}}ae.normalize=function(e){return Array.isArray(e)?ae("[",void 0,void 0,ae.normalizeChildren(e),void 0,void 0):e==null||typeof e=="boolean"?null:typeof e=="object"?e:ae("#",void 0,void 0,String(e),void 0,void 0)};ae.normalizeChildren=function(e){var n=[];if(e.length){for(var a=e[0]!=null&&e[0].key!=null,l=1;l{"use strict";var Ir=te();ht.exports=function(){var e=arguments[this],n=this+1,a;if(e==null?e={}:(typeof e!="object"||e.tag!=null||Array.isArray(e))&&(e={},n=this),arguments.length===n+1)a=arguments[n],Array.isArray(a)||(a=[a]);else for(a=[];n{"use strict";var gt=te(),Pr=Fe(),Nr=/(?:(^|#|\.)([^#\.\[\]]+))|(\[(.+?)(?:\s*=\s*("|'|)((?:\\["'\]]|.)*?)\5)?\])/g,dt={},ue={}.hasOwnProperty;function yt(e){for(var n in e)if(ue.call(e,n))return!1;return!0}function Ar(e){for(var n,a="div",l=[],m={};n=Nr.exec(e);){var h=n[1],c=n[2];if(h===""&&c!=="")a=c;else if(h==="#")m.id=c;else if(h===".")l.push(c);else if(n[3][0]==="["){var o=n[6];o&&(o=o.replace(/\\(["'])/g,"$1").replace(/\\\\/g,"\\")),n[4]==="class"?l.push(o):m[n[4]]=o===""?o:o||!0}}return l.length>0&&(m.className=l.join(" ")),dt[e]={tag:a,attrs:m}}function Mr(e,n){var a=n.attrs,l=gt.normalizeChildren(n.children),m=ue.call(a,"class"),h=m?a.class:a.className;if(n.tag=e.tag,n.attrs=null,n.children=void 0,!yt(e.attrs)&&!yt(a)){var c={};for(var o in a)ue.call(a,o)&&(c[o]=a[o]);a=c}for(var o in e.attrs)ue.call(e.attrs,o)&&o!=="className"&&!ue.call(a,o)&&(a[o]=e.attrs[o]);(h!=null||e.attrs.className!=null)&&(a.className=h!=null?e.attrs.className!=null?String(e.attrs.className)+" "+String(h):h:e.attrs.className!=null?e.attrs.className:null),m&&(a.class=null);for(var o in a)if(ue.call(a,o)&&o!=="key"){n.attrs=a;break}return Array.isArray(l)&&l.length===1&&l[0]!=null&&l[0].tag==="#"?n.text=l[0].children:n.children=l,n}function vr(e){if(e==null||typeof e!="string"&&typeof e!="function"&&typeof e.view!="function")throw Error("The selector must be either a string or a component.");var n=Pr.apply(1,arguments);return typeof e=="string"&&(n.children=gt.normalizeChildren(n.children),e!=="[")?Mr(dt[e]||Ar(e),n):(n.tag=e,n)}mt.exports=vr});var bt=M((Nn,wt)=>{"use strict";var Or=te();wt.exports=function(e){return e==null&&(e=""),Or("<",void 0,void 0,e,void 0,void 0)}});var Et=M((An,xt)=>{"use strict";var Lr=te(),zr=Fe();xt.exports=function(){var e=zr.apply(0,arguments);return e.tag="[",e.children=Lr.normalizeChildren(e.children),e}});var Tt=M((Mn,Dt)=>{"use strict";var He=Be();He.trust=bt();He.fragment=Et();Dt.exports=He});var $e=M((vn,qt)=>{"use strict";var _=function(e){if(!(this instanceof _))throw new Error("Promise must be called with `new`");if(typeof e!="function")throw new TypeError("executor must be a function");var n=this,a=[],l=[],m=u(a,!0),h=u(l,!1),c=n._instance={resolvers:a,rejectors:l},o=typeof setImmediate=="function"?setImmediate:setTimeout;function u(w,x){return function T(y){var E;try{if(x&&y!=null&&(typeof y=="object"||typeof y=="function")&&typeof(E=y.then)=="function"){if(y===n)throw new TypeError("Promise can't be resolved w/ itself");d(E.bind(y))}else o(function(){!x&&w.length===0&&console.error("Possible unhandled promise rejection:",y);for(var p=0;p0||E(p)}}var y=T(h);try{w(T(m),y)}catch(E){y(E)}}d(e)};_.prototype.then=function(e,n){var a=this,l=a._instance;function m(u,d,w,x){d.push(function(T){if(typeof u!="function")w(T);else try{h(u(T))}catch(y){c&&c(y)}}),typeof l.retry=="function"&&x===l.state&&l.retry()}var h,c,o=new _(function(u,d){h=u,c=d});return m(e,l.resolvers,h,!0),m(n,l.rejectors,c,!1),o};_.prototype.catch=function(e){return this.then(null,e)};_.prototype.finally=function(e){return this.then(function(n){return _.resolve(e()).then(function(){return n})},function(n){return _.resolve(e()).then(function(){return _.reject(n)})})};_.resolve=function(e){return e instanceof _?e:new _(function(n){n(e)})};_.reject=function(e){return new _(function(n,a){a(e)})};_.all=function(e){return new _(function(n,a){var l=e.length,m=0,h=[];if(e.length===0)n([]);else for(var c=0;c{"use strict";var pe=$e();typeof window!="undefined"?(typeof window.Promise=="undefined"?window.Promise=pe:window.Promise.prototype.finally||(window.Promise.prototype.finally=pe.prototype.finally),be.exports=window.Promise):typeof global!="undefined"?(typeof global.Promise=="undefined"?global.Promise=pe:global.Promise.prototype.finally||(global.Promise.prototype.finally=pe.prototype.finally),be.exports=global.Promise):be.exports=pe});var St=M((Ln,Ct)=>{"use strict";var ce=te();Ct.exports=function(e){var n=e&&e.document,a,l={svg:"http://www.w3.org/2000/svg",math:"http://www.w3.org/1998/Math/MathML"};function m(r){return r.attrs&&r.attrs.xmlns||l[r.tag]}function h(r,t){if(r.state!==t)throw new Error("`vnode.state` must not be modified")}function c(r){var t=r.state;try{return this.apply(t,arguments)}finally{h(r,t)}}function o(){try{return n.activeElement}catch(r){return null}}function u(r,t,i,s,f,g,j){for(var I=i;I'+t.children+"",g=g.firstChild):g.innerHTML=t.children,t.dom=g.firstChild,t.domSize=g.childNodes.length,t.instance=[];for(var j=n.createDocumentFragment(),I;I=g.firstChild;)t.instance.push(I),j.appendChild(I);ne(r,j,s)}function y(r,t,i,s,f){var g=n.createDocumentFragment();if(t.children!=null){var j=t.children;u(g,j,0,j.length,i,null,s)}t.dom=g.firstChild,t.domSize=g.childNodes.length,ne(r,g,f)}function E(r,t,i,s,f){var g=t.tag,j=t.attrs,I=j&&j.is;s=m(t)||s;var D=s?I?n.createElementNS(s,g,{is:I}):n.createElementNS(s,g):I?n.createElement(g,{is:I}):n.createElement(g);if(t.dom=D,j!=null&&or(t,j,s),ne(r,D,f),!ie(t)&&(t.text!=null&&(t.text!==""?D.textContent=t.text:t.children=[ce("#",void 0,void 0,t.text,void 0,void 0)]),t.children!=null)){var N=t.children;u(D,N,0,N.length,i,null,s),t.tag==="select"&&j!=null&&hr(t,j)}}function p(r,t){var i;if(typeof r.tag.view=="function"){if(r.state=Object.create(r.tag),i=r.state.view,i.$$reentrantLock$$!=null)return;i.$$reentrantLock$$=!0}else{if(r.state=void 0,i=r.tag,i.$$reentrantLock$$!=null)return;i.$$reentrantLock$$=!0,r.state=r.tag.prototype!=null&&typeof r.tag.prototype.view=="function"?new r.tag(r):r.tag(r)}if(Ae(r.state,r,t),r.attrs!=null&&Ae(r.attrs,r,t),r.instance=ce.normalize(c.call(r.state.view,r)),r.instance===r)throw Error("A view cannot return the vnode it received as argument");i.$$reentrantLock$$=null}function b(r,t,i,s,f){p(t,i),t.instance!=null?(d(r,t.instance,i,s,f),t.dom=t.instance.dom,t.domSize=t.dom!=null?t.instance.domSize:0):t.domSize=0}function S(r,t,i,s,f,g){if(!(t===i||t==null&&i==null))if(t==null||t.length===0)u(r,i,0,i.length,s,f,g);else if(i==null||i.length===0)Y(r,t,0,t.length);else{var j=t[0]!=null&&t[0].key!=null,I=i[0]!=null&&i[0].key!=null,D=0,N=0;if(!j)for(;N=N&&U>=D&&(B=t[V],A=i[U],B.key===A.key);)B!==A&&O(r,B,A,s,f,g),A.dom!=null&&(f=A.dom),V--,U--;for(;V>=N&&U>=D&&(K=t[N],z=i[D],K.key===z.key);)N++,D++,K!==z&&O(r,K,z,s,Z(t,N,f),g);for(;V>=N&&U>=D&&!(D===U||K.key!==A.key||B.key!==z.key);)Oe=Z(t,N,f),J(r,B,Oe),B!==z&&O(r,B,z,s,Oe,g),++D<=--U&&J(r,K,f),K!==A&&O(r,K,A,s,f,g),A.dom!=null&&(f=A.dom),N++,V--,B=t[V],A=i[U],K=t[N],z=i[D];for(;V>=N&&U>=D&&B.key===A.key;)B!==A&&O(r,B,A,s,f,g),A.dom!=null&&(f=A.dom),V--,U--,B=t[V],A=i[U];if(D>U)Y(r,t,N,V+1);else if(N>V)u(r,i,D,U+1,s,f,g);else{var br=f,ot=U-D+1,oe=new Array(ot),Le=0,L=0,ze=2147483647,Re=0,we,Ue;for(L=0;L=D;L--){we==null&&(we=W(t,N,V+1)),A=i[L];var fe=we[A.key];fe!=null&&(ze=fe=D;L--)z=i[L],oe[L-D]===-1?d(r,z,s,g,f):Ue[Le]===L-D?Le--:J(r,z,f),z.dom!=null&&(f=i[L].dom);else for(L=U;L>=D;L--)z=i[L],oe[L-D]===-1&&d(r,z,s,g,f),z.dom!=null&&(f=i[L].dom)}}else{var ve=t.lengthve&&Y(r,t,D,t.length),i.length>ve&&u(r,i,D,i.length,s,f,g)}}}function O(r,t,i,s,f,g){var j=t.tag,I=i.tag;if(j===I){if(i.state=t.state,i.events=t.events,wr(i,t))return;if(typeof j=="string")switch(i.attrs!=null&&Me(i.attrs,i,s),j){case"#":$(t,i);break;case"<":Q(r,t,i,g,f);break;case"[":v(r,t,i,s,f,g);break;default:C(t,i,s,g)}else R(r,t,i,s,f,g)}else de(r,t),d(r,i,s,g,f)}function $(r,t){r.children.toString()!==t.children.toString()&&(r.dom.nodeValue=t.children),t.dom=r.dom}function Q(r,t,i,s,f){t.children!==i.children?(lt(r,t),T(r,i,s,f)):(i.dom=t.dom,i.domSize=t.domSize,i.instance=t.instance)}function v(r,t,i,s,f,g){S(r,t.children,i.children,s,f,g);var j=0,I=i.children;if(i.dom=null,I!=null){for(var D=0;D>>1)+(s>>>1)+(i&s&1);r[t[I]]0&&(F[f]=t[i-1]),t[i]=f)}for(i=t.length,s=t[i-1];i-- >0;)t[i]=s,s=F[s];return F.length=0,t}function Z(r,t,i){for(;t-1||r.attrs!=null&&r.attrs.is||t!=="href"&&t!=="list"&&t!=="form"&&t!=="width"&&t!=="height")&&t in r.dom}var dr=/[A-Z]/g;function yr(r){return"-"+r.toLowerCase()}function Pe(r){return r[0]==="-"&&r[1]==="-"?r:r==="cssFloat"?"float":r.replace(dr,yr)}function ut(r,t,i){if(t!==i)if(i==null)r.style.cssText="";else if(typeof i!="object")r.style.cssText=i;else if(t==null||typeof t!="object"){r.style.cssText="";for(var s in i){var f=i[s];f!=null&&r.style.setProperty(Pe(s),String(f))}}else{for(var s in i){var f=i[s];f!=null&&(f=String(f))!==String(t[s])&&r.style.setProperty(Pe(s),f)}for(var s in t)t[s]!=null&&i[s]==null&&r.style.removeProperty(Pe(s))}}function Ne(){this._=a}Ne.prototype=Object.create(null),Ne.prototype.handleEvent=function(r){var t=this["on"+r.type],i;typeof t=="function"?i=t.call(r.currentTarget,r):typeof t.handleEvent=="function"&&t.handleEvent(r),this._&&r.redraw!==!1&&(0,this._)(),i===!1&&(r.preventDefault(),r.stopPropagation())};function ct(r,t,i){if(r.events!=null){if(r.events[t]===i)return;i!=null&&(typeof i=="function"||typeof i=="object")?(r.events[t]==null&&r.dom.addEventListener(t.slice(2),r.events,!1),r.events[t]=i):(r.events[t]!=null&&r.dom.removeEventListener(t.slice(2),r.events,!1),r.events[t]=void 0)}else i!=null&&(typeof i=="function"||typeof i=="object")&&(r.events=new Ne,r.dom.addEventListener(t.slice(2),r.events,!1),r.events[t]=i)}function Ae(r,t,i){typeof r.oninit=="function"&&c.call(r.oninit,t),typeof r.oncreate=="function"&&i.push(c.bind(r.oncreate,t))}function Me(r,t,i){typeof r.onupdate=="function"&&i.push(c.bind(r.onupdate,t))}function wr(r,t){do{if(r.attrs!=null&&typeof r.attrs.onbeforeupdate=="function"){var i=c.call(r.attrs.onbeforeupdate,r,t);if(i!==void 0&&!i)break}if(typeof r.tag!="string"&&typeof r.state.onbeforeupdate=="function"){var i=c.call(r.state.onbeforeupdate,r,t);if(i!==void 0&&!i)break}return!1}while(!1);return r.dom=t.dom,r.domSize=t.domSize,r.instance=t.instance,r.attrs=t.attrs,r.children=t.children,r.text=t.text,!0}return function(r,t,i){if(!r)throw new TypeError("Ensure the DOM element being passed to m.route/m.mount/m.render is not undefined.");var s=[],f=o(),g=r.namespaceURI;r.vnodes==null&&(r.textContent=""),t=ce.normalizeChildren(Array.isArray(t)?t:[t]);var j=a;try{a=typeof i=="function"?i:void 0,S(r,r.vnodes,t,s,null,g==="http://www.w3.org/1999/xhtml"?void 0:g)}finally{a=j}r.vnodes=t,f!=null&&o()!==f&&typeof f.focus=="function"&&f.focus();for(var I=0;I{"use strict";jt.exports=St()(window)});var Nt=M((Rn,It)=>{"use strict";var Pt=te();It.exports=function(e,n,a){var l=[],m=!1,h=!1;function c(){if(m)throw new Error("Nested m.redraw.sync() call");m=!0;for(var d=0;d=0&&(l.splice(x,2),e(d,[],o)),w!=null&&(l.push(d,w),e(d,Pt(w),o))}return{mount:u,redraw:o}}});var xe=M((Un,At)=>{"use strict";var Rr=Ke();At.exports=Nt()(Rr,requestAnimationFrame,console)});var ke=M((_n,Mt)=>{"use strict";Mt.exports=function(e){if(Object.prototype.toString.call(e)!=="[object Object]")return"";var n=[];for(var a in e)l(a,e[a]);return n.join("&");function l(m,h){if(Array.isArray(h))for(var c=0;c{"use strict";vt.exports=Object.assign||function(e,n){n&&Object.keys(n).forEach(function(a){e[a]=n[a]})}});var Ee=M((Bn,Ot)=>{"use strict";var Ur=ke(),_r=Qe();Ot.exports=function(e,n){if(/:([^\/\.-]+)(\.{3})?:/.test(e))throw new SyntaxError("Template parameter names *must* be separated");if(n==null)return e;var a=e.indexOf("?"),l=e.indexOf("#"),m=l<0?e.length:l,h=a<0?m:a,c=e.slice(0,h),o={};_r(o,n);var u=c.replace(/:([^\/\.-]+)(\.{3})?/g,function(p,b,S){return delete o[b],n[b]==null?p:S?n[b]:encodeURIComponent(String(n[b]))}),d=u.indexOf("?"),w=u.indexOf("#"),x=w<0?u.length:w,T=d<0?x:d,y=u.slice(0,T);a>=0&&(y+=e.slice(a,m)),d>=0&&(y+=(a<0?"?":"&")+u.slice(d,x));var E=Ur(o);return E&&(y+=(a<0&&d<0?"?":"&")+E),l>=0&&(y+=e.slice(l)),w>=0&&(y+=(l<0?"":"&")+u.slice(w)),y}});var zt=M((Hn,Lt)=>{"use strict";var Fr=Ee();Lt.exports=function(e,n,a){var l=0;function m(o){return new n(o)}m.prototype=n.prototype,m.__proto__=n;function h(o){return function(u,d){typeof u!="string"?(d=u,u=u.url):d==null&&(d={});var w=new n(function(E,p){o(Fr(u,d.params),d,function(b){if(typeof d.type=="function")if(Array.isArray(b))for(var S=0;S=200&&v.target.status<300||v.target.status===304||/^file:\/\//i.test(o),R=v.target.response,W;if(E==="json"?!v.target.responseType&&typeof u.extract!="function"&&(R=JSON.parse(v.target.responseText)):(!E||E==="text")&&R==null&&(R=v.target.responseText),typeof u.extract=="function"?(R=u.extract(v.target,u),C=!0):typeof u.deserialize=="function"&&(R=u.deserialize(R)),C)d(R);else{try{W=v.target.responseText}catch(re){W=R}var F=new Error(W);F.code=v.target.status,F.response=R,w(F)}}catch(re){w(re)}},typeof u.config=="function"&&(p=u.config(p,u,o)||p,p!==S&&(O=p.abort,p.abort=function(){b=!0,O.call(this)})),T==null?p.send():typeof u.serialize=="function"?p.send(u.serialize(T)):T instanceof e.FormData?p.send(T):p.send(JSON.stringify(T))}),jsonp:h(function(o,u,d,w){var x=u.callbackName||"_mithril_"+Math.round(Math.random()*1e16)+"_"+l++,T=e.document.createElement("script");e[x]=function(y){delete e[x],T.parentNode.removeChild(T),d(y)},T.onerror=function(){delete e[x],T.parentNode.removeChild(T),w(new Error("JSONP request failed"))},T.src=o+(o.indexOf("?")<0?"?":"&")+encodeURIComponent(u.callbackKey||"callback")+"="+encodeURIComponent(x),e.document.documentElement.appendChild(T)})}}});var Ut=M(($n,Rt)=>{"use strict";var Br=Ve(),Hr=xe();Rt.exports=zt()(window,Br,Hr.redraw)});var We=M((Vn,_t)=>{"use strict";_t.exports=function(e){if(e===""||e==null)return{};e.charAt(0)==="?"&&(e=e.slice(1));for(var n=e.split("&"),a={},l={},m=0;m-1&&u.pop();for(var w=0;w{"use strict";var $r=We();Ft.exports=function(e){var n=e.indexOf("?"),a=e.indexOf("#"),l=a<0?e.length:a,m=n<0?l:n,h=e.slice(0,m).replace(/\/{2,}/g,"/");return h?(h[0]!=="/"&&(h="/"+h),h.length>1&&h[h.length-1]==="/"&&(h=h.slice(0,-1))):h="/",{path:h,params:n<0?{}:$r(e.slice(n+1,l))}}});var Ht=M((kn,Bt)=>{"use strict";var Vr=De();Bt.exports=function(e){var n=Vr(e),a=Object.keys(n.params),l=[],m=new RegExp("^"+n.path.replace(/:([^\/.-]+)(\.{3}|\.(?!\.)|-)?|[\\^$*+.()|\[\]{}]/g,function(h,c,o){return c==null?"\\"+h:(l.push({k:c,r:o==="..."}),o==="..."?"(.*)":o==="."?"([^/]+)\\.":"([^/]+)"+(o||""))})+"$");return function(h){for(var c=0;c{"use strict";var Kr=te(),kr=Be(),Qr=Ve(),Wr=Ee(),Vt=De(),Jr=Ht(),Kt=Qe(),Je={};$t.exports=function(e,n){var a;function l(x,T,y){if(x=Wr(x,T),a!=null){a();var E=y?y.state:null,p=y?y.title:null;y&&y.replace?e.history.replaceState(E,p,w.prefix+x):e.history.pushState(E,p,w.prefix+x)}else e.location.href=w.prefix+x}var m=Je,h,c,o,u,d=w.SKIP={};function w(x,T,y){if(x==null)throw new Error("Ensure the DOM element that was passed to `m.route` is not undefined");var E=0,p=Object.keys(y).map(function(C){if(C[0]!=="/")throw new SyntaxError("Routes must start with a `/`");if(/:([^\/\.-]+)(\.{3})?:/.test(C))throw new SyntaxError("Route parameter names must be separated with either `/`, `.`, or `-`");return{route:C,component:y[C],check:Jr(C)}}),b=typeof setImmediate=="function"?setImmediate:setTimeout,S=Qr.resolve(),O=!1,$;if(a=null,T!=null){var Q=Vt(T);if(!p.some(function(C){return C.check(Q)}))throw new ReferenceError("Default route doesn't match any known routes")}function v(){O=!1;var C=e.location.hash;w.prefix[0]!=="#"&&(C=e.location.search+C,w.prefix[0]!=="?"&&(C=e.location.pathname+C,C[0]!=="/"&&(C="/"+C)));var R=C.concat().replace(/(?:%[a-f89][a-f0-9])+/gim,decodeURIComponent).slice(w.prefix.length),W=Vt(R);Kt(W.params,e.history.state);function F(){if(R===T)throw new Error("Could not resolve default route "+T);l(T,null,{replace:!0})}re(0);function re(Z){for(;Z{"use strict";var Zr=xe();Qt.exports=kt()(window,Zr)});var Gt=M((Jn,Jt)=>{"use strict";var Te=Tt(),Zt=Ut(),Yt=xe(),H=function(){return Te.apply(this,arguments)};H.m=Te;H.trust=Te.trust;H.fragment=Te.fragment;H.mount=Yt.mount;H.route=Wt();H.render=Ke();H.redraw=Yt.redraw;H.request=Zt.request;H.jsonp=Zt.jsonp;H.parseQueryString=We();H.buildQueryString=ke();H.parsePathname=De();H.buildPathname=Ee();H.vnode=te();H.PromisePolyfill=$e();Jt.exports=H});var cr=M(()=>{var P=jr(Gt()),st=ir("minoteaur",1,{upgrade:(e,n)=>{n<1&&e.createObjectStore("drafts")},blocking:()=>{window.location.reload()}});st.then(e=>{window.idb=e});var hn=(e,n=250)=>{let a;return(...l)=>{clearTimeout(a),a=setTimeout(e,n,...l)}},k={showingSearchDialog:!1,searchResults:[],searchError:null,searchQuery:""},mn=([e,...n])=>e.toLowerCase()+n.join(""),gn=([e,...n])=>e.toUpperCase()+n.join(""),dn=e=>e.split(/[ _]/).map(mn).join("_"),yn=e=>e.split(/[ _]/).map(gn).join(" "),me=(e,n)=>{let a=`/${encodeURIComponent(dn(e))}`;return n&&(a+="/"+n),a},wn=e=>{window.lastError=e,console.warn(e);let n=`HTTP error ${e.code}`;e.message!==null&&(n+=" "+e.message),k.searchError=n},bn=e=>{let n=e.target.value;k.searchQuery=n,P.default.request({url:"/api/search",params:{q:n}}).then(a=>{typeof a=="string"?(console.warn(a),k.searchError=a):(k.searchResults=a,k.searchError=null)},wn)},le=yn(decodeURIComponent(/^\/([^/]+)/.exec(location.pathname)[1]).replace(/\+/g," "));if(le==="Login")return;var xn=e=>{if(e.code==="Enter"){let n=k.searchResults.filter(a=>a.page!==le);n[0]&&(location.href=me(n[0].page))}},En={view:()=>P.default(".dialog.search",[P.default("h1","Search"),P.default("input[type=search]",{placeholder:"Query",oninput:bn,onkeydown:xn,value:k.searchQuery,oncreate:({dom:e})=>e.focus()}),k.searchError&&P.default(".error",k.searchError),P.default("ul",k.searchResults.map(e=>P.default("li",[P.default(".flex-space",[P.default("a.wikilink",{href:me(e.page)},e.page),P.default("",e.rank.toFixed(3))]),P.default("",e.snippet.map(n=>n[0]?P.default("span.highlight",n[1]):n[1]))])))])},Dn={view:()=>P.default("",k.showingSearchDialog?P.default(En):null)},fr=document.createElement("div");document.querySelector("main").insertBefore(fr,document.querySelector(".header"));P.default.mount(fr,Dn);var Tn=document.querySelector("nav .search");Tn.addEventListener("click",e=>{k.showingSearchDialog=!k.showingSearchDialog,e.preventDefault(),P.default.redraw()});document.body.addEventListener("keydown",e=>{e.target===document.body&&(e.key==="e"?location.pathname=me(le,"edit"):e.key==="v"?location.pathname=me(le):e.key==="r"?location.pathname=me(le,"revisions"):e.key==="/"&&(k.showingSearchDialog=!k.showingSearchDialog,e.preventDefault(),P.default.redraw()))});var ur=e=>at(e,"yyyy-MM-dd HH:mm:ss"),qn=e=>{let n=0;for(let a of e.split(/\s+/))/[^#*+>|`-]/.test(a)&&(n+=1);return n},Cn=e=>e.split(` +`).length,q=document.querySelector(".edit-form textarea");if(q){let e={keypresses:0,draftSelected:!1,pendingFiles:new Map},n=document.createElement("div");document.querySelector(".sidebar").appendChild(n);let a=Infinity,l=()=>{let p=document.body.scrollTop;(q.scrollHeight+2!=q.style.height.slice(0,-2)||a>q.value.length)&&(q.style.height="0px",q.style.height=`${Math.max(q.scrollHeight+2,100)}px`,document.body.scrollTop=p),a=q.value.length},m=parseInt(document.querySelector("input[name=last-edit]").value),h=q.value,c=JSON.parse(document.querySelector("input[name=associated-files]").value).map(({filename:p,mimeType:b})=>({file:{name:p,type:b,state:"uploaded"},state:"preexisting"})),o=()=>{!e.initialDraft||(e.draftSelected=!0,q.value=e.initialDraft.text,l())},u=()=>{console.log("server value swapped in, allegedly?"),e.draftSelected=!1,console.log(q.value,h),q.value=h,l()};st.then(p=>p.get("drafts",le)).then(p=>{e.initialDraft=p,console.log("found draft ",p),p&&p.ts>m&&o(),P.default.redraw()});let d={view:()=>e.initialDraft==null?"No draft":[P.default(e.draftSelected?".selected":"",{onclick:o},`Draft from ${ur(e.initialDraft.ts)}`),m>0&&P.default(e.draftSelected?"":".selected",{onclick:u},`Page from ${ur(m)}`)]},w=()=>{let p=document.createElement("input");p.type="file",p.multiple=!0,p.click(),p.oninput=b=>{for(let S of b.target.files)e.pendingFiles.set(S.name,{file:S,state:"pending"}),window.file=S;b.target.files.length>0&&P.default.redraw()}},x={view:({attrs:p})=>P.default("li.file",[P.default("",p.file.name),P.default("",p.state)])},T={view:()=>[P.default("button.upload",{onclick:w},"Upload"),P.default("ul.files",c.concat(Array.from(e.pendingFiles.values())).map(p=>P.default(x,{...p,key:p.file.name}))),P.default("",`${e.chars} chars`),P.default("",`${e.words} words`),P.default("",`${e.lines} lines`),P.default("",`${e.keypresses} keypresses`),P.default(d)]},y=p=>{e.words=qn(p),e.lines=Cn(p),e.chars=p.length};y(q.value),P.default.mount(n,T),q.addEventListener("keypress",p=>{let b=q.selectionStart,S=q.selectionEnd;if(b!==S)return;let O=` +`+q.value.substr(0,b),$=O.lastIndexOf(` +`)+1,Q=b+(q.value.substr(b)+` `).indexOf(` -`);if(g.code==="Enter"){if(g.ctrlKey){T.parentElement.submit();return}let v=x.substr(q),A=/^(\s*)(([*+-])|(\d+)([).]))(\s*)/.exec(v);if(A){let W=A[1]+(A[4]?(parseInt(A[4])+1).toString()+A[5]:A[2])+A[6],R=T.value.slice(p,S),P=T.value.substr(0,p)+` -`+W;T.value=P+R+T.value.substr(S),T.selectionStart=T.selectionEnd=P.length,f(),g.preventDefault()}}}),T.addEventListener("keydown",g=>{let p=T.selectionStart,E=T.selectionEnd;if(p!==E)return;let q=(` -`+T.value.substr(0,p)).lastIndexOf(` -`),S=p+(T.value.substr(p)+` +`);if(p.code==="Enter"){if(p.ctrlKey){q.parentElement.submit();return}let v=O.substr($),C=/^(\s*)(([*+-])|(\d+)([).]))(\s*)/.exec(v);if(C){let R=C[1]+(C[4]?(parseInt(C[4])+1).toString()+C[5]:C[2])+C[6],W=q.value.slice(b,Q),F=q.value.substr(0,b)+` +`+R;q.value=F+W+q.value.substr(Q),q.selectionStart=q.selectionEnd=F.length,l(),p.preventDefault()}}}),q.addEventListener("keydown",p=>{let b=q.selectionStart,S=q.selectionEnd;if(b!==S)return;let $=(` +`+q.value.substr(0,b)).lastIndexOf(` +`),Q=b+(q.value.substr(b)+` `).indexOf(` -`);if(g.code==="Backspace"){if(/^\s*([*+-]|\d+[).])\s*$/y.test(T.value.slice(q,p))){let A=T.value.substr(0,q),W=T.value.substr(p);T.value=A+W,T.selectionStart=T.selectionEnd=A.length,f(),g.preventDefault()}}else if(g.code==="Tab"){let v=/^(\s*)([*+-]|\d+[).])/.exec(T.value.slice(q,S)),A=T.value.substr(q);g.shiftKey?A=A.replace(/^ /,""):A=" "+A,v&&(T.value=T.value.substr(0,q)+A,T.selectionStart=T.selectionEnd=p+(g.shiftKey?-2:2),f(),g.preventDefault())}e.keypresses++,N.default.redraw()});let b=Dn(()=>{st.then(g=>g.put("drafts",{text:T.value,ts:Date.now()},ce)),console.log("saved")});T.addEventListener("input",()=>{f(),w(T.value),b()}),f()}})(); +`);if(p.code==="Backspace"){if(/^\s*([*+-]|\d+[).])\s*$/y.test(q.value.slice($,b))){let C=q.value.substr(0,$),R=q.value.substr(b);q.value=C+R,q.selectionStart=q.selectionEnd=C.length,l(),p.preventDefault()}}else if(p.code==="Tab"){let v=/^(\s*)([*+-]|\d+[).])/.exec(q.value.slice($,Q)),C=q.value.substr($);p.shiftKey?C=C.replace(/^ /,""):C=" "+C,v&&(q.value=q.value.substr(0,$)+C,q.selectionStart=q.selectionEnd=b+(p.shiftKey?-2:2),l(),p.preventDefault())}e.keypresses++,P.default.redraw()});let E=hn(()=>{st.then(p=>p.put("drafts",{text:q.value,ts:Date.now()},le)),console.log("saved")});q.addEventListener("input",()=>{l(),y(q.value),E()}),l()}});var Yr=(e,n)=>n.some(a=>e instanceof a),Xt,er;function Gr(){return Xt||(Xt=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Xr(){return er||(er=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var tr=new WeakMap,Ze=new WeakMap,rr=new WeakMap,Ye=new WeakMap,Ge=new WeakMap;function en(e){let n=new Promise((a,l)=>{let m=()=>{e.removeEventListener("success",h),e.removeEventListener("error",c)},h=()=>{a(X(e.result)),m()},c=()=>{l(e.error),m()};e.addEventListener("success",h),e.addEventListener("error",c)});return n.then(a=>{a instanceof IDBCursor&&tr.set(a,e)}).catch(()=>{}),Ge.set(n,e),n}function tn(e){if(Ze.has(e))return;let n=new Promise((a,l)=>{let m=()=>{e.removeEventListener("complete",h),e.removeEventListener("error",c),e.removeEventListener("abort",c)},h=()=>{a(),m()},c=()=>{l(e.error||new DOMException("AbortError","AbortError")),m()};e.addEventListener("complete",h),e.addEventListener("error",c),e.addEventListener("abort",c)});Ze.set(e,n)}var Xe={get(e,n,a){if(e instanceof IDBTransaction){if(n==="done")return Ze.get(e);if(n==="objectStoreNames")return e.objectStoreNames||rr.get(e);if(n==="store")return a.objectStoreNames[1]?void 0:a.objectStore(a.objectStoreNames[0])}return X(e[n])},set(e,n,a){return e[n]=a,!0},has(e,n){return e instanceof IDBTransaction&&(n==="done"||n==="store")?!0:n in e}};function nr(e){Xe=e(Xe)}function rn(e){return e===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(n,...a){let l=e.call(qe(this),n,...a);return rr.set(l,n.sort?n.sort():[n]),X(l)}:Xr().includes(e)?function(...n){return e.apply(qe(this),n),X(tr.get(this))}:function(...n){return X(e.apply(qe(this),n))}}function nn(e){return typeof e=="function"?rn(e):(e instanceof IDBTransaction&&tn(e),Yr(e,Gr())?new Proxy(e,Xe):e)}function X(e){if(e instanceof IDBRequest)return en(e);if(Ye.has(e))return Ye.get(e);let n=nn(e);return n!==e&&(Ye.set(e,n),Ge.set(n,e)),n}var qe=e=>Ge.get(e);function ir(e,n,{blocked:a,upgrade:l,blocking:m,terminated:h}={}){let c=indexedDB.open(e,n),o=X(c);return l&&c.addEventListener("upgradeneeded",u=>{l(X(c.result),u.oldVersion,u.newVersion,X(c.transaction))}),a&&c.addEventListener("blocked",()=>a()),o.then(u=>{h&&u.addEventListener("close",()=>h()),m&&u.addEventListener("versionchange",()=>m())}).catch(()=>{}),o}var an=["get","getKey","getAll","getAllKeys","count"],sn=["put","add","delete","clear"],et=new Map;function ar(e,n){if(!(e instanceof IDBDatabase&&!(n in e)&&typeof n=="string"))return;if(et.get(n))return et.get(n);let a=n.replace(/FromIndex$/,""),l=n!==a,m=sn.includes(a);if(!(a in(l?IDBIndex:IDBObjectStore).prototype)||!(m||an.includes(a)))return;let h=async function(c,...o){let u=this.transaction(c,m?"readwrite":"readonly"),d=u.store;return l&&(d=d.index(o.shift())),(await Promise.all([d[a](...o),m&&u.done]))[0]};return et.set(n,h),h}nr(e=>({...e,get:(n,a,l)=>ar(n,a)||e.get(n,a,l),has:(n,a)=>!!ar(n,a)||e.has(n,a)}));function he(e){if(e===null||e===!0||e===!1)return NaN;var n=Number(e);return isNaN(n)?n:n<0?Math.ceil(n):Math.floor(n)}function G(e,n){if(n.length1?"s":"")+" required, but only "+n.length+" present")}function se(e){G(1,arguments);var n=Object.prototype.toString.call(e);return e instanceof Date||typeof e=="object"&&n==="[object Date]"?new Date(e.getTime()):typeof e=="number"||n==="[object Number]"?new Date(e):((typeof e=="string"||n==="[object String]")&&typeof console!="undefined"&&(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://git.io/fjule"),console.warn(new Error().stack)),new Date(NaN))}function tt(e,n){G(2,arguments);var a=se(e).getTime(),l=he(n);return new Date(a+l)}var Ce=6e4;function sr(e){return e.getTime()%Ce}function rt(e){var n=new Date(e.getTime()),a=Math.ceil(n.getTimezoneOffset());n.setSeconds(0,0);var l=a>0,m=l?(Ce+sr(n))%Ce:sr(n);return a*Ce+m}function nt(e){G(1,arguments);var n=se(e);return!isNaN(n)}function it(e,n){G(2,arguments);var a=he(n);return tt(e,-a)}function ee(e,n){for(var a=e<0?"-":"",l=Math.abs(e).toString();l.length0?a:1-a;return ee(n==="yy"?l%100:l,n.length)},M:function(e,n){var a=e.getUTCMonth();return n==="M"?String(a+1):ee(a+1,2)},d:function(e,n){return ee(e.getUTCDate(),n.length)},a:function(e,n){var a=e.getUTCHours()/12>=1?"pm":"am";switch(n){case"a":case"aa":return a.toUpperCase();case"aaa":return a;case"aaaaa":return a[0];case"aaaa":default:return a==="am"?"a.m.":"p.m."}},h:function(e,n){return ee(e.getUTCHours()%12||12,n.length)},H:function(e,n){return ee(e.getUTCHours(),n.length)},m:function(e,n){return ee(e.getUTCMinutes(),n.length)},s:function(e,n){return ee(e.getUTCSeconds(),n.length)},S:function(e,n){var a=n.length,l=e.getUTCMilliseconds(),m=Math.floor(l*Math.pow(10,a-3));return ee(m,n.length)}},lr=ln;var fn=/(\w)\1*|''|'(''|[^'])+('|$)|./g,un=/^'([^]*?)'?$/,cn=/''/g,on=/[a-zA-Z]/;function at(e,n){G(2,arguments);var a=String(n),l=se(e);if(!nt(l))throw new RangeError("Invalid time value");var m=rt(l),h=it(l,m),c=a.match(fn).map(function(o){if(o==="''")return"'";var u=o[0];if(u==="'")return pn(o);var d=lr[u];if(d)return d(h,o,null,{});if(u.match(on))throw new RangeError("Format string contains an unescaped latin alphabet character `"+u+"`");return o}).join("");return c}function pn(e){return e.match(un)[1].replace(cn,"'")}cr();})(); //# sourceMappingURL=client.js.map diff --git a/static/client.js.map b/static/client.js.map index 2551667..f4b76f5 100644 --- a/static/client.js.map +++ b/static/client.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../node_modules/mithril/render/vnode.js", "../node_modules/mithril/render/hyperscriptVnode.js", "../node_modules/mithril/render/hyperscript.js", "../node_modules/mithril/render/trust.js", "../node_modules/mithril/render/fragment.js", "../node_modules/mithril/hyperscript.js", "../node_modules/mithril/promise/polyfill.js", "../node_modules/mithril/promise/promise.js", "../node_modules/mithril/render/render.js", "../node_modules/mithril/render.js", "../node_modules/mithril/api/mount-redraw.js", "../node_modules/mithril/mount-redraw.js", "../node_modules/mithril/querystring/build.js", "../node_modules/mithril/pathname/assign.js", "../node_modules/mithril/pathname/build.js", "../node_modules/mithril/request/request.js", "../node_modules/mithril/request.js", "../node_modules/mithril/querystring/parse.js", "../node_modules/mithril/pathname/parse.js", "../node_modules/mithril/pathname/compileTemplate.js", "../node_modules/mithril/api/router.js", "../node_modules/mithril/route.js", "../node_modules/mithril/index.js", "../src/client.js", "../node_modules/idb/build/esm/wrap-idb-value.js", "../node_modules/idb/build/esm/index.js", "../node_modules/date-fns/esm/_lib/toInteger/index.js", "../node_modules/date-fns/esm/_lib/requiredArgs/index.js", "../node_modules/date-fns/esm/toDate/index.js", "../node_modules/date-fns/esm/addMilliseconds/index.js", "../node_modules/date-fns/esm/_lib/getTimezoneOffsetInMilliseconds/index.js", "../node_modules/date-fns/esm/isValid/index.js", "../node_modules/date-fns/esm/subMilliseconds/index.js", "../node_modules/date-fns/esm/_lib/addLeadingZeros/index.js", "../node_modules/date-fns/esm/_lib/format/lightFormatters/index.js", "../node_modules/date-fns/esm/lightFormat/index.js"], - "sourcesContent": ["\"use strict\"\n\nfunction Vnode(tag, key, attrs, children, text, dom) {\n\treturn {tag: tag, key: key, attrs: attrs, children: children, text: text, dom: dom, domSize: undefined, state: undefined, events: undefined, instance: undefined}\n}\nVnode.normalize = function(node) {\n\tif (Array.isArray(node)) return Vnode(\"[\", undefined, undefined, Vnode.normalizeChildren(node), undefined, undefined)\n\tif (node == null || typeof node === \"boolean\") return null\n\tif (typeof node === \"object\") return node\n\treturn Vnode(\"#\", undefined, undefined, String(node), undefined, undefined)\n}\nVnode.normalizeChildren = function(input) {\n\tvar children = []\n\tif (input.length) {\n\t\tvar isKeyed = input[0] != null && input[0].key != null\n\t\t// Note: this is a *very* perf-sensitive check.\n\t\t// Fun fact: merging the loop like this is somehow faster than splitting\n\t\t// it, noticeably so.\n\t\tfor (var i = 1; i < input.length; i++) {\n\t\t\tif ((input[i] != null && input[i].key != null) !== isKeyed) {\n\t\t\t\tthrow new TypeError(\"Vnodes must either always have keys or never have keys!\")\n\t\t\t}\n\t\t}\n\t\tfor (var i = 0; i < input.length; i++) {\n\t\t\tchildren[i] = Vnode.normalize(input[i])\n\t\t}\n\t}\n\treturn children\n}\n\nmodule.exports = Vnode\n", "\"use strict\"\n\nvar Vnode = require(\"../render/vnode\")\n\n// Call via `hyperscriptVnode.apply(startOffset, arguments)`\n//\n// The reason I do it this way, forwarding the arguments and passing the start\n// offset in `this`, is so I don't have to create a temporary array in a\n// performance-critical path.\n//\n// In native ES6, I'd instead add a final `...args` parameter to the\n// `hyperscript` and `fragment` factories and define this as\n// `hyperscriptVnode(...args)`, since modern engines do optimize that away. But\n// ES5 (what Mithril requires thanks to IE support) doesn't give me that luxury,\n// and engines aren't nearly intelligent enough to do either of these:\n//\n// 1. Elide the allocation for `[].slice.call(arguments, 1)` when it's passed to\n// another function only to be indexed.\n// 2. Elide an `arguments` allocation when it's passed to any function other\n// than `Function.prototype.apply` or `Reflect.apply`.\n//\n// In ES6, it'd probably look closer to this (I'd need to profile it, though):\n// module.exports = function(attrs, ...children) {\n// if (attrs == null || typeof attrs === \"object\" && attrs.tag == null && !Array.isArray(attrs)) {\n// if (children.length === 1 && Array.isArray(children[0])) children = children[0]\n// } else {\n// children = children.length === 0 && Array.isArray(attrs) ? attrs : [attrs, ...children]\n// attrs = undefined\n// }\n//\n// if (attrs == null) attrs = {}\n// return Vnode(\"\", attrs.key, attrs, children)\n// }\nmodule.exports = function() {\n\tvar attrs = arguments[this], start = this + 1, children\n\n\tif (attrs == null) {\n\t\tattrs = {}\n\t} else if (typeof attrs !== \"object\" || attrs.tag != null || Array.isArray(attrs)) {\n\t\tattrs = {}\n\t\tstart = this\n\t}\n\n\tif (arguments.length === start + 1) {\n\t\tchildren = arguments[start]\n\t\tif (!Array.isArray(children)) children = [children]\n\t} else {\n\t\tchildren = []\n\t\twhile (start < arguments.length) children.push(arguments[start++])\n\t}\n\n\treturn Vnode(\"\", attrs.key, attrs, children)\n}\n", "\"use strict\"\n\nvar Vnode = require(\"../render/vnode\")\nvar hyperscriptVnode = require(\"./hyperscriptVnode\")\n\nvar selectorParser = /(?:(^|#|\\.)([^#\\.\\[\\]]+))|(\\[(.+?)(?:\\s*=\\s*(\"|'|)((?:\\\\[\"'\\]]|.)*?)\\5)?\\])/g\nvar selectorCache = {}\nvar hasOwn = {}.hasOwnProperty\n\nfunction isEmpty(object) {\n\tfor (var key in object) if (hasOwn.call(object, key)) return false\n\treturn true\n}\n\nfunction compileSelector(selector) {\n\tvar match, tag = \"div\", classes = [], attrs = {}\n\twhile (match = selectorParser.exec(selector)) {\n\t\tvar type = match[1], value = match[2]\n\t\tif (type === \"\" && value !== \"\") tag = value\n\t\telse if (type === \"#\") attrs.id = value\n\t\telse if (type === \".\") classes.push(value)\n\t\telse if (match[3][0] === \"[\") {\n\t\t\tvar attrValue = match[6]\n\t\t\tif (attrValue) attrValue = attrValue.replace(/\\\\([\"'])/g, \"$1\").replace(/\\\\\\\\/g, \"\\\\\")\n\t\t\tif (match[4] === \"class\") classes.push(attrValue)\n\t\t\telse attrs[match[4]] = attrValue === \"\" ? attrValue : attrValue || true\n\t\t}\n\t}\n\tif (classes.length > 0) attrs.className = classes.join(\" \")\n\treturn selectorCache[selector] = {tag: tag, attrs: attrs}\n}\n\nfunction execSelector(state, vnode) {\n\tvar attrs = vnode.attrs\n\tvar children = Vnode.normalizeChildren(vnode.children)\n\tvar hasClass = hasOwn.call(attrs, \"class\")\n\tvar className = hasClass ? attrs.class : attrs.className\n\n\tvnode.tag = state.tag\n\tvnode.attrs = null\n\tvnode.children = undefined\n\n\tif (!isEmpty(state.attrs) && !isEmpty(attrs)) {\n\t\tvar newAttrs = {}\n\n\t\tfor (var key in attrs) {\n\t\t\tif (hasOwn.call(attrs, key)) newAttrs[key] = attrs[key]\n\t\t}\n\n\t\tattrs = newAttrs\n\t}\n\n\tfor (var key in state.attrs) {\n\t\tif (hasOwn.call(state.attrs, key) && key !== \"className\" && !hasOwn.call(attrs, key)){\n\t\t\tattrs[key] = state.attrs[key]\n\t\t}\n\t}\n\tif (className != null || state.attrs.className != null) attrs.className =\n\t\tclassName != null\n\t\t\t? state.attrs.className != null\n\t\t\t\t? String(state.attrs.className) + \" \" + String(className)\n\t\t\t\t: className\n\t\t\t: state.attrs.className != null\n\t\t\t\t? state.attrs.className\n\t\t\t\t: null\n\n\tif (hasClass) attrs.class = null\n\n\tfor (var key in attrs) {\n\t\tif (hasOwn.call(attrs, key) && key !== \"key\") {\n\t\t\tvnode.attrs = attrs\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif (Array.isArray(children) && children.length === 1 && children[0] != null && children[0].tag === \"#\") {\n\t\tvnode.text = children[0].children\n\t} else {\n\t\tvnode.children = children\n\t}\n\n\treturn vnode\n}\n\nfunction hyperscript(selector) {\n\tif (selector == null || typeof selector !== \"string\" && typeof selector !== \"function\" && typeof selector.view !== \"function\") {\n\t\tthrow Error(\"The selector must be either a string or a component.\");\n\t}\n\n\tvar vnode = hyperscriptVnode.apply(1, arguments)\n\n\tif (typeof selector === \"string\") {\n\t\tvnode.children = Vnode.normalizeChildren(vnode.children)\n\t\tif (selector !== \"[\") return execSelector(selectorCache[selector] || compileSelector(selector), vnode)\n\t}\n\n\tvnode.tag = selector\n\treturn vnode\n}\n\nmodule.exports = hyperscript\n", "\"use strict\"\n\nvar Vnode = require(\"../render/vnode\")\n\nmodule.exports = function(html) {\n\tif (html == null) html = \"\"\n\treturn Vnode(\"<\", undefined, undefined, html, undefined, undefined)\n}\n", "\"use strict\"\n\nvar Vnode = require(\"../render/vnode\")\nvar hyperscriptVnode = require(\"./hyperscriptVnode\")\n\nmodule.exports = function() {\n\tvar vnode = hyperscriptVnode.apply(0, arguments)\n\n\tvnode.tag = \"[\"\n\tvnode.children = Vnode.normalizeChildren(vnode.children)\n\treturn vnode\n}\n", "\"use strict\"\n\nvar hyperscript = require(\"./render/hyperscript\")\n\nhyperscript.trust = require(\"./render/trust\")\nhyperscript.fragment = require(\"./render/fragment\")\n\nmodule.exports = hyperscript\n", "\"use strict\"\n/** @constructor */\nvar PromisePolyfill = function(executor) {\n\tif (!(this instanceof PromisePolyfill)) throw new Error(\"Promise must be called with `new`\")\n\tif (typeof executor !== \"function\") throw new TypeError(\"executor must be a function\")\n\n\tvar self = this, resolvers = [], rejectors = [], resolveCurrent = handler(resolvers, true), rejectCurrent = handler(rejectors, false)\n\tvar instance = self._instance = {resolvers: resolvers, rejectors: rejectors}\n\tvar callAsync = typeof setImmediate === \"function\" ? setImmediate : setTimeout\n\tfunction handler(list, shouldAbsorb) {\n\t\treturn function execute(value) {\n\t\t\tvar then\n\t\t\ttry {\n\t\t\t\tif (shouldAbsorb && value != null && (typeof value === \"object\" || typeof value === \"function\") && typeof (then = value.then) === \"function\") {\n\t\t\t\t\tif (value === self) throw new TypeError(\"Promise can't be resolved w/ itself\")\n\t\t\t\t\texecuteOnce(then.bind(value))\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tcallAsync(function() {\n\t\t\t\t\t\tif (!shouldAbsorb && list.length === 0) console.error(\"Possible unhandled promise rejection:\", value)\n\t\t\t\t\t\tfor (var i = 0; i < list.length; i++) list[i](value)\n\t\t\t\t\t\tresolvers.length = 0, rejectors.length = 0\n\t\t\t\t\t\tinstance.state = shouldAbsorb\n\t\t\t\t\t\tinstance.retry = function() {execute(value)}\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (e) {\n\t\t\t\trejectCurrent(e)\n\t\t\t}\n\t\t}\n\t}\n\tfunction executeOnce(then) {\n\t\tvar runs = 0\n\t\tfunction run(fn) {\n\t\t\treturn function(value) {\n\t\t\t\tif (runs++ > 0) return\n\t\t\t\tfn(value)\n\t\t\t}\n\t\t}\n\t\tvar onerror = run(rejectCurrent)\n\t\ttry {then(run(resolveCurrent), onerror)} catch (e) {onerror(e)}\n\t}\n\n\texecuteOnce(executor)\n}\nPromisePolyfill.prototype.then = function(onFulfilled, onRejection) {\n\tvar self = this, instance = self._instance\n\tfunction handle(callback, list, next, state) {\n\t\tlist.push(function(value) {\n\t\t\tif (typeof callback !== \"function\") next(value)\n\t\t\telse try {resolveNext(callback(value))} catch (e) {if (rejectNext) rejectNext(e)}\n\t\t})\n\t\tif (typeof instance.retry === \"function\" && state === instance.state) instance.retry()\n\t}\n\tvar resolveNext, rejectNext\n\tvar promise = new PromisePolyfill(function(resolve, reject) {resolveNext = resolve, rejectNext = reject})\n\thandle(onFulfilled, instance.resolvers, resolveNext, true), handle(onRejection, instance.rejectors, rejectNext, false)\n\treturn promise\n}\nPromisePolyfill.prototype.catch = function(onRejection) {\n\treturn this.then(null, onRejection)\n}\nPromisePolyfill.prototype.finally = function(callback) {\n\treturn this.then(\n\t\tfunction(value) {\n\t\t\treturn PromisePolyfill.resolve(callback()).then(function() {\n\t\t\t\treturn value\n\t\t\t})\n\t\t},\n\t\tfunction(reason) {\n\t\t\treturn PromisePolyfill.resolve(callback()).then(function() {\n\t\t\t\treturn PromisePolyfill.reject(reason);\n\t\t\t})\n\t\t}\n\t)\n}\nPromisePolyfill.resolve = function(value) {\n\tif (value instanceof PromisePolyfill) return value\n\treturn new PromisePolyfill(function(resolve) {resolve(value)})\n}\nPromisePolyfill.reject = function(value) {\n\treturn new PromisePolyfill(function(resolve, reject) {reject(value)})\n}\nPromisePolyfill.all = function(list) {\n\treturn new PromisePolyfill(function(resolve, reject) {\n\t\tvar total = list.length, count = 0, values = []\n\t\tif (list.length === 0) resolve([])\n\t\telse for (var i = 0; i < list.length; i++) {\n\t\t\t(function(i) {\n\t\t\t\tfunction consume(value) {\n\t\t\t\t\tcount++\n\t\t\t\t\tvalues[i] = value\n\t\t\t\t\tif (count === total) resolve(values)\n\t\t\t\t}\n\t\t\t\tif (list[i] != null && (typeof list[i] === \"object\" || typeof list[i] === \"function\") && typeof list[i].then === \"function\") {\n\t\t\t\t\tlist[i].then(consume, reject)\n\t\t\t\t}\n\t\t\t\telse consume(list[i])\n\t\t\t})(i)\n\t\t}\n\t})\n}\nPromisePolyfill.race = function(list) {\n\treturn new PromisePolyfill(function(resolve, reject) {\n\t\tfor (var i = 0; i < list.length; i++) {\n\t\t\tlist[i].then(resolve, reject)\n\t\t}\n\t})\n}\n\nmodule.exports = PromisePolyfill\n", "\"use strict\"\n\nvar PromisePolyfill = require(\"./polyfill\")\n\nif (typeof window !== \"undefined\") {\n\tif (typeof window.Promise === \"undefined\") {\n\t\twindow.Promise = PromisePolyfill\n\t} else if (!window.Promise.prototype.finally) {\n\t\twindow.Promise.prototype.finally = PromisePolyfill.prototype.finally\n\t}\n\tmodule.exports = window.Promise\n} else if (typeof global !== \"undefined\") {\n\tif (typeof global.Promise === \"undefined\") {\n\t\tglobal.Promise = PromisePolyfill\n\t} else if (!global.Promise.prototype.finally) {\n\t\tglobal.Promise.prototype.finally = PromisePolyfill.prototype.finally\n\t}\n\tmodule.exports = global.Promise\n} else {\n\tmodule.exports = PromisePolyfill\n}\n", "\"use strict\"\n\nvar Vnode = require(\"../render/vnode\")\n\nmodule.exports = function($window) {\n\tvar $doc = $window && $window.document\n\tvar currentRedraw\n\n\tvar nameSpace = {\n\t\tsvg: \"http://www.w3.org/2000/svg\",\n\t\tmath: \"http://www.w3.org/1998/Math/MathML\"\n\t}\n\n\tfunction getNameSpace(vnode) {\n\t\treturn vnode.attrs && vnode.attrs.xmlns || nameSpace[vnode.tag]\n\t}\n\n\t//sanity check to discourage people from doing `vnode.state = ...`\n\tfunction checkState(vnode, original) {\n\t\tif (vnode.state !== original) throw new Error(\"`vnode.state` must not be modified\")\n\t}\n\n\t//Note: the hook is passed as the `this` argument to allow proxying the\n\t//arguments without requiring a full array allocation to do so. It also\n\t//takes advantage of the fact the current `vnode` is the first argument in\n\t//all lifecycle methods.\n\tfunction callHook(vnode) {\n\t\tvar original = vnode.state\n\t\ttry {\n\t\t\treturn this.apply(original, arguments)\n\t\t} finally {\n\t\t\tcheckState(vnode, original)\n\t\t}\n\t}\n\n\t// IE11 (at least) throws an UnspecifiedError when accessing document.activeElement when\n\t// inside an iframe. Catch and swallow this error, and heavy-handidly return null.\n\tfunction activeElement() {\n\t\ttry {\n\t\t\treturn $doc.activeElement\n\t\t} catch (e) {\n\t\t\treturn null\n\t\t}\n\t}\n\t//create\n\tfunction createNodes(parent, vnodes, start, end, hooks, nextSibling, ns) {\n\t\tfor (var i = start; i < end; i++) {\n\t\t\tvar vnode = vnodes[i]\n\t\t\tif (vnode != null) {\n\t\t\t\tcreateNode(parent, vnode, hooks, ns, nextSibling)\n\t\t\t}\n\t\t}\n\t}\n\tfunction createNode(parent, vnode, hooks, ns, nextSibling) {\n\t\tvar tag = vnode.tag\n\t\tif (typeof tag === \"string\") {\n\t\t\tvnode.state = {}\n\t\t\tif (vnode.attrs != null) initLifecycle(vnode.attrs, vnode, hooks)\n\t\t\tswitch (tag) {\n\t\t\t\tcase \"#\": createText(parent, vnode, nextSibling); break\n\t\t\t\tcase \"<\": createHTML(parent, vnode, ns, nextSibling); break\n\t\t\t\tcase \"[\": createFragment(parent, vnode, hooks, ns, nextSibling); break\n\t\t\t\tdefault: createElement(parent, vnode, hooks, ns, nextSibling)\n\t\t\t}\n\t\t}\n\t\telse createComponent(parent, vnode, hooks, ns, nextSibling)\n\t}\n\tfunction createText(parent, vnode, nextSibling) {\n\t\tvnode.dom = $doc.createTextNode(vnode.children)\n\t\tinsertNode(parent, vnode.dom, nextSibling)\n\t}\n\tvar possibleParents = {caption: \"table\", thead: \"table\", tbody: \"table\", tfoot: \"table\", tr: \"tbody\", th: \"tr\", td: \"tr\", colgroup: \"table\", col: \"colgroup\"}\n\tfunction createHTML(parent, vnode, ns, nextSibling) {\n\t\tvar match = vnode.children.match(/^\\s*?<(\\w+)/im) || []\n\t\t// not using the proper parent makes the child element(s) vanish.\n\t\t// var div = document.createElement(\"div\")\n\t\t// div.innerHTML = \"ij\"\n\t\t// console.log(div.innerHTML)\n\t\t// --> \"ij\", no in sight.\n\t\tvar temp = $doc.createElement(possibleParents[match[1]] || \"div\")\n\t\tif (ns === \"http://www.w3.org/2000/svg\") {\n\t\t\ttemp.innerHTML = \"\" + vnode.children + \"\"\n\t\t\ttemp = temp.firstChild\n\t\t} else {\n\t\t\ttemp.innerHTML = vnode.children\n\t\t}\n\t\tvnode.dom = temp.firstChild\n\t\tvnode.domSize = temp.childNodes.length\n\t\t// Capture nodes to remove, so we don't confuse them.\n\t\tvnode.instance = []\n\t\tvar fragment = $doc.createDocumentFragment()\n\t\tvar child\n\t\twhile (child = temp.firstChild) {\n\t\t\tvnode.instance.push(child)\n\t\t\tfragment.appendChild(child)\n\t\t}\n\t\tinsertNode(parent, fragment, nextSibling)\n\t}\n\tfunction createFragment(parent, vnode, hooks, ns, nextSibling) {\n\t\tvar fragment = $doc.createDocumentFragment()\n\t\tif (vnode.children != null) {\n\t\t\tvar children = vnode.children\n\t\t\tcreateNodes(fragment, children, 0, children.length, hooks, null, ns)\n\t\t}\n\t\tvnode.dom = fragment.firstChild\n\t\tvnode.domSize = fragment.childNodes.length\n\t\tinsertNode(parent, fragment, nextSibling)\n\t}\n\tfunction createElement(parent, vnode, hooks, ns, nextSibling) {\n\t\tvar tag = vnode.tag\n\t\tvar attrs = vnode.attrs\n\t\tvar is = attrs && attrs.is\n\n\t\tns = getNameSpace(vnode) || ns\n\n\t\tvar element = ns ?\n\t\t\tis ? $doc.createElementNS(ns, tag, {is: is}) : $doc.createElementNS(ns, tag) :\n\t\t\tis ? $doc.createElement(tag, {is: is}) : $doc.createElement(tag)\n\t\tvnode.dom = element\n\n\t\tif (attrs != null) {\n\t\t\tsetAttrs(vnode, attrs, ns)\n\t\t}\n\n\t\tinsertNode(parent, element, nextSibling)\n\n\t\tif (!maybeSetContentEditable(vnode)) {\n\t\t\tif (vnode.text != null) {\n\t\t\t\tif (vnode.text !== \"\") element.textContent = vnode.text\n\t\t\t\telse vnode.children = [Vnode(\"#\", undefined, undefined, vnode.text, undefined, undefined)]\n\t\t\t}\n\t\t\tif (vnode.children != null) {\n\t\t\t\tvar children = vnode.children\n\t\t\t\tcreateNodes(element, children, 0, children.length, hooks, null, ns)\n\t\t\t\tif (vnode.tag === \"select\" && attrs != null) setLateSelectAttrs(vnode, attrs)\n\t\t\t}\n\t\t}\n\t}\n\tfunction initComponent(vnode, hooks) {\n\t\tvar sentinel\n\t\tif (typeof vnode.tag.view === \"function\") {\n\t\t\tvnode.state = Object.create(vnode.tag)\n\t\t\tsentinel = vnode.state.view\n\t\t\tif (sentinel.$$reentrantLock$$ != null) return\n\t\t\tsentinel.$$reentrantLock$$ = true\n\t\t} else {\n\t\t\tvnode.state = void 0\n\t\t\tsentinel = vnode.tag\n\t\t\tif (sentinel.$$reentrantLock$$ != null) return\n\t\t\tsentinel.$$reentrantLock$$ = true\n\t\t\tvnode.state = (vnode.tag.prototype != null && typeof vnode.tag.prototype.view === \"function\") ? new vnode.tag(vnode) : vnode.tag(vnode)\n\t\t}\n\t\tinitLifecycle(vnode.state, vnode, hooks)\n\t\tif (vnode.attrs != null) initLifecycle(vnode.attrs, vnode, hooks)\n\t\tvnode.instance = Vnode.normalize(callHook.call(vnode.state.view, vnode))\n\t\tif (vnode.instance === vnode) throw Error(\"A view cannot return the vnode it received as argument\")\n\t\tsentinel.$$reentrantLock$$ = null\n\t}\n\tfunction createComponent(parent, vnode, hooks, ns, nextSibling) {\n\t\tinitComponent(vnode, hooks)\n\t\tif (vnode.instance != null) {\n\t\t\tcreateNode(parent, vnode.instance, hooks, ns, nextSibling)\n\t\t\tvnode.dom = vnode.instance.dom\n\t\t\tvnode.domSize = vnode.dom != null ? vnode.instance.domSize : 0\n\t\t}\n\t\telse {\n\t\t\tvnode.domSize = 0\n\t\t}\n\t}\n\n\t//update\n\t/**\n\t * @param {Element|Fragment} parent - the parent element\n\t * @param {Vnode[] | null} old - the list of vnodes of the last `render()` call for\n\t * this part of the tree\n\t * @param {Vnode[] | null} vnodes - as above, but for the current `render()` call.\n\t * @param {Function[]} hooks - an accumulator of post-render hooks (oncreate/onupdate)\n\t * @param {Element | null} nextSibling - the next DOM node if we're dealing with a\n\t * fragment that is not the last item in its\n\t * parent\n\t * @param {'svg' | 'math' | String | null} ns) - the current XML namespace, if any\n\t * @returns void\n\t */\n\t// This function diffs and patches lists of vnodes, both keyed and unkeyed.\n\t//\n\t// We will:\n\t//\n\t// 1. describe its general structure\n\t// 2. focus on the diff algorithm optimizations\n\t// 3. discuss DOM node operations.\n\n\t// ## Overview:\n\t//\n\t// The updateNodes() function:\n\t// - deals with trivial cases\n\t// - determines whether the lists are keyed or unkeyed based on the first non-null node\n\t// of each list.\n\t// - diffs them and patches the DOM if needed (that's the brunt of the code)\n\t// - manages the leftovers: after diffing, are there:\n\t// - old nodes left to remove?\n\t// \t - new nodes to insert?\n\t// \t deal with them!\n\t//\n\t// The lists are only iterated over once, with an exception for the nodes in `old` that\n\t// are visited in the fourth part of the diff and in the `removeNodes` loop.\n\n\t// ## Diffing\n\t//\n\t// Reading https://github.com/localvoid/ivi/blob/ddc09d06abaef45248e6133f7040d00d3c6be853/packages/ivi/src/vdom/implementation.ts#L617-L837\n\t// may be good for context on longest increasing subsequence-based logic for moving nodes.\n\t//\n\t// In order to diff keyed lists, one has to\n\t//\n\t// 1) match nodes in both lists, per key, and update them accordingly\n\t// 2) create the nodes present in the new list, but absent in the old one\n\t// 3) remove the nodes present in the old list, but absent in the new one\n\t// 4) figure out what nodes in 1) to move in order to minimize the DOM operations.\n\t//\n\t// To achieve 1) one can create a dictionary of keys => index (for the old list), then iterate\n\t// over the new list and for each new vnode, find the corresponding vnode in the old list using\n\t// the map.\n\t// 2) is achieved in the same step: if a new node has no corresponding entry in the map, it is new\n\t// and must be created.\n\t// For the removals, we actually remove the nodes that have been updated from the old list.\n\t// The nodes that remain in that list after 1) and 2) have been performed can be safely removed.\n\t// The fourth step is a bit more complex and relies on the longest increasing subsequence (LIS)\n\t// algorithm.\n\t//\n\t// the longest increasing subsequence is the list of nodes that can remain in place. Imagine going\n\t// from `1,2,3,4,5` to `4,5,1,2,3` where the numbers are not necessarily the keys, but the indices\n\t// corresponding to the keyed nodes in the old list (keyed nodes `e,d,c,b,a` => `b,a,e,d,c` would\n\t// match the above lists, for example).\n\t//\n\t// In there are two increasing subsequences: `4,5` and `1,2,3`, the latter being the longest. We\n\t// can update those nodes without moving them, and only call `insertNode` on `4` and `5`.\n\t//\n\t// @localvoid adapted the algo to also support node deletions and insertions (the `lis` is actually\n\t// the longest increasing subsequence *of old nodes still present in the new list*).\n\t//\n\t// It is a general algorithm that is fireproof in all circumstances, but it requires the allocation\n\t// and the construction of a `key => oldIndex` map, and three arrays (one with `newIndex => oldIndex`,\n\t// the `LIS` and a temporary one to create the LIS).\n\t//\n\t// So we cheat where we can: if the tails of the lists are identical, they are guaranteed to be part of\n\t// the LIS and can be updated without moving them.\n\t//\n\t// If two nodes are swapped, they are guaranteed not to be part of the LIS, and must be moved (with\n\t// the exception of the last node if the list is fully reversed).\n\t//\n\t// ## Finding the next sibling.\n\t//\n\t// `updateNode()` and `createNode()` expect a nextSibling parameter to perform DOM operations.\n\t// When the list is being traversed top-down, at any index, the DOM nodes up to the previous\n\t// vnode reflect the content of the new list, whereas the rest of the DOM nodes reflect the old\n\t// list. The next sibling must be looked for in the old list using `getNextSibling(... oldStart + 1 ...)`.\n\t//\n\t// In the other scenarios (swaps, upwards traversal, map-based diff),\n\t// the new vnodes list is traversed upwards. The DOM nodes at the bottom of the list reflect the\n\t// bottom part of the new vnodes list, and we can use the `v.dom` value of the previous node\n\t// as the next sibling (cached in the `nextSibling` variable).\n\n\n\t// ## DOM node moves\n\t//\n\t// In most scenarios `updateNode()` and `createNode()` perform the DOM operations. However,\n\t// this is not the case if the node moved (second and fourth part of the diff algo). We move\n\t// the old DOM nodes before updateNode runs because it enables us to use the cached `nextSibling`\n\t// variable rather than fetching it using `getNextSibling()`.\n\t//\n\t// The fourth part of the diff currently inserts nodes unconditionally, leading to issues\n\t// like #1791 and #1999. We need to be smarter about those situations where adjascent old\n\t// nodes remain together in the new list in a way that isn't covered by parts one and\n\t// three of the diff algo.\n\n\tfunction updateNodes(parent, old, vnodes, hooks, nextSibling, ns) {\n\t\tif (old === vnodes || old == null && vnodes == null) return\n\t\telse if (old == null || old.length === 0) createNodes(parent, vnodes, 0, vnodes.length, hooks, nextSibling, ns)\n\t\telse if (vnodes == null || vnodes.length === 0) removeNodes(parent, old, 0, old.length)\n\t\telse {\n\t\t\tvar isOldKeyed = old[0] != null && old[0].key != null\n\t\t\tvar isKeyed = vnodes[0] != null && vnodes[0].key != null\n\t\t\tvar start = 0, oldStart = 0\n\t\t\tif (!isOldKeyed) while (oldStart < old.length && old[oldStart] == null) oldStart++\n\t\t\tif (!isKeyed) while (start < vnodes.length && vnodes[start] == null) start++\n\t\t\tif (isKeyed === null && isOldKeyed == null) return // both lists are full of nulls\n\t\t\tif (isOldKeyed !== isKeyed) {\n\t\t\t\tremoveNodes(parent, old, oldStart, old.length)\n\t\t\t\tcreateNodes(parent, vnodes, start, vnodes.length, hooks, nextSibling, ns)\n\t\t\t} else if (!isKeyed) {\n\t\t\t\t// Don't index past the end of either list (causes deopts).\n\t\t\t\tvar commonLength = old.length < vnodes.length ? old.length : vnodes.length\n\t\t\t\t// Rewind if necessary to the first non-null index on either side.\n\t\t\t\t// We could alternatively either explicitly create or remove nodes when `start !== oldStart`\n\t\t\t\t// but that would be optimizing for sparse lists which are more rare than dense ones.\n\t\t\t\tstart = start < oldStart ? start : oldStart\n\t\t\t\tfor (; start < commonLength; start++) {\n\t\t\t\t\to = old[start]\n\t\t\t\t\tv = vnodes[start]\n\t\t\t\t\tif (o === v || o == null && v == null) continue\n\t\t\t\t\telse if (o == null) createNode(parent, v, hooks, ns, getNextSibling(old, start + 1, nextSibling))\n\t\t\t\t\telse if (v == null) removeNode(parent, o)\n\t\t\t\t\telse updateNode(parent, o, v, hooks, getNextSibling(old, start + 1, nextSibling), ns)\n\t\t\t\t}\n\t\t\t\tif (old.length > commonLength) removeNodes(parent, old, start, old.length)\n\t\t\t\tif (vnodes.length > commonLength) createNodes(parent, vnodes, start, vnodes.length, hooks, nextSibling, ns)\n\t\t\t} else {\n\t\t\t\t// keyed diff\n\t\t\t\tvar oldEnd = old.length - 1, end = vnodes.length - 1, map, o, v, oe, ve, topSibling\n\n\t\t\t\t// bottom-up\n\t\t\t\twhile (oldEnd >= oldStart && end >= start) {\n\t\t\t\t\toe = old[oldEnd]\n\t\t\t\t\tve = vnodes[end]\n\t\t\t\t\tif (oe.key !== ve.key) break\n\t\t\t\t\tif (oe !== ve) updateNode(parent, oe, ve, hooks, nextSibling, ns)\n\t\t\t\t\tif (ve.dom != null) nextSibling = ve.dom\n\t\t\t\t\toldEnd--, end--\n\t\t\t\t}\n\t\t\t\t// top-down\n\t\t\t\twhile (oldEnd >= oldStart && end >= start) {\n\t\t\t\t\to = old[oldStart]\n\t\t\t\t\tv = vnodes[start]\n\t\t\t\t\tif (o.key !== v.key) break\n\t\t\t\t\toldStart++, start++\n\t\t\t\t\tif (o !== v) updateNode(parent, o, v, hooks, getNextSibling(old, oldStart, nextSibling), ns)\n\t\t\t\t}\n\t\t\t\t// swaps and list reversals\n\t\t\t\twhile (oldEnd >= oldStart && end >= start) {\n\t\t\t\t\tif (start === end) break\n\t\t\t\t\tif (o.key !== ve.key || oe.key !== v.key) break\n\t\t\t\t\ttopSibling = getNextSibling(old, oldStart, nextSibling)\n\t\t\t\t\tmoveNodes(parent, oe, topSibling)\n\t\t\t\t\tif (oe !== v) updateNode(parent, oe, v, hooks, topSibling, ns)\n\t\t\t\t\tif (++start <= --end) moveNodes(parent, o, nextSibling)\n\t\t\t\t\tif (o !== ve) updateNode(parent, o, ve, hooks, nextSibling, ns)\n\t\t\t\t\tif (ve.dom != null) nextSibling = ve.dom\n\t\t\t\t\toldStart++; oldEnd--\n\t\t\t\t\toe = old[oldEnd]\n\t\t\t\t\tve = vnodes[end]\n\t\t\t\t\to = old[oldStart]\n\t\t\t\t\tv = vnodes[start]\n\t\t\t\t}\n\t\t\t\t// bottom up once again\n\t\t\t\twhile (oldEnd >= oldStart && end >= start) {\n\t\t\t\t\tif (oe.key !== ve.key) break\n\t\t\t\t\tif (oe !== ve) updateNode(parent, oe, ve, hooks, nextSibling, ns)\n\t\t\t\t\tif (ve.dom != null) nextSibling = ve.dom\n\t\t\t\t\toldEnd--, end--\n\t\t\t\t\toe = old[oldEnd]\n\t\t\t\t\tve = vnodes[end]\n\t\t\t\t}\n\t\t\t\tif (start > end) removeNodes(parent, old, oldStart, oldEnd + 1)\n\t\t\t\telse if (oldStart > oldEnd) createNodes(parent, vnodes, start, end + 1, hooks, nextSibling, ns)\n\t\t\t\telse {\n\t\t\t\t\t// inspired by ivi https://github.com/ivijs/ivi/ by Boris Kaul\n\t\t\t\t\tvar originalNextSibling = nextSibling, vnodesLength = end - start + 1, oldIndices = new Array(vnodesLength), li=0, i=0, pos = 2147483647, matched = 0, map, lisIndices\n\t\t\t\t\tfor (i = 0; i < vnodesLength; i++) oldIndices[i] = -1\n\t\t\t\t\tfor (i = end; i >= start; i--) {\n\t\t\t\t\t\tif (map == null) map = getKeyMap(old, oldStart, oldEnd + 1)\n\t\t\t\t\t\tve = vnodes[i]\n\t\t\t\t\t\tvar oldIndex = map[ve.key]\n\t\t\t\t\t\tif (oldIndex != null) {\n\t\t\t\t\t\t\tpos = (oldIndex < pos) ? oldIndex : -1 // becomes -1 if nodes were re-ordered\n\t\t\t\t\t\t\toldIndices[i-start] = oldIndex\n\t\t\t\t\t\t\toe = old[oldIndex]\n\t\t\t\t\t\t\told[oldIndex] = null\n\t\t\t\t\t\t\tif (oe !== ve) updateNode(parent, oe, ve, hooks, nextSibling, ns)\n\t\t\t\t\t\t\tif (ve.dom != null) nextSibling = ve.dom\n\t\t\t\t\t\t\tmatched++\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tnextSibling = originalNextSibling\n\t\t\t\t\tif (matched !== oldEnd - oldStart + 1) removeNodes(parent, old, oldStart, oldEnd + 1)\n\t\t\t\t\tif (matched === 0) createNodes(parent, vnodes, start, end + 1, hooks, nextSibling, ns)\n\t\t\t\t\telse {\n\t\t\t\t\t\tif (pos === -1) {\n\t\t\t\t\t\t\t// the indices of the indices of the items that are part of the\n\t\t\t\t\t\t\t// longest increasing subsequence in the oldIndices list\n\t\t\t\t\t\t\tlisIndices = makeLisIndices(oldIndices)\n\t\t\t\t\t\t\tli = lisIndices.length - 1\n\t\t\t\t\t\t\tfor (i = end; i >= start; i--) {\n\t\t\t\t\t\t\t\tv = vnodes[i]\n\t\t\t\t\t\t\t\tif (oldIndices[i-start] === -1) createNode(parent, v, hooks, ns, nextSibling)\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tif (lisIndices[li] === i - start) li--\n\t\t\t\t\t\t\t\t\telse moveNodes(parent, v, nextSibling)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (v.dom != null) nextSibling = vnodes[i].dom\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tfor (i = end; i >= start; i--) {\n\t\t\t\t\t\t\t\tv = vnodes[i]\n\t\t\t\t\t\t\t\tif (oldIndices[i-start] === -1) createNode(parent, v, hooks, ns, nextSibling)\n\t\t\t\t\t\t\t\tif (v.dom != null) nextSibling = vnodes[i].dom\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfunction updateNode(parent, old, vnode, hooks, nextSibling, ns) {\n\t\tvar oldTag = old.tag, tag = vnode.tag\n\t\tif (oldTag === tag) {\n\t\t\tvnode.state = old.state\n\t\t\tvnode.events = old.events\n\t\t\tif (shouldNotUpdate(vnode, old)) return\n\t\t\tif (typeof oldTag === \"string\") {\n\t\t\t\tif (vnode.attrs != null) {\n\t\t\t\t\tupdateLifecycle(vnode.attrs, vnode, hooks)\n\t\t\t\t}\n\t\t\t\tswitch (oldTag) {\n\t\t\t\t\tcase \"#\": updateText(old, vnode); break\n\t\t\t\t\tcase \"<\": updateHTML(parent, old, vnode, ns, nextSibling); break\n\t\t\t\t\tcase \"[\": updateFragment(parent, old, vnode, hooks, nextSibling, ns); break\n\t\t\t\t\tdefault: updateElement(old, vnode, hooks, ns)\n\t\t\t\t}\n\t\t\t}\n\t\t\telse updateComponent(parent, old, vnode, hooks, nextSibling, ns)\n\t\t}\n\t\telse {\n\t\t\tremoveNode(parent, old)\n\t\t\tcreateNode(parent, vnode, hooks, ns, nextSibling)\n\t\t}\n\t}\n\tfunction updateText(old, vnode) {\n\t\tif (old.children.toString() !== vnode.children.toString()) {\n\t\t\told.dom.nodeValue = vnode.children\n\t\t}\n\t\tvnode.dom = old.dom\n\t}\n\tfunction updateHTML(parent, old, vnode, ns, nextSibling) {\n\t\tif (old.children !== vnode.children) {\n\t\t\tremoveHTML(parent, old)\n\t\t\tcreateHTML(parent, vnode, ns, nextSibling)\n\t\t}\n\t\telse {\n\t\t\tvnode.dom = old.dom\n\t\t\tvnode.domSize = old.domSize\n\t\t\tvnode.instance = old.instance\n\t\t}\n\t}\n\tfunction updateFragment(parent, old, vnode, hooks, nextSibling, ns) {\n\t\tupdateNodes(parent, old.children, vnode.children, hooks, nextSibling, ns)\n\t\tvar domSize = 0, children = vnode.children\n\t\tvnode.dom = null\n\t\tif (children != null) {\n\t\t\tfor (var i = 0; i < children.length; i++) {\n\t\t\t\tvar child = children[i]\n\t\t\t\tif (child != null && child.dom != null) {\n\t\t\t\t\tif (vnode.dom == null) vnode.dom = child.dom\n\t\t\t\t\tdomSize += child.domSize || 1\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (domSize !== 1) vnode.domSize = domSize\n\t\t}\n\t}\n\tfunction updateElement(old, vnode, hooks, ns) {\n\t\tvar element = vnode.dom = old.dom\n\t\tns = getNameSpace(vnode) || ns\n\n\t\tif (vnode.tag === \"textarea\") {\n\t\t\tif (vnode.attrs == null) vnode.attrs = {}\n\t\t\tif (vnode.text != null) {\n\t\t\t\tvnode.attrs.value = vnode.text //FIXME handle multiple children\n\t\t\t\tvnode.text = undefined\n\t\t\t}\n\t\t}\n\t\tupdateAttrs(vnode, old.attrs, vnode.attrs, ns)\n\t\tif (!maybeSetContentEditable(vnode)) {\n\t\t\tif (old.text != null && vnode.text != null && vnode.text !== \"\") {\n\t\t\t\tif (old.text.toString() !== vnode.text.toString()) old.dom.firstChild.nodeValue = vnode.text\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (old.text != null) old.children = [Vnode(\"#\", undefined, undefined, old.text, undefined, old.dom.firstChild)]\n\t\t\t\tif (vnode.text != null) vnode.children = [Vnode(\"#\", undefined, undefined, vnode.text, undefined, undefined)]\n\t\t\t\tupdateNodes(element, old.children, vnode.children, hooks, null, ns)\n\t\t\t}\n\t\t}\n\t}\n\tfunction updateComponent(parent, old, vnode, hooks, nextSibling, ns) {\n\t\tvnode.instance = Vnode.normalize(callHook.call(vnode.state.view, vnode))\n\t\tif (vnode.instance === vnode) throw Error(\"A view cannot return the vnode it received as argument\")\n\t\tupdateLifecycle(vnode.state, vnode, hooks)\n\t\tif (vnode.attrs != null) updateLifecycle(vnode.attrs, vnode, hooks)\n\t\tif (vnode.instance != null) {\n\t\t\tif (old.instance == null) createNode(parent, vnode.instance, hooks, ns, nextSibling)\n\t\t\telse updateNode(parent, old.instance, vnode.instance, hooks, nextSibling, ns)\n\t\t\tvnode.dom = vnode.instance.dom\n\t\t\tvnode.domSize = vnode.instance.domSize\n\t\t}\n\t\telse if (old.instance != null) {\n\t\t\tremoveNode(parent, old.instance)\n\t\t\tvnode.dom = undefined\n\t\t\tvnode.domSize = 0\n\t\t}\n\t\telse {\n\t\t\tvnode.dom = old.dom\n\t\t\tvnode.domSize = old.domSize\n\t\t}\n\t}\n\tfunction getKeyMap(vnodes, start, end) {\n\t\tvar map = Object.create(null)\n\t\tfor (; start < end; start++) {\n\t\t\tvar vnode = vnodes[start]\n\t\t\tif (vnode != null) {\n\t\t\t\tvar key = vnode.key\n\t\t\t\tif (key != null) map[key] = start\n\t\t\t}\n\t\t}\n\t\treturn map\n\t}\n\t// Lifted from ivi https://github.com/ivijs/ivi/\n\t// takes a list of unique numbers (-1 is special and can\n\t// occur multiple times) and returns an array with the indices\n\t// of the items that are part of the longest increasing\n\t// subsequece\n\tvar lisTemp = []\n\tfunction makeLisIndices(a) {\n\t\tvar result = [0]\n\t\tvar u = 0, v = 0, i = 0\n\t\tvar il = lisTemp.length = a.length\n\t\tfor (var i = 0; i < il; i++) lisTemp[i] = a[i]\n\t\tfor (var i = 0; i < il; ++i) {\n\t\t\tif (a[i] === -1) continue\n\t\t\tvar j = result[result.length - 1]\n\t\t\tif (a[j] < a[i]) {\n\t\t\t\tlisTemp[i] = j\n\t\t\t\tresult.push(i)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tu = 0\n\t\t\tv = result.length - 1\n\t\t\twhile (u < v) {\n\t\t\t\t// Fast integer average without overflow.\n\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\tvar c = (u >>> 1) + (v >>> 1) + (u & v & 1)\n\t\t\t\tif (a[result[c]] < a[i]) {\n\t\t\t\t\tu = c + 1\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tv = c\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (a[i] < a[result[u]]) {\n\t\t\t\tif (u > 0) lisTemp[i] = result[u - 1]\n\t\t\t\tresult[u] = i\n\t\t\t}\n\t\t}\n\t\tu = result.length\n\t\tv = result[u - 1]\n\t\twhile (u-- > 0) {\n\t\t\tresult[u] = v\n\t\t\tv = lisTemp[v]\n\t\t}\n\t\tlisTemp.length = 0\n\t\treturn result\n\t}\n\n\tfunction getNextSibling(vnodes, i, nextSibling) {\n\t\tfor (; i < vnodes.length; i++) {\n\t\t\tif (vnodes[i] != null && vnodes[i].dom != null) return vnodes[i].dom\n\t\t}\n\t\treturn nextSibling\n\t}\n\n\t// This covers a really specific edge case:\n\t// - Parent node is keyed and contains child\n\t// - Child is removed, returns unresolved promise in `onbeforeremove`\n\t// - Parent node is moved in keyed diff\n\t// - Remaining children still need moved appropriately\n\t//\n\t// Ideally, I'd track removed nodes as well, but that introduces a lot more\n\t// complexity and I'm not exactly interested in doing that.\n\tfunction moveNodes(parent, vnode, nextSibling) {\n\t\tvar frag = $doc.createDocumentFragment()\n\t\tmoveChildToFrag(parent, frag, vnode)\n\t\tinsertNode(parent, frag, nextSibling)\n\t}\n\tfunction moveChildToFrag(parent, frag, vnode) {\n\t\t// Dodge the recursion overhead in a few of the most common cases.\n\t\twhile (vnode.dom != null && vnode.dom.parentNode === parent) {\n\t\t\tif (typeof vnode.tag !== \"string\") {\n\t\t\t\tvnode = vnode.instance\n\t\t\t\tif (vnode != null) continue\n\t\t\t} else if (vnode.tag === \"<\") {\n\t\t\t\tfor (var i = 0; i < vnode.instance.length; i++) {\n\t\t\t\t\tfrag.appendChild(vnode.instance[i])\n\t\t\t\t}\n\t\t\t} else if (vnode.tag !== \"[\") {\n\t\t\t\t// Don't recurse for text nodes *or* elements, just fragments\n\t\t\t\tfrag.appendChild(vnode.dom)\n\t\t\t} else if (vnode.children.length === 1) {\n\t\t\t\tvnode = vnode.children[0]\n\t\t\t\tif (vnode != null) continue\n\t\t\t} else {\n\t\t\t\tfor (var i = 0; i < vnode.children.length; i++) {\n\t\t\t\t\tvar child = vnode.children[i]\n\t\t\t\t\tif (child != null) moveChildToFrag(parent, frag, child)\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t}\n\n\tfunction insertNode(parent, dom, nextSibling) {\n\t\tif (nextSibling != null) parent.insertBefore(dom, nextSibling)\n\t\telse parent.appendChild(dom)\n\t}\n\n\tfunction maybeSetContentEditable(vnode) {\n\t\tif (vnode.attrs == null || (\n\t\t\tvnode.attrs.contenteditable == null && // attribute\n\t\t\tvnode.attrs.contentEditable == null // property\n\t\t)) return false\n\t\tvar children = vnode.children\n\t\tif (children != null && children.length === 1 && children[0].tag === \"<\") {\n\t\t\tvar content = children[0].children\n\t\t\tif (vnode.dom.innerHTML !== content) vnode.dom.innerHTML = content\n\t\t}\n\t\telse if (vnode.text != null || children != null && children.length !== 0) throw new Error(\"Child node of a contenteditable must be trusted\")\n\t\treturn true\n\t}\n\n\t//remove\n\tfunction removeNodes(parent, vnodes, start, end) {\n\t\tfor (var i = start; i < end; i++) {\n\t\t\tvar vnode = vnodes[i]\n\t\t\tif (vnode != null) removeNode(parent, vnode)\n\t\t}\n\t}\n\tfunction removeNode(parent, vnode) {\n\t\tvar mask = 0\n\t\tvar original = vnode.state\n\t\tvar stateResult, attrsResult\n\t\tif (typeof vnode.tag !== \"string\" && typeof vnode.state.onbeforeremove === \"function\") {\n\t\t\tvar result = callHook.call(vnode.state.onbeforeremove, vnode)\n\t\t\tif (result != null && typeof result.then === \"function\") {\n\t\t\t\tmask = 1\n\t\t\t\tstateResult = result\n\t\t\t}\n\t\t}\n\t\tif (vnode.attrs && typeof vnode.attrs.onbeforeremove === \"function\") {\n\t\t\tvar result = callHook.call(vnode.attrs.onbeforeremove, vnode)\n\t\t\tif (result != null && typeof result.then === \"function\") {\n\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\tmask |= 2\n\t\t\t\tattrsResult = result\n\t\t\t}\n\t\t}\n\t\tcheckState(vnode, original)\n\n\t\t// If we can, try to fast-path it and avoid all the overhead of awaiting\n\t\tif (!mask) {\n\t\t\tonremove(vnode)\n\t\t\tremoveChild(parent, vnode)\n\t\t} else {\n\t\t\tif (stateResult != null) {\n\t\t\t\tvar next = function () {\n\t\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\t\tif (mask & 1) { mask &= 2; if (!mask) reallyRemove() }\n\t\t\t\t}\n\t\t\t\tstateResult.then(next, next)\n\t\t\t}\n\t\t\tif (attrsResult != null) {\n\t\t\t\tvar next = function () {\n\t\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\t\tif (mask & 2) { mask &= 1; if (!mask) reallyRemove() }\n\t\t\t\t}\n\t\t\t\tattrsResult.then(next, next)\n\t\t\t}\n\t\t}\n\n\t\tfunction reallyRemove() {\n\t\t\tcheckState(vnode, original)\n\t\t\tonremove(vnode)\n\t\t\tremoveChild(parent, vnode)\n\t\t}\n\t}\n\tfunction removeHTML(parent, vnode) {\n\t\tfor (var i = 0; i < vnode.instance.length; i++) {\n\t\t\tparent.removeChild(vnode.instance[i])\n\t\t}\n\t}\n\tfunction removeChild(parent, vnode) {\n\t\t// Dodge the recursion overhead in a few of the most common cases.\n\t\twhile (vnode.dom != null && vnode.dom.parentNode === parent) {\n\t\t\tif (typeof vnode.tag !== \"string\") {\n\t\t\t\tvnode = vnode.instance\n\t\t\t\tif (vnode != null) continue\n\t\t\t} else if (vnode.tag === \"<\") {\n\t\t\t\tremoveHTML(parent, vnode)\n\t\t\t} else {\n\t\t\t\tif (vnode.tag !== \"[\") {\n\t\t\t\t\tparent.removeChild(vnode.dom)\n\t\t\t\t\tif (!Array.isArray(vnode.children)) break\n\t\t\t\t}\n\t\t\t\tif (vnode.children.length === 1) {\n\t\t\t\t\tvnode = vnode.children[0]\n\t\t\t\t\tif (vnode != null) continue\n\t\t\t\t} else {\n\t\t\t\t\tfor (var i = 0; i < vnode.children.length; i++) {\n\t\t\t\t\t\tvar child = vnode.children[i]\n\t\t\t\t\t\tif (child != null) removeChild(parent, child)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t}\n\tfunction onremove(vnode) {\n\t\tif (typeof vnode.tag !== \"string\" && typeof vnode.state.onremove === \"function\") callHook.call(vnode.state.onremove, vnode)\n\t\tif (vnode.attrs && typeof vnode.attrs.onremove === \"function\") callHook.call(vnode.attrs.onremove, vnode)\n\t\tif (typeof vnode.tag !== \"string\") {\n\t\t\tif (vnode.instance != null) onremove(vnode.instance)\n\t\t} else {\n\t\t\tvar children = vnode.children\n\t\t\tif (Array.isArray(children)) {\n\t\t\t\tfor (var i = 0; i < children.length; i++) {\n\t\t\t\t\tvar child = children[i]\n\t\t\t\t\tif (child != null) onremove(child)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t//attrs\n\tfunction setAttrs(vnode, attrs, ns) {\n\t\tfor (var key in attrs) {\n\t\t\tsetAttr(vnode, key, null, attrs[key], ns)\n\t\t}\n\t}\n\tfunction setAttr(vnode, key, old, value, ns) {\n\t\tif (key === \"key\" || key === \"is\" || value == null || isLifecycleMethod(key) || (old === value && !isFormAttribute(vnode, key)) && typeof value !== \"object\") return\n\t\tif (key[0] === \"o\" && key[1] === \"n\") return updateEvent(vnode, key, value)\n\t\tif (key.slice(0, 6) === \"xlink:\") vnode.dom.setAttributeNS(\"http://www.w3.org/1999/xlink\", key.slice(6), value)\n\t\telse if (key === \"style\") updateStyle(vnode.dom, old, value)\n\t\telse if (hasPropertyKey(vnode, key, ns)) {\n\t\t\tif (key === \"value\") {\n\t\t\t\t// Only do the coercion if we're actually going to check the value.\n\t\t\t\t/* eslint-disable no-implicit-coercion */\n\t\t\t\t//setting input[value] to same value by typing on focused element moves cursor to end in Chrome\n\t\t\t\tif ((vnode.tag === \"input\" || vnode.tag === \"textarea\") && vnode.dom.value === \"\" + value && vnode.dom === activeElement()) return\n\t\t\t\t//setting select[value] to same value while having select open blinks select dropdown in Chrome\n\t\t\t\tif (vnode.tag === \"select\" && old !== null && vnode.dom.value === \"\" + value) return\n\t\t\t\t//setting option[value] to same value while having select open blinks select dropdown in Chrome\n\t\t\t\tif (vnode.tag === \"option\" && old !== null && vnode.dom.value === \"\" + value) return\n\t\t\t\t/* eslint-enable no-implicit-coercion */\n\t\t\t}\n\t\t\t// If you assign an input type that is not supported by IE 11 with an assignment expression, an error will occur.\n\t\t\tif (vnode.tag === \"input\" && key === \"type\") vnode.dom.setAttribute(key, value)\n\t\t\telse vnode.dom[key] = value\n\t\t} else {\n\t\t\tif (typeof value === \"boolean\") {\n\t\t\t\tif (value) vnode.dom.setAttribute(key, \"\")\n\t\t\t\telse vnode.dom.removeAttribute(key)\n\t\t\t}\n\t\t\telse vnode.dom.setAttribute(key === \"className\" ? \"class\" : key, value)\n\t\t}\n\t}\n\tfunction removeAttr(vnode, key, old, ns) {\n\t\tif (key === \"key\" || key === \"is\" || old == null || isLifecycleMethod(key)) return\n\t\tif (key[0] === \"o\" && key[1] === \"n\" && !isLifecycleMethod(key)) updateEvent(vnode, key, undefined)\n\t\telse if (key === \"style\") updateStyle(vnode.dom, old, null)\n\t\telse if (\n\t\t\thasPropertyKey(vnode, key, ns)\n\t\t\t&& key !== \"className\"\n\t\t\t&& !(key === \"value\" && (\n\t\t\t\tvnode.tag === \"option\"\n\t\t\t\t|| vnode.tag === \"select\" && vnode.dom.selectedIndex === -1 && vnode.dom === activeElement()\n\t\t\t))\n\t\t\t&& !(vnode.tag === \"input\" && key === \"type\")\n\t\t) {\n\t\t\tvnode.dom[key] = null\n\t\t} else {\n\t\t\tvar nsLastIndex = key.indexOf(\":\")\n\t\t\tif (nsLastIndex !== -1) key = key.slice(nsLastIndex + 1)\n\t\t\tif (old !== false) vnode.dom.removeAttribute(key === \"className\" ? \"class\" : key)\n\t\t}\n\t}\n\tfunction setLateSelectAttrs(vnode, attrs) {\n\t\tif (\"value\" in attrs) {\n\t\t\tif(attrs.value === null) {\n\t\t\t\tif (vnode.dom.selectedIndex !== -1) vnode.dom.value = null\n\t\t\t} else {\n\t\t\t\tvar normalized = \"\" + attrs.value // eslint-disable-line no-implicit-coercion\n\t\t\t\tif (vnode.dom.value !== normalized || vnode.dom.selectedIndex === -1) {\n\t\t\t\t\tvnode.dom.value = normalized\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (\"selectedIndex\" in attrs) setAttr(vnode, \"selectedIndex\", null, attrs.selectedIndex, undefined)\n\t}\n\tfunction updateAttrs(vnode, old, attrs, ns) {\n\t\tif (attrs != null) {\n\t\t\tfor (var key in attrs) {\n\t\t\t\tsetAttr(vnode, key, old && old[key], attrs[key], ns)\n\t\t\t}\n\t\t}\n\t\tvar val\n\t\tif (old != null) {\n\t\t\tfor (var key in old) {\n\t\t\t\tif (((val = old[key]) != null) && (attrs == null || attrs[key] == null)) {\n\t\t\t\t\tremoveAttr(vnode, key, val, ns)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfunction isFormAttribute(vnode, attr) {\n\t\treturn attr === \"value\" || attr === \"checked\" || attr === \"selectedIndex\" || attr === \"selected\" && vnode.dom === activeElement() || vnode.tag === \"option\" && vnode.dom.parentNode === $doc.activeElement\n\t}\n\tfunction isLifecycleMethod(attr) {\n\t\treturn attr === \"oninit\" || attr === \"oncreate\" || attr === \"onupdate\" || attr === \"onremove\" || attr === \"onbeforeremove\" || attr === \"onbeforeupdate\"\n\t}\n\tfunction hasPropertyKey(vnode, key, ns) {\n\t\t// Filter out namespaced keys\n\t\treturn ns === undefined && (\n\t\t\t// If it's a custom element, just keep it.\n\t\t\tvnode.tag.indexOf(\"-\") > -1 || vnode.attrs != null && vnode.attrs.is ||\n\t\t\t// If it's a normal element, let's try to avoid a few browser bugs.\n\t\t\tkey !== \"href\" && key !== \"list\" && key !== \"form\" && key !== \"width\" && key !== \"height\"// && key !== \"type\"\n\t\t\t// Defer the property check until *after* we check everything.\n\t\t) && key in vnode.dom\n\t}\n\n\t//style\n\tvar uppercaseRegex = /[A-Z]/g\n\tfunction toLowerCase(capital) { return \"-\" + capital.toLowerCase() }\n\tfunction normalizeKey(key) {\n\t\treturn key[0] === \"-\" && key[1] === \"-\" ? key :\n\t\t\tkey === \"cssFloat\" ? \"float\" :\n\t\t\t\tkey.replace(uppercaseRegex, toLowerCase)\n\t}\n\tfunction updateStyle(element, old, style) {\n\t\tif (old === style) {\n\t\t\t// Styles are equivalent, do nothing.\n\t\t} else if (style == null) {\n\t\t\t// New style is missing, just clear it.\n\t\t\telement.style.cssText = \"\"\n\t\t} else if (typeof style !== \"object\") {\n\t\t\t// New style is a string, let engine deal with patching.\n\t\t\telement.style.cssText = style\n\t\t} else if (old == null || typeof old !== \"object\") {\n\t\t\t// `old` is missing or a string, `style` is an object.\n\t\t\telement.style.cssText = \"\"\n\t\t\t// Add new style properties\n\t\t\tfor (var key in style) {\n\t\t\t\tvar value = style[key]\n\t\t\t\tif (value != null) element.style.setProperty(normalizeKey(key), String(value))\n\t\t\t}\n\t\t} else {\n\t\t\t// Both old & new are (different) objects.\n\t\t\t// Update style properties that have changed\n\t\t\tfor (var key in style) {\n\t\t\t\tvar value = style[key]\n\t\t\t\tif (value != null && (value = String(value)) !== String(old[key])) {\n\t\t\t\t\telement.style.setProperty(normalizeKey(key), value)\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Remove style properties that no longer exist\n\t\t\tfor (var key in old) {\n\t\t\t\tif (old[key] != null && style[key] == null) {\n\t\t\t\t\telement.style.removeProperty(normalizeKey(key))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Here's an explanation of how this works:\n\t// 1. The event names are always (by design) prefixed by `on`.\n\t// 2. The EventListener interface accepts either a function or an object\n\t// with a `handleEvent` method.\n\t// 3. The object does not inherit from `Object.prototype`, to avoid\n\t// any potential interference with that (e.g. setters).\n\t// 4. The event name is remapped to the handler before calling it.\n\t// 5. In function-based event handlers, `ev.target === this`. We replicate\n\t// that below.\n\t// 6. In function-based event handlers, `return false` prevents the default\n\t// action and stops event propagation. We replicate that below.\n\tfunction EventDict() {\n\t\t// Save this, so the current redraw is correctly tracked.\n\t\tthis._ = currentRedraw\n\t}\n\tEventDict.prototype = Object.create(null)\n\tEventDict.prototype.handleEvent = function (ev) {\n\t\tvar handler = this[\"on\" + ev.type]\n\t\tvar result\n\t\tif (typeof handler === \"function\") result = handler.call(ev.currentTarget, ev)\n\t\telse if (typeof handler.handleEvent === \"function\") handler.handleEvent(ev)\n\t\tif (this._ && ev.redraw !== false) (0, this._)()\n\t\tif (result === false) {\n\t\t\tev.preventDefault()\n\t\t\tev.stopPropagation()\n\t\t}\n\t}\n\n\t//event\n\tfunction updateEvent(vnode, key, value) {\n\t\tif (vnode.events != null) {\n\t\t\tif (vnode.events[key] === value) return\n\t\t\tif (value != null && (typeof value === \"function\" || typeof value === \"object\")) {\n\t\t\t\tif (vnode.events[key] == null) vnode.dom.addEventListener(key.slice(2), vnode.events, false)\n\t\t\t\tvnode.events[key] = value\n\t\t\t} else {\n\t\t\t\tif (vnode.events[key] != null) vnode.dom.removeEventListener(key.slice(2), vnode.events, false)\n\t\t\t\tvnode.events[key] = undefined\n\t\t\t}\n\t\t} else if (value != null && (typeof value === \"function\" || typeof value === \"object\")) {\n\t\t\tvnode.events = new EventDict()\n\t\t\tvnode.dom.addEventListener(key.slice(2), vnode.events, false)\n\t\t\tvnode.events[key] = value\n\t\t}\n\t}\n\n\t//lifecycle\n\tfunction initLifecycle(source, vnode, hooks) {\n\t\tif (typeof source.oninit === \"function\") callHook.call(source.oninit, vnode)\n\t\tif (typeof source.oncreate === \"function\") hooks.push(callHook.bind(source.oncreate, vnode))\n\t}\n\tfunction updateLifecycle(source, vnode, hooks) {\n\t\tif (typeof source.onupdate === \"function\") hooks.push(callHook.bind(source.onupdate, vnode))\n\t}\n\tfunction shouldNotUpdate(vnode, old) {\n\t\tdo {\n\t\t\tif (vnode.attrs != null && typeof vnode.attrs.onbeforeupdate === \"function\") {\n\t\t\t\tvar force = callHook.call(vnode.attrs.onbeforeupdate, vnode, old)\n\t\t\t\tif (force !== undefined && !force) break\n\t\t\t}\n\t\t\tif (typeof vnode.tag !== \"string\" && typeof vnode.state.onbeforeupdate === \"function\") {\n\t\t\t\tvar force = callHook.call(vnode.state.onbeforeupdate, vnode, old)\n\t\t\t\tif (force !== undefined && !force) break\n\t\t\t}\n\t\t\treturn false\n\t\t} while (false); // eslint-disable-line no-constant-condition\n\t\tvnode.dom = old.dom\n\t\tvnode.domSize = old.domSize\n\t\tvnode.instance = old.instance\n\t\t// One would think having the actual latest attributes would be ideal,\n\t\t// but it doesn't let us properly diff based on our current internal\n\t\t// representation. We have to save not only the old DOM info, but also\n\t\t// the attributes used to create it, as we diff *that*, not against the\n\t\t// DOM directly (with a few exceptions in `setAttr`). And, of course, we\n\t\t// need to save the children and text as they are conceptually not\n\t\t// unlike special \"attributes\" internally.\n\t\tvnode.attrs = old.attrs\n\t\tvnode.children = old.children\n\t\tvnode.text = old.text\n\t\treturn true\n\t}\n\n\treturn function(dom, vnodes, redraw) {\n\t\tif (!dom) throw new TypeError(\"Ensure the DOM element being passed to m.route/m.mount/m.render is not undefined.\")\n\t\tvar hooks = []\n\t\tvar active = activeElement()\n\t\tvar namespace = dom.namespaceURI\n\n\t\t// First time rendering into a node clears it out\n\t\tif (dom.vnodes == null) dom.textContent = \"\"\n\n\t\tvnodes = Vnode.normalizeChildren(Array.isArray(vnodes) ? vnodes : [vnodes])\n\t\tvar prevRedraw = currentRedraw\n\t\ttry {\n\t\t\tcurrentRedraw = typeof redraw === \"function\" ? redraw : undefined\n\t\t\tupdateNodes(dom, dom.vnodes, vnodes, hooks, null, namespace === \"http://www.w3.org/1999/xhtml\" ? undefined : namespace)\n\t\t} finally {\n\t\t\tcurrentRedraw = prevRedraw\n\t\t}\n\t\tdom.vnodes = vnodes\n\t\t// `document.activeElement` can return null: https://html.spec.whatwg.org/multipage/interaction.html#dom-document-activeelement\n\t\tif (active != null && activeElement() !== active && typeof active.focus === \"function\") active.focus()\n\t\tfor (var i = 0; i < hooks.length; i++) hooks[i]()\n\t}\n}\n", "\"use strict\"\n\nmodule.exports = require(\"./render/render\")(window)\n", "\"use strict\"\n\nvar Vnode = require(\"../render/vnode\")\n\nmodule.exports = function(render, schedule, console) {\n\tvar subscriptions = []\n\tvar rendering = false\n\tvar pending = false\n\n\tfunction sync() {\n\t\tif (rendering) throw new Error(\"Nested m.redraw.sync() call\")\n\t\trendering = true\n\t\tfor (var i = 0; i < subscriptions.length; i += 2) {\n\t\t\ttry { render(subscriptions[i], Vnode(subscriptions[i + 1]), redraw) }\n\t\t\tcatch (e) { console.error(e) }\n\t\t}\n\t\trendering = false\n\t}\n\n\tfunction redraw() {\n\t\tif (!pending) {\n\t\t\tpending = true\n\t\t\tschedule(function() {\n\t\t\t\tpending = false\n\t\t\t\tsync()\n\t\t\t})\n\t\t}\n\t}\n\n\tredraw.sync = sync\n\n\tfunction mount(root, component) {\n\t\tif (component != null && component.view == null && typeof component !== \"function\") {\n\t\t\tthrow new TypeError(\"m.mount(element, component) expects a component, not a vnode\")\n\t\t}\n\n\t\tvar index = subscriptions.indexOf(root)\n\t\tif (index >= 0) {\n\t\t\tsubscriptions.splice(index, 2)\n\t\t\trender(root, [], redraw)\n\t\t}\n\n\t\tif (component != null) {\n\t\t\tsubscriptions.push(root, component)\n\t\t\trender(root, Vnode(component), redraw)\n\t\t}\n\t}\n\n\treturn {mount: mount, redraw: redraw}\n}\n", "\"use strict\"\n\nvar render = require(\"./render\")\n\nmodule.exports = require(\"./api/mount-redraw\")(render, requestAnimationFrame, console)\n", "\"use strict\"\n\nmodule.exports = function(object) {\n\tif (Object.prototype.toString.call(object) !== \"[object Object]\") return \"\"\n\n\tvar args = []\n\tfor (var key in object) {\n\t\tdestructure(key, object[key])\n\t}\n\n\treturn args.join(\"&\")\n\n\tfunction destructure(key, value) {\n\t\tif (Array.isArray(value)) {\n\t\t\tfor (var i = 0; i < value.length; i++) {\n\t\t\t\tdestructure(key + \"[\" + i + \"]\", value[i])\n\t\t\t}\n\t\t}\n\t\telse if (Object.prototype.toString.call(value) === \"[object Object]\") {\n\t\t\tfor (var i in value) {\n\t\t\t\tdestructure(key + \"[\" + i + \"]\", value[i])\n\t\t\t}\n\t\t}\n\t\telse args.push(encodeURIComponent(key) + (value != null && value !== \"\" ? \"=\" + encodeURIComponent(value) : \"\"))\n\t}\n}\n", "\"use strict\"\n\nmodule.exports = Object.assign || function(target, source) {\n\tif(source) Object.keys(source).forEach(function(key) { target[key] = source[key] })\n}\n", "\"use strict\"\n\nvar buildQueryString = require(\"../querystring/build\")\nvar assign = require(\"./assign\")\n\n// Returns `path` from `template` + `params`\nmodule.exports = function(template, params) {\n\tif ((/:([^\\/\\.-]+)(\\.{3})?:/).test(template)) {\n\t\tthrow new SyntaxError(\"Template parameter names *must* be separated\")\n\t}\n\tif (params == null) return template\n\tvar queryIndex = template.indexOf(\"?\")\n\tvar hashIndex = template.indexOf(\"#\")\n\tvar queryEnd = hashIndex < 0 ? template.length : hashIndex\n\tvar pathEnd = queryIndex < 0 ? queryEnd : queryIndex\n\tvar path = template.slice(0, pathEnd)\n\tvar query = {}\n\n\tassign(query, params)\n\n\tvar resolved = path.replace(/:([^\\/\\.-]+)(\\.{3})?/g, function(m, key, variadic) {\n\t\tdelete query[key]\n\t\t// If no such parameter exists, don't interpolate it.\n\t\tif (params[key] == null) return m\n\t\t// Escape normal parameters, but not variadic ones.\n\t\treturn variadic ? params[key] : encodeURIComponent(String(params[key]))\n\t})\n\n\t// In case the template substitution adds new query/hash parameters.\n\tvar newQueryIndex = resolved.indexOf(\"?\")\n\tvar newHashIndex = resolved.indexOf(\"#\")\n\tvar newQueryEnd = newHashIndex < 0 ? resolved.length : newHashIndex\n\tvar newPathEnd = newQueryIndex < 0 ? newQueryEnd : newQueryIndex\n\tvar result = resolved.slice(0, newPathEnd)\n\n\tif (queryIndex >= 0) result += template.slice(queryIndex, queryEnd)\n\tif (newQueryIndex >= 0) result += (queryIndex < 0 ? \"?\" : \"&\") + resolved.slice(newQueryIndex, newQueryEnd)\n\tvar querystring = buildQueryString(query)\n\tif (querystring) result += (queryIndex < 0 && newQueryIndex < 0 ? \"?\" : \"&\") + querystring\n\tif (hashIndex >= 0) result += template.slice(hashIndex)\n\tif (newHashIndex >= 0) result += (hashIndex < 0 ? \"\" : \"&\") + resolved.slice(newHashIndex)\n\treturn result\n}\n", "\"use strict\"\n\nvar buildPathname = require(\"../pathname/build\")\n\nmodule.exports = function($window, Promise, oncompletion) {\n\tvar callbackCount = 0\n\n\tfunction PromiseProxy(executor) {\n\t\treturn new Promise(executor)\n\t}\n\n\t// In case the global Promise is some userland library's where they rely on\n\t// `foo instanceof this.constructor`, `this.constructor.resolve(value)`, or\n\t// similar. Let's *not* break them.\n\tPromiseProxy.prototype = Promise.prototype\n\tPromiseProxy.__proto__ = Promise // eslint-disable-line no-proto\n\n\tfunction makeRequest(factory) {\n\t\treturn function(url, args) {\n\t\t\tif (typeof url !== \"string\") { args = url; url = url.url }\n\t\t\telse if (args == null) args = {}\n\t\t\tvar promise = new Promise(function(resolve, reject) {\n\t\t\t\tfactory(buildPathname(url, args.params), args, function (data) {\n\t\t\t\t\tif (typeof args.type === \"function\") {\n\t\t\t\t\t\tif (Array.isArray(data)) {\n\t\t\t\t\t\t\tfor (var i = 0; i < data.length; i++) {\n\t\t\t\t\t\t\t\tdata[i] = new args.type(data[i])\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse data = new args.type(data)\n\t\t\t\t\t}\n\t\t\t\t\tresolve(data)\n\t\t\t\t}, reject)\n\t\t\t})\n\t\t\tif (args.background === true) return promise\n\t\t\tvar count = 0\n\t\t\tfunction complete() {\n\t\t\t\tif (--count === 0 && typeof oncompletion === \"function\") oncompletion()\n\t\t\t}\n\n\t\t\treturn wrap(promise)\n\n\t\t\tfunction wrap(promise) {\n\t\t\t\tvar then = promise.then\n\t\t\t\t// Set the constructor, so engines know to not await or resolve\n\t\t\t\t// this as a native promise. At the time of writing, this is\n\t\t\t\t// only necessary for V8, but their behavior is the correct\n\t\t\t\t// behavior per spec. See this spec issue for more details:\n\t\t\t\t// https://github.com/tc39/ecma262/issues/1577. Also, see the\n\t\t\t\t// corresponding comment in `request/tests/test-request.js` for\n\t\t\t\t// a bit more background on the issue at hand.\n\t\t\t\tpromise.constructor = PromiseProxy\n\t\t\t\tpromise.then = function() {\n\t\t\t\t\tcount++\n\t\t\t\t\tvar next = then.apply(promise, arguments)\n\t\t\t\t\tnext.then(complete, function(e) {\n\t\t\t\t\t\tcomplete()\n\t\t\t\t\t\tif (count === 0) throw e\n\t\t\t\t\t})\n\t\t\t\t\treturn wrap(next)\n\t\t\t\t}\n\t\t\t\treturn promise\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction hasHeader(args, name) {\n\t\tfor (var key in args.headers) {\n\t\t\tif ({}.hasOwnProperty.call(args.headers, key) && name.test(key)) return true\n\t\t}\n\t\treturn false\n\t}\n\n\treturn {\n\t\trequest: makeRequest(function(url, args, resolve, reject) {\n\t\t\tvar method = args.method != null ? args.method.toUpperCase() : \"GET\"\n\t\t\tvar body = args.body\n\t\t\tvar assumeJSON = (args.serialize == null || args.serialize === JSON.serialize) && !(body instanceof $window.FormData)\n\t\t\tvar responseType = args.responseType || (typeof args.extract === \"function\" ? \"\" : \"json\")\n\n\t\t\tvar xhr = new $window.XMLHttpRequest(), aborted = false\n\t\t\tvar original = xhr, replacedAbort\n\t\t\tvar abort = xhr.abort\n\n\t\t\txhr.abort = function() {\n\t\t\t\taborted = true\n\t\t\t\tabort.call(this)\n\t\t\t}\n\n\t\t\txhr.open(method, url, args.async !== false, typeof args.user === \"string\" ? args.user : undefined, typeof args.password === \"string\" ? args.password : undefined)\n\n\t\t\tif (assumeJSON && body != null && !hasHeader(args, /^content-type$/i)) {\n\t\t\t\txhr.setRequestHeader(\"Content-Type\", \"application/json; charset=utf-8\")\n\t\t\t}\n\t\t\tif (typeof args.deserialize !== \"function\" && !hasHeader(args, /^accept$/i)) {\n\t\t\t\txhr.setRequestHeader(\"Accept\", \"application/json, text/*\")\n\t\t\t}\n\t\t\tif (args.withCredentials) xhr.withCredentials = args.withCredentials\n\t\t\tif (args.timeout) xhr.timeout = args.timeout\n\t\t\txhr.responseType = responseType\n\n\t\t\tfor (var key in args.headers) {\n\t\t\t\tif ({}.hasOwnProperty.call(args.headers, key)) {\n\t\t\t\t\txhr.setRequestHeader(key, args.headers[key])\n\t\t\t\t}\n\t\t\t}\n\n\t\t\txhr.onreadystatechange = function(ev) {\n\t\t\t\t// Don't throw errors on xhr.abort().\n\t\t\t\tif (aborted) return\n\n\t\t\t\tif (ev.target.readyState === 4) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tvar success = (ev.target.status >= 200 && ev.target.status < 300) || ev.target.status === 304 || (/^file:\\/\\//i).test(url)\n\t\t\t\t\t\t// When the response type isn't \"\" or \"text\",\n\t\t\t\t\t\t// `xhr.responseText` is the wrong thing to use.\n\t\t\t\t\t\t// Browsers do the right thing and throw here, and we\n\t\t\t\t\t\t// should honor that and do the right thing by\n\t\t\t\t\t\t// preferring `xhr.response` where possible/practical.\n\t\t\t\t\t\tvar response = ev.target.response, message\n\n\t\t\t\t\t\tif (responseType === \"json\") {\n\t\t\t\t\t\t\t// For IE and Edge, which don't implement\n\t\t\t\t\t\t\t// `responseType: \"json\"`.\n\t\t\t\t\t\t\tif (!ev.target.responseType && typeof args.extract !== \"function\") response = JSON.parse(ev.target.responseText)\n\t\t\t\t\t\t} else if (!responseType || responseType === \"text\") {\n\t\t\t\t\t\t\t// Only use this default if it's text. If a parsed\n\t\t\t\t\t\t\t// document is needed on old IE and friends (all\n\t\t\t\t\t\t\t// unsupported), the user should use a custom\n\t\t\t\t\t\t\t// `config` instead. They're already using this at\n\t\t\t\t\t\t\t// their own risk.\n\t\t\t\t\t\t\tif (response == null) response = ev.target.responseText\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (typeof args.extract === \"function\") {\n\t\t\t\t\t\t\tresponse = args.extract(ev.target, args)\n\t\t\t\t\t\t\tsuccess = true\n\t\t\t\t\t\t} else if (typeof args.deserialize === \"function\") {\n\t\t\t\t\t\t\tresponse = args.deserialize(response)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (success) resolve(response)\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\ttry { message = ev.target.responseText }\n\t\t\t\t\t\t\tcatch (e) { message = response }\n\t\t\t\t\t\t\tvar error = new Error(message)\n\t\t\t\t\t\t\terror.code = ev.target.status\n\t\t\t\t\t\t\terror.response = response\n\t\t\t\t\t\t\treject(error)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tcatch (e) {\n\t\t\t\t\t\treject(e)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (typeof args.config === \"function\") {\n\t\t\t\txhr = args.config(xhr, args, url) || xhr\n\n\t\t\t\t// Propagate the `abort` to any replacement XHR as well.\n\t\t\t\tif (xhr !== original) {\n\t\t\t\t\treplacedAbort = xhr.abort\n\t\t\t\t\txhr.abort = function() {\n\t\t\t\t\t\taborted = true\n\t\t\t\t\t\treplacedAbort.call(this)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (body == null) xhr.send()\n\t\t\telse if (typeof args.serialize === \"function\") xhr.send(args.serialize(body))\n\t\t\telse if (body instanceof $window.FormData) xhr.send(body)\n\t\t\telse xhr.send(JSON.stringify(body))\n\t\t}),\n\t\tjsonp: makeRequest(function(url, args, resolve, reject) {\n\t\t\tvar callbackName = args.callbackName || \"_mithril_\" + Math.round(Math.random() * 1e16) + \"_\" + callbackCount++\n\t\t\tvar script = $window.document.createElement(\"script\")\n\t\t\t$window[callbackName] = function(data) {\n\t\t\t\tdelete $window[callbackName]\n\t\t\t\tscript.parentNode.removeChild(script)\n\t\t\t\tresolve(data)\n\t\t\t}\n\t\t\tscript.onerror = function() {\n\t\t\t\tdelete $window[callbackName]\n\t\t\t\tscript.parentNode.removeChild(script)\n\t\t\t\treject(new Error(\"JSONP request failed\"))\n\t\t\t}\n\t\t\tscript.src = url + (url.indexOf(\"?\") < 0 ? \"?\" : \"&\") +\n\t\t\t\tencodeURIComponent(args.callbackKey || \"callback\") + \"=\" +\n\t\t\t\tencodeURIComponent(callbackName)\n\t\t\t$window.document.documentElement.appendChild(script)\n\t\t}),\n\t}\n}\n", "\"use strict\"\n\nvar PromisePolyfill = require(\"./promise/promise\")\nvar mountRedraw = require(\"./mount-redraw\")\n\nmodule.exports = require(\"./request/request\")(window, PromisePolyfill, mountRedraw.redraw)\n", "\"use strict\"\n\nmodule.exports = function(string) {\n\tif (string === \"\" || string == null) return {}\n\tif (string.charAt(0) === \"?\") string = string.slice(1)\n\n\tvar entries = string.split(\"&\"), counters = {}, data = {}\n\tfor (var i = 0; i < entries.length; i++) {\n\t\tvar entry = entries[i].split(\"=\")\n\t\tvar key = decodeURIComponent(entry[0])\n\t\tvar value = entry.length === 2 ? decodeURIComponent(entry[1]) : \"\"\n\n\t\tif (value === \"true\") value = true\n\t\telse if (value === \"false\") value = false\n\n\t\tvar levels = key.split(/\\]\\[?|\\[/)\n\t\tvar cursor = data\n\t\tif (key.indexOf(\"[\") > -1) levels.pop()\n\t\tfor (var j = 0; j < levels.length; j++) {\n\t\t\tvar level = levels[j], nextLevel = levels[j + 1]\n\t\t\tvar isNumber = nextLevel == \"\" || !isNaN(parseInt(nextLevel, 10))\n\t\t\tif (level === \"\") {\n\t\t\t\tvar key = levels.slice(0, j).join()\n\t\t\t\tif (counters[key] == null) {\n\t\t\t\t\tcounters[key] = Array.isArray(cursor) ? cursor.length : 0\n\t\t\t\t}\n\t\t\t\tlevel = counters[key]++\n\t\t\t}\n\t\t\t// Disallow direct prototype pollution\n\t\t\telse if (level === \"__proto__\") break\n\t\t\tif (j === levels.length - 1) cursor[level] = value\n\t\t\telse {\n\t\t\t\t// Read own properties exclusively to disallow indirect\n\t\t\t\t// prototype pollution\n\t\t\t\tvar desc = Object.getOwnPropertyDescriptor(cursor, level)\n\t\t\t\tif (desc != null) desc = desc.value\n\t\t\t\tif (desc == null) cursor[level] = desc = isNumber ? [] : {}\n\t\t\t\tcursor = desc\n\t\t\t}\n\t\t}\n\t}\n\treturn data\n}\n", "\"use strict\"\n\nvar parseQueryString = require(\"../querystring/parse\")\n\n// Returns `{path, params}` from `url`\nmodule.exports = function(url) {\n\tvar queryIndex = url.indexOf(\"?\")\n\tvar hashIndex = url.indexOf(\"#\")\n\tvar queryEnd = hashIndex < 0 ? url.length : hashIndex\n\tvar pathEnd = queryIndex < 0 ? queryEnd : queryIndex\n\tvar path = url.slice(0, pathEnd).replace(/\\/{2,}/g, \"/\")\n\n\tif (!path) path = \"/\"\n\telse {\n\t\tif (path[0] !== \"/\") path = \"/\" + path\n\t\tif (path.length > 1 && path[path.length - 1] === \"/\") path = path.slice(0, -1)\n\t}\n\treturn {\n\t\tpath: path,\n\t\tparams: queryIndex < 0\n\t\t\t? {}\n\t\t\t: parseQueryString(url.slice(queryIndex + 1, queryEnd)),\n\t}\n}\n", "\"use strict\"\n\nvar parsePathname = require(\"./parse\")\n\n// Compiles a template into a function that takes a resolved path (without query\n// strings) and returns an object containing the template parameters with their\n// parsed values. This expects the input of the compiled template to be the\n// output of `parsePathname`. Note that it does *not* remove query parameters\n// specified in the template.\nmodule.exports = function(template) {\n\tvar templateData = parsePathname(template)\n\tvar templateKeys = Object.keys(templateData.params)\n\tvar keys = []\n\tvar regexp = new RegExp(\"^\" + templateData.path.replace(\n\t\t// I escape literal text so people can use things like `:file.:ext` or\n\t\t// `:lang-:locale` in routes. This is all merged into one pass so I\n\t\t// don't also accidentally escape `-` and make it harder to detect it to\n\t\t// ban it from template parameters.\n\t\t/:([^\\/.-]+)(\\.{3}|\\.(?!\\.)|-)?|[\\\\^$*+.()|\\[\\]{}]/g,\n\t\tfunction(m, key, extra) {\n\t\t\tif (key == null) return \"\\\\\" + m\n\t\t\tkeys.push({k: key, r: extra === \"...\"})\n\t\t\tif (extra === \"...\") return \"(.*)\"\n\t\t\tif (extra === \".\") return \"([^/]+)\\\\.\"\n\t\t\treturn \"([^/]+)\" + (extra || \"\")\n\t\t}\n\t) + \"$\")\n\treturn function(data) {\n\t\t// First, check the params. Usually, there isn't any, and it's just\n\t\t// checking a static set.\n\t\tfor (var i = 0; i < templateKeys.length; i++) {\n\t\t\tif (templateData.params[templateKeys[i]] !== data.params[templateKeys[i]]) return false\n\t\t}\n\t\t// If no interpolations exist, let's skip all the ceremony\n\t\tif (!keys.length) return regexp.test(data.path)\n\t\tvar values = regexp.exec(data.path)\n\t\tif (values == null) return false\n\t\tfor (var i = 0; i < keys.length; i++) {\n\t\t\tdata.params[keys[i].k] = keys[i].r ? values[i + 1] : decodeURIComponent(values[i + 1])\n\t\t}\n\t\treturn true\n\t}\n}\n", "\"use strict\"\n\nvar Vnode = require(\"../render/vnode\")\nvar m = require(\"../render/hyperscript\")\nvar Promise = require(\"../promise/promise\")\n\nvar buildPathname = require(\"../pathname/build\")\nvar parsePathname = require(\"../pathname/parse\")\nvar compileTemplate = require(\"../pathname/compileTemplate\")\nvar assign = require(\"../pathname/assign\")\n\nvar sentinel = {}\n\nmodule.exports = function($window, mountRedraw) {\n\tvar fireAsync\n\n\tfunction setPath(path, data, options) {\n\t\tpath = buildPathname(path, data)\n\t\tif (fireAsync != null) {\n\t\t\tfireAsync()\n\t\t\tvar state = options ? options.state : null\n\t\t\tvar title = options ? options.title : null\n\t\t\tif (options && options.replace) $window.history.replaceState(state, title, route.prefix + path)\n\t\t\telse $window.history.pushState(state, title, route.prefix + path)\n\t\t}\n\t\telse {\n\t\t\t$window.location.href = route.prefix + path\n\t\t}\n\t}\n\n\tvar currentResolver = sentinel, component, attrs, currentPath, lastUpdate\n\n\tvar SKIP = route.SKIP = {}\n\n\tfunction route(root, defaultRoute, routes) {\n\t\tif (root == null) throw new Error(\"Ensure the DOM element that was passed to `m.route` is not undefined\")\n\t\t// 0 = start\n\t\t// 1 = init\n\t\t// 2 = ready\n\t\tvar state = 0\n\n\t\tvar compiled = Object.keys(routes).map(function(route) {\n\t\t\tif (route[0] !== \"/\") throw new SyntaxError(\"Routes must start with a `/`\")\n\t\t\tif ((/:([^\\/\\.-]+)(\\.{3})?:/).test(route)) {\n\t\t\t\tthrow new SyntaxError(\"Route parameter names must be separated with either `/`, `.`, or `-`\")\n\t\t\t}\n\t\t\treturn {\n\t\t\t\troute: route,\n\t\t\t\tcomponent: routes[route],\n\t\t\t\tcheck: compileTemplate(route),\n\t\t\t}\n\t\t})\n\t\tvar callAsync = typeof setImmediate === \"function\" ? setImmediate : setTimeout\n\t\tvar p = Promise.resolve()\n\t\tvar scheduled = false\n\t\tvar onremove\n\n\t\tfireAsync = null\n\n\t\tif (defaultRoute != null) {\n\t\t\tvar defaultData = parsePathname(defaultRoute)\n\n\t\t\tif (!compiled.some(function (i) { return i.check(defaultData) })) {\n\t\t\t\tthrow new ReferenceError(\"Default route doesn't match any known routes\")\n\t\t\t}\n\t\t}\n\n\t\tfunction resolveRoute() {\n\t\t\tscheduled = false\n\t\t\t// Consider the pathname holistically. The prefix might even be invalid,\n\t\t\t// but that's not our problem.\n\t\t\tvar prefix = $window.location.hash\n\t\t\tif (route.prefix[0] !== \"#\") {\n\t\t\t\tprefix = $window.location.search + prefix\n\t\t\t\tif (route.prefix[0] !== \"?\") {\n\t\t\t\t\tprefix = $window.location.pathname + prefix\n\t\t\t\t\tif (prefix[0] !== \"/\") prefix = \"/\" + prefix\n\t\t\t\t}\n\t\t\t}\n\t\t\t// This seemingly useless `.concat()` speeds up the tests quite a bit,\n\t\t\t// since the representation is consistently a relatively poorly\n\t\t\t// optimized cons string.\n\t\t\tvar path = prefix.concat()\n\t\t\t\t.replace(/(?:%[a-f89][a-f0-9])+/gim, decodeURIComponent)\n\t\t\t\t.slice(route.prefix.length)\n\t\t\tvar data = parsePathname(path)\n\n\t\t\tassign(data.params, $window.history.state)\n\n\t\t\tfunction fail() {\n\t\t\t\tif (path === defaultRoute) throw new Error(\"Could not resolve default route \" + defaultRoute)\n\t\t\t\tsetPath(defaultRoute, null, {replace: true})\n\t\t\t}\n\n\t\t\tloop(0)\n\t\t\tfunction loop(i) {\n\t\t\t\t// 0 = init\n\t\t\t\t// 1 = scheduled\n\t\t\t\t// 2 = done\n\t\t\t\tfor (; i < compiled.length; i++) {\n\t\t\t\t\tif (compiled[i].check(data)) {\n\t\t\t\t\t\tvar payload = compiled[i].component\n\t\t\t\t\t\tvar matchedRoute = compiled[i].route\n\t\t\t\t\t\tvar localComp = payload\n\t\t\t\t\t\tvar update = lastUpdate = function(comp) {\n\t\t\t\t\t\t\tif (update !== lastUpdate) return\n\t\t\t\t\t\t\tif (comp === SKIP) return loop(i + 1)\n\t\t\t\t\t\t\tcomponent = comp != null && (typeof comp.view === \"function\" || typeof comp === \"function\")? comp : \"div\"\n\t\t\t\t\t\t\tattrs = data.params, currentPath = path, lastUpdate = null\n\t\t\t\t\t\t\tcurrentResolver = payload.render ? payload : null\n\t\t\t\t\t\t\tif (state === 2) mountRedraw.redraw()\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tstate = 2\n\t\t\t\t\t\t\t\tmountRedraw.redraw.sync()\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// There's no understating how much I *wish* I could\n\t\t\t\t\t\t// use `async`/`await` here...\n\t\t\t\t\t\tif (payload.view || typeof payload === \"function\") {\n\t\t\t\t\t\t\tpayload = {}\n\t\t\t\t\t\t\tupdate(localComp)\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (payload.onmatch) {\n\t\t\t\t\t\t\tp.then(function () {\n\t\t\t\t\t\t\t\treturn payload.onmatch(data.params, path, matchedRoute)\n\t\t\t\t\t\t\t}).then(update, fail)\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse update(\"div\")\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfail()\n\t\t\t}\n\t\t}\n\n\t\t// Set it unconditionally so `m.route.set` and `m.route.Link` both work,\n\t\t// even if neither `pushState` nor `hashchange` are supported. It's\n\t\t// cleared if `hashchange` is used, since that makes it automatically\n\t\t// async.\n\t\tfireAsync = function() {\n\t\t\tif (!scheduled) {\n\t\t\t\tscheduled = true\n\t\t\t\tcallAsync(resolveRoute)\n\t\t\t}\n\t\t}\n\n\t\tif (typeof $window.history.pushState === \"function\") {\n\t\t\tonremove = function() {\n\t\t\t\t$window.removeEventListener(\"popstate\", fireAsync, false)\n\t\t\t}\n\t\t\t$window.addEventListener(\"popstate\", fireAsync, false)\n\t\t} else if (route.prefix[0] === \"#\") {\n\t\t\tfireAsync = null\n\t\t\tonremove = function() {\n\t\t\t\t$window.removeEventListener(\"hashchange\", resolveRoute, false)\n\t\t\t}\n\t\t\t$window.addEventListener(\"hashchange\", resolveRoute, false)\n\t\t}\n\n\t\treturn mountRedraw.mount(root, {\n\t\t\tonbeforeupdate: function() {\n\t\t\t\tstate = state ? 2 : 1\n\t\t\t\treturn !(!state || sentinel === currentResolver)\n\t\t\t},\n\t\t\toncreate: resolveRoute,\n\t\t\tonremove: onremove,\n\t\t\tview: function() {\n\t\t\t\tif (!state || sentinel === currentResolver) return\n\t\t\t\t// Wrap in a fragment to preserve existing key semantics\n\t\t\t\tvar vnode = [Vnode(component, attrs.key, attrs)]\n\t\t\t\tif (currentResolver) vnode = currentResolver.render(vnode[0])\n\t\t\t\treturn vnode\n\t\t\t},\n\t\t})\n\t}\n\troute.set = function(path, data, options) {\n\t\tif (lastUpdate != null) {\n\t\t\toptions = options || {}\n\t\t\toptions.replace = true\n\t\t}\n\t\tlastUpdate = null\n\t\tsetPath(path, data, options)\n\t}\n\troute.get = function() {return currentPath}\n\troute.prefix = \"#!\"\n\troute.Link = {\n\t\tview: function(vnode) {\n\t\t\tvar options = vnode.attrs.options\n\t\t\t// Remove these so they don't get overwritten\n\t\t\tvar attrs = {}, onclick, href\n\t\t\tassign(attrs, vnode.attrs)\n\t\t\t// The first two are internal, but the rest are magic attributes\n\t\t\t// that need censored to not screw up rendering.\n\t\t\tattrs.selector = attrs.options = attrs.key = attrs.oninit =\n\t\t\tattrs.oncreate = attrs.onbeforeupdate = attrs.onupdate =\n\t\t\tattrs.onbeforeremove = attrs.onremove = null\n\n\t\t\t// Do this now so we can get the most current `href` and `disabled`.\n\t\t\t// Those attributes may also be specified in the selector, and we\n\t\t\t// should honor that.\n\t\t\tvar child = m(vnode.attrs.selector || \"a\", attrs, vnode.children)\n\n\t\t\t// Let's provide a *right* way to disable a route link, rather than\n\t\t\t// letting people screw up accessibility on accident.\n\t\t\t//\n\t\t\t// The attribute is coerced so users don't get surprised over\n\t\t\t// `disabled: 0` resulting in a button that's somehow routable\n\t\t\t// despite being visibly disabled.\n\t\t\tif (child.attrs.disabled = Boolean(child.attrs.disabled)) {\n\t\t\t\tchild.attrs.href = null\n\t\t\t\tchild.attrs[\"aria-disabled\"] = \"true\"\n\t\t\t\t// If you *really* do want to do this on a disabled link, use\n\t\t\t\t// an `oncreate` hook to add it.\n\t\t\t\tchild.attrs.onclick = null\n\t\t\t} else {\n\t\t\t\tonclick = child.attrs.onclick\n\t\t\t\thref = child.attrs.href\n\t\t\t\tchild.attrs.href = route.prefix + href\n\t\t\t\tchild.attrs.onclick = function(e) {\n\t\t\t\t\tvar result\n\t\t\t\t\tif (typeof onclick === \"function\") {\n\t\t\t\t\t\tresult = onclick.call(e.currentTarget, e)\n\t\t\t\t\t} else if (onclick == null || typeof onclick !== \"object\") {\n\t\t\t\t\t\t// do nothing\n\t\t\t\t\t} else if (typeof onclick.handleEvent === \"function\") {\n\t\t\t\t\t\tonclick.handleEvent(e)\n\t\t\t\t\t}\n\n\t\t\t\t\t// Adapted from React Router's implementation:\n\t\t\t\t\t// https://github.com/ReactTraining/react-router/blob/520a0acd48ae1b066eb0b07d6d4d1790a1d02482/packages/react-router-dom/modules/Link.js\n\t\t\t\t\t//\n\t\t\t\t\t// Try to be flexible and intuitive in how we handle links.\n\t\t\t\t\t// Fun fact: links aren't as obvious to get right as you\n\t\t\t\t\t// would expect. There's a lot more valid ways to click a\n\t\t\t\t\t// link than this, and one might want to not simply click a\n\t\t\t\t\t// link, but right click or command-click it to copy the\n\t\t\t\t\t// link target, etc. Nope, this isn't just for blind people.\n\t\t\t\t\tif (\n\t\t\t\t\t\t// Skip if `onclick` prevented default\n\t\t\t\t\t\tresult !== false && !e.defaultPrevented &&\n\t\t\t\t\t\t// Ignore everything but left clicks\n\t\t\t\t\t\t(e.button === 0 || e.which === 0 || e.which === 1) &&\n\t\t\t\t\t\t// Let the browser handle `target=_blank`, etc.\n\t\t\t\t\t\t(!e.currentTarget.target || e.currentTarget.target === \"_self\") &&\n\t\t\t\t\t\t// No modifier keys\n\t\t\t\t\t\t!e.ctrlKey && !e.metaKey && !e.shiftKey && !e.altKey\n\t\t\t\t\t) {\n\t\t\t\t\t\te.preventDefault()\n\t\t\t\t\t\te.redraw = false\n\t\t\t\t\t\troute.set(href, null, options)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn child\n\t\t},\n\t}\n\troute.param = function(key) {\n\t\treturn attrs && key != null ? attrs[key] : attrs\n\t}\n\n\treturn route\n}\n", "\"use strict\"\n\nvar mountRedraw = require(\"./mount-redraw\")\n\nmodule.exports = require(\"./api/router\")(window, mountRedraw)\n", "\"use strict\"\n\nvar hyperscript = require(\"./hyperscript\")\nvar request = require(\"./request\")\nvar mountRedraw = require(\"./mount-redraw\")\n\nvar m = function m() { return hyperscript.apply(this, arguments) }\nm.m = hyperscript\nm.trust = hyperscript.trust\nm.fragment = hyperscript.fragment\nm.mount = mountRedraw.mount\nm.route = require(\"./route\")\nm.render = require(\"./render\")\nm.redraw = mountRedraw.redraw\nm.request = request.request\nm.jsonp = request.jsonp\nm.parseQueryString = require(\"./querystring/parse\")\nm.buildQueryString = require(\"./querystring/build\")\nm.parsePathname = require(\"./pathname/parse\")\nm.buildPathname = require(\"./pathname/build\")\nm.vnode = require(\"./render/vnode\")\nm.PromisePolyfill = require(\"./promise/polyfill\")\n\nmodule.exports = m\n", "import m from \"mithril\"\nimport { openDB } from \"idb\"\nimport { lightFormat } from \"date-fns\"\n\nconst dbPromise = openDB(\"minoteaur\", 1, {\n upgrade: (db, oldVersion) => {\n if (oldVersion < 1) { db.createObjectStore(\"drafts\") }\n },\n blocking: () => { window.location.reload() }\n});\n// debugging thing\ndbPromise.then(x => { window.idb = x })\n\nconst searchState = {\n showingSearchDialog: false,\n searchResults: [],\n searchError: null,\n searchQuery: \"\"\n}\n\nconst lowercaseFirst = ([first, ...rest]) => first.toLowerCase() + rest.join(\"\")\nconst uppercaseFirst = ([first, ...rest]) => first.toUpperCase() + rest.join(\"\")\nconst pageToSlug = page => page.split(/[ _]/).map(lowercaseFirst).join(\"_\")\nconst slugToPage = slug => slug.split(/[ _]/).map(uppercaseFirst).join(\" \")\n\nconst urlForPage = (page, subpage) => {\n let p = `/${encodeURIComponent(pageToSlug(page))}`\n if (subpage) { p += \"/\" + subpage }\n return p\n}\n\nconst handleHTTPError = e => {\n window.lastError = e\n console.warn(e)\n let x = `HTTP error ${e.code}`\n if (e.message !== null) { x += \" \" + e.message }\n searchState.searchError = x\n}\n\nconst onsearch = ev => {\n const query = ev.target.value\n searchState.searchQuery = query\n m.request({\n url: \"/api/search\",\n params: { q: query }\n }).then(x => {\n if (typeof x === \"string\") { // error from server\n console.warn(x)\n searchState.searchError = x\n } else {\n searchState.searchResults = x\n searchState.searchError = null\n }\n }, handleHTTPError)\n}\n\nconst currentPage = slugToPage(decodeURIComponent(/^\\/([^/]+)/.exec(location.pathname)[1]).replace(/\\+/g, \" \"))\n\nconst searchKeyHandler = ev => {\n if (ev.code === \"Enter\") { // enter key\n // not very useful to just navigate to the same page\n const otherResults = searchState.searchResults.filter(r => r.page !== currentPage)\n if (otherResults[0]) { location.href = urlForPage(otherResults[0].page) }\n }\n}\n\nconst SearchDialog = {\n view: () => m(\".dialog.search\", [\n m(\"h1\", \"Search\"),\n m(\"input[type=search]\", { placeholder: \"Query\", oninput: onsearch, onkeydown: searchKeyHandler, value: searchState.searchQuery, oncreate: ({ dom }) => dom.focus() }),\n searchState.searchError && m(\".error\", searchState.searchError),\n m(\"ul\", searchState.searchResults.map(x => m(\"li\", [\n m(\".flex-space\", [ m(\"a.wikilink\", { href: urlForPage(x.page) }, x.page), m(\"\", x.rank.toFixed(3)) ]),\n m(\"\", x.snippet.map(s => s[0] ? m(\"span.highlight\", s[1]) : s[1]))\n ])))\n ])\n}\n\nconst SearchApp = {\n view: () => m(\"\", searchState.showingSearchDialog ? m(SearchDialog) : null)\n}\n\nconst mountpoint = document.createElement(\"div\")\ndocument.querySelector(\"main\").insertBefore(mountpoint, document.querySelector(\".header\"))\nm.mount(mountpoint, SearchApp)\n\nconst searchButton = document.querySelector(\"nav .search\")\n\nsearchButton.addEventListener(\"click\", e => {\n searchState.showingSearchDialog = !searchState.showingSearchDialog\n e.preventDefault()\n m.redraw()\n})\n\n// basic keyboard shortcuts - search, switch to view/edit/revs\ndocument.body.addEventListener(\"keydown\", e => {\n if (e.target === document.body) { // detect only unfocused keypresses - ctrl+key seems to cause issues when copy/pasting\n if (e.key === \"e\") {\n location.pathname = urlForPage(currentPage, \"edit\")\n } else if (e.key === \"v\") {\n location.pathname = urlForPage(currentPage)\n } else if (e.key === \"r\") {\n location.pathname = urlForPage(currentPage, \"revisions\")\n } else if (e.key === \"/\") {\n searchState.showingSearchDialog = !searchState.showingSearchDialog\n e.preventDefault()\n m.redraw()\n }\n }\n})\n\nconst debounce = (fn, timeout = 250) => {\n let timer;\n return () => {\n clearTimeout(timer)\n timer = setTimeout(fn, timeout)\n }\n}\n\nconst dispDateTime = dt => lightFormat(dt, \"yyyy-MM-dd HH:mm:ss\")\n\nconst wordCount = s => {\n let words = 0\n for (const possibleWord of s.split(/\\s+/)) {\n if (/[^#*+>|`-]/.test(possibleWord)) { words += 1 }\n }\n return words\n}\nconst lineCount = s => s.split(\"\\n\").length\n\nconst editor = document.querySelector(\".edit-form textarea\")\nif (editor) {\n const editorUIState = {\n keypresses: 0,\n draftSelected: false\n }\n const mountpoint = document.createElement(\"div\")\n document.querySelector(\".sidebar\").appendChild(mountpoint)\n\n // automatic resize of textareas upon typing\n // this is slightly \"efficient\" in that it avoids constantly setting the height to 0 and back in a few situations, which is seemingly quite expensive\n let lengthWas = Infinity\n const resize = () => {\n const scrolltop = document.body.scrollTop\n const targetHeight = editor.scrollHeight + 2\n if (targetHeight != editor.style.height.slice(0, -2) || lengthWas > editor.value.length) {\n editor.style.height = 0\n editor.style.height = editor.scrollHeight + 2\n document.body.scrollTop = scrolltop\n }\n lengthWas = editor.value.length\n }\n\n // retrieve last edit timestamp from field\n const lastEditTime = parseInt(document.querySelector(\"input[name=last-edit]\").value)\n const serverValue = editor.value\n\n // load in the initially loaded draft\n const swapInDraft = () => {\n if (!editorUIState.initialDraft) { return }\n editorUIState.draftSelected = true\n editor.value = editorUIState.initialDraft.text\n resize()\n }\n // load in the initial page from the server\n const swapInServer = () => {\n console.log(\"server value swapped in, allegedly?\")\n editorUIState.draftSelected = false\n console.log(editor.value, serverValue)\n editor.value = serverValue\n resize()\n }\n\n dbPromise.then(db => db.get(\"drafts\", currentPage)).then(draft => {\n editorUIState.initialDraft = draft\n console.log(\"loaded memetic/beemetic entity \", draft)\n // if the draft is newer than the server page, load it in (the user can override this)\n if (draft.ts > lastEditTime) {\n swapInDraft()\n }\n m.redraw()\n })\n\n const DraftInfo = {\n view: () => editorUIState.initialDraft == null ? \"No draft\" : [\n m(editorUIState.draftSelected ? \".selected\" : \"\", { onclick: swapInDraft }, `Draft from ${dispDateTime(editorUIState.initialDraft.ts)}`),\n lastEditTime > 0 && m(editorUIState.draftSelected ? \"\" : \".selected\", { onclick: swapInServer }, `Page from ${dispDateTime(lastEditTime)}`)\n ]\n }\n\n const EditorUIApp = {\n view: () => [\n m(\"\", `${editorUIState.chars} chars`),\n m(\"\", `${editorUIState.words} words`),\n m(\"\", `${editorUIState.lines} lines`),\n m(\"\", `${editorUIState.keypresses} keypresses`),\n m(DraftInfo)\n ]\n }\n\n const updateCounts = text => {\n editorUIState.words = wordCount(text)\n editorUIState.lines = lineCount(text)\n editorUIState.chars = text.length // incorrect for some unicode, but doing it correctly would be more complex and slow\n }\n updateCounts(editor.value)\n\n m.mount(mountpoint, EditorUIApp)\n\n editor.addEventListener(\"keypress\", ev => {\n const selStart = editor.selectionStart\n const selEnd = editor.selectionEnd\n if (selStart !== selEnd) return // text is actually selected; these shortcuts are not meant for that situation\n\n const search = \"\\n\" + editor.value.substr(0, selStart)\n const lastLineStart = search.lastIndexOf(\"\\n\") + 1 // drop the \\n\n const nextLineStart = selStart + (editor.value.substr(selStart) + \"\\n\").indexOf(\"\\n\")\n\n if (ev.code === \"Enter\") { // enter\n // save on ctrl+enter\n if (ev.ctrlKey) {\n editor.parentElement.submit()\n return\n }\n\n const line = search.substr(lastLineStart)\n // detect lists on the previous line to continue on the next one\n const match = /^(\\s*)(([*+-])|(\\d+)([).]))(\\s*)/.exec(line)\n if (match) {\n // if it is an unordered list, just take the bullet type + associated whitespace\n // if it is an ordered list, increment the number and take the dot/paren and whitespace\n const lineStart = match[1] + (match[4] ? (parseInt(match[4]) + 1).toString() + match[5] : match[2]) + match[6]\n // get everything after the cursor on the same line\n const contentAfterCursor = editor.value.slice(selStart, nextLineStart)\n // all the content of the textbox preceding where the cursor should now be\n const prev = editor.value.substr(0, selStart) + \"\\n\" + lineStart\n // update editor\n editor.value = prev + contentAfterCursor + editor.value.substr(nextLineStart)\n editor.selectionStart = editor.selectionEnd = prev.length\n resize()\n ev.preventDefault()\n }\n }\n })\n editor.addEventListener(\"keydown\", ev => {\n const selStart = editor.selectionStart\n const selEnd = editor.selectionEnd\n if (selStart !== selEnd) return\n\n const search = \"\\n\" + editor.value.substr(0, selStart)\n // this is missing the + 1 that the enter key listener has. I forgot why. Good luck working out this!\n const lastLineStart = search.lastIndexOf(\"\\n\")\n const nextLineStart = selStart + (editor.value.substr(selStart) + \"\\n\").indexOf(\"\\n\")\n if (ev.code === \"Backspace\") {\n // detect if backspacing the start of a list line\n const re = /^\\s*([*+-]|\\d+[).])\\s*$/y\n if (re.test(editor.value.slice(lastLineStart, selStart))) {\n // if so, remove entire list line start at once\n const before = editor.value.substr(0, lastLineStart)\n const after = editor.value.substr(selStart)\n editor.value = before + after\n editor.selectionStart = editor.selectionEnd = before.length\n resize()\n ev.preventDefault()\n }\n } else if (ev.code === \"Tab\") {\n // indent/dedent lists by 2 spaces, depending on shift key\n const match = /^(\\s*)([*+-]|\\d+[).])/.exec(editor.value.slice(lastLineStart, nextLineStart))\n let line = editor.value.substr(lastLineStart)\n if (ev.shiftKey) {\n line = line.replace(/^ /, \"\")\n } else {\n line = \" \" + line\n }\n if (match) {\n editor.value = editor.value.substr(0, lastLineStart) + line\n editor.selectionStart = editor.selectionEnd = selStart + (ev.shiftKey ? -2 : 2)\n resize()\n ev.preventDefault()\n }\n }\n\n editorUIState.keypresses++\n m.redraw()\n })\n\n const saveDraft = debounce(() => {\n dbPromise.then(idb => idb.put(\"drafts\", { text: editor.value, ts: Date.now() }, currentPage))\n console.log(\"saved\")\n })\n\n editor.addEventListener(\"input\", () => {\n resize()\n updateCounts(editor.value)\n saveDraft()\n })\n resize()\n}", "const instanceOfAny = (object, constructors) => constructors.some((c) => object instanceof c);\n\nlet idbProxyableTypes;\nlet cursorAdvanceMethods;\n// This is a function to prevent it throwing up in node environments.\nfunction getIdbProxyableTypes() {\n return (idbProxyableTypes ||\n (idbProxyableTypes = [\n IDBDatabase,\n IDBObjectStore,\n IDBIndex,\n IDBCursor,\n IDBTransaction,\n ]));\n}\n// This is a function to prevent it throwing up in node environments.\nfunction getCursorAdvanceMethods() {\n return (cursorAdvanceMethods ||\n (cursorAdvanceMethods = [\n IDBCursor.prototype.advance,\n IDBCursor.prototype.continue,\n IDBCursor.prototype.continuePrimaryKey,\n ]));\n}\nconst cursorRequestMap = new WeakMap();\nconst transactionDoneMap = new WeakMap();\nconst transactionStoreNamesMap = new WeakMap();\nconst transformCache = new WeakMap();\nconst reverseTransformCache = new WeakMap();\nfunction promisifyRequest(request) {\n const promise = new Promise((resolve, reject) => {\n const unlisten = () => {\n request.removeEventListener('success', success);\n request.removeEventListener('error', error);\n };\n const success = () => {\n resolve(wrap(request.result));\n unlisten();\n };\n const error = () => {\n reject(request.error);\n unlisten();\n };\n request.addEventListener('success', success);\n request.addEventListener('error', error);\n });\n promise\n .then((value) => {\n // Since cursoring reuses the IDBRequest (*sigh*), we cache it for later retrieval\n // (see wrapFunction).\n if (value instanceof IDBCursor) {\n cursorRequestMap.set(value, request);\n }\n // Catching to avoid \"Uncaught Promise exceptions\"\n })\n .catch(() => { });\n // This mapping exists in reverseTransformCache but doesn't doesn't exist in transformCache. This\n // is because we create many promises from a single IDBRequest.\n reverseTransformCache.set(promise, request);\n return promise;\n}\nfunction cacheDonePromiseForTransaction(tx) {\n // Early bail if we've already created a done promise for this transaction.\n if (transactionDoneMap.has(tx))\n return;\n const done = new Promise((resolve, reject) => {\n const unlisten = () => {\n tx.removeEventListener('complete', complete);\n tx.removeEventListener('error', error);\n tx.removeEventListener('abort', error);\n };\n const complete = () => {\n resolve();\n unlisten();\n };\n const error = () => {\n reject(tx.error || new DOMException('AbortError', 'AbortError'));\n unlisten();\n };\n tx.addEventListener('complete', complete);\n tx.addEventListener('error', error);\n tx.addEventListener('abort', error);\n });\n // Cache it for later retrieval.\n transactionDoneMap.set(tx, done);\n}\nlet idbProxyTraps = {\n get(target, prop, receiver) {\n if (target instanceof IDBTransaction) {\n // Special handling for transaction.done.\n if (prop === 'done')\n return transactionDoneMap.get(target);\n // Polyfill for objectStoreNames because of Edge.\n if (prop === 'objectStoreNames') {\n return target.objectStoreNames || transactionStoreNamesMap.get(target);\n }\n // Make tx.store return the only store in the transaction, or undefined if there are many.\n if (prop === 'store') {\n return receiver.objectStoreNames[1]\n ? undefined\n : receiver.objectStore(receiver.objectStoreNames[0]);\n }\n }\n // Else transform whatever we get back.\n return wrap(target[prop]);\n },\n set(target, prop, value) {\n target[prop] = value;\n return true;\n },\n has(target, prop) {\n if (target instanceof IDBTransaction &&\n (prop === 'done' || prop === 'store')) {\n return true;\n }\n return prop in target;\n },\n};\nfunction replaceTraps(callback) {\n idbProxyTraps = callback(idbProxyTraps);\n}\nfunction wrapFunction(func) {\n // Due to expected object equality (which is enforced by the caching in `wrap`), we\n // only create one new func per func.\n // Edge doesn't support objectStoreNames (booo), so we polyfill it here.\n if (func === IDBDatabase.prototype.transaction &&\n !('objectStoreNames' in IDBTransaction.prototype)) {\n return function (storeNames, ...args) {\n const tx = func.call(unwrap(this), storeNames, ...args);\n transactionStoreNamesMap.set(tx, storeNames.sort ? storeNames.sort() : [storeNames]);\n return wrap(tx);\n };\n }\n // Cursor methods are special, as the behaviour is a little more different to standard IDB. In\n // IDB, you advance the cursor and wait for a new 'success' on the IDBRequest that gave you the\n // cursor. It's kinda like a promise that can resolve with many values. That doesn't make sense\n // with real promises, so each advance methods returns a new promise for the cursor object, or\n // undefined if the end of the cursor has been reached.\n if (getCursorAdvanceMethods().includes(func)) {\n return function (...args) {\n // Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use\n // the original object.\n func.apply(unwrap(this), args);\n return wrap(cursorRequestMap.get(this));\n };\n }\n return function (...args) {\n // Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use\n // the original object.\n return wrap(func.apply(unwrap(this), args));\n };\n}\nfunction transformCachableValue(value) {\n if (typeof value === 'function')\n return wrapFunction(value);\n // This doesn't return, it just creates a 'done' promise for the transaction,\n // which is later returned for transaction.done (see idbObjectHandler).\n if (value instanceof IDBTransaction)\n cacheDonePromiseForTransaction(value);\n if (instanceOfAny(value, getIdbProxyableTypes()))\n return new Proxy(value, idbProxyTraps);\n // Return the same value back if we're not going to transform it.\n return value;\n}\nfunction wrap(value) {\n // We sometimes generate multiple promises from a single IDBRequest (eg when cursoring), because\n // IDB is weird and a single IDBRequest can yield many responses, so these can't be cached.\n if (value instanceof IDBRequest)\n return promisifyRequest(value);\n // If we've already transformed this value before, reuse the transformed value.\n // This is faster, but it also provides object equality.\n if (transformCache.has(value))\n return transformCache.get(value);\n const newValue = transformCachableValue(value);\n // Not all types are transformed.\n // These may be primitive types, so they can't be WeakMap keys.\n if (newValue !== value) {\n transformCache.set(value, newValue);\n reverseTransformCache.set(newValue, value);\n }\n return newValue;\n}\nconst unwrap = (value) => reverseTransformCache.get(value);\n\nexport { reverseTransformCache as a, instanceOfAny as i, replaceTraps as r, unwrap as u, wrap as w };\n", "import { w as wrap, r as replaceTraps } from './wrap-idb-value.js';\nexport { u as unwrap, w as wrap } from './wrap-idb-value.js';\n\n/**\n * Open a database.\n *\n * @param name Name of the database.\n * @param version Schema version.\n * @param callbacks Additional callbacks.\n */\nfunction openDB(name, version, { blocked, upgrade, blocking, terminated } = {}) {\n const request = indexedDB.open(name, version);\n const openPromise = wrap(request);\n if (upgrade) {\n request.addEventListener('upgradeneeded', (event) => {\n upgrade(wrap(request.result), event.oldVersion, event.newVersion, wrap(request.transaction));\n });\n }\n if (blocked)\n request.addEventListener('blocked', () => blocked());\n openPromise\n .then((db) => {\n if (terminated)\n db.addEventListener('close', () => terminated());\n if (blocking)\n db.addEventListener('versionchange', () => blocking());\n })\n .catch(() => { });\n return openPromise;\n}\n/**\n * Delete a database.\n *\n * @param name Name of the database.\n */\nfunction deleteDB(name, { blocked } = {}) {\n const request = indexedDB.deleteDatabase(name);\n if (blocked)\n request.addEventListener('blocked', () => blocked());\n return wrap(request).then(() => undefined);\n}\n\nconst readMethods = ['get', 'getKey', 'getAll', 'getAllKeys', 'count'];\nconst writeMethods = ['put', 'add', 'delete', 'clear'];\nconst cachedMethods = new Map();\nfunction getMethod(target, prop) {\n if (!(target instanceof IDBDatabase &&\n !(prop in target) &&\n typeof prop === 'string')) {\n return;\n }\n if (cachedMethods.get(prop))\n return cachedMethods.get(prop);\n const targetFuncName = prop.replace(/FromIndex$/, '');\n const useIndex = prop !== targetFuncName;\n const isWrite = writeMethods.includes(targetFuncName);\n if (\n // Bail if the target doesn't exist on the target. Eg, getAll isn't in Edge.\n !(targetFuncName in (useIndex ? IDBIndex : IDBObjectStore).prototype) ||\n !(isWrite || readMethods.includes(targetFuncName))) {\n return;\n }\n const method = async function (storeName, ...args) {\n // isWrite ? 'readwrite' : undefined gzipps better, but fails in Edge :(\n const tx = this.transaction(storeName, isWrite ? 'readwrite' : 'readonly');\n let target = tx.store;\n if (useIndex)\n target = target.index(args.shift());\n // Must reject if op rejects.\n // If it's a write operation, must reject if tx.done rejects.\n // Must reject with op rejection first.\n // Must resolve with op value.\n // Must handle both promises (no unhandled rejections)\n return (await Promise.all([\n target[targetFuncName](...args),\n isWrite && tx.done,\n ]))[0];\n };\n cachedMethods.set(prop, method);\n return method;\n}\nreplaceTraps((oldTraps) => ({\n ...oldTraps,\n get: (target, prop, receiver) => getMethod(target, prop) || oldTraps.get(target, prop, receiver),\n has: (target, prop) => !!getMethod(target, prop) || oldTraps.has(target, prop),\n}));\n\nexport { deleteDB, openDB };\n", "export default function toInteger(dirtyNumber) {\n if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {\n return NaN;\n }\n\n var number = Number(dirtyNumber);\n\n if (isNaN(number)) {\n return number;\n }\n\n return number < 0 ? Math.ceil(number) : Math.floor(number);\n}", "export default function requiredArgs(required, args) {\n if (args.length < required) {\n throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present');\n }\n}", "import requiredArgs from \"../_lib/requiredArgs/index.js\";\n/**\n * @name toDate\n * @category Common Helpers\n * @summary Convert the given argument to an instance of Date.\n *\n * @description\n * Convert the given argument to an instance of Date.\n *\n * If the argument is an instance of Date, the function returns its clone.\n *\n * If the argument is a number, it is treated as a timestamp.\n *\n * If the argument is none of the above, the function returns Invalid Date.\n *\n * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.\n *\n * @param {Date|Number} argument - the value to convert\n * @returns {Date} the parsed date in the local time zone\n * @throws {TypeError} 1 argument required\n *\n * @example\n * // Clone the date:\n * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))\n * //=> Tue Feb 11 2014 11:30:30\n *\n * @example\n * // Convert the timestamp to date:\n * const result = toDate(1392098430000)\n * //=> Tue Feb 11 2014 11:30:30\n */\n\nexport default function toDate(argument) {\n requiredArgs(1, arguments);\n var argStr = Object.prototype.toString.call(argument); // Clone the date\n\n if (argument instanceof Date || typeof argument === 'object' && argStr === '[object Date]') {\n // Prevent the date to lose the milliseconds when passed to new Date() in IE10\n return new Date(argument.getTime());\n } else if (typeof argument === 'number' || argStr === '[object Number]') {\n return new Date(argument);\n } else {\n if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') {\n // eslint-disable-next-line no-console\n console.warn(\"Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://git.io/fjule\"); // eslint-disable-next-line no-console\n\n console.warn(new Error().stack);\n }\n\n return new Date(NaN);\n }\n}", "import toInteger from \"../_lib/toInteger/index.js\";\nimport toDate from \"../toDate/index.js\";\nimport requiredArgs from \"../_lib/requiredArgs/index.js\";\n/**\n * @name addMilliseconds\n * @category Millisecond Helpers\n * @summary Add the specified number of milliseconds to the given date.\n *\n * @description\n * Add the specified number of milliseconds to the given date.\n *\n * ### v2.0.0 breaking changes:\n *\n * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).\n *\n * @param {Date|Number} date - the date to be changed\n * @param {Number} amount - the amount of milliseconds to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.\n * @returns {Date} the new date with the milliseconds added\n * @throws {TypeError} 2 arguments required\n *\n * @example\n * // Add 750 milliseconds to 10 July 2014 12:45:30.000:\n * const result = addMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)\n * //=> Thu Jul 10 2014 12:45:30.750\n */\n\nexport default function addMilliseconds(dirtyDate, dirtyAmount) {\n requiredArgs(2, arguments);\n var timestamp = toDate(dirtyDate).getTime();\n var amount = toInteger(dirtyAmount);\n return new Date(timestamp + amount);\n}", "var MILLISECONDS_IN_MINUTE = 60000;\n\nfunction getDateMillisecondsPart(date) {\n return date.getTime() % MILLISECONDS_IN_MINUTE;\n}\n/**\n * Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.\n * They usually appear for dates that denote time before the timezones were introduced\n * (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891\n * and GMT+01:00:00 after that date)\n *\n * Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,\n * which would lead to incorrect calculations.\n *\n * This function returns the timezone offset in milliseconds that takes seconds in account.\n */\n\n\nexport default function getTimezoneOffsetInMilliseconds(dirtyDate) {\n var date = new Date(dirtyDate.getTime());\n var baseTimezoneOffset = Math.ceil(date.getTimezoneOffset());\n date.setSeconds(0, 0);\n var hasNegativeUTCOffset = baseTimezoneOffset > 0;\n var millisecondsPartOfTimezoneOffset = hasNegativeUTCOffset ? (MILLISECONDS_IN_MINUTE + getDateMillisecondsPart(date)) % MILLISECONDS_IN_MINUTE : getDateMillisecondsPart(date);\n return baseTimezoneOffset * MILLISECONDS_IN_MINUTE + millisecondsPartOfTimezoneOffset;\n}", "import toDate from \"../toDate/index.js\";\nimport requiredArgs from \"../_lib/requiredArgs/index.js\";\n/**\n * @name isValid\n * @category Common Helpers\n * @summary Is the given date valid?\n *\n * @description\n * Returns false if argument is Invalid Date and true otherwise.\n * Argument is converted to Date using `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate}\n * Invalid Date is a Date, whose time value is NaN.\n *\n * Time value of Date: http://es5.github.io/#x15.9.1.1\n *\n * ### v2.0.0 breaking changes:\n *\n * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).\n *\n * - Now `isValid` doesn't throw an exception\n * if the first argument is not an instance of Date.\n * Instead, argument is converted beforehand using `toDate`.\n *\n * Examples:\n *\n * | `isValid` argument | Before v2.0.0 | v2.0.0 onward |\n * |---------------------------|---------------|---------------|\n * | `new Date()` | `true` | `true` |\n * | `new Date('2016-01-01')` | `true` | `true` |\n * | `new Date('')` | `false` | `false` |\n * | `new Date(1488370835081)` | `true` | `true` |\n * | `new Date(NaN)` | `false` | `false` |\n * | `'2016-01-01'` | `TypeError` | `false` |\n * | `''` | `TypeError` | `false` |\n * | `1488370835081` | `TypeError` | `true` |\n * | `NaN` | `TypeError` | `false` |\n *\n * We introduce this change to make *date-fns* consistent with ECMAScript behavior\n * that try to coerce arguments to the expected type\n * (which is also the case with other *date-fns* functions).\n *\n * @param {*} date - the date to check\n * @returns {Boolean} the date is valid\n * @throws {TypeError} 1 argument required\n *\n * @example\n * // For the valid date:\n * var result = isValid(new Date(2014, 1, 31))\n * //=> true\n *\n * @example\n * // For the value, convertable into a date:\n * var result = isValid(1393804800000)\n * //=> true\n *\n * @example\n * // For the invalid date:\n * var result = isValid(new Date(''))\n * //=> false\n */\n\nexport default function isValid(dirtyDate) {\n requiredArgs(1, arguments);\n var date = toDate(dirtyDate);\n return !isNaN(date);\n}", "import toInteger from \"../_lib/toInteger/index.js\";\nimport addMilliseconds from \"../addMilliseconds/index.js\";\nimport requiredArgs from \"../_lib/requiredArgs/index.js\";\n/**\n * @name subMilliseconds\n * @category Millisecond Helpers\n * @summary Subtract the specified number of milliseconds from the given date.\n *\n * @description\n * Subtract the specified number of milliseconds from the given date.\n *\n * ### v2.0.0 breaking changes:\n *\n * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).\n *\n * @param {Date|Number} date - the date to be changed\n * @param {Number} amount - the amount of milliseconds to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.\n * @returns {Date} the new date with the milliseconds subtracted\n * @throws {TypeError} 2 arguments required\n *\n * @example\n * // Subtract 750 milliseconds from 10 July 2014 12:45:30.000:\n * const result = subMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)\n * //=> Thu Jul 10 2014 12:45:29.250\n */\n\nexport default function subMilliseconds(dirtyDate, dirtyAmount) {\n requiredArgs(2, arguments);\n var amount = toInteger(dirtyAmount);\n return addMilliseconds(dirtyDate, -amount);\n}", "export default function addLeadingZeros(number, targetLength) {\n var sign = number < 0 ? '-' : '';\n var output = Math.abs(number).toString();\n\n while (output.length < targetLength) {\n output = '0' + output;\n }\n\n return sign + output;\n}", "import addLeadingZeros from \"../../addLeadingZeros/index.js\";\n/*\n * | | Unit | | Unit |\n * |-----|--------------------------------|-----|--------------------------------|\n * | a | AM, PM | A* | |\n * | d | Day of month | D | |\n * | h | Hour [1-12] | H | Hour [0-23] |\n * | m | Minute | M | Month |\n * | s | Second | S | Fraction of second |\n * | y | Year (abs) | Y | |\n *\n * Letters marked by * are not implemented but reserved by Unicode standard.\n */\n\nvar formatters = {\n // Year\n y: function (date, token) {\n // From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_tokens\n // | Year | y | yy | yyy | yyyy | yyyyy |\n // |----------|-------|----|-------|-------|-------|\n // | AD 1 | 1 | 01 | 001 | 0001 | 00001 |\n // | AD 12 | 12 | 12 | 012 | 0012 | 00012 |\n // | AD 123 | 123 | 23 | 123 | 0123 | 00123 |\n // | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 |\n // | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 |\n var signedYear = date.getUTCFullYear(); // Returns 1 for 1 BC (which is year 0 in JavaScript)\n\n var year = signedYear > 0 ? signedYear : 1 - signedYear;\n return addLeadingZeros(token === 'yy' ? year % 100 : year, token.length);\n },\n // Month\n M: function (date, token) {\n var month = date.getUTCMonth();\n return token === 'M' ? String(month + 1) : addLeadingZeros(month + 1, 2);\n },\n // Day of the month\n d: function (date, token) {\n return addLeadingZeros(date.getUTCDate(), token.length);\n },\n // AM or PM\n a: function (date, token) {\n var dayPeriodEnumValue = date.getUTCHours() / 12 >= 1 ? 'pm' : 'am';\n\n switch (token) {\n case 'a':\n case 'aa':\n return dayPeriodEnumValue.toUpperCase();\n\n case 'aaa':\n return dayPeriodEnumValue;\n\n case 'aaaaa':\n return dayPeriodEnumValue[0];\n\n case 'aaaa':\n default:\n return dayPeriodEnumValue === 'am' ? 'a.m.' : 'p.m.';\n }\n },\n // Hour [1-12]\n h: function (date, token) {\n return addLeadingZeros(date.getUTCHours() % 12 || 12, token.length);\n },\n // Hour [0-23]\n H: function (date, token) {\n return addLeadingZeros(date.getUTCHours(), token.length);\n },\n // Minute\n m: function (date, token) {\n return addLeadingZeros(date.getUTCMinutes(), token.length);\n },\n // Second\n s: function (date, token) {\n return addLeadingZeros(date.getUTCSeconds(), token.length);\n },\n // Fraction of second\n S: function (date, token) {\n var numberOfDigits = token.length;\n var milliseconds = date.getUTCMilliseconds();\n var fractionalSeconds = Math.floor(milliseconds * Math.pow(10, numberOfDigits - 3));\n return addLeadingZeros(fractionalSeconds, token.length);\n }\n};\nexport default formatters;", "import toDate from \"../toDate/index.js\";\nimport formatters from \"../_lib/format/lightFormatters/index.js\";\nimport getTimezoneOffsetInMilliseconds from \"../_lib/getTimezoneOffsetInMilliseconds/index.js\";\nimport isValid from \"../isValid/index.js\";\nimport subMilliseconds from \"../subMilliseconds/index.js\";\nimport requiredArgs from \"../_lib/requiredArgs/index.js\"; // This RegExp consists of three parts separated by `|`:\n// - (\\w)\\1* matches any sequences of the same letter\n// - '' matches two quote characters in a row\n// - '(''|[^'])+('|$) matches anything surrounded by two quote characters ('),\n// except a single quote symbol, which ends the sequence.\n// Two quote characters do not end the sequence.\n// If there is no matching single quote\n// then the sequence will continue until the end of the string.\n// - . matches any single character unmatched by previous parts of the RegExps\n\nvar formattingTokensRegExp = /(\\w)\\1*|''|'(''|[^'])+('|$)|./g;\nvar escapedStringRegExp = /^'([^]*?)'?$/;\nvar doubleQuoteRegExp = /''/g;\nvar unescapedLatinCharacterRegExp = /[a-zA-Z]/;\n/**\n * @name lightFormat\n * @category Common Helpers\n * @summary Format the date.\n *\n * @description\n * Return the formatted date string in the given format. Unlike `format`,\n * `lightFormat` doesn't use locales and outputs date using the most popular tokens.\n *\n * > \u26A0\uFE0F Please note that the `lightFormat` tokens differ from Moment.js and other libraries.\n * > See: https://git.io/fxCyr\n *\n * The characters wrapped between two single quotes characters (') are escaped.\n * Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote.\n *\n * Format of the string is based on Unicode Technical Standard #35:\n * https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table\n *\n * Accepted patterns:\n * | Unit | Pattern | Result examples |\n * |---------------------------------|---------|-----------------------------------|\n * | AM, PM | a..aaa | AM, PM |\n * | | aaaa | a.m., p.m. |\n * | | aaaaa | a, p |\n * | Calendar year | y | 44, 1, 1900, 2017 |\n * | | yy | 44, 01, 00, 17 |\n * | | yyy | 044, 001, 000, 017 |\n * | | yyyy | 0044, 0001, 1900, 2017 |\n * | Month (formatting) | M | 1, 2, ..., 12 |\n * | | MM | 01, 02, ..., 12 |\n * | Day of month | d | 1, 2, ..., 31 |\n * | | dd | 01, 02, ..., 31 |\n * | Hour [1-12] | h | 1, 2, ..., 11, 12 |\n * | | hh | 01, 02, ..., 11, 12 |\n * | Hour [0-23] | H | 0, 1, 2, ..., 23 |\n * | | HH | 00, 01, 02, ..., 23 |\n * | Minute | m | 0, 1, ..., 59 |\n * | | mm | 00, 01, ..., 59 |\n * | Second | s | 0, 1, ..., 59 |\n * | | ss | 00, 01, ..., 59 |\n * | Fraction of second | S | 0, 1, ..., 9 |\n * | | SS | 00, 01, ..., 99 |\n * | | SSS | 000, 0001, ..., 999 |\n * | | SSSS | ... |\n *\n * @param {Date|Number} date - the original date\n * @param {String} format - the string of tokens\n * @returns {String} the formatted date string\n * @throws {TypeError} 2 arguments required\n * @throws {RangeError} format string contains an unescaped latin alphabet character\n *\n * @example\n * var result = lightFormat(new Date(2014, 1, 11), 'yyyy-MM-dd')\n * //=> '2014-02-11'\n */\n\nexport default function lightFormat(dirtyDate, dirtyFormatStr) {\n requiredArgs(2, arguments);\n var formatStr = String(dirtyFormatStr);\n var originalDate = toDate(dirtyDate);\n\n if (!isValid(originalDate)) {\n throw new RangeError('Invalid time value');\n } // Convert the date in system timezone to the same date in UTC+00:00 timezone.\n // This ensures that when UTC functions will be implemented, locales will be compatible with them.\n // See an issue about UTC functions: https://github.com/date-fns/date-fns/issues/376\n\n\n var timezoneOffset = getTimezoneOffsetInMilliseconds(originalDate);\n var utcDate = subMilliseconds(originalDate, timezoneOffset);\n var result = formatStr.match(formattingTokensRegExp).map(function (substring) {\n // Replace two single quote characters with one single quote character\n if (substring === \"''\") {\n return \"'\";\n }\n\n var firstCharacter = substring[0];\n\n if (firstCharacter === \"'\") {\n return cleanEscapedString(substring);\n }\n\n var formatter = formatters[firstCharacter];\n\n if (formatter) {\n return formatter(utcDate, substring, null, {});\n }\n\n if (firstCharacter.match(unescapedLatinCharacterRegExp)) {\n throw new RangeError('Format string contains an unescaped latin alphabet character `' + firstCharacter + '`');\n }\n\n return substring;\n }).join('');\n return result;\n}\n\nfunction cleanEscapedString(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ACvD,EAAO,eAAiB,EAAO,aAAe,EAAY,GAAG,SAAW,GAAK,GAC7E,IACA,EAAG,kBAIX,EAAc,aACd,UAAE,WAGN,GAAM,GAAY,GAAS,KACvB,GAAU,KAAK,GAAO,EAAI,IAAI,SAAU,CAAE,KAAM,EAAO,MAAO,GAAI,KAAK,OAAS,KAChF,QAAQ,IAAI,WAGhB,EAAO,iBAAiB,QAAS,KAC7B,IACA,EAAa,EAAO,OACpB,MAEJ", + "sourcesContent": ["\"use strict\"\n\nfunction Vnode(tag, key, attrs, children, text, dom) {\n\treturn {tag: tag, key: key, attrs: attrs, children: children, text: text, dom: dom, domSize: undefined, state: undefined, events: undefined, instance: undefined}\n}\nVnode.normalize = function(node) {\n\tif (Array.isArray(node)) return Vnode(\"[\", undefined, undefined, Vnode.normalizeChildren(node), undefined, undefined)\n\tif (node == null || typeof node === \"boolean\") return null\n\tif (typeof node === \"object\") return node\n\treturn Vnode(\"#\", undefined, undefined, String(node), undefined, undefined)\n}\nVnode.normalizeChildren = function(input) {\n\tvar children = []\n\tif (input.length) {\n\t\tvar isKeyed = input[0] != null && input[0].key != null\n\t\t// Note: this is a *very* perf-sensitive check.\n\t\t// Fun fact: merging the loop like this is somehow faster than splitting\n\t\t// it, noticeably so.\n\t\tfor (var i = 1; i < input.length; i++) {\n\t\t\tif ((input[i] != null && input[i].key != null) !== isKeyed) {\n\t\t\t\tthrow new TypeError(\"Vnodes must either always have keys or never have keys!\")\n\t\t\t}\n\t\t}\n\t\tfor (var i = 0; i < input.length; i++) {\n\t\t\tchildren[i] = Vnode.normalize(input[i])\n\t\t}\n\t}\n\treturn children\n}\n\nmodule.exports = Vnode\n", "\"use strict\"\n\nvar Vnode = require(\"../render/vnode\")\n\n// Call via `hyperscriptVnode.apply(startOffset, arguments)`\n//\n// The reason I do it this way, forwarding the arguments and passing the start\n// offset in `this`, is so I don't have to create a temporary array in a\n// performance-critical path.\n//\n// In native ES6, I'd instead add a final `...args` parameter to the\n// `hyperscript` and `fragment` factories and define this as\n// `hyperscriptVnode(...args)`, since modern engines do optimize that away. But\n// ES5 (what Mithril requires thanks to IE support) doesn't give me that luxury,\n// and engines aren't nearly intelligent enough to do either of these:\n//\n// 1. Elide the allocation for `[].slice.call(arguments, 1)` when it's passed to\n// another function only to be indexed.\n// 2. Elide an `arguments` allocation when it's passed to any function other\n// than `Function.prototype.apply` or `Reflect.apply`.\n//\n// In ES6, it'd probably look closer to this (I'd need to profile it, though):\n// module.exports = function(attrs, ...children) {\n// if (attrs == null || typeof attrs === \"object\" && attrs.tag == null && !Array.isArray(attrs)) {\n// if (children.length === 1 && Array.isArray(children[0])) children = children[0]\n// } else {\n// children = children.length === 0 && Array.isArray(attrs) ? attrs : [attrs, ...children]\n// attrs = undefined\n// }\n//\n// if (attrs == null) attrs = {}\n// return Vnode(\"\", attrs.key, attrs, children)\n// }\nmodule.exports = function() {\n\tvar attrs = arguments[this], start = this + 1, children\n\n\tif (attrs == null) {\n\t\tattrs = {}\n\t} else if (typeof attrs !== \"object\" || attrs.tag != null || Array.isArray(attrs)) {\n\t\tattrs = {}\n\t\tstart = this\n\t}\n\n\tif (arguments.length === start + 1) {\n\t\tchildren = arguments[start]\n\t\tif (!Array.isArray(children)) children = [children]\n\t} else {\n\t\tchildren = []\n\t\twhile (start < arguments.length) children.push(arguments[start++])\n\t}\n\n\treturn Vnode(\"\", attrs.key, attrs, children)\n}\n", "\"use strict\"\n\nvar Vnode = require(\"../render/vnode\")\nvar hyperscriptVnode = require(\"./hyperscriptVnode\")\n\nvar selectorParser = /(?:(^|#|\\.)([^#\\.\\[\\]]+))|(\\[(.+?)(?:\\s*=\\s*(\"|'|)((?:\\\\[\"'\\]]|.)*?)\\5)?\\])/g\nvar selectorCache = {}\nvar hasOwn = {}.hasOwnProperty\n\nfunction isEmpty(object) {\n\tfor (var key in object) if (hasOwn.call(object, key)) return false\n\treturn true\n}\n\nfunction compileSelector(selector) {\n\tvar match, tag = \"div\", classes = [], attrs = {}\n\twhile (match = selectorParser.exec(selector)) {\n\t\tvar type = match[1], value = match[2]\n\t\tif (type === \"\" && value !== \"\") tag = value\n\t\telse if (type === \"#\") attrs.id = value\n\t\telse if (type === \".\") classes.push(value)\n\t\telse if (match[3][0] === \"[\") {\n\t\t\tvar attrValue = match[6]\n\t\t\tif (attrValue) attrValue = attrValue.replace(/\\\\([\"'])/g, \"$1\").replace(/\\\\\\\\/g, \"\\\\\")\n\t\t\tif (match[4] === \"class\") classes.push(attrValue)\n\t\t\telse attrs[match[4]] = attrValue === \"\" ? attrValue : attrValue || true\n\t\t}\n\t}\n\tif (classes.length > 0) attrs.className = classes.join(\" \")\n\treturn selectorCache[selector] = {tag: tag, attrs: attrs}\n}\n\nfunction execSelector(state, vnode) {\n\tvar attrs = vnode.attrs\n\tvar children = Vnode.normalizeChildren(vnode.children)\n\tvar hasClass = hasOwn.call(attrs, \"class\")\n\tvar className = hasClass ? attrs.class : attrs.className\n\n\tvnode.tag = state.tag\n\tvnode.attrs = null\n\tvnode.children = undefined\n\n\tif (!isEmpty(state.attrs) && !isEmpty(attrs)) {\n\t\tvar newAttrs = {}\n\n\t\tfor (var key in attrs) {\n\t\t\tif (hasOwn.call(attrs, key)) newAttrs[key] = attrs[key]\n\t\t}\n\n\t\tattrs = newAttrs\n\t}\n\n\tfor (var key in state.attrs) {\n\t\tif (hasOwn.call(state.attrs, key) && key !== \"className\" && !hasOwn.call(attrs, key)){\n\t\t\tattrs[key] = state.attrs[key]\n\t\t}\n\t}\n\tif (className != null || state.attrs.className != null) attrs.className =\n\t\tclassName != null\n\t\t\t? state.attrs.className != null\n\t\t\t\t? String(state.attrs.className) + \" \" + String(className)\n\t\t\t\t: className\n\t\t\t: state.attrs.className != null\n\t\t\t\t? state.attrs.className\n\t\t\t\t: null\n\n\tif (hasClass) attrs.class = null\n\n\tfor (var key in attrs) {\n\t\tif (hasOwn.call(attrs, key) && key !== \"key\") {\n\t\t\tvnode.attrs = attrs\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif (Array.isArray(children) && children.length === 1 && children[0] != null && children[0].tag === \"#\") {\n\t\tvnode.text = children[0].children\n\t} else {\n\t\tvnode.children = children\n\t}\n\n\treturn vnode\n}\n\nfunction hyperscript(selector) {\n\tif (selector == null || typeof selector !== \"string\" && typeof selector !== \"function\" && typeof selector.view !== \"function\") {\n\t\tthrow Error(\"The selector must be either a string or a component.\");\n\t}\n\n\tvar vnode = hyperscriptVnode.apply(1, arguments)\n\n\tif (typeof selector === \"string\") {\n\t\tvnode.children = Vnode.normalizeChildren(vnode.children)\n\t\tif (selector !== \"[\") return execSelector(selectorCache[selector] || compileSelector(selector), vnode)\n\t}\n\n\tvnode.tag = selector\n\treturn vnode\n}\n\nmodule.exports = hyperscript\n", "\"use strict\"\n\nvar Vnode = require(\"../render/vnode\")\n\nmodule.exports = function(html) {\n\tif (html == null) html = \"\"\n\treturn Vnode(\"<\", undefined, undefined, html, undefined, undefined)\n}\n", "\"use strict\"\n\nvar Vnode = require(\"../render/vnode\")\nvar hyperscriptVnode = require(\"./hyperscriptVnode\")\n\nmodule.exports = function() {\n\tvar vnode = hyperscriptVnode.apply(0, arguments)\n\n\tvnode.tag = \"[\"\n\tvnode.children = Vnode.normalizeChildren(vnode.children)\n\treturn vnode\n}\n", "\"use strict\"\n\nvar hyperscript = require(\"./render/hyperscript\")\n\nhyperscript.trust = require(\"./render/trust\")\nhyperscript.fragment = require(\"./render/fragment\")\n\nmodule.exports = hyperscript\n", "\"use strict\"\n/** @constructor */\nvar PromisePolyfill = function(executor) {\n\tif (!(this instanceof PromisePolyfill)) throw new Error(\"Promise must be called with `new`\")\n\tif (typeof executor !== \"function\") throw new TypeError(\"executor must be a function\")\n\n\tvar self = this, resolvers = [], rejectors = [], resolveCurrent = handler(resolvers, true), rejectCurrent = handler(rejectors, false)\n\tvar instance = self._instance = {resolvers: resolvers, rejectors: rejectors}\n\tvar callAsync = typeof setImmediate === \"function\" ? setImmediate : setTimeout\n\tfunction handler(list, shouldAbsorb) {\n\t\treturn function execute(value) {\n\t\t\tvar then\n\t\t\ttry {\n\t\t\t\tif (shouldAbsorb && value != null && (typeof value === \"object\" || typeof value === \"function\") && typeof (then = value.then) === \"function\") {\n\t\t\t\t\tif (value === self) throw new TypeError(\"Promise can't be resolved w/ itself\")\n\t\t\t\t\texecuteOnce(then.bind(value))\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tcallAsync(function() {\n\t\t\t\t\t\tif (!shouldAbsorb && list.length === 0) console.error(\"Possible unhandled promise rejection:\", value)\n\t\t\t\t\t\tfor (var i = 0; i < list.length; i++) list[i](value)\n\t\t\t\t\t\tresolvers.length = 0, rejectors.length = 0\n\t\t\t\t\t\tinstance.state = shouldAbsorb\n\t\t\t\t\t\tinstance.retry = function() {execute(value)}\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}\n\t\t\tcatch (e) {\n\t\t\t\trejectCurrent(e)\n\t\t\t}\n\t\t}\n\t}\n\tfunction executeOnce(then) {\n\t\tvar runs = 0\n\t\tfunction run(fn) {\n\t\t\treturn function(value) {\n\t\t\t\tif (runs++ > 0) return\n\t\t\t\tfn(value)\n\t\t\t}\n\t\t}\n\t\tvar onerror = run(rejectCurrent)\n\t\ttry {then(run(resolveCurrent), onerror)} catch (e) {onerror(e)}\n\t}\n\n\texecuteOnce(executor)\n}\nPromisePolyfill.prototype.then = function(onFulfilled, onRejection) {\n\tvar self = this, instance = self._instance\n\tfunction handle(callback, list, next, state) {\n\t\tlist.push(function(value) {\n\t\t\tif (typeof callback !== \"function\") next(value)\n\t\t\telse try {resolveNext(callback(value))} catch (e) {if (rejectNext) rejectNext(e)}\n\t\t})\n\t\tif (typeof instance.retry === \"function\" && state === instance.state) instance.retry()\n\t}\n\tvar resolveNext, rejectNext\n\tvar promise = new PromisePolyfill(function(resolve, reject) {resolveNext = resolve, rejectNext = reject})\n\thandle(onFulfilled, instance.resolvers, resolveNext, true), handle(onRejection, instance.rejectors, rejectNext, false)\n\treturn promise\n}\nPromisePolyfill.prototype.catch = function(onRejection) {\n\treturn this.then(null, onRejection)\n}\nPromisePolyfill.prototype.finally = function(callback) {\n\treturn this.then(\n\t\tfunction(value) {\n\t\t\treturn PromisePolyfill.resolve(callback()).then(function() {\n\t\t\t\treturn value\n\t\t\t})\n\t\t},\n\t\tfunction(reason) {\n\t\t\treturn PromisePolyfill.resolve(callback()).then(function() {\n\t\t\t\treturn PromisePolyfill.reject(reason);\n\t\t\t})\n\t\t}\n\t)\n}\nPromisePolyfill.resolve = function(value) {\n\tif (value instanceof PromisePolyfill) return value\n\treturn new PromisePolyfill(function(resolve) {resolve(value)})\n}\nPromisePolyfill.reject = function(value) {\n\treturn new PromisePolyfill(function(resolve, reject) {reject(value)})\n}\nPromisePolyfill.all = function(list) {\n\treturn new PromisePolyfill(function(resolve, reject) {\n\t\tvar total = list.length, count = 0, values = []\n\t\tif (list.length === 0) resolve([])\n\t\telse for (var i = 0; i < list.length; i++) {\n\t\t\t(function(i) {\n\t\t\t\tfunction consume(value) {\n\t\t\t\t\tcount++\n\t\t\t\t\tvalues[i] = value\n\t\t\t\t\tif (count === total) resolve(values)\n\t\t\t\t}\n\t\t\t\tif (list[i] != null && (typeof list[i] === \"object\" || typeof list[i] === \"function\") && typeof list[i].then === \"function\") {\n\t\t\t\t\tlist[i].then(consume, reject)\n\t\t\t\t}\n\t\t\t\telse consume(list[i])\n\t\t\t})(i)\n\t\t}\n\t})\n}\nPromisePolyfill.race = function(list) {\n\treturn new PromisePolyfill(function(resolve, reject) {\n\t\tfor (var i = 0; i < list.length; i++) {\n\t\t\tlist[i].then(resolve, reject)\n\t\t}\n\t})\n}\n\nmodule.exports = PromisePolyfill\n", "\"use strict\"\n\nvar PromisePolyfill = require(\"./polyfill\")\n\nif (typeof window !== \"undefined\") {\n\tif (typeof window.Promise === \"undefined\") {\n\t\twindow.Promise = PromisePolyfill\n\t} else if (!window.Promise.prototype.finally) {\n\t\twindow.Promise.prototype.finally = PromisePolyfill.prototype.finally\n\t}\n\tmodule.exports = window.Promise\n} else if (typeof global !== \"undefined\") {\n\tif (typeof global.Promise === \"undefined\") {\n\t\tglobal.Promise = PromisePolyfill\n\t} else if (!global.Promise.prototype.finally) {\n\t\tglobal.Promise.prototype.finally = PromisePolyfill.prototype.finally\n\t}\n\tmodule.exports = global.Promise\n} else {\n\tmodule.exports = PromisePolyfill\n}\n", "\"use strict\"\n\nvar Vnode = require(\"../render/vnode\")\n\nmodule.exports = function($window) {\n\tvar $doc = $window && $window.document\n\tvar currentRedraw\n\n\tvar nameSpace = {\n\t\tsvg: \"http://www.w3.org/2000/svg\",\n\t\tmath: \"http://www.w3.org/1998/Math/MathML\"\n\t}\n\n\tfunction getNameSpace(vnode) {\n\t\treturn vnode.attrs && vnode.attrs.xmlns || nameSpace[vnode.tag]\n\t}\n\n\t//sanity check to discourage people from doing `vnode.state = ...`\n\tfunction checkState(vnode, original) {\n\t\tif (vnode.state !== original) throw new Error(\"`vnode.state` must not be modified\")\n\t}\n\n\t//Note: the hook is passed as the `this` argument to allow proxying the\n\t//arguments without requiring a full array allocation to do so. It also\n\t//takes advantage of the fact the current `vnode` is the first argument in\n\t//all lifecycle methods.\n\tfunction callHook(vnode) {\n\t\tvar original = vnode.state\n\t\ttry {\n\t\t\treturn this.apply(original, arguments)\n\t\t} finally {\n\t\t\tcheckState(vnode, original)\n\t\t}\n\t}\n\n\t// IE11 (at least) throws an UnspecifiedError when accessing document.activeElement when\n\t// inside an iframe. Catch and swallow this error, and heavy-handidly return null.\n\tfunction activeElement() {\n\t\ttry {\n\t\t\treturn $doc.activeElement\n\t\t} catch (e) {\n\t\t\treturn null\n\t\t}\n\t}\n\t//create\n\tfunction createNodes(parent, vnodes, start, end, hooks, nextSibling, ns) {\n\t\tfor (var i = start; i < end; i++) {\n\t\t\tvar vnode = vnodes[i]\n\t\t\tif (vnode != null) {\n\t\t\t\tcreateNode(parent, vnode, hooks, ns, nextSibling)\n\t\t\t}\n\t\t}\n\t}\n\tfunction createNode(parent, vnode, hooks, ns, nextSibling) {\n\t\tvar tag = vnode.tag\n\t\tif (typeof tag === \"string\") {\n\t\t\tvnode.state = {}\n\t\t\tif (vnode.attrs != null) initLifecycle(vnode.attrs, vnode, hooks)\n\t\t\tswitch (tag) {\n\t\t\t\tcase \"#\": createText(parent, vnode, nextSibling); break\n\t\t\t\tcase \"<\": createHTML(parent, vnode, ns, nextSibling); break\n\t\t\t\tcase \"[\": createFragment(parent, vnode, hooks, ns, nextSibling); break\n\t\t\t\tdefault: createElement(parent, vnode, hooks, ns, nextSibling)\n\t\t\t}\n\t\t}\n\t\telse createComponent(parent, vnode, hooks, ns, nextSibling)\n\t}\n\tfunction createText(parent, vnode, nextSibling) {\n\t\tvnode.dom = $doc.createTextNode(vnode.children)\n\t\tinsertNode(parent, vnode.dom, nextSibling)\n\t}\n\tvar possibleParents = {caption: \"table\", thead: \"table\", tbody: \"table\", tfoot: \"table\", tr: \"tbody\", th: \"tr\", td: \"tr\", colgroup: \"table\", col: \"colgroup\"}\n\tfunction createHTML(parent, vnode, ns, nextSibling) {\n\t\tvar match = vnode.children.match(/^\\s*?<(\\w+)/im) || []\n\t\t// not using the proper parent makes the child element(s) vanish.\n\t\t// var div = document.createElement(\"div\")\n\t\t// div.innerHTML = \"ij\"\n\t\t// console.log(div.innerHTML)\n\t\t// --> \"ij\", no in sight.\n\t\tvar temp = $doc.createElement(possibleParents[match[1]] || \"div\")\n\t\tif (ns === \"http://www.w3.org/2000/svg\") {\n\t\t\ttemp.innerHTML = \"\" + vnode.children + \"\"\n\t\t\ttemp = temp.firstChild\n\t\t} else {\n\t\t\ttemp.innerHTML = vnode.children\n\t\t}\n\t\tvnode.dom = temp.firstChild\n\t\tvnode.domSize = temp.childNodes.length\n\t\t// Capture nodes to remove, so we don't confuse them.\n\t\tvnode.instance = []\n\t\tvar fragment = $doc.createDocumentFragment()\n\t\tvar child\n\t\twhile (child = temp.firstChild) {\n\t\t\tvnode.instance.push(child)\n\t\t\tfragment.appendChild(child)\n\t\t}\n\t\tinsertNode(parent, fragment, nextSibling)\n\t}\n\tfunction createFragment(parent, vnode, hooks, ns, nextSibling) {\n\t\tvar fragment = $doc.createDocumentFragment()\n\t\tif (vnode.children != null) {\n\t\t\tvar children = vnode.children\n\t\t\tcreateNodes(fragment, children, 0, children.length, hooks, null, ns)\n\t\t}\n\t\tvnode.dom = fragment.firstChild\n\t\tvnode.domSize = fragment.childNodes.length\n\t\tinsertNode(parent, fragment, nextSibling)\n\t}\n\tfunction createElement(parent, vnode, hooks, ns, nextSibling) {\n\t\tvar tag = vnode.tag\n\t\tvar attrs = vnode.attrs\n\t\tvar is = attrs && attrs.is\n\n\t\tns = getNameSpace(vnode) || ns\n\n\t\tvar element = ns ?\n\t\t\tis ? $doc.createElementNS(ns, tag, {is: is}) : $doc.createElementNS(ns, tag) :\n\t\t\tis ? $doc.createElement(tag, {is: is}) : $doc.createElement(tag)\n\t\tvnode.dom = element\n\n\t\tif (attrs != null) {\n\t\t\tsetAttrs(vnode, attrs, ns)\n\t\t}\n\n\t\tinsertNode(parent, element, nextSibling)\n\n\t\tif (!maybeSetContentEditable(vnode)) {\n\t\t\tif (vnode.text != null) {\n\t\t\t\tif (vnode.text !== \"\") element.textContent = vnode.text\n\t\t\t\telse vnode.children = [Vnode(\"#\", undefined, undefined, vnode.text, undefined, undefined)]\n\t\t\t}\n\t\t\tif (vnode.children != null) {\n\t\t\t\tvar children = vnode.children\n\t\t\t\tcreateNodes(element, children, 0, children.length, hooks, null, ns)\n\t\t\t\tif (vnode.tag === \"select\" && attrs != null) setLateSelectAttrs(vnode, attrs)\n\t\t\t}\n\t\t}\n\t}\n\tfunction initComponent(vnode, hooks) {\n\t\tvar sentinel\n\t\tif (typeof vnode.tag.view === \"function\") {\n\t\t\tvnode.state = Object.create(vnode.tag)\n\t\t\tsentinel = vnode.state.view\n\t\t\tif (sentinel.$$reentrantLock$$ != null) return\n\t\t\tsentinel.$$reentrantLock$$ = true\n\t\t} else {\n\t\t\tvnode.state = void 0\n\t\t\tsentinel = vnode.tag\n\t\t\tif (sentinel.$$reentrantLock$$ != null) return\n\t\t\tsentinel.$$reentrantLock$$ = true\n\t\t\tvnode.state = (vnode.tag.prototype != null && typeof vnode.tag.prototype.view === \"function\") ? new vnode.tag(vnode) : vnode.tag(vnode)\n\t\t}\n\t\tinitLifecycle(vnode.state, vnode, hooks)\n\t\tif (vnode.attrs != null) initLifecycle(vnode.attrs, vnode, hooks)\n\t\tvnode.instance = Vnode.normalize(callHook.call(vnode.state.view, vnode))\n\t\tif (vnode.instance === vnode) throw Error(\"A view cannot return the vnode it received as argument\")\n\t\tsentinel.$$reentrantLock$$ = null\n\t}\n\tfunction createComponent(parent, vnode, hooks, ns, nextSibling) {\n\t\tinitComponent(vnode, hooks)\n\t\tif (vnode.instance != null) {\n\t\t\tcreateNode(parent, vnode.instance, hooks, ns, nextSibling)\n\t\t\tvnode.dom = vnode.instance.dom\n\t\t\tvnode.domSize = vnode.dom != null ? vnode.instance.domSize : 0\n\t\t}\n\t\telse {\n\t\t\tvnode.domSize = 0\n\t\t}\n\t}\n\n\t//update\n\t/**\n\t * @param {Element|Fragment} parent - the parent element\n\t * @param {Vnode[] | null} old - the list of vnodes of the last `render()` call for\n\t * this part of the tree\n\t * @param {Vnode[] | null} vnodes - as above, but for the current `render()` call.\n\t * @param {Function[]} hooks - an accumulator of post-render hooks (oncreate/onupdate)\n\t * @param {Element | null} nextSibling - the next DOM node if we're dealing with a\n\t * fragment that is not the last item in its\n\t * parent\n\t * @param {'svg' | 'math' | String | null} ns) - the current XML namespace, if any\n\t * @returns void\n\t */\n\t// This function diffs and patches lists of vnodes, both keyed and unkeyed.\n\t//\n\t// We will:\n\t//\n\t// 1. describe its general structure\n\t// 2. focus on the diff algorithm optimizations\n\t// 3. discuss DOM node operations.\n\n\t// ## Overview:\n\t//\n\t// The updateNodes() function:\n\t// - deals with trivial cases\n\t// - determines whether the lists are keyed or unkeyed based on the first non-null node\n\t// of each list.\n\t// - diffs them and patches the DOM if needed (that's the brunt of the code)\n\t// - manages the leftovers: after diffing, are there:\n\t// - old nodes left to remove?\n\t// \t - new nodes to insert?\n\t// \t deal with them!\n\t//\n\t// The lists are only iterated over once, with an exception for the nodes in `old` that\n\t// are visited in the fourth part of the diff and in the `removeNodes` loop.\n\n\t// ## Diffing\n\t//\n\t// Reading https://github.com/localvoid/ivi/blob/ddc09d06abaef45248e6133f7040d00d3c6be853/packages/ivi/src/vdom/implementation.ts#L617-L837\n\t// may be good for context on longest increasing subsequence-based logic for moving nodes.\n\t//\n\t// In order to diff keyed lists, one has to\n\t//\n\t// 1) match nodes in both lists, per key, and update them accordingly\n\t// 2) create the nodes present in the new list, but absent in the old one\n\t// 3) remove the nodes present in the old list, but absent in the new one\n\t// 4) figure out what nodes in 1) to move in order to minimize the DOM operations.\n\t//\n\t// To achieve 1) one can create a dictionary of keys => index (for the old list), then iterate\n\t// over the new list and for each new vnode, find the corresponding vnode in the old list using\n\t// the map.\n\t// 2) is achieved in the same step: if a new node has no corresponding entry in the map, it is new\n\t// and must be created.\n\t// For the removals, we actually remove the nodes that have been updated from the old list.\n\t// The nodes that remain in that list after 1) and 2) have been performed can be safely removed.\n\t// The fourth step is a bit more complex and relies on the longest increasing subsequence (LIS)\n\t// algorithm.\n\t//\n\t// the longest increasing subsequence is the list of nodes that can remain in place. Imagine going\n\t// from `1,2,3,4,5` to `4,5,1,2,3` where the numbers are not necessarily the keys, but the indices\n\t// corresponding to the keyed nodes in the old list (keyed nodes `e,d,c,b,a` => `b,a,e,d,c` would\n\t// match the above lists, for example).\n\t//\n\t// In there are two increasing subsequences: `4,5` and `1,2,3`, the latter being the longest. We\n\t// can update those nodes without moving them, and only call `insertNode` on `4` and `5`.\n\t//\n\t// @localvoid adapted the algo to also support node deletions and insertions (the `lis` is actually\n\t// the longest increasing subsequence *of old nodes still present in the new list*).\n\t//\n\t// It is a general algorithm that is fireproof in all circumstances, but it requires the allocation\n\t// and the construction of a `key => oldIndex` map, and three arrays (one with `newIndex => oldIndex`,\n\t// the `LIS` and a temporary one to create the LIS).\n\t//\n\t// So we cheat where we can: if the tails of the lists are identical, they are guaranteed to be part of\n\t// the LIS and can be updated without moving them.\n\t//\n\t// If two nodes are swapped, they are guaranteed not to be part of the LIS, and must be moved (with\n\t// the exception of the last node if the list is fully reversed).\n\t//\n\t// ## Finding the next sibling.\n\t//\n\t// `updateNode()` and `createNode()` expect a nextSibling parameter to perform DOM operations.\n\t// When the list is being traversed top-down, at any index, the DOM nodes up to the previous\n\t// vnode reflect the content of the new list, whereas the rest of the DOM nodes reflect the old\n\t// list. The next sibling must be looked for in the old list using `getNextSibling(... oldStart + 1 ...)`.\n\t//\n\t// In the other scenarios (swaps, upwards traversal, map-based diff),\n\t// the new vnodes list is traversed upwards. The DOM nodes at the bottom of the list reflect the\n\t// bottom part of the new vnodes list, and we can use the `v.dom` value of the previous node\n\t// as the next sibling (cached in the `nextSibling` variable).\n\n\n\t// ## DOM node moves\n\t//\n\t// In most scenarios `updateNode()` and `createNode()` perform the DOM operations. However,\n\t// this is not the case if the node moved (second and fourth part of the diff algo). We move\n\t// the old DOM nodes before updateNode runs because it enables us to use the cached `nextSibling`\n\t// variable rather than fetching it using `getNextSibling()`.\n\t//\n\t// The fourth part of the diff currently inserts nodes unconditionally, leading to issues\n\t// like #1791 and #1999. We need to be smarter about those situations where adjascent old\n\t// nodes remain together in the new list in a way that isn't covered by parts one and\n\t// three of the diff algo.\n\n\tfunction updateNodes(parent, old, vnodes, hooks, nextSibling, ns) {\n\t\tif (old === vnodes || old == null && vnodes == null) return\n\t\telse if (old == null || old.length === 0) createNodes(parent, vnodes, 0, vnodes.length, hooks, nextSibling, ns)\n\t\telse if (vnodes == null || vnodes.length === 0) removeNodes(parent, old, 0, old.length)\n\t\telse {\n\t\t\tvar isOldKeyed = old[0] != null && old[0].key != null\n\t\t\tvar isKeyed = vnodes[0] != null && vnodes[0].key != null\n\t\t\tvar start = 0, oldStart = 0\n\t\t\tif (!isOldKeyed) while (oldStart < old.length && old[oldStart] == null) oldStart++\n\t\t\tif (!isKeyed) while (start < vnodes.length && vnodes[start] == null) start++\n\t\t\tif (isKeyed === null && isOldKeyed == null) return // both lists are full of nulls\n\t\t\tif (isOldKeyed !== isKeyed) {\n\t\t\t\tremoveNodes(parent, old, oldStart, old.length)\n\t\t\t\tcreateNodes(parent, vnodes, start, vnodes.length, hooks, nextSibling, ns)\n\t\t\t} else if (!isKeyed) {\n\t\t\t\t// Don't index past the end of either list (causes deopts).\n\t\t\t\tvar commonLength = old.length < vnodes.length ? old.length : vnodes.length\n\t\t\t\t// Rewind if necessary to the first non-null index on either side.\n\t\t\t\t// We could alternatively either explicitly create or remove nodes when `start !== oldStart`\n\t\t\t\t// but that would be optimizing for sparse lists which are more rare than dense ones.\n\t\t\t\tstart = start < oldStart ? start : oldStart\n\t\t\t\tfor (; start < commonLength; start++) {\n\t\t\t\t\to = old[start]\n\t\t\t\t\tv = vnodes[start]\n\t\t\t\t\tif (o === v || o == null && v == null) continue\n\t\t\t\t\telse if (o == null) createNode(parent, v, hooks, ns, getNextSibling(old, start + 1, nextSibling))\n\t\t\t\t\telse if (v == null) removeNode(parent, o)\n\t\t\t\t\telse updateNode(parent, o, v, hooks, getNextSibling(old, start + 1, nextSibling), ns)\n\t\t\t\t}\n\t\t\t\tif (old.length > commonLength) removeNodes(parent, old, start, old.length)\n\t\t\t\tif (vnodes.length > commonLength) createNodes(parent, vnodes, start, vnodes.length, hooks, nextSibling, ns)\n\t\t\t} else {\n\t\t\t\t// keyed diff\n\t\t\t\tvar oldEnd = old.length - 1, end = vnodes.length - 1, map, o, v, oe, ve, topSibling\n\n\t\t\t\t// bottom-up\n\t\t\t\twhile (oldEnd >= oldStart && end >= start) {\n\t\t\t\t\toe = old[oldEnd]\n\t\t\t\t\tve = vnodes[end]\n\t\t\t\t\tif (oe.key !== ve.key) break\n\t\t\t\t\tif (oe !== ve) updateNode(parent, oe, ve, hooks, nextSibling, ns)\n\t\t\t\t\tif (ve.dom != null) nextSibling = ve.dom\n\t\t\t\t\toldEnd--, end--\n\t\t\t\t}\n\t\t\t\t// top-down\n\t\t\t\twhile (oldEnd >= oldStart && end >= start) {\n\t\t\t\t\to = old[oldStart]\n\t\t\t\t\tv = vnodes[start]\n\t\t\t\t\tif (o.key !== v.key) break\n\t\t\t\t\toldStart++, start++\n\t\t\t\t\tif (o !== v) updateNode(parent, o, v, hooks, getNextSibling(old, oldStart, nextSibling), ns)\n\t\t\t\t}\n\t\t\t\t// swaps and list reversals\n\t\t\t\twhile (oldEnd >= oldStart && end >= start) {\n\t\t\t\t\tif (start === end) break\n\t\t\t\t\tif (o.key !== ve.key || oe.key !== v.key) break\n\t\t\t\t\ttopSibling = getNextSibling(old, oldStart, nextSibling)\n\t\t\t\t\tmoveNodes(parent, oe, topSibling)\n\t\t\t\t\tif (oe !== v) updateNode(parent, oe, v, hooks, topSibling, ns)\n\t\t\t\t\tif (++start <= --end) moveNodes(parent, o, nextSibling)\n\t\t\t\t\tif (o !== ve) updateNode(parent, o, ve, hooks, nextSibling, ns)\n\t\t\t\t\tif (ve.dom != null) nextSibling = ve.dom\n\t\t\t\t\toldStart++; oldEnd--\n\t\t\t\t\toe = old[oldEnd]\n\t\t\t\t\tve = vnodes[end]\n\t\t\t\t\to = old[oldStart]\n\t\t\t\t\tv = vnodes[start]\n\t\t\t\t}\n\t\t\t\t// bottom up once again\n\t\t\t\twhile (oldEnd >= oldStart && end >= start) {\n\t\t\t\t\tif (oe.key !== ve.key) break\n\t\t\t\t\tif (oe !== ve) updateNode(parent, oe, ve, hooks, nextSibling, ns)\n\t\t\t\t\tif (ve.dom != null) nextSibling = ve.dom\n\t\t\t\t\toldEnd--, end--\n\t\t\t\t\toe = old[oldEnd]\n\t\t\t\t\tve = vnodes[end]\n\t\t\t\t}\n\t\t\t\tif (start > end) removeNodes(parent, old, oldStart, oldEnd + 1)\n\t\t\t\telse if (oldStart > oldEnd) createNodes(parent, vnodes, start, end + 1, hooks, nextSibling, ns)\n\t\t\t\telse {\n\t\t\t\t\t// inspired by ivi https://github.com/ivijs/ivi/ by Boris Kaul\n\t\t\t\t\tvar originalNextSibling = nextSibling, vnodesLength = end - start + 1, oldIndices = new Array(vnodesLength), li=0, i=0, pos = 2147483647, matched = 0, map, lisIndices\n\t\t\t\t\tfor (i = 0; i < vnodesLength; i++) oldIndices[i] = -1\n\t\t\t\t\tfor (i = end; i >= start; i--) {\n\t\t\t\t\t\tif (map == null) map = getKeyMap(old, oldStart, oldEnd + 1)\n\t\t\t\t\t\tve = vnodes[i]\n\t\t\t\t\t\tvar oldIndex = map[ve.key]\n\t\t\t\t\t\tif (oldIndex != null) {\n\t\t\t\t\t\t\tpos = (oldIndex < pos) ? oldIndex : -1 // becomes -1 if nodes were re-ordered\n\t\t\t\t\t\t\toldIndices[i-start] = oldIndex\n\t\t\t\t\t\t\toe = old[oldIndex]\n\t\t\t\t\t\t\told[oldIndex] = null\n\t\t\t\t\t\t\tif (oe !== ve) updateNode(parent, oe, ve, hooks, nextSibling, ns)\n\t\t\t\t\t\t\tif (ve.dom != null) nextSibling = ve.dom\n\t\t\t\t\t\t\tmatched++\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tnextSibling = originalNextSibling\n\t\t\t\t\tif (matched !== oldEnd - oldStart + 1) removeNodes(parent, old, oldStart, oldEnd + 1)\n\t\t\t\t\tif (matched === 0) createNodes(parent, vnodes, start, end + 1, hooks, nextSibling, ns)\n\t\t\t\t\telse {\n\t\t\t\t\t\tif (pos === -1) {\n\t\t\t\t\t\t\t// the indices of the indices of the items that are part of the\n\t\t\t\t\t\t\t// longest increasing subsequence in the oldIndices list\n\t\t\t\t\t\t\tlisIndices = makeLisIndices(oldIndices)\n\t\t\t\t\t\t\tli = lisIndices.length - 1\n\t\t\t\t\t\t\tfor (i = end; i >= start; i--) {\n\t\t\t\t\t\t\t\tv = vnodes[i]\n\t\t\t\t\t\t\t\tif (oldIndices[i-start] === -1) createNode(parent, v, hooks, ns, nextSibling)\n\t\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\t\tif (lisIndices[li] === i - start) li--\n\t\t\t\t\t\t\t\t\telse moveNodes(parent, v, nextSibling)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (v.dom != null) nextSibling = vnodes[i].dom\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tfor (i = end; i >= start; i--) {\n\t\t\t\t\t\t\t\tv = vnodes[i]\n\t\t\t\t\t\t\t\tif (oldIndices[i-start] === -1) createNode(parent, v, hooks, ns, nextSibling)\n\t\t\t\t\t\t\t\tif (v.dom != null) nextSibling = vnodes[i].dom\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfunction updateNode(parent, old, vnode, hooks, nextSibling, ns) {\n\t\tvar oldTag = old.tag, tag = vnode.tag\n\t\tif (oldTag === tag) {\n\t\t\tvnode.state = old.state\n\t\t\tvnode.events = old.events\n\t\t\tif (shouldNotUpdate(vnode, old)) return\n\t\t\tif (typeof oldTag === \"string\") {\n\t\t\t\tif (vnode.attrs != null) {\n\t\t\t\t\tupdateLifecycle(vnode.attrs, vnode, hooks)\n\t\t\t\t}\n\t\t\t\tswitch (oldTag) {\n\t\t\t\t\tcase \"#\": updateText(old, vnode); break\n\t\t\t\t\tcase \"<\": updateHTML(parent, old, vnode, ns, nextSibling); break\n\t\t\t\t\tcase \"[\": updateFragment(parent, old, vnode, hooks, nextSibling, ns); break\n\t\t\t\t\tdefault: updateElement(old, vnode, hooks, ns)\n\t\t\t\t}\n\t\t\t}\n\t\t\telse updateComponent(parent, old, vnode, hooks, nextSibling, ns)\n\t\t}\n\t\telse {\n\t\t\tremoveNode(parent, old)\n\t\t\tcreateNode(parent, vnode, hooks, ns, nextSibling)\n\t\t}\n\t}\n\tfunction updateText(old, vnode) {\n\t\tif (old.children.toString() !== vnode.children.toString()) {\n\t\t\told.dom.nodeValue = vnode.children\n\t\t}\n\t\tvnode.dom = old.dom\n\t}\n\tfunction updateHTML(parent, old, vnode, ns, nextSibling) {\n\t\tif (old.children !== vnode.children) {\n\t\t\tremoveHTML(parent, old)\n\t\t\tcreateHTML(parent, vnode, ns, nextSibling)\n\t\t}\n\t\telse {\n\t\t\tvnode.dom = old.dom\n\t\t\tvnode.domSize = old.domSize\n\t\t\tvnode.instance = old.instance\n\t\t}\n\t}\n\tfunction updateFragment(parent, old, vnode, hooks, nextSibling, ns) {\n\t\tupdateNodes(parent, old.children, vnode.children, hooks, nextSibling, ns)\n\t\tvar domSize = 0, children = vnode.children\n\t\tvnode.dom = null\n\t\tif (children != null) {\n\t\t\tfor (var i = 0; i < children.length; i++) {\n\t\t\t\tvar child = children[i]\n\t\t\t\tif (child != null && child.dom != null) {\n\t\t\t\t\tif (vnode.dom == null) vnode.dom = child.dom\n\t\t\t\t\tdomSize += child.domSize || 1\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (domSize !== 1) vnode.domSize = domSize\n\t\t}\n\t}\n\tfunction updateElement(old, vnode, hooks, ns) {\n\t\tvar element = vnode.dom = old.dom\n\t\tns = getNameSpace(vnode) || ns\n\n\t\tif (vnode.tag === \"textarea\") {\n\t\t\tif (vnode.attrs == null) vnode.attrs = {}\n\t\t\tif (vnode.text != null) {\n\t\t\t\tvnode.attrs.value = vnode.text //FIXME handle multiple children\n\t\t\t\tvnode.text = undefined\n\t\t\t}\n\t\t}\n\t\tupdateAttrs(vnode, old.attrs, vnode.attrs, ns)\n\t\tif (!maybeSetContentEditable(vnode)) {\n\t\t\tif (old.text != null && vnode.text != null && vnode.text !== \"\") {\n\t\t\t\tif (old.text.toString() !== vnode.text.toString()) old.dom.firstChild.nodeValue = vnode.text\n\t\t\t}\n\t\t\telse {\n\t\t\t\tif (old.text != null) old.children = [Vnode(\"#\", undefined, undefined, old.text, undefined, old.dom.firstChild)]\n\t\t\t\tif (vnode.text != null) vnode.children = [Vnode(\"#\", undefined, undefined, vnode.text, undefined, undefined)]\n\t\t\t\tupdateNodes(element, old.children, vnode.children, hooks, null, ns)\n\t\t\t}\n\t\t}\n\t}\n\tfunction updateComponent(parent, old, vnode, hooks, nextSibling, ns) {\n\t\tvnode.instance = Vnode.normalize(callHook.call(vnode.state.view, vnode))\n\t\tif (vnode.instance === vnode) throw Error(\"A view cannot return the vnode it received as argument\")\n\t\tupdateLifecycle(vnode.state, vnode, hooks)\n\t\tif (vnode.attrs != null) updateLifecycle(vnode.attrs, vnode, hooks)\n\t\tif (vnode.instance != null) {\n\t\t\tif (old.instance == null) createNode(parent, vnode.instance, hooks, ns, nextSibling)\n\t\t\telse updateNode(parent, old.instance, vnode.instance, hooks, nextSibling, ns)\n\t\t\tvnode.dom = vnode.instance.dom\n\t\t\tvnode.domSize = vnode.instance.domSize\n\t\t}\n\t\telse if (old.instance != null) {\n\t\t\tremoveNode(parent, old.instance)\n\t\t\tvnode.dom = undefined\n\t\t\tvnode.domSize = 0\n\t\t}\n\t\telse {\n\t\t\tvnode.dom = old.dom\n\t\t\tvnode.domSize = old.domSize\n\t\t}\n\t}\n\tfunction getKeyMap(vnodes, start, end) {\n\t\tvar map = Object.create(null)\n\t\tfor (; start < end; start++) {\n\t\t\tvar vnode = vnodes[start]\n\t\t\tif (vnode != null) {\n\t\t\t\tvar key = vnode.key\n\t\t\t\tif (key != null) map[key] = start\n\t\t\t}\n\t\t}\n\t\treturn map\n\t}\n\t// Lifted from ivi https://github.com/ivijs/ivi/\n\t// takes a list of unique numbers (-1 is special and can\n\t// occur multiple times) and returns an array with the indices\n\t// of the items that are part of the longest increasing\n\t// subsequece\n\tvar lisTemp = []\n\tfunction makeLisIndices(a) {\n\t\tvar result = [0]\n\t\tvar u = 0, v = 0, i = 0\n\t\tvar il = lisTemp.length = a.length\n\t\tfor (var i = 0; i < il; i++) lisTemp[i] = a[i]\n\t\tfor (var i = 0; i < il; ++i) {\n\t\t\tif (a[i] === -1) continue\n\t\t\tvar j = result[result.length - 1]\n\t\t\tif (a[j] < a[i]) {\n\t\t\t\tlisTemp[i] = j\n\t\t\t\tresult.push(i)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tu = 0\n\t\t\tv = result.length - 1\n\t\t\twhile (u < v) {\n\t\t\t\t// Fast integer average without overflow.\n\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\tvar c = (u >>> 1) + (v >>> 1) + (u & v & 1)\n\t\t\t\tif (a[result[c]] < a[i]) {\n\t\t\t\t\tu = c + 1\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tv = c\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (a[i] < a[result[u]]) {\n\t\t\t\tif (u > 0) lisTemp[i] = result[u - 1]\n\t\t\t\tresult[u] = i\n\t\t\t}\n\t\t}\n\t\tu = result.length\n\t\tv = result[u - 1]\n\t\twhile (u-- > 0) {\n\t\t\tresult[u] = v\n\t\t\tv = lisTemp[v]\n\t\t}\n\t\tlisTemp.length = 0\n\t\treturn result\n\t}\n\n\tfunction getNextSibling(vnodes, i, nextSibling) {\n\t\tfor (; i < vnodes.length; i++) {\n\t\t\tif (vnodes[i] != null && vnodes[i].dom != null) return vnodes[i].dom\n\t\t}\n\t\treturn nextSibling\n\t}\n\n\t// This covers a really specific edge case:\n\t// - Parent node is keyed and contains child\n\t// - Child is removed, returns unresolved promise in `onbeforeremove`\n\t// - Parent node is moved in keyed diff\n\t// - Remaining children still need moved appropriately\n\t//\n\t// Ideally, I'd track removed nodes as well, but that introduces a lot more\n\t// complexity and I'm not exactly interested in doing that.\n\tfunction moveNodes(parent, vnode, nextSibling) {\n\t\tvar frag = $doc.createDocumentFragment()\n\t\tmoveChildToFrag(parent, frag, vnode)\n\t\tinsertNode(parent, frag, nextSibling)\n\t}\n\tfunction moveChildToFrag(parent, frag, vnode) {\n\t\t// Dodge the recursion overhead in a few of the most common cases.\n\t\twhile (vnode.dom != null && vnode.dom.parentNode === parent) {\n\t\t\tif (typeof vnode.tag !== \"string\") {\n\t\t\t\tvnode = vnode.instance\n\t\t\t\tif (vnode != null) continue\n\t\t\t} else if (vnode.tag === \"<\") {\n\t\t\t\tfor (var i = 0; i < vnode.instance.length; i++) {\n\t\t\t\t\tfrag.appendChild(vnode.instance[i])\n\t\t\t\t}\n\t\t\t} else if (vnode.tag !== \"[\") {\n\t\t\t\t// Don't recurse for text nodes *or* elements, just fragments\n\t\t\t\tfrag.appendChild(vnode.dom)\n\t\t\t} else if (vnode.children.length === 1) {\n\t\t\t\tvnode = vnode.children[0]\n\t\t\t\tif (vnode != null) continue\n\t\t\t} else {\n\t\t\t\tfor (var i = 0; i < vnode.children.length; i++) {\n\t\t\t\t\tvar child = vnode.children[i]\n\t\t\t\t\tif (child != null) moveChildToFrag(parent, frag, child)\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t}\n\n\tfunction insertNode(parent, dom, nextSibling) {\n\t\tif (nextSibling != null) parent.insertBefore(dom, nextSibling)\n\t\telse parent.appendChild(dom)\n\t}\n\n\tfunction maybeSetContentEditable(vnode) {\n\t\tif (vnode.attrs == null || (\n\t\t\tvnode.attrs.contenteditable == null && // attribute\n\t\t\tvnode.attrs.contentEditable == null // property\n\t\t)) return false\n\t\tvar children = vnode.children\n\t\tif (children != null && children.length === 1 && children[0].tag === \"<\") {\n\t\t\tvar content = children[0].children\n\t\t\tif (vnode.dom.innerHTML !== content) vnode.dom.innerHTML = content\n\t\t}\n\t\telse if (vnode.text != null || children != null && children.length !== 0) throw new Error(\"Child node of a contenteditable must be trusted\")\n\t\treturn true\n\t}\n\n\t//remove\n\tfunction removeNodes(parent, vnodes, start, end) {\n\t\tfor (var i = start; i < end; i++) {\n\t\t\tvar vnode = vnodes[i]\n\t\t\tif (vnode != null) removeNode(parent, vnode)\n\t\t}\n\t}\n\tfunction removeNode(parent, vnode) {\n\t\tvar mask = 0\n\t\tvar original = vnode.state\n\t\tvar stateResult, attrsResult\n\t\tif (typeof vnode.tag !== \"string\" && typeof vnode.state.onbeforeremove === \"function\") {\n\t\t\tvar result = callHook.call(vnode.state.onbeforeremove, vnode)\n\t\t\tif (result != null && typeof result.then === \"function\") {\n\t\t\t\tmask = 1\n\t\t\t\tstateResult = result\n\t\t\t}\n\t\t}\n\t\tif (vnode.attrs && typeof vnode.attrs.onbeforeremove === \"function\") {\n\t\t\tvar result = callHook.call(vnode.attrs.onbeforeremove, vnode)\n\t\t\tif (result != null && typeof result.then === \"function\") {\n\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\tmask |= 2\n\t\t\t\tattrsResult = result\n\t\t\t}\n\t\t}\n\t\tcheckState(vnode, original)\n\n\t\t// If we can, try to fast-path it and avoid all the overhead of awaiting\n\t\tif (!mask) {\n\t\t\tonremove(vnode)\n\t\t\tremoveChild(parent, vnode)\n\t\t} else {\n\t\t\tif (stateResult != null) {\n\t\t\t\tvar next = function () {\n\t\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\t\tif (mask & 1) { mask &= 2; if (!mask) reallyRemove() }\n\t\t\t\t}\n\t\t\t\tstateResult.then(next, next)\n\t\t\t}\n\t\t\tif (attrsResult != null) {\n\t\t\t\tvar next = function () {\n\t\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\t\tif (mask & 2) { mask &= 1; if (!mask) reallyRemove() }\n\t\t\t\t}\n\t\t\t\tattrsResult.then(next, next)\n\t\t\t}\n\t\t}\n\n\t\tfunction reallyRemove() {\n\t\t\tcheckState(vnode, original)\n\t\t\tonremove(vnode)\n\t\t\tremoveChild(parent, vnode)\n\t\t}\n\t}\n\tfunction removeHTML(parent, vnode) {\n\t\tfor (var i = 0; i < vnode.instance.length; i++) {\n\t\t\tparent.removeChild(vnode.instance[i])\n\t\t}\n\t}\n\tfunction removeChild(parent, vnode) {\n\t\t// Dodge the recursion overhead in a few of the most common cases.\n\t\twhile (vnode.dom != null && vnode.dom.parentNode === parent) {\n\t\t\tif (typeof vnode.tag !== \"string\") {\n\t\t\t\tvnode = vnode.instance\n\t\t\t\tif (vnode != null) continue\n\t\t\t} else if (vnode.tag === \"<\") {\n\t\t\t\tremoveHTML(parent, vnode)\n\t\t\t} else {\n\t\t\t\tif (vnode.tag !== \"[\") {\n\t\t\t\t\tparent.removeChild(vnode.dom)\n\t\t\t\t\tif (!Array.isArray(vnode.children)) break\n\t\t\t\t}\n\t\t\t\tif (vnode.children.length === 1) {\n\t\t\t\t\tvnode = vnode.children[0]\n\t\t\t\t\tif (vnode != null) continue\n\t\t\t\t} else {\n\t\t\t\t\tfor (var i = 0; i < vnode.children.length; i++) {\n\t\t\t\t\t\tvar child = vnode.children[i]\n\t\t\t\t\t\tif (child != null) removeChild(parent, child)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t}\n\tfunction onremove(vnode) {\n\t\tif (typeof vnode.tag !== \"string\" && typeof vnode.state.onremove === \"function\") callHook.call(vnode.state.onremove, vnode)\n\t\tif (vnode.attrs && typeof vnode.attrs.onremove === \"function\") callHook.call(vnode.attrs.onremove, vnode)\n\t\tif (typeof vnode.tag !== \"string\") {\n\t\t\tif (vnode.instance != null) onremove(vnode.instance)\n\t\t} else {\n\t\t\tvar children = vnode.children\n\t\t\tif (Array.isArray(children)) {\n\t\t\t\tfor (var i = 0; i < children.length; i++) {\n\t\t\t\t\tvar child = children[i]\n\t\t\t\t\tif (child != null) onremove(child)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t//attrs\n\tfunction setAttrs(vnode, attrs, ns) {\n\t\tfor (var key in attrs) {\n\t\t\tsetAttr(vnode, key, null, attrs[key], ns)\n\t\t}\n\t}\n\tfunction setAttr(vnode, key, old, value, ns) {\n\t\tif (key === \"key\" || key === \"is\" || value == null || isLifecycleMethod(key) || (old === value && !isFormAttribute(vnode, key)) && typeof value !== \"object\") return\n\t\tif (key[0] === \"o\" && key[1] === \"n\") return updateEvent(vnode, key, value)\n\t\tif (key.slice(0, 6) === \"xlink:\") vnode.dom.setAttributeNS(\"http://www.w3.org/1999/xlink\", key.slice(6), value)\n\t\telse if (key === \"style\") updateStyle(vnode.dom, old, value)\n\t\telse if (hasPropertyKey(vnode, key, ns)) {\n\t\t\tif (key === \"value\") {\n\t\t\t\t// Only do the coercion if we're actually going to check the value.\n\t\t\t\t/* eslint-disable no-implicit-coercion */\n\t\t\t\t//setting input[value] to same value by typing on focused element moves cursor to end in Chrome\n\t\t\t\tif ((vnode.tag === \"input\" || vnode.tag === \"textarea\") && vnode.dom.value === \"\" + value && vnode.dom === activeElement()) return\n\t\t\t\t//setting select[value] to same value while having select open blinks select dropdown in Chrome\n\t\t\t\tif (vnode.tag === \"select\" && old !== null && vnode.dom.value === \"\" + value) return\n\t\t\t\t//setting option[value] to same value while having select open blinks select dropdown in Chrome\n\t\t\t\tif (vnode.tag === \"option\" && old !== null && vnode.dom.value === \"\" + value) return\n\t\t\t\t/* eslint-enable no-implicit-coercion */\n\t\t\t}\n\t\t\t// If you assign an input type that is not supported by IE 11 with an assignment expression, an error will occur.\n\t\t\tif (vnode.tag === \"input\" && key === \"type\") vnode.dom.setAttribute(key, value)\n\t\t\telse vnode.dom[key] = value\n\t\t} else {\n\t\t\tif (typeof value === \"boolean\") {\n\t\t\t\tif (value) vnode.dom.setAttribute(key, \"\")\n\t\t\t\telse vnode.dom.removeAttribute(key)\n\t\t\t}\n\t\t\telse vnode.dom.setAttribute(key === \"className\" ? \"class\" : key, value)\n\t\t}\n\t}\n\tfunction removeAttr(vnode, key, old, ns) {\n\t\tif (key === \"key\" || key === \"is\" || old == null || isLifecycleMethod(key)) return\n\t\tif (key[0] === \"o\" && key[1] === \"n\" && !isLifecycleMethod(key)) updateEvent(vnode, key, undefined)\n\t\telse if (key === \"style\") updateStyle(vnode.dom, old, null)\n\t\telse if (\n\t\t\thasPropertyKey(vnode, key, ns)\n\t\t\t&& key !== \"className\"\n\t\t\t&& !(key === \"value\" && (\n\t\t\t\tvnode.tag === \"option\"\n\t\t\t\t|| vnode.tag === \"select\" && vnode.dom.selectedIndex === -1 && vnode.dom === activeElement()\n\t\t\t))\n\t\t\t&& !(vnode.tag === \"input\" && key === \"type\")\n\t\t) {\n\t\t\tvnode.dom[key] = null\n\t\t} else {\n\t\t\tvar nsLastIndex = key.indexOf(\":\")\n\t\t\tif (nsLastIndex !== -1) key = key.slice(nsLastIndex + 1)\n\t\t\tif (old !== false) vnode.dom.removeAttribute(key === \"className\" ? \"class\" : key)\n\t\t}\n\t}\n\tfunction setLateSelectAttrs(vnode, attrs) {\n\t\tif (\"value\" in attrs) {\n\t\t\tif(attrs.value === null) {\n\t\t\t\tif (vnode.dom.selectedIndex !== -1) vnode.dom.value = null\n\t\t\t} else {\n\t\t\t\tvar normalized = \"\" + attrs.value // eslint-disable-line no-implicit-coercion\n\t\t\t\tif (vnode.dom.value !== normalized || vnode.dom.selectedIndex === -1) {\n\t\t\t\t\tvnode.dom.value = normalized\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (\"selectedIndex\" in attrs) setAttr(vnode, \"selectedIndex\", null, attrs.selectedIndex, undefined)\n\t}\n\tfunction updateAttrs(vnode, old, attrs, ns) {\n\t\tif (attrs != null) {\n\t\t\tfor (var key in attrs) {\n\t\t\t\tsetAttr(vnode, key, old && old[key], attrs[key], ns)\n\t\t\t}\n\t\t}\n\t\tvar val\n\t\tif (old != null) {\n\t\t\tfor (var key in old) {\n\t\t\t\tif (((val = old[key]) != null) && (attrs == null || attrs[key] == null)) {\n\t\t\t\t\tremoveAttr(vnode, key, val, ns)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tfunction isFormAttribute(vnode, attr) {\n\t\treturn attr === \"value\" || attr === \"checked\" || attr === \"selectedIndex\" || attr === \"selected\" && vnode.dom === activeElement() || vnode.tag === \"option\" && vnode.dom.parentNode === $doc.activeElement\n\t}\n\tfunction isLifecycleMethod(attr) {\n\t\treturn attr === \"oninit\" || attr === \"oncreate\" || attr === \"onupdate\" || attr === \"onremove\" || attr === \"onbeforeremove\" || attr === \"onbeforeupdate\"\n\t}\n\tfunction hasPropertyKey(vnode, key, ns) {\n\t\t// Filter out namespaced keys\n\t\treturn ns === undefined && (\n\t\t\t// If it's a custom element, just keep it.\n\t\t\tvnode.tag.indexOf(\"-\") > -1 || vnode.attrs != null && vnode.attrs.is ||\n\t\t\t// If it's a normal element, let's try to avoid a few browser bugs.\n\t\t\tkey !== \"href\" && key !== \"list\" && key !== \"form\" && key !== \"width\" && key !== \"height\"// && key !== \"type\"\n\t\t\t// Defer the property check until *after* we check everything.\n\t\t) && key in vnode.dom\n\t}\n\n\t//style\n\tvar uppercaseRegex = /[A-Z]/g\n\tfunction toLowerCase(capital) { return \"-\" + capital.toLowerCase() }\n\tfunction normalizeKey(key) {\n\t\treturn key[0] === \"-\" && key[1] === \"-\" ? key :\n\t\t\tkey === \"cssFloat\" ? \"float\" :\n\t\t\t\tkey.replace(uppercaseRegex, toLowerCase)\n\t}\n\tfunction updateStyle(element, old, style) {\n\t\tif (old === style) {\n\t\t\t// Styles are equivalent, do nothing.\n\t\t} else if (style == null) {\n\t\t\t// New style is missing, just clear it.\n\t\t\telement.style.cssText = \"\"\n\t\t} else if (typeof style !== \"object\") {\n\t\t\t// New style is a string, let engine deal with patching.\n\t\t\telement.style.cssText = style\n\t\t} else if (old == null || typeof old !== \"object\") {\n\t\t\t// `old` is missing or a string, `style` is an object.\n\t\t\telement.style.cssText = \"\"\n\t\t\t// Add new style properties\n\t\t\tfor (var key in style) {\n\t\t\t\tvar value = style[key]\n\t\t\t\tif (value != null) element.style.setProperty(normalizeKey(key), String(value))\n\t\t\t}\n\t\t} else {\n\t\t\t// Both old & new are (different) objects.\n\t\t\t// Update style properties that have changed\n\t\t\tfor (var key in style) {\n\t\t\t\tvar value = style[key]\n\t\t\t\tif (value != null && (value = String(value)) !== String(old[key])) {\n\t\t\t\t\telement.style.setProperty(normalizeKey(key), value)\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Remove style properties that no longer exist\n\t\t\tfor (var key in old) {\n\t\t\t\tif (old[key] != null && style[key] == null) {\n\t\t\t\t\telement.style.removeProperty(normalizeKey(key))\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// Here's an explanation of how this works:\n\t// 1. The event names are always (by design) prefixed by `on`.\n\t// 2. The EventListener interface accepts either a function or an object\n\t// with a `handleEvent` method.\n\t// 3. The object does not inherit from `Object.prototype`, to avoid\n\t// any potential interference with that (e.g. setters).\n\t// 4. The event name is remapped to the handler before calling it.\n\t// 5. In function-based event handlers, `ev.target === this`. We replicate\n\t// that below.\n\t// 6. In function-based event handlers, `return false` prevents the default\n\t// action and stops event propagation. We replicate that below.\n\tfunction EventDict() {\n\t\t// Save this, so the current redraw is correctly tracked.\n\t\tthis._ = currentRedraw\n\t}\n\tEventDict.prototype = Object.create(null)\n\tEventDict.prototype.handleEvent = function (ev) {\n\t\tvar handler = this[\"on\" + ev.type]\n\t\tvar result\n\t\tif (typeof handler === \"function\") result = handler.call(ev.currentTarget, ev)\n\t\telse if (typeof handler.handleEvent === \"function\") handler.handleEvent(ev)\n\t\tif (this._ && ev.redraw !== false) (0, this._)()\n\t\tif (result === false) {\n\t\t\tev.preventDefault()\n\t\t\tev.stopPropagation()\n\t\t}\n\t}\n\n\t//event\n\tfunction updateEvent(vnode, key, value) {\n\t\tif (vnode.events != null) {\n\t\t\tif (vnode.events[key] === value) return\n\t\t\tif (value != null && (typeof value === \"function\" || typeof value === \"object\")) {\n\t\t\t\tif (vnode.events[key] == null) vnode.dom.addEventListener(key.slice(2), vnode.events, false)\n\t\t\t\tvnode.events[key] = value\n\t\t\t} else {\n\t\t\t\tif (vnode.events[key] != null) vnode.dom.removeEventListener(key.slice(2), vnode.events, false)\n\t\t\t\tvnode.events[key] = undefined\n\t\t\t}\n\t\t} else if (value != null && (typeof value === \"function\" || typeof value === \"object\")) {\n\t\t\tvnode.events = new EventDict()\n\t\t\tvnode.dom.addEventListener(key.slice(2), vnode.events, false)\n\t\t\tvnode.events[key] = value\n\t\t}\n\t}\n\n\t//lifecycle\n\tfunction initLifecycle(source, vnode, hooks) {\n\t\tif (typeof source.oninit === \"function\") callHook.call(source.oninit, vnode)\n\t\tif (typeof source.oncreate === \"function\") hooks.push(callHook.bind(source.oncreate, vnode))\n\t}\n\tfunction updateLifecycle(source, vnode, hooks) {\n\t\tif (typeof source.onupdate === \"function\") hooks.push(callHook.bind(source.onupdate, vnode))\n\t}\n\tfunction shouldNotUpdate(vnode, old) {\n\t\tdo {\n\t\t\tif (vnode.attrs != null && typeof vnode.attrs.onbeforeupdate === \"function\") {\n\t\t\t\tvar force = callHook.call(vnode.attrs.onbeforeupdate, vnode, old)\n\t\t\t\tif (force !== undefined && !force) break\n\t\t\t}\n\t\t\tif (typeof vnode.tag !== \"string\" && typeof vnode.state.onbeforeupdate === \"function\") {\n\t\t\t\tvar force = callHook.call(vnode.state.onbeforeupdate, vnode, old)\n\t\t\t\tif (force !== undefined && !force) break\n\t\t\t}\n\t\t\treturn false\n\t\t} while (false); // eslint-disable-line no-constant-condition\n\t\tvnode.dom = old.dom\n\t\tvnode.domSize = old.domSize\n\t\tvnode.instance = old.instance\n\t\t// One would think having the actual latest attributes would be ideal,\n\t\t// but it doesn't let us properly diff based on our current internal\n\t\t// representation. We have to save not only the old DOM info, but also\n\t\t// the attributes used to create it, as we diff *that*, not against the\n\t\t// DOM directly (with a few exceptions in `setAttr`). And, of course, we\n\t\t// need to save the children and text as they are conceptually not\n\t\t// unlike special \"attributes\" internally.\n\t\tvnode.attrs = old.attrs\n\t\tvnode.children = old.children\n\t\tvnode.text = old.text\n\t\treturn true\n\t}\n\n\treturn function(dom, vnodes, redraw) {\n\t\tif (!dom) throw new TypeError(\"Ensure the DOM element being passed to m.route/m.mount/m.render is not undefined.\")\n\t\tvar hooks = []\n\t\tvar active = activeElement()\n\t\tvar namespace = dom.namespaceURI\n\n\t\t// First time rendering into a node clears it out\n\t\tif (dom.vnodes == null) dom.textContent = \"\"\n\n\t\tvnodes = Vnode.normalizeChildren(Array.isArray(vnodes) ? vnodes : [vnodes])\n\t\tvar prevRedraw = currentRedraw\n\t\ttry {\n\t\t\tcurrentRedraw = typeof redraw === \"function\" ? redraw : undefined\n\t\t\tupdateNodes(dom, dom.vnodes, vnodes, hooks, null, namespace === \"http://www.w3.org/1999/xhtml\" ? undefined : namespace)\n\t\t} finally {\n\t\t\tcurrentRedraw = prevRedraw\n\t\t}\n\t\tdom.vnodes = vnodes\n\t\t// `document.activeElement` can return null: https://html.spec.whatwg.org/multipage/interaction.html#dom-document-activeelement\n\t\tif (active != null && activeElement() !== active && typeof active.focus === \"function\") active.focus()\n\t\tfor (var i = 0; i < hooks.length; i++) hooks[i]()\n\t}\n}\n", "\"use strict\"\n\nmodule.exports = require(\"./render/render\")(window)\n", "\"use strict\"\n\nvar Vnode = require(\"../render/vnode\")\n\nmodule.exports = function(render, schedule, console) {\n\tvar subscriptions = []\n\tvar rendering = false\n\tvar pending = false\n\n\tfunction sync() {\n\t\tif (rendering) throw new Error(\"Nested m.redraw.sync() call\")\n\t\trendering = true\n\t\tfor (var i = 0; i < subscriptions.length; i += 2) {\n\t\t\ttry { render(subscriptions[i], Vnode(subscriptions[i + 1]), redraw) }\n\t\t\tcatch (e) { console.error(e) }\n\t\t}\n\t\trendering = false\n\t}\n\n\tfunction redraw() {\n\t\tif (!pending) {\n\t\t\tpending = true\n\t\t\tschedule(function() {\n\t\t\t\tpending = false\n\t\t\t\tsync()\n\t\t\t})\n\t\t}\n\t}\n\n\tredraw.sync = sync\n\n\tfunction mount(root, component) {\n\t\tif (component != null && component.view == null && typeof component !== \"function\") {\n\t\t\tthrow new TypeError(\"m.mount(element, component) expects a component, not a vnode\")\n\t\t}\n\n\t\tvar index = subscriptions.indexOf(root)\n\t\tif (index >= 0) {\n\t\t\tsubscriptions.splice(index, 2)\n\t\t\trender(root, [], redraw)\n\t\t}\n\n\t\tif (component != null) {\n\t\t\tsubscriptions.push(root, component)\n\t\t\trender(root, Vnode(component), redraw)\n\t\t}\n\t}\n\n\treturn {mount: mount, redraw: redraw}\n}\n", "\"use strict\"\n\nvar render = require(\"./render\")\n\nmodule.exports = require(\"./api/mount-redraw\")(render, requestAnimationFrame, console)\n", "\"use strict\"\n\nmodule.exports = function(object) {\n\tif (Object.prototype.toString.call(object) !== \"[object Object]\") return \"\"\n\n\tvar args = []\n\tfor (var key in object) {\n\t\tdestructure(key, object[key])\n\t}\n\n\treturn args.join(\"&\")\n\n\tfunction destructure(key, value) {\n\t\tif (Array.isArray(value)) {\n\t\t\tfor (var i = 0; i < value.length; i++) {\n\t\t\t\tdestructure(key + \"[\" + i + \"]\", value[i])\n\t\t\t}\n\t\t}\n\t\telse if (Object.prototype.toString.call(value) === \"[object Object]\") {\n\t\t\tfor (var i in value) {\n\t\t\t\tdestructure(key + \"[\" + i + \"]\", value[i])\n\t\t\t}\n\t\t}\n\t\telse args.push(encodeURIComponent(key) + (value != null && value !== \"\" ? \"=\" + encodeURIComponent(value) : \"\"))\n\t}\n}\n", "\"use strict\"\n\nmodule.exports = Object.assign || function(target, source) {\n\tif(source) Object.keys(source).forEach(function(key) { target[key] = source[key] })\n}\n", "\"use strict\"\n\nvar buildQueryString = require(\"../querystring/build\")\nvar assign = require(\"./assign\")\n\n// Returns `path` from `template` + `params`\nmodule.exports = function(template, params) {\n\tif ((/:([^\\/\\.-]+)(\\.{3})?:/).test(template)) {\n\t\tthrow new SyntaxError(\"Template parameter names *must* be separated\")\n\t}\n\tif (params == null) return template\n\tvar queryIndex = template.indexOf(\"?\")\n\tvar hashIndex = template.indexOf(\"#\")\n\tvar queryEnd = hashIndex < 0 ? template.length : hashIndex\n\tvar pathEnd = queryIndex < 0 ? queryEnd : queryIndex\n\tvar path = template.slice(0, pathEnd)\n\tvar query = {}\n\n\tassign(query, params)\n\n\tvar resolved = path.replace(/:([^\\/\\.-]+)(\\.{3})?/g, function(m, key, variadic) {\n\t\tdelete query[key]\n\t\t// If no such parameter exists, don't interpolate it.\n\t\tif (params[key] == null) return m\n\t\t// Escape normal parameters, but not variadic ones.\n\t\treturn variadic ? params[key] : encodeURIComponent(String(params[key]))\n\t})\n\n\t// In case the template substitution adds new query/hash parameters.\n\tvar newQueryIndex = resolved.indexOf(\"?\")\n\tvar newHashIndex = resolved.indexOf(\"#\")\n\tvar newQueryEnd = newHashIndex < 0 ? resolved.length : newHashIndex\n\tvar newPathEnd = newQueryIndex < 0 ? newQueryEnd : newQueryIndex\n\tvar result = resolved.slice(0, newPathEnd)\n\n\tif (queryIndex >= 0) result += template.slice(queryIndex, queryEnd)\n\tif (newQueryIndex >= 0) result += (queryIndex < 0 ? \"?\" : \"&\") + resolved.slice(newQueryIndex, newQueryEnd)\n\tvar querystring = buildQueryString(query)\n\tif (querystring) result += (queryIndex < 0 && newQueryIndex < 0 ? \"?\" : \"&\") + querystring\n\tif (hashIndex >= 0) result += template.slice(hashIndex)\n\tif (newHashIndex >= 0) result += (hashIndex < 0 ? \"\" : \"&\") + resolved.slice(newHashIndex)\n\treturn result\n}\n", "\"use strict\"\n\nvar buildPathname = require(\"../pathname/build\")\n\nmodule.exports = function($window, Promise, oncompletion) {\n\tvar callbackCount = 0\n\n\tfunction PromiseProxy(executor) {\n\t\treturn new Promise(executor)\n\t}\n\n\t// In case the global Promise is some userland library's where they rely on\n\t// `foo instanceof this.constructor`, `this.constructor.resolve(value)`, or\n\t// similar. Let's *not* break them.\n\tPromiseProxy.prototype = Promise.prototype\n\tPromiseProxy.__proto__ = Promise // eslint-disable-line no-proto\n\n\tfunction makeRequest(factory) {\n\t\treturn function(url, args) {\n\t\t\tif (typeof url !== \"string\") { args = url; url = url.url }\n\t\t\telse if (args == null) args = {}\n\t\t\tvar promise = new Promise(function(resolve, reject) {\n\t\t\t\tfactory(buildPathname(url, args.params), args, function (data) {\n\t\t\t\t\tif (typeof args.type === \"function\") {\n\t\t\t\t\t\tif (Array.isArray(data)) {\n\t\t\t\t\t\t\tfor (var i = 0; i < data.length; i++) {\n\t\t\t\t\t\t\t\tdata[i] = new args.type(data[i])\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse data = new args.type(data)\n\t\t\t\t\t}\n\t\t\t\t\tresolve(data)\n\t\t\t\t}, reject)\n\t\t\t})\n\t\t\tif (args.background === true) return promise\n\t\t\tvar count = 0\n\t\t\tfunction complete() {\n\t\t\t\tif (--count === 0 && typeof oncompletion === \"function\") oncompletion()\n\t\t\t}\n\n\t\t\treturn wrap(promise)\n\n\t\t\tfunction wrap(promise) {\n\t\t\t\tvar then = promise.then\n\t\t\t\t// Set the constructor, so engines know to not await or resolve\n\t\t\t\t// this as a native promise. At the time of writing, this is\n\t\t\t\t// only necessary for V8, but their behavior is the correct\n\t\t\t\t// behavior per spec. See this spec issue for more details:\n\t\t\t\t// https://github.com/tc39/ecma262/issues/1577. Also, see the\n\t\t\t\t// corresponding comment in `request/tests/test-request.js` for\n\t\t\t\t// a bit more background on the issue at hand.\n\t\t\t\tpromise.constructor = PromiseProxy\n\t\t\t\tpromise.then = function() {\n\t\t\t\t\tcount++\n\t\t\t\t\tvar next = then.apply(promise, arguments)\n\t\t\t\t\tnext.then(complete, function(e) {\n\t\t\t\t\t\tcomplete()\n\t\t\t\t\t\tif (count === 0) throw e\n\t\t\t\t\t})\n\t\t\t\t\treturn wrap(next)\n\t\t\t\t}\n\t\t\t\treturn promise\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction hasHeader(args, name) {\n\t\tfor (var key in args.headers) {\n\t\t\tif ({}.hasOwnProperty.call(args.headers, key) && name.test(key)) return true\n\t\t}\n\t\treturn false\n\t}\n\n\treturn {\n\t\trequest: makeRequest(function(url, args, resolve, reject) {\n\t\t\tvar method = args.method != null ? args.method.toUpperCase() : \"GET\"\n\t\t\tvar body = args.body\n\t\t\tvar assumeJSON = (args.serialize == null || args.serialize === JSON.serialize) && !(body instanceof $window.FormData)\n\t\t\tvar responseType = args.responseType || (typeof args.extract === \"function\" ? \"\" : \"json\")\n\n\t\t\tvar xhr = new $window.XMLHttpRequest(), aborted = false\n\t\t\tvar original = xhr, replacedAbort\n\t\t\tvar abort = xhr.abort\n\n\t\t\txhr.abort = function() {\n\t\t\t\taborted = true\n\t\t\t\tabort.call(this)\n\t\t\t}\n\n\t\t\txhr.open(method, url, args.async !== false, typeof args.user === \"string\" ? args.user : undefined, typeof args.password === \"string\" ? args.password : undefined)\n\n\t\t\tif (assumeJSON && body != null && !hasHeader(args, /^content-type$/i)) {\n\t\t\t\txhr.setRequestHeader(\"Content-Type\", \"application/json; charset=utf-8\")\n\t\t\t}\n\t\t\tif (typeof args.deserialize !== \"function\" && !hasHeader(args, /^accept$/i)) {\n\t\t\t\txhr.setRequestHeader(\"Accept\", \"application/json, text/*\")\n\t\t\t}\n\t\t\tif (args.withCredentials) xhr.withCredentials = args.withCredentials\n\t\t\tif (args.timeout) xhr.timeout = args.timeout\n\t\t\txhr.responseType = responseType\n\n\t\t\tfor (var key in args.headers) {\n\t\t\t\tif ({}.hasOwnProperty.call(args.headers, key)) {\n\t\t\t\t\txhr.setRequestHeader(key, args.headers[key])\n\t\t\t\t}\n\t\t\t}\n\n\t\t\txhr.onreadystatechange = function(ev) {\n\t\t\t\t// Don't throw errors on xhr.abort().\n\t\t\t\tif (aborted) return\n\n\t\t\t\tif (ev.target.readyState === 4) {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tvar success = (ev.target.status >= 200 && ev.target.status < 300) || ev.target.status === 304 || (/^file:\\/\\//i).test(url)\n\t\t\t\t\t\t// When the response type isn't \"\" or \"text\",\n\t\t\t\t\t\t// `xhr.responseText` is the wrong thing to use.\n\t\t\t\t\t\t// Browsers do the right thing and throw here, and we\n\t\t\t\t\t\t// should honor that and do the right thing by\n\t\t\t\t\t\t// preferring `xhr.response` where possible/practical.\n\t\t\t\t\t\tvar response = ev.target.response, message\n\n\t\t\t\t\t\tif (responseType === \"json\") {\n\t\t\t\t\t\t\t// For IE and Edge, which don't implement\n\t\t\t\t\t\t\t// `responseType: \"json\"`.\n\t\t\t\t\t\t\tif (!ev.target.responseType && typeof args.extract !== \"function\") response = JSON.parse(ev.target.responseText)\n\t\t\t\t\t\t} else if (!responseType || responseType === \"text\") {\n\t\t\t\t\t\t\t// Only use this default if it's text. If a parsed\n\t\t\t\t\t\t\t// document is needed on old IE and friends (all\n\t\t\t\t\t\t\t// unsupported), the user should use a custom\n\t\t\t\t\t\t\t// `config` instead. They're already using this at\n\t\t\t\t\t\t\t// their own risk.\n\t\t\t\t\t\t\tif (response == null) response = ev.target.responseText\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (typeof args.extract === \"function\") {\n\t\t\t\t\t\t\tresponse = args.extract(ev.target, args)\n\t\t\t\t\t\t\tsuccess = true\n\t\t\t\t\t\t} else if (typeof args.deserialize === \"function\") {\n\t\t\t\t\t\t\tresponse = args.deserialize(response)\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (success) resolve(response)\n\t\t\t\t\t\telse {\n\t\t\t\t\t\t\ttry { message = ev.target.responseText }\n\t\t\t\t\t\t\tcatch (e) { message = response }\n\t\t\t\t\t\t\tvar error = new Error(message)\n\t\t\t\t\t\t\terror.code = ev.target.status\n\t\t\t\t\t\t\terror.response = response\n\t\t\t\t\t\t\treject(error)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tcatch (e) {\n\t\t\t\t\t\treject(e)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (typeof args.config === \"function\") {\n\t\t\t\txhr = args.config(xhr, args, url) || xhr\n\n\t\t\t\t// Propagate the `abort` to any replacement XHR as well.\n\t\t\t\tif (xhr !== original) {\n\t\t\t\t\treplacedAbort = xhr.abort\n\t\t\t\t\txhr.abort = function() {\n\t\t\t\t\t\taborted = true\n\t\t\t\t\t\treplacedAbort.call(this)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (body == null) xhr.send()\n\t\t\telse if (typeof args.serialize === \"function\") xhr.send(args.serialize(body))\n\t\t\telse if (body instanceof $window.FormData) xhr.send(body)\n\t\t\telse xhr.send(JSON.stringify(body))\n\t\t}),\n\t\tjsonp: makeRequest(function(url, args, resolve, reject) {\n\t\t\tvar callbackName = args.callbackName || \"_mithril_\" + Math.round(Math.random() * 1e16) + \"_\" + callbackCount++\n\t\t\tvar script = $window.document.createElement(\"script\")\n\t\t\t$window[callbackName] = function(data) {\n\t\t\t\tdelete $window[callbackName]\n\t\t\t\tscript.parentNode.removeChild(script)\n\t\t\t\tresolve(data)\n\t\t\t}\n\t\t\tscript.onerror = function() {\n\t\t\t\tdelete $window[callbackName]\n\t\t\t\tscript.parentNode.removeChild(script)\n\t\t\t\treject(new Error(\"JSONP request failed\"))\n\t\t\t}\n\t\t\tscript.src = url + (url.indexOf(\"?\") < 0 ? \"?\" : \"&\") +\n\t\t\t\tencodeURIComponent(args.callbackKey || \"callback\") + \"=\" +\n\t\t\t\tencodeURIComponent(callbackName)\n\t\t\t$window.document.documentElement.appendChild(script)\n\t\t}),\n\t}\n}\n", "\"use strict\"\n\nvar PromisePolyfill = require(\"./promise/promise\")\nvar mountRedraw = require(\"./mount-redraw\")\n\nmodule.exports = require(\"./request/request\")(window, PromisePolyfill, mountRedraw.redraw)\n", "\"use strict\"\n\nmodule.exports = function(string) {\n\tif (string === \"\" || string == null) return {}\n\tif (string.charAt(0) === \"?\") string = string.slice(1)\n\n\tvar entries = string.split(\"&\"), counters = {}, data = {}\n\tfor (var i = 0; i < entries.length; i++) {\n\t\tvar entry = entries[i].split(\"=\")\n\t\tvar key = decodeURIComponent(entry[0])\n\t\tvar value = entry.length === 2 ? decodeURIComponent(entry[1]) : \"\"\n\n\t\tif (value === \"true\") value = true\n\t\telse if (value === \"false\") value = false\n\n\t\tvar levels = key.split(/\\]\\[?|\\[/)\n\t\tvar cursor = data\n\t\tif (key.indexOf(\"[\") > -1) levels.pop()\n\t\tfor (var j = 0; j < levels.length; j++) {\n\t\t\tvar level = levels[j], nextLevel = levels[j + 1]\n\t\t\tvar isNumber = nextLevel == \"\" || !isNaN(parseInt(nextLevel, 10))\n\t\t\tif (level === \"\") {\n\t\t\t\tvar key = levels.slice(0, j).join()\n\t\t\t\tif (counters[key] == null) {\n\t\t\t\t\tcounters[key] = Array.isArray(cursor) ? cursor.length : 0\n\t\t\t\t}\n\t\t\t\tlevel = counters[key]++\n\t\t\t}\n\t\t\t// Disallow direct prototype pollution\n\t\t\telse if (level === \"__proto__\") break\n\t\t\tif (j === levels.length - 1) cursor[level] = value\n\t\t\telse {\n\t\t\t\t// Read own properties exclusively to disallow indirect\n\t\t\t\t// prototype pollution\n\t\t\t\tvar desc = Object.getOwnPropertyDescriptor(cursor, level)\n\t\t\t\tif (desc != null) desc = desc.value\n\t\t\t\tif (desc == null) cursor[level] = desc = isNumber ? [] : {}\n\t\t\t\tcursor = desc\n\t\t\t}\n\t\t}\n\t}\n\treturn data\n}\n", "\"use strict\"\n\nvar parseQueryString = require(\"../querystring/parse\")\n\n// Returns `{path, params}` from `url`\nmodule.exports = function(url) {\n\tvar queryIndex = url.indexOf(\"?\")\n\tvar hashIndex = url.indexOf(\"#\")\n\tvar queryEnd = hashIndex < 0 ? url.length : hashIndex\n\tvar pathEnd = queryIndex < 0 ? queryEnd : queryIndex\n\tvar path = url.slice(0, pathEnd).replace(/\\/{2,}/g, \"/\")\n\n\tif (!path) path = \"/\"\n\telse {\n\t\tif (path[0] !== \"/\") path = \"/\" + path\n\t\tif (path.length > 1 && path[path.length - 1] === \"/\") path = path.slice(0, -1)\n\t}\n\treturn {\n\t\tpath: path,\n\t\tparams: queryIndex < 0\n\t\t\t? {}\n\t\t\t: parseQueryString(url.slice(queryIndex + 1, queryEnd)),\n\t}\n}\n", "\"use strict\"\n\nvar parsePathname = require(\"./parse\")\n\n// Compiles a template into a function that takes a resolved path (without query\n// strings) and returns an object containing the template parameters with their\n// parsed values. This expects the input of the compiled template to be the\n// output of `parsePathname`. Note that it does *not* remove query parameters\n// specified in the template.\nmodule.exports = function(template) {\n\tvar templateData = parsePathname(template)\n\tvar templateKeys = Object.keys(templateData.params)\n\tvar keys = []\n\tvar regexp = new RegExp(\"^\" + templateData.path.replace(\n\t\t// I escape literal text so people can use things like `:file.:ext` or\n\t\t// `:lang-:locale` in routes. This is all merged into one pass so I\n\t\t// don't also accidentally escape `-` and make it harder to detect it to\n\t\t// ban it from template parameters.\n\t\t/:([^\\/.-]+)(\\.{3}|\\.(?!\\.)|-)?|[\\\\^$*+.()|\\[\\]{}]/g,\n\t\tfunction(m, key, extra) {\n\t\t\tif (key == null) return \"\\\\\" + m\n\t\t\tkeys.push({k: key, r: extra === \"...\"})\n\t\t\tif (extra === \"...\") return \"(.*)\"\n\t\t\tif (extra === \".\") return \"([^/]+)\\\\.\"\n\t\t\treturn \"([^/]+)\" + (extra || \"\")\n\t\t}\n\t) + \"$\")\n\treturn function(data) {\n\t\t// First, check the params. Usually, there isn't any, and it's just\n\t\t// checking a static set.\n\t\tfor (var i = 0; i < templateKeys.length; i++) {\n\t\t\tif (templateData.params[templateKeys[i]] !== data.params[templateKeys[i]]) return false\n\t\t}\n\t\t// If no interpolations exist, let's skip all the ceremony\n\t\tif (!keys.length) return regexp.test(data.path)\n\t\tvar values = regexp.exec(data.path)\n\t\tif (values == null) return false\n\t\tfor (var i = 0; i < keys.length; i++) {\n\t\t\tdata.params[keys[i].k] = keys[i].r ? values[i + 1] : decodeURIComponent(values[i + 1])\n\t\t}\n\t\treturn true\n\t}\n}\n", "\"use strict\"\n\nvar Vnode = require(\"../render/vnode\")\nvar m = require(\"../render/hyperscript\")\nvar Promise = require(\"../promise/promise\")\n\nvar buildPathname = require(\"../pathname/build\")\nvar parsePathname = require(\"../pathname/parse\")\nvar compileTemplate = require(\"../pathname/compileTemplate\")\nvar assign = require(\"../pathname/assign\")\n\nvar sentinel = {}\n\nmodule.exports = function($window, mountRedraw) {\n\tvar fireAsync\n\n\tfunction setPath(path, data, options) {\n\t\tpath = buildPathname(path, data)\n\t\tif (fireAsync != null) {\n\t\t\tfireAsync()\n\t\t\tvar state = options ? options.state : null\n\t\t\tvar title = options ? options.title : null\n\t\t\tif (options && options.replace) $window.history.replaceState(state, title, route.prefix + path)\n\t\t\telse $window.history.pushState(state, title, route.prefix + path)\n\t\t}\n\t\telse {\n\t\t\t$window.location.href = route.prefix + path\n\t\t}\n\t}\n\n\tvar currentResolver = sentinel, component, attrs, currentPath, lastUpdate\n\n\tvar SKIP = route.SKIP = {}\n\n\tfunction route(root, defaultRoute, routes) {\n\t\tif (root == null) throw new Error(\"Ensure the DOM element that was passed to `m.route` is not undefined\")\n\t\t// 0 = start\n\t\t// 1 = init\n\t\t// 2 = ready\n\t\tvar state = 0\n\n\t\tvar compiled = Object.keys(routes).map(function(route) {\n\t\t\tif (route[0] !== \"/\") throw new SyntaxError(\"Routes must start with a `/`\")\n\t\t\tif ((/:([^\\/\\.-]+)(\\.{3})?:/).test(route)) {\n\t\t\t\tthrow new SyntaxError(\"Route parameter names must be separated with either `/`, `.`, or `-`\")\n\t\t\t}\n\t\t\treturn {\n\t\t\t\troute: route,\n\t\t\t\tcomponent: routes[route],\n\t\t\t\tcheck: compileTemplate(route),\n\t\t\t}\n\t\t})\n\t\tvar callAsync = typeof setImmediate === \"function\" ? setImmediate : setTimeout\n\t\tvar p = Promise.resolve()\n\t\tvar scheduled = false\n\t\tvar onremove\n\n\t\tfireAsync = null\n\n\t\tif (defaultRoute != null) {\n\t\t\tvar defaultData = parsePathname(defaultRoute)\n\n\t\t\tif (!compiled.some(function (i) { return i.check(defaultData) })) {\n\t\t\t\tthrow new ReferenceError(\"Default route doesn't match any known routes\")\n\t\t\t}\n\t\t}\n\n\t\tfunction resolveRoute() {\n\t\t\tscheduled = false\n\t\t\t// Consider the pathname holistically. The prefix might even be invalid,\n\t\t\t// but that's not our problem.\n\t\t\tvar prefix = $window.location.hash\n\t\t\tif (route.prefix[0] !== \"#\") {\n\t\t\t\tprefix = $window.location.search + prefix\n\t\t\t\tif (route.prefix[0] !== \"?\") {\n\t\t\t\t\tprefix = $window.location.pathname + prefix\n\t\t\t\t\tif (prefix[0] !== \"/\") prefix = \"/\" + prefix\n\t\t\t\t}\n\t\t\t}\n\t\t\t// This seemingly useless `.concat()` speeds up the tests quite a bit,\n\t\t\t// since the representation is consistently a relatively poorly\n\t\t\t// optimized cons string.\n\t\t\tvar path = prefix.concat()\n\t\t\t\t.replace(/(?:%[a-f89][a-f0-9])+/gim, decodeURIComponent)\n\t\t\t\t.slice(route.prefix.length)\n\t\t\tvar data = parsePathname(path)\n\n\t\t\tassign(data.params, $window.history.state)\n\n\t\t\tfunction fail() {\n\t\t\t\tif (path === defaultRoute) throw new Error(\"Could not resolve default route \" + defaultRoute)\n\t\t\t\tsetPath(defaultRoute, null, {replace: true})\n\t\t\t}\n\n\t\t\tloop(0)\n\t\t\tfunction loop(i) {\n\t\t\t\t// 0 = init\n\t\t\t\t// 1 = scheduled\n\t\t\t\t// 2 = done\n\t\t\t\tfor (; i < compiled.length; i++) {\n\t\t\t\t\tif (compiled[i].check(data)) {\n\t\t\t\t\t\tvar payload = compiled[i].component\n\t\t\t\t\t\tvar matchedRoute = compiled[i].route\n\t\t\t\t\t\tvar localComp = payload\n\t\t\t\t\t\tvar update = lastUpdate = function(comp) {\n\t\t\t\t\t\t\tif (update !== lastUpdate) return\n\t\t\t\t\t\t\tif (comp === SKIP) return loop(i + 1)\n\t\t\t\t\t\t\tcomponent = comp != null && (typeof comp.view === \"function\" || typeof comp === \"function\")? comp : \"div\"\n\t\t\t\t\t\t\tattrs = data.params, currentPath = path, lastUpdate = null\n\t\t\t\t\t\t\tcurrentResolver = payload.render ? payload : null\n\t\t\t\t\t\t\tif (state === 2) mountRedraw.redraw()\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tstate = 2\n\t\t\t\t\t\t\t\tmountRedraw.redraw.sync()\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// There's no understating how much I *wish* I could\n\t\t\t\t\t\t// use `async`/`await` here...\n\t\t\t\t\t\tif (payload.view || typeof payload === \"function\") {\n\t\t\t\t\t\t\tpayload = {}\n\t\t\t\t\t\t\tupdate(localComp)\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse if (payload.onmatch) {\n\t\t\t\t\t\t\tp.then(function () {\n\t\t\t\t\t\t\t\treturn payload.onmatch(data.params, path, matchedRoute)\n\t\t\t\t\t\t\t}).then(update, fail)\n\t\t\t\t\t\t}\n\t\t\t\t\t\telse update(\"div\")\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfail()\n\t\t\t}\n\t\t}\n\n\t\t// Set it unconditionally so `m.route.set` and `m.route.Link` both work,\n\t\t// even if neither `pushState` nor `hashchange` are supported. It's\n\t\t// cleared if `hashchange` is used, since that makes it automatically\n\t\t// async.\n\t\tfireAsync = function() {\n\t\t\tif (!scheduled) {\n\t\t\t\tscheduled = true\n\t\t\t\tcallAsync(resolveRoute)\n\t\t\t}\n\t\t}\n\n\t\tif (typeof $window.history.pushState === \"function\") {\n\t\t\tonremove = function() {\n\t\t\t\t$window.removeEventListener(\"popstate\", fireAsync, false)\n\t\t\t}\n\t\t\t$window.addEventListener(\"popstate\", fireAsync, false)\n\t\t} else if (route.prefix[0] === \"#\") {\n\t\t\tfireAsync = null\n\t\t\tonremove = function() {\n\t\t\t\t$window.removeEventListener(\"hashchange\", resolveRoute, false)\n\t\t\t}\n\t\t\t$window.addEventListener(\"hashchange\", resolveRoute, false)\n\t\t}\n\n\t\treturn mountRedraw.mount(root, {\n\t\t\tonbeforeupdate: function() {\n\t\t\t\tstate = state ? 2 : 1\n\t\t\t\treturn !(!state || sentinel === currentResolver)\n\t\t\t},\n\t\t\toncreate: resolveRoute,\n\t\t\tonremove: onremove,\n\t\t\tview: function() {\n\t\t\t\tif (!state || sentinel === currentResolver) return\n\t\t\t\t// Wrap in a fragment to preserve existing key semantics\n\t\t\t\tvar vnode = [Vnode(component, attrs.key, attrs)]\n\t\t\t\tif (currentResolver) vnode = currentResolver.render(vnode[0])\n\t\t\t\treturn vnode\n\t\t\t},\n\t\t})\n\t}\n\troute.set = function(path, data, options) {\n\t\tif (lastUpdate != null) {\n\t\t\toptions = options || {}\n\t\t\toptions.replace = true\n\t\t}\n\t\tlastUpdate = null\n\t\tsetPath(path, data, options)\n\t}\n\troute.get = function() {return currentPath}\n\troute.prefix = \"#!\"\n\troute.Link = {\n\t\tview: function(vnode) {\n\t\t\tvar options = vnode.attrs.options\n\t\t\t// Remove these so they don't get overwritten\n\t\t\tvar attrs = {}, onclick, href\n\t\t\tassign(attrs, vnode.attrs)\n\t\t\t// The first two are internal, but the rest are magic attributes\n\t\t\t// that need censored to not screw up rendering.\n\t\t\tattrs.selector = attrs.options = attrs.key = attrs.oninit =\n\t\t\tattrs.oncreate = attrs.onbeforeupdate = attrs.onupdate =\n\t\t\tattrs.onbeforeremove = attrs.onremove = null\n\n\t\t\t// Do this now so we can get the most current `href` and `disabled`.\n\t\t\t// Those attributes may also be specified in the selector, and we\n\t\t\t// should honor that.\n\t\t\tvar child = m(vnode.attrs.selector || \"a\", attrs, vnode.children)\n\n\t\t\t// Let's provide a *right* way to disable a route link, rather than\n\t\t\t// letting people screw up accessibility on accident.\n\t\t\t//\n\t\t\t// The attribute is coerced so users don't get surprised over\n\t\t\t// `disabled: 0` resulting in a button that's somehow routable\n\t\t\t// despite being visibly disabled.\n\t\t\tif (child.attrs.disabled = Boolean(child.attrs.disabled)) {\n\t\t\t\tchild.attrs.href = null\n\t\t\t\tchild.attrs[\"aria-disabled\"] = \"true\"\n\t\t\t\t// If you *really* do want to do this on a disabled link, use\n\t\t\t\t// an `oncreate` hook to add it.\n\t\t\t\tchild.attrs.onclick = null\n\t\t\t} else {\n\t\t\t\tonclick = child.attrs.onclick\n\t\t\t\thref = child.attrs.href\n\t\t\t\tchild.attrs.href = route.prefix + href\n\t\t\t\tchild.attrs.onclick = function(e) {\n\t\t\t\t\tvar result\n\t\t\t\t\tif (typeof onclick === \"function\") {\n\t\t\t\t\t\tresult = onclick.call(e.currentTarget, e)\n\t\t\t\t\t} else if (onclick == null || typeof onclick !== \"object\") {\n\t\t\t\t\t\t// do nothing\n\t\t\t\t\t} else if (typeof onclick.handleEvent === \"function\") {\n\t\t\t\t\t\tonclick.handleEvent(e)\n\t\t\t\t\t}\n\n\t\t\t\t\t// Adapted from React Router's implementation:\n\t\t\t\t\t// https://github.com/ReactTraining/react-router/blob/520a0acd48ae1b066eb0b07d6d4d1790a1d02482/packages/react-router-dom/modules/Link.js\n\t\t\t\t\t//\n\t\t\t\t\t// Try to be flexible and intuitive in how we handle links.\n\t\t\t\t\t// Fun fact: links aren't as obvious to get right as you\n\t\t\t\t\t// would expect. There's a lot more valid ways to click a\n\t\t\t\t\t// link than this, and one might want to not simply click a\n\t\t\t\t\t// link, but right click or command-click it to copy the\n\t\t\t\t\t// link target, etc. Nope, this isn't just for blind people.\n\t\t\t\t\tif (\n\t\t\t\t\t\t// Skip if `onclick` prevented default\n\t\t\t\t\t\tresult !== false && !e.defaultPrevented &&\n\t\t\t\t\t\t// Ignore everything but left clicks\n\t\t\t\t\t\t(e.button === 0 || e.which === 0 || e.which === 1) &&\n\t\t\t\t\t\t// Let the browser handle `target=_blank`, etc.\n\t\t\t\t\t\t(!e.currentTarget.target || e.currentTarget.target === \"_self\") &&\n\t\t\t\t\t\t// No modifier keys\n\t\t\t\t\t\t!e.ctrlKey && !e.metaKey && !e.shiftKey && !e.altKey\n\t\t\t\t\t) {\n\t\t\t\t\t\te.preventDefault()\n\t\t\t\t\t\te.redraw = false\n\t\t\t\t\t\troute.set(href, null, options)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn child\n\t\t},\n\t}\n\troute.param = function(key) {\n\t\treturn attrs && key != null ? attrs[key] : attrs\n\t}\n\n\treturn route\n}\n", "\"use strict\"\n\nvar mountRedraw = require(\"./mount-redraw\")\n\nmodule.exports = require(\"./api/router\")(window, mountRedraw)\n", "\"use strict\"\n\nvar hyperscript = require(\"./hyperscript\")\nvar request = require(\"./request\")\nvar mountRedraw = require(\"./mount-redraw\")\n\nvar m = function m() { return hyperscript.apply(this, arguments) }\nm.m = hyperscript\nm.trust = hyperscript.trust\nm.fragment = hyperscript.fragment\nm.mount = mountRedraw.mount\nm.route = require(\"./route\")\nm.render = require(\"./render\")\nm.redraw = mountRedraw.redraw\nm.request = request.request\nm.jsonp = request.jsonp\nm.parseQueryString = require(\"./querystring/parse\")\nm.buildQueryString = require(\"./querystring/build\")\nm.parsePathname = require(\"./pathname/parse\")\nm.buildPathname = require(\"./pathname/build\")\nm.vnode = require(\"./render/vnode\")\nm.PromisePolyfill = require(\"./promise/polyfill\")\n\nmodule.exports = m\n", "// Minoteaur clientside code (runs editor enhancements, file upload, search, keyboard shortcuts)\n// It may be worth rewriting this in Nim for codesharing, but I think the interaction with e.g. IndexedDB may be trickier\n\nimport m from \"mithril\"\nimport { openDB } from \"idb\"\nimport { lightFormat } from \"date-fns\"\n\nconst dbPromise = openDB(\"minoteaur\", 1, {\n upgrade: (db, oldVersion) => {\n if (oldVersion < 1) { db.createObjectStore(\"drafts\") }\n },\n blocking: () => { window.location.reload() }\n});\n// debugging thing\ndbPromise.then(x => { window.idb = x })\n\nconst debounce = (fn, timeout = 250) => {\n let timer;\n return (...args) => {\n clearTimeout(timer)\n timer = setTimeout(fn, timeout, ...args)\n }\n}\n\nconst searchState = {\n showingSearchDialog: false,\n searchResults: [],\n searchError: null,\n searchQuery: \"\"\n}\n\nconst lowercaseFirst = ([first, ...rest]) => first.toLowerCase() + rest.join(\"\")\nconst uppercaseFirst = ([first, ...rest]) => first.toUpperCase() + rest.join(\"\")\nconst pageToSlug = page => page.split(/[ _]/).map(lowercaseFirst).join(\"_\")\nconst slugToPage = slug => slug.split(/[ _]/).map(uppercaseFirst).join(\" \")\n\nconst urlForPage = (page, subpage) => {\n let p = `/${encodeURIComponent(pageToSlug(page))}`\n if (subpage) { p += \"/\" + subpage }\n return p\n}\n\nconst handleHTTPError = e => {\n window.lastError = e\n console.warn(e)\n let x = `HTTP error ${e.code}`\n if (e.message !== null) { x += \" \" + e.message }\n searchState.searchError = x\n}\n\n// handle input in search box\nconst onsearch = ev => {\n const query = ev.target.value\n searchState.searchQuery = query\n m.request({\n url: \"/api/search\",\n params: { q: query }\n }).then(x => {\n if (typeof x === \"string\") { // in case of error from server, show it but keep the existing results shown\n console.warn(x)\n searchState.searchError = x\n } else {\n searchState.searchResults = x\n searchState.searchError = null\n }\n }, handleHTTPError)\n}\n\nconst currentPage = slugToPage(decodeURIComponent(/^\\/([^/]+)/.exec(location.pathname)[1]).replace(/\\+/g, \" \"))\nif (currentPage === \"Login\") { return }\n\nconst searchKeyHandler = ev => {\n if (ev.code === \"Enter\") { // enter key\n // navigate to the first page (excluding the current one) in results\n const otherResults = searchState.searchResults.filter(r => r.page !== currentPage)\n if (otherResults[0]) { location.href = urlForPage(otherResults[0].page) }\n }\n}\n\nconst SearchDialog = {\n view: () => m(\".dialog.search\", [\n m(\"h1\", \"Search\"),\n m(\"input[type=search]\", { placeholder: \"Query\", oninput: onsearch, onkeydown: searchKeyHandler, value: searchState.searchQuery, oncreate: ({ dom }) => dom.focus() }),\n searchState.searchError && m(\".error\", searchState.searchError),\n m(\"ul\", searchState.searchResults.map(x => m(\"li\", [\n m(\".flex-space\", [ m(\"a.wikilink\", { href: urlForPage(x.page) }, x.page), m(\"\", x.rank.toFixed(3)) ]),\n m(\"\", x.snippet.map(s => s[0] ? m(\"span.highlight\", s[1]) : s[1]))\n ])))\n ])\n}\n\nconst SearchApp = {\n view: () => m(\"\", searchState.showingSearchDialog ? m(SearchDialog) : null)\n}\n\nconst mountpoint = document.createElement(\"div\")\ndocument.querySelector(\"main\").insertBefore(mountpoint, document.querySelector(\".header\"))\nm.mount(mountpoint, SearchApp)\n\nconst searchButton = document.querySelector(\"nav .search\")\n\nsearchButton.addEventListener(\"click\", e => {\n searchState.showingSearchDialog = !searchState.showingSearchDialog\n e.preventDefault()\n m.redraw()\n})\n\n// basic keyboard shortcuts - search, switch to view/edit/revs\ndocument.body.addEventListener(\"keydown\", e => {\n if (e.target === document.body) { // detect only unfocused keypresses - ctrl+key seems to cause issues when copy/pasting\n if (e.key === \"e\") {\n location.pathname = urlForPage(currentPage, \"edit\")\n } else if (e.key === \"v\") {\n location.pathname = urlForPage(currentPage)\n } else if (e.key === \"r\") {\n location.pathname = urlForPage(currentPage, \"revisions\")\n } else if (e.key === \"/\") {\n searchState.showingSearchDialog = !searchState.showingSearchDialog\n e.preventDefault()\n m.redraw()\n }\n }\n})\n\nconst dispDateTime = dt => lightFormat(dt, \"yyyy-MM-dd HH:mm:ss\")\n\nconst wordCount = s => {\n let words = 0\n for (const possibleWord of s.split(/\\s+/)) {\n if (/[^#*+>|`-]/.test(possibleWord)) { words += 1 }\n }\n return words\n}\nconst lineCount = s => s.split(\"\\n\").length\n\n// edit-page UI\nconst editor = document.querySelector(\".edit-form textarea\")\nif (editor) {\n // most of the state for the edit page UI\n // this excludes the text area autoresize logic, as well as the actual editor textarea content\n const editorUIState = {\n keypresses: 0,\n draftSelected: false,\n pendingFiles: new Map()\n }\n const mountpoint = document.createElement(\"div\")\n document.querySelector(\".sidebar\").appendChild(mountpoint)\n\n // automatic resize of textareas upon typing\n // this is slightly \"efficient\" in that it avoids constantly setting the height to 0 and back in a few situations, which is seemingly quite expensive\n let lengthWas = Infinity\n const resize = () => {\n const scrolltop = document.body.scrollTop\n const targetHeight = editor.scrollHeight + 2\n //console.log(targetHeight, editor.scrollHeight)\n if (targetHeight != editor.style.height.slice(0, -2) || lengthWas > editor.value.length) {\n editor.style.height = `0px`\n editor.style.height = `${Math.max(editor.scrollHeight + 2, 100)}px`\n document.body.scrollTop = scrolltop\n }\n lengthWas = editor.value.length\n }\n\n // retrieve last edit timestamp from field\n const lastEditTime = parseInt(document.querySelector(\"input[name=last-edit]\").value)\n const serverValue = editor.value\n const associatedFiles = JSON.parse(document.querySelector(\"input[name=associated-files]\").value)\n .map(({ filename, mimeType }) => ({ file: { name: filename, type: mimeType, state: \"uploaded\" }, state: \"preexisting\" }))\n\n // load in the initially loaded draft\n const swapInDraft = () => {\n if (!editorUIState.initialDraft) { return }\n editorUIState.draftSelected = true\n editor.value = editorUIState.initialDraft.text\n resize()\n }\n // load in the initial page from the server\n const swapInServer = () => {\n console.log(\"server value swapped in, allegedly?\")\n editorUIState.draftSelected = false\n console.log(editor.value, serverValue)\n editor.value = serverValue\n resize()\n }\n\n dbPromise.then(db => db.get(\"drafts\", currentPage)).then(draft => {\n editorUIState.initialDraft = draft\n console.log(\"found draft \", draft)\n // if the draft is newer than the server page, load it in (the user can override this)\n if (draft && draft.ts > lastEditTime) {\n swapInDraft()\n }\n m.redraw()\n })\n\n const DraftInfo = {\n view: () => editorUIState.initialDraft == null ? \"No draft\" : [\n m(editorUIState.draftSelected ? \".selected\" : \"\", { onclick: swapInDraft }, `Draft from ${dispDateTime(editorUIState.initialDraft.ts)}`),\n lastEditTime > 0 && m(editorUIState.draftSelected ? \"\" : \".selected\", { onclick: swapInServer }, `Page from ${dispDateTime(lastEditTime)}`)\n ]\n }\n\n // Prompt the user to upload file(s)\n const uploadFile = () => {\n // create a fake and click it, because JavaScript\n const input = document.createElement(\"input\")\n input.type = \"file\"\n input.multiple = true\n input.click()\n input.oninput = ev => {\n for (const file of ev.target.files) {\n editorUIState.pendingFiles.set(file.name, { file, state: \"pending\" })\n window.file = file\n }\n if (ev.target.files.length > 0) { m.redraw() }\n }\n }\n\n const File = {\n view: ({ attrs }) => m(\"li.file\", [\n m(\"\", attrs.file.name),\n m(\"\", attrs.state)\n ])\n }\n\n const EditorUIApp = {\n view: () => [\n m(\"button.upload\", { onclick: uploadFile }, \"Upload\"),\n m(\"ul.files\", associatedFiles.concat(Array.from(editorUIState.pendingFiles.values()))\n .map(file => m(File, { ...file, key: file.file.name }))),\n m(\"\", `${editorUIState.chars} chars`),\n m(\"\", `${editorUIState.words} words`),\n m(\"\", `${editorUIState.lines} lines`),\n m(\"\", `${editorUIState.keypresses} keypresses`),\n m(DraftInfo)\n ]\n }\n\n // Update the sidebar word/line/char counts\n const updateCounts = text => {\n editorUIState.words = wordCount(text)\n editorUIState.lines = lineCount(text)\n editorUIState.chars = text.length // incorrect for some unicode, but doing it correctly would be more complex and slow\n }\n updateCounts(editor.value)\n\n m.mount(mountpoint, EditorUIApp)\n\n editor.addEventListener(\"keypress\", ev => {\n const selStart = editor.selectionStart\n const selEnd = editor.selectionEnd\n if (selStart !== selEnd) return // text is actually selected; these shortcuts are not meant for that situation\n\n const search = \"\\n\" + editor.value.substr(0, selStart)\n const lastLineStart = search.lastIndexOf(\"\\n\") + 1 // drop the \\n\n const nextLineStart = selStart + (editor.value.substr(selStart) + \"\\n\").indexOf(\"\\n\")\n\n if (ev.code === \"Enter\") { // enter\n // save on ctrl+enter\n if (ev.ctrlKey) {\n editor.parentElement.submit()\n return\n }\n\n const line = search.substr(lastLineStart)\n // detect lists on the previous line to continue on the next one\n const match = /^(\\s*)(([*+-])|(\\d+)([).]))(\\s*)/.exec(line)\n if (match) {\n // if it is an unordered list, just take the bullet type + associated whitespace\n // if it is an ordered list, increment the number and take the dot/paren and whitespace\n const lineStart = match[1] + (match[4] ? (parseInt(match[4]) + 1).toString() + match[5] : match[2]) + match[6]\n // get everything after the cursor on the same line\n const contentAfterCursor = editor.value.slice(selStart, nextLineStart)\n // all the content of the textbox preceding where the cursor should now be\n const prev = editor.value.substr(0, selStart) + \"\\n\" + lineStart\n // update editor\n editor.value = prev + contentAfterCursor + editor.value.substr(nextLineStart)\n editor.selectionStart = editor.selectionEnd = prev.length\n resize()\n ev.preventDefault()\n }\n }\n })\n editor.addEventListener(\"keydown\", ev => {\n const selStart = editor.selectionStart\n const selEnd = editor.selectionEnd\n if (selStart !== selEnd) return\n\n const search = \"\\n\" + editor.value.substr(0, selStart)\n // this is missing the + 1 that the enter key listener has. I forgot why. Good luck working out this!\n const lastLineStart = search.lastIndexOf(\"\\n\")\n const nextLineStart = selStart + (editor.value.substr(selStart) + \"\\n\").indexOf(\"\\n\")\n if (ev.code === \"Backspace\") {\n // detect if backspacing the start of a list line\n const re = /^\\s*([*+-]|\\d+[).])\\s*$/y\n if (re.test(editor.value.slice(lastLineStart, selStart))) {\n // if so, remove entire list line start at once\n const before = editor.value.substr(0, lastLineStart)\n const after = editor.value.substr(selStart)\n editor.value = before + after\n editor.selectionStart = editor.selectionEnd = before.length\n resize()\n ev.preventDefault()\n }\n } else if (ev.code === \"Tab\") {\n // indent/dedent lists by 2 spaces, depending on shift key\n const match = /^(\\s*)([*+-]|\\d+[).])/.exec(editor.value.slice(lastLineStart, nextLineStart))\n let line = editor.value.substr(lastLineStart)\n if (ev.shiftKey) {\n line = line.replace(/^ /, \"\")\n } else {\n line = \" \" + line\n }\n if (match) {\n editor.value = editor.value.substr(0, lastLineStart) + line\n editor.selectionStart = editor.selectionEnd = selStart + (ev.shiftKey ? -2 : 2)\n resize()\n ev.preventDefault()\n }\n }\n\n editorUIState.keypresses++\n m.redraw()\n })\n\n const saveDraft = debounce(() => {\n dbPromise.then(idb => idb.put(\"drafts\", { text: editor.value, ts: Date.now() }, currentPage))\n console.log(\"saved\")\n })\n\n editor.addEventListener(\"input\", () => {\n resize()\n updateCounts(editor.value)\n saveDraft()\n })\n resize()\n}", "const instanceOfAny = (object, constructors) => constructors.some((c) => object instanceof c);\n\nlet idbProxyableTypes;\nlet cursorAdvanceMethods;\n// This is a function to prevent it throwing up in node environments.\nfunction getIdbProxyableTypes() {\n return (idbProxyableTypes ||\n (idbProxyableTypes = [\n IDBDatabase,\n IDBObjectStore,\n IDBIndex,\n IDBCursor,\n IDBTransaction,\n ]));\n}\n// This is a function to prevent it throwing up in node environments.\nfunction getCursorAdvanceMethods() {\n return (cursorAdvanceMethods ||\n (cursorAdvanceMethods = [\n IDBCursor.prototype.advance,\n IDBCursor.prototype.continue,\n IDBCursor.prototype.continuePrimaryKey,\n ]));\n}\nconst cursorRequestMap = new WeakMap();\nconst transactionDoneMap = new WeakMap();\nconst transactionStoreNamesMap = new WeakMap();\nconst transformCache = new WeakMap();\nconst reverseTransformCache = new WeakMap();\nfunction promisifyRequest(request) {\n const promise = new Promise((resolve, reject) => {\n const unlisten = () => {\n request.removeEventListener('success', success);\n request.removeEventListener('error', error);\n };\n const success = () => {\n resolve(wrap(request.result));\n unlisten();\n };\n const error = () => {\n reject(request.error);\n unlisten();\n };\n request.addEventListener('success', success);\n request.addEventListener('error', error);\n });\n promise\n .then((value) => {\n // Since cursoring reuses the IDBRequest (*sigh*), we cache it for later retrieval\n // (see wrapFunction).\n if (value instanceof IDBCursor) {\n cursorRequestMap.set(value, request);\n }\n // Catching to avoid \"Uncaught Promise exceptions\"\n })\n .catch(() => { });\n // This mapping exists in reverseTransformCache but doesn't doesn't exist in transformCache. This\n // is because we create many promises from a single IDBRequest.\n reverseTransformCache.set(promise, request);\n return promise;\n}\nfunction cacheDonePromiseForTransaction(tx) {\n // Early bail if we've already created a done promise for this transaction.\n if (transactionDoneMap.has(tx))\n return;\n const done = new Promise((resolve, reject) => {\n const unlisten = () => {\n tx.removeEventListener('complete', complete);\n tx.removeEventListener('error', error);\n tx.removeEventListener('abort', error);\n };\n const complete = () => {\n resolve();\n unlisten();\n };\n const error = () => {\n reject(tx.error || new DOMException('AbortError', 'AbortError'));\n unlisten();\n };\n tx.addEventListener('complete', complete);\n tx.addEventListener('error', error);\n tx.addEventListener('abort', error);\n });\n // Cache it for later retrieval.\n transactionDoneMap.set(tx, done);\n}\nlet idbProxyTraps = {\n get(target, prop, receiver) {\n if (target instanceof IDBTransaction) {\n // Special handling for transaction.done.\n if (prop === 'done')\n return transactionDoneMap.get(target);\n // Polyfill for objectStoreNames because of Edge.\n if (prop === 'objectStoreNames') {\n return target.objectStoreNames || transactionStoreNamesMap.get(target);\n }\n // Make tx.store return the only store in the transaction, or undefined if there are many.\n if (prop === 'store') {\n return receiver.objectStoreNames[1]\n ? undefined\n : receiver.objectStore(receiver.objectStoreNames[0]);\n }\n }\n // Else transform whatever we get back.\n return wrap(target[prop]);\n },\n set(target, prop, value) {\n target[prop] = value;\n return true;\n },\n has(target, prop) {\n if (target instanceof IDBTransaction &&\n (prop === 'done' || prop === 'store')) {\n return true;\n }\n return prop in target;\n },\n};\nfunction replaceTraps(callback) {\n idbProxyTraps = callback(idbProxyTraps);\n}\nfunction wrapFunction(func) {\n // Due to expected object equality (which is enforced by the caching in `wrap`), we\n // only create one new func per func.\n // Edge doesn't support objectStoreNames (booo), so we polyfill it here.\n if (func === IDBDatabase.prototype.transaction &&\n !('objectStoreNames' in IDBTransaction.prototype)) {\n return function (storeNames, ...args) {\n const tx = func.call(unwrap(this), storeNames, ...args);\n transactionStoreNamesMap.set(tx, storeNames.sort ? storeNames.sort() : [storeNames]);\n return wrap(tx);\n };\n }\n // Cursor methods are special, as the behaviour is a little more different to standard IDB. In\n // IDB, you advance the cursor and wait for a new 'success' on the IDBRequest that gave you the\n // cursor. It's kinda like a promise that can resolve with many values. That doesn't make sense\n // with real promises, so each advance methods returns a new promise for the cursor object, or\n // undefined if the end of the cursor has been reached.\n if (getCursorAdvanceMethods().includes(func)) {\n return function (...args) {\n // Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use\n // the original object.\n func.apply(unwrap(this), args);\n return wrap(cursorRequestMap.get(this));\n };\n }\n return function (...args) {\n // Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use\n // the original object.\n return wrap(func.apply(unwrap(this), args));\n };\n}\nfunction transformCachableValue(value) {\n if (typeof value === 'function')\n return wrapFunction(value);\n // This doesn't return, it just creates a 'done' promise for the transaction,\n // which is later returned for transaction.done (see idbObjectHandler).\n if (value instanceof IDBTransaction)\n cacheDonePromiseForTransaction(value);\n if (instanceOfAny(value, getIdbProxyableTypes()))\n return new Proxy(value, idbProxyTraps);\n // Return the same value back if we're not going to transform it.\n return value;\n}\nfunction wrap(value) {\n // We sometimes generate multiple promises from a single IDBRequest (eg when cursoring), because\n // IDB is weird and a single IDBRequest can yield many responses, so these can't be cached.\n if (value instanceof IDBRequest)\n return promisifyRequest(value);\n // If we've already transformed this value before, reuse the transformed value.\n // This is faster, but it also provides object equality.\n if (transformCache.has(value))\n return transformCache.get(value);\n const newValue = transformCachableValue(value);\n // Not all types are transformed.\n // These may be primitive types, so they can't be WeakMap keys.\n if (newValue !== value) {\n transformCache.set(value, newValue);\n reverseTransformCache.set(newValue, value);\n }\n return newValue;\n}\nconst unwrap = (value) => reverseTransformCache.get(value);\n\nexport { reverseTransformCache as a, instanceOfAny as i, replaceTraps as r, unwrap as u, wrap as w };\n", "import { w as wrap, r as replaceTraps } from './wrap-idb-value.js';\nexport { u as unwrap, w as wrap } from './wrap-idb-value.js';\n\n/**\n * Open a database.\n *\n * @param name Name of the database.\n * @param version Schema version.\n * @param callbacks Additional callbacks.\n */\nfunction openDB(name, version, { blocked, upgrade, blocking, terminated } = {}) {\n const request = indexedDB.open(name, version);\n const openPromise = wrap(request);\n if (upgrade) {\n request.addEventListener('upgradeneeded', (event) => {\n upgrade(wrap(request.result), event.oldVersion, event.newVersion, wrap(request.transaction));\n });\n }\n if (blocked)\n request.addEventListener('blocked', () => blocked());\n openPromise\n .then((db) => {\n if (terminated)\n db.addEventListener('close', () => terminated());\n if (blocking)\n db.addEventListener('versionchange', () => blocking());\n })\n .catch(() => { });\n return openPromise;\n}\n/**\n * Delete a database.\n *\n * @param name Name of the database.\n */\nfunction deleteDB(name, { blocked } = {}) {\n const request = indexedDB.deleteDatabase(name);\n if (blocked)\n request.addEventListener('blocked', () => blocked());\n return wrap(request).then(() => undefined);\n}\n\nconst readMethods = ['get', 'getKey', 'getAll', 'getAllKeys', 'count'];\nconst writeMethods = ['put', 'add', 'delete', 'clear'];\nconst cachedMethods = new Map();\nfunction getMethod(target, prop) {\n if (!(target instanceof IDBDatabase &&\n !(prop in target) &&\n typeof prop === 'string')) {\n return;\n }\n if (cachedMethods.get(prop))\n return cachedMethods.get(prop);\n const targetFuncName = prop.replace(/FromIndex$/, '');\n const useIndex = prop !== targetFuncName;\n const isWrite = writeMethods.includes(targetFuncName);\n if (\n // Bail if the target doesn't exist on the target. Eg, getAll isn't in Edge.\n !(targetFuncName in (useIndex ? IDBIndex : IDBObjectStore).prototype) ||\n !(isWrite || readMethods.includes(targetFuncName))) {\n return;\n }\n const method = async function (storeName, ...args) {\n // isWrite ? 'readwrite' : undefined gzipps better, but fails in Edge :(\n const tx = this.transaction(storeName, isWrite ? 'readwrite' : 'readonly');\n let target = tx.store;\n if (useIndex)\n target = target.index(args.shift());\n // Must reject if op rejects.\n // If it's a write operation, must reject if tx.done rejects.\n // Must reject with op rejection first.\n // Must resolve with op value.\n // Must handle both promises (no unhandled rejections)\n return (await Promise.all([\n target[targetFuncName](...args),\n isWrite && tx.done,\n ]))[0];\n };\n cachedMethods.set(prop, method);\n return method;\n}\nreplaceTraps((oldTraps) => ({\n ...oldTraps,\n get: (target, prop, receiver) => getMethod(target, prop) || oldTraps.get(target, prop, receiver),\n has: (target, prop) => !!getMethod(target, prop) || oldTraps.has(target, prop),\n}));\n\nexport { deleteDB, openDB };\n", "export default function toInteger(dirtyNumber) {\n if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {\n return NaN;\n }\n\n var number = Number(dirtyNumber);\n\n if (isNaN(number)) {\n return number;\n }\n\n return number < 0 ? Math.ceil(number) : Math.floor(number);\n}", "export default function requiredArgs(required, args) {\n if (args.length < required) {\n throw new TypeError(required + ' argument' + (required > 1 ? 's' : '') + ' required, but only ' + args.length + ' present');\n }\n}", "import requiredArgs from \"../_lib/requiredArgs/index.js\";\n/**\n * @name toDate\n * @category Common Helpers\n * @summary Convert the given argument to an instance of Date.\n *\n * @description\n * Convert the given argument to an instance of Date.\n *\n * If the argument is an instance of Date, the function returns its clone.\n *\n * If the argument is a number, it is treated as a timestamp.\n *\n * If the argument is none of the above, the function returns Invalid Date.\n *\n * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.\n *\n * @param {Date|Number} argument - the value to convert\n * @returns {Date} the parsed date in the local time zone\n * @throws {TypeError} 1 argument required\n *\n * @example\n * // Clone the date:\n * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))\n * //=> Tue Feb 11 2014 11:30:30\n *\n * @example\n * // Convert the timestamp to date:\n * const result = toDate(1392098430000)\n * //=> Tue Feb 11 2014 11:30:30\n */\n\nexport default function toDate(argument) {\n requiredArgs(1, arguments);\n var argStr = Object.prototype.toString.call(argument); // Clone the date\n\n if (argument instanceof Date || typeof argument === 'object' && argStr === '[object Date]') {\n // Prevent the date to lose the milliseconds when passed to new Date() in IE10\n return new Date(argument.getTime());\n } else if (typeof argument === 'number' || argStr === '[object Number]') {\n return new Date(argument);\n } else {\n if ((typeof argument === 'string' || argStr === '[object String]') && typeof console !== 'undefined') {\n // eslint-disable-next-line no-console\n console.warn(\"Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://git.io/fjule\"); // eslint-disable-next-line no-console\n\n console.warn(new Error().stack);\n }\n\n return new Date(NaN);\n }\n}", "import toInteger from \"../_lib/toInteger/index.js\";\nimport toDate from \"../toDate/index.js\";\nimport requiredArgs from \"../_lib/requiredArgs/index.js\";\n/**\n * @name addMilliseconds\n * @category Millisecond Helpers\n * @summary Add the specified number of milliseconds to the given date.\n *\n * @description\n * Add the specified number of milliseconds to the given date.\n *\n * ### v2.0.0 breaking changes:\n *\n * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).\n *\n * @param {Date|Number} date - the date to be changed\n * @param {Number} amount - the amount of milliseconds to be added. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.\n * @returns {Date} the new date with the milliseconds added\n * @throws {TypeError} 2 arguments required\n *\n * @example\n * // Add 750 milliseconds to 10 July 2014 12:45:30.000:\n * const result = addMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)\n * //=> Thu Jul 10 2014 12:45:30.750\n */\n\nexport default function addMilliseconds(dirtyDate, dirtyAmount) {\n requiredArgs(2, arguments);\n var timestamp = toDate(dirtyDate).getTime();\n var amount = toInteger(dirtyAmount);\n return new Date(timestamp + amount);\n}", "var MILLISECONDS_IN_MINUTE = 60000;\n\nfunction getDateMillisecondsPart(date) {\n return date.getTime() % MILLISECONDS_IN_MINUTE;\n}\n/**\n * Google Chrome as of 67.0.3396.87 introduced timezones with offset that includes seconds.\n * They usually appear for dates that denote time before the timezones were introduced\n * (e.g. for 'Europe/Prague' timezone the offset is GMT+00:57:44 before 1 October 1891\n * and GMT+01:00:00 after that date)\n *\n * Date#getTimezoneOffset returns the offset in minutes and would return 57 for the example above,\n * which would lead to incorrect calculations.\n *\n * This function returns the timezone offset in milliseconds that takes seconds in account.\n */\n\n\nexport default function getTimezoneOffsetInMilliseconds(dirtyDate) {\n var date = new Date(dirtyDate.getTime());\n var baseTimezoneOffset = Math.ceil(date.getTimezoneOffset());\n date.setSeconds(0, 0);\n var hasNegativeUTCOffset = baseTimezoneOffset > 0;\n var millisecondsPartOfTimezoneOffset = hasNegativeUTCOffset ? (MILLISECONDS_IN_MINUTE + getDateMillisecondsPart(date)) % MILLISECONDS_IN_MINUTE : getDateMillisecondsPart(date);\n return baseTimezoneOffset * MILLISECONDS_IN_MINUTE + millisecondsPartOfTimezoneOffset;\n}", "import toDate from \"../toDate/index.js\";\nimport requiredArgs from \"../_lib/requiredArgs/index.js\";\n/**\n * @name isValid\n * @category Common Helpers\n * @summary Is the given date valid?\n *\n * @description\n * Returns false if argument is Invalid Date and true otherwise.\n * Argument is converted to Date using `toDate`. See [toDate]{@link https://date-fns.org/docs/toDate}\n * Invalid Date is a Date, whose time value is NaN.\n *\n * Time value of Date: http://es5.github.io/#x15.9.1.1\n *\n * ### v2.0.0 breaking changes:\n *\n * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).\n *\n * - Now `isValid` doesn't throw an exception\n * if the first argument is not an instance of Date.\n * Instead, argument is converted beforehand using `toDate`.\n *\n * Examples:\n *\n * | `isValid` argument | Before v2.0.0 | v2.0.0 onward |\n * |---------------------------|---------------|---------------|\n * | `new Date()` | `true` | `true` |\n * | `new Date('2016-01-01')` | `true` | `true` |\n * | `new Date('')` | `false` | `false` |\n * | `new Date(1488370835081)` | `true` | `true` |\n * | `new Date(NaN)` | `false` | `false` |\n * | `'2016-01-01'` | `TypeError` | `false` |\n * | `''` | `TypeError` | `false` |\n * | `1488370835081` | `TypeError` | `true` |\n * | `NaN` | `TypeError` | `false` |\n *\n * We introduce this change to make *date-fns* consistent with ECMAScript behavior\n * that try to coerce arguments to the expected type\n * (which is also the case with other *date-fns* functions).\n *\n * @param {*} date - the date to check\n * @returns {Boolean} the date is valid\n * @throws {TypeError} 1 argument required\n *\n * @example\n * // For the valid date:\n * var result = isValid(new Date(2014, 1, 31))\n * //=> true\n *\n * @example\n * // For the value, convertable into a date:\n * var result = isValid(1393804800000)\n * //=> true\n *\n * @example\n * // For the invalid date:\n * var result = isValid(new Date(''))\n * //=> false\n */\n\nexport default function isValid(dirtyDate) {\n requiredArgs(1, arguments);\n var date = toDate(dirtyDate);\n return !isNaN(date);\n}", "import toInteger from \"../_lib/toInteger/index.js\";\nimport addMilliseconds from \"../addMilliseconds/index.js\";\nimport requiredArgs from \"../_lib/requiredArgs/index.js\";\n/**\n * @name subMilliseconds\n * @category Millisecond Helpers\n * @summary Subtract the specified number of milliseconds from the given date.\n *\n * @description\n * Subtract the specified number of milliseconds from the given date.\n *\n * ### v2.0.0 breaking changes:\n *\n * - [Changes that are common for the whole library](https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#Common-Changes).\n *\n * @param {Date|Number} date - the date to be changed\n * @param {Number} amount - the amount of milliseconds to be subtracted. Positive decimals will be rounded using `Math.floor`, decimals less than zero will be rounded using `Math.ceil`.\n * @returns {Date} the new date with the milliseconds subtracted\n * @throws {TypeError} 2 arguments required\n *\n * @example\n * // Subtract 750 milliseconds from 10 July 2014 12:45:30.000:\n * const result = subMilliseconds(new Date(2014, 6, 10, 12, 45, 30, 0), 750)\n * //=> Thu Jul 10 2014 12:45:29.250\n */\n\nexport default function subMilliseconds(dirtyDate, dirtyAmount) {\n requiredArgs(2, arguments);\n var amount = toInteger(dirtyAmount);\n return addMilliseconds(dirtyDate, -amount);\n}", "export default function addLeadingZeros(number, targetLength) {\n var sign = number < 0 ? '-' : '';\n var output = Math.abs(number).toString();\n\n while (output.length < targetLength) {\n output = '0' + output;\n }\n\n return sign + output;\n}", "import addLeadingZeros from \"../../addLeadingZeros/index.js\";\n/*\n * | | Unit | | Unit |\n * |-----|--------------------------------|-----|--------------------------------|\n * | a | AM, PM | A* | |\n * | d | Day of month | D | |\n * | h | Hour [1-12] | H | Hour [0-23] |\n * | m | Minute | M | Month |\n * | s | Second | S | Fraction of second |\n * | y | Year (abs) | Y | |\n *\n * Letters marked by * are not implemented but reserved by Unicode standard.\n */\n\nvar formatters = {\n // Year\n y: function (date, token) {\n // From http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_tokens\n // | Year | y | yy | yyy | yyyy | yyyyy |\n // |----------|-------|----|-------|-------|-------|\n // | AD 1 | 1 | 01 | 001 | 0001 | 00001 |\n // | AD 12 | 12 | 12 | 012 | 0012 | 00012 |\n // | AD 123 | 123 | 23 | 123 | 0123 | 00123 |\n // | AD 1234 | 1234 | 34 | 1234 | 1234 | 01234 |\n // | AD 12345 | 12345 | 45 | 12345 | 12345 | 12345 |\n var signedYear = date.getUTCFullYear(); // Returns 1 for 1 BC (which is year 0 in JavaScript)\n\n var year = signedYear > 0 ? signedYear : 1 - signedYear;\n return addLeadingZeros(token === 'yy' ? year % 100 : year, token.length);\n },\n // Month\n M: function (date, token) {\n var month = date.getUTCMonth();\n return token === 'M' ? String(month + 1) : addLeadingZeros(month + 1, 2);\n },\n // Day of the month\n d: function (date, token) {\n return addLeadingZeros(date.getUTCDate(), token.length);\n },\n // AM or PM\n a: function (date, token) {\n var dayPeriodEnumValue = date.getUTCHours() / 12 >= 1 ? 'pm' : 'am';\n\n switch (token) {\n case 'a':\n case 'aa':\n return dayPeriodEnumValue.toUpperCase();\n\n case 'aaa':\n return dayPeriodEnumValue;\n\n case 'aaaaa':\n return dayPeriodEnumValue[0];\n\n case 'aaaa':\n default:\n return dayPeriodEnumValue === 'am' ? 'a.m.' : 'p.m.';\n }\n },\n // Hour [1-12]\n h: function (date, token) {\n return addLeadingZeros(date.getUTCHours() % 12 || 12, token.length);\n },\n // Hour [0-23]\n H: function (date, token) {\n return addLeadingZeros(date.getUTCHours(), token.length);\n },\n // Minute\n m: function (date, token) {\n return addLeadingZeros(date.getUTCMinutes(), token.length);\n },\n // Second\n s: function (date, token) {\n return addLeadingZeros(date.getUTCSeconds(), token.length);\n },\n // Fraction of second\n S: function (date, token) {\n var numberOfDigits = token.length;\n var milliseconds = date.getUTCMilliseconds();\n var fractionalSeconds = Math.floor(milliseconds * Math.pow(10, numberOfDigits - 3));\n return addLeadingZeros(fractionalSeconds, token.length);\n }\n};\nexport default formatters;", "import toDate from \"../toDate/index.js\";\nimport formatters from \"../_lib/format/lightFormatters/index.js\";\nimport getTimezoneOffsetInMilliseconds from \"../_lib/getTimezoneOffsetInMilliseconds/index.js\";\nimport isValid from \"../isValid/index.js\";\nimport subMilliseconds from \"../subMilliseconds/index.js\";\nimport requiredArgs from \"../_lib/requiredArgs/index.js\"; // This RegExp consists of three parts separated by `|`:\n// - (\\w)\\1* matches any sequences of the same letter\n// - '' matches two quote characters in a row\n// - '(''|[^'])+('|$) matches anything surrounded by two quote characters ('),\n// except a single quote symbol, which ends the sequence.\n// Two quote characters do not end the sequence.\n// If there is no matching single quote\n// then the sequence will continue until the end of the string.\n// - . matches any single character unmatched by previous parts of the RegExps\n\nvar formattingTokensRegExp = /(\\w)\\1*|''|'(''|[^'])+('|$)|./g;\nvar escapedStringRegExp = /^'([^]*?)'?$/;\nvar doubleQuoteRegExp = /''/g;\nvar unescapedLatinCharacterRegExp = /[a-zA-Z]/;\n/**\n * @name lightFormat\n * @category Common Helpers\n * @summary Format the date.\n *\n * @description\n * Return the formatted date string in the given format. Unlike `format`,\n * `lightFormat` doesn't use locales and outputs date using the most popular tokens.\n *\n * > \u26A0\uFE0F Please note that the `lightFormat` tokens differ from Moment.js and other libraries.\n * > See: https://git.io/fxCyr\n *\n * The characters wrapped between two single quotes characters (') are escaped.\n * Two single quotes in a row, whether inside or outside a quoted sequence, represent a 'real' single quote.\n *\n * Format of the string is based on Unicode Technical Standard #35:\n * https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table\n *\n * Accepted patterns:\n * | Unit | Pattern | Result examples |\n * |---------------------------------|---------|-----------------------------------|\n * | AM, PM | a..aaa | AM, PM |\n * | | aaaa | a.m., p.m. |\n * | | aaaaa | a, p |\n * | Calendar year | y | 44, 1, 1900, 2017 |\n * | | yy | 44, 01, 00, 17 |\n * | | yyy | 044, 001, 000, 017 |\n * | | yyyy | 0044, 0001, 1900, 2017 |\n * | Month (formatting) | M | 1, 2, ..., 12 |\n * | | MM | 01, 02, ..., 12 |\n * | Day of month | d | 1, 2, ..., 31 |\n * | | dd | 01, 02, ..., 31 |\n * | Hour [1-12] | h | 1, 2, ..., 11, 12 |\n * | | hh | 01, 02, ..., 11, 12 |\n * | Hour [0-23] | H | 0, 1, 2, ..., 23 |\n * | | HH | 00, 01, 02, ..., 23 |\n * | Minute | m | 0, 1, ..., 59 |\n * | | mm | 00, 01, ..., 59 |\n * | Second | s | 0, 1, ..., 59 |\n * | | ss | 00, 01, ..., 59 |\n * | Fraction of second | S | 0, 1, ..., 9 |\n * | | SS | 00, 01, ..., 99 |\n * | | SSS | 000, 0001, ..., 999 |\n * | | SSSS | ... |\n *\n * @param {Date|Number} date - the original date\n * @param {String} format - the string of tokens\n * @returns {String} the formatted date string\n * @throws {TypeError} 2 arguments required\n * @throws {RangeError} format string contains an unescaped latin alphabet character\n *\n * @example\n * var result = lightFormat(new Date(2014, 1, 11), 'yyyy-MM-dd')\n * //=> '2014-02-11'\n */\n\nexport default function lightFormat(dirtyDate, dirtyFormatStr) {\n requiredArgs(2, arguments);\n var formatStr = String(dirtyFormatStr);\n var originalDate = toDate(dirtyDate);\n\n if (!isValid(originalDate)) {\n throw new RangeError('Invalid time value');\n } // Convert the date in system timezone to the same date in UTC+00:00 timezone.\n // This ensures that when UTC functions will be implemented, locales will be compatible with them.\n // See an issue about UTC functions: https://github.com/date-fns/date-fns/issues/376\n\n\n var timezoneOffset = getTimezoneOffsetInMilliseconds(originalDate);\n var utcDate = subMilliseconds(originalDate, timezoneOffset);\n var result = formatStr.match(formattingTokensRegExp).map(function (substring) {\n // Replace two single quote characters with one single quote character\n if (substring === \"''\") {\n return \"'\";\n }\n\n var firstCharacter = substring[0];\n\n if (firstCharacter === \"'\") {\n return cleanEscapedString(substring);\n }\n\n var formatter = formatters[firstCharacter];\n\n if (formatter) {\n return formatter(utcDate, substring, null, {});\n }\n\n if (firstCharacter.match(unescapedLatinCharacterRegExp)) {\n throw new RangeError('Format string contains an unescaped latin alphabet character `' + firstCharacter + '`');\n }\n\n return substring;\n }).join('');\n return result;\n}\n\nfunction cleanEscapedString(input) {\n return input.match(escapedStringRegExp)[1].replace(doubleQuoteRegExp, \"'\");\n}"], + "mappings": "8iBAAA,gCAEA,YAAe,EAAK,EAAK,EAAO,EAAU,EAAM,EAAK,CACpD,MAAO,CAAC,IAAK,EAAK,IAAK,EAAK,MAAO,EAAO,SAAU,EAAU,KAAM,EAAM,IAAK,EAAK,QAAS,OAAW,MAAO,OAAW,OAAQ,OAAW,SAAU,QAExJ,GAAM,UAAY,SAAS,EAAM,CAChC,MAAI,OAAM,QAAQ,GAAc,GAAM,IAAK,OAAW,OAAW,GAAM,kBAAkB,GAAO,OAAW,QACvG,GAAQ,MAAQ,MAAO,IAAS,UAAkB,KAClD,MAAO,IAAS,SAAiB,EAC9B,GAAM,IAAK,OAAW,OAAW,OAAO,GAAO,OAAW,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qB,GAAG,QAAQ,GAAmB", "names": [] } diff --git a/static/style.css b/static/style.css index dd22a04..bc5a38e 100644 --- a/static/style.css +++ b/static/style.css @@ -1 +1 @@ -html{scrollbar-color:#000 #d3d3d3}*{box-sizing:border-box}body{font-family:"Fira Sans","Noto Sans","Segoe UI",Verdana,sans-serif;font-weight:300;margin:0 0 1em 0;display:flex;flex-wrap:wrap;justify-content:space-around}main{max-width:50em;width:100%;padding:0 1em 0 1em;margin-left:auto;margin-right:auto}main.has-sidebar{margin-right:0}.sidebar{padding:1em 1em 1em 1em;margin-right:auto;min-width:16em}strong{font-weight:600}h1,h2,h3,h4,h5,h6{margin:0 0 .5em 0;font-weight:500}h1:first-of-type,h2:first-of-type,h3:first-of-type,h4:first-of-type,h5:first-of-type,h6:first-of-type{border-bottom:1px solid gray}h1 a,h2 a,h3 a,h4 a,h5 a,h6 a{color:inherit}:not(pre)>code{background:#000;color:#fff;padding:.3em}ul,ol{padding-left:1em}ul{list-style-type:square}blockquote{border-left:.3em solid #000;padding-left:.3em}table{border-collapse:collapse}table th{background:#000;color:#fff;font-weight:normal}table td,table th{padding:.2em .5em}table td{border:1px solid gray}.rev-table{width:100%}.rev-table td{border:none}.rev-table td.ts{white-space:nowrap}.md{margin-top:.5em}.md>*,.md p{margin:0 0 .5em 0}nav{margin-bottom:.5em}.error{color:red}img{max-width:100%}.timestamp{color:gray}.selected{font-style:italic}a.wikilink{text-decoration:none;color:#0165fc;font-style:italic}a.wikilink:hover{text-decoration:underline}.link-button,button,input[type=submit]{border:none;padding:.75em;background:gray;text-align:center;text-decoration:none;color:#000;display:inline-block;font-size:1rem}.link-button:hover,button:hover,input[type=submit]:hover{background-image:linear-gradient(rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2))}.link-button.view-page,button.view-page,input[type=submit].view-page{background-color:#76cd26}.link-button.edit-page,button.edit-page,input[type=submit].edit-page{background-color:#75bbfd}.link-button.page-revisions,button.page-revisions,input[type=submit].page-revisions{background-color:#f97306}.link-button.save,button.save,input[type=submit].save{background-color:#06c2ac}.link-button.next-page,button.next-page,input[type=submit].next-page{background-color:#5170d7}.link-button.prev-page,button.prev-page,input[type=submit].prev-page{background-color:#bc13fe}.link-button.search,button.search,input[type=submit].search{background-color:#fac205}input[type=search],input[type=text]{border:1px solid gray;padding:.75em;width:100%}.edit-form{margin-bottom:0}.edit-form textarea{resize:vertical;width:100%;height:70vh;border:1px solid gray}.highlight{background-color:#ff0}.dialog{width:100%;background:#fff;padding:1em;border:1px solid gray}.flex-space{display:flex;justify-content:space-between}/*# sourceMappingURL=style.css.map */ +html{scrollbar-color:#000 #d3d3d3}*{box-sizing:border-box}body{font-family:"Fira Sans","Noto Sans","Segoe UI",Verdana,sans-serif;font-weight:300;margin:0 0 0 0;display:flex;flex-wrap:wrap;justify-content:space-around}main{max-width:50em;width:100%;padding:0 1em 0 1em;margin-left:auto;margin-right:auto}main.has-sidebar{margin-right:0}.sidebar{padding:1em 1em 1em 1em;margin-right:auto;min-width:16em}strong{font-weight:600}h1,h2,h3,h4,h5,h6{margin:0 0 .5em 0;font-weight:500}h1:first-of-type,h2:first-of-type,h3:first-of-type,h4:first-of-type,h5:first-of-type,h6:first-of-type{border-bottom:1px solid gray}h1 a,h2 a,h3 a,h4 a,h5 a,h6 a{color:inherit}:not(pre)>code{background:#000;color:#fff;padding:.3em}ul,ol{padding-left:1em}ul{list-style-type:square}blockquote{border-left:.3em solid #000;padding-left:.3em}table{border-collapse:collapse}table th{background:#000;color:#fff;font-weight:normal}table td,table th{padding:.2em .5em}table td{border:1px solid gray}.rev-table{width:100%}.rev-table td{border:none}.rev-table td.ts{white-space:nowrap}.md{margin-top:.5em}.md>*,.md p{margin:0 0 .5em 0}nav{margin-bottom:.5em}.error{color:red}img{max-width:100%}.timestamp{color:gray}.selected{font-style:italic}a.wikilink{text-decoration:none;color:#0165fc;font-style:italic}a.wikilink:hover{text-decoration:underline}.link-button,button,input[type=submit]{border:none;border-radius:0;padding:.75em;background:gray;text-align:center;text-decoration:none;color:#000;display:inline-block;font-size:1rem}.link-button:hover,button:hover,input[type=submit]:hover{background-image:linear-gradient(rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2))}.link-button.view-page,button.view-page,input[type=submit].view-page{background-color:#76cd26}.link-button.edit-page,button.edit-page,input[type=submit].edit-page{background-color:#75bbfd}.link-button.page-revisions,button.page-revisions,input[type=submit].page-revisions{background-color:#f97306}.link-button.save,button.save,input[type=submit].save{background-color:#06c2ac}.link-button.next-page,button.next-page,input[type=submit].next-page{background-color:#5170d7}.link-button.prev-page,button.prev-page,input[type=submit].prev-page{background-color:#bc13fe}.link-button.search,button.search,input[type=submit].search{background-color:#fac205}.link-button.upload,button.upload,input[type=submit].upload{background-color:#49759c}.link-button.login,button.login,input[type=submit].login{background-color:#02ab2e}input[type=search],input[type=text],input[type=password]{border:1px solid gray;padding:.75em;width:100%;border-radius:0}.edit-form{margin-bottom:0}.edit-form textarea{resize:vertical;width:100%;height:70vh;border:1px solid gray}.highlight{background-color:#ff0}.dialog{width:100%;background:#fff;padding:1em;border:1px solid gray}.flex-space{display:flex;justify-content:space-between}.login{display:flex}/*# sourceMappingURL=style.css.map */ diff --git a/static/style.css.map b/static/style.css.map index 85f852d..fe1f8f7 100644 --- a/static/style.css.map +++ b/static/style.css.map @@ -1 +1 @@ -{"version":3,"sourceRoot":"","sources":["../src/style.sass"],"names":[],"mappings":"AAAA,KACI,6BAEJ,EACI,sBAEJ,KACI,kEACA,gBACA,iBAEA,aACA,eACA,6BAEJ,KACI,eACA,WACA,oBACA,iBACA,kBACA,iBACI,eAER,SACI,wBACA,kBACA,eAEJ,OACI,gBAEJ,kBAGI,kBACA,gBAHA,sGACI,6BAGJ,8BACI,cAER,eACI,gBACA,WACA,aAEJ,MACI,iBACJ,GACI,uBACJ,WACI,4BACA,kBACJ,MACI,yBAEA,SACI,gBACA,WACA,mBACJ,kBACI,kBACJ,SACI,sBAER,WACI,WACA,cACI,YACA,iBACI,mBAEZ,IACI,gBACA,YACI,kBAER,IACI,mBAEJ,OACI,UAEJ,IACI,eAEJ,WACI,WAEJ,UACI,kBAEJ,WACI,qBACA,cACA,kBACA,iBACI,0BAER,uCACI,YACA,cACA,gBACA,kBACA,qBACA,WACA,qBACA,eACA,yDAEI,yEAEJ,qEACI,yBACJ,qEACI,yBACJ,oFACI,yBACJ,sDACI,yBACJ,qEACI,yBACJ,qEACI,yBACJ,4DACI,yBAER,oCACI,sBACA,cACA,WAEJ,WAMI,gBALA,oBACI,gBACA,WACA,YACA,sBAGR,WACI,sBAEJ,QACI,WACA,gBACA,YACA,sBAEJ,YACI,aACA","file":"style.css"} \ No newline at end of file +{"version":3,"sourceRoot":"","sources":["../src/style.sass"],"names":[],"mappings":"AAAA,KACI,6BAEJ,EACI,sBAEJ,KACI,kEACA,gBACA,eACA,aACA,eACA,6BAEJ,KACI,eACA,WACA,oBACA,iBACA,kBACA,iBACI,eAER,SACI,wBACA,kBACA,eAEJ,OACI,gBAEJ,kBAGI,kBACA,gBAHA,sGACI,6BAGJ,8BACI,cAER,eACI,gBACA,WACA,aAEJ,MACI,iBACJ,GACI,uBACJ,WACI,4BACA,kBACJ,MACI,yBAEA,SACI,gBACA,WACA,mBACJ,kBACI,kBACJ,SACI,sBAER,WACI,WACA,cACI,YACA,iBACI,mBAEZ,IACI,gBACA,YACI,kBAER,IACI,mBAEJ,OACI,UAEJ,IACI,eAEJ,WACI,WAEJ,UACI,kBAEJ,WACI,qBACA,cACA,kBACA,iBACI,0BAER,uCACI,YACA,gBACA,cACA,gBACA,kBACA,qBACA,WACA,qBACA,eACA,yDAEI,yEAEJ,qEACI,yBACJ,qEACI,yBACJ,oFACI,yBACJ,sDACI,yBACJ,qEACI,yBACJ,qEACI,yBACJ,4DACI,yBACJ,4DACI,yBACJ,yDACI,yBAER,yDACI,sBACA,cACA,WACA,gBAEJ,WAMI,gBALA,oBACI,gBACA,WACA,YACA,sBAGR,WACI,sBAEJ,QACI,WACA,gBACA,YACA,sBAEJ,YACI,aACA,8BAEJ,OACI","file":"style.css"} \ No newline at end of file