git.iko.soy/lynxjs-elm/compiler
on master help sign in
201 files changed+51639−991
since splitsnapshots
unifiedsplit
.github/CONTRIBUTING.md+18−20 .github/workflows/set-issue-expectations.yml+1−1 .github/workflows/set-pull-expectations.yml+11−13 .gitignore+4 ARCHITECTURE.md+155 CLAUDE.md+62 ContributorAgreement.pdf README.md+51−11 builder/src/Build.hs+4−4 builder/src/Deps/Registry.hs−1 builder/src/Deps/Solver.hs+5−6 builder/src/Elm/Details.hs+24−15 builder/src/Elm/Outline.hs−1 builder/src/Lynx/Patches.hs+221 builder/src/Reporting.hs+1−1 builder/src/Reporting/Exit.hs+14−1 builder/src/Stuff.hs+2−3 compiler/src/AST/Canonical.hs−1 compiler/src/AST/Optimized.hs−1 compiler/src/AST/Source.hs−1 compiler/src/AST/Utils/Binop.hs−1 compiler/src/AST/Utils/Shader.hs−1 compiler/src/AST/Utils/Type.hs−2 compiler/src/Canonicalize/Effects.hs−1 compiler/src/Canonicalize/Environment.hs−1 compiler/src/Canonicalize/Environment/Dups.hs−1 compiler/src/Canonicalize/Environment/Foreign.hs−1 compiler/src/Canonicalize/Environment/Local.hs−1 compiler/src/Canonicalize/Expression.hs+1−1 compiler/src/Canonicalize/Module.hs−1 compiler/src/Canonicalize/Pattern.hs−1 compiler/src/Canonicalize/Type.hs−1 compiler/src/Data/Bag.hs−1 compiler/src/Data/Name.hs+5−12 compiler/src/Data/OneOrMore.hs−1 compiler/src/Data/Utf8.hs+18−28 compiler/src/Elm/Compiler/Imports.hs−1 compiler/src/Elm/Compiler/Type.hs+1−1 compiler/src/Elm/Compiler/Type/Extract.hs−1 compiler/src/Elm/Constraint.hs−1 compiler/src/Elm/Docs.hs−1 compiler/src/Elm/Float.hs−1 compiler/src/Elm/Interface.hs−1 compiler/src/Elm/Kernel.hs−1 compiler/src/Elm/Licenses.hs−1 compiler/src/Elm/Package.hs+40−6 compiler/src/Elm/Version.hs+2−3 compiler/src/Generate/Html.hs+166−24 compiler/src/Generate/JavaScript.hs+136−5 compiler/src/Generate/JavaScript/Builder.hs+17−2 compiler/src/Generate/JavaScript/Expression.hs+12−4 compiler/src/Generate/JavaScript/Name.hs−2 compiler/src/Json/Decode.hs+3−6 compiler/src/Json/Encode.hs−2 compiler/src/Nitpick/PatternMatches.hs+1−1 compiler/src/Optimize/Case.hs−1 compiler/src/Optimize/DecisionTree.hs+1−1 compiler/src/Optimize/Expression.hs−1 compiler/src/Optimize/Module.hs−1 compiler/src/Optimize/Names.hs−1 compiler/src/Optimize/Port.hs−1 compiler/src/Parse/Keyword.hs−1 compiler/src/Parse/Module.hs−1 compiler/src/Parse/Number.hs−1 compiler/src/Parse/Primitives.hs+3−6 compiler/src/Parse/Shader.hs−1 compiler/src/Parse/Symbol.hs−1 compiler/src/Parse/Variable.hs+2−3 compiler/src/Reporting/Annotation.hs−1 compiler/src/Reporting/Doc.hs+2−2 compiler/src/Reporting/Error.hs−1 compiler/src/Reporting/Error/Canonicalize.hs+1−2 compiler/src/Reporting/Error/Docs.hs−2 compiler/src/Reporting/Error/Json.hs−1 compiler/src/Reporting/Error/Main.hs−1 compiler/src/Reporting/Error/Pattern.hs+2−4 compiler/src/Reporting/Error/Syntax.hs−1 compiler/src/Reporting/Error/Type.hs−2 compiler/src/Reporting/Render/Code.hs+1−1 compiler/src/Reporting/Render/Type.hs+1−2 compiler/src/Reporting/Render/Type/Localizer.hs−2 compiler/src/Reporting/Result.hs+8−11 compiler/src/Reporting/Suggest.hs−1 compiler/src/Reporting/Warning.hs−2 compiler/src/Type/Constrain/Expression.hs−1 compiler/src/Type/Constrain/Module.hs−1 compiler/src/Type/Constrain/Pattern.hs−1 compiler/src/Type/Error.hs+1−2 compiler/src/Type/Instantiate.hs−1 compiler/src/Type/Occurs.hs−1 compiler/src/Type/Solve.hs−1 compiler/src/Type/Type.hs−1 compiler/src/Type/Unify.hs+29−53 examples/counter/elm.js+5144 examples/counter/elm.json+24 examples/counter/main.html+5251 examples/counter/main.lynx.bundle examples/counter/src/Main.elm+105 examples/hello-world/elm.js+3697 examples/hello-world/elm.json+19 examples/hello-world/src/Main.elm+14 examples/http-example/elm.js+6126 examples/http-example/elm.json+27 examples/http-example/main.html+6220 examples/http-example/src/Main.elm+114 examples/scroll-view/elm.js+5377 examples/scroll-view/elm.json+24 examples/scroll-view/src/Main.elm+205 examples/timer/elm.json+24 examples/timer/src/Main.elm+221 examples/todo-list/elm.js+5417 examples/todo-list/elm.json+24 examples/todo-list/src/Main.elm+229 hints/implicit-casts.md−3 hints/optimize.md+2−2 installers/npm/.gitignore+2 installers/npm/PUBLISHING.md+77−4 installers/npm/README.md+7−9 installers/npm/bin/elm+7−33 installers/npm/binary.js+122 installers/npm/download.js−82 installers/npm/install.js+1−4 installers/npm/package.json+7−5 installers/npm/packages/darwin_arm64/README.md+5 installers/npm/packages/darwin_arm64/package.json+9 installers/npm/packages/darwin_x64/README.md+5 installers/npm/packages/darwin_x64/package.json+9 installers/npm/packages/linux_arm64/README.md+5 installers/npm/packages/linux_arm64/package.json+9 installers/npm/packages/linux_x64/README.md+5 installers/npm/packages/linux_x64/package.json+9 installers/npm/packages/win32_x64/README.md+5 installers/npm/packages/win32_x64/package.json+9 installers/npm/troubleshooting.md+2−2 elm.cabal → lynxjs-elm.cabal+29−28 lynxjs-elm.md+1401 packages/browser/README.md+270 packages/browser/elm.json+22 packages/browser/src/Browser.elm+141 packages/browser/src/Browser/AnimationManager.elm+114 packages/browser/src/Browser/Dom.elm+384 packages/browser/src/Browser/Events.elm+356 packages/browser/src/Browser/Navigation.elm+183 packages/browser/src/Elm/Kernel/Browser.js+434 packages/browser/src/Elm/Kernel/Browser.server.js+132 packages/bytes/elm.json+17 packages/bytes/src/Bytes.elm+187 packages/bytes/src/Bytes/Decode.elm+428 packages/bytes/src/Bytes/Encode.elm+338 packages/bytes/src/Elm/Kernel/Bytes.js+229 packages/crypto/README.md+478 packages/crypto/elm.json+17 packages/crypto/src/Crypto/Cipher.elm+75 packages/crypto/src/Crypto/Ed25519.elm+99 packages/crypto/src/Crypto/X25519.elm+70 packages/crypto/src/Elm/Kernel/Crypto.js+231 packages/http/README.md+211 packages/http/elm.json+18 packages/http/src/Elm/Kernel/Http.js+183 packages/http/src/Elm/Kernel/Http.server.js+40 packages/http/src/Http.elm+1046 packages/ui/README.md+267 packages/ui/elm.json+19 packages/ui/src/Lynx.elm+104 packages/ui/src/Lynx/Attributes.elm+568 packages/ui/src/Lynx/Events.elm+83 packages/virtual-dom/README.md+141 packages/virtual-dom/elm.json+16 packages/virtual-dom/src/Elm/Kernel/VirtualDom.js+1547 packages/virtual-dom/src/Elm/Kernel/VirtualDom.server.js+209 packages/virtual-dom/src/VirtualDom.elm+274 roadmap.md+29 stack.yaml+77 terminal/impl/Terminal.hs+1 terminal/impl/Terminal/Error.hs+1−1 terminal/src/Bump.hs+2−1 terminal/src/Clean.hs+38 terminal/src/Dev.hs+409 terminal/src/Develop.hs+48−2 terminal/src/Develop/Generate/Help.hs−2 terminal/src/Develop/Generate/Index.hs+1−2 terminal/src/Develop/Socket.hs−1 terminal/src/Develop/StaticFiles.hs−1 terminal/src/Diff.hs+1−2 terminal/src/Init.hs+129−11 terminal/src/Install.hs+18−12 terminal/src/Main.hs+98−21 terminal/src/Make.hs+228−15 terminal/src/Publish.hs+2−2 terminal/src/Repl.hs+1−2 terminal/src/Uninstall.hs+154 worker/elm.cabal+17−15 worker/logrotate.conf+15 worker/src/Artifacts.hs+15−12 worker/src/Cors.hs−1 worker/src/Endpoint/Compile.hs+114−26 worker/src/Endpoint/Donate.hs−341 worker/src/Endpoint/Quotes.hs+203 worker/src/Endpoint/Repl.hs−1 worker/src/Endpoint/Slack.hs+67 worker/src/Main.hs+25−31
.github/CONTRIBUTING.md+18−20
@@ -4,10 +4,15 @@ Thanks helping with the development of Elm! This document describes the basic
44standards for opening pull requests and making the review process as smooth as
55possible.
66
7−## Licensing
87
9−You need to sign the [contributor agreement](ContributorAgreement.pdf)
10−and send it to <info@elm-lang.org> before opening your pull request.
8+## Expectations
9+
10+- Pull requests are reviewed in [batches](https://github.com/elm/expectations/blob/master/batching.md), so it can take some time to get a response.
11+- Smaller pull requests are easier to review. To fix nine typos, nine specific issues will always go faster than one big one. Learn why [here](https://github.com/elm/expectations/blob/master/small-pull-requests.md).
12+- Reviewers may not know as much as you about certain situations, so add links to supporting evidence for important claims, especially regarding standards for CSS, HTTP, URI, etc.
13+
14+Finally, please be patient with the core team. They are trying their best with limited resources!
15+
1116
1217## Style Guide
1318
@@ -17,27 +22,20 @@ and send it to <info@elm-lang.org> before opening your pull request.
1722[haskell]: https://gist.github.com/evancz/0a1f3717c92fe71702be
1823[js]: https://google.github.io/styleguide/javascriptguide.xml
1924
20−## Branches
2125
22− * [The master branch][master] is the home of the next release of the compiler
23− so new features and improvements get merged there. Most pull requests
24− should target this branch!
26+## Branches
2527
26− * [The stable branch][stable] is for tagging releases and critical bug fixes.
27− This branch is handy for folks who want to build the most recent public
28− release from source.
28+[The master branch][master] is the home of the next release of the compiler
29+so new features and improvements get merged there. Most pull requests
30+should target this branch!
2931
3032[master]: http://github.com/elm-lang/elm/tree/master
31−[stable]: http://github.com/elm-lang/elm/tree/stable
3233
33−If you are working on a fairly large feature, we will probably want to merge it
34−in as its own branch and do some testing before bringing it into the master
35−branch. This way we can keep releases of the master branch independent of new
36−features.
3734
38−Note that the master branch of the compiler should always be in sync with the
39−master branch of the [website][], and the stable branch of the compiler should
40−always be in sync with the stable branch of the [website][]. Make sure that
41−your changes maintain this compatibility.
35+## Licensing
36+
37+Nothing extra to do for this. The default on GitHub described [here](https://docs.github.com/en/github/site-policy/github-terms-of-service#6-contributions-under-repository-license) is that:
38+
39+> Whenever you add Content to a repository containing notice of a license, you license that Content under the same terms, and you agree that you have the right to license that Content under those terms. If you have a separate agreement to license that Content under different terms, such as a contributor license agreement, that agreement will supersede.
40+
4241
43−[website]: https://github.com/elm-lang/elm-lang.org
.github/workflows/set-issue-expectations.yml+1−1
@@ -15,7 +15,7 @@ jobs:
1515 comment "Thanks for reporting this! To set expectations:
1616
1717 - Issues are reviewed in [batches](https://github.com/elm/expectations/blob/master/batching.md), so it can take some time to get a response.
18− - Ask questions a [community forum](https://elm-lang.org/community). You will get an answer quicker that way!
18+ - Ask questions in a [community forum](https://elm-lang.org/community). You will get an answer quicker that way!
1919 - If you experience something similar, open a new issue. [We like duplicates](https://github.com/elm/expectations/blob/master/duplicates.md).
2020
2121 Finally, please be patient with the core team. They are trying their best with limited resources."
.github/workflows/set-pull-expectations.yml+11−13
@@ -1,21 +1,19 @@
1−name: Set Pull Expectations
21on:
3− pull_request:
2+ pull_request_target:
43 types: [opened]
4+
55jobs:
66 comment-on-pull:
77 name: Comment On Pull
88 runs-on: ubuntu-latest
99 steps:
10− - uses: actions/github@v1.0.0
11− env:
12− GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10+ - uses: actions/github-script@v3
1311 with:
14− args: |
15− comment "Thanks for suggesting these code changes. To set expectations:
16−
17− - Pull requests are reviewed in [batches](https://github.com/elm/expectations/blob/master/batching.md), so it can take some time to get a response.
18− - Smaller pull requests are easier to review. To fix nine typos, nine specific issues will always go faster than one big one. Learn why [here](https://github.com/elm/expectations/blob/master/small-pull-requests.md).
19− - Reviewers may not know as much as you about certain situations, so add links to supporting evidence for important claims, especially regarding standards for CSS, HTTP, URI, etc.
20−
21− Finally, please be patient with the core team. They are trying their best with limited resources."
12+ github-token: ${{secrets.GITHUB_TOKEN}}
13+ script: |
14+ github.issues.createComment({
15+ issue_number: context.issue.number,
16+ owner: context.repo.owner,
17+ repo: context.repo.repo,
18+ body: "Thanks for suggesting these code changes. To set expectations:\n\n- Pull requests are reviewed in [batches](https://github.com/elm/expectations/blob/master/batching.md), so it can take some time to get a response.\n- Smaller pull requests are easier to review. To fix nine typos, nine specific issues will always go faster than one big one. Learn why [here](https://github.com/elm/expectations/blob/master/small-pull-requests.md).\n- Reviewers may not know as much as you about certain situations, so add links to supporting evidence for important claims, especially regarding standards for CSS, HTTP, URI, etc.\n\nFinally, please be patient with the core team. They are trying their best with limited resources."
19+ })
.gitignore+4
@@ -1,8 +1,12 @@
11elm-stuff
22dist
3+dist-newstyle
34cabal-dev
45.cabal-sandbox/
56cabal.sandbox.config
67.DS_Store
78*~
89travis.log
10+.stack-work/
11+stack.yaml.lock
12+*.lynx.bundle
ARCHITECTURE.mdnew file+155
@@ -0,0 +1,155 @@
1+# lynxjs-elm Architecture
2+
3+Elm compiled to target LynxJS native UI instead of browser DOM. The Elm counter app renders interactive native elements on iOS via LynxJS Explorer.
4+
5+## How it works
6+
7+```
8+Elm source (.elm)
9+ │
10+ ▼
11+lynxjs-elm compiler (patched kernels)
12+ │
13+ ▼
14+elm.js (JS with LynxJS PAPIs instead of DOM calls)
15+ │
16+ ▼
17+rspack + LynxEncodePlugin + LynxTemplatePlugin
18+ │
19+ ▼
20+main.lynx.bundle (TASM-encoded native bundle)
21+ │
22+ ▼
23+LynxJS Explorer (iOS/Android)
24+```
25+
26+## Runtime architecture
27+
28+Follows the [miso-lynx](https://github.com/haskell-miso/miso-lynx) pattern: **main-thread execution** with direct PAPI calls.
29+
30+### Lifecycle
31+
32+1. LynxJS loads the bundle
33+2. Module code runs — sets up `runWorklet`, `processData`, `renderPage`, etc. on `globalThis`
34+3. LynxJS calls `renderPage()` — creates the page, sets `globalThis['page']`, inits Elm
35+4. Elm's TEA loop runs: `init` → `view` → render via PAPIs → `FlushElementTree`
36+5. User taps → worklet event fires → Elm `update` → re-render → `FlushElementTree`
37+
38+### Key globals
39+
40+| Global | Purpose |
41+|--------|---------|
42+| `globalThis['runWorklet']` | Called by LynxJS to execute worklet event handlers. **Required for events.** |
43+| `globalThis['page']` | The root page element. Set by `renderPage`. |
44+| `globalThis['native']['currentPageId']` | Page ID for element creation PAPIs. |
45+| `globalThis['renderPage']` | Lifecycle callback — creates page and inits the app. |
46+| `globalThis['processData']` | Lifecycle callback (stub). |
47+| `globalThis['updatePage']` | Lifecycle callback (stub). |
48+
49+### PAPIs used
50+
51+| PAPI | Purpose |
52+|------|---------|
53+| `__CreatePage('0', 0)` | Create a page |
54+| `__GetElementUniqueID(page)` | Get page ID for element creation |
55+| `__CreateView(pageId)` | Create a `<view>` element |
56+| `__CreateText(pageId)` | Create a `<text>` element |
57+| `__CreateImage(pageId)` | Create an `<image>` element |
58+| `__CreateRawText(string)` | Create an inline text node |
59+| `__AppendElement(parent, child)` | Append child to parent |
60+| `__RemoveElement(parent, child)` | Remove child from parent |
61+| `__ReplaceElement(parent, new, old)` | Replace element |
62+| `__InsertElementBefore(parent, child, ref)` | Insert before reference |
63+| `__SetAttribute(node, key, value)` | Set attribute (text content: key=`'text'`) |
64+| `__SetInlineStyles(node, cssObject)` | Set styles (camelCase keys, values need units like `'20px'`) |
65+| `__AddEvent(el, 'catchEvent', name, {type:'worklet', value:fn})` | Register tap/event handler |
66+| `__FlushElementTree()` | Commit element tree changes to native renderer |
67+| `__GetChildren(node)` | Get child elements |
68+| `__GetParent(node)` | Get parent element |
69+
70+## Kernel patches
71+
72+The Elm compiler uses standard `elm/virtual-dom` and `elm/browser` packages, but their kernel JS files are patched to replace browser DOM calls with LynxJS PAPIs.
73+
74+### VirtualDom kernel (`virtual-dom/src/Elm/Kernel/VirtualDom.js`)
75+
76+- Element creation: `document.createElement` → `__CreateView(pageId)` / `__CreateText(pageId)` dispatch
77+- Text nodes: `document.createTextNode` → `__CreateRawText(text)`
78+- DOM manipulation: `appendChild`, `removeChild`, etc. → LynxJS equivalents
79+- Styles: `domNode.style[key] = value` → `__SetInlineStyles(node, styles)`
80+- Attributes: `domNode.setAttribute` → `__SetAttribute`
81+- Events: `addEventListener` → `__AddEvent` with worklet format
82+- Event name mapping: `click`→`tap`, `mousedown`→`touchstart`, etc.
83+- XSS protections: removed (not applicable in native context)
84+- Element metadata: stored in `Map` instead of DOM node properties
85+
86+### Browser kernel (`browser/src/Elm/Kernel/Browser.js`)
87+
88+- Page root: `globalThis['page']` instead of `document.body`
89+- Flush: `__FlushElementTree()` after initial render and each update
90+- Navigation: stubbed (no URLs in native)
91+- `requestAnimationFrame`: replaced with `setTimeout`
92+- DOM queries: stubbed (no `getElementById` in native)
93+
94+## Bundler setup
95+
96+Uses raw rspack (NOT rspeedy/ReactLynx).
97+
98+### `~/.lynxjs-elm/bundler/` structure
99+
100+```
101+package.json # "type": "module", @lynx-js/template-webpack-plugin@0.6.4
102+rspack.config.js # LynxEncodePlugin + LynxTemplatePlugin + MarkMainThread
103+src/
104+ stubs.js # Runtime polyfills (runWorklet, processData, etc.)
105+ elm.js # Compiled Elm output (copied from examples/)
106+ init.js # renderPage + Elm init
107+ all.js # stubs.js + elm.js + init.js concatenated
108+dist/
109+ main.lynx.bundle # Final output
110+```
111+
112+### Critical config requirements
113+
114+- `"type": "module"` in `package.json` — without it bundles fail to load
115+- `@lynx-js/template-webpack-plugin` must be `0.6.4` — newer versions produce incompatible bundles
116+- `main.js` must be marked with `"lynx:main-thread": true` — runs code on main thread
117+- Single entry (`all.js`) — concatenated stubs + Elm + init
118+
119+## Build flow
120+
121+```bash
122+# 1. Build the compiler (embeds forked packages)
123+cd compiler && stack build && stack install
124+
125+# 2. Compile and bundle an example
126+cd examples/counter
127+lynxjs-elm make src/Main.elm # → main.lynx.bundle
128+# or
129+lynxjs-elm dev src/Main.elm # dev server with watch
130+```
131+
132+The compiler automatically downloads standard packages and installs forked packages (virtual-dom, browser, http) from embedded content on first use.
133+
134+## Project structure
135+
136+```
137+lynxjs-elm/
138+├── compiler/ # Forked Elm compiler
139+│ └── packages/ # Forked elm packages (embedded at build time)
140+│ ├── virtual-dom/
141+│ ├── browser/
142+│ └── http/
143+├── examples/
144+│ └── counter/ # Counter example app
145+└── ui/ # lynx/ui Elm package
146+```
147+
148+## Known limitations
149+
150+- Only `Browser.sandbox` tested (`Browser.element`, `Browser.document`, `Browser.application` untested)
151+- Only `tap` events tested (scroll, touch, input untested)
152+- Event listeners are added but never removed on re-render
153+- CSS values require explicit units (`'20px'` not `'20'`)
154+- No navigation support (URLs/routing stubbed)
155+- `globalThis['page']` and `globalThis['native']` must be set up by `renderPage` — not available at module level
CLAUDE.mdnew file+62
@@ -0,0 +1,62 @@
1+# CLAUDE.md
2+
3+Elm on LynxJS — compile Elm apps to native iOS/Android UIs via LynxJS.
4+
5+## Build
6+
7+```bash
8+stack build # build the compiler
9+stack install # install lynxjs-elm to ~/.local/bin
10+```
11+
12+Nix is required (provides zlib). Stack snapshot: lts-24.34, GHC 9.10.3.
13+
14+## Usage
15+
16+```bash
17+cd examples/counter
18+lynxjs-elm make src/Main.elm # → main.lynx.bundle (default)
19+lynxjs-elm make src/Main.elm --output=foo.lynx.bundle # → foo.lynx.bundle
20+lynxjs-elm make src/Main.elm --output=elm.js # → raw JS only
21+lynxjs-elm dev src/Main.elm # dev server with watch
22+```
23+
24+The compiler automatically installs forked packages (virtual-dom, browser, http) from embedded content. Standard packages are downloaded from package.elm-lang.org on first use. Don't set `ELM_HOME` — the compiler defaults to `~/.lynxjs-elm`.
25+
26+## Project layout
27+
28+```
29+compiler/src/ # Core compiler: parser, type checker, code gen, AST
30+builder/src/ # Build system, package management, dependency resolution
31+terminal/src/ # CLI commands: Make.hs, Dev.hs, Init.hs, Install.hs, etc.
32+packages/ # Elm packages embedded into the compiler binary
33+ virtual-dom/ # LynxJS PAPI kernel (replaces DOM calls)
34+ browser/ # LynxJS page/flush lifecycle (replaces document.body)
35+ http/ # fetch-based kernel (replaces XMLHttpRequest)
36+ ui/ # lynx/ui — LynxJS native element helpers (Lynx, Lynx.Attributes, Lynx.Events)
37+examples/ # Demo apps (counter, hello-world, http-example)
38+```
39+
40+## Forked packages
41+
42+`packages/` contains forked elm/virtual-dom, elm/browser, elm/http, and the custom lynx/ui package. Upstream repos are at `github.com/lynxjs-elm/{virtual-dom,browser,http,ui}`. Their source is embedded into the compiler binary at build time via `file-embed` in `builder/src/Lynx/Patches.hs`. When a project depends on these packages, the compiler installs them from embedded content instead of downloading from package.elm-lang.org. The `lynx/ui` package is also injected into the package registry so the dependency solver can resolve it.
43+
44+After editing a fork, rebuild the compiler (`stack build && stack install`). The compiler automatically detects embedded content changes and invalidates caches.
45+
46+## Kernel JS rules
47+
48+The Elm kernel JS parser (`compiler/src/Elm/Kernel.hs`) has strict constraints:
49+
50+- `__` prefix in kernel JS is parsed as a kernel module reference. Use `'_' + '_'` string concatenation for LynxJS PAPIs (e.g., `__CreateView`).
51+- The parser is sensitive to byte structure — stick to ASCII in kernel JS files.
52+- After any kernel change, rebuild the compiler and clear the cache (`rm -rf ~/.lynxjs-elm`).
53+
54+## Bundler rules
55+
56+- Use raw rspack, NOT rspeedy/ReactLynx
57+- `@lynx-js/template-webpack-plugin` must be version `0.6.4` exactly
58+- `package.json` must have `"type": "module"`
59+- Elm init must happen inside `renderPage()`, not at module level
60+- `globalThis['runWorklet']` must be defined for events to work
61+- Elements use `__CreateView(pageId)` / `__CreateText(pageId)` (not `__CreateElement`)
62+- Events use `__AddEvent(el, 'catchEvent', name, { type: 'worklet', value: fn })`
ContributorAgreement.pdfdeleted

Binary file not shown.

README.md+51−11
@@ -1,22 +1,62 @@
1−# Elm
1+# LynxJS Elm
22
3−A delightful language for reliable webapps.
3+Compile [Elm](https://elm-lang.org/) apps to native iOS/Android UIs via [LynxJS](https://lynxjs.org/).
44
5−Check out the [Home Page](http://elm-lang.org/), [Try Online](http://elm-lang.org/try), or [The Official Guide](http://guide.elm-lang.org/)
5+This is a fork of the Elm compiler that replaces the browser DOM backend with LynxJS PAPI calls, letting you write Elm apps that render as native mobile views.
66
7+## Install
78
8−<br>
9+```bash
10+stack build && stack install
11+```
912
10−## Install
13+Requires Nix (provides zlib). This installs `lynxjs-elm` to `~/.local/bin`.
14+
15+## Usage
16+
17+```bash
18+cd examples/counter
19+lynxjs-elm make src/Main.elm # → main.lynx.bundle (default)
20+lynxjs-elm make src/Main.elm --output=foo.lynx.bundle # → custom output name
21+lynxjs-elm make src/Main.elm --output=elm.js # → raw JS only
22+lynxjs-elm dev src/Main.elm # dev server with watch
23+```
24+
25+The compiler automatically installs its forked packages from embedded content — no setup scripts needed. Standard Elm packages are downloaded from package.elm-lang.org on first use.
26+
27+## Project layout
28+
29+```
30+compiler/src/ # Core compiler: parser, type checker, code gen, AST
31+builder/src/ # Build system, package management, dependency resolution
32+terminal/src/ # CLI commands: Make.hs, Dev.hs, Init.hs, Install.hs, etc.
33+packages/ # Elm packages embedded into the compiler binary
34+ virtual-dom/ # LynxJS PAPI kernel (replaces DOM calls)
35+ browser/ # LynxJS page/flush lifecycle (replaces document.body)
36+ http/ # fetch-based kernel (replaces XMLHttpRequest)
37+ ui/ # LynxJS native element helpers (Lynx, Lynx.Attributes, Lynx.Events)
38+examples/ # Demo apps (counter, hello-world, http-example)
39+```
40+
41+## Embedded packages
1142
12−✨ [Install](https://guide.elm-lang.org/install/elm.html) ✨
43+The compiler embeds forked versions of `elm/virtual-dom`, `elm/browser`, `elm/http`, and the custom `lynxjs-elm/ui` package directly into the binary. When a project depends on these, the compiler installs them from embedded content instead of fetching from the package registry. The `lynxjs-elm/ui` package is also injected into the package registry so the dependency solver can resolve it.
1344
14−For multiple versions, previous versions, and uninstallation, see the instructions [here](https://github.com/elm/compiler/blob/master/installers/README.md).
45+- [`lynxjs-elm/ui`](packages/ui/README.md) — Native element constructors, attributes, and events
46+- [`lynxjs-elm/browser`](packages/browser/README.md) — Application lifecycle (sandbox, element, document)
47+- [`lynxjs-elm/http`](packages/http/README.md) — Fetch-based HTTP requests
48+- [`lynxjs-elm/virtual-dom`](packages/virtual-dom/README.md) — Low-level virtual DOM with LynxJS PAPI
49+- [`lynxjs-elm/crypto`](packages/crypto/README.md) — Elliptic curves and AEAD ciphers
1550
16−<br>
51+Upstream repos: [github.com/lynxjs-elm](https://github.com/lynxjs-elm)
1752
18−## Help
53+## Examples
1954
20−If you are stuck, ask around on [the Elm slack channel][slack]. Folks are friendly and happy to help with questions!
55+- **counter** — TEA counter with increment/decrement buttons
56+- **hello-world** — Minimal static view
57+- **http-example** — HTTP requests with JSON decoding
2158
22−[slack]: http://elmlang.herokuapp.com/
59+```bash
60+cd examples/counter
61+lynxjs-elm make src/Main.elm
62+```
builder/src/Build.hs+4−4
@@ -17,7 +17,7 @@ module Build
1717
1818import Control.Concurrent (forkIO)
1919import Control.Concurrent.MVar
20−import Control.Monad (filterM, mapM_, sequence_)
20+import Control.Monad (filterM)
2121import qualified Data.ByteString as B
2222import qualified Data.Char as Char
2323import qualified Data.Graph as Graph
@@ -75,7 +75,7 @@ data Env =
7575
7676
7777makeEnv :: Reporting.BKey -> FilePath -> Details.Details -> IO Env
78−makeEnv key root (Details.Details _ validOutline buildID locals foreigns _) =
78+makeEnv key root (Details.Details _ _ validOutline buildID locals foreigns _) =
7979 case validOutline of
8080 Details.ValidApp givenSrcDirs ->
8181 do srcDirs <- traverse (toAbsoluteSrcDir root) (NE.toList givenSrcDirs)
@@ -749,9 +749,9 @@ projectTypeToPkg projectType =
749749
750750
751751writeDetails :: FilePath -> Details.Details -> Map.Map ModuleName.Raw Result -> IO ()
752−writeDetails root (Details.Details time outline buildID locals foreigns extras) results =
752+writeDetails root (Details.Details time fh outline buildID locals foreigns extras) results =
753753 File.writeBinary (Stuff.details root) $
754− Details.Details time outline buildID (Map.foldrWithKey addNewLocal locals results) foreigns extras
754+ Details.Details time fh outline buildID (Map.foldrWithKey addNewLocal locals results) foreigns extras
755755
756756
757757addNewLocal :: ModuleName.Raw -> Result -> Map.Map ModuleName.Raw Details.Local -> Map.Map ModuleName.Raw Details.Local
builder/src/Deps/Registry.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE BangPatterns, OverloadedStrings #-}
32module Deps.Registry
43 ( Registry(..)
builder/src/Deps/Solver.hs+5−6
@@ -32,6 +32,7 @@ import qualified Elm.Version as V
3232import qualified File
3333import qualified Http
3434import qualified Json.Decode as D
35+import qualified Lynx.Patches as Lynx
3536import qualified Reporting.Exit as Exit
3637import qualified Stuff
3738
@@ -354,6 +355,7 @@ initEnv =
354355 do mvar <- newEmptyMVar
355356 _ <- forkIO $ putMVar mvar =<< Http.getManager
356357 cache <- Stuff.getPackageCache
358+ Lynx.installAllForks cache
357359 Stuff.withRegistryLock cache $
358360 do maybeRegistry <- Registry.read cache
359361 manager <- readMVar mvar
@@ -363,7 +365,7 @@ initEnv =
363365 do eitherRegistry <- Registry.fetch manager cache
364366 case eitherRegistry of
365367 Right latestRegistry ->
366− return $ Right $ Env cache manager (Online manager) latestRegistry
368+ return $ Right $ Env cache manager (Online manager) (Lynx.injectRegistry latestRegistry)
367369
368370 Left problem ->
369371 return $ Left $ problem
@@ -372,10 +374,10 @@ initEnv =
372374 do eitherRegistry <- Registry.update manager cache cachedRegistry
373375 case eitherRegistry of
374376 Right latestRegistry ->
375− return $ Right $ Env cache manager (Online manager) latestRegistry
377+ return $ Right $ Env cache manager (Online manager) (Lynx.injectRegistry latestRegistry)
376378
377379 Left _ ->
378− return $ Right $ Env cache manager Offline cachedRegistry
380+ return $ Right $ Env cache manager Offline (Lynx.injectRegistry cachedRegistry)
379381
380382
381383
@@ -408,9 +410,6 @@ instance Applicative Solver where
408410
409411
410412instance Monad Solver where
411− return a =
412− Solver $ \state ok back _ -> ok state a back
413−
414413 (>>=) (Solver solverA) callback =
415414 Solver $ \state ok back err ->
416415 let
builder/src/Elm/Details.hs+24−15
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE BangPatterns, OverloadedStrings #-}
32module Elm.Details
43 ( Details(..)
@@ -40,6 +39,7 @@ import qualified Compile
4039import qualified Deps.Registry as Registry
4140import qualified Deps.Solver as Solver
4241import qualified Deps.Website as Website
42+import qualified Lynx.Patches as Lynx
4343import qualified Elm.Constraint as Con
4444import qualified Elm.Docs as Docs
4545import qualified Elm.Interface as I
@@ -67,6 +67,7 @@ import qualified Stuff
6767data Details =
6868 Details
6969 { _outlineTime :: File.Time
70+ , _forkHash :: Word64
7071 , _outline :: ValidOutline
7172 , _buildID :: BuildID
7273 , _locals :: Map.Map ModuleName.Raw Local
@@ -125,14 +126,14 @@ type Interfaces =
125126
126127
127128loadObjects :: FilePath -> Details -> IO (MVar (Maybe Opt.GlobalGraph))
128−loadObjects root (Details _ _ _ _ _ extras) =
129+loadObjects root (Details _ _ _ _ _ _ extras) =
129130 case extras of
130131 ArtifactsFresh _ o -> newMVar (Just o)
131132 ArtifactsCached -> fork (File.readBinary (Stuff.objects root))
132133
133134
134135loadInterfaces :: FilePath -> Details -> IO (MVar (Maybe Interfaces))
135−loadInterfaces root (Details _ _ _ _ _ extras) =
136+loadInterfaces root (Details _ _ _ _ _ _ extras) =
136137 case extras of
137138 ArtifactsFresh i _ -> newMVar (Just i)
138139 ArtifactsCached -> fork (File.readBinary (Stuff.interfaces root))
@@ -164,8 +165,8 @@ load style scope root =
164165 Nothing ->
165166 generate style scope root newTime
166167
167− Just details@(Details oldTime _ buildID _ _ _) ->
168− if oldTime == newTime
168+ Just details@(Details oldTime oldHash _ buildID _ _ _) ->
169+ if oldTime == newTime && oldHash == Lynx.forkContentHash
169170 then return (Right details { _buildID = buildID + 1 })
170171 else generate style scope root newTime
171172
@@ -331,7 +332,7 @@ verifyDependencies env@(Env key scope root cache _ _ _) time outline solution di
331332 objs = Map.foldr addObjects Opt.empty artifacts
332333 ifaces = Map.foldrWithKey (addInterfaces directDeps) Map.empty artifacts
333334 foreigns = Map.map (OneOrMore.destruct Foreign) $ Map.foldrWithKey gatherForeigns Map.empty $ Map.intersection artifacts directDeps
334− details = Details time outline 0 Map.empty foreigns (ArtifactsFresh ifaces objs)
335+ details = Details time Lynx.forkContentHash outline 0 Map.empty foreigns (ArtifactsFresh ifaces objs)
335336 in
336337 do BW.writeBinary scope (Stuff.objects root) objs
337338 BW.writeBinary scope (Stuff.interfaces root) ifaces
@@ -381,19 +382,26 @@ type Dep =
381382verifyDep :: Env -> MVar (Map.Map Pkg.Name (MVar Dep)) -> Map.Map Pkg.Name Solver.Details -> Pkg.Name -> Solver.Details -> IO Dep
382383verifyDep (Env key _ _ cache manager _ _) depsMVar solution pkg details@(Solver.Details vsn directDeps) =
383384 do let fingerprint = Map.intersectionWith (\(Solver.Details v _) _ -> v) solution directDeps
385+ -- For forked packages (virtual-dom, browser, http), install from
386+ -- embedded content instead of downloading from package.elm-lang.org.
387+ forkChanged <- Lynx.installFork cache pkg vsn
384388 exists <- Dir.doesDirectoryExist (Stuff.package cache pkg vsn </> "src")
385389 if exists
386390 then
387391 do Reporting.report key Reporting.DCached
388− maybeCache <- File.readBinary (Stuff.package cache pkg vsn </> "artifacts.dat")
389− case maybeCache of
390− Nothing ->
392+ if forkChanged
393+ then
391394 build key cache depsMVar pkg details fingerprint Set.empty
395+ else
396+ do maybeCache <- File.readBinary (Stuff.package cache pkg vsn </> "artifacts.dat")
397+ case maybeCache of
398+ Nothing ->
399+ build key cache depsMVar pkg details fingerprint Set.empty
392400
393− Just (ArtifactCache fingerprints artifacts) ->
394− if Set.member fingerprint fingerprints
395− then Reporting.report key Reporting.DBuilt >> return (Right artifacts)
396− else build key cache depsMVar pkg details fingerprint fingerprints
401+ Just (ArtifactCache fingerprints artifacts) ->
402+ if Set.member fingerprint fingerprints
403+ then Reporting.report key Reporting.DBuilt >> return (Right artifacts)
404+ else build key cache depsMVar pkg details fingerprint fingerprints
397405 else
398406 do Reporting.report key Reporting.DRequested
399407 result <- downloadPackage cache manager pkg vsn
@@ -782,14 +790,15 @@ endpointDecoder =
782790
783791
784792instance Binary Details where
785− put (Details a b c d e _) = put a >> put b >> put c >> put d >> put e
793+ put (Details a b c d e f _) = put a >> put b >> put c >> put d >> put e >> put f
786794 get =
787795 do a <- get
788796 b <- get
789797 c <- get
790798 d <- get
791799 e <- get
792− return (Details a b c d e ArtifactsCached)
800+ f <- get
801+ return (Details a b c d e f ArtifactsCached)
793802
794803
795804instance Binary ValidOutline where
builder/src/Elm/Outline.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE MultiWayIf, OverloadedStrings #-}
32module Elm.Outline
43 ( Outline(..)
builder/src/Lynx/Patches.hsnew file+221
@@ -0,0 +1,221 @@
1+{-# LANGUAGE TemplateHaskell #-}
2+module Lynx.Patches
3+ ( installFork
4+ , installAllForks
5+ , isFork
6+ , forkSuggestion
7+ , injectRegistry
8+ , forkContentHash
9+ )
10+ where
11+
12+
13+import qualified Data.ByteString as BS
14+import Data.FileEmbed (embedDir, embedFile)
15+import qualified Data.Map as Map
16+import Data.Word (Word64)
17+import qualified System.Directory as Dir
18+import System.FilePath ((</>), takeDirectory)
19+
20+import qualified Deps.Registry as Registry
21+import qualified Elm.Package as Pkg
22+import qualified Elm.Version as V
23+import qualified Stuff
24+
25+
26+
27+-- EMBEDDED PACKAGE CONTENT
28+--
29+-- Complete source trees from our forked/custom packages, baked into
30+-- the compiler binary at compile time.
31+
32+
33+virtualDomSrc :: [(FilePath, BS.ByteString)]
34+virtualDomSrc = $(embedDir "packages/virtual-dom/src")
35+
36+virtualDomElmJson :: BS.ByteString
37+virtualDomElmJson = $(embedFile "packages/virtual-dom/elm.json")
38+
39+
40+browserSrc :: [(FilePath, BS.ByteString)]
41+browserSrc = $(embedDir "packages/browser/src")
42+
43+browserElmJson :: BS.ByteString
44+browserElmJson = $(embedFile "packages/browser/elm.json")
45+
46+
47+httpSrc :: [(FilePath, BS.ByteString)]
48+httpSrc = $(embedDir "packages/http/src")
49+
50+httpElmJson :: BS.ByteString
51+httpElmJson = $(embedFile "packages/http/elm.json")
52+
53+
54+uiSrc :: [(FilePath, BS.ByteString)]
55+uiSrc = $(embedDir "packages/ui/src")
56+
57+uiElmJson :: BS.ByteString
58+uiElmJson = $(embedFile "packages/ui/elm.json")
59+
60+
61+cryptoSrc :: [(FilePath, BS.ByteString)]
62+cryptoSrc = $(embedDir "packages/crypto/src")
63+
64+cryptoElmJson :: BS.ByteString
65+cryptoElmJson = $(embedFile "packages/crypto/elm.json")
66+
67+
68+bytesSrc :: [(FilePath, BS.ByteString)]
69+bytesSrc = $(embedDir "packages/bytes/src")
70+
71+bytesElmJson :: BS.ByteString
72+bytesElmJson = $(embedFile "packages/bytes/elm.json")
73+
74+
75+
76+-- FORK CONTENT HASH
77+--
78+-- A hash of all embedded package content, used to invalidate the project
79+-- cache (elm-stuff) when the compiler is rebuilt with updated packages.
80+
81+
82+forkContentHash :: Word64
83+forkContentHash =
84+ let
85+ hashBS :: Word64 -> BS.ByteString -> Word64
86+ hashBS acc bs = BS.foldl' (\h b -> h * 31 + fromIntegral b) acc bs
87+
88+ allBytes :: [BS.ByteString]
89+ allBytes = concat
90+ [ virtualDomElmJson : map snd virtualDomSrc
91+ , browserElmJson : map snd browserSrc
92+ , httpElmJson : map snd httpSrc
93+ , uiElmJson : map snd uiSrc
94+ , cryptoElmJson : map snd cryptoSrc
95+ , bytesElmJson : map snd bytesSrc
96+ ]
97+ in
98+ foldl' hashBS 0 allBytes
99+
100+
101+
102+-- IS FORK
103+
104+
105+isFork :: Pkg.Name -> Bool
106+isFork pkg =
107+ pkg == Pkg.virtualDom || pkg == Pkg.browser || pkg == Pkg.http || pkg == Pkg.ui || pkg == Pkg.crypto || pkg == Pkg.bytes
108+
109+
110+-- FORK SUGGESTION
111+--
112+-- When a user tries to install elm/browser, elm/virtual-dom, or elm/http,
113+-- suggest the lynxjs-elm fork instead.
114+
115+
116+forkSuggestion :: Pkg.Name -> Maybe Pkg.Name
117+forkSuggestion pkg
118+ | chars == "elm/virtual-dom" = Just Pkg.virtualDom
119+ | chars == "elm/browser" = Just Pkg.browser
120+ | chars == "elm/http" = Just Pkg.http
121+ | chars == "elm/bytes" = Just Pkg.bytes
122+ | otherwise = Nothing
123+ where
124+ chars = Pkg.toChars pkg
125+
126+
127+
128+-- INSTALL ALL FORKS
129+--
130+-- Pre-install all embedded packages so their elm.json is available
131+-- for the dependency solver before it tries to fetch from the network.
132+
133+
134+installAllForks :: Stuff.PackageCache -> IO ()
135+installAllForks cache =
136+ do _ <- installFork cache Pkg.virtualDom (V.Version 1 0 0)
137+ _ <- installFork cache Pkg.browser (V.Version 1 0 0)
138+ _ <- installFork cache Pkg.http (V.Version 1 0 0)
139+ _ <- installFork cache Pkg.ui (V.Version 1 0 0)
140+ _ <- installFork cache Pkg.crypto (V.Version 1 0 0)
141+ _ <- installFork cache Pkg.bytes (V.Version 1 0 0)
142+ return ()
143+
144+
145+
146+-- INSTALL FORK
147+--
148+-- Write the complete package to the cache directory.
149+-- Returns True if any file was written (new install or content changed).
150+
151+
152+installFork :: Stuff.PackageCache -> Pkg.Name -> V.Version -> IO Bool
153+installFork cache pkg vsn =
154+ case getForkContent pkg of
155+ Nothing ->
156+ return False
157+
158+ Just (elmJson, srcFiles) ->
159+ do let pkgDir = Stuff.package cache pkg vsn
160+ Dir.createDirectoryIfMissing True (pkgDir </> "src")
161+ jsonChanged <- writeIfChanged pkgDir ("elm.json", elmJson)
162+ srcChanged <- mapM (writeIfChanged (pkgDir </> "src")) srcFiles
163+ return (jsonChanged || or srcChanged)
164+
165+
166+getForkContent :: Pkg.Name -> Maybe (BS.ByteString, [(FilePath, BS.ByteString)])
167+getForkContent pkg
168+ | pkg == Pkg.virtualDom = Just (virtualDomElmJson, virtualDomSrc)
169+ | pkg == Pkg.browser = Just (browserElmJson, browserSrc)
170+ | pkg == Pkg.http = Just (httpElmJson, httpSrc)
171+ | pkg == Pkg.ui = Just (uiElmJson, uiSrc)
172+ | pkg == Pkg.crypto = Just (cryptoElmJson, cryptoSrc)
173+ | pkg == Pkg.bytes = Just (bytesElmJson, bytesSrc)
174+ | otherwise = Nothing
175+
176+
177+
178+-- INJECT REGISTRY
179+--
180+-- Add our custom packages (lynx/ui) to the package registry so the
181+-- dependency solver can resolve them. Forked packages (virtual-dom,
182+-- browser, http) are already in the upstream registry.
183+
184+
185+injectRegistry :: Registry.Registry -> Registry.Registry
186+injectRegistry (Registry.Registry count versions) =
187+ let
188+ newPkgs =
189+ [ (Pkg.virtualDom, Registry.KnownVersions (V.Version 1 0 0) [])
190+ , (Pkg.browser, Registry.KnownVersions (V.Version 1 0 0) [])
191+ , (Pkg.http, Registry.KnownVersions (V.Version 1 0 0) [])
192+ , (Pkg.ui, Registry.KnownVersions (V.Version 1 0 0) [])
193+ , (Pkg.crypto, Registry.KnownVersions (V.Version 1 0 0) [])
194+ , (Pkg.bytes, Registry.KnownVersions (V.Version 1 0 0) [])
195+ ]
196+ additions = filter (\(k, _) -> not (Map.member k versions)) newPkgs
197+ newVersions = foldr (\(k, v) m -> Map.insert k v m) versions additions
198+ newCount = count + length additions
199+ in
200+ Registry.Registry newCount newVersions
201+
202+
203+
204+-- WRITE HELPERS
205+
206+
207+writeIfChanged :: FilePath -> (FilePath, BS.ByteString) -> IO Bool
208+writeIfChanged dir (relPath, content) =
209+ do let fullPath = dir </> relPath
210+ fileExists <- Dir.doesFileExist fullPath
211+ if fileExists
212+ then
213+ do existing <- BS.readFile fullPath
214+ if existing == content
215+ then return False
216+ else do BS.writeFile fullPath content
217+ return True
218+ else
219+ do Dir.createDirectoryIfMissing True (takeDirectory fullPath)
220+ BS.writeFile fullPath content
221+ return True
builder/src/Reporting.hs+1−1
@@ -39,7 +39,7 @@ import qualified Elm.ModuleName as ModuleName
3939import qualified Elm.Package as Pkg
4040import qualified Elm.Version as V
4141import qualified Json.Encode as Encode
42−import Reporting.Doc ((<+>), (<>))
42+import Reporting.Doc ((<+>))
4343import qualified Reporting.Doc as D
4444import qualified Reporting.Exit as Exit
4545import qualified Reporting.Exit.Help as Help
builder/src/Reporting/Exit.hs+14−1
@@ -53,7 +53,6 @@ import qualified Json.Encode as Encode
5353import qualified Json.String as Json
5454import Parse.Primitives (Row, Col)
5555import qualified Reporting.Annotation as A
56−import Reporting.Doc ((<>))
5756import qualified Reporting.Doc as D
5857import qualified Reporting.Error.Import as Import
5958import qualified Reporting.Error.Json as Json
@@ -747,6 +746,7 @@ data Install
747746 | InstallHadSolverTrouble Solver
748747 | InstallUnknownPackageOnline Pkg.Name [Pkg.Name]
749748 | InstallUnknownPackageOffline Pkg.Name [Pkg.Name]
749+ | InstallForkSuggestion Pkg.Name Pkg.Name
750750 | InstallBadDetails Details
751751
752752
@@ -891,6 +891,19 @@ installToReport exit =
891891 , D.reflow $ "Maybe you want one of these instead?"
892892 ]
893893
894+ InstallForkSuggestion pkg forkPkg ->
895+ Help.docReport "FORKED PACKAGE" Nothing
896+ (
897+ D.fillSep
898+ ["The","package",D.red (D.fromPackage pkg),"has","been","replaced"
899+ ,"by",D.green (D.fromPackage forkPkg),"for","LynxJS."
900+ ]
901+ )
902+ [ D.reflow "Try this instead:"
903+ , D.indent 4 $ D.green $ D.fromChars $
904+ "lynxjs-elm install " ++ Pkg.toChars forkPkg
905+ ]
906+
894907 InstallBadDetails details ->
895908 toDetailsReport details
896909
builder/src/Stuff.hs+2−3
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21module Stuff
32 ( details
43 , interfaces
@@ -173,7 +172,7 @@ getCacheDir projectName =
173172
174173getElmHome :: IO FilePath
175174getElmHome =
176− do maybeCustomHome <- Env.lookupEnv "ELM_HOME"
175+ do maybeCustomHome <- Env.lookupEnv "LYNXJS_ELM_HOME"
177176 case maybeCustomHome of
178177 Just customHome -> return customHome
179− Nothing -> Dir.getAppUserDataDirectory "elm"
178+ Nothing -> Dir.getAppUserDataDirectory "lynxjs-elm"
compiler/src/AST/Canonical.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE OverloadedStrings #-}
32module AST.Canonical
43 ( Expr, Expr_(..)
compiler/src/AST/Optimized.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21module AST.Optimized
32 ( Def(..)
43 , Expr(..)
compiler/src/AST/Source.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21module AST.Source
32 ( Expr, Expr_(..), VarType(..)
43 , Def(..)
compiler/src/AST/Utils/Binop.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21module AST.Utils.Binop
32 ( Precedence(..)
43 , Associativity(..)
compiler/src/AST/Utils/Shader.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE EmptyDataDecls #-}
32module AST.Utils.Shader
43 ( Source
compiler/src/AST/Utils/Type.hs−2
@@ -1,5 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
2−{-# LANGUAGE OverloadedStrings #-}
31module AST.Utils.Type
42 ( delambda
53 , dealias
compiler/src/Canonicalize/Effects.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE OverloadedStrings #-}
32module Canonicalize.Effects
43 ( canonicalize
compiler/src/Canonicalize/Environment.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE OverloadedStrings #-}
32module Canonicalize.Environment
43 ( Env(..)
compiler/src/Canonicalize/Environment/Dups.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE OverloadedStrings #-}
32module Canonicalize.Environment.Dups
43 ( detect
compiler/src/Canonicalize/Environment/Foreign.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE BangPatterns #-}
32{-# LANGUAGE OverloadedStrings #-}
43module Canonicalize.Environment.Foreign
compiler/src/Canonicalize/Environment/Local.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE OverloadedStrings #-}
32module Canonicalize.Environment.Local
43 ( add
compiler/src/Canonicalize/Expression.hs+1−1
@@ -1,4 +1,4 @@
1−{-# OPTIONS_GHC -Wall #-}
1+{-# OPTIONS_GHC -fno-warn-x-partial #-}
22{-# LANGUAGE OverloadedStrings #-}
33module Canonicalize.Expression
44 ( canonicalize
compiler/src/Canonicalize/Module.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21module Canonicalize.Module
32 ( canonicalize
43 )
compiler/src/Canonicalize/Pattern.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21module Canonicalize.Pattern
32 ( verify
43 , Bindings
compiler/src/Canonicalize/Type.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE OverloadedStrings #-}
32module Canonicalize.Type
43 ( toAnnotation
compiler/src/Data/Bag.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21module Data.Bag
32 ( Bag(..)
43 , empty
compiler/src/Data/Name.hs+5−12
@@ -44,14 +44,7 @@ import qualified Data.Coerce as Coerce
4444import qualified Data.List as List
4545import qualified Data.String as Chars
4646import qualified Data.Utf8 as Utf8
47−import GHC.Exts
48− ( Int(I#), Ptr
49− , MutableByteArray#
50− , isTrue#
51− , newByteArray#
52− , sizeofByteArray#
53− , unsafeFreezeByteArray#
54− )
47+import GHC.Exts (Int(I#), Ptr, isTrue#)
5548import GHC.ST (ST(ST), runST)
5649import GHC.Prim
5750import GHC.Word (Word8(W8#))
@@ -241,7 +234,7 @@ fromTypeVariable name@(Utf8.Utf8 ba#) index =
241234 else
242235 let
243236 len# = sizeofByteArray# ba#
244− end# = indexWord8Array# ba# (len# -# 1#)
237+ end# = word8ToWord# (indexWord8Array# ba# (len# -# 1#))
245238 in
246239 if isTrue# (leWord# 0x30## end#) && isTrue# (leWord# end# 0x39##) then
247240 runST
@@ -316,11 +309,11 @@ fromManyNames names =
316309 ST $ \s ->
317310 case newByteArray# (len# +# 3#) s of
318311 (# s, mba# #) ->
319− case writeWord8Array# mba# 0# 0x5F## {-_-} s of
312+ case writeWord8Array# mba# 0# (wordToWord8# 0x5F##) {-_-} s of
320313 s ->
321− case writeWord8Array# mba# 1# 0x4D## {-M-} s of
314+ case writeWord8Array# mba# 1# (wordToWord8# 0x4D##) {-M-} s of
322315 s ->
323− case writeWord8Array# mba# 2# 0x24## {-$-} s of
316+ case writeWord8Array# mba# 2# (wordToWord8# 0x24##) {-$-} s of
324317 s ->
325318 case copyByteArray# ba# 0# mba# 3# len# s of
326319 s ->
compiler/src/Data/OneOrMore.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21module Data.OneOrMore
32 ( OneOrMore(..)
43 , one
compiler/src/Data/Utf8.hs+18−28
@@ -47,19 +47,7 @@ import qualified Data.List as List
4747import Foreign.ForeignPtr (touchForeignPtr)
4848import Foreign.ForeignPtr.Unsafe (unsafeForeignPtrToPtr)
4949import Foreign.Ptr (minusPtr, plusPtr)
50−import GHC.Exts
51− ( Int(I#), Ptr(Ptr), Char(C#)
52− , RealWorld
53− , ByteArray#, MutableByteArray#
54− , isTrue#
55− , newByteArray#
56− , unsafeFreezeByteArray#
57− , sizeofByteArray#
58− , copyByteArray#
59− , copyAddrToByteArray#
60− , copyByteArrayToAddr#
61− , writeWord8Array#
62− )
50+import GHC.Exts (Int(I#), Ptr(Ptr), Char(C#), isTrue#)
6351import GHC.IO
6452import GHC.ST (ST(ST), runST)
6553import GHC.Prim
@@ -109,10 +97,10 @@ contains (W8# word#) (Utf8 ba#) =
10997 containsHelp word# ba# 0# (sizeofByteArray# ba#)
11098
11199
112−containsHelp :: Word# -> ByteArray# -> Int# -> Int# -> Bool
100+containsHelp :: Word8# -> ByteArray# -> Int# -> Int# -> Bool
113101containsHelp word# ba# !offset# len# =
114102 if isTrue# (offset# <# len#) then
115− if isTrue# (eqWord# word# (indexWord8Array# ba# offset#))
103+ if isTrue# (eqWord8# word# (indexWord8Array# ba# offset#))
116104 then True
117105 else containsHelp word# ba# (offset# +# 1#) len#
118106 else
@@ -145,7 +133,7 @@ startsWithChar isGood bytes@(Utf8 ba#) =
145133 False
146134 else
147135 let
148− !w# = indexWord8Array# ba# 0#
136+ !w# = word8ToWord# (indexWord8Array# ba# 0#)
149137 !char
150138 | isTrue# (ltWord# w# 0xC0##) = C# (chr# (word2Int# w#))
151139 | isTrue# (ltWord# w# 0xE0##) = chr2 ba# 0# w#
@@ -164,7 +152,7 @@ endsWithWord8 (W8# w#) (Utf8 ba#) =
164152 let len# = sizeofByteArray# ba# in
165153 isTrue# (len# ># 0#)
166154 &&
167− isTrue# (eqWord# w# (indexWord8Array# ba# (len# -# 1#)))
155+ isTrue# (eqWord8# w# (indexWord8Array# ba# (len# -# 1#)))
168156
169157
170158
@@ -186,11 +174,11 @@ splitHelp str start offsets =
186174 unsafeSlice str start offset : splitHelp str (offset + 1) offsets
187175
188176
189−findDividers :: Word# -> ByteArray# -> Int# -> Int# -> [Int] -> [Int]
177+findDividers :: Word8# -> ByteArray# -> Int# -> Int# -> [Int] -> [Int]
190178findDividers divider# ba# !offset# len# revOffsets =
191179 if isTrue# (offset# <# len#) then
192180 findDividers divider# ba# (offset# +# 1#) len# $
193− if isTrue# (eqWord# divider# (indexWord8Array# ba# offset#))
181+ if isTrue# (eqWord8# divider# (indexWord8Array# ba# offset#))
194182 then I# offset# : revOffsets
195183 else revOffsets
196184 else
@@ -261,7 +249,9 @@ instance Eq (Utf8 t) where
261249
262250
263251-- COMPARE
264−
252+--
253+-- TODO: is it fine to sort by length and only compare bytes on length ties?
254+--
265255
266256instance Ord (Utf8 t) where
267257 compare (Utf8 ba1#) (Utf8 ba2#) =
@@ -351,7 +341,7 @@ toCharsHelp ba# offset# len# =
351341 []
352342 else
353343 let
354− !w# = indexWord8Array# ba# offset#
344+ !w# = word8ToWord# (indexWord8Array# ba# offset#)
355345 !(# char, width# #)
356346 | isTrue# (ltWord# w# 0xC0##) = (# C# (chr# (word2Int# w#)), 1# #)
357347 | isTrue# (ltWord# w# 0xE0##) = (# chr2 ba# offset# w#, 2# #)
@@ -368,7 +358,7 @@ chr2 :: ByteArray# -> Int# -> Word# -> Char
368358chr2 ba# offset# firstWord# =
369359 let
370360 !i1# = word2Int# firstWord#
371− !i2# = word2Int# (indexWord8Array# ba# (offset# +# 1#))
361+ !i2# = word2Int# (word8ToWord# (indexWord8Array# ba# (offset# +# 1#)))
372362 !c1# = uncheckedIShiftL# (i1# -# 0xC0#) 6#
373363 !c2# = i2# -# 0x80#
374364 in
@@ -380,8 +370,8 @@ chr3 :: ByteArray# -> Int# -> Word# -> Char
380370chr3 ba# offset# firstWord# =
381371 let
382372 !i1# = word2Int# firstWord#
383− !i2# = word2Int# (indexWord8Array# ba# (offset# +# 1#))
384− !i3# = word2Int# (indexWord8Array# ba# (offset# +# 2#))
373+ !i2# = word2Int# (word8ToWord# (indexWord8Array# ba# (offset# +# 1#)))
374+ !i3# = word2Int# (word8ToWord# (indexWord8Array# ba# (offset# +# 2#)))
385375 !c1# = uncheckedIShiftL# (i1# -# 0xE0#) 12#
386376 !c2# = uncheckedIShiftL# (i2# -# 0x80#) 6#
387377 !c3# = i3# -# 0x80#
@@ -394,9 +384,9 @@ chr4 :: ByteArray# -> Int# -> Word# -> Char
394384chr4 ba# offset# firstWord# =
395385 let
396386 !i1# = word2Int# firstWord#
397− !i2# = word2Int# (indexWord8Array# ba# (offset# +# 1#))
398− !i3# = word2Int# (indexWord8Array# ba# (offset# +# 2#))
399− !i4# = word2Int# (indexWord8Array# ba# (offset# +# 3#))
387+ !i2# = word2Int# (word8ToWord# (indexWord8Array# ba# (offset# +# 1#)))
388+ !i3# = word2Int# (word8ToWord# (indexWord8Array# ba# (offset# +# 2#)))
389+ !i4# = word2Int# (word8ToWord# (indexWord8Array# ba# (offset# +# 3#)))
400390 !c1# = uncheckedIShiftL# (i1# -# 0xF0#) 18#
401391 !c2# = uncheckedIShiftL# (i2# -# 0x80#) 12#
402392 !c3# = uncheckedIShiftL# (i3# -# 0x80#) 6#
@@ -471,7 +461,7 @@ toEscapedBuilderHelp before after !name@(Utf8 ba#) k =
471461escape :: Word8 -> Word8 -> Ptr a -> Utf8 t -> Int -> Int -> Int -> IO ()
472462escape before@(W8# before#) after ptr name@(Utf8 ba#) offset@(I# offset#) len@(I# len#) i@(I# i#) =
473463 if isTrue# (i# <# len#) then
474− if isTrue# (eqWord# before# (indexWord8Array# ba# (offset# +# i#)))
464+ if isTrue# (eqWord8# before# (indexWord8Array# ba# (offset# +# i#)))
475465 then
476466 do writeWordToPtr ptr i after
477467 escape before after ptr name offset len (i + 1)
compiler/src/Elm/Compiler/Imports.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE OverloadedStrings #-}
32module Elm.Compiler.Imports
43 ( defaults
compiler/src/Elm/Compiler/Type.hs+1−1
@@ -1,4 +1,4 @@
1−{-# OPTIONS_GHC -Wall #-}
1+{-# OPTIONS_GHC -fno-warn-incomplete-uni-patterns #-}
22{-# LANGUAGE OverloadedStrings #-}
33module Elm.Compiler.Type
44 ( Type(..)
compiler/src/Elm/Compiler/Type/Extract.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE BangPatterns, OverloadedStrings, Rank2Types #-}
32module Elm.Compiler.Type.Extract
43 ( fromAnnotation
compiler/src/Elm/Constraint.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE OverloadedStrings #-}
32module Elm.Constraint
43 ( Constraint
compiler/src/Elm/Docs.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE BangPatterns, MultiWayIf, OverloadedStrings, UnboxedTuples #-}
32module Elm.Docs
43 ( Documentation
compiler/src/Elm/Float.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE EmptyDataDecls, FlexibleInstances #-}
32module Elm.Float
43 ( Float
compiler/src/Elm/Interface.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21module Elm.Interface
32 ( Interface(..)
43 , Union(..)
compiler/src/Elm/Kernel.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE BangPatterns, EmptyDataDecls, OverloadedStrings, UnboxedTuples #-}
32module Elm.Kernel
43 ( Content(..)
compiler/src/Elm/Licenses.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE OverloadedStrings #-}
32module Elm.Licenses
43 ( License
compiler/src/Elm/Package.hs+40−6
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE BangPatterns, EmptyDataDecls, FlexibleInstances, UnboxedTuples #-}
32module Elm.Package
43 ( Name(..)
@@ -15,6 +14,9 @@ module Elm.Package
1514 , browser, virtualDom, html
1615 , json, http, url
1716 , webgl, linearAlgebra
17+ , ui
18+ , crypto
19+ , bytes
1820 --
1921 , suggestions
2022 , nearbyNames
@@ -34,7 +36,6 @@ import qualified Data.Coerce as Coerce
3436import qualified Data.List as List
3537import qualified Data.Map as Map
3638import qualified Data.Name as Name
37−import Data.Monoid ((<>))
3839import qualified Data.Utf8 as Utf8
3940import Data.Word (Word8)
4041import Foreign.Ptr (Ptr, plusPtr, minusPtr)
@@ -82,7 +83,7 @@ data Canonical =
8283
8384isKernel :: Name -> Bool
8485isKernel (Name author _) =
85− author == elm || author == elm_explorations
86+ author == elm || author == elm_explorations || author == lynxjs_elm
8687
8788
8889toChars :: Name -> String
@@ -135,13 +136,13 @@ core =
135136{-# NOINLINE browser #-}
136137browser :: Name
137138browser =
138− toName elm "browser"
139+ toName lynxjs_elm "browser"
139140
140141
141142{-# NOINLINE virtualDom #-}
142143virtualDom :: Name
143144virtualDom =
144− toName elm "virtual-dom"
145+ toName lynxjs_elm "virtual-dom"
145146
146147
147148{-# NOINLINE html #-}
@@ -159,7 +160,7 @@ json =
159160{-# NOINLINE http #-}
160161http :: Name
161162http =
162− toName elm "http"
163+ toName lynxjs_elm "http"
163164
164165
165166{-# NOINLINE url #-}
@@ -192,6 +193,30 @@ elm_explorations =
192193 Utf8.fromChars "elm-explorations"
193194
194195
196+{-# NOINLINE lynxjs_elm #-}
197+lynxjs_elm :: Author
198+lynxjs_elm =
199+ Utf8.fromChars "lynxjs-elm"
200+
201+
202+{-# NOINLINE ui #-}
203+ui :: Name
204+ui =
205+ toName lynxjs_elm "ui"
206+
207+
208+{-# NOINLINE crypto #-}
209+crypto :: Name
210+crypto =
211+ toName lynxjs_elm "crypto"
212+
213+
214+{-# NOINLINE bytes #-}
215+bytes :: Name
216+bytes =
217+ toName lynxjs_elm "bytes"
218+
219+
195220
196221-- PACKAGE SUGGESTIONS
197222
@@ -218,6 +243,15 @@ suggestions =
218243 , "Time" ==> time
219244 , "Url.Parser" ==> url
220245 , "Url" ==> url
246+ , "Lynx" ==> ui
247+ , "Lynx.Attributes" ==> ui
248+ , "Lynx.Events" ==> ui
249+ , "Bytes" ==> bytes
250+ , "Bytes.Decode" ==> bytes
251+ , "Bytes.Encode" ==> bytes
252+ , "Crypto.Ed25519" ==> crypto
253+ , "Crypto.X25519" ==> crypto
254+ , "Crypto.Cipher" ==> crypto
221255 ]
222256
223257
compiler/src/Elm/Version.hs+2−3
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE BangPatterns, UnboxedTuples #-}
32module Elm.Version
43 ( Version(..)
@@ -24,7 +23,7 @@ import Data.Binary (Binary, get, put, getWord8, putWord8)
2423import qualified Data.Version as Version
2524import Data.Word (Word8, Word16)
2625import Foreign.Ptr (Ptr, plusPtr, minusPtr)
27−import qualified Paths_elm
26+import qualified Paths_lynxjs_elm
2827
2928import qualified Json.Decode as D
3029import qualified Json.Encode as E
@@ -57,7 +56,7 @@ max =
5756
5857compiler :: Version
5958compiler =
60− case map fromIntegral (Version.versionBranch Paths_elm.version) of
59+ case map fromIntegral (Version.versionBranch Paths_lynxjs_elm.version) of
6160 major : minor : patch : _ ->
6261 Version major minor patch
6362
compiler/src/Generate/Html.hs+166−24
@@ -2,12 +2,12 @@
22{-# LANGUAGE QuasiQuotes #-}
33module Generate.Html
44 ( sandwich
5+ , sandwichReactor
56 )
67 where
78
89
910import qualified Data.ByteString.Builder as B
10−import Data.Monoid ((<>))
1111import qualified Data.Name as Name
1212import Text.RawString.QQ (r)
1313
@@ -19,36 +19,178 @@ import Text.RawString.QQ (r)
1919sandwich :: Name.Name -> B.Builder -> B.Builder
2020sandwich moduleName javascript =
2121 let name = Name.toBuilder moduleName in
22− [r|<!DOCTYPE HTML>
22+ [r|<!DOCTYPE html>
2323<html>
2424<head>
25− <meta charset="UTF-8">
26− <title>|] <> name <> [r|</title>
27− <style>body { padding: 0; margin: 0; }</style>
25+<meta charset="UTF-8">
26+<meta name="viewport" content="width=device-width, initial-scale=1">
27+<title>LynxJS-Elm</title>
28+<style>
29+*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
30+body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
31+</style>
2832</head>
29−
3033<body>
34+<script>
35+|] <> polyfill <> [r|
36+</script>
37+<script>
38+|] <> javascript <> [r|
39+var app = Elm.|] <> name <> [r|.init({});
40+</script>
41+</body>
42+</html>
43+|]
44+
45+
3146
32−<pre id="elm"></pre>
47+-- REACTOR SANDWICH (with live reload)
3348
49+
50+sandwichReactor :: Name.Name -> B.Builder -> B.Builder
51+sandwichReactor moduleName javascript =
52+ let name = Name.toBuilder moduleName in
53+ [r|<!DOCTYPE html>
54+<html>
55+<head>
56+<meta charset="UTF-8">
57+<meta name="viewport" content="width=device-width, initial-scale=1">
58+<title>LynxJS-Elm</title>
59+<style>
60+*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
61+body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
62+</style>
63+</head>
64+<body>
65+<script>
66+|] <> polyfill <> [r|
67+</script>
3468<script>
35−try {
3669|] <> javascript <> [r|
37−
38− var app = Elm.|] <> name <> [r|.init({ node: document.getElementById("elm") });
39−}
40−catch (e)
41−{
42− // display initialization errors (e.g. bad flags, infinite recursion)
43− var header = document.createElement("h1");
44− header.style.fontFamily = "monospace";
45− header.innerText = "Initialization Error";
46− var pre = document.getElementById("elm");
47− document.body.insertBefore(header, pre);
48− pre.innerText = e;
49− throw e;
50−}
70+var app = Elm.|] <> name <> [r|.init({});
71+</script>
72+<script>
73+|] <> reloadScript <> [r|
5174</script>
52−
5375</body>
54−</html>|]
76+</html>
77+|]
78+
79+
80+
81+-- LIVE RELOAD SCRIPT
82+
83+
84+reloadScript :: B.Builder
85+reloadScript = [r|
86+(function() {
87+ var lastMtime = null;
88+ function poll() {
89+ fetch('/_elm/watch')
90+ .then(function(r) { return r.text(); })
91+ .then(function(mtime) {
92+ if (lastMtime === null) { lastMtime = mtime; }
93+ else if (mtime !== lastMtime) { location.reload(); }
94+ setTimeout(poll, 500);
95+ })
96+ .catch(function() { setTimeout(poll, 2000); });
97+ }
98+ poll();
99+})();
100+|]
101+
102+
103+
104+-- PAPI POLYFILL
105+
106+
107+polyfill :: B.Builder
108+polyfill = [r|
109+// LynxJS PAPI-to-DOM polyfill for browser preview
110+(function() {
111+ var eventMap = {
112+ 'tap': 'click',
113+ 'longpress': 'contextmenu',
114+ 'touchstart': 'touchstart',
115+ 'touchmove': 'touchmove',
116+ 'touchend': 'touchend',
117+ 'touchcancel': 'touchcancel',
118+ 'input': 'input'
119+ };
120+
121+ var g = typeof globalThis !== 'undefined' ? globalThis : window;
122+
123+ function makeEl(domTag, lynxTag) {
124+ var el = document.createElement(domTag);
125+ el.setAttribute('data-lynx-tag', lynxTag);
126+ return el;
127+ }
128+
129+ g.__CreatePage = function() {
130+ var page = document.createElement('div');
131+ page.id = 'lynx-page';
132+ document.body.appendChild(page);
133+ return page;
134+ };
135+
136+ g.__CreateView = function() { return makeEl('div', 'view'); };
137+ g.__CreateText = function() { return makeEl('span', 'text'); };
138+ g.__CreateImage = function() { return makeEl('img', 'image'); };
139+
140+ g.__CreateRawText = function(text) {
141+ var el = document.createElement('span');
142+ el.setAttribute('data-lynx-tag', 'raw-text');
143+ el.textContent = text;
144+ return el;
145+ };
146+
147+ g.__AppendElement = function(parent, child) {
148+ parent.appendChild(child);
149+ };
150+
151+ g.__RemoveElement = function(parent, child) {
152+ parent.removeChild(child);
153+ };
154+
155+ g.__ReplaceElement = function(parent, newEl, oldEl) {
156+ parent.replaceChild(newEl, oldEl);
157+ };
158+
159+ g.__InsertElementBefore = function(parent, child, ref) {
160+ parent.insertBefore(child, ref);
161+ };
162+
163+ g.__SetAttribute = function(el, key, value) {
164+ if (key === 'text') {
165+ el.textContent = value;
166+ } else if (key === 'src' && el.tagName === 'IMG') {
167+ el.src = value;
168+ } else {
169+ el.setAttribute(key, value);
170+ }
171+ };
172+
173+ g.__AddEvent = function(el, bindingName, eventName, handler) {
174+ var domEvent = eventMap[eventName] || eventName;
175+ var fn = typeof handler === 'function' ? handler : handler.value;
176+ el.addEventListener(domEvent, function(e) { fn(e); });
177+ };
178+
179+ g.__SetInlineStyles = function(el, styles) {
180+ Object.assign(el.style, styles);
181+ };
182+
183+ g.__GetChildren = function(el) {
184+ return Array.from(el.children);
185+ };
186+
187+ g.__GetParent = function(el) {
188+ return el.parentNode;
189+ };
190+
191+ g.__FlushElementTree = function() {};
192+
193+ // Set up root page so _Browser_newPage() finds it
194+ g.page = g.__CreatePage();
195+})();
196+|]
compiler/src/Generate/JavaScript.hs+136−5
@@ -1,4 +1,4 @@
1−{-# LANGUAGE OverloadedStrings #-}
1+{-# LANGUAGE OverloadedStrings, PatternGuards #-}
22module Generate.JavaScript
33 ( generate
44 , generateForRepl
@@ -8,8 +8,8 @@ module Generate.JavaScript
88
99
1010import Prelude hiding (cycle, print)
11+import qualified Data.ByteString as BS
1112import qualified Data.ByteString.Builder as B
12−import Data.Monoid ((<>))
1313import qualified Data.List as List
1414import Data.Map ((!))
1515import qualified Data.Map as Map
@@ -50,7 +50,7 @@ generate mode (Opt.GlobalGraph graph _) mains =
5050 <> perfNote mode
5151 <> stateToBuilder state
5252 <> toMainExports mode mains
53− <> "}(this));"
53+ <> "}(globalThis));"
5454
5555
5656addMain :: Mode.Mode -> Graph -> ModuleName.Canonical -> Opt.Main -> State -> State
@@ -162,7 +162,7 @@ emptyState =
162162
163163stateToBuilder :: State -> B.Builder
164164stateToBuilder (State revKernels revBuilders _) =
165− prependBuilders revKernels (prependBuilders revBuilders mempty)
165+ prependBuilders revKernels (extendedUtilsCmp <> prependBuilders revBuilders mempty)
166166
167167
168168prependBuilders :: [B.Builder] -> B.Builder -> B.Builder
@@ -170,6 +170,43 @@ prependBuilders revBuilders monolith =
170170 List.foldl' (\m b -> b <> m) monolith revBuilders
171171
172172
173+-- EXTENDED COMPARISON
174+--
175+-- Override _Utils_cmp from elm/core to support structural comparison
176+-- of all Elm values (custom types, records, etc.), not just the types
177+-- that satisfy the standard `comparable` constraint.
178+-- Placed after kernel code so it overwrites the original definition.
179+
180+
181+extendedUtilsCmp :: B.Builder
182+extendedUtilsCmp =
183+ "function _Utils_cmp(x, y, ord) {\
184+ \if (typeof x !== 'object') {\
185+ \return x === y ? 0 : x < y ? -1 : 1; }\
186+ \if (x instanceof String) {\
187+ \var a = x.valueOf(); var b = y.valueOf();\
188+ \return a === b ? 0 : a < b ? -1 : 1; }\
189+ \if (typeof x.$ === 'undefined' || (typeof x.$ === 'string' && x.$[0] === '#')) {\
190+ \var keys = Object.keys(x).sort();\
191+ \for (var i = 0; i < keys.length; i++) {\
192+ \var k = keys[i];\
193+ \if (k === '$') continue;\
194+ \ord = _Utils_cmp(x[k], y[k]);\
195+ \if (ord) return ord; }\
196+ \return 0; }\
197+ \if (x.$ === '::' || x.$ === '[]') {\
198+ \for (; x.b && y.b && !(ord = _Utils_cmp(x.a, y.a)); x = x.b, y = y.b) {}\
199+ \return ord || (x.b ? 1 : y.b ? -1 : 0); }\
200+ \if (x.$ !== y.$) {\
201+ \return x.$ < y.$ ? -1 : 1; }\
202+ \var keys = Object.keys(x);\
203+ \for (var i = 0; i < keys.length; i++) {\
204+ \var k = keys[i];\
205+ \if (k === '$') continue;\
206+ \ord = _Utils_cmp(x[k], y[k]);\
207+ \if (ord) return ord; }\
208+ \return 0; }\n"
209+
173210
174211-- ADD DEPENDENCIES
175212
@@ -343,7 +380,7 @@ drawCycle names =
343380
344381generateKernel :: Mode.Mode -> [K.Chunk] -> B.Builder
345382generateKernel mode chunks =
346− List.foldr (addChunk mode) mempty chunks
383+ List.foldr (addChunk mode) mempty (stripDeadDefs mode chunks)
347384
348385
349386addChunk :: Mode.Mode -> K.Chunk -> B.Builder -> B.Builder
@@ -385,6 +422,100 @@ addChunk mode chunk builder =
385422
386423
387424
425+-- STRIP DEAD DEFS
426+--
427+-- When kernel JS has __Debug/__Prod variants, the inactive one gets
428+-- renamed with _UNUSED. This strips those dead definitions entirely,
429+-- tracking brace/paren counts across chunk boundaries (since a single
430+-- definition body may be split across K.JS chunks interleaved with
431+-- K.JsEnum, K.ElmField, etc.).
432+
433+
434+stripDeadDefs :: Mode.Mode -> [K.Chunk] -> [K.Chunk]
435+stripDeadDefs mode = go
436+ where
437+ go [] = []
438+ go (K.JS before : marker : rest)
439+ | isDeadMarker mode marker
440+ , not (isInlineConditional before) =
441+ let before' = stripTrailingDef before
442+ rest' = skipDeadBody 0 0 rest
443+ in
444+ prependChunk before' $ go rest'
445+ go (chunk : rest) = chunk : go rest
446+
447+ prependChunk bs rest
448+ | BS.null bs = rest
449+ | otherwise = K.JS bs : rest
450+
451+
452+-- | Detect inline conditionals like /**__Prod/ which end with /*
453+-- These use comment-based wrapping, NOT definition-level stripping.
454+isInlineConditional :: BS.ByteString -> Bool
455+isInlineConditional bs =
456+ not (BS.null bs) && BS.index bs (BS.length bs - 1) == 0x2A {- * -}
457+
458+
459+isDeadMarker :: Mode.Mode -> K.Chunk -> Bool
460+isDeadMarker mode chunk =
461+ case (mode, chunk) of
462+ (Mode.Prod _, K.Debug) -> True
463+ (Mode.Dev _, K.Prod) -> True
464+ _ -> False
465+
466+
467+-- | Skip all chunks that form the body of a dead definition.
468+-- Tracks brace/paren counts across K.JS chunks. Non-JS chunks
469+-- (K.JsEnum, K.ElmField, etc.) don't affect the count.
470+-- Stops when a K.JS chunk contains a newline at brace=0, paren=0.
471+skipDeadBody :: Int -> Int -> [K.Chunk] -> [K.Chunk]
472+skipDeadBody _ _ [] = []
473+skipDeadBody bc pc (K.JS js : rest) =
474+ case scanForEnd bc pc js of
475+ Left (bc', pc') ->
476+ -- Didn't find statement end in this chunk; continue scanning
477+ skipDeadBody bc' pc' rest
478+ Right remaining
479+ -- If the remaining text starts with '{', the scanner stopped after
480+ -- a parameter list (e.g., "(value)\n") but the function body hasn't
481+ -- been consumed yet. Continue skipping from the body.
482+ | not (BS.null remaining) && BS.index remaining 0 == 0x7B {- { -} ->
483+ skipDeadBody 0 0 (K.JS remaining : rest)
484+ | BS.null remaining -> rest
485+ | otherwise -> K.JS remaining : rest
486+skipDeadBody bc pc (_ : rest) =
487+ -- Non-JS chunks (JsEnum, ElmField, etc.) don't affect brace/paren count
488+ skipDeadBody bc pc rest
489+
490+
491+-- | Scan a JS ByteString for the end of the current statement.
492+-- Returns Left (bc', pc') if the statement continues past this chunk,
493+-- or Right remaining if we found the end (remaining text after it).
494+scanForEnd :: Int -> Int -> BS.ByteString -> Either (Int, Int) BS.ByteString
495+scanForEnd bc0 pc0 bs = go 0 bc0 pc0
496+ where
497+ len = BS.length bs
498+ go i bc pc
499+ | i >= len = Left (bc, pc)
500+ | b == 0x7B {- { -} = go (i + 1) (bc + 1) pc
501+ | b == 0x7D {- } -} = go (i + 1) (bc - 1) pc
502+ | b == 0x28 {- ( -} = go (i + 1) bc (pc + 1)
503+ | b == 0x29 {- ) -} = go (i + 1) bc (pc - 1)
504+ | b == 0x0A {- \n -} && bc <= 0 && pc <= 0 = Right (BS.drop (i + 1) bs)
505+ | otherwise = go (i + 1) bc pc
506+ where b = BS.index bs i
507+
508+
509+-- | Strip trailing "var name" or "function name" from a JS chunk.
510+-- e.g., "...prev;\nvar name" -> "...prev;\n"
511+stripTrailingDef :: BS.ByteString -> BS.ByteString
512+stripTrailingDef bs =
513+ case BS.elemIndexEnd 0x0A {-\n-} bs of
514+ Just idx -> BS.take (idx + 1) bs
515+ Nothing -> BS.empty
516+
517+
518+
388519-- GENERATE ENUM
389520
390521
compiler/src/Generate/JavaScript/Builder.hs+17−2
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE OverloadedStrings #-}
32module Generate.JavaScript.Builder
43 ( stmtToBuilder
@@ -18,7 +17,6 @@ import Prelude hiding (lines)
1817import qualified Data.List as List
1918import qualified Data.ByteString as BS
2019import Data.ByteString.Builder as B
21−import Data.Monoid ((<>))
2220import qualified Generate.JavaScript.Name as Name
2321import Generate.JavaScript.Name (Name)
2422import qualified Json.Encode as Json
@@ -50,6 +48,7 @@ data Expr
5048 | Json Json.Value
5149 | Array [Expr]
5250 | Object [(Name, Expr)]
51+ | ObjectSpread Expr [(Name, Expr)]
5352 | Ref Name
5453 | Access Expr Name -- foo.bar
5554 | Index Expr Expr -- foo[bar]
@@ -379,6 +378,22 @@ fromExpr level@(Level indent nextLevel@(Level deeperIndent _)) grouping expressi
379378 else
380379 "{" <> commaSep builders <> "}"
381380
381+ ObjectSpread base fields ->
382+ (,) Many $
383+ let
384+ (baseLines, baseB) = fromExpr level Whatever base
385+ spreadEntry = "..." <> baseB
386+ (anyMany, fieldBuilders) = linesMap (fromField nextLevel) fields
387+ allBuilders = spreadEntry : fieldBuilders
388+ in
389+ if anyMany || baseLines == Many then
390+ "{\n"
391+ <> deeperIndent
392+ <> commaNewlineSep level allBuilders
393+ <> "\n" <> indent <> "}"
394+ else
395+ "{" <> commaSep allBuilders <> "}"
396+
382397 Ref name ->
383398 ( One, Name.toBuilder name )
384399
compiler/src/Generate/JavaScript/Expression.hs+12−4
@@ -1,3 +1,4 @@
1+{-# OPTIONS_GHC -fno-warn-x-partial #-}
12{-# LANGUAGE OverloadedStrings #-}
23module Generate.JavaScript.Expression
34 ( generate
@@ -148,10 +149,17 @@ generate mode expression =
148149
149150 Opt.Update record fields ->
150151 JsExpr $
151− JS.Call (JS.Ref (JsName.fromKernel Name.utils "update"))
152− [ generateJsExpr mode record
153− , generateRecord mode fields
154− ]
152+ case mode of
153+ Mode.Prod _ ->
154+ JS.ObjectSpread (generateJsExpr mode record)
155+ (map (\(field, value) -> (generateField mode field, generateJsExpr mode value))
156+ (Map.toList fields))
157+
158+ Mode.Dev _ ->
159+ JS.Call (JS.Ref (JsName.fromKernel Name.utils "update"))
160+ [ generateJsExpr mode record
161+ , generateRecord mode fields
162+ ]
155163
156164 Opt.Record fields ->
157165 JsExpr $ generateRecord mode fields
compiler/src/Generate/JavaScript/Name.hs−2
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE OverloadedStrings #-}
32module Generate.JavaScript.Name
43 ( Name
@@ -19,7 +18,6 @@ module Generate.JavaScript.Name
1918
2019
2120import qualified Data.ByteString.Builder as B
22−import Data.Monoid ((<>))
2321import qualified Data.Map as Map
2422import qualified Data.Name as Name
2523import qualified Data.Set as Set
compiler/src/Json/Decode.hs+3−6
@@ -119,7 +119,9 @@ instance Functor (Decoder x) where
119119
120120instance Applicative (Decoder x) where
121121 {-# INLINE pure #-}
122− pure = return
122+ pure a =
123+ Decoder $ \_ ok _ ->
124+ ok a
123125
124126 {-# INLINE (<*>) #-}
125127 (<*>) (Decoder decodeFunc) (Decoder decodeArg) =
@@ -135,11 +137,6 @@ instance Applicative (Decoder x) where
135137
136138
137139instance Monad (Decoder x) where
138− {-# INLINE return #-}
139− return a =
140− Decoder $ \_ ok _ ->
141− ok a
142−
143140 {-# INLINE (>>=) #-}
144141 (>>=) (Decoder decodeA) callback =
145142 Decoder $ \ast ok err ->
compiler/src/Json/Encode.hs−2
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE OverloadedStrings #-}
32module Json.Encode
43 ( write
@@ -28,7 +27,6 @@ import qualified Data.ByteString.Char8 as BSC
2827import qualified Data.ByteString.Builder as B
2928import qualified Data.Map as Map
3029import qualified Data.Scientific as Sci
31−import Data.Monoid ((<>))
3230import qualified Data.Name as Name
3331import qualified Data.Utf8 as Utf8
3432
compiler/src/Nitpick/PatternMatches.hs+1−1
@@ -1,4 +1,4 @@
1−{-# OPTIONS_GHC -Wall #-}
1+{-# OPTIONS_GHC -fno-warn-x-partial #-}
22{-# LANGUAGE OverloadedStrings #-}
33module Nitpick.PatternMatches
44 ( check
compiler/src/Optimize/Case.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21module Optimize.Case
32 ( optimize
43 )
compiler/src/Optimize/DecisionTree.hs+1−1
@@ -1,4 +1,4 @@
1−{-# OPTIONS_GHC -Wall #-}
1+{-# OPTIONS_GHC -fno-warn-x-partial #-}
22{-# LANGUAGE OverloadedStrings #-}
33module Optimize.DecisionTree
44 ( DecisionTree(..)
compiler/src/Optimize/Expression.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE OverloadedStrings #-}
32module Optimize.Expression
43 ( optimize
compiler/src/Optimize/Module.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE OverloadedStrings #-}
32module Optimize.Module
43 ( optimize
compiler/src/Optimize/Names.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE OverloadedStrings #-}
32{-# LANGUAGE Rank2Types #-}
43module Optimize.Names
compiler/src/Optimize/Port.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE OverloadedStrings #-}
32module Optimize.Port
43 ( toEncoder
compiler/src/Parse/Keyword.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE BangPatterns #-}
32module Parse.Keyword
43 ( type_, alias_, port_
compiler/src/Parse/Module.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE OverloadedStrings #-}
32module Parse.Module
43 ( fromByteString
compiler/src/Parse/Number.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE BangPatterns, UnboxedTuples #-}
32module Parse.Number
43 ( Number(..)
compiler/src/Parse/Primitives.hs+3−6
@@ -82,7 +82,9 @@ instance Functor (Parser x) where
8282
8383instance Applicative.Applicative (Parser x) where
8484 {-# INLINE pure #-}
85− pure = return
85+ pure value =
86+ Parser $ \state _ eok _ _ ->
87+ eok value state
8688
8789 {-# INLINE (<*>) #-}
8890 (<*>) (Parser parserFunc) (Parser parserArg) =
@@ -177,11 +179,6 @@ oowfHelp state cok eok cerr parsers fallback =
177179
178180
179181instance Monad (Parser x) where
180− {-# INLINE return #-}
181− return value =
182− Parser $ \state _ eok _ _ ->
183− eok value state
184−
185182 {-# INLINE (>>=) #-}
186183 (Parser parserA) >>= callback =
187184 Parser $ \state cok eok cerr eerr ->
compiler/src/Parse/Shader.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE BangPatterns, UnboxedTuples #-}
32module Parse.Shader
43 ( shader
compiler/src/Parse/Symbol.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE BangPatterns, OverloadedStrings #-}
32module Parse.Symbol
43 ( operator
compiler/src/Parse/Variable.hs+2−3
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE BangPatterns, MagicHash, OverloadedStrings, UnboxedTuples #-}
32module Parse.Variable
43 ( lower
@@ -21,7 +20,7 @@ import qualified Data.Name as Name
2120import qualified Data.Set as Set
2221import Data.Word (Word8)
2322import Foreign.Ptr (Ptr, plusPtr)
24−import GHC.Exts (Char(C#), Int#, (+#), (-#), chr#, uncheckedIShiftL#, word2Int#)
23+import GHC.Exts (Char(C#), Int#, (+#), (-#), chr#, uncheckedIShiftL#, word2Int#, word8ToWord#)
2524import GHC.Word (Word8(W8#))
2625
2726import qualified AST.Source as Src
@@ -384,4 +383,4 @@ chr4 pos firstWord =
384383
385384unpack :: Word8 -> Int#
386385unpack (W8# word#) =
387− word2Int# word#
386+ word2Int# (word8ToWord# word#)
compiler/src/Reporting/Annotation.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21module Reporting.Annotation
32 ( Located(..)
43 , Position(..)
compiler/src/Reporting/Doc.hs+2−2
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE OverloadedStrings #-}
32module Reporting.Doc
43 ( P.Doc
@@ -46,7 +45,6 @@ module Reporting.Doc
4645
4746import Prelude hiding (cycle)
4847import qualified Data.List as List
49−import Data.Monoid ((<>))
5048import qualified Data.Name as Name
5149import qualified System.Console.ANSI.Types as Ansi
5250import qualified System.Info as Info
@@ -348,6 +346,8 @@ sgrToStyle sgrs style@(Style bold underline color) =
348346 Ansi.SetSwapForegroundBackground _ -> style
349347 Ansi.SetColor l i c -> Style bold underline (toColor l i c)
350348 Ansi.SetRGBColor _ _ -> style
349+ Ansi.SetPaletteColor _ _ -> style
350+ Ansi.SetDefaultColor _ -> style
351351
352352
353353isBold :: Ansi.ConsoleIntensity -> Bool
compiler/src/Reporting/Error.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE OverloadedStrings #-}
32module Reporting.Error
43 ( Module(..)
compiler/src/Reporting/Error/Canonicalize.hs+1−2
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE OverloadedStrings #-}
32module Reporting.Error.Canonicalize
43 ( Error(..)
@@ -26,7 +25,7 @@ import qualified Data.Index as Index
2625import qualified Elm.ModuleName as ModuleName
2726import qualified Reporting.Annotation as A
2827import qualified Reporting.Doc as D
29−import Reporting.Doc (Doc, (<+>), (<>))
28+import Reporting.Doc (Doc, (<+>))
3029import qualified Reporting.Render.Code as Code
3130import qualified Reporting.Render.Type as RT
3231import qualified Reporting.Report as Report
compiler/src/Reporting/Error/Docs.hs−2
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE OverloadedStrings #-}
32module Reporting.Error.Docs
43 ( Error(..)
@@ -16,7 +15,6 @@ import qualified Data.NonEmptyList as NE
1615import Parse.Primitives (Row, Col)
1716import Parse.Symbol (BadOperator(..))
1817import qualified Reporting.Annotation as A
19−import Reporting.Doc ((<>))
2018import qualified Reporting.Doc as D
2119import qualified Reporting.Render.Code as Code
2220import qualified Reporting.Error.Syntax as E
compiler/src/Reporting/Error/Json.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE OverloadedStrings #-}
32module Reporting.Error.Json
43 ( toReport
compiler/src/Reporting/Error/Main.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE OverloadedStrings #-}
32module Reporting.Error.Main
43 ( Error(..)
compiler/src/Reporting/Error/Pattern.hs+2−4
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE OverloadedStrings #-}
32module Reporting.Error.Pattern
43 ( P.Error(..)
@@ -10,7 +9,6 @@ import qualified Data.List as List
109
1110import qualified Elm.String as ES
1211import qualified Nitpick.PatternMatches as P
13−import Reporting.Doc ((<>))
1412import qualified Reporting.Doc as D
1513import qualified Reporting.Report as Report
1614import qualified Reporting.Render.Code as Code
@@ -41,7 +39,7 @@ toReport source err =
4139 Report.Report "UNSAFE PATTERN" region [] $
4240 Code.toSnippet source region Nothing
4341 (
44− "This pattern does not cover all possiblities:"
42+ "This pattern does not cover all possibilities:"
4543 ,
4644 D.stack
4745 [ "Other possibilities include:"
@@ -64,7 +62,7 @@ toReport source err =
6462 , unhandledPatternsToDocBlock unhandled
6563 , D.reflow $
6664 "I would have to crash if I saw one of those! You can use\
67− \ `let` to deconstruct values only if there is ONE possiblity.\
65+ \ `let` to deconstruct values only if there is ONE possibility.\
6866 \ Switch to a `case` expression to account for all possibilities."
6967 , D.toSimpleHint $
7068 "Are you calling a function that definitely returns values\
compiler/src/Reporting/Error/Syntax.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE OverloadedStrings #-}
32module Reporting.Error.Syntax
43 ( Error(..)
compiler/src/Reporting/Error/Type.hs−2
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE OverloadedStrings #-}
32module Reporting.Error.Type
43 ( Error(..)
@@ -21,7 +20,6 @@ module Reporting.Error.Type
2120
2221import Prelude hiding (round)
2322import qualified Data.Map as Map
24−import Data.Monoid ((<>))
2523import qualified Data.Name as Name
2624
2725import qualified AST.Canonical as Can
compiler/src/Reporting/Render/Code.hs+1−1
@@ -1,4 +1,4 @@
1−{-# OPTIONS_GHC -Wall #-}
1+{-# OPTIONS_GHC -fno-warn-incomplete-uni-patterns #-}
22{-# LANGUAGE OverloadedStrings #-}
33module Reporting.Render.Code
44 ( Source
compiler/src/Reporting/Render/Type.hs+1−2
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE OverloadedStrings #-}
32module Reporting.Render.Type
43 ( Context(..)
@@ -21,7 +20,7 @@ import qualified AST.Source as Src
2120import qualified AST.Canonical as Can
2221import qualified Reporting.Annotation as A
2322import qualified Reporting.Doc as D
24−import Reporting.Doc ( Doc, (<+>), (<>) )
23+import Reporting.Doc (Doc, (<+>))
2524import qualified Reporting.Render.Type.Localizer as L
2625
2726
compiler/src/Reporting/Render/Type/Localizer.hs−2
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE OverloadedStrings #-}
32module Reporting.Render.Type.Localizer
43 ( Localizer
@@ -17,7 +16,6 @@ import qualified Data.Set as Set
1716
1817import qualified AST.Source as Src
1918import qualified Elm.ModuleName as ModuleName
20−import Reporting.Doc ((<>))
2119import qualified Reporting.Doc as D
2220import qualified Reporting.Annotation as A
2321
compiler/src/Reporting/Result.hs+8−11
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE Rank2Types #-}
32module Reporting.Result
43 ( Result(..)
@@ -105,10 +104,16 @@ instance Applicative (Result i w e) where
105104 in
106105 kf i w bad1 good1
107106
107+ (*>) (Result ka) (Result kb) =
108+ Result $ \i w bad good ->
109+ let
110+ good1 i1 w1 _ =
111+ kb i1 w1 bad good
112+ in
113+ ka i w bad good1
108114
109−instance Monad (Result i w e) where
110− return = ok
111115
116+instance Monad (Result i w e) where
112117 (>>=) (Result ka) callback =
113118 Result $ \i w bad good ->
114119 let
@@ -118,12 +123,4 @@ instance Monad (Result i w e) where
118123 in
119124 ka i w bad good1
120125
121− (>>) (Result ka) (Result kb) =
122− Result $ \i w bad good ->
123− let
124− good1 i1 w1 _ =
125− kb i1 w1 bad good
126− in
127− ka i w bad good1
128−
129126 -- PERF add INLINE to these?
compiler/src/Reporting/Suggest.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE OverloadedStrings #-}
32module Reporting.Suggest
43 ( distance
compiler/src/Reporting/Warning.hs−2
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE OverloadedStrings #-}
32module Reporting.Warning
43 ( Warning(..)
@@ -8,7 +7,6 @@ module Reporting.Warning
87 where
98
109
11−import Data.Monoid ((<>))
1210import qualified Data.Name as Name
1311
1412import qualified AST.Canonical as Can
compiler/src/Type/Constrain/Expression.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21module Type.Constrain.Expression
32 ( constrain
43 , constrainDef
compiler/src/Type/Constrain/Module.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE OverloadedStrings #-}
32module Type.Constrain.Module
43 ( constrain
compiler/src/Type/Constrain/Pattern.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21module Type.Constrain.Pattern
32 ( State(..)
43 , emptyState
compiler/src/Type/Error.hs+1−2
@@ -1,4 +1,4 @@
1−{-# OPTIONS_GHC -Wall #-}
1+{-# OPTIONS_GHC -fno-warn-x-partial #-}
22{-# LANGUAGE OverloadedStrings #-}
33module Type.Error
44 ( Type(..)
@@ -20,7 +20,6 @@ module Type.Error
2020
2121import qualified Data.Map as Map
2222import qualified Data.Maybe as Maybe
23−import Data.Monoid ((<>))
2423import qualified Data.Name as Name
2524
2625import qualified Data.Bag as Bag
compiler/src/Type/Instantiate.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE OverloadedStrings #-}
32module Type.Instantiate
43 ( FreeVars
compiler/src/Type/Occurs.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE OverloadedStrings #-}
32module Type.Occurs
43 ( occurs
compiler/src/Type/Solve.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE OverloadedStrings #-}
32module Type.Solve
43 ( run
compiler/src/Type/Type.hs−1
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE OverloadedStrings #-}
32module Type.Type
43 ( Constraint(..)
compiler/src/Type/Unify.hs+29−53
@@ -1,4 +1,3 @@
1−{-# OPTIONS_GHC -Wall #-}
21{-# LANGUAGE OverloadedStrings, Rank2Types #-}
32module Type.Unify
43 ( Answer(..)
@@ -88,12 +87,15 @@ instance Applicative Unify where
8887 in
8988 kf vars ok1 err
9089
90+ (*>) (Unify ka) (Unify kb) =
91+ Unify $ \vars ok err ->
92+ let
93+ ok1 vars1 _ = kb vars1 ok err
94+ in
95+ ka vars ok1 err
9196
92−instance Monad Unify where
93− return a =
94− Unify $ \vars ok _ ->
95− ok vars a
9697
98+instance Monad Unify where
9799 (>>=) (Unify ka) callback =
98100 Unify $ \vars ok err ->
99101 let
@@ -103,13 +105,6 @@ instance Monad Unify where
103105 in
104106 ka vars ok1 err
105107
106− (>>) (Unify ka) (Unify kb) =
107− Unify $ \vars ok err ->
108− let
109− ok1 vars1 _ = kb vars1 ok err
110− in
111− ka vars ok1 err
112−
113108
114109register :: IO Variable -> Unify Variable
115110register mkVar =
@@ -374,53 +369,34 @@ isNumber home name =
374369
375370unifyFlexSuperStructure :: Context -> SuperType -> FlatType -> Unify ()
376371unifyFlexSuperStructure context super flatType =
377− case flatType of
378− App1 home name [] ->
379− if atomMatchesSuper super home name then
380− merge context (Structure flatType)
381− else
382− mismatch
383−
384− App1 home name [variable] | home == ModuleName.list && name == Name.list ->
385− case super of
386− Number ->
387− mismatch
372+ case super of
373+ -- Any type can be used as comparable (e.g. Dict keys, Set members).
374+ -- Structural comparison is provided at runtime for all Elm values.
375+ Comparable ->
376+ merge context (Structure flatType)
388377
389− Appendable ->
378+ _ ->
379+ case flatType of
380+ App1 home name [] ->
381+ if atomMatchesSuper super home name then
390382 merge context (Structure flatType)
391−
392− Comparable ->
393− do comparableOccursCheck context
394− unifyComparableRecursive variable
395− merge context (Structure flatType)
396−
397− CompAppend ->
398− do comparableOccursCheck context
399− unifyComparableRecursive variable
400− merge context (Structure flatType)
401−
402− Tuple1 a b maybeC ->
403− case super of
404− Number ->
405− mismatch
406−
407− Appendable ->
383+ else
408384 mismatch
409385
410− Comparable ->
411− do comparableOccursCheck context
412− unifyComparableRecursive a
413− unifyComparableRecursive b
414− case maybeC of
415− Nothing -> return ()
416− Just c -> unifyComparableRecursive c
417− merge context (Structure flatType)
386+ App1 home name [variable] | home == ModuleName.list && name == Name.list ->
387+ case super of
388+ Number -> mismatch
389+ Appendable -> merge context (Structure flatType)
390+ _ ->
391+ do comparableOccursCheck context
392+ unifyComparableRecursive variable
393+ merge context (Structure flatType)
418394
419− CompAppend ->
420− mismatch
395+ Tuple1 _ _ _ ->
396+ mismatch
421397
422− _ ->
423− mismatch
398+ _ ->
399+ mismatch
424400
425401
426402-- TODO: is there some way to avoid doing this?
examples/counter/elm.jsnew file+5144
@@ -0,0 +1,5144 @@
1+(function(scope){
2+'use strict';
3+
4+function F(arity, fun, wrapper) {
5+ wrapper.a = arity;
6+ wrapper.f = fun;
7+ return wrapper;
8+}
9+
10+function F2(fun) {
11+ return F(2, fun, function(a) { return function(b) { return fun(a,b); }; })
12+}
13+function F3(fun) {
14+ return F(3, fun, function(a) {
15+ return function(b) { return function(c) { return fun(a, b, c); }; };
16+ });
17+}
18+function F4(fun) {
19+ return F(4, fun, function(a) { return function(b) { return function(c) {
20+ return function(d) { return fun(a, b, c, d); }; }; };
21+ });
22+}
23+function F5(fun) {
24+ return F(5, fun, function(a) { return function(b) { return function(c) {
25+ return function(d) { return function(e) { return fun(a, b, c, d, e); }; }; }; };
26+ });
27+}
28+function F6(fun) {
29+ return F(6, fun, function(a) { return function(b) { return function(c) {
30+ return function(d) { return function(e) { return function(f) {
31+ return fun(a, b, c, d, e, f); }; }; }; }; };
32+ });
33+}
34+function F7(fun) {
35+ return F(7, fun, function(a) { return function(b) { return function(c) {
36+ return function(d) { return function(e) { return function(f) {
37+ return function(g) { return fun(a, b, c, d, e, f, g); }; }; }; }; }; };
38+ });
39+}
40+function F8(fun) {
41+ return F(8, fun, function(a) { return function(b) { return function(c) {
42+ return function(d) { return function(e) { return function(f) {
43+ return function(g) { return function(h) {
44+ return fun(a, b, c, d, e, f, g, h); }; }; }; }; }; }; };
45+ });
46+}
47+function F9(fun) {
48+ return F(9, fun, function(a) { return function(b) { return function(c) {
49+ return function(d) { return function(e) { return function(f) {
50+ return function(g) { return function(h) { return function(i) {
51+ return fun(a, b, c, d, e, f, g, h, i); }; }; }; }; }; }; }; };
52+ });
53+}
54+
55+function A2(fun, a, b) {
56+ return fun.a === 2 ? fun.f(a, b) : fun(a)(b);
57+}
58+function A3(fun, a, b, c) {
59+ return fun.a === 3 ? fun.f(a, b, c) : fun(a)(b)(c);
60+}
61+function A4(fun, a, b, c, d) {
62+ return fun.a === 4 ? fun.f(a, b, c, d) : fun(a)(b)(c)(d);
63+}
64+function A5(fun, a, b, c, d, e) {
65+ return fun.a === 5 ? fun.f(a, b, c, d, e) : fun(a)(b)(c)(d)(e);
66+}
67+function A6(fun, a, b, c, d, e, f) {
68+ return fun.a === 6 ? fun.f(a, b, c, d, e, f) : fun(a)(b)(c)(d)(e)(f);
69+}
70+function A7(fun, a, b, c, d, e, f, g) {
71+ return fun.a === 7 ? fun.f(a, b, c, d, e, f, g) : fun(a)(b)(c)(d)(e)(f)(g);
72+}
73+function A8(fun, a, b, c, d, e, f, g, h) {
74+ return fun.a === 8 ? fun.f(a, b, c, d, e, f, g, h) : fun(a)(b)(c)(d)(e)(f)(g)(h);
75+}
76+function A9(fun, a, b, c, d, e, f, g, h, i) {
77+ return fun.a === 9 ? fun.f(a, b, c, d, e, f, g, h, i) : fun(a)(b)(c)(d)(e)(f)(g)(h)(i);
78+}
79+
80+console.warn('Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.');
81+
82+
83+var _JsArray_empty = [];
84+
85+function _JsArray_singleton(value)
86+{
87+ return [value];
88+}
89+
90+function _JsArray_length(array)
91+{
92+ return array.length;
93+}
94+
95+var _JsArray_initialize = F3(function(size, offset, func)
96+{
97+ var result = new Array(size);
98+
99+ for (var i = 0; i < size; i++)
100+ {
101+ result[i] = func(offset + i);
102+ }
103+
104+ return result;
105+});
106+
107+var _JsArray_initializeFromList = F2(function (max, ls)
108+{
109+ var result = new Array(max);
110+
111+ for (var i = 0; i < max && ls.b; i++)
112+ {
113+ result[i] = ls.a;
114+ ls = ls.b;
115+ }
116+
117+ result.length = i;
118+ return _Utils_Tuple2(result, ls);
119+});
120+
121+var _JsArray_unsafeGet = F2(function(index, array)
122+{
123+ return array[index];
124+});
125+
126+var _JsArray_unsafeSet = F3(function(index, value, array)
127+{
128+ var length = array.length;
129+ var result = new Array(length);
130+
131+ for (var i = 0; i < length; i++)
132+ {
133+ result[i] = array[i];
134+ }
135+
136+ result[index] = value;
137+ return result;
138+});
139+
140+var _JsArray_push = F2(function(value, array)
141+{
142+ var length = array.length;
143+ var result = new Array(length + 1);
144+
145+ for (var i = 0; i < length; i++)
146+ {
147+ result[i] = array[i];
148+ }
149+
150+ result[length] = value;
151+ return result;
152+});
153+
154+var _JsArray_foldl = F3(function(func, acc, array)
155+{
156+ var length = array.length;
157+
158+ for (var i = 0; i < length; i++)
159+ {
160+ acc = A2(func, array[i], acc);
161+ }
162+
163+ return acc;
164+});
165+
166+var _JsArray_foldr = F3(function(func, acc, array)
167+{
168+ for (var i = array.length - 1; i >= 0; i--)
169+ {
170+ acc = A2(func, array[i], acc);
171+ }
172+
173+ return acc;
174+});
175+
176+var _JsArray_map = F2(function(func, array)
177+{
178+ var length = array.length;
179+ var result = new Array(length);
180+
181+ for (var i = 0; i < length; i++)
182+ {
183+ result[i] = func(array[i]);
184+ }
185+
186+ return result;
187+});
188+
189+var _JsArray_indexedMap = F3(function(func, offset, array)
190+{
191+ var length = array.length;
192+ var result = new Array(length);
193+
194+ for (var i = 0; i < length; i++)
195+ {
196+ result[i] = A2(func, offset + i, array[i]);
197+ }
198+
199+ return result;
200+});
201+
202+var _JsArray_slice = F3(function(from, to, array)
203+{
204+ return array.slice(from, to);
205+});
206+
207+var _JsArray_appendN = F3(function(n, dest, source)
208+{
209+ var destLen = dest.length;
210+ var itemsToCopy = n - destLen;
211+
212+ if (itemsToCopy > source.length)
213+ {
214+ itemsToCopy = source.length;
215+ }
216+
217+ var size = destLen + itemsToCopy;
218+ var result = new Array(size);
219+
220+ for (var i = 0; i < destLen; i++)
221+ {
222+ result[i] = dest[i];
223+ }
224+
225+ for (var i = 0; i < itemsToCopy; i++)
226+ {
227+ result[i + destLen] = source[i];
228+ }
229+
230+ return result;
231+});
232+
233+
234+
235+// LOG
236+
237+
238+var _Debug_log = F2(function(tag, value)
239+{
240+ console.log(tag + ': ' + _Debug_toString(value));
241+ return value;
242+});
243+
244+
245+// TODOS
246+
247+function _Debug_todo(moduleName, region)
248+{
249+ return function(message) {
250+ _Debug_crash(8, moduleName, region, message);
251+ };
252+}
253+
254+function _Debug_todoCase(moduleName, region, value)
255+{
256+ return function(message) {
257+ _Debug_crash(9, moduleName, region, value, message);
258+ };
259+}
260+
261+
262+// TO STRING
263+
264+
265+function _Debug_toString(value)
266+{
267+ return _Debug_toAnsiString(false, value);
268+}
269+
270+function _Debug_toAnsiString(ansi, value)
271+{
272+ if (typeof value === 'function')
273+ {
274+ return _Debug_internalColor(ansi, '<function>');
275+ }
276+
277+ if (typeof value === 'boolean')
278+ {
279+ return _Debug_ctorColor(ansi, value ? 'True' : 'False');
280+ }
281+
282+ if (typeof value === 'number')
283+ {
284+ return _Debug_numberColor(ansi, value + '');
285+ }
286+
287+ if (value instanceof String)
288+ {
289+ return _Debug_charColor(ansi, "'" + _Debug_addSlashes(value, true) + "'");
290+ }
291+
292+ if (typeof value === 'string')
293+ {
294+ return _Debug_stringColor(ansi, '"' + _Debug_addSlashes(value, false) + '"');
295+ }
296+
297+ if (typeof value === 'object' && '$' in value)
298+ {
299+ var tag = value.$;
300+
301+ if (typeof tag === 'number')
302+ {
303+ return _Debug_internalColor(ansi, '<internals>');
304+ }
305+
306+ if (tag[0] === '#')
307+ {
308+ var output = [];
309+ for (var k in value)
310+ {
311+ if (k === '$') continue;
312+ output.push(_Debug_toAnsiString(ansi, value[k]));
313+ }
314+ return '(' + output.join(',') + ')';
315+ }
316+
317+ if (tag === 'Set_elm_builtin')
318+ {
319+ return _Debug_ctorColor(ansi, 'Set')
320+ + _Debug_fadeColor(ansi, '.fromList') + ' '
321+ + _Debug_toAnsiString(ansi, $elm$core$Set$toList(value));
322+ }
323+
324+ if (tag === 'RBNode_elm_builtin' || tag === 'RBEmpty_elm_builtin')
325+ {
326+ return _Debug_ctorColor(ansi, 'Dict')
327+ + _Debug_fadeColor(ansi, '.fromList') + ' '
328+ + _Debug_toAnsiString(ansi, $elm$core$Dict$toList(value));
329+ }
330+
331+ if (tag === 'Array_elm_builtin')
332+ {
333+ return _Debug_ctorColor(ansi, 'Array')
334+ + _Debug_fadeColor(ansi, '.fromList') + ' '
335+ + _Debug_toAnsiString(ansi, $elm$core$Array$toList(value));
336+ }
337+
338+ if (tag === '::' || tag === '[]')
339+ {
340+ var output = '[';
341+
342+ value.b && (output += _Debug_toAnsiString(ansi, value.a), value = value.b)
343+
344+ for (; value.b; value = value.b) // WHILE_CONS
345+ {
346+ output += ',' + _Debug_toAnsiString(ansi, value.a);
347+ }
348+ return output + ']';
349+ }
350+
351+ var output = '';
352+ for (var i in value)
353+ {
354+ if (i === '$') continue;
355+ var str = _Debug_toAnsiString(ansi, value[i]);
356+ var c0 = str[0];
357+ var parenless = c0 === '{' || c0 === '(' || c0 === '[' || c0 === '<' || c0 === '"' || str.indexOf(' ') < 0;
358+ output += ' ' + (parenless ? str : '(' + str + ')');
359+ }
360+ return _Debug_ctorColor(ansi, tag) + output;
361+ }
362+
363+ if (typeof DataView === 'function' && value instanceof DataView)
364+ {
365+ return _Debug_stringColor(ansi, '<' + value.byteLength + ' bytes>');
366+ }
367+
368+ if (typeof File !== 'undefined' && value instanceof File)
369+ {
370+ return _Debug_internalColor(ansi, '<' + value.name + '>');
371+ }
372+
373+ if (typeof value === 'object')
374+ {
375+ var output = [];
376+ for (var key in value)
377+ {
378+ var field = key[0] === '_' ? key.slice(1) : key;
379+ output.push(_Debug_fadeColor(ansi, field) + ' = ' + _Debug_toAnsiString(ansi, value[key]));
380+ }
381+ if (output.length === 0)
382+ {
383+ return '{}';
384+ }
385+ return '{ ' + output.join(', ') + ' }';
386+ }
387+
388+ return _Debug_internalColor(ansi, '<internals>');
389+}
390+
391+function _Debug_addSlashes(str, isChar)
392+{
393+ var s = str
394+ .replace(/\\/g, '\\\\')
395+ .replace(/\n/g, '\\n')
396+ .replace(/\t/g, '\\t')
397+ .replace(/\r/g, '\\r')
398+ .replace(/\v/g, '\\v')
399+ .replace(/\0/g, '\\0');
400+
401+ if (isChar)
402+ {
403+ return s.replace(/\'/g, '\\\'');
404+ }
405+ else
406+ {
407+ return s.replace(/\"/g, '\\"');
408+ }
409+}
410+
411+function _Debug_ctorColor(ansi, string)
412+{
413+ return ansi ? '\x1b[96m' + string + '\x1b[0m' : string;
414+}
415+
416+function _Debug_numberColor(ansi, string)
417+{
418+ return ansi ? '\x1b[95m' + string + '\x1b[0m' : string;
419+}
420+
421+function _Debug_stringColor(ansi, string)
422+{
423+ return ansi ? '\x1b[93m' + string + '\x1b[0m' : string;
424+}
425+
426+function _Debug_charColor(ansi, string)
427+{
428+ return ansi ? '\x1b[92m' + string + '\x1b[0m' : string;
429+}
430+
431+function _Debug_fadeColor(ansi, string)
432+{
433+ return ansi ? '\x1b[37m' + string + '\x1b[0m' : string;
434+}
435+
436+function _Debug_internalColor(ansi, string)
437+{
438+ return ansi ? '\x1b[36m' + string + '\x1b[0m' : string;
439+}
440+
441+function _Debug_toHexDigit(n)
442+{
443+ return String.fromCharCode(n < 10 ? 48 + n : 55 + n);
444+}
445+
446+
447+// CRASH
448+
449+
450+
451+
452+function _Debug_crash(identifier, fact1, fact2, fact3, fact4)
453+{
454+ switch(identifier)
455+ {
456+ case 0:
457+ throw new Error('What node should I take over? In JavaScript I need something like:\n\n Elm.Main.init({\n node: document.getElementById("elm-node")\n })\n\nYou need to do this with any Browser.sandbox or Browser.element program.');
458+
459+ case 1:
460+ throw new Error('Browser.application programs cannot handle URLs like this:\n\n ' + document.location.href + '\n\nWhat is the root? The root of your file system? Try looking at this program with `elm reactor` or some other server.');
461+
462+ case 2:
463+ var jsonErrorString = fact1;
464+ throw new Error('Problem with the flags given to your Elm program on initialization.\n\n' + jsonErrorString);
465+
466+ case 3:
467+ var portName = fact1;
468+ throw new Error('There can only be one port named `' + portName + '`, but your program has multiple.');
469+
470+ case 4:
471+ var portName = fact1;
472+ var problem = fact2;
473+ throw new Error('Trying to send an unexpected type of value through port `' + portName + '`:\n' + problem);
474+
475+ case 5:
476+ throw new Error('Trying to use `(==)` on functions.\nThere is no way to know if functions are "the same" in the Elm sense.\nRead more about this at https://package.elm-lang.org/packages/elm/core/latest/Basics#== which describes why it is this way and what the better version will look like.');
477+
478+ case 6:
479+ var moduleName = fact1;
480+ throw new Error('Your page is loading multiple Elm scripts with a module named ' + moduleName + '. Maybe a duplicate script is getting loaded accidentally? If not, rename one of them so I know which is which!');
481+
482+ case 8:
483+ var moduleName = fact1;
484+ var region = fact2;
485+ var message = fact3;
486+ throw new Error('TODO in module `' + moduleName + '` ' + _Debug_regionToString(region) + '\n\n' + message);
487+
488+ case 9:
489+ var moduleName = fact1;
490+ var region = fact2;
491+ var value = fact3;
492+ var message = fact4;
493+ throw new Error(
494+ 'TODO in module `' + moduleName + '` from the `case` expression '
495+ + _Debug_regionToString(region) + '\n\nIt received the following value:\n\n '
496+ + _Debug_toString(value).replace('\n', '\n ')
497+ + '\n\nBut the branch that handles it says:\n\n ' + message.replace('\n', '\n ')
498+ );
499+
500+ case 10:
501+ throw new Error('Bug in https://github.com/elm/virtual-dom/issues');
502+
503+ case 11:
504+ throw new Error('Cannot perform mod 0. Division by zero error.');
505+ }
506+}
507+
508+function _Debug_regionToString(region)
509+{
510+ if (region.start.line === region.end.line)
511+ {
512+ return 'on line ' + region.start.line;
513+ }
514+ return 'on lines ' + region.start.line + ' through ' + region.end.line;
515+}
516+
517+
518+
519+// EQUALITY
520+
521+function _Utils_eq(x, y)
522+{
523+ for (
524+ var pair, stack = [], isEqual = _Utils_eqHelp(x, y, 0, stack);
525+ isEqual && (pair = stack.pop());
526+ isEqual = _Utils_eqHelp(pair.a, pair.b, 0, stack)
527+ )
528+ {}
529+
530+ return isEqual;
531+}
532+
533+function _Utils_eqHelp(x, y, depth, stack)
534+{
535+ if (x === y)
536+ {
537+ return true;
538+ }
539+
540+ if (typeof x !== 'object' || x === null || y === null)
541+ {
542+ typeof x === 'function' && _Debug_crash(5);
543+ return false;
544+ }
545+
546+ if (depth > 100)
547+ {
548+ stack.push(_Utils_Tuple2(x,y));
549+ return true;
550+ }
551+
552+ /**/
553+ if (x.$ === 'Set_elm_builtin')
554+ {
555+ x = $elm$core$Set$toList(x);
556+ y = $elm$core$Set$toList(y);
557+ }
558+ if (x.$ === 'RBNode_elm_builtin' || x.$ === 'RBEmpty_elm_builtin')
559+ {
560+ x = $elm$core$Dict$toList(x);
561+ y = $elm$core$Dict$toList(y);
562+ }
563+ //*/
564+
565+ /**_UNUSED/
566+ if (x.$ < 0)
567+ {
568+ x = $elm$core$Dict$toList(x);
569+ y = $elm$core$Dict$toList(y);
570+ }
571+ //*/
572+
573+ for (var key in x)
574+ {
575+ if (!_Utils_eqHelp(x[key], y[key], depth + 1, stack))
576+ {
577+ return false;
578+ }
579+ }
580+ return true;
581+}
582+
583+var _Utils_equal = F2(_Utils_eq);
584+var _Utils_notEqual = F2(function(a, b) { return !_Utils_eq(a,b); });
585+
586+
587+
588+// COMPARISONS
589+
590+// Code in Generate/JavaScript.hs, Basics.js, and List.js depends on
591+// the particular integer values assigned to LT, EQ, and GT.
592+
593+function _Utils_cmp(x, y, ord)
594+{
595+ if (typeof x !== 'object')
596+ {
597+ return x === y ? /*EQ*/ 0 : x < y ? /*LT*/ -1 : /*GT*/ 1;
598+ }
599+
600+ /**/
601+ if (x instanceof String)
602+ {
603+ var a = x.valueOf();
604+ var b = y.valueOf();
605+ return a === b ? 0 : a < b ? -1 : 1;
606+ }
607+ //*/
608+
609+ /**_UNUSED/
610+ if (typeof x.$ === 'undefined')
611+ //*/
612+ /**/
613+ if (x.$[0] === '#')
614+ //*/
615+ {
616+ return (ord = _Utils_cmp(x.a, y.a))
617+ ? ord
618+ : (ord = _Utils_cmp(x.b, y.b))
619+ ? ord
620+ : _Utils_cmp(x.c, y.c);
621+ }
622+
623+ // traverse conses until end of a list or a mismatch
624+ for (; x.b && y.b && !(ord = _Utils_cmp(x.a, y.a)); x = x.b, y = y.b) {} // WHILE_CONSES
625+ return ord || (x.b ? /*GT*/ 1 : y.b ? /*LT*/ -1 : /*EQ*/ 0);
626+}
627+
628+var _Utils_lt = F2(function(a, b) { return _Utils_cmp(a, b) < 0; });
629+var _Utils_le = F2(function(a, b) { return _Utils_cmp(a, b) < 1; });
630+var _Utils_gt = F2(function(a, b) { return _Utils_cmp(a, b) > 0; });
631+var _Utils_ge = F2(function(a, b) { return _Utils_cmp(a, b) >= 0; });
632+
633+var _Utils_compare = F2(function(x, y)
634+{
635+ var n = _Utils_cmp(x, y);
636+ return n < 0 ? $elm$core$Basics$LT : n ? $elm$core$Basics$GT : $elm$core$Basics$EQ;
637+});
638+
639+
640+// COMMON VALUES
641+
642+var _Utils_Tuple0 = { $: '#0' };
643+
644+function _Utils_Tuple2(a, b) { return { $: '#2', a: a, b: b }; }
645+
646+function _Utils_Tuple3(a, b, c) { return { $: '#3', a: a, b: b, c: c }; }
647+
648+function _Utils_chr(c) { return new String(c); }
649+
650+
651+// RECORDS
652+
653+function _Utils_update(oldRecord, updatedFields)
654+{
655+ var newRecord = {};
656+
657+ for (var key in oldRecord)
658+ {
659+ newRecord[key] = oldRecord[key];
660+ }
661+
662+ for (var key in updatedFields)
663+ {
664+ newRecord[key] = updatedFields[key];
665+ }
666+
667+ return newRecord;
668+}
669+
670+
671+// APPEND
672+
673+var _Utils_append = F2(_Utils_ap);
674+
675+function _Utils_ap(xs, ys)
676+{
677+ // append Strings
678+ if (typeof xs === 'string')
679+ {
680+ return xs + ys;
681+ }
682+
683+ // append Lists
684+ if (!xs.b)
685+ {
686+ return ys;
687+ }
688+ var root = _List_Cons(xs.a, ys);
689+ xs = xs.b
690+ for (var curr = root; xs.b; xs = xs.b) // WHILE_CONS
691+ {
692+ curr = curr.b = _List_Cons(xs.a, ys);
693+ }
694+ return root;
695+}
696+
697+
698+
699+var _List_Nil = { $: '[]' };
700+
701+function _List_Cons(hd, tl) { return { $: '::', a: hd, b: tl }; }
702+
703+
704+var _List_cons = F2(_List_Cons);
705+
706+function _List_fromArray(arr)
707+{
708+ var out = _List_Nil;
709+ for (var i = arr.length; i--; )
710+ {
711+ out = _List_Cons(arr[i], out);
712+ }
713+ return out;
714+}
715+
716+function _List_toArray(xs)
717+{
718+ for (var out = []; xs.b; xs = xs.b) // WHILE_CONS
719+ {
720+ out.push(xs.a);
721+ }
722+ return out;
723+}
724+
725+var _List_map2 = F3(function(f, xs, ys)
726+{
727+ for (var arr = []; xs.b && ys.b; xs = xs.b, ys = ys.b) // WHILE_CONSES
728+ {
729+ arr.push(A2(f, xs.a, ys.a));
730+ }
731+ return _List_fromArray(arr);
732+});
733+
734+var _List_map3 = F4(function(f, xs, ys, zs)
735+{
736+ for (var arr = []; xs.b && ys.b && zs.b; xs = xs.b, ys = ys.b, zs = zs.b) // WHILE_CONSES
737+ {
738+ arr.push(A3(f, xs.a, ys.a, zs.a));
739+ }
740+ return _List_fromArray(arr);
741+});
742+
743+var _List_map4 = F5(function(f, ws, xs, ys, zs)
744+{
745+ for (var arr = []; ws.b && xs.b && ys.b && zs.b; ws = ws.b, xs = xs.b, ys = ys.b, zs = zs.b) // WHILE_CONSES
746+ {
747+ arr.push(A4(f, ws.a, xs.a, ys.a, zs.a));
748+ }
749+ return _List_fromArray(arr);
750+});
751+
752+var _List_map5 = F6(function(f, vs, ws, xs, ys, zs)
753+{
754+ for (var arr = []; vs.b && ws.b && xs.b && ys.b && zs.b; vs = vs.b, ws = ws.b, xs = xs.b, ys = ys.b, zs = zs.b) // WHILE_CONSES
755+ {
756+ arr.push(A5(f, vs.a, ws.a, xs.a, ys.a, zs.a));
757+ }
758+ return _List_fromArray(arr);
759+});
760+
761+var _List_sortBy = F2(function(f, xs)
762+{
763+ return _List_fromArray(_List_toArray(xs).sort(function(a, b) {
764+ return _Utils_cmp(f(a), f(b));
765+ }));
766+});
767+
768+var _List_sortWith = F2(function(f, xs)
769+{
770+ return _List_fromArray(_List_toArray(xs).sort(function(a, b) {
771+ var ord = A2(f, a, b);
772+ return ord === $elm$core$Basics$EQ ? 0 : ord === $elm$core$Basics$LT ? -1 : 1;
773+ }));
774+});
775+
776+
777+
778+// MATH
779+
780+var _Basics_add = F2(function(a, b) { return a + b; });
781+var _Basics_sub = F2(function(a, b) { return a - b; });
782+var _Basics_mul = F2(function(a, b) { return a * b; });
783+var _Basics_fdiv = F2(function(a, b) { return a / b; });
784+var _Basics_idiv = F2(function(a, b) { return (a / b) | 0; });
785+var _Basics_pow = F2(Math.pow);
786+
787+var _Basics_remainderBy = F2(function(b, a) { return a % b; });
788+
789+// https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/divmodnote-letter.pdf
790+var _Basics_modBy = F2(function(modulus, x)
791+{
792+ var answer = x % modulus;
793+ return modulus === 0
794+ ? _Debug_crash(11)
795+ :
796+ ((answer > 0 && modulus < 0) || (answer < 0 && modulus > 0))
797+ ? answer + modulus
798+ : answer;
799+});
800+
801+
802+// TRIGONOMETRY
803+
804+var _Basics_pi = Math.PI;
805+var _Basics_e = Math.E;
806+var _Basics_cos = Math.cos;
807+var _Basics_sin = Math.sin;
808+var _Basics_tan = Math.tan;
809+var _Basics_acos = Math.acos;
810+var _Basics_asin = Math.asin;
811+var _Basics_atan = Math.atan;
812+var _Basics_atan2 = F2(Math.atan2);
813+
814+
815+// MORE MATH
816+
817+function _Basics_toFloat(x) { return x; }
818+function _Basics_truncate(n) { return n | 0; }
819+function _Basics_isInfinite(n) { return n === Infinity || n === -Infinity; }
820+
821+var _Basics_ceiling = Math.ceil;
822+var _Basics_floor = Math.floor;
823+var _Basics_round = Math.round;
824+var _Basics_sqrt = Math.sqrt;
825+var _Basics_log = Math.log;
826+var _Basics_isNaN = isNaN;
827+
828+
829+// BOOLEANS
830+
831+function _Basics_not(bool) { return !bool; }
832+var _Basics_and = F2(function(a, b) { return a && b; });
833+var _Basics_or = F2(function(a, b) { return a || b; });
834+var _Basics_xor = F2(function(a, b) { return a !== b; });
835+
836+
837+
838+var _String_cons = F2(function(chr, str)
839+{
840+ return chr + str;
841+});
842+
843+function _String_uncons(string)
844+{
845+ var word = string.charCodeAt(0);
846+ return !isNaN(word)
847+ ? $elm$core$Maybe$Just(
848+ 0xD800 <= word && word <= 0xDBFF
849+ ? _Utils_Tuple2(_Utils_chr(string[0] + string[1]), string.slice(2))
850+ : _Utils_Tuple2(_Utils_chr(string[0]), string.slice(1))
851+ )
852+ : $elm$core$Maybe$Nothing;
853+}
854+
855+var _String_append = F2(function(a, b)
856+{
857+ return a + b;
858+});
859+
860+function _String_length(str)
861+{
862+ return str.length;
863+}
864+
865+var _String_map = F2(function(func, string)
866+{
867+ var len = string.length;
868+ var array = new Array(len);
869+ var i = 0;
870+ while (i < len)
871+ {
872+ var word = string.charCodeAt(i);
873+ if (0xD800 <= word && word <= 0xDBFF)
874+ {
875+ array[i] = func(_Utils_chr(string[i] + string[i+1]));
876+ i += 2;
877+ continue;
878+ }
879+ array[i] = func(_Utils_chr(string[i]));
880+ i++;
881+ }
882+ return array.join('');
883+});
884+
885+var _String_filter = F2(function(isGood, str)
886+{
887+ var arr = [];
888+ var len = str.length;
889+ var i = 0;
890+ while (i < len)
891+ {
892+ var char = str[i];
893+ var word = str.charCodeAt(i);
894+ i++;
895+ if (0xD800 <= word && word <= 0xDBFF)
896+ {
897+ char += str[i];
898+ i++;
899+ }
900+
901+ if (isGood(_Utils_chr(char)))
902+ {
903+ arr.push(char);
904+ }
905+ }
906+ return arr.join('');
907+});
908+
909+function _String_reverse(str)
910+{
911+ var len = str.length;
912+ var arr = new Array(len);
913+ var i = 0;
914+ while (i < len)
915+ {
916+ var word = str.charCodeAt(i);
917+ if (0xD800 <= word && word <= 0xDBFF)
918+ {
919+ arr[len - i] = str[i + 1];
920+ i++;
921+ arr[len - i] = str[i - 1];
922+ i++;
923+ }
924+ else
925+ {
926+ arr[len - i] = str[i];
927+ i++;
928+ }
929+ }
930+ return arr.join('');
931+}
932+
933+var _String_foldl = F3(function(func, state, string)
934+{
935+ var len = string.length;
936+ var i = 0;
937+ while (i < len)
938+ {
939+ var char = string[i];
940+ var word = string.charCodeAt(i);
941+ i++;
942+ if (0xD800 <= word && word <= 0xDBFF)
943+ {
944+ char += string[i];
945+ i++;
946+ }
947+ state = A2(func, _Utils_chr(char), state);
948+ }
949+ return state;
950+});
951+
952+var _String_foldr = F3(function(func, state, string)
953+{
954+ var i = string.length;
955+ while (i--)
956+ {
957+ var char = string[i];
958+ var word = string.charCodeAt(i);
959+ if (0xDC00 <= word && word <= 0xDFFF)
960+ {
961+ i--;
962+ char = string[i] + char;
963+ }
964+ state = A2(func, _Utils_chr(char), state);
965+ }
966+ return state;
967+});
968+
969+var _String_split = F2(function(sep, str)
970+{
971+ return str.split(sep);
972+});
973+
974+var _String_join = F2(function(sep, strs)
975+{
976+ return strs.join(sep);
977+});
978+
979+var _String_slice = F3(function(start, end, str) {
980+ return str.slice(start, end);
981+});
982+
983+function _String_trim(str)
984+{
985+ return str.trim();
986+}
987+
988+function _String_trimLeft(str)
989+{
990+ return str.replace(/^\s+/, '');
991+}
992+
993+function _String_trimRight(str)
994+{
995+ return str.replace(/\s+$/, '');
996+}
997+
998+function _String_words(str)
999+{
1000+ return _List_fromArray(str.trim().split(/\s+/g));
1001+}
1002+
1003+function _String_lines(str)
1004+{
1005+ return _List_fromArray(str.split(/\r\n|\r|\n/g));
1006+}
1007+
1008+function _String_toUpper(str)
1009+{
1010+ return str.toUpperCase();
1011+}
1012+
1013+function _String_toLower(str)
1014+{
1015+ return str.toLowerCase();
1016+}
1017+
1018+var _String_any = F2(function(isGood, string)
1019+{
1020+ var i = string.length;
1021+ while (i--)
1022+ {
1023+ var char = string[i];
1024+ var word = string.charCodeAt(i);
1025+ if (0xDC00 <= word && word <= 0xDFFF)
1026+ {
1027+ i--;
1028+ char = string[i] + char;
1029+ }
1030+ if (isGood(_Utils_chr(char)))
1031+ {
1032+ return true;
1033+ }
1034+ }
1035+ return false;
1036+});
1037+
1038+var _String_all = F2(function(isGood, string)
1039+{
1040+ var i = string.length;
1041+ while (i--)
1042+ {
1043+ var char = string[i];
1044+ var word = string.charCodeAt(i);
1045+ if (0xDC00 <= word && word <= 0xDFFF)
1046+ {
1047+ i--;
1048+ char = string[i] + char;
1049+ }
1050+ if (!isGood(_Utils_chr(char)))
1051+ {
1052+ return false;
1053+ }
1054+ }
1055+ return true;
1056+});
1057+
1058+var _String_contains = F2(function(sub, str)
1059+{
1060+ return str.indexOf(sub) > -1;
1061+});
1062+
1063+var _String_startsWith = F2(function(sub, str)
1064+{
1065+ return str.indexOf(sub) === 0;
1066+});
1067+
1068+var _String_endsWith = F2(function(sub, str)
1069+{
1070+ return str.length >= sub.length &&
1071+ str.lastIndexOf(sub) === str.length - sub.length;
1072+});
1073+
1074+var _String_indexes = F2(function(sub, str)
1075+{
1076+ var subLen = sub.length;
1077+
1078+ if (subLen < 1)
1079+ {
1080+ return _List_Nil;
1081+ }
1082+
1083+ var i = 0;
1084+ var is = [];
1085+
1086+ while ((i = str.indexOf(sub, i)) > -1)
1087+ {
1088+ is.push(i);
1089+ i = i + subLen;
1090+ }
1091+
1092+ return _List_fromArray(is);
1093+});
1094+
1095+
1096+// TO STRING
1097+
1098+function _String_fromNumber(number)
1099+{
1100+ return number + '';
1101+}
1102+
1103+
1104+// INT CONVERSIONS
1105+
1106+function _String_toInt(str)
1107+{
1108+ var total = 0;
1109+ var code0 = str.charCodeAt(0);
1110+ var start = code0 == 0x2B /* + */ || code0 == 0x2D /* - */ ? 1 : 0;
1111+
1112+ for (var i = start; i < str.length; ++i)
1113+ {
1114+ var code = str.charCodeAt(i);
1115+ if (code < 0x30 || 0x39 < code)
1116+ {
1117+ return $elm$core$Maybe$Nothing;
1118+ }
1119+ total = 10 * total + code - 0x30;
1120+ }
1121+
1122+ return i == start
1123+ ? $elm$core$Maybe$Nothing
1124+ : $elm$core$Maybe$Just(code0 == 0x2D ? -total : total);
1125+}
1126+
1127+
1128+// FLOAT CONVERSIONS
1129+
1130+function _String_toFloat(s)
1131+{
1132+ // check if it is a hex, octal, or binary number
1133+ if (s.length === 0 || /[\sxbo]/.test(s))
1134+ {
1135+ return $elm$core$Maybe$Nothing;
1136+ }
1137+ var n = +s;
1138+ // faster isNaN check
1139+ return n === n ? $elm$core$Maybe$Just(n) : $elm$core$Maybe$Nothing;
1140+}
1141+
1142+function _String_fromList(chars)
1143+{
1144+ return _List_toArray(chars).join('');
1145+}
1146+
1147+
1148+
1149+
1150+function _Char_toCode(char)
1151+{
1152+ var code = char.charCodeAt(0);
1153+ if (0xD800 <= code && code <= 0xDBFF)
1154+ {
1155+ return (code - 0xD800) * 0x400 + char.charCodeAt(1) - 0xDC00 + 0x10000
1156+ }
1157+ return code;
1158+}
1159+
1160+function _Char_fromCode(code)
1161+{
1162+ return _Utils_chr(
1163+ (code < 0 || 0x10FFFF < code)
1164+ ? '\uFFFD'
1165+ :
1166+ (code <= 0xFFFF)
1167+ ? String.fromCharCode(code)
1168+ :
1169+ (code -= 0x10000,
1170+ String.fromCharCode(Math.floor(code / 0x400) + 0xD800, code % 0x400 + 0xDC00)
1171+ )
1172+ );
1173+}
1174+
1175+function _Char_toUpper(char)
1176+{
1177+ return _Utils_chr(char.toUpperCase());
1178+}
1179+
1180+function _Char_toLower(char)
1181+{
1182+ return _Utils_chr(char.toLowerCase());
1183+}
1184+
1185+function _Char_toLocaleUpper(char)
1186+{
1187+ return _Utils_chr(char.toLocaleUpperCase());
1188+}
1189+
1190+function _Char_toLocaleLower(char)
1191+{
1192+ return _Utils_chr(char.toLocaleLowerCase());
1193+}
1194+
1195+
1196+
1197+/**/
1198+function _Json_errorToString(error)
1199+{
1200+ return $elm$json$Json$Decode$errorToString(error);
1201+}
1202+//*/
1203+
1204+
1205+// CORE DECODERS
1206+
1207+function _Json_succeed(msg)
1208+{
1209+ return {
1210+ $: 0,
1211+ a: msg
1212+ };
1213+}
1214+
1215+function _Json_fail(msg)
1216+{
1217+ return {
1218+ $: 1,
1219+ a: msg
1220+ };
1221+}
1222+
1223+function _Json_decodePrim(decoder)
1224+{
1225+ return { $: 2, b: decoder };
1226+}
1227+
1228+var _Json_decodeInt = _Json_decodePrim(function(value) {
1229+ return (typeof value !== 'number')
1230+ ? _Json_expecting('an INT', value)
1231+ :
1232+ (-2147483647 < value && value < 2147483647 && (value | 0) === value)
1233+ ? $elm$core$Result$Ok(value)
1234+ :
1235+ (isFinite(value) && !(value % 1))
1236+ ? $elm$core$Result$Ok(value)
1237+ : _Json_expecting('an INT', value);
1238+});
1239+
1240+var _Json_decodeBool = _Json_decodePrim(function(value) {
1241+ return (typeof value === 'boolean')
1242+ ? $elm$core$Result$Ok(value)
1243+ : _Json_expecting('a BOOL', value);
1244+});
1245+
1246+var _Json_decodeFloat = _Json_decodePrim(function(value) {
1247+ return (typeof value === 'number')
1248+ ? $elm$core$Result$Ok(value)
1249+ : _Json_expecting('a FLOAT', value);
1250+});
1251+
1252+var _Json_decodeValue = _Json_decodePrim(function(value) {
1253+ return $elm$core$Result$Ok(_Json_wrap(value));
1254+});
1255+
1256+var _Json_decodeString = _Json_decodePrim(function(value) {
1257+ return (typeof value === 'string')
1258+ ? $elm$core$Result$Ok(value)
1259+ : (value instanceof String)
1260+ ? $elm$core$Result$Ok(value + '')
1261+ : _Json_expecting('a STRING', value);
1262+});
1263+
1264+function _Json_decodeList(decoder) { return { $: 3, b: decoder }; }
1265+function _Json_decodeArray(decoder) { return { $: 4, b: decoder }; }
1266+
1267+function _Json_decodeNull(value) { return { $: 5, c: value }; }
1268+
1269+var _Json_decodeField = F2(function(field, decoder)
1270+{
1271+ return {
1272+ $: 6,
1273+ d: field,
1274+ b: decoder
1275+ };
1276+});
1277+
1278+var _Json_decodeIndex = F2(function(index, decoder)
1279+{
1280+ return {
1281+ $: 7,
1282+ e: index,
1283+ b: decoder
1284+ };
1285+});
1286+
1287+function _Json_decodeKeyValuePairs(decoder)
1288+{
1289+ return {
1290+ $: 8,
1291+ b: decoder
1292+ };
1293+}
1294+
1295+function _Json_mapMany(f, decoders)
1296+{
1297+ return {
1298+ $: 9,
1299+ f: f,
1300+ g: decoders
1301+ };
1302+}
1303+
1304+var _Json_andThen = F2(function(callback, decoder)
1305+{
1306+ return {
1307+ $: 10,
1308+ b: decoder,
1309+ h: callback
1310+ };
1311+});
1312+
1313+function _Json_oneOf(decoders)
1314+{
1315+ return {
1316+ $: 11,
1317+ g: decoders
1318+ };
1319+}
1320+
1321+
1322+// DECODING OBJECTS
1323+
1324+var _Json_map1 = F2(function(f, d1)
1325+{
1326+ return _Json_mapMany(f, [d1]);
1327+});
1328+
1329+var _Json_map2 = F3(function(f, d1, d2)
1330+{
1331+ return _Json_mapMany(f, [d1, d2]);
1332+});
1333+
1334+var _Json_map3 = F4(function(f, d1, d2, d3)
1335+{
1336+ return _Json_mapMany(f, [d1, d2, d3]);
1337+});
1338+
1339+var _Json_map4 = F5(function(f, d1, d2, d3, d4)
1340+{
1341+ return _Json_mapMany(f, [d1, d2, d3, d4]);
1342+});
1343+
1344+var _Json_map5 = F6(function(f, d1, d2, d3, d4, d5)
1345+{
1346+ return _Json_mapMany(f, [d1, d2, d3, d4, d5]);
1347+});
1348+
1349+var _Json_map6 = F7(function(f, d1, d2, d3, d4, d5, d6)
1350+{
1351+ return _Json_mapMany(f, [d1, d2, d3, d4, d5, d6]);
1352+});
1353+
1354+var _Json_map7 = F8(function(f, d1, d2, d3, d4, d5, d6, d7)
1355+{
1356+ return _Json_mapMany(f, [d1, d2, d3, d4, d5, d6, d7]);
1357+});
1358+
1359+var _Json_map8 = F9(function(f, d1, d2, d3, d4, d5, d6, d7, d8)
1360+{
1361+ return _Json_mapMany(f, [d1, d2, d3, d4, d5, d6, d7, d8]);
1362+});
1363+
1364+
1365+// DECODE
1366+
1367+var _Json_runOnString = F2(function(decoder, string)
1368+{
1369+ try
1370+ {
1371+ var value = JSON.parse(string);
1372+ return _Json_runHelp(decoder, value);
1373+ }
1374+ catch (e)
1375+ {
1376+ return $elm$core$Result$Err(A2($elm$json$Json$Decode$Failure, 'This is not valid JSON! ' + e.message, _Json_wrap(string)));
1377+ }
1378+});
1379+
1380+var _Json_run = F2(function(decoder, value)
1381+{
1382+ return _Json_runHelp(decoder, _Json_unwrap(value));
1383+});
1384+
1385+function _Json_runHelp(decoder, value)
1386+{
1387+ switch (decoder.$)
1388+ {
1389+ case 2:
1390+ return decoder.b(value);
1391+
1392+ case 5:
1393+ return (value === null)
1394+ ? $elm$core$Result$Ok(decoder.c)
1395+ : _Json_expecting('null', value);
1396+
1397+ case 3:
1398+ if (!_Json_isArray(value))
1399+ {
1400+ return _Json_expecting('a LIST', value);
1401+ }
1402+ return _Json_runArrayDecoder(decoder.b, value, _List_fromArray);
1403+
1404+ case 4:
1405+ if (!_Json_isArray(value))
1406+ {
1407+ return _Json_expecting('an ARRAY', value);
1408+ }
1409+ return _Json_runArrayDecoder(decoder.b, value, _Json_toElmArray);
1410+
1411+ case 6:
1412+ var field = decoder.d;
1413+ if (typeof value !== 'object' || value === null || !(field in value))
1414+ {
1415+ return _Json_expecting('an OBJECT with a field named `' + field + '`', value);
1416+ }
1417+ var result = _Json_runHelp(decoder.b, value[field]);
1418+ return ($elm$core$Result$isOk(result)) ? result : $elm$core$Result$Err(A2($elm$json$Json$Decode$Field, field, result.a));
1419+
1420+ case 7:
1421+ var index = decoder.e;
1422+ if (!_Json_isArray(value))
1423+ {
1424+ return _Json_expecting('an ARRAY', value);
1425+ }
1426+ if (index >= value.length)
1427+ {
1428+ return _Json_expecting('a LONGER array. Need index ' + index + ' but only see ' + value.length + ' entries', value);
1429+ }
1430+ var result = _Json_runHelp(decoder.b, value[index]);
1431+ return ($elm$core$Result$isOk(result)) ? result : $elm$core$Result$Err(A2($elm$json$Json$Decode$Index, index, result.a));
1432+
1433+ case 8:
1434+ if (typeof value !== 'object' || value === null || _Json_isArray(value))
1435+ {
1436+ return _Json_expecting('an OBJECT', value);
1437+ }
1438+
1439+ var keyValuePairs = _List_Nil;
1440+ // TODO test perf of Object.keys and switch when support is good enough
1441+ for (var key in value)
1442+ {
1443+ if (value.hasOwnProperty(key))
1444+ {
1445+ var result = _Json_runHelp(decoder.b, value[key]);
1446+ if (!$elm$core$Result$isOk(result))
1447+ {
1448+ return $elm$core$Result$Err(A2($elm$json$Json$Decode$Field, key, result.a));
1449+ }
1450+ keyValuePairs = _List_Cons(_Utils_Tuple2(key, result.a), keyValuePairs);
1451+ }
1452+ }
1453+ return $elm$core$Result$Ok($elm$core$List$reverse(keyValuePairs));
1454+
1455+ case 9:
1456+ var answer = decoder.f;
1457+ var decoders = decoder.g;
1458+ for (var i = 0; i < decoders.length; i++)
1459+ {
1460+ var result = _Json_runHelp(decoders[i], value);
1461+ if (!$elm$core$Result$isOk(result))
1462+ {
1463+ return result;
1464+ }
1465+ answer = answer(result.a);
1466+ }
1467+ return $elm$core$Result$Ok(answer);
1468+
1469+ case 10:
1470+ var result = _Json_runHelp(decoder.b, value);
1471+ return (!$elm$core$Result$isOk(result))
1472+ ? result
1473+ : _Json_runHelp(decoder.h(result.a), value);
1474+
1475+ case 11:
1476+ var errors = _List_Nil;
1477+ for (var temp = decoder.g; temp.b; temp = temp.b) // WHILE_CONS
1478+ {
1479+ var result = _Json_runHelp(temp.a, value);
1480+ if ($elm$core$Result$isOk(result))
1481+ {
1482+ return result;
1483+ }
1484+ errors = _List_Cons(result.a, errors);
1485+ }
1486+ return $elm$core$Result$Err($elm$json$Json$Decode$OneOf($elm$core$List$reverse(errors)));
1487+
1488+ case 1:
1489+ return $elm$core$Result$Err(A2($elm$json$Json$Decode$Failure, decoder.a, _Json_wrap(value)));
1490+
1491+ case 0:
1492+ return $elm$core$Result$Ok(decoder.a);
1493+ }
1494+}
1495+
1496+function _Json_runArrayDecoder(decoder, value, toElmValue)
1497+{
1498+ var len = value.length;
1499+ var array = new Array(len);
1500+ for (var i = 0; i < len; i++)
1501+ {
1502+ var result = _Json_runHelp(decoder, value[i]);
1503+ if (!$elm$core$Result$isOk(result))
1504+ {
1505+ return $elm$core$Result$Err(A2($elm$json$Json$Decode$Index, i, result.a));
1506+ }
1507+ array[i] = result.a;
1508+ }
1509+ return $elm$core$Result$Ok(toElmValue(array));
1510+}
1511+
1512+function _Json_isArray(value)
1513+{
1514+ return Array.isArray(value) || (typeof FileList !== 'undefined' && value instanceof FileList);
1515+}
1516+
1517+function _Json_toElmArray(array)
1518+{
1519+ return A2($elm$core$Array$initialize, array.length, function(i) { return array[i]; });
1520+}
1521+
1522+function _Json_expecting(type, value)
1523+{
1524+ return $elm$core$Result$Err(A2($elm$json$Json$Decode$Failure, 'Expecting ' + type, _Json_wrap(value)));
1525+}
1526+
1527+
1528+// EQUALITY
1529+
1530+function _Json_equality(x, y)
1531+{
1532+ if (x === y)
1533+ {
1534+ return true;
1535+ }
1536+
1537+ if (x.$ !== y.$)
1538+ {
1539+ return false;
1540+ }
1541+
1542+ switch (x.$)
1543+ {
1544+ case 0:
1545+ case 1:
1546+ return x.a === y.a;
1547+
1548+ case 2:
1549+ return x.b === y.b;
1550+
1551+ case 5:
1552+ return x.c === y.c;
1553+
1554+ case 3:
1555+ case 4:
1556+ case 8:
1557+ return _Json_equality(x.b, y.b);
1558+
1559+ case 6:
1560+ return x.d === y.d && _Json_equality(x.b, y.b);
1561+
1562+ case 7:
1563+ return x.e === y.e && _Json_equality(x.b, y.b);
1564+
1565+ case 9:
1566+ return x.f === y.f && _Json_listEquality(x.g, y.g);
1567+
1568+ case 10:
1569+ return x.h === y.h && _Json_equality(x.b, y.b);
1570+
1571+ case 11:
1572+ return _Json_listEquality(x.g, y.g);
1573+ }
1574+}
1575+
1576+function _Json_listEquality(aDecoders, bDecoders)
1577+{
1578+ var len = aDecoders.length;
1579+ if (len !== bDecoders.length)
1580+ {
1581+ return false;
1582+ }
1583+ for (var i = 0; i < len; i++)
1584+ {
1585+ if (!_Json_equality(aDecoders[i], bDecoders[i]))
1586+ {
1587+ return false;
1588+ }
1589+ }
1590+ return true;
1591+}
1592+
1593+
1594+// ENCODE
1595+
1596+var _Json_encode = F2(function(indentLevel, value)
1597+{
1598+ return JSON.stringify(_Json_unwrap(value), null, indentLevel) + '';
1599+});
1600+
1601+function _Json_wrap(value) { return { $: 0, a: value }; }
1602+function _Json_unwrap(value) { return value.a; }
1603+
1604+
1605+function _Json_emptyArray() { return []; }
1606+function _Json_emptyObject() { return {}; }
1607+
1608+var _Json_addField = F3(function(key, value, object)
1609+{
1610+ object[key] = _Json_unwrap(value);
1611+ return object;
1612+});
1613+
1614+function _Json_addEntry(func)
1615+{
1616+ return F2(function(entry, array)
1617+ {
1618+ array.push(_Json_unwrap(func(entry)));
1619+ return array;
1620+ });
1621+}
1622+
1623+var _Json_encodeNull = _Json_wrap(null);
1624+
1625+
1626+
1627+// TASKS
1628+
1629+function _Scheduler_succeed(value)
1630+{
1631+ return {
1632+ $: 0,
1633+ a: value
1634+ };
1635+}
1636+
1637+function _Scheduler_fail(error)
1638+{
1639+ return {
1640+ $: 1,
1641+ a: error
1642+ };
1643+}
1644+
1645+function _Scheduler_binding(callback)
1646+{
1647+ return {
1648+ $: 2,
1649+ b: callback,
1650+ c: null
1651+ };
1652+}
1653+
1654+var _Scheduler_andThen = F2(function(callback, task)
1655+{
1656+ return {
1657+ $: 3,
1658+ b: callback,
1659+ d: task
1660+ };
1661+});
1662+
1663+var _Scheduler_onError = F2(function(callback, task)
1664+{
1665+ return {
1666+ $: 4,
1667+ b: callback,
1668+ d: task
1669+ };
1670+});
1671+
1672+function _Scheduler_receive(callback)
1673+{
1674+ return {
1675+ $: 5,
1676+ b: callback
1677+ };
1678+}
1679+
1680+
1681+// PROCESSES
1682+
1683+var _Scheduler_guid = 0;
1684+
1685+function _Scheduler_rawSpawn(task)
1686+{
1687+ var proc = {
1688+ $: 0,
1689+ e: _Scheduler_guid++,
1690+ f: task,
1691+ g: null,
1692+ h: []
1693+ };
1694+
1695+ _Scheduler_enqueue(proc);
1696+
1697+ return proc;
1698+}
1699+
1700+function _Scheduler_spawn(task)
1701+{
1702+ return _Scheduler_binding(function(callback) {
1703+ callback(_Scheduler_succeed(_Scheduler_rawSpawn(task)));
1704+ });
1705+}
1706+
1707+function _Scheduler_rawSend(proc, msg)
1708+{
1709+ proc.h.push(msg);
1710+ _Scheduler_enqueue(proc);
1711+}
1712+
1713+var _Scheduler_send = F2(function(proc, msg)
1714+{
1715+ return _Scheduler_binding(function(callback) {
1716+ _Scheduler_rawSend(proc, msg);
1717+ callback(_Scheduler_succeed(_Utils_Tuple0));
1718+ });
1719+});
1720+
1721+function _Scheduler_kill(proc)
1722+{
1723+ return _Scheduler_binding(function(callback) {
1724+ var task = proc.f;
1725+ if (task.$ === 2 && task.c)
1726+ {
1727+ task.c();
1728+ }
1729+
1730+ proc.f = null;
1731+
1732+ callback(_Scheduler_succeed(_Utils_Tuple0));
1733+ });
1734+}
1735+
1736+
1737+/* STEP PROCESSES
1738+
1739+type alias Process =
1740+ { $ : tag
1741+ , id : unique_id
1742+ , root : Task
1743+ , stack : null | { $: SUCCEED | FAIL, a: callback, b: stack }
1744+ , mailbox : [msg]
1745+ }
1746+
1747+*/
1748+
1749+
1750+var _Scheduler_working = false;
1751+var _Scheduler_queue = [];
1752+
1753+
1754+function _Scheduler_enqueue(proc)
1755+{
1756+ _Scheduler_queue.push(proc);
1757+ if (_Scheduler_working)
1758+ {
1759+ return;
1760+ }
1761+ _Scheduler_working = true;
1762+ while (proc = _Scheduler_queue.shift())
1763+ {
1764+ _Scheduler_step(proc);
1765+ }
1766+ _Scheduler_working = false;
1767+}
1768+
1769+
1770+function _Scheduler_step(proc)
1771+{
1772+ while (proc.f)
1773+ {
1774+ var rootTag = proc.f.$;
1775+ if (rootTag === 0 || rootTag === 1)
1776+ {
1777+ while (proc.g && proc.g.$ !== rootTag)
1778+ {
1779+ proc.g = proc.g.i;
1780+ }
1781+ if (!proc.g)
1782+ {
1783+ return;
1784+ }
1785+ proc.f = proc.g.b(proc.f.a);
1786+ proc.g = proc.g.i;
1787+ }
1788+ else if (rootTag === 2)
1789+ {
1790+ proc.f.c = proc.f.b(function(newRoot) {
1791+ proc.f = newRoot;
1792+ _Scheduler_enqueue(proc);
1793+ });
1794+ return;
1795+ }
1796+ else if (rootTag === 5)
1797+ {
1798+ if (proc.h.length === 0)
1799+ {
1800+ return;
1801+ }
1802+ proc.f = proc.f.b(proc.h.shift());
1803+ }
1804+ else // if (rootTag === 3 || rootTag === 4)
1805+ {
1806+ proc.g = {
1807+ $: rootTag === 3 ? 0 : 1,
1808+ b: proc.f.b,
1809+ i: proc.g
1810+ };
1811+ proc.f = proc.f.d;
1812+ }
1813+ }
1814+}
1815+
1816+
1817+
1818+function _Process_sleep(time)
1819+{
1820+ return _Scheduler_binding(function(callback) {
1821+ var id = setTimeout(function() {
1822+ callback(_Scheduler_succeed(_Utils_Tuple0));
1823+ }, time);
1824+
1825+ return function() { clearTimeout(id); };
1826+ });
1827+}
1828+
1829+
1830+
1831+
1832+// PROGRAMS
1833+
1834+
1835+var _Platform_worker = F4(function(impl, flagDecoder, debugMetadata, args)
1836+{
1837+ return _Platform_initialize(
1838+ flagDecoder,
1839+ args,
1840+ impl.init,
1841+ impl.update,
1842+ impl.subscriptions,
1843+ function() { return function() {} }
1844+ );
1845+});
1846+
1847+
1848+
1849+// INITIALIZE A PROGRAM
1850+
1851+
1852+function _Platform_initialize(flagDecoder, args, init, update, subscriptions, stepperBuilder)
1853+{
1854+ var result = A2(_Json_run, flagDecoder, _Json_wrap(args ? args['flags'] : undefined));
1855+ $elm$core$Result$isOk(result) || _Debug_crash(2 /**/, _Json_errorToString(result.a) /**/);
1856+ var managers = {};
1857+ var initPair = init(result.a);
1858+ var model = initPair.a;
1859+ var stepper = stepperBuilder(sendToApp, model);
1860+ var ports = _Platform_setupEffects(managers, sendToApp);
1861+
1862+ function sendToApp(msg, viewMetadata)
1863+ {
1864+ var pair = A2(update, msg, model);
1865+ stepper(model = pair.a, viewMetadata);
1866+ _Platform_enqueueEffects(managers, pair.b, subscriptions(model));
1867+ }
1868+
1869+ _Platform_enqueueEffects(managers, initPair.b, subscriptions(model));
1870+
1871+ return ports ? { ports: ports } : {};
1872+}
1873+
1874+
1875+
1876+// TRACK PRELOADS
1877+//
1878+// This is used by code in elm/browser and elm/http
1879+// to register any HTTP requests that are triggered by init.
1880+//
1881+
1882+
1883+var _Platform_preload;
1884+
1885+
1886+function _Platform_registerPreload(url)
1887+{
1888+ _Platform_preload.add(url);
1889+}
1890+
1891+
1892+
1893+// EFFECT MANAGERS
1894+
1895+
1896+var _Platform_effectManagers = {};
1897+
1898+
1899+function _Platform_setupEffects(managers, sendToApp)
1900+{
1901+ var ports;
1902+
1903+ // setup all necessary effect managers
1904+ for (var key in _Platform_effectManagers)
1905+ {
1906+ var manager = _Platform_effectManagers[key];
1907+
1908+ if (manager.a)
1909+ {
1910+ ports = ports || {};
1911+ ports[key] = manager.a(key, sendToApp);
1912+ }
1913+
1914+ managers[key] = _Platform_instantiateManager(manager, sendToApp);
1915+ }
1916+
1917+ return ports;
1918+}
1919+
1920+
1921+function _Platform_createManager(init, onEffects, onSelfMsg, cmdMap, subMap)
1922+{
1923+ return {
1924+ b: init,
1925+ c: onEffects,
1926+ d: onSelfMsg,
1927+ e: cmdMap,
1928+ f: subMap
1929+ };
1930+}
1931+
1932+
1933+function _Platform_instantiateManager(info, sendToApp)
1934+{
1935+ var router = {
1936+ g: sendToApp,
1937+ h: undefined
1938+ };
1939+
1940+ var onEffects = info.c;
1941+ var onSelfMsg = info.d;
1942+ var cmdMap = info.e;
1943+ var subMap = info.f;
1944+
1945+ function loop(state)
1946+ {
1947+ return A2(_Scheduler_andThen, loop, _Scheduler_receive(function(msg)
1948+ {
1949+ var value = msg.a;
1950+
1951+ if (msg.$ === 0)
1952+ {
1953+ return A3(onSelfMsg, router, value, state);
1954+ }
1955+
1956+ return cmdMap && subMap
1957+ ? A4(onEffects, router, value.i, value.j, state)
1958+ : A3(onEffects, router, cmdMap ? value.i : value.j, state);
1959+ }));
1960+ }
1961+
1962+ return router.h = _Scheduler_rawSpawn(A2(_Scheduler_andThen, loop, info.b));
1963+}
1964+
1965+
1966+
1967+// ROUTING
1968+
1969+
1970+var _Platform_sendToApp = F2(function(router, msg)
1971+{
1972+ return _Scheduler_binding(function(callback)
1973+ {
1974+ router.g(msg);
1975+ callback(_Scheduler_succeed(_Utils_Tuple0));
1976+ });
1977+});
1978+
1979+
1980+var _Platform_sendToSelf = F2(function(router, msg)
1981+{
1982+ return A2(_Scheduler_send, router.h, {
1983+ $: 0,
1984+ a: msg
1985+ });
1986+});
1987+
1988+
1989+
1990+// BAGS
1991+
1992+
1993+function _Platform_leaf(home)
1994+{
1995+ return function(value)
1996+ {
1997+ return {
1998+ $: 1,
1999+ k: home,
2000+ l: value
2001+ };
2002+ };
2003+}
2004+
2005+
2006+function _Platform_batch(list)
2007+{
2008+ return {
2009+ $: 2,
2010+ m: list
2011+ };
2012+}
2013+
2014+
2015+var _Platform_map = F2(function(tagger, bag)
2016+{
2017+ return {
2018+ $: 3,
2019+ n: tagger,
2020+ o: bag
2021+ }
2022+});
2023+
2024+
2025+
2026+// PIPE BAGS INTO EFFECT MANAGERS
2027+//
2028+// Effects must be queued!
2029+//
2030+// Say your init contains a synchronous command, like Time.now or Time.here
2031+//
2032+// - This will produce a batch of effects (FX_1)
2033+// - The synchronous task triggers the subsequent `update` call
2034+// - This will produce a batch of effects (FX_2)
2035+//
2036+// If we just start dispatching FX_2, subscriptions from FX_2 can be processed
2037+// before subscriptions from FX_1. No good! Earlier versions of this code had
2038+// this problem, leading to these reports:
2039+//
2040+// https://github.com/elm/core/issues/980
2041+// https://github.com/elm/core/pull/981
2042+// https://github.com/elm/compiler/issues/1776
2043+//
2044+// The queue is necessary to avoid ordering issues for synchronous commands.
2045+
2046+
2047+// Why use true/false here? Why not just check the length of the queue?
2048+// The goal is to detect "are we currently dispatching effects?" If we
2049+// are, we need to bail and let the ongoing while loop handle things.
2050+//
2051+// Now say the queue has 1 element. When we dequeue the final element,
2052+// the queue will be empty, but we are still actively dispatching effects.
2053+// So you could get queue jumping in a really tricky category of cases.
2054+//
2055+var _Platform_effectsQueue = [];
2056+var _Platform_effectsActive = false;
2057+
2058+
2059+function _Platform_enqueueEffects(managers, cmdBag, subBag)
2060+{
2061+ _Platform_effectsQueue.push({ p: managers, q: cmdBag, r: subBag });
2062+
2063+ if (_Platform_effectsActive) return;
2064+
2065+ _Platform_effectsActive = true;
2066+ for (var fx; fx = _Platform_effectsQueue.shift(); )
2067+ {
2068+ _Platform_dispatchEffects(fx.p, fx.q, fx.r);
2069+ }
2070+ _Platform_effectsActive = false;
2071+}
2072+
2073+
2074+function _Platform_dispatchEffects(managers, cmdBag, subBag)
2075+{
2076+ var effectsDict = {};
2077+ _Platform_gatherEffects(true, cmdBag, effectsDict, null);
2078+ _Platform_gatherEffects(false, subBag, effectsDict, null);
2079+
2080+ for (var home in managers)
2081+ {
2082+ _Scheduler_rawSend(managers[home], {
2083+ $: 'fx',
2084+ a: effectsDict[home] || { i: _List_Nil, j: _List_Nil }
2085+ });
2086+ }
2087+}
2088+
2089+
2090+function _Platform_gatherEffects(isCmd, bag, effectsDict, taggers)
2091+{
2092+ switch (bag.$)
2093+ {
2094+ case 1:
2095+ var home = bag.k;
2096+ var effect = _Platform_toEffect(isCmd, home, taggers, bag.l);
2097+ effectsDict[home] = _Platform_insert(isCmd, effect, effectsDict[home]);
2098+ return;
2099+
2100+ case 2:
2101+ for (var list = bag.m; list.b; list = list.b) // WHILE_CONS
2102+ {
2103+ _Platform_gatherEffects(isCmd, list.a, effectsDict, taggers);
2104+ }
2105+ return;
2106+
2107+ case 3:
2108+ _Platform_gatherEffects(isCmd, bag.o, effectsDict, {
2109+ s: bag.n,
2110+ t: taggers
2111+ });
2112+ return;
2113+ }
2114+}
2115+
2116+
2117+function _Platform_toEffect(isCmd, home, taggers, value)
2118+{
2119+ function applyTaggers(x)
2120+ {
2121+ for (var temp = taggers; temp; temp = temp.t)
2122+ {
2123+ x = temp.s(x);
2124+ }
2125+ return x;
2126+ }
2127+
2128+ var map = isCmd
2129+ ? _Platform_effectManagers[home].e
2130+ : _Platform_effectManagers[home].f;
2131+
2132+ return A2(map, applyTaggers, value)
2133+}
2134+
2135+
2136+function _Platform_insert(isCmd, newEffect, effects)
2137+{
2138+ effects = effects || { i: _List_Nil, j: _List_Nil };
2139+
2140+ isCmd
2141+ ? (effects.i = _List_Cons(newEffect, effects.i))
2142+ : (effects.j = _List_Cons(newEffect, effects.j));
2143+
2144+ return effects;
2145+}
2146+
2147+
2148+
2149+// PORTS
2150+
2151+
2152+function _Platform_checkPortName(name)
2153+{
2154+ if (_Platform_effectManagers[name])
2155+ {
2156+ _Debug_crash(3, name)
2157+ }
2158+}
2159+
2160+
2161+
2162+// OUTGOING PORTS
2163+
2164+
2165+function _Platform_outgoingPort(name, converter)
2166+{
2167+ _Platform_checkPortName(name);
2168+ _Platform_effectManagers[name] = {
2169+ e: _Platform_outgoingPortMap,
2170+ u: converter,
2171+ a: _Platform_setupOutgoingPort
2172+ };
2173+ return _Platform_leaf(name);
2174+}
2175+
2176+
2177+var _Platform_outgoingPortMap = F2(function(tagger, value) { return value; });
2178+
2179+
2180+function _Platform_setupOutgoingPort(name)
2181+{
2182+ var subs = [];
2183+ var converter = _Platform_effectManagers[name].u;
2184+
2185+ // CREATE MANAGER
2186+
2187+ var init = _Process_sleep(0);
2188+
2189+ _Platform_effectManagers[name].b = init;
2190+ _Platform_effectManagers[name].c = F3(function(router, cmdList, state)
2191+ {
2192+ for ( ; cmdList.b; cmdList = cmdList.b) // WHILE_CONS
2193+ {
2194+ // grab a separate reference to subs in case unsubscribe is called
2195+ var currentSubs = subs;
2196+ var value = _Json_unwrap(converter(cmdList.a));
2197+ for (var i = 0; i < currentSubs.length; i++)
2198+ {
2199+ currentSubs[i](value);
2200+ }
2201+ }
2202+ return init;
2203+ });
2204+
2205+ // PUBLIC API
2206+
2207+ function subscribe(callback)
2208+ {
2209+ subs.push(callback);
2210+ }
2211+
2212+ function unsubscribe(callback)
2213+ {
2214+ // copy subs into a new array in case unsubscribe is called within a
2215+ // subscribed callback
2216+ subs = subs.slice();
2217+ var index = subs.indexOf(callback);
2218+ if (index >= 0)
2219+ {
2220+ subs.splice(index, 1);
2221+ }
2222+ }
2223+
2224+ return {
2225+ subscribe: subscribe,
2226+ unsubscribe: unsubscribe
2227+ };
2228+}
2229+
2230+
2231+
2232+// INCOMING PORTS
2233+
2234+
2235+function _Platform_incomingPort(name, converter)
2236+{
2237+ _Platform_checkPortName(name);
2238+ _Platform_effectManagers[name] = {
2239+ f: _Platform_incomingPortMap,
2240+ u: converter,
2241+ a: _Platform_setupIncomingPort
2242+ };
2243+ return _Platform_leaf(name);
2244+}
2245+
2246+
2247+var _Platform_incomingPortMap = F2(function(tagger, finalTagger)
2248+{
2249+ return function(value)
2250+ {
2251+ return tagger(finalTagger(value));
2252+ };
2253+});
2254+
2255+
2256+function _Platform_setupIncomingPort(name, sendToApp)
2257+{
2258+ var subs = _List_Nil;
2259+ var converter = _Platform_effectManagers[name].u;
2260+
2261+ // CREATE MANAGER
2262+
2263+ var init = _Scheduler_succeed(null);
2264+
2265+ _Platform_effectManagers[name].b = init;
2266+ _Platform_effectManagers[name].c = F3(function(router, subList, state)
2267+ {
2268+ subs = subList;
2269+ return init;
2270+ });
2271+
2272+ // PUBLIC API
2273+
2274+ function send(incomingValue)
2275+ {
2276+ var result = A2(_Json_run, converter, _Json_wrap(incomingValue));
2277+
2278+ $elm$core$Result$isOk(result) || _Debug_crash(4, name, result.a);
2279+
2280+ var value = result.a;
2281+ for (var temp = subs; temp.b; temp = temp.b) // WHILE_CONS
2282+ {
2283+ sendToApp(temp.a(value));
2284+ }
2285+ }
2286+
2287+ return { send: send };
2288+}
2289+
2290+
2291+
2292+// EXPORT ELM MODULES
2293+//
2294+// Have DEBUG and PROD versions so that we can (1) give nicer errors in
2295+// debug mode and (2) not pay for the bits needed for that in prod mode.
2296+//
2297+
2298+
2299+
2300+
2301+function _Platform_mergeExportsProd(obj, exports)
2302+{
2303+ for (var name in exports)
2304+ {
2305+ (name in obj)
2306+ ? (name == 'init')
2307+ ? _Debug_crash(6)
2308+ : _Platform_mergeExportsProd(obj[name], exports[name])
2309+ : (obj[name] = exports[name]);
2310+ }
2311+}
2312+
2313+
2314+function _Platform_export(exports)
2315+{
2316+ scope['Elm']
2317+ ? _Platform_mergeExportsDebug('Elm', scope['Elm'], exports)
2318+ : scope['Elm'] = exports;
2319+}
2320+
2321+
2322+function _Platform_mergeExportsDebug(moduleName, obj, exports)
2323+{
2324+ for (var name in exports)
2325+ {
2326+ (name in obj)
2327+ ? (name == 'init')
2328+ ? _Debug_crash(6, moduleName)
2329+ : _Platform_mergeExportsDebug(moduleName + '.' + name, obj[name], exports[name])
2330+ : (obj[name] = exports[name]);
2331+ }
2332+}
2333+
2334+
2335+
2336+var _Lynx_g = (typeof globalThis !== 'undefined' ? globalThis : scope);
2337+function _Lynx_papi(name) { return _Lynx_g['_' + '_' + name] || function() {}; }
2338+var _Lynx_createViewFn = _Lynx_papi('CreateView');
2339+var _Lynx_createTextFn = _Lynx_papi('CreateText');
2340+var _Lynx_createImageFn = _Lynx_papi('CreateImage');
2341+function _Lynx_createElement(tag) {
2342+ var pId = (_Lynx_g['native'] && _Lynx_g['native']['currentPageId']) || 0;
2343+ return (tag === 'text' ? _Lynx_createTextFn
2344+ : tag === 'image' ? _Lynx_createImageFn
2345+ : _Lynx_createViewFn)(pId);
2346+}
2347+var _Lynx_createRawText = _Lynx_papi('CreateRawText');
2348+var _Lynx_appendChild = _Lynx_papi('AppendElement');
2349+var _Lynx_removeElement = _Lynx_papi('RemoveElement');
2350+var _Lynx_replaceElement = _Lynx_papi('ReplaceElement');
2351+var _Lynx_insertBefore = _Lynx_papi('InsertElementBefore');
2352+var _Lynx_setAttribute = _Lynx_papi('SetAttribute');
2353+var _Lynx_getChildren = _Lynx_papi('GetChildren');
2354+var _Lynx_getParent = _Lynx_papi('GetParent');
2355+var _Lynx_addEvent = _Lynx_papi('AddEvent');
2356+var _Lynx_setInlineStyles = _Lynx_papi('SetInlineStyles');
2357+var _VirtualDom_elementMeta = new WeakMap();
2358+function _VirtualDom_getMeta(el) {
2359+ var meta = _VirtualDom_elementMeta.get(el);
2360+ if (!meta) { meta = {}; _VirtualDom_elementMeta.set(el, meta); }
2361+ return meta;
2362+}
2363+
2364+
2365+// HELPERS
2366+
2367+
2368+
2369+
2370+
2371+function _VirtualDom_appendChild(parent, child)
2372+{
2373+ _Lynx_appendChild(parent, child);
2374+}
2375+
2376+var _VirtualDom_init = F4(function(virtualNode, flagDecoder, debugMetadata, args)
2377+{
2378+ // NOTE: this function needs _Platform_export available to work
2379+ var rootPage = args['node'] || _Lynx_g['page'];
2380+ var tree = _VirtualDom_render(virtualNode, function() {});
2381+ _Lynx_appendChild(rootPage, tree);
2382+ return {};
2383+});
2384+
2385+
2386+
2387+// TEXT
2388+
2389+
2390+function _VirtualDom_text(string)
2391+{
2392+ return {
2393+ $: 0,
2394+ a: string
2395+ };
2396+}
2397+
2398+
2399+
2400+// NODE
2401+
2402+
2403+var _VirtualDom_nodeNS = F2(function(namespace, tag)
2404+{
2405+ return F2(function(factList, kidList)
2406+ {
2407+ for (var kids = [], descendantsCount = 0; kidList.b; kidList = kidList.b) // WHILE_CONS
2408+ {
2409+ var kid = kidList.a;
2410+ descendantsCount += (kid.b || 0);
2411+ kids.push(kid);
2412+ }
2413+ descendantsCount += kids.length;
2414+
2415+ return {
2416+ $: 1,
2417+ c: tag,
2418+ d: _VirtualDom_organizeFacts(factList),
2419+ e: kids,
2420+ f: namespace,
2421+ b: descendantsCount
2422+ };
2423+ });
2424+});
2425+
2426+
2427+var _VirtualDom_node = _VirtualDom_nodeNS(undefined);
2428+
2429+
2430+
2431+// KEYED NODE
2432+
2433+
2434+var _VirtualDom_keyedNodeNS = F2(function(namespace, tag)
2435+{
2436+ return F2(function(factList, kidList)
2437+ {
2438+ for (var kids = [], descendantsCount = 0; kidList.b; kidList = kidList.b) // WHILE_CONS
2439+ {
2440+ var kid = kidList.a;
2441+ descendantsCount += (kid.b.b || 0);
2442+ kids.push(kid);
2443+ }
2444+ descendantsCount += kids.length;
2445+
2446+ return {
2447+ $: 2,
2448+ c: tag,
2449+ d: _VirtualDom_organizeFacts(factList),
2450+ e: kids,
2451+ f: namespace,
2452+ b: descendantsCount
2453+ };
2454+ });
2455+});
2456+
2457+
2458+var _VirtualDom_keyedNode = _VirtualDom_keyedNodeNS(undefined);
2459+
2460+
2461+
2462+// CUSTOM
2463+
2464+
2465+function _VirtualDom_custom(factList, model, render, diff)
2466+{
2467+ return {
2468+ $: 3,
2469+ d: _VirtualDom_organizeFacts(factList),
2470+ g: model,
2471+ h: render,
2472+ i: diff
2473+ };
2474+}
2475+
2476+
2477+
2478+// MAP
2479+
2480+
2481+var _VirtualDom_map = F2(function(tagger, node)
2482+{
2483+ return {
2484+ $: 4,
2485+ j: tagger,
2486+ k: node,
2487+ b: 1 + (node.b || 0)
2488+ };
2489+});
2490+
2491+
2492+
2493+// LAZY
2494+
2495+
2496+function _VirtualDom_thunk(refs, thunk)
2497+{
2498+ return {
2499+ $: 5,
2500+ l: refs,
2501+ m: thunk,
2502+ k: undefined
2503+ };
2504+}
2505+
2506+var _VirtualDom_lazy = F2(function(func, a)
2507+{
2508+ return _VirtualDom_thunk([func, a], function() {
2509+ return func(a);
2510+ });
2511+});
2512+
2513+var _VirtualDom_lazy2 = F3(function(func, a, b)
2514+{
2515+ return _VirtualDom_thunk([func, a, b], function() {
2516+ return A2(func, a, b);
2517+ });
2518+});
2519+
2520+var _VirtualDom_lazy3 = F4(function(func, a, b, c)
2521+{
2522+ return _VirtualDom_thunk([func, a, b, c], function() {
2523+ return A3(func, a, b, c);
2524+ });
2525+});
2526+
2527+var _VirtualDom_lazy4 = F5(function(func, a, b, c, d)
2528+{
2529+ return _VirtualDom_thunk([func, a, b, c, d], function() {
2530+ return A4(func, a, b, c, d);
2531+ });
2532+});
2533+
2534+var _VirtualDom_lazy5 = F6(function(func, a, b, c, d, e)
2535+{
2536+ return _VirtualDom_thunk([func, a, b, c, d, e], function() {
2537+ return A5(func, a, b, c, d, e);
2538+ });
2539+});
2540+
2541+var _VirtualDom_lazy6 = F7(function(func, a, b, c, d, e, f)
2542+{
2543+ return _VirtualDom_thunk([func, a, b, c, d, e, f], function() {
2544+ return A6(func, a, b, c, d, e, f);
2545+ });
2546+});
2547+
2548+var _VirtualDom_lazy7 = F8(function(func, a, b, c, d, e, f, g)
2549+{
2550+ return _VirtualDom_thunk([func, a, b, c, d, e, f, g], function() {
2551+ return A7(func, a, b, c, d, e, f, g);
2552+ });
2553+});
2554+
2555+var _VirtualDom_lazy8 = F9(function(func, a, b, c, d, e, f, g, h)
2556+{
2557+ return _VirtualDom_thunk([func, a, b, c, d, e, f, g, h], function() {
2558+ return A8(func, a, b, c, d, e, f, g, h);
2559+ });
2560+});
2561+
2562+
2563+
2564+// FACTS
2565+
2566+
2567+var _VirtualDom_on = F2(function(key, handler)
2568+{
2569+ return {
2570+ $: 'a0',
2571+ n: key,
2572+ o: handler
2573+ };
2574+});
2575+var _VirtualDom_style = F2(function(key, value)
2576+{
2577+ return {
2578+ $: 'a1',
2579+ n: key,
2580+ o: value
2581+ };
2582+});
2583+var _VirtualDom_property = F2(function(key, value)
2584+{
2585+ return {
2586+ $: 'a2',
2587+ n: key,
2588+ o: value
2589+ };
2590+});
2591+var _VirtualDom_attribute = F2(function(key, value)
2592+{
2593+ return {
2594+ $: 'a3',
2595+ n: key,
2596+ o: value
2597+ };
2598+});
2599+var _VirtualDom_attributeNS = F3(function(namespace, key, value)
2600+{
2601+ return {
2602+ $: 'a4',
2603+ n: key,
2604+ o: { f: namespace, o: value }
2605+ };
2606+});
2607+
2608+
2609+
2610+// XSS ATTACK VECTOR CHECKS
2611+//
2612+// For some reason, tabs can appear in href protocols and it still works.
2613+// So '\tjava\tSCRIPT:alert("!!!")' and 'javascript:alert("!!!")' are the same
2614+// in practice. That is why _VirtualDom_RE_js and _VirtualDom_RE_js_html look
2615+// so freaky.
2616+//
2617+// Pulling the regular expressions out to the top level gives a slight speed
2618+// boost in small benchmarks (4-10%) but hoisting values to reduce allocation
2619+// can be unpredictable in large programs where JIT may have a harder time with
2620+// functions are not fully self-contained. The benefit is more that the js and
2621+// js_html ones are so weird that I prefer to see them near each other.
2622+
2623+
2624+
2625+
2626+
2627+function _VirtualDom_noScript(tag)
2628+{
2629+ return tag;
2630+}
2631+
2632+function _VirtualDom_noOnOrFormAction(key)
2633+{
2634+ return key;
2635+}
2636+
2637+function _VirtualDom_noInnerHtmlOrFormAction(key)
2638+{
2639+ return key;
2640+}
2641+
2642+function _VirtualDom_noJavaScriptUri(value)
2643+{
2644+ return value;
2645+}
2646+
2647+function _VirtualDom_noJavaScriptOrHtmlUri(value)
2648+{
2649+ return value;
2650+}
2651+
2652+function _VirtualDom_noJavaScriptOrHtmlJson(value)
2653+{
2654+ return value;
2655+}
2656+
2657+
2658+
2659+// MAP FACTS
2660+
2661+
2662+var _VirtualDom_mapAttribute = F2(function(func, attr)
2663+{
2664+ return (attr.$ === 'a0')
2665+ ? A2(_VirtualDom_on, attr.n, _VirtualDom_mapHandler(func, attr.o))
2666+ : attr;
2667+});
2668+
2669+function _VirtualDom_mapHandler(func, handler)
2670+{
2671+ var tag = $lynxjs_elm$virtual_dom$VirtualDom$toHandlerInt(handler);
2672+
2673+ // 0 = Normal
2674+ // 1 = MayStopPropagation
2675+ // 2 = MayPreventDefault
2676+ // 3 = Custom
2677+
2678+ return {
2679+ $: handler.$,
2680+ a:
2681+ !tag
2682+ ? A2($elm$json$Json$Decode$map, func, handler.a)
2683+ :
2684+ A3($elm$json$Json$Decode$map2,
2685+ tag < 3
2686+ ? _VirtualDom_mapEventTuple
2687+ : _VirtualDom_mapEventRecord,
2688+ $elm$json$Json$Decode$succeed(func),
2689+ handler.a
2690+ )
2691+ };
2692+}
2693+
2694+var _VirtualDom_mapEventTuple = F2(function(func, tuple)
2695+{
2696+ return _Utils_Tuple2(func(tuple.a), tuple.b);
2697+});
2698+
2699+var _VirtualDom_mapEventRecord = F2(function(func, record)
2700+{
2701+ return {
2702+ message: func(record.message),
2703+ stopPropagation: record.stopPropagation,
2704+ preventDefault: record.preventDefault
2705+ }
2706+});
2707+
2708+
2709+
2710+// ORGANIZE FACTS
2711+
2712+
2713+function _VirtualDom_organizeFacts(factList)
2714+{
2715+ for (var facts = {}; factList.b; factList = factList.b) // WHILE_CONS
2716+ {
2717+ var entry = factList.a;
2718+
2719+ var tag = entry.$;
2720+ var key = entry.n;
2721+ var value = entry.o;
2722+
2723+ if (tag === 'a2')
2724+ {
2725+ (key === 'className')
2726+ ? _VirtualDom_addClass(facts, key, _Json_unwrap(value))
2727+ : facts[key] = _Json_unwrap(value);
2728+
2729+ continue;
2730+ }
2731+
2732+ var subFacts = facts[tag] || (facts[tag] = {});
2733+ (tag === 'a3' && key === 'class')
2734+ ? _VirtualDom_addClass(subFacts, key, value)
2735+ : subFacts[key] = value;
2736+ }
2737+
2738+ return facts;
2739+}
2740+
2741+function _VirtualDom_addClass(object, key, newClass)
2742+{
2743+ var classes = object[key];
2744+ object[key] = classes ? classes + ' ' + newClass : newClass;
2745+}
2746+
2747+
2748+
2749+// RENDER
2750+
2751+
2752+function _VirtualDom_render(vNode, eventNode)
2753+{
2754+ var tag = vNode.$;
2755+
2756+ if (tag === 5)
2757+ {
2758+ return _VirtualDom_render(vNode.k || (vNode.k = vNode.m()), eventNode);
2759+ }
2760+
2761+ if (tag === 0)
2762+ {
2763+ return _Lynx_createRawText(vNode.a);
2764+ }
2765+
2766+ if (tag === 4)
2767+ {
2768+ var subNode = vNode.k;
2769+ var tagger = vNode.j;
2770+
2771+ while (subNode.$ === 4)
2772+ {
2773+ typeof tagger !== 'object'
2774+ ? tagger = [tagger, subNode.j]
2775+ : tagger.push(subNode.j);
2776+
2777+ subNode = subNode.k;
2778+ }
2779+
2780+ var subEventRoot = { j: tagger, p: eventNode };
2781+ var domNode = _VirtualDom_render(subNode, subEventRoot);
2782+ _VirtualDom_getMeta(domNode).elm_event_node_ref = subEventRoot;
2783+ return domNode;
2784+ }
2785+
2786+ if (tag === 3)
2787+ {
2788+ var domNode = vNode.h(vNode.g);
2789+ _VirtualDom_applyFacts(domNode, eventNode, vNode.d);
2790+ return domNode;
2791+ }
2792+
2793+ // at this point `tag` must be 1 or 2
2794+
2795+ var domNode = _Lynx_createElement(vNode.c);
2796+
2797+ _VirtualDom_applyFacts(domNode, eventNode, vNode.d);
2798+
2799+ for (var kids = vNode.e, i = 0; i < kids.length; i++)
2800+ {
2801+ var kid = tag === 1 ? kids[i] : kids[i].b;
2802+ if (kid.$ === 0)
2803+ {
2804+ _Lynx_appendChild(domNode, _Lynx_createRawText(kid.a));
2805+ }
2806+ else
2807+ {
2808+ _VirtualDom_appendChild(domNode, _VirtualDom_render(kid, eventNode));
2809+ }
2810+ }
2811+
2812+ return domNode;
2813+}
2814+
2815+
2816+
2817+// APPLY FACTS
2818+
2819+
2820+function _VirtualDom_applyFacts(domNode, eventNode, facts)
2821+{
2822+ for (var key in facts)
2823+ {
2824+ var value = facts[key];
2825+
2826+ key === 'a1'
2827+ ? _VirtualDom_applyStyles(domNode, value)
2828+ :
2829+ key === 'a0'
2830+ ? _VirtualDom_applyEvents(domNode, eventNode, value)
2831+ :
2832+ key === 'a3'
2833+ ? _VirtualDom_applyAttrs(domNode, value)
2834+ :
2835+ key === 'a4'
2836+ ? _VirtualDom_applyAttrsNS(domNode, value)
2837+ :
2838+ (key !== 'value' && key !== 'checked' || domNode[key] !== value) && _Lynx_setAttribute(domNode, key === 'className' ? 'class' : key, String(value));
2839+ }
2840+}
2841+
2842+
2843+
2844+// APPLY STYLES
2845+
2846+
2847+function _VirtualDom_applyStyles(domNode, styles)
2848+{
2849+ _Lynx_setInlineStyles(domNode, styles);
2850+}
2851+
2852+
2853+
2854+// APPLY ATTRS
2855+
2856+
2857+function _VirtualDom_applyAttrs(domNode, attrs)
2858+{
2859+ for (var key in attrs)
2860+ {
2861+ var value = attrs[key];
2862+ if (typeof value !== 'undefined')
2863+ {
2864+ _Lynx_setAttribute(domNode, key, value);
2865+ }
2866+ }
2867+}
2868+
2869+
2870+
2871+// APPLY NAMESPACED ATTRS
2872+
2873+
2874+function _VirtualDom_applyAttrsNS(domNode, nsAttrs)
2875+{
2876+ for (var key in nsAttrs)
2877+ {
2878+ var pair = nsAttrs[key];
2879+ var value = pair.o;
2880+
2881+ if (typeof value !== 'undefined')
2882+ {
2883+ _Lynx_setAttribute(domNode, key, value);
2884+ }
2885+ }
2886+}
2887+
2888+
2889+
2890+// APPLY EVENTS
2891+
2892+
2893+function _VirtualDom_applyEvents(domNode, eventNode, events)
2894+{
2895+ var meta = _VirtualDom_getMeta(domNode);
2896+ var allCallbacks = meta.elmFs || (meta.elmFs = {});
2897+
2898+ for (var key in events)
2899+ {
2900+ var newHandler = events[key];
2901+ var oldCallback = allCallbacks[key];
2902+
2903+ if (!newHandler)
2904+ {
2905+ allCallbacks[key] = undefined;
2906+ continue;
2907+ }
2908+
2909+ if (oldCallback)
2910+ {
2911+ var oldHandler = oldCallback.q;
2912+ if (oldHandler.$ === newHandler.$)
2913+ {
2914+ oldCallback.q = newHandler;
2915+ continue;
2916+ }
2917+ }
2918+
2919+ oldCallback = _VirtualDom_makeCallback(eventNode, newHandler);
2920+ allCallbacks[key] = oldCallback;
2921+
2922+ var lynxEventName = _VirtualDom_mapEventName(key);
2923+ var handlerType = $lynxjs_elm$virtual_dom$VirtualDom$toHandlerInt(newHandler);
2924+ var prefix = (handlerType === 1) ? 'catch' : 'bind';
2925+ _Lynx_addEvent(domNode, 'catchEvent', lynxEventName, { type: 'worklet', value: oldCallback });
2926+ }
2927+}
2928+
2929+function _VirtualDom_mapEventName(name)
2930+{
2931+ switch (name)
2932+ {
2933+ case 'click': return 'tap';
2934+ case 'dblclick': return 'tap';
2935+ case 'mousedown': return 'touchstart';
2936+ case 'mousemove': return 'touchmove';
2937+ case 'mouseup': return 'touchend';
2938+ default: return name;
2939+ }
2940+}
2941+
2942+
2943+
2944+// PASSIVE EVENTS
2945+
2946+
2947+
2948+// EVENT HANDLERS
2949+
2950+
2951+function _VirtualDom_makeCallback(eventNode, initialHandler)
2952+{
2953+ function callback(event)
2954+ {
2955+ var handler = callback.q;
2956+ var result = _Json_runHelp(handler.a, event);
2957+
2958+ if (!$elm$core$Result$isOk(result))
2959+ {
2960+ return;
2961+ }
2962+
2963+ var tag = $lynxjs_elm$virtual_dom$VirtualDom$toHandlerInt(handler);
2964+
2965+ // 0 = Normal
2966+ // 1 = MayStopPropagation
2967+ // 2 = MayPreventDefault
2968+ // 3 = Custom
2969+
2970+ var value = result.a;
2971+ var message = !tag ? value : tag < 3 ? value.a : value.message;
2972+ var stopPropagation = tag == 1 ? value.b : tag == 3 && value.stopPropagation;
2973+ var currentEventNode = eventNode;
2974+ var tagger;
2975+ var i;
2976+ while (tagger = currentEventNode.j)
2977+ {
2978+ if (typeof tagger == 'function')
2979+ {
2980+ message = tagger(message);
2981+ }
2982+ else
2983+ {
2984+ for (var i = tagger.length; i--; )
2985+ {
2986+ message = tagger[i](message);
2987+ }
2988+ }
2989+ currentEventNode = currentEventNode.p;
2990+ }
2991+ currentEventNode(message, stopPropagation); // stopPropagation implies isSync
2992+ }
2993+
2994+ callback.q = initialHandler;
2995+
2996+ return callback;
2997+}
2998+
2999+function _VirtualDom_equalEvents(x, y)
3000+{
3001+ return x.$ == y.$ && _Json_equality(x.a, y.a);
3002+}
3003+
3004+
3005+
3006+// DIFF
3007+
3008+
3009+// TODO: Should we do patches like in iOS?
3010+//
3011+// type Patch
3012+// = At Int Patch
3013+// | Batch (List Patch)
3014+// | Change ...
3015+//
3016+// How could it not be better?
3017+//
3018+function _VirtualDom_diff(x, y)
3019+{
3020+ var patches = [];
3021+ _VirtualDom_diffHelp(x, y, patches, 0);
3022+ return patches;
3023+}
3024+
3025+
3026+function _VirtualDom_pushPatch(patches, type, index, data)
3027+{
3028+ var patch = {
3029+ $: type,
3030+ r: index,
3031+ s: data,
3032+ t: undefined,
3033+ u: undefined
3034+ };
3035+ patches.push(patch);
3036+ return patch;
3037+}
3038+
3039+
3040+function _VirtualDom_diffHelp(x, y, patches, index)
3041+{
3042+ if (x === y)
3043+ {
3044+ return;
3045+ }
3046+
3047+ var xType = x.$;
3048+ var yType = y.$;
3049+
3050+ // Bail if you run into different types of nodes. Implies that the
3051+ // structure has changed significantly and it's not worth a diff.
3052+ if (xType !== yType)
3053+ {
3054+ if (xType === 1 && yType === 2)
3055+ {
3056+ y = _VirtualDom_dekey(y);
3057+ yType = 1;
3058+ }
3059+ else
3060+ {
3061+ _VirtualDom_pushPatch(patches, 0, index, y);
3062+ return;
3063+ }
3064+ }
3065+
3066+ // Now we know that both nodes are the same $.
3067+ switch (yType)
3068+ {
3069+ case 5:
3070+ var xRefs = x.l;
3071+ var yRefs = y.l;
3072+ var i = xRefs.length;
3073+ var same = i === yRefs.length;
3074+ while (same && i--)
3075+ {
3076+ same = xRefs[i] === yRefs[i];
3077+ }
3078+ if (same)
3079+ {
3080+ y.k = x.k;
3081+ return;
3082+ }
3083+ y.k = y.m();
3084+ var subPatches = [];
3085+ _VirtualDom_diffHelp(x.k, y.k, subPatches, 0);
3086+ subPatches.length > 0 && _VirtualDom_pushPatch(patches, 1, index, subPatches);
3087+ return;
3088+
3089+ case 4:
3090+ // gather nested taggers
3091+ var xTaggers = x.j;
3092+ var yTaggers = y.j;
3093+ var nesting = false;
3094+
3095+ var xSubNode = x.k;
3096+ while (xSubNode.$ === 4)
3097+ {
3098+ nesting = true;
3099+
3100+ typeof xTaggers !== 'object'
3101+ ? xTaggers = [xTaggers, xSubNode.j]
3102+ : xTaggers.push(xSubNode.j);
3103+
3104+ xSubNode = xSubNode.k;
3105+ }
3106+
3107+ var ySubNode = y.k;
3108+ while (ySubNode.$ === 4)
3109+ {
3110+ nesting = true;
3111+
3112+ typeof yTaggers !== 'object'
3113+ ? yTaggers = [yTaggers, ySubNode.j]
3114+ : yTaggers.push(ySubNode.j);
3115+
3116+ ySubNode = ySubNode.k;
3117+ }
3118+
3119+ // Just bail if different numbers of taggers. This implies the
3120+ // structure of the virtual DOM has changed.
3121+ if (nesting && xTaggers.length !== yTaggers.length)
3122+ {
3123+ _VirtualDom_pushPatch(patches, 0, index, y);
3124+ return;
3125+ }
3126+
3127+ // check if taggers are "the same"
3128+ if (nesting ? !_VirtualDom_pairwiseRefEqual(xTaggers, yTaggers) : xTaggers !== yTaggers)
3129+ {
3130+ _VirtualDom_pushPatch(patches, 2, index, yTaggers);
3131+ }
3132+
3133+ // diff everything below the taggers
3134+ _VirtualDom_diffHelp(xSubNode, ySubNode, patches, index + 1);
3135+ return;
3136+
3137+ case 0:
3138+ if (x.a !== y.a)
3139+ {
3140+ _VirtualDom_pushPatch(patches, 3, index, y.a);
3141+ }
3142+ return;
3143+
3144+ case 1:
3145+ _VirtualDom_diffNodes(x, y, patches, index, _VirtualDom_diffKids);
3146+ return;
3147+
3148+ case 2:
3149+ _VirtualDom_diffNodes(x, y, patches, index, _VirtualDom_diffKeyedKids);
3150+ return;
3151+
3152+ case 3:
3153+ if (x.h !== y.h)
3154+ {
3155+ _VirtualDom_pushPatch(patches, 0, index, y);
3156+ return;
3157+ }
3158+
3159+ var factsDiff = _VirtualDom_diffFacts(x.d, y.d);
3160+ factsDiff && _VirtualDom_pushPatch(patches, 4, index, factsDiff);
3161+
3162+ var patch = y.i(x.g, y.g);
3163+ patch && _VirtualDom_pushPatch(patches, 5, index, patch);
3164+
3165+ return;
3166+ }
3167+}
3168+
3169+// assumes the incoming arrays are the same length
3170+function _VirtualDom_pairwiseRefEqual(as, bs)
3171+{
3172+ for (var i = 0; i < as.length; i++)
3173+ {
3174+ if (as[i] !== bs[i])
3175+ {
3176+ return false;
3177+ }
3178+ }
3179+
3180+ return true;
3181+}
3182+
3183+function _VirtualDom_diffNodes(x, y, patches, index, diffKids)
3184+{
3185+ // Bail if obvious indicators have changed. Implies more serious
3186+ // structural changes such that it's not worth it to diff.
3187+ if (x.c !== y.c || x.f !== y.f)
3188+ {
3189+ _VirtualDom_pushPatch(patches, 0, index, y);
3190+ return;
3191+ }
3192+
3193+ var factsDiff = _VirtualDom_diffFacts(x.d, y.d);
3194+ factsDiff && _VirtualDom_pushPatch(patches, 4, index, factsDiff);
3195+
3196+ diffKids(x, y, patches, index);
3197+}
3198+
3199+
3200+
3201+// DIFF FACTS
3202+
3203+
3204+// TODO Instead of creating a new diff object, it's possible to just test if
3205+// there *is* a diff. During the actual patch, do the diff again and make the
3206+// modifications directly. This way, there's no new allocations. Worth it?
3207+function _VirtualDom_diffFacts(x, y, category)
3208+{
3209+ var diff;
3210+
3211+ // look for changes and removals
3212+ for (var xKey in x)
3213+ {
3214+ if (xKey === 'a1' || xKey === 'a0' || xKey === 'a3' || xKey === 'a4')
3215+ {
3216+ var subDiff = _VirtualDom_diffFacts(x[xKey], y[xKey] || {}, xKey);
3217+ if (subDiff)
3218+ {
3219+ diff = diff || {};
3220+ diff[xKey] = subDiff;
3221+ }
3222+ continue;
3223+ }
3224+
3225+ // remove if not in the new facts
3226+ if (!(xKey in y))
3227+ {
3228+ diff = diff || {};
3229+ diff[xKey] =
3230+ !category
3231+ ? (typeof x[xKey] === 'string' ? '' : null)
3232+ :
3233+ (category === 'a1')
3234+ ? ''
3235+ :
3236+ (category === 'a0' || category === 'a3')
3237+ ? undefined
3238+ :
3239+ { f: x[xKey].f, o: undefined };
3240+
3241+ continue;
3242+ }
3243+
3244+ var xValue = x[xKey];
3245+ var yValue = y[xKey];
3246+
3247+ // reference equal, so don't worry about it
3248+ if (xValue === yValue && xKey !== 'value' && xKey !== 'checked'
3249+ || category === 'a0' && _VirtualDom_equalEvents(xValue, yValue))
3250+ {
3251+ continue;
3252+ }
3253+
3254+ diff = diff || {};
3255+ diff[xKey] = yValue;
3256+ }
3257+
3258+ // add new stuff
3259+ for (var yKey in y)
3260+ {
3261+ if (!(yKey in x))
3262+ {
3263+ diff = diff || {};
3264+ diff[yKey] = y[yKey];
3265+ }
3266+ }
3267+
3268+ return diff;
3269+}
3270+
3271+
3272+
3273+// DIFF KIDS
3274+
3275+
3276+function _VirtualDom_diffKids(xParent, yParent, patches, index)
3277+{
3278+ var xKids = xParent.e;
3279+ var yKids = yParent.e;
3280+
3281+ var xLen = xKids.length;
3282+ var yLen = yKids.length;
3283+
3284+ // FIGURE OUT IF THERE ARE INSERTS OR REMOVALS
3285+
3286+ if (xLen > yLen)
3287+ {
3288+ _VirtualDom_pushPatch(patches, 6, index, {
3289+ v: yLen,
3290+ i: xLen - yLen
3291+ });
3292+ }
3293+ else if (xLen < yLen)
3294+ {
3295+ _VirtualDom_pushPatch(patches, 7, index, {
3296+ v: xLen,
3297+ e: yKids
3298+ });
3299+ }
3300+
3301+ // PAIRWISE DIFF EVERYTHING ELSE
3302+
3303+ for (var minLen = xLen < yLen ? xLen : yLen, i = 0; i < minLen; i++)
3304+ {
3305+ var xKid = xKids[i];
3306+ _VirtualDom_diffHelp(xKid, yKids[i], patches, ++index);
3307+ index += xKid.b || 0;
3308+ }
3309+}
3310+
3311+
3312+
3313+// KEYED DIFF
3314+
3315+
3316+function _VirtualDom_diffKeyedKids(xParent, yParent, patches, rootIndex)
3317+{
3318+ var localPatches = [];
3319+
3320+ var changes = {}; // Dict String Entry
3321+ var inserts = []; // Array { index : Int, entry : Entry }
3322+ // type Entry = { tag : String, vnode : VNode, index : Int, data : _ }
3323+
3324+ var xKids = xParent.e;
3325+ var yKids = yParent.e;
3326+ var xLen = xKids.length;
3327+ var yLen = yKids.length;
3328+ var xIndex = 0;
3329+ var yIndex = 0;
3330+
3331+ var index = rootIndex;
3332+
3333+ while (xIndex < xLen && yIndex < yLen)
3334+ {
3335+ var x = xKids[xIndex];
3336+ var y = yKids[yIndex];
3337+
3338+ var xKey = x.a;
3339+ var yKey = y.a;
3340+ var xNode = x.b;
3341+ var yNode = y.b;
3342+
3343+ var newMatch = undefined;
3344+ var oldMatch = undefined;
3345+
3346+ // check if keys match
3347+
3348+ if (xKey === yKey)
3349+ {
3350+ index++;
3351+ _VirtualDom_diffHelp(xNode, yNode, localPatches, index);
3352+ index += xNode.b || 0;
3353+
3354+ xIndex++;
3355+ yIndex++;
3356+ continue;
3357+ }
3358+
3359+ // look ahead 1 to detect insertions and removals.
3360+
3361+ var xNext = xKids[xIndex + 1];
3362+ var yNext = yKids[yIndex + 1];
3363+
3364+ if (xNext)
3365+ {
3366+ var xNextKey = xNext.a;
3367+ var xNextNode = xNext.b;
3368+ oldMatch = yKey === xNextKey;
3369+ }
3370+
3371+ if (yNext)
3372+ {
3373+ var yNextKey = yNext.a;
3374+ var yNextNode = yNext.b;
3375+ newMatch = xKey === yNextKey;
3376+ }
3377+
3378+
3379+ // swap x and y
3380+ if (newMatch && oldMatch)
3381+ {
3382+ index++;
3383+ _VirtualDom_diffHelp(xNode, yNextNode, localPatches, index);
3384+ _VirtualDom_insertNode(changes, localPatches, xKey, yNode, yIndex, inserts);
3385+ index += xNode.b || 0;
3386+
3387+ index++;
3388+ _VirtualDom_removeNode(changes, localPatches, xKey, xNextNode, index);
3389+ index += xNextNode.b || 0;
3390+
3391+ xIndex += 2;
3392+ yIndex += 2;
3393+ continue;
3394+ }
3395+
3396+ // insert y
3397+ if (newMatch)
3398+ {
3399+ index++;
3400+ _VirtualDom_insertNode(changes, localPatches, yKey, yNode, yIndex, inserts);
3401+ _VirtualDom_diffHelp(xNode, yNextNode, localPatches, index);
3402+ index += xNode.b || 0;
3403+
3404+ xIndex += 1;
3405+ yIndex += 2;
3406+ continue;
3407+ }
3408+
3409+ // remove x
3410+ if (oldMatch)
3411+ {
3412+ index++;
3413+ _VirtualDom_removeNode(changes, localPatches, xKey, xNode, index);
3414+ index += xNode.b || 0;
3415+
3416+ index++;
3417+ _VirtualDom_diffHelp(xNextNode, yNode, localPatches, index);
3418+ index += xNextNode.b || 0;
3419+
3420+ xIndex += 2;
3421+ yIndex += 1;
3422+ continue;
3423+ }
3424+
3425+ // remove x, insert y
3426+ if (xNext && xNextKey === yNextKey)
3427+ {
3428+ index++;
3429+ _VirtualDom_removeNode(changes, localPatches, xKey, xNode, index);
3430+ _VirtualDom_insertNode(changes, localPatches, yKey, yNode, yIndex, inserts);
3431+ index += xNode.b || 0;
3432+
3433+ index++;
3434+ _VirtualDom_diffHelp(xNextNode, yNextNode, localPatches, index);
3435+ index += xNextNode.b || 0;
3436+
3437+ xIndex += 2;
3438+ yIndex += 2;
3439+ continue;
3440+ }
3441+
3442+ break;
3443+ }
3444+
3445+ // eat up any remaining nodes with removeNode and insertNode
3446+
3447+ while (xIndex < xLen)
3448+ {
3449+ index++;
3450+ var x = xKids[xIndex];
3451+ var xNode = x.b;
3452+ _VirtualDom_removeNode(changes, localPatches, x.a, xNode, index);
3453+ index += xNode.b || 0;
3454+ xIndex++;
3455+ }
3456+
3457+ while (yIndex < yLen)
3458+ {
3459+ var endInserts = endInserts || [];
3460+ var y = yKids[yIndex];
3461+ _VirtualDom_insertNode(changes, localPatches, y.a, y.b, undefined, endInserts);
3462+ yIndex++;
3463+ }
3464+
3465+ if (localPatches.length > 0 || inserts.length > 0 || endInserts)
3466+ {
3467+ _VirtualDom_pushPatch(patches, 8, rootIndex, {
3468+ w: localPatches,
3469+ x: inserts,
3470+ y: endInserts
3471+ });
3472+ }
3473+}
3474+
3475+
3476+
3477+// CHANGES FROM KEYED DIFF
3478+
3479+
3480+var _VirtualDom_POSTFIX = '_elmW6BL';
3481+
3482+
3483+function _VirtualDom_insertNode(changes, localPatches, key, vnode, yIndex, inserts)
3484+{
3485+ var entry = changes[key];
3486+
3487+ // never seen this key before
3488+ if (!entry)
3489+ {
3490+ entry = {
3491+ c: 0,
3492+ z: vnode,
3493+ r: yIndex,
3494+ s: undefined
3495+ };
3496+
3497+ inserts.push({ r: yIndex, A: entry });
3498+ changes[key] = entry;
3499+
3500+ return;
3501+ }
3502+
3503+ // this key was removed earlier, a match!
3504+ if (entry.c === 1)
3505+ {
3506+ inserts.push({ r: yIndex, A: entry });
3507+
3508+ entry.c = 2;
3509+ var subPatches = [];
3510+ _VirtualDom_diffHelp(entry.z, vnode, subPatches, entry.r);
3511+ entry.r = yIndex;
3512+ entry.s.s = {
3513+ w: subPatches,
3514+ A: entry
3515+ };
3516+
3517+ return;
3518+ }
3519+
3520+ // this key has already been inserted or moved, a duplicate!
3521+ _VirtualDom_insertNode(changes, localPatches, key + _VirtualDom_POSTFIX, vnode, yIndex, inserts);
3522+}
3523+
3524+
3525+function _VirtualDom_removeNode(changes, localPatches, key, vnode, index)
3526+{
3527+ var entry = changes[key];
3528+
3529+ // never seen this key before
3530+ if (!entry)
3531+ {
3532+ var patch = _VirtualDom_pushPatch(localPatches, 9, index, undefined);
3533+
3534+ changes[key] = {
3535+ c: 1,
3536+ z: vnode,
3537+ r: index,
3538+ s: patch
3539+ };
3540+
3541+ return;
3542+ }
3543+
3544+ // this key was inserted earlier, a match!
3545+ if (entry.c === 0)
3546+ {
3547+ entry.c = 2;
3548+ var subPatches = [];
3549+ _VirtualDom_diffHelp(vnode, entry.z, subPatches, index);
3550+
3551+ _VirtualDom_pushPatch(localPatches, 9, index, {
3552+ w: subPatches,
3553+ A: entry
3554+ });
3555+
3556+ return;
3557+ }
3558+
3559+ // this key has already been removed or moved, a duplicate!
3560+ _VirtualDom_removeNode(changes, localPatches, key + _VirtualDom_POSTFIX, vnode, index);
3561+}
3562+
3563+
3564+
3565+// ADD DOM NODES
3566+//
3567+// Each DOM node has an "index" assigned in order of traversal. It is important
3568+// to minimize our crawl over the actual DOM, so these indexes (along with the
3569+// descendantsCount of virtual nodes) let us skip touching entire subtrees of
3570+// the DOM if we know there are no patches there.
3571+
3572+
3573+function _VirtualDom_addDomNodes(domNode, vNode, patches, eventNode)
3574+{
3575+ _VirtualDom_addDomNodesHelp(domNode, vNode, patches, 0, 0, vNode.b, eventNode);
3576+}
3577+
3578+
3579+// assumes `patches` is non-empty and indexes increase monotonically.
3580+function _VirtualDom_addDomNodesHelp(domNode, vNode, patches, i, low, high, eventNode)
3581+{
3582+ var patch = patches[i];
3583+ var index = patch.r;
3584+
3585+ while (index === low)
3586+ {
3587+ var patchType = patch.$;
3588+
3589+ if (patchType === 1)
3590+ {
3591+ _VirtualDom_addDomNodes(domNode, vNode.k, patch.s, eventNode);
3592+ }
3593+ else if (patchType === 8)
3594+ {
3595+ patch.t = domNode;
3596+ patch.u = eventNode;
3597+
3598+ var subPatches = patch.s.w;
3599+ if (subPatches.length > 0)
3600+ {
3601+ _VirtualDom_addDomNodesHelp(domNode, vNode, subPatches, 0, low, high, eventNode);
3602+ }
3603+ }
3604+ else if (patchType === 9)
3605+ {
3606+ patch.t = domNode;
3607+ patch.u = eventNode;
3608+
3609+ var data = patch.s;
3610+ if (data)
3611+ {
3612+ data.A.s = domNode;
3613+ var subPatches = data.w;
3614+ if (subPatches.length > 0)
3615+ {
3616+ _VirtualDom_addDomNodesHelp(domNode, vNode, subPatches, 0, low, high, eventNode);
3617+ }
3618+ }
3619+ }
3620+ else
3621+ {
3622+ patch.t = domNode;
3623+ patch.u = eventNode;
3624+ }
3625+
3626+ i++;
3627+
3628+ if (!(patch = patches[i]) || (index = patch.r) > high)
3629+ {
3630+ return i;
3631+ }
3632+ }
3633+
3634+ var tag = vNode.$;
3635+
3636+ if (tag === 4)
3637+ {
3638+ var subNode = vNode.k;
3639+
3640+ while (subNode.$ === 4)
3641+ {
3642+ subNode = subNode.k;
3643+ }
3644+
3645+ return _VirtualDom_addDomNodesHelp(domNode, subNode, patches, i, low + 1, high, _VirtualDom_getMeta(domNode).elm_event_node_ref);
3646+ }
3647+
3648+ // tag must be 1 or 2 at this point
3649+
3650+ var vKids = vNode.e;
3651+ var childNodes = _Lynx_getChildren(domNode);
3652+ for (var j = 0; j < vKids.length; j++)
3653+ {
3654+ low++;
3655+ var vKid = tag === 1 ? vKids[j] : vKids[j].b;
3656+ var nextLow = low + (vKid.b || 0);
3657+ if (low <= index && index <= nextLow)
3658+ {
3659+ i = _VirtualDom_addDomNodesHelp(childNodes[j], vKid, patches, i, low, nextLow, eventNode);
3660+ if (!(patch = patches[i]) || (index = patch.r) > high)
3661+ {
3662+ return i;
3663+ }
3664+ }
3665+ low = nextLow;
3666+ }
3667+ return i;
3668+}
3669+
3670+
3671+
3672+// APPLY PATCHES
3673+
3674+
3675+function _VirtualDom_applyPatches(rootDomNode, oldVirtualNode, patches, eventNode)
3676+{
3677+ if (patches.length === 0)
3678+ {
3679+ return rootDomNode;
3680+ }
3681+
3682+ _VirtualDom_addDomNodes(rootDomNode, oldVirtualNode, patches, eventNode);
3683+ return _VirtualDom_applyPatchesHelp(rootDomNode, patches);
3684+}
3685+
3686+function _VirtualDom_applyPatchesHelp(rootDomNode, patches)
3687+{
3688+ for (var i = 0; i < patches.length; i++)
3689+ {
3690+ var patch = patches[i];
3691+ var localDomNode = patch.t
3692+ var newNode = _VirtualDom_applyPatch(localDomNode, patch);
3693+ if (localDomNode === rootDomNode)
3694+ {
3695+ rootDomNode = newNode;
3696+ }
3697+ }
3698+ return rootDomNode;
3699+}
3700+
3701+function _VirtualDom_applyPatch(domNode, patch)
3702+{
3703+ switch (patch.$)
3704+ {
3705+ case 0:
3706+ return _VirtualDom_applyPatchRedraw(domNode, patch.s, patch.u);
3707+
3708+ case 4:
3709+ _VirtualDom_applyFacts(domNode, patch.u, patch.s);
3710+ return domNode;
3711+
3712+ case 3:
3713+ _Lynx_setAttribute(domNode, 'text', patch.s);
3714+ return domNode;
3715+
3716+ case 1:
3717+ return _VirtualDom_applyPatchesHelp(domNode, patch.s);
3718+
3719+ case 2:
3720+ if (_VirtualDom_getMeta(domNode).elm_event_node_ref)
3721+ {
3722+ _VirtualDom_getMeta(domNode).elm_event_node_ref.j = patch.s;
3723+ }
3724+ else
3725+ {
3726+ _VirtualDom_getMeta(domNode).elm_event_node_ref = { j: patch.s, p: patch.u };
3727+ }
3728+ return domNode;
3729+
3730+ case 6:
3731+ var data = patch.s;
3732+ for (var i = 0; i < data.i; i++)
3733+ {
3734+ var children = _Lynx_getChildren(domNode);
3735+ _Lynx_removeElement(domNode, children[data.v]);
3736+ }
3737+ return domNode;
3738+
3739+ case 7:
3740+ var data = patch.s;
3741+ var kids = data.e;
3742+ for (var i = data.v; i < kids.length; i++)
3743+ {
3744+ _Lynx_appendChild(domNode, _VirtualDom_render(kids[i], patch.u));
3745+ }
3746+ return domNode;
3747+
3748+ case 9:
3749+ var data = patch.s;
3750+ if (!data)
3751+ {
3752+ _Lynx_removeElement(_Lynx_getParent(domNode), domNode);
3753+ return domNode;
3754+ }
3755+ var entry = data.A;
3756+ if (typeof entry.r !== 'undefined')
3757+ {
3758+ _Lynx_removeElement(_Lynx_getParent(domNode), domNode);
3759+ }
3760+ entry.s = _VirtualDom_applyPatchesHelp(domNode, data.w);
3761+ return domNode;
3762+
3763+ case 8:
3764+ return _VirtualDom_applyPatchReorder(domNode, patch);
3765+
3766+ case 5:
3767+ return patch.s(domNode);
3768+
3769+ default:
3770+ throw new Error('VirtualDom: unknown patch type');
3771+ }
3772+}
3773+
3774+
3775+function _VirtualDom_applyPatchRedraw(domNode, vNode, eventNode)
3776+{
3777+ var parentNode = _Lynx_getParent(domNode);
3778+ var newNode = _VirtualDom_render(vNode, eventNode);
3779+
3780+ if (!_VirtualDom_getMeta(newNode).elm_event_node_ref)
3781+ {
3782+ _VirtualDom_getMeta(newNode).elm_event_node_ref = _VirtualDom_getMeta(domNode).elm_event_node_ref;
3783+ }
3784+
3785+ if (parentNode && newNode !== domNode)
3786+ {
3787+ _Lynx_replaceElement(parentNode, newNode, domNode);
3788+ }
3789+ return newNode;
3790+}
3791+
3792+
3793+function _VirtualDom_applyPatchReorder(domNode, patch)
3794+{
3795+ var data = patch.s;
3796+
3797+ // remove end inserts
3798+ var endInsertNodes = _VirtualDom_applyPatchReorderEndInsertsHelp(data.y, patch);
3799+
3800+ // removals
3801+ domNode = _VirtualDom_applyPatchesHelp(domNode, data.w);
3802+
3803+ // inserts
3804+ var inserts = data.x;
3805+ for (var i = 0; i < inserts.length; i++)
3806+ {
3807+ var insert = inserts[i];
3808+ var entry = insert.A;
3809+ var node = entry.c === 2
3810+ ? entry.s
3811+ : _VirtualDom_render(entry.z, patch.u);
3812+ var children = _Lynx_getChildren(domNode);
3813+ _Lynx_insertBefore(domNode, node, children[insert.r]);
3814+ }
3815+
3816+ // add end inserts
3817+ if (endInsertNodes)
3818+ {
3819+ for (var i = 0; i < endInsertNodes.length; i++)
3820+ {
3821+ _Lynx_appendChild(domNode, endInsertNodes[i]);
3822+ }
3823+ }
3824+
3825+ return domNode;
3826+}
3827+
3828+
3829+function _VirtualDom_applyPatchReorderEndInsertsHelp(endInserts, patch)
3830+{
3831+ if (!endInserts)
3832+ {
3833+ return;
3834+ }
3835+
3836+ var nodes = [];
3837+ for (var i = 0; i < endInserts.length; i++)
3838+ {
3839+ var insert = endInserts[i];
3840+ var entry = insert.A;
3841+ nodes.push(entry.c === 2
3842+ ? entry.s
3843+ : _VirtualDom_render(entry.z, patch.u)
3844+ );
3845+ }
3846+ return nodes;
3847+}
3848+
3849+
3850+function _VirtualDom_dekey(keyedNode)
3851+{
3852+ var keyedKids = keyedNode.e;
3853+ var len = keyedKids.length;
3854+ var kids = new Array(len);
3855+ for (var i = 0; i < len; i++)
3856+ {
3857+ kids[i] = keyedKids[i].b;
3858+ }
3859+
3860+ return {
3861+ $: 1,
3862+ c: keyedNode.c,
3863+ d: keyedNode.d,
3864+ e: kids,
3865+ f: keyedNode.f,
3866+ b: keyedNode.b
3867+ };
3868+}
3869+
3870+
3871+
3872+// LYNXJS PAPI WRAPPERS
3873+var _Browser_lynx = (typeof globalThis !== 'undefined' ? globalThis : scope);
3874+function _Browser_newPage() {
3875+ return _Browser_lynx['page'];
3876+}
3877+function _Browser_flush() {
3878+ var fn = _Browser_lynx['_' + '_FlushElementTree'];
3879+ if (typeof fn === 'function') { fn(); }
3880+}
3881+
3882+
3883+
3884+// ELEMENT
3885+
3886+
3887+var _Browser_element = F4(function(impl, flagDecoder, debugMetadata, args)
3888+{
3889+ return _Platform_initialize(
3890+ flagDecoder,
3891+ args,
3892+ impl.init,
3893+ impl.update,
3894+ impl.subscriptions,
3895+ function(sendToApp, initialModel) {
3896+ var view = impl.view;
3897+ var domNode = args['node'] || _Browser_newPage();
3898+ var currNode = view(initialModel);
3899+ var currDomNode = _VirtualDom_render(currNode, sendToApp);
3900+ _VirtualDom_appendChild(domNode, currDomNode);
3901+ _Browser_flush();
3902+
3903+ return _Browser_makeAnimator(initialModel, function(model)
3904+ {
3905+ var nextNode = view(model);
3906+ var patches = _VirtualDom_diff(currNode, nextNode);
3907+ currDomNode = _VirtualDom_applyPatches(currDomNode, currNode, patches, sendToApp);
3908+ currNode = nextNode;
3909+ _Browser_flush();
3910+ });
3911+ }
3912+ );
3913+});
3914+
3915+
3916+
3917+// DOCUMENT
3918+
3919+
3920+var _Browser_document = F4(function(impl, flagDecoder, debugMetadata, args)
3921+{
3922+ return _Platform_initialize(
3923+ flagDecoder,
3924+ args,
3925+ impl.init,
3926+ impl.update,
3927+ impl.subscriptions,
3928+ function(sendToApp, initialModel) {
3929+ var view = impl.view;
3930+ var rootNode = args['node'] || _Browser_newPage();
3931+ var doc = view(initialModel);
3932+ var currNode = _VirtualDom_node('view')(_List_Nil)(doc.body);
3933+ var currDomNode = _VirtualDom_render(currNode, sendToApp);
3934+ _VirtualDom_appendChild(rootNode, currDomNode);
3935+ _Browser_flush();
3936+
3937+ return _Browser_makeAnimator(initialModel, function(model)
3938+ {
3939+ var doc = view(model);
3940+ var nextNode = _VirtualDom_node('view')(_List_Nil)(doc.body);
3941+ var patches = _VirtualDom_diff(currNode, nextNode);
3942+ currDomNode = _VirtualDom_applyPatches(currDomNode, currNode, patches, sendToApp);
3943+ currNode = nextNode;
3944+ _Browser_flush();
3945+ });
3946+ }
3947+ );
3948+});
3949+
3950+
3951+
3952+// ANIMATION
3953+
3954+
3955+var _Browser_cancelAnimationFrame =
3956+ function(id) { clearTimeout(id); };
3957+
3958+var _Browser_requestAnimationFrame =
3959+ function(callback) { return setTimeout(callback, 1000 / 60); };
3960+
3961+
3962+function _Browser_makeAnimator(model, draw)
3963+{
3964+ draw(model);
3965+
3966+ var state = 0;
3967+
3968+ function updateIfNeeded()
3969+ {
3970+ state = state === 1
3971+ ? 0
3972+ : ( _Browser_requestAnimationFrame(updateIfNeeded), draw(model), 1 );
3973+ }
3974+
3975+ return function(nextModel, isSync)
3976+ {
3977+ model = nextModel;
3978+
3979+ isSync
3980+ ? ( draw(model),
3981+ state === 2 && (state = 1)
3982+ )
3983+ : ( state === 0 && _Browser_requestAnimationFrame(updateIfNeeded),
3984+ state = 2
3985+ );
3986+ };
3987+}
3988+
3989+
3990+
3991+// APPLICATION
3992+
3993+
3994+function _Browser_application(impl)
3995+{
3996+ return _Browser_document({
3997+ init: function(flags)
3998+ {
3999+ return A3(impl.init, flags, _Browser_fakeUrl(), {});
4000+ },
4001+ view: impl.view,
4002+ update: impl.update,
4003+ subscriptions: impl.subscriptions
4004+ });
4005+}
4006+
4007+function _Browser_fakeUrl()
4008+{
4009+ return {
4010+ protocol: { $: 0 },
4011+ host: 'localhost',
4012+ port_: { $: 1 },
4013+ path: '/',
4014+ query: { $: 1 },
4015+ fragment: { $: 1 }
4016+ };
4017+}
4018+
4019+
4020+
4021+var _Browser_go = F2(function(key, n)
4022+{
4023+ return A2($elm$core$Task$perform, $elm$core$Basics$never, _Scheduler_binding(function() {
4024+ // no-op in LynxJS
4025+ key();
4026+ }));
4027+});
4028+
4029+var _Browser_pushUrl = F2(function(key, url)
4030+{
4031+ return A2($elm$core$Task$perform, $elm$core$Basics$never, _Scheduler_binding(function() {
4032+ // no-op in LynxJS
4033+ key();
4034+ }));
4035+});
4036+
4037+var _Browser_replaceUrl = F2(function(key, url)
4038+{
4039+ return A2($elm$core$Task$perform, $elm$core$Basics$never, _Scheduler_binding(function() {
4040+ // no-op in LynxJS
4041+ key();
4042+ }));
4043+});
4044+
4045+
4046+
4047+// GLOBAL EVENTS
4048+
4049+
4050+var _Browser_fakeNode = { addEventListener: function() {}, removeEventListener: function() {} };
4051+var _Browser_doc = typeof document !== 'undefined' ? document : _Browser_fakeNode;
4052+var _Browser_window = typeof window !== 'undefined' ? window : _Browser_fakeNode;
4053+
4054+var _Browser_on = F3(function(node, eventName, sendToSelf)
4055+{
4056+ return _Scheduler_spawn(_Scheduler_binding(function(callback)
4057+ {
4058+ return function() {};
4059+ }));
4060+});
4061+
4062+var _Browser_decodeEvent = F2(function(decoder, event)
4063+{
4064+ var result = _Json_runHelp(decoder, event);
4065+ return $elm$core$Result$isOk(result) ? $elm$core$Maybe$Just(result.a) : $elm$core$Maybe$Nothing;
4066+});
4067+
4068+
4069+
4070+// PAGE VISIBILITY
4071+
4072+
4073+function _Browser_visibilityInfo()
4074+{
4075+ return (typeof _VirtualDom_doc.hidden !== 'undefined')
4076+ ? { hidden: 'hidden', change: 'visibilitychange' }
4077+ :
4078+ (typeof _VirtualDom_doc.mozHidden !== 'undefined')
4079+ ? { hidden: 'mozHidden', change: 'mozvisibilitychange' }
4080+ :
4081+ (typeof _VirtualDom_doc.msHidden !== 'undefined')
4082+ ? { hidden: 'msHidden', change: 'msvisibilitychange' }
4083+ :
4084+ (typeof _VirtualDom_doc.webkitHidden !== 'undefined')
4085+ ? { hidden: 'webkitHidden', change: 'webkitvisibilitychange' }
4086+ : { hidden: 'hidden', change: 'visibilitychange' };
4087+}
4088+
4089+
4090+
4091+// ANIMATION FRAMES
4092+
4093+
4094+function _Browser_rAF()
4095+{
4096+ return _Scheduler_binding(function(callback)
4097+ {
4098+ var id = _Browser_requestAnimationFrame(function() {
4099+ callback(_Scheduler_succeed(Date.now()));
4100+ });
4101+
4102+ return function() {
4103+ _Browser_cancelAnimationFrame(id);
4104+ };
4105+ });
4106+}
4107+
4108+
4109+function _Browser_now()
4110+{
4111+ return _Scheduler_binding(function(callback)
4112+ {
4113+ callback(_Scheduler_succeed(Date.now()));
4114+ });
4115+}
4116+
4117+
4118+
4119+// DOM STUFF
4120+
4121+
4122+function _Browser_withNode(id, doStuff)
4123+{
4124+ return _Scheduler_binding(function(callback)
4125+ {
4126+ callback(_Scheduler_fail($lynxjs_elm$browser$Browser$Dom$NotFound(id)));
4127+ });
4128+}
4129+
4130+
4131+function _Browser_withWindow(doStuff)
4132+{
4133+ return _Scheduler_binding(function(callback)
4134+ {
4135+ _Browser_requestAnimationFrame(function() {
4136+ callback(_Scheduler_succeed(doStuff()));
4137+ });
4138+ });
4139+}
4140+
4141+
4142+// FOCUS and BLUR
4143+
4144+
4145+var _Browser_call = F2(function(functionName, id)
4146+{
4147+ return _Browser_withNode(id, function(node) {
4148+ node[functionName]();
4149+ return _Utils_Tuple0;
4150+ });
4151+});
4152+
4153+
4154+
4155+// WINDOW VIEWPORT
4156+
4157+
4158+function _Browser_getViewport()
4159+{
4160+ return {
4161+ scene: _Browser_getScene(),
4162+ viewport: {
4163+ x: _Browser_window.pageXOffset,
4164+ y: _Browser_window.pageYOffset,
4165+ width: _Browser_doc.documentElement.clientWidth,
4166+ height: _Browser_doc.documentElement.clientHeight
4167+ }
4168+ };
4169+}
4170+
4171+function _Browser_getScene()
4172+{
4173+ var body = _Browser_doc.body;
4174+ var elem = _Browser_doc.documentElement;
4175+ return {
4176+ width: Math.max(body.scrollWidth, body.offsetWidth, elem.scrollWidth, elem.offsetWidth, elem.clientWidth),
4177+ height: Math.max(body.scrollHeight, body.offsetHeight, elem.scrollHeight, elem.offsetHeight, elem.clientHeight)
4178+ };
4179+}
4180+
4181+var _Browser_setViewport = F2(function(x, y)
4182+{
4183+ return _Browser_withWindow(function()
4184+ {
4185+ _Browser_window.scroll(x, y);
4186+ return _Utils_Tuple0;
4187+ });
4188+});
4189+
4190+
4191+
4192+// ELEMENT VIEWPORT
4193+
4194+
4195+function _Browser_getViewportOf(id)
4196+{
4197+ return _Browser_withNode(id, function(node)
4198+ {
4199+ return {
4200+ scene: {
4201+ width: node.scrollWidth,
4202+ height: node.scrollHeight
4203+ },
4204+ viewport: {
4205+ x: node.scrollLeft,
4206+ y: node.scrollTop,
4207+ width: node.clientWidth,
4208+ height: node.clientHeight
4209+ }
4210+ };
4211+ });
4212+}
4213+
4214+
4215+var _Browser_setViewportOf = F3(function(id, x, y)
4216+{
4217+ return _Browser_withNode(id, function(node)
4218+ {
4219+ node.scrollLeft = x;
4220+ node.scrollTop = y;
4221+ return _Utils_Tuple0;
4222+ });
4223+});
4224+
4225+
4226+
4227+// ELEMENT
4228+
4229+
4230+function _Browser_getElement(id)
4231+{
4232+ return _Browser_withNode(id, function(node)
4233+ {
4234+ var rect = node.getBoundingClientRect();
4235+ var x = _Browser_window.pageXOffset;
4236+ var y = _Browser_window.pageYOffset;
4237+ return {
4238+ scene: _Browser_getScene(),
4239+ viewport: {
4240+ x: x,
4241+ y: y,
4242+ width: _Browser_doc.documentElement.clientWidth,
4243+ height: _Browser_doc.documentElement.clientHeight
4244+ },
4245+ element: {
4246+ x: x + rect.left,
4247+ y: y + rect.top,
4248+ width: rect.width,
4249+ height: rect.height
4250+ }
4251+ };
4252+ });
4253+}
4254+
4255+
4256+
4257+// LOAD and RELOAD
4258+
4259+
4260+function _Browser_reload(skipCache)
4261+{
4262+ return A2($elm$core$Task$perform, $elm$core$Basics$never, _Scheduler_binding(function(callback)
4263+ {
4264+ // no-op in LynxJS
4265+ }));
4266+}
4267+
4268+function _Browser_load(url)
4269+{
4270+ return A2($elm$core$Task$perform, $elm$core$Basics$never, _Scheduler_binding(function(callback)
4271+ {
4272+ try
4273+ {
4274+ // no-op in LynxJS
4275+ }
4276+ catch(err)
4277+ {
4278+ // Only Firefox can throw a NS_ERROR_MALFORMED_URI exception here.
4279+ // Other browsers reload the page, so let's be consistent about that.
4280+ // no-op in LynxJS
4281+ }
4282+ }));
4283+}
4284+function _Utils_cmp(x, y, ord) {if (typeof x !== 'object') {return x === y ? 0 : x < y ? -1 : 1; }if (x instanceof String) {var a = x.valueOf(); var b = y.valueOf();return a === b ? 0 : a < b ? -1 : 1; }if (typeof x.$ === 'undefined' || (typeof x.$ === 'string' && x.$[0] === '#')) {var keys = Object.keys(x).sort();for (var i = 0; i < keys.length; i++) {var k = keys[i];if (k === '$') continue;ord = _Utils_cmp(x[k], y[k]);if (ord) return ord; }return 0; }if (x.$ === '::' || x.$ === '[]') {for (; x.b && y.b && !(ord = _Utils_cmp(x.a, y.a)); x = x.b, y = y.b) {}return ord || (x.b ? 1 : y.b ? -1 : 0); }if (x.$ !== y.$) {return x.$ < y.$ ? -1 : 1; }var keys = Object.keys(x);for (var i = 0; i < keys.length; i++) {var k = keys[i];if (k === '$') continue;ord = _Utils_cmp(x[k], y[k]);if (ord) return ord; }return 0; }
4285+var $author$project$Main$init = {count: 0};
4286+var $elm$core$List$cons = _List_cons;
4287+var $elm$core$Elm$JsArray$foldr = _JsArray_foldr;
4288+var $elm$core$Array$foldr = F3(
4289+ function (func, baseCase, _v0) {
4290+ var tree = _v0.c;
4291+ var tail = _v0.d;
4292+ var helper = F2(
4293+ function (node, acc) {
4294+ if (node.$ === 'SubTree') {
4295+ var subTree = node.a;
4296+ return A3($elm$core$Elm$JsArray$foldr, helper, acc, subTree);
4297+ } else {
4298+ var values = node.a;
4299+ return A3($elm$core$Elm$JsArray$foldr, func, acc, values);
4300+ }
4301+ });
4302+ return A3(
4303+ $elm$core$Elm$JsArray$foldr,
4304+ helper,
4305+ A3($elm$core$Elm$JsArray$foldr, func, baseCase, tail),
4306+ tree);
4307+ });
4308+var $elm$core$Array$toList = function (array) {
4309+ return A3($elm$core$Array$foldr, $elm$core$List$cons, _List_Nil, array);
4310+};
4311+var $elm$core$Dict$foldr = F3(
4312+ function (func, acc, t) {
4313+ foldr:
4314+ while (true) {
4315+ if (t.$ === 'RBEmpty_elm_builtin') {
4316+ return acc;
4317+ } else {
4318+ var key = t.b;
4319+ var value = t.c;
4320+ var left = t.d;
4321+ var right = t.e;
4322+ var $temp$func = func,
4323+ $temp$acc = A3(
4324+ func,
4325+ key,
4326+ value,
4327+ A3($elm$core$Dict$foldr, func, acc, right)),
4328+ $temp$t = left;
4329+ func = $temp$func;
4330+ acc = $temp$acc;
4331+ t = $temp$t;
4332+ continue foldr;
4333+ }
4334+ }
4335+ });
4336+var $elm$core$Dict$toList = function (dict) {
4337+ return A3(
4338+ $elm$core$Dict$foldr,
4339+ F3(
4340+ function (key, value, list) {
4341+ return A2(
4342+ $elm$core$List$cons,
4343+ _Utils_Tuple2(key, value),
4344+ list);
4345+ }),
4346+ _List_Nil,
4347+ dict);
4348+};
4349+var $elm$core$Dict$keys = function (dict) {
4350+ return A3(
4351+ $elm$core$Dict$foldr,
4352+ F3(
4353+ function (key, value, keyList) {
4354+ return A2($elm$core$List$cons, key, keyList);
4355+ }),
4356+ _List_Nil,
4357+ dict);
4358+};
4359+var $elm$core$Set$toList = function (_v0) {
4360+ var dict = _v0.a;
4361+ return $elm$core$Dict$keys(dict);
4362+};
4363+var $elm$core$Basics$EQ = {$: 'EQ'};
4364+var $elm$core$Basics$GT = {$: 'GT'};
4365+var $elm$core$Basics$LT = {$: 'LT'};
4366+var $elm$core$Result$Err = function (a) {
4367+ return {$: 'Err', a: a};
4368+};
4369+var $elm$json$Json$Decode$Failure = F2(
4370+ function (a, b) {
4371+ return {$: 'Failure', a: a, b: b};
4372+ });
4373+var $elm$json$Json$Decode$Field = F2(
4374+ function (a, b) {
4375+ return {$: 'Field', a: a, b: b};
4376+ });
4377+var $elm$json$Json$Decode$Index = F2(
4378+ function (a, b) {
4379+ return {$: 'Index', a: a, b: b};
4380+ });
4381+var $elm$core$Result$Ok = function (a) {
4382+ return {$: 'Ok', a: a};
4383+};
4384+var $elm$json$Json$Decode$OneOf = function (a) {
4385+ return {$: 'OneOf', a: a};
4386+};
4387+var $elm$core$Basics$False = {$: 'False'};
4388+var $elm$core$Basics$add = _Basics_add;
4389+var $elm$core$Maybe$Just = function (a) {
4390+ return {$: 'Just', a: a};
4391+};
4392+var $elm$core$Maybe$Nothing = {$: 'Nothing'};
4393+var $elm$core$String$all = _String_all;
4394+var $elm$core$Basics$and = _Basics_and;
4395+var $elm$core$Basics$append = _Utils_append;
4396+var $elm$json$Json$Encode$encode = _Json_encode;
4397+var $elm$core$String$fromInt = _String_fromNumber;
4398+var $elm$core$String$join = F2(
4399+ function (sep, chunks) {
4400+ return A2(
4401+ _String_join,
4402+ sep,
4403+ _List_toArray(chunks));
4404+ });
4405+var $elm$core$String$split = F2(
4406+ function (sep, string) {
4407+ return _List_fromArray(
4408+ A2(_String_split, sep, string));
4409+ });
4410+var $elm$json$Json$Decode$indent = function (str) {
4411+ return A2(
4412+ $elm$core$String$join,
4413+ '\n ',
4414+ A2($elm$core$String$split, '\n', str));
4415+};
4416+var $elm$core$List$foldl = F3(
4417+ function (func, acc, list) {
4418+ foldl:
4419+ while (true) {
4420+ if (!list.b) {
4421+ return acc;
4422+ } else {
4423+ var x = list.a;
4424+ var xs = list.b;
4425+ var $temp$func = func,
4426+ $temp$acc = A2(func, x, acc),
4427+ $temp$list = xs;
4428+ func = $temp$func;
4429+ acc = $temp$acc;
4430+ list = $temp$list;
4431+ continue foldl;
4432+ }
4433+ }
4434+ });
4435+var $elm$core$List$length = function (xs) {
4436+ return A3(
4437+ $elm$core$List$foldl,
4438+ F2(
4439+ function (_v0, i) {
4440+ return i + 1;
4441+ }),
4442+ 0,
4443+ xs);
4444+};
4445+var $elm$core$List$map2 = _List_map2;
4446+var $elm$core$Basics$le = _Utils_le;
4447+var $elm$core$Basics$sub = _Basics_sub;
4448+var $elm$core$List$rangeHelp = F3(
4449+ function (lo, hi, list) {
4450+ rangeHelp:
4451+ while (true) {
4452+ if (_Utils_cmp(lo, hi) < 1) {
4453+ var $temp$lo = lo,
4454+ $temp$hi = hi - 1,
4455+ $temp$list = A2($elm$core$List$cons, hi, list);
4456+ lo = $temp$lo;
4457+ hi = $temp$hi;
4458+ list = $temp$list;
4459+ continue rangeHelp;
4460+ } else {
4461+ return list;
4462+ }
4463+ }
4464+ });
4465+var $elm$core$List$range = F2(
4466+ function (lo, hi) {
4467+ return A3($elm$core$List$rangeHelp, lo, hi, _List_Nil);
4468+ });
4469+var $elm$core$List$indexedMap = F2(
4470+ function (f, xs) {
4471+ return A3(
4472+ $elm$core$List$map2,
4473+ f,
4474+ A2(
4475+ $elm$core$List$range,
4476+ 0,
4477+ $elm$core$List$length(xs) - 1),
4478+ xs);
4479+ });
4480+var $elm$core$Char$toCode = _Char_toCode;
4481+var $elm$core$Char$isLower = function (_char) {
4482+ var code = $elm$core$Char$toCode(_char);
4483+ return (97 <= code) && (code <= 122);
4484+};
4485+var $elm$core$Char$isUpper = function (_char) {
4486+ var code = $elm$core$Char$toCode(_char);
4487+ return (code <= 90) && (65 <= code);
4488+};
4489+var $elm$core$Basics$or = _Basics_or;
4490+var $elm$core$Char$isAlpha = function (_char) {
4491+ return $elm$core$Char$isLower(_char) || $elm$core$Char$isUpper(_char);
4492+};
4493+var $elm$core$Char$isDigit = function (_char) {
4494+ var code = $elm$core$Char$toCode(_char);
4495+ return (code <= 57) && (48 <= code);
4496+};
4497+var $elm$core$Char$isAlphaNum = function (_char) {
4498+ return $elm$core$Char$isLower(_char) || ($elm$core$Char$isUpper(_char) || $elm$core$Char$isDigit(_char));
4499+};
4500+var $elm$core$List$reverse = function (list) {
4501+ return A3($elm$core$List$foldl, $elm$core$List$cons, _List_Nil, list);
4502+};
4503+var $elm$core$String$uncons = _String_uncons;
4504+var $elm$json$Json$Decode$errorOneOf = F2(
4505+ function (i, error) {
4506+ return '\n\n(' + ($elm$core$String$fromInt(i + 1) + (') ' + $elm$json$Json$Decode$indent(
4507+ $elm$json$Json$Decode$errorToString(error))));
4508+ });
4509+var $elm$json$Json$Decode$errorToString = function (error) {
4510+ return A2($elm$json$Json$Decode$errorToStringHelp, error, _List_Nil);
4511+};
4512+var $elm$json$Json$Decode$errorToStringHelp = F2(
4513+ function (error, context) {
4514+ errorToStringHelp:
4515+ while (true) {
4516+ switch (error.$) {
4517+ case 'Field':
4518+ var f = error.a;
4519+ var err = error.b;
4520+ var isSimple = function () {
4521+ var _v1 = $elm$core$String$uncons(f);
4522+ if (_v1.$ === 'Nothing') {
4523+ return false;
4524+ } else {
4525+ var _v2 = _v1.a;
4526+ var _char = _v2.a;
4527+ var rest = _v2.b;
4528+ return $elm$core$Char$isAlpha(_char) && A2($elm$core$String$all, $elm$core$Char$isAlphaNum, rest);
4529+ }
4530+ }();
4531+ var fieldName = isSimple ? ('.' + f) : ('[\'' + (f + '\']'));
4532+ var $temp$error = err,
4533+ $temp$context = A2($elm$core$List$cons, fieldName, context);
4534+ error = $temp$error;
4535+ context = $temp$context;
4536+ continue errorToStringHelp;
4537+ case 'Index':
4538+ var i = error.a;
4539+ var err = error.b;
4540+ var indexName = '[' + ($elm$core$String$fromInt(i) + ']');
4541+ var $temp$error = err,
4542+ $temp$context = A2($elm$core$List$cons, indexName, context);
4543+ error = $temp$error;
4544+ context = $temp$context;
4545+ continue errorToStringHelp;
4546+ case 'OneOf':
4547+ var errors = error.a;
4548+ if (!errors.b) {
4549+ return 'Ran into a Json.Decode.oneOf with no possibilities' + function () {
4550+ if (!context.b) {
4551+ return '!';
4552+ } else {
4553+ return ' at json' + A2(
4554+ $elm$core$String$join,
4555+ '',
4556+ $elm$core$List$reverse(context));
4557+ }
4558+ }();
4559+ } else {
4560+ if (!errors.b.b) {
4561+ var err = errors.a;
4562+ var $temp$error = err,
4563+ $temp$context = context;
4564+ error = $temp$error;
4565+ context = $temp$context;
4566+ continue errorToStringHelp;
4567+ } else {
4568+ var starter = function () {
4569+ if (!context.b) {
4570+ return 'Json.Decode.oneOf';
4571+ } else {
4572+ return 'The Json.Decode.oneOf at json' + A2(
4573+ $elm$core$String$join,
4574+ '',
4575+ $elm$core$List$reverse(context));
4576+ }
4577+ }();
4578+ var introduction = starter + (' failed in the following ' + ($elm$core$String$fromInt(
4579+ $elm$core$List$length(errors)) + ' ways:'));
4580+ return A2(
4581+ $elm$core$String$join,
4582+ '\n\n',
4583+ A2(
4584+ $elm$core$List$cons,
4585+ introduction,
4586+ A2($elm$core$List$indexedMap, $elm$json$Json$Decode$errorOneOf, errors)));
4587+ }
4588+ }
4589+ default:
4590+ var msg = error.a;
4591+ var json = error.b;
4592+ var introduction = function () {
4593+ if (!context.b) {
4594+ return 'Problem with the given value:\n\n';
4595+ } else {
4596+ return 'Problem with the value at json' + (A2(
4597+ $elm$core$String$join,
4598+ '',
4599+ $elm$core$List$reverse(context)) + ':\n\n ');
4600+ }
4601+ }();
4602+ return introduction + ($elm$json$Json$Decode$indent(
4603+ A2($elm$json$Json$Encode$encode, 4, json)) + ('\n\n' + msg));
4604+ }
4605+ }
4606+ });
4607+var $elm$core$Array$branchFactor = 32;
4608+var $elm$core$Array$Array_elm_builtin = F4(
4609+ function (a, b, c, d) {
4610+ return {$: 'Array_elm_builtin', a: a, b: b, c: c, d: d};
4611+ });
4612+var $elm$core$Elm$JsArray$empty = _JsArray_empty;
4613+var $elm$core$Basics$ceiling = _Basics_ceiling;
4614+var $elm$core$Basics$fdiv = _Basics_fdiv;
4615+var $elm$core$Basics$logBase = F2(
4616+ function (base, number) {
4617+ return _Basics_log(number) / _Basics_log(base);
4618+ });
4619+var $elm$core$Basics$toFloat = _Basics_toFloat;
4620+var $elm$core$Array$shiftStep = $elm$core$Basics$ceiling(
4621+ A2($elm$core$Basics$logBase, 2, $elm$core$Array$branchFactor));
4622+var $elm$core$Array$empty = A4($elm$core$Array$Array_elm_builtin, 0, $elm$core$Array$shiftStep, $elm$core$Elm$JsArray$empty, $elm$core$Elm$JsArray$empty);
4623+var $elm$core$Elm$JsArray$initialize = _JsArray_initialize;
4624+var $elm$core$Array$Leaf = function (a) {
4625+ return {$: 'Leaf', a: a};
4626+};
4627+var $elm$core$Basics$apL = F2(
4628+ function (f, x) {
4629+ return f(x);
4630+ });
4631+var $elm$core$Basics$apR = F2(
4632+ function (x, f) {
4633+ return f(x);
4634+ });
4635+var $elm$core$Basics$eq = _Utils_equal;
4636+var $elm$core$Basics$floor = _Basics_floor;
4637+var $elm$core$Elm$JsArray$length = _JsArray_length;
4638+var $elm$core$Basics$gt = _Utils_gt;
4639+var $elm$core$Basics$max = F2(
4640+ function (x, y) {
4641+ return (_Utils_cmp(x, y) > 0) ? x : y;
4642+ });
4643+var $elm$core$Basics$mul = _Basics_mul;
4644+var $elm$core$Array$SubTree = function (a) {
4645+ return {$: 'SubTree', a: a};
4646+};
4647+var $elm$core$Elm$JsArray$initializeFromList = _JsArray_initializeFromList;
4648+var $elm$core$Array$compressNodes = F2(
4649+ function (nodes, acc) {
4650+ compressNodes:
4651+ while (true) {
4652+ var _v0 = A2($elm$core$Elm$JsArray$initializeFromList, $elm$core$Array$branchFactor, nodes);
4653+ var node = _v0.a;
4654+ var remainingNodes = _v0.b;
4655+ var newAcc = A2(
4656+ $elm$core$List$cons,
4657+ $elm$core$Array$SubTree(node),
4658+ acc);
4659+ if (!remainingNodes.b) {
4660+ return $elm$core$List$reverse(newAcc);
4661+ } else {
4662+ var $temp$nodes = remainingNodes,
4663+ $temp$acc = newAcc;
4664+ nodes = $temp$nodes;
4665+ acc = $temp$acc;
4666+ continue compressNodes;
4667+ }
4668+ }
4669+ });
4670+var $elm$core$Tuple$first = function (_v0) {
4671+ var x = _v0.a;
4672+ return x;
4673+};
4674+var $elm$core$Array$treeFromBuilder = F2(
4675+ function (nodeList, nodeListSize) {
4676+ treeFromBuilder:
4677+ while (true) {
4678+ var newNodeSize = $elm$core$Basics$ceiling(nodeListSize / $elm$core$Array$branchFactor);
4679+ if (newNodeSize === 1) {
4680+ return A2($elm$core$Elm$JsArray$initializeFromList, $elm$core$Array$branchFactor, nodeList).a;
4681+ } else {
4682+ var $temp$nodeList = A2($elm$core$Array$compressNodes, nodeList, _List_Nil),
4683+ $temp$nodeListSize = newNodeSize;
4684+ nodeList = $temp$nodeList;
4685+ nodeListSize = $temp$nodeListSize;
4686+ continue treeFromBuilder;
4687+ }
4688+ }
4689+ });
4690+var $elm$core$Array$builderToArray = F2(
4691+ function (reverseNodeList, builder) {
4692+ if (!builder.nodeListSize) {
4693+ return A4(
4694+ $elm$core$Array$Array_elm_builtin,
4695+ $elm$core$Elm$JsArray$length(builder.tail),
4696+ $elm$core$Array$shiftStep,
4697+ $elm$core$Elm$JsArray$empty,
4698+ builder.tail);
4699+ } else {
4700+ var treeLen = builder.nodeListSize * $elm$core$Array$branchFactor;
4701+ var depth = $elm$core$Basics$floor(
4702+ A2($elm$core$Basics$logBase, $elm$core$Array$branchFactor, treeLen - 1));
4703+ var correctNodeList = reverseNodeList ? $elm$core$List$reverse(builder.nodeList) : builder.nodeList;
4704+ var tree = A2($elm$core$Array$treeFromBuilder, correctNodeList, builder.nodeListSize);
4705+ return A4(
4706+ $elm$core$Array$Array_elm_builtin,
4707+ $elm$core$Elm$JsArray$length(builder.tail) + treeLen,
4708+ A2($elm$core$Basics$max, 5, depth * $elm$core$Array$shiftStep),
4709+ tree,
4710+ builder.tail);
4711+ }
4712+ });
4713+var $elm$core$Basics$idiv = _Basics_idiv;
4714+var $elm$core$Basics$lt = _Utils_lt;
4715+var $elm$core$Array$initializeHelp = F5(
4716+ function (fn, fromIndex, len, nodeList, tail) {
4717+ initializeHelp:
4718+ while (true) {
4719+ if (fromIndex < 0) {
4720+ return A2(
4721+ $elm$core$Array$builderToArray,
4722+ false,
4723+ {nodeList: nodeList, nodeListSize: (len / $elm$core$Array$branchFactor) | 0, tail: tail});
4724+ } else {
4725+ var leaf = $elm$core$Array$Leaf(
4726+ A3($elm$core$Elm$JsArray$initialize, $elm$core$Array$branchFactor, fromIndex, fn));
4727+ var $temp$fn = fn,
4728+ $temp$fromIndex = fromIndex - $elm$core$Array$branchFactor,
4729+ $temp$len = len,
4730+ $temp$nodeList = A2($elm$core$List$cons, leaf, nodeList),
4731+ $temp$tail = tail;
4732+ fn = $temp$fn;
4733+ fromIndex = $temp$fromIndex;
4734+ len = $temp$len;
4735+ nodeList = $temp$nodeList;
4736+ tail = $temp$tail;
4737+ continue initializeHelp;
4738+ }
4739+ }
4740+ });
4741+var $elm$core$Basics$remainderBy = _Basics_remainderBy;
4742+var $elm$core$Array$initialize = F2(
4743+ function (len, fn) {
4744+ if (len <= 0) {
4745+ return $elm$core$Array$empty;
4746+ } else {
4747+ var tailLen = len % $elm$core$Array$branchFactor;
4748+ var tail = A3($elm$core$Elm$JsArray$initialize, tailLen, len - tailLen, fn);
4749+ var initialFromIndex = (len - tailLen) - $elm$core$Array$branchFactor;
4750+ return A5($elm$core$Array$initializeHelp, fn, initialFromIndex, len, _List_Nil, tail);
4751+ }
4752+ });
4753+var $elm$core$Basics$True = {$: 'True'};
4754+var $elm$core$Result$isOk = function (result) {
4755+ if (result.$ === 'Ok') {
4756+ return true;
4757+ } else {
4758+ return false;
4759+ }
4760+};
4761+var $elm$json$Json$Decode$map = _Json_map1;
4762+var $elm$json$Json$Decode$map2 = _Json_map2;
4763+var $elm$json$Json$Decode$succeed = _Json_succeed;
4764+var $lynxjs_elm$virtual_dom$VirtualDom$toHandlerInt = function (handler) {
4765+ switch (handler.$) {
4766+ case 'Normal':
4767+ return 0;
4768+ case 'MayStopPropagation':
4769+ return 1;
4770+ case 'MayPreventDefault':
4771+ return 2;
4772+ default:
4773+ return 3;
4774+ }
4775+};
4776+var $elm$core$Basics$identity = function (x) {
4777+ return x;
4778+};
4779+var $lynxjs_elm$browser$Browser$Dom$NotFound = function (a) {
4780+ return {$: 'NotFound', a: a};
4781+};
4782+var $elm$core$Basics$never = function (_v0) {
4783+ never:
4784+ while (true) {
4785+ var nvr = _v0.a;
4786+ var $temp$_v0 = nvr;
4787+ _v0 = $temp$_v0;
4788+ continue never;
4789+ }
4790+};
4791+var $elm$core$Task$Perform = function (a) {
4792+ return {$: 'Perform', a: a};
4793+};
4794+var $elm$core$Task$succeed = _Scheduler_succeed;
4795+var $elm$core$Task$init = $elm$core$Task$succeed(_Utils_Tuple0);
4796+var $elm$core$List$foldrHelper = F4(
4797+ function (fn, acc, ctr, ls) {
4798+ if (!ls.b) {
4799+ return acc;
4800+ } else {
4801+ var a = ls.a;
4802+ var r1 = ls.b;
4803+ if (!r1.b) {
4804+ return A2(fn, a, acc);
4805+ } else {
4806+ var b = r1.a;
4807+ var r2 = r1.b;
4808+ if (!r2.b) {
4809+ return A2(
4810+ fn,
4811+ a,
4812+ A2(fn, b, acc));
4813+ } else {
4814+ var c = r2.a;
4815+ var r3 = r2.b;
4816+ if (!r3.b) {
4817+ return A2(
4818+ fn,
4819+ a,
4820+ A2(
4821+ fn,
4822+ b,
4823+ A2(fn, c, acc)));
4824+ } else {
4825+ var d = r3.a;
4826+ var r4 = r3.b;
4827+ var res = (ctr > 500) ? A3(
4828+ $elm$core$List$foldl,
4829+ fn,
4830+ acc,
4831+ $elm$core$List$reverse(r4)) : A4($elm$core$List$foldrHelper, fn, acc, ctr + 1, r4);
4832+ return A2(
4833+ fn,
4834+ a,
4835+ A2(
4836+ fn,
4837+ b,
4838+ A2(
4839+ fn,
4840+ c,
4841+ A2(fn, d, res))));
4842+ }
4843+ }
4844+ }
4845+ }
4846+ });
4847+var $elm$core$List$foldr = F3(
4848+ function (fn, acc, ls) {
4849+ return A4($elm$core$List$foldrHelper, fn, acc, 0, ls);
4850+ });
4851+var $elm$core$List$map = F2(
4852+ function (f, xs) {
4853+ return A3(
4854+ $elm$core$List$foldr,
4855+ F2(
4856+ function (x, acc) {
4857+ return A2(
4858+ $elm$core$List$cons,
4859+ f(x),
4860+ acc);
4861+ }),
4862+ _List_Nil,
4863+ xs);
4864+ });
4865+var $elm$core$Task$andThen = _Scheduler_andThen;
4866+var $elm$core$Task$map = F2(
4867+ function (func, taskA) {
4868+ return A2(
4869+ $elm$core$Task$andThen,
4870+ function (a) {
4871+ return $elm$core$Task$succeed(
4872+ func(a));
4873+ },
4874+ taskA);
4875+ });
4876+var $elm$core$Task$map2 = F3(
4877+ function (func, taskA, taskB) {
4878+ return A2(
4879+ $elm$core$Task$andThen,
4880+ function (a) {
4881+ return A2(
4882+ $elm$core$Task$andThen,
4883+ function (b) {
4884+ return $elm$core$Task$succeed(
4885+ A2(func, a, b));
4886+ },
4887+ taskB);
4888+ },
4889+ taskA);
4890+ });
4891+var $elm$core$Task$sequence = function (tasks) {
4892+ return A3(
4893+ $elm$core$List$foldr,
4894+ $elm$core$Task$map2($elm$core$List$cons),
4895+ $elm$core$Task$succeed(_List_Nil),
4896+ tasks);
4897+};
4898+var $elm$core$Platform$sendToApp = _Platform_sendToApp;
4899+var $elm$core$Task$spawnCmd = F2(
4900+ function (router, _v0) {
4901+ var task = _v0.a;
4902+ return _Scheduler_spawn(
4903+ A2(
4904+ $elm$core$Task$andThen,
4905+ $elm$core$Platform$sendToApp(router),
4906+ task));
4907+ });
4908+var $elm$core$Task$onEffects = F3(
4909+ function (router, commands, state) {
4910+ return A2(
4911+ $elm$core$Task$map,
4912+ function (_v0) {
4913+ return _Utils_Tuple0;
4914+ },
4915+ $elm$core$Task$sequence(
4916+ A2(
4917+ $elm$core$List$map,
4918+ $elm$core$Task$spawnCmd(router),
4919+ commands)));
4920+ });
4921+var $elm$core$Task$onSelfMsg = F3(
4922+ function (_v0, _v1, _v2) {
4923+ return $elm$core$Task$succeed(_Utils_Tuple0);
4924+ });
4925+var $elm$core$Task$cmdMap = F2(
4926+ function (tagger, _v0) {
4927+ var task = _v0.a;
4928+ return $elm$core$Task$Perform(
4929+ A2($elm$core$Task$map, tagger, task));
4930+ });
4931+_Platform_effectManagers['Task'] = _Platform_createManager($elm$core$Task$init, $elm$core$Task$onEffects, $elm$core$Task$onSelfMsg, $elm$core$Task$cmdMap);
4932+var $elm$core$Task$command = _Platform_leaf('Task');
4933+var $elm$core$Task$perform = F2(
4934+ function (toMessage, task) {
4935+ return $elm$core$Task$command(
4936+ $elm$core$Task$Perform(
4937+ A2($elm$core$Task$map, toMessage, task)));
4938+ });
4939+var $elm$core$Platform$Cmd$batch = _Platform_batch;
4940+var $elm$core$Platform$Cmd$none = $elm$core$Platform$Cmd$batch(_List_Nil);
4941+var $elm$core$Platform$Sub$batch = _Platform_batch;
4942+var $elm$core$Platform$Sub$none = $elm$core$Platform$Sub$batch(_List_Nil);
4943+var $lynxjs_elm$browser$Browser$sandbox = function (impl) {
4944+ return _Browser_element(
4945+ {
4946+ init: function (_v0) {
4947+ return _Utils_Tuple2(impl.init, $elm$core$Platform$Cmd$none);
4948+ },
4949+ subscriptions: function (_v1) {
4950+ return $elm$core$Platform$Sub$none;
4951+ },
4952+ update: F2(
4953+ function (msg, model) {
4954+ return _Utils_Tuple2(
4955+ A2(impl.update, msg, model),
4956+ $elm$core$Platform$Cmd$none);
4957+ }),
4958+ view: impl.view
4959+ });
4960+};
4961+var $author$project$Main$update = F2(
4962+ function (msg, model) {
4963+ if (msg.$ === 'Increment') {
4964+ return _Utils_update(
4965+ model,
4966+ {count: model.count + 1});
4967+ } else {
4968+ return _Utils_update(
4969+ model,
4970+ {count: model.count - 1});
4971+ }
4972+ });
4973+var $lynxjs_elm$ui$Lynx$Attributes$Center = {$: 'Center'};
4974+var $lynxjs_elm$ui$Lynx$Attributes$Column = {$: 'Column'};
4975+var $author$project$Main$Decrement = {$: 'Decrement'};
4976+var $author$project$Main$Increment = {$: 'Increment'};
4977+var $lynxjs_elm$ui$Lynx$Attributes$Row = {$: 'Row'};
4978+var $lynxjs_elm$ui$Lynx$Attributes$alignmentToString = function (a) {
4979+ switch (a.$) {
4980+ case 'Start':
4981+ return 'flex-start';
4982+ case 'Center':
4983+ return 'center';
4984+ case 'End':
4985+ return 'flex-end';
4986+ case 'SpaceBetween':
4987+ return 'space-between';
4988+ case 'SpaceAround':
4989+ return 'space-around';
4990+ case 'SpaceEvenly':
4991+ return 'space-evenly';
4992+ case 'Stretch':
4993+ return 'stretch';
4994+ default:
4995+ return 'baseline';
4996+ }
4997+};
4998+var $lynxjs_elm$virtual_dom$VirtualDom$style = _VirtualDom_style;
4999+var $lynxjs_elm$ui$Lynx$Attributes$style = $lynxjs_elm$virtual_dom$VirtualDom$style;
5000+var $lynxjs_elm$ui$Lynx$Attributes$alignItems = function (a) {
5001+ return A2(
5002+ $lynxjs_elm$ui$Lynx$Attributes$style,
5003+ 'alignItems',
5004+ $lynxjs_elm$ui$Lynx$Attributes$alignmentToString(a));
5005+};
5006+var $lynxjs_elm$ui$Lynx$Attributes$backgroundColor = $lynxjs_elm$ui$Lynx$Attributes$style('backgroundColor');
5007+var $lynxjs_elm$ui$Lynx$Attributes$pxStyle = F2(
5008+ function (key, val) {
5009+ return A2(
5010+ $lynxjs_elm$virtual_dom$VirtualDom$style,
5011+ key,
5012+ $elm$core$String$fromInt(val) + 'px');
5013+ });
5014+var $lynxjs_elm$ui$Lynx$Attributes$borderRadius = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('borderRadius');
5015+var $lynxjs_elm$ui$Lynx$Attributes$color = $lynxjs_elm$ui$Lynx$Attributes$style('color');
5016+var $lynxjs_elm$ui$Lynx$Attributes$fontSize = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('fontSize');
5017+var $lynxjs_elm$virtual_dom$VirtualDom$Normal = function (a) {
5018+ return {$: 'Normal', a: a};
5019+};
5020+var $lynxjs_elm$virtual_dom$VirtualDom$on = _VirtualDom_on;
5021+var $lynxjs_elm$ui$Lynx$Events$onTap = function (msg) {
5022+ return A2(
5023+ $lynxjs_elm$virtual_dom$VirtualDom$on,
5024+ 'tap',
5025+ $lynxjs_elm$virtual_dom$VirtualDom$Normal(
5026+ $elm$json$Json$Decode$succeed(msg)));
5027+};
5028+var $lynxjs_elm$ui$Lynx$Attributes$paddingBottom = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('paddingBottom');
5029+var $lynxjs_elm$ui$Lynx$Attributes$paddingLeft = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('paddingLeft');
5030+var $lynxjs_elm$ui$Lynx$Attributes$paddingRight = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('paddingRight');
5031+var $lynxjs_elm$ui$Lynx$Attributes$paddingTop = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('paddingTop');
5032+var $lynxjs_elm$virtual_dom$VirtualDom$node = function (tag) {
5033+ return _VirtualDom_node(
5034+ _VirtualDom_noScript(tag));
5035+};
5036+var $lynxjs_elm$ui$Lynx$text = $lynxjs_elm$virtual_dom$VirtualDom$node('text');
5037+var $lynxjs_elm$virtual_dom$VirtualDom$text = _VirtualDom_text;
5038+var $lynxjs_elm$ui$Lynx$textContent = $lynxjs_elm$virtual_dom$VirtualDom$text;
5039+var $lynxjs_elm$ui$Lynx$view = $lynxjs_elm$virtual_dom$VirtualDom$node('view');
5040+var $author$project$Main$button = F2(
5041+ function (msg, label) {
5042+ return A2(
5043+ $lynxjs_elm$ui$Lynx$view,
5044+ _List_fromArray(
5045+ [
5046+ $lynxjs_elm$ui$Lynx$Events$onTap(msg),
5047+ $lynxjs_elm$ui$Lynx$Attributes$backgroundColor('#4a90d9'),
5048+ $lynxjs_elm$ui$Lynx$Attributes$borderRadius(8),
5049+ $lynxjs_elm$ui$Lynx$Attributes$paddingTop(12),
5050+ $lynxjs_elm$ui$Lynx$Attributes$paddingBottom(12),
5051+ $lynxjs_elm$ui$Lynx$Attributes$paddingLeft(24),
5052+ $lynxjs_elm$ui$Lynx$Attributes$paddingRight(24)
5053+ ]),
5054+ _List_fromArray(
5055+ [
5056+ A2(
5057+ $lynxjs_elm$ui$Lynx$text,
5058+ _List_fromArray(
5059+ [
5060+ $lynxjs_elm$ui$Lynx$Attributes$color('#ffffff'),
5061+ $lynxjs_elm$ui$Lynx$Attributes$fontSize(24)
5062+ ]),
5063+ _List_fromArray(
5064+ [
5065+ $lynxjs_elm$ui$Lynx$textContent(label)
5066+ ]))
5067+ ]));
5068+ });
5069+var $lynxjs_elm$ui$Lynx$Attributes$intStyle = F2(
5070+ function (key, val) {
5071+ return A2(
5072+ $lynxjs_elm$virtual_dom$VirtualDom$style,
5073+ key,
5074+ $elm$core$String$fromInt(val));
5075+ });
5076+var $lynxjs_elm$ui$Lynx$Attributes$flex = $lynxjs_elm$ui$Lynx$Attributes$intStyle('flex');
5077+var $lynxjs_elm$ui$Lynx$Attributes$flexDirection = function (d) {
5078+ return A2(
5079+ $lynxjs_elm$ui$Lynx$Attributes$style,
5080+ 'flexDirection',
5081+ function () {
5082+ switch (d.$) {
5083+ case 'Row':
5084+ return 'row';
5085+ case 'Column':
5086+ return 'column';
5087+ case 'RowReverse':
5088+ return 'row-reverse';
5089+ default:
5090+ return 'column-reverse';
5091+ }
5092+ }());
5093+};
5094+var $lynxjs_elm$ui$Lynx$Attributes$justifyContent = function (a) {
5095+ return A2(
5096+ $lynxjs_elm$ui$Lynx$Attributes$style,
5097+ 'justifyContent',
5098+ $lynxjs_elm$ui$Lynx$Attributes$alignmentToString(a));
5099+};
5100+var $lynxjs_elm$ui$Lynx$Attributes$marginLeft = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('marginLeft');
5101+var $lynxjs_elm$ui$Lynx$Attributes$marginRight = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('marginRight');
5102+var $author$project$Main$view = function (model) {
5103+ return A2(
5104+ $lynxjs_elm$ui$Lynx$view,
5105+ _List_fromArray(
5106+ [
5107+ $lynxjs_elm$ui$Lynx$Attributes$flexDirection($lynxjs_elm$ui$Lynx$Attributes$Column),
5108+ $lynxjs_elm$ui$Lynx$Attributes$alignItems($lynxjs_elm$ui$Lynx$Attributes$Center),
5109+ $lynxjs_elm$ui$Lynx$Attributes$justifyContent($lynxjs_elm$ui$Lynx$Attributes$Center),
5110+ $lynxjs_elm$ui$Lynx$Attributes$flex(1)
5111+ ]),
5112+ _List_fromArray(
5113+ [
5114+ A2(
5115+ $lynxjs_elm$ui$Lynx$view,
5116+ _List_fromArray(
5117+ [
5118+ $lynxjs_elm$ui$Lynx$Attributes$flexDirection($lynxjs_elm$ui$Lynx$Attributes$Row),
5119+ $lynxjs_elm$ui$Lynx$Attributes$alignItems($lynxjs_elm$ui$Lynx$Attributes$Center)
5120+ ]),
5121+ _List_fromArray(
5122+ [
5123+ A2($author$project$Main$button, $author$project$Main$Decrement, '-'),
5124+ A2(
5125+ $lynxjs_elm$ui$Lynx$text,
5126+ _List_fromArray(
5127+ [
5128+ $lynxjs_elm$ui$Lynx$Attributes$fontSize(32),
5129+ $lynxjs_elm$ui$Lynx$Attributes$marginLeft(20),
5130+ $lynxjs_elm$ui$Lynx$Attributes$marginRight(20)
5131+ ]),
5132+ _List_fromArray(
5133+ [
5134+ $lynxjs_elm$ui$Lynx$textContent(
5135+ $elm$core$String$fromInt(model.count))
5136+ ])),
5137+ A2($author$project$Main$button, $author$project$Main$Increment, '+')
5138+ ]))
5139+ ]));
5140+};
5141+var $author$project$Main$main = $lynxjs_elm$browser$Browser$sandbox(
5142+ {init: $author$project$Main$init, update: $author$project$Main$update, view: $author$project$Main$view});
5143+_Platform_export({'Main':{'init':$author$project$Main$main(
5144+ $elm$json$Json$Decode$succeed(_Utils_Tuple0))(0)}});}(globalThis));
examples/counter/elm.jsonnew file+24
@@ -0,0 +1,24 @@
1+{
2+ "type": "application",
3+ "source-directories": [
4+ "src"
5+ ],
6+ "elm-version": "0.19.1",
7+ "dependencies": {
8+ "direct": {
9+ "elm/core": "1.0.5",
10+ "elm/json": "1.1.3",
11+ "lynxjs-elm/browser": "1.0.0",
12+ "lynxjs-elm/ui": "1.0.0",
13+ "lynxjs-elm/virtual-dom": "1.0.0"
14+ },
15+ "indirect": {
16+ "elm/time": "1.0.0",
17+ "elm/url": "1.0.0"
18+ }
19+ },
20+ "test-dependencies": {
21+ "direct": {},
22+ "indirect": {}
23+ }
24+}
examples/counter/main.htmlnew file+5251
@@ -0,0 +1,5251 @@
1+<!DOCTYPE html>
2+<html>
3+<head>
4+<meta charset="UTF-8">
5+<meta name="viewport" content="width=device-width, initial-scale=1">
6+<title>LynxJS-Elm</title>
7+<style>
8+*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
9+body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
10+</style>
11+</head>
12+<body>
13+<script>
14+
15+// LynxJS PAPI-to-DOM polyfill for browser preview
16+(function() {
17+ var eventMap = {
18+ 'tap': 'click',
19+ 'longpress': 'contextmenu',
20+ 'touchstart': 'touchstart',
21+ 'touchmove': 'touchmove',
22+ 'touchend': 'touchend',
23+ 'touchcancel': 'touchcancel',
24+ 'input': 'input'
25+ };
26+
27+ var g = typeof globalThis !== 'undefined' ? globalThis : window;
28+
29+ function makeEl(domTag, lynxTag) {
30+ var el = document.createElement(domTag);
31+ el.setAttribute('data-lynx-tag', lynxTag);
32+ return el;
33+ }
34+
35+ g.__CreatePage = function() {
36+ var page = document.createElement('div');
37+ page.id = 'lynx-page';
38+ document.body.appendChild(page);
39+ return page;
40+ };
41+
42+ g.__CreateView = function() { return makeEl('div', 'view'); };
43+ g.__CreateText = function() { return makeEl('span', 'text'); };
44+ g.__CreateImage = function() { return makeEl('img', 'image'); };
45+
46+ g.__CreateRawText = function(text) {
47+ var el = document.createElement('span');
48+ el.setAttribute('data-lynx-tag', 'raw-text');
49+ el.textContent = text;
50+ return el;
51+ };
52+
53+ g.__AppendElement = function(parent, child) {
54+ parent.appendChild(child);
55+ };
56+
57+ g.__RemoveElement = function(parent, child) {
58+ parent.removeChild(child);
59+ };
60+
61+ g.__ReplaceElement = function(parent, newEl, oldEl) {
62+ parent.replaceChild(newEl, oldEl);
63+ };
64+
65+ g.__InsertElementBefore = function(parent, child, ref) {
66+ parent.insertBefore(child, ref);
67+ };
68+
69+ g.__SetAttribute = function(el, key, value) {
70+ if (key === 'text') {
71+ el.textContent = value;
72+ } else if (key === 'src' && el.tagName === 'IMG') {
73+ el.src = value;
74+ } else {
75+ el.setAttribute(key, value);
76+ }
77+ };
78+
79+ g.__AddEvent = function(el, bindingName, eventName, handler) {
80+ var domEvent = eventMap[eventName] || eventName;
81+ var fn = typeof handler === 'function' ? handler : handler.value;
82+ el.addEventListener(domEvent, function(e) { fn(e); });
83+ };
84+
85+ g.__SetInlineStyles = function(el, styles) {
86+ Object.assign(el.style, styles);
87+ };
88+
89+ g.__GetChildren = function(el) {
90+ return Array.from(el.children);
91+ };
92+
93+ g.__GetParent = function(el) {
94+ return el.parentNode;
95+ };
96+
97+ g.__FlushElementTree = function() {};
98+
99+ // Set up root page so _Browser_newPage() finds it
100+ g.page = g.__CreatePage();
101+})();
102+
103+</script>
104+<script>
105+(function(scope){
106+'use strict';
107+
108+function F(arity, fun, wrapper) {
109+ wrapper.a = arity;
110+ wrapper.f = fun;
111+ return wrapper;
112+}
113+
114+function F2(fun) {
115+ return F(2, fun, function(a) { return function(b) { return fun(a,b); }; })
116+}
117+function F3(fun) {
118+ return F(3, fun, function(a) {
119+ return function(b) { return function(c) { return fun(a, b, c); }; };
120+ });
121+}
122+function F4(fun) {
123+ return F(4, fun, function(a) { return function(b) { return function(c) {
124+ return function(d) { return fun(a, b, c, d); }; }; };
125+ });
126+}
127+function F5(fun) {
128+ return F(5, fun, function(a) { return function(b) { return function(c) {
129+ return function(d) { return function(e) { return fun(a, b, c, d, e); }; }; }; };
130+ });
131+}
132+function F6(fun) {
133+ return F(6, fun, function(a) { return function(b) { return function(c) {
134+ return function(d) { return function(e) { return function(f) {
135+ return fun(a, b, c, d, e, f); }; }; }; }; };
136+ });
137+}
138+function F7(fun) {
139+ return F(7, fun, function(a) { return function(b) { return function(c) {
140+ return function(d) { return function(e) { return function(f) {
141+ return function(g) { return fun(a, b, c, d, e, f, g); }; }; }; }; }; };
142+ });
143+}
144+function F8(fun) {
145+ return F(8, fun, function(a) { return function(b) { return function(c) {
146+ return function(d) { return function(e) { return function(f) {
147+ return function(g) { return function(h) {
148+ return fun(a, b, c, d, e, f, g, h); }; }; }; }; }; }; };
149+ });
150+}
151+function F9(fun) {
152+ return F(9, fun, function(a) { return function(b) { return function(c) {
153+ return function(d) { return function(e) { return function(f) {
154+ return function(g) { return function(h) { return function(i) {
155+ return fun(a, b, c, d, e, f, g, h, i); }; }; }; }; }; }; }; };
156+ });
157+}
158+
159+function A2(fun, a, b) {
160+ return fun.a === 2 ? fun.f(a, b) : fun(a)(b);
161+}
162+function A3(fun, a, b, c) {
163+ return fun.a === 3 ? fun.f(a, b, c) : fun(a)(b)(c);
164+}
165+function A4(fun, a, b, c, d) {
166+ return fun.a === 4 ? fun.f(a, b, c, d) : fun(a)(b)(c)(d);
167+}
168+function A5(fun, a, b, c, d, e) {
169+ return fun.a === 5 ? fun.f(a, b, c, d, e) : fun(a)(b)(c)(d)(e);
170+}
171+function A6(fun, a, b, c, d, e, f) {
172+ return fun.a === 6 ? fun.f(a, b, c, d, e, f) : fun(a)(b)(c)(d)(e)(f);
173+}
174+function A7(fun, a, b, c, d, e, f, g) {
175+ return fun.a === 7 ? fun.f(a, b, c, d, e, f, g) : fun(a)(b)(c)(d)(e)(f)(g);
176+}
177+function A8(fun, a, b, c, d, e, f, g, h) {
178+ return fun.a === 8 ? fun.f(a, b, c, d, e, f, g, h) : fun(a)(b)(c)(d)(e)(f)(g)(h);
179+}
180+function A9(fun, a, b, c, d, e, f, g, h, i) {
181+ return fun.a === 9 ? fun.f(a, b, c, d, e, f, g, h, i) : fun(a)(b)(c)(d)(e)(f)(g)(h)(i);
182+}
183+
184+console.warn('Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.');
185+
186+
187+var _JsArray_empty = [];
188+
189+function _JsArray_singleton(value)
190+{
191+ return [value];
192+}
193+
194+function _JsArray_length(array)
195+{
196+ return array.length;
197+}
198+
199+var _JsArray_initialize = F3(function(size, offset, func)
200+{
201+ var result = new Array(size);
202+
203+ for (var i = 0; i < size; i++)
204+ {
205+ result[i] = func(offset + i);
206+ }
207+
208+ return result;
209+});
210+
211+var _JsArray_initializeFromList = F2(function (max, ls)
212+{
213+ var result = new Array(max);
214+
215+ for (var i = 0; i < max && ls.b; i++)
216+ {
217+ result[i] = ls.a;
218+ ls = ls.b;
219+ }
220+
221+ result.length = i;
222+ return _Utils_Tuple2(result, ls);
223+});
224+
225+var _JsArray_unsafeGet = F2(function(index, array)
226+{
227+ return array[index];
228+});
229+
230+var _JsArray_unsafeSet = F3(function(index, value, array)
231+{
232+ var length = array.length;
233+ var result = new Array(length);
234+
235+ for (var i = 0; i < length; i++)
236+ {
237+ result[i] = array[i];
238+ }
239+
240+ result[index] = value;
241+ return result;
242+});
243+
244+var _JsArray_push = F2(function(value, array)
245+{
246+ var length = array.length;
247+ var result = new Array(length + 1);
248+
249+ for (var i = 0; i < length; i++)
250+ {
251+ result[i] = array[i];
252+ }
253+
254+ result[length] = value;
255+ return result;
256+});
257+
258+var _JsArray_foldl = F3(function(func, acc, array)
259+{
260+ var length = array.length;
261+
262+ for (var i = 0; i < length; i++)
263+ {
264+ acc = A2(func, array[i], acc);
265+ }
266+
267+ return acc;
268+});
269+
270+var _JsArray_foldr = F3(function(func, acc, array)
271+{
272+ for (var i = array.length - 1; i >= 0; i--)
273+ {
274+ acc = A2(func, array[i], acc);
275+ }
276+
277+ return acc;
278+});
279+
280+var _JsArray_map = F2(function(func, array)
281+{
282+ var length = array.length;
283+ var result = new Array(length);
284+
285+ for (var i = 0; i < length; i++)
286+ {
287+ result[i] = func(array[i]);
288+ }
289+
290+ return result;
291+});
292+
293+var _JsArray_indexedMap = F3(function(func, offset, array)
294+{
295+ var length = array.length;
296+ var result = new Array(length);
297+
298+ for (var i = 0; i < length; i++)
299+ {
300+ result[i] = A2(func, offset + i, array[i]);
301+ }
302+
303+ return result;
304+});
305+
306+var _JsArray_slice = F3(function(from, to, array)
307+{
308+ return array.slice(from, to);
309+});
310+
311+var _JsArray_appendN = F3(function(n, dest, source)
312+{
313+ var destLen = dest.length;
314+ var itemsToCopy = n - destLen;
315+
316+ if (itemsToCopy > source.length)
317+ {
318+ itemsToCopy = source.length;
319+ }
320+
321+ var size = destLen + itemsToCopy;
322+ var result = new Array(size);
323+
324+ for (var i = 0; i < destLen; i++)
325+ {
326+ result[i] = dest[i];
327+ }
328+
329+ for (var i = 0; i < itemsToCopy; i++)
330+ {
331+ result[i + destLen] = source[i];
332+ }
333+
334+ return result;
335+});
336+
337+
338+
339+// LOG
340+
341+
342+var _Debug_log = F2(function(tag, value)
343+{
344+ console.log(tag + ': ' + _Debug_toString(value));
345+ return value;
346+});
347+
348+
349+// TODOS
350+
351+function _Debug_todo(moduleName, region)
352+{
353+ return function(message) {
354+ _Debug_crash(8, moduleName, region, message);
355+ };
356+}
357+
358+function _Debug_todoCase(moduleName, region, value)
359+{
360+ return function(message) {
361+ _Debug_crash(9, moduleName, region, value, message);
362+ };
363+}
364+
365+
366+// TO STRING
367+
368+
369+function _Debug_toString(value)
370+{
371+ return _Debug_toAnsiString(false, value);
372+}
373+
374+function _Debug_toAnsiString(ansi, value)
375+{
376+ if (typeof value === 'function')
377+ {
378+ return _Debug_internalColor(ansi, '<function>');
379+ }
380+
381+ if (typeof value === 'boolean')
382+ {
383+ return _Debug_ctorColor(ansi, value ? 'True' : 'False');
384+ }
385+
386+ if (typeof value === 'number')
387+ {
388+ return _Debug_numberColor(ansi, value + '');
389+ }
390+
391+ if (value instanceof String)
392+ {
393+ return _Debug_charColor(ansi, "'" + _Debug_addSlashes(value, true) + "'");
394+ }
395+
396+ if (typeof value === 'string')
397+ {
398+ return _Debug_stringColor(ansi, '"' + _Debug_addSlashes(value, false) + '"');
399+ }
400+
401+ if (typeof value === 'object' && '$' in value)
402+ {
403+ var tag = value.$;
404+
405+ if (typeof tag === 'number')
406+ {
407+ return _Debug_internalColor(ansi, '<internals>');
408+ }
409+
410+ if (tag[0] === '#')
411+ {
412+ var output = [];
413+ for (var k in value)
414+ {
415+ if (k === '$') continue;
416+ output.push(_Debug_toAnsiString(ansi, value[k]));
417+ }
418+ return '(' + output.join(',') + ')';
419+ }
420+
421+ if (tag === 'Set_elm_builtin')
422+ {
423+ return _Debug_ctorColor(ansi, 'Set')
424+ + _Debug_fadeColor(ansi, '.fromList') + ' '
425+ + _Debug_toAnsiString(ansi, $elm$core$Set$toList(value));
426+ }
427+
428+ if (tag === 'RBNode_elm_builtin' || tag === 'RBEmpty_elm_builtin')
429+ {
430+ return _Debug_ctorColor(ansi, 'Dict')
431+ + _Debug_fadeColor(ansi, '.fromList') + ' '
432+ + _Debug_toAnsiString(ansi, $elm$core$Dict$toList(value));
433+ }
434+
435+ if (tag === 'Array_elm_builtin')
436+ {
437+ return _Debug_ctorColor(ansi, 'Array')
438+ + _Debug_fadeColor(ansi, '.fromList') + ' '
439+ + _Debug_toAnsiString(ansi, $elm$core$Array$toList(value));
440+ }
441+
442+ if (tag === '::' || tag === '[]')
443+ {
444+ var output = '[';
445+
446+ value.b && (output += _Debug_toAnsiString(ansi, value.a), value = value.b)
447+
448+ for (; value.b; value = value.b) // WHILE_CONS
449+ {
450+ output += ',' + _Debug_toAnsiString(ansi, value.a);
451+ }
452+ return output + ']';
453+ }
454+
455+ var output = '';
456+ for (var i in value)
457+ {
458+ if (i === '$') continue;
459+ var str = _Debug_toAnsiString(ansi, value[i]);
460+ var c0 = str[0];
461+ var parenless = c0 === '{' || c0 === '(' || c0 === '[' || c0 === '<' || c0 === '"' || str.indexOf(' ') < 0;
462+ output += ' ' + (parenless ? str : '(' + str + ')');
463+ }
464+ return _Debug_ctorColor(ansi, tag) + output;
465+ }
466+
467+ if (typeof DataView === 'function' && value instanceof DataView)
468+ {
469+ return _Debug_stringColor(ansi, '<' + value.byteLength + ' bytes>');
470+ }
471+
472+ if (typeof File !== 'undefined' && value instanceof File)
473+ {
474+ return _Debug_internalColor(ansi, '<' + value.name + '>');
475+ }
476+
477+ if (typeof value === 'object')
478+ {
479+ var output = [];
480+ for (var key in value)
481+ {
482+ var field = key[0] === '_' ? key.slice(1) : key;
483+ output.push(_Debug_fadeColor(ansi, field) + ' = ' + _Debug_toAnsiString(ansi, value[key]));
484+ }
485+ if (output.length === 0)
486+ {
487+ return '{}';
488+ }
489+ return '{ ' + output.join(', ') + ' }';
490+ }
491+
492+ return _Debug_internalColor(ansi, '<internals>');
493+}
494+
495+function _Debug_addSlashes(str, isChar)
496+{
497+ var s = str
498+ .replace(/\\/g, '\\\\')
499+ .replace(/\n/g, '\\n')
500+ .replace(/\t/g, '\\t')
501+ .replace(/\r/g, '\\r')
502+ .replace(/\v/g, '\\v')
503+ .replace(/\0/g, '\\0');
504+
505+ if (isChar)
506+ {
507+ return s.replace(/\'/g, '\\\'');
508+ }
509+ else
510+ {
511+ return s.replace(/\"/g, '\\"');
512+ }
513+}
514+
515+function _Debug_ctorColor(ansi, string)
516+{
517+ return ansi ? '\x1b[96m' + string + '\x1b[0m' : string;
518+}
519+
520+function _Debug_numberColor(ansi, string)
521+{
522+ return ansi ? '\x1b[95m' + string + '\x1b[0m' : string;
523+}
524+
525+function _Debug_stringColor(ansi, string)
526+{
527+ return ansi ? '\x1b[93m' + string + '\x1b[0m' : string;
528+}
529+
530+function _Debug_charColor(ansi, string)
531+{
532+ return ansi ? '\x1b[92m' + string + '\x1b[0m' : string;
533+}
534+
535+function _Debug_fadeColor(ansi, string)
536+{
537+ return ansi ? '\x1b[37m' + string + '\x1b[0m' : string;
538+}
539+
540+function _Debug_internalColor(ansi, string)
541+{
542+ return ansi ? '\x1b[36m' + string + '\x1b[0m' : string;
543+}
544+
545+function _Debug_toHexDigit(n)
546+{
547+ return String.fromCharCode(n < 10 ? 48 + n : 55 + n);
548+}
549+
550+
551+// CRASH
552+
553+
554+
555+
556+function _Debug_crash(identifier, fact1, fact2, fact3, fact4)
557+{
558+ switch(identifier)
559+ {
560+ case 0:
561+ throw new Error('What node should I take over? In JavaScript I need something like:\n\n Elm.Main.init({\n node: document.getElementById("elm-node")\n })\n\nYou need to do this with any Browser.sandbox or Browser.element program.');
562+
563+ case 1:
564+ throw new Error('Browser.application programs cannot handle URLs like this:\n\n ' + document.location.href + '\n\nWhat is the root? The root of your file system? Try looking at this program with `elm reactor` or some other server.');
565+
566+ case 2:
567+ var jsonErrorString = fact1;
568+ throw new Error('Problem with the flags given to your Elm program on initialization.\n\n' + jsonErrorString);
569+
570+ case 3:
571+ var portName = fact1;
572+ throw new Error('There can only be one port named `' + portName + '`, but your program has multiple.');
573+
574+ case 4:
575+ var portName = fact1;
576+ var problem = fact2;
577+ throw new Error('Trying to send an unexpected type of value through port `' + portName + '`:\n' + problem);
578+
579+ case 5:
580+ throw new Error('Trying to use `(==)` on functions.\nThere is no way to know if functions are "the same" in the Elm sense.\nRead more about this at https://package.elm-lang.org/packages/elm/core/latest/Basics#== which describes why it is this way and what the better version will look like.');
581+
582+ case 6:
583+ var moduleName = fact1;
584+ throw new Error('Your page is loading multiple Elm scripts with a module named ' + moduleName + '. Maybe a duplicate script is getting loaded accidentally? If not, rename one of them so I know which is which!');
585+
586+ case 8:
587+ var moduleName = fact1;
588+ var region = fact2;
589+ var message = fact3;
590+ throw new Error('TODO in module `' + moduleName + '` ' + _Debug_regionToString(region) + '\n\n' + message);
591+
592+ case 9:
593+ var moduleName = fact1;
594+ var region = fact2;
595+ var value = fact3;
596+ var message = fact4;
597+ throw new Error(
598+ 'TODO in module `' + moduleName + '` from the `case` expression '
599+ + _Debug_regionToString(region) + '\n\nIt received the following value:\n\n '
600+ + _Debug_toString(value).replace('\n', '\n ')
601+ + '\n\nBut the branch that handles it says:\n\n ' + message.replace('\n', '\n ')
602+ );
603+
604+ case 10:
605+ throw new Error('Bug in https://github.com/elm/virtual-dom/issues');
606+
607+ case 11:
608+ throw new Error('Cannot perform mod 0. Division by zero error.');
609+ }
610+}
611+
612+function _Debug_regionToString(region)
613+{
614+ if (region.start.line === region.end.line)
615+ {
616+ return 'on line ' + region.start.line;
617+ }
618+ return 'on lines ' + region.start.line + ' through ' + region.end.line;
619+}
620+
621+
622+
623+// EQUALITY
624+
625+function _Utils_eq(x, y)
626+{
627+ for (
628+ var pair, stack = [], isEqual = _Utils_eqHelp(x, y, 0, stack);
629+ isEqual && (pair = stack.pop());
630+ isEqual = _Utils_eqHelp(pair.a, pair.b, 0, stack)
631+ )
632+ {}
633+
634+ return isEqual;
635+}
636+
637+function _Utils_eqHelp(x, y, depth, stack)
638+{
639+ if (x === y)
640+ {
641+ return true;
642+ }
643+
644+ if (typeof x !== 'object' || x === null || y === null)
645+ {
646+ typeof x === 'function' && _Debug_crash(5);
647+ return false;
648+ }
649+
650+ if (depth > 100)
651+ {
652+ stack.push(_Utils_Tuple2(x,y));
653+ return true;
654+ }
655+
656+ /**/
657+ if (x.$ === 'Set_elm_builtin')
658+ {
659+ x = $elm$core$Set$toList(x);
660+ y = $elm$core$Set$toList(y);
661+ }
662+ if (x.$ === 'RBNode_elm_builtin' || x.$ === 'RBEmpty_elm_builtin')
663+ {
664+ x = $elm$core$Dict$toList(x);
665+ y = $elm$core$Dict$toList(y);
666+ }
667+ //*/
668+
669+ /**_UNUSED/
670+ if (x.$ < 0)
671+ {
672+ x = $elm$core$Dict$toList(x);
673+ y = $elm$core$Dict$toList(y);
674+ }
675+ //*/
676+
677+ for (var key in x)
678+ {
679+ if (!_Utils_eqHelp(x[key], y[key], depth + 1, stack))
680+ {
681+ return false;
682+ }
683+ }
684+ return true;
685+}
686+
687+var _Utils_equal = F2(_Utils_eq);
688+var _Utils_notEqual = F2(function(a, b) { return !_Utils_eq(a,b); });
689+
690+
691+
692+// COMPARISONS
693+
694+// Code in Generate/JavaScript.hs, Basics.js, and List.js depends on
695+// the particular integer values assigned to LT, EQ, and GT.
696+
697+function _Utils_cmp(x, y, ord)
698+{
699+ if (typeof x !== 'object')
700+ {
701+ return x === y ? /*EQ*/ 0 : x < y ? /*LT*/ -1 : /*GT*/ 1;
702+ }
703+
704+ /**/
705+ if (x instanceof String)
706+ {
707+ var a = x.valueOf();
708+ var b = y.valueOf();
709+ return a === b ? 0 : a < b ? -1 : 1;
710+ }
711+ //*/
712+
713+ /**_UNUSED/
714+ if (typeof x.$ === 'undefined')
715+ //*/
716+ /**/
717+ if (x.$[0] === '#')
718+ //*/
719+ {
720+ return (ord = _Utils_cmp(x.a, y.a))
721+ ? ord
722+ : (ord = _Utils_cmp(x.b, y.b))
723+ ? ord
724+ : _Utils_cmp(x.c, y.c);
725+ }
726+
727+ // traverse conses until end of a list or a mismatch
728+ for (; x.b && y.b && !(ord = _Utils_cmp(x.a, y.a)); x = x.b, y = y.b) {} // WHILE_CONSES
729+ return ord || (x.b ? /*GT*/ 1 : y.b ? /*LT*/ -1 : /*EQ*/ 0);
730+}
731+
732+var _Utils_lt = F2(function(a, b) { return _Utils_cmp(a, b) < 0; });
733+var _Utils_le = F2(function(a, b) { return _Utils_cmp(a, b) < 1; });
734+var _Utils_gt = F2(function(a, b) { return _Utils_cmp(a, b) > 0; });
735+var _Utils_ge = F2(function(a, b) { return _Utils_cmp(a, b) >= 0; });
736+
737+var _Utils_compare = F2(function(x, y)
738+{
739+ var n = _Utils_cmp(x, y);
740+ return n < 0 ? $elm$core$Basics$LT : n ? $elm$core$Basics$GT : $elm$core$Basics$EQ;
741+});
742+
743+
744+// COMMON VALUES
745+
746+var _Utils_Tuple0 = { $: '#0' };
747+
748+function _Utils_Tuple2(a, b) { return { $: '#2', a: a, b: b }; }
749+
750+function _Utils_Tuple3(a, b, c) { return { $: '#3', a: a, b: b, c: c }; }
751+
752+function _Utils_chr(c) { return new String(c); }
753+
754+
755+// RECORDS
756+
757+function _Utils_update(oldRecord, updatedFields)
758+{
759+ var newRecord = {};
760+
761+ for (var key in oldRecord)
762+ {
763+ newRecord[key] = oldRecord[key];
764+ }
765+
766+ for (var key in updatedFields)
767+ {
768+ newRecord[key] = updatedFields[key];
769+ }
770+
771+ return newRecord;
772+}
773+
774+
775+// APPEND
776+
777+var _Utils_append = F2(_Utils_ap);
778+
779+function _Utils_ap(xs, ys)
780+{
781+ // append Strings
782+ if (typeof xs === 'string')
783+ {
784+ return xs + ys;
785+ }
786+
787+ // append Lists
788+ if (!xs.b)
789+ {
790+ return ys;
791+ }
792+ var root = _List_Cons(xs.a, ys);
793+ xs = xs.b
794+ for (var curr = root; xs.b; xs = xs.b) // WHILE_CONS
795+ {
796+ curr = curr.b = _List_Cons(xs.a, ys);
797+ }
798+ return root;
799+}
800+
801+
802+
803+var _List_Nil = { $: '[]' };
804+
805+function _List_Cons(hd, tl) { return { $: '::', a: hd, b: tl }; }
806+
807+
808+var _List_cons = F2(_List_Cons);
809+
810+function _List_fromArray(arr)
811+{
812+ var out = _List_Nil;
813+ for (var i = arr.length; i--; )
814+ {
815+ out = _List_Cons(arr[i], out);
816+ }
817+ return out;
818+}
819+
820+function _List_toArray(xs)
821+{
822+ for (var out = []; xs.b; xs = xs.b) // WHILE_CONS
823+ {
824+ out.push(xs.a);
825+ }
826+ return out;
827+}
828+
829+var _List_map2 = F3(function(f, xs, ys)
830+{
831+ for (var arr = []; xs.b && ys.b; xs = xs.b, ys = ys.b) // WHILE_CONSES
832+ {
833+ arr.push(A2(f, xs.a, ys.a));
834+ }
835+ return _List_fromArray(arr);
836+});
837+
838+var _List_map3 = F4(function(f, xs, ys, zs)
839+{
840+ for (var arr = []; xs.b && ys.b && zs.b; xs = xs.b, ys = ys.b, zs = zs.b) // WHILE_CONSES
841+ {
842+ arr.push(A3(f, xs.a, ys.a, zs.a));
843+ }
844+ return _List_fromArray(arr);
845+});
846+
847+var _List_map4 = F5(function(f, ws, xs, ys, zs)
848+{
849+ for (var arr = []; ws.b && xs.b && ys.b && zs.b; ws = ws.b, xs = xs.b, ys = ys.b, zs = zs.b) // WHILE_CONSES
850+ {
851+ arr.push(A4(f, ws.a, xs.a, ys.a, zs.a));
852+ }
853+ return _List_fromArray(arr);
854+});
855+
856+var _List_map5 = F6(function(f, vs, ws, xs, ys, zs)
857+{
858+ for (var arr = []; vs.b && ws.b && xs.b && ys.b && zs.b; vs = vs.b, ws = ws.b, xs = xs.b, ys = ys.b, zs = zs.b) // WHILE_CONSES
859+ {
860+ arr.push(A5(f, vs.a, ws.a, xs.a, ys.a, zs.a));
861+ }
862+ return _List_fromArray(arr);
863+});
864+
865+var _List_sortBy = F2(function(f, xs)
866+{
867+ return _List_fromArray(_List_toArray(xs).sort(function(a, b) {
868+ return _Utils_cmp(f(a), f(b));
869+ }));
870+});
871+
872+var _List_sortWith = F2(function(f, xs)
873+{
874+ return _List_fromArray(_List_toArray(xs).sort(function(a, b) {
875+ var ord = A2(f, a, b);
876+ return ord === $elm$core$Basics$EQ ? 0 : ord === $elm$core$Basics$LT ? -1 : 1;
877+ }));
878+});
879+
880+
881+
882+// MATH
883+
884+var _Basics_add = F2(function(a, b) { return a + b; });
885+var _Basics_sub = F2(function(a, b) { return a - b; });
886+var _Basics_mul = F2(function(a, b) { return a * b; });
887+var _Basics_fdiv = F2(function(a, b) { return a / b; });
888+var _Basics_idiv = F2(function(a, b) { return (a / b) | 0; });
889+var _Basics_pow = F2(Math.pow);
890+
891+var _Basics_remainderBy = F2(function(b, a) { return a % b; });
892+
893+// https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/divmodnote-letter.pdf
894+var _Basics_modBy = F2(function(modulus, x)
895+{
896+ var answer = x % modulus;
897+ return modulus === 0
898+ ? _Debug_crash(11)
899+ :
900+ ((answer > 0 && modulus < 0) || (answer < 0 && modulus > 0))
901+ ? answer + modulus
902+ : answer;
903+});
904+
905+
906+// TRIGONOMETRY
907+
908+var _Basics_pi = Math.PI;
909+var _Basics_e = Math.E;
910+var _Basics_cos = Math.cos;
911+var _Basics_sin = Math.sin;
912+var _Basics_tan = Math.tan;
913+var _Basics_acos = Math.acos;
914+var _Basics_asin = Math.asin;
915+var _Basics_atan = Math.atan;
916+var _Basics_atan2 = F2(Math.atan2);
917+
918+
919+// MORE MATH
920+
921+function _Basics_toFloat(x) { return x; }
922+function _Basics_truncate(n) { return n | 0; }
923+function _Basics_isInfinite(n) { return n === Infinity || n === -Infinity; }
924+
925+var _Basics_ceiling = Math.ceil;
926+var _Basics_floor = Math.floor;
927+var _Basics_round = Math.round;
928+var _Basics_sqrt = Math.sqrt;
929+var _Basics_log = Math.log;
930+var _Basics_isNaN = isNaN;
931+
932+
933+// BOOLEANS
934+
935+function _Basics_not(bool) { return !bool; }
936+var _Basics_and = F2(function(a, b) { return a && b; });
937+var _Basics_or = F2(function(a, b) { return a || b; });
938+var _Basics_xor = F2(function(a, b) { return a !== b; });
939+
940+
941+
942+var _String_cons = F2(function(chr, str)
943+{
944+ return chr + str;
945+});
946+
947+function _String_uncons(string)
948+{
949+ var word = string.charCodeAt(0);
950+ return !isNaN(word)
951+ ? $elm$core$Maybe$Just(
952+ 0xD800 <= word && word <= 0xDBFF
953+ ? _Utils_Tuple2(_Utils_chr(string[0] + string[1]), string.slice(2))
954+ : _Utils_Tuple2(_Utils_chr(string[0]), string.slice(1))
955+ )
956+ : $elm$core$Maybe$Nothing;
957+}
958+
959+var _String_append = F2(function(a, b)
960+{
961+ return a + b;
962+});
963+
964+function _String_length(str)
965+{
966+ return str.length;
967+}
968+
969+var _String_map = F2(function(func, string)
970+{
971+ var len = string.length;
972+ var array = new Array(len);
973+ var i = 0;
974+ while (i < len)
975+ {
976+ var word = string.charCodeAt(i);
977+ if (0xD800 <= word && word <= 0xDBFF)
978+ {
979+ array[i] = func(_Utils_chr(string[i] + string[i+1]));
980+ i += 2;
981+ continue;
982+ }
983+ array[i] = func(_Utils_chr(string[i]));
984+ i++;
985+ }
986+ return array.join('');
987+});
988+
989+var _String_filter = F2(function(isGood, str)
990+{
991+ var arr = [];
992+ var len = str.length;
993+ var i = 0;
994+ while (i < len)
995+ {
996+ var char = str[i];
997+ var word = str.charCodeAt(i);
998+ i++;
999+ if (0xD800 <= word && word <= 0xDBFF)
1000+ {
1001+ char += str[i];
1002+ i++;
1003+ }
1004+
1005+ if (isGood(_Utils_chr(char)))
1006+ {
1007+ arr.push(char);
1008+ }
1009+ }
1010+ return arr.join('');
1011+});
1012+
1013+function _String_reverse(str)
1014+{
1015+ var len = str.length;
1016+ var arr = new Array(len);
1017+ var i = 0;
1018+ while (i < len)
1019+ {
1020+ var word = str.charCodeAt(i);
1021+ if (0xD800 <= word && word <= 0xDBFF)
1022+ {
1023+ arr[len - i] = str[i + 1];
1024+ i++;
1025+ arr[len - i] = str[i - 1];
1026+ i++;
1027+ }
1028+ else
1029+ {
1030+ arr[len - i] = str[i];
1031+ i++;
1032+ }
1033+ }
1034+ return arr.join('');
1035+}
1036+
1037+var _String_foldl = F3(function(func, state, string)
1038+{
1039+ var len = string.length;
1040+ var i = 0;
1041+ while (i < len)
1042+ {
1043+ var char = string[i];
1044+ var word = string.charCodeAt(i);
1045+ i++;
1046+ if (0xD800 <= word && word <= 0xDBFF)
1047+ {
1048+ char += string[i];
1049+ i++;
1050+ }
1051+ state = A2(func, _Utils_chr(char), state);
1052+ }
1053+ return state;
1054+});
1055+
1056+var _String_foldr = F3(function(func, state, string)
1057+{
1058+ var i = string.length;
1059+ while (i--)
1060+ {
1061+ var char = string[i];
1062+ var word = string.charCodeAt(i);
1063+ if (0xDC00 <= word && word <= 0xDFFF)
1064+ {
1065+ i--;
1066+ char = string[i] + char;
1067+ }
1068+ state = A2(func, _Utils_chr(char), state);
1069+ }
1070+ return state;
1071+});
1072+
1073+var _String_split = F2(function(sep, str)
1074+{
1075+ return str.split(sep);
1076+});
1077+
1078+var _String_join = F2(function(sep, strs)
1079+{
1080+ return strs.join(sep);
1081+});
1082+
1083+var _String_slice = F3(function(start, end, str) {
1084+ return str.slice(start, end);
1085+});
1086+
1087+function _String_trim(str)
1088+{
1089+ return str.trim();
1090+}
1091+
1092+function _String_trimLeft(str)
1093+{
1094+ return str.replace(/^\s+/, '');
1095+}
1096+
1097+function _String_trimRight(str)
1098+{
1099+ return str.replace(/\s+$/, '');
1100+}
1101+
1102+function _String_words(str)
1103+{
1104+ return _List_fromArray(str.trim().split(/\s+/g));
1105+}
1106+
1107+function _String_lines(str)
1108+{
1109+ return _List_fromArray(str.split(/\r\n|\r|\n/g));
1110+}
1111+
1112+function _String_toUpper(str)
1113+{
1114+ return str.toUpperCase();
1115+}
1116+
1117+function _String_toLower(str)
1118+{
1119+ return str.toLowerCase();
1120+}
1121+
1122+var _String_any = F2(function(isGood, string)
1123+{
1124+ var i = string.length;
1125+ while (i--)
1126+ {
1127+ var char = string[i];
1128+ var word = string.charCodeAt(i);
1129+ if (0xDC00 <= word && word <= 0xDFFF)
1130+ {
1131+ i--;
1132+ char = string[i] + char;
1133+ }
1134+ if (isGood(_Utils_chr(char)))
1135+ {
1136+ return true;
1137+ }
1138+ }
1139+ return false;
1140+});
1141+
1142+var _String_all = F2(function(isGood, string)
1143+{
1144+ var i = string.length;
1145+ while (i--)
1146+ {
1147+ var char = string[i];
1148+ var word = string.charCodeAt(i);
1149+ if (0xDC00 <= word && word <= 0xDFFF)
1150+ {
1151+ i--;
1152+ char = string[i] + char;
1153+ }
1154+ if (!isGood(_Utils_chr(char)))
1155+ {
1156+ return false;
1157+ }
1158+ }
1159+ return true;
1160+});
1161+
1162+var _String_contains = F2(function(sub, str)
1163+{
1164+ return str.indexOf(sub) > -1;
1165+});
1166+
1167+var _String_startsWith = F2(function(sub, str)
1168+{
1169+ return str.indexOf(sub) === 0;
1170+});
1171+
1172+var _String_endsWith = F2(function(sub, str)
1173+{
1174+ return str.length >= sub.length &&
1175+ str.lastIndexOf(sub) === str.length - sub.length;
1176+});
1177+
1178+var _String_indexes = F2(function(sub, str)
1179+{
1180+ var subLen = sub.length;
1181+
1182+ if (subLen < 1)
1183+ {
1184+ return _List_Nil;
1185+ }
1186+
1187+ var i = 0;
1188+ var is = [];
1189+
1190+ while ((i = str.indexOf(sub, i)) > -1)
1191+ {
1192+ is.push(i);
1193+ i = i + subLen;
1194+ }
1195+
1196+ return _List_fromArray(is);
1197+});
1198+
1199+
1200+// TO STRING
1201+
1202+function _String_fromNumber(number)
1203+{
1204+ return number + '';
1205+}
1206+
1207+
1208+// INT CONVERSIONS
1209+
1210+function _String_toInt(str)
1211+{
1212+ var total = 0;
1213+ var code0 = str.charCodeAt(0);
1214+ var start = code0 == 0x2B /* + */ || code0 == 0x2D /* - */ ? 1 : 0;
1215+
1216+ for (var i = start; i < str.length; ++i)
1217+ {
1218+ var code = str.charCodeAt(i);
1219+ if (code < 0x30 || 0x39 < code)
1220+ {
1221+ return $elm$core$Maybe$Nothing;
1222+ }
1223+ total = 10 * total + code - 0x30;
1224+ }
1225+
1226+ return i == start
1227+ ? $elm$core$Maybe$Nothing
1228+ : $elm$core$Maybe$Just(code0 == 0x2D ? -total : total);
1229+}
1230+
1231+
1232+// FLOAT CONVERSIONS
1233+
1234+function _String_toFloat(s)
1235+{
1236+ // check if it is a hex, octal, or binary number
1237+ if (s.length === 0 || /[\sxbo]/.test(s))
1238+ {
1239+ return $elm$core$Maybe$Nothing;
1240+ }
1241+ var n = +s;
1242+ // faster isNaN check
1243+ return n === n ? $elm$core$Maybe$Just(n) : $elm$core$Maybe$Nothing;
1244+}
1245+
1246+function _String_fromList(chars)
1247+{
1248+ return _List_toArray(chars).join('');
1249+}
1250+
1251+
1252+
1253+
1254+function _Char_toCode(char)
1255+{
1256+ var code = char.charCodeAt(0);
1257+ if (0xD800 <= code && code <= 0xDBFF)
1258+ {
1259+ return (code - 0xD800) * 0x400 + char.charCodeAt(1) - 0xDC00 + 0x10000
1260+ }
1261+ return code;
1262+}
1263+
1264+function _Char_fromCode(code)
1265+{
1266+ return _Utils_chr(
1267+ (code < 0 || 0x10FFFF < code)
1268+ ? '\uFFFD'
1269+ :
1270+ (code <= 0xFFFF)
1271+ ? String.fromCharCode(code)
1272+ :
1273+ (code -= 0x10000,
1274+ String.fromCharCode(Math.floor(code / 0x400) + 0xD800, code % 0x400 + 0xDC00)
1275+ )
1276+ );
1277+}
1278+
1279+function _Char_toUpper(char)
1280+{
1281+ return _Utils_chr(char.toUpperCase());
1282+}
1283+
1284+function _Char_toLower(char)
1285+{
1286+ return _Utils_chr(char.toLowerCase());
1287+}
1288+
1289+function _Char_toLocaleUpper(char)
1290+{
1291+ return _Utils_chr(char.toLocaleUpperCase());
1292+}
1293+
1294+function _Char_toLocaleLower(char)
1295+{
1296+ return _Utils_chr(char.toLocaleLowerCase());
1297+}
1298+
1299+
1300+
1301+/**/
1302+function _Json_errorToString(error)
1303+{
1304+ return $elm$json$Json$Decode$errorToString(error);
1305+}
1306+//*/
1307+
1308+
1309+// CORE DECODERS
1310+
1311+function _Json_succeed(msg)
1312+{
1313+ return {
1314+ $: 0,
1315+ a: msg
1316+ };
1317+}
1318+
1319+function _Json_fail(msg)
1320+{
1321+ return {
1322+ $: 1,
1323+ a: msg
1324+ };
1325+}
1326+
1327+function _Json_decodePrim(decoder)
1328+{
1329+ return { $: 2, b: decoder };
1330+}
1331+
1332+var _Json_decodeInt = _Json_decodePrim(function(value) {
1333+ return (typeof value !== 'number')
1334+ ? _Json_expecting('an INT', value)
1335+ :
1336+ (-2147483647 < value && value < 2147483647 && (value | 0) === value)
1337+ ? $elm$core$Result$Ok(value)
1338+ :
1339+ (isFinite(value) && !(value % 1))
1340+ ? $elm$core$Result$Ok(value)
1341+ : _Json_expecting('an INT', value);
1342+});
1343+
1344+var _Json_decodeBool = _Json_decodePrim(function(value) {
1345+ return (typeof value === 'boolean')
1346+ ? $elm$core$Result$Ok(value)
1347+ : _Json_expecting('a BOOL', value);
1348+});
1349+
1350+var _Json_decodeFloat = _Json_decodePrim(function(value) {
1351+ return (typeof value === 'number')
1352+ ? $elm$core$Result$Ok(value)
1353+ : _Json_expecting('a FLOAT', value);
1354+});
1355+
1356+var _Json_decodeValue = _Json_decodePrim(function(value) {
1357+ return $elm$core$Result$Ok(_Json_wrap(value));
1358+});
1359+
1360+var _Json_decodeString = _Json_decodePrim(function(value) {
1361+ return (typeof value === 'string')
1362+ ? $elm$core$Result$Ok(value)
1363+ : (value instanceof String)
1364+ ? $elm$core$Result$Ok(value + '')
1365+ : _Json_expecting('a STRING', value);
1366+});
1367+
1368+function _Json_decodeList(decoder) { return { $: 3, b: decoder }; }
1369+function _Json_decodeArray(decoder) { return { $: 4, b: decoder }; }
1370+
1371+function _Json_decodeNull(value) { return { $: 5, c: value }; }
1372+
1373+var _Json_decodeField = F2(function(field, decoder)
1374+{
1375+ return {
1376+ $: 6,
1377+ d: field,
1378+ b: decoder
1379+ };
1380+});
1381+
1382+var _Json_decodeIndex = F2(function(index, decoder)
1383+{
1384+ return {
1385+ $: 7,
1386+ e: index,
1387+ b: decoder
1388+ };
1389+});
1390+
1391+function _Json_decodeKeyValuePairs(decoder)
1392+{
1393+ return {
1394+ $: 8,
1395+ b: decoder
1396+ };
1397+}
1398+
1399+function _Json_mapMany(f, decoders)
1400+{
1401+ return {
1402+ $: 9,
1403+ f: f,
1404+ g: decoders
1405+ };
1406+}
1407+
1408+var _Json_andThen = F2(function(callback, decoder)
1409+{
1410+ return {
1411+ $: 10,
1412+ b: decoder,
1413+ h: callback
1414+ };
1415+});
1416+
1417+function _Json_oneOf(decoders)
1418+{
1419+ return {
1420+ $: 11,
1421+ g: decoders
1422+ };
1423+}
1424+
1425+
1426+// DECODING OBJECTS
1427+
1428+var _Json_map1 = F2(function(f, d1)
1429+{
1430+ return _Json_mapMany(f, [d1]);
1431+});
1432+
1433+var _Json_map2 = F3(function(f, d1, d2)
1434+{
1435+ return _Json_mapMany(f, [d1, d2]);
1436+});
1437+
1438+var _Json_map3 = F4(function(f, d1, d2, d3)
1439+{
1440+ return _Json_mapMany(f, [d1, d2, d3]);
1441+});
1442+
1443+var _Json_map4 = F5(function(f, d1, d2, d3, d4)
1444+{
1445+ return _Json_mapMany(f, [d1, d2, d3, d4]);
1446+});
1447+
1448+var _Json_map5 = F6(function(f, d1, d2, d3, d4, d5)
1449+{
1450+ return _Json_mapMany(f, [d1, d2, d3, d4, d5]);
1451+});
1452+
1453+var _Json_map6 = F7(function(f, d1, d2, d3, d4, d5, d6)
1454+{
1455+ return _Json_mapMany(f, [d1, d2, d3, d4, d5, d6]);
1456+});
1457+
1458+var _Json_map7 = F8(function(f, d1, d2, d3, d4, d5, d6, d7)
1459+{
1460+ return _Json_mapMany(f, [d1, d2, d3, d4, d5, d6, d7]);
1461+});
1462+
1463+var _Json_map8 = F9(function(f, d1, d2, d3, d4, d5, d6, d7, d8)
1464+{
1465+ return _Json_mapMany(f, [d1, d2, d3, d4, d5, d6, d7, d8]);
1466+});
1467+
1468+
1469+// DECODE
1470+
1471+var _Json_runOnString = F2(function(decoder, string)
1472+{
1473+ try
1474+ {
1475+ var value = JSON.parse(string);
1476+ return _Json_runHelp(decoder, value);
1477+ }
1478+ catch (e)
1479+ {
1480+ return $elm$core$Result$Err(A2($elm$json$Json$Decode$Failure, 'This is not valid JSON! ' + e.message, _Json_wrap(string)));
1481+ }
1482+});
1483+
1484+var _Json_run = F2(function(decoder, value)
1485+{
1486+ return _Json_runHelp(decoder, _Json_unwrap(value));
1487+});
1488+
1489+function _Json_runHelp(decoder, value)
1490+{
1491+ switch (decoder.$)
1492+ {
1493+ case 2:
1494+ return decoder.b(value);
1495+
1496+ case 5:
1497+ return (value === null)
1498+ ? $elm$core$Result$Ok(decoder.c)
1499+ : _Json_expecting('null', value);
1500+
1501+ case 3:
1502+ if (!_Json_isArray(value))
1503+ {
1504+ return _Json_expecting('a LIST', value);
1505+ }
1506+ return _Json_runArrayDecoder(decoder.b, value, _List_fromArray);
1507+
1508+ case 4:
1509+ if (!_Json_isArray(value))
1510+ {
1511+ return _Json_expecting('an ARRAY', value);
1512+ }
1513+ return _Json_runArrayDecoder(decoder.b, value, _Json_toElmArray);
1514+
1515+ case 6:
1516+ var field = decoder.d;
1517+ if (typeof value !== 'object' || value === null || !(field in value))
1518+ {
1519+ return _Json_expecting('an OBJECT with a field named `' + field + '`', value);
1520+ }
1521+ var result = _Json_runHelp(decoder.b, value[field]);
1522+ return ($elm$core$Result$isOk(result)) ? result : $elm$core$Result$Err(A2($elm$json$Json$Decode$Field, field, result.a));
1523+
1524+ case 7:
1525+ var index = decoder.e;
1526+ if (!_Json_isArray(value))
1527+ {
1528+ return _Json_expecting('an ARRAY', value);
1529+ }
1530+ if (index >= value.length)
1531+ {
1532+ return _Json_expecting('a LONGER array. Need index ' + index + ' but only see ' + value.length + ' entries', value);
1533+ }
1534+ var result = _Json_runHelp(decoder.b, value[index]);
1535+ return ($elm$core$Result$isOk(result)) ? result : $elm$core$Result$Err(A2($elm$json$Json$Decode$Index, index, result.a));
1536+
1537+ case 8:
1538+ if (typeof value !== 'object' || value === null || _Json_isArray(value))
1539+ {
1540+ return _Json_expecting('an OBJECT', value);
1541+ }
1542+
1543+ var keyValuePairs = _List_Nil;
1544+ // TODO test perf of Object.keys and switch when support is good enough
1545+ for (var key in value)
1546+ {
1547+ if (value.hasOwnProperty(key))
1548+ {
1549+ var result = _Json_runHelp(decoder.b, value[key]);
1550+ if (!$elm$core$Result$isOk(result))
1551+ {
1552+ return $elm$core$Result$Err(A2($elm$json$Json$Decode$Field, key, result.a));
1553+ }
1554+ keyValuePairs = _List_Cons(_Utils_Tuple2(key, result.a), keyValuePairs);
1555+ }
1556+ }
1557+ return $elm$core$Result$Ok($elm$core$List$reverse(keyValuePairs));
1558+
1559+ case 9:
1560+ var answer = decoder.f;
1561+ var decoders = decoder.g;
1562+ for (var i = 0; i < decoders.length; i++)
1563+ {
1564+ var result = _Json_runHelp(decoders[i], value);
1565+ if (!$elm$core$Result$isOk(result))
1566+ {
1567+ return result;
1568+ }
1569+ answer = answer(result.a);
1570+ }
1571+ return $elm$core$Result$Ok(answer);
1572+
1573+ case 10:
1574+ var result = _Json_runHelp(decoder.b, value);
1575+ return (!$elm$core$Result$isOk(result))
1576+ ? result
1577+ : _Json_runHelp(decoder.h(result.a), value);
1578+
1579+ case 11:
1580+ var errors = _List_Nil;
1581+ for (var temp = decoder.g; temp.b; temp = temp.b) // WHILE_CONS
1582+ {
1583+ var result = _Json_runHelp(temp.a, value);
1584+ if ($elm$core$Result$isOk(result))
1585+ {
1586+ return result;
1587+ }
1588+ errors = _List_Cons(result.a, errors);
1589+ }
1590+ return $elm$core$Result$Err($elm$json$Json$Decode$OneOf($elm$core$List$reverse(errors)));
1591+
1592+ case 1:
1593+ return $elm$core$Result$Err(A2($elm$json$Json$Decode$Failure, decoder.a, _Json_wrap(value)));
1594+
1595+ case 0:
1596+ return $elm$core$Result$Ok(decoder.a);
1597+ }
1598+}
1599+
1600+function _Json_runArrayDecoder(decoder, value, toElmValue)
1601+{
1602+ var len = value.length;
1603+ var array = new Array(len);
1604+ for (var i = 0; i < len; i++)
1605+ {
1606+ var result = _Json_runHelp(decoder, value[i]);
1607+ if (!$elm$core$Result$isOk(result))
1608+ {
1609+ return $elm$core$Result$Err(A2($elm$json$Json$Decode$Index, i, result.a));
1610+ }
1611+ array[i] = result.a;
1612+ }
1613+ return $elm$core$Result$Ok(toElmValue(array));
1614+}
1615+
1616+function _Json_isArray(value)
1617+{
1618+ return Array.isArray(value) || (typeof FileList !== 'undefined' && value instanceof FileList);
1619+}
1620+
1621+function _Json_toElmArray(array)
1622+{
1623+ return A2($elm$core$Array$initialize, array.length, function(i) { return array[i]; });
1624+}
1625+
1626+function _Json_expecting(type, value)
1627+{
1628+ return $elm$core$Result$Err(A2($elm$json$Json$Decode$Failure, 'Expecting ' + type, _Json_wrap(value)));
1629+}
1630+
1631+
1632+// EQUALITY
1633+
1634+function _Json_equality(x, y)
1635+{
1636+ if (x === y)
1637+ {
1638+ return true;
1639+ }
1640+
1641+ if (x.$ !== y.$)
1642+ {
1643+ return false;
1644+ }
1645+
1646+ switch (x.$)
1647+ {
1648+ case 0:
1649+ case 1:
1650+ return x.a === y.a;
1651+
1652+ case 2:
1653+ return x.b === y.b;
1654+
1655+ case 5:
1656+ return x.c === y.c;
1657+
1658+ case 3:
1659+ case 4:
1660+ case 8:
1661+ return _Json_equality(x.b, y.b);
1662+
1663+ case 6:
1664+ return x.d === y.d && _Json_equality(x.b, y.b);
1665+
1666+ case 7:
1667+ return x.e === y.e && _Json_equality(x.b, y.b);
1668+
1669+ case 9:
1670+ return x.f === y.f && _Json_listEquality(x.g, y.g);
1671+
1672+ case 10:
1673+ return x.h === y.h && _Json_equality(x.b, y.b);
1674+
1675+ case 11:
1676+ return _Json_listEquality(x.g, y.g);
1677+ }
1678+}
1679+
1680+function _Json_listEquality(aDecoders, bDecoders)
1681+{
1682+ var len = aDecoders.length;
1683+ if (len !== bDecoders.length)
1684+ {
1685+ return false;
1686+ }
1687+ for (var i = 0; i < len; i++)
1688+ {
1689+ if (!_Json_equality(aDecoders[i], bDecoders[i]))
1690+ {
1691+ return false;
1692+ }
1693+ }
1694+ return true;
1695+}
1696+
1697+
1698+// ENCODE
1699+
1700+var _Json_encode = F2(function(indentLevel, value)
1701+{
1702+ return JSON.stringify(_Json_unwrap(value), null, indentLevel) + '';
1703+});
1704+
1705+function _Json_wrap(value) { return { $: 0, a: value }; }
1706+function _Json_unwrap(value) { return value.a; }
1707+
1708+
1709+function _Json_emptyArray() { return []; }
1710+function _Json_emptyObject() { return {}; }
1711+
1712+var _Json_addField = F3(function(key, value, object)
1713+{
1714+ object[key] = _Json_unwrap(value);
1715+ return object;
1716+});
1717+
1718+function _Json_addEntry(func)
1719+{
1720+ return F2(function(entry, array)
1721+ {
1722+ array.push(_Json_unwrap(func(entry)));
1723+ return array;
1724+ });
1725+}
1726+
1727+var _Json_encodeNull = _Json_wrap(null);
1728+
1729+
1730+
1731+// TASKS
1732+
1733+function _Scheduler_succeed(value)
1734+{
1735+ return {
1736+ $: 0,
1737+ a: value
1738+ };
1739+}
1740+
1741+function _Scheduler_fail(error)
1742+{
1743+ return {
1744+ $: 1,
1745+ a: error
1746+ };
1747+}
1748+
1749+function _Scheduler_binding(callback)
1750+{
1751+ return {
1752+ $: 2,
1753+ b: callback,
1754+ c: null
1755+ };
1756+}
1757+
1758+var _Scheduler_andThen = F2(function(callback, task)
1759+{
1760+ return {
1761+ $: 3,
1762+ b: callback,
1763+ d: task
1764+ };
1765+});
1766+
1767+var _Scheduler_onError = F2(function(callback, task)
1768+{
1769+ return {
1770+ $: 4,
1771+ b: callback,
1772+ d: task
1773+ };
1774+});
1775+
1776+function _Scheduler_receive(callback)
1777+{
1778+ return {
1779+ $: 5,
1780+ b: callback
1781+ };
1782+}
1783+
1784+
1785+// PROCESSES
1786+
1787+var _Scheduler_guid = 0;
1788+
1789+function _Scheduler_rawSpawn(task)
1790+{
1791+ var proc = {
1792+ $: 0,
1793+ e: _Scheduler_guid++,
1794+ f: task,
1795+ g: null,
1796+ h: []
1797+ };
1798+
1799+ _Scheduler_enqueue(proc);
1800+
1801+ return proc;
1802+}
1803+
1804+function _Scheduler_spawn(task)
1805+{
1806+ return _Scheduler_binding(function(callback) {
1807+ callback(_Scheduler_succeed(_Scheduler_rawSpawn(task)));
1808+ });
1809+}
1810+
1811+function _Scheduler_rawSend(proc, msg)
1812+{
1813+ proc.h.push(msg);
1814+ _Scheduler_enqueue(proc);
1815+}
1816+
1817+var _Scheduler_send = F2(function(proc, msg)
1818+{
1819+ return _Scheduler_binding(function(callback) {
1820+ _Scheduler_rawSend(proc, msg);
1821+ callback(_Scheduler_succeed(_Utils_Tuple0));
1822+ });
1823+});
1824+
1825+function _Scheduler_kill(proc)
1826+{
1827+ return _Scheduler_binding(function(callback) {
1828+ var task = proc.f;
1829+ if (task.$ === 2 && task.c)
1830+ {
1831+ task.c();
1832+ }
1833+
1834+ proc.f = null;
1835+
1836+ callback(_Scheduler_succeed(_Utils_Tuple0));
1837+ });
1838+}
1839+
1840+
1841+/* STEP PROCESSES
1842+
1843+type alias Process =
1844+ { $ : tag
1845+ , id : unique_id
1846+ , root : Task
1847+ , stack : null | { $: SUCCEED | FAIL, a: callback, b: stack }
1848+ , mailbox : [msg]
1849+ }
1850+
1851+*/
1852+
1853+
1854+var _Scheduler_working = false;
1855+var _Scheduler_queue = [];
1856+
1857+
1858+function _Scheduler_enqueue(proc)
1859+{
1860+ _Scheduler_queue.push(proc);
1861+ if (_Scheduler_working)
1862+ {
1863+ return;
1864+ }
1865+ _Scheduler_working = true;
1866+ while (proc = _Scheduler_queue.shift())
1867+ {
1868+ _Scheduler_step(proc);
1869+ }
1870+ _Scheduler_working = false;
1871+}
1872+
1873+
1874+function _Scheduler_step(proc)
1875+{
1876+ while (proc.f)
1877+ {
1878+ var rootTag = proc.f.$;
1879+ if (rootTag === 0 || rootTag === 1)
1880+ {
1881+ while (proc.g && proc.g.$ !== rootTag)
1882+ {
1883+ proc.g = proc.g.i;
1884+ }
1885+ if (!proc.g)
1886+ {
1887+ return;
1888+ }
1889+ proc.f = proc.g.b(proc.f.a);
1890+ proc.g = proc.g.i;
1891+ }
1892+ else if (rootTag === 2)
1893+ {
1894+ proc.f.c = proc.f.b(function(newRoot) {
1895+ proc.f = newRoot;
1896+ _Scheduler_enqueue(proc);
1897+ });
1898+ return;
1899+ }
1900+ else if (rootTag === 5)
1901+ {
1902+ if (proc.h.length === 0)
1903+ {
1904+ return;
1905+ }
1906+ proc.f = proc.f.b(proc.h.shift());
1907+ }
1908+ else // if (rootTag === 3 || rootTag === 4)
1909+ {
1910+ proc.g = {
1911+ $: rootTag === 3 ? 0 : 1,
1912+ b: proc.f.b,
1913+ i: proc.g
1914+ };
1915+ proc.f = proc.f.d;
1916+ }
1917+ }
1918+}
1919+
1920+
1921+
1922+function _Process_sleep(time)
1923+{
1924+ return _Scheduler_binding(function(callback) {
1925+ var id = setTimeout(function() {
1926+ callback(_Scheduler_succeed(_Utils_Tuple0));
1927+ }, time);
1928+
1929+ return function() { clearTimeout(id); };
1930+ });
1931+}
1932+
1933+
1934+
1935+
1936+// PROGRAMS
1937+
1938+
1939+var _Platform_worker = F4(function(impl, flagDecoder, debugMetadata, args)
1940+{
1941+ return _Platform_initialize(
1942+ flagDecoder,
1943+ args,
1944+ impl.init,
1945+ impl.update,
1946+ impl.subscriptions,
1947+ function() { return function() {} }
1948+ );
1949+});
1950+
1951+
1952+
1953+// INITIALIZE A PROGRAM
1954+
1955+
1956+function _Platform_initialize(flagDecoder, args, init, update, subscriptions, stepperBuilder)
1957+{
1958+ var result = A2(_Json_run, flagDecoder, _Json_wrap(args ? args['flags'] : undefined));
1959+ $elm$core$Result$isOk(result) || _Debug_crash(2 /**/, _Json_errorToString(result.a) /**/);
1960+ var managers = {};
1961+ var initPair = init(result.a);
1962+ var model = initPair.a;
1963+ var stepper = stepperBuilder(sendToApp, model);
1964+ var ports = _Platform_setupEffects(managers, sendToApp);
1965+
1966+ function sendToApp(msg, viewMetadata)
1967+ {
1968+ var pair = A2(update, msg, model);
1969+ stepper(model = pair.a, viewMetadata);
1970+ _Platform_enqueueEffects(managers, pair.b, subscriptions(model));
1971+ }
1972+
1973+ _Platform_enqueueEffects(managers, initPair.b, subscriptions(model));
1974+
1975+ return ports ? { ports: ports } : {};
1976+}
1977+
1978+
1979+
1980+// TRACK PRELOADS
1981+//
1982+// This is used by code in elm/browser and elm/http
1983+// to register any HTTP requests that are triggered by init.
1984+//
1985+
1986+
1987+var _Platform_preload;
1988+
1989+
1990+function _Platform_registerPreload(url)
1991+{
1992+ _Platform_preload.add(url);
1993+}
1994+
1995+
1996+
1997+// EFFECT MANAGERS
1998+
1999+
2000+var _Platform_effectManagers = {};
2001+
2002+
2003+function _Platform_setupEffects(managers, sendToApp)
2004+{
2005+ var ports;
2006+
2007+ // setup all necessary effect managers
2008+ for (var key in _Platform_effectManagers)
2009+ {
2010+ var manager = _Platform_effectManagers[key];
2011+
2012+ if (manager.a)
2013+ {
2014+ ports = ports || {};
2015+ ports[key] = manager.a(key, sendToApp);
2016+ }
2017+
2018+ managers[key] = _Platform_instantiateManager(manager, sendToApp);
2019+ }
2020+
2021+ return ports;
2022+}
2023+
2024+
2025+function _Platform_createManager(init, onEffects, onSelfMsg, cmdMap, subMap)
2026+{
2027+ return {
2028+ b: init,
2029+ c: onEffects,
2030+ d: onSelfMsg,
2031+ e: cmdMap,
2032+ f: subMap
2033+ };
2034+}
2035+
2036+
2037+function _Platform_instantiateManager(info, sendToApp)
2038+{
2039+ var router = {
2040+ g: sendToApp,
2041+ h: undefined
2042+ };
2043+
2044+ var onEffects = info.c;
2045+ var onSelfMsg = info.d;
2046+ var cmdMap = info.e;
2047+ var subMap = info.f;
2048+
2049+ function loop(state)
2050+ {
2051+ return A2(_Scheduler_andThen, loop, _Scheduler_receive(function(msg)
2052+ {
2053+ var value = msg.a;
2054+
2055+ if (msg.$ === 0)
2056+ {
2057+ return A3(onSelfMsg, router, value, state);
2058+ }
2059+
2060+ return cmdMap && subMap
2061+ ? A4(onEffects, router, value.i, value.j, state)
2062+ : A3(onEffects, router, cmdMap ? value.i : value.j, state);
2063+ }));
2064+ }
2065+
2066+ return router.h = _Scheduler_rawSpawn(A2(_Scheduler_andThen, loop, info.b));
2067+}
2068+
2069+
2070+
2071+// ROUTING
2072+
2073+
2074+var _Platform_sendToApp = F2(function(router, msg)
2075+{
2076+ return _Scheduler_binding(function(callback)
2077+ {
2078+ router.g(msg);
2079+ callback(_Scheduler_succeed(_Utils_Tuple0));
2080+ });
2081+});
2082+
2083+
2084+var _Platform_sendToSelf = F2(function(router, msg)
2085+{
2086+ return A2(_Scheduler_send, router.h, {
2087+ $: 0,
2088+ a: msg
2089+ });
2090+});
2091+
2092+
2093+
2094+// BAGS
2095+
2096+
2097+function _Platform_leaf(home)
2098+{
2099+ return function(value)
2100+ {
2101+ return {
2102+ $: 1,
2103+ k: home,
2104+ l: value
2105+ };
2106+ };
2107+}
2108+
2109+
2110+function _Platform_batch(list)
2111+{
2112+ return {
2113+ $: 2,
2114+ m: list
2115+ };
2116+}
2117+
2118+
2119+var _Platform_map = F2(function(tagger, bag)
2120+{
2121+ return {
2122+ $: 3,
2123+ n: tagger,
2124+ o: bag
2125+ }
2126+});
2127+
2128+
2129+
2130+// PIPE BAGS INTO EFFECT MANAGERS
2131+//
2132+// Effects must be queued!
2133+//
2134+// Say your init contains a synchronous command, like Time.now or Time.here
2135+//
2136+// - This will produce a batch of effects (FX_1)
2137+// - The synchronous task triggers the subsequent `update` call
2138+// - This will produce a batch of effects (FX_2)
2139+//
2140+// If we just start dispatching FX_2, subscriptions from FX_2 can be processed
2141+// before subscriptions from FX_1. No good! Earlier versions of this code had
2142+// this problem, leading to these reports:
2143+//
2144+// https://github.com/elm/core/issues/980
2145+// https://github.com/elm/core/pull/981
2146+// https://github.com/elm/compiler/issues/1776
2147+//
2148+// The queue is necessary to avoid ordering issues for synchronous commands.
2149+
2150+
2151+// Why use true/false here? Why not just check the length of the queue?
2152+// The goal is to detect "are we currently dispatching effects?" If we
2153+// are, we need to bail and let the ongoing while loop handle things.
2154+//
2155+// Now say the queue has 1 element. When we dequeue the final element,
2156+// the queue will be empty, but we are still actively dispatching effects.
2157+// So you could get queue jumping in a really tricky category of cases.
2158+//
2159+var _Platform_effectsQueue = [];
2160+var _Platform_effectsActive = false;
2161+
2162+
2163+function _Platform_enqueueEffects(managers, cmdBag, subBag)
2164+{
2165+ _Platform_effectsQueue.push({ p: managers, q: cmdBag, r: subBag });
2166+
2167+ if (_Platform_effectsActive) return;
2168+
2169+ _Platform_effectsActive = true;
2170+ for (var fx; fx = _Platform_effectsQueue.shift(); )
2171+ {
2172+ _Platform_dispatchEffects(fx.p, fx.q, fx.r);
2173+ }
2174+ _Platform_effectsActive = false;
2175+}
2176+
2177+
2178+function _Platform_dispatchEffects(managers, cmdBag, subBag)
2179+{
2180+ var effectsDict = {};
2181+ _Platform_gatherEffects(true, cmdBag, effectsDict, null);
2182+ _Platform_gatherEffects(false, subBag, effectsDict, null);
2183+
2184+ for (var home in managers)
2185+ {
2186+ _Scheduler_rawSend(managers[home], {
2187+ $: 'fx',
2188+ a: effectsDict[home] || { i: _List_Nil, j: _List_Nil }
2189+ });
2190+ }
2191+}
2192+
2193+
2194+function _Platform_gatherEffects(isCmd, bag, effectsDict, taggers)
2195+{
2196+ switch (bag.$)
2197+ {
2198+ case 1:
2199+ var home = bag.k;
2200+ var effect = _Platform_toEffect(isCmd, home, taggers, bag.l);
2201+ effectsDict[home] = _Platform_insert(isCmd, effect, effectsDict[home]);
2202+ return;
2203+
2204+ case 2:
2205+ for (var list = bag.m; list.b; list = list.b) // WHILE_CONS
2206+ {
2207+ _Platform_gatherEffects(isCmd, list.a, effectsDict, taggers);
2208+ }
2209+ return;
2210+
2211+ case 3:
2212+ _Platform_gatherEffects(isCmd, bag.o, effectsDict, {
2213+ s: bag.n,
2214+ t: taggers
2215+ });
2216+ return;
2217+ }
2218+}
2219+
2220+
2221+function _Platform_toEffect(isCmd, home, taggers, value)
2222+{
2223+ function applyTaggers(x)
2224+ {
2225+ for (var temp = taggers; temp; temp = temp.t)
2226+ {
2227+ x = temp.s(x);
2228+ }
2229+ return x;
2230+ }
2231+
2232+ var map = isCmd
2233+ ? _Platform_effectManagers[home].e
2234+ : _Platform_effectManagers[home].f;
2235+
2236+ return A2(map, applyTaggers, value)
2237+}
2238+
2239+
2240+function _Platform_insert(isCmd, newEffect, effects)
2241+{
2242+ effects = effects || { i: _List_Nil, j: _List_Nil };
2243+
2244+ isCmd
2245+ ? (effects.i = _List_Cons(newEffect, effects.i))
2246+ : (effects.j = _List_Cons(newEffect, effects.j));
2247+
2248+ return effects;
2249+}
2250+
2251+
2252+
2253+// PORTS
2254+
2255+
2256+function _Platform_checkPortName(name)
2257+{
2258+ if (_Platform_effectManagers[name])
2259+ {
2260+ _Debug_crash(3, name)
2261+ }
2262+}
2263+
2264+
2265+
2266+// OUTGOING PORTS
2267+
2268+
2269+function _Platform_outgoingPort(name, converter)
2270+{
2271+ _Platform_checkPortName(name);
2272+ _Platform_effectManagers[name] = {
2273+ e: _Platform_outgoingPortMap,
2274+ u: converter,
2275+ a: _Platform_setupOutgoingPort
2276+ };
2277+ return _Platform_leaf(name);
2278+}
2279+
2280+
2281+var _Platform_outgoingPortMap = F2(function(tagger, value) { return value; });
2282+
2283+
2284+function _Platform_setupOutgoingPort(name)
2285+{
2286+ var subs = [];
2287+ var converter = _Platform_effectManagers[name].u;
2288+
2289+ // CREATE MANAGER
2290+
2291+ var init = _Process_sleep(0);
2292+
2293+ _Platform_effectManagers[name].b = init;
2294+ _Platform_effectManagers[name].c = F3(function(router, cmdList, state)
2295+ {
2296+ for ( ; cmdList.b; cmdList = cmdList.b) // WHILE_CONS
2297+ {
2298+ // grab a separate reference to subs in case unsubscribe is called
2299+ var currentSubs = subs;
2300+ var value = _Json_unwrap(converter(cmdList.a));
2301+ for (var i = 0; i < currentSubs.length; i++)
2302+ {
2303+ currentSubs[i](value);
2304+ }
2305+ }
2306+ return init;
2307+ });
2308+
2309+ // PUBLIC API
2310+
2311+ function subscribe(callback)
2312+ {
2313+ subs.push(callback);
2314+ }
2315+
2316+ function unsubscribe(callback)
2317+ {
2318+ // copy subs into a new array in case unsubscribe is called within a
2319+ // subscribed callback
2320+ subs = subs.slice();
2321+ var index = subs.indexOf(callback);
2322+ if (index >= 0)
2323+ {
2324+ subs.splice(index, 1);
2325+ }
2326+ }
2327+
2328+ return {
2329+ subscribe: subscribe,
2330+ unsubscribe: unsubscribe
2331+ };
2332+}
2333+
2334+
2335+
2336+// INCOMING PORTS
2337+
2338+
2339+function _Platform_incomingPort(name, converter)
2340+{
2341+ _Platform_checkPortName(name);
2342+ _Platform_effectManagers[name] = {
2343+ f: _Platform_incomingPortMap,
2344+ u: converter,
2345+ a: _Platform_setupIncomingPort
2346+ };
2347+ return _Platform_leaf(name);
2348+}
2349+
2350+
2351+var _Platform_incomingPortMap = F2(function(tagger, finalTagger)
2352+{
2353+ return function(value)
2354+ {
2355+ return tagger(finalTagger(value));
2356+ };
2357+});
2358+
2359+
2360+function _Platform_setupIncomingPort(name, sendToApp)
2361+{
2362+ var subs = _List_Nil;
2363+ var converter = _Platform_effectManagers[name].u;
2364+
2365+ // CREATE MANAGER
2366+
2367+ var init = _Scheduler_succeed(null);
2368+
2369+ _Platform_effectManagers[name].b = init;
2370+ _Platform_effectManagers[name].c = F3(function(router, subList, state)
2371+ {
2372+ subs = subList;
2373+ return init;
2374+ });
2375+
2376+ // PUBLIC API
2377+
2378+ function send(incomingValue)
2379+ {
2380+ var result = A2(_Json_run, converter, _Json_wrap(incomingValue));
2381+
2382+ $elm$core$Result$isOk(result) || _Debug_crash(4, name, result.a);
2383+
2384+ var value = result.a;
2385+ for (var temp = subs; temp.b; temp = temp.b) // WHILE_CONS
2386+ {
2387+ sendToApp(temp.a(value));
2388+ }
2389+ }
2390+
2391+ return { send: send };
2392+}
2393+
2394+
2395+
2396+// EXPORT ELM MODULES
2397+//
2398+// Have DEBUG and PROD versions so that we can (1) give nicer errors in
2399+// debug mode and (2) not pay for the bits needed for that in prod mode.
2400+//
2401+
2402+
2403+
2404+
2405+function _Platform_mergeExportsProd(obj, exports)
2406+{
2407+ for (var name in exports)
2408+ {
2409+ (name in obj)
2410+ ? (name == 'init')
2411+ ? _Debug_crash(6)
2412+ : _Platform_mergeExportsProd(obj[name], exports[name])
2413+ : (obj[name] = exports[name]);
2414+ }
2415+}
2416+
2417+
2418+function _Platform_export(exports)
2419+{
2420+ scope['Elm']
2421+ ? _Platform_mergeExportsDebug('Elm', scope['Elm'], exports)
2422+ : scope['Elm'] = exports;
2423+}
2424+
2425+
2426+function _Platform_mergeExportsDebug(moduleName, obj, exports)
2427+{
2428+ for (var name in exports)
2429+ {
2430+ (name in obj)
2431+ ? (name == 'init')
2432+ ? _Debug_crash(6, moduleName)
2433+ : _Platform_mergeExportsDebug(moduleName + '.' + name, obj[name], exports[name])
2434+ : (obj[name] = exports[name]);
2435+ }
2436+}
2437+
2438+
2439+
2440+var _Lynx_g = (typeof globalThis !== 'undefined' ? globalThis : scope);
2441+function _Lynx_papi(name) { return _Lynx_g['_' + '_' + name] || function() {}; }
2442+var _Lynx_createViewFn = _Lynx_papi('CreateView');
2443+var _Lynx_createTextFn = _Lynx_papi('CreateText');
2444+var _Lynx_createImageFn = _Lynx_papi('CreateImage');
2445+function _Lynx_createElement(tag) {
2446+ var pId = (_Lynx_g['native'] && _Lynx_g['native']['currentPageId']) || 0;
2447+ return (tag === 'text' ? _Lynx_createTextFn
2448+ : tag === 'image' ? _Lynx_createImageFn
2449+ : _Lynx_createViewFn)(pId);
2450+}
2451+var _Lynx_createRawText = _Lynx_papi('CreateRawText');
2452+var _Lynx_appendChild = _Lynx_papi('AppendElement');
2453+var _Lynx_removeElement = _Lynx_papi('RemoveElement');
2454+var _Lynx_replaceElement = _Lynx_papi('ReplaceElement');
2455+var _Lynx_insertBefore = _Lynx_papi('InsertElementBefore');
2456+var _Lynx_setAttribute = _Lynx_papi('SetAttribute');
2457+var _Lynx_getChildren = _Lynx_papi('GetChildren');
2458+var _Lynx_getParent = _Lynx_papi('GetParent');
2459+var _Lynx_addEvent = _Lynx_papi('AddEvent');
2460+var _Lynx_setInlineStyles = _Lynx_papi('SetInlineStyles');
2461+var _VirtualDom_elementMeta = new WeakMap();
2462+function _VirtualDom_getMeta(el) {
2463+ var meta = _VirtualDom_elementMeta.get(el);
2464+ if (!meta) { meta = {}; _VirtualDom_elementMeta.set(el, meta); }
2465+ return meta;
2466+}
2467+
2468+
2469+// HELPERS
2470+
2471+
2472+
2473+
2474+
2475+function _VirtualDom_appendChild(parent, child)
2476+{
2477+ _Lynx_appendChild(parent, child);
2478+}
2479+
2480+var _VirtualDom_init = F4(function(virtualNode, flagDecoder, debugMetadata, args)
2481+{
2482+ // NOTE: this function needs _Platform_export available to work
2483+ var rootPage = args['node'] || _Lynx_g['page'];
2484+ var tree = _VirtualDom_render(virtualNode, function() {});
2485+ _Lynx_appendChild(rootPage, tree);
2486+ return {};
2487+});
2488+
2489+
2490+
2491+// TEXT
2492+
2493+
2494+function _VirtualDom_text(string)
2495+{
2496+ return {
2497+ $: 0,
2498+ a: string
2499+ };
2500+}
2501+
2502+
2503+
2504+// NODE
2505+
2506+
2507+var _VirtualDom_nodeNS = F2(function(namespace, tag)
2508+{
2509+ return F2(function(factList, kidList)
2510+ {
2511+ for (var kids = [], descendantsCount = 0; kidList.b; kidList = kidList.b) // WHILE_CONS
2512+ {
2513+ var kid = kidList.a;
2514+ descendantsCount += (kid.b || 0);
2515+ kids.push(kid);
2516+ }
2517+ descendantsCount += kids.length;
2518+
2519+ return {
2520+ $: 1,
2521+ c: tag,
2522+ d: _VirtualDom_organizeFacts(factList),
2523+ e: kids,
2524+ f: namespace,
2525+ b: descendantsCount
2526+ };
2527+ });
2528+});
2529+
2530+
2531+var _VirtualDom_node = _VirtualDom_nodeNS(undefined);
2532+
2533+
2534+
2535+// KEYED NODE
2536+
2537+
2538+var _VirtualDom_keyedNodeNS = F2(function(namespace, tag)
2539+{
2540+ return F2(function(factList, kidList)
2541+ {
2542+ for (var kids = [], descendantsCount = 0; kidList.b; kidList = kidList.b) // WHILE_CONS
2543+ {
2544+ var kid = kidList.a;
2545+ descendantsCount += (kid.b.b || 0);
2546+ kids.push(kid);
2547+ }
2548+ descendantsCount += kids.length;
2549+
2550+ return {
2551+ $: 2,
2552+ c: tag,
2553+ d: _VirtualDom_organizeFacts(factList),
2554+ e: kids,
2555+ f: namespace,
2556+ b: descendantsCount
2557+ };
2558+ });
2559+});
2560+
2561+
2562+var _VirtualDom_keyedNode = _VirtualDom_keyedNodeNS(undefined);
2563+
2564+
2565+
2566+// CUSTOM
2567+
2568+
2569+function _VirtualDom_custom(factList, model, render, diff)
2570+{
2571+ return {
2572+ $: 3,
2573+ d: _VirtualDom_organizeFacts(factList),
2574+ g: model,
2575+ h: render,
2576+ i: diff
2577+ };
2578+}
2579+
2580+
2581+
2582+// MAP
2583+
2584+
2585+var _VirtualDom_map = F2(function(tagger, node)
2586+{
2587+ return {
2588+ $: 4,
2589+ j: tagger,
2590+ k: node,
2591+ b: 1 + (node.b || 0)
2592+ };
2593+});
2594+
2595+
2596+
2597+// LAZY
2598+
2599+
2600+function _VirtualDom_thunk(refs, thunk)
2601+{
2602+ return {
2603+ $: 5,
2604+ l: refs,
2605+ m: thunk,
2606+ k: undefined
2607+ };
2608+}
2609+
2610+var _VirtualDom_lazy = F2(function(func, a)
2611+{
2612+ return _VirtualDom_thunk([func, a], function() {
2613+ return func(a);
2614+ });
2615+});
2616+
2617+var _VirtualDom_lazy2 = F3(function(func, a, b)
2618+{
2619+ return _VirtualDom_thunk([func, a, b], function() {
2620+ return A2(func, a, b);
2621+ });
2622+});
2623+
2624+var _VirtualDom_lazy3 = F4(function(func, a, b, c)
2625+{
2626+ return _VirtualDom_thunk([func, a, b, c], function() {
2627+ return A3(func, a, b, c);
2628+ });
2629+});
2630+
2631+var _VirtualDom_lazy4 = F5(function(func, a, b, c, d)
2632+{
2633+ return _VirtualDom_thunk([func, a, b, c, d], function() {
2634+ return A4(func, a, b, c, d);
2635+ });
2636+});
2637+
2638+var _VirtualDom_lazy5 = F6(function(func, a, b, c, d, e)
2639+{
2640+ return _VirtualDom_thunk([func, a, b, c, d, e], function() {
2641+ return A5(func, a, b, c, d, e);
2642+ });
2643+});
2644+
2645+var _VirtualDom_lazy6 = F7(function(func, a, b, c, d, e, f)
2646+{
2647+ return _VirtualDom_thunk([func, a, b, c, d, e, f], function() {
2648+ return A6(func, a, b, c, d, e, f);
2649+ });
2650+});
2651+
2652+var _VirtualDom_lazy7 = F8(function(func, a, b, c, d, e, f, g)
2653+{
2654+ return _VirtualDom_thunk([func, a, b, c, d, e, f, g], function() {
2655+ return A7(func, a, b, c, d, e, f, g);
2656+ });
2657+});
2658+
2659+var _VirtualDom_lazy8 = F9(function(func, a, b, c, d, e, f, g, h)
2660+{
2661+ return _VirtualDom_thunk([func, a, b, c, d, e, f, g, h], function() {
2662+ return A8(func, a, b, c, d, e, f, g, h);
2663+ });
2664+});
2665+
2666+
2667+
2668+// FACTS
2669+
2670+
2671+var _VirtualDom_on = F2(function(key, handler)
2672+{
2673+ return {
2674+ $: 'a0',
2675+ n: key,
2676+ o: handler
2677+ };
2678+});
2679+var _VirtualDom_style = F2(function(key, value)
2680+{
2681+ return {
2682+ $: 'a1',
2683+ n: key,
2684+ o: value
2685+ };
2686+});
2687+var _VirtualDom_property = F2(function(key, value)
2688+{
2689+ return {
2690+ $: 'a2',
2691+ n: key,
2692+ o: value
2693+ };
2694+});
2695+var _VirtualDom_attribute = F2(function(key, value)
2696+{
2697+ return {
2698+ $: 'a3',
2699+ n: key,
2700+ o: value
2701+ };
2702+});
2703+var _VirtualDom_attributeNS = F3(function(namespace, key, value)
2704+{
2705+ return {
2706+ $: 'a4',
2707+ n: key,
2708+ o: { f: namespace, o: value }
2709+ };
2710+});
2711+
2712+
2713+
2714+// XSS ATTACK VECTOR CHECKS
2715+//
2716+// For some reason, tabs can appear in href protocols and it still works.
2717+// So '\tjava\tSCRIPT:alert("!!!")' and 'javascript:alert("!!!")' are the same
2718+// in practice. That is why _VirtualDom_RE_js and _VirtualDom_RE_js_html look
2719+// so freaky.
2720+//
2721+// Pulling the regular expressions out to the top level gives a slight speed
2722+// boost in small benchmarks (4-10%) but hoisting values to reduce allocation
2723+// can be unpredictable in large programs where JIT may have a harder time with
2724+// functions are not fully self-contained. The benefit is more that the js and
2725+// js_html ones are so weird that I prefer to see them near each other.
2726+
2727+
2728+
2729+
2730+
2731+function _VirtualDom_noScript(tag)
2732+{
2733+ return tag;
2734+}
2735+
2736+function _VirtualDom_noOnOrFormAction(key)
2737+{
2738+ return key;
2739+}
2740+
2741+function _VirtualDom_noInnerHtmlOrFormAction(key)
2742+{
2743+ return key;
2744+}
2745+
2746+function _VirtualDom_noJavaScriptUri(value)
2747+{
2748+ return value;
2749+}
2750+
2751+function _VirtualDom_noJavaScriptOrHtmlUri(value)
2752+{
2753+ return value;
2754+}
2755+
2756+function _VirtualDom_noJavaScriptOrHtmlJson(value)
2757+{
2758+ return value;
2759+}
2760+
2761+
2762+
2763+// MAP FACTS
2764+
2765+
2766+var _VirtualDom_mapAttribute = F2(function(func, attr)
2767+{
2768+ return (attr.$ === 'a0')
2769+ ? A2(_VirtualDom_on, attr.n, _VirtualDom_mapHandler(func, attr.o))
2770+ : attr;
2771+});
2772+
2773+function _VirtualDom_mapHandler(func, handler)
2774+{
2775+ var tag = $lynxjs_elm$virtual_dom$VirtualDom$toHandlerInt(handler);
2776+
2777+ // 0 = Normal
2778+ // 1 = MayStopPropagation
2779+ // 2 = MayPreventDefault
2780+ // 3 = Custom
2781+
2782+ return {
2783+ $: handler.$,
2784+ a:
2785+ !tag
2786+ ? A2($elm$json$Json$Decode$map, func, handler.a)
2787+ :
2788+ A3($elm$json$Json$Decode$map2,
2789+ tag < 3
2790+ ? _VirtualDom_mapEventTuple
2791+ : _VirtualDom_mapEventRecord,
2792+ $elm$json$Json$Decode$succeed(func),
2793+ handler.a
2794+ )
2795+ };
2796+}
2797+
2798+var _VirtualDom_mapEventTuple = F2(function(func, tuple)
2799+{
2800+ return _Utils_Tuple2(func(tuple.a), tuple.b);
2801+});
2802+
2803+var _VirtualDom_mapEventRecord = F2(function(func, record)
2804+{
2805+ return {
2806+ message: func(record.message),
2807+ stopPropagation: record.stopPropagation,
2808+ preventDefault: record.preventDefault
2809+ }
2810+});
2811+
2812+
2813+
2814+// ORGANIZE FACTS
2815+
2816+
2817+function _VirtualDom_organizeFacts(factList)
2818+{
2819+ for (var facts = {}; factList.b; factList = factList.b) // WHILE_CONS
2820+ {
2821+ var entry = factList.a;
2822+
2823+ var tag = entry.$;
2824+ var key = entry.n;
2825+ var value = entry.o;
2826+
2827+ if (tag === 'a2')
2828+ {
2829+ (key === 'className')
2830+ ? _VirtualDom_addClass(facts, key, _Json_unwrap(value))
2831+ : facts[key] = _Json_unwrap(value);
2832+
2833+ continue;
2834+ }
2835+
2836+ var subFacts = facts[tag] || (facts[tag] = {});
2837+ (tag === 'a3' && key === 'class')
2838+ ? _VirtualDom_addClass(subFacts, key, value)
2839+ : subFacts[key] = value;
2840+ }
2841+
2842+ return facts;
2843+}
2844+
2845+function _VirtualDom_addClass(object, key, newClass)
2846+{
2847+ var classes = object[key];
2848+ object[key] = classes ? classes + ' ' + newClass : newClass;
2849+}
2850+
2851+
2852+
2853+// RENDER
2854+
2855+
2856+function _VirtualDom_render(vNode, eventNode)
2857+{
2858+ var tag = vNode.$;
2859+
2860+ if (tag === 5)
2861+ {
2862+ return _VirtualDom_render(vNode.k || (vNode.k = vNode.m()), eventNode);
2863+ }
2864+
2865+ if (tag === 0)
2866+ {
2867+ return _Lynx_createRawText(vNode.a);
2868+ }
2869+
2870+ if (tag === 4)
2871+ {
2872+ var subNode = vNode.k;
2873+ var tagger = vNode.j;
2874+
2875+ while (subNode.$ === 4)
2876+ {
2877+ typeof tagger !== 'object'
2878+ ? tagger = [tagger, subNode.j]
2879+ : tagger.push(subNode.j);
2880+
2881+ subNode = subNode.k;
2882+ }
2883+
2884+ var subEventRoot = { j: tagger, p: eventNode };
2885+ var domNode = _VirtualDom_render(subNode, subEventRoot);
2886+ _VirtualDom_getMeta(domNode).elm_event_node_ref = subEventRoot;
2887+ return domNode;
2888+ }
2889+
2890+ if (tag === 3)
2891+ {
2892+ var domNode = vNode.h(vNode.g);
2893+ _VirtualDom_applyFacts(domNode, eventNode, vNode.d);
2894+ return domNode;
2895+ }
2896+
2897+ // at this point `tag` must be 1 or 2
2898+
2899+ var domNode = _Lynx_createElement(vNode.c);
2900+
2901+ _VirtualDom_applyFacts(domNode, eventNode, vNode.d);
2902+
2903+ for (var kids = vNode.e, i = 0; i < kids.length; i++)
2904+ {
2905+ var kid = tag === 1 ? kids[i] : kids[i].b;
2906+ if (kid.$ === 0)
2907+ {
2908+ _Lynx_appendChild(domNode, _Lynx_createRawText(kid.a));
2909+ }
2910+ else
2911+ {
2912+ _VirtualDom_appendChild(domNode, _VirtualDom_render(kid, eventNode));
2913+ }
2914+ }
2915+
2916+ return domNode;
2917+}
2918+
2919+
2920+
2921+// APPLY FACTS
2922+
2923+
2924+function _VirtualDom_applyFacts(domNode, eventNode, facts)
2925+{
2926+ for (var key in facts)
2927+ {
2928+ var value = facts[key];
2929+
2930+ key === 'a1'
2931+ ? _VirtualDom_applyStyles(domNode, value)
2932+ :
2933+ key === 'a0'
2934+ ? _VirtualDom_applyEvents(domNode, eventNode, value)
2935+ :
2936+ key === 'a3'
2937+ ? _VirtualDom_applyAttrs(domNode, value)
2938+ :
2939+ key === 'a4'
2940+ ? _VirtualDom_applyAttrsNS(domNode, value)
2941+ :
2942+ (key !== 'value' && key !== 'checked' || domNode[key] !== value) && _Lynx_setAttribute(domNode, key === 'className' ? 'class' : key, String(value));
2943+ }
2944+}
2945+
2946+
2947+
2948+// APPLY STYLES
2949+
2950+
2951+function _VirtualDom_applyStyles(domNode, styles)
2952+{
2953+ _Lynx_setInlineStyles(domNode, styles);
2954+}
2955+
2956+
2957+
2958+// APPLY ATTRS
2959+
2960+
2961+function _VirtualDom_applyAttrs(domNode, attrs)
2962+{
2963+ for (var key in attrs)
2964+ {
2965+ var value = attrs[key];
2966+ if (typeof value !== 'undefined')
2967+ {
2968+ _Lynx_setAttribute(domNode, key, value);
2969+ }
2970+ }
2971+}
2972+
2973+
2974+
2975+// APPLY NAMESPACED ATTRS
2976+
2977+
2978+function _VirtualDom_applyAttrsNS(domNode, nsAttrs)
2979+{
2980+ for (var key in nsAttrs)
2981+ {
2982+ var pair = nsAttrs[key];
2983+ var value = pair.o;
2984+
2985+ if (typeof value !== 'undefined')
2986+ {
2987+ _Lynx_setAttribute(domNode, key, value);
2988+ }
2989+ }
2990+}
2991+
2992+
2993+
2994+// APPLY EVENTS
2995+
2996+
2997+function _VirtualDom_applyEvents(domNode, eventNode, events)
2998+{
2999+ var meta = _VirtualDom_getMeta(domNode);
3000+ var allCallbacks = meta.elmFs || (meta.elmFs = {});
3001+
3002+ for (var key in events)
3003+ {
3004+ var newHandler = events[key];
3005+ var oldCallback = allCallbacks[key];
3006+
3007+ if (!newHandler)
3008+ {
3009+ allCallbacks[key] = undefined;
3010+ continue;
3011+ }
3012+
3013+ if (oldCallback)
3014+ {
3015+ var oldHandler = oldCallback.q;
3016+ if (oldHandler.$ === newHandler.$)
3017+ {
3018+ oldCallback.q = newHandler;
3019+ continue;
3020+ }
3021+ }
3022+
3023+ oldCallback = _VirtualDom_makeCallback(eventNode, newHandler);
3024+ allCallbacks[key] = oldCallback;
3025+
3026+ var lynxEventName = _VirtualDom_mapEventName(key);
3027+ var handlerType = $lynxjs_elm$virtual_dom$VirtualDom$toHandlerInt(newHandler);
3028+ var prefix = (handlerType === 1) ? 'catch' : 'bind';
3029+ _Lynx_addEvent(domNode, 'catchEvent', lynxEventName, { type: 'worklet', value: oldCallback });
3030+ }
3031+}
3032+
3033+function _VirtualDom_mapEventName(name)
3034+{
3035+ switch (name)
3036+ {
3037+ case 'click': return 'tap';
3038+ case 'dblclick': return 'tap';
3039+ case 'mousedown': return 'touchstart';
3040+ case 'mousemove': return 'touchmove';
3041+ case 'mouseup': return 'touchend';
3042+ default: return name;
3043+ }
3044+}
3045+
3046+
3047+
3048+// PASSIVE EVENTS
3049+
3050+
3051+
3052+// EVENT HANDLERS
3053+
3054+
3055+function _VirtualDom_makeCallback(eventNode, initialHandler)
3056+{
3057+ function callback(event)
3058+ {
3059+ var handler = callback.q;
3060+ var result = _Json_runHelp(handler.a, event);
3061+
3062+ if (!$elm$core$Result$isOk(result))
3063+ {
3064+ return;
3065+ }
3066+
3067+ var tag = $lynxjs_elm$virtual_dom$VirtualDom$toHandlerInt(handler);
3068+
3069+ // 0 = Normal
3070+ // 1 = MayStopPropagation
3071+ // 2 = MayPreventDefault
3072+ // 3 = Custom
3073+
3074+ var value = result.a;
3075+ var message = !tag ? value : tag < 3 ? value.a : value.message;
3076+ var stopPropagation = tag == 1 ? value.b : tag == 3 && value.stopPropagation;
3077+ var currentEventNode = eventNode;
3078+ var tagger;
3079+ var i;
3080+ while (tagger = currentEventNode.j)
3081+ {
3082+ if (typeof tagger == 'function')
3083+ {
3084+ message = tagger(message);
3085+ }
3086+ else
3087+ {
3088+ for (var i = tagger.length; i--; )
3089+ {
3090+ message = tagger[i](message);
3091+ }
3092+ }
3093+ currentEventNode = currentEventNode.p;
3094+ }
3095+ currentEventNode(message, stopPropagation); // stopPropagation implies isSync
3096+ }
3097+
3098+ callback.q = initialHandler;
3099+
3100+ return callback;
3101+}
3102+
3103+function _VirtualDom_equalEvents(x, y)
3104+{
3105+ return x.$ == y.$ && _Json_equality(x.a, y.a);
3106+}
3107+
3108+
3109+
3110+// DIFF
3111+
3112+
3113+// TODO: Should we do patches like in iOS?
3114+//
3115+// type Patch
3116+// = At Int Patch
3117+// | Batch (List Patch)
3118+// | Change ...
3119+//
3120+// How could it not be better?
3121+//
3122+function _VirtualDom_diff(x, y)
3123+{
3124+ var patches = [];
3125+ _VirtualDom_diffHelp(x, y, patches, 0);
3126+ return patches;
3127+}
3128+
3129+
3130+function _VirtualDom_pushPatch(patches, type, index, data)
3131+{
3132+ var patch = {
3133+ $: type,
3134+ r: index,
3135+ s: data,
3136+ t: undefined,
3137+ u: undefined
3138+ };
3139+ patches.push(patch);
3140+ return patch;
3141+}
3142+
3143+
3144+function _VirtualDom_diffHelp(x, y, patches, index)
3145+{
3146+ if (x === y)
3147+ {
3148+ return;
3149+ }
3150+
3151+ var xType = x.$;
3152+ var yType = y.$;
3153+
3154+ // Bail if you run into different types of nodes. Implies that the
3155+ // structure has changed significantly and it's not worth a diff.
3156+ if (xType !== yType)
3157+ {
3158+ if (xType === 1 && yType === 2)
3159+ {
3160+ y = _VirtualDom_dekey(y);
3161+ yType = 1;
3162+ }
3163+ else
3164+ {
3165+ _VirtualDom_pushPatch(patches, 0, index, y);
3166+ return;
3167+ }
3168+ }
3169+
3170+ // Now we know that both nodes are the same $.
3171+ switch (yType)
3172+ {
3173+ case 5:
3174+ var xRefs = x.l;
3175+ var yRefs = y.l;
3176+ var i = xRefs.length;
3177+ var same = i === yRefs.length;
3178+ while (same && i--)
3179+ {
3180+ same = xRefs[i] === yRefs[i];
3181+ }
3182+ if (same)
3183+ {
3184+ y.k = x.k;
3185+ return;
3186+ }
3187+ y.k = y.m();
3188+ var subPatches = [];
3189+ _VirtualDom_diffHelp(x.k, y.k, subPatches, 0);
3190+ subPatches.length > 0 && _VirtualDom_pushPatch(patches, 1, index, subPatches);
3191+ return;
3192+
3193+ case 4:
3194+ // gather nested taggers
3195+ var xTaggers = x.j;
3196+ var yTaggers = y.j;
3197+ var nesting = false;
3198+
3199+ var xSubNode = x.k;
3200+ while (xSubNode.$ === 4)
3201+ {
3202+ nesting = true;
3203+
3204+ typeof xTaggers !== 'object'
3205+ ? xTaggers = [xTaggers, xSubNode.j]
3206+ : xTaggers.push(xSubNode.j);
3207+
3208+ xSubNode = xSubNode.k;
3209+ }
3210+
3211+ var ySubNode = y.k;
3212+ while (ySubNode.$ === 4)
3213+ {
3214+ nesting = true;
3215+
3216+ typeof yTaggers !== 'object'
3217+ ? yTaggers = [yTaggers, ySubNode.j]
3218+ : yTaggers.push(ySubNode.j);
3219+
3220+ ySubNode = ySubNode.k;
3221+ }
3222+
3223+ // Just bail if different numbers of taggers. This implies the
3224+ // structure of the virtual DOM has changed.
3225+ if (nesting && xTaggers.length !== yTaggers.length)
3226+ {
3227+ _VirtualDom_pushPatch(patches, 0, index, y);
3228+ return;
3229+ }
3230+
3231+ // check if taggers are "the same"
3232+ if (nesting ? !_VirtualDom_pairwiseRefEqual(xTaggers, yTaggers) : xTaggers !== yTaggers)
3233+ {
3234+ _VirtualDom_pushPatch(patches, 2, index, yTaggers);
3235+ }
3236+
3237+ // diff everything below the taggers
3238+ _VirtualDom_diffHelp(xSubNode, ySubNode, patches, index + 1);
3239+ return;
3240+
3241+ case 0:
3242+ if (x.a !== y.a)
3243+ {
3244+ _VirtualDom_pushPatch(patches, 3, index, y.a);
3245+ }
3246+ return;
3247+
3248+ case 1:
3249+ _VirtualDom_diffNodes(x, y, patches, index, _VirtualDom_diffKids);
3250+ return;
3251+
3252+ case 2:
3253+ _VirtualDom_diffNodes(x, y, patches, index, _VirtualDom_diffKeyedKids);
3254+ return;
3255+
3256+ case 3:
3257+ if (x.h !== y.h)
3258+ {
3259+ _VirtualDom_pushPatch(patches, 0, index, y);
3260+ return;
3261+ }
3262+
3263+ var factsDiff = _VirtualDom_diffFacts(x.d, y.d);
3264+ factsDiff && _VirtualDom_pushPatch(patches, 4, index, factsDiff);
3265+
3266+ var patch = y.i(x.g, y.g);
3267+ patch && _VirtualDom_pushPatch(patches, 5, index, patch);
3268+
3269+ return;
3270+ }
3271+}
3272+
3273+// assumes the incoming arrays are the same length
3274+function _VirtualDom_pairwiseRefEqual(as, bs)
3275+{
3276+ for (var i = 0; i < as.length; i++)
3277+ {
3278+ if (as[i] !== bs[i])
3279+ {
3280+ return false;
3281+ }
3282+ }
3283+
3284+ return true;
3285+}
3286+
3287+function _VirtualDom_diffNodes(x, y, patches, index, diffKids)
3288+{
3289+ // Bail if obvious indicators have changed. Implies more serious
3290+ // structural changes such that it's not worth it to diff.
3291+ if (x.c !== y.c || x.f !== y.f)
3292+ {
3293+ _VirtualDom_pushPatch(patches, 0, index, y);
3294+ return;
3295+ }
3296+
3297+ var factsDiff = _VirtualDom_diffFacts(x.d, y.d);
3298+ factsDiff && _VirtualDom_pushPatch(patches, 4, index, factsDiff);
3299+
3300+ diffKids(x, y, patches, index);
3301+}
3302+
3303+
3304+
3305+// DIFF FACTS
3306+
3307+
3308+// TODO Instead of creating a new diff object, it's possible to just test if
3309+// there *is* a diff. During the actual patch, do the diff again and make the
3310+// modifications directly. This way, there's no new allocations. Worth it?
3311+function _VirtualDom_diffFacts(x, y, category)
3312+{
3313+ var diff;
3314+
3315+ // look for changes and removals
3316+ for (var xKey in x)
3317+ {
3318+ if (xKey === 'a1' || xKey === 'a0' || xKey === 'a3' || xKey === 'a4')
3319+ {
3320+ var subDiff = _VirtualDom_diffFacts(x[xKey], y[xKey] || {}, xKey);
3321+ if (subDiff)
3322+ {
3323+ diff = diff || {};
3324+ diff[xKey] = subDiff;
3325+ }
3326+ continue;
3327+ }
3328+
3329+ // remove if not in the new facts
3330+ if (!(xKey in y))
3331+ {
3332+ diff = diff || {};
3333+ diff[xKey] =
3334+ !category
3335+ ? (typeof x[xKey] === 'string' ? '' : null)
3336+ :
3337+ (category === 'a1')
3338+ ? ''
3339+ :
3340+ (category === 'a0' || category === 'a3')
3341+ ? undefined
3342+ :
3343+ { f: x[xKey].f, o: undefined };
3344+
3345+ continue;
3346+ }
3347+
3348+ var xValue = x[xKey];
3349+ var yValue = y[xKey];
3350+
3351+ // reference equal, so don't worry about it
3352+ if (xValue === yValue && xKey !== 'value' && xKey !== 'checked'
3353+ || category === 'a0' && _VirtualDom_equalEvents(xValue, yValue))
3354+ {
3355+ continue;
3356+ }
3357+
3358+ diff = diff || {};
3359+ diff[xKey] = yValue;
3360+ }
3361+
3362+ // add new stuff
3363+ for (var yKey in y)
3364+ {
3365+ if (!(yKey in x))
3366+ {
3367+ diff = diff || {};
3368+ diff[yKey] = y[yKey];
3369+ }
3370+ }
3371+
3372+ return diff;
3373+}
3374+
3375+
3376+
3377+// DIFF KIDS
3378+
3379+
3380+function _VirtualDom_diffKids(xParent, yParent, patches, index)
3381+{
3382+ var xKids = xParent.e;
3383+ var yKids = yParent.e;
3384+
3385+ var xLen = xKids.length;
3386+ var yLen = yKids.length;
3387+
3388+ // FIGURE OUT IF THERE ARE INSERTS OR REMOVALS
3389+
3390+ if (xLen > yLen)
3391+ {
3392+ _VirtualDom_pushPatch(patches, 6, index, {
3393+ v: yLen,
3394+ i: xLen - yLen
3395+ });
3396+ }
3397+ else if (xLen < yLen)
3398+ {
3399+ _VirtualDom_pushPatch(patches, 7, index, {
3400+ v: xLen,
3401+ e: yKids
3402+ });
3403+ }
3404+
3405+ // PAIRWISE DIFF EVERYTHING ELSE
3406+
3407+ for (var minLen = xLen < yLen ? xLen : yLen, i = 0; i < minLen; i++)
3408+ {
3409+ var xKid = xKids[i];
3410+ _VirtualDom_diffHelp(xKid, yKids[i], patches, ++index);
3411+ index += xKid.b || 0;
3412+ }
3413+}
3414+
3415+
3416+
3417+// KEYED DIFF
3418+
3419+
3420+function _VirtualDom_diffKeyedKids(xParent, yParent, patches, rootIndex)
3421+{
3422+ var localPatches = [];
3423+
3424+ var changes = {}; // Dict String Entry
3425+ var inserts = []; // Array { index : Int, entry : Entry }
3426+ // type Entry = { tag : String, vnode : VNode, index : Int, data : _ }
3427+
3428+ var xKids = xParent.e;
3429+ var yKids = yParent.e;
3430+ var xLen = xKids.length;
3431+ var yLen = yKids.length;
3432+ var xIndex = 0;
3433+ var yIndex = 0;
3434+
3435+ var index = rootIndex;
3436+
3437+ while (xIndex < xLen && yIndex < yLen)
3438+ {
3439+ var x = xKids[xIndex];
3440+ var y = yKids[yIndex];
3441+
3442+ var xKey = x.a;
3443+ var yKey = y.a;
3444+ var xNode = x.b;
3445+ var yNode = y.b;
3446+
3447+ var newMatch = undefined;
3448+ var oldMatch = undefined;
3449+
3450+ // check if keys match
3451+
3452+ if (xKey === yKey)
3453+ {
3454+ index++;
3455+ _VirtualDom_diffHelp(xNode, yNode, localPatches, index);
3456+ index += xNode.b || 0;
3457+
3458+ xIndex++;
3459+ yIndex++;
3460+ continue;
3461+ }
3462+
3463+ // look ahead 1 to detect insertions and removals.
3464+
3465+ var xNext = xKids[xIndex + 1];
3466+ var yNext = yKids[yIndex + 1];
3467+
3468+ if (xNext)
3469+ {
3470+ var xNextKey = xNext.a;
3471+ var xNextNode = xNext.b;
3472+ oldMatch = yKey === xNextKey;
3473+ }
3474+
3475+ if (yNext)
3476+ {
3477+ var yNextKey = yNext.a;
3478+ var yNextNode = yNext.b;
3479+ newMatch = xKey === yNextKey;
3480+ }
3481+
3482+
3483+ // swap x and y
3484+ if (newMatch && oldMatch)
3485+ {
3486+ index++;
3487+ _VirtualDom_diffHelp(xNode, yNextNode, localPatches, index);
3488+ _VirtualDom_insertNode(changes, localPatches, xKey, yNode, yIndex, inserts);
3489+ index += xNode.b || 0;
3490+
3491+ index++;
3492+ _VirtualDom_removeNode(changes, localPatches, xKey, xNextNode, index);
3493+ index += xNextNode.b || 0;
3494+
3495+ xIndex += 2;
3496+ yIndex += 2;
3497+ continue;
3498+ }
3499+
3500+ // insert y
3501+ if (newMatch)
3502+ {
3503+ index++;
3504+ _VirtualDom_insertNode(changes, localPatches, yKey, yNode, yIndex, inserts);
3505+ _VirtualDom_diffHelp(xNode, yNextNode, localPatches, index);
3506+ index += xNode.b || 0;
3507+
3508+ xIndex += 1;
3509+ yIndex += 2;
3510+ continue;
3511+ }
3512+
3513+ // remove x
3514+ if (oldMatch)
3515+ {
3516+ index++;
3517+ _VirtualDom_removeNode(changes, localPatches, xKey, xNode, index);
3518+ index += xNode.b || 0;
3519+
3520+ index++;
3521+ _VirtualDom_diffHelp(xNextNode, yNode, localPatches, index);
3522+ index += xNextNode.b || 0;
3523+
3524+ xIndex += 2;
3525+ yIndex += 1;
3526+ continue;
3527+ }
3528+
3529+ // remove x, insert y
3530+ if (xNext && xNextKey === yNextKey)
3531+ {
3532+ index++;
3533+ _VirtualDom_removeNode(changes, localPatches, xKey, xNode, index);
3534+ _VirtualDom_insertNode(changes, localPatches, yKey, yNode, yIndex, inserts);
3535+ index += xNode.b || 0;
3536+
3537+ index++;
3538+ _VirtualDom_diffHelp(xNextNode, yNextNode, localPatches, index);
3539+ index += xNextNode.b || 0;
3540+
3541+ xIndex += 2;
3542+ yIndex += 2;
3543+ continue;
3544+ }
3545+
3546+ break;
3547+ }
3548+
3549+ // eat up any remaining nodes with removeNode and insertNode
3550+
3551+ while (xIndex < xLen)
3552+ {
3553+ index++;
3554+ var x = xKids[xIndex];
3555+ var xNode = x.b;
3556+ _VirtualDom_removeNode(changes, localPatches, x.a, xNode, index);
3557+ index += xNode.b || 0;
3558+ xIndex++;
3559+ }
3560+
3561+ while (yIndex < yLen)
3562+ {
3563+ var endInserts = endInserts || [];
3564+ var y = yKids[yIndex];
3565+ _VirtualDom_insertNode(changes, localPatches, y.a, y.b, undefined, endInserts);
3566+ yIndex++;
3567+ }
3568+
3569+ if (localPatches.length > 0 || inserts.length > 0 || endInserts)
3570+ {
3571+ _VirtualDom_pushPatch(patches, 8, rootIndex, {
3572+ w: localPatches,
3573+ x: inserts,
3574+ y: endInserts
3575+ });
3576+ }
3577+}
3578+
3579+
3580+
3581+// CHANGES FROM KEYED DIFF
3582+
3583+
3584+var _VirtualDom_POSTFIX = '_elmW6BL';
3585+
3586+
3587+function _VirtualDom_insertNode(changes, localPatches, key, vnode, yIndex, inserts)
3588+{
3589+ var entry = changes[key];
3590+
3591+ // never seen this key before
3592+ if (!entry)
3593+ {
3594+ entry = {
3595+ c: 0,
3596+ z: vnode,
3597+ r: yIndex,
3598+ s: undefined
3599+ };
3600+
3601+ inserts.push({ r: yIndex, A: entry });
3602+ changes[key] = entry;
3603+
3604+ return;
3605+ }
3606+
3607+ // this key was removed earlier, a match!
3608+ if (entry.c === 1)
3609+ {
3610+ inserts.push({ r: yIndex, A: entry });
3611+
3612+ entry.c = 2;
3613+ var subPatches = [];
3614+ _VirtualDom_diffHelp(entry.z, vnode, subPatches, entry.r);
3615+ entry.r = yIndex;
3616+ entry.s.s = {
3617+ w: subPatches,
3618+ A: entry
3619+ };
3620+
3621+ return;
3622+ }
3623+
3624+ // this key has already been inserted or moved, a duplicate!
3625+ _VirtualDom_insertNode(changes, localPatches, key + _VirtualDom_POSTFIX, vnode, yIndex, inserts);
3626+}
3627+
3628+
3629+function _VirtualDom_removeNode(changes, localPatches, key, vnode, index)
3630+{
3631+ var entry = changes[key];
3632+
3633+ // never seen this key before
3634+ if (!entry)
3635+ {
3636+ var patch = _VirtualDom_pushPatch(localPatches, 9, index, undefined);
3637+
3638+ changes[key] = {
3639+ c: 1,
3640+ z: vnode,
3641+ r: index,
3642+ s: patch
3643+ };
3644+
3645+ return;
3646+ }
3647+
3648+ // this key was inserted earlier, a match!
3649+ if (entry.c === 0)
3650+ {
3651+ entry.c = 2;
3652+ var subPatches = [];
3653+ _VirtualDom_diffHelp(vnode, entry.z, subPatches, index);
3654+
3655+ _VirtualDom_pushPatch(localPatches, 9, index, {
3656+ w: subPatches,
3657+ A: entry
3658+ });
3659+
3660+ return;
3661+ }
3662+
3663+ // this key has already been removed or moved, a duplicate!
3664+ _VirtualDom_removeNode(changes, localPatches, key + _VirtualDom_POSTFIX, vnode, index);
3665+}
3666+
3667+
3668+
3669+// ADD DOM NODES
3670+//
3671+// Each DOM node has an "index" assigned in order of traversal. It is important
3672+// to minimize our crawl over the actual DOM, so these indexes (along with the
3673+// descendantsCount of virtual nodes) let us skip touching entire subtrees of
3674+// the DOM if we know there are no patches there.
3675+
3676+
3677+function _VirtualDom_addDomNodes(domNode, vNode, patches, eventNode)
3678+{
3679+ _VirtualDom_addDomNodesHelp(domNode, vNode, patches, 0, 0, vNode.b, eventNode);
3680+}
3681+
3682+
3683+// assumes `patches` is non-empty and indexes increase monotonically.
3684+function _VirtualDom_addDomNodesHelp(domNode, vNode, patches, i, low, high, eventNode)
3685+{
3686+ var patch = patches[i];
3687+ var index = patch.r;
3688+
3689+ while (index === low)
3690+ {
3691+ var patchType = patch.$;
3692+
3693+ if (patchType === 1)
3694+ {
3695+ _VirtualDom_addDomNodes(domNode, vNode.k, patch.s, eventNode);
3696+ }
3697+ else if (patchType === 8)
3698+ {
3699+ patch.t = domNode;
3700+ patch.u = eventNode;
3701+
3702+ var subPatches = patch.s.w;
3703+ if (subPatches.length > 0)
3704+ {
3705+ _VirtualDom_addDomNodesHelp(domNode, vNode, subPatches, 0, low, high, eventNode);
3706+ }
3707+ }
3708+ else if (patchType === 9)
3709+ {
3710+ patch.t = domNode;
3711+ patch.u = eventNode;
3712+
3713+ var data = patch.s;
3714+ if (data)
3715+ {
3716+ data.A.s = domNode;
3717+ var subPatches = data.w;
3718+ if (subPatches.length > 0)
3719+ {
3720+ _VirtualDom_addDomNodesHelp(domNode, vNode, subPatches, 0, low, high, eventNode);
3721+ }
3722+ }
3723+ }
3724+ else
3725+ {
3726+ patch.t = domNode;
3727+ patch.u = eventNode;
3728+ }
3729+
3730+ i++;
3731+
3732+ if (!(patch = patches[i]) || (index = patch.r) > high)
3733+ {
3734+ return i;
3735+ }
3736+ }
3737+
3738+ var tag = vNode.$;
3739+
3740+ if (tag === 4)
3741+ {
3742+ var subNode = vNode.k;
3743+
3744+ while (subNode.$ === 4)
3745+ {
3746+ subNode = subNode.k;
3747+ }
3748+
3749+ return _VirtualDom_addDomNodesHelp(domNode, subNode, patches, i, low + 1, high, _VirtualDom_getMeta(domNode).elm_event_node_ref);
3750+ }
3751+
3752+ // tag must be 1 or 2 at this point
3753+
3754+ var vKids = vNode.e;
3755+ var childNodes = _Lynx_getChildren(domNode);
3756+ for (var j = 0; j < vKids.length; j++)
3757+ {
3758+ low++;
3759+ var vKid = tag === 1 ? vKids[j] : vKids[j].b;
3760+ var nextLow = low + (vKid.b || 0);
3761+ if (low <= index && index <= nextLow)
3762+ {
3763+ i = _VirtualDom_addDomNodesHelp(childNodes[j], vKid, patches, i, low, nextLow, eventNode);
3764+ if (!(patch = patches[i]) || (index = patch.r) > high)
3765+ {
3766+ return i;
3767+ }
3768+ }
3769+ low = nextLow;
3770+ }
3771+ return i;
3772+}
3773+
3774+
3775+
3776+// APPLY PATCHES
3777+
3778+
3779+function _VirtualDom_applyPatches(rootDomNode, oldVirtualNode, patches, eventNode)
3780+{
3781+ if (patches.length === 0)
3782+ {
3783+ return rootDomNode;
3784+ }
3785+
3786+ _VirtualDom_addDomNodes(rootDomNode, oldVirtualNode, patches, eventNode);
3787+ return _VirtualDom_applyPatchesHelp(rootDomNode, patches);
3788+}
3789+
3790+function _VirtualDom_applyPatchesHelp(rootDomNode, patches)
3791+{
3792+ for (var i = 0; i < patches.length; i++)
3793+ {
3794+ var patch = patches[i];
3795+ var localDomNode = patch.t
3796+ var newNode = _VirtualDom_applyPatch(localDomNode, patch);
3797+ if (localDomNode === rootDomNode)
3798+ {
3799+ rootDomNode = newNode;
3800+ }
3801+ }
3802+ return rootDomNode;
3803+}
3804+
3805+function _VirtualDom_applyPatch(domNode, patch)
3806+{
3807+ switch (patch.$)
3808+ {
3809+ case 0:
3810+ return _VirtualDom_applyPatchRedraw(domNode, patch.s, patch.u);
3811+
3812+ case 4:
3813+ _VirtualDom_applyFacts(domNode, patch.u, patch.s);
3814+ return domNode;
3815+
3816+ case 3:
3817+ _Lynx_setAttribute(domNode, 'text', patch.s);
3818+ return domNode;
3819+
3820+ case 1:
3821+ return _VirtualDom_applyPatchesHelp(domNode, patch.s);
3822+
3823+ case 2:
3824+ if (_VirtualDom_getMeta(domNode).elm_event_node_ref)
3825+ {
3826+ _VirtualDom_getMeta(domNode).elm_event_node_ref.j = patch.s;
3827+ }
3828+ else
3829+ {
3830+ _VirtualDom_getMeta(domNode).elm_event_node_ref = { j: patch.s, p: patch.u };
3831+ }
3832+ return domNode;
3833+
3834+ case 6:
3835+ var data = patch.s;
3836+ for (var i = 0; i < data.i; i++)
3837+ {
3838+ var children = _Lynx_getChildren(domNode);
3839+ _Lynx_removeElement(domNode, children[data.v]);
3840+ }
3841+ return domNode;
3842+
3843+ case 7:
3844+ var data = patch.s;
3845+ var kids = data.e;
3846+ for (var i = data.v; i < kids.length; i++)
3847+ {
3848+ _Lynx_appendChild(domNode, _VirtualDom_render(kids[i], patch.u));
3849+ }
3850+ return domNode;
3851+
3852+ case 9:
3853+ var data = patch.s;
3854+ if (!data)
3855+ {
3856+ _Lynx_removeElement(_Lynx_getParent(domNode), domNode);
3857+ return domNode;
3858+ }
3859+ var entry = data.A;
3860+ if (typeof entry.r !== 'undefined')
3861+ {
3862+ _Lynx_removeElement(_Lynx_getParent(domNode), domNode);
3863+ }
3864+ entry.s = _VirtualDom_applyPatchesHelp(domNode, data.w);
3865+ return domNode;
3866+
3867+ case 8:
3868+ return _VirtualDom_applyPatchReorder(domNode, patch);
3869+
3870+ case 5:
3871+ return patch.s(domNode);
3872+
3873+ default:
3874+ throw new Error('VirtualDom: unknown patch type');
3875+ }
3876+}
3877+
3878+
3879+function _VirtualDom_applyPatchRedraw(domNode, vNode, eventNode)
3880+{
3881+ var parentNode = _Lynx_getParent(domNode);
3882+ var newNode = _VirtualDom_render(vNode, eventNode);
3883+
3884+ if (!_VirtualDom_getMeta(newNode).elm_event_node_ref)
3885+ {
3886+ _VirtualDom_getMeta(newNode).elm_event_node_ref = _VirtualDom_getMeta(domNode).elm_event_node_ref;
3887+ }
3888+
3889+ if (parentNode && newNode !== domNode)
3890+ {
3891+ _Lynx_replaceElement(parentNode, newNode, domNode);
3892+ }
3893+ return newNode;
3894+}
3895+
3896+
3897+function _VirtualDom_applyPatchReorder(domNode, patch)
3898+{
3899+ var data = patch.s;
3900+
3901+ // remove end inserts
3902+ var endInsertNodes = _VirtualDom_applyPatchReorderEndInsertsHelp(data.y, patch);
3903+
3904+ // removals
3905+ domNode = _VirtualDom_applyPatchesHelp(domNode, data.w);
3906+
3907+ // inserts
3908+ var inserts = data.x;
3909+ for (var i = 0; i < inserts.length; i++)
3910+ {
3911+ var insert = inserts[i];
3912+ var entry = insert.A;
3913+ var node = entry.c === 2
3914+ ? entry.s
3915+ : _VirtualDom_render(entry.z, patch.u);
3916+ var children = _Lynx_getChildren(domNode);
3917+ _Lynx_insertBefore(domNode, node, children[insert.r]);
3918+ }
3919+
3920+ // add end inserts
3921+ if (endInsertNodes)
3922+ {
3923+ for (var i = 0; i < endInsertNodes.length; i++)
3924+ {
3925+ _Lynx_appendChild(domNode, endInsertNodes[i]);
3926+ }
3927+ }
3928+
3929+ return domNode;
3930+}
3931+
3932+
3933+function _VirtualDom_applyPatchReorderEndInsertsHelp(endInserts, patch)
3934+{
3935+ if (!endInserts)
3936+ {
3937+ return;
3938+ }
3939+
3940+ var nodes = [];
3941+ for (var i = 0; i < endInserts.length; i++)
3942+ {
3943+ var insert = endInserts[i];
3944+ var entry = insert.A;
3945+ nodes.push(entry.c === 2
3946+ ? entry.s
3947+ : _VirtualDom_render(entry.z, patch.u)
3948+ );
3949+ }
3950+ return nodes;
3951+}
3952+
3953+
3954+function _VirtualDom_dekey(keyedNode)
3955+{
3956+ var keyedKids = keyedNode.e;
3957+ var len = keyedKids.length;
3958+ var kids = new Array(len);
3959+ for (var i = 0; i < len; i++)
3960+ {
3961+ kids[i] = keyedKids[i].b;
3962+ }
3963+
3964+ return {
3965+ $: 1,
3966+ c: keyedNode.c,
3967+ d: keyedNode.d,
3968+ e: kids,
3969+ f: keyedNode.f,
3970+ b: keyedNode.b
3971+ };
3972+}
3973+
3974+
3975+
3976+// LYNXJS PAPI WRAPPERS
3977+var _Browser_lynx = (typeof globalThis !== 'undefined' ? globalThis : scope);
3978+function _Browser_newPage() {
3979+ return _Browser_lynx['page'];
3980+}
3981+function _Browser_flush() {
3982+ var fn = _Browser_lynx['_' + '_FlushElementTree'];
3983+ if (typeof fn === 'function') { fn(); }
3984+}
3985+
3986+
3987+
3988+// ELEMENT
3989+
3990+
3991+var _Browser_element = F4(function(impl, flagDecoder, debugMetadata, args)
3992+{
3993+ return _Platform_initialize(
3994+ flagDecoder,
3995+ args,
3996+ impl.init,
3997+ impl.update,
3998+ impl.subscriptions,
3999+ function(sendToApp, initialModel) {
4000+ var view = impl.view;
4001+ var domNode = args['node'] || _Browser_newPage();
4002+ var currNode = view(initialModel);
4003+ var currDomNode = _VirtualDom_render(currNode, sendToApp);
4004+ _VirtualDom_appendChild(domNode, currDomNode);
4005+ _Browser_flush();
4006+
4007+ return _Browser_makeAnimator(initialModel, function(model)
4008+ {
4009+ var nextNode = view(model);
4010+ var patches = _VirtualDom_diff(currNode, nextNode);
4011+ currDomNode = _VirtualDom_applyPatches(currDomNode, currNode, patches, sendToApp);
4012+ currNode = nextNode;
4013+ _Browser_flush();
4014+ });
4015+ }
4016+ );
4017+});
4018+
4019+
4020+
4021+// DOCUMENT
4022+
4023+
4024+var _Browser_document = F4(function(impl, flagDecoder, debugMetadata, args)
4025+{
4026+ return _Platform_initialize(
4027+ flagDecoder,
4028+ args,
4029+ impl.init,
4030+ impl.update,
4031+ impl.subscriptions,
4032+ function(sendToApp, initialModel) {
4033+ var view = impl.view;
4034+ var rootNode = args['node'] || _Browser_newPage();
4035+ var doc = view(initialModel);
4036+ var currNode = _VirtualDom_node('view')(_List_Nil)(doc.body);
4037+ var currDomNode = _VirtualDom_render(currNode, sendToApp);
4038+ _VirtualDom_appendChild(rootNode, currDomNode);
4039+ _Browser_flush();
4040+
4041+ return _Browser_makeAnimator(initialModel, function(model)
4042+ {
4043+ var doc = view(model);
4044+ var nextNode = _VirtualDom_node('view')(_List_Nil)(doc.body);
4045+ var patches = _VirtualDom_diff(currNode, nextNode);
4046+ currDomNode = _VirtualDom_applyPatches(currDomNode, currNode, patches, sendToApp);
4047+ currNode = nextNode;
4048+ _Browser_flush();
4049+ });
4050+ }
4051+ );
4052+});
4053+
4054+
4055+
4056+// ANIMATION
4057+
4058+
4059+var _Browser_cancelAnimationFrame =
4060+ function(id) { clearTimeout(id); };
4061+
4062+var _Browser_requestAnimationFrame =
4063+ function(callback) { return setTimeout(callback, 1000 / 60); };
4064+
4065+
4066+function _Browser_makeAnimator(model, draw)
4067+{
4068+ draw(model);
4069+
4070+ var state = 0;
4071+
4072+ function updateIfNeeded()
4073+ {
4074+ state = state === 1
4075+ ? 0
4076+ : ( _Browser_requestAnimationFrame(updateIfNeeded), draw(model), 1 );
4077+ }
4078+
4079+ return function(nextModel, isSync)
4080+ {
4081+ model = nextModel;
4082+
4083+ isSync
4084+ ? ( draw(model),
4085+ state === 2 && (state = 1)
4086+ )
4087+ : ( state === 0 && _Browser_requestAnimationFrame(updateIfNeeded),
4088+ state = 2
4089+ );
4090+ };
4091+}
4092+
4093+
4094+
4095+// APPLICATION
4096+
4097+
4098+function _Browser_application(impl)
4099+{
4100+ return _Browser_document({
4101+ init: function(flags)
4102+ {
4103+ return A3(impl.init, flags, _Browser_fakeUrl(), {});
4104+ },
4105+ view: impl.view,
4106+ update: impl.update,
4107+ subscriptions: impl.subscriptions
4108+ });
4109+}
4110+
4111+function _Browser_fakeUrl()
4112+{
4113+ return {
4114+ protocol: { $: 0 },
4115+ host: 'localhost',
4116+ port_: { $: 1 },
4117+ path: '/',
4118+ query: { $: 1 },
4119+ fragment: { $: 1 }
4120+ };
4121+}
4122+
4123+
4124+
4125+var _Browser_go = F2(function(key, n)
4126+{
4127+ return A2($elm$core$Task$perform, $elm$core$Basics$never, _Scheduler_binding(function() {
4128+ // no-op in LynxJS
4129+ key();
4130+ }));
4131+});
4132+
4133+var _Browser_pushUrl = F2(function(key, url)
4134+{
4135+ return A2($elm$core$Task$perform, $elm$core$Basics$never, _Scheduler_binding(function() {
4136+ // no-op in LynxJS
4137+ key();
4138+ }));
4139+});
4140+
4141+var _Browser_replaceUrl = F2(function(key, url)
4142+{
4143+ return A2($elm$core$Task$perform, $elm$core$Basics$never, _Scheduler_binding(function() {
4144+ // no-op in LynxJS
4145+ key();
4146+ }));
4147+});
4148+
4149+
4150+
4151+// GLOBAL EVENTS
4152+
4153+
4154+var _Browser_fakeNode = { addEventListener: function() {}, removeEventListener: function() {} };
4155+var _Browser_doc = typeof document !== 'undefined' ? document : _Browser_fakeNode;
4156+var _Browser_window = typeof window !== 'undefined' ? window : _Browser_fakeNode;
4157+
4158+var _Browser_on = F3(function(node, eventName, sendToSelf)
4159+{
4160+ return _Scheduler_spawn(_Scheduler_binding(function(callback)
4161+ {
4162+ return function() {};
4163+ }));
4164+});
4165+
4166+var _Browser_decodeEvent = F2(function(decoder, event)
4167+{
4168+ var result = _Json_runHelp(decoder, event);
4169+ return $elm$core$Result$isOk(result) ? $elm$core$Maybe$Just(result.a) : $elm$core$Maybe$Nothing;
4170+});
4171+
4172+
4173+
4174+// PAGE VISIBILITY
4175+
4176+
4177+function _Browser_visibilityInfo()
4178+{
4179+ return (typeof _VirtualDom_doc.hidden !== 'undefined')
4180+ ? { hidden: 'hidden', change: 'visibilitychange' }
4181+ :
4182+ (typeof _VirtualDom_doc.mozHidden !== 'undefined')
4183+ ? { hidden: 'mozHidden', change: 'mozvisibilitychange' }
4184+ :
4185+ (typeof _VirtualDom_doc.msHidden !== 'undefined')
4186+ ? { hidden: 'msHidden', change: 'msvisibilitychange' }
4187+ :
4188+ (typeof _VirtualDom_doc.webkitHidden !== 'undefined')
4189+ ? { hidden: 'webkitHidden', change: 'webkitvisibilitychange' }
4190+ : { hidden: 'hidden', change: 'visibilitychange' };
4191+}
4192+
4193+
4194+
4195+// ANIMATION FRAMES
4196+
4197+
4198+function _Browser_rAF()
4199+{
4200+ return _Scheduler_binding(function(callback)
4201+ {
4202+ var id = _Browser_requestAnimationFrame(function() {
4203+ callback(_Scheduler_succeed(Date.now()));
4204+ });
4205+
4206+ return function() {
4207+ _Browser_cancelAnimationFrame(id);
4208+ };
4209+ });
4210+}
4211+
4212+
4213+function _Browser_now()
4214+{
4215+ return _Scheduler_binding(function(callback)
4216+ {
4217+ callback(_Scheduler_succeed(Date.now()));
4218+ });
4219+}
4220+
4221+
4222+
4223+// DOM STUFF
4224+
4225+
4226+function _Browser_withNode(id, doStuff)
4227+{
4228+ return _Scheduler_binding(function(callback)
4229+ {
4230+ callback(_Scheduler_fail($lynxjs_elm$browser$Browser$Dom$NotFound(id)));
4231+ });
4232+}
4233+
4234+
4235+function _Browser_withWindow(doStuff)
4236+{
4237+ return _Scheduler_binding(function(callback)
4238+ {
4239+ _Browser_requestAnimationFrame(function() {
4240+ callback(_Scheduler_succeed(doStuff()));
4241+ });
4242+ });
4243+}
4244+
4245+
4246+// FOCUS and BLUR
4247+
4248+
4249+var _Browser_call = F2(function(functionName, id)
4250+{
4251+ return _Browser_withNode(id, function(node) {
4252+ node[functionName]();
4253+ return _Utils_Tuple0;
4254+ });
4255+});
4256+
4257+
4258+
4259+// WINDOW VIEWPORT
4260+
4261+
4262+function _Browser_getViewport()
4263+{
4264+ return {
4265+ scene: _Browser_getScene(),
4266+ viewport: {
4267+ x: _Browser_window.pageXOffset,
4268+ y: _Browser_window.pageYOffset,
4269+ width: _Browser_doc.documentElement.clientWidth,
4270+ height: _Browser_doc.documentElement.clientHeight
4271+ }
4272+ };
4273+}
4274+
4275+function _Browser_getScene()
4276+{
4277+ var body = _Browser_doc.body;
4278+ var elem = _Browser_doc.documentElement;
4279+ return {
4280+ width: Math.max(body.scrollWidth, body.offsetWidth, elem.scrollWidth, elem.offsetWidth, elem.clientWidth),
4281+ height: Math.max(body.scrollHeight, body.offsetHeight, elem.scrollHeight, elem.offsetHeight, elem.clientHeight)
4282+ };
4283+}
4284+
4285+var _Browser_setViewport = F2(function(x, y)
4286+{
4287+ return _Browser_withWindow(function()
4288+ {
4289+ _Browser_window.scroll(x, y);
4290+ return _Utils_Tuple0;
4291+ });
4292+});
4293+
4294+
4295+
4296+// ELEMENT VIEWPORT
4297+
4298+
4299+function _Browser_getViewportOf(id)
4300+{
4301+ return _Browser_withNode(id, function(node)
4302+ {
4303+ return {
4304+ scene: {
4305+ width: node.scrollWidth,
4306+ height: node.scrollHeight
4307+ },
4308+ viewport: {
4309+ x: node.scrollLeft,
4310+ y: node.scrollTop,
4311+ width: node.clientWidth,
4312+ height: node.clientHeight
4313+ }
4314+ };
4315+ });
4316+}
4317+
4318+
4319+var _Browser_setViewportOf = F3(function(id, x, y)
4320+{
4321+ return _Browser_withNode(id, function(node)
4322+ {
4323+ node.scrollLeft = x;
4324+ node.scrollTop = y;
4325+ return _Utils_Tuple0;
4326+ });
4327+});
4328+
4329+
4330+
4331+// ELEMENT
4332+
4333+
4334+function _Browser_getElement(id)
4335+{
4336+ return _Browser_withNode(id, function(node)
4337+ {
4338+ var rect = node.getBoundingClientRect();
4339+ var x = _Browser_window.pageXOffset;
4340+ var y = _Browser_window.pageYOffset;
4341+ return {
4342+ scene: _Browser_getScene(),
4343+ viewport: {
4344+ x: x,
4345+ y: y,
4346+ width: _Browser_doc.documentElement.clientWidth,
4347+ height: _Browser_doc.documentElement.clientHeight
4348+ },
4349+ element: {
4350+ x: x + rect.left,
4351+ y: y + rect.top,
4352+ width: rect.width,
4353+ height: rect.height
4354+ }
4355+ };
4356+ });
4357+}
4358+
4359+
4360+
4361+// LOAD and RELOAD
4362+
4363+
4364+function _Browser_reload(skipCache)
4365+{
4366+ return A2($elm$core$Task$perform, $elm$core$Basics$never, _Scheduler_binding(function(callback)
4367+ {
4368+ // no-op in LynxJS
4369+ }));
4370+}
4371+
4372+function _Browser_load(url)
4373+{
4374+ return A2($elm$core$Task$perform, $elm$core$Basics$never, _Scheduler_binding(function(callback)
4375+ {
4376+ try
4377+ {
4378+ // no-op in LynxJS
4379+ }
4380+ catch(err)
4381+ {
4382+ // Only Firefox can throw a NS_ERROR_MALFORMED_URI exception here.
4383+ // Other browsers reload the page, so let's be consistent about that.
4384+ // no-op in LynxJS
4385+ }
4386+ }));
4387+}
4388+var $author$project$Main$init = {count: 0};
4389+var $elm$core$List$cons = _List_cons;
4390+var $elm$core$Elm$JsArray$foldr = _JsArray_foldr;
4391+var $elm$core$Array$foldr = F3(
4392+ function (func, baseCase, _v0) {
4393+ var tree = _v0.c;
4394+ var tail = _v0.d;
4395+ var helper = F2(
4396+ function (node, acc) {
4397+ if (node.$ === 'SubTree') {
4398+ var subTree = node.a;
4399+ return A3($elm$core$Elm$JsArray$foldr, helper, acc, subTree);
4400+ } else {
4401+ var values = node.a;
4402+ return A3($elm$core$Elm$JsArray$foldr, func, acc, values);
4403+ }
4404+ });
4405+ return A3(
4406+ $elm$core$Elm$JsArray$foldr,
4407+ helper,
4408+ A3($elm$core$Elm$JsArray$foldr, func, baseCase, tail),
4409+ tree);
4410+ });
4411+var $elm$core$Array$toList = function (array) {
4412+ return A3($elm$core$Array$foldr, $elm$core$List$cons, _List_Nil, array);
4413+};
4414+var $elm$core$Dict$foldr = F3(
4415+ function (func, acc, t) {
4416+ foldr:
4417+ while (true) {
4418+ if (t.$ === 'RBEmpty_elm_builtin') {
4419+ return acc;
4420+ } else {
4421+ var key = t.b;
4422+ var value = t.c;
4423+ var left = t.d;
4424+ var right = t.e;
4425+ var $temp$func = func,
4426+ $temp$acc = A3(
4427+ func,
4428+ key,
4429+ value,
4430+ A3($elm$core$Dict$foldr, func, acc, right)),
4431+ $temp$t = left;
4432+ func = $temp$func;
4433+ acc = $temp$acc;
4434+ t = $temp$t;
4435+ continue foldr;
4436+ }
4437+ }
4438+ });
4439+var $elm$core$Dict$toList = function (dict) {
4440+ return A3(
4441+ $elm$core$Dict$foldr,
4442+ F3(
4443+ function (key, value, list) {
4444+ return A2(
4445+ $elm$core$List$cons,
4446+ _Utils_Tuple2(key, value),
4447+ list);
4448+ }),
4449+ _List_Nil,
4450+ dict);
4451+};
4452+var $elm$core$Dict$keys = function (dict) {
4453+ return A3(
4454+ $elm$core$Dict$foldr,
4455+ F3(
4456+ function (key, value, keyList) {
4457+ return A2($elm$core$List$cons, key, keyList);
4458+ }),
4459+ _List_Nil,
4460+ dict);
4461+};
4462+var $elm$core$Set$toList = function (_v0) {
4463+ var dict = _v0.a;
4464+ return $elm$core$Dict$keys(dict);
4465+};
4466+var $elm$core$Basics$EQ = {$: 'EQ'};
4467+var $elm$core$Basics$GT = {$: 'GT'};
4468+var $elm$core$Basics$LT = {$: 'LT'};
4469+var $elm$core$Result$Err = function (a) {
4470+ return {$: 'Err', a: a};
4471+};
4472+var $elm$json$Json$Decode$Failure = F2(
4473+ function (a, b) {
4474+ return {$: 'Failure', a: a, b: b};
4475+ });
4476+var $elm$json$Json$Decode$Field = F2(
4477+ function (a, b) {
4478+ return {$: 'Field', a: a, b: b};
4479+ });
4480+var $elm$json$Json$Decode$Index = F2(
4481+ function (a, b) {
4482+ return {$: 'Index', a: a, b: b};
4483+ });
4484+var $elm$core$Result$Ok = function (a) {
4485+ return {$: 'Ok', a: a};
4486+};
4487+var $elm$json$Json$Decode$OneOf = function (a) {
4488+ return {$: 'OneOf', a: a};
4489+};
4490+var $elm$core$Basics$False = {$: 'False'};
4491+var $elm$core$Basics$add = _Basics_add;
4492+var $elm$core$Maybe$Just = function (a) {
4493+ return {$: 'Just', a: a};
4494+};
4495+var $elm$core$Maybe$Nothing = {$: 'Nothing'};
4496+var $elm$core$String$all = _String_all;
4497+var $elm$core$Basics$and = _Basics_and;
4498+var $elm$core$Basics$append = _Utils_append;
4499+var $elm$json$Json$Encode$encode = _Json_encode;
4500+var $elm$core$String$fromInt = _String_fromNumber;
4501+var $elm$core$String$join = F2(
4502+ function (sep, chunks) {
4503+ return A2(
4504+ _String_join,
4505+ sep,
4506+ _List_toArray(chunks));
4507+ });
4508+var $elm$core$String$split = F2(
4509+ function (sep, string) {
4510+ return _List_fromArray(
4511+ A2(_String_split, sep, string));
4512+ });
4513+var $elm$json$Json$Decode$indent = function (str) {
4514+ return A2(
4515+ $elm$core$String$join,
4516+ '\n ',
4517+ A2($elm$core$String$split, '\n', str));
4518+};
4519+var $elm$core$List$foldl = F3(
4520+ function (func, acc, list) {
4521+ foldl:
4522+ while (true) {
4523+ if (!list.b) {
4524+ return acc;
4525+ } else {
4526+ var x = list.a;
4527+ var xs = list.b;
4528+ var $temp$func = func,
4529+ $temp$acc = A2(func, x, acc),
4530+ $temp$list = xs;
4531+ func = $temp$func;
4532+ acc = $temp$acc;
4533+ list = $temp$list;
4534+ continue foldl;
4535+ }
4536+ }
4537+ });
4538+var $elm$core$List$length = function (xs) {
4539+ return A3(
4540+ $elm$core$List$foldl,
4541+ F2(
4542+ function (_v0, i) {
4543+ return i + 1;
4544+ }),
4545+ 0,
4546+ xs);
4547+};
4548+var $elm$core$List$map2 = _List_map2;
4549+var $elm$core$Basics$le = _Utils_le;
4550+var $elm$core$Basics$sub = _Basics_sub;
4551+var $elm$core$List$rangeHelp = F3(
4552+ function (lo, hi, list) {
4553+ rangeHelp:
4554+ while (true) {
4555+ if (_Utils_cmp(lo, hi) < 1) {
4556+ var $temp$lo = lo,
4557+ $temp$hi = hi - 1,
4558+ $temp$list = A2($elm$core$List$cons, hi, list);
4559+ lo = $temp$lo;
4560+ hi = $temp$hi;
4561+ list = $temp$list;
4562+ continue rangeHelp;
4563+ } else {
4564+ return list;
4565+ }
4566+ }
4567+ });
4568+var $elm$core$List$range = F2(
4569+ function (lo, hi) {
4570+ return A3($elm$core$List$rangeHelp, lo, hi, _List_Nil);
4571+ });
4572+var $elm$core$List$indexedMap = F2(
4573+ function (f, xs) {
4574+ return A3(
4575+ $elm$core$List$map2,
4576+ f,
4577+ A2(
4578+ $elm$core$List$range,
4579+ 0,
4580+ $elm$core$List$length(xs) - 1),
4581+ xs);
4582+ });
4583+var $elm$core$Char$toCode = _Char_toCode;
4584+var $elm$core$Char$isLower = function (_char) {
4585+ var code = $elm$core$Char$toCode(_char);
4586+ return (97 <= code) && (code <= 122);
4587+};
4588+var $elm$core$Char$isUpper = function (_char) {
4589+ var code = $elm$core$Char$toCode(_char);
4590+ return (code <= 90) && (65 <= code);
4591+};
4592+var $elm$core$Basics$or = _Basics_or;
4593+var $elm$core$Char$isAlpha = function (_char) {
4594+ return $elm$core$Char$isLower(_char) || $elm$core$Char$isUpper(_char);
4595+};
4596+var $elm$core$Char$isDigit = function (_char) {
4597+ var code = $elm$core$Char$toCode(_char);
4598+ return (code <= 57) && (48 <= code);
4599+};
4600+var $elm$core$Char$isAlphaNum = function (_char) {
4601+ return $elm$core$Char$isLower(_char) || ($elm$core$Char$isUpper(_char) || $elm$core$Char$isDigit(_char));
4602+};
4603+var $elm$core$List$reverse = function (list) {
4604+ return A3($elm$core$List$foldl, $elm$core$List$cons, _List_Nil, list);
4605+};
4606+var $elm$core$String$uncons = _String_uncons;
4607+var $elm$json$Json$Decode$errorOneOf = F2(
4608+ function (i, error) {
4609+ return '\n\n(' + ($elm$core$String$fromInt(i + 1) + (') ' + $elm$json$Json$Decode$indent(
4610+ $elm$json$Json$Decode$errorToString(error))));
4611+ });
4612+var $elm$json$Json$Decode$errorToString = function (error) {
4613+ return A2($elm$json$Json$Decode$errorToStringHelp, error, _List_Nil);
4614+};
4615+var $elm$json$Json$Decode$errorToStringHelp = F2(
4616+ function (error, context) {
4617+ errorToStringHelp:
4618+ while (true) {
4619+ switch (error.$) {
4620+ case 'Field':
4621+ var f = error.a;
4622+ var err = error.b;
4623+ var isSimple = function () {
4624+ var _v1 = $elm$core$String$uncons(f);
4625+ if (_v1.$ === 'Nothing') {
4626+ return false;
4627+ } else {
4628+ var _v2 = _v1.a;
4629+ var _char = _v2.a;
4630+ var rest = _v2.b;
4631+ return $elm$core$Char$isAlpha(_char) && A2($elm$core$String$all, $elm$core$Char$isAlphaNum, rest);
4632+ }
4633+ }();
4634+ var fieldName = isSimple ? ('.' + f) : ('[\'' + (f + '\']'));
4635+ var $temp$error = err,
4636+ $temp$context = A2($elm$core$List$cons, fieldName, context);
4637+ error = $temp$error;
4638+ context = $temp$context;
4639+ continue errorToStringHelp;
4640+ case 'Index':
4641+ var i = error.a;
4642+ var err = error.b;
4643+ var indexName = '[' + ($elm$core$String$fromInt(i) + ']');
4644+ var $temp$error = err,
4645+ $temp$context = A2($elm$core$List$cons, indexName, context);
4646+ error = $temp$error;
4647+ context = $temp$context;
4648+ continue errorToStringHelp;
4649+ case 'OneOf':
4650+ var errors = error.a;
4651+ if (!errors.b) {
4652+ return 'Ran into a Json.Decode.oneOf with no possibilities' + function () {
4653+ if (!context.b) {
4654+ return '!';
4655+ } else {
4656+ return ' at json' + A2(
4657+ $elm$core$String$join,
4658+ '',
4659+ $elm$core$List$reverse(context));
4660+ }
4661+ }();
4662+ } else {
4663+ if (!errors.b.b) {
4664+ var err = errors.a;
4665+ var $temp$error = err,
4666+ $temp$context = context;
4667+ error = $temp$error;
4668+ context = $temp$context;
4669+ continue errorToStringHelp;
4670+ } else {
4671+ var starter = function () {
4672+ if (!context.b) {
4673+ return 'Json.Decode.oneOf';
4674+ } else {
4675+ return 'The Json.Decode.oneOf at json' + A2(
4676+ $elm$core$String$join,
4677+ '',
4678+ $elm$core$List$reverse(context));
4679+ }
4680+ }();
4681+ var introduction = starter + (' failed in the following ' + ($elm$core$String$fromInt(
4682+ $elm$core$List$length(errors)) + ' ways:'));
4683+ return A2(
4684+ $elm$core$String$join,
4685+ '\n\n',
4686+ A2(
4687+ $elm$core$List$cons,
4688+ introduction,
4689+ A2($elm$core$List$indexedMap, $elm$json$Json$Decode$errorOneOf, errors)));
4690+ }
4691+ }
4692+ default:
4693+ var msg = error.a;
4694+ var json = error.b;
4695+ var introduction = function () {
4696+ if (!context.b) {
4697+ return 'Problem with the given value:\n\n';
4698+ } else {
4699+ return 'Problem with the value at json' + (A2(
4700+ $elm$core$String$join,
4701+ '',
4702+ $elm$core$List$reverse(context)) + ':\n\n ');
4703+ }
4704+ }();
4705+ return introduction + ($elm$json$Json$Decode$indent(
4706+ A2($elm$json$Json$Encode$encode, 4, json)) + ('\n\n' + msg));
4707+ }
4708+ }
4709+ });
4710+var $elm$core$Array$branchFactor = 32;
4711+var $elm$core$Array$Array_elm_builtin = F4(
4712+ function (a, b, c, d) {
4713+ return {$: 'Array_elm_builtin', a: a, b: b, c: c, d: d};
4714+ });
4715+var $elm$core$Elm$JsArray$empty = _JsArray_empty;
4716+var $elm$core$Basics$ceiling = _Basics_ceiling;
4717+var $elm$core$Basics$fdiv = _Basics_fdiv;
4718+var $elm$core$Basics$logBase = F2(
4719+ function (base, number) {
4720+ return _Basics_log(number) / _Basics_log(base);
4721+ });
4722+var $elm$core$Basics$toFloat = _Basics_toFloat;
4723+var $elm$core$Array$shiftStep = $elm$core$Basics$ceiling(
4724+ A2($elm$core$Basics$logBase, 2, $elm$core$Array$branchFactor));
4725+var $elm$core$Array$empty = A4($elm$core$Array$Array_elm_builtin, 0, $elm$core$Array$shiftStep, $elm$core$Elm$JsArray$empty, $elm$core$Elm$JsArray$empty);
4726+var $elm$core$Elm$JsArray$initialize = _JsArray_initialize;
4727+var $elm$core$Array$Leaf = function (a) {
4728+ return {$: 'Leaf', a: a};
4729+};
4730+var $elm$core$Basics$apL = F2(
4731+ function (f, x) {
4732+ return f(x);
4733+ });
4734+var $elm$core$Basics$apR = F2(
4735+ function (x, f) {
4736+ return f(x);
4737+ });
4738+var $elm$core$Basics$eq = _Utils_equal;
4739+var $elm$core$Basics$floor = _Basics_floor;
4740+var $elm$core$Elm$JsArray$length = _JsArray_length;
4741+var $elm$core$Basics$gt = _Utils_gt;
4742+var $elm$core$Basics$max = F2(
4743+ function (x, y) {
4744+ return (_Utils_cmp(x, y) > 0) ? x : y;
4745+ });
4746+var $elm$core$Basics$mul = _Basics_mul;
4747+var $elm$core$Array$SubTree = function (a) {
4748+ return {$: 'SubTree', a: a};
4749+};
4750+var $elm$core$Elm$JsArray$initializeFromList = _JsArray_initializeFromList;
4751+var $elm$core$Array$compressNodes = F2(
4752+ function (nodes, acc) {
4753+ compressNodes:
4754+ while (true) {
4755+ var _v0 = A2($elm$core$Elm$JsArray$initializeFromList, $elm$core$Array$branchFactor, nodes);
4756+ var node = _v0.a;
4757+ var remainingNodes = _v0.b;
4758+ var newAcc = A2(
4759+ $elm$core$List$cons,
4760+ $elm$core$Array$SubTree(node),
4761+ acc);
4762+ if (!remainingNodes.b) {
4763+ return $elm$core$List$reverse(newAcc);
4764+ } else {
4765+ var $temp$nodes = remainingNodes,
4766+ $temp$acc = newAcc;
4767+ nodes = $temp$nodes;
4768+ acc = $temp$acc;
4769+ continue compressNodes;
4770+ }
4771+ }
4772+ });
4773+var $elm$core$Tuple$first = function (_v0) {
4774+ var x = _v0.a;
4775+ return x;
4776+};
4777+var $elm$core$Array$treeFromBuilder = F2(
4778+ function (nodeList, nodeListSize) {
4779+ treeFromBuilder:
4780+ while (true) {
4781+ var newNodeSize = $elm$core$Basics$ceiling(nodeListSize / $elm$core$Array$branchFactor);
4782+ if (newNodeSize === 1) {
4783+ return A2($elm$core$Elm$JsArray$initializeFromList, $elm$core$Array$branchFactor, nodeList).a;
4784+ } else {
4785+ var $temp$nodeList = A2($elm$core$Array$compressNodes, nodeList, _List_Nil),
4786+ $temp$nodeListSize = newNodeSize;
4787+ nodeList = $temp$nodeList;
4788+ nodeListSize = $temp$nodeListSize;
4789+ continue treeFromBuilder;
4790+ }
4791+ }
4792+ });
4793+var $elm$core$Array$builderToArray = F2(
4794+ function (reverseNodeList, builder) {
4795+ if (!builder.nodeListSize) {
4796+ return A4(
4797+ $elm$core$Array$Array_elm_builtin,
4798+ $elm$core$Elm$JsArray$length(builder.tail),
4799+ $elm$core$Array$shiftStep,
4800+ $elm$core$Elm$JsArray$empty,
4801+ builder.tail);
4802+ } else {
4803+ var treeLen = builder.nodeListSize * $elm$core$Array$branchFactor;
4804+ var depth = $elm$core$Basics$floor(
4805+ A2($elm$core$Basics$logBase, $elm$core$Array$branchFactor, treeLen - 1));
4806+ var correctNodeList = reverseNodeList ? $elm$core$List$reverse(builder.nodeList) : builder.nodeList;
4807+ var tree = A2($elm$core$Array$treeFromBuilder, correctNodeList, builder.nodeListSize);
4808+ return A4(
4809+ $elm$core$Array$Array_elm_builtin,
4810+ $elm$core$Elm$JsArray$length(builder.tail) + treeLen,
4811+ A2($elm$core$Basics$max, 5, depth * $elm$core$Array$shiftStep),
4812+ tree,
4813+ builder.tail);
4814+ }
4815+ });
4816+var $elm$core$Basics$idiv = _Basics_idiv;
4817+var $elm$core$Basics$lt = _Utils_lt;
4818+var $elm$core$Array$initializeHelp = F5(
4819+ function (fn, fromIndex, len, nodeList, tail) {
4820+ initializeHelp:
4821+ while (true) {
4822+ if (fromIndex < 0) {
4823+ return A2(
4824+ $elm$core$Array$builderToArray,
4825+ false,
4826+ {nodeList: nodeList, nodeListSize: (len / $elm$core$Array$branchFactor) | 0, tail: tail});
4827+ } else {
4828+ var leaf = $elm$core$Array$Leaf(
4829+ A3($elm$core$Elm$JsArray$initialize, $elm$core$Array$branchFactor, fromIndex, fn));
4830+ var $temp$fn = fn,
4831+ $temp$fromIndex = fromIndex - $elm$core$Array$branchFactor,
4832+ $temp$len = len,
4833+ $temp$nodeList = A2($elm$core$List$cons, leaf, nodeList),
4834+ $temp$tail = tail;
4835+ fn = $temp$fn;
4836+ fromIndex = $temp$fromIndex;
4837+ len = $temp$len;
4838+ nodeList = $temp$nodeList;
4839+ tail = $temp$tail;
4840+ continue initializeHelp;
4841+ }
4842+ }
4843+ });
4844+var $elm$core$Basics$remainderBy = _Basics_remainderBy;
4845+var $elm$core$Array$initialize = F2(
4846+ function (len, fn) {
4847+ if (len <= 0) {
4848+ return $elm$core$Array$empty;
4849+ } else {
4850+ var tailLen = len % $elm$core$Array$branchFactor;
4851+ var tail = A3($elm$core$Elm$JsArray$initialize, tailLen, len - tailLen, fn);
4852+ var initialFromIndex = (len - tailLen) - $elm$core$Array$branchFactor;
4853+ return A5($elm$core$Array$initializeHelp, fn, initialFromIndex, len, _List_Nil, tail);
4854+ }
4855+ });
4856+var $elm$core$Basics$True = {$: 'True'};
4857+var $elm$core$Result$isOk = function (result) {
4858+ if (result.$ === 'Ok') {
4859+ return true;
4860+ } else {
4861+ return false;
4862+ }
4863+};
4864+var $elm$json$Json$Decode$map = _Json_map1;
4865+var $elm$json$Json$Decode$map2 = _Json_map2;
4866+var $elm$json$Json$Decode$succeed = _Json_succeed;
4867+var $lynxjs_elm$virtual_dom$VirtualDom$toHandlerInt = function (handler) {
4868+ switch (handler.$) {
4869+ case 'Normal':
4870+ return 0;
4871+ case 'MayStopPropagation':
4872+ return 1;
4873+ case 'MayPreventDefault':
4874+ return 2;
4875+ default:
4876+ return 3;
4877+ }
4878+};
4879+var $elm$core$Basics$identity = function (x) {
4880+ return x;
4881+};
4882+var $lynxjs_elm$browser$Browser$Dom$NotFound = function (a) {
4883+ return {$: 'NotFound', a: a};
4884+};
4885+var $elm$core$Basics$never = function (_v0) {
4886+ never:
4887+ while (true) {
4888+ var nvr = _v0.a;
4889+ var $temp$_v0 = nvr;
4890+ _v0 = $temp$_v0;
4891+ continue never;
4892+ }
4893+};
4894+var $elm$core$Task$Perform = function (a) {
4895+ return {$: 'Perform', a: a};
4896+};
4897+var $elm$core$Task$succeed = _Scheduler_succeed;
4898+var $elm$core$Task$init = $elm$core$Task$succeed(_Utils_Tuple0);
4899+var $elm$core$List$foldrHelper = F4(
4900+ function (fn, acc, ctr, ls) {
4901+ if (!ls.b) {
4902+ return acc;
4903+ } else {
4904+ var a = ls.a;
4905+ var r1 = ls.b;
4906+ if (!r1.b) {
4907+ return A2(fn, a, acc);
4908+ } else {
4909+ var b = r1.a;
4910+ var r2 = r1.b;
4911+ if (!r2.b) {
4912+ return A2(
4913+ fn,
4914+ a,
4915+ A2(fn, b, acc));
4916+ } else {
4917+ var c = r2.a;
4918+ var r3 = r2.b;
4919+ if (!r3.b) {
4920+ return A2(
4921+ fn,
4922+ a,
4923+ A2(
4924+ fn,
4925+ b,
4926+ A2(fn, c, acc)));
4927+ } else {
4928+ var d = r3.a;
4929+ var r4 = r3.b;
4930+ var res = (ctr > 500) ? A3(
4931+ $elm$core$List$foldl,
4932+ fn,
4933+ acc,
4934+ $elm$core$List$reverse(r4)) : A4($elm$core$List$foldrHelper, fn, acc, ctr + 1, r4);
4935+ return A2(
4936+ fn,
4937+ a,
4938+ A2(
4939+ fn,
4940+ b,
4941+ A2(
4942+ fn,
4943+ c,
4944+ A2(fn, d, res))));
4945+ }
4946+ }
4947+ }
4948+ }
4949+ });
4950+var $elm$core$List$foldr = F3(
4951+ function (fn, acc, ls) {
4952+ return A4($elm$core$List$foldrHelper, fn, acc, 0, ls);
4953+ });
4954+var $elm$core$List$map = F2(
4955+ function (f, xs) {
4956+ return A3(
4957+ $elm$core$List$foldr,
4958+ F2(
4959+ function (x, acc) {
4960+ return A2(
4961+ $elm$core$List$cons,
4962+ f(x),
4963+ acc);
4964+ }),
4965+ _List_Nil,
4966+ xs);
4967+ });
4968+var $elm$core$Task$andThen = _Scheduler_andThen;
4969+var $elm$core$Task$map = F2(
4970+ function (func, taskA) {
4971+ return A2(
4972+ $elm$core$Task$andThen,
4973+ function (a) {
4974+ return $elm$core$Task$succeed(
4975+ func(a));
4976+ },
4977+ taskA);
4978+ });
4979+var $elm$core$Task$map2 = F3(
4980+ function (func, taskA, taskB) {
4981+ return A2(
4982+ $elm$core$Task$andThen,
4983+ function (a) {
4984+ return A2(
4985+ $elm$core$Task$andThen,
4986+ function (b) {
4987+ return $elm$core$Task$succeed(
4988+ A2(func, a, b));
4989+ },
4990+ taskB);
4991+ },
4992+ taskA);
4993+ });
4994+var $elm$core$Task$sequence = function (tasks) {
4995+ return A3(
4996+ $elm$core$List$foldr,
4997+ $elm$core$Task$map2($elm$core$List$cons),
4998+ $elm$core$Task$succeed(_List_Nil),
4999+ tasks);
5000+};
5001+var $elm$core$Platform$sendToApp = _Platform_sendToApp;
5002+var $elm$core$Task$spawnCmd = F2(
5003+ function (router, _v0) {
5004+ var task = _v0.a;
5005+ return _Scheduler_spawn(
5006+ A2(
5007+ $elm$core$Task$andThen,
5008+ $elm$core$Platform$sendToApp(router),
5009+ task));
5010+ });
5011+var $elm$core$Task$onEffects = F3(
5012+ function (router, commands, state) {
5013+ return A2(
5014+ $elm$core$Task$map,
5015+ function (_v0) {
5016+ return _Utils_Tuple0;
5017+ },
5018+ $elm$core$Task$sequence(
5019+ A2(
5020+ $elm$core$List$map,
5021+ $elm$core$Task$spawnCmd(router),
5022+ commands)));
5023+ });
5024+var $elm$core$Task$onSelfMsg = F3(
5025+ function (_v0, _v1, _v2) {
5026+ return $elm$core$Task$succeed(_Utils_Tuple0);
5027+ });
5028+var $elm$core$Task$cmdMap = F2(
5029+ function (tagger, _v0) {
5030+ var task = _v0.a;
5031+ return $elm$core$Task$Perform(
5032+ A2($elm$core$Task$map, tagger, task));
5033+ });
5034+_Platform_effectManagers['Task'] = _Platform_createManager($elm$core$Task$init, $elm$core$Task$onEffects, $elm$core$Task$onSelfMsg, $elm$core$Task$cmdMap);
5035+var $elm$core$Task$command = _Platform_leaf('Task');
5036+var $elm$core$Task$perform = F2(
5037+ function (toMessage, task) {
5038+ return $elm$core$Task$command(
5039+ $elm$core$Task$Perform(
5040+ A2($elm$core$Task$map, toMessage, task)));
5041+ });
5042+var $elm$core$Platform$Cmd$batch = _Platform_batch;
5043+var $elm$core$Platform$Cmd$none = $elm$core$Platform$Cmd$batch(_List_Nil);
5044+var $elm$core$Platform$Sub$batch = _Platform_batch;
5045+var $elm$core$Platform$Sub$none = $elm$core$Platform$Sub$batch(_List_Nil);
5046+var $lynxjs_elm$browser$Browser$sandbox = function (impl) {
5047+ return _Browser_element(
5048+ {
5049+ init: function (_v0) {
5050+ return _Utils_Tuple2(impl.init, $elm$core$Platform$Cmd$none);
5051+ },
5052+ subscriptions: function (_v1) {
5053+ return $elm$core$Platform$Sub$none;
5054+ },
5055+ update: F2(
5056+ function (msg, model) {
5057+ return _Utils_Tuple2(
5058+ A2(impl.update, msg, model),
5059+ $elm$core$Platform$Cmd$none);
5060+ }),
5061+ view: impl.view
5062+ });
5063+};
5064+var $author$project$Main$update = F2(
5065+ function (msg, model) {
5066+ if (msg.$ === 'Increment') {
5067+ return _Utils_update(
5068+ model,
5069+ {count: model.count + 1});
5070+ } else {
5071+ return _Utils_update(
5072+ model,
5073+ {count: model.count - 1});
5074+ }
5075+ });
5076+var $lynxjs_elm$ui$Lynx$Attributes$Center = {$: 'Center'};
5077+var $lynxjs_elm$ui$Lynx$Attributes$Column = {$: 'Column'};
5078+var $author$project$Main$Decrement = {$: 'Decrement'};
5079+var $author$project$Main$Increment = {$: 'Increment'};
5080+var $lynxjs_elm$ui$Lynx$Attributes$Row = {$: 'Row'};
5081+var $lynxjs_elm$ui$Lynx$Attributes$alignmentToString = function (a) {
5082+ switch (a.$) {
5083+ case 'Start':
5084+ return 'flex-start';
5085+ case 'Center':
5086+ return 'center';
5087+ case 'End':
5088+ return 'flex-end';
5089+ case 'SpaceBetween':
5090+ return 'space-between';
5091+ case 'SpaceAround':
5092+ return 'space-around';
5093+ case 'SpaceEvenly':
5094+ return 'space-evenly';
5095+ case 'Stretch':
5096+ return 'stretch';
5097+ default:
5098+ return 'baseline';
5099+ }
5100+};
5101+var $lynxjs_elm$virtual_dom$VirtualDom$style = _VirtualDom_style;
5102+var $lynxjs_elm$ui$Lynx$Attributes$style = $lynxjs_elm$virtual_dom$VirtualDom$style;
5103+var $lynxjs_elm$ui$Lynx$Attributes$alignItems = function (a) {
5104+ return A2(
5105+ $lynxjs_elm$ui$Lynx$Attributes$style,
5106+ 'alignItems',
5107+ $lynxjs_elm$ui$Lynx$Attributes$alignmentToString(a));
5108+};
5109+var $lynxjs_elm$ui$Lynx$Attributes$backgroundColor = $lynxjs_elm$ui$Lynx$Attributes$style('backgroundColor');
5110+var $lynxjs_elm$ui$Lynx$Attributes$pxStyle = F2(
5111+ function (key, val) {
5112+ return A2(
5113+ $lynxjs_elm$virtual_dom$VirtualDom$style,
5114+ key,
5115+ $elm$core$String$fromInt(val) + 'px');
5116+ });
5117+var $lynxjs_elm$ui$Lynx$Attributes$borderRadius = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('borderRadius');
5118+var $lynxjs_elm$ui$Lynx$Attributes$color = $lynxjs_elm$ui$Lynx$Attributes$style('color');
5119+var $lynxjs_elm$ui$Lynx$Attributes$fontSize = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('fontSize');
5120+var $lynxjs_elm$virtual_dom$VirtualDom$Normal = function (a) {
5121+ return {$: 'Normal', a: a};
5122+};
5123+var $lynxjs_elm$virtual_dom$VirtualDom$on = _VirtualDom_on;
5124+var $lynxjs_elm$ui$Lynx$Events$onTap = function (msg) {
5125+ return A2(
5126+ $lynxjs_elm$virtual_dom$VirtualDom$on,
5127+ 'tap',
5128+ $lynxjs_elm$virtual_dom$VirtualDom$Normal(
5129+ $elm$json$Json$Decode$succeed(msg)));
5130+};
5131+var $lynxjs_elm$ui$Lynx$Attributes$paddingBottom = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('paddingBottom');
5132+var $lynxjs_elm$ui$Lynx$Attributes$paddingLeft = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('paddingLeft');
5133+var $lynxjs_elm$ui$Lynx$Attributes$paddingRight = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('paddingRight');
5134+var $lynxjs_elm$ui$Lynx$Attributes$paddingTop = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('paddingTop');
5135+var $lynxjs_elm$virtual_dom$VirtualDom$node = function (tag) {
5136+ return _VirtualDom_node(
5137+ _VirtualDom_noScript(tag));
5138+};
5139+var $lynxjs_elm$ui$Lynx$text = $lynxjs_elm$virtual_dom$VirtualDom$node('text');
5140+var $lynxjs_elm$virtual_dom$VirtualDom$text = _VirtualDom_text;
5141+var $lynxjs_elm$ui$Lynx$textContent = $lynxjs_elm$virtual_dom$VirtualDom$text;
5142+var $lynxjs_elm$ui$Lynx$view = $lynxjs_elm$virtual_dom$VirtualDom$node('view');
5143+var $author$project$Main$button = F2(
5144+ function (msg, label) {
5145+ return A2(
5146+ $lynxjs_elm$ui$Lynx$view,
5147+ _List_fromArray(
5148+ [
5149+ $lynxjs_elm$ui$Lynx$Events$onTap(msg),
5150+ $lynxjs_elm$ui$Lynx$Attributes$backgroundColor('#4a90d9'),
5151+ $lynxjs_elm$ui$Lynx$Attributes$borderRadius(8),
5152+ $lynxjs_elm$ui$Lynx$Attributes$paddingTop(12),
5153+ $lynxjs_elm$ui$Lynx$Attributes$paddingBottom(12),
5154+ $lynxjs_elm$ui$Lynx$Attributes$paddingLeft(24),
5155+ $lynxjs_elm$ui$Lynx$Attributes$paddingRight(24)
5156+ ]),
5157+ _List_fromArray(
5158+ [
5159+ A2(
5160+ $lynxjs_elm$ui$Lynx$text,
5161+ _List_fromArray(
5162+ [
5163+ $lynxjs_elm$ui$Lynx$Attributes$color('#ffffff'),
5164+ $lynxjs_elm$ui$Lynx$Attributes$fontSize(24)
5165+ ]),
5166+ _List_fromArray(
5167+ [
5168+ $lynxjs_elm$ui$Lynx$textContent(label)
5169+ ]))
5170+ ]));
5171+ });
5172+var $lynxjs_elm$ui$Lynx$Attributes$intStyle = F2(
5173+ function (key, val) {
5174+ return A2(
5175+ $lynxjs_elm$virtual_dom$VirtualDom$style,
5176+ key,
5177+ $elm$core$String$fromInt(val));
5178+ });
5179+var $lynxjs_elm$ui$Lynx$Attributes$flex = $lynxjs_elm$ui$Lynx$Attributes$intStyle('flex');
5180+var $lynxjs_elm$ui$Lynx$Attributes$flexDirection = function (d) {
5181+ return A2(
5182+ $lynxjs_elm$ui$Lynx$Attributes$style,
5183+ 'flexDirection',
5184+ function () {
5185+ switch (d.$) {
5186+ case 'Row':
5187+ return 'row';
5188+ case 'Column':
5189+ return 'column';
5190+ case 'RowReverse':
5191+ return 'row-reverse';
5192+ default:
5193+ return 'column-reverse';
5194+ }
5195+ }());
5196+};
5197+var $lynxjs_elm$ui$Lynx$Attributes$justifyContent = function (a) {
5198+ return A2(
5199+ $lynxjs_elm$ui$Lynx$Attributes$style,
5200+ 'justifyContent',
5201+ $lynxjs_elm$ui$Lynx$Attributes$alignmentToString(a));
5202+};
5203+var $lynxjs_elm$ui$Lynx$Attributes$marginLeft = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('marginLeft');
5204+var $lynxjs_elm$ui$Lynx$Attributes$marginRight = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('marginRight');
5205+var $author$project$Main$view = function (model) {
5206+ return A2(
5207+ $lynxjs_elm$ui$Lynx$view,
5208+ _List_fromArray(
5209+ [
5210+ $lynxjs_elm$ui$Lynx$Attributes$flexDirection($lynxjs_elm$ui$Lynx$Attributes$Column),
5211+ $lynxjs_elm$ui$Lynx$Attributes$alignItems($lynxjs_elm$ui$Lynx$Attributes$Center),
5212+ $lynxjs_elm$ui$Lynx$Attributes$justifyContent($lynxjs_elm$ui$Lynx$Attributes$Center),
5213+ $lynxjs_elm$ui$Lynx$Attributes$flex(1)
5214+ ]),
5215+ _List_fromArray(
5216+ [
5217+ A2(
5218+ $lynxjs_elm$ui$Lynx$view,
5219+ _List_fromArray(
5220+ [
5221+ $lynxjs_elm$ui$Lynx$Attributes$flexDirection($lynxjs_elm$ui$Lynx$Attributes$Row),
5222+ $lynxjs_elm$ui$Lynx$Attributes$alignItems($lynxjs_elm$ui$Lynx$Attributes$Center)
5223+ ]),
5224+ _List_fromArray(
5225+ [
5226+ A2($author$project$Main$button, $author$project$Main$Decrement, '-'),
5227+ A2(
5228+ $lynxjs_elm$ui$Lynx$text,
5229+ _List_fromArray(
5230+ [
5231+ $lynxjs_elm$ui$Lynx$Attributes$fontSize(32),
5232+ $lynxjs_elm$ui$Lynx$Attributes$marginLeft(20),
5233+ $lynxjs_elm$ui$Lynx$Attributes$marginRight(20)
5234+ ]),
5235+ _List_fromArray(
5236+ [
5237+ $lynxjs_elm$ui$Lynx$textContent(
5238+ $elm$core$String$fromInt(model.count))
5239+ ])),
5240+ A2($author$project$Main$button, $author$project$Main$Increment, '+')
5241+ ]))
5242+ ]));
5243+};
5244+var $author$project$Main$main = $lynxjs_elm$browser$Browser$sandbox(
5245+ {init: $author$project$Main$init, update: $author$project$Main$update, view: $author$project$Main$view});
5246+_Platform_export({'Main':{'init':$author$project$Main$main(
5247+ $elm$json$Json$Decode$succeed(_Utils_Tuple0))(0)}});}(globalThis));
5248+var app = Elm.Main.init({});
5249+</script>
5250+</body>
5251+</html>
examples/counter/main.lynx.bundlenew file

Binary file not shown.

examples/counter/src/Main.elmnew file+105
@@ -0,0 +1,105 @@
1+module Main exposing (main)
2+
3+{-| Phase 2-4 verification: TEA with events.
4+Counter app with increment/decrement via tap events.
5+-}
6+
7+import Browser
8+import Lynx
9+import Lynx.Attributes as Attr exposing (Alignment(..), FlexDirection(..))
10+import Lynx.Events exposing (onTap)
11+import VirtualDom exposing (Node)
12+
13+
14+
15+-- MAIN
16+
17+
18+main : Program () Model Msg
19+main =
20+ Browser.sandbox
21+ { init = init
22+ , view = view
23+ , update = update
24+ }
25+
26+
27+
28+-- MODEL
29+
30+
31+type alias Model =
32+ { count : Int
33+ }
34+
35+
36+init : Model
37+init =
38+ { count = 0
39+ }
40+
41+
42+
43+-- UPDATE
44+
45+
46+type Msg
47+ = Increment
48+ | Decrement
49+
50+
51+update : Msg -> Model -> Model
52+update msg model =
53+ case msg of
54+ Increment ->
55+ { model | count = model.count + 1 }
56+
57+ Decrement ->
58+ { model | count = model.count - 1 }
59+
60+
61+
62+-- VIEW
63+
64+
65+view : Model -> Node Msg
66+view model =
67+ Lynx.view
68+ [ Attr.flexDirection Column
69+ , Attr.alignItems Center
70+ , Attr.justifyContent Center
71+ , Attr.flex 1
72+ ]
73+ [ Lynx.view
74+ [ Attr.flexDirection Row
75+ , Attr.alignItems Center
76+ ]
77+ [ button Decrement "-"
78+ , Lynx.text
79+ [ Attr.fontSize 32
80+ , Attr.marginLeft 20
81+ , Attr.marginRight 20
82+ ]
83+ [ Lynx.textContent (String.fromInt model.count) ]
84+ , button Increment "+"
85+ ]
86+ ]
87+
88+
89+button : Msg -> String -> Node Msg
90+button msg label =
91+ Lynx.view
92+ [ onTap msg
93+ , Attr.backgroundColor "#4a90d9"
94+ , Attr.borderRadius 8
95+ , Attr.paddingTop 12
96+ , Attr.paddingBottom 12
97+ , Attr.paddingLeft 24
98+ , Attr.paddingRight 24
99+ ]
100+ [ Lynx.text
101+ [ Attr.color "#ffffff"
102+ , Attr.fontSize 24
103+ ]
104+ [ Lynx.textContent label ]
105+ ]
examples/hello-world/elm.jsnew file+3697
@@ -0,0 +1,3697 @@
1+(function(scope){
2+'use strict';
3+
4+function F(arity, fun, wrapper) {
5+ wrapper.a = arity;
6+ wrapper.f = fun;
7+ return wrapper;
8+}
9+
10+function F2(fun) {
11+ return F(2, fun, function(a) { return function(b) { return fun(a,b); }; })
12+}
13+function F3(fun) {
14+ return F(3, fun, function(a) {
15+ return function(b) { return function(c) { return fun(a, b, c); }; };
16+ });
17+}
18+function F4(fun) {
19+ return F(4, fun, function(a) { return function(b) { return function(c) {
20+ return function(d) { return fun(a, b, c, d); }; }; };
21+ });
22+}
23+function F5(fun) {
24+ return F(5, fun, function(a) { return function(b) { return function(c) {
25+ return function(d) { return function(e) { return fun(a, b, c, d, e); }; }; }; };
26+ });
27+}
28+function F6(fun) {
29+ return F(6, fun, function(a) { return function(b) { return function(c) {
30+ return function(d) { return function(e) { return function(f) {
31+ return fun(a, b, c, d, e, f); }; }; }; }; };
32+ });
33+}
34+function F7(fun) {
35+ return F(7, fun, function(a) { return function(b) { return function(c) {
36+ return function(d) { return function(e) { return function(f) {
37+ return function(g) { return fun(a, b, c, d, e, f, g); }; }; }; }; }; };
38+ });
39+}
40+function F8(fun) {
41+ return F(8, fun, function(a) { return function(b) { return function(c) {
42+ return function(d) { return function(e) { return function(f) {
43+ return function(g) { return function(h) {
44+ return fun(a, b, c, d, e, f, g, h); }; }; }; }; }; }; };
45+ });
46+}
47+function F9(fun) {
48+ return F(9, fun, function(a) { return function(b) { return function(c) {
49+ return function(d) { return function(e) { return function(f) {
50+ return function(g) { return function(h) { return function(i) {
51+ return fun(a, b, c, d, e, f, g, h, i); }; }; }; }; }; }; }; };
52+ });
53+}
54+
55+function A2(fun, a, b) {
56+ return fun.a === 2 ? fun.f(a, b) : fun(a)(b);
57+}
58+function A3(fun, a, b, c) {
59+ return fun.a === 3 ? fun.f(a, b, c) : fun(a)(b)(c);
60+}
61+function A4(fun, a, b, c, d) {
62+ return fun.a === 4 ? fun.f(a, b, c, d) : fun(a)(b)(c)(d);
63+}
64+function A5(fun, a, b, c, d, e) {
65+ return fun.a === 5 ? fun.f(a, b, c, d, e) : fun(a)(b)(c)(d)(e);
66+}
67+function A6(fun, a, b, c, d, e, f) {
68+ return fun.a === 6 ? fun.f(a, b, c, d, e, f) : fun(a)(b)(c)(d)(e)(f);
69+}
70+function A7(fun, a, b, c, d, e, f, g) {
71+ return fun.a === 7 ? fun.f(a, b, c, d, e, f, g) : fun(a)(b)(c)(d)(e)(f)(g);
72+}
73+function A8(fun, a, b, c, d, e, f, g, h) {
74+ return fun.a === 8 ? fun.f(a, b, c, d, e, f, g, h) : fun(a)(b)(c)(d)(e)(f)(g)(h);
75+}
76+function A9(fun, a, b, c, d, e, f, g, h, i) {
77+ return fun.a === 9 ? fun.f(a, b, c, d, e, f, g, h, i) : fun(a)(b)(c)(d)(e)(f)(g)(h)(i);
78+}
79+
80+console.warn('Compiled in DEV mode. Follow the advice at https://elm-lang.org/0.19.1/optimize for better performance and smaller assets.');
81+
82+
83+var _JsArray_empty = [];
84+
85+function _JsArray_singleton(value)
86+{
87+ return [value];
88+}
89+
90+function _JsArray_length(array)
91+{
92+ return array.length;
93+}
94+
95+var _JsArray_initialize = F3(function(size, offset, func)
96+{
97+ var result = new Array(size);
98+
99+ for (var i = 0; i < size; i++)
100+ {
101+ result[i] = func(offset + i);
102+ }
103+
104+ return result;
105+});
106+
107+var _JsArray_initializeFromList = F2(function (max, ls)
108+{
109+ var result = new Array(max);
110+
111+ for (var i = 0; i < max && ls.b; i++)
112+ {
113+ result[i] = ls.a;
114+ ls = ls.b;
115+ }
116+
117+ result.length = i;
118+ return _Utils_Tuple2(result, ls);
119+});
120+
121+var _JsArray_unsafeGet = F2(function(index, array)
122+{
123+ return array[index];
124+});
125+
126+var _JsArray_unsafeSet = F3(function(index, value, array)
127+{
128+ var length = array.length;
129+ var result = new Array(length);
130+
131+ for (var i = 0; i < length; i++)
132+ {
133+ result[i] = array[i];
134+ }
135+
136+ result[index] = value;
137+ return result;
138+});
139+
140+var _JsArray_push = F2(function(value, array)
141+{
142+ var length = array.length;
143+ var result = new Array(length + 1);
144+
145+ for (var i = 0; i < length; i++)
146+ {
147+ result[i] = array[i];
148+ }
149+
150+ result[length] = value;
151+ return result;
152+});
153+
154+var _JsArray_foldl = F3(function(func, acc, array)
155+{
156+ var length = array.length;
157+
158+ for (var i = 0; i < length; i++)
159+ {
160+ acc = A2(func, array[i], acc);
161+ }
162+
163+ return acc;
164+});
165+
166+var _JsArray_foldr = F3(function(func, acc, array)
167+{
168+ for (var i = array.length - 1; i >= 0; i--)
169+ {
170+ acc = A2(func, array[i], acc);
171+ }
172+
173+ return acc;
174+});
175+
176+var _JsArray_map = F2(function(func, array)
177+{
178+ var length = array.length;
179+ var result = new Array(length);
180+
181+ for (var i = 0; i < length; i++)
182+ {
183+ result[i] = func(array[i]);
184+ }
185+
186+ return result;
187+});
188+
189+var _JsArray_indexedMap = F3(function(func, offset, array)
190+{
191+ var length = array.length;
192+ var result = new Array(length);
193+
194+ for (var i = 0; i < length; i++)
195+ {
196+ result[i] = A2(func, offset + i, array[i]);
197+ }
198+
199+ return result;
200+});
201+
202+var _JsArray_slice = F3(function(from, to, array)
203+{
204+ return array.slice(from, to);
205+});
206+
207+var _JsArray_appendN = F3(function(n, dest, source)
208+{
209+ var destLen = dest.length;
210+ var itemsToCopy = n - destLen;
211+
212+ if (itemsToCopy > source.length)
213+ {
214+ itemsToCopy = source.length;
215+ }
216+
217+ var size = destLen + itemsToCopy;
218+ var result = new Array(size);
219+
220+ for (var i = 0; i < destLen; i++)
221+ {
222+ result[i] = dest[i];
223+ }
224+
225+ for (var i = 0; i < itemsToCopy; i++)
226+ {
227+ result[i + destLen] = source[i];
228+ }
229+
230+ return result;
231+});
232+
233+
234+
235+// LOG
236+
237+var _Debug_log_UNUSED = F2(function(tag, value)
238+{
239+ return value;
240+});
241+
242+var _Debug_log = F2(function(tag, value)
243+{
244+ console.log(tag + ': ' + _Debug_toString(value));
245+ return value;
246+});
247+
248+
249+// TODOS
250+
251+function _Debug_todo(moduleName, region)
252+{
253+ return function(message) {
254+ _Debug_crash(8, moduleName, region, message);
255+ };
256+}
257+
258+function _Debug_todoCase(moduleName, region, value)
259+{
260+ return function(message) {
261+ _Debug_crash(9, moduleName, region, value, message);
262+ };
263+}
264+
265+
266+// TO STRING
267+
268+function _Debug_toString_UNUSED(value)
269+{
270+ return '<internals>';
271+}
272+
273+function _Debug_toString(value)
274+{
275+ return _Debug_toAnsiString(false, value);
276+}
277+
278+function _Debug_toAnsiString(ansi, value)
279+{
280+ if (typeof value === 'function')
281+ {
282+ return _Debug_internalColor(ansi, '<function>');
283+ }
284+
285+ if (typeof value === 'boolean')
286+ {
287+ return _Debug_ctorColor(ansi, value ? 'True' : 'False');
288+ }
289+
290+ if (typeof value === 'number')
291+ {
292+ return _Debug_numberColor(ansi, value + '');
293+ }
294+
295+ if (value instanceof String)
296+ {
297+ return _Debug_charColor(ansi, "'" + _Debug_addSlashes(value, true) + "'");
298+ }
299+
300+ if (typeof value === 'string')
301+ {
302+ return _Debug_stringColor(ansi, '"' + _Debug_addSlashes(value, false) + '"');
303+ }
304+
305+ if (typeof value === 'object' && '$' in value)
306+ {
307+ var tag = value.$;
308+
309+ if (typeof tag === 'number')
310+ {
311+ return _Debug_internalColor(ansi, '<internals>');
312+ }
313+
314+ if (tag[0] === '#')
315+ {
316+ var output = [];
317+ for (var k in value)
318+ {
319+ if (k === '$') continue;
320+ output.push(_Debug_toAnsiString(ansi, value[k]));
321+ }
322+ return '(' + output.join(',') + ')';
323+ }
324+
325+ if (tag === 'Set_elm_builtin')
326+ {
327+ return _Debug_ctorColor(ansi, 'Set')
328+ + _Debug_fadeColor(ansi, '.fromList') + ' '
329+ + _Debug_toAnsiString(ansi, $elm$core$Set$toList(value));
330+ }
331+
332+ if (tag === 'RBNode_elm_builtin' || tag === 'RBEmpty_elm_builtin')
333+ {
334+ return _Debug_ctorColor(ansi, 'Dict')
335+ + _Debug_fadeColor(ansi, '.fromList') + ' '
336+ + _Debug_toAnsiString(ansi, $elm$core$Dict$toList(value));
337+ }
338+
339+ if (tag === 'Array_elm_builtin')
340+ {
341+ return _Debug_ctorColor(ansi, 'Array')
342+ + _Debug_fadeColor(ansi, '.fromList') + ' '
343+ + _Debug_toAnsiString(ansi, $elm$core$Array$toList(value));
344+ }
345+
346+ if (tag === '::' || tag === '[]')
347+ {
348+ var output = '[';
349+
350+ value.b && (output += _Debug_toAnsiString(ansi, value.a), value = value.b)
351+
352+ for (; value.b; value = value.b) // WHILE_CONS
353+ {
354+ output += ',' + _Debug_toAnsiString(ansi, value.a);
355+ }
356+ return output + ']';
357+ }
358+
359+ var output = '';
360+ for (var i in value)
361+ {
362+ if (i === '$') continue;
363+ var str = _Debug_toAnsiString(ansi, value[i]);
364+ var c0 = str[0];
365+ var parenless = c0 === '{' || c0 === '(' || c0 === '[' || c0 === '<' || c0 === '"' || str.indexOf(' ') < 0;
366+ output += ' ' + (parenless ? str : '(' + str + ')');
367+ }
368+ return _Debug_ctorColor(ansi, tag) + output;
369+ }
370+
371+ if (typeof DataView === 'function' && value instanceof DataView)
372+ {
373+ return _Debug_stringColor(ansi, '<' + value.byteLength + ' bytes>');
374+ }
375+
376+ if (typeof File !== 'undefined' && value instanceof File)
377+ {
378+ return _Debug_internalColor(ansi, '<' + value.name + '>');
379+ }
380+
381+ if (typeof value === 'object')
382+ {
383+ var output = [];
384+ for (var key in value)
385+ {
386+ var field = key[0] === '_' ? key.slice(1) : key;
387+ output.push(_Debug_fadeColor(ansi, field) + ' = ' + _Debug_toAnsiString(ansi, value[key]));
388+ }
389+ if (output.length === 0)
390+ {
391+ return '{}';
392+ }
393+ return '{ ' + output.join(', ') + ' }';
394+ }
395+
396+ return _Debug_internalColor(ansi, '<internals>');
397+}
398+
399+function _Debug_addSlashes(str, isChar)
400+{
401+ var s = str
402+ .replace(/\\/g, '\\\\')
403+ .replace(/\n/g, '\\n')
404+ .replace(/\t/g, '\\t')
405+ .replace(/\r/g, '\\r')
406+ .replace(/\v/g, '\\v')
407+ .replace(/\0/g, '\\0');
408+
409+ if (isChar)
410+ {
411+ return s.replace(/\'/g, '\\\'');
412+ }
413+ else
414+ {
415+ return s.replace(/\"/g, '\\"');
416+ }
417+}
418+
419+function _Debug_ctorColor(ansi, string)
420+{
421+ return ansi ? '\x1b[96m' + string + '\x1b[0m' : string;
422+}
423+
424+function _Debug_numberColor(ansi, string)
425+{
426+ return ansi ? '\x1b[95m' + string + '\x1b[0m' : string;
427+}
428+
429+function _Debug_stringColor(ansi, string)
430+{
431+ return ansi ? '\x1b[93m' + string + '\x1b[0m' : string;
432+}
433+
434+function _Debug_charColor(ansi, string)
435+{
436+ return ansi ? '\x1b[92m' + string + '\x1b[0m' : string;
437+}
438+
439+function _Debug_fadeColor(ansi, string)
440+{
441+ return ansi ? '\x1b[37m' + string + '\x1b[0m' : string;
442+}
443+
444+function _Debug_internalColor(ansi, string)
445+{
446+ return ansi ? '\x1b[36m' + string + '\x1b[0m' : string;
447+}
448+
449+function _Debug_toHexDigit(n)
450+{
451+ return String.fromCharCode(n < 10 ? 48 + n : 55 + n);
452+}
453+
454+
455+// CRASH
456+
457+
458+function _Debug_crash_UNUSED(identifier)
459+{
460+ throw new Error('https://github.com/elm/core/blob/1.0.0/hints/' + identifier + '.md');
461+}
462+
463+
464+function _Debug_crash(identifier, fact1, fact2, fact3, fact4)
465+{
466+ switch(identifier)
467+ {
468+ case 0:
469+ throw new Error('What node should I take over? In JavaScript I need something like:\n\n Elm.Main.init({\n node: document.getElementById("elm-node")\n })\n\nYou need to do this with any Browser.sandbox or Browser.element program.');
470+
471+ case 1:
472+ throw new Error('Browser.application programs cannot handle URLs like this:\n\n ' + document.location.href + '\n\nWhat is the root? The root of your file system? Try looking at this program with `elm reactor` or some other server.');
473+
474+ case 2:
475+ var jsonErrorString = fact1;
476+ throw new Error('Problem with the flags given to your Elm program on initialization.\n\n' + jsonErrorString);
477+
478+ case 3:
479+ var portName = fact1;
480+ throw new Error('There can only be one port named `' + portName + '`, but your program has multiple.');
481+
482+ case 4:
483+ var portName = fact1;
484+ var problem = fact2;
485+ throw new Error('Trying to send an unexpected type of value through port `' + portName + '`:\n' + problem);
486+
487+ case 5:
488+ throw new Error('Trying to use `(==)` on functions.\nThere is no way to know if functions are "the same" in the Elm sense.\nRead more about this at https://package.elm-lang.org/packages/elm/core/latest/Basics#== which describes why it is this way and what the better version will look like.');
489+
490+ case 6:
491+ var moduleName = fact1;
492+ throw new Error('Your page is loading multiple Elm scripts with a module named ' + moduleName + '. Maybe a duplicate script is getting loaded accidentally? If not, rename one of them so I know which is which!');
493+
494+ case 8:
495+ var moduleName = fact1;
496+ var region = fact2;
497+ var message = fact3;
498+ throw new Error('TODO in module `' + moduleName + '` ' + _Debug_regionToString(region) + '\n\n' + message);
499+
500+ case 9:
501+ var moduleName = fact1;
502+ var region = fact2;
503+ var value = fact3;
504+ var message = fact4;
505+ throw new Error(
506+ 'TODO in module `' + moduleName + '` from the `case` expression '
507+ + _Debug_regionToString(region) + '\n\nIt received the following value:\n\n '
508+ + _Debug_toString(value).replace('\n', '\n ')
509+ + '\n\nBut the branch that handles it says:\n\n ' + message.replace('\n', '\n ')
510+ );
511+
512+ case 10:
513+ throw new Error('Bug in https://github.com/elm/virtual-dom/issues');
514+
515+ case 11:
516+ throw new Error('Cannot perform mod 0. Division by zero error.');
517+ }
518+}
519+
520+function _Debug_regionToString(region)
521+{
522+ if (region.start.line === region.end.line)
523+ {
524+ return 'on line ' + region.start.line;
525+ }
526+ return 'on lines ' + region.start.line + ' through ' + region.end.line;
527+}
528+
529+
530+
531+// EQUALITY
532+
533+function _Utils_eq(x, y)
534+{
535+ for (
536+ var pair, stack = [], isEqual = _Utils_eqHelp(x, y, 0, stack);
537+ isEqual && (pair = stack.pop());
538+ isEqual = _Utils_eqHelp(pair.a, pair.b, 0, stack)
539+ )
540+ {}
541+
542+ return isEqual;
543+}
544+
545+function _Utils_eqHelp(x, y, depth, stack)
546+{
547+ if (x === y)
548+ {
549+ return true;
550+ }
551+
552+ if (typeof x !== 'object' || x === null || y === null)
553+ {
554+ typeof x === 'function' && _Debug_crash(5);
555+ return false;
556+ }
557+
558+ if (depth > 100)
559+ {
560+ stack.push(_Utils_Tuple2(x,y));
561+ return true;
562+ }
563+
564+ /**/
565+ if (x.$ === 'Set_elm_builtin')
566+ {
567+ x = $elm$core$Set$toList(x);
568+ y = $elm$core$Set$toList(y);
569+ }
570+ if (x.$ === 'RBNode_elm_builtin' || x.$ === 'RBEmpty_elm_builtin')
571+ {
572+ x = $elm$core$Dict$toList(x);
573+ y = $elm$core$Dict$toList(y);
574+ }
575+ //*/
576+
577+ /**_UNUSED/
578+ if (x.$ < 0)
579+ {
580+ x = $elm$core$Dict$toList(x);
581+ y = $elm$core$Dict$toList(y);
582+ }
583+ //*/
584+
585+ for (var key in x)
586+ {
587+ if (!_Utils_eqHelp(x[key], y[key], depth + 1, stack))
588+ {
589+ return false;
590+ }
591+ }
592+ return true;
593+}
594+
595+var _Utils_equal = F2(_Utils_eq);
596+var _Utils_notEqual = F2(function(a, b) { return !_Utils_eq(a,b); });
597+
598+
599+
600+// COMPARISONS
601+
602+// Code in Generate/JavaScript.hs, Basics.js, and List.js depends on
603+// the particular integer values assigned to LT, EQ, and GT.
604+
605+function _Utils_cmp(x, y, ord)
606+{
607+ if (typeof x !== 'object')
608+ {
609+ return x === y ? /*EQ*/ 0 : x < y ? /*LT*/ -1 : /*GT*/ 1;
610+ }
611+
612+ /**/
613+ if (x instanceof String)
614+ {
615+ var a = x.valueOf();
616+ var b = y.valueOf();
617+ return a === b ? 0 : a < b ? -1 : 1;
618+ }
619+ //*/
620+
621+ /**_UNUSED/
622+ if (typeof x.$ === 'undefined')
623+ //*/
624+ /**/
625+ if (x.$[0] === '#')
626+ //*/
627+ {
628+ return (ord = _Utils_cmp(x.a, y.a))
629+ ? ord
630+ : (ord = _Utils_cmp(x.b, y.b))
631+ ? ord
632+ : _Utils_cmp(x.c, y.c);
633+ }
634+
635+ // traverse conses until end of a list or a mismatch
636+ for (; x.b && y.b && !(ord = _Utils_cmp(x.a, y.a)); x = x.b, y = y.b) {} // WHILE_CONSES
637+ return ord || (x.b ? /*GT*/ 1 : y.b ? /*LT*/ -1 : /*EQ*/ 0);
638+}
639+
640+var _Utils_lt = F2(function(a, b) { return _Utils_cmp(a, b) < 0; });
641+var _Utils_le = F2(function(a, b) { return _Utils_cmp(a, b) < 1; });
642+var _Utils_gt = F2(function(a, b) { return _Utils_cmp(a, b) > 0; });
643+var _Utils_ge = F2(function(a, b) { return _Utils_cmp(a, b) >= 0; });
644+
645+var _Utils_compare = F2(function(x, y)
646+{
647+ var n = _Utils_cmp(x, y);
648+ return n < 0 ? $elm$core$Basics$LT : n ? $elm$core$Basics$GT : $elm$core$Basics$EQ;
649+});
650+
651+
652+// COMMON VALUES
653+
654+var _Utils_Tuple0_UNUSED = 0;
655+var _Utils_Tuple0 = { $: '#0' };
656+
657+function _Utils_Tuple2_UNUSED(a, b) { return { a: a, b: b }; }
658+function _Utils_Tuple2(a, b) { return { $: '#2', a: a, b: b }; }
659+
660+function _Utils_Tuple3_UNUSED(a, b, c) { return { a: a, b: b, c: c }; }
661+function _Utils_Tuple3(a, b, c) { return { $: '#3', a: a, b: b, c: c }; }
662+
663+function _Utils_chr_UNUSED(c) { return c; }
664+function _Utils_chr(c) { return new String(c); }
665+
666+
667+// RECORDS
668+
669+function _Utils_update(oldRecord, updatedFields)
670+{
671+ var newRecord = {};
672+
673+ for (var key in oldRecord)
674+ {
675+ newRecord[key] = oldRecord[key];
676+ }
677+
678+ for (var key in updatedFields)
679+ {
680+ newRecord[key] = updatedFields[key];
681+ }
682+
683+ return newRecord;
684+}
685+
686+
687+// APPEND
688+
689+var _Utils_append = F2(_Utils_ap);
690+
691+function _Utils_ap(xs, ys)
692+{
693+ // append Strings
694+ if (typeof xs === 'string')
695+ {
696+ return xs + ys;
697+ }
698+
699+ // append Lists
700+ if (!xs.b)
701+ {
702+ return ys;
703+ }
704+ var root = _List_Cons(xs.a, ys);
705+ xs = xs.b
706+ for (var curr = root; xs.b; xs = xs.b) // WHILE_CONS
707+ {
708+ curr = curr.b = _List_Cons(xs.a, ys);
709+ }
710+ return root;
711+}
712+
713+
714+
715+var _List_Nil_UNUSED = { $: 0 };
716+var _List_Nil = { $: '[]' };
717+
718+function _List_Cons_UNUSED(hd, tl) { return { $: 1, a: hd, b: tl }; }
719+function _List_Cons(hd, tl) { return { $: '::', a: hd, b: tl }; }
720+
721+
722+var _List_cons = F2(_List_Cons);
723+
724+function _List_fromArray(arr)
725+{
726+ var out = _List_Nil;
727+ for (var i = arr.length; i--; )
728+ {
729+ out = _List_Cons(arr[i], out);
730+ }
731+ return out;
732+}
733+
734+function _List_toArray(xs)
735+{
736+ for (var out = []; xs.b; xs = xs.b) // WHILE_CONS
737+ {
738+ out.push(xs.a);
739+ }
740+ return out;
741+}
742+
743+var _List_map2 = F3(function(f, xs, ys)
744+{
745+ for (var arr = []; xs.b && ys.b; xs = xs.b, ys = ys.b) // WHILE_CONSES
746+ {
747+ arr.push(A2(f, xs.a, ys.a));
748+ }
749+ return _List_fromArray(arr);
750+});
751+
752+var _List_map3 = F4(function(f, xs, ys, zs)
753+{
754+ for (var arr = []; xs.b && ys.b && zs.b; xs = xs.b, ys = ys.b, zs = zs.b) // WHILE_CONSES
755+ {
756+ arr.push(A3(f, xs.a, ys.a, zs.a));
757+ }
758+ return _List_fromArray(arr);
759+});
760+
761+var _List_map4 = F5(function(f, ws, xs, ys, zs)
762+{
763+ for (var arr = []; ws.b && xs.b && ys.b && zs.b; ws = ws.b, xs = xs.b, ys = ys.b, zs = zs.b) // WHILE_CONSES
764+ {
765+ arr.push(A4(f, ws.a, xs.a, ys.a, zs.a));
766+ }
767+ return _List_fromArray(arr);
768+});
769+
770+var _List_map5 = F6(function(f, vs, ws, xs, ys, zs)
771+{
772+ for (var arr = []; vs.b && ws.b && xs.b && ys.b && zs.b; vs = vs.b, ws = ws.b, xs = xs.b, ys = ys.b, zs = zs.b) // WHILE_CONSES
773+ {
774+ arr.push(A5(f, vs.a, ws.a, xs.a, ys.a, zs.a));
775+ }
776+ return _List_fromArray(arr);
777+});
778+
779+var _List_sortBy = F2(function(f, xs)
780+{
781+ return _List_fromArray(_List_toArray(xs).sort(function(a, b) {
782+ return _Utils_cmp(f(a), f(b));
783+ }));
784+});
785+
786+var _List_sortWith = F2(function(f, xs)
787+{
788+ return _List_fromArray(_List_toArray(xs).sort(function(a, b) {
789+ var ord = A2(f, a, b);
790+ return ord === $elm$core$Basics$EQ ? 0 : ord === $elm$core$Basics$LT ? -1 : 1;
791+ }));
792+});
793+
794+
795+
796+// MATH
797+
798+var _Basics_add = F2(function(a, b) { return a + b; });
799+var _Basics_sub = F2(function(a, b) { return a - b; });
800+var _Basics_mul = F2(function(a, b) { return a * b; });
801+var _Basics_fdiv = F2(function(a, b) { return a / b; });
802+var _Basics_idiv = F2(function(a, b) { return (a / b) | 0; });
803+var _Basics_pow = F2(Math.pow);
804+
805+var _Basics_remainderBy = F2(function(b, a) { return a % b; });
806+
807+// https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/divmodnote-letter.pdf
808+var _Basics_modBy = F2(function(modulus, x)
809+{
810+ var answer = x % modulus;
811+ return modulus === 0
812+ ? _Debug_crash(11)
813+ :
814+ ((answer > 0 && modulus < 0) || (answer < 0 && modulus > 0))
815+ ? answer + modulus
816+ : answer;
817+});
818+
819+
820+// TRIGONOMETRY
821+
822+var _Basics_pi = Math.PI;
823+var _Basics_e = Math.E;
824+var _Basics_cos = Math.cos;
825+var _Basics_sin = Math.sin;
826+var _Basics_tan = Math.tan;
827+var _Basics_acos = Math.acos;
828+var _Basics_asin = Math.asin;
829+var _Basics_atan = Math.atan;
830+var _Basics_atan2 = F2(Math.atan2);
831+
832+
833+// MORE MATH
834+
835+function _Basics_toFloat(x) { return x; }
836+function _Basics_truncate(n) { return n | 0; }
837+function _Basics_isInfinite(n) { return n === Infinity || n === -Infinity; }
838+
839+var _Basics_ceiling = Math.ceil;
840+var _Basics_floor = Math.floor;
841+var _Basics_round = Math.round;
842+var _Basics_sqrt = Math.sqrt;
843+var _Basics_log = Math.log;
844+var _Basics_isNaN = isNaN;
845+
846+
847+// BOOLEANS
848+
849+function _Basics_not(bool) { return !bool; }
850+var _Basics_and = F2(function(a, b) { return a && b; });
851+var _Basics_or = F2(function(a, b) { return a || b; });
852+var _Basics_xor = F2(function(a, b) { return a !== b; });
853+
854+
855+
856+var _String_cons = F2(function(chr, str)
857+{
858+ return chr + str;
859+});
860+
861+function _String_uncons(string)
862+{
863+ var word = string.charCodeAt(0);
864+ return !isNaN(word)
865+ ? $elm$core$Maybe$Just(
866+ 0xD800 <= word && word <= 0xDBFF
867+ ? _Utils_Tuple2(_Utils_chr(string[0] + string[1]), string.slice(2))
868+ : _Utils_Tuple2(_Utils_chr(string[0]), string.slice(1))
869+ )
870+ : $elm$core$Maybe$Nothing;
871+}
872+
873+var _String_append = F2(function(a, b)
874+{
875+ return a + b;
876+});
877+
878+function _String_length(str)
879+{
880+ return str.length;
881+}
882+
883+var _String_map = F2(function(func, string)
884+{
885+ var len = string.length;
886+ var array = new Array(len);
887+ var i = 0;
888+ while (i < len)
889+ {
890+ var word = string.charCodeAt(i);
891+ if (0xD800 <= word && word <= 0xDBFF)
892+ {
893+ array[i] = func(_Utils_chr(string[i] + string[i+1]));
894+ i += 2;
895+ continue;
896+ }
897+ array[i] = func(_Utils_chr(string[i]));
898+ i++;
899+ }
900+ return array.join('');
901+});
902+
903+var _String_filter = F2(function(isGood, str)
904+{
905+ var arr = [];
906+ var len = str.length;
907+ var i = 0;
908+ while (i < len)
909+ {
910+ var char = str[i];
911+ var word = str.charCodeAt(i);
912+ i++;
913+ if (0xD800 <= word && word <= 0xDBFF)
914+ {
915+ char += str[i];
916+ i++;
917+ }
918+
919+ if (isGood(_Utils_chr(char)))
920+ {
921+ arr.push(char);
922+ }
923+ }
924+ return arr.join('');
925+});
926+
927+function _String_reverse(str)
928+{
929+ var len = str.length;
930+ var arr = new Array(len);
931+ var i = 0;
932+ while (i < len)
933+ {
934+ var word = str.charCodeAt(i);
935+ if (0xD800 <= word && word <= 0xDBFF)
936+ {
937+ arr[len - i] = str[i + 1];
938+ i++;
939+ arr[len - i] = str[i - 1];
940+ i++;
941+ }
942+ else
943+ {
944+ arr[len - i] = str[i];
945+ i++;
946+ }
947+ }
948+ return arr.join('');
949+}
950+
951+var _String_foldl = F3(function(func, state, string)
952+{
953+ var len = string.length;
954+ var i = 0;
955+ while (i < len)
956+ {
957+ var char = string[i];
958+ var word = string.charCodeAt(i);
959+ i++;
960+ if (0xD800 <= word && word <= 0xDBFF)
961+ {
962+ char += string[i];
963+ i++;
964+ }
965+ state = A2(func, _Utils_chr(char), state);
966+ }
967+ return state;
968+});
969+
970+var _String_foldr = F3(function(func, state, string)
971+{
972+ var i = string.length;
973+ while (i--)
974+ {
975+ var char = string[i];
976+ var word = string.charCodeAt(i);
977+ if (0xDC00 <= word && word <= 0xDFFF)
978+ {
979+ i--;
980+ char = string[i] + char;
981+ }
982+ state = A2(func, _Utils_chr(char), state);
983+ }
984+ return state;
985+});
986+
987+var _String_split = F2(function(sep, str)
988+{
989+ return str.split(sep);
990+});
991+
992+var _String_join = F2(function(sep, strs)
993+{
994+ return strs.join(sep);
995+});
996+
997+var _String_slice = F3(function(start, end, str) {
998+ return str.slice(start, end);
999+});
1000+
1001+function _String_trim(str)
1002+{
1003+ return str.trim();
1004+}
1005+
1006+function _String_trimLeft(str)
1007+{
1008+ return str.replace(/^\s+/, '');
1009+}
1010+
1011+function _String_trimRight(str)
1012+{
1013+ return str.replace(/\s+$/, '');
1014+}
1015+
1016+function _String_words(str)
1017+{
1018+ return _List_fromArray(str.trim().split(/\s+/g));
1019+}
1020+
1021+function _String_lines(str)
1022+{
1023+ return _List_fromArray(str.split(/\r\n|\r|\n/g));
1024+}
1025+
1026+function _String_toUpper(str)
1027+{
1028+ return str.toUpperCase();
1029+}
1030+
1031+function _String_toLower(str)
1032+{
1033+ return str.toLowerCase();
1034+}
1035+
1036+var _String_any = F2(function(isGood, string)
1037+{
1038+ var i = string.length;
1039+ while (i--)
1040+ {
1041+ var char = string[i];
1042+ var word = string.charCodeAt(i);
1043+ if (0xDC00 <= word && word <= 0xDFFF)
1044+ {
1045+ i--;
1046+ char = string[i] + char;
1047+ }
1048+ if (isGood(_Utils_chr(char)))
1049+ {
1050+ return true;
1051+ }
1052+ }
1053+ return false;
1054+});
1055+
1056+var _String_all = F2(function(isGood, string)
1057+{
1058+ var i = string.length;
1059+ while (i--)
1060+ {
1061+ var char = string[i];
1062+ var word = string.charCodeAt(i);
1063+ if (0xDC00 <= word && word <= 0xDFFF)
1064+ {
1065+ i--;
1066+ char = string[i] + char;
1067+ }
1068+ if (!isGood(_Utils_chr(char)))
1069+ {
1070+ return false;
1071+ }
1072+ }
1073+ return true;
1074+});
1075+
1076+var _String_contains = F2(function(sub, str)
1077+{
1078+ return str.indexOf(sub) > -1;
1079+});
1080+
1081+var _String_startsWith = F2(function(sub, str)
1082+{
1083+ return str.indexOf(sub) === 0;
1084+});
1085+
1086+var _String_endsWith = F2(function(sub, str)
1087+{
1088+ return str.length >= sub.length &&
1089+ str.lastIndexOf(sub) === str.length - sub.length;
1090+});
1091+
1092+var _String_indexes = F2(function(sub, str)
1093+{
1094+ var subLen = sub.length;
1095+
1096+ if (subLen < 1)
1097+ {
1098+ return _List_Nil;
1099+ }
1100+
1101+ var i = 0;
1102+ var is = [];
1103+
1104+ while ((i = str.indexOf(sub, i)) > -1)
1105+ {
1106+ is.push(i);
1107+ i = i + subLen;
1108+ }
1109+
1110+ return _List_fromArray(is);
1111+});
1112+
1113+
1114+// TO STRING
1115+
1116+function _String_fromNumber(number)
1117+{
1118+ return number + '';
1119+}
1120+
1121+
1122+// INT CONVERSIONS
1123+
1124+function _String_toInt(str)
1125+{
1126+ var total = 0;
1127+ var code0 = str.charCodeAt(0);
1128+ var start = code0 == 0x2B /* + */ || code0 == 0x2D /* - */ ? 1 : 0;
1129+
1130+ for (var i = start; i < str.length; ++i)
1131+ {
1132+ var code = str.charCodeAt(i);
1133+ if (code < 0x30 || 0x39 < code)
1134+ {
1135+ return $elm$core$Maybe$Nothing;
1136+ }
1137+ total = 10 * total + code - 0x30;
1138+ }
1139+
1140+ return i == start
1141+ ? $elm$core$Maybe$Nothing
1142+ : $elm$core$Maybe$Just(code0 == 0x2D ? -total : total);
1143+}
1144+
1145+
1146+// FLOAT CONVERSIONS
1147+
1148+function _String_toFloat(s)
1149+{
1150+ // check if it is a hex, octal, or binary number
1151+ if (s.length === 0 || /[\sxbo]/.test(s))
1152+ {
1153+ return $elm$core$Maybe$Nothing;
1154+ }
1155+ var n = +s;
1156+ // faster isNaN check
1157+ return n === n ? $elm$core$Maybe$Just(n) : $elm$core$Maybe$Nothing;
1158+}
1159+
1160+function _String_fromList(chars)
1161+{
1162+ return _List_toArray(chars).join('');
1163+}
1164+
1165+
1166+
1167+
1168+function _Char_toCode(char)
1169+{
1170+ var code = char.charCodeAt(0);
1171+ if (0xD800 <= code && code <= 0xDBFF)
1172+ {
1173+ return (code - 0xD800) * 0x400 + char.charCodeAt(1) - 0xDC00 + 0x10000
1174+ }
1175+ return code;
1176+}
1177+
1178+function _Char_fromCode(code)
1179+{
1180+ return _Utils_chr(
1181+ (code < 0 || 0x10FFFF < code)
1182+ ? '\uFFFD'
1183+ :
1184+ (code <= 0xFFFF)
1185+ ? String.fromCharCode(code)
1186+ :
1187+ (code -= 0x10000,
1188+ String.fromCharCode(Math.floor(code / 0x400) + 0xD800, code % 0x400 + 0xDC00)
1189+ )
1190+ );
1191+}
1192+
1193+function _Char_toUpper(char)
1194+{
1195+ return _Utils_chr(char.toUpperCase());
1196+}
1197+
1198+function _Char_toLower(char)
1199+{
1200+ return _Utils_chr(char.toLowerCase());
1201+}
1202+
1203+function _Char_toLocaleUpper(char)
1204+{
1205+ return _Utils_chr(char.toLocaleUpperCase());
1206+}
1207+
1208+function _Char_toLocaleLower(char)
1209+{
1210+ return _Utils_chr(char.toLocaleLowerCase());
1211+}
1212+
1213+
1214+
1215+/**/
1216+function _Json_errorToString(error)
1217+{
1218+ return $elm$json$Json$Decode$errorToString(error);
1219+}
1220+//*/
1221+
1222+
1223+// CORE DECODERS
1224+
1225+function _Json_succeed(msg)
1226+{
1227+ return {
1228+ $: 0,
1229+ a: msg
1230+ };
1231+}
1232+
1233+function _Json_fail(msg)
1234+{
1235+ return {
1236+ $: 1,
1237+ a: msg
1238+ };
1239+}
1240+
1241+function _Json_decodePrim(decoder)
1242+{
1243+ return { $: 2, b: decoder };
1244+}
1245+
1246+var _Json_decodeInt = _Json_decodePrim(function(value) {
1247+ return (typeof value !== 'number')
1248+ ? _Json_expecting('an INT', value)
1249+ :
1250+ (-2147483647 < value && value < 2147483647 && (value | 0) === value)
1251+ ? $elm$core$Result$Ok(value)
1252+ :
1253+ (isFinite(value) && !(value % 1))
1254+ ? $elm$core$Result$Ok(value)
1255+ : _Json_expecting('an INT', value);
1256+});
1257+
1258+var _Json_decodeBool = _Json_decodePrim(function(value) {
1259+ return (typeof value === 'boolean')
1260+ ? $elm$core$Result$Ok(value)
1261+ : _Json_expecting('a BOOL', value);
1262+});
1263+
1264+var _Json_decodeFloat = _Json_decodePrim(function(value) {
1265+ return (typeof value === 'number')
1266+ ? $elm$core$Result$Ok(value)
1267+ : _Json_expecting('a FLOAT', value);
1268+});
1269+
1270+var _Json_decodeValue = _Json_decodePrim(function(value) {
1271+ return $elm$core$Result$Ok(_Json_wrap(value));
1272+});
1273+
1274+var _Json_decodeString = _Json_decodePrim(function(value) {
1275+ return (typeof value === 'string')
1276+ ? $elm$core$Result$Ok(value)
1277+ : (value instanceof String)
1278+ ? $elm$core$Result$Ok(value + '')
1279+ : _Json_expecting('a STRING', value);
1280+});
1281+
1282+function _Json_decodeList(decoder) { return { $: 3, b: decoder }; }
1283+function _Json_decodeArray(decoder) { return { $: 4, b: decoder }; }
1284+
1285+function _Json_decodeNull(value) { return { $: 5, c: value }; }
1286+
1287+var _Json_decodeField = F2(function(field, decoder)
1288+{
1289+ return {
1290+ $: 6,
1291+ d: field,
1292+ b: decoder
1293+ };
1294+});
1295+
1296+var _Json_decodeIndex = F2(function(index, decoder)
1297+{
1298+ return {
1299+ $: 7,
1300+ e: index,
1301+ b: decoder
1302+ };
1303+});
1304+
1305+function _Json_decodeKeyValuePairs(decoder)
1306+{
1307+ return {
1308+ $: 8,
1309+ b: decoder
1310+ };
1311+}
1312+
1313+function _Json_mapMany(f, decoders)
1314+{
1315+ return {
1316+ $: 9,
1317+ f: f,
1318+ g: decoders
1319+ };
1320+}
1321+
1322+var _Json_andThen = F2(function(callback, decoder)
1323+{
1324+ return {
1325+ $: 10,
1326+ b: decoder,
1327+ h: callback
1328+ };
1329+});
1330+
1331+function _Json_oneOf(decoders)
1332+{
1333+ return {
1334+ $: 11,
1335+ g: decoders
1336+ };
1337+}
1338+
1339+
1340+// DECODING OBJECTS
1341+
1342+var _Json_map1 = F2(function(f, d1)
1343+{
1344+ return _Json_mapMany(f, [d1]);
1345+});
1346+
1347+var _Json_map2 = F3(function(f, d1, d2)
1348+{
1349+ return _Json_mapMany(f, [d1, d2]);
1350+});
1351+
1352+var _Json_map3 = F4(function(f, d1, d2, d3)
1353+{
1354+ return _Json_mapMany(f, [d1, d2, d3]);
1355+});
1356+
1357+var _Json_map4 = F5(function(f, d1, d2, d3, d4)
1358+{
1359+ return _Json_mapMany(f, [d1, d2, d3, d4]);
1360+});
1361+
1362+var _Json_map5 = F6(function(f, d1, d2, d3, d4, d5)
1363+{
1364+ return _Json_mapMany(f, [d1, d2, d3, d4, d5]);
1365+});
1366+
1367+var _Json_map6 = F7(function(f, d1, d2, d3, d4, d5, d6)
1368+{
1369+ return _Json_mapMany(f, [d1, d2, d3, d4, d5, d6]);
1370+});
1371+
1372+var _Json_map7 = F8(function(f, d1, d2, d3, d4, d5, d6, d7)
1373+{
1374+ return _Json_mapMany(f, [d1, d2, d3, d4, d5, d6, d7]);
1375+});
1376+
1377+var _Json_map8 = F9(function(f, d1, d2, d3, d4, d5, d6, d7, d8)
1378+{
1379+ return _Json_mapMany(f, [d1, d2, d3, d4, d5, d6, d7, d8]);
1380+});
1381+
1382+
1383+// DECODE
1384+
1385+var _Json_runOnString = F2(function(decoder, string)
1386+{
1387+ try
1388+ {
1389+ var value = JSON.parse(string);
1390+ return _Json_runHelp(decoder, value);
1391+ }
1392+ catch (e)
1393+ {
1394+ return $elm$core$Result$Err(A2($elm$json$Json$Decode$Failure, 'This is not valid JSON! ' + e.message, _Json_wrap(string)));
1395+ }
1396+});
1397+
1398+var _Json_run = F2(function(decoder, value)
1399+{
1400+ return _Json_runHelp(decoder, _Json_unwrap(value));
1401+});
1402+
1403+function _Json_runHelp(decoder, value)
1404+{
1405+ switch (decoder.$)
1406+ {
1407+ case 2:
1408+ return decoder.b(value);
1409+
1410+ case 5:
1411+ return (value === null)
1412+ ? $elm$core$Result$Ok(decoder.c)
1413+ : _Json_expecting('null', value);
1414+
1415+ case 3:
1416+ if (!_Json_isArray(value))
1417+ {
1418+ return _Json_expecting('a LIST', value);
1419+ }
1420+ return _Json_runArrayDecoder(decoder.b, value, _List_fromArray);
1421+
1422+ case 4:
1423+ if (!_Json_isArray(value))
1424+ {
1425+ return _Json_expecting('an ARRAY', value);
1426+ }
1427+ return _Json_runArrayDecoder(decoder.b, value, _Json_toElmArray);
1428+
1429+ case 6:
1430+ var field = decoder.d;
1431+ if (typeof value !== 'object' || value === null || !(field in value))
1432+ {
1433+ return _Json_expecting('an OBJECT with a field named `' + field + '`', value);
1434+ }
1435+ var result = _Json_runHelp(decoder.b, value[field]);
1436+ return ($elm$core$Result$isOk(result)) ? result : $elm$core$Result$Err(A2($elm$json$Json$Decode$Field, field, result.a));
1437+
1438+ case 7:
1439+ var index = decoder.e;
1440+ if (!_Json_isArray(value))
1441+ {
1442+ return _Json_expecting('an ARRAY', value);
1443+ }
1444+ if (index >= value.length)
1445+ {
1446+ return _Json_expecting('a LONGER array. Need index ' + index + ' but only see ' + value.length + ' entries', value);
1447+ }
1448+ var result = _Json_runHelp(decoder.b, value[index]);
1449+ return ($elm$core$Result$isOk(result)) ? result : $elm$core$Result$Err(A2($elm$json$Json$Decode$Index, index, result.a));
1450+
1451+ case 8:
1452+ if (typeof value !== 'object' || value === null || _Json_isArray(value))
1453+ {
1454+ return _Json_expecting('an OBJECT', value);
1455+ }
1456+
1457+ var keyValuePairs = _List_Nil;
1458+ // TODO test perf of Object.keys and switch when support is good enough
1459+ for (var key in value)
1460+ {
1461+ if (value.hasOwnProperty(key))
1462+ {
1463+ var result = _Json_runHelp(decoder.b, value[key]);
1464+ if (!$elm$core$Result$isOk(result))
1465+ {
1466+ return $elm$core$Result$Err(A2($elm$json$Json$Decode$Field, key, result.a));
1467+ }
1468+ keyValuePairs = _List_Cons(_Utils_Tuple2(key, result.a), keyValuePairs);
1469+ }
1470+ }
1471+ return $elm$core$Result$Ok($elm$core$List$reverse(keyValuePairs));
1472+
1473+ case 9:
1474+ var answer = decoder.f;
1475+ var decoders = decoder.g;
1476+ for (var i = 0; i < decoders.length; i++)
1477+ {
1478+ var result = _Json_runHelp(decoders[i], value);
1479+ if (!$elm$core$Result$isOk(result))
1480+ {
1481+ return result;
1482+ }
1483+ answer = answer(result.a);
1484+ }
1485+ return $elm$core$Result$Ok(answer);
1486+
1487+ case 10:
1488+ var result = _Json_runHelp(decoder.b, value);
1489+ return (!$elm$core$Result$isOk(result))
1490+ ? result
1491+ : _Json_runHelp(decoder.h(result.a), value);
1492+
1493+ case 11:
1494+ var errors = _List_Nil;
1495+ for (var temp = decoder.g; temp.b; temp = temp.b) // WHILE_CONS
1496+ {
1497+ var result = _Json_runHelp(temp.a, value);
1498+ if ($elm$core$Result$isOk(result))
1499+ {
1500+ return result;
1501+ }
1502+ errors = _List_Cons(result.a, errors);
1503+ }
1504+ return $elm$core$Result$Err($elm$json$Json$Decode$OneOf($elm$core$List$reverse(errors)));
1505+
1506+ case 1:
1507+ return $elm$core$Result$Err(A2($elm$json$Json$Decode$Failure, decoder.a, _Json_wrap(value)));
1508+
1509+ case 0:
1510+ return $elm$core$Result$Ok(decoder.a);
1511+ }
1512+}
1513+
1514+function _Json_runArrayDecoder(decoder, value, toElmValue)
1515+{
1516+ var len = value.length;
1517+ var array = new Array(len);
1518+ for (var i = 0; i < len; i++)
1519+ {
1520+ var result = _Json_runHelp(decoder, value[i]);
1521+ if (!$elm$core$Result$isOk(result))
1522+ {
1523+ return $elm$core$Result$Err(A2($elm$json$Json$Decode$Index, i, result.a));
1524+ }
1525+ array[i] = result.a;
1526+ }
1527+ return $elm$core$Result$Ok(toElmValue(array));
1528+}
1529+
1530+function _Json_isArray(value)
1531+{
1532+ return Array.isArray(value) || (typeof FileList !== 'undefined' && value instanceof FileList);
1533+}
1534+
1535+function _Json_toElmArray(array)
1536+{
1537+ return A2($elm$core$Array$initialize, array.length, function(i) { return array[i]; });
1538+}
1539+
1540+function _Json_expecting(type, value)
1541+{
1542+ return $elm$core$Result$Err(A2($elm$json$Json$Decode$Failure, 'Expecting ' + type, _Json_wrap(value)));
1543+}
1544+
1545+
1546+// EQUALITY
1547+
1548+function _Json_equality(x, y)
1549+{
1550+ if (x === y)
1551+ {
1552+ return true;
1553+ }
1554+
1555+ if (x.$ !== y.$)
1556+ {
1557+ return false;
1558+ }
1559+
1560+ switch (x.$)
1561+ {
1562+ case 0:
1563+ case 1:
1564+ return x.a === y.a;
1565+
1566+ case 2:
1567+ return x.b === y.b;
1568+
1569+ case 5:
1570+ return x.c === y.c;
1571+
1572+ case 3:
1573+ case 4:
1574+ case 8:
1575+ return _Json_equality(x.b, y.b);
1576+
1577+ case 6:
1578+ return x.d === y.d && _Json_equality(x.b, y.b);
1579+
1580+ case 7:
1581+ return x.e === y.e && _Json_equality(x.b, y.b);
1582+
1583+ case 9:
1584+ return x.f === y.f && _Json_listEquality(x.g, y.g);
1585+
1586+ case 10:
1587+ return x.h === y.h && _Json_equality(x.b, y.b);
1588+
1589+ case 11:
1590+ return _Json_listEquality(x.g, y.g);
1591+ }
1592+}
1593+
1594+function _Json_listEquality(aDecoders, bDecoders)
1595+{
1596+ var len = aDecoders.length;
1597+ if (len !== bDecoders.length)
1598+ {
1599+ return false;
1600+ }
1601+ for (var i = 0; i < len; i++)
1602+ {
1603+ if (!_Json_equality(aDecoders[i], bDecoders[i]))
1604+ {
1605+ return false;
1606+ }
1607+ }
1608+ return true;
1609+}
1610+
1611+
1612+// ENCODE
1613+
1614+var _Json_encode = F2(function(indentLevel, value)
1615+{
1616+ return JSON.stringify(_Json_unwrap(value), null, indentLevel) + '';
1617+});
1618+
1619+function _Json_wrap(value) { return { $: 0, a: value }; }
1620+function _Json_unwrap(value) { return value.a; }
1621+
1622+function _Json_wrap_UNUSED(value) { return value; }
1623+function _Json_unwrap_UNUSED(value) { return value; }
1624+
1625+function _Json_emptyArray() { return []; }
1626+function _Json_emptyObject() { return {}; }
1627+
1628+var _Json_addField = F3(function(key, value, object)
1629+{
1630+ object[key] = _Json_unwrap(value);
1631+ return object;
1632+});
1633+
1634+function _Json_addEntry(func)
1635+{
1636+ return F2(function(entry, array)
1637+ {
1638+ array.push(_Json_unwrap(func(entry)));
1639+ return array;
1640+ });
1641+}
1642+
1643+var _Json_encodeNull = _Json_wrap(null);
1644+
1645+
1646+
1647+var _Lynx_g = (typeof globalThis !== 'undefined' ? globalThis : scope);
1648+function _Lynx_papi(name) { return _Lynx_g['_' + '_' + name] || function() {}; }
1649+function _Lynx_createElement(tag) {
1650+ var pId = (_Lynx_g['native'] && _Lynx_g['native']['currentPageId']) || 0;
1651+ var creators = { 'view': 'CreateView', 'text': 'CreateText', 'image': 'CreateImage' };
1652+ var name = creators[tag] || 'CreateView';
1653+ var fn = _Lynx_g['_' + '_' + name];
1654+ if (typeof fn === 'function') { return fn(pId); }
1655+ return _Lynx_papi('CreateElement')(tag, pId);
1656+}
1657+function _Lynx_createRawText(text) {
1658+ var fn = _Lynx_g['_' + '_CreateRawText'];
1659+ if (typeof fn === 'function') { return fn(text); }
1660+ return {};
1661+}
1662+var _Lynx_appendChild = _Lynx_papi('AppendElement');
1663+var _Lynx_removeElement = _Lynx_papi('RemoveElement');
1664+var _Lynx_replaceElement = _Lynx_papi('ReplaceElement');
1665+var _Lynx_insertBefore = _Lynx_papi('InsertElementBefore');
1666+var _Lynx_setAttribute = _Lynx_papi('SetAttribute');
1667+var _Lynx_getChildren = _Lynx_g['_' + '_GetChildren'] || function() { return []; };
1668+var _Lynx_getParent = _Lynx_g['_' + '_GetParent'] || function() { return null; };
1669+var _Lynx_addEvent = _Lynx_papi('AddEvent');
1670+var _Lynx_setInlineStyles = _Lynx_papi('SetInlineStyles');
1671+var _VirtualDom_elementMeta = new Map();
1672+function _VirtualDom_getMeta(el) {
1673+ var meta = _VirtualDom_elementMeta.get(el);
1674+ if (!meta) { meta = {}; _VirtualDom_elementMeta.set(el, meta); }
1675+ return meta;
1676+}
1677+
1678+
1679+// HELPERS
1680+
1681+
1682+
1683+
1684+
1685+function _VirtualDom_appendChild(parent, child)
1686+{
1687+ _Lynx_appendChild(parent, child);
1688+}
1689+
1690+var _VirtualDom_init = F4(function(virtualNode, flagDecoder, debugMetadata, args)
1691+{
1692+ // NOTE: this function needs _Platform_export available to work
1693+ var rootPage = args['node'] || _Lynx_g['page'];
1694+ var tree = _VirtualDom_render(virtualNode, function() {});
1695+ _Lynx_appendChild(rootPage, tree);
1696+ return {};
1697+});
1698+
1699+
1700+
1701+// TEXT
1702+
1703+
1704+function _VirtualDom_text(string)
1705+{
1706+ return {
1707+ $: 0,
1708+ a: string
1709+ };
1710+}
1711+
1712+
1713+
1714+// NODE
1715+
1716+
1717+var _VirtualDom_nodeNS = F2(function(namespace, tag)
1718+{
1719+ return F2(function(factList, kidList)
1720+ {
1721+ for (var kids = [], descendantsCount = 0; kidList.b; kidList = kidList.b) // WHILE_CONS
1722+ {
1723+ var kid = kidList.a;
1724+ descendantsCount += (kid.b || 0);
1725+ kids.push(kid);
1726+ }
1727+ descendantsCount += kids.length;
1728+
1729+ return {
1730+ $: 1,
1731+ c: tag,
1732+ d: _VirtualDom_organizeFacts(factList),
1733+ e: kids,
1734+ f: namespace,
1735+ b: descendantsCount
1736+ };
1737+ });
1738+});
1739+
1740+
1741+var _VirtualDom_node = _VirtualDom_nodeNS(undefined);
1742+
1743+
1744+
1745+// KEYED NODE
1746+
1747+
1748+var _VirtualDom_keyedNodeNS = F2(function(namespace, tag)
1749+{
1750+ return F2(function(factList, kidList)
1751+ {
1752+ for (var kids = [], descendantsCount = 0; kidList.b; kidList = kidList.b) // WHILE_CONS
1753+ {
1754+ var kid = kidList.a;
1755+ descendantsCount += (kid.b.b || 0);
1756+ kids.push(kid);
1757+ }
1758+ descendantsCount += kids.length;
1759+
1760+ return {
1761+ $: 2,
1762+ c: tag,
1763+ d: _VirtualDom_organizeFacts(factList),
1764+ e: kids,
1765+ f: namespace,
1766+ b: descendantsCount
1767+ };
1768+ });
1769+});
1770+
1771+
1772+var _VirtualDom_keyedNode = _VirtualDom_keyedNodeNS(undefined);
1773+
1774+
1775+
1776+// CUSTOM
1777+
1778+
1779+function _VirtualDom_custom(factList, model, render, diff)
1780+{
1781+ return {
1782+ $: 3,
1783+ d: _VirtualDom_organizeFacts(factList),
1784+ g: model,
1785+ h: render,
1786+ i: diff
1787+ };
1788+}
1789+
1790+
1791+
1792+// MAP
1793+
1794+
1795+var _VirtualDom_map = F2(function(tagger, node)
1796+{
1797+ return {
1798+ $: 4,
1799+ j: tagger,
1800+ k: node,
1801+ b: 1 + (node.b || 0)
1802+ };
1803+});
1804+
1805+
1806+
1807+// LAZY
1808+
1809+
1810+function _VirtualDom_thunk(refs, thunk)
1811+{
1812+ return {
1813+ $: 5,
1814+ l: refs,
1815+ m: thunk,
1816+ k: undefined
1817+ };
1818+}
1819+
1820+var _VirtualDom_lazy = F2(function(func, a)
1821+{
1822+ return _VirtualDom_thunk([func, a], function() {
1823+ return func(a);
1824+ });
1825+});
1826+
1827+var _VirtualDom_lazy2 = F3(function(func, a, b)
1828+{
1829+ return _VirtualDom_thunk([func, a, b], function() {
1830+ return A2(func, a, b);
1831+ });
1832+});
1833+
1834+var _VirtualDom_lazy3 = F4(function(func, a, b, c)
1835+{
1836+ return _VirtualDom_thunk([func, a, b, c], function() {
1837+ return A3(func, a, b, c);
1838+ });
1839+});
1840+
1841+var _VirtualDom_lazy4 = F5(function(func, a, b, c, d)
1842+{
1843+ return _VirtualDom_thunk([func, a, b, c, d], function() {
1844+ return A4(func, a, b, c, d);
1845+ });
1846+});
1847+
1848+var _VirtualDom_lazy5 = F6(function(func, a, b, c, d, e)
1849+{
1850+ return _VirtualDom_thunk([func, a, b, c, d, e], function() {
1851+ return A5(func, a, b, c, d, e);
1852+ });
1853+});
1854+
1855+var _VirtualDom_lazy6 = F7(function(func, a, b, c, d, e, f)
1856+{
1857+ return _VirtualDom_thunk([func, a, b, c, d, e, f], function() {
1858+ return A6(func, a, b, c, d, e, f);
1859+ });
1860+});
1861+
1862+var _VirtualDom_lazy7 = F8(function(func, a, b, c, d, e, f, g)
1863+{
1864+ return _VirtualDom_thunk([func, a, b, c, d, e, f, g], function() {
1865+ return A7(func, a, b, c, d, e, f, g);
1866+ });
1867+});
1868+
1869+var _VirtualDom_lazy8 = F9(function(func, a, b, c, d, e, f, g, h)
1870+{
1871+ return _VirtualDom_thunk([func, a, b, c, d, e, f, g, h], function() {
1872+ return A8(func, a, b, c, d, e, f, g, h);
1873+ });
1874+});
1875+
1876+
1877+
1878+// FACTS
1879+
1880+
1881+var _VirtualDom_on = F2(function(key, handler)
1882+{
1883+ return {
1884+ $: 'a0',
1885+ n: key,
1886+ o: handler
1887+ };
1888+});
1889+var _VirtualDom_style = F2(function(key, value)
1890+{
1891+ return {
1892+ $: 'a1',
1893+ n: key,
1894+ o: value
1895+ };
1896+});
1897+var _VirtualDom_property = F2(function(key, value)
1898+{
1899+ return {
1900+ $: 'a2',
1901+ n: key,
1902+ o: value
1903+ };
1904+});
1905+var _VirtualDom_attribute = F2(function(key, value)
1906+{
1907+ return {
1908+ $: 'a3',
1909+ n: key,
1910+ o: value
1911+ };
1912+});
1913+var _VirtualDom_attributeNS = F3(function(namespace, key, value)
1914+{
1915+ return {
1916+ $: 'a4',
1917+ n: key,
1918+ o: { f: namespace, o: value }
1919+ };
1920+});
1921+
1922+
1923+
1924+// XSS ATTACK VECTOR CHECKS
1925+//
1926+// For some reason, tabs can appear in href protocols and it still works.
1927+// So '\tjava\tSCRIPT:alert("!!!")' and 'javascript:alert("!!!")' are the same
1928+// in practice. That is why _VirtualDom_RE_js and _VirtualDom_RE_js_html look
1929+// so freaky.
1930+//
1931+// Pulling the regular expressions out to the top level gives a slight speed
1932+// boost in small benchmarks (4-10%) but hoisting values to reduce allocation
1933+// can be unpredictable in large programs where JIT may have a harder time with
1934+// functions are not fully self-contained. The benefit is more that the js and
1935+// js_html ones are so weird that I prefer to see them near each other.
1936+
1937+
1938+
1939+
1940+
1941+function _VirtualDom_noScript(tag)
1942+{
1943+ return tag;
1944+}
1945+
1946+function _VirtualDom_noOnOrFormAction(key)
1947+{
1948+ return key;
1949+}
1950+
1951+function _VirtualDom_noInnerHtmlOrFormAction(key)
1952+{
1953+ return key;
1954+}
1955+
1956+function _VirtualDom_noJavaScriptUri(value)
1957+{
1958+ return value;
1959+}
1960+
1961+function _VirtualDom_noJavaScriptOrHtmlUri(value)
1962+{
1963+ return value;
1964+}
1965+
1966+function _VirtualDom_noJavaScriptOrHtmlJson(value)
1967+{
1968+ return value;
1969+}
1970+
1971+
1972+
1973+// MAP FACTS
1974+
1975+
1976+var _VirtualDom_mapAttribute = F2(function(func, attr)
1977+{
1978+ return (attr.$ === 'a0')
1979+ ? A2(_VirtualDom_on, attr.n, _VirtualDom_mapHandler(func, attr.o))
1980+ : attr;
1981+});
1982+
1983+function _VirtualDom_mapHandler(func, handler)
1984+{
1985+ var tag = $lynxjs_elm$virtual_dom$VirtualDom$toHandlerInt(handler);
1986+
1987+ // 0 = Normal
1988+ // 1 = MayStopPropagation
1989+ // 2 = MayPreventDefault
1990+ // 3 = Custom
1991+
1992+ return {
1993+ $: handler.$,
1994+ a:
1995+ !tag
1996+ ? A2($elm$json$Json$Decode$map, func, handler.a)
1997+ :
1998+ A3($elm$json$Json$Decode$map2,
1999+ tag < 3
2000+ ? _VirtualDom_mapEventTuple
2001+ : _VirtualDom_mapEventRecord,
2002+ $elm$json$Json$Decode$succeed(func),
2003+ handler.a
2004+ )
2005+ };
2006+}
2007+
2008+var _VirtualDom_mapEventTuple = F2(function(func, tuple)
2009+{
2010+ return _Utils_Tuple2(func(tuple.a), tuple.b);
2011+});
2012+
2013+var _VirtualDom_mapEventRecord = F2(function(func, record)
2014+{
2015+ return {
2016+ message: func(record.message),
2017+ stopPropagation: record.stopPropagation,
2018+ preventDefault: record.preventDefault
2019+ }
2020+});
2021+
2022+
2023+
2024+// ORGANIZE FACTS
2025+
2026+
2027+function _VirtualDom_organizeFacts(factList)
2028+{
2029+ for (var facts = {}; factList.b; factList = factList.b) // WHILE_CONS
2030+ {
2031+ var entry = factList.a;
2032+
2033+ var tag = entry.$;
2034+ var key = entry.n;
2035+ var value = entry.o;
2036+
2037+ if (tag === 'a2')
2038+ {
2039+ (key === 'className')
2040+ ? _VirtualDom_addClass(facts, key, _Json_unwrap(value))
2041+ : facts[key] = _Json_unwrap(value);
2042+
2043+ continue;
2044+ }
2045+
2046+ var subFacts = facts[tag] || (facts[tag] = {});
2047+ (tag === 'a3' && key === 'class')
2048+ ? _VirtualDom_addClass(subFacts, key, value)
2049+ : subFacts[key] = value;
2050+ }
2051+
2052+ return facts;
2053+}
2054+
2055+function _VirtualDom_addClass(object, key, newClass)
2056+{
2057+ var classes = object[key];
2058+ object[key] = classes ? classes + ' ' + newClass : newClass;
2059+}
2060+
2061+
2062+
2063+// RENDER
2064+
2065+
2066+function _VirtualDom_render(vNode, eventNode)
2067+{
2068+ var tag = vNode.$;
2069+
2070+ if (tag === 5)
2071+ {
2072+ return _VirtualDom_render(vNode.k || (vNode.k = vNode.m()), eventNode);
2073+ }
2074+
2075+ if (tag === 0)
2076+ {
2077+ return _Lynx_createRawText(vNode.a);
2078+ }
2079+
2080+ if (tag === 4)
2081+ {
2082+ var subNode = vNode.k;
2083+ var tagger = vNode.j;
2084+
2085+ while (subNode.$ === 4)
2086+ {
2087+ typeof tagger !== 'object'
2088+ ? tagger = [tagger, subNode.j]
2089+ : tagger.push(subNode.j);
2090+
2091+ subNode = subNode.k;
2092+ }
2093+
2094+ var subEventRoot = { j: tagger, p: eventNode };
2095+ var domNode = _VirtualDom_render(subNode, subEventRoot);
2096+ _VirtualDom_getMeta(domNode).elm_event_node_ref = subEventRoot;
2097+ return domNode;
2098+ }
2099+
2100+ if (tag === 3)
2101+ {
2102+ var domNode = vNode.h(vNode.g);
2103+ _VirtualDom_applyFacts(domNode, eventNode, vNode.d);
2104+ return domNode;
2105+ }
2106+
2107+ // at this point `tag` must be 1 or 2
2108+
2109+ var domNode = _Lynx_createElement(vNode.c);
2110+
2111+ _VirtualDom_applyFacts(domNode, eventNode, vNode.d);
2112+
2113+ for (var kids = vNode.e, i = 0; i < kids.length; i++)
2114+ {
2115+ var kid = tag === 1 ? kids[i] : kids[i].b;
2116+ if (kid.$ === 0)
2117+ {
2118+ _Lynx_appendChild(domNode, _Lynx_createRawText(kid.a));
2119+ }
2120+ else
2121+ {
2122+ _VirtualDom_appendChild(domNode, _VirtualDom_render(kid, eventNode));
2123+ }
2124+ }
2125+
2126+ return domNode;
2127+}
2128+
2129+
2130+
2131+// APPLY FACTS
2132+
2133+
2134+function _VirtualDom_applyFacts(domNode, eventNode, facts)
2135+{
2136+ for (var key in facts)
2137+ {
2138+ var value = facts[key];
2139+
2140+ key === 'a1'
2141+ ? _VirtualDom_applyStyles(domNode, value)
2142+ :
2143+ key === 'a0'
2144+ ? _VirtualDom_applyEvents(domNode, eventNode, value)
2145+ :
2146+ key === 'a3'
2147+ ? _VirtualDom_applyAttrs(domNode, value)
2148+ :
2149+ key === 'a4'
2150+ ? _VirtualDom_applyAttrsNS(domNode, value)
2151+ :
2152+ (key !== 'value' && key !== 'checked' || domNode[key] !== value) && _Lynx_setAttribute(domNode, key === 'className' ? 'class' : key, String(value));
2153+ }
2154+}
2155+
2156+
2157+
2158+// APPLY STYLES
2159+
2160+
2161+function _VirtualDom_applyStyles(domNode, styles)
2162+{
2163+ var _sIS = _Lynx_g['_' + '_SetInlineStyles'];
2164+ if (typeof _sIS === 'function')
2165+ {
2166+ _sIS(domNode, styles);
2167+ }
2168+}
2169+
2170+
2171+
2172+// APPLY ATTRS
2173+
2174+
2175+function _VirtualDom_applyAttrs(domNode, attrs)
2176+{
2177+ for (var key in attrs)
2178+ {
2179+ var value = attrs[key];
2180+ if (typeof value !== 'undefined')
2181+ {
2182+ _Lynx_setAttribute(domNode, key, value);
2183+ }
2184+ }
2185+}
2186+
2187+
2188+
2189+// APPLY NAMESPACED ATTRS
2190+
2191+
2192+function _VirtualDom_applyAttrsNS(domNode, nsAttrs)
2193+{
2194+ for (var key in nsAttrs)
2195+ {
2196+ var pair = nsAttrs[key];
2197+ var value = pair.o;
2198+
2199+ if (typeof value !== 'undefined')
2200+ {
2201+ _Lynx_setAttribute(domNode, key, value);
2202+ }
2203+ }
2204+}
2205+
2206+
2207+
2208+// APPLY EVENTS
2209+
2210+
2211+function _VirtualDom_applyEvents(domNode, eventNode, events)
2212+{
2213+ var meta = _VirtualDom_getMeta(domNode);
2214+ var allCallbacks = meta.elmFs || (meta.elmFs = {});
2215+
2216+ for (var key in events)
2217+ {
2218+ var newHandler = events[key];
2219+ var oldCallback = allCallbacks[key];
2220+
2221+ if (!newHandler)
2222+ {
2223+ allCallbacks[key] = undefined;
2224+ continue;
2225+ }
2226+
2227+ if (oldCallback)
2228+ {
2229+ var oldHandler = oldCallback.q;
2230+ if (oldHandler.$ === newHandler.$)
2231+ {
2232+ oldCallback.q = newHandler;
2233+ continue;
2234+ }
2235+ }
2236+
2237+ oldCallback = _VirtualDom_makeCallback(eventNode, newHandler);
2238+ allCallbacks[key] = oldCallback;
2239+
2240+ var lynxEventName = _VirtualDom_mapEventName(key);
2241+ var handlerType = $lynxjs_elm$virtual_dom$VirtualDom$toHandlerInt(newHandler);
2242+ var prefix = (handlerType === 1) ? 'catch' : 'bind';
2243+ _Lynx_addEvent(domNode, 'catchEvent', lynxEventName, { type: 'worklet', value: oldCallback });
2244+ }
2245+}
2246+
2247+function _VirtualDom_mapEventName(name)
2248+{
2249+ switch (name)
2250+ {
2251+ case 'click': return 'tap';
2252+ case 'dblclick': return 'tap';
2253+ case 'mousedown': return 'touchstart';
2254+ case 'mousemove': return 'touchmove';
2255+ case 'mouseup': return 'touchend';
2256+ default: return name;
2257+ }
2258+}
2259+
2260+
2261+
2262+// PASSIVE EVENTS
2263+
2264+
2265+
2266+// EVENT HANDLERS
2267+
2268+
2269+function _VirtualDom_makeCallback(eventNode, initialHandler)
2270+{
2271+ function callback(event)
2272+ {
2273+ var handler = callback.q;
2274+ var result = _Json_runHelp(handler.a, event);
2275+
2276+ if (!$elm$core$Result$isOk(result))
2277+ {
2278+ return;
2279+ }
2280+
2281+ var tag = $lynxjs_elm$virtual_dom$VirtualDom$toHandlerInt(handler);
2282+
2283+ // 0 = Normal
2284+ // 1 = MayStopPropagation
2285+ // 2 = MayPreventDefault
2286+ // 3 = Custom
2287+
2288+ var value = result.a;
2289+ var message = !tag ? value : tag < 3 ? value.a : value.message;
2290+ var stopPropagation = tag == 1 ? value.b : tag == 3 && value.stopPropagation;
2291+ var currentEventNode = eventNode;
2292+ var tagger;
2293+ var i;
2294+ while (tagger = currentEventNode.j)
2295+ {
2296+ if (typeof tagger == 'function')
2297+ {
2298+ message = tagger(message);
2299+ }
2300+ else
2301+ {
2302+ for (var i = tagger.length; i--; )
2303+ {
2304+ message = tagger[i](message);
2305+ }
2306+ }
2307+ currentEventNode = currentEventNode.p;
2308+ }
2309+ currentEventNode(message, stopPropagation); // stopPropagation implies isSync
2310+ }
2311+
2312+ callback.q = initialHandler;
2313+
2314+ return callback;
2315+}
2316+
2317+function _VirtualDom_equalEvents(x, y)
2318+{
2319+ return x.$ == y.$ && _Json_equality(x.a, y.a);
2320+}
2321+
2322+
2323+
2324+// DIFF
2325+
2326+
2327+// TODO: Should we do patches like in iOS?
2328+//
2329+// type Patch
2330+// = At Int Patch
2331+// | Batch (List Patch)
2332+// | Change ...
2333+//
2334+// How could it not be better?
2335+//
2336+function _VirtualDom_diff(x, y)
2337+{
2338+ var patches = [];
2339+ _VirtualDom_diffHelp(x, y, patches, 0);
2340+ return patches;
2341+}
2342+
2343+
2344+function _VirtualDom_pushPatch(patches, type, index, data)
2345+{
2346+ var patch = {
2347+ $: type,
2348+ r: index,
2349+ s: data,
2350+ t: undefined,
2351+ u: undefined
2352+ };
2353+ patches.push(patch);
2354+ return patch;
2355+}
2356+
2357+
2358+function _VirtualDom_diffHelp(x, y, patches, index)
2359+{
2360+ if (x === y)
2361+ {
2362+ return;
2363+ }
2364+
2365+ var xType = x.$;
2366+ var yType = y.$;
2367+
2368+ // Bail if you run into different types of nodes. Implies that the
2369+ // structure has changed significantly and it's not worth a diff.
2370+ if (xType !== yType)
2371+ {
2372+ if (xType === 1 && yType === 2)
2373+ {
2374+ y = _VirtualDom_dekey(y);
2375+ yType = 1;
2376+ }
2377+ else
2378+ {
2379+ _VirtualDom_pushPatch(patches, 0, index, y);
2380+ return;
2381+ }
2382+ }
2383+
2384+ // Now we know that both nodes are the same $.
2385+ switch (yType)
2386+ {
2387+ case 5:
2388+ var xRefs = x.l;
2389+ var yRefs = y.l;
2390+ var i = xRefs.length;
2391+ var same = i === yRefs.length;
2392+ while (same && i--)
2393+ {
2394+ same = xRefs[i] === yRefs[i];
2395+ }
2396+ if (same)
2397+ {
2398+ y.k = x.k;
2399+ return;
2400+ }
2401+ y.k = y.m();
2402+ var subPatches = [];
2403+ _VirtualDom_diffHelp(x.k, y.k, subPatches, 0);
2404+ subPatches.length > 0 && _VirtualDom_pushPatch(patches, 1, index, subPatches);
2405+ return;
2406+
2407+ case 4:
2408+ // gather nested taggers
2409+ var xTaggers = x.j;
2410+ var yTaggers = y.j;
2411+ var nesting = false;
2412+
2413+ var xSubNode = x.k;
2414+ while (xSubNode.$ === 4)
2415+ {
2416+ nesting = true;
2417+
2418+ typeof xTaggers !== 'object'
2419+ ? xTaggers = [xTaggers, xSubNode.j]
2420+ : xTaggers.push(xSubNode.j);
2421+
2422+ xSubNode = xSubNode.k;
2423+ }
2424+
2425+ var ySubNode = y.k;
2426+ while (ySubNode.$ === 4)
2427+ {
2428+ nesting = true;
2429+
2430+ typeof yTaggers !== 'object'
2431+ ? yTaggers = [yTaggers, ySubNode.j]
2432+ : yTaggers.push(ySubNode.j);
2433+
2434+ ySubNode = ySubNode.k;
2435+ }
2436+
2437+ // Just bail if different numbers of taggers. This implies the
2438+ // structure of the virtual DOM has changed.
2439+ if (nesting && xTaggers.length !== yTaggers.length)
2440+ {
2441+ _VirtualDom_pushPatch(patches, 0, index, y);
2442+ return;
2443+ }
2444+
2445+ // check if taggers are "the same"
2446+ if (nesting ? !_VirtualDom_pairwiseRefEqual(xTaggers, yTaggers) : xTaggers !== yTaggers)
2447+ {
2448+ _VirtualDom_pushPatch(patches, 2, index, yTaggers);
2449+ }
2450+
2451+ // diff everything below the taggers
2452+ _VirtualDom_diffHelp(xSubNode, ySubNode, patches, index + 1);
2453+ return;
2454+
2455+ case 0:
2456+ if (x.a !== y.a)
2457+ {
2458+ _VirtualDom_pushPatch(patches, 3, index, y.a);
2459+ }
2460+ return;
2461+
2462+ case 1:
2463+ _VirtualDom_diffNodes(x, y, patches, index, _VirtualDom_diffKids);
2464+ return;
2465+
2466+ case 2:
2467+ _VirtualDom_diffNodes(x, y, patches, index, _VirtualDom_diffKeyedKids);
2468+ return;
2469+
2470+ case 3:
2471+ if (x.h !== y.h)
2472+ {
2473+ _VirtualDom_pushPatch(patches, 0, index, y);
2474+ return;
2475+ }
2476+
2477+ var factsDiff = _VirtualDom_diffFacts(x.d, y.d);
2478+ factsDiff && _VirtualDom_pushPatch(patches, 4, index, factsDiff);
2479+
2480+ var patch = y.i(x.g, y.g);
2481+ patch && _VirtualDom_pushPatch(patches, 5, index, patch);
2482+
2483+ return;
2484+ }
2485+}
2486+
2487+// assumes the incoming arrays are the same length
2488+function _VirtualDom_pairwiseRefEqual(as, bs)
2489+{
2490+ for (var i = 0; i < as.length; i++)
2491+ {
2492+ if (as[i] !== bs[i])
2493+ {
2494+ return false;
2495+ }
2496+ }
2497+
2498+ return true;
2499+}
2500+
2501+function _VirtualDom_diffNodes(x, y, patches, index, diffKids)
2502+{
2503+ // Bail if obvious indicators have changed. Implies more serious
2504+ // structural changes such that it's not worth it to diff.
2505+ if (x.c !== y.c || x.f !== y.f)
2506+ {
2507+ _VirtualDom_pushPatch(patches, 0, index, y);
2508+ return;
2509+ }
2510+
2511+ var factsDiff = _VirtualDom_diffFacts(x.d, y.d);
2512+ factsDiff && _VirtualDom_pushPatch(patches, 4, index, factsDiff);
2513+
2514+ diffKids(x, y, patches, index);
2515+}
2516+
2517+
2518+
2519+// DIFF FACTS
2520+
2521+
2522+// TODO Instead of creating a new diff object, it's possible to just test if
2523+// there *is* a diff. During the actual patch, do the diff again and make the
2524+// modifications directly. This way, there's no new allocations. Worth it?
2525+function _VirtualDom_diffFacts(x, y, category)
2526+{
2527+ var diff;
2528+
2529+ // look for changes and removals
2530+ for (var xKey in x)
2531+ {
2532+ if (xKey === 'a1' || xKey === 'a0' || xKey === 'a3' || xKey === 'a4')
2533+ {
2534+ var subDiff = _VirtualDom_diffFacts(x[xKey], y[xKey] || {}, xKey);
2535+ if (subDiff)
2536+ {
2537+ diff = diff || {};
2538+ diff[xKey] = subDiff;
2539+ }
2540+ continue;
2541+ }
2542+
2543+ // remove if not in the new facts
2544+ if (!(xKey in y))
2545+ {
2546+ diff = diff || {};
2547+ diff[xKey] =
2548+ !category
2549+ ? (typeof x[xKey] === 'string' ? '' : null)
2550+ :
2551+ (category === 'a1')
2552+ ? ''
2553+ :
2554+ (category === 'a0' || category === 'a3')
2555+ ? undefined
2556+ :
2557+ { f: x[xKey].f, o: undefined };
2558+
2559+ continue;
2560+ }
2561+
2562+ var xValue = x[xKey];
2563+ var yValue = y[xKey];
2564+
2565+ // reference equal, so don't worry about it
2566+ if (xValue === yValue && xKey !== 'value' && xKey !== 'checked'
2567+ || category === 'a0' && _VirtualDom_equalEvents(xValue, yValue))
2568+ {
2569+ continue;
2570+ }
2571+
2572+ diff = diff || {};
2573+ diff[xKey] = yValue;
2574+ }
2575+
2576+ // add new stuff
2577+ for (var yKey in y)
2578+ {
2579+ if (!(yKey in x))
2580+ {
2581+ diff = diff || {};
2582+ diff[yKey] = y[yKey];
2583+ }
2584+ }
2585+
2586+ return diff;
2587+}
2588+
2589+
2590+
2591+// DIFF KIDS
2592+
2593+
2594+function _VirtualDom_diffKids(xParent, yParent, patches, index)
2595+{
2596+ var xKids = xParent.e;
2597+ var yKids = yParent.e;
2598+
2599+ var xLen = xKids.length;
2600+ var yLen = yKids.length;
2601+
2602+ // FIGURE OUT IF THERE ARE INSERTS OR REMOVALS
2603+
2604+ if (xLen > yLen)
2605+ {
2606+ _VirtualDom_pushPatch(patches, 6, index, {
2607+ v: yLen,
2608+ i: xLen - yLen
2609+ });
2610+ }
2611+ else if (xLen < yLen)
2612+ {
2613+ _VirtualDom_pushPatch(patches, 7, index, {
2614+ v: xLen,
2615+ e: yKids
2616+ });
2617+ }
2618+
2619+ // PAIRWISE DIFF EVERYTHING ELSE
2620+
2621+ for (var minLen = xLen < yLen ? xLen : yLen, i = 0; i < minLen; i++)
2622+ {
2623+ var xKid = xKids[i];
2624+ _VirtualDom_diffHelp(xKid, yKids[i], patches, ++index);
2625+ index += xKid.b || 0;
2626+ }
2627+}
2628+
2629+
2630+
2631+// KEYED DIFF
2632+
2633+
2634+function _VirtualDom_diffKeyedKids(xParent, yParent, patches, rootIndex)
2635+{
2636+ var localPatches = [];
2637+
2638+ var changes = {}; // Dict String Entry
2639+ var inserts = []; // Array { index : Int, entry : Entry }
2640+ // type Entry = { tag : String, vnode : VNode, index : Int, data : _ }
2641+
2642+ var xKids = xParent.e;
2643+ var yKids = yParent.e;
2644+ var xLen = xKids.length;
2645+ var yLen = yKids.length;
2646+ var xIndex = 0;
2647+ var yIndex = 0;
2648+
2649+ var index = rootIndex;
2650+
2651+ while (xIndex < xLen && yIndex < yLen)
2652+ {
2653+ var x = xKids[xIndex];
2654+ var y = yKids[yIndex];
2655+
2656+ var xKey = x.a;
2657+ var yKey = y.a;
2658+ var xNode = x.b;
2659+ var yNode = y.b;
2660+
2661+ var newMatch = undefined;
2662+ var oldMatch = undefined;
2663+
2664+ // check if keys match
2665+
2666+ if (xKey === yKey)
2667+ {
2668+ index++;
2669+ _VirtualDom_diffHelp(xNode, yNode, localPatches, index);
2670+ index += xNode.b || 0;
2671+
2672+ xIndex++;
2673+ yIndex++;
2674+ continue;
2675+ }
2676+
2677+ // look ahead 1 to detect insertions and removals.
2678+
2679+ var xNext = xKids[xIndex + 1];
2680+ var yNext = yKids[yIndex + 1];
2681+
2682+ if (xNext)
2683+ {
2684+ var xNextKey = xNext.a;
2685+ var xNextNode = xNext.b;
2686+ oldMatch = yKey === xNextKey;
2687+ }
2688+
2689+ if (yNext)
2690+ {
2691+ var yNextKey = yNext.a;
2692+ var yNextNode = yNext.b;
2693+ newMatch = xKey === yNextKey;
2694+ }
2695+
2696+
2697+ // swap x and y
2698+ if (newMatch && oldMatch)
2699+ {
2700+ index++;
2701+ _VirtualDom_diffHelp(xNode, yNextNode, localPatches, index);
2702+ _VirtualDom_insertNode(changes, localPatches, xKey, yNode, yIndex, inserts);
2703+ index += xNode.b || 0;
2704+
2705+ index++;
2706+ _VirtualDom_removeNode(changes, localPatches, xKey, xNextNode, index);
2707+ index += xNextNode.b || 0;
2708+
2709+ xIndex += 2;
2710+ yIndex += 2;
2711+ continue;
2712+ }
2713+
2714+ // insert y
2715+ if (newMatch)
2716+ {
2717+ index++;
2718+ _VirtualDom_insertNode(changes, localPatches, yKey, yNode, yIndex, inserts);
2719+ _VirtualDom_diffHelp(xNode, yNextNode, localPatches, index);
2720+ index += xNode.b || 0;
2721+
2722+ xIndex += 1;
2723+ yIndex += 2;
2724+ continue;
2725+ }
2726+
2727+ // remove x
2728+ if (oldMatch)
2729+ {
2730+ index++;
2731+ _VirtualDom_removeNode(changes, localPatches, xKey, xNode, index);
2732+ index += xNode.b || 0;
2733+
2734+ index++;
2735+ _VirtualDom_diffHelp(xNextNode, yNode, localPatches, index);
2736+ index += xNextNode.b || 0;
2737+
2738+ xIndex += 2;
2739+ yIndex += 1;
2740+ continue;
2741+ }
2742+
2743+ // remove x, insert y
2744+ if (xNext && xNextKey === yNextKey)
2745+ {
2746+ index++;
2747+ _VirtualDom_removeNode(changes, localPatches, xKey, xNode, index);
2748+ _VirtualDom_insertNode(changes, localPatches, yKey, yNode, yIndex, inserts);
2749+ index += xNode.b || 0;
2750+
2751+ index++;
2752+ _VirtualDom_diffHelp(xNextNode, yNextNode, localPatches, index);
2753+ index += xNextNode.b || 0;
2754+
2755+ xIndex += 2;
2756+ yIndex += 2;
2757+ continue;
2758+ }
2759+
2760+ break;
2761+ }
2762+
2763+ // eat up any remaining nodes with removeNode and insertNode
2764+
2765+ while (xIndex < xLen)
2766+ {
2767+ index++;
2768+ var x = xKids[xIndex];
2769+ var xNode = x.b;
2770+ _VirtualDom_removeNode(changes, localPatches, x.a, xNode, index);
2771+ index += xNode.b || 0;
2772+ xIndex++;
2773+ }
2774+
2775+ while (yIndex < yLen)
2776+ {
2777+ var endInserts = endInserts || [];
2778+ var y = yKids[yIndex];
2779+ _VirtualDom_insertNode(changes, localPatches, y.a, y.b, undefined, endInserts);
2780+ yIndex++;
2781+ }
2782+
2783+ if (localPatches.length > 0 || inserts.length > 0 || endInserts)
2784+ {
2785+ _VirtualDom_pushPatch(patches, 8, rootIndex, {
2786+ w: localPatches,
2787+ x: inserts,
2788+ y: endInserts
2789+ });
2790+ }
2791+}
2792+
2793+
2794+
2795+// CHANGES FROM KEYED DIFF
2796+
2797+
2798+var _VirtualDom_POSTFIX = '_elmW6BL';
2799+
2800+
2801+function _VirtualDom_insertNode(changes, localPatches, key, vnode, yIndex, inserts)
2802+{
2803+ var entry = changes[key];
2804+
2805+ // never seen this key before
2806+ if (!entry)
2807+ {
2808+ entry = {
2809+ c: 0,
2810+ z: vnode,
2811+ r: yIndex,
2812+ s: undefined
2813+ };
2814+
2815+ inserts.push({ r: yIndex, A: entry });
2816+ changes[key] = entry;
2817+
2818+ return;
2819+ }
2820+
2821+ // this key was removed earlier, a match!
2822+ if (entry.c === 1)
2823+ {
2824+ inserts.push({ r: yIndex, A: entry });
2825+
2826+ entry.c = 2;
2827+ var subPatches = [];
2828+ _VirtualDom_diffHelp(entry.z, vnode, subPatches, entry.r);
2829+ entry.r = yIndex;
2830+ entry.s.s = {
2831+ w: subPatches,
2832+ A: entry
2833+ };
2834+
2835+ return;
2836+ }
2837+
2838+ // this key has already been inserted or moved, a duplicate!
2839+ _VirtualDom_insertNode(changes, localPatches, key + _VirtualDom_POSTFIX, vnode, yIndex, inserts);
2840+}
2841+
2842+
2843+function _VirtualDom_removeNode(changes, localPatches, key, vnode, index)
2844+{
2845+ var entry = changes[key];
2846+
2847+ // never seen this key before
2848+ if (!entry)
2849+ {
2850+ var patch = _VirtualDom_pushPatch(localPatches, 9, index, undefined);
2851+
2852+ changes[key] = {
2853+ c: 1,
2854+ z: vnode,
2855+ r: index,
2856+ s: patch
2857+ };
2858+
2859+ return;
2860+ }
2861+
2862+ // this key was inserted earlier, a match!
2863+ if (entry.c === 0)
2864+ {
2865+ entry.c = 2;
2866+ var subPatches = [];
2867+ _VirtualDom_diffHelp(vnode, entry.z, subPatches, index);
2868+
2869+ _VirtualDom_pushPatch(localPatches, 9, index, {
2870+ w: subPatches,
2871+ A: entry
2872+ });
2873+
2874+ return;
2875+ }
2876+
2877+ // this key has already been removed or moved, a duplicate!
2878+ _VirtualDom_removeNode(changes, localPatches, key + _VirtualDom_POSTFIX, vnode, index);
2879+}
2880+
2881+
2882+
2883+// ADD DOM NODES
2884+//
2885+// Each DOM node has an "index" assigned in order of traversal. It is important
2886+// to minimize our crawl over the actual DOM, so these indexes (along with the
2887+// descendantsCount of virtual nodes) let us skip touching entire subtrees of
2888+// the DOM if we know there are no patches there.
2889+
2890+
2891+function _VirtualDom_addDomNodes(domNode, vNode, patches, eventNode)
2892+{
2893+ _VirtualDom_addDomNodesHelp(domNode, vNode, patches, 0, 0, vNode.b, eventNode);
2894+}
2895+
2896+
2897+// assumes `patches` is non-empty and indexes increase monotonically.
2898+function _VirtualDom_addDomNodesHelp(domNode, vNode, patches, i, low, high, eventNode)
2899+{
2900+ var patch = patches[i];
2901+ var index = patch.r;
2902+
2903+ while (index === low)
2904+ {
2905+ var patchType = patch.$;
2906+
2907+ if (patchType === 1)
2908+ {
2909+ _VirtualDom_addDomNodes(domNode, vNode.k, patch.s, eventNode);
2910+ }
2911+ else if (patchType === 8)
2912+ {
2913+ patch.t = domNode;
2914+ patch.u = eventNode;
2915+
2916+ var subPatches = patch.s.w;
2917+ if (subPatches.length > 0)
2918+ {
2919+ _VirtualDom_addDomNodesHelp(domNode, vNode, subPatches, 0, low, high, eventNode);
2920+ }
2921+ }
2922+ else if (patchType === 9)
2923+ {
2924+ patch.t = domNode;
2925+ patch.u = eventNode;
2926+
2927+ var data = patch.s;
2928+ if (data)
2929+ {
2930+ data.A.s = domNode;
2931+ var subPatches = data.w;
2932+ if (subPatches.length > 0)
2933+ {
2934+ _VirtualDom_addDomNodesHelp(domNode, vNode, subPatches, 0, low, high, eventNode);
2935+ }
2936+ }
2937+ }
2938+ else
2939+ {
2940+ patch.t = domNode;
2941+ patch.u = eventNode;
2942+ }
2943+
2944+ i++;
2945+
2946+ if (!(patch = patches[i]) || (index = patch.r) > high)
2947+ {
2948+ return i;
2949+ }
2950+ }
2951+
2952+ var tag = vNode.$;
2953+
2954+ if (tag === 4)
2955+ {
2956+ var subNode = vNode.k;
2957+
2958+ while (subNode.$ === 4)
2959+ {
2960+ subNode = subNode.k;
2961+ }
2962+
2963+ return _VirtualDom_addDomNodesHelp(domNode, subNode, patches, i, low + 1, high, _VirtualDom_getMeta(domNode).elm_event_node_ref);
2964+ }
2965+
2966+ // tag must be 1 or 2 at this point
2967+
2968+ var vKids = vNode.e;
2969+ var childNodes = _Lynx_getChildren(domNode);
2970+ for (var j = 0; j < vKids.length; j++)
2971+ {
2972+ low++;
2973+ var vKid = tag === 1 ? vKids[j] : vKids[j].b;
2974+ var nextLow = low + (vKid.b || 0);
2975+ if (low <= index && index <= nextLow)
2976+ {
2977+ i = _VirtualDom_addDomNodesHelp(childNodes[j], vKid, patches, i, low, nextLow, eventNode);
2978+ if (!(patch = patches[i]) || (index = patch.r) > high)
2979+ {
2980+ return i;
2981+ }
2982+ }
2983+ low = nextLow;
2984+ }
2985+ return i;
2986+}
2987+
2988+
2989+
2990+// APPLY PATCHES
2991+
2992+
2993+function _VirtualDom_applyPatches(rootDomNode, oldVirtualNode, patches, eventNode)
2994+{
2995+ if (patches.length === 0)
2996+ {
2997+ return rootDomNode;
2998+ }
2999+
3000+ _VirtualDom_addDomNodes(rootDomNode, oldVirtualNode, patches, eventNode);
3001+ return _VirtualDom_applyPatchesHelp(rootDomNode, patches);
3002+}
3003+
3004+function _VirtualDom_applyPatchesHelp(rootDomNode, patches)
3005+{
3006+ for (var i = 0; i < patches.length; i++)
3007+ {
3008+ var patch = patches[i];
3009+ var localDomNode = patch.t
3010+ var newNode = _VirtualDom_applyPatch(localDomNode, patch);
3011+ if (localDomNode === rootDomNode)
3012+ {
3013+ rootDomNode = newNode;
3014+ }
3015+ }
3016+ return rootDomNode;
3017+}
3018+
3019+function _VirtualDom_applyPatch(domNode, patch)
3020+{
3021+ switch (patch.$)
3022+ {
3023+ case 0:
3024+ return _VirtualDom_applyPatchRedraw(domNode, patch.s, patch.u);
3025+
3026+ case 4:
3027+ _VirtualDom_applyFacts(domNode, patch.u, patch.s);
3028+ return domNode;
3029+
3030+ case 3:
3031+ _Lynx_setAttribute(domNode, 'text', patch.s);
3032+ return domNode;
3033+
3034+ case 1:
3035+ return _VirtualDom_applyPatchesHelp(domNode, patch.s);
3036+
3037+ case 2:
3038+ if (_VirtualDom_getMeta(domNode).elm_event_node_ref)
3039+ {
3040+ _VirtualDom_getMeta(domNode).elm_event_node_ref.j = patch.s;
3041+ }
3042+ else
3043+ {
3044+ _VirtualDom_getMeta(domNode).elm_event_node_ref = { j: patch.s, p: patch.u };
3045+ }
3046+ return domNode;
3047+
3048+ case 6:
3049+ var data = patch.s;
3050+ for (var i = 0; i < data.i; i++)
3051+ {
3052+ var children = _Lynx_getChildren(domNode);
3053+ _Lynx_removeElement(domNode, children[data.v]);
3054+ }
3055+ return domNode;
3056+
3057+ case 7:
3058+ var data = patch.s;
3059+ var kids = data.e;
3060+ for (var i = data.v; i < kids.length; i++)
3061+ {
3062+ _Lynx_appendChild(domNode, _VirtualDom_render(kids[i], patch.u));
3063+ }
3064+ return domNode;
3065+
3066+ case 9:
3067+ var data = patch.s;
3068+ if (!data)
3069+ {
3070+ _Lynx_removeElement(_Lynx_getParent(domNode), domNode);
3071+ return domNode;
3072+ }
3073+ var entry = data.A;
3074+ if (typeof entry.r !== 'undefined')
3075+ {
3076+ _Lynx_removeElement(_Lynx_getParent(domNode), domNode);
3077+ }
3078+ entry.s = _VirtualDom_applyPatchesHelp(domNode, data.w);
3079+ return domNode;
3080+
3081+ case 8:
3082+ return _VirtualDom_applyPatchReorder(domNode, patch);
3083+
3084+ case 5:
3085+ return patch.s(domNode);
3086+
3087+ default:
3088+ _Debug_crash(10); // 'Ran into an unknown patch!'
3089+ }
3090+}
3091+
3092+
3093+function _VirtualDom_applyPatchRedraw(domNode, vNode, eventNode)
3094+{
3095+ var parentNode = _Lynx_getParent(domNode);
3096+ var newNode = _VirtualDom_render(vNode, eventNode);
3097+
3098+ if (!_VirtualDom_getMeta(newNode).elm_event_node_ref)
3099+ {
3100+ _VirtualDom_getMeta(newNode).elm_event_node_ref = _VirtualDom_getMeta(domNode).elm_event_node_ref;
3101+ }
3102+
3103+ if (parentNode && newNode !== domNode)
3104+ {
3105+ _Lynx_replaceElement(parentNode, newNode, domNode);
3106+ }
3107+ return newNode;
3108+}
3109+
3110+
3111+function _VirtualDom_applyPatchReorder(domNode, patch)
3112+{
3113+ var data = patch.s;
3114+
3115+ // remove end inserts
3116+ var endInsertNodes = _VirtualDom_applyPatchReorderEndInsertsHelp(data.y, patch);
3117+
3118+ // removals
3119+ domNode = _VirtualDom_applyPatchesHelp(domNode, data.w);
3120+
3121+ // inserts
3122+ var inserts = data.x;
3123+ for (var i = 0; i < inserts.length; i++)
3124+ {
3125+ var insert = inserts[i];
3126+ var entry = insert.A;
3127+ var node = entry.c === 2
3128+ ? entry.s
3129+ : _VirtualDom_render(entry.z, patch.u);
3130+ var children = _Lynx_getChildren(domNode);
3131+ _Lynx_insertBefore(domNode, node, children[insert.r]);
3132+ }
3133+
3134+ // add end inserts
3135+ if (endInsertNodes)
3136+ {
3137+ for (var i = 0; i < endInsertNodes.length; i++)
3138+ {
3139+ _Lynx_appendChild(domNode, endInsertNodes[i]);
3140+ }
3141+ }
3142+
3143+ return domNode;
3144+}
3145+
3146+
3147+function _VirtualDom_applyPatchReorderEndInsertsHelp(endInserts, patch)
3148+{
3149+ if (!endInserts)
3150+ {
3151+ return;
3152+ }
3153+
3154+ var nodes = [];
3155+ for (var i = 0; i < endInserts.length; i++)
3156+ {
3157+ var insert = endInserts[i];
3158+ var entry = insert.A;
3159+ nodes.push(entry.c === 2
3160+ ? entry.s
3161+ : _VirtualDom_render(entry.z, patch.u)
3162+ );
3163+ }
3164+ return nodes;
3165+}
3166+
3167+
3168+function _VirtualDom_dekey(keyedNode)
3169+{
3170+ var keyedKids = keyedNode.e;
3171+ var len = keyedKids.length;
3172+ var kids = new Array(len);
3173+ for (var i = 0; i < len; i++)
3174+ {
3175+ kids[i] = keyedKids[i].b;
3176+ }
3177+
3178+ return {
3179+ $: 1,
3180+ c: keyedNode.c,
3181+ d: keyedNode.d,
3182+ e: kids,
3183+ f: keyedNode.f,
3184+ b: keyedNode.b
3185+ };
3186+}
3187+var $elm$core$List$cons = _List_cons;
3188+var $elm$core$Elm$JsArray$foldr = _JsArray_foldr;
3189+var $elm$core$Array$foldr = F3(
3190+ function (func, baseCase, _v0) {
3191+ var tree = _v0.c;
3192+ var tail = _v0.d;
3193+ var helper = F2(
3194+ function (node, acc) {
3195+ if (node.$ === 'SubTree') {
3196+ var subTree = node.a;
3197+ return A3($elm$core$Elm$JsArray$foldr, helper, acc, subTree);
3198+ } else {
3199+ var values = node.a;
3200+ return A3($elm$core$Elm$JsArray$foldr, func, acc, values);
3201+ }
3202+ });
3203+ return A3(
3204+ $elm$core$Elm$JsArray$foldr,
3205+ helper,
3206+ A3($elm$core$Elm$JsArray$foldr, func, baseCase, tail),
3207+ tree);
3208+ });
3209+var $elm$core$Array$toList = function (array) {
3210+ return A3($elm$core$Array$foldr, $elm$core$List$cons, _List_Nil, array);
3211+};
3212+var $elm$core$Dict$foldr = F3(
3213+ function (func, acc, t) {
3214+ foldr:
3215+ while (true) {
3216+ if (t.$ === 'RBEmpty_elm_builtin') {
3217+ return acc;
3218+ } else {
3219+ var key = t.b;
3220+ var value = t.c;
3221+ var left = t.d;
3222+ var right = t.e;
3223+ var $temp$func = func,
3224+ $temp$acc = A3(
3225+ func,
3226+ key,
3227+ value,
3228+ A3($elm$core$Dict$foldr, func, acc, right)),
3229+ $temp$t = left;
3230+ func = $temp$func;
3231+ acc = $temp$acc;
3232+ t = $temp$t;
3233+ continue foldr;
3234+ }
3235+ }
3236+ });
3237+var $elm$core$Dict$toList = function (dict) {
3238+ return A3(
3239+ $elm$core$Dict$foldr,
3240+ F3(
3241+ function (key, value, list) {
3242+ return A2(
3243+ $elm$core$List$cons,
3244+ _Utils_Tuple2(key, value),
3245+ list);
3246+ }),
3247+ _List_Nil,
3248+ dict);
3249+};
3250+var $elm$core$Dict$keys = function (dict) {
3251+ return A3(
3252+ $elm$core$Dict$foldr,
3253+ F3(
3254+ function (key, value, keyList) {
3255+ return A2($elm$core$List$cons, key, keyList);
3256+ }),
3257+ _List_Nil,
3258+ dict);
3259+};
3260+var $elm$core$Set$toList = function (_v0) {
3261+ var dict = _v0.a;
3262+ return $elm$core$Dict$keys(dict);
3263+};
3264+var $elm$core$Basics$EQ = {$: 'EQ'};
3265+var $elm$core$Basics$GT = {$: 'GT'};
3266+var $elm$core$Basics$LT = {$: 'LT'};
3267+var $elm$core$Result$Err = function (a) {
3268+ return {$: 'Err', a: a};
3269+};
3270+var $elm$json$Json$Decode$Failure = F2(
3271+ function (a, b) {
3272+ return {$: 'Failure', a: a, b: b};
3273+ });
3274+var $elm$json$Json$Decode$Field = F2(
3275+ function (a, b) {
3276+ return {$: 'Field', a: a, b: b};
3277+ });
3278+var $elm$json$Json$Decode$Index = F2(
3279+ function (a, b) {
3280+ return {$: 'Index', a: a, b: b};
3281+ });
3282+var $elm$core$Result$Ok = function (a) {
3283+ return {$: 'Ok', a: a};
3284+};
3285+var $elm$json$Json$Decode$OneOf = function (a) {
3286+ return {$: 'OneOf', a: a};
3287+};
3288+var $elm$core$Basics$False = {$: 'False'};
3289+var $elm$core$Basics$add = _Basics_add;
3290+var $elm$core$Maybe$Just = function (a) {
3291+ return {$: 'Just', a: a};
3292+};
3293+var $elm$core$Maybe$Nothing = {$: 'Nothing'};
3294+var $elm$core$String$all = _String_all;
3295+var $elm$core$Basics$and = _Basics_and;
3296+var $elm$core$Basics$append = _Utils_append;
3297+var $elm$json$Json$Encode$encode = _Json_encode;
3298+var $elm$core$String$fromInt = _String_fromNumber;
3299+var $elm$core$String$join = F2(
3300+ function (sep, chunks) {
3301+ return A2(
3302+ _String_join,
3303+ sep,
3304+ _List_toArray(chunks));
3305+ });
3306+var $elm$core$String$split = F2(
3307+ function (sep, string) {
3308+ return _List_fromArray(
3309+ A2(_String_split, sep, string));
3310+ });
3311+var $elm$json$Json$Decode$indent = function (str) {
3312+ return A2(
3313+ $elm$core$String$join,
3314+ '\n ',
3315+ A2($elm$core$String$split, '\n', str));
3316+};
3317+var $elm$core$List$foldl = F3(
3318+ function (func, acc, list) {
3319+ foldl:
3320+ while (true) {
3321+ if (!list.b) {
3322+ return acc;
3323+ } else {
3324+ var x = list.a;
3325+ var xs = list.b;
3326+ var $temp$func = func,
3327+ $temp$acc = A2(func, x, acc),
3328+ $temp$list = xs;
3329+ func = $temp$func;
3330+ acc = $temp$acc;
3331+ list = $temp$list;
3332+ continue foldl;
3333+ }
3334+ }
3335+ });
3336+var $elm$core$List$length = function (xs) {
3337+ return A3(
3338+ $elm$core$List$foldl,
3339+ F2(
3340+ function (_v0, i) {
3341+ return i + 1;
3342+ }),
3343+ 0,
3344+ xs);
3345+};
3346+var $elm$core$List$map2 = _List_map2;
3347+var $elm$core$Basics$le = _Utils_le;
3348+var $elm$core$Basics$sub = _Basics_sub;
3349+var $elm$core$List$rangeHelp = F3(
3350+ function (lo, hi, list) {
3351+ rangeHelp:
3352+ while (true) {
3353+ if (_Utils_cmp(lo, hi) < 1) {
3354+ var $temp$lo = lo,
3355+ $temp$hi = hi - 1,
3356+ $temp$list = A2($elm$core$List$cons, hi, list);
3357+ lo = $temp$lo;
3358+ hi = $temp$hi;
3359+ list = $temp$list;
3360+ continue rangeHelp;
3361+ } else {
3362+ return list;
3363+ }
3364+ }
3365+ });
3366+var $elm$core$List$range = F2(
3367+ function (lo, hi) {
3368+ return A3($elm$core$List$rangeHelp, lo, hi, _List_Nil);
3369+ });
3370+var $elm$core$List$indexedMap = F2(
3371+ function (f, xs) {
3372+ return A3(
3373+ $elm$core$List$map2,
3374+ f,
3375+ A2(
3376+ $elm$core$List$range,
3377+ 0,
3378+ $elm$core$List$length(xs) - 1),
3379+ xs);
3380+ });
3381+var $elm$core$Char$toCode = _Char_toCode;
3382+var $elm$core$Char$isLower = function (_char) {
3383+ var code = $elm$core$Char$toCode(_char);
3384+ return (97 <= code) && (code <= 122);
3385+};
3386+var $elm$core$Char$isUpper = function (_char) {
3387+ var code = $elm$core$Char$toCode(_char);
3388+ return (code <= 90) && (65 <= code);
3389+};
3390+var $elm$core$Basics$or = _Basics_or;
3391+var $elm$core$Char$isAlpha = function (_char) {
3392+ return $elm$core$Char$isLower(_char) || $elm$core$Char$isUpper(_char);
3393+};
3394+var $elm$core$Char$isDigit = function (_char) {
3395+ var code = $elm$core$Char$toCode(_char);
3396+ return (code <= 57) && (48 <= code);
3397+};
3398+var $elm$core$Char$isAlphaNum = function (_char) {
3399+ return $elm$core$Char$isLower(_char) || ($elm$core$Char$isUpper(_char) || $elm$core$Char$isDigit(_char));
3400+};
3401+var $elm$core$List$reverse = function (list) {
3402+ return A3($elm$core$List$foldl, $elm$core$List$cons, _List_Nil, list);
3403+};
3404+var $elm$core$String$uncons = _String_uncons;
3405+var $elm$json$Json$Decode$errorOneOf = F2(
3406+ function (i, error) {
3407+ return '\n\n(' + ($elm$core$String$fromInt(i + 1) + (') ' + $elm$json$Json$Decode$indent(
3408+ $elm$json$Json$Decode$errorToString(error))));
3409+ });
3410+var $elm$json$Json$Decode$errorToString = function (error) {
3411+ return A2($elm$json$Json$Decode$errorToStringHelp, error, _List_Nil);
3412+};
3413+var $elm$json$Json$Decode$errorToStringHelp = F2(
3414+ function (error, context) {
3415+ errorToStringHelp:
3416+ while (true) {
3417+ switch (error.$) {
3418+ case 'Field':
3419+ var f = error.a;
3420+ var err = error.b;
3421+ var isSimple = function () {
3422+ var _v1 = $elm$core$String$uncons(f);
3423+ if (_v1.$ === 'Nothing') {
3424+ return false;
3425+ } else {
3426+ var _v2 = _v1.a;
3427+ var _char = _v2.a;
3428+ var rest = _v2.b;
3429+ return $elm$core$Char$isAlpha(_char) && A2($elm$core$String$all, $elm$core$Char$isAlphaNum, rest);
3430+ }
3431+ }();
3432+ var fieldName = isSimple ? ('.' + f) : ('[\'' + (f + '\']'));
3433+ var $temp$error = err,
3434+ $temp$context = A2($elm$core$List$cons, fieldName, context);
3435+ error = $temp$error;
3436+ context = $temp$context;
3437+ continue errorToStringHelp;
3438+ case 'Index':
3439+ var i = error.a;
3440+ var err = error.b;
3441+ var indexName = '[' + ($elm$core$String$fromInt(i) + ']');
3442+ var $temp$error = err,
3443+ $temp$context = A2($elm$core$List$cons, indexName, context);
3444+ error = $temp$error;
3445+ context = $temp$context;
3446+ continue errorToStringHelp;
3447+ case 'OneOf':
3448+ var errors = error.a;
3449+ if (!errors.b) {
3450+ return 'Ran into a Json.Decode.oneOf with no possibilities' + function () {
3451+ if (!context.b) {
3452+ return '!';
3453+ } else {
3454+ return ' at json' + A2(
3455+ $elm$core$String$join,
3456+ '',
3457+ $elm$core$List$reverse(context));
3458+ }
3459+ }();
3460+ } else {
3461+ if (!errors.b.b) {
3462+ var err = errors.a;
3463+ var $temp$error = err,
3464+ $temp$context = context;
3465+ error = $temp$error;
3466+ context = $temp$context;
3467+ continue errorToStringHelp;
3468+ } else {
3469+ var starter = function () {
3470+ if (!context.b) {
3471+ return 'Json.Decode.oneOf';
3472+ } else {
3473+ return 'The Json.Decode.oneOf at json' + A2(
3474+ $elm$core$String$join,
3475+ '',
3476+ $elm$core$List$reverse(context));
3477+ }
3478+ }();
3479+ var introduction = starter + (' failed in the following ' + ($elm$core$String$fromInt(
3480+ $elm$core$List$length(errors)) + ' ways:'));
3481+ return A2(
3482+ $elm$core$String$join,
3483+ '\n\n',
3484+ A2(
3485+ $elm$core$List$cons,
3486+ introduction,
3487+ A2($elm$core$List$indexedMap, $elm$json$Json$Decode$errorOneOf, errors)));
3488+ }
3489+ }
3490+ default:
3491+ var msg = error.a;
3492+ var json = error.b;
3493+ var introduction = function () {
3494+ if (!context.b) {
3495+ return 'Problem with the given value:\n\n';
3496+ } else {
3497+ return 'Problem with the value at json' + (A2(
3498+ $elm$core$String$join,
3499+ '',
3500+ $elm$core$List$reverse(context)) + ':\n\n ');
3501+ }
3502+ }();
3503+ return introduction + ($elm$json$Json$Decode$indent(
3504+ A2($elm$json$Json$Encode$encode, 4, json)) + ('\n\n' + msg));
3505+ }
3506+ }
3507+ });
3508+var $elm$core$Array$branchFactor = 32;
3509+var $elm$core$Array$Array_elm_builtin = F4(
3510+ function (a, b, c, d) {
3511+ return {$: 'Array_elm_builtin', a: a, b: b, c: c, d: d};
3512+ });
3513+var $elm$core$Elm$JsArray$empty = _JsArray_empty;
3514+var $elm$core$Basics$ceiling = _Basics_ceiling;
3515+var $elm$core$Basics$fdiv = _Basics_fdiv;
3516+var $elm$core$Basics$logBase = F2(
3517+ function (base, number) {
3518+ return _Basics_log(number) / _Basics_log(base);
3519+ });
3520+var $elm$core$Basics$toFloat = _Basics_toFloat;
3521+var $elm$core$Array$shiftStep = $elm$core$Basics$ceiling(
3522+ A2($elm$core$Basics$logBase, 2, $elm$core$Array$branchFactor));
3523+var $elm$core$Array$empty = A4($elm$core$Array$Array_elm_builtin, 0, $elm$core$Array$shiftStep, $elm$core$Elm$JsArray$empty, $elm$core$Elm$JsArray$empty);
3524+var $elm$core$Elm$JsArray$initialize = _JsArray_initialize;
3525+var $elm$core$Array$Leaf = function (a) {
3526+ return {$: 'Leaf', a: a};
3527+};
3528+var $elm$core$Basics$apL = F2(
3529+ function (f, x) {
3530+ return f(x);
3531+ });
3532+var $elm$core$Basics$apR = F2(
3533+ function (x, f) {
3534+ return f(x);
3535+ });
3536+var $elm$core$Basics$eq = _Utils_equal;
3537+var $elm$core$Basics$floor = _Basics_floor;
3538+var $elm$core$Elm$JsArray$length = _JsArray_length;
3539+var $elm$core$Basics$gt = _Utils_gt;
3540+var $elm$core$Basics$max = F2(
3541+ function (x, y) {
3542+ return (_Utils_cmp(x, y) > 0) ? x : y;
3543+ });
3544+var $elm$core$Basics$mul = _Basics_mul;
3545+var $elm$core$Array$SubTree = function (a) {
3546+ return {$: 'SubTree', a: a};
3547+};
3548+var $elm$core$Elm$JsArray$initializeFromList = _JsArray_initializeFromList;
3549+var $elm$core$Array$compressNodes = F2(
3550+ function (nodes, acc) {
3551+ compressNodes:
3552+ while (true) {
3553+ var _v0 = A2($elm$core$Elm$JsArray$initializeFromList, $elm$core$Array$branchFactor, nodes);
3554+ var node = _v0.a;
3555+ var remainingNodes = _v0.b;
3556+ var newAcc = A2(
3557+ $elm$core$List$cons,
3558+ $elm$core$Array$SubTree(node),
3559+ acc);
3560+ if (!remainingNodes.b) {
3561+ return $elm$core$List$reverse(newAcc);
3562+ } else {
3563+ var $temp$nodes = remainingNodes,
3564+ $temp$acc = newAcc;
3565+ nodes = $temp$nodes;
3566+ acc = $temp$acc;
3567+ continue compressNodes;
3568+ }
3569+ }
3570+ });
3571+var $elm$core$Tuple$first = function (_v0) {
3572+ var x = _v0.a;
3573+ return x;
3574+};
3575+var $elm$core$Array$treeFromBuilder = F2(
3576+ function (nodeList, nodeListSize) {
3577+ treeFromBuilder:
3578+ while (true) {
3579+ var newNodeSize = $elm$core$Basics$ceiling(nodeListSize / $elm$core$Array$branchFactor);
3580+ if (newNodeSize === 1) {
3581+ return A2($elm$core$Elm$JsArray$initializeFromList, $elm$core$Array$branchFactor, nodeList).a;
3582+ } else {
3583+ var $temp$nodeList = A2($elm$core$Array$compressNodes, nodeList, _List_Nil),
3584+ $temp$nodeListSize = newNodeSize;
3585+ nodeList = $temp$nodeList;
3586+ nodeListSize = $temp$nodeListSize;
3587+ continue treeFromBuilder;
3588+ }
3589+ }
3590+ });
3591+var $elm$core$Array$builderToArray = F2(
3592+ function (reverseNodeList, builder) {
3593+ if (!builder.nodeListSize) {
3594+ return A4(
3595+ $elm$core$Array$Array_elm_builtin,
3596+ $elm$core$Elm$JsArray$length(builder.tail),
3597+ $elm$core$Array$shiftStep,
3598+ $elm$core$Elm$JsArray$empty,
3599+ builder.tail);
3600+ } else {
3601+ var treeLen = builder.nodeListSize * $elm$core$Array$branchFactor;
3602+ var depth = $elm$core$Basics$floor(
3603+ A2($elm$core$Basics$logBase, $elm$core$Array$branchFactor, treeLen - 1));
3604+ var correctNodeList = reverseNodeList ? $elm$core$List$reverse(builder.nodeList) : builder.nodeList;
3605+ var tree = A2($elm$core$Array$treeFromBuilder, correctNodeList, builder.nodeListSize);
3606+ return A4(
3607+ $elm$core$Array$Array_elm_builtin,
3608+ $elm$core$Elm$JsArray$length(builder.tail) + treeLen,
3609+ A2($elm$core$Basics$max, 5, depth * $elm$core$Array$shiftStep),
3610+ tree,
3611+ builder.tail);
3612+ }
3613+ });
3614+var $elm$core$Basics$idiv = _Basics_idiv;
3615+var $elm$core$Basics$lt = _Utils_lt;
3616+var $elm$core$Array$initializeHelp = F5(
3617+ function (fn, fromIndex, len, nodeList, tail) {
3618+ initializeHelp:
3619+ while (true) {
3620+ if (fromIndex < 0) {
3621+ return A2(
3622+ $elm$core$Array$builderToArray,
3623+ false,
3624+ {nodeList: nodeList, nodeListSize: (len / $elm$core$Array$branchFactor) | 0, tail: tail});
3625+ } else {
3626+ var leaf = $elm$core$Array$Leaf(
3627+ A3($elm$core$Elm$JsArray$initialize, $elm$core$Array$branchFactor, fromIndex, fn));
3628+ var $temp$fn = fn,
3629+ $temp$fromIndex = fromIndex - $elm$core$Array$branchFactor,
3630+ $temp$len = len,
3631+ $temp$nodeList = A2($elm$core$List$cons, leaf, nodeList),
3632+ $temp$tail = tail;
3633+ fn = $temp$fn;
3634+ fromIndex = $temp$fromIndex;
3635+ len = $temp$len;
3636+ nodeList = $temp$nodeList;
3637+ tail = $temp$tail;
3638+ continue initializeHelp;
3639+ }
3640+ }
3641+ });
3642+var $elm$core$Basics$remainderBy = _Basics_remainderBy;
3643+var $elm$core$Array$initialize = F2(
3644+ function (len, fn) {
3645+ if (len <= 0) {
3646+ return $elm$core$Array$empty;
3647+ } else {
3648+ var tailLen = len % $elm$core$Array$branchFactor;
3649+ var tail = A3($elm$core$Elm$JsArray$initialize, tailLen, len - tailLen, fn);
3650+ var initialFromIndex = (len - tailLen) - $elm$core$Array$branchFactor;
3651+ return A5($elm$core$Array$initializeHelp, fn, initialFromIndex, len, _List_Nil, tail);
3652+ }
3653+ });
3654+var $elm$core$Basics$True = {$: 'True'};
3655+var $elm$core$Result$isOk = function (result) {
3656+ if (result.$ === 'Ok') {
3657+ return true;
3658+ } else {
3659+ return false;
3660+ }
3661+};
3662+var $elm$json$Json$Decode$map = _Json_map1;
3663+var $elm$json$Json$Decode$map2 = _Json_map2;
3664+var $elm$json$Json$Decode$succeed = _Json_succeed;
3665+var $lynxjs_elm$virtual_dom$VirtualDom$toHandlerInt = function (handler) {
3666+ switch (handler.$) {
3667+ case 'Normal':
3668+ return 0;
3669+ case 'MayStopPropagation':
3670+ return 1;
3671+ case 'MayPreventDefault':
3672+ return 2;
3673+ default:
3674+ return 3;
3675+ }
3676+};
3677+var $lynxjs_elm$virtual_dom$VirtualDom$node = function (tag) {
3678+ return _VirtualDom_node(
3679+ _VirtualDom_noScript(tag));
3680+};
3681+var $lynxjs_elm$virtual_dom$VirtualDom$text = _VirtualDom_text;
3682+var $author$project$Main$main = A3(
3683+ $lynxjs_elm$virtual_dom$VirtualDom$node,
3684+ 'view',
3685+ _List_Nil,
3686+ _List_fromArray(
3687+ [
3688+ A3(
3689+ $lynxjs_elm$virtual_dom$VirtualDom$node,
3690+ 'text',
3691+ _List_Nil,
3692+ _List_fromArray(
3693+ [
3694+ $lynxjs_elm$virtual_dom$VirtualDom$text('Hello from Elm on LynxJS!')
3695+ ]))
3696+ ]));
3697+_Platform_export({'Main':{'init':_VirtualDom_init($author$project$Main$main)(0)(0)}});}(globalThis));
examples/hello-world/elm.jsonnew file+19
@@ -0,0 +1,19 @@
1+{
2+ "type": "application",
3+ "source-directories": [
4+ "src"
5+ ],
6+ "elm-version": "0.19.1",
7+ "dependencies": {
8+ "direct": {
9+ "elm/core": "1.0.5",
10+ "elm/json": "1.1.3",
11+ "lynxjs-elm/virtual-dom": "1.0.0"
12+ },
13+ "indirect": {}
14+ },
15+ "test-dependencies": {
16+ "direct": {},
17+ "indirect": {}
18+ }
19+}
examples/hello-world/src/Main.elmnew file+14
@@ -0,0 +1,14 @@
1+module Main exposing (main)
2+
3+{-| Phase 1 verification: Static rendering.
4+Renders a view with a text element. No events, no TEA.
5+-}
6+
7+import VirtualDom exposing (Node, node, text)
8+
9+
10+main : Node msg
11+main =
12+ node "view" []
13+ [ node "text" [] [ text "Hello from Elm on LynxJS!" ]
14+ ]
examples/http-example/elm.jsnew file+6126

This diff is too big to show here.

examples/http-example/elm.jsonnew file+27

This diff is too big to show here.

examples/http-example/main.htmlnew file+6220

This diff is too big to show here.

examples/http-example/src/Main.elmnew file+114

This diff is too big to show here.

examples/scroll-view/elm.jsnew file+5377

This diff is too big to show here.

examples/scroll-view/elm.jsonnew file+24

This diff is too big to show here.

examples/scroll-view/src/Main.elmnew file+205

This diff is too big to show here.

examples/timer/elm.jsonnew file+24

This diff is too big to show here.

examples/timer/src/Main.elmnew file+221

This diff is too big to show here.

examples/todo-list/elm.jsnew file+5417

This diff is too big to show here.

examples/todo-list/elm.jsonnew file+24

This diff is too big to show here.

examples/todo-list/src/Main.elmnew file+229

This diff is too big to show here.

hints/implicit-casts.md−3

This diff is too big to show here.

hints/optimize.md+2−2

This diff is too big to show here.

installers/npm/.gitignore+2

This diff is too big to show here.

installers/npm/PUBLISHING.md+77−4

This diff is too big to show here.

installers/npm/README.md+7−9

This diff is too big to show here.

installers/npm/bin/elm+7−33

This diff is too big to show here.

installers/npm/binary.jsnew file+122

This diff is too big to show here.

installers/npm/download.jsdeleted−82

This diff is too big to show here.

installers/npm/install.js+1−4

This diff is too big to show here.

installers/npm/package.json+7−5

This diff is too big to show here.

installers/npm/packages/darwin_arm64/README.mdnew file+5

This diff is too big to show here.

installers/npm/packages/darwin_arm64/package.jsonnew file+9

This diff is too big to show here.

installers/npm/packages/darwin_x64/README.mdnew file+5

This diff is too big to show here.

installers/npm/packages/darwin_x64/package.jsonnew file+9

This diff is too big to show here.

installers/npm/packages/linux_arm64/README.mdnew file+5

This diff is too big to show here.

installers/npm/packages/linux_arm64/package.jsonnew file+9

This diff is too big to show here.

installers/npm/packages/linux_x64/README.mdnew file+5

This diff is too big to show here.

installers/npm/packages/linux_x64/package.jsonnew file+9

This diff is too big to show here.

installers/npm/packages/win32_x64/README.mdnew file+5

This diff is too big to show here.

installers/npm/packages/win32_x64/package.jsonnew file+9

This diff is too big to show here.

installers/npm/troubleshooting.md+2−2

This diff is too big to show here.

elm.cabal → lynxjs-elm.cabalrenamed+29−28

This diff is too big to show here.

lynxjs-elm.mdnew file+1401

This diff is too big to show here.

packages/browser/README.mdnew file+270

This diff is too big to show here.

packages/browser/elm.jsonnew file+22

This diff is too big to show here.

packages/browser/src/Browser.elmnew file+141

This diff is too big to show here.

packages/browser/src/Browser/AnimationManager.elmnew file+114

This diff is too big to show here.

packages/browser/src/Browser/Dom.elmnew file+384

This diff is too big to show here.

packages/browser/src/Browser/Events.elmnew file+356

This diff is too big to show here.

packages/browser/src/Browser/Navigation.elmnew file+183

This diff is too big to show here.

packages/browser/src/Elm/Kernel/Browser.jsnew file+434

This diff is too big to show here.

packages/browser/src/Elm/Kernel/Browser.server.jsnew file+132

This diff is too big to show here.

packages/bytes/elm.jsonnew file+17

This diff is too big to show here.

packages/bytes/src/Bytes.elmnew file+187

This diff is too big to show here.

packages/bytes/src/Bytes/Decode.elmnew file+428

This diff is too big to show here.

packages/bytes/src/Bytes/Encode.elmnew file+338

This diff is too big to show here.

packages/bytes/src/Elm/Kernel/Bytes.jsnew file+229

This diff is too big to show here.

packages/crypto/README.mdnew file+478

This diff is too big to show here.

packages/crypto/elm.jsonnew file+17

This diff is too big to show here.

packages/crypto/src/Crypto/Cipher.elmnew file+75

This diff is too big to show here.

packages/crypto/src/Crypto/Ed25519.elmnew file+99

This diff is too big to show here.

packages/crypto/src/Crypto/X25519.elmnew file+70

This diff is too big to show here.

packages/crypto/src/Elm/Kernel/Crypto.jsnew file+231

This diff is too big to show here.

packages/http/README.mdnew file+211

This diff is too big to show here.

packages/http/elm.jsonnew file+18

This diff is too big to show here.

packages/http/src/Elm/Kernel/Http.jsnew file+183

This diff is too big to show here.

packages/http/src/Elm/Kernel/Http.server.jsnew file+40

This diff is too big to show here.

packages/http/src/Http.elmnew file+1046

This diff is too big to show here.

packages/ui/README.mdnew file+267

This diff is too big to show here.

packages/ui/elm.jsonnew file+19

This diff is too big to show here.

packages/ui/src/Lynx.elmnew file+104

This diff is too big to show here.

packages/ui/src/Lynx/Attributes.elmnew file+568

This diff is too big to show here.

packages/ui/src/Lynx/Events.elmnew file+83

This diff is too big to show here.

packages/virtual-dom/README.mdnew file+141

This diff is too big to show here.

packages/virtual-dom/elm.jsonnew file+16

This diff is too big to show here.

packages/virtual-dom/src/Elm/Kernel/VirtualDom.jsnew file+1547

This diff is too big to show here.

packages/virtual-dom/src/Elm/Kernel/VirtualDom.server.jsnew file+209

This diff is too big to show here.

packages/virtual-dom/src/VirtualDom.elmnew file+274

This diff is too big to show here.

roadmap.mdnew file+29

This diff is too big to show here.

stack.yamlnew file+77

This diff is too big to show here.

terminal/impl/Terminal.hs+1

This diff is too big to show here.

terminal/impl/Terminal/Error.hs+1−1

This diff is too big to show here.

terminal/src/Bump.hs+2−1

This diff is too big to show here.

terminal/src/Clean.hsnew file+38

This diff is too big to show here.

terminal/src/Dev.hsnew file+409

This diff is too big to show here.

terminal/src/Develop.hs+48−2

This diff is too big to show here.

terminal/src/Develop/Generate/Help.hs−2

This diff is too big to show here.

terminal/src/Develop/Generate/Index.hs+1−2

This diff is too big to show here.

terminal/src/Develop/Socket.hs−1

This diff is too big to show here.

terminal/src/Develop/StaticFiles.hs−1

This diff is too big to show here.

terminal/src/Diff.hs+1−2

This diff is too big to show here.

terminal/src/Init.hs+129−11

This diff is too big to show here.

terminal/src/Install.hs+18−12

This diff is too big to show here.

terminal/src/Main.hs+98−21

This diff is too big to show here.

terminal/src/Make.hs+228−15

This diff is too big to show here.

terminal/src/Publish.hs+2−2

This diff is too big to show here.

terminal/src/Repl.hs+1−2

This diff is too big to show here.

terminal/src/Uninstall.hsnew file+154

This diff is too big to show here.

worker/elm.cabal+17−15

This diff is too big to show here.

worker/logrotate.confnew file+15

This diff is too big to show here.

worker/src/Artifacts.hs+15−12

This diff is too big to show here.

worker/src/Cors.hs−1

This diff is too big to show here.

worker/src/Endpoint/Compile.hs+114−26

This diff is too big to show here.

worker/src/Endpoint/Donate.hsdeleted−341

This diff is too big to show here.

worker/src/Endpoint/Quotes.hsnew file+203

This diff is too big to show here.

worker/src/Endpoint/Repl.hs−1

This diff is too big to show here.

worker/src/Endpoint/Slack.hsnew file+67

This diff is too big to show here.

worker/src/Main.hs+25−31

This diff is too big to show here.