~evanj/cms

051b02dd570bb6f8de796a4b9304e02b07c27ae6 — Evan M Jones 5 months ago ccbab98
Fix(embed): Adding go get build dep via //go:generate
4 files changed, 30 insertions(+), 1395 deletions(-)

M cms.go
M go.mod
M go.sum
M internal/s/tmpl/tmpls_embed.go
M cms.go => cms.go +2 -0
@@ 20,6 20,8 @@ import (
	"git.sr.ht/~evanj/security"
)

//go:generate go get git.sr.ht/~evanj/embed

var (
	app *App


M go.mod => go.mod +1 -0
@@ 3,6 3,7 @@ module git.sr.ht/~evanj/cms
go 1.12

require (
	git.sr.ht/~evanj/embed v0.0.0-20200525225021-2cde7dae7bfa // indirect
	git.sr.ht/~evanj/security v0.0.0-20200228044358-9b9bc6682997
	github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869
	github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b

M go.sum => go.sum +8 -0
@@ 1,3 1,5 @@
git.sr.ht/~evanj/embed v0.0.0-20200525225021-2cde7dae7bfa h1:gpQ2a3/AYs0o1F/kg2V2GIUIS8pPkvoSlJPZCbF9Mvw=
git.sr.ht/~evanj/embed v0.0.0-20200525225021-2cde7dae7bfa/go.mod h1:o3sadZPJeN9scjfsbpsABLF2nNr6qUqMMkGLfCCsILc=
git.sr.ht/~evanj/security v0.0.0-20200228044358-9b9bc6682997 h1:fdAj8fR4mpS/OAvetjc9Xn96ZYrnJcQpbn/AUG0jihs=
git.sr.ht/~evanj/security v0.0.0-20200228044358-9b9bc6682997/go.mod h1:40791KVgThT97CT6mTsF4NUNPeX2BAVlsuH1RiiSrAs=
github.com/Pallinder/go-randomdata v1.2.0 h1:DZ41wBchNRb/0GfsePLiSwb0PHZmT67XY00lCDlaYPg=


@@ 20,12 22,15 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d h1:1ZiEyfaQIg3Qh0EoqpwAakHVhecoE5wlSg5GjnafJGw=
golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200320181102-891825fb96df h1:lDWgvUvNnaTnNBc/dwOty86cFeKoKWbwy2wQj0gIxbU=
golang.org/x/crypto v0.0.0-20200320181102-891825fb96df/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a h1:WXEvlFVvvGxCJLG6REjsT03iWnKLEWinaScsxF2Vm2o=
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=


@@ 38,6 43,9 @@ golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20200301222351-066e0c02454c h1:FD7jysxM+EJqg5UYYy3XYDsAiUickFsn4UiaanJkf8c=
golang.org/x/tools v0.0.0-20200301222351-066e0c02454c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM=
gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE=
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=

M internal/s/tmpl/tmpls_embed.go => internal/s/tmpl/tmpls_embed.go +19 -1395
@@ 2,1417 2,41 @@

package tmpl

var tmpls map[string]string

func init() {
	tmpls = make(map[string]string)

	tmpls["css/main.css"] = `body { 
  margin-left: auto;
  margin-right: auto;
}

body main {
  margin-left: 10px;
  margin-right: 10px;
}

fieldset {
  display: inline-block;
}

.contenttype details:nth-child(2) form fieldset,
.content details:nth-child(2) form fieldset {
  display: block;
}

fieldset + br { 
  height: 20px; 
  content: " "; 
  display: block; 
}

header nav { 
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header nav ul,
header nav li { 
  list-style: none;
}

header nav li { 
  float: left;
  margin-left: 10px;
}

.tox.tox-tinymce {
  min-height: 600px;
}

.aa-dropdown-menu {
  background: #f1f1f1;
  width: calc(100% - 4px);
  border: 2px solid black;
  padding: 7.5px 0;
}

.aa-dropdown-menu p {
  margin: 0;
  padding: 7.5px 15px;
  cursor: pointer;
}

.aa-dropdown-menu p:hover {
  background: rgba(0, 0, 0, 0.05);
}

span.tox-statusbar__branding {
  display: none;
}

summary {
  cursor: pointer;
}
`

	tmpls["css/mvp.css"] = `:root {
    --border-radius: 5px;
    --box-shadow: 2px 2px 10px;
    --color: #118bee;
    --color-accent: #118bee0b;
    --color-bg: #fff;
    --color-bg-secondary: #e9e9e9;
    --color-secondary: #920de9;
    --color-secondary-accent: #920de90b;
    --color-shadow: #f4f4f4;
    --color-text: #000;
    --color-text-secondary: #999;
    --hover-brightness: 1.2;
    --justify-important: center;
    --justify-normal: left;
    --line-height: 150%!;(MISSING)
    --width-card: 285px;
    --width-card-medium: 460px;
    --width-card-wide: 800px;
    --width-content: 1080px;
}

/* MVP.css v1.0 - by Andy Brewer */

/* Layout */
article aside {
    background: var(--color-secondary-accent);
    border-left: 4px solid var(--color-secondary);
    padding: 0.01rem 0.8rem;
}

body {
    background: var(--color-bg);
    color: var(--color-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    line-height: var(--line-height);
    margin: 0;
    overflow-x: hidden;
    padding: 1rem 0;
}

footer,
header,
main {
    margin: 0 auto;
    max-width: var(--width-content);
    padding: 2rem 1rem;
}

hr {
    background-color: var(--color-bg-secondary);
    border: none;
    height: 1px;
    margin: 4rem 0;
}

section {
    display: flex;
    flex-wrap: wrap;
    justify-content: var(--justify-important);
}

section aside {
    border: 1px solid var(--color-bg-secondary);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow) var(--color-shadow);
    margin: 1rem;
    padding: 1.25rem;
    width: var(--width-card);
}

section aside:hover {
    box-shadow: var(--box-shadow) var(--color-bg-secondary);
}

section aside img {
    max-width: 100%!;(MISSING)
}

/* Headers */
article header,
div header,
main header {
    padding-top: 0;
}

header {
    text-align: var(--justify-important);
}

header a b,
header a em,
header a i,
header a strong {
    margin-left: 1rem;
    margin-right: 1rem;
}

header nav img {
    margin: 1rem 0;
}

section header {
    padding-top: 0;
    width: 100%!;(MISSING)
}

/* Nav */
nav {
    align-items: center;
    display: flex;
    font-weight: bold;
    justify-content: space-between;
    margin-bottom: 7rem;
}

nav ul {
    list-style: none;
    padding: 0;
}

nav ul li {
    display: inline-block;
    margin: 0 0.5rem;
}

/* Typography */
code {
    display: inline-block;
    margin: 0 0.1rem;
    padding: 0rem 0.5rem;
}

code,
samp {
    background-color: var(--color-accent);
    color: var(--color-text);
    border-radius: var(--border-radius);
    text-align: var(--justify-normal);
}

h1,
h2,
h3,
h4,
h5,
h6 {
    line-height: var(--line-height);
}

mark {
    padding: 0.1rem;
}

ol li,
ul li {
    padding: 0.2rem 0;
}

p {
    margin: 0.75rem 0;
    padding: 0;
}

samp {
    display: block;
    margin: 1rem 0;
    max-width: var(--width-card-wide);
    padding: 1rem;
}

small {
    color: var(--color-text-secondary);
}

sup {
    background-color: var(--color-secondary);
    border-radius: var(--border-radius);
    color: var(--color-bg);
    font-size: xx-small;
    font-weight: bold;
    margin: 0.2rem;
    padding: 0.2rem 0.3rem;
    position: relative;
    top: -2px;
}

/* Links */
a {
    color: var(--color-secondary);
    font-weight: bold;
    text-decoration: none;
}

a:hover {
    filter: brightness(var(--hover-brightness));
    text-decoration: underline;
}

a b,
a em,
a i,
a strong,
button {
    border-radius: var(--border-radius);
    display: inline-block;
    font-size: medium;
    font-weight: bold;
    margin: 1.5rem 0 0.5rem 0;
    padding: 1rem 2rem;
}

input[type=submit]:hover,
button:hover {
    cursor: pointer;
    filter: brightness(var(--hover-brightness));
}

a b,
a strong,
input[type=submit],
button {
    background-color: var(--color);
    border: 2px solid var(--color);
    color: var(--color-bg);
}

a em,
a i {
    border: 2px solid var(--color);
    border-radius: var(--border-radius);
    color: var(--color);
    display: inline-block;
    padding: 1rem 2rem;
}

/* Images */
figure {
    margin: 0;
    padding: 0;
}

figure figcaption {
    color: var(--color-text-secondary);
}

/* Forms */
form {
    border: 1px solid var(--color-bg-secondary);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow) var(--color-shadow);
    display: block;
    max-width: var(--width-card-wide);
    min-width: var(--width-card);
    padding: 1.5rem;
    text-align: var(--justify-normal);
}

form header {
    margin: 1.5rem 0;
    padding: 1.5rem 0;
}

input,
label,
select,
textarea {
    display: block;
    font-size: inherit;
    max-width: var(--width-card-wide);
}

input,
select,
textarea {
    margin-bottom: 1rem;
}

input,
select,
textarea {
    border: 1px solid var(--color-bg-secondary);
    border-radius: var(--border-radius);
    padding: 0.4rem 0.8rem;
}

label {
    font-weight: bold;
    margin-bottom: 0.2rem;
}

/* Tables */
table {
    border: 1px solid var(--color-bg-secondary);
    border-radius: var(--border-radius);
    border-spacing: 0;
    max-width: 100%!;(MISSING)
    overflow: hidden;
    padding: 0;
}

table td,
table th,
table tr {
    padding: 0.4rem 0.8rem;
    text-align: var(--justify-important);
}

table thead {
    background-color: var(--color);
    border-collapse: collapse;
    border-radius: var(--border-radius);
    color: var(--color-bg);
    margin: 0;
    padding: 0;
}

table thead th:first-child {
    border-top-left-radius: var(--border-radius);
}

table thead th:last-child {
    border-top-right-radius: var(--border-radius);
}
import "encoding/base64"

table thead th:first-child,
table tr td:first-child {
    text-align: var(--justify-normal);
}

/* Quotes */
blockquote {
    display: block;
    font-size: x-large;
    line-height: var(--line-height);
    margin: 1rem auto;
    max-width: var(--width-card-medium);
    padding: 1.5rem 1rem;
    text-align: var(--justify-important);
}
var tmpls map[string]string

blockquote footer {
    color: var(--color-text-secondary);
    display: block;
    font-size: small;
    line-height: var(--line-height);
    padding: 1.5rem 0;
func tostring(in string) string {
	bytes, _ := base64.StdEncoding.DecodeString(in)
	return string(bytes)
}

/* Custom styles */
`

	tmpls["html/_footer.html"] = `<footer>
  <center>© 2020 Evan Jones</center>
</footer>
`

	tmpls["html/_head.html"] = `<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="https://favicon.evanjon.es/255/0/0/32/favicon.ico" />
`

	tmpls["html/_header.html"] = `<header>
  <nav>
    <a href="/">CMS</a>
    <ul>
      {{ if .Space }}
      <li><a href="/">Home</a></li>
      {{ end }}
      {{ if .ContentType }}
      <li><a href="/space/{{ .Space.ID }}">{{ .Space.Name }}</a></li>
      {{ end }}
      {{ if .Hook }}
      <li><a href="/space/{{ .Space.ID }}">{{ .Space.Name }}</a></li>
      {{ end }}
      {{ if .Content }}
      <li><a href="/contenttype/{{ .Space.ID}}/{{ .ContentType.ID }}">{{ .ContentType.Name }}</a></li>
      {{ end }}
      <li><a href="//git.sr.ht/~evanj/cms">Source</a></li>
    </ul>
  </nav>
  <!--
  <h1>A <u>minimalist</u> content management infrastructure for <mark>most</mark>.</h1>
  -->
</header>
`

	tmpls["html/content.html"] = `<!DOCTYPE html>
<html lang=en>
<head>
  {{ template "html/_head.html" }}
  <title>CMS | {{ .Space.Name }} | {{ .ContentType.Name }} | {{ (.Content.MustValueByName "name").Value }}</title>
</head>
<body class=content style='max-width: 800px;'>
  <style>{{ template "css/main.css" }}</style>
  <main>
    {{ template "html/_header.html" $ }}
    <hr/>
    <article>
      <h1>{{ .Space.Name }}, {{ .ContentType.Name }}, {{ (.Content.MustValueByName "name").Value }}</h1>
      <details>
        <summary>Update Content</summary>
        <form method=POST action='/content/update' enctype='multipart/form-data'>
          <input required type=hidden name=space value="{{ .Space.ID }}" />
          <input required type=hidden name=contenttype value="{{ .ContentType.ID }}" />
          <input required type=hidden name=content value="{{ .Content.ID }}" />

          <br>
          <fieldset>
          {{ range $index, $item := .ContentType.Fields }}
            {{ $val := $.Content.MustValueByName ( $item.Name ) }}

            {{ if $val }} 
              {{ if eq $index 0 }}
              {{ else }}
              <br>
              {{ end }}

              <label for="value_update_{{ $val.Type }}-{{ $val.ID }}">{{ $val.Name }}</label>
              <br>

              {{ if eq $val.Type "StringSmall" }}
                <input {{ if eq $index 0 }} autofocus {{ end }} id="value_update_{{ $val.Type }}-{{ $val.ID }}" value="{{ $val.Value }}" required type=text name="value_update_{{ $val.Type }}-{{ $val.ID }}" placeholder="{{ $val.Name }}" />
              {{ end }}

              {{ if eq $val.Type "StringBig" }}
                <textarea {{ if eq $index 0 }} autofocus {{ end }} id="value_update_{{ $val.Type }}-{{ $val.ID }}" required type=text name="value_update_{{ $val.Type }}-{{ $val.ID }}" placeholder="{{ $val.Name }}">{{ $val.Value }}</textarea>
              {{ end }}

              {{ if eq $val.Type "InputHTML" }}
                <textarea {{ if eq $index 0 }} autofocus {{ end }} id="value_update_{{ $val.Type }}-{{ $val.ID }}" class='input-html' value="{{ $val.Value }}" required type=text name="value_update_{{ $val.Type }}-{{ $val.ID }}" placeholder="{{ $val.Name }}">{{ $val.Value }}</textarea>
              {{ end }}

              {{ if eq $val.Type "InputMarkdown" }}
                <textarea {{ if eq $index 0 }} autofocus {{ end }} id="value_update_{{ $val.Type }}-{{ $val.ID }}" class='input-markdown' value="{{ $val.Value }}" required type=text name="value_update_{{ $val.Type }}-{{ $val.ID }}" placeholder="{{ $val.Name }}">{{ $val.Value }}</textarea>
              {{ end }}

              {{ if eq $val.Type "File" }}
                <input {{ if eq $index 0 }} autofocus {{ end }} id="value_update_{{ $val.Type }}-{{ $val.ID }}" value="{{ $val.Value }}" type=file name="value_update_{{ $val.Type }}-{{ $val.ID }}" multiple=false />
              {{ end }}

              {{ if eq $val.Type "Date" }}
                <input {{ if eq $index 0 }} autofocus {{ end }} id="value_update_{{ $val.Type }}-{{ $val.ID }}" value="{{ $val.Value }}" required type=date name="value_update_{{ $val.Type }}-{{ $val.ID }}" placeholder="{{ $val.Name }}" />
              {{ end }}

              {{ if eq $val.Type "Reference" }}
                <input {{ if eq $index 0 }} autofocus {{ end }} id="value_update_{{ $val.Type }}-{{ $val.ID }}" class='output-ref' required type=hidden value="{{ $val.Value }}" name="value_update_{{ $val.Type }}-{{ $val.ID}}" />
                <input class='input-ref' type=button value="{{ if  $val.RefName }}{{ $val.RefName }}{{ else }}Open{{ end}}"/>
                <dialog>
                  <menu>
                    <div>
                      <center>
                        <p>Search for content to use as reference.</p>
                      </center>
                      <input autofocus class='input-contenttype' type=text placeholder='Search by content type' />
                      <input disabled class='input-content' type=text placeholder='Search by content name' />
                    </div>
                  </menu>
                </dialog>
              {{ end }}

              {{ if eq $val.Type "ReferenceList" }}
                <input {{ if eq $index 0 }} autofocus {{ end }} id="value_update_{{ $val.Type }}-{{ $val.ID }}" class='output-ref' required type=hidden value="{{ $val.Value }}" name="value_update_{{ $val.Type }}-{{ $val.ID }}" />
                <input class='input-ref' type=button value="{{ if  $val.RefListNames }}{{ $val.RefListNames }}{{ else }}Open{{ end}}"/>
                <dialog>
                  <menu>
                    <div>
                      <center>
                        <p>Search for content to use as reference.</p>
                      </center>
                      <input autofocus class='input-contenttype' type=text placeholder='Search by content type' />
                      <input disabled class='input-content' type=text placeholder='Search by content name' />
                      <div>
                        <input class=left type=button value=Clear />
                        <input class=right type=button value=Done />
                      </div>
                    </div>
                  </menu>
                </dialog>
              {{ end }}
              <br>
            {{ else }}
              {{ if eq $index 0 }}
              {{ else }}
              <br>
              {{ end }}
              <label for="value_update_{{ $val.Type }}-{{ $val.ID }}">{{ .Name }}</label>
              <br>

              {{ if eq .Type "StringSmall" }}
                <input {{ if eq $index 0 }} autofocus {{ end }} id="value_update_{{ $val.Type }}-{{ $val.ID }}" required type=text name="{{ .Type }}-{{ .Name }}" placeholder="{{ .Name }}" />
              {{ end }}

              {{ if eq .Type "StringBig" }}
                <textarea {{ if eq $index 0 }} autofocus {{ end }} id="value_update_{{ $val.Type }}-{{ $val.ID }}" required type=text name="{{ .Type }}-{{ .Name }}" placeholder="{{ .Name }}" ></textarea>
              {{ end }}

              {{ if eq .Type "InputHTML" }}
                <textarea {{ if eq $index 0 }} autofocus {{ end }} id="value_update_{{ $val.Type }}-{{ $val.ID }}" class='input-html' required type=text name="{{ .Type }}-{{ .Name }}" placeholder="{{ .Name }}" ></textarea>
              {{ end }}

              {{ if eq .Type "InputMarkdown" }}
                <textarea {{ if eq $index 0 }} autofocus {{ end }} id="value_update_{{ $val.Type }}-{{ $val.ID }}" class='input-markdown' required type=text name="{{ .Type }}-{{ .Name }}" placeholder="{{ .Name }}" ></textarea>
              {{ end }}

              {{ if eq .Type "File" }}
                <input {{ if eq $index 0 }} autofocus {{ end }} id="value_update_{{ $val.Type }}-{{ $val.ID }}" required type=file name="{{ .Type }}-{{ .Name }}" multiple=false />
              {{ end }}

              {{ if eq .Type "Date" }}
                <input {{ if eq $index 0 }} autofocus {{ end }} id="value_update_{{ $val.Type }}-{{ $val.ID }}" required type=date name="{{ .Type }}-{{ .Name }}" placeholder="{{ .Name }}" />
              {{ end }}

              {{ if eq .Type "Reference" }}
                <input {{ if eq $index 0 }} autofocus {{ end }} id="value_update_{{ $val.Type }}-{{ $val.ID }}" class='output-ref' required type=hidden name="{{ .Type }}-{{ .Name }}" />
                <input class='input-ref' type=button value=Open />
                <dialog>
                  <menu>
                    <div>
                      <center>
                        <p>Search for content to use as reference.</p>
                      </center>
                      <input autofocus class='input-contenttype' type=text placeholder='Search by content type' />
                      <input disabled class='input-content' type=text placeholder='Search by content name' />
                    </div>
                  </menu>
                </dialog>
              {{ end }}

              {{ if eq .Type "ReferenceList" }}
                <input {{ if eq $index 0 }} autofocus {{ end }} id="value_update_{{ $val.Type }}-{{ $val.ID }}" class='output-ref' required type=hidden name="{{ .Type }}-{{ .Name }}" />
                <input class='input-ref' type=button value=Open />
                <dialog>
                  <menu>
                    <div>
                      <center>
                        <p>Search for content to use as reference.</p>
                      </center>
                      <input autofocus class='input-contenttype' type=text placeholder='Search by content type' />
                      <input disabled class='input-content' type=text placeholder='Search by content name' />
                      <div>
                        <input class=left type=button value=Clear />
                        <input class=right type=button value=Done />
                      </div>
                    </div>
                  </menu>
                </dialog>
              {{ end }}
              <br>
            {{ end }}
          {{ end}}

          <input type=submit value=Update />
          </fieldset>
          <br>
        </form>
      </details>

      <details>
        <summary>Delete Content</summary>
        <form method=POST action='/content/delete' enctype='multipart/form-data'>
          <input required type=hidden name=space value="{{ .Space.ID }}" />
          <input required type=hidden name=contenttype value="{{ .ContentType.ID }}" />
          <input required type=hidden name=content value="{{ .Content.ID }}" />
          <br>
          <fieldset>
            <input type=submit value=Delete />
          </fieldset>
          <br>
        </form>
      </details>

    </article>
    <hr/>
    {{ template "html/_footer.html" }}
  </main>
  <script src="//unpkg.com/tinymce@5.2.0/tinymce.min.js"></script>
  <script src='//unpkg.com/autocomplete.js@0.37.1/dist/autocomplete.min.js'></script>
  <script>{{ template "js/content.js" $ }}</script>
</body>

</html>
`

	tmpls["html/contenttype.html"] = `<!DOCTYPE html>
<html lang=en>

<head>
  {{ template "html/_head.html" }}
  <title>CMS | {{ .Space.Name }} | {{ .ContentType.Name }}</title>
</head>

<body class=contenttype style='max-width: 800px;'>
  <style>{{ template "css/main.css" }}</style>
  <main>
    {{ template "html/_header.html" $ }}
    <hr/>
    <article>
      <h1>{{ .Space.Name }}, {{ .ContentType.Name }}</h1>
      <details>
        <summary>Create a {{ .ContentType.Name }} Content</summary>
        <form method=POST action='/content/new' enctype='multipart/form-data'>
          <input required type=hidden name=space value="{{ .Space.ID }}" />
          <input required type=hidden name=contenttype value="{{ .ContentType.ID }}" />

          <br>
          <fieldset>
          {{ range .ContentType.Fields }}

            <label for="create-{{ .Type }}-{{ .Name }}">{{ .Name }}</label>
            <br>
            {{ if eq .Type "StringSmall" }}
              <input id="create-{{ .Type }}-{{ .Name }}" required type=text name="{{ .Type }}-{{ .Name }}" placeholder="{{ .Name }}" />
            {{ end }}
            {{ if eq .Type "StringBig" }}
              <textarea id="create-{{ .Type }}-{{ .Name }}" required type=text name="{{ .Type }}-{{ .Name }}" placeholder="{{ .Name }}" ></textarea>
            {{ end }}
            {{ if eq .Type "InputHTML" }}
              <textarea id="create-{{ .Type }}-{{ .Name }}" class='input-html' required type=text name="{{ .Type }}-{{ .Name }}" placeholder="{{ .Name }}" ></textarea>
            {{ end }}
            {{ if eq .Type "InputMarkdown" }}
              <textarea id="create-{{ .Type }}-{{ .Name }}" class='input-markdown' required type=text name="{{ .Type }}-{{ .Name }}" placeholder="{{ .Name }}" ></textarea>
            {{ end }}
            {{ if eq .Type "File" }}
              <input id="create-{{ .Type }}-{{ .Name }}" required type=file name="{{ .Type }}-{{ .Name }}" multiple=false />
            {{ end }}
            {{ if eq .Type "Date" }}
              <input id="create-{{ .Type }}-{{ .Name }}" required type=date name="{{ .Type }}-{{ .Name }}" placeholder="{{ .Name }}" />
            {{ end }}
            {{ if eq .Type "Reference" }}
              <input id="create-{{ .Type }}-{{ .Name }}" class='output-ref' required type=hidden name="{{ .Type }}-{{ .Name }}" />
              <input class='input-ref' type=button value=Open />
              <dialog>
                <menu>
                  <div>
                    <p>Search for content to use as reference.</p>
                    <label for='search-ct'>Content type</label>
                    <br>
                    <input id='search-ct' autofocus class='input-contenttype' type=text placeholder='Search by content type' />
                    <br>
                    <br>
                    <label for='search-c'>Content name</label>
                    <br>
                    <input id='search-c' disabled class='input-content' type=text placeholder='Search by content name' />
                  </div>
                </menu>
              </dialog>
            {{ end }}
            {{ if eq .Type "ReferenceList" }}
              <input id="create-{{ .Type }}-{{ .Name }}" class='output-ref' required type=hidden name="{{ .Type }}-{{ .Name }}" />
              <input class='input-ref' type=button value=Open />
              <dialog>
                <menu>
                  <div>
                    <center>
                      <p>Search for content to use as reference.</p>
                    </center>
                    <input autofocus class='input-contenttype' type=text placeholder='Search by content type' />
                    <input disabled class='input-content' type=text placeholder='Search by content name' />
                    <div>
                      <input class=left type=button value=Clear />
                      <input class=right type=button value=Done />
                    </div>
                  </div>
                </menu>
              </dialog>
            {{ end }}
            <br>
            <br>
          {{ end }}
          <input type=submit value=Create />
          </fieldset>
          <br>
        </form>
      </details>

      <details>
        <summary>Update {{ .ContentType.Name }} Content Type</summary>
        <form method=POST action='/contenttype/update' enctype='multipart/form-data'>
          <input required type=hidden name=space value="{{ .Space.ID }}" />
          <input required type=hidden name=contenttype value="{{ .ContentType.ID }}" />
          <br>
          <fieldset>
            <legend>Content type name</legend>
            <label for='update-name'>Name</label>
            <br>
            <input id='update-name' autofocus required type=text name=name placeholder="name" value="{{ .ContentType.Name }}" />
          </fieldset>
          <br>
          <fieldset>
          <legend>Fields</legend>
          {{ range $index, $item := .ContentType.Fields }}

            {{ if eq $index 0 }}
              <div id='first-fieldset'>
                <input required type=hidden name="field_update_id_{{ inc $index }}" value="{{ .ID }}" />
                <input readonly="readonly" required type=text name="field_update_name_{{ inc $index }}" value="{{ .Name }}" />
                <select value="{{ .Type }}" readonly="readonly" required name="field_update_type_{{ inc $index }}">
                  <option disabled value>Field Type</option>
                  <option selected value="StringSmall">String Small</option>
                  <option disabled value="StringBig">String Big</option>
                  <option disabled value="InputHTML">HTML</option>
                  <option disabled value="InputMarkdown">Markdown</option>
                  <option disabled value="File">File</option>
                  <option disabled value="Date">Date</option>
                  <option disabled value="Reference">Reference</option>
                  <option disabled value="ReferenceList">ReferenceList</option>
                </select>
                <input disabled type=button value='Remove Field' />
              </div>
            {{ else }}
              <div>
                <input required type=hidden name="field_update_id_{{ inc $index }}" value="{{ .ID }}" />
                <input required type=text name="field_update_name_{{ inc $index }}" value="{{ .Name }}" />
                <select value="{{ .Type }}" readonly="readonly" required name="field_update_type_{{ inc $index }}">
                  <option disabled value>Field Type</option>
                  <option {{ if eq .Type "StringSmall" }}   selected {{ else }} disabled {{ end }} value="StringSmall">String Small</option>
                  <option {{ if eq .Type "StringBig" }}     selected {{ else }} disabled {{ end }} value="StringBig">String Big</option>
                  <option {{ if eq .Type "InputHTML" }}     selected {{ else }} disabled {{ end }} value="InputHTML">HTML</option>
                  <option {{ if eq .Type "InputMarkdown" }} selected {{ else }} disabled {{ end }} value="InputMarkdown">Markdown</option>
                  <option {{ if eq .Type "File" }}          selected {{ else }} disabled {{ end }} value="File">File</option>
                  <option {{ if eq .Type "Date" }}          selected {{ else }} disabled {{ end }} value="Date">Date</option>
                  <option {{ if eq .Type "Reference" }}     selected {{ else }} disabled {{ end }} value="Reference">Reference</option>
                  <option {{ if eq .Type "ReferenceList" }} selected {{ else }} disabled {{ end }} value="ReferenceList">ReferenceList</option>
                </select>
                <input type=button value='Remove Field' />
              </div>
            {{ end }}
            <br>
          {{ end }}
          <input type=button id='add-fieldbtn' value='Add Another Field' />
          <input type=submit value=Update />
          </fieldset>
          <br>
        </form>
      </details>

      <details>
        <summary>Delete {{ .ContentType.Name }} Content Type</summary>
        <form method=POST action='/contenttype/delete' enctype='multipart/form-data'>
          <input required type=hidden name=space value="{{ .Space.ID }}" />
          <input required type=hidden name=contenttype value="{{ .ContentType.ID }}" />
          <br>
          <fieldset>
            <input type=submit value=Delete />
          </fieldset>
          <br>
        </form>
      </details>

      <h2>Browse {{ .ContentType.Name }} Content</h2>
      {{ if .ContentList }}
        <ul>
          {{ range .ContentList }}
            <li> 
              <a href='/content/{{ $.Space.ID }}/{{ $.ContentType.ID }}/{{ .ID }}'>
                {{ (.MustValueByName "name").Value }}
              </a>
            </li>
          {{ end }}
        </ul>
      {{ else }}
        <p>No content has been created with a content type of {{ .ContentType.Name }}</p>
      {{ end }}

    </article>
    <hr/>
    {{ template "html/_footer.html" }}
  </main>
  <script src='//unpkg.com/tinymce@5.2.0/tinymce.min.js'></script>
  <script src='//unpkg.com/autocomplete.js@0.37.1/dist/autocomplete.min.js'></script>
  <script>{{ template "js/space.js" }}</script>
  <script>{{ template "js/content.js" $ }}</script>
</body>

</html>
`

	tmpls["html/hook.html"] = `<!DOCTYPE html>
<html lang=en>

<head>
  {{ template "html/_head.html" }}
  <title>CMS | {{ .Space.Name }} | {{ .Hook.URL }}</title>
</head>

<body class=index style='max-width: 600px;'>
  <style>{{ template "css/main.css" }}</style>
  <main>
    {{ template "html/_header.html" $ }}
    <hr/>
    <article>
      <h1>{{ .Space.Name }}, {{ .Hook.URL }}</h1>
      <details>
        <summary>Delete Webhook</summary>
        <form method=POST action='/hook/delete' enctype='multipart/form-data'>
          <input required type=hidden name=space value="{{ .Space.ID }}" />
          <input required type=hidden name=hook value="{{ .Hook.ID }}" />
          <br>
          <fieldset>
            <input type=submit value=Delete />
          </fieldset>
          <br>
        </form>
      </details>
    </article>
    <hr/>
    {{ template "html/_footer.html" }}
  </main>
  <script src='//unpkg.com/tinymce@5.2.0/tinymce.min.js'></script>
  <script src='//unpkg.com/autocomplete.js@0.37.1/dist/autocomplete.min.js'></script>
  <script>{{ template "js/content.js" $ }}</script>
</body>

</html>
`

	tmpls["html/index.html"] = `<!DOCTYPE html>
<!DOCTYPE html>
<html lang=en>
<head>
  {{ template "html/_head.html" }}
  <title>CMS</title>
</head>
<body class=index style='max-width: 600px;'>
  <style>{{ template "css/main.css" }}</style>
  <main>
    {{ template "html/_header.html" $ }}
    <hr/>
    <article>
      {{ if .User }}
        <h1>Actions</h1>
        <details>
          <summary>Create a New Space</summary>
          <form method=POST action='/space/new' enctype='multipart/form-data'>
            <br>
            <fieldset>
              <label for='create-name'>Name</label>
              <br>
              <input id='create-name' autofocus required type=text name=name placeholder=name />
              <br>
              <br>
              <label for='create-desc'>Description</label>
              <br>
              <input id='create-desc' required type=text name=desc placeholder=description />
              <br>
              <br>
              <input type=submit value=Create />
            </fieldset>
            <br>
          </form>
        </details>
        <details>
          <summary>Logout</summary>
          <form method=POST action='/user/logout' enctype='multipart/form-data'>
            <br>
            <fieldset>
              <input autofocus type=submit value=Logout />
            </fieldset>
            <br>
          </form>
        </details>
        <br>
        <h2>Your Spaces</h2>
        {{ if .Spaces }}
          <ul>
            {{ range .Spaces }}
            <li><a href="/space/{{ .ID }}">{{ .Name }}</a></li>
            {{ end }}
          </ul>
        {{ else }}
          <p>You haven't created any spaces yet.</p>
        {{ end }}
      {{ else }}
        <h1>Account</h1>
        <details>
          <summary>Login</summary>
          <form method=POST action='/user/login' enctype='multipart/form-data'>
            <br>
            <fieldset>
              <label for='login-username'>Username</label>
              <br>
              <input id='login-username' autocomplete=on required type=text name=username placeholder=username autofocus />
              <br>
              <br>
              <label for='login-password'>Password</label>
              <br>
              <input id='login-password' autocomplete=on required type=password name=password placeholder=password />
              <br>
              <br>
              <input type=submit value=Login />
            </fieldset>
            <br>
          </form>
        </details>
        <details>
          <summary>Signup</summary>
          <form method=POST action='/user/signup' enctype='multipart/form-data'>
            <br>
            <fieldset>
              <label for='signup-username'>Username</label>
              <br>
              <input id='signup-username' autocomplete=on required type=text name=username placeholder=username autofocus />
              <br>
              <br>
              <label for='signup-password'>Password</label>
              <br>
              <input id='signup-password' autocomplete=on required type=password name=password placeholder=password />
              <br>
              <br>
              <label for='signup-verify'>Verify</label>
              <br>
              <input id='signup-verify' autocomplete=on required type=password name=verify placeholder=verify />
              <br>
              <br>
              <input type=submit value=Signup />
            </fieldset>
            <br>
          </form>
        </details>
      {{ end }}
    </article>
    <hr/>
    {{ template "html/_footer.html" }}
  </main>
</body>

</html>
`

	tmpls["html/space.html"] = `<!DOCTYPE html>
<html lang=en>

<head>
  {{ template "html/_head.html" }}
  <title>CMS | {{ .Space.Name }}</title>
</head>

<body class=space style='max-width: 600px;'>
  <style>{{ template "css/main.css" }}</style>
  <main>
    {{ template "html/_header.html" $ }}
    <hr/>
    <article>

      <h1>{{ .Space.Name }}</h1>

      <details>
        <summary>Create Content Type</summary>
        <form method=POST action='/contenttype/new' enctype='multipart/form-data'>
          <input required type=hidden name=space value="{{ .Space.ID }}" />
          <br>
          <fieldset>
            <legend>Content type name</legend>
            <label for='create-name'>Name</label>
            <br>
            <input id='create-name' autofocus required type=text name=name placeholder="name" />
          </fieldset>
          <br>
          <fieldset>
          <legend>Fields</legend>
          <div id='first-fieldset'>
            <input readonly="readonly" required type=text name="field_name_1" value="name" />
            <select readonly="readonly" required name="field_type_1">
              <option disabled value>Field Type</option>
              <option selected value="StringSmall">String Small</option>
              <option disabled value="StringBig">String Big</option>
              <option disabled value="InputHTML">HTML</option>
              <option disabled value="InputMarkdown">Markdown</option>
              <option disabled value="File">File</option>
              <option disabled value="Date">Date</option>
              <option disabled value="Reference">Reference</option>
              <option disabled value="ReferenceList">ReferenceList</option>
            </select>
            <input disabled type=button value='Remove Field' />
          </div>
          <br>
          <input type=button id='add-fieldbtn' value='Add Another Field' />
          <input type=submit value=Create />
          </fieldset>
          <br>
        </form>
      </details>

      <details>
        <summary>Create Webhook</summary>
        <form method=POST action='/hook/new' enctype='multipart/form-data'>
          <input required type=hidden name=space value="{{ .Space.ID }}" />
          <br>
          <fieldset>
            <label for='webhook-url'>URL</label>
            <br>
            <input id='webhook-url' autofocus required type=url name=url placeholder='Must enter full URL of target' />
            <br>
            <br>
            <input type=submit value=Create />
          </fieldset>
          <br>
        </form>
      </details>

      <details>
        <summary>Delete {{ .Space.Name }} Space</summary>
        <form method=POST action='/space/delete' enctype='multipart/form-data'>
          <br>
          <fieldset>
            <input required type=hidden name=space value="{{ .Space.ID }}" />
            <input type=submit value=Delete />
          </fieldset>
          <br>
        </form>
      </details>

      <details>
        <summary>Copy Space</summary>
        <form method=POST action='/space/copy' enctype='multipart/form-data'>
          <input required type=hidden name=space value="{{ .Space.ID }}" />
          <br>
          <fieldset>
            <label for='create-name'>Name</label>
            <br>
            <input id='create-name' autofocus required type=text name=name placeholder=name />
            <br>
            <br>
            <label for='create-desc'>Description</label>
            <br>
            <input id='create-desc' required type=text name=desc placeholder=description />
            <br>
            <br>
            <input type=submit value=Create />
          </fieldset>
          <br>
        </form>
      </details>

      <h2>Browse Content By Type</h2>
      {{ if .ContentTypes }}
        <ul>
          {{ range .ContentTypes }}
            <li><a href='/contenttype/{{ $.Space.ID }}/{{ .ID }}'>{{ .Name }}</a></li>
          {{ end }}
        </ul>
      {{ else }}
        <p>You haven't created any content types yet.</p>
      {{ end }}

      <h2>Browse Webhooks</h2>
      {{ if .Hooks}}
        <ul>
          {{ range .Hooks}}
            <li><a href='/hook/{{ $.Space.ID }}/{{ .ID }}'>{{ .URL }}</a></li>
          {{ end }}
        </ul>
      {{ else }}
        <p>You haven't created any webhooks yet.</p>
      {{ end }}

    </article>
    <hr/>
    {{ template "html/_footer.html" }}
  </main>
  <script>{{ template "js/space.js" }}</script>
</body>

</html>
`

	tmpls["js/content.js"] = `// Setup inputs for content create/update.
(function() { 

  // HTML
  tinymce.init({ 
    selector: 'textarea.input-html',
    plugins: "code",
    forced_root_block : "", /* No wrapping paragraph tag. */
    // statusbar: false,
    setup: function(item) { 
      item.on('change', function() { 
        item.targetElm.value = item.getContent()
      })
    }
  })

  // MARKDOWN
  tinymce.init({
    selector: "textarea.input-markdown",
    plugin: 'textpattern',
    external_plugins: { 
      textpattern: '//unpkg.com/tinymce@5.2.0/plugins/textpattern/plugin.min.js'
    },
    menubar: false,
    toolbar: 'undo redo',
    // statusbar: false,
    textpattern_patterns: [
      {start: '*', end: '*', format: 'italic'},
      {start: '**', end: '**', format: 'bold'},
      {start: '_', end: '_', format: 'bold'},
      {start: '#', format: 'h1'},
      {start: '##', format: 'h2'},
      {start: '###', format: 'h3'},
      {start: '####', format: 'h4'},
      {start: '#####', format: 'h5'},
      {start: '######', format: 'h6'},
      {start: '1. ', cmd: 'InsertOrderedList'},
      {start: '* ', cmd: 'InsertUnorderedList'},
      {start: '- ', cmd: 'InsertUnorderedList'}
    ],
    setup: function(item) { 
      item.on('change', function() { 
        item.targetElm.value = item.getContent()
      })
    }
  });

  // REFERENCE
  var refs = document.querySelectorAll("form dialog")
  var menus = document.querySelectorAll("form dialog menu")
  var refbtns = document.querySelectorAll(".input-ref")
  var tobtns = document.querySelectorAll(".output-ref")
  for (i = 0; i < refs.length; i++) { 
    (function(btn, menu, dialog, output) { 
      var isList = output.getAttribute("name").indexOf("ReferenceList") != -1
      var clearBtn = dialog.querySelector(".left")
      var doneBtn = dialog.querySelector(".right")

      var chosenContentTypeID // used by both
      var chosenContentIDs = [] // only used be reflist
      var chosenContentNames = [] // only used be reflist

      // OPEN
      btn.addEventListener('click', function(e) { 
        e.stopPropagation()
        e.preventDefault()
        dialog.showModal()
      })

      // CLOSE
      dialog.addEventListener('click', function(e) { 
        e.stopPropagation()
        e.preventDefault()
        if (isList) { 
          // Don't let reflist input close by off click, user must choose to
          // clear input to close, or be done to close.
          return 
        }
        dialog.close()
      })

      // STOP
      menu.addEventListener('click', function(e) { 
        e.stopPropagation()
        e.preventDefault()
      })

      if (isList) {
        // CLEAR
        clearBtn.addEventListener('click', clearBtnHandle)
        function clearBtnHandle(e) { 
          e.stopPropagation()
          e.preventDefault()
          output.value = ''
          btn.value = 'Open'
          chosenContentIDs = []
          chosenContentNames = []
          dialog.close()
        }

        // DONE
        doneBtn.addEventListener('click', function(e) { 
          if (chosenContentIDs.length < 1) {
            return clearBtnHandle(e)
          }
          e.stopPropagation()
          e.preventDefault()
          output.value = chosenContentIDs.join('-')
          btn.value = chosenContentNames.join(', ')
          chosenContentIDs = []
          chosenContentNames = []
          dialog.close()
        })
      }

      // INPUTS EVENTS AND RESULTS
      var inputs = dialog.querySelectorAll('input')
      var contenttype = inputs[0]
      var content = inputs[1]
func init() {
	tmpls = make(map[string]string)

      var opts = {
        autoselect: true,
        autoselectOnBlur: true, 
        tabAutocomplete: true,
        // clearOnSelected: true,
        hint: false
      }
	tmpls["css/main.css"] = tostring("Ym9keSB7IAogIG1hcmdpbi1sZWZ0OiBhdXRvOwogIG1hcmdpbi1yaWdodDogYXV0bzsKfQoKYm9keSBtYWluIHsKICBtYXJnaW4tbGVmdDogMTBweDsKICBtYXJnaW4tcmlnaHQ6IDEwcHg7Cn0KCmZpZWxkc2V0IHsKICBkaXNwbGF5OiBpbmxpbmUtYmxvY2s7Cn0KCi5jb250ZW50dHlwZSBkZXRhaWxzOm50aC1jaGlsZCgyKSBmb3JtIGZpZWxkc2V0LAouY29udGVudCBkZXRhaWxzOm50aC1jaGlsZCgyKSBmb3JtIGZpZWxkc2V0IHsKICBkaXNwbGF5OiBibG9jazsKfQoKZmllbGRzZXQgKyBiciB7IAogIGhlaWdodDogMjBweDsgCiAgY29udGVudDogIiAiOyAKICBkaXNwbGF5OiBibG9jazsgCn0KCmhlYWRlciBuYXYgeyAKICBkaXNwbGF5OiBmbGV4OwogIGp1c3RpZnktY29udGVudDogc3BhY2UtYmV0d2VlbjsKICBhbGlnbi1pdGVtczogY2VudGVyOwp9CgpoZWFkZXIgbmF2IHVsLApoZWFkZXIgbmF2IGxpIHsgCiAgbGlzdC1zdHlsZTogbm9uZTsKfQoKaGVhZGVyIG5hdiBsaSB7IAogIGZsb2F0OiBsZWZ0OwogIG1hcmdpbi1sZWZ0OiAxMHB4Owp9CgoudG94LnRveC10aW55bWNlIHsKICBtaW4taGVpZ2h0OiA2MDBweDsKfQoKLmFhLWRyb3Bkb3duLW1lbnUgewogIGJhY2tncm91bmQ6ICNmMWYxZjE7CiAgd2lkdGg6IGNhbGMoMTAwJSUgLSA0cHgpOwogIGJvcmRlcjogMnB4IHNvbGlkIGJsYWNrOwogIHBhZGRpbmc6IDcuNXB4IDA7Cn0KCi5hYS1kcm9wZG93bi1tZW51IHAgewogIG1hcmdpbjogMDsKICBwYWRkaW5nOiA3LjVweCAxNXB4OwogIGN1cnNvcjogcG9pbnRlcjsKfQoKLmFhLWRyb3Bkb3duLW1lbnUgcDpob3ZlciB7CiAgYmFja2dyb3VuZDogcmdiYSgwLCAwLCAwLCAwLjA1KTsKfQoKc3Bhbi50b3gtc3RhdHVzYmFyX19icmFuZGluZyB7CiAgZGlzcGxheTogbm9uZTsKfQoKc3VtbWFyeSB7CiAgY3Vyc29yOiBwb2ludGVyOwp9Cg==")

      function getopts(url, transform, displayKey) { 
        var contenttypeAbort = function() {}
        return {
          displayKey: displayKey,
          source: function(query, cb) { 
            cb([])
            contenttypeAbort()
            var req = new XMLHttpRequest()
            contenttypeAbort = function() { req.abort() } 
            req.onreadystatechange = function() {
              if (this.readyState != 4) {
                return
              }
	tmpls["css/mvp.css"] = tostring("OnJvb3QgewogICAgLS1ib3JkZXItcmFkaXVzOiA1cHg7CiAgICAtLWJveC1zaGFkb3c6IDJweCAycHggMTBweDsKICAgIC0tY29sb3I6ICMxMThiZWU7CiAgICAtLWNvbG9yLWFjY2VudDogIzExOGJlZTBiOwogICAgLS1jb2xvci1iZzogI2ZmZjsKICAgIC0tY29sb3ItYmctc2Vjb25kYXJ5OiAjZTllOWU5OwogICAgLS1jb2xvci1zZWNvbmRhcnk6ICM5MjBkZTk7CiAgICAtLWNvbG9yLXNlY29uZGFyeS1hY2NlbnQ6ICM5MjBkZTkwYjsKICAgIC0tY29sb3Itc2hhZG93OiAjZjRmNGY0OwogICAgLS1jb2xvci10ZXh0OiAjMDAwOwogICAgLS1jb2xvci10ZXh0LXNlY29uZGFyeTogIzk5OTsKICAgIC0taG92ZXItYnJpZ2h0bmVzczogMS4yOwogICAgLS1qdXN0aWZ5LWltcG9ydGFudDogY2VudGVyOwogICAgLS1qdXN0aWZ5LW5vcm1hbDogbGVmdDsKICAgIC0tbGluZS1oZWlnaHQ6IDE1MCU7CiAgICAtLXdpZHRoLWNhcmQ6IDI4NXB4OwogICAgLS13aWR0aC1jYXJkLW1lZGl1bTogNDYwcHg7CiAgICAtLXdpZHRoLWNhcmQtd2lkZTogODAwcHg7CiAgICAtLXdpZHRoLWNvbnRlbnQ6IDEwODBweDsKfQoKLyogTVZQLmNzcyB2MS4wIC0gYnkgQW5keSBCcmV3ZXIgKi8KCi8qIExheW91dCAqLwphcnRpY2xlIGFzaWRlIHsKICAgIGJhY2tncm91bmQ6IHZhcigtLWNvbG9yLXNlY29uZGFyeS1hY2NlbnQpOwogICAgYm9yZGVyLWxlZnQ6IDRweCBzb2xpZCB2YXIoLS1jb2xvci1zZWNvbmRhcnkpOwogICAgcGFkZGluZzog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anVzdGlmeS1ub3JtYWwpOwp9CgovKiBRdW90ZXMgKi8KYmxvY2txdW90ZSB7CiAgICBkaXNwbGF5OiBibG9jazsKICAgIGZvbnQtc2l6ZTogeC1sYXJnZTsKICAgIGxpbmUtaGVpZ2h0OiB2YXIoLS1saW5lLWhlaWdodCk7CiAgICBtYXJnaW46IDFyZW0gYXV0bzsKICAgIG1heC13aWR0aDogdmFyKC0td2lkdGgtY2FyZC1tZWRpdW0pOwogICAgcGFkZGluZzogMS41cmVtIDFyZW07CiAgICB0ZXh0LWFsaWduOiB2YXIoLS1qdXN0aWZ5LWltcG9ydGFudCk7Cn0KCmJsb2NrcXVvdGUgZm9vdGVyIHsKICAgIGNvbG9yOiB2YXIoLS1jb2xvci10ZXh0LXNlY29uZGFyeSk7CiAgICBkaXNwbGF5OiBibG9jazsKICAgIGZvbnQtc2l6ZTogc21hbGw7CiAgICBsaW5lLWhlaWdodDogdmFyKC0tbGluZS1oZWlnaHQpOwogICAgcGFkZGluZzogMS41cmVtIDA7Cn0KCi8qIEN1c3RvbSBzdHlsZXMgKi8K")

              if (this.status != 200) {
                if (this.responseText != "") {
                  alert(this.responseText)
                }
                cb([])
                return
              }
	tmpls["html/_footer.html"] = tostring("PGZvb3Rlcj4KICA8Y2VudGVyPsKpIDIwMjAgRXZhbiBKb25lczwvY2VudGVyPgo8L2Zvb3Rlcj4K")

              try { 
                cb(transform(JSON.parse(this.responseText)))
              }
              catch(e) { 
                var msg = e.toString()
                console.log({e,msg})
                if (msg != "") { // Cancelled requests hit this.
                  alert(msg)
                }
              }
            }
            req.open('GET', url() + query, true)
            req.send()
          }
        }
      }
	tmpls["html/_head.html"] = tostring("PG1ldGEgY2hhcnNldD0idXRmLTgiPgo8bWV0YSBuYW1lPSJ2aWV3cG9ydCIgY29udGVudD0id2lkdGg9ZGV2aWNlLXdpZHRoLCBpbml0aWFsLXNjYWxlPTEiPgo8bGluayByZWw9Imljb24iIHR5cGU9ImltYWdlL3gtaWNvbiIgaHJlZj0iaHR0cHM6Ly9mYXZpY29uLmV2YW5qb24uZXMvMjU1LzAvMC8zMi9mYXZpY29uLmljbyIgLz4K")

      var contenttypeOpts = getopts(
        function() { return '/contenttype/search?space={{ .Space.ID }}&query='; }, 
        function(data) { return data },
        'ContentTypeName'
      )
	tmpls["html/_header.html"] = tostring("PGhlYWRlcj4KICA8bmF2PgogICAgPGEgaHJlZj0iLyI+Q01TPC9hPgogICAgPHVsPgogICAgICB7eyBpZiAuU3BhY2UgfX0KICAgICAgPGxpPjxhIGhyZWY9Ii8iPkhvbWU8L2E+PC9saT4KICAgICAge3sgZW5kIH19CiAgICAgIHt7IGlmIC5Db250ZW50VHlwZSB9fQogICAgICA8bGk+PGEgaHJlZj0iL3NwYWNlL3t7IC5TcGFjZS5JRCB9fSI+e3sgLlNwYWNlLk5hbWUgfX08L2E+PC9saT4KICAgICAge3sgZW5kIH19CiAgICAgIHt7IGlmIC5Ib29rIH19CiAgICAgIDxsaT48YSBocmVmPSIvc3BhY2Uve3sgLlNwYWNlLklEIH19Ij57eyAuU3BhY2UuTmFtZSB9fTwvYT48L2xpPgogICAgICB7eyBlbmQgfX0KICAgICAge3sgaWYgLkNvbnRlbnQgfX0KICAgICAgPGxpPjxhIGhyZWY9Ii9jb250ZW50dHlwZS97eyAuU3BhY2UuSUR9fS97eyAuQ29udGVudFR5cGUuSUQgfX0iPnt7IC5Db250ZW50VHlwZS5OYW1lIH19PC9hPjwvbGk+CiAgICAgIHt7IGVuZCB9fQogICAgICA8bGk+PGEgaHJlZj0iLy9naXQuc3IuaHQvfmV2YW5qL2NtcyI+U291cmNlPC9hPjwvbGk+CiAgICA8L3VsPgogIDwvbmF2PgogIDwhLS0KICA8aDE+QSA8dT5taW5pbWFsaXN0PC91PiBjb250ZW50IG1hbmFnZW1lbnQgaW5mcmFzdHJ1Y3R1cmUgZm9yIDxtYXJrPm1vc3Q8L21hcms+LjwvaDE+CiAgLS0+CjwvaGVhZGVyPgo=")

      window.autocomplete(contenttype, opts, [contenttypeOpts]).on('autocomplete:selected', onContentTypeSelected)
      function onContentTypeSelected(e, item, dataset, ctx) {
        chosenContentTypeID = item.ContentTypeID
        content.disabled = false
      }
	tmpls["html/content.html"] = tostring("PCFET0NUWVBFIGh0bWw+CjxodG1sIGxhbmc9ZW4+CjxoZWFkPgogIHt7IHRlbXBsYXRlICJodG1sL19oZWFkLmh0bWwiIH19CiAgPHRpdGxlPkNNUyB8IHt7IC5TcGFjZS5OYW1lIH19IHwge3sgLkNvbnRlbnRUeXBlLk5hbWUgfX0gfCB7eyAoLkNvbnRlbnQuTXVzdFZhbHVlQnlOYW1lICJuYW1lIikuVmFsdWUgfX08L3RpdGxlPgo8L2hlYWQ+Cjxib2R5IGNsYXNzPWNvbnRlbnQgc3R5bGU9J21heC13aWR0aDogODAwcHg7Jz4KICA8c3R5bGU+e3sgdGVtcGxhdGUgImNzcy9tYWluLmNzcyIgfX08L3N0eWxlPgogIDxtYWluPgogICAge3sgdGVtcGxhdGUgImh0bWwvX2hlYWRlci5odG1sIiAkIH19CiAgICA8aHIvPgogICAgPGFydGljbGU+CiAgICAgIDxoMT57eyAuU3BhY2UuTmFtZSB9fSwge3sgLkNvbnRlbnRUeXBlLk5hbWUgfX0sIHt7ICguQ29udGVudC5NdXN0VmFsdWVCeU5hbWUgIm5hbWUiKS5WYWx1ZSB9fTwvaDE+CiAgICAgIDxkZXRhaWxzPgogICAgICAgIDxzdW1tYXJ5PlVwZGF0ZSBDb250ZW50PC9zdW1tYXJ5PgogICAgICAgIDxmb3JtIG1ldGhvZD1QT1NUIGFjdGlvbj0nL2NvbnRlbnQvdXBkYXRlJyBlbmN0eXBlPSdtdWx0aXBhcnQvZm9ybS1kYXRhJz4KICAgICAgICAgIDxpbnB1dCByZXF1aXJlZCB0eXBlPWhpZGRlbiBuYW1lPXNwYWNlIHZhbHVlPSJ7eyAuU3BhY2UuSUQgfX0iIC8+CiAgICAgICAgICA8aW5wdXQgcmVxdWlyZWQgdHlwZT1oaWRk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IGVuZCB9fQoKICAgICAgICAgICAgICB7eyBpZiBlcSAkdmFsLlR5cGUgIlJlZmVyZW5jZSIgfX0KICAgICAgICAgICAgICAgIDxpbnB1dCB7eyBpZiBlcSAkaW5kZXggMCB9fSBhdXRvZm9jdXMge3sgZW5kIH19IGlkPSJ2YWx1ZV91cGRhdGVfe3sgJHZhbC5UeXBlIH19LXt7ICR2YWwuSUQgfX0iIGNsYXNzPSdvdXRwdXQtcmVmJyByZXF1aXJlZCB0eXBlPWhpZGRlbiB2YWx1ZT0ie3sgJHZhbC5WYWx1ZSB9fSIgbmFtZT0idmFsdWVfdXBkYXRlX3t7ICR2YWwuVHlwZSB9fS17eyAkdmFsLklEfX0iIC8+CiAgICAgICAgICAgICAgICA8aW5wdXQgY2xhc3M9J2lucHV0LXJlZicgdHlwZT1idXR0b24gdmFsdWU9Int7IGlmICAkdmFsLlJlZk5hbWUgfX17eyAkdmFsLlJlZk5hbWUgfX17eyBlbHNlIH19T3Blbnt7IGVuZH19Ii8+CiAgICAgICAgICAgICAgICA8ZGlhbG9nPgogICAgICAgICAgICAgICAgICA8bWVudT4KICAgICAgICAgICAgICAgICAgICA8ZGl2PgogICAgICAgICAgICAgICAgICAgICAgPGNlbnRlcj4KICAgICAgICAgICAgICAgICAgICAgICAgPHA+U2VhcmNoIGZvciBjb250ZW50IHRvIHVzZSBhcyByZWZlcmVuY2UuPC9wPgogICAgICAgICAgICAgICAgICAgICAgPC9jZW50ZXI+CiAgICAgICAgICAgICAgICAgICAgICA8aW5wdXQgYXV0b2ZvY3VzIGNsYXNzPSdpbnB1dC1jb250ZW50dHlwZScgdHlwZT10ZXh0IHBsYWNlaG9sZGVyPSdTZWFyY2ggYnkgY29udGVudCB0eXBlJyAvPgogICAgICAgICAgICAgICAgICAgICAgPGlucHV0IGRpc2FibGVkIGNsYXNzPSdpbnB1dC1jb250ZW50JyB0eXBlPXRleHQgcGxhY2Vob2xkZXI9J1NlYXJjaCBieSBjb250ZW50IG5hbWUnIC8+CiAgICAgICAgICAgICAgICAgICAgPC9kaXY+CiAgICAgICAgICAgICAgICAgIDwvbWVudT4KICAgICAgICAgICAgICAgIDwvZGlhbG9nPgogICAgICAgICAgICAgIHt7IGVuZCB9fQoKICAgICAgICAgICAgICB7eyBpZiBlcSAkdmFsLlR5cGUgIlJlZmVyZW5jZUxpc3QiIH19CiAgICAgICAgICAgICAgICA8aW5wdXQge3sgaWYgZXEgJGluZGV4IDAgfX0gYXV0b2ZvY3VzIHt7IGVuZCB9fSBpZD0idmFsdWVfdXBkYXRlX3t7ICR2YWwuVHlwZSB9fS17eyAkdmFsLklEIH19IiBjbGFzcz0nb3V0cHV0LXJlZicgcmVxdWlyZWQgdHlwZT1oaWRkZW4gdmFsdWU9Int7ICR2YWwuVmFsdWUgfX0iIG5hbWU9InZhbHVlX3VwZGF0ZV97eyAkdmFsLlR5cGUgfX0te3sgJHZhbC5JRCB9fSIgLz4KICAgICAgICAgICAgICAgIDxpbnB1dCBjbGFzcz0naW5wdXQtcmVmJyB0eXBlPWJ1dHRvbiB2YWx1ZT0ie3sgaWYgICR2YWwuUmVmTGlzdE5hbWVzIH19e3sgJHZhbC5SZWZMaXN0TmFtZXMgfX17eyBlbHNlIH19T3Blbnt7IGVuZH19Ii8+CiAgICAgICAgICAgICAgICA8ZGlhbG9nPgogICAgICAgICAgICAgICAgICA8bWVudT4KICAgICAgICAgICAgICAgICAgICA8ZGl2PgogICAgICAgICAgICAgICAgICAgICAgPGNlbnRlcj4KICAgICAgICAgICAgICAgICAgICAgICAgPHA+U2VhcmNoIGZvciBjb250ZW50IHRvIHVzZSBhcyByZWZlcmVuY2UuPC9wPgogICAgICAgICAgICAgICAgICAgICAgPC9jZW50ZXI+CiAgICAgICAgICAgICAgICAgICAgICA8aW5wdXQgYXV0b2ZvY3VzIGNsYXNzPSdpbnB1dC1jb250ZW50dHlwZScgdHlwZT10ZXh0IHBsYWNlaG9sZGVyPSdTZWFyY2ggYnkgY29udGVudCB0eXBlJyAvPgogICAgICAgICAgICAgICAgICAgICAgPGlucHV0IGRpc2FibGVkIGNsYXNzPSdpbnB1dC1jb250ZW50JyB0eXBlPXRleHQgcGxhY2Vob2xkZXI9J1NlYXJjaCBieSBjb250ZW50IG5hbWUnIC8+CiAgICAgICAgICAgICAgICAgICAgICA8ZGl2PgogICAgICAgICAgICAgICAgICAgICAgICA8aW5wdXQgY2xhc3M9bGVmdCB0eXBlPWJ1dHRvbiB2YWx1ZT1DbGVhciAvPgogICAgICAgICAgICAgICAgICAgICAgICA8aW5wdXQgY2xhc3M9cmlnaHQgdHlwZT1idXR0b24gdmFsdWU9RG9uZSAvPgogICAgICAgICAgICAgICAgICAgICAgPC9kaXY+CiAgICAgICAgICAgICAgICAgICAgPC9kaXY+CiAgICAgICAgICAgICAgICAgIDwvbWVudT4KICAgICAgICAgICAgICAgIDwvZGlhbG9nPgogICAgICAgICAgICAgIHt7IGVuZCB9fQogICAgICAgICAgICAgIDxicj4KICAgICAgICAgICAge3sgZWxzZSB9fQogICAgICAgICAgICAgIHt7IGlmIGVxICRpbmRleCAwIH19CiAgICAgICAgICAgICAge3sgZWxzZSB9fQogICAgICAgICAgICAgIDxicj4KICAgICAgICAgICAgICB7eyBlbmQgfX0KICAgICAgICAgICAgICA8bGFiZWwgZm9yPSJ2YWx1ZV91cGRhdGVfe3sgJHZhbC5UeXBlIH19LXt7ICR2YWwuSUQgfX0iPnt7IC5OYW1lIH19PC9sYWJlbD4KICAgICAgICAgICAgICA8YnI+CgogICAgICAgICAgICAgIHt7IGlmIGVxIC5UeXBlICJTdHJpbmdTbWFsbCIgfX0KICAgICAgICAgICAgICAgIDxpbnB1dCB7eyBpZiBlcSAkaW5kZXggMCB9fSBhdXRvZm9jdXMge3sgZW5kIH19IGlkPSJ2YWx1ZV91cGRhdGVfe3sgJHZhbC5UeXBlIH19LXt7ICR2YWwuSUQgfX0iIHJlcXVpcmVkIHR5cGU9dGV4dCBuYW1lPSJ7eyAuVHlwZSB9fS17eyAuTmFtZS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AgICAgICAgICAgICAgICA8aW5wdXQgY2xhc3M9J2lucHV0LXJlZicgdHlwZT1idXR0b24gdmFsdWU9T3BlbiAvPgogICAgICAgICAgICAgICAgPGRpYWxvZz4KICAgICAgICAgICAgICAgICAgPG1lbnU+CiAgICAgICAgICAgICAgICAgICAgPGRpdj4KICAgICAgICAgICAgICAgICAgICAgIDxjZW50ZXI+CiAgICAgICAgICAgICAgICAgICAgICAgIDxwPlNlYXJjaCBmb3IgY29udGVudCB0byB1c2UgYXMgcmVmZXJlbmNlLjwvcD4KICAgICAgICAgICAgICAgICAgICAgIDwvY2VudGVyPgogICAgICAgICAgICAgICAgICAgICAgPGlucHV0IGF1dG9mb2N1cyBjbGFzcz0naW5wdXQtY29udGVudHR5cGUnIHR5cGU9dGV4dCBwbGFjZWhvbGRlcj0nU2VhcmNoIGJ5IGNvbnRlbnQgdHlwZScgLz4KICAgICAgICAgICAgICAgICAgICAgIDxpbnB1dCBkaXNhYmxlZCBjbGFzcz0naW5wdXQtY29udGVudCcgdHlwZT10ZXh0IHBsYWNlaG9sZGVyPSdTZWFyY2ggYnkgY29udGVudCBuYW1lJyAvPgogICAgICAgICAgICAgICAgICAgIDwvZGl2PgogICAgICAgICAgICAgICAgICA8L21lbnU+CiAgICAgICAgICAgICAgICA8L2RpYWxvZz4KICAgICAgICAgICAgICB7eyBlbmQgfX0KCiAgICAgICAgICAgICAge3sgaWYgZXEgLlR5cGUgIlJlZmVyZW5jZUxpc3QiIH19CiAgICAgICAgICAgICAgICA8aW5wdXQge3sgaWYgZXEgJGluZGV4IDAgfX0gYXV0b2ZvY3VzIHt7IGVuZCB9fSBpZD0idmFsdWVfdXBkYXRlX3t7ICR2YWwuVHlwZSB9fS17eyAkdmFsLklEIH19IiBjbGFzcz0nb3V0cHV0LXJlZicgcmVxdWlyZWQgdHlwZT1oaWRkZW4gbmFtZT0ie3sgLlR5cGUgfX0te3sgLk5hbWUgfX0iIC8+CiAgICAgICAgICAgICAgICA8aW5wdXQgY2xhc3M9J2lucHV0LXJlZicgdHlwZT1idXR0b24gdmFsdWU9T3BlbiAvPgogICAgICAgICAgICAgICAgPGRpYWxvZz4KICAgICAgICAgICAgICAgICAgPG1lbnU+CiAgICAgICAgICAgICAgICAgICAgPGRpdj4KICAgICAgICAgICAgICAgICAgICAgIDxjZW50ZXI+CiAgICAgICAgICAgICAgICAgICAgICAgIDxwPlNlYXJjaCBmb3IgY29udGVudCB0byB1c2UgYXMgcmVmZXJlbmNlLjwvcD4KICAgICAgICAgICAgICAgICAgICAgIDwvY2VudGVyPgogICAgICAgICAgICAgICAgICAgICAgPGlucHV0IGF1dG9mb2N1cyBjbGFzcz0naW5wdXQtY29udGVudHR5cGUnIHR5cGU9dGV4dCBwbGFjZWhvbGRlcj0nU2VhcmNoIGJ5IGNvbnRlbnQgdHlwZScgLz4KICAgICAgICAgICAgICAgICAgICAgIDxpbnB1dCBkaXNhYmxlZCBjbGFzcz0naW5wdXQtY29udGVudCcgdHlwZT10ZXh0IHBsYWNlaG9sZGVyPSdTZWFyY2ggYnkgY29udGVudCBuYW1lJyAvPgogICAgICAgICAgICAgICAgICAgICAgPGRpdj4KICAgICAgICAgICAgICAgICAgICAgICAgPGlucHV0IGNsYXNzPWxlZnQgdHlwZT1idXR0b24gdmFsdWU9Q2xlYXIgLz4KICAgICAgICAgICAgICAgICAgICAgICAgPGlucHV0IGNsYXNzPXJpZ2h0IHR5cGU9YnV0dG9uIHZhbHVlPURvbmUgLz4KICAgICAgICAgICAgICAgICAgICAgIDwvZGl2PgogICAgICAgICAgICAgICAgICAgIDwvZGl2PgogICAgICAgICAgICAgICAgICA8L21lbnU+CiAgICAgICAgICAgICAgICA8L2RpYWxvZz4KICAgICAgICAgICAgICB7eyBlbmQgfX0KICAgICAgICAgICAgICA8YnI+CiAgICAgICAgICAgIHt7IGVuZCB9fQogICAgICAgICAge3sgZW5kfX0KCiAgICAgICAgICA8aW5wdXQgdHlwZT1zdWJtaXQgdmFsdWU9VXBkYXRlIC8+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4KICA8c2NyaXB0Pnt7IHRlbXBsYXRlICJqcy9jb250ZW50LmpzIiAkIH19PC9zY3JpcHQ+CjwvYm9keT4KCjwvaHRtbD4K")

      var contentOpts = getopts(
        function() { return '/content/search?space={{ .Space.ID }}&contenttype=' + chosenContentTypeID + '&query='; }, 
        function(data) { 
          // Big hack.
          data = data ? data : []
          for (i = 0; i < data.length; i++) { // This response is paged, don't worry about O^2. Max of 20 items.
            for (j = 0; j < data[i].ContentValues.length; j++) {
              if (data[i].ContentValues[j].FieldName == "name") { // We're guaranteed to have this.
                Object.assign(data[i], data[i].ContentValues[j])
              }
            }
          }
          return data
        },
        'FieldValue'
      )
	tmpls["html/contenttype.html"] = tostring("PCFET0NUWVBFIGh0bWw+CjxodG1sIGxhbmc9ZW4+Cgo8aGVhZD4KICB7eyB0ZW1wbGF0ZSAiaHRtbC9faGVhZC5odG1sIiB9fQogIDx0aXRsZT5DTVMgfCB7eyAuU3BhY2UuTmFtZSB9fSB8IHt7IC5Db250ZW50VHlwZS5OYW1lIH19PC90aXRsZT4KPC9oZWFkPgoKPGJvZHkgY2xhc3M9Y29udGVudHR5cGUgc3R5bGU9J21heC13aWR0aDogODAwcHg7Jz4KICA8c3R5bGU+e3sgdGVtcGxhdGUgImNzcy9tYWluLmNzcyIgfX08L3N0eWxlPgogIDxtYWluPgogICAge3sgdGVtcGxhdGUgImh0bWwvX2hlYWRlci5odG1sIiAkIH19CiAgICA8aHIvPgogICAgPGFydGljbGU+CiAgICAgIDxoMT57eyAuU3BhY2UuTmFtZSB9fSwge3sgLkNvbnRlbnRUeXBlLk5hbWUgfX08L2gxPgogICAgICA8ZGV0YWlscz4KICAgICAgICA8c3VtbWFyeT5DcmVhdGUgYSB7eyAuQ29udGVudFR5cGUuTmFtZSB9fSBDb250ZW50PC9zdW1tYXJ5PgogICAgICAgIDxmb3JtIG1ldGhvZD1QT1NUIGFjdGlvbj0nL2NvbnRlbnQvbmV3JyBlbmN0eXBlPSdtdWx0aXBhcnQvZ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iIH19CiAgICAgICAgICAgICAgPGlucHV0IGlkPSJjcmVhdGUte3sgLlR5cGUgfX0te3sgLk5hbWUgfX0iIGNsYXNzPSdvdXRwdXQtcmVmJyByZXF1aXJlZCB0eXBlPWhpZGRlbiBuYW1lPSJ7eyAuVHlwZSB9fS17eyAuTmFtZSB9fSIgLz4KICAgICAgICAgICAgICA8aW5wdXQgY2xhc3M9J2lucHV0LXJlZicgdHlwZT1idXR0b24gdmFsdWU9T3BlbiAvPgogICAgICAgICAgICAgIDxkaWFsb2c+CiAgICAgICAgICAgICAgICA8bWVudT4KICAgICAgICAgICAgICAgICAgPGRpdj4KICAgICAgICAgICAgICAgICAgICA8cD5TZWFyY2ggZm9yIGNvbnRlbnQgdG8gdXNlIGFzIHJlZmVyZW5jZS48L3A+CiAgICAgICAgICAgICAgICAgICAgPGxhYmVsIGZvcj0nc2VhcmNoLWN0Jz5Db250ZW50IHR5cGU8L2xhYmVsPgogICAgICAgICAgICAgICAgICAgIDxicj4KICAgICAgICAgICAgICAgICAgICA8aW5wdXQgaWQ9J3NlYXJjaC1jdCcgYXV0b2ZvY3VzIGNsYXNzPSdpbnB1dC1jb250ZW50dHlwZScgdHlwZT10ZXh0IHBsYWNlaG9sZGVyPSdTZWFyY2ggYnkgY29udGVudCB0eXBlJyAvPgogICAgICAgICAgICAgICAgICAgIDxicj4KICAgICAgICAgICAgICAgICAgICA8YnI+CiAgICAgICAgICAgICAgICAgICAgPGxhYmVsIGZvcj0nc2VhcmNoLWMnPkNvbnRlbnQgbmFtZTwvbGFiZWw+CiAgICAgICAgICAgICAgICAgICAgPGJyPgogICAgICAgICAgICAgICAgICAgIDxpbnB1dCBpZD0nc2VhcmNoLWMnIGRpc2FibGVkIGNsYXNzPSdpbnB1dC1jb250ZW50JyB0eXBlPXRleHQgcGxhY2Vob2xkZXI9J1NlYXJjaCBieSBjb250ZW50IG5hbWUnIC8+CiAgICAgICAgICAgICAgICAgIDwvZGl2PgogICAgICAgICAgICAgICAgPC9tZW51PgogICAgICAgICAgICAgIDwvZGlhbG9nPgogICAgICAgICAgICB7eyBlbmQgfX0KICAgICAgICAgICAge3sgaWYgZXEgLlR5cGUgIlJlZmVyZW5jZUxpc3QiIH19CiAgICAgICAgICAgICAgPGlucHV0IGlkPSJjcmVhdGUte3sgLlR5cGUgfX0te3sgLk5hbWUgfX0iIGNsYXNzPSdvdXRwdXQtcmVmJyByZXF1aXJlZCB0eXBlPWhpZGRlbiBuYW1lPSJ7eyAuVHlwZSB9fS17eyAuTmFtZSB9fSIgLz4KICAgICAgICAgICAgICA8aW5wdXQgY2xhc3M9J2lucHV0LXJlZicgdHlwZT1idXR0b24gdmFsdWU9T3BlbiAvPgogICAgICAgICAgICAgIDxkaWFsb2c+CiAgICAgICAgICAgICAgICA8bWVudT4KICAgICAgICAgICAgICAgICAgPGRpdj4KICAgICAgICAgICAgICAgICAgICA8Y2VudGVyPgogICAgICAgICAgICAgICAgICAgICAgPHA+U2VhcmNoIGZvciBjb250ZW50IHRvIHVzZSBhcyByZWZlcmVuY2UuPC9wPgogICAgICAgICAgICAgICAgICAgIDwvY2VudGVyPgogICAgICAgICAgICAgICAgICAgIDxpbnB1dCBhdXRvZm9jdXMgY2xhc3M9J2lucHV0LWNvbnRlbnR0eXBlJyB0eXBlPXRleHQgcGxhY2Vob2xkZXI9J1NlYXJjaCBieSBjb250ZW50IHR5cGUnIC8+CiAgICAgICAgICAgICAgICAgICAgPGlucHV0IGRpc2FibGVkIGNsYXNzPSdpbnB1dC1jb250ZW50JyB0eXBlPXRleHQgcGxhY2Vob2xkZXI9J1NlYXJjaCBieSBjb250ZW50IG5hbWUnIC8+CiAgICAgICAgICAgICAgICAgICAgPGRpdj4KICAgICAgICAgICAgICAgICAgICAgIDxpbnB1dCBjbGFzcz1sZWZ0IHR5cGU9YnV0dG9uIHZhbHVlPUNsZWFyIC8+CiAgICAgICAgICAgICAgICAgICAgICA8aW5wdXQgY2xhc3M9cmlnaHQgdHlwZT1idXR0b24gdmFsdWU9RG9uZSAvPgogICAgICAgICAgICAgICAgICAgIDwvZGl2PgogICAgICAgICAgICAgICAgICA8L2Rpdj4KICAgICAgICAgICAgICAgIDwvbWVudT4KICAgICAgICAgICAgICA8L2RpYWxvZz4KICAgICAgICAgICAge3sgZW5kIH19CiAgICAgICAgICAgIDxicj4KICAgICAgICAgICAgPGJyPgogICAgICAgICAge3sgZW5kIH19CiAgICAgICAgICA8aW5wdXQgdHlwZT1zdWJtaXQgdmFsdWU9Q3JlYXRlIC8+CiAgICAgICAgICA8L2ZpZWxkc2V0PgogICAgICAgICAgPGJyPgogICAgICAgIDwvZm9ybT4KICAgICAgPC9kZXRhaWxzPgoKICAgICAgPGRldGFpbHM+CiAgICAgICAgPHN1bW1hcnk+VXBkYXRlIHt7IC5Db250ZW50VHlwZS5OYW1lIH19IENvbnRlbnQgVHlwZTwvc3VtbWFyeT4KICAgICAgICA8Zm9ybSBtZXRob2Q9UE9TVCBhY3Rpb249Jy9jb250ZW50dHlwZS91cGRhdGUnIGVuY3R5cGU9J211bHRpcGFydC9mb3JtLWRhdGEnPgogICAgICAgICAgPGlucHV0IHJlcXVpcmVkIHR5cGU9aGlkZGVuIG5hbWU9c3BhY2UgdmFsdWU9Int7IC5TcGFjZS5JRCB9fSIgLz4KICAgICAgICAgIDxpbnB1dCByZXF1aXJlZCB0eXBlPWhpZGRlbiBuYW1lPWNvbnRlbnR0eXBlIHZhbHVlPSJ7eyAuQ29udGVudFR5cGUuSUQgfX0iIC8+CiAgICAgICAgICA8YnI+CiAgICAgICAgICA8ZmllbGRzZXQ+CiAgICAgICAgICAgIDxsZWdlbmQ+Q29udGVudCB0eXBlIG5hbWU8L2xlZ2VuZD4KICAgICAgICAgICAgPGxhYmVsIGZvcj0ndXBkYXRlLW5hbWUnPk5hbWU8L2xhYmVsPgogICAgICAgICAgICA8YnI+CiAgICAgICAgICAgIDxpbnB1dCBpZD0ndXBkYXRlLW5hbWUnIGF1dG9mb2N1cyByZXF1aXJlZCB0eXB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XRlZCB3aXRoIGEgY29udGVudCB0eXBlIG9mIHt7IC5Db250ZW50VHlwZS5OYW1lIH19PC9wPgogICAgICB7eyBlbmQgfX0KCiAgICA8L2FydGljbGU+CiAgICA8aHIvPgogICAge3sgdGVtcGxhdGUgImh0bWwvX2Zvb3Rlci5odG1sIiB9fQogIDwvbWFpbj4KICA8c2NyaXB0IHNyYz0nLy91bnBrZy5jb20vdGlueW1jZUA1LjIuMC90aW55bWNlLm1pbi5qcyc+PC9zY3JpcHQ+CiAgPHNjcmlwdCBzcmM9Jy8vdW5wa2cuY29tL2F1dG9jb21wbGV0ZS5qc0AwLjM3LjEvZGlzdC9hdXRvY29tcGxldGUubWluLmpzJz48L3NjcmlwdD4KICA8c2NyaXB0Pnt7IHRlbXBsYXRlICJqcy9zcGFjZS5qcyIgfX08L3NjcmlwdD4KICA8c2NyaXB0Pnt7IHRlbXBsYXRlICJqcy9jb250ZW50LmpzIiAkIH19PC9zY3JpcHQ+CjwvYm9keT4KCjwvaHRtbD4K")

      // TODO: Weird behavior here, why do I have to inline this clear on
      // selected? Why can't it exists in contentOpts?
      window.autocomplete(content, Object.assign({}, opts, {clearOnSelected:true}), [contentOpts]).on('autocomplete:selected', onContentSelected)
      function onContentSelected(e, item, dataset, ctx) {
        if (isList) {
          chosenContentIDs.push(item.ContentID)
          chosenContentNames.push(item.FieldValue)
          btn.value = chosenContentNames.join(', ')
        }
        else {
          output.value = item.ContentID
          btn.value = item.FieldValue
          dialog.close()
        }
      }
	tmpls["html/hook.html"] = tostring("PCFET0NUWVBFIGh0bWw+CjxodG1sIGxhbmc9ZW4+Cgo8aGVhZD4KICB7eyB0ZW1wbGF0ZSAiaHRtbC9faGVhZC5odG1sIiB9fQogIDx0aXRsZT5DTVMgfCB7eyAuU3BhY2UuTmFtZSB9fSB8IHt7IC5Ib29rLlVSTCB9fTwvdGl0bGU+CjwvaGVhZD4KCjxib2R5IGNsYXNzPWluZGV4IHN0eWxlPSdtYXgtd2lkdGg6IDYwM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tZSAvPgogICAgICAgICAgICAgIDxicj4KICAgICAgICAgICAgICA8YnI+CiAgICAgICAgICAgICAgPGxhYmVsIGZvcj0nY3JlYXRlLWRlc2MnPkRlc2NyaXB0aW9uPC9sYWJlbD4KICAgICAgICAgICAgICA8YnI+CiAgICAgICAgICAgICAgPGlucHV0IGlkPSdjcmVhdGUtZGVzYycgcmVxdWlyZWQgdHlwZT10ZXh0IG5hbWU9ZGVzYyBwbGFjZWhvbGRlcj1kZXNjcmlwdGlvbiAvPgogICAgICAgICAgICAgIDxicj4KICAgICAgICAgICAgICA8YnI+CiAgICAgICAgICAgICAgPGlucHV0IHR5cGU9c3VibWl0IHZhbHVlPUNyZWF0ZSAvPgogICAgICAgICAgICA8L2ZpZWxkc2V0PgogICAgICAgICAgICA8YnI+CiAgICAgICAgICA8L2Zvcm0+CiAgICAgICAgPC9kZXRhaWxzPgogICAgICAgIDxkZXRhaWxzPgogICAgICAgICAgPHN1bW1hcnk+TG9nb3V0PC9zdW1tYXJ5PgogICAgICAgICAgPGZvcm0gbWV0aG9kPVBPU1QgYWN0aW9uPScvdXNlci9sb2dvdXQnIGVuY3R5cGU9J211bHRpcGFydC9mb3JtLWRhdGEnPgogICAgICAgICAgICA8YnI+CiAgICAgICAgICAgIDxmaWVsZHNldD4KICAgICAgICAgICAgICA8aW5wdXQgYXV0b2ZvY3VzIHR5cGU9c3VibWl0IHZhbHVlPUxvZ291dCAvPgogICAgICAgICAgICA8L2ZpZWxkc2V0PgogICAgICAgICAgICA8YnI+CiAgICAgICAgICA8L2Zvcm0+CiAgICAgICAgPC9kZXRhaWxzPgogICAgICAgIDxicj4KICAgICAgICA8aDI+WW91ciBTcGFjZXM8L2gyPgogICAgICAgIHt7IGlmIC5TcGFjZXMgfX0KICAgICAgICAgIDx1bD4KICAgICAgICAgICAge3sgcmFuZ2UgLlNwYWNlcyB9fQogICAgICAgICAgICA8bGk+PGEgaHJlZj0iL3NwYWNlL3t7IC5JRCB9fSI+e3sgLk5hbWUgfX08L2E+PC9saT4KICAgICAgICAgICAge3sgZW5kIH19CiAgICAgICAgICA8L3VsPgogICAgICAgIHt7IGVsc2UgfX0KICAgICAgICAgIDxwPllvdSBoYXZlbid0IGNyZWF0ZWQgYW55IHNwYWNlcyB5ZXQuPC9wPgogICAgICAgIHt7IGVuZCB9fQogICAgICB7eyBlbHNlIH19CiAgICAgICAgPGgxPkFjY291bnQ8L2gxPgogICAgICAgIDxkZXRhaWxzPgogICAgICAgICAgPHN1bW1hcnk+TG9naW48L3N1bW1hcnk+CiAgICAgICAgICA8Zm9ybSBtZXRob2Q9UE9TVCBhY3Rpb249Jy91c2VyL2xvZ2luJyBlbmN0eXBlPSdtdWx0aXBhcnQvZm9ybS1kYXRhJz4KICAgICAgICAgICAgPGJyPgogICAgICAgICAgICA8ZmllbGRzZXQ+CiAgICAgICAgICAgICAgPGxhYmVsIGZvcj0nbG9naW4tdXNlcm5hbWUnPlVzZXJuYW1lPC9sYWJlbD4KICAgICAgICAgICAgICA8YnI+CiAgICAgICAgICAgICAgPGlucHV0IGlkPSdsb2dpbi11c2VybmFtZScgYXV0b2NvbXBsZXRlPW9uIHJlcXVpcmVkIHR5cGU9dGV4dCBuYW1lPXVzZXJuYW1lIHBsYWNlaG9sZGVyPXVzZXJuYW1lIGF1dG9mb2N1cyAvPgogICAgICAgICAgICAgIDxicj4KICAgICAgICAgICAgICA8YnI+CiAgICAgICAgICAgICAgPGxhYmVsIGZvcj0nbG9naW4tcGFzc3dvcmQnPlBhc3N3b3JkPC9sYWJlbD4KICAgICAgICAgICAgICA8YnI+CiAgICAgICAgICAgICAgPGlucHV0IGlkPSdsb2dpbi1wYXNzd29yZCcgYXV0b2NvbXBsZXRlPW9uIHJlcXVpcmVkIHR5cGU9cGFzc3dvcmQgbmFtZT1wYXNzd29yZCBwbGFjZWhvbGRlcj1wYXNzd29yZCAvPgogICAgICAgICAgICAgIDxicj4KICAgICAgICAgICAgICA8YnI+CiAgICAgICAgICAgICAgPGlucHV0IHR5cGU9c3VibWl0IHZhbHVlPUxvZ2luIC8+CiAgICAgICAgICAgIDwvZmllbGRzZXQ+CiAgICAgICAgICAgIDxicj4KICAgICAgICAgIDwvZm9ybT4KICAgICAgICA8L2RldGFpbHM+CiAgICAgICAgPGRldGFpbHM+CiAgICAgICAgICA8c3VtbWFyeT5TaWdudXA8L3N1bW1hcnk+CiAgICAgICAgICA8Zm9ybSBtZXRob2Q9UE9TVCBhY3Rpb249Jy91c2VyL3NpZ251cCcgZW5jdHlwZT0nbXVsdGlwYXJ0L2Zvcm0tZGF0YSc+CiAgICAgICAgICAgIDxicj4KICAgICAgICAgICAgPGZpZWxkc2V0PgogICAgICAgICAgICAgIDxsYWJlbCBmb3I9J3NpZ251cC11c2VybmFtZSc+VXNlcm5hbWU8L2xhYmVsPgogICAgICAgICAgICAgIDxicj4KICAgICAgICAgICAgICA8aW5wdXQgaWQ9J3NpZ251cC11c2VybmFtZScgYXV0b2NvbXBsZXRlPW9uIHJlcXVpcmVkIHR5cGU9dGV4dCBuYW1lPXVzZXJuYW1lIHBsYWNlaG9sZGVyPXVzZXJuYW1lIGF1dG9mb2N1cyAvPgogICAgICAgICAgICAgIDxicj4KICAgICAgICAgICAgICA8YnI+CiAgICAgICAgICAgICAgPGxhYmVsIGZvcj0nc2lnbnVwLXBhc3N3b3JkJz5QYXNzd29yZDwvbGFiZWw+CiAgICAgICAgICAgICAgPGJyPgogICAgICAgICAgICAgIDxpbnB1dCBpZD0nc2lnbnVwLXBhc3N3b3JkJyBhdXRvY29tcGxldGU9b24gcmVxdWlyZWQgdHlwZT1wYXNzd29yZCBuYW1lPXBhc3N3b3JkIHBsYWNlaG9sZGVyPXBhc3N3b3JkIC8+CiAgICAgICAgICAgICAgPGJyPgogICAgICAgICAgICAgIDxicj4KICAgICAgICAgICAgICA8bGFiZWwgZm9yPSdzaWdudXAtdmVyaWZ5Jz5WZXJpZnk8L2xhYmVsPgogICAgICAgICAgICAgIDxicj4KICAgICAgICAgICAgICA8aW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R5cGU8L2gyPgogICAgICB7eyBpZiAuQ29udGVudFR5cGVzIH19CiAgICAgICAgPHVsPgogICAgICAgICAge3sgcmFuZ2UgLkNvbnRlbnRUeXBlcyB9fQogICAgICAgICAgICA8bGk+PGEgaHJlZj0nL2NvbnRlbnR0eXBlL3t7ICQuU3BhY2UuSUQgfX0ve3sgLklEIH19Jz57eyAuTmFtZSB9fTwvYT48L2xpPgogICAgICAgICAge3sgZW5kIH19CiAgICAgICAgPC91bD4KICAgICAge3sgZWxzZSB9fQogICAgICAgIDxwPllvdSBoYXZlbid0IGNyZWF0ZWQgYW55IGNvbnRlbnQgdHlwZXMgeWV0LjwvcD4KICAgICAge3sgZW5kIH19CgogICAgICA8aDI+QnJvd3NlIFdlYmhvb2tzPC9oMj4KICAgICAge3sgaWYgLkhvb2tzfX0KICAgICAgICA8dWw+CiAgICAgICAgICB7eyByYW5nZSAuSG9va3N9fQogICAgICAgICAgICA8bGk+PGEgaHJlZj0nL2hvb2sve3sgJC5TcGFjZS5JRCB9fS97eyAuSUQgfX0nPnt7IC5VUkwgfX08L2E+PC9saT4KICAgICAgICAgIHt7IGVuZCB9fQogICAgICAgIDwvdWw+CiAgICAgIHt7IGVsc2UgfX0KICAgICAgICA8cD5Zb3UgaGF2ZW4ndCBjcmVhdGVkIGFueSB3ZWJob29rcyB5ZXQuPC9wPgogICAgICB7eyBlbmQgfX0KCiAgICA8L2FydGljbGU+CiAgICA8aHIvPgogICAge3sgdGVtcGxhdGUgImh0bWwvX2Zvb3Rlci5odG1sIiB9fQogIDwvbWFpbj4KICA8c2NyaXB0Pnt7IHRlbXBsYXRlICJqcy9zcGFjZS5qcyIgfX08L3NjcmlwdD4KPC9ib2R5PgoKPC9odG1sPgo=")

	tmpls["js/space.js"] = `// Add more fields to space create.
(function() { 
  var addFieldBtn = document.getElementById('add-fieldbtn')
  var i = 1
  addFieldBtn.addEventListener('click', function(e) { 
    i++
    e.preventDefault()
    e.stopPropagation()
    var el = document.createElement('div')
    el.innerHTML = ` + "`" + `
      <div>
        <input required type=text name="field_name_${i}" placeholder="field name" />
        <select required name="field_type_${i}">
          <option disabled selected value>Field Type</option>
          <option value="StringSmall">String Small</option>
          <option value="StringBig">String Big</option>
          <option value="InputHTML">HTML</option>
          <option value="InputMarkdown">Markdown</option>
          <option value="File">File</option>
          <option value="Date">Date</option>
          <option value="Reference">Reference</option>
          <option value="ReferenceList">ReferenceList</option>
        </select>
        <input type=button id='remove-fieldbtn_${i}' value='Remove Field' />
      </div>
      <br>
    ` + "`" + `
    addFieldBtn.parentNode.insertBefore(el, addFieldBtn)
    var removeFieldBtn = document.getElementById(` + "`" + `remove-fieldbtn_${i}` + "`" + `)
    removeFieldBtn.addEventListener('click', function(e) { 
      i--
      e.preventDefault()
      e.stopPropagation()
      el.parentNode.removeChild(el)
    })
  })
})();
	tmpls["js/content.js"] = tostring("Ly8gU2V0dXAgaW5wdXRzIGZvciBjb250ZW50IGNyZWF0ZS91cGRhdGUuCihmdW5jdGlvbigpIHsgCgogIC8vIEhUTUwKICB0aW55bWNlLmluaXQoeyAKICAgIHNlbGVjdG9yOiAndGV4dGFyZWEuaW5wdXQtaHRtbCcsCiAgICBwbHVnaW5zOiAiY29kZSIsCiAgICBmb3JjZWRfcm9vdF9ibG9jayA6ICIiLCAvKiBObyB3cmFwcGluZyBwYXJhZ3JhcGggdGFnLiAqLwogICAgLy8gc3RhdHVzYmFyOiBmYWxzZSwKICAgIHNldHVwOiBmdW5jdGlvbihpdGVtKSB7IAogICAgICBpdGVtLm9uKCdjaGFuZ2UnLCBmdW5jdGlvbigpIHsgCiAgICAgICAgaXRlbS50YXJnZXRFbG0udmFsdWUgPSBpdGVtLmdldENvbnRlbnQoKQogICAgICB9KQogICAgfQogIH0pCgogIC8vIE1BUktET1dOCiAgdGlueW1jZS5pbml0KHsKICAgIHNlbGVjdG9yOiAidGV4dGFyZWEuaW5wdXQtbWFya2Rvd24iLAogICAgcGx1Z2luOiAndGV4dHBhdHRlcm4nLAogICAg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5wcmV2ZW50RGVmYXVsdCgpCiAgICAgICAgZGlhbG9nLnNob3dNb2RhbCgpCiAgICAgIH0pCgogICAgICAvLyBDTE9TRQogICAgICBkaWFsb2cuYWRkRXZlbnRMaXN0ZW5lcignY2xpY2snLCBmdW5jdGlvbihlKSB7IAogICAgICAgIGUuc3RvcFByb3BhZ2F0aW9uKCkKICAgICAgICBlLnByZXZlbnREZWZhdWx0KCkKICAgICAgICBpZiAoaXNMaXN0KSB7IAogICAgICAgICAgLy8gRG9uJ3QgbGV0IHJlZmxpc3QgaW5wdXQgY2xvc2UgYnkgb2ZmIGNsaWNrLCB1c2VyIG11c3QgY2hvb3NlIHRvCiAgICAgICAgICAvLyBjbGVhciBpbnB1dCB0byBjbG9zZSwgb3IgYmUgZG9uZSB0byBjbG9zZS4KICAgICAgICAgIHJldHVybiAKICAgICAgICB9CiAgICAgICAgZGlhbG9nLmNsb3NlKCkKICAgICAgfSkKCiAgICAgIC8vIFNUT1AKICAgICAgbWVudS5hZGRFdmVudExpc3RlbmVyKCdjbGljaycsIGZ1bmN0aW9uKGUpIHsgCiAgICAgICAgZS5zdG9wUHJvcGFnYXRpb24oKQogICAgICAgIGUucHJldmVudERlZmF1bHQoKQogICAgICB9KQoKICAgICAgaWYgKGlzTGlzdCkgewogICAgICAgIC8vIENMRUFSCiAgICAgICAgY2xlYXJCdG4uYWRkRXZlbnRMaXN0ZW5lcignY2xpY2snLCBjbGVhckJ0bkhhbmRsZSkKICAgICAgICBmdW5jdGlvbiBjbGVhckJ0bkhhbmRsZShlKSB7IAogICAgICAgICAgZS5zdG9wUHJvcGFnYXRpb24oKQogICAgICAgICAgZS5wcmV2ZW50RGVmYXVsdCgpCiAgICAgICAgICBvdXRwdXQudmFsdWUgPSAnJwogICAgICAgICAgYnRuLnZhbHVlID0gJ09wZW4nCiAgICAgICAgICBjaG9zZW5Db250ZW50SURzID0gW10KICAgICAgICAgIGNob3NlbkNvbnRlbnROYW1lcyA9IFtdCiAgICAgICAgICBkaWFsb2cuY2xvc2UoKQogICAgICAgIH0KCiAgICAgICAgLy8gRE9ORQogICAgICAgIGRvbmVCdG4uYWRkRXZlbnRMaXN0ZW5lcignY2xpY2snLCBmdW5jdGlvbihlKSB7IAogICAgICAgICAgaWYgKGNob3NlbkNvbnRlbnRJRHMubGVuZ3RoIDwgMSkgewogICAgICAgICAgICByZXR1cm4gY2xlYXJCdG5IYW5kbGUoZSkKICAgICAgICAgIH0KICAgICAgICAgIGUuc3RvcFByb3BhZ2F0aW9uKCkKICAgICAgICAgIGUucHJldmVudERlZmF1bHQoKQogICAgICAgICAgb3V0cHV0LnZhbHVlID0gY2hvc2VuQ29udGVudElEcy5qb2luKCctJykKICAgICAgICAgIGJ0bi52YWx1ZSA9IGNob3NlbkNvbnRlbnROYW1lcy5qb2luKCcsICcpCiAgICAgICAgICBjaG9zZW5Db250ZW50SURzID0gW10KICAgICAgICAgIGNob3NlbkNvbnRlbnROYW1lcyA9IFtdCiAgICAgICAgICBkaWFsb2cuY2xvc2UoKQogICAgICAgIH0pCiAgICAgIH0KCiAgICAgIC8vIElOUFVUUyBFVkVOVFMgQU5EIFJFU1VMVFMKICAgICAgdmFyIGlucHV0cyA9IGRpYWxvZy5xdWVyeVNlbGVjdG9yQWxsKCdpbnB1dCcpCiAgICAgIHZhciBjb250ZW50dHlwZSA9IGlucHV0c1swXQogICAgICB2YXIgY29udGVudCA9IGlucHV0c1sxXQoKICAgICAgdmFyIG9wdHMgPSB7CiAgICAgICAgYXV0b3NlbGVjdDogdHJ1ZSwKICAgICAgICBhdXRvc2VsZWN0T25CbHVyOiB0cnVlLCAKICAgICAgICB0YWJBdXRvY29tcGxldGU6IHRydWUsCiAgICAgICAgLy8gY2xlYXJPblNlbGVjdGVkOiB0cnVlLAogICAgICAgIGhpbnQ6IGZhbHNlCiAgICAgIH0KCiAgICAgIGZ1bmN0aW9uIGdldG9wdHModXJsLCB0cmFuc2Zvcm0sIGRpc3BsYXlLZXkpIHsgCiAgICAgICAgdmFyIGNvbnRlbnR0eXBlQWJvcnQgPSBmdW5jdGlvbigpIHt9CiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIGRpc3BsYXlLZXk6IGRpc3BsYXlLZXksCiAgICAgICAgICBzb3VyY2U6IGZ1bmN0aW9uKHF1ZXJ5LCBjYikgeyAKICAgICAgICAgICAgY2IoW10pCiAgICAgICAgICAgIGNvbnRlbnR0eXBlQWJvcnQoKQogICAgICAgICAgICB2YXIgcmVxID0gbmV3IFhNTEh0dHBSZXF1ZXN0KCkKICAgICAgICAgICAgY29udGVudHR5cGVBYm9ydCA9IGZ1bmN0aW9uKCkgeyByZXEuYWJvcnQoKSB9IAogICAgICAgICAgICByZXEub25yZWFkeXN0YXRlY2hhbmdlID0gZnVuY3Rpb24oKSB7CiAgICAgICAgICAgICAgaWYgKHRoaXMucmVhZHlTdGF0ZSAhPSA0KSB7CiAgICAgICAgICAgICAgICByZXR1cm4KICAgICAgICAgICAgICB9CgogICAgICAgICAgICAgIGlmICh0aGlzLnN0YXR1cyAhPSAyMDApIHsKICAgICAgICAgICAgICAgIGlmICh0aGlzLnJlc3BvbnNlVGV4dCAhPSAiIikgewogICAgICAgICAgICAgICAgICBhbGVydCh0aGlzLnJlc3BvbnNlVGV4dCkKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGNiKFtdKQogICAgICAgICAgICAgICAgcmV0dXJuCiAgICAgICAgICAgICAgfQoKICAgICAgICAgICAgICB0cnkgeyAKICAgICAgICAgICAgICAgIGNiKHRyYW5zZm9ybShKU09OLnBhcnNlKHRoaXMucmVzcG9uc2VUZXh0KSkpCiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIGNhdGNoKGUpIHsgCiAgICAgICAgICAgICAgICB2YXIgbXNnID0gZS50b1N0cmluZygpCiAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyh7ZSxtc2d9KQogICAgICAgICAgICAgICAgaWYgKG1zZyAhPSAiIikgeyAvLyBDYW5jZWxsZWQgcmVxdWVzdHMgaGl0IHRoaXMuCiAgICAgICAgICAgICAgICAgIGFsZXJ0KG1zZykKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmVxLm9wZW4oJ0dFVCcsIHVybCgpICsgcXVlcnksIHRydWUpCiAgICAgICAgICAgIHJlcS5zZW5kKCkKICAgICAgICAgIH0KICAgICAgICB9CiAgICAgIH0KCiAgICAgIHZhciBjb250ZW50dHlwZU9wdHMgPSBnZXRvcHRzKAogICAgICAgIGZ1bmN0aW9uKCkgeyByZXR1cm4gJy9jb250ZW50dHlwZS9zZWFyY2g/c3BhY2U9e3sgLlNwYWNlLklEIH19JnF1ZXJ5PSc7IH0sIAogICAgICAgIGZ1bmN0aW9uKGRhdGEpIHsgcmV0dXJuIGRhdGEgfSwKICAgICAgICAnQ29udGVudFR5cGVOYW1lJwogICAgICApCgogICAgICB3aW5kb3cuYXV0b2NvbXBsZXRlKGNvbnRlbnR0eXBlLCBvcHRzLCBbY29udGVudHR5cGVPcHRzXSkub24oJ2F1dG9jb21wbGV0ZTpzZWxlY3RlZCcsIG9uQ29udGVudFR5cGVTZWxlY3RlZCkKICAgICAgZnVuY3Rpb24gb25Db250ZW50VHlwZVNlbGVjdGVkKGUsIGl0ZW0sIGRhdGFzZXQsIGN0eCkgewogICAgICAgIGNob3NlbkNvbnRlbnRUeXBlSUQgPSBpdGVtLkNvbnRlbnRUeXBlSUQKICAgICAgICBjb250ZW50LmRpc2FibGVkID0gZmFsc2UKICAgICAgfQoKICAgICAgdmFyIGNvbnRlbnRPcHRzID0gZ2V0b3B0cygKICAgICAgICBmdW5jdGlvbigpIHsgcmV0dXJuICcvY29udGVudC9zZWFyY2g/c3BhY2U9e3sgLlNwYWNlLklEIH19JmNvbnRlbnR0eXBlPScgKyBjaG9zZW5Db250ZW50VHlwZUlEICsgJyZxdWVyeT0nOyB9LCAKICAgICAgICBmdW5jdGlvbihkYXRhKSB7IAogICAgICAgICA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ZiAoaXNMaXN0KSB7CiAgICAgICAgICBjaG9zZW5Db250ZW50SURzLnB1c2goaXRlbS5Db250ZW50SUQpCiAgICAgICAgICBjaG9zZW5Db250ZW50TmFtZXMucHVzaChpdGVtLkZpZWxkVmFsdWUpCiAgICAgICAgICBidG4udmFsdWUgPSBjaG9zZW5Db250ZW50TmFtZXMuam9pbignLCAnKQogICAgICAgIH0KICAgICAgICBlbHNlIHsKICAgICAgICAgIG91dHB1dC52YWx1ZSA9IGl0ZW0uQ29udGVudElECiAgICAgICAgICBidG4udmFsdWUgPSBpdGVtLkZpZWxkVmFsdWUKICAgICAgICAgIGRpYWxvZy5jbG9zZSgpCiAgICAgICAgfQogICAgICB9CgogICAgfSkocmVmYnRuc1tpXSwgbWVudXNbaV0sIHJlZnNbaV0sIHRvYnRuc1tpXSkKICB9Cgp9KSgpOwo=")

// For update: remove old fields
(function() { 
  var btns = document.querySelectorAll("form div input[type=button]");
  for (var e = 0; e < btns.length; e++) {
    (function(btn) {
      btn.addEventListener("click", function handelClick() { 
        btn.parentElement.parentElement.removeChild(btn.parentElement);
      });
    })(btns[e]);
  }
})();
`
	tmpls["js/space.js"] = tostring("Ly8gQWRkIG1vcmUgZmllbGRzIHRvIHNwYWNlIGNyZWF0ZS4KKGZ1bmN0aW9uKCkgeyAKICB2YXIgYWRkRmllbGRCdG4gPSBkb2N1bWVudC5nZXRFbGVtZW50QnlJZCgnYWRkLWZpZWxkYnRuJykKICB2YXIgaSA9IDEKICBhZGRGaWVsZEJ0bi5hZGRFdmVudExpc3RlbmVyKCdjbGljaycsIGZ1bmN0aW9uKGUpIHsgCiAgICBpKysKICAgIGUucHJldmVudERlZmF1bHQoKQogICAgZS5zdG9wUHJvcGFnYXRpb24oKQogICAgdmFyIGVsID0gZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgnZGl2JykKICAgIGVsLmlubmVySFRNTCA9IGAKICAgICAgPGRpdj4KICAgICAgICA8aW5wdXQgcmVxdWlyZWQgdHlwZT10Z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