From: Dan Brown Date: Wed, 24 Jan 2024 21:59:33 +0000 (+0000) Subject: Started playing with webidx based search X-Git-Url: http://source.bookstackapp.com/website/commitdiff_plain/b18ffd2bd4e764b6d69d9ca72425e1b8cc0de1fd Started playing with webidx based search --- diff --git a/.gitignore b/.gitignore index 6ba3c98..9b97e96 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ node_modules /resources .hugo_build.lock .DS_Store -/search/data \ No newline at end of file +/search/data +/static/search.db \ No newline at end of file diff --git a/LICENSE b/LICENSE index 5d54591..23643c7 100644 --- a/LICENSE +++ b/LICENSE @@ -7,11 +7,19 @@ from those in directories with their own license files. Specifically: - static/images/blog-cover-images/cc-by-sa-4 - static/images/blog-cover-images/cc-by-4 +The following library files are also under a different license and copyright: +(Full License and copyright stated within these files): + +- search/webidx.pl (BSD 3-Clause) +- themes/bookstack/static/libs/webidx.js (BSD 3-Clause) +- themes/bookstack/static/libs/sql-wasm.js (MIT) +- themes/bookstack/static/libs/photoswipe.min.js (MIT) + --- The MIT License (MIT) -Copyright (c) 2023 Dan Brown +Copyright (c) 2024 Dan Brown Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/package.json b/package.json index 9a63c2d..7238bd2 100644 --- a/package.json +++ b/package.json @@ -9,11 +9,12 @@ "build:css:watch": "sass ./themes/bookstack/sass:./themes/bookstack/static/css --watch", "build:hugo:prod": "hugo", "build:hugo:watch": "hugo serve -DF", - "build": "npm-run-all --sequential build:css:prod build:hugo:prod", + "build:search:prod": "./search/webidx.pl public ./static/search.db", + "build": "npm-run-all --sequential build:css:prod build:hugo:prod build:search:prod", "serve": "npm-run-all build:hugo:watch", "dev": "npm-run-all --parallel build:hugo:watch build:css:watch", "deploy:server": "rsync -avx --delete --exclude '.git/' --exclude 'node_modules/' --exclude 'search/data/' ./ bs-site:/var/www/bookstackapp.com/", - "deploy": "npm-run-all --sequential build:css:prod build:hugo:prod deploy:server", + "deploy": "npm-run-all --sequential build:css:prod build:hugo:prod build:search:prod deploy:server", "test": "echo \"Error: no test specified\" && exit 1" }, "author": "Dan Brown", diff --git a/search/webidx.pl b/search/webidx.pl new file mode 100644 index 0000000..ae4c86e --- /dev/null +++ b/search/webidx.pl @@ -0,0 +1,318 @@ +#!/usr/bin/perl + +# Taken from https://github.com/gbxyz/webidx/tree/main +# BSD 3-Clause License +# Copyright (c) 2024, Gavin Brown +# Full license: https://github.com/gbxyz/webidx/blob/a28a984d38fd546d1bec4d6a4a5a47ab86cb08f8/LICENSE + +# Modifications have been made since taking a copy of the code +# to suit this particular website and use-case + +# To use, needed to install the following packages (Tested on Fedora 39): +# perl-open perl-HTML-Parser perl-DBD-SQLite + +use Cwd qw(abs_path); +use Getopt::Long qw(:config bundling auto_version auto_help); +use DBD::SQLite; +use DBI; +use File::Basename qw(basename); +use File::Glob qw(:bsd_glob); +use HTML::Parser; +use IPC::Open2; +use IO::File; +use List::Util qw(uniq none any); +use feature qw(say); +use open qw(:encoding(utf8)); +use strict; +use utf8; +use vars qw($VERSION); + +$VERSION = 0.02; + +# +# parse command line options +# +my (@exclude, @excludePattern, $compress, $origin); +die() unless (GetOptions('exclude|x=s' => \@exclude, 'excludePattern|xP=s' => \@excludePattern, 'compress|z' => \$compress, 'origin|o=s' => \$origin)); + +@exclude = map { abs_path($_) } @exclude; + +# +# determine the source directory and the database filename +# +my $dir = abs_path(shift(@ARGV) || '.'); +my $dbfile = abs_path(shift(@ARGV) || $dir.'/webidx.db'); + +# +# initialise the database +# +unlink($dbfile) if (-e $dbfile); +my $db = DBI->connect('dbi:SQLite:dbname='.$dbfile, '', '', { + 'PrintError' => 1, + 'RaiseError' => 1, + 'AutoCommit' => 0, +}); + +# +# a list of words we want to exclude +# +my @common = qw(be and of a in to it i for he on do at but from that not by or as can who get if my as up so me the are we was is); + +# +# this is a map of filename => page title +# +my $titles = {}; + +# +# this is map of word => page +# +my $index = {}; + +# +# scan the source directory +# + +say 'scanning ', $dir; + +scan_directory($dir); + +# +# generate the database +# + +say 'finished scan, generating index'; + +$db->do(qq{BEGIN}); + +$db->do(qq{CREATE TABLE `pages` (`id` INTEGER PRIMARY KEY, `url` TEXT, `title` TEXT)}); +$db->do(qq{CREATE TABLE `words` (`id` INTEGER PRIMARY KEY, `word` TEXT)}); +$db->do(qq{CREATE TABLE `index` (`id` INTEGER PRIMARY KEY, `word` INT, `page_id` INT)}); + +my $word_sth = $db->prepare(qq{INSERT INTO `words` (`word`) VALUES (?)}); +my $page_sth = $db->prepare(qq{INSERT INTO `pages` (`url`, `title`) VALUES (?, ?)}); +my $index_sth = $db->prepare(qq{INSERT INTO `index` (`word`, `page_id`) VALUES (?, ?)}); + +my $word_ids = {}; +my $page_ids = {}; + +# +# for each word... +# +foreach my $word (keys(%{$index})) { + + # + # insert an entry into the words table (if one doesn't already exist) + # + if (!defined($word_ids->{$word})) { + $word_sth->execute($word); + $word_ids->{$word} = $db->last_insert_id; + } + + # + # for each page... + # + foreach my $page (keys(%{$index->{$word}})) { + # + # clean up the page title by removing leading and trailing whitespace + # + my $title = $titles->{$page}; + $title =~ s/^[ \s\t\r\n]+//g; + $title =~ s/[ \s\t\r\n]+$//g; + # + # remove any trailing "· BookStack" + # + $title =~ s/· BookStack$//; + + # + # remove the directory + # + $page =~ s/^$dir//; + + # + # prepend the origin + # + $page = $origin.$page if ($origin); + + # + # Trim off the /index.html + # + $page =~ s/\/index\.html$//; + + # + # insert an entry into the pages table (if one doesn't already exist) + # + if (!defined($page_ids->{$page})) { + $page_sth->execute($page, $title); + $page_ids->{$page} = $db->last_insert_id; + } + + # + # insert an index entry + # + $index_sth->execute($word_ids->{$word}, $page_ids->{$page}) || die(); + } +} + +$db->do(qq{COMMIT}); + +$db->disconnect; + +if ($compress) { + say 'compressing database...'; + open2(undef, undef, qw(gzip -f -9), $dbfile); +} + +say 'done'; + +exit; + +# +# reads the contents of a directory: all HTML files are indexed, all directories +# are scanned recursively. symlinks to directories are *not* followed +# +sub scan_directory { + my $dir = shift; + + foreach my $file (map { abs_path($_) } bsd_glob(sprintf('%s/*', $dir))) { + if (-d $file) { + + next if (any { $file =~ m/\Q$_/i } @excludePattern); + + # + # directory, scan it + # + scan_directory($file); + + } elsif ($file =~ /\.html?$/i) { + # + # HTML file, index it + # + index_html($file); + + } + } +} + +# +# index an HTML file +# +sub index_html { + my $file = shift; + + return if (any { $_ eq $file } @exclude) || (any { $file =~ m/\Q$_/i } @excludePattern); + + my $currtag; + my $title; + my $text; + my $inmain = 0; + my $parser = HTML::Parser->new( + # + # text handler + # + 'text_h' => [sub { + if ('title' eq $currtag) { + # + # tag, which goes into the $titles hashref + # + $title = shift; + + } elsif ($inmain) { + # + # everything else, which just gets appended to the $text string + # + $text .= " ".shift; + + } + }, qq{dtext}], + + # + # start tag handler + # + 'start_h' => [sub { + # + # add the alt attributes of images, and any title attributes found + # + $text .= " ".$_[1]->{'alt'} if (lc('img') eq $_[0]); + $text .= " ".$_[1]->{'title'} if (defined($_[1]->{'title'})); + + $currtag = $_[0]; + if ('main' eq $currtag) { + $inmain = 1; + } + }, qq{tag,attr}], + + # + # end tag handler + # + 'end_h' => [sub { + undef($currtag); + if ('main' eq $_[0]) { + $inmain = 0; + } + }, qq{tag}], + ); + + $parser->unbroken_text(1); + + # + # we expect these elements contain text we don't want to index + # + $parser->ignore_elements(qw(script style header nav footer svg)); + + # + # open the file, being careful to ensure it's treated as UTF-8 + # + my $fh = IO::File->new($file); + $fh->binmode(qq{:utf8}); + + # + # parse + # + $parser->parse_file($fh); + $fh->close; + + return if (!$text); + + $titles->{$file} = $title; + my @words = grep { my $w = $_ ; none { $w eq $_ } @common } # filter out common words + grep { /\w/ } # filter out strings that don't contain at least one word character + map { + $_ =~ s/^[^\w]+//g; # remove leading non-word characters + $_ =~ s/[^\w]+$//g; # remove trailing non-word characters + $_; + } + split(/[\s\r\n]+/, lc($text)); # split by whitespace + + foreach my $word (@words) { + # + # increment the counter for this word/file + # + $index->{$word}->{$file}++; + } +} + +=pod + +=head1 SYNOPSIS + + webidx [-x FILE [-x FILE2 [...]]] [--xP PATTERN [--xP PATTERN2 [...]]] [-o ORIGIN] [-z] [DIRECTORY] [DBFILE] + +This will cause all HTML files in C<DIRECTORY> to be indexed, and the resulting database written to C<DBFILE>. The supported options are: + +=over + +=item * C<-x FILE> specifies a file to be excluded. May be specified multiple times. + +=item * C<--xP PATTERN> specifies a pattern of folders and files to be excluded. May be specified multiple times. + +=item * C<-o ORIGIN> specifies a base URL which will be prepended to the filenames (once C<DIRECTORY> has been removed). + +=item C<-z> specifies that the database file should be compressed once generated. If specified, the database will be at C<DBFILE.gz>. + +=item * C<DIRECTORY> is the directory to be indexed, defaults to the current working directory. + +=item * C<DBFILE> is the location where the database should be written. if not specified, defaults to C<DIRECTORY/index.db>. + +=back + +=cut \ No newline at end of file diff --git a/themes/bookstack/layouts/about/single.html b/themes/bookstack/layouts/about/single.html index 812fd37..770216d 100644 --- a/themes/bookstack/layouts/about/single.html +++ b/themes/bookstack/layouts/about/single.html @@ -1,6 +1,6 @@ {{ partial "header.html" . }} -<div class="about-page"> +<main class="about-page"> <div class="shaded primary"> <div class="container small hero padded-vertical"> <h1 class="text-center">{{.Title}}</h1> @@ -14,6 +14,6 @@ <div class="container small padded-vertical"> {{.Content}} </div> -</div> +</main> {{ partial "footer.html" . }} diff --git a/themes/bookstack/layouts/hacks/single.html b/themes/bookstack/layouts/hacks/single.html index fdc669e..0297282 100644 --- a/themes/bookstack/layouts/hacks/single.html +++ b/themes/bookstack/layouts/hacks/single.html @@ -36,66 +36,68 @@ </div> </aside> - <main class="col-md-8 col-md-offset-1 hacks-content"> + <div class="col-md-8 col-md-offset-1 hacks-content"> - {{ if .Params.Date }} - <div class="hack-warning"> - <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M4.47 21h15.06c1.54 0 2.5-1.67 1.73-3L13.73 4.99c-.77-1.33-2.69-1.33-3.46 0L2.74 18c-.77 1.33.19 3 1.73 3zM12 14c-.55 0-1-.45-1-1v-2c0-.55.45-1 1-1s1 .45 1 1v2c0 .55-.45 1-1 1zm1 4h-2v-2h2v2z"/></svg> - <div> - These hacks are unsupported customizations meant as unofficial workarounds. <br> - They can cause instability, introduce issues and may conflict with future updates. - Apply at your own risk! - </div> - </div> - {{ end }} + <main> - <h1>{{.Title}}</h1> - - {{ if .Params.Tested }} - <ul class="hack-meta"> - {{ $authors := strings.Split .Params.Author " " }} - <li><strong>Author{{ if gt (len $authors) 1 }}s{{end}}:</strong> {{ range $authors }}<a href="https://github.com/{{ strings.TrimLeft "@" . }}" target="_blank">{{ . }}</a> {{ end }}</li> - <li><strong>Created:</strong> {{ .Date.Format "2" | humanize }} {{ .Date.Format "Jan 2006" }}</li> - <li><strong>Updated:</strong> {{ .Params.Updated.Format "2" | humanize }} {{ .Params.Updated.Format "Jan 2006" }}</li> - <li><strong>Last Tested On:</strong> {{ .Params.Tested }}</li> - </ul> - {{ end }} + {{ if .Params.Date }} + <div class="hack-warning"> + <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M4.47 21h15.06c1.54 0 2.5-1.67 1.73-3L13.73 4.99c-.77-1.33-2.69-1.33-3.46 0L2.74 18c-.77 1.33.19 3 1.73 3zM12 14c-.55 0-1-.45-1-1v-2c0-.55.45-1 1-1s1 .45 1 1v2c0 .55-.45 1-1 1zm1 4h-2v-2h2v2z"/></svg> + <div> + These hacks are unsupported customizations meant as unofficial workarounds. <br> + They can cause instability, introduce issues and may conflict with future updates. + Apply at your own risk! + </div> + </div> + {{ end }} - {{.Content}} + <h1>{{.Title}}</h1> + {{ if .Params.Tested }} + <ul class="hack-meta"> + {{ $authors := strings.Split .Params.Author " " }} + <li><strong>Author{{ if gt (len $authors) 1 }}s{{end}}:</strong> {{ range $authors }}<a href="https://github.com/{{ strings.TrimLeft "@" . }}" target="_blank">{{ . }}</a> {{ end }}</li> + <li><strong>Created:</strong> {{ .Date.Format "2" | humanize }} {{ .Date.Format "Jan 2006" }}</li> + <li><strong>Updated:</strong> {{ .Params.Updated.Format "2" | humanize }} {{ .Params.Updated.Format "Jan 2006" }}</li> + <li><strong>Last Tested On:</strong> {{ .Params.Tested }}</li> + </ul> + {{ end }} + + {{.Content}} + </main> {{ if .Params.Tested }} - <hr> - - <h4>Request an Update</h4> - - <div class="row"> - <div class="col col-md-8"> - <p> - Hack not working on the latest version of BookStack? <br> - You can request this hack to be updated & tested for a small one-time fee. <br> - This helps keeps these hacks updated & maintained in a sustainable manner. - </p> - </div> - <div class="col col-md-4 text-center"> - <a href="https://bookstack-hacks.httpfunctions.com?hack_id={{ .File.ContentBaseName }}&hack_name={{.Title}}" class="button" target="_blank">Request Update</a> + <hr> + + <h4>Request an Update</h4> + + <div class="row"> + <div class="col col-md-8"> + <p> + Hack not working on the latest version of BookStack? <br> + You can request this hack to be updated & tested for a small one-time fee. <br> + This helps keeps these hacks updated & maintained in a sustainable manner. + </p> + </div> + <div class="col col-md-4 text-center"> + <a href="https://bookstack-hacks.httpfunctions.com?hack_id={{ .File.ContentBaseName }}&hack_name={{.Title}}" class="button" target="_blank">Request Update</a> + </div> </div> - </div> - <hr> + <hr> - <h4>Latest Hacks</h4> + <h4>Latest Hacks</h4> - <div class="hack-box-list"> - {{ range first 4 ( where .Site.RegularPages "Section" "hacks") }} - {{ if .Params.Date }} - {{ partial "list-hack" .}} + <div class="hack-box-list"> + {{ range first 4 ( where .Site.RegularPages "Section" "hacks") }} + {{ if .Params.Date }} + {{ partial "list-hack" .}} + {{ end }} {{ end }} - {{ end }} - </div> - {{ end }} + </div> + {{ end}} - </main> + </div> </div> </div> diff --git a/themes/bookstack/layouts/partials/footer.html b/themes/bookstack/layouts/partials/footer.html index 52b1bfc..4068d39 100644 --- a/themes/bookstack/layouts/partials/footer.html +++ b/themes/bookstack/layouts/partials/footer.html @@ -54,20 +54,12 @@ </div> </footer> + <form onsubmit="window.webidx.search({dbfile:'/search.db',query:document.getElementById('q').value});return false;"> + <input id="q" type="search"> + </form> - <script src="{{.Site.BaseURL}}libs/docs-searchbar.min.js"></script> - <script> - const searchInputSelector = '.doc-search-input,.blog-search-input'; - if (document.querySelector(searchInputSelector) !== null) { - docsSearchBar({ - hostUrl: 'https://search.bookstackapp.com', - apiKey: 'd36e621d5d924807a14c435b542aa98fd11d0c91df2526e128ecb19e617ba381', - indexUid: 'docs', - inputSelector: searchInputSelector, - debug: false, // Set debug to true if you want to inspect the dropdown - }) - } - </script> + <script src="{{.Site.BaseURL}}libs/sql-wasm.js"></script> + <script src="{{.Site.BaseURL}}libs/webidx.js"></script> <script src="{{.Site.BaseURL}}js/script.js"></script> </body> diff --git a/themes/bookstack/layouts/partials/header.html b/themes/bookstack/layouts/partials/header.html index f2ac34c..7d2189e 100644 --- a/themes/bookstack/layouts/partials/header.html +++ b/themes/bookstack/layouts/partials/header.html @@ -33,7 +33,7 @@ {{ end }} <title> - {{ if ne .RelPermalink "/" }} {{ .Title }} · {{ end }} {{ .Site.Title }} + {{ if ne .RelPermalink "/" }} {{ .Title }} · {{ end }}{{ .Site.Title }} {{ $description := .Site.Params.Description }} diff --git a/themes/bookstack/static/libs/photoswipe.min.js b/themes/bookstack/static/libs/photoswipe.min.js index 2546b5f..8eb97e5 100644 --- a/themes/bookstack/static/libs/photoswipe.min.js +++ b/themes/bookstack/static/libs/photoswipe.min.js @@ -1,5 +1,7 @@ /*! PhotoSwipe - v4.1.1 - 2015-12-24 * http://photoswipe.com +* MIT License +* https://github.com/dimsemenov/PhotoSwipe/blob/41ff96cb8e88ef6f884c388db9f2a6d5e9d3b77a/LICENSE * Copyright (c) 2015 Dmitry Semenov; */ !function(a,b){"function"==typeof define&&define.amd?define(b):"object"==typeof exports?module.exports=b():a.PhotoSwipe=b()}(this,function(){"use strict";var a=function(a,b,c,d){var e={features:null,bind:function(a,b,c,d){var e=(d?"remove":"add")+"EventListener";b=b.split(" ");for(var f=0;f0&&(g=parseInt(g[1],10),g>=1&&8>g&&(d.isOldIOSPhone=!0))}var h=f.match(/Android\s([0-9\.]*)/),i=h?h[1]:0;i=parseFloat(i),i>=1&&(4.4>i&&(d.isOldAndroid=!0),d.androidVersion=i),d.isMobileOpera=/opera mini|opera mobi/i.test(f)}for(var j,k,l=["transform","perspective","animationName"],m=["","webkit","Moz","ms","O"],n=0;4>n;n++){c=m[n];for(var o=0;3>o;o++)j=l[o],k=c+(c?j.charAt(0).toUpperCase()+j.slice(1):j),!d[j]&&k in b&&(d[j]=k);c&&!d.raf&&(c=c.toLowerCase(),d.raf=window[c+"RequestAnimationFrame"],d.raf&&(d.caf=window[c+"CancelAnimationFrame"]||window[c+"CancelRequestAnimationFrame"]))}if(!d.raf){var p=0;d.raf=function(a){var b=(new Date).getTime(),c=Math.max(0,16-(b-p)),d=window.setTimeout(function(){a(b+c)},c);return p=b+c,d},d.caf=function(a){clearTimeout(a)}}return d.svg=!!document.createElementNS&&!!document.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect,e.features=d,d}};e.detectFeatures(),e.features.oldIE&&(e.bind=function(a,b,c,d){b=b.split(" ");for(var e,f=(d?"detach":"attach")+"Event",g=function(){c.handleEvent.call(c)},h=0;hb-1?a-b:0>a?b+a:a},Aa={},Ba=function(a,b){return Aa[a]||(Aa[a]=[]),Aa[a].push(b)},Ca=function(a){var b=Aa[a];if(b){var c=Array.prototype.slice.call(arguments);c.shift();for(var d=0;df.currItem.fitRatio?xa||(lc(f.currItem,!1,!0),xa=!0):xa&&(lc(f.currItem),xa=!1)),Fa(da,oa.x,oa.y,s))},Ha=function(a){a.container&&Fa(a.container.style,a.initialPosition.x,a.initialPosition.y,a.initialZoomLevel,a)},Ia=function(a,b){b[E]=u+a+"px, 0px"+v},Ja=function(a,b){if(!i.loop&&b){var c=m+(sa.x*qa-a)/sa.x,d=Math.round(a-sb.x);(0>c&&d>0||c>=_b()-1&&0>d)&&(a=sb.x+d*i.mainScrollEndFriction)}sb.x=a,Ia(a,n)},Ka=function(a,b){var c=tb[a]-ra[a];return na[a]+ma[a]+c-c*(b/t)},La=function(a,b){a.x=b.x,a.y=b.y,b.id&&(a.id=b.id)},Ma=function(a){a.x=Math.round(a.x),a.y=Math.round(a.y)},Na=null,Oa=function(){Na&&(e.unbind(document,"mousemove",Oa),e.addClass(a,"pswp--has_mouse"),i.mouseUsed=!0,Ca("mouseUsed")),Na=setTimeout(function(){Na=null},100)},Pa=function(){e.bind(document,"keydown",f),N.transform&&e.bind(f.scrollWrap,"click",f),i.mouseUsed||e.bind(document,"mousemove",Oa),e.bind(window,"resize scroll",f),Ca("bindEvents")},Qa=function(){e.unbind(window,"resize",f),e.unbind(window,"scroll",r.scroll),e.unbind(document,"keydown",f),e.unbind(document,"mousemove",Oa),N.transform&&e.unbind(f.scrollWrap,"click",f),U&&e.unbind(window,p,f),Ca("unbindEvents")},Ra=function(a,b){var c=hc(f.currItem,pa,a);return b&&(ca=c),c},Sa=function(a){return a||(a=f.currItem),a.initialZoomLevel},Ta=function(a){return a||(a=f.currItem),a.w>0?i.maxSpreadZoom:1},Ua=function(a,b,c,d){return d===f.currItem.initialZoomLevel?(c[a]=f.currItem.initialPosition[a],!0):(c[a]=Ka(a,d),c[a]>b.min[a]?(c[a]=b.min[a],!0):c[a]1?1:a.fitRatio,c=a.container.style,d=b*a.w,e=b*a.h;c.width=d+"px",c.height=e+"px",c.left=a.initialPosition.x+"px",c.top=a.initialPosition.y+"px"},Ga=function(){if(da){var a=da,b=f.currItem,c=b.fitRatio>1?1:b.fitRatio,d=c*b.w,e=c*b.h;a.width=d+"px",a.height=e+"px",a.left=oa.x+"px",a.top=oa.y+"px"}}},Wa=function(a){var b="";i.escKey&&27===a.keyCode?b="close":i.arrowKeys&&(37===a.keyCode?b="prev":39===a.keyCode&&(b="next")),b&&(a.ctrlKey||a.altKey||a.shiftKey||a.metaKey||(a.preventDefault?a.preventDefault():a.returnValue=!1,f[b]()))},Xa=function(a){a&&(X||W||ea||S)&&(a.preventDefault(),a.stopPropagation())},Ya=function(){f.setScrollOffset(0,e.getScrollY())},Za={},$a=0,_a=function(a){Za[a]&&(Za[a].raf&&I(Za[a].raf),$a--,delete Za[a])},ab=function(a){Za[a]&&_a(a),Za[a]||($a++,Za[a]={})},bb=function(){for(var a in Za)Za.hasOwnProperty(a)&&_a(a)},cb=function(a,b,c,d,e,f,g){var h,i=Da();ab(a);var j=function(){if(Za[a]){if(h=Da()-i,h>=d)return _a(a),f(c),void(g&&g());f((c-b)*e(h/d)+b),Za[a].raf=H(j)}};j()},db={shout:Ca,listen:Ba,viewportSize:pa,options:i,isMainScrollAnimating:function(){return ea},getZoomLevel:function(){return s},getCurrentIndex:function(){return m},isDragging:function(){return U},isZooming:function(){return _},setScrollOffset:function(a,b){ra.x=a,M=ra.y=b,Ca("updateScrollOffset",ra)},applyZoomPan:function(a,b,c,d){oa.x=b,oa.y=c,s=a,Ga(d)},init:function(){if(!j&&!k){var c;f.framework=e,f.template=a,f.bg=e.getChildByClass(a,"pswp__bg"),J=a.className,j=!0,N=e.detectFeatures(),H=N.raf,I=N.caf,E=N.transform,L=N.oldIE,f.scrollWrap=e.getChildByClass(a,"pswp__scroll-wrap"),f.container=e.getChildByClass(f.scrollWrap,"pswp__container"),n=f.container.style,f.itemHolders=y=[{el:f.container.children[0],wrap:0,index:-1},{el:f.container.children[1],wrap:0,index:-1},{el:f.container.children[2],wrap:0,index:-1}],y[0].el.style.display=y[2].el.style.display="none",Va(),r={resize:f.updateSize,scroll:Ya,keydown:Wa,click:Xa};var d=N.isOldIOSPhone||N.isOldAndroid||N.isMobileOpera;for(N.animationName&&N.transform&&!d||(i.showAnimationDuration=i.hideAnimationDuration=0),c=0;cm||m>=_b())&&(m=0),f.currItem=$b(m),(N.isOldIOSPhone||N.isOldAndroid)&&(ua=!1),a.setAttribute("aria-hidden","false"),i.modal&&(ua?a.style.position="fixed":(a.style.position="absolute",a.style.top=e.getScrollY()+"px")),void 0===M&&(Ca("initialLayout"),M=K=e.getScrollY());var l="pswp--open ";for(i.mainClass&&(l+=i.mainClass+" "),i.showHideOpacity&&(l+="pswp--animate_opacity "),l+=G?"pswp--touch":"pswp--notouch",l+=N.animationName?" pswp--css_animation":"",l+=N.svg?" pswp--svg":"",e.addClass(a,l),f.updateSize(),o=-1,ta=null,c=0;h>c;c++)Ia((c+o)*sa.x,y[c].el.style);L||e.bind(f.scrollWrap,q,f),Ba("initialZoomInEnd",function(){f.setContent(y[0],m-1),f.setContent(y[2],m+1),y[0].el.style.display=y[2].el.style.display="block",i.focus&&a.focus(),Pa()}),f.setContent(y[1],m),f.updateCurrItem(),Ca("afterInit"),ua||(w=setInterval(function(){$a||U||_||s!==f.currItem.initialZoomLevel||f.updateSize()},1e3)),e.addClass(a,"pswp--visible")}},close:function(){j&&(j=!1,k=!0,Ca("close"),Qa(),bc(f.currItem,null,!0,f.destroy))},destroy:function(){Ca("destroy"),Wb&&clearTimeout(Wb),a.setAttribute("aria-hidden","true"),a.className=J,w&&clearInterval(w),e.unbind(f.scrollWrap,q,f),e.unbind(window,"scroll",f),yb(),bb(),Aa=null},panTo:function(a,b,c){c||(a>ca.min.x?a=ca.min.x:aca.min.y?b=ca.min.y:ba;a++)y[a].item&&(y[a].item.needsUpdate=!0)},updateCurrItem:function(a){if(0!==ta){var b,c=Math.abs(ta);if(!(a&&2>c)){f.currItem=$b(m),xa=!1,Ca("beforeChange",ta),c>=h&&(o+=ta+(ta>0?-h:h),c=h);for(var d=0;c>d;d++)ta>0?(b=y.shift(),y[h-1]=b,o++,Ia((o+2)*sa.x,b.el.style),f.setContent(b,m-c+d+1+1)):(b=y.pop(),y.unshift(b),o--,Ia(o*sa.x,b.el.style),f.setContent(b,m+c-d-1-1));if(da&&1===Math.abs(ta)){var e=$b(z);e.initialZoomLevel!==s&&(hc(e,pa),lc(e),Ha(e))}ta=0,f.updateCurrZoomItem(),z=m,Ca("afterChange")}}},updateSize:function(b){if(!ua&&i.modal){var c=e.getScrollY();if(M!==c&&(a.style.top=c+"px",M=c),!b&&wa.x===window.innerWidth&&wa.y===window.innerHeight)return;wa.x=window.innerWidth,wa.y=window.innerHeight,a.style.height=wa.y+"px"}if(pa.x=f.scrollWrap.clientWidth,pa.y=f.scrollWrap.clientHeight,Ya(),sa.x=pa.x+Math.round(pa.x*i.spacing),sa.y=pa.y,Ja(sa.x*qa),Ca("beforeResize"),void 0!==o){for(var d,g,j,k=0;h>k;k++)d=y[k],Ia((k+o)*sa.x,d.el.style),j=m+k-1,i.loop&&_b()>2&&(j=za(j)),g=$b(j),g&&(x||g.needsUpdate||!g.bounds)?(f.cleanSlide(g),f.setContent(d,j),1===k&&(f.currItem=g,f.updateCurrZoomItem(!0)),g.needsUpdate=!1):-1===d.index&&j>=0&&f.setContent(d,j),g&&g.container&&(hc(g,pa),lc(g),Ha(g));x=!1}t=s=f.currItem.initialZoomLevel,ca=f.currItem.bounds,ca&&(oa.x=ca.center.x,oa.y=ca.center.y,Ga(!0)),Ca("resize")},zoomTo:function(a,b,c,d,f){b&&(t=s,tb.x=Math.abs(b.x)-oa.x,tb.y=Math.abs(b.y)-oa.y,La(na,oa));var g=Ra(a,!1),h={};Ua("x",g,h,a),Ua("y",g,h,a);var i=s,j={x:oa.x,y:oa.y};Ma(h);var k=function(b){1===b?(s=a,oa.x=h.x,oa.y=h.y):(s=(a-i)*b+i,oa.x=(h.x-j.x)*b+j.x,oa.y=(h.y-j.y)*b+j.y),f&&f(b),Ga(1===b)};c?cb("customZoomTo",0,1,c,d||e.easing.sine.inOut,k):k(1)}},eb=30,fb=10,gb={},hb={},ib={},jb={},kb={},lb=[],mb={},nb=[],ob={},pb=0,qb=la(),rb=0,sb=la(),tb=la(),ub=la(),vb=function(a,b){return a.x===b.x&&a.y===b.y},wb=function(a,b){return Math.abs(a.x-b.x)-1?!1:b(a)?a:Bb(a.parentNode,b):!1},Cb={},Db=function(a,b){return Cb.prevent=!Bb(a.target,i.isClickableElement),Ca("preventDragEvent",a,b,Cb),Cb.prevent},Eb=function(a,b){return b.x=a.pageX,b.y=a.pageY,b.id=a.identifier,b},Fb=function(a,b,c){c.x=.5*(a.x+b.x),c.y=.5*(a.y+b.y)},Gb=function(a,b,c){if(a-P>50){var d=nb.length>2?nb.shift():{};d.x=b,d.y=c,nb.push(d),P=a}},Hb=function(){var a=oa.y-f.currItem.initialPosition.y;return 1-Math.abs(a/(pa.y/2))},Ib={},Jb={},Kb=[],Lb=function(a){for(;Kb.length>0;)Kb.pop();return F?(ka=0,lb.forEach(function(a){0===ka?Kb[0]=a:1===ka&&(Kb[1]=a),ka++})):a.type.indexOf("touch")>-1?a.touches&&a.touches.length>0&&(Kb[0]=Eb(a.touches[0],Ib),a.touches.length>1&&(Kb[1]=Eb(a.touches[1],Jb))):(Ib.x=a.pageX,Ib.y=a.pageY,Ib.id="",Kb[0]=Ib),Kb},Mb=function(a,b){var c,d,e,g,h=0,j=oa[a]+b[a],k=b[a]>0,l=sb.x+b.x,m=sb.x-mb.x;return c=j>ca.min[a]||jca.min[a]&&(c=i.panEndFriction,h=ca.min[a]-j,d=ca.min[a]-na[a]),(0>=d||0>m)&&_b()>1?(g=l,0>m&&l>mb.x&&(g=mb.x)):ca.min.x!==ca.max.x&&(e=j)):(j=d||m>0)&&_b()>1?(g=l,m>0&&lf.currItem.fitRatio&&(oa[a]+=b[a]*c)):(void 0!==g&&(Ja(g,!0),Z=g===mb.x?!1:!0),ca.min.x!==ca.max.x&&(void 0!==e?oa.x=e:Z||(oa.x+=b.x*c)),void 0!==g)},Nb=function(a){if(!("mousedown"===a.type&&a.button>0)){if(Zb)return void a.preventDefault();if(!T||"mousedown"!==a.type){if(Db(a,!0)&&a.preventDefault(),Ca("pointerDown"),F){var b=e.arraySearch(lb,a.pointerId,"id");0>b&&(b=lb.length),lb[b]={x:a.pageX,y:a.pageY,id:a.pointerId}}var c=Lb(a),d=c.length;$=null,bb(),U&&1!==d||(U=ga=!0,e.bind(window,p,f),R=ja=ha=S=Z=X=V=W=!1,fa=null,Ca("firstTouchStart",c),La(na,oa),ma.x=ma.y=0,La(jb,c[0]),La(kb,jb),mb.x=sa.x*qa,nb=[{x:jb.x,y:jb.y}],P=O=Da(),Ra(s,!0),yb(),zb()),!_&&d>1&&!ea&&!Z&&(t=s,W=!1,_=V=!0,ma.y=ma.x=0,La(na,oa),La(gb,c[0]),La(hb,c[1]),Fb(gb,hb,ub),tb.x=Math.abs(ub.x)-oa.x,tb.y=Math.abs(ub.y)-oa.y,aa=ba=xb(gb,hb))}}},Ob=function(a){if(a.preventDefault(),F){var b=e.arraySearch(lb,a.pointerId,"id");if(b>-1){var c=lb[b];c.x=a.pageX,c.y=a.pageY}}if(U){var d=Lb(a);if(fa||X||_)$=d;else if(sb.x!==sa.x*qa)fa="h";else{var f=Math.abs(d[0].x-jb.x)-Math.abs(d[0].y-jb.y);Math.abs(f)>=fb&&(fa=f>0?"h":"v",$=d)}}},Pb=function(){if($){var a=$.length;if(0!==a)if(La(gb,$[0]),ib.x=gb.x-jb.x,ib.y=gb.y-jb.y,_&&a>1){if(jb.x=gb.x,jb.y=gb.y,!ib.x&&!ib.y&&vb($[1],hb))return;La(hb,$[1]),W||(W=!0,Ca("zoomGestureStarted"));var b=xb(gb,hb),c=Ub(b);c>f.currItem.initialZoomLevel+f.currItem.initialZoomLevel/15&&(ja=!0);var d=1,e=Sa(),g=Ta();if(e>c)if(i.pinchToClose&&!ja&&t<=f.currItem.initialZoomLevel){var h=e-c,j=1-h/(e/1.2);Ea(j),Ca("onPinchClose",j),ha=!0}else d=(e-c)/e,d>1&&(d=1),c=e-d*(e/3);else c>g&&(d=(c-g)/(6*e),d>1&&(d=1),c=g+d*e);0>d&&(d=0),aa=b,Fb(gb,hb,qb),ma.x+=qb.x-ub.x,ma.y+=qb.y-ub.y,La(ub,qb),oa.x=Ka("x",c),oa.y=Ka("y",c),R=c>s,s=c,Ga()}else{if(!fa)return;if(ga&&(ga=!1,Math.abs(ib.x)>=fb&&(ib.x-=$[0].x-kb.x),Math.abs(ib.y)>=fb&&(ib.y-=$[0].y-kb.y)),jb.x=gb.x,jb.y=gb.y,0===ib.x&&0===ib.y)return;if("v"===fa&&i.closeOnVerticalDrag&&!Ab()){ma.y+=ib.y,oa.y+=ib.y;var k=Hb();return S=!0,Ca("onVerticalDrag",k),Ea(k),void Ga()}Gb(Da(),gb.x,gb.y),X=!0,ca=f.currItem.bounds;var l=Mb("x",ib);l||(Mb("y",ib),Ma(oa),Ga())}}},Qb=function(a){if(N.isOldAndroid){if(T&&"mouseup"===a.type)return;a.type.indexOf("touch")>-1&&(clearTimeout(T),T=setTimeout(function(){T=0},600))}Ca("pointerUp"),Db(a,!1)&&a.preventDefault();var b;if(F){var c=e.arraySearch(lb,a.pointerId,"id");if(c>-1)if(b=lb.splice(c,1)[0],navigator.pointerEnabled)b.type=a.pointerType||"mouse";else{var d={4:"mouse",2:"touch",3:"pen"};b.type=d[a.pointerType],b.type||(b.type=a.pointerType||"mouse")}}var g,h=Lb(a),j=h.length;if("mouseup"===a.type&&(j=0),2===j)return $=null,!0;1===j&&La(kb,h[0]),0!==j||fa||ea||(b||("mouseup"===a.type?b={x:a.pageX,y:a.pageY,type:"mouse"}:a.changedTouches&&a.changedTouches[0]&&(b={x:a.changedTouches[0].pageX,y:a.changedTouches[0].pageY,type:"touch"})),Ca("touchRelease",a,b));var k=-1;if(0===j&&(U=!1,e.unbind(window,p,f),yb(),_?k=0:-1!==rb&&(k=Da()-rb)),rb=1===j?Da():-1,g=-1!==k&&150>k?"zoom":"swipe",_&&2>j&&(_=!1,1===j&&(g="zoomPointerUp"),Ca("zoomGestureEnded")),$=null,X||W||ea||S)if(bb(),Q||(Q=Rb()),Q.calculateSwipeSpeed("x"),S){var l=Hb();if(lf.currItem.fitRatio&&Sb(Q))}},Rb=function(){var a,b,c={lastFlickOffset:{},lastFlickDist:{},lastFlickSpeed:{},slowDownRatio:{},slowDownRatioReverse:{},speedDecelerationRatio:{},speedDecelerationRatioAbs:{},distanceOffset:{},backAnimDestination:{},backAnimStarted:{},calculateSwipeSpeed:function(d){nb.length>1?(a=Da()-P+50,b=nb[nb.length-2][d]):(a=Da()-O,b=kb[d]),c.lastFlickOffset[d]=jb[d]-b,c.lastFlickDist[d]=Math.abs(c.lastFlickOffset[d]),c.lastFlickDist[d]>20?c.lastFlickSpeed[d]=c.lastFlickOffset[d]/a:c.lastFlickSpeed[d]=0,Math.abs(c.lastFlickSpeed[d])<.1&&(c.lastFlickSpeed[d]=0),c.slowDownRatio[d]=.95,c.slowDownRatioReverse[d]=1-c.slowDownRatio[d],c.speedDecelerationRatio[d]=1},calculateOverBoundsAnimOffset:function(a,b){c.backAnimStarted[a]||(oa[a]>ca.min[a]?c.backAnimDestination[a]=ca.min[a]:oa[a]eb&&(h||b.lastFlickOffset.x>20)?d=-1:-eb>g&&(h||b.lastFlickOffset.x<-20)&&(d=1)}var j;d&&(m+=d,0>m?(m=i.loop?_b()-1:0,j=!0):m>=_b()&&(m=i.loop?0:_b()-1,j=!0),(!j||i.loop)&&(ta+=d,qa-=d,c=!0));var k,l=sa.x*qa,n=Math.abs(l-sb.x);return c||l>sb.x==b.lastFlickSpeed.x>0?(k=Math.abs(b.lastFlickSpeed.x)>0?n/Math.abs(b.lastFlickSpeed.x):333,k=Math.min(k,400),k=Math.max(k,250)):k=333,pb===m&&(c=!1),ea=!0,Ca("mainScrollAnimStart"),cb("mainScroll",sb.x,l,k,e.easing.cubic.out,Ja,function(){bb(),ea=!1,pb=-1,(c||pb!==m)&&f.updateCurrItem(),Ca("mainScrollAnimComplete")}),c&&f.updateCurrItem(!0),c},Ub=function(a){return 1/ba*a*t},Vb=function(){var a=s,b=Sa(),c=Ta();b>s?a=b:s>c&&(a=c);var d,g=1,h=ia;return ha&&!R&&!ja&&b>s?(f.close(),!0):(ha&&(d=function(a){Ea((g-h)*a+h)}),f.zoomTo(a,0,200,e.easing.cubic.out,d),!0)};ya("Gestures",{publicMethods:{initGestures:function(){var a=function(a,b,c,d,e){A=a+b,B=a+c,C=a+d,D=e?a+e:""};F=N.pointerEvent,F&&N.touch&&(N.touch=!1),F?navigator.pointerEnabled?a("pointer","down","move","up","cancel"):a("MSPointer","Down","Move","Up","Cancel"):N.touch?(a("touch","start","move","end","cancel"),G=!0):a("mouse","down","move","up"),p=B+" "+C+" "+D,q=A,F&&!G&&(G=navigator.maxTouchPoints>1||navigator.msMaxTouchPoints>1),f.likelyTouchDevice=G,r[A]=Nb,r[B]=Ob,r[C]=Qb,D&&(r[D]=r[C]),N.touch&&(q+=" mousedown",p+=" mousemove mouseup",r.mousedown=r[A],r.mousemove=r[B],r.mouseup=r[C]),G||(i.allowPanToNext=!1)}}});var Wb,Xb,Yb,Zb,$b,_b,ac,bc=function(b,c,d,g){Wb&&clearTimeout(Wb),Zb=!0,Yb=!0;var h;b.initialLayout?(h=b.initialLayout,b.initialLayout=null):h=i.getThumbBoundsFn&&i.getThumbBoundsFn(m);var j=d?i.hideAnimationDuration:i.showAnimationDuration,k=function(){_a("initialZoom"),d?(f.template.removeAttribute("style"),f.bg.removeAttribute("style")):(Ea(1),c&&(c.style.display="block"),e.addClass(a,"pswp--animated-in"),Ca("initialZoom"+(d?"OutEnd":"InEnd"))),g&&g(),Zb=!1};if(!j||!h||void 0===h.x)return Ca("initialZoom"+(d?"Out":"In")),s=b.initialZoomLevel,La(oa,b.initialPosition),Ga(),a.style.opacity=d?0:1,Ea(1),void(j?setTimeout(function(){k()},j):k());var n=function(){var c=l,g=!f.currItem.src||f.currItem.loadError||i.showHideOpacity;b.miniImg&&(b.miniImg.style.webkitBackfaceVisibility="hidden"),d||(s=h.w/b.w,oa.x=h.x,oa.y=h.y-K,f[g?"template":"bg"].style.opacity=.001,Ga()),ab("initialZoom"),d&&!c&&e.removeClass(a,"pswp--animated-in"),g&&(d?e[(c?"remove":"add")+"Class"](a,"pswp--animate_opacity"):setTimeout(function(){e.addClass(a,"pswp--animate_opacity")},30)),Wb=setTimeout(function(){if(Ca("initialZoom"+(d?"Out":"In")),d){var f=h.w/b.w,i={x:oa.x,y:oa.y},l=s,m=ia,n=function(b){1===b?(s=f,oa.x=h.x,oa.y=h.y-M):(s=(f-l)*b+l,oa.x=(h.x-i.x)*b+i.x,oa.y=(h.y-M-i.y)*b+i.y),Ga(),g?a.style.opacity=1-b:Ea(m-b*m)};c?cb("initialZoom",0,1,j,e.easing.cubic.out,n,k):(n(1),Wb=setTimeout(k,j+20))}else s=b.initialZoomLevel,La(oa,b.initialPosition),Ga(),Ea(1),g?a.style.opacity=1:Ea(1),Wb=setTimeout(k,j+20)},d?25:90)};n()},cc={},dc=[],ec={index:0,errorMsg:'
The image could not be loaded.
',forceProgressiveLoading:!1,preload:[1,1],getNumItemsFn:function(){return Xb.length}},fc=function(){return{center:{x:0,y:0},max:{x:0,y:0},min:{x:0,y:0}}},gc=function(a,b,c){var d=a.bounds;d.center.x=Math.round((cc.x-b)/2),d.center.y=Math.round((cc.y-c)/2)+a.vGap.top,d.max.x=b>cc.x?Math.round(cc.x-b):d.center.x,d.max.y=c>cc.y?Math.round(cc.y-c)+a.vGap.top:d.center.y,d.min.x=b>cc.x?0:d.center.x,d.min.y=c>cc.y?a.vGap.top:d.center.y},hc=function(a,b,c){if(a.src&&!a.loadError){var d=!c;if(d&&(a.vGap||(a.vGap={top:0,bottom:0}),Ca("parseVerticalMargin",a)),cc.x=b.x,cc.y=b.y-a.vGap.top-a.vGap.bottom,d){var e=cc.x/a.w,f=cc.y/a.h;a.fitRatio=f>e?e:f;var g=i.scaleMode;"orig"===g?c=1:"fit"===g&&(c=a.fitRatio),c>1&&(c=1),a.initialZoomLevel=c,a.bounds||(a.bounds=fc())}if(!c)return;return gc(a,a.w*c,a.h*c),d&&c===a.initialZoomLevel&&(a.initialPosition=a.bounds.center),a.bounds}return a.w=a.h=0,a.initialZoomLevel=a.fitRatio=1,a.bounds=fc(),a.initialPosition=a.bounds.center,a.bounds},ic=function(a,b,c,d,e,g){b.loadError||d&&(b.imageAppended=!0,lc(b,d,b===f.currItem&&xa),c.appendChild(d),g&&setTimeout(function(){b&&b.loaded&&b.placeholder&&(b.placeholder.style.display="none",b.placeholder=null)},500))},jc=function(a){a.loading=!0,a.loaded=!1;var b=a.img=e.createEl("pswp__img","img"),c=function(){a.loading=!1,a.loaded=!0,a.loadComplete?a.loadComplete(a):a.img=null,b.onload=b.onerror=null,b=null};return b.onload=c,b.onerror=function(){a.loadError=!0,c()},b.src=a.src,b},kc=function(a,b){return a.src&&a.loadError&&a.container?(b&&(a.container.innerHTML=""),a.container.innerHTML=i.errorMsg.replace("%url%",a.src),!0):void 0},lc=function(a,b,c){if(a.src){b||(b=a.container.lastChild);var d=c?a.w:Math.round(a.w*a.fitRatio),e=c?a.h:Math.round(a.h*a.fitRatio);a.placeholder&&!a.loaded&&(a.placeholder.style.width=d+"px",a.placeholder.style.height=e+"px"),b.style.width=d+"px",b.style.height=e+"px"}},mc=function(){if(dc.length){for(var a,b=0;b=0,e=Math.min(c[0],_b()),g=Math.min(c[1],_b());for(b=1;(d?g:e)>=b;b++)f.lazyLoadItem(m+b);for(b=1;(d?e:g)>=b;b++)f.lazyLoadItem(m-b)}),Ba("initialLayout",function(){f.currItem.initialLayout=i.getThumbBoundsFn&&i.getThumbBoundsFn(m)}),Ba("mainScrollAnimComplete",mc),Ba("initialZoomInEnd",mc),Ba("destroy",function(){for(var a,b=0;b=0&&void 0!==Xb[a]?Xb[a]:!1},allowProgressiveImg:function(){return i.forceProgressiveLoading||!G||i.mouseUsed||screen.width>1200},setContent:function(a,b){i.loop&&(b=za(b));var c=f.getItemAt(a.index);c&&(c.container=null);var d,g=f.getItemAt(b);if(!g)return void(a.el.innerHTML="");Ca("gettingData",b,g),a.index=b,a.item=g;var h=g.container=e.createEl("pswp__zoom-wrap");if(!g.src&&g.html&&(g.html.tagName?h.appendChild(g.html):h.innerHTML=g.html),kc(g),hc(g,pa),!g.src||g.loadError||g.loaded)g.src&&!g.loadError&&(d=e.createEl("pswp__img","img"),d.style.opacity=1,d.src=g.src,lc(g,d),ic(b,g,h,d,!0));else{if(g.loadComplete=function(c){if(j){if(a&&a.index===b){if(kc(c,!0))return c.loadComplete=c.img=null,hc(c,pa),Ha(c),void(a.index===m&&f.updateCurrZoomItem());c.imageAppended?!Zb&&c.placeholder&&(c.placeholder.style.display="none",c.placeholder=null):N.transform&&(ea||Zb)?dc.push({item:c,baseDiv:h,img:c.img,index:b,holder:a,clearPlaceholder:!0}):ic(b,c,h,c.img,ea||Zb,!0)}c.loadComplete=null,c.img=null,Ca("imageLoadComplete",b,c)}},e.features.transform){var k="pswp__img pswp__img--placeholder";k+=g.msrc?"":" pswp__img--placeholder--blank";var l=e.createEl(k,g.msrc?"img":"");g.msrc&&(l.src=g.msrc),lc(g,l),h.appendChild(l),g.placeholder=l}g.loading||jc(g),f.allowProgressiveImg()&&(!Yb&&N.transform?dc.push({item:g,baseDiv:h,img:g.img,index:b,holder:a}):ic(b,g,h,g.img,!0,!0))}Yb||b!==m?Ha(g):(da=h.style,bc(g,d||g.img)),a.el.innerHTML="",a.el.appendChild(h)},cleanSlide:function(a){a.img&&(a.img.onload=a.img.onerror=null),a.loaded=a.loading=a.img=a.imageAppended=!1}}});var nc,oc={},pc=function(a,b,c){var d=document.createEvent("CustomEvent"),e={origEvent:a,target:a.target,releasePoint:b,pointerType:c||"touch"};d.initCustomEvent("pswpTap",!0,!0,e),a.target.dispatchEvent(d)};ya("Tap",{publicMethods:{initTap:function(){Ba("firstTouchStart",f.onTapStart),Ba("touchRelease",f.onTapRelease),Ba("destroy",function(){oc={},nc=null})},onTapStart:function(a){a.length>1&&(clearTimeout(nc),nc=null)},onTapRelease:function(a,b){if(b&&!X&&!V&&!$a){var c=b;if(nc&&(clearTimeout(nc),nc=null,wb(c,oc)))return void Ca("doubleTap",c);if("mouse"===b.type)return void pc(a,b,"mouse");var d=a.target.tagName.toUpperCase();if("BUTTON"===d||e.hasClass(a.target,"pswp__single-tap"))return void pc(a,b);La(oc,c),nc=setTimeout(function(){pc(a,b),nc=null},300)}}}});var qc;ya("DesktopZoom",{publicMethods:{initDesktopZoom:function(){L||(G?Ba("mouseUsed",function(){f.setupDesktopZoom()}):f.setupDesktopZoom(!0))},setupDesktopZoom:function(b){qc={};var c="wheel mousewheel DOMMouseScroll";Ba("bindEvents",function(){e.bind(a,c,f.handleMouseWheel)}),Ba("unbindEvents",function(){qc&&e.unbind(a,c,f.handleMouseWheel)}),f.mouseZoomedIn=!1;var d,g=function(){f.mouseZoomedIn&&(e.removeClass(a,"pswp--zoomed-in"),f.mouseZoomedIn=!1),1>s?e.addClass(a,"pswp--zoom-allowed"):e.removeClass(a,"pswp--zoom-allowed"),h()},h=function(){d&&(e.removeClass(a,"pswp--dragging"),d=!1)};Ba("resize",g),Ba("afterChange",g),Ba("pointerDown",function(){f.mouseZoomedIn&&(d=!0,e.addClass(a,"pswp--dragging"))}),Ba("pointerUp",h),b||g()},handleMouseWheel:function(a){if(s<=f.currItem.fitRatio)return i.modal&&(!i.closeOnScroll||$a||U?a.preventDefault():E&&Math.abs(a.deltaY)>2&&(l=!0,f.close())),!0;if(a.stopPropagation(),qc.x=0,"deltaX"in a)1===a.deltaMode?(qc.x=18*a.deltaX,qc.y=18*a.deltaY):(qc.x=a.deltaX,qc.y=a.deltaY);else if("wheelDelta"in a)a.wheelDeltaX&&(qc.x=-.16*a.wheelDeltaX),a.wheelDeltaY?qc.y=-.16*a.wheelDeltaY:qc.y=-.16*a.wheelDelta;else{if(!("detail"in a))return;qc.y=a.detail}Ra(s,!0);var b=oa.x-qc.x,c=oa.y-qc.y;(i.modal||b<=ca.min.x&&b>=ca.max.x&&c<=ca.min.y&&c>=ca.max.y)&&a.preventDefault(),f.panTo(b,c)},toggleDesktopZoom:function(b){b=b||{x:pa.x/2+ra.x,y:pa.y/2+ra.y};var c=i.getDoubleTapZoom(!0,f.currItem),d=s===c;f.mouseZoomedIn=!d,f.zoomTo(d?f.currItem.initialZoomLevel:c,b,333),e[(d?"remove":"add")+"Class"](a,"pswp--zoomed-in")}}});var rc,sc,tc,uc,vc,wc,xc,yc,zc,Ac,Bc,Cc,Dc={history:!0,galleryUID:1},Ec=function(){return Bc.hash.substring(1)},Fc=function(){rc&&clearTimeout(rc),tc&&clearTimeout(tc)},Gc=function(){var a=Ec(),b={};if(a.length<5)return b;var c,d=a.split("&");for(c=0;c-1&&(xc=xc.substring(0,b),"&"===xc.slice(-1)&&(xc=xc.slice(0,-1))),setTimeout(function(){j&&e.bind(window,"hashchange",f.onHashChange)},40)}},onHashChange:function(){return Ec()===xc?(zc=!0,void f.close()):void(uc||(vc=!0,f.goTo(Gc().pid),vc=!1))},updateURL:function(){Fc(),vc||(yc?rc=setTimeout(Hc,800):Hc())}}}),e.extend(f,db)};return a}); diff --git a/themes/bookstack/static/libs/sql-wasm.js b/themes/bookstack/static/libs/sql-wasm.js new file mode 100644 index 0000000..b234f6b --- /dev/null +++ b/themes/bookstack/static/libs/sql-wasm.js @@ -0,0 +1,8 @@ + +// sql.js 1.10.1 +// Copyright (c) 2017 sql.js authors (see AUTHORS) +// https://github.com/sql-js/sql.js/blob/master/LICENSE +// https://github.com/sql-js/sql.js/blob/master/AUTHORS +// MIT license +// Fetched via cdnjs: https://cdnjs.cloudflare.com/ajax/libs/sql.js/1.10.1/sql-wasm.min.js +var initSqlJsPromise=void 0,initSqlJs=function(Dt){return initSqlJsPromise=initSqlJsPromise||new Promise(function(A,I){var B,S,x,O,G,R,a,e=void 0!==Dt?Dt:{},H=e.onAbort,t=(e.onAbort=function(e){I(new Error(e)),H&&H(e)},e.postRun=e.postRun||[],e.postRun.push(function(){A(e)}),module=void 0,(B||=void 0!==e?e:{}).onRuntimeInitialized=function(){function u(e,t){switch(typeof t){case"boolean":C(e,t?1:0);break;case"number":W(e,t);break;case"string":J(e,t,-1,-1);break;case"object":var r;null===t?R(e):null!=t.length?(r=Mt(t,kt),K(e,r,t.length,-1),Ht(r)):H(e,"Wrong API use : tried to return a value of an unknown type ("+t+").",-1);break;default:R(e)}}function l(e,t){for(var r=[],n=0;n>>0),null!=e){var t=this.filename,r=t;if((n="/")&&(n="string"==typeof n?n:He(n),r=t?X(n+"/"+t):n),r=Ke(r,4095&(void 0!==(t=Ae(!0,!0))?t:438)|32768,0),e){if("string"==typeof e){for(var n=Array(e.length),i=0,a=e.length;i(e=ue(e)?new URL(e):x.normalize(e),S.readFileSync(e,t?void 0:"utf8")),G=e=>e=(e=O(e,!0)).buffer?e:new Uint8Array(e),R=(e,r,n,i=!0)=>{e=ue(e)?new URL(e):x.normalize(e),S.readFile(e,i?void 0:"utf8",(e,t)=>{e?n(e):r(i?t.buffer:t)})},!B.thisProgram&&1"[Emscripten Module object]"):(N||j)&&(j?r=self.location.href:"undefined"!=typeof document&&document.currentScript&&(r=document.currentScript.src),r=0!==r.indexOf("blob:")?r.substr(0,r.replace(/[?#].*/,"").lastIndexOf("/")+1):"",O=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText},j&&(G=e=>{var t=new XMLHttpRequest;return t.open("GET",e,!1),t.responseType="arraybuffer",t.send(null),new Uint8Array(t.response)}),R=(e,t,r)=>{var n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType="arraybuffer",n.onload=()=>{200==n.status||0==n.status&&n.response?t(n.response):r()},n.onerror=r,n.send(null)}),B.print||console.log.bind(console)),o=B.printErr||console.error.bind(console);Object.assign(B,t),B.thisProgram&&(L=B.thisProgram),B.wasmBinary&&(a=B.wasmBinary),"object"!=typeof WebAssembly&&i("no native wasm support detected");var P,Q,V,U,h,c,z,F,W=!1;function J(){var e=P.buffer;B.HEAP8=Q=new Int8Array(e),B.HEAP16=U=new Int16Array(e),B.HEAPU8=V=new Uint8Array(e),B.HEAPU16=new Uint16Array(e),B.HEAP32=h=new Int32Array(e),B.HEAPU32=c=new Uint32Array(e),B.HEAPF32=z=new Float32Array(e),B.HEAPF64=F=new Float64Array(e)}var K=[],C=[],ne=[];var s=0,ie=null,ae=null;function i(e){throw B.onAbort?.(e),o(e="Aborted("+e+")"),W=!0,new WebAssembly.RuntimeError(e+". Build with -sASSERTIONS for more info.")}var oe,se=e=>e.startsWith("data:application/octet-stream;base64,"),ue=e=>e.startsWith("file://");function le(e){if(e==oe&&a)return new Uint8Array(a);if(G)return G(e);throw"both async and sync fetching of the wasm failed"}function fe(e,t,r){return function(r){if(!a&&(N||j)){if("function"==typeof fetch&&!ue(r))return fetch(r,{credentials:"same-origin"}).then(e=>{if(e.ok)return e.arrayBuffer();throw"failed to load wasm binary file at '"+r+"'"}).catch(()=>le(r));if(R)return new Promise((t,e)=>{R(r,e=>t(new Uint8Array(e)),e)})}return Promise.resolve().then(()=>le(r))}(e).then(e=>WebAssembly.instantiate(e,t)).then(e=>e).then(r,e=>{o("failed to asynchronously prepare wasm: "+e),i(e)})}se(oe="sql-wasm.wasm")||(t=oe,oe=B.locateFile?B.locateFile(t,r):r+t);var u,l,he=e=>{for(;0>0];case"i16":return U[e>>1];case"i32":return h[e>>2];case"i64":i("to do getValue(i64) use WASM_BIGINT");case"float":return z[e>>2];case"double":return F[e>>3];case"*":return c[e>>2];default:i("invalid type for getValue: "+t)}}function ce(e){var t="i32";switch(t=t.endsWith("*")?"*":t){case"i1":case"i8":Q[e>>0]=0;break;case"i16":U[e>>1]=0;break;case"i32":h[e>>2]=0;break;case"i64":i("to do setValue(i64) use WASM_BIGINT");case"float":z[e>>2]=0;break;case"double":F[e>>3]=0;break;case"*":c[e>>2]=0;break;default:i("invalid type for setValue: "+t)}}var de="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0,d=(e,t,r)=>{var n=t+r;for(r=t;e[r]&&!(n<=r);)++r;if(16>10,56320|1023&o)))):n+=String.fromCharCode(o)}return n},be=(e,t)=>e?d(V,e,t):"",me=(e,t)=>{for(var r=0,n=e.length-1;0<=n;n--){var i=e[n];"."===i?e.splice(n,1):".."===i?(e.splice(n,1),r++):r&&(e.splice(n,1),r--)}if(t)for(;r;r--)e.unshift("..");return e},X=e=>{var t="/"===e.charAt(0),r="/"===e.substr(-1);return(e=(e=me(e.split("/").filter(e=>!!e),!t).join("/"))||t?e:".")&&r&&(e+="/"),(t?"/":"")+e},pe=e=>{var t=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1);return e=t[0],t=t[1],e||t?e+(t&&=t.substr(0,t.length-1)):"."},we=e=>{if("/"===e)return"/";var t=(e=(e=X(e)).replace(/\/$/,"")).lastIndexOf("/");return-1===t?e:e.substr(t+1)},_e=e=>(_e=(()=>{if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues)return e=>crypto.getRandomValues(e);if(T)try{var t=require("crypto");if(t.randomFillSync)return e=>t.randomFillSync(e);var r=t.randomBytes;return e=>(e.set(r(e.byteLength)),e)}catch(e){}i("initRandomDevice")})())(e);function ve(){for(var e="",t=!1,r=arguments.length-1;-1<=r&&!t;r--){if("string"!=typeof(t=0<=r?arguments[r]:"/"))throw new TypeError("Arguments to path.resolve must be strings");if(!t)return"";e=t+"/"+e,t="/"===t.charAt(0)}return(t?"/":"")+(e=me(e.split("/").filter(e=>!!e),!t).join("/"))||"."}var ye=[],$=e=>{for(var t=0,r=0;r{if(!(0>6}else{if(o<=65535){if(n<=r+2)break;t[r++]=224|o>>12}else{if(n<=r+3)break;t[r++]=240|o>>18,t[r++]=128|o>>12&63}t[r++]=128|o>>6&63}t[r++]=128|63&o}}return t[r]=0,r-i};function ge(e,t){var r=Array($(e)+1);return e=Z(e,r,0,r.length),t&&(r.length=e),r}var qe=[];function Ee(e,t){qe[e]={input:[],output:[],Xa:t},We(e,ke)}var ke={open(e){var t=qe[e.node.rdev];if(!t)throw new m(43);e.tty=t,e.seekable=!1},close(e){e.tty.Xa.fsync(e.tty)},fsync(e){e.tty.Xa.fsync(e.tty)},read(e,t,r,n){if(!e.tty||!e.tty.Xa.sb)throw new m(60);for(var i=0,a=0;a>>0),0!=r&&(t=Math.max(t,256)),r=e.Ia,e.Ia=new Uint8Array(t),0=e.node.Ma)return 0;if(8<(e=Math.min(e.node.Ma-i,n))&&a.subarray)t.set(a.subarray(i,i+e),r);else for(n=0;n{var r=0;return e&&(r|=365),t&&(r|=146),r},Ie=null,Se={},xe=[],Oe=1,b=null,Ge=!0,m=null,Re={};function p(e,t={}){if(!(e=ve(e)))return{path:"",node:null};if(8<(t=Object.assign({qb:!0,kb:0},t)).kb)throw new m(32);e=e.split("/").filter(e=>!!e);for(var r=Ie,n="/",i=0;i>>0)%b.length}function Ne(e){var t=Le(e.parent.id,e.name);if(b[t]===e)b[t]=e.Wa;else for(t=b[t];t;){if(t.Wa===e){t.Wa=e.Wa;break}t=t.Wa}}function w(e,t){var r;if(r=(r=v(e,"x"))?r:e.Ga.lookup?0:2)throw new m(r,e);for(r=b[Le(e.id,t)];r;r=r.Wa){var n=r.name;if(r.parent.id===e.id&&n===t)return r}return e.Ga.lookup(e,t)}function je(e,t,r,n){return t=Le((e=new St(e,t,r,n)).parent.id,e.name),e.Wa=b[t],b[t]=e}function _(e){return 16384==(61440&e)}function Te(e){var t=["r","w","rw"][3&e];return 512&e&&(t+="w"),t}function v(e,t){return!Ge&&(t.includes("r")&&!(292&e.mode)||t.includes("w")&&!(146&e.mode)||t.includes("x")&&!(73&e.mode))?2:0}function De(e,t){try{return w(e,t),20}catch(e){}return v(e,"wx")}function Pe(e,t,r){try{var n=w(e,t)}catch(e){return e.Ka}if(e=v(e,"wx"))return e;if(r){if(!_(n.mode))return 54;if(n===n.parent||"/"===He(n))return 10}else if(_(n.mode))return 31;return 0}function y(e){if(e=xe[e])return e;throw new m(8)}function Ue(e,t=-1){return ut||((ut=function(){this.$a={}}).prototype={},Object.defineProperties(ut.prototype,{object:{get(){return this.node},set(e){this.node=e}},flags:{get(){return this.$a.flags},set(e){this.$a.flags=e}},position:{get(){return this.$a.position},set(e){this.$a.position=e}}})),e=Object.assign(new ut,e),-1==t&&(t=function(){for(var e=0;e<=4096;e++)if(!xe[e])return e;throw new m(33)}()),e.fd=t,xe[t]=e}var ze,Fe={open(e){e.Ha=Se[e.node.rdev].Ha,e.Ha.open?.(e)},Ta(){throw new m(70)}};function We(e,t){Se[e]={Ha:t}}function Je(e,t){var r="/"===t,n=!t;if(r&&Ie)throw new m(10);if(!r&&!n){var i=p(t,{qb:!1});if(t=i.path,(i=i.node).Va)throw new m(10);if(!_(i.mode))throw new m(54)}((e=e.Ra(t={type:e,Pb:{},tb:t,Cb:[]})).Ra=t).root=e,r?Ie=e:i&&(i.Va=t,i.Ra&&i.Ra.Cb.push(t))}function Ke(e,t,r){var n=p(e,{parent:!0}).node;if(!(e=we(e))||"."===e||".."===e)throw new m(28);var i=De(n,e);if(i)throw new m(i);if(n.Ga.ab)return n.Ga.ab(n,e,t,r);throw new m(63)}function n(e,t){return Ke(e,1023&(void 0!==t?t:511)|16384,0)}function Ce(e,t,r){void 0===r&&(r=t,t=438),Ke(e,8192|t,r)}function Be(e,t){if(!ve(e))throw new m(44);var r=p(t,{parent:!0}).node;if(!r)throw new m(44);var n=De(r,t=we(t));if(n)throw new m(n);if(!r.Ga.symlink)throw new m(63);r.Ga.symlink(r,t,e)}function Qe(e){var t=p(e,{parent:!0}).node,r=w(t,e=we(e)),n=Pe(t,e,!0);if(n)throw new m(n);if(!t.Ga.rmdir)throw new m(63);if(r.Va)throw new m(10);t.Ga.rmdir(t,e),Ne(r)}function Ve(e){var t=p(e,{parent:!0}).node;if(!t)throw new m(44);var r=w(t,e=we(e)),n=Pe(t,e,!1);if(n)throw new m(n);if(!t.Ga.unlink)throw new m(63);if(r.Va)throw new m(10);t.Ga.unlink(t,e),Ne(r)}function Ye(e){if(!(e=p(e).node))throw new m(44);if(e.Ga.readlink)return ve(He(e.parent),e.Ga.readlink(e));throw new m(28)}function Xe(e,t){if(!(e=p(e,{Sa:!t}).node))throw new m(44);if(e.Ga.Pa)return e.Ga.Pa(e);throw new m(63)}function $e(e){return Xe(e,!0)}function Ze(e,t){if(!(e="string"==typeof e?p(e,{Sa:!0}).node:e).Ga.Oa)throw new m(63);e.Ga.Oa(e,{mode:4095&t|-4096&e.mode,timestamp:Date.now()})}function et(e,t){if(t<0)throw new m(28);if(!(e="string"==typeof e?p(e,{Sa:!0}).node:e).Ga.Oa)throw new m(63);if(_(e.mode))throw new m(31);if(32768!=(61440&e.mode))throw new m(28);var r=v(e,"w");if(r)throw new m(r);e.Ga.Oa(e,{size:t,timestamp:Date.now()})}function ee(e,t,r){if(""===e)throw new m(44);if("string"==typeof t){var n={r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090}[t];if(void 0===n)throw Error("Unknown file open mode: "+t);t=n}if(r=64&t?4095&(void 0===r?438:r)|32768:0,"object"==typeof e)var i=e;else{e=X(e);try{i=p(e,{Sa:!(131072&t)}).node}catch(e){}}if(n=!1,64&t)if(i){if(128&t)throw new m(20)}else i=Ke(e,r,0),n=!0;if(!i)throw new m(44);if(8192==(61440&i.mode)&&(t&=-513),65536&t&&!_(i.mode))throw new m(54);if(!n&&(r=i?40960==(61440&i.mode)?32:_(i.mode)&&("r"!==Te(t)||512&t)?31:v(i,Te(t)):44))throw new m(r);return 512&t&&!n&&et(i,0),t&=-131713,(i=Ue({node:i,path:He(i),flags:t,seekable:!0,position:0,Ha:i.Ha,Fb:[],error:!1})).Ha.open&&i.Ha.open(i),!B.logReadFiles||1&t||(e in(lt||={})||(lt[e]=1)),i}function tt(e){if(null===e.fd)throw new m(8);e.hb&&(e.hb=null);try{e.Ha.close&&e.Ha.close(e)}catch(e){throw e}finally{xe[e.fd]=null}e.fd=null}function rt(e,t,r){if(null===e.fd)throw new m(8);if(!e.seekable||!e.Ha.Ta)throw new m(70);if(0!=r&&1!=r&&2!=r)throw new m(28);e.position=e.Ha.Ta(e,t,r),e.Fb=[]}function nt(e,t,r,n,i){if(n<0||i<0)throw new m(28);if(null===e.fd)throw new m(8);if(1==(2097155&e.flags))throw new m(8);if(_(e.node.mode))throw new m(31);if(!e.Ha.read)throw new m(28);var a=void 0!==i;if(a){if(!e.seekable)throw new m(70)}else i=e.position;return t=e.Ha.read(e,t,r,n,i),a||(e.position+=t),t}function it(e,t,r,n,i){if(n<0||i<0)throw new m(28);if(null===e.fd)throw new m(8);if(0==(2097155&e.flags))throw new m(8);if(_(e.node.mode))throw new m(31);if(!e.Ha.write)throw new m(28);e.seekable&&1024&e.flags&&rt(e,0,2);var a=void 0!==i;if(a){if(!e.seekable)throw new m(70)}else i=e.position;return t=e.Ha.write(e,t,r,n,i,void 0),a||(e.position+=t),t}function at(){m||((m=function(e,t){this.name="ErrnoError",this.node=t,this.Eb=function(e){this.Ka=e},this.Eb(e),this.message="FS error"}).prototype=Error(),m.prototype.constructor=m,[44].forEach(e=>{Re[e]=new m(e),Re[e].stack=""}))}function ot(e,s,a){e=X("/dev/"+e);var t=Ae(!!s,!!a),r=(st||=64,st++<<8|0);We(r,{open(e){e.seekable=!1},close(){a?.buffer?.length&&a(10)},read(e,t,r,n){for(var i=0,a=0;a>2]=n.dev,h[r+4>>2]=n.mode,c[r+8>>2]=n.nlink,h[r+12>>2]=n.uid,h[r+16>>2]=n.gid,h[r+20>>2]=n.rdev,l=[n.size>>>0,(u=n.size,1<=+Math.abs(u)?0>>0:~~+Math.ceil((u-(~~u>>>0))/4294967296)>>>0:0)],h[r+24>>2]=l[0],h[r+28>>2]=l[1],h[r+32>>2]=4096,h[r+36>>2]=n.blocks,e=n.atime.getTime(),t=n.mtime.getTime();var i=n.ctime.getTime();return l=[Math.floor(e/1e3)>>>0,(u=Math.floor(e/1e3),1<=+Math.abs(u)?0>>0:~~+Math.ceil((u-(~~u>>>0))/4294967296)>>>0:0)],h[r+40>>2]=l[0],h[r+44>>2]=l[1],c[r+48>>2]=e%1e3*1e3,l=[Math.floor(t/1e3)>>>0,(u=Math.floor(t/1e3),1<=+Math.abs(u)?0>>0:~~+Math.ceil((u-(~~u>>>0))/4294967296)>>>0:0)],h[r+56>>2]=l[0],h[r+60>>2]=l[1],c[r+64>>2]=t%1e3*1e3,l=[Math.floor(i/1e3)>>>0,(u=Math.floor(i/1e3),1<=+Math.abs(u)?0>>0:~~+Math.ceil((u-(~~u>>>0))/4294967296)>>>0:0)],h[r+72>>2]=l[0],h[r+76>>2]=l[1],c[r+80>>2]=i%1e3*1e3,l=[n.ino>>>0,(u=n.ino,1<=+Math.abs(u)?0>>0:~~+Math.ceil((u-(~~u>>>0))/4294967296)>>>0:0)],h[r+88>>2]=l[0],h[r+92>>2]=l[1],0}var ht=void 0;function ct(){var e=h[+ht>>2];return ht+=4,e}var dt,E,k,bt,mt,pt,wt=(e,t)=>t+2097152>>>0<4194305-!!e?(e>>>0)+4294967296*t:NaN,_t=[0,31,60,91,121,152,182,213,244,274,305,335],vt=[0,31,59,90,120,151,181,212,243,273,304,334],yt=e=>{var t=$(e)+1,r=Rt(t);return r&&Z(e,V,r,t),r},gt={},qt=()=>{if(!dt){var e,t={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:L||"./this.program"};for(e in gt)void 0===gt[e]?delete t[e]:t[e]=gt[e];var r=[];for(e in t)r.push(e+"="+t[e]);dt=r}return dt},Et=e=>{var t=$(e)+1,r=re(t);return Z(e,V,r,t),r},kt=0,Mt=(e,t)=>(t=(1==t?re:Rt)(e.length),e.subarray||e.slice||(e=new Uint8Array(e)),V.set(e,t),t),At=[],te=e=>{E.delete(k.get(e)),k.set(e,null),At.push(e)},It=(t,r)=>{if(!E){E=new WeakMap;var n=k.length;if(E)for(var i=0;i<0+n;i++){var a=k.get(i);a&&E.set(a,i)}}if(n=E.get(t)||0)return n;if(At.length)n=At.pop();else{try{k.grow(1)}catch(e){if(e instanceof RangeError)throw"Unable to grow wasm table. Set ALLOW_TABLE_GROWTH.";throw e}n=k.length-1}try{k.set(n,t)}catch(e){if(!(e instanceof TypeError))throw e;if("function"==typeof WebAssembly.Function){for(var i=WebAssembly.Function,a={i:"i32",j:"i64",f:"f32",d:"f64",e:"externref",p:"i32"},o={parameters:[],results:"v"==r[0]?[]:[a[r[0]]]},s=1;s>7),s=0;s>7),r.push.apply(r,i),r.push(2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0),r=new WebAssembly.Module(new Uint8Array(r)),r=new WebAssembly.Instance(r,{e:{f:t}}).exports.f}k.set(n,r)}return E.set(t,n),n};function St(e,t,r,n){this.parent=e||=this,this.Ra=e.Ra,this.Va=null,this.id=Oe++,this.name=t,this.mode=r,this.Ga={},this.Ha={},this.rdev=n}Object.defineProperties(St.prototype,{read:{get:function(){return 365==(365&this.mode)},set:function(e){e?this.mode|=365:this.mode&=-366}},write:{get:function(){return 146==(146&this.mode)},set:function(e){e?this.mode|=146:this.mode&=-147}}}),at(),b=Array(4096),Je(f,"/"),n("/tmp"),n("/home"),n("/home/web_user"),n("/dev"),We(259,{read:()=>0,write:(e,t,r,n)=>n}),Ce("/dev/null",259),Ee(1280,r),Ee(1536,t),Ce("/dev/tty",1280),Ce("/dev/tty1",1536),bt=new Uint8Array(1024),mt=0,ot("random",r=()=>(0===mt&&(mt=_e(bt).byteLength),bt[--mt])),ot("urandom",r),n("/dev/shm"),n("/dev/shm/tmp"),n("/proc"),pt=n("/proc/self"),n("/proc/self/fd"),Je({Ra(){var e=je(pt,"fd",16895,73);return e.Ga={lookup(e,t){var r=y(+t);return(e={parent:null,Ra:{tb:"fake"},Ga:{readlink:()=>r.path}}).parent=e}},e}},"/proc/self/fd");var xt,Ot={a:(e,t,r,n)=>{i(`Assertion failed: ${e?d(V,e):""}, at: `+[t?d(V,t):"unknown filename",r,n?d(V,n):"unknown function"])},h:function(e,t){try{return Ze(e=e?d(V,e):"",t),0}catch(e){if(void 0===g||"ErrnoError"!==e.name)throw e;return-e.Ka}},H:function(e,t,r){try{if(t=q(e,t=t?d(V,t):""),-8&r)return-28;var n=p(t,{Sa:!0}).node;return n?(e="",4&r&&(e+="r"),2&r&&(e+="w"),1&r&&(e+="x"),e&&v(n,e)?-2:0):-44}catch(e){if(void 0===g||"ErrnoError"!==e.name)throw e;return-e.Ka}},i:function(e,t){try{return Ze(y(e).node,t),0}catch(e){if(void 0===g||"ErrnoError"!==e.name)throw e;return-e.Ka}},g:function(e){try{var t=y(e).node,r="string"==typeof t?p(t,{Sa:!0}).node:t;if(r.Ga.Oa)return r.Ga.Oa(r,{timestamp:Date.now()}),0;throw new m(63)}catch(e){if(void 0===g||"ErrnoError"!==e.name)throw e;return-e.Ka}},b:function(e,t,r){ht=r;try{var n=y(e);switch(t){case 0:var i=ct();if(i<0)return-28;for(;xe[i];)i++;return Ue(n,i).fd;case 1:case 2:return 0;case 3:return n.flags;case 4:return i=ct(),n.flags|=i,0;case 5:return i=ct(),U[i+0>>1]=2,0;case 6:case 7:return 0;case 16:case 8:return-28;case 9:return h[Gt()>>2]=28,-1;default:return-28}}catch(e){if(void 0===g||"ErrnoError"!==e.name)throw e;return-e.Ka}},f:function(e,t){try{return ft(Xe,y(e).path,t)}catch(e){if(void 0===g||"ErrnoError"!==e.name)throw e;return-e.Ka}},n:function(e,t,r){t=wt(t,r);try{if(isNaN(t))return 61;var n=y(e);if(0==(2097155&n.flags))throw new m(28);return et(n.node,t),0}catch(e){if(void 0===g||"ErrnoError"!==e.name)throw e;return-e.Ka}},C:function(e,t){try{if(0===t)return-28;var r=$("/")+1;return t>2]+4294967296*h[r+4>>2])+h[r+8>>2]/1e6,1e3*(c[(r+=16)>>2]+4294967296*h[r+4>>2])+h[r+8>>2]/1e6):n=Date.now(),e=n;var n,i,a=p(t,{Sa:!0}).node;return a.Ga.Oa(a,{timestamp:Math.max(e,i)}),0}catch(e){if(void 0===g||"ErrnoError"!==e.name)throw e;return-e.Ka}},l:function(e,t,r){e=new Date(1e3*wt(e,t)),h[r>>2]=e.getSeconds(),h[r+4>>2]=e.getMinutes(),h[r+8>>2]=e.getHours(),h[r+12>>2]=e.getDate(),h[r+16>>2]=e.getMonth(),h[r+20>>2]=e.getFullYear()-1900,h[r+24>>2]=e.getDay(),t=e.getFullYear(),h[r+28>>2]=(0!=t%4||0==t%100&&0!=t%400?vt:_t)[e.getMonth()]+e.getDate()-1|0,h[r+36>>2]=-60*e.getTimezoneOffset(),t=new Date(e.getFullYear(),6,1).getTimezoneOffset();var n=new Date(e.getFullYear(),0,1).getTimezoneOffset();h[r+32>>2]=0|(t!=n&&e.getTimezoneOffset()==Math.min(n,t))},j:function(e,t,r,n,i,a,o,s){i=wt(i,a);try{if(isNaN(i))return 61;var u=y(n);if(0!=(2&t)&&0==(2&r)&&2!=(2097155&u.flags))throw new m(2);if(1==(2097155&u.flags))throw new m(2);if(!u.Ha.bb)throw new m(43);var l=u.Ha.bb(u,e,i,t,r),f=l.Db;return h[o>>2]=l.ub,c[s>>2]=f,0}catch(e){if(void 0===g||"ErrnoError"!==e.name)throw e;return-e.Ka}},k:function(e,t,r,n,i,a,o){a=wt(a,o);try{if(isNaN(a))return 61;var s,u=y(i);if(2&r){if(32768!=(61440&u.node.mode))throw new m(43);2&n||(s=V.slice(e,e+t),u.Ha.cb&&u.Ha.cb(u,s,a,t,n))}}catch(e){if(void 0===g||"ErrnoError"!==e.name)throw e;return-e.Ka}},s:(e,t,r)=>{function n(e){return(e=e.toTimeString().match(/\(([A-Za-z ]+)\)$/))?e[1]:"GMT"}var i=(new Date).getFullYear(),a=new Date(i,0,1),o=new Date(i,6,1),i=a.getTimezoneOffset(),s=o.getTimezoneOffset();c[e>>2]=60*Math.max(i,s),h[t>>2]=Number(i!=s),e=n(a),t=n(o),e=yt(e),t=yt(t),s>2]=e,c[r+4>>2]=t):(c[r>>2]=t,c[r+4>>2]=e)},d:()=>Date.now(),t:()=>2147483648,c:()=>performance.now(),o:e=>{var t=V.length;if(2147483648<(e>>>=0))return!1;for(var r=1;r<=4;r*=2){var n=t*(1+.2/r),n=Math.min(n,e+100663296),i=Math;n=Math.max(e,n);e:{i=(i.min.call(i,2147483648,n+(65536-n%65536)%65536)-P.buffer.byteLength+65535)/65536;try{P.grow(i),J();var a=1;break e}catch(e){}a=void 0}if(a)return!0}return!1},A:(n,i)=>{var a=0;return qt().forEach((e,t)=>{var r=i+a;for(t=c[n+4*t>>2]=r,r=0;r>0]=e.charCodeAt(r);Q[t>>0]=0,a+=e.length+1}),0},B:(e,t)=>{var r=qt(),n=(c[e>>2]=r.length,0);return r.forEach(e=>n+=e.length+1),c[t>>2]=n,0},e:function(e){try{return tt(y(e)),0}catch(e){if(void 0===g||"ErrnoError"!==e.name)throw e;return e.Ka}},p:function(e,t){try{var r=y(e);return Q[t>>0]=r.tty?2:_(r.mode)?3:40960==(61440&r.mode)?7:4,U[t+2>>1]=0,l=[0,(u=0,1<=+Math.abs(u)?0>>0:~~+Math.ceil((u-(~~u>>>0))/4294967296)>>>0:0)],h[t+8>>2]=l[0],h[t+12>>2]=l[1],l=[0,(u=0,1<=+Math.abs(u)?0>>0:~~+Math.ceil((u-(~~u>>>0))/4294967296)>>>0:0)],h[t+16>>2]=l[0],h[t+20>>2]=l[1],0}catch(e){if(void 0===g||"ErrnoError"!==e.name)throw e;return e.Ka}},x:function(e,t,r,n){try{e:{var i=y(e);e=t;for(var a,o=t=0;o>2],u=c[e+4>>2],l=(e+=8,nt(i,Q,s,u,a));if(l<0){var f=-1;break e}if(t+=l,l>2]=f,0}catch(e){if(void 0===g||"ErrnoError"!==e.name)throw e;return e.Ka}},m:function(e,t,r,n,i){t=wt(t,r);try{if(isNaN(t))return 61;var a=y(e);return rt(a,t,n),l=[a.position>>>0,(u=a.position,1<=+Math.abs(u)?0>>0:~~+Math.ceil((u-(~~u>>>0))/4294967296)>>>0:0)],h[i>>2]=l[0],h[i+4>>2]=l[1],a.hb&&0===t&&0===n&&(a.hb=null),0}catch(e){if(void 0===g||"ErrnoError"!==e.name)throw e;return e.Ka}},D:function(e){try{var t=y(e);return t.Ha?.fsync?t.Ha.fsync(t):0}catch(e){if(void 0===g||"ErrnoError"!==e.name)throw e;return e.Ka}},u:function(e,t,r,n){try{e:{var i=y(e);e=t;for(var a,o=t=0;o>2],u=c[e+4>>2],l=(e+=8,it(i,Q,s,u,a));if(l<0){var f=-1;break e}t+=l,void 0!==a&&(a+=l)}f=t}return c[n>>2]=f,0}catch(e){if(void 0===g||"ErrnoError"!==e.name)throw e;return e.Ka}}},M=function(){function t(e){return M=e.exports,P=M.I,J(),k=M.Aa,C.unshift(M.J),s--,B.monitorRunDependencies?.(s),0==s&&(null!==ie&&(clearInterval(ie),ie=null),ae&&(e=ae,ae=null,e())),M}var r,n,i,e={a:Ot};if(s++,B.monitorRunDependencies?.(s),B.instantiateWasm)try{return B.instantiateWasm(e,t)}catch(e){return o("Module.instantiateWasm callback failed with error: "+e),!1}return r=e,n=function(e){t(e.instance)},i=oe,a||"function"!=typeof WebAssembly.instantiateStreaming||se(i)||ue(i)||T||"function"!=typeof fetch?fe(i,r,n):fetch(i,{credentials:"same-origin"}).then(e=>WebAssembly.instantiateStreaming(e,r).then(n,function(e){return o("wasm streaming compile failed: "+e),o("falling back to ArrayBuffer instantiation"),fe(i,r,n)})),{}}(),Gt=(B._sqlite3_free=e=>(B._sqlite3_free=M.K)(e),B._sqlite3_value_text=e=>(B._sqlite3_value_text=M.L)(e),()=>(Gt=M.M)()),Rt=(B._sqlite3_prepare_v2=(e,t,r,n,i)=>(B._sqlite3_prepare_v2=M.N)(e,t,r,n,i),B._sqlite3_step=e=>(B._sqlite3_step=M.O)(e),B._sqlite3_finalize=e=>(B._sqlite3_finalize=M.P)(e),B._sqlite3_reset=e=>(B._sqlite3_reset=M.Q)(e),B._sqlite3_clear_bindings=e=>(B._sqlite3_clear_bindings=M.R)(e),B._sqlite3_value_blob=e=>(B._sqlite3_value_blob=M.S)(e),B._sqlite3_value_bytes=e=>(B._sqlite3_value_bytes=M.T)(e),B._sqlite3_value_double=e=>(B._sqlite3_value_double=M.U)(e),B._sqlite3_value_int=e=>(B._sqlite3_value_int=M.V)(e),B._sqlite3_value_type=e=>(B._sqlite3_value_type=M.W)(e),B._sqlite3_result_blob=(e,t,r,n)=>(B._sqlite3_result_blob=M.X)(e,t,r,n),B._sqlite3_result_double=(e,t)=>(B._sqlite3_result_double=M.Y)(e,t),B._sqlite3_result_error=(e,t,r)=>(B._sqlite3_result_error=M.Z)(e,t,r),B._sqlite3_result_int=(e,t)=>(B._sqlite3_result_int=M._)(e,t),B._sqlite3_result_int64=(e,t,r)=>(B._sqlite3_result_int64=M.$)(e,t,r),B._sqlite3_result_null=e=>(B._sqlite3_result_null=M.aa)(e),B._sqlite3_result_text=(e,t,r,n)=>(B._sqlite3_result_text=M.ba)(e,t,r,n),B._sqlite3_aggregate_context=(e,t)=>(B._sqlite3_aggregate_context=M.ca)(e,t),B._sqlite3_column_count=e=>(B._sqlite3_column_count=M.da)(e),B._sqlite3_data_count=e=>(B._sqlite3_data_count=M.ea)(e),B._sqlite3_column_blob=(e,t)=>(B._sqlite3_column_blob=M.fa)(e,t),B._sqlite3_column_bytes=(e,t)=>(B._sqlite3_column_bytes=M.ga)(e,t),B._sqlite3_column_double=(e,t)=>(B._sqlite3_column_double=M.ha)(e,t),B._sqlite3_column_text=(e,t)=>(B._sqlite3_column_text=M.ia)(e,t),B._sqlite3_column_type=(e,t)=>(B._sqlite3_column_type=M.ja)(e,t),B._sqlite3_column_name=(e,t)=>(B._sqlite3_column_name=M.ka)(e,t),B._sqlite3_bind_blob=(e,t,r,n,i)=>(B._sqlite3_bind_blob=M.la)(e,t,r,n,i),B._sqlite3_bind_double=(e,t,r)=>(B._sqlite3_bind_double=M.ma)(e,t,r),B._sqlite3_bind_int=(e,t,r)=>(B._sqlite3_bind_int=M.na)(e,t,r),B._sqlite3_bind_text=(e,t,r,n,i)=>(B._sqlite3_bind_text=M.oa)(e,t,r,n,i),B._sqlite3_bind_parameter_index=(e,t)=>(B._sqlite3_bind_parameter_index=M.pa)(e,t),B._sqlite3_sql=e=>(B._sqlite3_sql=M.qa)(e),B._sqlite3_normalized_sql=e=>(B._sqlite3_normalized_sql=M.ra)(e),B._sqlite3_errmsg=e=>(B._sqlite3_errmsg=M.sa)(e),B._sqlite3_exec=(e,t,r,n,i)=>(B._sqlite3_exec=M.ta)(e,t,r,n,i),B._sqlite3_changes=e=>(B._sqlite3_changes=M.ua)(e),B._sqlite3_close_v2=e=>(B._sqlite3_close_v2=M.va)(e),B._sqlite3_create_function_v2=(e,t,r,n,i,a,o,s,u)=>(B._sqlite3_create_function_v2=M.wa)(e,t,r,n,i,a,o,s,u),B._sqlite3_open=(e,t)=>(B._sqlite3_open=M.xa)(e,t),B._malloc=e=>(Rt=B._malloc=M.ya)(e)),Ht=B._free=e=>(Ht=B._free=M.za)(e),Lt=(B._RegisterExtensionFunctions=e=>(B._RegisterExtensionFunctions=M.Ba)(e),(e,t)=>(Lt=M.Ca)(e,t)),Nt=()=>(Nt=M.Da)(),jt=e=>(jt=M.Ea)(e),re=e=>(re=M.Fa)(e);function Tt(){function e(){if(!xt&&(xt=!0,B.calledRun=!0,!W)){if(B.noFSInit||ze||(ze=!0,at(),B.stdin=B.stdin,B.stdout=B.stdout,B.stderr=B.stderr,B.stdin?ot("stdin",B.stdin):Be("/dev/tty","/dev/stdin"),B.stdout?ot("stdout",null,B.stdout):Be("/dev/tty","/dev/stdout"),B.stderr?ot("stderr",null,B.stderr):Be("/dev/tty1","/dev/stderr"),ee("/dev/stdin",0),ee("/dev/stdout",1),ee("/dev/stderr",1)),Ge=!1,he(C),B.onRuntimeInitialized&&B.onRuntimeInitialized(),B.postRun)for("function"==typeof B.postRun&&(B.postRun=[B.postRun]);B.postRun.length;){var e=B.postRun.shift();ne.unshift(e)}he(ne)}}if(!(0{var t=!h||h.every(e=>"number"===e||"boolean"===e);return"string"!==f&&t&&!e?B["_"+l]:function(){var e=l,t=f,r=h,n=arguments,i={string:e=>{var t=0;return t=null!=e&&0!==e?Et(e):t},array:e=>{var t=re(e.length);return Q.set(e,t),t}},a=(e=B["_"+e],[]),o=0;if(n)for(var s=0;s `https://sql.js.org/dist/${file}`}); + } + + if (webidx.hasOwnProperty('db')) { + webidx.displayResults(webidx.query(params.query), params); + + } else { + webidx.loadDB(params); + + } +}; + +webidx.loadDB = function (params) { + var xhr = new XMLHttpRequest(); + + xhr.open('GET', params.dbfile); + xhr.timeout = params.timeout ?? 5000; + xhr.responseType = 'arraybuffer'; + + xhr.ontimeout = function() { + if (params.hasOwnProperty('errorCallback')) { + params.errorCallback('Unable to load index, please refresh the page.'); + } + }; + + xhr.onload = function() { + webidx.initializeDB(this.response); + webidx.displayResults(webidx.query(params.query), params); + }; + + xhr.send(); +}; + +webidx.initializeDB = function (arrayBuffer) { + webidx.db = new webidx.sql.Database(new Uint8Array(arrayBuffer)); + + // + // prepare statements + // + webidx.wordQuery = webidx.db.prepare("SELECT `id` FROM `words` WHERE (`word`=:word)"); + webidx.idxQuery = webidx.db.prepare("SELECT `page_id` FROM `index` WHERE (`word`=:word)"); + webidx.pageQuery = webidx.db.prepare("SELECT `url`,`title` FROM `pages` WHERE (`id`=:id)"); +}; + +webidx.getWordID = function (word) { + webidx.wordQuery.bind([word]); + webidx.wordQuery.step(); + var word_id = webidx.wordQuery.get().shift(); + + webidx.wordQuery.reset(); + + return word_id; +}; + +webidx.getPagesHavingWord = function (word_id) { + var pages = []; + + webidx.idxQuery.bind([word_id]); + + while (webidx.idxQuery.step()) { + pages.push(webidx.idxQuery.get().shift()); + } + + webidx.idxQuery.reset(); + + return pages; +}; + +webidx.getPage = function (page_id) { + webidx.pageQuery.bind([page_id]); + + webidx.pageQuery.step(); + + var page = webidx.pageQuery.getAsObject(); + + webidx.pageQuery.reset(); + + return page; +}; + +webidx.query = function (query) { + // + // split the search term into words + // + var words = query.toLowerCase().split(" "); + + // + // this array maps page ID to rank + // + var pageRank = []; + + // + // iterate over each word + // + while (words.length > 0) { + var word = words.shift(); + + var invert = false; + if (0 == word.indexOf("-")) { + invert = true; + word = word.substring(1); + } + + var word_id = webidx.getWordID(word); + + // + // if the word isn't present, ignore it + // + if (word_id) { + var pages = webidx.getPagesHavingWord(word_id); + + pages.forEach(function (page_id) { + if (invert) { + if (pageRank[page_id]) { + pageRank[page_id] -= 65535; + + } else { + pageRank[page_id] = -65535; + + } + + } else { + if (pageRank[page_id]) { + pageRank[page_id]++; + + } else { + pageRank[page_id] = 1; + + } + } + }); + } + } + + // + // transform the results into a format that can be sorted + // + var sortedPages = []; + + pageRank.forEach(function (rank, page_id) { + if (rank > 0) { + sortedPages.push({rank: rank, page_id: page_id}); + } + }) + + // + // sort the results in descending rank order + // + sortedPages.sort(function(a, b) { + return b.rank - a.rank; + }); + + // + // this will be populated with the actual pages + // + var pages = []; + + // + // get page data for each result + // + sortedPages.forEach(function(result) { + pages.push(webidx.getPage(result.page_id)); + }); + + return pages; +}; + +webidx.regExpQuote = function (str) { + return str.replace(/[/\-\\^$*+?.()|[\]{}]/g, '\\$&'); +}; + +webidx.displayResults = function (pages, params) { + var callback = params.resultCallback ?? webidx.displayDialog; + callback(pages, params); +}; + +webidx.displayDialog = function (pages, params) { + var dialog = document.createElement('dialog'); + dialog.classList.add('webidx-results-dialog') + + dialog.appendChild(document.createElement('h2')).appendChild(document.createTextNode('Search Results')); + + if (pages.length < 1) { + dialog.appendChild(document.createElement('p')).appendChild(document.createTextNode('Nothing found.')); + + } else { + var ul = dialog.appendChild(document.createElement('ul')); + + pages.forEach(function(page) { + var titleText = page.title; + + if (params.titleSuffix) { + titleText = titleText.replace(new RegExp(webidx.regExpQuote(params.titleSuffix)+'$'), ''); + } + + if (params.titlePrefix) { + titleText = titleText.replace(new RegExp('^' + webidx.regExpQuote(params.titleSuffix)), ''); + } + + var li = ul.appendChild(document.createElement('li')); + var a = li.appendChild(document.createElement('a')); + a.setAttribute('href', page.url); + a.appendChild(document.createTextNode(titleText)); + li.appendChild(document.createElement('br')); + + var span = li.appendChild(document.createElement('span')); + span.classList.add('webidx-page-url'); + span.appendChild(document.createTextNode(page.url)); + }); + } + + var form = dialog.appendChild(document.createElement('form')); + form.setAttribute('method', 'dialog'); + + var button = form.appendChild(document.createElement('button')); + button.setAttribute('autofocus', true); + button.appendChild(document.createTextNode('Close')); + + document.body.appendChild(dialog); + + dialog.addEventListener('close', function() { + dialog.parentNode.removeChild(dialog); + }); + + dialog.showModal(); + dialog.scrollTop = 0; +};