git.iko.soy/lynxjs-elm/compiler
on master help sign in
36 files changed+14377−1057
since splitsnapshots
unifiedsplit
builder/src/Lynx/Patches.hs+13−1 compiler/src/Elm/Package.hs+11−2 compiler/src/Generate/Html.hs+23−24 compiler/src/Generate/JavaScript.hs+135−3 compiler/src/Generate/JavaScript/Builder.hs+17 compiler/src/Generate/JavaScript/Expression.hs+11−4 compiler/src/Type/Unify.hs+22−41 examples/counter/elm.js+70−53 examples/counter/main.html+187−150 examples/counter/src/Main.elm+6−6 examples/http-example/src/Main.elm+2−2 examples/scroll-view/elm.js+5377 examples/scroll-view/src/Main.elm+11−11 examples/timer/src/Main.elm+10−10 examples/todo-list/elm.js+5417 examples/todo-list/src/Main.elm+10−10 lynxjs-elm.md+1401 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+63 packages/crypto/elm.json+2−3 packages/crypto/src/Crypto/Cipher.elm+29−85 packages/crypto/src/Crypto/P256.elm−121 packages/crypto/src/Crypto/Secp256k1.elm−121 packages/crypto/src/Crypto/X25519.elm+70 packages/crypto/src/Elm/Kernel/Crypto.js+68−327 packages/http/elm.json+1−1 packages/http/src/Elm/Kernel/Http.js+2−1 packages/ui/src/Lynx.elm+3−3 packages/ui/src/Lynx/Attributes.elm+190−47 packages/virtual-dom/src/Elm/Kernel/VirtualDom.js+12−20 terminal/src/Dev.hs+1−1 terminal/src/Make.hs+14−10
builder/src/Lynx/Patches.hs+13−1
@@ -65,6 +65,13 @@ cryptoElmJson :: BS.ByteString
6565cryptoElmJson = $(embedFile "packages/crypto/elm.json")
6666
6767
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+
6875
6976-- FORK CONTENT HASH
7077--
@@ -85,6 +92,7 @@ forkContentHash =
8592 , httpElmJson : map snd httpSrc
8693 , uiElmJson : map snd uiSrc
8794 , cryptoElmJson : map snd cryptoSrc
95+ , bytesElmJson : map snd bytesSrc
8896 ]
8997 in
9098 foldl' hashBS 0 allBytes
@@ -96,7 +104,7 @@ forkContentHash =
96104
97105isFork :: Pkg.Name -> Bool
98106isFork pkg =
99− pkg == Pkg.virtualDom || pkg == Pkg.browser || pkg == Pkg.http || pkg == Pkg.ui || pkg == Pkg.crypto
107+ pkg == Pkg.virtualDom || pkg == Pkg.browser || pkg == Pkg.http || pkg == Pkg.ui || pkg == Pkg.crypto || pkg == Pkg.bytes
100108
101109
102110-- FORK SUGGESTION
@@ -110,6 +118,7 @@ forkSuggestion pkg
110118 | chars == "elm/virtual-dom" = Just Pkg.virtualDom
111119 | chars == "elm/browser" = Just Pkg.browser
112120 | chars == "elm/http" = Just Pkg.http
121+ | chars == "elm/bytes" = Just Pkg.bytes
113122 | otherwise = Nothing
114123 where
115124 chars = Pkg.toChars pkg
@@ -129,6 +138,7 @@ installAllForks cache =
129138 _ <- installFork cache Pkg.http (V.Version 1 0 0)
130139 _ <- installFork cache Pkg.ui (V.Version 1 0 0)
131140 _ <- installFork cache Pkg.crypto (V.Version 1 0 0)
141+ _ <- installFork cache Pkg.bytes (V.Version 1 0 0)
132142 return ()
133143
134144
@@ -160,6 +170,7 @@ getForkContent pkg
160170 | pkg == Pkg.http = Just (httpElmJson, httpSrc)
161171 | pkg == Pkg.ui = Just (uiElmJson, uiSrc)
162172 | pkg == Pkg.crypto = Just (cryptoElmJson, cryptoSrc)
173+ | pkg == Pkg.bytes = Just (bytesElmJson, bytesSrc)
163174 | otherwise = Nothing
164175
165176
@@ -180,6 +191,7 @@ injectRegistry (Registry.Registry count versions) =
180191 , (Pkg.http, Registry.KnownVersions (V.Version 1 0 0) [])
181192 , (Pkg.ui, Registry.KnownVersions (V.Version 1 0 0) [])
182193 , (Pkg.crypto, Registry.KnownVersions (V.Version 1 0 0) [])
194+ , (Pkg.bytes, Registry.KnownVersions (V.Version 1 0 0) [])
183195 ]
184196 additions = filter (\(k, _) -> not (Map.member k versions)) newPkgs
185197 newVersions = foldr (\(k, v) m -> Map.insert k v m) versions additions
compiler/src/Elm/Package.hs+11−2
@@ -16,6 +16,7 @@ module Elm.Package
1616 , webgl, linearAlgebra
1717 , ui
1818 , crypto
19+ , bytes
1920 --
2021 , suggestions
2122 , nearbyNames
@@ -210,6 +211,12 @@ crypto =
210211 toName lynxjs_elm "crypto"
211212
212213
214+{-# NOINLINE bytes #-}
215+bytes :: Name
216+bytes =
217+ toName lynxjs_elm "bytes"
218+
219+
213220
214221-- PACKAGE SUGGESTIONS
215222
@@ -239,9 +246,11 @@ suggestions =
239246 , "Lynx" ==> ui
240247 , "Lynx.Attributes" ==> ui
241248 , "Lynx.Events" ==> ui
242− , "Crypto.Secp256k1" ==> crypto
249+ , "Bytes" ==> bytes
250+ , "Bytes.Decode" ==> bytes
251+ , "Bytes.Encode" ==> bytes
243252 , "Crypto.Ed25519" ==> crypto
244− , "Crypto.P256" ==> crypto
253+ , "Crypto.X25519" ==> crypto
245254 , "Crypto.Cipher" ==> crypto
246255 ]
247256
compiler/src/Generate/Html.hs+23−24
@@ -108,16 +108,6 @@ polyfill :: B.Builder
108108polyfill = [r|
109109// LynxJS PAPI-to-DOM polyfill for browser preview
110110(function() {
111− var tagMap = {
112− 'view': 'div',
113− 'text': 'span',
114− 'image': 'img',
115− 'scroll-view': 'div',
116− 'input': 'input',
117− 'textarea': 'textarea',
118− 'list': 'div'
119− };
120−
121111 var eventMap = {
122112 'tap': 'click',
123113 'longpress': 'contextmenu',
@@ -130,6 +120,12 @@ polyfill = [r|
130120
131121 var g = typeof globalThis !== 'undefined' ? globalThis : window;
132122
123+ function makeEl(domTag, lynxTag) {
124+ var el = document.createElement(domTag);
125+ el.setAttribute('data-lynx-tag', lynxTag);
126+ return el;
127+ }
128+
133129 g.__CreatePage = function() {
134130 var page = document.createElement('div');
135131 page.id = 'lynx-page';
@@ -137,11 +133,14 @@ polyfill = [r|
137133 return page;
138134 };
139135
140− g.__CreateElement = function(tag) {
141− var domTag = tagMap[tag] || 'div';
142− var el = document.createElement(domTag);
143− if (tag === 'scroll-view') { el.style.overflow = 'auto'; }
144− el.setAttribute('data-lynx-tag', tag);
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;
145144 return el;
146145 };
147146
@@ -162,7 +161,7 @@ polyfill = [r|
162161 };
163162
164163 g.__SetAttribute = function(el, key, value) {
165− if (key === 'content' && el.getAttribute('data-lynx-tag') === 'text') {
164+ if (key === 'text') {
166165 el.textContent = value;
167166 } else if (key === 'src' && el.tagName === 'IMG') {
168167 el.src = value;
@@ -171,21 +170,16 @@ polyfill = [r|
171170 }
172171 };
173172
174− g.__AddEvent = function(el, bindingName, eventName, callback) {
173+ g.__AddEvent = function(el, bindingName, eventName, handler) {
175174 var domEvent = eventMap[eventName] || eventName;
176− el.addEventListener(domEvent, function(e) {
177− callback(e);
178− });
175+ var fn = typeof handler === 'function' ? handler : handler.value;
176+ el.addEventListener(domEvent, function(e) { fn(e); });
179177 };
180178
181179 g.__SetInlineStyles = function(el, styles) {
182180 Object.assign(el.style, styles);
183181 };
184182
185− g.__AddInlineStyle = function(el, key, value) {
186− el.style[key] = value;
187− };
188−
189183 g.__GetChildren = function(el) {
190184 return Array.from(el.children);
191185 };
@@ -193,5 +187,10 @@ polyfill = [r|
193187 g.__GetParent = function(el) {
194188 return el.parentNode;
195189 };
190+
191+ g.__FlushElementTree = function() {};
192+
193+ // Set up root page so _Browser_newPage() finds it
194+ g.page = g.__CreatePage();
196195})();
197196|]
compiler/src/Generate/JavaScript.hs+135−3
@@ -1,4 +1,4 @@
1−{-# LANGUAGE OverloadedStrings #-}
1+{-# LANGUAGE OverloadedStrings, PatternGuards #-}
22module Generate.JavaScript
33 ( generate
44 , generateForRepl
@@ -8,6 +8,7 @@ module Generate.JavaScript
88
99
1010import Prelude hiding (cycle, print)
11+import qualified Data.ByteString as BS
1112import qualified Data.ByteString.Builder as B
1213import qualified Data.List as List
1314import Data.Map ((!))
@@ -161,7 +162,7 @@ emptyState =
161162
162163stateToBuilder :: State -> B.Builder
163164stateToBuilder (State revKernels revBuilders _) =
164− prependBuilders revKernels (prependBuilders revBuilders mempty)
165+ prependBuilders revKernels (extendedUtilsCmp <> prependBuilders revBuilders mempty)
165166
166167
167168prependBuilders :: [B.Builder] -> B.Builder -> B.Builder
@@ -169,6 +170,43 @@ prependBuilders revBuilders monolith =
169170 List.foldl' (\m b -> b <> m) monolith revBuilders
170171
171172
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+
172210
173211-- ADD DEPENDENCIES
174212
@@ -342,7 +380,7 @@ drawCycle names =
342380
343381generateKernel :: Mode.Mode -> [K.Chunk] -> B.Builder
344382generateKernel mode chunks =
345− List.foldr (addChunk mode) mempty chunks
383+ List.foldr (addChunk mode) mempty (stripDeadDefs mode chunks)
346384
347385
348386addChunk :: Mode.Mode -> K.Chunk -> B.Builder -> B.Builder
@@ -384,6 +422,100 @@ addChunk mode chunk builder =
384422
385423
386424
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+
387519-- GENERATE ENUM
388520
389521
compiler/src/Generate/JavaScript/Builder.hs+17
@@ -48,6 +48,7 @@ data Expr
4848 | Json Json.Value
4949 | Array [Expr]
5050 | Object [(Name, Expr)]
51+ | ObjectSpread Expr [(Name, Expr)]
5152 | Ref Name
5253 | Access Expr Name -- foo.bar
5354 | Index Expr Expr -- foo[bar]
@@ -377,6 +378,22 @@ fromExpr level@(Level indent nextLevel@(Level deeperIndent _)) grouping expressi
377378 else
378379 "{" <> commaSep builders <> "}"
379380
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+
380397 Ref name ->
381398 ( One, Name.toBuilder name )
382399
compiler/src/Generate/JavaScript/Expression.hs+11−4
@@ -149,10 +149,17 @@ generate mode expression =
149149
150150 Opt.Update record fields ->
151151 JsExpr $
152− JS.Call (JS.Ref (JsName.fromKernel Name.utils "update"))
153− [ generateJsExpr mode record
154− , generateRecord mode fields
155− ]
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+ ]
156163
157164 Opt.Record fields ->
158165 JsExpr $ generateRecord mode fields
compiler/src/Type/Unify.hs+22−41
@@ -369,53 +369,34 @@ isNumber home name =
369369
370370unifyFlexSuperStructure :: Context -> SuperType -> FlatType -> Unify ()
371371unifyFlexSuperStructure context super flatType =
372− case flatType of
373− App1 home name [] ->
374− if atomMatchesSuper super home name then
375− merge context (Structure flatType)
376− else
377− mismatch
378−
379− App1 home name [variable] | home == ModuleName.list && name == Name.list ->
380− case super of
381− Number ->
382− 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)
383377
384− Appendable ->
378+ _ ->
379+ case flatType of
380+ App1 home name [] ->
381+ if atomMatchesSuper super home name then
385382 merge context (Structure flatType)
386−
387− Comparable ->
388− do comparableOccursCheck context
389− unifyComparableRecursive variable
390− merge context (Structure flatType)
391−
392− CompAppend ->
393− do comparableOccursCheck context
394− unifyComparableRecursive variable
395− merge context (Structure flatType)
396−
397− Tuple1 a b maybeC ->
398− case super of
399− Number ->
400− mismatch
401−
402− Appendable ->
383+ else
403384 mismatch
404385
405− Comparable ->
406− do comparableOccursCheck context
407− unifyComparableRecursive a
408− unifyComparableRecursive b
409− case maybeC of
410− Nothing -> return ()
411− Just c -> unifyComparableRecursive c
412− 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)
413394
414− CompAppend ->
415− mismatch
395+ Tuple1 _ _ _ ->
396+ mismatch
416397
417− _ ->
418− mismatch
398+ _ ->
399+ mismatch
419400
420401
421402-- TODO: is there some way to avoid doing this?
examples/counter/elm.js+70−53
@@ -234,10 +234,6 @@ var _JsArray_appendN = F3(function(n, dest, source)
234234
235235// LOG
236236
237−var _Debug_log_UNUSED = F2(function(tag, value)
238−{
239− return value;
240−});
241237
242238var _Debug_log = F2(function(tag, value)
243239{
@@ -265,10 +261,6 @@ function _Debug_todoCase(moduleName, region, value)
265261
266262// TO STRING
267263
268−function _Debug_toString_UNUSED(value)
269−{
270− return '<internals>';
271−}
272264
273265function _Debug_toString(value)
274266{
@@ -455,10 +447,6 @@ function _Debug_toHexDigit(n)
455447// CRASH
456448
457449
458−function _Debug_crash_UNUSED(identifier)
459−{
460− throw new Error('https://github.com/elm/core/blob/1.0.0/hints/' + identifier + '.md');
461−}
462450
463451
464452function _Debug_crash(identifier, fact1, fact2, fact3, fact4)
@@ -651,16 +639,12 @@ var _Utils_compare = F2(function(x, y)
651639
652640// COMMON VALUES
653641
654−var _Utils_Tuple0_UNUSED = 0;
655642var _Utils_Tuple0 = { $: '#0' };
656643
657−function _Utils_Tuple2_UNUSED(a, b) { return { a: a, b: b }; }
658644function _Utils_Tuple2(a, b) { return { $: '#2', a: a, b: b }; }
659645
660−function _Utils_Tuple3_UNUSED(a, b, c) { return { a: a, b: b, c: c }; }
661646function _Utils_Tuple3(a, b, c) { return { $: '#3', a: a, b: b, c: c }; }
662647
663−function _Utils_chr_UNUSED(c) { return c; }
664648function _Utils_chr(c) { return new String(c); }
665649
666650
@@ -712,10 +696,8 @@ function _Utils_ap(xs, ys)
712696
713697
714698
715−var _List_Nil_UNUSED = { $: 0 };
716699var _List_Nil = { $: '[]' };
717700
718−function _List_Cons_UNUSED(hd, tl) { return { $: 1, a: hd, b: tl }; }
719701function _List_Cons(hd, tl) { return { $: '::', a: hd, b: tl }; }
720702
721703
@@ -1619,8 +1601,6 @@ var _Json_encode = F2(function(indentLevel, value)
16191601function _Json_wrap(value) { return { $: 0, a: value }; }
16201602function _Json_unwrap(value) { return value.a; }
16211603
1622−function _Json_wrap_UNUSED(value) { return value; }
1623−function _Json_unwrap_UNUSED(value) { return value; }
16241604
16251605function _Json_emptyArray() { return []; }
16261606function _Json_emptyObject() { return {}; }
@@ -2316,12 +2296,6 @@ function _Platform_setupIncomingPort(name, sendToApp)
23162296//
23172297
23182298
2319−function _Platform_export_UNUSED(exports)
2320−{
2321− scope['Elm']
2322− ? _Platform_mergeExportsProd(scope['Elm'], exports)
2323− : scope['Elm'] = exports;
2324−}
23252299
23262300
23272301function _Platform_mergeExportsProd(obj, exports)
@@ -2361,29 +2335,26 @@ function _Platform_mergeExportsDebug(moduleName, obj, exports)
23612335
23622336var _Lynx_g = (typeof globalThis !== 'undefined' ? globalThis : scope);
23632337function _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');
23642341function _Lynx_createElement(tag) {
23652342 var pId = (_Lynx_g['native'] && _Lynx_g['native']['currentPageId']) || 0;
2366− var creators = { 'view': 'CreateView', 'text': 'CreateText', 'image': 'CreateImage' };
2367− var name = creators[tag] || 'CreateView';
2368− var fn = _Lynx_g['_' + '_' + name];
2369− if (typeof fn === 'function') { return fn(pId); }
2370− return _Lynx_papi('CreateElement')(tag, pId);
2371−}
2372−function _Lynx_createRawText(text) {
2373− var fn = _Lynx_g['_' + '_CreateRawText'];
2374− if (typeof fn === 'function') { return fn(text); }
2375− return {};
2343+ return (tag === 'text' ? _Lynx_createTextFn
2344+ : tag === 'image' ? _Lynx_createImageFn
2345+ : _Lynx_createViewFn)(pId);
23762346}
2347+var _Lynx_createRawText = _Lynx_papi('CreateRawText');
23772348var _Lynx_appendChild = _Lynx_papi('AppendElement');
23782349var _Lynx_removeElement = _Lynx_papi('RemoveElement');
23792350var _Lynx_replaceElement = _Lynx_papi('ReplaceElement');
23802351var _Lynx_insertBefore = _Lynx_papi('InsertElementBefore');
23812352var _Lynx_setAttribute = _Lynx_papi('SetAttribute');
2382−var _Lynx_getChildren = _Lynx_g['_' + '_GetChildren'] || function() { return []; };
2383−var _Lynx_getParent = _Lynx_g['_' + '_GetParent'] || function() { return null; };
2353+var _Lynx_getChildren = _Lynx_papi('GetChildren');
2354+var _Lynx_getParent = _Lynx_papi('GetParent');
23842355var _Lynx_addEvent = _Lynx_papi('AddEvent');
23852356var _Lynx_setInlineStyles = _Lynx_papi('SetInlineStyles');
2386−var _VirtualDom_elementMeta = new Map();
2357+var _VirtualDom_elementMeta = new WeakMap();
23872358function _VirtualDom_getMeta(el) {
23882359 var meta = _VirtualDom_elementMeta.get(el);
23892360 if (!meta) { meta = {}; _VirtualDom_elementMeta.set(el, meta); }
@@ -2875,11 +2846,7 @@ function _VirtualDom_applyFacts(domNode, eventNode, facts)
28752846
28762847function _VirtualDom_applyStyles(domNode, styles)
28772848{
2878− var _sIS = _Lynx_g['_' + '_SetInlineStyles'];
2879− if (typeof _sIS === 'function')
2880− {
2881− _sIS(domNode, styles);
2882− }
2849+ _Lynx_setInlineStyles(domNode, styles);
28832850}
28842851
28852852
@@ -3800,7 +3767,7 @@ function _VirtualDom_applyPatch(domNode, patch)
38003767 return patch.s(domNode);
38013768
38023769 default:
3803− _Debug_crash(10); // 'Ran into an unknown patch!'
3770+ throw new Error('VirtualDom: unknown patch type');
38043771 }
38053772}
38063773
@@ -4314,6 +4281,7 @@ function _Browser_load(url)
43144281 }
43154282 }));
43164283}
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; }
43174285var $author$project$Main$init = {count: 0};
43184286var $elm$core$List$cons = _List_cons;
43194287var $elm$core$Elm$JsArray$foldr = _JsArray_foldr;
@@ -5002,11 +4970,39 @@ var $author$project$Main$update = F2(
50024970 {count: model.count - 1});
50034971 }
50044972 });
4973+var $lynxjs_elm$ui$Lynx$Attributes$Center = {$: 'Center'};
4974+var $lynxjs_elm$ui$Lynx$Attributes$Column = {$: 'Column'};
50054975var $author$project$Main$Decrement = {$: 'Decrement'};
50064976var $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+};
50074998var $lynxjs_elm$virtual_dom$VirtualDom$style = _VirtualDom_style;
50084999var $lynxjs_elm$ui$Lynx$Attributes$style = $lynxjs_elm$virtual_dom$VirtualDom$style;
5009−var $lynxjs_elm$ui$Lynx$Attributes$alignItems = $lynxjs_elm$ui$Lynx$Attributes$style('alignItems');
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+};
50105006var $lynxjs_elm$ui$Lynx$Attributes$backgroundColor = $lynxjs_elm$ui$Lynx$Attributes$style('backgroundColor');
50115007var $lynxjs_elm$ui$Lynx$Attributes$pxStyle = F2(
50125008 function (key, val) {
@@ -5078,8 +5074,29 @@ var $lynxjs_elm$ui$Lynx$Attributes$intStyle = F2(
50785074 $elm$core$String$fromInt(val));
50795075 });
50805076var $lynxjs_elm$ui$Lynx$Attributes$flex = $lynxjs_elm$ui$Lynx$Attributes$intStyle('flex');
5081−var $lynxjs_elm$ui$Lynx$Attributes$flexDirection = $lynxjs_elm$ui$Lynx$Attributes$style('flexDirection');
5082−var $lynxjs_elm$ui$Lynx$Attributes$justifyContent = $lynxjs_elm$ui$Lynx$Attributes$style('justifyContent');
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+};
50835100var $lynxjs_elm$ui$Lynx$Attributes$marginLeft = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('marginLeft');
50845101var $lynxjs_elm$ui$Lynx$Attributes$marginRight = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('marginRight');
50855102var $author$project$Main$view = function (model) {
@@ -5087,9 +5104,9 @@ var $author$project$Main$view = function (model) {
50875104 $lynxjs_elm$ui$Lynx$view,
50885105 _List_fromArray(
50895106 [
5090− $lynxjs_elm$ui$Lynx$Attributes$flexDirection('column'),
5091− $lynxjs_elm$ui$Lynx$Attributes$alignItems('center'),
5092− $lynxjs_elm$ui$Lynx$Attributes$justifyContent('center'),
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),
50935110 $lynxjs_elm$ui$Lynx$Attributes$flex(1)
50945111 ]),
50955112 _List_fromArray(
@@ -5098,8 +5115,8 @@ var $author$project$Main$view = function (model) {
50985115 $lynxjs_elm$ui$Lynx$view,
50995116 _List_fromArray(
51005117 [
5101− $lynxjs_elm$ui$Lynx$Attributes$flexDirection('row'),
5102− $lynxjs_elm$ui$Lynx$Attributes$alignItems('center')
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)
51035120 ]),
51045121 _List_fromArray(
51055122 [
examples/counter/main.html+187−150
@@ -14,16 +14,6 @@ body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-
1414
1515// LynxJS PAPI-to-DOM polyfill for browser preview
1616(function() {
17− var tagMap = {
18− 'view': 'div',
19− 'text': 'span',
20− 'image': 'img',
21− 'scroll-view': 'div',
22− 'input': 'input',
23− 'textarea': 'textarea',
24− 'list': 'div'
25− };
26−
2717 var eventMap = {
2818 'tap': 'click',
2919 'longpress': 'contextmenu',
@@ -36,6 +26,12 @@ body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-
3626
3727 var g = typeof globalThis !== 'undefined' ? globalThis : window;
3828
29+ function makeEl(domTag, lynxTag) {
30+ var el = document.createElement(domTag);
31+ el.setAttribute('data-lynx-tag', lynxTag);
32+ return el;
33+ }
34+
3935 g.__CreatePage = function() {
4036 var page = document.createElement('div');
4137 page.id = 'lynx-page';
@@ -43,11 +39,14 @@ body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-
4339 return page;
4440 };
4541
46− g.__createElement = function(tag) {
47− var domTag = tagMap[tag] || 'div';
48− var el = document.createElement(domTag);
49− if (tag === 'scroll-view') { el.style.overflow = 'auto'; }
50− el.setAttribute('data-lynx-tag', tag);
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;
5150 return el;
5251 };
5352
@@ -68,7 +67,7 @@ body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-
6867 };
6968
7069 g.__SetAttribute = function(el, key, value) {
71− if (key === 'content' && el.getAttribute('data-lynx-tag') === 'text') {
70+ if (key === 'text') {
7271 el.textContent = value;
7372 } else if (key === 'src' && el.tagName === 'IMG') {
7473 el.src = value;
@@ -77,21 +76,16 @@ body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-
7776 }
7877 };
7978
80− g.__AddEvent = function(el, bindingName, eventName, callback) {
79+ g.__AddEvent = function(el, bindingName, eventName, handler) {
8180 var domEvent = eventMap[eventName] || eventName;
82− el.addEventListener(domEvent, function(e) {
83− callback(e);
84− });
81+ var fn = typeof handler === 'function' ? handler : handler.value;
82+ el.addEventListener(domEvent, function(e) { fn(e); });
8583 };
8684
8785 g.__SetInlineStyles = function(el, styles) {
8886 Object.assign(el.style, styles);
8987 };
9088
91− g.__AddInlineStyle = function(el, key, value) {
92− el.style[key] = value;
93− };
94−
9589 g.__GetChildren = function(el) {
9690 return Array.from(el.children);
9791 };
@@ -99,6 +93,11 @@ body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-
9993 g.__GetParent = function(el) {
10094 return el.parentNode;
10195 };
96+
97+ g.__FlushElementTree = function() {};
98+
99+ // Set up root page so _Browser_newPage() finds it
100+ g.page = g.__CreatePage();
102101})();
103102
104103</script>
@@ -339,10 +338,6 @@ var _JsArray_appendN = F3(function(n, dest, source)
339338
340339// LOG
341340
342−var _Debug_log_UNUSED = F2(function(tag, value)
343−{
344− return value;
345−});
346341
347342var _Debug_log = F2(function(tag, value)
348343{
@@ -370,10 +365,6 @@ function _Debug_todoCase(moduleName, region, value)
370365
371366// TO STRING
372367
373−function _Debug_toString_UNUSED(value)
374−{
375− return '<internals>';
376−}
377368
378369function _Debug_toString(value)
379370{
@@ -560,10 +551,6 @@ function _Debug_toHexDigit(n)
560551// CRASH
561552
562553
563−function _Debug_crash_UNUSED(identifier)
564−{
565− throw new Error('https://github.com/elm/core/blob/1.0.0/hints/' + identifier + '.md');
566−}
567554
568555
569556function _Debug_crash(identifier, fact1, fact2, fact3, fact4)
@@ -756,16 +743,12 @@ var _Utils_compare = F2(function(x, y)
756743
757744// COMMON VALUES
758745
759−var _Utils_Tuple0_UNUSED = 0;
760746var _Utils_Tuple0 = { $: '#0' };
761747
762−function _Utils_Tuple2_UNUSED(a, b) { return { a: a, b: b }; }
763748function _Utils_Tuple2(a, b) { return { $: '#2', a: a, b: b }; }
764749
765−function _Utils_Tuple3_UNUSED(a, b, c) { return { a: a, b: b, c: c }; }
766750function _Utils_Tuple3(a, b, c) { return { $: '#3', a: a, b: b, c: c }; }
767751
768−function _Utils_chr_UNUSED(c) { return c; }
769752function _Utils_chr(c) { return new String(c); }
770753
771754
@@ -817,10 +800,8 @@ function _Utils_ap(xs, ys)
817800
818801
819802
820−var _List_Nil_UNUSED = { $: 0 };
821803var _List_Nil = { $: '[]' };
822804
823−function _List_Cons_UNUSED(hd, tl) { return { $: 1, a: hd, b: tl }; }
824805function _List_Cons(hd, tl) { return { $: '::', a: hd, b: tl }; }
825806
826807
@@ -1724,8 +1705,6 @@ var _Json_encode = F2(function(indentLevel, value)
17241705function _Json_wrap(value) { return { $: 0, a: value }; }
17251706function _Json_unwrap(value) { return value.a; }
17261707
1727−function _Json_wrap_UNUSED(value) { return value; }
1728−function _Json_unwrap_UNUSED(value) { return value; }
17291708
17301709function _Json_emptyArray() { return []; }
17311710function _Json_emptyObject() { return {}; }
@@ -2421,12 +2400,6 @@ function _Platform_setupIncomingPort(name, sendToApp)
24212400//
24222401
24232402
2424−function _Platform_export_UNUSED(exports)
2425−{
2426− scope['Elm']
2427− ? _Platform_mergeExportsProd(scope['Elm'], exports)
2428− : scope['Elm'] = exports;
2429−}
24302403
24312404
24322405function _Platform_mergeExportsProd(obj, exports)
@@ -2466,20 +2439,26 @@ function _Platform_mergeExportsDebug(moduleName, obj, exports)
24662439
24672440var _Lynx_g = (typeof globalThis !== 'undefined' ? globalThis : scope);
24682441function _Lynx_papi(name) { return _Lynx_g['_' + '_' + name] || function() {}; }
2469−var _Lynx_createElement = _Lynx_papi('createElement');
2470−var _Lynx_createPage = _Lynx_papi('CreatePage');
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');
24712452var _Lynx_appendChild = _Lynx_papi('AppendElement');
24722453var _Lynx_removeElement = _Lynx_papi('RemoveElement');
24732454var _Lynx_replaceElement = _Lynx_papi('ReplaceElement');
24742455var _Lynx_insertBefore = _Lynx_papi('InsertElementBefore');
24752456var _Lynx_setAttribute = _Lynx_papi('SetAttribute');
2476−var _Lynx_getChildren = _Lynx_g['_' + '_GetChildren'] || function() { return []; };
2477−var _Lynx_getParent = _Lynx_g['_' + '_GetParent'] || function() { return null; };
2457+var _Lynx_getChildren = _Lynx_papi('GetChildren');
2458+var _Lynx_getParent = _Lynx_papi('GetParent');
24782459var _Lynx_addEvent = _Lynx_papi('AddEvent');
2479−var _Lynx_setInlineStyles = _Lynx_g['_' + '_SetInlineStyles'];
2480−var _Lynx_addInlineStyle = _Lynx_papi('AddInlineStyle');
2481−
2482−var _VirtualDom_elementMeta = new Map();
2460+var _Lynx_setInlineStyles = _Lynx_papi('SetInlineStyles');
2461+var _VirtualDom_elementMeta = new WeakMap();
24832462function _VirtualDom_getMeta(el) {
24842463 var meta = _VirtualDom_elementMeta.get(el);
24852464 if (!meta) { meta = {}; _VirtualDom_elementMeta.set(el, meta); }
@@ -2501,7 +2480,7 @@ function _VirtualDom_appendChild(parent, child)
25012480var _VirtualDom_init = F4(function(virtualNode, flagDecoder, debugMetadata, args)
25022481{
25032482 // NOTE: this function needs _Platform_export available to work
2504− var rootPage = args['node'] || _Lynx_createPage();
2483+ var rootPage = args['node'] || _Lynx_g['page'];
25052484 var tree = _VirtualDom_render(virtualNode, function() {});
25062485 _Lynx_appendChild(rootPage, tree);
25072486 return {};
@@ -2793,7 +2772,7 @@ var _VirtualDom_mapAttribute = F2(function(func, attr)
27932772
27942773function _VirtualDom_mapHandler(func, handler)
27952774{
2796− var tag = $elm$virtual_dom$VirtualDom$toHandlerInt(handler);
2775+ var tag = $lynxjs_elm$virtual_dom$VirtualDom$toHandlerInt(handler);
27972776
27982777 // 0 = Normal
27992778 // 1 = MayStopPropagation
@@ -2885,9 +2864,7 @@ function _VirtualDom_render(vNode, eventNode)
28852864
28862865 if (tag === 0)
28872866 {
2888− var textEl = _Lynx_createElement('text', 0, {});
2889− _Lynx_setAttribute(textEl, 'content', vNode.a);
2890− return textEl;
2867+ return _Lynx_createRawText(vNode.a);
28912868 }
28922869
28932870 if (tag === 4)
@@ -2919,13 +2896,21 @@ function _VirtualDom_render(vNode, eventNode)
29192896
29202897 // at this point `tag` must be 1 or 2
29212898
2922− var domNode = _Lynx_createElement(vNode.c, 0, {});
2899+ var domNode = _Lynx_createElement(vNode.c);
29232900
29242901 _VirtualDom_applyFacts(domNode, eventNode, vNode.d);
29252902
29262903 for (var kids = vNode.e, i = 0; i < kids.length; i++)
29272904 {
2928− _VirtualDom_appendChild(domNode, _VirtualDom_render(tag === 1 ? kids[i] : kids[i].b, eventNode));
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+ }
29292914 }
29302915
29312916 return domNode;
@@ -2965,17 +2950,7 @@ function _VirtualDom_applyFacts(domNode, eventNode, facts)
29652950
29662951function _VirtualDom_applyStyles(domNode, styles)
29672952{
2968− if (_Lynx_setInlineStyles)
2969− {
2970− _Lynx_setInlineStyles(domNode, styles);
2971− }
2972− else
2973− {
2974− for (var key in styles)
2975− {
2976− _Lynx_addInlineStyle(domNode, key, styles[key]);
2977− }
2978− }
2953+ _Lynx_setInlineStyles(domNode, styles);
29792954}
29802955
29812956
@@ -3049,9 +3024,9 @@ function _VirtualDom_applyEvents(domNode, eventNode, events)
30493024 allCallbacks[key] = oldCallback;
30503025
30513026 var lynxEventName = _VirtualDom_mapEventName(key);
3052− var handlerType = $elm$virtual_dom$VirtualDom$toHandlerInt(newHandler);
3027+ var handlerType = $lynxjs_elm$virtual_dom$VirtualDom$toHandlerInt(newHandler);
30533028 var prefix = (handlerType === 1) ? 'catch' : 'bind';
3054− _Lynx_addEvent(domNode, prefix + lynxEventName, lynxEventName, oldCallback);
3029+ _Lynx_addEvent(domNode, 'catchEvent', lynxEventName, { type: 'worklet', value: oldCallback });
30553030 }
30563031}
30573032
@@ -3089,7 +3064,7 @@ function _VirtualDom_makeCallback(eventNode, initialHandler)
30893064 return;
30903065 }
30913066
3092− var tag = $elm$virtual_dom$VirtualDom$toHandlerInt(handler);
3067+ var tag = $lynxjs_elm$virtual_dom$VirtualDom$toHandlerInt(handler);
30933068
30943069 // 0 = Normal
30953070 // 1 = MayStopPropagation
@@ -3839,7 +3814,7 @@ function _VirtualDom_applyPatch(domNode, patch)
38393814 return domNode;
38403815
38413816 case 3:
3842− _Lynx_setAttribute(domNode, 'content', patch.s);
3817+ _Lynx_setAttribute(domNode, 'text', patch.s);
38433818 return domNode;
38443819
38453820 case 1:
@@ -3896,7 +3871,7 @@ function _VirtualDom_applyPatch(domNode, patch)
38963871 return patch.s(domNode);
38973872
38983873 default:
3899− _Debug_crash(10); // 'Ran into an unknown patch!'
3874+ throw new Error('VirtualDom: unknown patch type');
39003875 }
39013876}
39023877
@@ -4000,16 +3975,20 @@ function _VirtualDom_dekey(keyedNode)
40003975
40013976// LYNXJS PAPI WRAPPERS
40023977var _Browser_lynx = (typeof globalThis !== 'undefined' ? globalThis : scope);
4003−var _Browser_createPage = _Browser_lynx['_' + '_CreatePage'] || function() { return {}; };
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+}
40043985
40053986
40063987
40073988// ELEMENT
40083989
40093990
4010−var _Debugger_element;
4011−
4012−var _Browser_element = _Debugger_element || F4(function(impl, flagDecoder, debugMetadata, args)
3991+var _Browser_element = F4(function(impl, flagDecoder, debugMetadata, args)
40133992{
40143993 return _Platform_initialize(
40153994 flagDecoder,
@@ -4019,10 +3998,11 @@ var _Browser_element = _Debugger_element || F4(function(impl, flagDecoder, debug
40193998 impl.subscriptions,
40203999 function(sendToApp, initialModel) {
40214000 var view = impl.view;
4022− var domNode = args['node'] || _Browser_createPage();
4001+ var domNode = args['node'] || _Browser_newPage();
40234002 var currNode = view(initialModel);
40244003 var currDomNode = _VirtualDom_render(currNode, sendToApp);
40254004 _VirtualDom_appendChild(domNode, currDomNode);
4005+ _Browser_flush();
40264006
40274007 return _Browser_makeAnimator(initialModel, function(model)
40284008 {
@@ -4030,6 +4010,7 @@ var _Browser_element = _Debugger_element || F4(function(impl, flagDecoder, debug
40304010 var patches = _VirtualDom_diff(currNode, nextNode);
40314011 currDomNode = _VirtualDom_applyPatches(currDomNode, currNode, patches, sendToApp);
40324012 currNode = nextNode;
4013+ _Browser_flush();
40334014 });
40344015 }
40354016 );
@@ -4040,9 +4021,7 @@ var _Browser_element = _Debugger_element || F4(function(impl, flagDecoder, debug
40404021// DOCUMENT
40414022
40424023
4043−var _Debugger_document;
4044−
4045−var _Browser_document = _Debugger_document || F4(function(impl, flagDecoder, debugMetadata, args)
4024+var _Browser_document = F4(function(impl, flagDecoder, debugMetadata, args)
40464025{
40474026 return _Platform_initialize(
40484027 flagDecoder,
@@ -4052,11 +4031,12 @@ var _Browser_document = _Debugger_document || F4(function(impl, flagDecoder, deb
40524031 impl.subscriptions,
40534032 function(sendToApp, initialModel) {
40544033 var view = impl.view;
4055− var rootNode = args['node'] || _Browser_createPage();
4034+ var rootNode = args['node'] || _Browser_newPage();
40564035 var doc = view(initialModel);
40574036 var currNode = _VirtualDom_node('view')(_List_Nil)(doc.body);
40584037 var currDomNode = _VirtualDom_render(currNode, sendToApp);
40594038 _VirtualDom_appendChild(rootNode, currDomNode);
4039+ _Browser_flush();
40604040
40614041 return _Browser_makeAnimator(initialModel, function(model)
40624042 {
@@ -4065,6 +4045,7 @@ var _Browser_document = _Debugger_document || F4(function(impl, flagDecoder, deb
40654045 var patches = _VirtualDom_diff(currNode, nextNode);
40664046 currDomNode = _VirtualDom_applyPatches(currDomNode, currNode, patches, sendToApp);
40674047 currNode = nextNode;
4048+ _Browser_flush();
40684049 });
40694050 }
40704051 );
@@ -4246,7 +4227,7 @@ function _Browser_withNode(id, doStuff)
42464227{
42474228 return _Scheduler_binding(function(callback)
42484229 {
4249− callback(_Scheduler_fail($elm$browser$Browser$Dom$NotFound(id)));
4230+ callback(_Scheduler_fail($lynxjs_elm$browser$Browser$Dom$NotFound(id)));
42504231 });
42514232}
42524233
@@ -4883,7 +4864,7 @@ var $elm$core$Result$isOk = function (result) {
48834864var $elm$json$Json$Decode$map = _Json_map1;
48844865var $elm$json$Json$Decode$map2 = _Json_map2;
48854866var $elm$json$Json$Decode$succeed = _Json_succeed;
4886−var $elm$virtual_dom$VirtualDom$toHandlerInt = function (handler) {
4867+var $lynxjs_elm$virtual_dom$VirtualDom$toHandlerInt = function (handler) {
48874868 switch (handler.$) {
48884869 case 'Normal':
48894870 return 0;
@@ -4898,7 +4879,7 @@ var $elm$virtual_dom$VirtualDom$toHandlerInt = function (handler) {
48984879var $elm$core$Basics$identity = function (x) {
48994880 return x;
49004881};
4901−var $elm$browser$Browser$Dom$NotFound = function (a) {
4882+var $lynxjs_elm$browser$Browser$Dom$NotFound = function (a) {
49024883 return {$: 'NotFound', a: a};
49034884};
49044885var $elm$core$Basics$never = function (_v0) {
@@ -5062,7 +5043,7 @@ var $elm$core$Platform$Cmd$batch = _Platform_batch;
50625043var $elm$core$Platform$Cmd$none = $elm$core$Platform$Cmd$batch(_List_Nil);
50635044var $elm$core$Platform$Sub$batch = _Platform_batch;
50645045var $elm$core$Platform$Sub$none = $elm$core$Platform$Sub$batch(_List_Nil);
5065−var $elm$browser$Browser$sandbox = function (impl) {
5046+var $lynxjs_elm$browser$Browser$sandbox = function (impl) {
50665047 return _Browser_element(
50675048 {
50685049 init: function (_v0) {
@@ -5092,122 +5073,178 @@ var $author$project$Main$update = F2(
50925073 {count: model.count - 1});
50935074 }
50945075 });
5076+var $lynxjs_elm$ui$Lynx$Attributes$Center = {$: 'Center'};
5077+var $lynxjs_elm$ui$Lynx$Attributes$Column = {$: 'Column'};
50955078var $author$project$Main$Decrement = {$: 'Decrement'};
50965079var $author$project$Main$Increment = {$: 'Increment'};
5097−var $elm$virtual_dom$VirtualDom$style = _VirtualDom_style;
5098−var $author$project$Lynx$Attributes$style = $elm$virtual_dom$VirtualDom$style;
5099−var $author$project$Lynx$Attributes$alignItems = $author$project$Lynx$Attributes$style('alignItems');
5100−var $author$project$Lynx$Attributes$backgroundColor = $author$project$Lynx$Attributes$style('backgroundColor');
5101−var $author$project$Lynx$Attributes$intStyle = F2(
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(
51025111 function (key, val) {
51035112 return A2(
5104− $elm$virtual_dom$VirtualDom$style,
5113+ $lynxjs_elm$virtual_dom$VirtualDom$style,
51055114 key,
5106− $elm$core$String$fromInt(val));
5115+ $elm$core$String$fromInt(val) + 'px');
51075116 });
5108−var $author$project$Lynx$Attributes$borderRadius = $author$project$Lynx$Attributes$intStyle('borderRadius');
5109−var $author$project$Lynx$Attributes$color = $author$project$Lynx$Attributes$style('color');
5110−var $author$project$Lynx$Attributes$fontSize = $author$project$Lynx$Attributes$intStyle('fontSize');
5111−var $elm$virtual_dom$VirtualDom$Normal = function (a) {
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) {
51125121 return {$: 'Normal', a: a};
51135122};
5114−var $elm$virtual_dom$VirtualDom$on = _VirtualDom_on;
5115−var $author$project$Lynx$Events$onTap = function (msg) {
5123+var $lynxjs_elm$virtual_dom$VirtualDom$on = _VirtualDom_on;
5124+var $lynxjs_elm$ui$Lynx$Events$onTap = function (msg) {
51165125 return A2(
5117− $elm$virtual_dom$VirtualDom$on,
5126+ $lynxjs_elm$virtual_dom$VirtualDom$on,
51185127 'tap',
5119− $elm$virtual_dom$VirtualDom$Normal(
5128+ $lynxjs_elm$virtual_dom$VirtualDom$Normal(
51205129 $elm$json$Json$Decode$succeed(msg)));
51215130};
5122−var $author$project$Lynx$Attributes$paddingBottom = $author$project$Lynx$Attributes$intStyle('paddingBottom');
5123−var $author$project$Lynx$Attributes$paddingLeft = $author$project$Lynx$Attributes$intStyle('paddingLeft');
5124−var $author$project$Lynx$Attributes$paddingRight = $author$project$Lynx$Attributes$intStyle('paddingRight');
5125−var $author$project$Lynx$Attributes$paddingTop = $author$project$Lynx$Attributes$intStyle('paddingTop');
5126−var $elm$virtual_dom$VirtualDom$node = function (tag) {
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) {
51275136 return _VirtualDom_node(
51285137 _VirtualDom_noScript(tag));
51295138};
5130−var $author$project$Lynx$text = $elm$virtual_dom$VirtualDom$node('text');
5131−var $elm$virtual_dom$VirtualDom$text = _VirtualDom_text;
5132−var $author$project$Lynx$textContent = $elm$virtual_dom$VirtualDom$text;
5133−var $author$project$Lynx$view = $elm$virtual_dom$VirtualDom$node('view');
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');
51345143var $author$project$Main$button = F2(
51355144 function (msg, label) {
51365145 return A2(
5137− $author$project$Lynx$view,
5146+ $lynxjs_elm$ui$Lynx$view,
51385147 _List_fromArray(
51395148 [
5140− $author$project$Lynx$Events$onTap(msg),
5141− $author$project$Lynx$Attributes$backgroundColor('#4a90d9'),
5142− $author$project$Lynx$Attributes$borderRadius(8),
5143− $author$project$Lynx$Attributes$paddingTop(12),
5144− $author$project$Lynx$Attributes$paddingBottom(12),
5145− $author$project$Lynx$Attributes$paddingLeft(24),
5146− $author$project$Lynx$Attributes$paddingRight(24)
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)
51475156 ]),
51485157 _List_fromArray(
51495158 [
51505159 A2(
5151− $author$project$Lynx$text,
5160+ $lynxjs_elm$ui$Lynx$text,
51525161 _List_fromArray(
51535162 [
5154− $author$project$Lynx$Attributes$color('#ffffff'),
5155− $author$project$Lynx$Attributes$fontSize(24)
5163+ $lynxjs_elm$ui$Lynx$Attributes$color('#ffffff'),
5164+ $lynxjs_elm$ui$Lynx$Attributes$fontSize(24)
51565165 ]),
51575166 _List_fromArray(
51585167 [
5159− $author$project$Lynx$textContent(label)
5168+ $lynxjs_elm$ui$Lynx$textContent(label)
51605169 ]))
51615170 ]));
51625171 });
5163−var $author$project$Lynx$Attributes$flex = $author$project$Lynx$Attributes$intStyle('flex');
5164−var $author$project$Lynx$Attributes$flexDirection = $author$project$Lynx$Attributes$style('flexDirection');
5165−var $author$project$Lynx$Attributes$justifyContent = $author$project$Lynx$Attributes$style('justifyContent');
5166−var $author$project$Lynx$Attributes$marginLeft = $author$project$Lynx$Attributes$intStyle('marginLeft');
5167−var $author$project$Lynx$Attributes$marginRight = $author$project$Lynx$Attributes$intStyle('marginRight');
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');
51685205var $author$project$Main$view = function (model) {
51695206 return A2(
5170− $author$project$Lynx$view,
5207+ $lynxjs_elm$ui$Lynx$view,
51715208 _List_fromArray(
51725209 [
5173− $author$project$Lynx$Attributes$flexDirection('column'),
5174− $author$project$Lynx$Attributes$alignItems('center'),
5175− $author$project$Lynx$Attributes$justifyContent('center'),
5176− $author$project$Lynx$Attributes$flex(1)
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)
51775214 ]),
51785215 _List_fromArray(
51795216 [
51805217 A2(
5181− $author$project$Lynx$view,
5218+ $lynxjs_elm$ui$Lynx$view,
51825219 _List_fromArray(
51835220 [
5184− $author$project$Lynx$Attributes$flexDirection('row'),
5185− $author$project$Lynx$Attributes$alignItems('center')
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)
51865223 ]),
51875224 _List_fromArray(
51885225 [
51895226 A2($author$project$Main$button, $author$project$Main$Decrement, '-'),
51905227 A2(
5191− $author$project$Lynx$text,
5228+ $lynxjs_elm$ui$Lynx$text,
51925229 _List_fromArray(
51935230 [
5194− $author$project$Lynx$Attributes$fontSize(32),
5195− $author$project$Lynx$Attributes$marginLeft(20),
5196− $author$project$Lynx$Attributes$marginRight(20)
5231+ $lynxjs_elm$ui$Lynx$Attributes$fontSize(32),
5232+ $lynxjs_elm$ui$Lynx$Attributes$marginLeft(20),
5233+ $lynxjs_elm$ui$Lynx$Attributes$marginRight(20)
51975234 ]),
51985235 _List_fromArray(
51995236 [
5200− $author$project$Lynx$textContent(
5237+ $lynxjs_elm$ui$Lynx$textContent(
52015238 $elm$core$String$fromInt(model.count))
52025239 ])),
52035240 A2($author$project$Main$button, $author$project$Main$Increment, '+')
52045241 ]))
52055242 ]));
52065243};
5207−var $author$project$Main$main = $elm$browser$Browser$sandbox(
5244+var $author$project$Main$main = $lynxjs_elm$browser$Browser$sandbox(
52085245 {init: $author$project$Main$init, update: $author$project$Main$update, view: $author$project$Main$view});
52095246_Platform_export({'Main':{'init':$author$project$Main$main(
5210− $elm$json$Json$Decode$succeed(_Utils_Tuple0))(0)}});}(this));
5247+ $elm$json$Json$Decode$succeed(_Utils_Tuple0))(0)}});}(globalThis));
52115248var app = Elm.Main.init({});
52125249</script>
52135250</body>
examples/counter/src/Main.elm+6−6
@@ -6,7 +6,7 @@ Counter app with increment/decrement via tap events.
66
77import Browser
88import Lynx
9−import Lynx.Attributes as Attr
9+import Lynx.Attributes as Attr exposing (Alignment(..), FlexDirection(..))
1010import Lynx.Events exposing (onTap)
1111import VirtualDom exposing (Node)
1212
@@ -65,14 +65,14 @@ update msg model =
6565view : Model -> Node Msg
6666view model =
6767 Lynx.view
68− [ Attr.flexDirection "column"
69− , Attr.alignItems "center"
70− , Attr.justifyContent "center"
68+ [ Attr.flexDirection Column
69+ , Attr.alignItems Center
70+ , Attr.justifyContent Center
7171 , Attr.flex 1
7272 ]
7373 [ Lynx.view
74− [ Attr.flexDirection "row"
75− , Attr.alignItems "center"
74+ [ Attr.flexDirection Row
75+ , Attr.alignItems Center
7676 ]
7777 [ button Decrement "-"
7878 , Lynx.text
examples/http-example/src/Main.elm+2−2
@@ -3,7 +3,7 @@ module Main exposing (main)
33import Browser
44import Http
55import Lynx exposing (view, text, textContent)
6−import Lynx.Attributes exposing (fontSize, padding, color, flexDirection, alignItems)
6+import Lynx.Attributes exposing (Alignment(..), FlexDirection(..), fontSize, padding, color, flexDirection, alignItems)
77import Lynx.Events exposing (onTap)
88
99
@@ -84,7 +84,7 @@ errorToString err =
8484
8585view_ : Model -> Lynx.Node Msg
8686view_ model =
87− view [ padding 20, flexDirection "column", alignItems "center" ]
87+ view [ padding 20, flexDirection Column, alignItems Center ]
8888 [ text [ fontSize 24, padding 10 ]
8989 [ textContent "HTTP Example" ]
9090 , view [ padding 10 ]
examples/scroll-view/elm.jsnew file+5377
@@ -0,0 +1,5377 @@
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+ return '<internals>';
266+}
267+
268+function _Debug_toString(value)
269+{
270+ return _Debug_toAnsiString(false, value);
271+}
272+
273+function _Debug_toAnsiString(ansi, value)
274+{
275+ if (typeof value === 'function')
276+ {
277+ return _Debug_internalColor(ansi, '<function>');
278+ }
279+
280+ if (typeof value === 'boolean')
281+ {
282+ return _Debug_ctorColor(ansi, value ? 'True' : 'False');
283+ }
284+
285+ if (typeof value === 'number')
286+ {
287+ return _Debug_numberColor(ansi, value + '');
288+ }
289+
290+ if (value instanceof String)
291+ {
292+ return _Debug_charColor(ansi, "'" + _Debug_addSlashes(value, true) + "'");
293+ }
294+
295+ if (typeof value === 'string')
296+ {
297+ return _Debug_stringColor(ansi, '"' + _Debug_addSlashes(value, false) + '"');
298+ }
299+
300+ if (typeof value === 'object' && '$' in value)
301+ {
302+ var tag = value.$;
303+
304+ if (typeof tag === 'number')
305+ {
306+ return _Debug_internalColor(ansi, '<internals>');
307+ }
308+
309+ if (tag[0] === '#')
310+ {
311+ var output = [];
312+ for (var k in value)
313+ {
314+ if (k === '$') continue;
315+ output.push(_Debug_toAnsiString(ansi, value[k]));
316+ }
317+ return '(' + output.join(',') + ')';
318+ }
319+
320+ if (tag === 'Set_elm_builtin')
321+ {
322+ return _Debug_ctorColor(ansi, 'Set')
323+ + _Debug_fadeColor(ansi, '.fromList') + ' '
324+ + _Debug_toAnsiString(ansi, $elm$core$Set$toList(value));
325+ }
326+
327+ if (tag === 'RBNode_elm_builtin' || tag === 'RBEmpty_elm_builtin')
328+ {
329+ return _Debug_ctorColor(ansi, 'Dict')
330+ + _Debug_fadeColor(ansi, '.fromList') + ' '
331+ + _Debug_toAnsiString(ansi, $elm$core$Dict$toList(value));
332+ }
333+
334+ if (tag === 'Array_elm_builtin')
335+ {
336+ return _Debug_ctorColor(ansi, 'Array')
337+ + _Debug_fadeColor(ansi, '.fromList') + ' '
338+ + _Debug_toAnsiString(ansi, $elm$core$Array$toList(value));
339+ }
340+
341+ if (tag === '::' || tag === '[]')
342+ {
343+ var output = '[';
344+
345+ value.b && (output += _Debug_toAnsiString(ansi, value.a), value = value.b)
346+
347+ for (; value.b; value = value.b) // WHILE_CONS
348+ {
349+ output += ',' + _Debug_toAnsiString(ansi, value.a);
350+ }
351+ return output + ']';
352+ }
353+
354+ var output = '';
355+ for (var i in value)
356+ {
357+ if (i === '$') continue;
358+ var str = _Debug_toAnsiString(ansi, value[i]);
359+ var c0 = str[0];
360+ var parenless = c0 === '{' || c0 === '(' || c0 === '[' || c0 === '<' || c0 === '"' || str.indexOf(' ') < 0;
361+ output += ' ' + (parenless ? str : '(' + str + ')');
362+ }
363+ return _Debug_ctorColor(ansi, tag) + output;
364+ }
365+
366+ if (typeof DataView === 'function' && value instanceof DataView)
367+ {
368+ return _Debug_stringColor(ansi, '<' + value.byteLength + ' bytes>');
369+ }
370+
371+ if (typeof File !== 'undefined' && value instanceof File)
372+ {
373+ return _Debug_internalColor(ansi, '<' + value.name + '>');
374+ }
375+
376+ if (typeof value === 'object')
377+ {
378+ var output = [];
379+ for (var key in value)
380+ {
381+ var field = key[0] === '_' ? key.slice(1) : key;
382+ output.push(_Debug_fadeColor(ansi, field) + ' = ' + _Debug_toAnsiString(ansi, value[key]));
383+ }
384+ if (output.length === 0)
385+ {
386+ return '{}';
387+ }
388+ return '{ ' + output.join(', ') + ' }';
389+ }
390+
391+ return _Debug_internalColor(ansi, '<internals>');
392+}
393+
394+function _Debug_addSlashes(str, isChar)
395+{
396+ var s = str
397+ .replace(/\\/g, '\\\\')
398+ .replace(/\n/g, '\\n')
399+ .replace(/\t/g, '\\t')
400+ .replace(/\r/g, '\\r')
401+ .replace(/\v/g, '\\v')
402+ .replace(/\0/g, '\\0');
403+
404+ if (isChar)
405+ {
406+ return s.replace(/\'/g, '\\\'');
407+ }
408+ else
409+ {
410+ return s.replace(/\"/g, '\\"');
411+ }
412+}
413+
414+function _Debug_ctorColor(ansi, string)
415+{
416+ return ansi ? '\x1b[96m' + string + '\x1b[0m' : string;
417+}
418+
419+function _Debug_numberColor(ansi, string)
420+{
421+ return ansi ? '\x1b[95m' + string + '\x1b[0m' : string;
422+}
423+
424+function _Debug_stringColor(ansi, string)
425+{
426+ return ansi ? '\x1b[93m' + string + '\x1b[0m' : string;
427+}
428+
429+function _Debug_charColor(ansi, string)
430+{
431+ return ansi ? '\x1b[92m' + string + '\x1b[0m' : string;
432+}
433+
434+function _Debug_fadeColor(ansi, string)
435+{
436+ return ansi ? '\x1b[37m' + string + '\x1b[0m' : string;
437+}
438+
439+function _Debug_internalColor(ansi, string)
440+{
441+ return ansi ? '\x1b[36m' + string + '\x1b[0m' : string;
442+}
443+
444+function _Debug_toHexDigit(n)
445+{
446+ return String.fromCharCode(n < 10 ? 48 + n : 55 + n);
447+}
448+
449+
450+// CRASH
451+
452+
453+{
454+ throw new Error('https://github.com/elm/core/blob/1.0.0/hints/' + identifier + '.md');
455+}
456+
457+
458+function _Debug_crash(identifier, fact1, fact2, fact3, fact4)
459+{
460+ switch(identifier)
461+ {
462+ case 0:
463+ 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.');
464+
465+ case 1:
466+ 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.');
467+
468+ case 2:
469+ var jsonErrorString = fact1;
470+ throw new Error('Problem with the flags given to your Elm program on initialization.\n\n' + jsonErrorString);
471+
472+ case 3:
473+ var portName = fact1;
474+ throw new Error('There can only be one port named `' + portName + '`, but your program has multiple.');
475+
476+ case 4:
477+ var portName = fact1;
478+ var problem = fact2;
479+ throw new Error('Trying to send an unexpected type of value through port `' + portName + '`:\n' + problem);
480+
481+ case 5:
482+ 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.');
483+
484+ case 6:
485+ var moduleName = fact1;
486+ 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!');
487+
488+ case 8:
489+ var moduleName = fact1;
490+ var region = fact2;
491+ var message = fact3;
492+ throw new Error('TODO in module `' + moduleName + '` ' + _Debug_regionToString(region) + '\n\n' + message);
493+
494+ case 9:
495+ var moduleName = fact1;
496+ var region = fact2;
497+ var value = fact3;
498+ var message = fact4;
499+ throw new Error(
500+ 'TODO in module `' + moduleName + '` from the `case` expression '
501+ + _Debug_regionToString(region) + '\n\nIt received the following value:\n\n '
502+ + _Debug_toString(value).replace('\n', '\n ')
503+ + '\n\nBut the branch that handles it says:\n\n ' + message.replace('\n', '\n ')
504+ );
505+
506+ case 10:
507+ throw new Error('Bug in https://github.com/elm/virtual-dom/issues');
508+
509+ case 11:
510+ throw new Error('Cannot perform mod 0. Division by zero error.');
511+ }
512+}
513+
514+function _Debug_regionToString(region)
515+{
516+ if (region.start.line === region.end.line)
517+ {
518+ return 'on line ' + region.start.line;
519+ }
520+ return 'on lines ' + region.start.line + ' through ' + region.end.line;
521+}
522+
523+
524+
525+// EQUALITY
526+
527+function _Utils_eq(x, y)
528+{
529+ for (
530+ var pair, stack = [], isEqual = _Utils_eqHelp(x, y, 0, stack);
531+ isEqual && (pair = stack.pop());
532+ isEqual = _Utils_eqHelp(pair.a, pair.b, 0, stack)
533+ )
534+ {}
535+
536+ return isEqual;
537+}
538+
539+function _Utils_eqHelp(x, y, depth, stack)
540+{
541+ if (x === y)
542+ {
543+ return true;
544+ }
545+
546+ if (typeof x !== 'object' || x === null || y === null)
547+ {
548+ typeof x === 'function' && _Debug_crash(5);
549+ return false;
550+ }
551+
552+ if (depth > 100)
553+ {
554+ stack.push(_Utils_Tuple2(x,y));
555+ return true;
556+ }
557+
558+ /**/
559+ if (x.$ === 'Set_elm_builtin')
560+ {
561+ x = $elm$core$Set$toList(x);
562+ y = $elm$core$Set$toList(y);
563+ }
564+ if (x.$ === 'RBNode_elm_builtin' || x.$ === 'RBEmpty_elm_builtin')
565+ {
566+ x = $elm$core$Dict$toList(x);
567+ y = $elm$core$Dict$toList(y);
568+ }
569+ //*/
570+
571+ /**_UNUSED/
572+ if (x.$ < 0)
573+ {
574+ x = $elm$core$Dict$toList(x);
575+ y = $elm$core$Dict$toList(y);
576+ }
577+ //*/
578+
579+ for (var key in x)
580+ {
581+ if (!_Utils_eqHelp(x[key], y[key], depth + 1, stack))
582+ {
583+ return false;
584+ }
585+ }
586+ return true;
587+}
588+
589+var _Utils_equal = F2(_Utils_eq);
590+var _Utils_notEqual = F2(function(a, b) { return !_Utils_eq(a,b); });
591+
592+
593+
594+// COMPARISONS
595+
596+// Code in Generate/JavaScript.hs, Basics.js, and List.js depends on
597+// the particular integer values assigned to LT, EQ, and GT.
598+
599+function _Utils_cmp(x, y, ord)
600+{
601+ if (typeof x !== 'object')
602+ {
603+ return x === y ? /*EQ*/ 0 : x < y ? /*LT*/ -1 : /*GT*/ 1;
604+ }
605+
606+ /**/
607+ if (x instanceof String)
608+ {
609+ var a = x.valueOf();
610+ var b = y.valueOf();
611+ return a === b ? 0 : a < b ? -1 : 1;
612+ }
613+ //*/
614+
615+ /**_UNUSED/
616+ if (typeof x.$ === 'undefined')
617+ //*/
618+ /**/
619+ if (x.$[0] === '#')
620+ //*/
621+ {
622+ return (ord = _Utils_cmp(x.a, y.a))
623+ ? ord
624+ : (ord = _Utils_cmp(x.b, y.b))
625+ ? ord
626+ : _Utils_cmp(x.c, y.c);
627+ }
628+
629+ // traverse conses until end of a list or a mismatch
630+ for (; x.b && y.b && !(ord = _Utils_cmp(x.a, y.a)); x = x.b, y = y.b) {} // WHILE_CONSES
631+ return ord || (x.b ? /*GT*/ 1 : y.b ? /*LT*/ -1 : /*EQ*/ 0);
632+}
633+
634+var _Utils_lt = F2(function(a, b) { return _Utils_cmp(a, b) < 0; });
635+var _Utils_le = F2(function(a, b) { return _Utils_cmp(a, b) < 1; });
636+var _Utils_gt = F2(function(a, b) { return _Utils_cmp(a, b) > 0; });
637+var _Utils_ge = F2(function(a, b) { return _Utils_cmp(a, b) >= 0; });
638+
639+var _Utils_compare = F2(function(x, y)
640+{
641+ var n = _Utils_cmp(x, y);
642+ return n < 0 ? $elm$core$Basics$LT : n ? $elm$core$Basics$GT : $elm$core$Basics$EQ;
643+});
644+
645+
646+// COMMON VALUES
647+
648+var _Utils_Tuple0 = { $: '#0' };
649+
650+function _Utils_Tuple2(a, b) { return { $: '#2', a: a, b: b }; }
651+
652+function _Utils_Tuple3(a, b, c) { return { $: '#3', a: a, b: b, c: c }; }
653+
654+function _Utils_chr(c) { return new String(c); }
655+
656+
657+// RECORDS
658+
659+function _Utils_update(oldRecord, updatedFields)
660+{
661+ var newRecord = {};
662+
663+ for (var key in oldRecord)
664+ {
665+ newRecord[key] = oldRecord[key];
666+ }
667+
668+ for (var key in updatedFields)
669+ {
670+ newRecord[key] = updatedFields[key];
671+ }
672+
673+ return newRecord;
674+}
675+
676+
677+// APPEND
678+
679+var _Utils_append = F2(_Utils_ap);
680+
681+function _Utils_ap(xs, ys)
682+{
683+ // append Strings
684+ if (typeof xs === 'string')
685+ {
686+ return xs + ys;
687+ }
688+
689+ // append Lists
690+ if (!xs.b)
691+ {
692+ return ys;
693+ }
694+ var root = _List_Cons(xs.a, ys);
695+ xs = xs.b
696+ for (var curr = root; xs.b; xs = xs.b) // WHILE_CONS
697+ {
698+ curr = curr.b = _List_Cons(xs.a, ys);
699+ }
700+ return root;
701+}
702+
703+
704+
705+var _List_Nil = { $: '[]' };
706+
707+function _List_Cons(hd, tl) { return { $: '::', a: hd, b: tl }; }
708+
709+
710+var _List_cons = F2(_List_Cons);
711+
712+function _List_fromArray(arr)
713+{
714+ var out = _List_Nil;
715+ for (var i = arr.length; i--; )
716+ {
717+ out = _List_Cons(arr[i], out);
718+ }
719+ return out;
720+}
721+
722+function _List_toArray(xs)
723+{
724+ for (var out = []; xs.b; xs = xs.b) // WHILE_CONS
725+ {
726+ out.push(xs.a);
727+ }
728+ return out;
729+}
730+
731+var _List_map2 = F3(function(f, xs, ys)
732+{
733+ for (var arr = []; xs.b && ys.b; xs = xs.b, ys = ys.b) // WHILE_CONSES
734+ {
735+ arr.push(A2(f, xs.a, ys.a));
736+ }
737+ return _List_fromArray(arr);
738+});
739+
740+var _List_map3 = F4(function(f, xs, ys, zs)
741+{
742+ for (var arr = []; xs.b && ys.b && zs.b; xs = xs.b, ys = ys.b, zs = zs.b) // WHILE_CONSES
743+ {
744+ arr.push(A3(f, xs.a, ys.a, zs.a));
745+ }
746+ return _List_fromArray(arr);
747+});
748+
749+var _List_map4 = F5(function(f, ws, xs, ys, zs)
750+{
751+ 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
752+ {
753+ arr.push(A4(f, ws.a, xs.a, ys.a, zs.a));
754+ }
755+ return _List_fromArray(arr);
756+});
757+
758+var _List_map5 = F6(function(f, vs, ws, xs, ys, zs)
759+{
760+ 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
761+ {
762+ arr.push(A5(f, vs.a, ws.a, xs.a, ys.a, zs.a));
763+ }
764+ return _List_fromArray(arr);
765+});
766+
767+var _List_sortBy = F2(function(f, xs)
768+{
769+ return _List_fromArray(_List_toArray(xs).sort(function(a, b) {
770+ return _Utils_cmp(f(a), f(b));
771+ }));
772+});
773+
774+var _List_sortWith = F2(function(f, xs)
775+{
776+ return _List_fromArray(_List_toArray(xs).sort(function(a, b) {
777+ var ord = A2(f, a, b);
778+ return ord === $elm$core$Basics$EQ ? 0 : ord === $elm$core$Basics$LT ? -1 : 1;
779+ }));
780+});
781+
782+
783+
784+// MATH
785+
786+var _Basics_add = F2(function(a, b) { return a + b; });
787+var _Basics_sub = F2(function(a, b) { return a - b; });
788+var _Basics_mul = F2(function(a, b) { return a * b; });
789+var _Basics_fdiv = F2(function(a, b) { return a / b; });
790+var _Basics_idiv = F2(function(a, b) { return (a / b) | 0; });
791+var _Basics_pow = F2(Math.pow);
792+
793+var _Basics_remainderBy = F2(function(b, a) { return a % b; });
794+
795+// https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/divmodnote-letter.pdf
796+var _Basics_modBy = F2(function(modulus, x)
797+{
798+ var answer = x % modulus;
799+ return modulus === 0
800+ ? _Debug_crash(11)
801+ :
802+ ((answer > 0 && modulus < 0) || (answer < 0 && modulus > 0))
803+ ? answer + modulus
804+ : answer;
805+});
806+
807+
808+// TRIGONOMETRY
809+
810+var _Basics_pi = Math.PI;
811+var _Basics_e = Math.E;
812+var _Basics_cos = Math.cos;
813+var _Basics_sin = Math.sin;
814+var _Basics_tan = Math.tan;
815+var _Basics_acos = Math.acos;
816+var _Basics_asin = Math.asin;
817+var _Basics_atan = Math.atan;
818+var _Basics_atan2 = F2(Math.atan2);
819+
820+
821+// MORE MATH
822+
823+function _Basics_toFloat(x) { return x; }
824+function _Basics_truncate(n) { return n | 0; }
825+function _Basics_isInfinite(n) { return n === Infinity || n === -Infinity; }
826+
827+var _Basics_ceiling = Math.ceil;
828+var _Basics_floor = Math.floor;
829+var _Basics_round = Math.round;
830+var _Basics_sqrt = Math.sqrt;
831+var _Basics_log = Math.log;
832+var _Basics_isNaN = isNaN;
833+
834+
835+// BOOLEANS
836+
837+function _Basics_not(bool) { return !bool; }
838+var _Basics_and = F2(function(a, b) { return a && b; });
839+var _Basics_or = F2(function(a, b) { return a || b; });
840+var _Basics_xor = F2(function(a, b) { return a !== b; });
841+
842+
843+
844+var _String_cons = F2(function(chr, str)
845+{
846+ return chr + str;
847+});
848+
849+function _String_uncons(string)
850+{
851+ var word = string.charCodeAt(0);
852+ return !isNaN(word)
853+ ? $elm$core$Maybe$Just(
854+ 0xD800 <= word && word <= 0xDBFF
855+ ? _Utils_Tuple2(_Utils_chr(string[0] + string[1]), string.slice(2))
856+ : _Utils_Tuple2(_Utils_chr(string[0]), string.slice(1))
857+ )
858+ : $elm$core$Maybe$Nothing;
859+}
860+
861+var _String_append = F2(function(a, b)
862+{
863+ return a + b;
864+});
865+
866+function _String_length(str)
867+{
868+ return str.length;
869+}
870+
871+var _String_map = F2(function(func, string)
872+{
873+ var len = string.length;
874+ var array = new Array(len);
875+ var i = 0;
876+ while (i < len)
877+ {
878+ var word = string.charCodeAt(i);
879+ if (0xD800 <= word && word <= 0xDBFF)
880+ {
881+ array[i] = func(_Utils_chr(string[i] + string[i+1]));
882+ i += 2;
883+ continue;
884+ }
885+ array[i] = func(_Utils_chr(string[i]));
886+ i++;
887+ }
888+ return array.join('');
889+});
890+
891+var _String_filter = F2(function(isGood, str)
892+{
893+ var arr = [];
894+ var len = str.length;
895+ var i = 0;
896+ while (i < len)
897+ {
898+ var char = str[i];
899+ var word = str.charCodeAt(i);
900+ i++;
901+ if (0xD800 <= word && word <= 0xDBFF)
902+ {
903+ char += str[i];
904+ i++;
905+ }
906+
907+ if (isGood(_Utils_chr(char)))
908+ {
909+ arr.push(char);
910+ }
911+ }
912+ return arr.join('');
913+});
914+
915+function _String_reverse(str)
916+{
917+ var len = str.length;
918+ var arr = new Array(len);
919+ var i = 0;
920+ while (i < len)
921+ {
922+ var word = str.charCodeAt(i);
923+ if (0xD800 <= word && word <= 0xDBFF)
924+ {
925+ arr[len - i] = str[i + 1];
926+ i++;
927+ arr[len - i] = str[i - 1];
928+ i++;
929+ }
930+ else
931+ {
932+ arr[len - i] = str[i];
933+ i++;
934+ }
935+ }
936+ return arr.join('');
937+}
938+
939+var _String_foldl = F3(function(func, state, string)
940+{
941+ var len = string.length;
942+ var i = 0;
943+ while (i < len)
944+ {
945+ var char = string[i];
946+ var word = string.charCodeAt(i);
947+ i++;
948+ if (0xD800 <= word && word <= 0xDBFF)
949+ {
950+ char += string[i];
951+ i++;
952+ }
953+ state = A2(func, _Utils_chr(char), state);
954+ }
955+ return state;
956+});
957+
958+var _String_foldr = F3(function(func, state, string)
959+{
960+ var i = string.length;
961+ while (i--)
962+ {
963+ var char = string[i];
964+ var word = string.charCodeAt(i);
965+ if (0xDC00 <= word && word <= 0xDFFF)
966+ {
967+ i--;
968+ char = string[i] + char;
969+ }
970+ state = A2(func, _Utils_chr(char), state);
971+ }
972+ return state;
973+});
974+
975+var _String_split = F2(function(sep, str)
976+{
977+ return str.split(sep);
978+});
979+
980+var _String_join = F2(function(sep, strs)
981+{
982+ return strs.join(sep);
983+});
984+
985+var _String_slice = F3(function(start, end, str) {
986+ return str.slice(start, end);
987+});
988+
989+function _String_trim(str)
990+{
991+ return str.trim();
992+}
993+
994+function _String_trimLeft(str)
995+{
996+ return str.replace(/^\s+/, '');
997+}
998+
999+function _String_trimRight(str)
1000+{
1001+ return str.replace(/\s+$/, '');
1002+}
1003+
1004+function _String_words(str)
1005+{
1006+ return _List_fromArray(str.trim().split(/\s+/g));
1007+}
1008+
1009+function _String_lines(str)
1010+{
1011+ return _List_fromArray(str.split(/\r\n|\r|\n/g));
1012+}
1013+
1014+function _String_toUpper(str)
1015+{
1016+ return str.toUpperCase();
1017+}
1018+
1019+function _String_toLower(str)
1020+{
1021+ return str.toLowerCase();
1022+}
1023+
1024+var _String_any = F2(function(isGood, string)
1025+{
1026+ var i = string.length;
1027+ while (i--)
1028+ {
1029+ var char = string[i];
1030+ var word = string.charCodeAt(i);
1031+ if (0xDC00 <= word && word <= 0xDFFF)
1032+ {
1033+ i--;
1034+ char = string[i] + char;
1035+ }
1036+ if (isGood(_Utils_chr(char)))
1037+ {
1038+ return true;
1039+ }
1040+ }
1041+ return false;
1042+});
1043+
1044+var _String_all = F2(function(isGood, string)
1045+{
1046+ var i = string.length;
1047+ while (i--)
1048+ {
1049+ var char = string[i];
1050+ var word = string.charCodeAt(i);
1051+ if (0xDC00 <= word && word <= 0xDFFF)
1052+ {
1053+ i--;
1054+ char = string[i] + char;
1055+ }
1056+ if (!isGood(_Utils_chr(char)))
1057+ {
1058+ return false;
1059+ }
1060+ }
1061+ return true;
1062+});
1063+
1064+var _String_contains = F2(function(sub, str)
1065+{
1066+ return str.indexOf(sub) > -1;
1067+});
1068+
1069+var _String_startsWith = F2(function(sub, str)
1070+{
1071+ return str.indexOf(sub) === 0;
1072+});
1073+
1074+var _String_endsWith = F2(function(sub, str)
1075+{
1076+ return str.length >= sub.length &&
1077+ str.lastIndexOf(sub) === str.length - sub.length;
1078+});
1079+
1080+var _String_indexes = F2(function(sub, str)
1081+{
1082+ var subLen = sub.length;
1083+
1084+ if (subLen < 1)
1085+ {
1086+ return _List_Nil;
1087+ }
1088+
1089+ var i = 0;
1090+ var is = [];
1091+
1092+ while ((i = str.indexOf(sub, i)) > -1)
1093+ {
1094+ is.push(i);
1095+ i = i + subLen;
1096+ }
1097+
1098+ return _List_fromArray(is);
1099+});
1100+
1101+
1102+// TO STRING
1103+
1104+function _String_fromNumber(number)
1105+{
1106+ return number + '';
1107+}
1108+
1109+
1110+// INT CONVERSIONS
1111+
1112+function _String_toInt(str)
1113+{
1114+ var total = 0;
1115+ var code0 = str.charCodeAt(0);
1116+ var start = code0 == 0x2B /* + */ || code0 == 0x2D /* - */ ? 1 : 0;
1117+
1118+ for (var i = start; i < str.length; ++i)
1119+ {
1120+ var code = str.charCodeAt(i);
1121+ if (code < 0x30 || 0x39 < code)
1122+ {
1123+ return $elm$core$Maybe$Nothing;
1124+ }
1125+ total = 10 * total + code - 0x30;
1126+ }
1127+
1128+ return i == start
1129+ ? $elm$core$Maybe$Nothing
1130+ : $elm$core$Maybe$Just(code0 == 0x2D ? -total : total);
1131+}
1132+
1133+
1134+// FLOAT CONVERSIONS
1135+
1136+function _String_toFloat(s)
1137+{
1138+ // check if it is a hex, octal, or binary number
1139+ if (s.length === 0 || /[\sxbo]/.test(s))
1140+ {
1141+ return $elm$core$Maybe$Nothing;
1142+ }
1143+ var n = +s;
1144+ // faster isNaN check
1145+ return n === n ? $elm$core$Maybe$Just(n) : $elm$core$Maybe$Nothing;
1146+}
1147+
1148+function _String_fromList(chars)
1149+{
1150+ return _List_toArray(chars).join('');
1151+}
1152+
1153+
1154+
1155+
1156+function _Char_toCode(char)
1157+{
1158+ var code = char.charCodeAt(0);
1159+ if (0xD800 <= code && code <= 0xDBFF)
1160+ {
1161+ return (code - 0xD800) * 0x400 + char.charCodeAt(1) - 0xDC00 + 0x10000
1162+ }
1163+ return code;
1164+}
1165+
1166+function _Char_fromCode(code)
1167+{
1168+ return _Utils_chr(
1169+ (code < 0 || 0x10FFFF < code)
1170+ ? '\uFFFD'
1171+ :
1172+ (code <= 0xFFFF)
1173+ ? String.fromCharCode(code)
1174+ :
1175+ (code -= 0x10000,
1176+ String.fromCharCode(Math.floor(code / 0x400) + 0xD800, code % 0x400 + 0xDC00)
1177+ )
1178+ );
1179+}
1180+
1181+function _Char_toUpper(char)
1182+{
1183+ return _Utils_chr(char.toUpperCase());
1184+}
1185+
1186+function _Char_toLower(char)
1187+{
1188+ return _Utils_chr(char.toLowerCase());
1189+}
1190+
1191+function _Char_toLocaleUpper(char)
1192+{
1193+ return _Utils_chr(char.toLocaleUpperCase());
1194+}
1195+
1196+function _Char_toLocaleLower(char)
1197+{
1198+ return _Utils_chr(char.toLocaleLowerCase());
1199+}
1200+
1201+
1202+
1203+/**/
1204+function _Json_errorToString(error)
1205+{
1206+ return $elm$json$Json$Decode$errorToString(error);
1207+}
1208+//*/
1209+
1210+
1211+// CORE DECODERS
1212+
1213+function _Json_succeed(msg)
1214+{
1215+ return {
1216+ $: 0,
1217+ a: msg
1218+ };
1219+}
1220+
1221+function _Json_fail(msg)
1222+{
1223+ return {
1224+ $: 1,
1225+ a: msg
1226+ };
1227+}
1228+
1229+function _Json_decodePrim(decoder)
1230+{
1231+ return { $: 2, b: decoder };
1232+}
1233+
1234+var _Json_decodeInt = _Json_decodePrim(function(value) {
1235+ return (typeof value !== 'number')
1236+ ? _Json_expecting('an INT', value)
1237+ :
1238+ (-2147483647 < value && value < 2147483647 && (value | 0) === value)
1239+ ? $elm$core$Result$Ok(value)
1240+ :
1241+ (isFinite(value) && !(value % 1))
1242+ ? $elm$core$Result$Ok(value)
1243+ : _Json_expecting('an INT', value);
1244+});
1245+
1246+var _Json_decodeBool = _Json_decodePrim(function(value) {
1247+ return (typeof value === 'boolean')
1248+ ? $elm$core$Result$Ok(value)
1249+ : _Json_expecting('a BOOL', value);
1250+});
1251+
1252+var _Json_decodeFloat = _Json_decodePrim(function(value) {
1253+ return (typeof value === 'number')
1254+ ? $elm$core$Result$Ok(value)
1255+ : _Json_expecting('a FLOAT', value);
1256+});
1257+
1258+var _Json_decodeValue = _Json_decodePrim(function(value) {
1259+ return $elm$core$Result$Ok(_Json_wrap(value));
1260+});
1261+
1262+var _Json_decodeString = _Json_decodePrim(function(value) {
1263+ return (typeof value === 'string')
1264+ ? $elm$core$Result$Ok(value)
1265+ : (value instanceof String)
1266+ ? $elm$core$Result$Ok(value + '')
1267+ : _Json_expecting('a STRING', value);
1268+});
1269+
1270+function _Json_decodeList(decoder) { return { $: 3, b: decoder }; }
1271+function _Json_decodeArray(decoder) { return { $: 4, b: decoder }; }
1272+
1273+function _Json_decodeNull(value) { return { $: 5, c: value }; }
1274+
1275+var _Json_decodeField = F2(function(field, decoder)
1276+{
1277+ return {
1278+ $: 6,
1279+ d: field,
1280+ b: decoder
1281+ };
1282+});
1283+
1284+var _Json_decodeIndex = F2(function(index, decoder)
1285+{
1286+ return {
1287+ $: 7,
1288+ e: index,
1289+ b: decoder
1290+ };
1291+});
1292+
1293+function _Json_decodeKeyValuePairs(decoder)
1294+{
1295+ return {
1296+ $: 8,
1297+ b: decoder
1298+ };
1299+}
1300+
1301+function _Json_mapMany(f, decoders)
1302+{
1303+ return {
1304+ $: 9,
1305+ f: f,
1306+ g: decoders
1307+ };
1308+}
1309+
1310+var _Json_andThen = F2(function(callback, decoder)
1311+{
1312+ return {
1313+ $: 10,
1314+ b: decoder,
1315+ h: callback
1316+ };
1317+});
1318+
1319+function _Json_oneOf(decoders)
1320+{
1321+ return {
1322+ $: 11,
1323+ g: decoders
1324+ };
1325+}
1326+
1327+
1328+// DECODING OBJECTS
1329+
1330+var _Json_map1 = F2(function(f, d1)
1331+{
1332+ return _Json_mapMany(f, [d1]);
1333+});
1334+
1335+var _Json_map2 = F3(function(f, d1, d2)
1336+{
1337+ return _Json_mapMany(f, [d1, d2]);
1338+});
1339+
1340+var _Json_map3 = F4(function(f, d1, d2, d3)
1341+{
1342+ return _Json_mapMany(f, [d1, d2, d3]);
1343+});
1344+
1345+var _Json_map4 = F5(function(f, d1, d2, d3, d4)
1346+{
1347+ return _Json_mapMany(f, [d1, d2, d3, d4]);
1348+});
1349+
1350+var _Json_map5 = F6(function(f, d1, d2, d3, d4, d5)
1351+{
1352+ return _Json_mapMany(f, [d1, d2, d3, d4, d5]);
1353+});
1354+
1355+var _Json_map6 = F7(function(f, d1, d2, d3, d4, d5, d6)
1356+{
1357+ return _Json_mapMany(f, [d1, d2, d3, d4, d5, d6]);
1358+});
1359+
1360+var _Json_map7 = F8(function(f, d1, d2, d3, d4, d5, d6, d7)
1361+{
1362+ return _Json_mapMany(f, [d1, d2, d3, d4, d5, d6, d7]);
1363+});
1364+
1365+var _Json_map8 = F9(function(f, d1, d2, d3, d4, d5, d6, d7, d8)
1366+{
1367+ return _Json_mapMany(f, [d1, d2, d3, d4, d5, d6, d7, d8]);
1368+});
1369+
1370+
1371+// DECODE
1372+
1373+var _Json_runOnString = F2(function(decoder, string)
1374+{
1375+ try
1376+ {
1377+ var value = JSON.parse(string);
1378+ return _Json_runHelp(decoder, value);
1379+ }
1380+ catch (e)
1381+ {
1382+ return $elm$core$Result$Err(A2($elm$json$Json$Decode$Failure, 'This is not valid JSON! ' + e.message, _Json_wrap(string)));
1383+ }
1384+});
1385+
1386+var _Json_run = F2(function(decoder, value)
1387+{
1388+ return _Json_runHelp(decoder, _Json_unwrap(value));
1389+});
1390+
1391+function _Json_runHelp(decoder, value)
1392+{
1393+ switch (decoder.$)
1394+ {
1395+ case 2:
1396+ return decoder.b(value);
1397+
1398+ case 5:
1399+ return (value === null)
1400+ ? $elm$core$Result$Ok(decoder.c)
1401+ : _Json_expecting('null', value);
1402+
1403+ case 3:
1404+ if (!_Json_isArray(value))
1405+ {
1406+ return _Json_expecting('a LIST', value);
1407+ }
1408+ return _Json_runArrayDecoder(decoder.b, value, _List_fromArray);
1409+
1410+ case 4:
1411+ if (!_Json_isArray(value))
1412+ {
1413+ return _Json_expecting('an ARRAY', value);
1414+ }
1415+ return _Json_runArrayDecoder(decoder.b, value, _Json_toElmArray);
1416+
1417+ case 6:
1418+ var field = decoder.d;
1419+ if (typeof value !== 'object' || value === null || !(field in value))
1420+ {
1421+ return _Json_expecting('an OBJECT with a field named `' + field + '`', value);
1422+ }
1423+ var result = _Json_runHelp(decoder.b, value[field]);
1424+ return ($elm$core$Result$isOk(result)) ? result : $elm$core$Result$Err(A2($elm$json$Json$Decode$Field, field, result.a));
1425+
1426+ case 7:
1427+ var index = decoder.e;
1428+ if (!_Json_isArray(value))
1429+ {
1430+ return _Json_expecting('an ARRAY', value);
1431+ }
1432+ if (index >= value.length)
1433+ {
1434+ return _Json_expecting('a LONGER array. Need index ' + index + ' but only see ' + value.length + ' entries', value);
1435+ }
1436+ var result = _Json_runHelp(decoder.b, value[index]);
1437+ return ($elm$core$Result$isOk(result)) ? result : $elm$core$Result$Err(A2($elm$json$Json$Decode$Index, index, result.a));
1438+
1439+ case 8:
1440+ if (typeof value !== 'object' || value === null || _Json_isArray(value))
1441+ {
1442+ return _Json_expecting('an OBJECT', value);
1443+ }
1444+
1445+ var keyValuePairs = _List_Nil;
1446+ // TODO test perf of Object.keys and switch when support is good enough
1447+ for (var key in value)
1448+ {
1449+ if (value.hasOwnProperty(key))
1450+ {
1451+ var result = _Json_runHelp(decoder.b, value[key]);
1452+ if (!$elm$core$Result$isOk(result))
1453+ {
1454+ return $elm$core$Result$Err(A2($elm$json$Json$Decode$Field, key, result.a));
1455+ }
1456+ keyValuePairs = _List_Cons(_Utils_Tuple2(key, result.a), keyValuePairs);
1457+ }
1458+ }
1459+ return $elm$core$Result$Ok($elm$core$List$reverse(keyValuePairs));
1460+
1461+ case 9:
1462+ var answer = decoder.f;
1463+ var decoders = decoder.g;
1464+ for (var i = 0; i < decoders.length; i++)
1465+ {
1466+ var result = _Json_runHelp(decoders[i], value);
1467+ if (!$elm$core$Result$isOk(result))
1468+ {
1469+ return result;
1470+ }
1471+ answer = answer(result.a);
1472+ }
1473+ return $elm$core$Result$Ok(answer);
1474+
1475+ case 10:
1476+ var result = _Json_runHelp(decoder.b, value);
1477+ return (!$elm$core$Result$isOk(result))
1478+ ? result
1479+ : _Json_runHelp(decoder.h(result.a), value);
1480+
1481+ case 11:
1482+ var errors = _List_Nil;
1483+ for (var temp = decoder.g; temp.b; temp = temp.b) // WHILE_CONS
1484+ {
1485+ var result = _Json_runHelp(temp.a, value);
1486+ if ($elm$core$Result$isOk(result))
1487+ {
1488+ return result;
1489+ }
1490+ errors = _List_Cons(result.a, errors);
1491+ }
1492+ return $elm$core$Result$Err($elm$json$Json$Decode$OneOf($elm$core$List$reverse(errors)));
1493+
1494+ case 1:
1495+ return $elm$core$Result$Err(A2($elm$json$Json$Decode$Failure, decoder.a, _Json_wrap(value)));
1496+
1497+ case 0:
1498+ return $elm$core$Result$Ok(decoder.a);
1499+ }
1500+}
1501+
1502+function _Json_runArrayDecoder(decoder, value, toElmValue)
1503+{
1504+ var len = value.length;
1505+ var array = new Array(len);
1506+ for (var i = 0; i < len; i++)
1507+ {
1508+ var result = _Json_runHelp(decoder, value[i]);
1509+ if (!$elm$core$Result$isOk(result))
1510+ {
1511+ return $elm$core$Result$Err(A2($elm$json$Json$Decode$Index, i, result.a));
1512+ }
1513+ array[i] = result.a;
1514+ }
1515+ return $elm$core$Result$Ok(toElmValue(array));
1516+}
1517+
1518+function _Json_isArray(value)
1519+{
1520+ return Array.isArray(value) || (typeof FileList !== 'undefined' && value instanceof FileList);
1521+}
1522+
1523+function _Json_toElmArray(array)
1524+{
1525+ return A2($elm$core$Array$initialize, array.length, function(i) { return array[i]; });
1526+}
1527+
1528+function _Json_expecting(type, value)
1529+{
1530+ return $elm$core$Result$Err(A2($elm$json$Json$Decode$Failure, 'Expecting ' + type, _Json_wrap(value)));
1531+}
1532+
1533+
1534+// EQUALITY
1535+
1536+function _Json_equality(x, y)
1537+{
1538+ if (x === y)
1539+ {
1540+ return true;
1541+ }
1542+
1543+ if (x.$ !== y.$)
1544+ {
1545+ return false;
1546+ }
1547+
1548+ switch (x.$)
1549+ {
1550+ case 0:
1551+ case 1:
1552+ return x.a === y.a;
1553+
1554+ case 2:
1555+ return x.b === y.b;
1556+
1557+ case 5:
1558+ return x.c === y.c;
1559+
1560+ case 3:
1561+ case 4:
1562+ case 8:
1563+ return _Json_equality(x.b, y.b);
1564+
1565+ case 6:
1566+ return x.d === y.d && _Json_equality(x.b, y.b);
1567+
1568+ case 7:
1569+ return x.e === y.e && _Json_equality(x.b, y.b);
1570+
1571+ case 9:
1572+ return x.f === y.f && _Json_listEquality(x.g, y.g);
1573+
1574+ case 10:
1575+ return x.h === y.h && _Json_equality(x.b, y.b);
1576+
1577+ case 11:
1578+ return _Json_listEquality(x.g, y.g);
1579+ }
1580+}
1581+
1582+function _Json_listEquality(aDecoders, bDecoders)
1583+{
1584+ var len = aDecoders.length;
1585+ if (len !== bDecoders.length)
1586+ {
1587+ return false;
1588+ }
1589+ for (var i = 0; i < len; i++)
1590+ {
1591+ if (!_Json_equality(aDecoders[i], bDecoders[i]))
1592+ {
1593+ return false;
1594+ }
1595+ }
1596+ return true;
1597+}
1598+
1599+
1600+// ENCODE
1601+
1602+var _Json_encode = F2(function(indentLevel, value)
1603+{
1604+ return JSON.stringify(_Json_unwrap(value), null, indentLevel) + '';
1605+});
1606+
1607+function _Json_wrap(value) { return { $: 0, a: value }; }
1608+function _Json_unwrap(value) { return value.a; }
1609+
1610+
1611+function _Json_emptyArray() { return []; }
1612+function _Json_emptyObject() { return {}; }
1613+
1614+var _Json_addField = F3(function(key, value, object)
1615+{
1616+ object[key] = _Json_unwrap(value);
1617+ return object;
1618+});
1619+
1620+function _Json_addEntry(func)
1621+{
1622+ return F2(function(entry, array)
1623+ {
1624+ array.push(_Json_unwrap(func(entry)));
1625+ return array;
1626+ });
1627+}
1628+
1629+var _Json_encodeNull = _Json_wrap(null);
1630+
1631+
1632+
1633+// TASKS
1634+
1635+function _Scheduler_succeed(value)
1636+{
1637+ return {
1638+ $: 0,
1639+ a: value
1640+ };
1641+}
1642+
1643+function _Scheduler_fail(error)
1644+{
1645+ return {
1646+ $: 1,
1647+ a: error
1648+ };
1649+}
1650+
1651+function _Scheduler_binding(callback)
1652+{
1653+ return {
1654+ $: 2,
1655+ b: callback,
1656+ c: null
1657+ };
1658+}
1659+
1660+var _Scheduler_andThen = F2(function(callback, task)
1661+{
1662+ return {
1663+ $: 3,
1664+ b: callback,
1665+ d: task
1666+ };
1667+});
1668+
1669+var _Scheduler_onError = F2(function(callback, task)
1670+{
1671+ return {
1672+ $: 4,
1673+ b: callback,
1674+ d: task
1675+ };
1676+});
1677+
1678+function _Scheduler_receive(callback)
1679+{
1680+ return {
1681+ $: 5,
1682+ b: callback
1683+ };
1684+}
1685+
1686+
1687+// PROCESSES
1688+
1689+var _Scheduler_guid = 0;
1690+
1691+function _Scheduler_rawSpawn(task)
1692+{
1693+ var proc = {
1694+ $: 0,
1695+ e: _Scheduler_guid++,
1696+ f: task,
1697+ g: null,
1698+ h: []
1699+ };
1700+
1701+ _Scheduler_enqueue(proc);
1702+
1703+ return proc;
1704+}
1705+
1706+function _Scheduler_spawn(task)
1707+{
1708+ return _Scheduler_binding(function(callback) {
1709+ callback(_Scheduler_succeed(_Scheduler_rawSpawn(task)));
1710+ });
1711+}
1712+
1713+function _Scheduler_rawSend(proc, msg)
1714+{
1715+ proc.h.push(msg);
1716+ _Scheduler_enqueue(proc);
1717+}
1718+
1719+var _Scheduler_send = F2(function(proc, msg)
1720+{
1721+ return _Scheduler_binding(function(callback) {
1722+ _Scheduler_rawSend(proc, msg);
1723+ callback(_Scheduler_succeed(_Utils_Tuple0));
1724+ });
1725+});
1726+
1727+function _Scheduler_kill(proc)
1728+{
1729+ return _Scheduler_binding(function(callback) {
1730+ var task = proc.f;
1731+ if (task.$ === 2 && task.c)
1732+ {
1733+ task.c();
1734+ }
1735+
1736+ proc.f = null;
1737+
1738+ callback(_Scheduler_succeed(_Utils_Tuple0));
1739+ });
1740+}
1741+
1742+
1743+/* STEP PROCESSES
1744+
1745+type alias Process =
1746+ { $ : tag
1747+ , id : unique_id
1748+ , root : Task
1749+ , stack : null | { $: SUCCEED | FAIL, a: callback, b: stack }
1750+ , mailbox : [msg]
1751+ }
1752+
1753+*/
1754+
1755+
1756+var _Scheduler_working = false;
1757+var _Scheduler_queue = [];
1758+
1759+
1760+function _Scheduler_enqueue(proc)
1761+{
1762+ _Scheduler_queue.push(proc);
1763+ if (_Scheduler_working)
1764+ {
1765+ return;
1766+ }
1767+ _Scheduler_working = true;
1768+ while (proc = _Scheduler_queue.shift())
1769+ {
1770+ _Scheduler_step(proc);
1771+ }
1772+ _Scheduler_working = false;
1773+}
1774+
1775+
1776+function _Scheduler_step(proc)
1777+{
1778+ while (proc.f)
1779+ {
1780+ var rootTag = proc.f.$;
1781+ if (rootTag === 0 || rootTag === 1)
1782+ {
1783+ while (proc.g && proc.g.$ !== rootTag)
1784+ {
1785+ proc.g = proc.g.i;
1786+ }
1787+ if (!proc.g)
1788+ {
1789+ return;
1790+ }
1791+ proc.f = proc.g.b(proc.f.a);
1792+ proc.g = proc.g.i;
1793+ }
1794+ else if (rootTag === 2)
1795+ {
1796+ proc.f.c = proc.f.b(function(newRoot) {
1797+ proc.f = newRoot;
1798+ _Scheduler_enqueue(proc);
1799+ });
1800+ return;
1801+ }
1802+ else if (rootTag === 5)
1803+ {
1804+ if (proc.h.length === 0)
1805+ {
1806+ return;
1807+ }
1808+ proc.f = proc.f.b(proc.h.shift());
1809+ }
1810+ else // if (rootTag === 3 || rootTag === 4)
1811+ {
1812+ proc.g = {
1813+ $: rootTag === 3 ? 0 : 1,
1814+ b: proc.f.b,
1815+ i: proc.g
1816+ };
1817+ proc.f = proc.f.d;
1818+ }
1819+ }
1820+}
1821+
1822+
1823+
1824+function _Process_sleep(time)
1825+{
1826+ return _Scheduler_binding(function(callback) {
1827+ var id = setTimeout(function() {
1828+ callback(_Scheduler_succeed(_Utils_Tuple0));
1829+ }, time);
1830+
1831+ return function() { clearTimeout(id); };
1832+ });
1833+}
1834+
1835+
1836+
1837+
1838+// PROGRAMS
1839+
1840+
1841+var _Platform_worker = F4(function(impl, flagDecoder, debugMetadata, args)
1842+{
1843+ return _Platform_initialize(
1844+ flagDecoder,
1845+ args,
1846+ impl.init,
1847+ impl.update,
1848+ impl.subscriptions,
1849+ function() { return function() {} }
1850+ );
1851+});
1852+
1853+
1854+
1855+// INITIALIZE A PROGRAM
1856+
1857+
1858+function _Platform_initialize(flagDecoder, args, init, update, subscriptions, stepperBuilder)
1859+{
1860+ var result = A2(_Json_run, flagDecoder, _Json_wrap(args ? args['flags'] : undefined));
1861+ $elm$core$Result$isOk(result) || _Debug_crash(2 /**/, _Json_errorToString(result.a) /**/);
1862+ var managers = {};
1863+ var initPair = init(result.a);
1864+ var model = initPair.a;
1865+ var stepper = stepperBuilder(sendToApp, model);
1866+ var ports = _Platform_setupEffects(managers, sendToApp);
1867+
1868+ function sendToApp(msg, viewMetadata)
1869+ {
1870+ var pair = A2(update, msg, model);
1871+ stepper(model = pair.a, viewMetadata);
1872+ _Platform_enqueueEffects(managers, pair.b, subscriptions(model));
1873+ }
1874+
1875+ _Platform_enqueueEffects(managers, initPair.b, subscriptions(model));
1876+
1877+ return ports ? { ports: ports } : {};
1878+}
1879+
1880+
1881+
1882+// TRACK PRELOADS
1883+//
1884+// This is used by code in elm/browser and elm/http
1885+// to register any HTTP requests that are triggered by init.
1886+//
1887+
1888+
1889+var _Platform_preload;
1890+
1891+
1892+function _Platform_registerPreload(url)
1893+{
1894+ _Platform_preload.add(url);
1895+}
1896+
1897+
1898+
1899+// EFFECT MANAGERS
1900+
1901+
1902+var _Platform_effectManagers = {};
1903+
1904+
1905+function _Platform_setupEffects(managers, sendToApp)
1906+{
1907+ var ports;
1908+
1909+ // setup all necessary effect managers
1910+ for (var key in _Platform_effectManagers)
1911+ {
1912+ var manager = _Platform_effectManagers[key];
1913+
1914+ if (manager.a)
1915+ {
1916+ ports = ports || {};
1917+ ports[key] = manager.a(key, sendToApp);
1918+ }
1919+
1920+ managers[key] = _Platform_instantiateManager(manager, sendToApp);
1921+ }
1922+
1923+ return ports;
1924+}
1925+
1926+
1927+function _Platform_createManager(init, onEffects, onSelfMsg, cmdMap, subMap)
1928+{
1929+ return {
1930+ b: init,
1931+ c: onEffects,
1932+ d: onSelfMsg,
1933+ e: cmdMap,
1934+ f: subMap
1935+ };
1936+}
1937+
1938+
1939+function _Platform_instantiateManager(info, sendToApp)
1940+{
1941+ var router = {
1942+ g: sendToApp,
1943+ h: undefined
1944+ };
1945+
1946+ var onEffects = info.c;
1947+ var onSelfMsg = info.d;
1948+ var cmdMap = info.e;
1949+ var subMap = info.f;
1950+
1951+ function loop(state)
1952+ {
1953+ return A2(_Scheduler_andThen, loop, _Scheduler_receive(function(msg)
1954+ {
1955+ var value = msg.a;
1956+
1957+ if (msg.$ === 0)
1958+ {
1959+ return A3(onSelfMsg, router, value, state);
1960+ }
1961+
1962+ return cmdMap && subMap
1963+ ? A4(onEffects, router, value.i, value.j, state)
1964+ : A3(onEffects, router, cmdMap ? value.i : value.j, state);
1965+ }));
1966+ }
1967+
1968+ return router.h = _Scheduler_rawSpawn(A2(_Scheduler_andThen, loop, info.b));
1969+}
1970+
1971+
1972+
1973+// ROUTING
1974+
1975+
1976+var _Platform_sendToApp = F2(function(router, msg)
1977+{
1978+ return _Scheduler_binding(function(callback)
1979+ {
1980+ router.g(msg);
1981+ callback(_Scheduler_succeed(_Utils_Tuple0));
1982+ });
1983+});
1984+
1985+
1986+var _Platform_sendToSelf = F2(function(router, msg)
1987+{
1988+ return A2(_Scheduler_send, router.h, {
1989+ $: 0,
1990+ a: msg
1991+ });
1992+});
1993+
1994+
1995+
1996+// BAGS
1997+
1998+
1999+function _Platform_leaf(home)
2000+{
2001+ return function(value)
2002+ {
2003+ return {
2004+ $: 1,
2005+ k: home,
2006+ l: value
2007+ };
2008+ };
2009+}
2010+
2011+
2012+function _Platform_batch(list)
2013+{
2014+ return {
2015+ $: 2,
2016+ m: list
2017+ };
2018+}
2019+
2020+
2021+var _Platform_map = F2(function(tagger, bag)
2022+{
2023+ return {
2024+ $: 3,
2025+ n: tagger,
2026+ o: bag
2027+ }
2028+});
2029+
2030+
2031+
2032+// PIPE BAGS INTO EFFECT MANAGERS
2033+//
2034+// Effects must be queued!
2035+//
2036+// Say your init contains a synchronous command, like Time.now or Time.here
2037+//
2038+// - This will produce a batch of effects (FX_1)
2039+// - The synchronous task triggers the subsequent `update` call
2040+// - This will produce a batch of effects (FX_2)
2041+//
2042+// If we just start dispatching FX_2, subscriptions from FX_2 can be processed
2043+// before subscriptions from FX_1. No good! Earlier versions of this code had
2044+// this problem, leading to these reports:
2045+//
2046+// https://github.com/elm/core/issues/980
2047+// https://github.com/elm/core/pull/981
2048+// https://github.com/elm/compiler/issues/1776
2049+//
2050+// The queue is necessary to avoid ordering issues for synchronous commands.
2051+
2052+
2053+// Why use true/false here? Why not just check the length of the queue?
2054+// The goal is to detect "are we currently dispatching effects?" If we
2055+// are, we need to bail and let the ongoing while loop handle things.
2056+//
2057+// Now say the queue has 1 element. When we dequeue the final element,
2058+// the queue will be empty, but we are still actively dispatching effects.
2059+// So you could get queue jumping in a really tricky category of cases.
2060+//
2061+var _Platform_effectsQueue = [];
2062+var _Platform_effectsActive = false;
2063+
2064+
2065+function _Platform_enqueueEffects(managers, cmdBag, subBag)
2066+{
2067+ _Platform_effectsQueue.push({ p: managers, q: cmdBag, r: subBag });
2068+
2069+ if (_Platform_effectsActive) return;
2070+
2071+ _Platform_effectsActive = true;
2072+ for (var fx; fx = _Platform_effectsQueue.shift(); )
2073+ {
2074+ _Platform_dispatchEffects(fx.p, fx.q, fx.r);
2075+ }
2076+ _Platform_effectsActive = false;
2077+}
2078+
2079+
2080+function _Platform_dispatchEffects(managers, cmdBag, subBag)
2081+{
2082+ var effectsDict = {};
2083+ _Platform_gatherEffects(true, cmdBag, effectsDict, null);
2084+ _Platform_gatherEffects(false, subBag, effectsDict, null);
2085+
2086+ for (var home in managers)
2087+ {
2088+ _Scheduler_rawSend(managers[home], {
2089+ $: 'fx',
2090+ a: effectsDict[home] || { i: _List_Nil, j: _List_Nil }
2091+ });
2092+ }
2093+}
2094+
2095+
2096+function _Platform_gatherEffects(isCmd, bag, effectsDict, taggers)
2097+{
2098+ switch (bag.$)
2099+ {
2100+ case 1:
2101+ var home = bag.k;
2102+ var effect = _Platform_toEffect(isCmd, home, taggers, bag.l);
2103+ effectsDict[home] = _Platform_insert(isCmd, effect, effectsDict[home]);
2104+ return;
2105+
2106+ case 2:
2107+ for (var list = bag.m; list.b; list = list.b) // WHILE_CONS
2108+ {
2109+ _Platform_gatherEffects(isCmd, list.a, effectsDict, taggers);
2110+ }
2111+ return;
2112+
2113+ case 3:
2114+ _Platform_gatherEffects(isCmd, bag.o, effectsDict, {
2115+ s: bag.n,
2116+ t: taggers
2117+ });
2118+ return;
2119+ }
2120+}
2121+
2122+
2123+function _Platform_toEffect(isCmd, home, taggers, value)
2124+{
2125+ function applyTaggers(x)
2126+ {
2127+ for (var temp = taggers; temp; temp = temp.t)
2128+ {
2129+ x = temp.s(x);
2130+ }
2131+ return x;
2132+ }
2133+
2134+ var map = isCmd
2135+ ? _Platform_effectManagers[home].e
2136+ : _Platform_effectManagers[home].f;
2137+
2138+ return A2(map, applyTaggers, value)
2139+}
2140+
2141+
2142+function _Platform_insert(isCmd, newEffect, effects)
2143+{
2144+ effects = effects || { i: _List_Nil, j: _List_Nil };
2145+
2146+ isCmd
2147+ ? (effects.i = _List_Cons(newEffect, effects.i))
2148+ : (effects.j = _List_Cons(newEffect, effects.j));
2149+
2150+ return effects;
2151+}
2152+
2153+
2154+
2155+// PORTS
2156+
2157+
2158+function _Platform_checkPortName(name)
2159+{
2160+ if (_Platform_effectManagers[name])
2161+ {
2162+ _Debug_crash(3, name)
2163+ }
2164+}
2165+
2166+
2167+
2168+// OUTGOING PORTS
2169+
2170+
2171+function _Platform_outgoingPort(name, converter)
2172+{
2173+ _Platform_checkPortName(name);
2174+ _Platform_effectManagers[name] = {
2175+ e: _Platform_outgoingPortMap,
2176+ u: converter,
2177+ a: _Platform_setupOutgoingPort
2178+ };
2179+ return _Platform_leaf(name);
2180+}
2181+
2182+
2183+var _Platform_outgoingPortMap = F2(function(tagger, value) { return value; });
2184+
2185+
2186+function _Platform_setupOutgoingPort(name)
2187+{
2188+ var subs = [];
2189+ var converter = _Platform_effectManagers[name].u;
2190+
2191+ // CREATE MANAGER
2192+
2193+ var init = _Process_sleep(0);
2194+
2195+ _Platform_effectManagers[name].b = init;
2196+ _Platform_effectManagers[name].c = F3(function(router, cmdList, state)
2197+ {
2198+ for ( ; cmdList.b; cmdList = cmdList.b) // WHILE_CONS
2199+ {
2200+ // grab a separate reference to subs in case unsubscribe is called
2201+ var currentSubs = subs;
2202+ var value = _Json_unwrap(converter(cmdList.a));
2203+ for (var i = 0; i < currentSubs.length; i++)
2204+ {
2205+ currentSubs[i](value);
2206+ }
2207+ }
2208+ return init;
2209+ });
2210+
2211+ // PUBLIC API
2212+
2213+ function subscribe(callback)
2214+ {
2215+ subs.push(callback);
2216+ }
2217+
2218+ function unsubscribe(callback)
2219+ {
2220+ // copy subs into a new array in case unsubscribe is called within a
2221+ // subscribed callback
2222+ subs = subs.slice();
2223+ var index = subs.indexOf(callback);
2224+ if (index >= 0)
2225+ {
2226+ subs.splice(index, 1);
2227+ }
2228+ }
2229+
2230+ return {
2231+ subscribe: subscribe,
2232+ unsubscribe: unsubscribe
2233+ };
2234+}
2235+
2236+
2237+
2238+// INCOMING PORTS
2239+
2240+
2241+function _Platform_incomingPort(name, converter)
2242+{
2243+ _Platform_checkPortName(name);
2244+ _Platform_effectManagers[name] = {
2245+ f: _Platform_incomingPortMap,
2246+ u: converter,
2247+ a: _Platform_setupIncomingPort
2248+ };
2249+ return _Platform_leaf(name);
2250+}
2251+
2252+
2253+var _Platform_incomingPortMap = F2(function(tagger, finalTagger)
2254+{
2255+ return function(value)
2256+ {
2257+ return tagger(finalTagger(value));
2258+ };
2259+});
2260+
2261+
2262+function _Platform_setupIncomingPort(name, sendToApp)
2263+{
2264+ var subs = _List_Nil;
2265+ var converter = _Platform_effectManagers[name].u;
2266+
2267+ // CREATE MANAGER
2268+
2269+ var init = _Scheduler_succeed(null);
2270+
2271+ _Platform_effectManagers[name].b = init;
2272+ _Platform_effectManagers[name].c = F3(function(router, subList, state)
2273+ {
2274+ subs = subList;
2275+ return init;
2276+ });
2277+
2278+ // PUBLIC API
2279+
2280+ function send(incomingValue)
2281+ {
2282+ var result = A2(_Json_run, converter, _Json_wrap(incomingValue));
2283+
2284+ $elm$core$Result$isOk(result) || _Debug_crash(4, name, result.a);
2285+
2286+ var value = result.a;
2287+ for (var temp = subs; temp.b; temp = temp.b) // WHILE_CONS
2288+ {
2289+ sendToApp(temp.a(value));
2290+ }
2291+ }
2292+
2293+ return { send: send };
2294+}
2295+
2296+
2297+
2298+// EXPORT ELM MODULES
2299+//
2300+// Have DEBUG and PROD versions so that we can (1) give nicer errors in
2301+// debug mode and (2) not pay for the bits needed for that in prod mode.
2302+//
2303+
2304+
2305+{
2306+ scope['Elm']
2307+ ? _Platform_mergeExportsProd(scope['Elm'], exports)
2308+ : scope['Elm'] = exports;
2309+}
2310+
2311+
2312+function _Platform_mergeExportsProd(obj, exports)
2313+{
2314+ for (var name in exports)
2315+ {
2316+ (name in obj)
2317+ ? (name == 'init')
2318+ ? _Debug_crash(6)
2319+ : _Platform_mergeExportsProd(obj[name], exports[name])
2320+ : (obj[name] = exports[name]);
2321+ }
2322+}
2323+
2324+
2325+function _Platform_export(exports)
2326+{
2327+ scope['Elm']
2328+ ? _Platform_mergeExportsDebug('Elm', scope['Elm'], exports)
2329+ : scope['Elm'] = exports;
2330+}
2331+
2332+
2333+function _Platform_mergeExportsDebug(moduleName, obj, exports)
2334+{
2335+ for (var name in exports)
2336+ {
2337+ (name in obj)
2338+ ? (name == 'init')
2339+ ? _Debug_crash(6, moduleName)
2340+ : _Platform_mergeExportsDebug(moduleName + '.' + name, obj[name], exports[name])
2341+ : (obj[name] = exports[name]);
2342+ }
2343+}
2344+
2345+
2346+
2347+var _Lynx_g = (typeof globalThis !== 'undefined' ? globalThis : scope);
2348+function _Lynx_papi(name) { return _Lynx_g['_' + '_' + name] || function() {}; }
2349+var _Lynx_createViewFn = _Lynx_papi('CreateView');
2350+var _Lynx_createTextFn = _Lynx_papi('CreateText');
2351+var _Lynx_createImageFn = _Lynx_papi('CreateImage');
2352+function _Lynx_createElement(tag) {
2353+ var pId = (_Lynx_g['native'] && _Lynx_g['native']['currentPageId']) || 0;
2354+ return (tag === 'text' ? _Lynx_createTextFn
2355+ : tag === 'image' ? _Lynx_createImageFn
2356+ : _Lynx_createViewFn)(pId);
2357+}
2358+var _Lynx_createRawText = _Lynx_papi('CreateRawText');
2359+var _Lynx_appendChild = _Lynx_papi('AppendElement');
2360+var _Lynx_removeElement = _Lynx_papi('RemoveElement');
2361+var _Lynx_replaceElement = _Lynx_papi('ReplaceElement');
2362+var _Lynx_insertBefore = _Lynx_papi('InsertElementBefore');
2363+var _Lynx_setAttribute = _Lynx_papi('SetAttribute');
2364+var _Lynx_getChildren = _Lynx_papi('GetChildren');
2365+var _Lynx_getParent = _Lynx_papi('GetParent');
2366+var _Lynx_addEvent = _Lynx_papi('AddEvent');
2367+var _Lynx_setInlineStyles = _Lynx_papi('SetInlineStyles');
2368+var _VirtualDom_elementMeta = new WeakMap();
2369+function _VirtualDom_getMeta(el) {
2370+ var meta = _VirtualDom_elementMeta.get(el);
2371+ if (!meta) { meta = {}; _VirtualDom_elementMeta.set(el, meta); }
2372+ return meta;
2373+}
2374+
2375+
2376+// HELPERS
2377+
2378+
2379+
2380+
2381+
2382+function _VirtualDom_appendChild(parent, child)
2383+{
2384+ _Lynx_appendChild(parent, child);
2385+}
2386+
2387+var _VirtualDom_init = F4(function(virtualNode, flagDecoder, debugMetadata, args)
2388+{
2389+ // NOTE: this function needs _Platform_export available to work
2390+ var rootPage = args['node'] || _Lynx_g['page'];
2391+ var tree = _VirtualDom_render(virtualNode, function() {});
2392+ _Lynx_appendChild(rootPage, tree);
2393+ return {};
2394+});
2395+
2396+
2397+
2398+// TEXT
2399+
2400+
2401+function _VirtualDom_text(string)
2402+{
2403+ return {
2404+ $: 0,
2405+ a: string
2406+ };
2407+}
2408+
2409+
2410+
2411+// NODE
2412+
2413+
2414+var _VirtualDom_nodeNS = F2(function(namespace, tag)
2415+{
2416+ return F2(function(factList, kidList)
2417+ {
2418+ for (var kids = [], descendantsCount = 0; kidList.b; kidList = kidList.b) // WHILE_CONS
2419+ {
2420+ var kid = kidList.a;
2421+ descendantsCount += (kid.b || 0);
2422+ kids.push(kid);
2423+ }
2424+ descendantsCount += kids.length;
2425+
2426+ return {
2427+ $: 1,
2428+ c: tag,
2429+ d: _VirtualDom_organizeFacts(factList),
2430+ e: kids,
2431+ f: namespace,
2432+ b: descendantsCount
2433+ };
2434+ });
2435+});
2436+
2437+
2438+var _VirtualDom_node = _VirtualDom_nodeNS(undefined);
2439+
2440+
2441+
2442+// KEYED NODE
2443+
2444+
2445+var _VirtualDom_keyedNodeNS = F2(function(namespace, tag)
2446+{
2447+ return F2(function(factList, kidList)
2448+ {
2449+ for (var kids = [], descendantsCount = 0; kidList.b; kidList = kidList.b) // WHILE_CONS
2450+ {
2451+ var kid = kidList.a;
2452+ descendantsCount += (kid.b.b || 0);
2453+ kids.push(kid);
2454+ }
2455+ descendantsCount += kids.length;
2456+
2457+ return {
2458+ $: 2,
2459+ c: tag,
2460+ d: _VirtualDom_organizeFacts(factList),
2461+ e: kids,
2462+ f: namespace,
2463+ b: descendantsCount
2464+ };
2465+ });
2466+});
2467+
2468+
2469+var _VirtualDom_keyedNode = _VirtualDom_keyedNodeNS(undefined);
2470+
2471+
2472+
2473+// CUSTOM
2474+
2475+
2476+function _VirtualDom_custom(factList, model, render, diff)
2477+{
2478+ return {
2479+ $: 3,
2480+ d: _VirtualDom_organizeFacts(factList),
2481+ g: model,
2482+ h: render,
2483+ i: diff
2484+ };
2485+}
2486+
2487+
2488+
2489+// MAP
2490+
2491+
2492+var _VirtualDom_map = F2(function(tagger, node)
2493+{
2494+ return {
2495+ $: 4,
2496+ j: tagger,
2497+ k: node,
2498+ b: 1 + (node.b || 0)
2499+ };
2500+});
2501+
2502+
2503+
2504+// LAZY
2505+
2506+
2507+function _VirtualDom_thunk(refs, thunk)
2508+{
2509+ return {
2510+ $: 5,
2511+ l: refs,
2512+ m: thunk,
2513+ k: undefined
2514+ };
2515+}
2516+
2517+var _VirtualDom_lazy = F2(function(func, a)
2518+{
2519+ return _VirtualDom_thunk([func, a], function() {
2520+ return func(a);
2521+ });
2522+});
2523+
2524+var _VirtualDom_lazy2 = F3(function(func, a, b)
2525+{
2526+ return _VirtualDom_thunk([func, a, b], function() {
2527+ return A2(func, a, b);
2528+ });
2529+});
2530+
2531+var _VirtualDom_lazy3 = F4(function(func, a, b, c)
2532+{
2533+ return _VirtualDom_thunk([func, a, b, c], function() {
2534+ return A3(func, a, b, c);
2535+ });
2536+});
2537+
2538+var _VirtualDom_lazy4 = F5(function(func, a, b, c, d)
2539+{
2540+ return _VirtualDom_thunk([func, a, b, c, d], function() {
2541+ return A4(func, a, b, c, d);
2542+ });
2543+});
2544+
2545+var _VirtualDom_lazy5 = F6(function(func, a, b, c, d, e)
2546+{
2547+ return _VirtualDom_thunk([func, a, b, c, d, e], function() {
2548+ return A5(func, a, b, c, d, e);
2549+ });
2550+});
2551+
2552+var _VirtualDom_lazy6 = F7(function(func, a, b, c, d, e, f)
2553+{
2554+ return _VirtualDom_thunk([func, a, b, c, d, e, f], function() {
2555+ return A6(func, a, b, c, d, e, f);
2556+ });
2557+});
2558+
2559+var _VirtualDom_lazy7 = F8(function(func, a, b, c, d, e, f, g)
2560+{
2561+ return _VirtualDom_thunk([func, a, b, c, d, e, f, g], function() {
2562+ return A7(func, a, b, c, d, e, f, g);
2563+ });
2564+});
2565+
2566+var _VirtualDom_lazy8 = F9(function(func, a, b, c, d, e, f, g, h)
2567+{
2568+ return _VirtualDom_thunk([func, a, b, c, d, e, f, g, h], function() {
2569+ return A8(func, a, b, c, d, e, f, g, h);
2570+ });
2571+});
2572+
2573+
2574+
2575+// FACTS
2576+
2577+
2578+var _VirtualDom_on = F2(function(key, handler)
2579+{
2580+ return {
2581+ $: 'a0',
2582+ n: key,
2583+ o: handler
2584+ };
2585+});
2586+var _VirtualDom_style = F2(function(key, value)
2587+{
2588+ return {
2589+ $: 'a1',
2590+ n: key,
2591+ o: value
2592+ };
2593+});
2594+var _VirtualDom_property = F2(function(key, value)
2595+{
2596+ return {
2597+ $: 'a2',
2598+ n: key,
2599+ o: value
2600+ };
2601+});
2602+var _VirtualDom_attribute = F2(function(key, value)
2603+{
2604+ return {
2605+ $: 'a3',
2606+ n: key,
2607+ o: value
2608+ };
2609+});
2610+var _VirtualDom_attributeNS = F3(function(namespace, key, value)
2611+{
2612+ return {
2613+ $: 'a4',
2614+ n: key,
2615+ o: { f: namespace, o: value }
2616+ };
2617+});
2618+
2619+
2620+
2621+// XSS ATTACK VECTOR CHECKS
2622+//
2623+// For some reason, tabs can appear in href protocols and it still works.
2624+// So '\tjava\tSCRIPT:alert("!!!")' and 'javascript:alert("!!!")' are the same
2625+// in practice. That is why _VirtualDom_RE_js and _VirtualDom_RE_js_html look
2626+// so freaky.
2627+//
2628+// Pulling the regular expressions out to the top level gives a slight speed
2629+// boost in small benchmarks (4-10%) but hoisting values to reduce allocation
2630+// can be unpredictable in large programs where JIT may have a harder time with
2631+// functions are not fully self-contained. The benefit is more that the js and
2632+// js_html ones are so weird that I prefer to see them near each other.
2633+
2634+
2635+
2636+
2637+
2638+function _VirtualDom_noScript(tag)
2639+{
2640+ return tag;
2641+}
2642+
2643+function _VirtualDom_noOnOrFormAction(key)
2644+{
2645+ return key;
2646+}
2647+
2648+function _VirtualDom_noInnerHtmlOrFormAction(key)
2649+{
2650+ return key;
2651+}
2652+
2653+function _VirtualDom_noJavaScriptUri(value)
2654+{
2655+ return value;
2656+}
2657+
2658+function _VirtualDom_noJavaScriptOrHtmlUri(value)
2659+{
2660+ return value;
2661+}
2662+
2663+function _VirtualDom_noJavaScriptOrHtmlJson(value)
2664+{
2665+ return value;
2666+}
2667+
2668+
2669+
2670+// MAP FACTS
2671+
2672+
2673+var _VirtualDom_mapAttribute = F2(function(func, attr)
2674+{
2675+ return (attr.$ === 'a0')
2676+ ? A2(_VirtualDom_on, attr.n, _VirtualDom_mapHandler(func, attr.o))
2677+ : attr;
2678+});
2679+
2680+function _VirtualDom_mapHandler(func, handler)
2681+{
2682+ var tag = $lynxjs_elm$virtual_dom$VirtualDom$toHandlerInt(handler);
2683+
2684+ // 0 = Normal
2685+ // 1 = MayStopPropagation
2686+ // 2 = MayPreventDefault
2687+ // 3 = Custom
2688+
2689+ return {
2690+ $: handler.$,
2691+ a:
2692+ !tag
2693+ ? A2($elm$json$Json$Decode$map, func, handler.a)
2694+ :
2695+ A3($elm$json$Json$Decode$map2,
2696+ tag < 3
2697+ ? _VirtualDom_mapEventTuple
2698+ : _VirtualDom_mapEventRecord,
2699+ $elm$json$Json$Decode$succeed(func),
2700+ handler.a
2701+ )
2702+ };
2703+}
2704+
2705+var _VirtualDom_mapEventTuple = F2(function(func, tuple)
2706+{
2707+ return _Utils_Tuple2(func(tuple.a), tuple.b);
2708+});
2709+
2710+var _VirtualDom_mapEventRecord = F2(function(func, record)
2711+{
2712+ return {
2713+ message: func(record.message),
2714+ stopPropagation: record.stopPropagation,
2715+ preventDefault: record.preventDefault
2716+ }
2717+});
2718+
2719+
2720+
2721+// ORGANIZE FACTS
2722+
2723+
2724+function _VirtualDom_organizeFacts(factList)
2725+{
2726+ for (var facts = {}; factList.b; factList = factList.b) // WHILE_CONS
2727+ {
2728+ var entry = factList.a;
2729+
2730+ var tag = entry.$;
2731+ var key = entry.n;
2732+ var value = entry.o;
2733+
2734+ if (tag === 'a2')
2735+ {
2736+ (key === 'className')
2737+ ? _VirtualDom_addClass(facts, key, _Json_unwrap(value))
2738+ : facts[key] = _Json_unwrap(value);
2739+
2740+ continue;
2741+ }
2742+
2743+ var subFacts = facts[tag] || (facts[tag] = {});
2744+ (tag === 'a3' && key === 'class')
2745+ ? _VirtualDom_addClass(subFacts, key, value)
2746+ : subFacts[key] = value;
2747+ }
2748+
2749+ return facts;
2750+}
2751+
2752+function _VirtualDom_addClass(object, key, newClass)
2753+{
2754+ var classes = object[key];
2755+ object[key] = classes ? classes + ' ' + newClass : newClass;
2756+}
2757+
2758+
2759+
2760+// RENDER
2761+
2762+
2763+function _VirtualDom_render(vNode, eventNode)
2764+{
2765+ var tag = vNode.$;
2766+
2767+ if (tag === 5)
2768+ {
2769+ return _VirtualDom_render(vNode.k || (vNode.k = vNode.m()), eventNode);
2770+ }
2771+
2772+ if (tag === 0)
2773+ {
2774+ return _Lynx_createRawText(vNode.a);
2775+ }
2776+
2777+ if (tag === 4)
2778+ {
2779+ var subNode = vNode.k;
2780+ var tagger = vNode.j;
2781+
2782+ while (subNode.$ === 4)
2783+ {
2784+ typeof tagger !== 'object'
2785+ ? tagger = [tagger, subNode.j]
2786+ : tagger.push(subNode.j);
2787+
2788+ subNode = subNode.k;
2789+ }
2790+
2791+ var subEventRoot = { j: tagger, p: eventNode };
2792+ var domNode = _VirtualDom_render(subNode, subEventRoot);
2793+ _VirtualDom_getMeta(domNode).elm_event_node_ref = subEventRoot;
2794+ return domNode;
2795+ }
2796+
2797+ if (tag === 3)
2798+ {
2799+ var domNode = vNode.h(vNode.g);
2800+ _VirtualDom_applyFacts(domNode, eventNode, vNode.d);
2801+ return domNode;
2802+ }
2803+
2804+ // at this point `tag` must be 1 or 2
2805+
2806+ var domNode = _Lynx_createElement(vNode.c);
2807+
2808+ _VirtualDom_applyFacts(domNode, eventNode, vNode.d);
2809+
2810+ for (var kids = vNode.e, i = 0; i < kids.length; i++)
2811+ {
2812+ var kid = tag === 1 ? kids[i] : kids[i].b;
2813+ if (kid.$ === 0)
2814+ {
2815+ _Lynx_appendChild(domNode, _Lynx_createRawText(kid.a));
2816+ }
2817+ else
2818+ {
2819+ _VirtualDom_appendChild(domNode, _VirtualDom_render(kid, eventNode));
2820+ }
2821+ }
2822+
2823+ return domNode;
2824+}
2825+
2826+
2827+
2828+// APPLY FACTS
2829+
2830+
2831+function _VirtualDom_applyFacts(domNode, eventNode, facts)
2832+{
2833+ for (var key in facts)
2834+ {
2835+ var value = facts[key];
2836+
2837+ key === 'a1'
2838+ ? _VirtualDom_applyStyles(domNode, value)
2839+ :
2840+ key === 'a0'
2841+ ? _VirtualDom_applyEvents(domNode, eventNode, value)
2842+ :
2843+ key === 'a3'
2844+ ? _VirtualDom_applyAttrs(domNode, value)
2845+ :
2846+ key === 'a4'
2847+ ? _VirtualDom_applyAttrsNS(domNode, value)
2848+ :
2849+ (key !== 'value' && key !== 'checked' || domNode[key] !== value) && _Lynx_setAttribute(domNode, key === 'className' ? 'class' : key, String(value));
2850+ }
2851+}
2852+
2853+
2854+
2855+// APPLY STYLES
2856+
2857+
2858+function _VirtualDom_applyStyles(domNode, styles)
2859+{
2860+ _Lynx_setInlineStyles(domNode, styles);
2861+}
2862+
2863+
2864+
2865+// APPLY ATTRS
2866+
2867+
2868+function _VirtualDom_applyAttrs(domNode, attrs)
2869+{
2870+ for (var key in attrs)
2871+ {
2872+ var value = attrs[key];
2873+ if (typeof value !== 'undefined')
2874+ {
2875+ _Lynx_setAttribute(domNode, key, value);
2876+ }
2877+ }
2878+}
2879+
2880+
2881+
2882+// APPLY NAMESPACED ATTRS
2883+
2884+
2885+function _VirtualDom_applyAttrsNS(domNode, nsAttrs)
2886+{
2887+ for (var key in nsAttrs)
2888+ {
2889+ var pair = nsAttrs[key];
2890+ var value = pair.o;
2891+
2892+ if (typeof value !== 'undefined')
2893+ {
2894+ _Lynx_setAttribute(domNode, key, value);
2895+ }
2896+ }
2897+}
2898+
2899+
2900+
2901+// APPLY EVENTS
2902+
2903+
2904+function _VirtualDom_applyEvents(domNode, eventNode, events)
2905+{
2906+ var meta = _VirtualDom_getMeta(domNode);
2907+ var allCallbacks = meta.elmFs || (meta.elmFs = {});
2908+
2909+ for (var key in events)
2910+ {
2911+ var newHandler = events[key];
2912+ var oldCallback = allCallbacks[key];
2913+
2914+ if (!newHandler)
2915+ {
2916+ allCallbacks[key] = undefined;
2917+ continue;
2918+ }
2919+
2920+ if (oldCallback)
2921+ {
2922+ var oldHandler = oldCallback.q;
2923+ if (oldHandler.$ === newHandler.$)
2924+ {
2925+ oldCallback.q = newHandler;
2926+ continue;
2927+ }
2928+ }
2929+
2930+ oldCallback = _VirtualDom_makeCallback(eventNode, newHandler);
2931+ allCallbacks[key] = oldCallback;
2932+
2933+ var lynxEventName = _VirtualDom_mapEventName(key);
2934+ var handlerType = $lynxjs_elm$virtual_dom$VirtualDom$toHandlerInt(newHandler);
2935+ var prefix = (handlerType === 1) ? 'catch' : 'bind';
2936+ _Lynx_addEvent(domNode, 'catchEvent', lynxEventName, { type: 'worklet', value: oldCallback });
2937+ }
2938+}
2939+
2940+function _VirtualDom_mapEventName(name)
2941+{
2942+ switch (name)
2943+ {
2944+ case 'click': return 'tap';
2945+ case 'dblclick': return 'tap';
2946+ case 'mousedown': return 'touchstart';
2947+ case 'mousemove': return 'touchmove';
2948+ case 'mouseup': return 'touchend';
2949+ default: return name;
2950+ }
2951+}
2952+
2953+
2954+
2955+// PASSIVE EVENTS
2956+
2957+
2958+
2959+// EVENT HANDLERS
2960+
2961+
2962+function _VirtualDom_makeCallback(eventNode, initialHandler)
2963+{
2964+ function callback(event)
2965+ {
2966+ var handler = callback.q;
2967+ var result = _Json_runHelp(handler.a, event);
2968+
2969+ if (!$elm$core$Result$isOk(result))
2970+ {
2971+ return;
2972+ }
2973+
2974+ var tag = $lynxjs_elm$virtual_dom$VirtualDom$toHandlerInt(handler);
2975+
2976+ // 0 = Normal
2977+ // 1 = MayStopPropagation
2978+ // 2 = MayPreventDefault
2979+ // 3 = Custom
2980+
2981+ var value = result.a;
2982+ var message = !tag ? value : tag < 3 ? value.a : value.message;
2983+ var stopPropagation = tag == 1 ? value.b : tag == 3 && value.stopPropagation;
2984+ var currentEventNode = eventNode;
2985+ var tagger;
2986+ var i;
2987+ while (tagger = currentEventNode.j)
2988+ {
2989+ if (typeof tagger == 'function')
2990+ {
2991+ message = tagger(message);
2992+ }
2993+ else
2994+ {
2995+ for (var i = tagger.length; i--; )
2996+ {
2997+ message = tagger[i](message);
2998+ }
2999+ }
3000+ currentEventNode = currentEventNode.p;
3001+ }
3002+ currentEventNode(message, stopPropagation); // stopPropagation implies isSync
3003+ }
3004+
3005+ callback.q = initialHandler;
3006+
3007+ return callback;
3008+}
3009+
3010+function _VirtualDom_equalEvents(x, y)
3011+{
3012+ return x.$ == y.$ && _Json_equality(x.a, y.a);
3013+}
3014+
3015+
3016+
3017+// DIFF
3018+
3019+
3020+// TODO: Should we do patches like in iOS?
3021+//
3022+// type Patch
3023+// = At Int Patch
3024+// | Batch (List Patch)
3025+// | Change ...
3026+//
3027+// How could it not be better?
3028+//
3029+function _VirtualDom_diff(x, y)
3030+{
3031+ var patches = [];
3032+ _VirtualDom_diffHelp(x, y, patches, 0);
3033+ return patches;
3034+}
3035+
3036+
3037+function _VirtualDom_pushPatch(patches, type, index, data)
3038+{
3039+ var patch = {
3040+ $: type,
3041+ r: index,
3042+ s: data,
3043+ t: undefined,
3044+ u: undefined
3045+ };
3046+ patches.push(patch);
3047+ return patch;
3048+}
3049+
3050+
3051+function _VirtualDom_diffHelp(x, y, patches, index)
3052+{
3053+ if (x === y)
3054+ {
3055+ return;
3056+ }
3057+
3058+ var xType = x.$;
3059+ var yType = y.$;
3060+
3061+ // Bail if you run into different types of nodes. Implies that the
3062+ // structure has changed significantly and it's not worth a diff.
3063+ if (xType !== yType)
3064+ {
3065+ if (xType === 1 && yType === 2)
3066+ {
3067+ y = _VirtualDom_dekey(y);
3068+ yType = 1;
3069+ }
3070+ else
3071+ {
3072+ _VirtualDom_pushPatch(patches, 0, index, y);
3073+ return;
3074+ }
3075+ }
3076+
3077+ // Now we know that both nodes are the same $.
3078+ switch (yType)
3079+ {
3080+ case 5:
3081+ var xRefs = x.l;
3082+ var yRefs = y.l;
3083+ var i = xRefs.length;
3084+ var same = i === yRefs.length;
3085+ while (same && i--)
3086+ {
3087+ same = xRefs[i] === yRefs[i];
3088+ }
3089+ if (same)
3090+ {
3091+ y.k = x.k;
3092+ return;
3093+ }
3094+ y.k = y.m();
3095+ var subPatches = [];
3096+ _VirtualDom_diffHelp(x.k, y.k, subPatches, 0);
3097+ subPatches.length > 0 && _VirtualDom_pushPatch(patches, 1, index, subPatches);
3098+ return;
3099+
3100+ case 4:
3101+ // gather nested taggers
3102+ var xTaggers = x.j;
3103+ var yTaggers = y.j;
3104+ var nesting = false;
3105+
3106+ var xSubNode = x.k;
3107+ while (xSubNode.$ === 4)
3108+ {
3109+ nesting = true;
3110+
3111+ typeof xTaggers !== 'object'
3112+ ? xTaggers = [xTaggers, xSubNode.j]
3113+ : xTaggers.push(xSubNode.j);
3114+
3115+ xSubNode = xSubNode.k;
3116+ }
3117+
3118+ var ySubNode = y.k;
3119+ while (ySubNode.$ === 4)
3120+ {
3121+ nesting = true;
3122+
3123+ typeof yTaggers !== 'object'
3124+ ? yTaggers = [yTaggers, ySubNode.j]
3125+ : yTaggers.push(ySubNode.j);
3126+
3127+ ySubNode = ySubNode.k;
3128+ }
3129+
3130+ // Just bail if different numbers of taggers. This implies the
3131+ // structure of the virtual DOM has changed.
3132+ if (nesting && xTaggers.length !== yTaggers.length)
3133+ {
3134+ _VirtualDom_pushPatch(patches, 0, index, y);
3135+ return;
3136+ }
3137+
3138+ // check if taggers are "the same"
3139+ if (nesting ? !_VirtualDom_pairwiseRefEqual(xTaggers, yTaggers) : xTaggers !== yTaggers)
3140+ {
3141+ _VirtualDom_pushPatch(patches, 2, index, yTaggers);
3142+ }
3143+
3144+ // diff everything below the taggers
3145+ _VirtualDom_diffHelp(xSubNode, ySubNode, patches, index + 1);
3146+ return;
3147+
3148+ case 0:
3149+ if (x.a !== y.a)
3150+ {
3151+ _VirtualDom_pushPatch(patches, 3, index, y.a);
3152+ }
3153+ return;
3154+
3155+ case 1:
3156+ _VirtualDom_diffNodes(x, y, patches, index, _VirtualDom_diffKids);
3157+ return;
3158+
3159+ case 2:
3160+ _VirtualDom_diffNodes(x, y, patches, index, _VirtualDom_diffKeyedKids);
3161+ return;
3162+
3163+ case 3:
3164+ if (x.h !== y.h)
3165+ {
3166+ _VirtualDom_pushPatch(patches, 0, index, y);
3167+ return;
3168+ }
3169+
3170+ var factsDiff = _VirtualDom_diffFacts(x.d, y.d);
3171+ factsDiff && _VirtualDom_pushPatch(patches, 4, index, factsDiff);
3172+
3173+ var patch = y.i(x.g, y.g);
3174+ patch && _VirtualDom_pushPatch(patches, 5, index, patch);
3175+
3176+ return;
3177+ }
3178+}
3179+
3180+// assumes the incoming arrays are the same length
3181+function _VirtualDom_pairwiseRefEqual(as, bs)
3182+{
3183+ for (var i = 0; i < as.length; i++)
3184+ {
3185+ if (as[i] !== bs[i])
3186+ {
3187+ return false;
3188+ }
3189+ }
3190+
3191+ return true;
3192+}
3193+
3194+function _VirtualDom_diffNodes(x, y, patches, index, diffKids)
3195+{
3196+ // Bail if obvious indicators have changed. Implies more serious
3197+ // structural changes such that it's not worth it to diff.
3198+ if (x.c !== y.c || x.f !== y.f)
3199+ {
3200+ _VirtualDom_pushPatch(patches, 0, index, y);
3201+ return;
3202+ }
3203+
3204+ var factsDiff = _VirtualDom_diffFacts(x.d, y.d);
3205+ factsDiff && _VirtualDom_pushPatch(patches, 4, index, factsDiff);
3206+
3207+ diffKids(x, y, patches, index);
3208+}
3209+
3210+
3211+
3212+// DIFF FACTS
3213+
3214+
3215+// TODO Instead of creating a new diff object, it's possible to just test if
3216+// there *is* a diff. During the actual patch, do the diff again and make the
3217+// modifications directly. This way, there's no new allocations. Worth it?
3218+function _VirtualDom_diffFacts(x, y, category)
3219+{
3220+ var diff;
3221+
3222+ // look for changes and removals
3223+ for (var xKey in x)
3224+ {
3225+ if (xKey === 'a1' || xKey === 'a0' || xKey === 'a3' || xKey === 'a4')
3226+ {
3227+ var subDiff = _VirtualDom_diffFacts(x[xKey], y[xKey] || {}, xKey);
3228+ if (subDiff)
3229+ {
3230+ diff = diff || {};
3231+ diff[xKey] = subDiff;
3232+ }
3233+ continue;
3234+ }
3235+
3236+ // remove if not in the new facts
3237+ if (!(xKey in y))
3238+ {
3239+ diff = diff || {};
3240+ diff[xKey] =
3241+ !category
3242+ ? (typeof x[xKey] === 'string' ? '' : null)
3243+ :
3244+ (category === 'a1')
3245+ ? ''
3246+ :
3247+ (category === 'a0' || category === 'a3')
3248+ ? undefined
3249+ :
3250+ { f: x[xKey].f, o: undefined };
3251+
3252+ continue;
3253+ }
3254+
3255+ var xValue = x[xKey];
3256+ var yValue = y[xKey];
3257+
3258+ // reference equal, so don't worry about it
3259+ if (xValue === yValue && xKey !== 'value' && xKey !== 'checked'
3260+ || category === 'a0' && _VirtualDom_equalEvents(xValue, yValue))
3261+ {
3262+ continue;
3263+ }
3264+
3265+ diff = diff || {};
3266+ diff[xKey] = yValue;
3267+ }
3268+
3269+ // add new stuff
3270+ for (var yKey in y)
3271+ {
3272+ if (!(yKey in x))
3273+ {
3274+ diff = diff || {};
3275+ diff[yKey] = y[yKey];
3276+ }
3277+ }
3278+
3279+ return diff;
3280+}
3281+
3282+
3283+
3284+// DIFF KIDS
3285+
3286+
3287+function _VirtualDom_diffKids(xParent, yParent, patches, index)
3288+{
3289+ var xKids = xParent.e;
3290+ var yKids = yParent.e;
3291+
3292+ var xLen = xKids.length;
3293+ var yLen = yKids.length;
3294+
3295+ // FIGURE OUT IF THERE ARE INSERTS OR REMOVALS
3296+
3297+ if (xLen > yLen)
3298+ {
3299+ _VirtualDom_pushPatch(patches, 6, index, {
3300+ v: yLen,
3301+ i: xLen - yLen
3302+ });
3303+ }
3304+ else if (xLen < yLen)
3305+ {
3306+ _VirtualDom_pushPatch(patches, 7, index, {
3307+ v: xLen,
3308+ e: yKids
3309+ });
3310+ }
3311+
3312+ // PAIRWISE DIFF EVERYTHING ELSE
3313+
3314+ for (var minLen = xLen < yLen ? xLen : yLen, i = 0; i < minLen; i++)
3315+ {
3316+ var xKid = xKids[i];
3317+ _VirtualDom_diffHelp(xKid, yKids[i], patches, ++index);
3318+ index += xKid.b || 0;
3319+ }
3320+}
3321+
3322+
3323+
3324+// KEYED DIFF
3325+
3326+
3327+function _VirtualDom_diffKeyedKids(xParent, yParent, patches, rootIndex)
3328+{
3329+ var localPatches = [];
3330+
3331+ var changes = {}; // Dict String Entry
3332+ var inserts = []; // Array { index : Int, entry : Entry }
3333+ // type Entry = { tag : String, vnode : VNode, index : Int, data : _ }
3334+
3335+ var xKids = xParent.e;
3336+ var yKids = yParent.e;
3337+ var xLen = xKids.length;
3338+ var yLen = yKids.length;
3339+ var xIndex = 0;
3340+ var yIndex = 0;
3341+
3342+ var index = rootIndex;
3343+
3344+ while (xIndex < xLen && yIndex < yLen)
3345+ {
3346+ var x = xKids[xIndex];
3347+ var y = yKids[yIndex];
3348+
3349+ var xKey = x.a;
3350+ var yKey = y.a;
3351+ var xNode = x.b;
3352+ var yNode = y.b;
3353+
3354+ var newMatch = undefined;
3355+ var oldMatch = undefined;
3356+
3357+ // check if keys match
3358+
3359+ if (xKey === yKey)
3360+ {
3361+ index++;
3362+ _VirtualDom_diffHelp(xNode, yNode, localPatches, index);
3363+ index += xNode.b || 0;
3364+
3365+ xIndex++;
3366+ yIndex++;
3367+ continue;
3368+ }
3369+
3370+ // look ahead 1 to detect insertions and removals.
3371+
3372+ var xNext = xKids[xIndex + 1];
3373+ var yNext = yKids[yIndex + 1];
3374+
3375+ if (xNext)
3376+ {
3377+ var xNextKey = xNext.a;
3378+ var xNextNode = xNext.b;
3379+ oldMatch = yKey === xNextKey;
3380+ }
3381+
3382+ if (yNext)
3383+ {
3384+ var yNextKey = yNext.a;
3385+ var yNextNode = yNext.b;
3386+ newMatch = xKey === yNextKey;
3387+ }
3388+
3389+
3390+ // swap x and y
3391+ if (newMatch && oldMatch)
3392+ {
3393+ index++;
3394+ _VirtualDom_diffHelp(xNode, yNextNode, localPatches, index);
3395+ _VirtualDom_insertNode(changes, localPatches, xKey, yNode, yIndex, inserts);
3396+ index += xNode.b || 0;
3397+
3398+ index++;
3399+ _VirtualDom_removeNode(changes, localPatches, xKey, xNextNode, index);
3400+ index += xNextNode.b || 0;
3401+
3402+ xIndex += 2;
3403+ yIndex += 2;
3404+ continue;
3405+ }
3406+
3407+ // insert y
3408+ if (newMatch)
3409+ {
3410+ index++;
3411+ _VirtualDom_insertNode(changes, localPatches, yKey, yNode, yIndex, inserts);
3412+ _VirtualDom_diffHelp(xNode, yNextNode, localPatches, index);
3413+ index += xNode.b || 0;
3414+
3415+ xIndex += 1;
3416+ yIndex += 2;
3417+ continue;
3418+ }
3419+
3420+ // remove x
3421+ if (oldMatch)
3422+ {
3423+ index++;
3424+ _VirtualDom_removeNode(changes, localPatches, xKey, xNode, index);
3425+ index += xNode.b || 0;
3426+
3427+ index++;
3428+ _VirtualDom_diffHelp(xNextNode, yNode, localPatches, index);
3429+ index += xNextNode.b || 0;
3430+
3431+ xIndex += 2;
3432+ yIndex += 1;
3433+ continue;
3434+ }
3435+
3436+ // remove x, insert y
3437+ if (xNext && xNextKey === yNextKey)
3438+ {
3439+ index++;
3440+ _VirtualDom_removeNode(changes, localPatches, xKey, xNode, index);
3441+ _VirtualDom_insertNode(changes, localPatches, yKey, yNode, yIndex, inserts);
3442+ index += xNode.b || 0;
3443+
3444+ index++;
3445+ _VirtualDom_diffHelp(xNextNode, yNextNode, localPatches, index);
3446+ index += xNextNode.b || 0;
3447+
3448+ xIndex += 2;
3449+ yIndex += 2;
3450+ continue;
3451+ }
3452+
3453+ break;
3454+ }
3455+
3456+ // eat up any remaining nodes with removeNode and insertNode
3457+
3458+ while (xIndex < xLen)
3459+ {
3460+ index++;
3461+ var x = xKids[xIndex];
3462+ var xNode = x.b;
3463+ _VirtualDom_removeNode(changes, localPatches, x.a, xNode, index);
3464+ index += xNode.b || 0;
3465+ xIndex++;
3466+ }
3467+
3468+ while (yIndex < yLen)
3469+ {
3470+ var endInserts = endInserts || [];
3471+ var y = yKids[yIndex];
3472+ _VirtualDom_insertNode(changes, localPatches, y.a, y.b, undefined, endInserts);
3473+ yIndex++;
3474+ }
3475+
3476+ if (localPatches.length > 0 || inserts.length > 0 || endInserts)
3477+ {
3478+ _VirtualDom_pushPatch(patches, 8, rootIndex, {
3479+ w: localPatches,
3480+ x: inserts,
3481+ y: endInserts
3482+ });
3483+ }
3484+}
3485+
3486+
3487+
3488+// CHANGES FROM KEYED DIFF
3489+
3490+
3491+var _VirtualDom_POSTFIX = '_elmW6BL';
3492+
3493+
3494+function _VirtualDom_insertNode(changes, localPatches, key, vnode, yIndex, inserts)
3495+{
3496+ var entry = changes[key];
3497+
3498+ // never seen this key before
3499+ if (!entry)
3500+ {
3501+ entry = {
3502+ c: 0,
3503+ z: vnode,
3504+ r: yIndex,
3505+ s: undefined
3506+ };
3507+
3508+ inserts.push({ r: yIndex, A: entry });
3509+ changes[key] = entry;
3510+
3511+ return;
3512+ }
3513+
3514+ // this key was removed earlier, a match!
3515+ if (entry.c === 1)
3516+ {
3517+ inserts.push({ r: yIndex, A: entry });
3518+
3519+ entry.c = 2;
3520+ var subPatches = [];
3521+ _VirtualDom_diffHelp(entry.z, vnode, subPatches, entry.r);
3522+ entry.r = yIndex;
3523+ entry.s.s = {
3524+ w: subPatches,
3525+ A: entry
3526+ };
3527+
3528+ return;
3529+ }
3530+
3531+ // this key has already been inserted or moved, a duplicate!
3532+ _VirtualDom_insertNode(changes, localPatches, key + _VirtualDom_POSTFIX, vnode, yIndex, inserts);
3533+}
3534+
3535+
3536+function _VirtualDom_removeNode(changes, localPatches, key, vnode, index)
3537+{
3538+ var entry = changes[key];
3539+
3540+ // never seen this key before
3541+ if (!entry)
3542+ {
3543+ var patch = _VirtualDom_pushPatch(localPatches, 9, index, undefined);
3544+
3545+ changes[key] = {
3546+ c: 1,
3547+ z: vnode,
3548+ r: index,
3549+ s: patch
3550+ };
3551+
3552+ return;
3553+ }
3554+
3555+ // this key was inserted earlier, a match!
3556+ if (entry.c === 0)
3557+ {
3558+ entry.c = 2;
3559+ var subPatches = [];
3560+ _VirtualDom_diffHelp(vnode, entry.z, subPatches, index);
3561+
3562+ _VirtualDom_pushPatch(localPatches, 9, index, {
3563+ w: subPatches,
3564+ A: entry
3565+ });
3566+
3567+ return;
3568+ }
3569+
3570+ // this key has already been removed or moved, a duplicate!
3571+ _VirtualDom_removeNode(changes, localPatches, key + _VirtualDom_POSTFIX, vnode, index);
3572+}
3573+
3574+
3575+
3576+// ADD DOM NODES
3577+//
3578+// Each DOM node has an "index" assigned in order of traversal. It is important
3579+// to minimize our crawl over the actual DOM, so these indexes (along with the
3580+// descendantsCount of virtual nodes) let us skip touching entire subtrees of
3581+// the DOM if we know there are no patches there.
3582+
3583+
3584+function _VirtualDom_addDomNodes(domNode, vNode, patches, eventNode)
3585+{
3586+ _VirtualDom_addDomNodesHelp(domNode, vNode, patches, 0, 0, vNode.b, eventNode);
3587+}
3588+
3589+
3590+// assumes `patches` is non-empty and indexes increase monotonically.
3591+function _VirtualDom_addDomNodesHelp(domNode, vNode, patches, i, low, high, eventNode)
3592+{
3593+ var patch = patches[i];
3594+ var index = patch.r;
3595+
3596+ while (index === low)
3597+ {
3598+ var patchType = patch.$;
3599+
3600+ if (patchType === 1)
3601+ {
3602+ _VirtualDom_addDomNodes(domNode, vNode.k, patch.s, eventNode);
3603+ }
3604+ else if (patchType === 8)
3605+ {
3606+ patch.t = domNode;
3607+ patch.u = eventNode;
3608+
3609+ var subPatches = patch.s.w;
3610+ if (subPatches.length > 0)
3611+ {
3612+ _VirtualDom_addDomNodesHelp(domNode, vNode, subPatches, 0, low, high, eventNode);
3613+ }
3614+ }
3615+ else if (patchType === 9)
3616+ {
3617+ patch.t = domNode;
3618+ patch.u = eventNode;
3619+
3620+ var data = patch.s;
3621+ if (data)
3622+ {
3623+ data.A.s = domNode;
3624+ var subPatches = data.w;
3625+ if (subPatches.length > 0)
3626+ {
3627+ _VirtualDom_addDomNodesHelp(domNode, vNode, subPatches, 0, low, high, eventNode);
3628+ }
3629+ }
3630+ }
3631+ else
3632+ {
3633+ patch.t = domNode;
3634+ patch.u = eventNode;
3635+ }
3636+
3637+ i++;
3638+
3639+ if (!(patch = patches[i]) || (index = patch.r) > high)
3640+ {
3641+ return i;
3642+ }
3643+ }
3644+
3645+ var tag = vNode.$;
3646+
3647+ if (tag === 4)
3648+ {
3649+ var subNode = vNode.k;
3650+
3651+ while (subNode.$ === 4)
3652+ {
3653+ subNode = subNode.k;
3654+ }
3655+
3656+ return _VirtualDom_addDomNodesHelp(domNode, subNode, patches, i, low + 1, high, _VirtualDom_getMeta(domNode).elm_event_node_ref);
3657+ }
3658+
3659+ // tag must be 1 or 2 at this point
3660+
3661+ var vKids = vNode.e;
3662+ var childNodes = _Lynx_getChildren(domNode);
3663+ for (var j = 0; j < vKids.length; j++)
3664+ {
3665+ low++;
3666+ var vKid = tag === 1 ? vKids[j] : vKids[j].b;
3667+ var nextLow = low + (vKid.b || 0);
3668+ if (low <= index && index <= nextLow)
3669+ {
3670+ i = _VirtualDom_addDomNodesHelp(childNodes[j], vKid, patches, i, low, nextLow, eventNode);
3671+ if (!(patch = patches[i]) || (index = patch.r) > high)
3672+ {
3673+ return i;
3674+ }
3675+ }
3676+ low = nextLow;
3677+ }
3678+ return i;
3679+}
3680+
3681+
3682+
3683+// APPLY PATCHES
3684+
3685+
3686+function _VirtualDom_applyPatches(rootDomNode, oldVirtualNode, patches, eventNode)
3687+{
3688+ if (patches.length === 0)
3689+ {
3690+ return rootDomNode;
3691+ }
3692+
3693+ _VirtualDom_addDomNodes(rootDomNode, oldVirtualNode, patches, eventNode);
3694+ return _VirtualDom_applyPatchesHelp(rootDomNode, patches);
3695+}
3696+
3697+function _VirtualDom_applyPatchesHelp(rootDomNode, patches)
3698+{
3699+ for (var i = 0; i < patches.length; i++)
3700+ {
3701+ var patch = patches[i];
3702+ var localDomNode = patch.t
3703+ var newNode = _VirtualDom_applyPatch(localDomNode, patch);
3704+ if (localDomNode === rootDomNode)
3705+ {
3706+ rootDomNode = newNode;
3707+ }
3708+ }
3709+ return rootDomNode;
3710+}
3711+
3712+function _VirtualDom_applyPatch(domNode, patch)
3713+{
3714+ switch (patch.$)
3715+ {
3716+ case 0:
3717+ return _VirtualDom_applyPatchRedraw(domNode, patch.s, patch.u);
3718+
3719+ case 4:
3720+ _VirtualDom_applyFacts(domNode, patch.u, patch.s);
3721+ return domNode;
3722+
3723+ case 3:
3724+ _Lynx_setAttribute(domNode, 'text', patch.s);
3725+ return domNode;
3726+
3727+ case 1:
3728+ return _VirtualDom_applyPatchesHelp(domNode, patch.s);
3729+
3730+ case 2:
3731+ if (_VirtualDom_getMeta(domNode).elm_event_node_ref)
3732+ {
3733+ _VirtualDom_getMeta(domNode).elm_event_node_ref.j = patch.s;
3734+ }
3735+ else
3736+ {
3737+ _VirtualDom_getMeta(domNode).elm_event_node_ref = { j: patch.s, p: patch.u };
3738+ }
3739+ return domNode;
3740+
3741+ case 6:
3742+ var data = patch.s;
3743+ for (var i = 0; i < data.i; i++)
3744+ {
3745+ var children = _Lynx_getChildren(domNode);
3746+ _Lynx_removeElement(domNode, children[data.v]);
3747+ }
3748+ return domNode;
3749+
3750+ case 7:
3751+ var data = patch.s;
3752+ var kids = data.e;
3753+ for (var i = data.v; i < kids.length; i++)
3754+ {
3755+ _Lynx_appendChild(domNode, _VirtualDom_render(kids[i], patch.u));
3756+ }
3757+ return domNode;
3758+
3759+ case 9:
3760+ var data = patch.s;
3761+ if (!data)
3762+ {
3763+ _Lynx_removeElement(_Lynx_getParent(domNode), domNode);
3764+ return domNode;
3765+ }
3766+ var entry = data.A;
3767+ if (typeof entry.r !== 'undefined')
3768+ {
3769+ _Lynx_removeElement(_Lynx_getParent(domNode), domNode);
3770+ }
3771+ entry.s = _VirtualDom_applyPatchesHelp(domNode, data.w);
3772+ return domNode;
3773+
3774+ case 8:
3775+ return _VirtualDom_applyPatchReorder(domNode, patch);
3776+
3777+ case 5:
3778+ return patch.s(domNode);
3779+
3780+ default:
3781+ throw new Error('VirtualDom: unknown patch type');
3782+ }
3783+}
3784+
3785+
3786+function _VirtualDom_applyPatchRedraw(domNode, vNode, eventNode)
3787+{
3788+ var parentNode = _Lynx_getParent(domNode);
3789+ var newNode = _VirtualDom_render(vNode, eventNode);
3790+
3791+ if (!_VirtualDom_getMeta(newNode).elm_event_node_ref)
3792+ {
3793+ _VirtualDom_getMeta(newNode).elm_event_node_ref = _VirtualDom_getMeta(domNode).elm_event_node_ref;
3794+ }
3795+
3796+ if (parentNode && newNode !== domNode)
3797+ {
3798+ _Lynx_replaceElement(parentNode, newNode, domNode);
3799+ }
3800+ return newNode;
3801+}
3802+
3803+
3804+function _VirtualDom_applyPatchReorder(domNode, patch)
3805+{
3806+ var data = patch.s;
3807+
3808+ // remove end inserts
3809+ var endInsertNodes = _VirtualDom_applyPatchReorderEndInsertsHelp(data.y, patch);
3810+
3811+ // removals
3812+ domNode = _VirtualDom_applyPatchesHelp(domNode, data.w);
3813+
3814+ // inserts
3815+ var inserts = data.x;
3816+ for (var i = 0; i < inserts.length; i++)
3817+ {
3818+ var insert = inserts[i];
3819+ var entry = insert.A;
3820+ var node = entry.c === 2
3821+ ? entry.s
3822+ : _VirtualDom_render(entry.z, patch.u);
3823+ var children = _Lynx_getChildren(domNode);
3824+ _Lynx_insertBefore(domNode, node, children[insert.r]);
3825+ }
3826+
3827+ // add end inserts
3828+ if (endInsertNodes)
3829+ {
3830+ for (var i = 0; i < endInsertNodes.length; i++)
3831+ {
3832+ _Lynx_appendChild(domNode, endInsertNodes[i]);
3833+ }
3834+ }
3835+
3836+ return domNode;
3837+}
3838+
3839+
3840+function _VirtualDom_applyPatchReorderEndInsertsHelp(endInserts, patch)
3841+{
3842+ if (!endInserts)
3843+ {
3844+ return;
3845+ }
3846+
3847+ var nodes = [];
3848+ for (var i = 0; i < endInserts.length; i++)
3849+ {
3850+ var insert = endInserts[i];
3851+ var entry = insert.A;
3852+ nodes.push(entry.c === 2
3853+ ? entry.s
3854+ : _VirtualDom_render(entry.z, patch.u)
3855+ );
3856+ }
3857+ return nodes;
3858+}
3859+
3860+
3861+function _VirtualDom_dekey(keyedNode)
3862+{
3863+ var keyedKids = keyedNode.e;
3864+ var len = keyedKids.length;
3865+ var kids = new Array(len);
3866+ for (var i = 0; i < len; i++)
3867+ {
3868+ kids[i] = keyedKids[i].b;
3869+ }
3870+
3871+ return {
3872+ $: 1,
3873+ c: keyedNode.c,
3874+ d: keyedNode.d,
3875+ e: kids,
3876+ f: keyedNode.f,
3877+ b: keyedNode.b
3878+ };
3879+}
3880+
3881+
3882+
3883+// LYNXJS PAPI WRAPPERS
3884+var _Browser_lynx = (typeof globalThis !== 'undefined' ? globalThis : scope);
3885+function _Browser_newPage() {
3886+ return _Browser_lynx['page'];
3887+}
3888+function _Browser_flush() {
3889+ var fn = _Browser_lynx['_' + '_FlushElementTree'];
3890+ if (typeof fn === 'function') { fn(); }
3891+}
3892+
3893+
3894+
3895+// ELEMENT
3896+
3897+
3898+var _Browser_element = F4(function(impl, flagDecoder, debugMetadata, args)
3899+{
3900+ return _Platform_initialize(
3901+ flagDecoder,
3902+ args,
3903+ impl.init,
3904+ impl.update,
3905+ impl.subscriptions,
3906+ function(sendToApp, initialModel) {
3907+ var view = impl.view;
3908+ var domNode = args['node'] || _Browser_newPage();
3909+ var currNode = view(initialModel);
3910+ var currDomNode = _VirtualDom_render(currNode, sendToApp);
3911+ _VirtualDom_appendChild(domNode, currDomNode);
3912+ _Browser_flush();
3913+
3914+ return _Browser_makeAnimator(initialModel, function(model)
3915+ {
3916+ var nextNode = view(model);
3917+ var patches = _VirtualDom_diff(currNode, nextNode);
3918+ currDomNode = _VirtualDom_applyPatches(currDomNode, currNode, patches, sendToApp);
3919+ currNode = nextNode;
3920+ _Browser_flush();
3921+ });
3922+ }
3923+ );
3924+});
3925+
3926+
3927+
3928+// DOCUMENT
3929+
3930+
3931+var _Browser_document = F4(function(impl, flagDecoder, debugMetadata, args)
3932+{
3933+ return _Platform_initialize(
3934+ flagDecoder,
3935+ args,
3936+ impl.init,
3937+ impl.update,
3938+ impl.subscriptions,
3939+ function(sendToApp, initialModel) {
3940+ var view = impl.view;
3941+ var rootNode = args['node'] || _Browser_newPage();
3942+ var doc = view(initialModel);
3943+ var currNode = _VirtualDom_node('view')(_List_Nil)(doc.body);
3944+ var currDomNode = _VirtualDom_render(currNode, sendToApp);
3945+ _VirtualDom_appendChild(rootNode, currDomNode);
3946+ _Browser_flush();
3947+
3948+ return _Browser_makeAnimator(initialModel, function(model)
3949+ {
3950+ var doc = view(model);
3951+ var nextNode = _VirtualDom_node('view')(_List_Nil)(doc.body);
3952+ var patches = _VirtualDom_diff(currNode, nextNode);
3953+ currDomNode = _VirtualDom_applyPatches(currDomNode, currNode, patches, sendToApp);
3954+ currNode = nextNode;
3955+ _Browser_flush();
3956+ });
3957+ }
3958+ );
3959+});
3960+
3961+
3962+
3963+// ANIMATION
3964+
3965+
3966+var _Browser_cancelAnimationFrame =
3967+ function(id) { clearTimeout(id); };
3968+
3969+var _Browser_requestAnimationFrame =
3970+ function(callback) { return setTimeout(callback, 1000 / 60); };
3971+
3972+
3973+function _Browser_makeAnimator(model, draw)
3974+{
3975+ draw(model);
3976+
3977+ var state = 0;
3978+
3979+ function updateIfNeeded()
3980+ {
3981+ state = state === 1
3982+ ? 0
3983+ : ( _Browser_requestAnimationFrame(updateIfNeeded), draw(model), 1 );
3984+ }
3985+
3986+ return function(nextModel, isSync)
3987+ {
3988+ model = nextModel;
3989+
3990+ isSync
3991+ ? ( draw(model),
3992+ state === 2 && (state = 1)
3993+ )
3994+ : ( state === 0 && _Browser_requestAnimationFrame(updateIfNeeded),
3995+ state = 2
3996+ );
3997+ };
3998+}
3999+
4000+
4001+
4002+// APPLICATION
4003+
4004+
4005+function _Browser_application(impl)
4006+{
4007+ return _Browser_document({
4008+ init: function(flags)
4009+ {
4010+ return A3(impl.init, flags, _Browser_fakeUrl(), {});
4011+ },
4012+ view: impl.view,
4013+ update: impl.update,
4014+ subscriptions: impl.subscriptions
4015+ });
4016+}
4017+
4018+function _Browser_fakeUrl()
4019+{
4020+ return {
4021+ protocol: { $: 0 },
4022+ host: 'localhost',
4023+ port_: { $: 1 },
4024+ path: '/',
4025+ query: { $: 1 },
4026+ fragment: { $: 1 }
4027+ };
4028+}
4029+
4030+
4031+
4032+var _Browser_go = F2(function(key, n)
4033+{
4034+ return A2($elm$core$Task$perform, $elm$core$Basics$never, _Scheduler_binding(function() {
4035+ // no-op in LynxJS
4036+ key();
4037+ }));
4038+});
4039+
4040+var _Browser_pushUrl = F2(function(key, url)
4041+{
4042+ return A2($elm$core$Task$perform, $elm$core$Basics$never, _Scheduler_binding(function() {
4043+ // no-op in LynxJS
4044+ key();
4045+ }));
4046+});
4047+
4048+var _Browser_replaceUrl = F2(function(key, url)
4049+{
4050+ return A2($elm$core$Task$perform, $elm$core$Basics$never, _Scheduler_binding(function() {
4051+ // no-op in LynxJS
4052+ key();
4053+ }));
4054+});
4055+
4056+
4057+
4058+// GLOBAL EVENTS
4059+
4060+
4061+var _Browser_fakeNode = { addEventListener: function() {}, removeEventListener: function() {} };
4062+var _Browser_doc = typeof document !== 'undefined' ? document : _Browser_fakeNode;
4063+var _Browser_window = typeof window !== 'undefined' ? window : _Browser_fakeNode;
4064+
4065+var _Browser_on = F3(function(node, eventName, sendToSelf)
4066+{
4067+ return _Scheduler_spawn(_Scheduler_binding(function(callback)
4068+ {
4069+ return function() {};
4070+ }));
4071+});
4072+
4073+var _Browser_decodeEvent = F2(function(decoder, event)
4074+{
4075+ var result = _Json_runHelp(decoder, event);
4076+ return $elm$core$Result$isOk(result) ? $elm$core$Maybe$Just(result.a) : $elm$core$Maybe$Nothing;
4077+});
4078+
4079+
4080+
4081+// PAGE VISIBILITY
4082+
4083+
4084+function _Browser_visibilityInfo()
4085+{
4086+ return (typeof _VirtualDom_doc.hidden !== 'undefined')
4087+ ? { hidden: 'hidden', change: 'visibilitychange' }
4088+ :
4089+ (typeof _VirtualDom_doc.mozHidden !== 'undefined')
4090+ ? { hidden: 'mozHidden', change: 'mozvisibilitychange' }
4091+ :
4092+ (typeof _VirtualDom_doc.msHidden !== 'undefined')
4093+ ? { hidden: 'msHidden', change: 'msvisibilitychange' }
4094+ :
4095+ (typeof _VirtualDom_doc.webkitHidden !== 'undefined')
4096+ ? { hidden: 'webkitHidden', change: 'webkitvisibilitychange' }
4097+ : { hidden: 'hidden', change: 'visibilitychange' };
4098+}
4099+
4100+
4101+
4102+// ANIMATION FRAMES
4103+
4104+
4105+function _Browser_rAF()
4106+{
4107+ return _Scheduler_binding(function(callback)
4108+ {
4109+ var id = _Browser_requestAnimationFrame(function() {
4110+ callback(_Scheduler_succeed(Date.now()));
4111+ });
4112+
4113+ return function() {
4114+ _Browser_cancelAnimationFrame(id);
4115+ };
4116+ });
4117+}
4118+
4119+
4120+function _Browser_now()
4121+{
4122+ return _Scheduler_binding(function(callback)
4123+ {
4124+ callback(_Scheduler_succeed(Date.now()));
4125+ });
4126+}
4127+
4128+
4129+
4130+// DOM STUFF
4131+
4132+
4133+function _Browser_withNode(id, doStuff)
4134+{
4135+ return _Scheduler_binding(function(callback)
4136+ {
4137+ callback(_Scheduler_fail($lynxjs_elm$browser$Browser$Dom$NotFound(id)));
4138+ });
4139+}
4140+
4141+
4142+function _Browser_withWindow(doStuff)
4143+{
4144+ return _Scheduler_binding(function(callback)
4145+ {
4146+ _Browser_requestAnimationFrame(function() {
4147+ callback(_Scheduler_succeed(doStuff()));
4148+ });
4149+ });
4150+}
4151+
4152+
4153+// FOCUS and BLUR
4154+
4155+
4156+var _Browser_call = F2(function(functionName, id)
4157+{
4158+ return _Browser_withNode(id, function(node) {
4159+ node[functionName]();
4160+ return _Utils_Tuple0;
4161+ });
4162+});
4163+
4164+
4165+
4166+// WINDOW VIEWPORT
4167+
4168+
4169+function _Browser_getViewport()
4170+{
4171+ return {
4172+ scene: _Browser_getScene(),
4173+ viewport: {
4174+ x: _Browser_window.pageXOffset,
4175+ y: _Browser_window.pageYOffset,
4176+ width: _Browser_doc.documentElement.clientWidth,
4177+ height: _Browser_doc.documentElement.clientHeight
4178+ }
4179+ };
4180+}
4181+
4182+function _Browser_getScene()
4183+{
4184+ var body = _Browser_doc.body;
4185+ var elem = _Browser_doc.documentElement;
4186+ return {
4187+ width: Math.max(body.scrollWidth, body.offsetWidth, elem.scrollWidth, elem.offsetWidth, elem.clientWidth),
4188+ height: Math.max(body.scrollHeight, body.offsetHeight, elem.scrollHeight, elem.offsetHeight, elem.clientHeight)
4189+ };
4190+}
4191+
4192+var _Browser_setViewport = F2(function(x, y)
4193+{
4194+ return _Browser_withWindow(function()
4195+ {
4196+ _Browser_window.scroll(x, y);
4197+ return _Utils_Tuple0;
4198+ });
4199+});
4200+
4201+
4202+
4203+// ELEMENT VIEWPORT
4204+
4205+
4206+function _Browser_getViewportOf(id)
4207+{
4208+ return _Browser_withNode(id, function(node)
4209+ {
4210+ return {
4211+ scene: {
4212+ width: node.scrollWidth,
4213+ height: node.scrollHeight
4214+ },
4215+ viewport: {
4216+ x: node.scrollLeft,
4217+ y: node.scrollTop,
4218+ width: node.clientWidth,
4219+ height: node.clientHeight
4220+ }
4221+ };
4222+ });
4223+}
4224+
4225+
4226+var _Browser_setViewportOf = F3(function(id, x, y)
4227+{
4228+ return _Browser_withNode(id, function(node)
4229+ {
4230+ node.scrollLeft = x;
4231+ node.scrollTop = y;
4232+ return _Utils_Tuple0;
4233+ });
4234+});
4235+
4236+
4237+
4238+// ELEMENT
4239+
4240+
4241+function _Browser_getElement(id)
4242+{
4243+ return _Browser_withNode(id, function(node)
4244+ {
4245+ var rect = node.getBoundingClientRect();
4246+ var x = _Browser_window.pageXOffset;
4247+ var y = _Browser_window.pageYOffset;
4248+ return {
4249+ scene: _Browser_getScene(),
4250+ viewport: {
4251+ x: x,
4252+ y: y,
4253+ width: _Browser_doc.documentElement.clientWidth,
4254+ height: _Browser_doc.documentElement.clientHeight
4255+ },
4256+ element: {
4257+ x: x + rect.left,
4258+ y: y + rect.top,
4259+ width: rect.width,
4260+ height: rect.height
4261+ }
4262+ };
4263+ });
4264+}
4265+
4266+
4267+
4268+// LOAD and RELOAD
4269+
4270+
4271+function _Browser_reload(skipCache)
4272+{
4273+ return A2($elm$core$Task$perform, $elm$core$Basics$never, _Scheduler_binding(function(callback)
4274+ {
4275+ // no-op in LynxJS
4276+ }));
4277+}
4278+
4279+function _Browser_load(url)
4280+{
4281+ return A2($elm$core$Task$perform, $elm$core$Basics$never, _Scheduler_binding(function(callback)
4282+ {
4283+ try
4284+ {
4285+ // no-op in LynxJS
4286+ }
4287+ catch(err)
4288+ {
4289+ // Only Firefox can throw a NS_ERROR_MALFORMED_URI exception here.
4290+ // Other browsers reload the page, so let's be consistent about that.
4291+ // no-op in LynxJS
4292+ }
4293+ }));
4294+}
4295+var $elm$core$Maybe$Nothing = {$: 'Nothing'};
4296+var $author$project$Main$init = {selected: $elm$core$Maybe$Nothing};
4297+var $elm$core$List$cons = _List_cons;
4298+var $elm$core$Elm$JsArray$foldr = _JsArray_foldr;
4299+var $elm$core$Array$foldr = F3(
4300+ function (func, baseCase, _v0) {
4301+ var tree = _v0.c;
4302+ var tail = _v0.d;
4303+ var helper = F2(
4304+ function (node, acc) {
4305+ if (node.$ === 'SubTree') {
4306+ var subTree = node.a;
4307+ return A3($elm$core$Elm$JsArray$foldr, helper, acc, subTree);
4308+ } else {
4309+ var values = node.a;
4310+ return A3($elm$core$Elm$JsArray$foldr, func, acc, values);
4311+ }
4312+ });
4313+ return A3(
4314+ $elm$core$Elm$JsArray$foldr,
4315+ helper,
4316+ A3($elm$core$Elm$JsArray$foldr, func, baseCase, tail),
4317+ tree);
4318+ });
4319+var $elm$core$Array$toList = function (array) {
4320+ return A3($elm$core$Array$foldr, $elm$core$List$cons, _List_Nil, array);
4321+};
4322+var $elm$core$Dict$foldr = F3(
4323+ function (func, acc, t) {
4324+ foldr:
4325+ while (true) {
4326+ if (t.$ === 'RBEmpty_elm_builtin') {
4327+ return acc;
4328+ } else {
4329+ var key = t.b;
4330+ var value = t.c;
4331+ var left = t.d;
4332+ var right = t.e;
4333+ var $temp$func = func,
4334+ $temp$acc = A3(
4335+ func,
4336+ key,
4337+ value,
4338+ A3($elm$core$Dict$foldr, func, acc, right)),
4339+ $temp$t = left;
4340+ func = $temp$func;
4341+ acc = $temp$acc;
4342+ t = $temp$t;
4343+ continue foldr;
4344+ }
4345+ }
4346+ });
4347+var $elm$core$Dict$toList = function (dict) {
4348+ return A3(
4349+ $elm$core$Dict$foldr,
4350+ F3(
4351+ function (key, value, list) {
4352+ return A2(
4353+ $elm$core$List$cons,
4354+ _Utils_Tuple2(key, value),
4355+ list);
4356+ }),
4357+ _List_Nil,
4358+ dict);
4359+};
4360+var $elm$core$Dict$keys = function (dict) {
4361+ return A3(
4362+ $elm$core$Dict$foldr,
4363+ F3(
4364+ function (key, value, keyList) {
4365+ return A2($elm$core$List$cons, key, keyList);
4366+ }),
4367+ _List_Nil,
4368+ dict);
4369+};
4370+var $elm$core$Set$toList = function (_v0) {
4371+ var dict = _v0.a;
4372+ return $elm$core$Dict$keys(dict);
4373+};
4374+var $elm$core$Basics$EQ = {$: 'EQ'};
4375+var $elm$core$Basics$GT = {$: 'GT'};
4376+var $elm$core$Basics$LT = {$: 'LT'};
4377+var $elm$core$Result$Err = function (a) {
4378+ return {$: 'Err', a: a};
4379+};
4380+var $elm$json$Json$Decode$Failure = F2(
4381+ function (a, b) {
4382+ return {$: 'Failure', a: a, b: b};
4383+ });
4384+var $elm$json$Json$Decode$Field = F2(
4385+ function (a, b) {
4386+ return {$: 'Field', a: a, b: b};
4387+ });
4388+var $elm$json$Json$Decode$Index = F2(
4389+ function (a, b) {
4390+ return {$: 'Index', a: a, b: b};
4391+ });
4392+var $elm$core$Result$Ok = function (a) {
4393+ return {$: 'Ok', a: a};
4394+};
4395+var $elm$json$Json$Decode$OneOf = function (a) {
4396+ return {$: 'OneOf', a: a};
4397+};
4398+var $elm$core$Basics$False = {$: 'False'};
4399+var $elm$core$Basics$add = _Basics_add;
4400+var $elm$core$Maybe$Just = function (a) {
4401+ return {$: 'Just', a: a};
4402+};
4403+var $elm$core$String$all = _String_all;
4404+var $elm$core$Basics$and = _Basics_and;
4405+var $elm$core$Basics$append = _Utils_append;
4406+var $elm$json$Json$Encode$encode = _Json_encode;
4407+var $elm$core$String$fromInt = _String_fromNumber;
4408+var $elm$core$String$join = F2(
4409+ function (sep, chunks) {
4410+ return A2(
4411+ _String_join,
4412+ sep,
4413+ _List_toArray(chunks));
4414+ });
4415+var $elm$core$String$split = F2(
4416+ function (sep, string) {
4417+ return _List_fromArray(
4418+ A2(_String_split, sep, string));
4419+ });
4420+var $elm$json$Json$Decode$indent = function (str) {
4421+ return A2(
4422+ $elm$core$String$join,
4423+ '\n ',
4424+ A2($elm$core$String$split, '\n', str));
4425+};
4426+var $elm$core$List$foldl = F3(
4427+ function (func, acc, list) {
4428+ foldl:
4429+ while (true) {
4430+ if (!list.b) {
4431+ return acc;
4432+ } else {
4433+ var x = list.a;
4434+ var xs = list.b;
4435+ var $temp$func = func,
4436+ $temp$acc = A2(func, x, acc),
4437+ $temp$list = xs;
4438+ func = $temp$func;
4439+ acc = $temp$acc;
4440+ list = $temp$list;
4441+ continue foldl;
4442+ }
4443+ }
4444+ });
4445+var $elm$core$List$length = function (xs) {
4446+ return A3(
4447+ $elm$core$List$foldl,
4448+ F2(
4449+ function (_v0, i) {
4450+ return i + 1;
4451+ }),
4452+ 0,
4453+ xs);
4454+};
4455+var $elm$core$List$map2 = _List_map2;
4456+var $elm$core$Basics$le = _Utils_le;
4457+var $elm$core$Basics$sub = _Basics_sub;
4458+var $elm$core$List$rangeHelp = F3(
4459+ function (lo, hi, list) {
4460+ rangeHelp:
4461+ while (true) {
4462+ if (_Utils_cmp(lo, hi) < 1) {
4463+ var $temp$lo = lo,
4464+ $temp$hi = hi - 1,
4465+ $temp$list = A2($elm$core$List$cons, hi, list);
4466+ lo = $temp$lo;
4467+ hi = $temp$hi;
4468+ list = $temp$list;
4469+ continue rangeHelp;
4470+ } else {
4471+ return list;
4472+ }
4473+ }
4474+ });
4475+var $elm$core$List$range = F2(
4476+ function (lo, hi) {
4477+ return A3($elm$core$List$rangeHelp, lo, hi, _List_Nil);
4478+ });
4479+var $elm$core$List$indexedMap = F2(
4480+ function (f, xs) {
4481+ return A3(
4482+ $elm$core$List$map2,
4483+ f,
4484+ A2(
4485+ $elm$core$List$range,
4486+ 0,
4487+ $elm$core$List$length(xs) - 1),
4488+ xs);
4489+ });
4490+var $elm$core$Char$toCode = _Char_toCode;
4491+var $elm$core$Char$isLower = function (_char) {
4492+ var code = $elm$core$Char$toCode(_char);
4493+ return (97 <= code) && (code <= 122);
4494+};
4495+var $elm$core$Char$isUpper = function (_char) {
4496+ var code = $elm$core$Char$toCode(_char);
4497+ return (code <= 90) && (65 <= code);
4498+};
4499+var $elm$core$Basics$or = _Basics_or;
4500+var $elm$core$Char$isAlpha = function (_char) {
4501+ return $elm$core$Char$isLower(_char) || $elm$core$Char$isUpper(_char);
4502+};
4503+var $elm$core$Char$isDigit = function (_char) {
4504+ var code = $elm$core$Char$toCode(_char);
4505+ return (code <= 57) && (48 <= code);
4506+};
4507+var $elm$core$Char$isAlphaNum = function (_char) {
4508+ return $elm$core$Char$isLower(_char) || ($elm$core$Char$isUpper(_char) || $elm$core$Char$isDigit(_char));
4509+};
4510+var $elm$core$List$reverse = function (list) {
4511+ return A3($elm$core$List$foldl, $elm$core$List$cons, _List_Nil, list);
4512+};
4513+var $elm$core$String$uncons = _String_uncons;
4514+var $elm$json$Json$Decode$errorOneOf = F2(
4515+ function (i, error) {
4516+ return '\n\n(' + ($elm$core$String$fromInt(i + 1) + (') ' + $elm$json$Json$Decode$indent(
4517+ $elm$json$Json$Decode$errorToString(error))));
4518+ });
4519+var $elm$json$Json$Decode$errorToString = function (error) {
4520+ return A2($elm$json$Json$Decode$errorToStringHelp, error, _List_Nil);
4521+};
4522+var $elm$json$Json$Decode$errorToStringHelp = F2(
4523+ function (error, context) {
4524+ errorToStringHelp:
4525+ while (true) {
4526+ switch (error.$) {
4527+ case 'Field':
4528+ var f = error.a;
4529+ var err = error.b;
4530+ var isSimple = function () {
4531+ var _v1 = $elm$core$String$uncons(f);
4532+ if (_v1.$ === 'Nothing') {
4533+ return false;
4534+ } else {
4535+ var _v2 = _v1.a;
4536+ var _char = _v2.a;
4537+ var rest = _v2.b;
4538+ return $elm$core$Char$isAlpha(_char) && A2($elm$core$String$all, $elm$core$Char$isAlphaNum, rest);
4539+ }
4540+ }();
4541+ var fieldName = isSimple ? ('.' + f) : ('[\'' + (f + '\']'));
4542+ var $temp$error = err,
4543+ $temp$context = A2($elm$core$List$cons, fieldName, context);
4544+ error = $temp$error;
4545+ context = $temp$context;
4546+ continue errorToStringHelp;
4547+ case 'Index':
4548+ var i = error.a;
4549+ var err = error.b;
4550+ var indexName = '[' + ($elm$core$String$fromInt(i) + ']');
4551+ var $temp$error = err,
4552+ $temp$context = A2($elm$core$List$cons, indexName, context);
4553+ error = $temp$error;
4554+ context = $temp$context;
4555+ continue errorToStringHelp;
4556+ case 'OneOf':
4557+ var errors = error.a;
4558+ if (!errors.b) {
4559+ return 'Ran into a Json.Decode.oneOf with no possibilities' + function () {
4560+ if (!context.b) {
4561+ return '!';
4562+ } else {
4563+ return ' at json' + A2(
4564+ $elm$core$String$join,
4565+ '',
4566+ $elm$core$List$reverse(context));
4567+ }
4568+ }();
4569+ } else {
4570+ if (!errors.b.b) {
4571+ var err = errors.a;
4572+ var $temp$error = err,
4573+ $temp$context = context;
4574+ error = $temp$error;
4575+ context = $temp$context;
4576+ continue errorToStringHelp;
4577+ } else {
4578+ var starter = function () {
4579+ if (!context.b) {
4580+ return 'Json.Decode.oneOf';
4581+ } else {
4582+ return 'The Json.Decode.oneOf at json' + A2(
4583+ $elm$core$String$join,
4584+ '',
4585+ $elm$core$List$reverse(context));
4586+ }
4587+ }();
4588+ var introduction = starter + (' failed in the following ' + ($elm$core$String$fromInt(
4589+ $elm$core$List$length(errors)) + ' ways:'));
4590+ return A2(
4591+ $elm$core$String$join,
4592+ '\n\n',
4593+ A2(
4594+ $elm$core$List$cons,
4595+ introduction,
4596+ A2($elm$core$List$indexedMap, $elm$json$Json$Decode$errorOneOf, errors)));
4597+ }
4598+ }
4599+ default:
4600+ var msg = error.a;
4601+ var json = error.b;
4602+ var introduction = function () {
4603+ if (!context.b) {
4604+ return 'Problem with the given value:\n\n';
4605+ } else {
4606+ return 'Problem with the value at json' + (A2(
4607+ $elm$core$String$join,
4608+ '',
4609+ $elm$core$List$reverse(context)) + ':\n\n ');
4610+ }
4611+ }();
4612+ return introduction + ($elm$json$Json$Decode$indent(
4613+ A2($elm$json$Json$Encode$encode, 4, json)) + ('\n\n' + msg));
4614+ }
4615+ }
4616+ });
4617+var $elm$core$Array$branchFactor = 32;
4618+var $elm$core$Array$Array_elm_builtin = F4(
4619+ function (a, b, c, d) {
4620+ return {$: 'Array_elm_builtin', a: a, b: b, c: c, d: d};
4621+ });
4622+var $elm$core$Elm$JsArray$empty = _JsArray_empty;
4623+var $elm$core$Basics$ceiling = _Basics_ceiling;
4624+var $elm$core$Basics$fdiv = _Basics_fdiv;
4625+var $elm$core$Basics$logBase = F2(
4626+ function (base, number) {
4627+ return _Basics_log(number) / _Basics_log(base);
4628+ });
4629+var $elm$core$Basics$toFloat = _Basics_toFloat;
4630+var $elm$core$Array$shiftStep = $elm$core$Basics$ceiling(
4631+ A2($elm$core$Basics$logBase, 2, $elm$core$Array$branchFactor));
4632+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);
4633+var $elm$core$Elm$JsArray$initialize = _JsArray_initialize;
4634+var $elm$core$Array$Leaf = function (a) {
4635+ return {$: 'Leaf', a: a};
4636+};
4637+var $elm$core$Basics$apL = F2(
4638+ function (f, x) {
4639+ return f(x);
4640+ });
4641+var $elm$core$Basics$apR = F2(
4642+ function (x, f) {
4643+ return f(x);
4644+ });
4645+var $elm$core$Basics$eq = _Utils_equal;
4646+var $elm$core$Basics$floor = _Basics_floor;
4647+var $elm$core$Elm$JsArray$length = _JsArray_length;
4648+var $elm$core$Basics$gt = _Utils_gt;
4649+var $elm$core$Basics$max = F2(
4650+ function (x, y) {
4651+ return (_Utils_cmp(x, y) > 0) ? x : y;
4652+ });
4653+var $elm$core$Basics$mul = _Basics_mul;
4654+var $elm$core$Array$SubTree = function (a) {
4655+ return {$: 'SubTree', a: a};
4656+};
4657+var $elm$core$Elm$JsArray$initializeFromList = _JsArray_initializeFromList;
4658+var $elm$core$Array$compressNodes = F2(
4659+ function (nodes, acc) {
4660+ compressNodes:
4661+ while (true) {
4662+ var _v0 = A2($elm$core$Elm$JsArray$initializeFromList, $elm$core$Array$branchFactor, nodes);
4663+ var node = _v0.a;
4664+ var remainingNodes = _v0.b;
4665+ var newAcc = A2(
4666+ $elm$core$List$cons,
4667+ $elm$core$Array$SubTree(node),
4668+ acc);
4669+ if (!remainingNodes.b) {
4670+ return $elm$core$List$reverse(newAcc);
4671+ } else {
4672+ var $temp$nodes = remainingNodes,
4673+ $temp$acc = newAcc;
4674+ nodes = $temp$nodes;
4675+ acc = $temp$acc;
4676+ continue compressNodes;
4677+ }
4678+ }
4679+ });
4680+var $elm$core$Tuple$first = function (_v0) {
4681+ var x = _v0.a;
4682+ return x;
4683+};
4684+var $elm$core$Array$treeFromBuilder = F2(
4685+ function (nodeList, nodeListSize) {
4686+ treeFromBuilder:
4687+ while (true) {
4688+ var newNodeSize = $elm$core$Basics$ceiling(nodeListSize / $elm$core$Array$branchFactor);
4689+ if (newNodeSize === 1) {
4690+ return A2($elm$core$Elm$JsArray$initializeFromList, $elm$core$Array$branchFactor, nodeList).a;
4691+ } else {
4692+ var $temp$nodeList = A2($elm$core$Array$compressNodes, nodeList, _List_Nil),
4693+ $temp$nodeListSize = newNodeSize;
4694+ nodeList = $temp$nodeList;
4695+ nodeListSize = $temp$nodeListSize;
4696+ continue treeFromBuilder;
4697+ }
4698+ }
4699+ });
4700+var $elm$core$Array$builderToArray = F2(
4701+ function (reverseNodeList, builder) {
4702+ if (!builder.nodeListSize) {
4703+ return A4(
4704+ $elm$core$Array$Array_elm_builtin,
4705+ $elm$core$Elm$JsArray$length(builder.tail),
4706+ $elm$core$Array$shiftStep,
4707+ $elm$core$Elm$JsArray$empty,
4708+ builder.tail);
4709+ } else {
4710+ var treeLen = builder.nodeListSize * $elm$core$Array$branchFactor;
4711+ var depth = $elm$core$Basics$floor(
4712+ A2($elm$core$Basics$logBase, $elm$core$Array$branchFactor, treeLen - 1));
4713+ var correctNodeList = reverseNodeList ? $elm$core$List$reverse(builder.nodeList) : builder.nodeList;
4714+ var tree = A2($elm$core$Array$treeFromBuilder, correctNodeList, builder.nodeListSize);
4715+ return A4(
4716+ $elm$core$Array$Array_elm_builtin,
4717+ $elm$core$Elm$JsArray$length(builder.tail) + treeLen,
4718+ A2($elm$core$Basics$max, 5, depth * $elm$core$Array$shiftStep),
4719+ tree,
4720+ builder.tail);
4721+ }
4722+ });
4723+var $elm$core$Basics$idiv = _Basics_idiv;
4724+var $elm$core$Basics$lt = _Utils_lt;
4725+var $elm$core$Array$initializeHelp = F5(
4726+ function (fn, fromIndex, len, nodeList, tail) {
4727+ initializeHelp:
4728+ while (true) {
4729+ if (fromIndex < 0) {
4730+ return A2(
4731+ $elm$core$Array$builderToArray,
4732+ false,
4733+ {nodeList: nodeList, nodeListSize: (len / $elm$core$Array$branchFactor) | 0, tail: tail});
4734+ } else {
4735+ var leaf = $elm$core$Array$Leaf(
4736+ A3($elm$core$Elm$JsArray$initialize, $elm$core$Array$branchFactor, fromIndex, fn));
4737+ var $temp$fn = fn,
4738+ $temp$fromIndex = fromIndex - $elm$core$Array$branchFactor,
4739+ $temp$len = len,
4740+ $temp$nodeList = A2($elm$core$List$cons, leaf, nodeList),
4741+ $temp$tail = tail;
4742+ fn = $temp$fn;
4743+ fromIndex = $temp$fromIndex;
4744+ len = $temp$len;
4745+ nodeList = $temp$nodeList;
4746+ tail = $temp$tail;
4747+ continue initializeHelp;
4748+ }
4749+ }
4750+ });
4751+var $elm$core$Basics$remainderBy = _Basics_remainderBy;
4752+var $elm$core$Array$initialize = F2(
4753+ function (len, fn) {
4754+ if (len <= 0) {
4755+ return $elm$core$Array$empty;
4756+ } else {
4757+ var tailLen = len % $elm$core$Array$branchFactor;
4758+ var tail = A3($elm$core$Elm$JsArray$initialize, tailLen, len - tailLen, fn);
4759+ var initialFromIndex = (len - tailLen) - $elm$core$Array$branchFactor;
4760+ return A5($elm$core$Array$initializeHelp, fn, initialFromIndex, len, _List_Nil, tail);
4761+ }
4762+ });
4763+var $elm$core$Basics$True = {$: 'True'};
4764+var $elm$core$Result$isOk = function (result) {
4765+ if (result.$ === 'Ok') {
4766+ return true;
4767+ } else {
4768+ return false;
4769+ }
4770+};
4771+var $elm$json$Json$Decode$map = _Json_map1;
4772+var $elm$json$Json$Decode$map2 = _Json_map2;
4773+var $elm$json$Json$Decode$succeed = _Json_succeed;
4774+var $lynxjs_elm$virtual_dom$VirtualDom$toHandlerInt = function (handler) {
4775+ switch (handler.$) {
4776+ case 'Normal':
4777+ return 0;
4778+ case 'MayStopPropagation':
4779+ return 1;
4780+ case 'MayPreventDefault':
4781+ return 2;
4782+ default:
4783+ return 3;
4784+ }
4785+};
4786+var $elm$core$Basics$identity = function (x) {
4787+ return x;
4788+};
4789+var $lynxjs_elm$browser$Browser$Dom$NotFound = function (a) {
4790+ return {$: 'NotFound', a: a};
4791+};
4792+var $elm$core$Basics$never = function (_v0) {
4793+ never:
4794+ while (true) {
4795+ var nvr = _v0.a;
4796+ var $temp$_v0 = nvr;
4797+ _v0 = $temp$_v0;
4798+ continue never;
4799+ }
4800+};
4801+var $elm$core$Task$Perform = function (a) {
4802+ return {$: 'Perform', a: a};
4803+};
4804+var $elm$core$Task$succeed = _Scheduler_succeed;
4805+var $elm$core$Task$init = $elm$core$Task$succeed(_Utils_Tuple0);
4806+var $elm$core$List$foldrHelper = F4(
4807+ function (fn, acc, ctr, ls) {
4808+ if (!ls.b) {
4809+ return acc;
4810+ } else {
4811+ var a = ls.a;
4812+ var r1 = ls.b;
4813+ if (!r1.b) {
4814+ return A2(fn, a, acc);
4815+ } else {
4816+ var b = r1.a;
4817+ var r2 = r1.b;
4818+ if (!r2.b) {
4819+ return A2(
4820+ fn,
4821+ a,
4822+ A2(fn, b, acc));
4823+ } else {
4824+ var c = r2.a;
4825+ var r3 = r2.b;
4826+ if (!r3.b) {
4827+ return A2(
4828+ fn,
4829+ a,
4830+ A2(
4831+ fn,
4832+ b,
4833+ A2(fn, c, acc)));
4834+ } else {
4835+ var d = r3.a;
4836+ var r4 = r3.b;
4837+ var res = (ctr > 500) ? A3(
4838+ $elm$core$List$foldl,
4839+ fn,
4840+ acc,
4841+ $elm$core$List$reverse(r4)) : A4($elm$core$List$foldrHelper, fn, acc, ctr + 1, r4);
4842+ return A2(
4843+ fn,
4844+ a,
4845+ A2(
4846+ fn,
4847+ b,
4848+ A2(
4849+ fn,
4850+ c,
4851+ A2(fn, d, res))));
4852+ }
4853+ }
4854+ }
4855+ }
4856+ });
4857+var $elm$core$List$foldr = F3(
4858+ function (fn, acc, ls) {
4859+ return A4($elm$core$List$foldrHelper, fn, acc, 0, ls);
4860+ });
4861+var $elm$core$List$map = F2(
4862+ function (f, xs) {
4863+ return A3(
4864+ $elm$core$List$foldr,
4865+ F2(
4866+ function (x, acc) {
4867+ return A2(
4868+ $elm$core$List$cons,
4869+ f(x),
4870+ acc);
4871+ }),
4872+ _List_Nil,
4873+ xs);
4874+ });
4875+var $elm$core$Task$andThen = _Scheduler_andThen;
4876+var $elm$core$Task$map = F2(
4877+ function (func, taskA) {
4878+ return A2(
4879+ $elm$core$Task$andThen,
4880+ function (a) {
4881+ return $elm$core$Task$succeed(
4882+ func(a));
4883+ },
4884+ taskA);
4885+ });
4886+var $elm$core$Task$map2 = F3(
4887+ function (func, taskA, taskB) {
4888+ return A2(
4889+ $elm$core$Task$andThen,
4890+ function (a) {
4891+ return A2(
4892+ $elm$core$Task$andThen,
4893+ function (b) {
4894+ return $elm$core$Task$succeed(
4895+ A2(func, a, b));
4896+ },
4897+ taskB);
4898+ },
4899+ taskA);
4900+ });
4901+var $elm$core$Task$sequence = function (tasks) {
4902+ return A3(
4903+ $elm$core$List$foldr,
4904+ $elm$core$Task$map2($elm$core$List$cons),
4905+ $elm$core$Task$succeed(_List_Nil),
4906+ tasks);
4907+};
4908+var $elm$core$Platform$sendToApp = _Platform_sendToApp;
4909+var $elm$core$Task$spawnCmd = F2(
4910+ function (router, _v0) {
4911+ var task = _v0.a;
4912+ return _Scheduler_spawn(
4913+ A2(
4914+ $elm$core$Task$andThen,
4915+ $elm$core$Platform$sendToApp(router),
4916+ task));
4917+ });
4918+var $elm$core$Task$onEffects = F3(
4919+ function (router, commands, state) {
4920+ return A2(
4921+ $elm$core$Task$map,
4922+ function (_v0) {
4923+ return _Utils_Tuple0;
4924+ },
4925+ $elm$core$Task$sequence(
4926+ A2(
4927+ $elm$core$List$map,
4928+ $elm$core$Task$spawnCmd(router),
4929+ commands)));
4930+ });
4931+var $elm$core$Task$onSelfMsg = F3(
4932+ function (_v0, _v1, _v2) {
4933+ return $elm$core$Task$succeed(_Utils_Tuple0);
4934+ });
4935+var $elm$core$Task$cmdMap = F2(
4936+ function (tagger, _v0) {
4937+ var task = _v0.a;
4938+ return $elm$core$Task$Perform(
4939+ A2($elm$core$Task$map, tagger, task));
4940+ });
4941+_Platform_effectManagers['Task'] = _Platform_createManager($elm$core$Task$init, $elm$core$Task$onEffects, $elm$core$Task$onSelfMsg, $elm$core$Task$cmdMap);
4942+var $elm$core$Task$command = _Platform_leaf('Task');
4943+var $elm$core$Task$perform = F2(
4944+ function (toMessage, task) {
4945+ return $elm$core$Task$command(
4946+ $elm$core$Task$Perform(
4947+ A2($elm$core$Task$map, toMessage, task)));
4948+ });
4949+var $elm$core$Platform$Cmd$batch = _Platform_batch;
4950+var $elm$core$Platform$Cmd$none = $elm$core$Platform$Cmd$batch(_List_Nil);
4951+var $elm$core$Platform$Sub$batch = _Platform_batch;
4952+var $elm$core$Platform$Sub$none = $elm$core$Platform$Sub$batch(_List_Nil);
4953+var $lynxjs_elm$browser$Browser$sandbox = function (impl) {
4954+ return _Browser_element(
4955+ {
4956+ init: function (_v0) {
4957+ return _Utils_Tuple2(impl.init, $elm$core$Platform$Cmd$none);
4958+ },
4959+ subscriptions: function (_v1) {
4960+ return $elm$core$Platform$Sub$none;
4961+ },
4962+ update: F2(
4963+ function (msg, model) {
4964+ return _Utils_Tuple2(
4965+ A2(impl.update, msg, model),
4966+ $elm$core$Platform$Cmd$none);
4967+ }),
4968+ view: impl.view
4969+ });
4970+};
4971+var $author$project$Main$update = F2(
4972+ function (msg, model) {
4973+ var idx = msg.a;
4974+ return _Utils_update(
4975+ model,
4976+ {
4977+ selected: _Utils_eq(
4978+ model.selected,
4979+ $elm$core$Maybe$Just(idx)) ? $elm$core$Maybe$Nothing : $elm$core$Maybe$Just(idx)
4980+ });
4981+ });
4982+var $lynxjs_elm$ui$Lynx$Attributes$Bold = {$: 'Bold'};
4983+var $lynxjs_elm$ui$Lynx$Attributes$Center = {$: 'Center'};
4984+var $lynxjs_elm$ui$Lynx$Attributes$Column = {$: 'Column'};
4985+var $lynxjs_elm$ui$Lynx$Attributes$Row = {$: 'Row'};
4986+var $lynxjs_elm$ui$Lynx$Attributes$Vertical = {$: 'Vertical'};
4987+var $lynxjs_elm$ui$Lynx$Attributes$alignmentToString = function (a) {
4988+ switch (a.$) {
4989+ case 'Start':
4990+ return 'flex-start';
4991+ case 'Center':
4992+ return 'center';
4993+ case 'End':
4994+ return 'flex-end';
4995+ case 'SpaceBetween':
4996+ return 'space-between';
4997+ case 'SpaceAround':
4998+ return 'space-around';
4999+ case 'SpaceEvenly':
5000+ return 'space-evenly';
5001+ case 'Stretch':
5002+ return 'stretch';
5003+ default:
5004+ return 'baseline';
5005+ }
5006+};
5007+var $lynxjs_elm$virtual_dom$VirtualDom$style = _VirtualDom_style;
5008+var $lynxjs_elm$ui$Lynx$Attributes$style = $lynxjs_elm$virtual_dom$VirtualDom$style;
5009+var $lynxjs_elm$ui$Lynx$Attributes$alignItems = function (a) {
5010+ return A2(
5011+ $lynxjs_elm$ui$Lynx$Attributes$style,
5012+ 'alignItems',
5013+ $lynxjs_elm$ui$Lynx$Attributes$alignmentToString(a));
5014+};
5015+var $lynxjs_elm$ui$Lynx$Attributes$backgroundColor = $lynxjs_elm$ui$Lynx$Attributes$style('backgroundColor');
5016+var $lynxjs_elm$ui$Lynx$Attributes$pxStyle = F2(
5017+ function (key, val) {
5018+ return A2(
5019+ $lynxjs_elm$virtual_dom$VirtualDom$style,
5020+ key,
5021+ $elm$core$String$fromInt(val) + 'px');
5022+ });
5023+var $lynxjs_elm$ui$Lynx$Attributes$borderRadius = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('borderRadius');
5024+var $lynxjs_elm$ui$Lynx$Attributes$color = $lynxjs_elm$ui$Lynx$Attributes$style('color');
5025+var $author$project$Main$colors = _List_fromArray(
5026+ ['#FF6B6B', '#4ECDC4', '#45B7D1', '#96CEB4', '#FFEAA7', '#DDA0DD', '#98D8C8', '#F7DC6F', '#BB8FCE', '#85C1E9', '#F0B27A', '#82E0AA', '#F1948A', '#85929E', '#D7BDE2', '#A3E4D7', '#FAD7A0', '#AED6F1', '#D5DBDB', '#EDBB99']);
5027+var $elm$core$List$drop = F2(
5028+ function (n, list) {
5029+ drop:
5030+ while (true) {
5031+ if (n <= 0) {
5032+ return list;
5033+ } else {
5034+ if (!list.b) {
5035+ return list;
5036+ } else {
5037+ var x = list.a;
5038+ var xs = list.b;
5039+ var $temp$n = n - 1,
5040+ $temp$list = xs;
5041+ n = $temp$n;
5042+ list = $temp$list;
5043+ continue drop;
5044+ }
5045+ }
5046+ }
5047+ });
5048+var $lynxjs_elm$ui$Lynx$Attributes$intStyle = F2(
5049+ function (key, val) {
5050+ return A2(
5051+ $lynxjs_elm$virtual_dom$VirtualDom$style,
5052+ key,
5053+ $elm$core$String$fromInt(val));
5054+ });
5055+var $lynxjs_elm$ui$Lynx$Attributes$flex = $lynxjs_elm$ui$Lynx$Attributes$intStyle('flex');
5056+var $lynxjs_elm$ui$Lynx$Attributes$flexDirection = function (d) {
5057+ return A2(
5058+ $lynxjs_elm$ui$Lynx$Attributes$style,
5059+ 'flexDirection',
5060+ function () {
5061+ switch (d.$) {
5062+ case 'Row':
5063+ return 'row';
5064+ case 'Column':
5065+ return 'column';
5066+ case 'RowReverse':
5067+ return 'row-reverse';
5068+ default:
5069+ return 'column-reverse';
5070+ }
5071+ }());
5072+};
5073+var $lynxjs_elm$ui$Lynx$Attributes$fontSize = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('fontSize');
5074+var $lynxjs_elm$ui$Lynx$Attributes$fontWeight = function (w) {
5075+ return A2(
5076+ $lynxjs_elm$ui$Lynx$Attributes$style,
5077+ 'fontWeight',
5078+ function () {
5079+ if (w.$ === 'Normal') {
5080+ return 'normal';
5081+ } else {
5082+ return 'bold';
5083+ }
5084+ }());
5085+};
5086+var $elm$core$List$head = function (list) {
5087+ if (list.b) {
5088+ var x = list.a;
5089+ var xs = list.b;
5090+ return $elm$core$Maybe$Just(x);
5091+ } else {
5092+ return $elm$core$Maybe$Nothing;
5093+ }
5094+};
5095+var $lynxjs_elm$ui$Lynx$Attributes$height = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('height');
5096+var $lynxjs_elm$ui$Lynx$Attributes$marginRight = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('marginRight');
5097+var $lynxjs_elm$ui$Lynx$Attributes$marginTop = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('marginTop');
5098+var $lynxjs_elm$ui$Lynx$Attributes$padding = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('padding');
5099+var $lynxjs_elm$ui$Lynx$Attributes$paddingBottom = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('paddingBottom');
5100+var $lynxjs_elm$ui$Lynx$Attributes$paddingLeft = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('paddingLeft');
5101+var $lynxjs_elm$ui$Lynx$Attributes$paddingRight = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('paddingRight');
5102+var $lynxjs_elm$ui$Lynx$Attributes$paddingTop = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('paddingTop');
5103+var $lynxjs_elm$virtual_dom$VirtualDom$attribute = F2(
5104+ function (key, value) {
5105+ return A2(
5106+ _VirtualDom_attribute,
5107+ _VirtualDom_noOnOrFormAction(key),
5108+ _VirtualDom_noJavaScriptOrHtmlUri(value));
5109+ });
5110+var $lynxjs_elm$ui$Lynx$Attributes$attr = $lynxjs_elm$virtual_dom$VirtualDom$attribute;
5111+var $lynxjs_elm$ui$Lynx$Attributes$scrollDirection = function (d) {
5112+ return A2(
5113+ $lynxjs_elm$ui$Lynx$Attributes$attr,
5114+ 'scroll-direction',
5115+ function () {
5116+ if (d.$ === 'Vertical') {
5117+ return 'vertical';
5118+ } else {
5119+ return 'horizontal';
5120+ }
5121+ }());
5122+};
5123+var $lynxjs_elm$virtual_dom$VirtualDom$node = function (tag) {
5124+ return _VirtualDom_node(
5125+ _VirtualDom_noScript(tag));
5126+};
5127+var $lynxjs_elm$ui$Lynx$scrollView = $lynxjs_elm$virtual_dom$VirtualDom$node('scroll-view');
5128+var $lynxjs_elm$ui$Lynx$text = $lynxjs_elm$virtual_dom$VirtualDom$node('text');
5129+var $lynxjs_elm$virtual_dom$VirtualDom$text = _VirtualDom_text;
5130+var $lynxjs_elm$ui$Lynx$textContent = $lynxjs_elm$virtual_dom$VirtualDom$text;
5131+var $lynxjs_elm$ui$Lynx$view = $lynxjs_elm$virtual_dom$VirtualDom$node('view');
5132+var $author$project$Main$Select = function (a) {
5133+ return {$: 'Select', a: a};
5134+};
5135+var $lynxjs_elm$ui$Lynx$Attributes$borderColor = $lynxjs_elm$ui$Lynx$Attributes$style('borderColor');
5136+var $lynxjs_elm$ui$Lynx$Attributes$borderWidth = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('borderWidth');
5137+var $lynxjs_elm$ui$Lynx$Attributes$marginBottom = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('marginBottom');
5138+var $lynxjs_elm$virtual_dom$VirtualDom$Normal = function (a) {
5139+ return {$: 'Normal', a: a};
5140+};
5141+var $lynxjs_elm$virtual_dom$VirtualDom$on = _VirtualDom_on;
5142+var $lynxjs_elm$ui$Lynx$Events$onTap = function (msg) {
5143+ return A2(
5144+ $lynxjs_elm$virtual_dom$VirtualDom$on,
5145+ 'tap',
5146+ $lynxjs_elm$virtual_dom$VirtualDom$Normal(
5147+ $elm$json$Json$Decode$succeed(msg)));
5148+};
5149+var $lynxjs_elm$ui$Lynx$Attributes$width = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('width');
5150+var $author$project$Main$viewCard = F3(
5151+ function (selected, idx, colorHex) {
5152+ var isSelected = _Utils_eq(
5153+ selected,
5154+ $elm$core$Maybe$Just(idx));
5155+ return A2(
5156+ $lynxjs_elm$ui$Lynx$view,
5157+ _List_fromArray(
5158+ [
5159+ $lynxjs_elm$ui$Lynx$Events$onTap(
5160+ $author$project$Main$Select(idx)),
5161+ $lynxjs_elm$ui$Lynx$Attributes$flexDirection($lynxjs_elm$ui$Lynx$Attributes$Row),
5162+ $lynxjs_elm$ui$Lynx$Attributes$alignItems($lynxjs_elm$ui$Lynx$Attributes$Center),
5163+ $lynxjs_elm$ui$Lynx$Attributes$marginBottom(8),
5164+ $lynxjs_elm$ui$Lynx$Attributes$borderRadius(12),
5165+ $lynxjs_elm$ui$Lynx$Attributes$backgroundColor('#ffffff'),
5166+ $lynxjs_elm$ui$Lynx$Attributes$borderWidth(
5167+ isSelected ? 2 : 0),
5168+ $lynxjs_elm$ui$Lynx$Attributes$borderColor(colorHex),
5169+ $lynxjs_elm$ui$Lynx$Attributes$paddingTop(14),
5170+ $lynxjs_elm$ui$Lynx$Attributes$paddingBottom(14),
5171+ $lynxjs_elm$ui$Lynx$Attributes$paddingLeft(16),
5172+ $lynxjs_elm$ui$Lynx$Attributes$paddingRight(16)
5173+ ]),
5174+ _List_fromArray(
5175+ [
5176+ A2(
5177+ $lynxjs_elm$ui$Lynx$view,
5178+ _List_fromArray(
5179+ [
5180+ $lynxjs_elm$ui$Lynx$Attributes$width(48),
5181+ $lynxjs_elm$ui$Lynx$Attributes$height(48),
5182+ $lynxjs_elm$ui$Lynx$Attributes$borderRadius(12),
5183+ $lynxjs_elm$ui$Lynx$Attributes$backgroundColor(colorHex),
5184+ $lynxjs_elm$ui$Lynx$Attributes$marginRight(16)
5185+ ]),
5186+ _List_Nil),
5187+ A2(
5188+ $lynxjs_elm$ui$Lynx$view,
5189+ _List_fromArray(
5190+ [
5191+ $lynxjs_elm$ui$Lynx$Attributes$flex(1)
5192+ ]),
5193+ _List_fromArray(
5194+ [
5195+ A2(
5196+ $lynxjs_elm$ui$Lynx$text,
5197+ _List_fromArray(
5198+ [
5199+ $lynxjs_elm$ui$Lynx$Attributes$fontSize(16),
5200+ $lynxjs_elm$ui$Lynx$Attributes$fontWeight($lynxjs_elm$ui$Lynx$Attributes$Bold),
5201+ $lynxjs_elm$ui$Lynx$Attributes$color('#2C3E50')
5202+ ]),
5203+ _List_fromArray(
5204+ [
5205+ $lynxjs_elm$ui$Lynx$textContent(
5206+ 'Color #' + $elm$core$String$fromInt(idx + 1))
5207+ ])),
5208+ A2(
5209+ $lynxjs_elm$ui$Lynx$text,
5210+ _List_fromArray(
5211+ [
5212+ $lynxjs_elm$ui$Lynx$Attributes$fontSize(13),
5213+ $lynxjs_elm$ui$Lynx$Attributes$color('#7F8C8D'),
5214+ $lynxjs_elm$ui$Lynx$Attributes$marginTop(2)
5215+ ]),
5216+ _List_fromArray(
5217+ [
5218+ $lynxjs_elm$ui$Lynx$textContent(colorHex)
5219+ ]))
5220+ ])),
5221+ isSelected ? A2(
5222+ $lynxjs_elm$ui$Lynx$text,
5223+ _List_fromArray(
5224+ [
5225+ $lynxjs_elm$ui$Lynx$Attributes$fontSize(20),
5226+ $lynxjs_elm$ui$Lynx$Attributes$color(colorHex)
5227+ ]),
5228+ _List_fromArray(
5229+ [
5230+ $lynxjs_elm$ui$Lynx$textContent('●')
5231+ ])) : A2($lynxjs_elm$ui$Lynx$text, _List_Nil, _List_Nil)
5232+ ]));
5233+ });
5234+var $elm$core$Maybe$withDefault = F2(
5235+ function (_default, maybe) {
5236+ if (maybe.$ === 'Just') {
5237+ var value = maybe.a;
5238+ return value;
5239+ } else {
5240+ return _default;
5241+ }
5242+ });
5243+var $author$project$Main$view = function (model) {
5244+ return A2(
5245+ $lynxjs_elm$ui$Lynx$view,
5246+ _List_fromArray(
5247+ [
5248+ $lynxjs_elm$ui$Lynx$Attributes$flexDirection($lynxjs_elm$ui$Lynx$Attributes$Column),
5249+ $lynxjs_elm$ui$Lynx$Attributes$flex(1)
5250+ ]),
5251+ _List_fromArray(
5252+ [
5253+ A2(
5254+ $lynxjs_elm$ui$Lynx$view,
5255+ _List_fromArray(
5256+ [
5257+ $lynxjs_elm$ui$Lynx$Attributes$backgroundColor('#2C3E50'),
5258+ $lynxjs_elm$ui$Lynx$Attributes$paddingTop(16),
5259+ $lynxjs_elm$ui$Lynx$Attributes$paddingBottom(16),
5260+ $lynxjs_elm$ui$Lynx$Attributes$paddingLeft(20),
5261+ $lynxjs_elm$ui$Lynx$Attributes$paddingRight(20)
5262+ ]),
5263+ _List_fromArray(
5264+ [
5265+ A2(
5266+ $lynxjs_elm$ui$Lynx$text,
5267+ _List_fromArray(
5268+ [
5269+ $lynxjs_elm$ui$Lynx$Attributes$fontSize(22),
5270+ $lynxjs_elm$ui$Lynx$Attributes$fontWeight($lynxjs_elm$ui$Lynx$Attributes$Bold),
5271+ $lynxjs_elm$ui$Lynx$Attributes$color('#ffffff')
5272+ ]),
5273+ _List_fromArray(
5274+ [
5275+ $lynxjs_elm$ui$Lynx$textContent('Color Palette')
5276+ ])),
5277+ A2(
5278+ $lynxjs_elm$ui$Lynx$text,
5279+ _List_fromArray(
5280+ [
5281+ $lynxjs_elm$ui$Lynx$Attributes$fontSize(14),
5282+ $lynxjs_elm$ui$Lynx$Attributes$color('#95A5A6'),
5283+ $lynxjs_elm$ui$Lynx$Attributes$marginTop(4)
5284+ ]),
5285+ _List_fromArray(
5286+ [
5287+ $lynxjs_elm$ui$Lynx$textContent('Tap a color to select it')
5288+ ]))
5289+ ])),
5290+ A2(
5291+ $lynxjs_elm$ui$Lynx$scrollView,
5292+ _List_fromArray(
5293+ [
5294+ $lynxjs_elm$ui$Lynx$Attributes$flex(1),
5295+ $lynxjs_elm$ui$Lynx$Attributes$scrollDirection($lynxjs_elm$ui$Lynx$Attributes$Vertical),
5296+ $lynxjs_elm$ui$Lynx$Attributes$padding(12)
5297+ ]),
5298+ A2(
5299+ $elm$core$List$indexedMap,
5300+ $author$project$Main$viewCard(model.selected),
5301+ $author$project$Main$colors)),
5302+ A2(
5303+ $lynxjs_elm$ui$Lynx$view,
5304+ _List_fromArray(
5305+ [
5306+ $lynxjs_elm$ui$Lynx$Attributes$backgroundColor('#34495E'),
5307+ $lynxjs_elm$ui$Lynx$Attributes$paddingTop(12),
5308+ $lynxjs_elm$ui$Lynx$Attributes$paddingBottom(12),
5309+ $lynxjs_elm$ui$Lynx$Attributes$paddingLeft(20),
5310+ $lynxjs_elm$ui$Lynx$Attributes$paddingRight(20),
5311+ $lynxjs_elm$ui$Lynx$Attributes$flexDirection($lynxjs_elm$ui$Lynx$Attributes$Row),
5312+ $lynxjs_elm$ui$Lynx$Attributes$alignItems($lynxjs_elm$ui$Lynx$Attributes$Center)
5313+ ]),
5314+ _List_fromArray(
5315+ [
5316+ function () {
5317+ var _v0 = model.selected;
5318+ if (_v0.$ === 'Nothing') {
5319+ return A2(
5320+ $lynxjs_elm$ui$Lynx$text,
5321+ _List_fromArray(
5322+ [
5323+ $lynxjs_elm$ui$Lynx$Attributes$color('#95A5A6'),
5324+ $lynxjs_elm$ui$Lynx$Attributes$fontSize(14)
5325+ ]),
5326+ _List_fromArray(
5327+ [
5328+ $lynxjs_elm$ui$Lynx$textContent('No color selected')
5329+ ]));
5330+ } else {
5331+ var idx = _v0.a;
5332+ var colorHex = A2(
5333+ $elm$core$Maybe$withDefault,
5334+ '#000000',
5335+ $elm$core$List$head(
5336+ A2($elm$core$List$drop, idx, $author$project$Main$colors)));
5337+ return A2(
5338+ $lynxjs_elm$ui$Lynx$view,
5339+ _List_fromArray(
5340+ [
5341+ $lynxjs_elm$ui$Lynx$Attributes$flexDirection($lynxjs_elm$ui$Lynx$Attributes$Row),
5342+ $lynxjs_elm$ui$Lynx$Attributes$alignItems($lynxjs_elm$ui$Lynx$Attributes$Center)
5343+ ]),
5344+ _List_fromArray(
5345+ [
5346+ A2(
5347+ $lynxjs_elm$ui$Lynx$view,
5348+ _List_fromArray(
5349+ [
5350+ $lynxjs_elm$ui$Lynx$Attributes$width(20),
5351+ $lynxjs_elm$ui$Lynx$Attributes$height(20),
5352+ $lynxjs_elm$ui$Lynx$Attributes$borderRadius(10),
5353+ $lynxjs_elm$ui$Lynx$Attributes$backgroundColor(colorHex),
5354+ $lynxjs_elm$ui$Lynx$Attributes$marginRight(8)
5355+ ]),
5356+ _List_Nil),
5357+ A2(
5358+ $lynxjs_elm$ui$Lynx$text,
5359+ _List_fromArray(
5360+ [
5361+ $lynxjs_elm$ui$Lynx$Attributes$color('#ffffff'),
5362+ $lynxjs_elm$ui$Lynx$Attributes$fontSize(14)
5363+ ]),
5364+ _List_fromArray(
5365+ [
5366+ $lynxjs_elm$ui$Lynx$textContent('Selected: ' + colorHex)
5367+ ]))
5368+ ]));
5369+ }
5370+ }()
5371+ ]))
5372+ ]));
5373+};
5374+var $author$project$Main$main = $lynxjs_elm$browser$Browser$sandbox(
5375+ {init: $author$project$Main$init, update: $author$project$Main$update, view: $author$project$Main$view});
5376+_Platform_export({'Main':{'init':$author$project$Main$main(
5377+ $elm$json$Json$Decode$succeed(_Utils_Tuple0))(0)}});}(globalThis));
examples/scroll-view/src/Main.elm+11−11
@@ -6,7 +6,7 @@ Demonstrates scrollView, list rendering, and layout patterns.
66
77import Browser
88import Lynx
9−import Lynx.Attributes as Attr
9+import Lynx.Attributes as Attr exposing (Alignment(..), FlexDirection(..), FontWeight(..), ScrollDirection(..))
1010import Lynx.Events exposing (onTap)
1111import VirtualDom exposing (Node)
1212
@@ -76,7 +76,7 @@ update msg model =
7676view : Model -> Node Msg
7777view model =
7878 Lynx.view
79− [ Attr.flexDirection "column"
79+ [ Attr.flexDirection Column
8080 , Attr.flex 1
8181 ]
8282 [ -- Header
@@ -89,7 +89,7 @@ view model =
8989 ]
9090 [ Lynx.text
9191 [ Attr.fontSize 22
92− , Attr.fontWeight "bold"
92+ , Attr.fontWeight Bold
9393 , Attr.color "#ffffff"
9494 ]
9595 [ Lynx.textContent "Color Palette" ]
@@ -104,7 +104,7 @@ view model =
104104 -- Scrollable content
105105 , Lynx.scrollView
106106 [ Attr.flex 1
107− , Attr.scrollDirection "vertical"
107+ , Attr.scrollDirection Vertical
108108 , Attr.padding 12
109109 ]
110110 (List.indexedMap (viewCard model.selected) colors)
@@ -116,8 +116,8 @@ view model =
116116 , Attr.paddingBottom 12
117117 , Attr.paddingLeft 20
118118 , Attr.paddingRight 20
119− , Attr.flexDirection "row"
120− , Attr.alignItems "center"
119+ , Attr.flexDirection Row
120+ , Attr.alignItems Center
121121 ]
122122 [ case model.selected of
123123 Nothing ->
@@ -132,8 +132,8 @@ view model =
132132 |> Maybe.withDefault "#000000"
133133 in
134134 Lynx.view
135− [ Attr.flexDirection "row"
136− , Attr.alignItems "center"
135+ [ Attr.flexDirection Row
136+ , Attr.alignItems Center
137137 ]
138138 [ Lynx.view
139139 [ Attr.width 20
@@ -158,8 +158,8 @@ viewCard selected idx colorHex =
158158 in
159159 Lynx.view
160160 [ onTap (Select idx)
161− , Attr.flexDirection "row"
162− , Attr.alignItems "center"
161+ , Attr.flexDirection Row
162+ , Attr.alignItems Center
163163 , Attr.marginBottom 8
164164 , Attr.borderRadius 12
165165 , Attr.backgroundColor "#ffffff"
@@ -184,7 +184,7 @@ viewCard selected idx colorHex =
184184 , Lynx.view [ Attr.flex 1 ]
185185 [ Lynx.text
186186 [ Attr.fontSize 16
187− , Attr.fontWeight "bold"
187+ , Attr.fontWeight Bold
188188 , Attr.color "#2C3E50"
189189 ]
190190 [ Lynx.textContent ("Color #" ++ String.fromInt (idx + 1)) ]
examples/timer/src/Main.elm+10−10
@@ -5,7 +5,7 @@ module Main exposing (main)
55
66import Browser
77import Lynx
8−import Lynx.Attributes as Attr
8+import Lynx.Attributes as Attr exposing (Alignment(..), FlexDirection(..), FontWeight(..))
99import Lynx.Events exposing (onTap)
1010import Time
1111import VirtualDom exposing (Node)
@@ -100,8 +100,8 @@ subscriptions model =
100100view : Model -> Node Msg
101101view model =
102102 Lynx.view
103− [ Attr.flexDirection "column"
104− , Attr.alignItems "center"
103+ [ Attr.flexDirection Column
104+ , Attr.alignItems Center
105105 , Attr.flex 1
106106 , Attr.backgroundColor "#1a1a2e"
107107 , Attr.paddingTop 40
@@ -109,14 +109,14 @@ view model =
109109 [ -- Timer display
110110 Lynx.text
111111 [ Attr.fontSize 64
112− , Attr.fontWeight "bold"
112+ , Attr.fontWeight Bold
113113 , Attr.color "#e94560"
114114 ]
115115 [ Lynx.textContent (formatTime model.elapsed) ]
116116
117117 -- Controls
118118 , Lynx.view
119− [ Attr.flexDirection "row"
119+ [ Attr.flexDirection Row
120120 , Attr.marginTop 30
121121 ]
122122 [ -- Start/Stop
@@ -144,8 +144,8 @@ view model =
144144 else
145145 Lynx.view
146146 [ Attr.marginTop 30
147− , Attr.flexDirection "column"
148− , Attr.alignItems "center"
147+ , Attr.flexDirection Column
148+ , Attr.alignItems Center
149149 ]
150150 [ Lynx.text
151151 [ Attr.fontSize 18
@@ -153,7 +153,7 @@ view model =
153153 , Attr.marginBottom 12
154154 ]
155155 [ Lynx.textContent "Laps" ]
156− , Lynx.view [ Attr.flexDirection "column" ]
156+ , Lynx.view [ Attr.flexDirection Column ]
157157 (List.indexedMap viewLap (List.reverse model.laps))
158158 ]
159159 ]
@@ -175,7 +175,7 @@ timerButton bgColor msg label =
175175 [ Lynx.text
176176 [ Attr.color "#ffffff"
177177 , Attr.fontSize 18
178− , Attr.fontWeight "bold"
178+ , Attr.fontWeight Bold
179179 ]
180180 [ Lynx.textContent label ]
181181 ]
@@ -184,7 +184,7 @@ timerButton bgColor msg label =
184184viewLap : Int -> Int -> Node Msg
185185viewLap index tenths =
186186 Lynx.view
187− [ Attr.flexDirection "row"
187+ [ Attr.flexDirection Row
188188 , Attr.paddingTop 8
189189 , Attr.paddingBottom 8
190190 ]
examples/todo-list/elm.jsnew file+5417
@@ -0,0 +1,5417 @@
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+ return '<internals>';
266+}
267+
268+function _Debug_toString(value)
269+{
270+ return _Debug_toAnsiString(false, value);
271+}
272+
273+function _Debug_toAnsiString(ansi, value)
274+{
275+ if (typeof value === 'function')
276+ {
277+ return _Debug_internalColor(ansi, '<function>');
278+ }
279+
280+ if (typeof value === 'boolean')
281+ {
282+ return _Debug_ctorColor(ansi, value ? 'True' : 'False');
283+ }
284+
285+ if (typeof value === 'number')
286+ {
287+ return _Debug_numberColor(ansi, value + '');
288+ }
289+
290+ if (value instanceof String)
291+ {
292+ return _Debug_charColor(ansi, "'" + _Debug_addSlashes(value, true) + "'");
293+ }
294+
295+ if (typeof value === 'string')
296+ {
297+ return _Debug_stringColor(ansi, '"' + _Debug_addSlashes(value, false) + '"');
298+ }
299+
300+ if (typeof value === 'object' && '$' in value)
301+ {
302+ var tag = value.$;
303+
304+ if (typeof tag === 'number')
305+ {
306+ return _Debug_internalColor(ansi, '<internals>');
307+ }
308+
309+ if (tag[0] === '#')
310+ {
311+ var output = [];
312+ for (var k in value)
313+ {
314+ if (k === '$') continue;
315+ output.push(_Debug_toAnsiString(ansi, value[k]));
316+ }
317+ return '(' + output.join(',') + ')';
318+ }
319+
320+ if (tag === 'Set_elm_builtin')
321+ {
322+ return _Debug_ctorColor(ansi, 'Set')
323+ + _Debug_fadeColor(ansi, '.fromList') + ' '
324+ + _Debug_toAnsiString(ansi, $elm$core$Set$toList(value));
325+ }
326+
327+ if (tag === 'RBNode_elm_builtin' || tag === 'RBEmpty_elm_builtin')
328+ {
329+ return _Debug_ctorColor(ansi, 'Dict')
330+ + _Debug_fadeColor(ansi, '.fromList') + ' '
331+ + _Debug_toAnsiString(ansi, $elm$core$Dict$toList(value));
332+ }
333+
334+ if (tag === 'Array_elm_builtin')
335+ {
336+ return _Debug_ctorColor(ansi, 'Array')
337+ + _Debug_fadeColor(ansi, '.fromList') + ' '
338+ + _Debug_toAnsiString(ansi, $elm$core$Array$toList(value));
339+ }
340+
341+ if (tag === '::' || tag === '[]')
342+ {
343+ var output = '[';
344+
345+ value.b && (output += _Debug_toAnsiString(ansi, value.a), value = value.b)
346+
347+ for (; value.b; value = value.b) // WHILE_CONS
348+ {
349+ output += ',' + _Debug_toAnsiString(ansi, value.a);
350+ }
351+ return output + ']';
352+ }
353+
354+ var output = '';
355+ for (var i in value)
356+ {
357+ if (i === '$') continue;
358+ var str = _Debug_toAnsiString(ansi, value[i]);
359+ var c0 = str[0];
360+ var parenless = c0 === '{' || c0 === '(' || c0 === '[' || c0 === '<' || c0 === '"' || str.indexOf(' ') < 0;
361+ output += ' ' + (parenless ? str : '(' + str + ')');
362+ }
363+ return _Debug_ctorColor(ansi, tag) + output;
364+ }
365+
366+ if (typeof DataView === 'function' && value instanceof DataView)
367+ {
368+ return _Debug_stringColor(ansi, '<' + value.byteLength + ' bytes>');
369+ }
370+
371+ if (typeof File !== 'undefined' && value instanceof File)
372+ {
373+ return _Debug_internalColor(ansi, '<' + value.name + '>');
374+ }
375+
376+ if (typeof value === 'object')
377+ {
378+ var output = [];
379+ for (var key in value)
380+ {
381+ var field = key[0] === '_' ? key.slice(1) : key;
382+ output.push(_Debug_fadeColor(ansi, field) + ' = ' + _Debug_toAnsiString(ansi, value[key]));
383+ }
384+ if (output.length === 0)
385+ {
386+ return '{}';
387+ }
388+ return '{ ' + output.join(', ') + ' }';
389+ }
390+
391+ return _Debug_internalColor(ansi, '<internals>');
392+}
393+
394+function _Debug_addSlashes(str, isChar)
395+{
396+ var s = str
397+ .replace(/\\/g, '\\\\')
398+ .replace(/\n/g, '\\n')
399+ .replace(/\t/g, '\\t')
400+ .replace(/\r/g, '\\r')
401+ .replace(/\v/g, '\\v')
402+ .replace(/\0/g, '\\0');
403+
404+ if (isChar)
405+ {
406+ return s.replace(/\'/g, '\\\'');
407+ }
408+ else
409+ {
410+ return s.replace(/\"/g, '\\"');
411+ }
412+}
413+
414+function _Debug_ctorColor(ansi, string)
415+{
416+ return ansi ? '\x1b[96m' + string + '\x1b[0m' : string;
417+}
418+
419+function _Debug_numberColor(ansi, string)
420+{
421+ return ansi ? '\x1b[95m' + string + '\x1b[0m' : string;
422+}
423+
424+function _Debug_stringColor(ansi, string)
425+{
426+ return ansi ? '\x1b[93m' + string + '\x1b[0m' : string;
427+}
428+
429+function _Debug_charColor(ansi, string)
430+{
431+ return ansi ? '\x1b[92m' + string + '\x1b[0m' : string;
432+}
433+
434+function _Debug_fadeColor(ansi, string)
435+{
436+ return ansi ? '\x1b[37m' + string + '\x1b[0m' : string;
437+}
438+
439+function _Debug_internalColor(ansi, string)
440+{
441+ return ansi ? '\x1b[36m' + string + '\x1b[0m' : string;
442+}
443+
444+function _Debug_toHexDigit(n)
445+{
446+ return String.fromCharCode(n < 10 ? 48 + n : 55 + n);
447+}
448+
449+
450+// CRASH
451+
452+
453+{
454+ throw new Error('https://github.com/elm/core/blob/1.0.0/hints/' + identifier + '.md');
455+}
456+
457+
458+function _Debug_crash(identifier, fact1, fact2, fact3, fact4)
459+{
460+ switch(identifier)
461+ {
462+ case 0:
463+ 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.');
464+
465+ case 1:
466+ 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.');
467+
468+ case 2:
469+ var jsonErrorString = fact1;
470+ throw new Error('Problem with the flags given to your Elm program on initialization.\n\n' + jsonErrorString);
471+
472+ case 3:
473+ var portName = fact1;
474+ throw new Error('There can only be one port named `' + portName + '`, but your program has multiple.');
475+
476+ case 4:
477+ var portName = fact1;
478+ var problem = fact2;
479+ throw new Error('Trying to send an unexpected type of value through port `' + portName + '`:\n' + problem);
480+
481+ case 5:
482+ 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.');
483+
484+ case 6:
485+ var moduleName = fact1;
486+ 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!');
487+
488+ case 8:
489+ var moduleName = fact1;
490+ var region = fact2;
491+ var message = fact3;
492+ throw new Error('TODO in module `' + moduleName + '` ' + _Debug_regionToString(region) + '\n\n' + message);
493+
494+ case 9:
495+ var moduleName = fact1;
496+ var region = fact2;
497+ var value = fact3;
498+ var message = fact4;
499+ throw new Error(
500+ 'TODO in module `' + moduleName + '` from the `case` expression '
501+ + _Debug_regionToString(region) + '\n\nIt received the following value:\n\n '
502+ + _Debug_toString(value).replace('\n', '\n ')
503+ + '\n\nBut the branch that handles it says:\n\n ' + message.replace('\n', '\n ')
504+ );
505+
506+ case 10:
507+ throw new Error('Bug in https://github.com/elm/virtual-dom/issues');
508+
509+ case 11:
510+ throw new Error('Cannot perform mod 0. Division by zero error.');
511+ }
512+}
513+
514+function _Debug_regionToString(region)
515+{
516+ if (region.start.line === region.end.line)
517+ {
518+ return 'on line ' + region.start.line;
519+ }
520+ return 'on lines ' + region.start.line + ' through ' + region.end.line;
521+}
522+
523+
524+
525+// EQUALITY
526+
527+function _Utils_eq(x, y)
528+{
529+ for (
530+ var pair, stack = [], isEqual = _Utils_eqHelp(x, y, 0, stack);
531+ isEqual && (pair = stack.pop());
532+ isEqual = _Utils_eqHelp(pair.a, pair.b, 0, stack)
533+ )
534+ {}
535+
536+ return isEqual;
537+}
538+
539+function _Utils_eqHelp(x, y, depth, stack)
540+{
541+ if (x === y)
542+ {
543+ return true;
544+ }
545+
546+ if (typeof x !== 'object' || x === null || y === null)
547+ {
548+ typeof x === 'function' && _Debug_crash(5);
549+ return false;
550+ }
551+
552+ if (depth > 100)
553+ {
554+ stack.push(_Utils_Tuple2(x,y));
555+ return true;
556+ }
557+
558+ /**/
559+ if (x.$ === 'Set_elm_builtin')
560+ {
561+ x = $elm$core$Set$toList(x);
562+ y = $elm$core$Set$toList(y);
563+ }
564+ if (x.$ === 'RBNode_elm_builtin' || x.$ === 'RBEmpty_elm_builtin')
565+ {
566+ x = $elm$core$Dict$toList(x);
567+ y = $elm$core$Dict$toList(y);
568+ }
569+ //*/
570+
571+ /**_UNUSED/
572+ if (x.$ < 0)
573+ {
574+ x = $elm$core$Dict$toList(x);
575+ y = $elm$core$Dict$toList(y);
576+ }
577+ //*/
578+
579+ for (var key in x)
580+ {
581+ if (!_Utils_eqHelp(x[key], y[key], depth + 1, stack))
582+ {
583+ return false;
584+ }
585+ }
586+ return true;
587+}
588+
589+var _Utils_equal = F2(_Utils_eq);
590+var _Utils_notEqual = F2(function(a, b) { return !_Utils_eq(a,b); });
591+
592+
593+
594+// COMPARISONS
595+
596+// Code in Generate/JavaScript.hs, Basics.js, and List.js depends on
597+// the particular integer values assigned to LT, EQ, and GT.
598+
599+function _Utils_cmp(x, y, ord)
600+{
601+ if (typeof x !== 'object')
602+ {
603+ return x === y ? /*EQ*/ 0 : x < y ? /*LT*/ -1 : /*GT*/ 1;
604+ }
605+
606+ /**/
607+ if (x instanceof String)
608+ {
609+ var a = x.valueOf();
610+ var b = y.valueOf();
611+ return a === b ? 0 : a < b ? -1 : 1;
612+ }
613+ //*/
614+
615+ /**_UNUSED/
616+ if (typeof x.$ === 'undefined')
617+ //*/
618+ /**/
619+ if (x.$[0] === '#')
620+ //*/
621+ {
622+ return (ord = _Utils_cmp(x.a, y.a))
623+ ? ord
624+ : (ord = _Utils_cmp(x.b, y.b))
625+ ? ord
626+ : _Utils_cmp(x.c, y.c);
627+ }
628+
629+ // traverse conses until end of a list or a mismatch
630+ for (; x.b && y.b && !(ord = _Utils_cmp(x.a, y.a)); x = x.b, y = y.b) {} // WHILE_CONSES
631+ return ord || (x.b ? /*GT*/ 1 : y.b ? /*LT*/ -1 : /*EQ*/ 0);
632+}
633+
634+var _Utils_lt = F2(function(a, b) { return _Utils_cmp(a, b) < 0; });
635+var _Utils_le = F2(function(a, b) { return _Utils_cmp(a, b) < 1; });
636+var _Utils_gt = F2(function(a, b) { return _Utils_cmp(a, b) > 0; });
637+var _Utils_ge = F2(function(a, b) { return _Utils_cmp(a, b) >= 0; });
638+
639+var _Utils_compare = F2(function(x, y)
640+{
641+ var n = _Utils_cmp(x, y);
642+ return n < 0 ? $elm$core$Basics$LT : n ? $elm$core$Basics$GT : $elm$core$Basics$EQ;
643+});
644+
645+
646+// COMMON VALUES
647+
648+var _Utils_Tuple0 = { $: '#0' };
649+
650+function _Utils_Tuple2(a, b) { return { $: '#2', a: a, b: b }; }
651+
652+function _Utils_Tuple3(a, b, c) { return { $: '#3', a: a, b: b, c: c }; }
653+
654+function _Utils_chr(c) { return new String(c); }
655+
656+
657+// RECORDS
658+
659+function _Utils_update(oldRecord, updatedFields)
660+{
661+ var newRecord = {};
662+
663+ for (var key in oldRecord)
664+ {
665+ newRecord[key] = oldRecord[key];
666+ }
667+
668+ for (var key in updatedFields)
669+ {
670+ newRecord[key] = updatedFields[key];
671+ }
672+
673+ return newRecord;
674+}
675+
676+
677+// APPEND
678+
679+var _Utils_append = F2(_Utils_ap);
680+
681+function _Utils_ap(xs, ys)
682+{
683+ // append Strings
684+ if (typeof xs === 'string')
685+ {
686+ return xs + ys;
687+ }
688+
689+ // append Lists
690+ if (!xs.b)
691+ {
692+ return ys;
693+ }
694+ var root = _List_Cons(xs.a, ys);
695+ xs = xs.b
696+ for (var curr = root; xs.b; xs = xs.b) // WHILE_CONS
697+ {
698+ curr = curr.b = _List_Cons(xs.a, ys);
699+ }
700+ return root;
701+}
702+
703+
704+
705+var _List_Nil = { $: '[]' };
706+
707+function _List_Cons(hd, tl) { return { $: '::', a: hd, b: tl }; }
708+
709+
710+var _List_cons = F2(_List_Cons);
711+
712+function _List_fromArray(arr)
713+{
714+ var out = _List_Nil;
715+ for (var i = arr.length; i--; )
716+ {
717+ out = _List_Cons(arr[i], out);
718+ }
719+ return out;
720+}
721+
722+function _List_toArray(xs)
723+{
724+ for (var out = []; xs.b; xs = xs.b) // WHILE_CONS
725+ {
726+ out.push(xs.a);
727+ }
728+ return out;
729+}
730+
731+var _List_map2 = F3(function(f, xs, ys)
732+{
733+ for (var arr = []; xs.b && ys.b; xs = xs.b, ys = ys.b) // WHILE_CONSES
734+ {
735+ arr.push(A2(f, xs.a, ys.a));
736+ }
737+ return _List_fromArray(arr);
738+});
739+
740+var _List_map3 = F4(function(f, xs, ys, zs)
741+{
742+ for (var arr = []; xs.b && ys.b && zs.b; xs = xs.b, ys = ys.b, zs = zs.b) // WHILE_CONSES
743+ {
744+ arr.push(A3(f, xs.a, ys.a, zs.a));
745+ }
746+ return _List_fromArray(arr);
747+});
748+
749+var _List_map4 = F5(function(f, ws, xs, ys, zs)
750+{
751+ 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
752+ {
753+ arr.push(A4(f, ws.a, xs.a, ys.a, zs.a));
754+ }
755+ return _List_fromArray(arr);
756+});
757+
758+var _List_map5 = F6(function(f, vs, ws, xs, ys, zs)
759+{
760+ 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
761+ {
762+ arr.push(A5(f, vs.a, ws.a, xs.a, ys.a, zs.a));
763+ }
764+ return _List_fromArray(arr);
765+});
766+
767+var _List_sortBy = F2(function(f, xs)
768+{
769+ return _List_fromArray(_List_toArray(xs).sort(function(a, b) {
770+ return _Utils_cmp(f(a), f(b));
771+ }));
772+});
773+
774+var _List_sortWith = F2(function(f, xs)
775+{
776+ return _List_fromArray(_List_toArray(xs).sort(function(a, b) {
777+ var ord = A2(f, a, b);
778+ return ord === $elm$core$Basics$EQ ? 0 : ord === $elm$core$Basics$LT ? -1 : 1;
779+ }));
780+});
781+
782+
783+
784+// MATH
785+
786+var _Basics_add = F2(function(a, b) { return a + b; });
787+var _Basics_sub = F2(function(a, b) { return a - b; });
788+var _Basics_mul = F2(function(a, b) { return a * b; });
789+var _Basics_fdiv = F2(function(a, b) { return a / b; });
790+var _Basics_idiv = F2(function(a, b) { return (a / b) | 0; });
791+var _Basics_pow = F2(Math.pow);
792+
793+var _Basics_remainderBy = F2(function(b, a) { return a % b; });
794+
795+// https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/divmodnote-letter.pdf
796+var _Basics_modBy = F2(function(modulus, x)
797+{
798+ var answer = x % modulus;
799+ return modulus === 0
800+ ? _Debug_crash(11)
801+ :
802+ ((answer > 0 && modulus < 0) || (answer < 0 && modulus > 0))
803+ ? answer + modulus
804+ : answer;
805+});
806+
807+
808+// TRIGONOMETRY
809+
810+var _Basics_pi = Math.PI;
811+var _Basics_e = Math.E;
812+var _Basics_cos = Math.cos;
813+var _Basics_sin = Math.sin;
814+var _Basics_tan = Math.tan;
815+var _Basics_acos = Math.acos;
816+var _Basics_asin = Math.asin;
817+var _Basics_atan = Math.atan;
818+var _Basics_atan2 = F2(Math.atan2);
819+
820+
821+// MORE MATH
822+
823+function _Basics_toFloat(x) { return x; }
824+function _Basics_truncate(n) { return n | 0; }
825+function _Basics_isInfinite(n) { return n === Infinity || n === -Infinity; }
826+
827+var _Basics_ceiling = Math.ceil;
828+var _Basics_floor = Math.floor;
829+var _Basics_round = Math.round;
830+var _Basics_sqrt = Math.sqrt;
831+var _Basics_log = Math.log;
832+var _Basics_isNaN = isNaN;
833+
834+
835+// BOOLEANS
836+
837+function _Basics_not(bool) { return !bool; }
838+var _Basics_and = F2(function(a, b) { return a && b; });
839+var _Basics_or = F2(function(a, b) { return a || b; });
840+var _Basics_xor = F2(function(a, b) { return a !== b; });
841+
842+
843+
844+var _String_cons = F2(function(chr, str)
845+{
846+ return chr + str;
847+});
848+
849+function _String_uncons(string)
850+{
851+ var word = string.charCodeAt(0);
852+ return !isNaN(word)
853+ ? $elm$core$Maybe$Just(
854+ 0xD800 <= word && word <= 0xDBFF
855+ ? _Utils_Tuple2(_Utils_chr(string[0] + string[1]), string.slice(2))
856+ : _Utils_Tuple2(_Utils_chr(string[0]), string.slice(1))
857+ )
858+ : $elm$core$Maybe$Nothing;
859+}
860+
861+var _String_append = F2(function(a, b)
862+{
863+ return a + b;
864+});
865+
866+function _String_length(str)
867+{
868+ return str.length;
869+}
870+
871+var _String_map = F2(function(func, string)
872+{
873+ var len = string.length;
874+ var array = new Array(len);
875+ var i = 0;
876+ while (i < len)
877+ {
878+ var word = string.charCodeAt(i);
879+ if (0xD800 <= word && word <= 0xDBFF)
880+ {
881+ array[i] = func(_Utils_chr(string[i] + string[i+1]));
882+ i += 2;
883+ continue;
884+ }
885+ array[i] = func(_Utils_chr(string[i]));
886+ i++;
887+ }
888+ return array.join('');
889+});
890+
891+var _String_filter = F2(function(isGood, str)
892+{
893+ var arr = [];
894+ var len = str.length;
895+ var i = 0;
896+ while (i < len)
897+ {
898+ var char = str[i];
899+ var word = str.charCodeAt(i);
900+ i++;
901+ if (0xD800 <= word && word <= 0xDBFF)
902+ {
903+ char += str[i];
904+ i++;
905+ }
906+
907+ if (isGood(_Utils_chr(char)))
908+ {
909+ arr.push(char);
910+ }
911+ }
912+ return arr.join('');
913+});
914+
915+function _String_reverse(str)
916+{
917+ var len = str.length;
918+ var arr = new Array(len);
919+ var i = 0;
920+ while (i < len)
921+ {
922+ var word = str.charCodeAt(i);
923+ if (0xD800 <= word && word <= 0xDBFF)
924+ {
925+ arr[len - i] = str[i + 1];
926+ i++;
927+ arr[len - i] = str[i - 1];
928+ i++;
929+ }
930+ else
931+ {
932+ arr[len - i] = str[i];
933+ i++;
934+ }
935+ }
936+ return arr.join('');
937+}
938+
939+var _String_foldl = F3(function(func, state, string)
940+{
941+ var len = string.length;
942+ var i = 0;
943+ while (i < len)
944+ {
945+ var char = string[i];
946+ var word = string.charCodeAt(i);
947+ i++;
948+ if (0xD800 <= word && word <= 0xDBFF)
949+ {
950+ char += string[i];
951+ i++;
952+ }
953+ state = A2(func, _Utils_chr(char), state);
954+ }
955+ return state;
956+});
957+
958+var _String_foldr = F3(function(func, state, string)
959+{
960+ var i = string.length;
961+ while (i--)
962+ {
963+ var char = string[i];
964+ var word = string.charCodeAt(i);
965+ if (0xDC00 <= word && word <= 0xDFFF)
966+ {
967+ i--;
968+ char = string[i] + char;
969+ }
970+ state = A2(func, _Utils_chr(char), state);
971+ }
972+ return state;
973+});
974+
975+var _String_split = F2(function(sep, str)
976+{
977+ return str.split(sep);
978+});
979+
980+var _String_join = F2(function(sep, strs)
981+{
982+ return strs.join(sep);
983+});
984+
985+var _String_slice = F3(function(start, end, str) {
986+ return str.slice(start, end);
987+});
988+
989+function _String_trim(str)
990+{
991+ return str.trim();
992+}
993+
994+function _String_trimLeft(str)
995+{
996+ return str.replace(/^\s+/, '');
997+}
998+
999+function _String_trimRight(str)
1000+{
1001+ return str.replace(/\s+$/, '');
1002+}
1003+
1004+function _String_words(str)
1005+{
1006+ return _List_fromArray(str.trim().split(/\s+/g));
1007+}
1008+
1009+function _String_lines(str)
1010+{
1011+ return _List_fromArray(str.split(/\r\n|\r|\n/g));
1012+}
1013+
1014+function _String_toUpper(str)
1015+{
1016+ return str.toUpperCase();
1017+}
1018+
1019+function _String_toLower(str)
1020+{
1021+ return str.toLowerCase();
1022+}
1023+
1024+var _String_any = F2(function(isGood, string)
1025+{
1026+ var i = string.length;
1027+ while (i--)
1028+ {
1029+ var char = string[i];
1030+ var word = string.charCodeAt(i);
1031+ if (0xDC00 <= word && word <= 0xDFFF)
1032+ {
1033+ i--;
1034+ char = string[i] + char;
1035+ }
1036+ if (isGood(_Utils_chr(char)))
1037+ {
1038+ return true;
1039+ }
1040+ }
1041+ return false;
1042+});
1043+
1044+var _String_all = F2(function(isGood, string)
1045+{
1046+ var i = string.length;
1047+ while (i--)
1048+ {
1049+ var char = string[i];
1050+ var word = string.charCodeAt(i);
1051+ if (0xDC00 <= word && word <= 0xDFFF)
1052+ {
1053+ i--;
1054+ char = string[i] + char;
1055+ }
1056+ if (!isGood(_Utils_chr(char)))
1057+ {
1058+ return false;
1059+ }
1060+ }
1061+ return true;
1062+});
1063+
1064+var _String_contains = F2(function(sub, str)
1065+{
1066+ return str.indexOf(sub) > -1;
1067+});
1068+
1069+var _String_startsWith = F2(function(sub, str)
1070+{
1071+ return str.indexOf(sub) === 0;
1072+});
1073+
1074+var _String_endsWith = F2(function(sub, str)
1075+{
1076+ return str.length >= sub.length &&
1077+ str.lastIndexOf(sub) === str.length - sub.length;
1078+});
1079+
1080+var _String_indexes = F2(function(sub, str)
1081+{
1082+ var subLen = sub.length;
1083+
1084+ if (subLen < 1)
1085+ {
1086+ return _List_Nil;
1087+ }
1088+
1089+ var i = 0;
1090+ var is = [];
1091+
1092+ while ((i = str.indexOf(sub, i)) > -1)
1093+ {
1094+ is.push(i);
1095+ i = i + subLen;
1096+ }
1097+
1098+ return _List_fromArray(is);
1099+});
1100+
1101+
1102+// TO STRING
1103+
1104+function _String_fromNumber(number)
1105+{
1106+ return number + '';
1107+}
1108+
1109+
1110+// INT CONVERSIONS
1111+
1112+function _String_toInt(str)
1113+{
1114+ var total = 0;
1115+ var code0 = str.charCodeAt(0);
1116+ var start = code0 == 0x2B /* + */ || code0 == 0x2D /* - */ ? 1 : 0;
1117+
1118+ for (var i = start; i < str.length; ++i)
1119+ {
1120+ var code = str.charCodeAt(i);
1121+ if (code < 0x30 || 0x39 < code)
1122+ {
1123+ return $elm$core$Maybe$Nothing;
1124+ }
1125+ total = 10 * total + code - 0x30;
1126+ }
1127+
1128+ return i == start
1129+ ? $elm$core$Maybe$Nothing
1130+ : $elm$core$Maybe$Just(code0 == 0x2D ? -total : total);
1131+}
1132+
1133+
1134+// FLOAT CONVERSIONS
1135+
1136+function _String_toFloat(s)
1137+{
1138+ // check if it is a hex, octal, or binary number
1139+ if (s.length === 0 || /[\sxbo]/.test(s))
1140+ {
1141+ return $elm$core$Maybe$Nothing;
1142+ }
1143+ var n = +s;
1144+ // faster isNaN check
1145+ return n === n ? $elm$core$Maybe$Just(n) : $elm$core$Maybe$Nothing;
1146+}
1147+
1148+function _String_fromList(chars)
1149+{
1150+ return _List_toArray(chars).join('');
1151+}
1152+
1153+
1154+
1155+
1156+function _Char_toCode(char)
1157+{
1158+ var code = char.charCodeAt(0);
1159+ if (0xD800 <= code && code <= 0xDBFF)
1160+ {
1161+ return (code - 0xD800) * 0x400 + char.charCodeAt(1) - 0xDC00 + 0x10000
1162+ }
1163+ return code;
1164+}
1165+
1166+function _Char_fromCode(code)
1167+{
1168+ return _Utils_chr(
1169+ (code < 0 || 0x10FFFF < code)
1170+ ? '\uFFFD'
1171+ :
1172+ (code <= 0xFFFF)
1173+ ? String.fromCharCode(code)
1174+ :
1175+ (code -= 0x10000,
1176+ String.fromCharCode(Math.floor(code / 0x400) + 0xD800, code % 0x400 + 0xDC00)
1177+ )
1178+ );
1179+}
1180+
1181+function _Char_toUpper(char)
1182+{
1183+ return _Utils_chr(char.toUpperCase());
1184+}
1185+
1186+function _Char_toLower(char)
1187+{
1188+ return _Utils_chr(char.toLowerCase());
1189+}
1190+
1191+function _Char_toLocaleUpper(char)
1192+{
1193+ return _Utils_chr(char.toLocaleUpperCase());
1194+}
1195+
1196+function _Char_toLocaleLower(char)
1197+{
1198+ return _Utils_chr(char.toLocaleLowerCase());
1199+}
1200+
1201+
1202+
1203+/**/
1204+function _Json_errorToString(error)
1205+{
1206+ return $elm$json$Json$Decode$errorToString(error);
1207+}
1208+//*/
1209+
1210+
1211+// CORE DECODERS
1212+
1213+function _Json_succeed(msg)
1214+{
1215+ return {
1216+ $: 0,
1217+ a: msg
1218+ };
1219+}
1220+
1221+function _Json_fail(msg)
1222+{
1223+ return {
1224+ $: 1,
1225+ a: msg
1226+ };
1227+}
1228+
1229+function _Json_decodePrim(decoder)
1230+{
1231+ return { $: 2, b: decoder };
1232+}
1233+
1234+var _Json_decodeInt = _Json_decodePrim(function(value) {
1235+ return (typeof value !== 'number')
1236+ ? _Json_expecting('an INT', value)
1237+ :
1238+ (-2147483647 < value && value < 2147483647 && (value | 0) === value)
1239+ ? $elm$core$Result$Ok(value)
1240+ :
1241+ (isFinite(value) && !(value % 1))
1242+ ? $elm$core$Result$Ok(value)
1243+ : _Json_expecting('an INT', value);
1244+});
1245+
1246+var _Json_decodeBool = _Json_decodePrim(function(value) {
1247+ return (typeof value === 'boolean')
1248+ ? $elm$core$Result$Ok(value)
1249+ : _Json_expecting('a BOOL', value);
1250+});
1251+
1252+var _Json_decodeFloat = _Json_decodePrim(function(value) {
1253+ return (typeof value === 'number')
1254+ ? $elm$core$Result$Ok(value)
1255+ : _Json_expecting('a FLOAT', value);
1256+});
1257+
1258+var _Json_decodeValue = _Json_decodePrim(function(value) {
1259+ return $elm$core$Result$Ok(_Json_wrap(value));
1260+});
1261+
1262+var _Json_decodeString = _Json_decodePrim(function(value) {
1263+ return (typeof value === 'string')
1264+ ? $elm$core$Result$Ok(value)
1265+ : (value instanceof String)
1266+ ? $elm$core$Result$Ok(value + '')
1267+ : _Json_expecting('a STRING', value);
1268+});
1269+
1270+function _Json_decodeList(decoder) { return { $: 3, b: decoder }; }
1271+function _Json_decodeArray(decoder) { return { $: 4, b: decoder }; }
1272+
1273+function _Json_decodeNull(value) { return { $: 5, c: value }; }
1274+
1275+var _Json_decodeField = F2(function(field, decoder)
1276+{
1277+ return {
1278+ $: 6,
1279+ d: field,
1280+ b: decoder
1281+ };
1282+});
1283+
1284+var _Json_decodeIndex = F2(function(index, decoder)
1285+{
1286+ return {
1287+ $: 7,
1288+ e: index,
1289+ b: decoder
1290+ };
1291+});
1292+
1293+function _Json_decodeKeyValuePairs(decoder)
1294+{
1295+ return {
1296+ $: 8,
1297+ b: decoder
1298+ };
1299+}
1300+
1301+function _Json_mapMany(f, decoders)
1302+{
1303+ return {
1304+ $: 9,
1305+ f: f,
1306+ g: decoders
1307+ };
1308+}
1309+
1310+var _Json_andThen = F2(function(callback, decoder)
1311+{
1312+ return {
1313+ $: 10,
1314+ b: decoder,
1315+ h: callback
1316+ };
1317+});
1318+
1319+function _Json_oneOf(decoders)
1320+{
1321+ return {
1322+ $: 11,
1323+ g: decoders
1324+ };
1325+}
1326+
1327+
1328+// DECODING OBJECTS
1329+
1330+var _Json_map1 = F2(function(f, d1)
1331+{
1332+ return _Json_mapMany(f, [d1]);
1333+});
1334+
1335+var _Json_map2 = F3(function(f, d1, d2)
1336+{
1337+ return _Json_mapMany(f, [d1, d2]);
1338+});
1339+
1340+var _Json_map3 = F4(function(f, d1, d2, d3)
1341+{
1342+ return _Json_mapMany(f, [d1, d2, d3]);
1343+});
1344+
1345+var _Json_map4 = F5(function(f, d1, d2, d3, d4)
1346+{
1347+ return _Json_mapMany(f, [d1, d2, d3, d4]);
1348+});
1349+
1350+var _Json_map5 = F6(function(f, d1, d2, d3, d4, d5)
1351+{
1352+ return _Json_mapMany(f, [d1, d2, d3, d4, d5]);
1353+});
1354+
1355+var _Json_map6 = F7(function(f, d1, d2, d3, d4, d5, d6)
1356+{
1357+ return _Json_mapMany(f, [d1, d2, d3, d4, d5, d6]);
1358+});
1359+
1360+var _Json_map7 = F8(function(f, d1, d2, d3, d4, d5, d6, d7)
1361+{
1362+ return _Json_mapMany(f, [d1, d2, d3, d4, d5, d6, d7]);
1363+});
1364+
1365+var _Json_map8 = F9(function(f, d1, d2, d3, d4, d5, d6, d7, d8)
1366+{
1367+ return _Json_mapMany(f, [d1, d2, d3, d4, d5, d6, d7, d8]);
1368+});
1369+
1370+
1371+// DECODE
1372+
1373+var _Json_runOnString = F2(function(decoder, string)
1374+{
1375+ try
1376+ {
1377+ var value = JSON.parse(string);
1378+ return _Json_runHelp(decoder, value);
1379+ }
1380+ catch (e)
1381+ {
1382+ return $elm$core$Result$Err(A2($elm$json$Json$Decode$Failure, 'This is not valid JSON! ' + e.message, _Json_wrap(string)));
1383+ }
1384+});
1385+
1386+var _Json_run = F2(function(decoder, value)
1387+{
1388+ return _Json_runHelp(decoder, _Json_unwrap(value));
1389+});
1390+
1391+function _Json_runHelp(decoder, value)
1392+{
1393+ switch (decoder.$)
1394+ {
1395+ case 2:
1396+ return decoder.b(value);
1397+
1398+ case 5:
1399+ return (value === null)
1400+ ? $elm$core$Result$Ok(decoder.c)
1401+ : _Json_expecting('null', value);
1402+
1403+ case 3:
1404+ if (!_Json_isArray(value))
1405+ {
1406+ return _Json_expecting('a LIST', value);
1407+ }
1408+ return _Json_runArrayDecoder(decoder.b, value, _List_fromArray);
1409+
1410+ case 4:
1411+ if (!_Json_isArray(value))
1412+ {
1413+ return _Json_expecting('an ARRAY', value);
1414+ }
1415+ return _Json_runArrayDecoder(decoder.b, value, _Json_toElmArray);
1416+
1417+ case 6:
1418+ var field = decoder.d;
1419+ if (typeof value !== 'object' || value === null || !(field in value))
1420+ {
1421+ return _Json_expecting('an OBJECT with a field named `' + field + '`', value);
1422+ }
1423+ var result = _Json_runHelp(decoder.b, value[field]);
1424+ return ($elm$core$Result$isOk(result)) ? result : $elm$core$Result$Err(A2($elm$json$Json$Decode$Field, field, result.a));
1425+
1426+ case 7:
1427+ var index = decoder.e;
1428+ if (!_Json_isArray(value))
1429+ {
1430+ return _Json_expecting('an ARRAY', value);
1431+ }
1432+ if (index >= value.length)
1433+ {
1434+ return _Json_expecting('a LONGER array. Need index ' + index + ' but only see ' + value.length + ' entries', value);
1435+ }
1436+ var result = _Json_runHelp(decoder.b, value[index]);
1437+ return ($elm$core$Result$isOk(result)) ? result : $elm$core$Result$Err(A2($elm$json$Json$Decode$Index, index, result.a));
1438+
1439+ case 8:
1440+ if (typeof value !== 'object' || value === null || _Json_isArray(value))
1441+ {
1442+ return _Json_expecting('an OBJECT', value);
1443+ }
1444+
1445+ var keyValuePairs = _List_Nil;
1446+ // TODO test perf of Object.keys and switch when support is good enough
1447+ for (var key in value)
1448+ {
1449+ if (value.hasOwnProperty(key))
1450+ {
1451+ var result = _Json_runHelp(decoder.b, value[key]);
1452+ if (!$elm$core$Result$isOk(result))
1453+ {
1454+ return $elm$core$Result$Err(A2($elm$json$Json$Decode$Field, key, result.a));
1455+ }
1456+ keyValuePairs = _List_Cons(_Utils_Tuple2(key, result.a), keyValuePairs);
1457+ }
1458+ }
1459+ return $elm$core$Result$Ok($elm$core$List$reverse(keyValuePairs));
1460+
1461+ case 9:
1462+ var answer = decoder.f;
1463+ var decoders = decoder.g;
1464+ for (var i = 0; i < decoders.length; i++)
1465+ {
1466+ var result = _Json_runHelp(decoders[i], value);
1467+ if (!$elm$core$Result$isOk(result))
1468+ {
1469+ return result;
1470+ }
1471+ answer = answer(result.a);
1472+ }
1473+ return $elm$core$Result$Ok(answer);
1474+
1475+ case 10:
1476+ var result = _Json_runHelp(decoder.b, value);
1477+ return (!$elm$core$Result$isOk(result))
1478+ ? result
1479+ : _Json_runHelp(decoder.h(result.a), value);
1480+
1481+ case 11:
1482+ var errors = _List_Nil;
1483+ for (var temp = decoder.g; temp.b; temp = temp.b) // WHILE_CONS
1484+ {
1485+ var result = _Json_runHelp(temp.a, value);
1486+ if ($elm$core$Result$isOk(result))
1487+ {
1488+ return result;
1489+ }
1490+ errors = _List_Cons(result.a, errors);
1491+ }
1492+ return $elm$core$Result$Err($elm$json$Json$Decode$OneOf($elm$core$List$reverse(errors)));
1493+
1494+ case 1:
1495+ return $elm$core$Result$Err(A2($elm$json$Json$Decode$Failure, decoder.a, _Json_wrap(value)));
1496+
1497+ case 0:
1498+ return $elm$core$Result$Ok(decoder.a);
1499+ }
1500+}
1501+
1502+function _Json_runArrayDecoder(decoder, value, toElmValue)
1503+{
1504+ var len = value.length;
1505+ var array = new Array(len);
1506+ for (var i = 0; i < len; i++)
1507+ {
1508+ var result = _Json_runHelp(decoder, value[i]);
1509+ if (!$elm$core$Result$isOk(result))
1510+ {
1511+ return $elm$core$Result$Err(A2($elm$json$Json$Decode$Index, i, result.a));
1512+ }
1513+ array[i] = result.a;
1514+ }
1515+ return $elm$core$Result$Ok(toElmValue(array));
1516+}
1517+
1518+function _Json_isArray(value)
1519+{
1520+ return Array.isArray(value) || (typeof FileList !== 'undefined' && value instanceof FileList);
1521+}
1522+
1523+function _Json_toElmArray(array)
1524+{
1525+ return A2($elm$core$Array$initialize, array.length, function(i) { return array[i]; });
1526+}
1527+
1528+function _Json_expecting(type, value)
1529+{
1530+ return $elm$core$Result$Err(A2($elm$json$Json$Decode$Failure, 'Expecting ' + type, _Json_wrap(value)));
1531+}
1532+
1533+
1534+// EQUALITY
1535+
1536+function _Json_equality(x, y)
1537+{
1538+ if (x === y)
1539+ {
1540+ return true;
1541+ }
1542+
1543+ if (x.$ !== y.$)
1544+ {
1545+ return false;
1546+ }
1547+
1548+ switch (x.$)
1549+ {
1550+ case 0:
1551+ case 1:
1552+ return x.a === y.a;
1553+
1554+ case 2:
1555+ return x.b === y.b;
1556+
1557+ case 5:
1558+ return x.c === y.c;
1559+
1560+ case 3:
1561+ case 4:
1562+ case 8:
1563+ return _Json_equality(x.b, y.b);
1564+
1565+ case 6:
1566+ return x.d === y.d && _Json_equality(x.b, y.b);
1567+
1568+ case 7:
1569+ return x.e === y.e && _Json_equality(x.b, y.b);
1570+
1571+ case 9:
1572+ return x.f === y.f && _Json_listEquality(x.g, y.g);
1573+
1574+ case 10:
1575+ return x.h === y.h && _Json_equality(x.b, y.b);
1576+
1577+ case 11:
1578+ return _Json_listEquality(x.g, y.g);
1579+ }
1580+}
1581+
1582+function _Json_listEquality(aDecoders, bDecoders)
1583+{
1584+ var len = aDecoders.length;
1585+ if (len !== bDecoders.length)
1586+ {
1587+ return false;
1588+ }
1589+ for (var i = 0; i < len; i++)
1590+ {
1591+ if (!_Json_equality(aDecoders[i], bDecoders[i]))
1592+ {
1593+ return false;
1594+ }
1595+ }
1596+ return true;
1597+}
1598+
1599+
1600+// ENCODE
1601+
1602+var _Json_encode = F2(function(indentLevel, value)
1603+{
1604+ return JSON.stringify(_Json_unwrap(value), null, indentLevel) + '';
1605+});
1606+
1607+function _Json_wrap(value) { return { $: 0, a: value }; }
1608+function _Json_unwrap(value) { return value.a; }
1609+
1610+
1611+function _Json_emptyArray() { return []; }
1612+function _Json_emptyObject() { return {}; }
1613+
1614+var _Json_addField = F3(function(key, value, object)
1615+{
1616+ object[key] = _Json_unwrap(value);
1617+ return object;
1618+});
1619+
1620+function _Json_addEntry(func)
1621+{
1622+ return F2(function(entry, array)
1623+ {
1624+ array.push(_Json_unwrap(func(entry)));
1625+ return array;
1626+ });
1627+}
1628+
1629+var _Json_encodeNull = _Json_wrap(null);
1630+
1631+
1632+
1633+// TASKS
1634+
1635+function _Scheduler_succeed(value)
1636+{
1637+ return {
1638+ $: 0,
1639+ a: value
1640+ };
1641+}
1642+
1643+function _Scheduler_fail(error)
1644+{
1645+ return {
1646+ $: 1,
1647+ a: error
1648+ };
1649+}
1650+
1651+function _Scheduler_binding(callback)
1652+{
1653+ return {
1654+ $: 2,
1655+ b: callback,
1656+ c: null
1657+ };
1658+}
1659+
1660+var _Scheduler_andThen = F2(function(callback, task)
1661+{
1662+ return {
1663+ $: 3,
1664+ b: callback,
1665+ d: task
1666+ };
1667+});
1668+
1669+var _Scheduler_onError = F2(function(callback, task)
1670+{
1671+ return {
1672+ $: 4,
1673+ b: callback,
1674+ d: task
1675+ };
1676+});
1677+
1678+function _Scheduler_receive(callback)
1679+{
1680+ return {
1681+ $: 5,
1682+ b: callback
1683+ };
1684+}
1685+
1686+
1687+// PROCESSES
1688+
1689+var _Scheduler_guid = 0;
1690+
1691+function _Scheduler_rawSpawn(task)
1692+{
1693+ var proc = {
1694+ $: 0,
1695+ e: _Scheduler_guid++,
1696+ f: task,
1697+ g: null,
1698+ h: []
1699+ };
1700+
1701+ _Scheduler_enqueue(proc);
1702+
1703+ return proc;
1704+}
1705+
1706+function _Scheduler_spawn(task)
1707+{
1708+ return _Scheduler_binding(function(callback) {
1709+ callback(_Scheduler_succeed(_Scheduler_rawSpawn(task)));
1710+ });
1711+}
1712+
1713+function _Scheduler_rawSend(proc, msg)
1714+{
1715+ proc.h.push(msg);
1716+ _Scheduler_enqueue(proc);
1717+}
1718+
1719+var _Scheduler_send = F2(function(proc, msg)
1720+{
1721+ return _Scheduler_binding(function(callback) {
1722+ _Scheduler_rawSend(proc, msg);
1723+ callback(_Scheduler_succeed(_Utils_Tuple0));
1724+ });
1725+});
1726+
1727+function _Scheduler_kill(proc)
1728+{
1729+ return _Scheduler_binding(function(callback) {
1730+ var task = proc.f;
1731+ if (task.$ === 2 && task.c)
1732+ {
1733+ task.c();
1734+ }
1735+
1736+ proc.f = null;
1737+
1738+ callback(_Scheduler_succeed(_Utils_Tuple0));
1739+ });
1740+}
1741+
1742+
1743+/* STEP PROCESSES
1744+
1745+type alias Process =
1746+ { $ : tag
1747+ , id : unique_id
1748+ , root : Task
1749+ , stack : null | { $: SUCCEED | FAIL, a: callback, b: stack }
1750+ , mailbox : [msg]
1751+ }
1752+
1753+*/
1754+
1755+
1756+var _Scheduler_working = false;
1757+var _Scheduler_queue = [];
1758+
1759+
1760+function _Scheduler_enqueue(proc)
1761+{
1762+ _Scheduler_queue.push(proc);
1763+ if (_Scheduler_working)
1764+ {
1765+ return;
1766+ }
1767+ _Scheduler_working = true;
1768+ while (proc = _Scheduler_queue.shift())
1769+ {
1770+ _Scheduler_step(proc);
1771+ }
1772+ _Scheduler_working = false;
1773+}
1774+
1775+
1776+function _Scheduler_step(proc)
1777+{
1778+ while (proc.f)
1779+ {
1780+ var rootTag = proc.f.$;
1781+ if (rootTag === 0 || rootTag === 1)
1782+ {
1783+ while (proc.g && proc.g.$ !== rootTag)
1784+ {
1785+ proc.g = proc.g.i;
1786+ }
1787+ if (!proc.g)
1788+ {
1789+ return;
1790+ }
1791+ proc.f = proc.g.b(proc.f.a);
1792+ proc.g = proc.g.i;
1793+ }
1794+ else if (rootTag === 2)
1795+ {
1796+ proc.f.c = proc.f.b(function(newRoot) {
1797+ proc.f = newRoot;
1798+ _Scheduler_enqueue(proc);
1799+ });
1800+ return;
1801+ }
1802+ else if (rootTag === 5)
1803+ {
1804+ if (proc.h.length === 0)
1805+ {
1806+ return;
1807+ }
1808+ proc.f = proc.f.b(proc.h.shift());
1809+ }
1810+ else // if (rootTag === 3 || rootTag === 4)
1811+ {
1812+ proc.g = {
1813+ $: rootTag === 3 ? 0 : 1,
1814+ b: proc.f.b,
1815+ i: proc.g
1816+ };
1817+ proc.f = proc.f.d;
1818+ }
1819+ }
1820+}
1821+
1822+
1823+
1824+function _Process_sleep(time)
1825+{
1826+ return _Scheduler_binding(function(callback) {
1827+ var id = setTimeout(function() {
1828+ callback(_Scheduler_succeed(_Utils_Tuple0));
1829+ }, time);
1830+
1831+ return function() { clearTimeout(id); };
1832+ });
1833+}
1834+
1835+
1836+
1837+
1838+// PROGRAMS
1839+
1840+
1841+var _Platform_worker = F4(function(impl, flagDecoder, debugMetadata, args)
1842+{
1843+ return _Platform_initialize(
1844+ flagDecoder,
1845+ args,
1846+ impl.init,
1847+ impl.update,
1848+ impl.subscriptions,
1849+ function() { return function() {} }
1850+ );
1851+});
1852+
1853+
1854+
1855+// INITIALIZE A PROGRAM
1856+
1857+
1858+function _Platform_initialize(flagDecoder, args, init, update, subscriptions, stepperBuilder)
1859+{
1860+ var result = A2(_Json_run, flagDecoder, _Json_wrap(args ? args['flags'] : undefined));
1861+ $elm$core$Result$isOk(result) || _Debug_crash(2 /**/, _Json_errorToString(result.a) /**/);
1862+ var managers = {};
1863+ var initPair = init(result.a);
1864+ var model = initPair.a;
1865+ var stepper = stepperBuilder(sendToApp, model);
1866+ var ports = _Platform_setupEffects(managers, sendToApp);
1867+
1868+ function sendToApp(msg, viewMetadata)
1869+ {
1870+ var pair = A2(update, msg, model);
1871+ stepper(model = pair.a, viewMetadata);
1872+ _Platform_enqueueEffects(managers, pair.b, subscriptions(model));
1873+ }
1874+
1875+ _Platform_enqueueEffects(managers, initPair.b, subscriptions(model));
1876+
1877+ return ports ? { ports: ports } : {};
1878+}
1879+
1880+
1881+
1882+// TRACK PRELOADS
1883+//
1884+// This is used by code in elm/browser and elm/http
1885+// to register any HTTP requests that are triggered by init.
1886+//
1887+
1888+
1889+var _Platform_preload;
1890+
1891+
1892+function _Platform_registerPreload(url)
1893+{
1894+ _Platform_preload.add(url);
1895+}
1896+
1897+
1898+
1899+// EFFECT MANAGERS
1900+
1901+
1902+var _Platform_effectManagers = {};
1903+
1904+
1905+function _Platform_setupEffects(managers, sendToApp)
1906+{
1907+ var ports;
1908+
1909+ // setup all necessary effect managers
1910+ for (var key in _Platform_effectManagers)
1911+ {
1912+ var manager = _Platform_effectManagers[key];
1913+
1914+ if (manager.a)
1915+ {
1916+ ports = ports || {};
1917+ ports[key] = manager.a(key, sendToApp);
1918+ }
1919+
1920+ managers[key] = _Platform_instantiateManager(manager, sendToApp);
1921+ }
1922+
1923+ return ports;
1924+}
1925+
1926+
1927+function _Platform_createManager(init, onEffects, onSelfMsg, cmdMap, subMap)
1928+{
1929+ return {
1930+ b: init,
1931+ c: onEffects,
1932+ d: onSelfMsg,
1933+ e: cmdMap,
1934+ f: subMap
1935+ };
1936+}
1937+
1938+
1939+function _Platform_instantiateManager(info, sendToApp)
1940+{
1941+ var router = {
1942+ g: sendToApp,
1943+ h: undefined
1944+ };
1945+
1946+ var onEffects = info.c;
1947+ var onSelfMsg = info.d;
1948+ var cmdMap = info.e;
1949+ var subMap = info.f;
1950+
1951+ function loop(state)
1952+ {
1953+ return A2(_Scheduler_andThen, loop, _Scheduler_receive(function(msg)
1954+ {
1955+ var value = msg.a;
1956+
1957+ if (msg.$ === 0)
1958+ {
1959+ return A3(onSelfMsg, router, value, state);
1960+ }
1961+
1962+ return cmdMap && subMap
1963+ ? A4(onEffects, router, value.i, value.j, state)
1964+ : A3(onEffects, router, cmdMap ? value.i : value.j, state);
1965+ }));
1966+ }
1967+
1968+ return router.h = _Scheduler_rawSpawn(A2(_Scheduler_andThen, loop, info.b));
1969+}
1970+
1971+
1972+
1973+// ROUTING
1974+
1975+
1976+var _Platform_sendToApp = F2(function(router, msg)
1977+{
1978+ return _Scheduler_binding(function(callback)
1979+ {
1980+ router.g(msg);
1981+ callback(_Scheduler_succeed(_Utils_Tuple0));
1982+ });
1983+});
1984+
1985+
1986+var _Platform_sendToSelf = F2(function(router, msg)
1987+{
1988+ return A2(_Scheduler_send, router.h, {
1989+ $: 0,
1990+ a: msg
1991+ });
1992+});
1993+
1994+
1995+
1996+// BAGS
1997+
1998+
1999+function _Platform_leaf(home)
2000+{
2001+ return function(value)
2002+ {
2003+ return {
2004+ $: 1,
2005+ k: home,
2006+ l: value
2007+ };
2008+ };
2009+}
2010+
2011+
2012+function _Platform_batch(list)
2013+{
2014+ return {
2015+ $: 2,
2016+ m: list
2017+ };
2018+}
2019+
2020+
2021+var _Platform_map = F2(function(tagger, bag)
2022+{
2023+ return {
2024+ $: 3,
2025+ n: tagger,
2026+ o: bag
2027+ }
2028+});
2029+
2030+
2031+
2032+// PIPE BAGS INTO EFFECT MANAGERS
2033+//
2034+// Effects must be queued!
2035+//
2036+// Say your init contains a synchronous command, like Time.now or Time.here
2037+//
2038+// - This will produce a batch of effects (FX_1)
2039+// - The synchronous task triggers the subsequent `update` call
2040+// - This will produce a batch of effects (FX_2)
2041+//
2042+// If we just start dispatching FX_2, subscriptions from FX_2 can be processed
2043+// before subscriptions from FX_1. No good! Earlier versions of this code had
2044+// this problem, leading to these reports:
2045+//
2046+// https://github.com/elm/core/issues/980
2047+// https://github.com/elm/core/pull/981
2048+// https://github.com/elm/compiler/issues/1776
2049+//
2050+// The queue is necessary to avoid ordering issues for synchronous commands.
2051+
2052+
2053+// Why use true/false here? Why not just check the length of the queue?
2054+// The goal is to detect "are we currently dispatching effects?" If we
2055+// are, we need to bail and let the ongoing while loop handle things.
2056+//
2057+// Now say the queue has 1 element. When we dequeue the final element,
2058+// the queue will be empty, but we are still actively dispatching effects.
2059+// So you could get queue jumping in a really tricky category of cases.
2060+//
2061+var _Platform_effectsQueue = [];
2062+var _Platform_effectsActive = false;
2063+
2064+
2065+function _Platform_enqueueEffects(managers, cmdBag, subBag)
2066+{
2067+ _Platform_effectsQueue.push({ p: managers, q: cmdBag, r: subBag });
2068+
2069+ if (_Platform_effectsActive) return;
2070+
2071+ _Platform_effectsActive = true;
2072+ for (var fx; fx = _Platform_effectsQueue.shift(); )
2073+ {
2074+ _Platform_dispatchEffects(fx.p, fx.q, fx.r);
2075+ }
2076+ _Platform_effectsActive = false;
2077+}
2078+
2079+
2080+function _Platform_dispatchEffects(managers, cmdBag, subBag)
2081+{
2082+ var effectsDict = {};
2083+ _Platform_gatherEffects(true, cmdBag, effectsDict, null);
2084+ _Platform_gatherEffects(false, subBag, effectsDict, null);
2085+
2086+ for (var home in managers)
2087+ {
2088+ _Scheduler_rawSend(managers[home], {
2089+ $: 'fx',
2090+ a: effectsDict[home] || { i: _List_Nil, j: _List_Nil }
2091+ });
2092+ }
2093+}
2094+
2095+
2096+function _Platform_gatherEffects(isCmd, bag, effectsDict, taggers)
2097+{
2098+ switch (bag.$)
2099+ {
2100+ case 1:
2101+ var home = bag.k;
2102+ var effect = _Platform_toEffect(isCmd, home, taggers, bag.l);
2103+ effectsDict[home] = _Platform_insert(isCmd, effect, effectsDict[home]);
2104+ return;
2105+
2106+ case 2:
2107+ for (var list = bag.m; list.b; list = list.b) // WHILE_CONS
2108+ {
2109+ _Platform_gatherEffects(isCmd, list.a, effectsDict, taggers);
2110+ }
2111+ return;
2112+
2113+ case 3:
2114+ _Platform_gatherEffects(isCmd, bag.o, effectsDict, {
2115+ s: bag.n,
2116+ t: taggers
2117+ });
2118+ return;
2119+ }
2120+}
2121+
2122+
2123+function _Platform_toEffect(isCmd, home, taggers, value)
2124+{
2125+ function applyTaggers(x)
2126+ {
2127+ for (var temp = taggers; temp; temp = temp.t)
2128+ {
2129+ x = temp.s(x);
2130+ }
2131+ return x;
2132+ }
2133+
2134+ var map = isCmd
2135+ ? _Platform_effectManagers[home].e
2136+ : _Platform_effectManagers[home].f;
2137+
2138+ return A2(map, applyTaggers, value)
2139+}
2140+
2141+
2142+function _Platform_insert(isCmd, newEffect, effects)
2143+{
2144+ effects = effects || { i: _List_Nil, j: _List_Nil };
2145+
2146+ isCmd
2147+ ? (effects.i = _List_Cons(newEffect, effects.i))
2148+ : (effects.j = _List_Cons(newEffect, effects.j));
2149+
2150+ return effects;
2151+}
2152+
2153+
2154+
2155+// PORTS
2156+
2157+
2158+function _Platform_checkPortName(name)
2159+{
2160+ if (_Platform_effectManagers[name])
2161+ {
2162+ _Debug_crash(3, name)
2163+ }
2164+}
2165+
2166+
2167+
2168+// OUTGOING PORTS
2169+
2170+
2171+function _Platform_outgoingPort(name, converter)
2172+{
2173+ _Platform_checkPortName(name);
2174+ _Platform_effectManagers[name] = {
2175+ e: _Platform_outgoingPortMap,
2176+ u: converter,
2177+ a: _Platform_setupOutgoingPort
2178+ };
2179+ return _Platform_leaf(name);
2180+}
2181+
2182+
2183+var _Platform_outgoingPortMap = F2(function(tagger, value) { return value; });
2184+
2185+
2186+function _Platform_setupOutgoingPort(name)
2187+{
2188+ var subs = [];
2189+ var converter = _Platform_effectManagers[name].u;
2190+
2191+ // CREATE MANAGER
2192+
2193+ var init = _Process_sleep(0);
2194+
2195+ _Platform_effectManagers[name].b = init;
2196+ _Platform_effectManagers[name].c = F3(function(router, cmdList, state)
2197+ {
2198+ for ( ; cmdList.b; cmdList = cmdList.b) // WHILE_CONS
2199+ {
2200+ // grab a separate reference to subs in case unsubscribe is called
2201+ var currentSubs = subs;
2202+ var value = _Json_unwrap(converter(cmdList.a));
2203+ for (var i = 0; i < currentSubs.length; i++)
2204+ {
2205+ currentSubs[i](value);
2206+ }
2207+ }
2208+ return init;
2209+ });
2210+
2211+ // PUBLIC API
2212+
2213+ function subscribe(callback)
2214+ {
2215+ subs.push(callback);
2216+ }
2217+
2218+ function unsubscribe(callback)
2219+ {
2220+ // copy subs into a new array in case unsubscribe is called within a
2221+ // subscribed callback
2222+ subs = subs.slice();
2223+ var index = subs.indexOf(callback);
2224+ if (index >= 0)
2225+ {
2226+ subs.splice(index, 1);
2227+ }
2228+ }
2229+
2230+ return {
2231+ subscribe: subscribe,
2232+ unsubscribe: unsubscribe
2233+ };
2234+}
2235+
2236+
2237+
2238+// INCOMING PORTS
2239+
2240+
2241+function _Platform_incomingPort(name, converter)
2242+{
2243+ _Platform_checkPortName(name);
2244+ _Platform_effectManagers[name] = {
2245+ f: _Platform_incomingPortMap,
2246+ u: converter,
2247+ a: _Platform_setupIncomingPort
2248+ };
2249+ return _Platform_leaf(name);
2250+}
2251+
2252+
2253+var _Platform_incomingPortMap = F2(function(tagger, finalTagger)
2254+{
2255+ return function(value)
2256+ {
2257+ return tagger(finalTagger(value));
2258+ };
2259+});
2260+
2261+
2262+function _Platform_setupIncomingPort(name, sendToApp)
2263+{
2264+ var subs = _List_Nil;
2265+ var converter = _Platform_effectManagers[name].u;
2266+
2267+ // CREATE MANAGER
2268+
2269+ var init = _Scheduler_succeed(null);
2270+
2271+ _Platform_effectManagers[name].b = init;
2272+ _Platform_effectManagers[name].c = F3(function(router, subList, state)
2273+ {
2274+ subs = subList;
2275+ return init;
2276+ });
2277+
2278+ // PUBLIC API
2279+
2280+ function send(incomingValue)
2281+ {
2282+ var result = A2(_Json_run, converter, _Json_wrap(incomingValue));
2283+
2284+ $elm$core$Result$isOk(result) || _Debug_crash(4, name, result.a);
2285+
2286+ var value = result.a;
2287+ for (var temp = subs; temp.b; temp = temp.b) // WHILE_CONS
2288+ {
2289+ sendToApp(temp.a(value));
2290+ }
2291+ }
2292+
2293+ return { send: send };
2294+}
2295+
2296+
2297+
2298+// EXPORT ELM MODULES
2299+//
2300+// Have DEBUG and PROD versions so that we can (1) give nicer errors in
2301+// debug mode and (2) not pay for the bits needed for that in prod mode.
2302+//
2303+
2304+
2305+{
2306+ scope['Elm']
2307+ ? _Platform_mergeExportsProd(scope['Elm'], exports)
2308+ : scope['Elm'] = exports;
2309+}
2310+
2311+
2312+function _Platform_mergeExportsProd(obj, exports)
2313+{
2314+ for (var name in exports)
2315+ {
2316+ (name in obj)
2317+ ? (name == 'init')
2318+ ? _Debug_crash(6)
2319+ : _Platform_mergeExportsProd(obj[name], exports[name])
2320+ : (obj[name] = exports[name]);
2321+ }
2322+}
2323+
2324+
2325+function _Platform_export(exports)
2326+{
2327+ scope['Elm']
2328+ ? _Platform_mergeExportsDebug('Elm', scope['Elm'], exports)
2329+ : scope['Elm'] = exports;
2330+}
2331+
2332+
2333+function _Platform_mergeExportsDebug(moduleName, obj, exports)
2334+{
2335+ for (var name in exports)
2336+ {
2337+ (name in obj)
2338+ ? (name == 'init')
2339+ ? _Debug_crash(6, moduleName)
2340+ : _Platform_mergeExportsDebug(moduleName + '.' + name, obj[name], exports[name])
2341+ : (obj[name] = exports[name]);
2342+ }
2343+}
2344+
2345+
2346+
2347+var _Lynx_g = (typeof globalThis !== 'undefined' ? globalThis : scope);
2348+function _Lynx_papi(name) { return _Lynx_g['_' + '_' + name] || function() {}; }
2349+var _Lynx_createViewFn = _Lynx_papi('CreateView');
2350+var _Lynx_createTextFn = _Lynx_papi('CreateText');
2351+var _Lynx_createImageFn = _Lynx_papi('CreateImage');
2352+function _Lynx_createElement(tag) {
2353+ var pId = (_Lynx_g['native'] && _Lynx_g['native']['currentPageId']) || 0;
2354+ return (tag === 'text' ? _Lynx_createTextFn
2355+ : tag === 'image' ? _Lynx_createImageFn
2356+ : _Lynx_createViewFn)(pId);
2357+}
2358+var _Lynx_createRawText = _Lynx_papi('CreateRawText');
2359+var _Lynx_appendChild = _Lynx_papi('AppendElement');
2360+var _Lynx_removeElement = _Lynx_papi('RemoveElement');
2361+var _Lynx_replaceElement = _Lynx_papi('ReplaceElement');
2362+var _Lynx_insertBefore = _Lynx_papi('InsertElementBefore');
2363+var _Lynx_setAttribute = _Lynx_papi('SetAttribute');
2364+var _Lynx_getChildren = _Lynx_papi('GetChildren');
2365+var _Lynx_getParent = _Lynx_papi('GetParent');
2366+var _Lynx_addEvent = _Lynx_papi('AddEvent');
2367+var _Lynx_setInlineStyles = _Lynx_papi('SetInlineStyles');
2368+var _VirtualDom_elementMeta = new WeakMap();
2369+function _VirtualDom_getMeta(el) {
2370+ var meta = _VirtualDom_elementMeta.get(el);
2371+ if (!meta) { meta = {}; _VirtualDom_elementMeta.set(el, meta); }
2372+ return meta;
2373+}
2374+
2375+
2376+// HELPERS
2377+
2378+
2379+
2380+
2381+
2382+function _VirtualDom_appendChild(parent, child)
2383+{
2384+ _Lynx_appendChild(parent, child);
2385+}
2386+
2387+var _VirtualDom_init = F4(function(virtualNode, flagDecoder, debugMetadata, args)
2388+{
2389+ // NOTE: this function needs _Platform_export available to work
2390+ var rootPage = args['node'] || _Lynx_g['page'];
2391+ var tree = _VirtualDom_render(virtualNode, function() {});
2392+ _Lynx_appendChild(rootPage, tree);
2393+ return {};
2394+});
2395+
2396+
2397+
2398+// TEXT
2399+
2400+
2401+function _VirtualDom_text(string)
2402+{
2403+ return {
2404+ $: 0,
2405+ a: string
2406+ };
2407+}
2408+
2409+
2410+
2411+// NODE
2412+
2413+
2414+var _VirtualDom_nodeNS = F2(function(namespace, tag)
2415+{
2416+ return F2(function(factList, kidList)
2417+ {
2418+ for (var kids = [], descendantsCount = 0; kidList.b; kidList = kidList.b) // WHILE_CONS
2419+ {
2420+ var kid = kidList.a;
2421+ descendantsCount += (kid.b || 0);
2422+ kids.push(kid);
2423+ }
2424+ descendantsCount += kids.length;
2425+
2426+ return {
2427+ $: 1,
2428+ c: tag,
2429+ d: _VirtualDom_organizeFacts(factList),
2430+ e: kids,
2431+ f: namespace,
2432+ b: descendantsCount
2433+ };
2434+ });
2435+});
2436+
2437+
2438+var _VirtualDom_node = _VirtualDom_nodeNS(undefined);
2439+
2440+
2441+
2442+// KEYED NODE
2443+
2444+
2445+var _VirtualDom_keyedNodeNS = F2(function(namespace, tag)
2446+{
2447+ return F2(function(factList, kidList)
2448+ {
2449+ for (var kids = [], descendantsCount = 0; kidList.b; kidList = kidList.b) // WHILE_CONS
2450+ {
2451+ var kid = kidList.a;
2452+ descendantsCount += (kid.b.b || 0);
2453+ kids.push(kid);
2454+ }
2455+ descendantsCount += kids.length;
2456+
2457+ return {
2458+ $: 2,
2459+ c: tag,
2460+ d: _VirtualDom_organizeFacts(factList),
2461+ e: kids,
2462+ f: namespace,
2463+ b: descendantsCount
2464+ };
2465+ });
2466+});
2467+
2468+
2469+var _VirtualDom_keyedNode = _VirtualDom_keyedNodeNS(undefined);
2470+
2471+
2472+
2473+// CUSTOM
2474+
2475+
2476+function _VirtualDom_custom(factList, model, render, diff)
2477+{
2478+ return {
2479+ $: 3,
2480+ d: _VirtualDom_organizeFacts(factList),
2481+ g: model,
2482+ h: render,
2483+ i: diff
2484+ };
2485+}
2486+
2487+
2488+
2489+// MAP
2490+
2491+
2492+var _VirtualDom_map = F2(function(tagger, node)
2493+{
2494+ return {
2495+ $: 4,
2496+ j: tagger,
2497+ k: node,
2498+ b: 1 + (node.b || 0)
2499+ };
2500+});
2501+
2502+
2503+
2504+// LAZY
2505+
2506+
2507+function _VirtualDom_thunk(refs, thunk)
2508+{
2509+ return {
2510+ $: 5,
2511+ l: refs,
2512+ m: thunk,
2513+ k: undefined
2514+ };
2515+}
2516+
2517+var _VirtualDom_lazy = F2(function(func, a)
2518+{
2519+ return _VirtualDom_thunk([func, a], function() {
2520+ return func(a);
2521+ });
2522+});
2523+
2524+var _VirtualDom_lazy2 = F3(function(func, a, b)
2525+{
2526+ return _VirtualDom_thunk([func, a, b], function() {
2527+ return A2(func, a, b);
2528+ });
2529+});
2530+
2531+var _VirtualDom_lazy3 = F4(function(func, a, b, c)
2532+{
2533+ return _VirtualDom_thunk([func, a, b, c], function() {
2534+ return A3(func, a, b, c);
2535+ });
2536+});
2537+
2538+var _VirtualDom_lazy4 = F5(function(func, a, b, c, d)
2539+{
2540+ return _VirtualDom_thunk([func, a, b, c, d], function() {
2541+ return A4(func, a, b, c, d);
2542+ });
2543+});
2544+
2545+var _VirtualDom_lazy5 = F6(function(func, a, b, c, d, e)
2546+{
2547+ return _VirtualDom_thunk([func, a, b, c, d, e], function() {
2548+ return A5(func, a, b, c, d, e);
2549+ });
2550+});
2551+
2552+var _VirtualDom_lazy6 = F7(function(func, a, b, c, d, e, f)
2553+{
2554+ return _VirtualDom_thunk([func, a, b, c, d, e, f], function() {
2555+ return A6(func, a, b, c, d, e, f);
2556+ });
2557+});
2558+
2559+var _VirtualDom_lazy7 = F8(function(func, a, b, c, d, e, f, g)
2560+{
2561+ return _VirtualDom_thunk([func, a, b, c, d, e, f, g], function() {
2562+ return A7(func, a, b, c, d, e, f, g);
2563+ });
2564+});
2565+
2566+var _VirtualDom_lazy8 = F9(function(func, a, b, c, d, e, f, g, h)
2567+{
2568+ return _VirtualDom_thunk([func, a, b, c, d, e, f, g, h], function() {
2569+ return A8(func, a, b, c, d, e, f, g, h);
2570+ });
2571+});
2572+
2573+
2574+
2575+// FACTS
2576+
2577+
2578+var _VirtualDom_on = F2(function(key, handler)
2579+{
2580+ return {
2581+ $: 'a0',
2582+ n: key,
2583+ o: handler
2584+ };
2585+});
2586+var _VirtualDom_style = F2(function(key, value)
2587+{
2588+ return {
2589+ $: 'a1',
2590+ n: key,
2591+ o: value
2592+ };
2593+});
2594+var _VirtualDom_property = F2(function(key, value)
2595+{
2596+ return {
2597+ $: 'a2',
2598+ n: key,
2599+ o: value
2600+ };
2601+});
2602+var _VirtualDom_attribute = F2(function(key, value)
2603+{
2604+ return {
2605+ $: 'a3',
2606+ n: key,
2607+ o: value
2608+ };
2609+});
2610+var _VirtualDom_attributeNS = F3(function(namespace, key, value)
2611+{
2612+ return {
2613+ $: 'a4',
2614+ n: key,
2615+ o: { f: namespace, o: value }
2616+ };
2617+});
2618+
2619+
2620+
2621+// XSS ATTACK VECTOR CHECKS
2622+//
2623+// For some reason, tabs can appear in href protocols and it still works.
2624+// So '\tjava\tSCRIPT:alert("!!!")' and 'javascript:alert("!!!")' are the same
2625+// in practice. That is why _VirtualDom_RE_js and _VirtualDom_RE_js_html look
2626+// so freaky.
2627+//
2628+// Pulling the regular expressions out to the top level gives a slight speed
2629+// boost in small benchmarks (4-10%) but hoisting values to reduce allocation
2630+// can be unpredictable in large programs where JIT may have a harder time with
2631+// functions are not fully self-contained. The benefit is more that the js and
2632+// js_html ones are so weird that I prefer to see them near each other.
2633+
2634+
2635+
2636+
2637+
2638+function _VirtualDom_noScript(tag)
2639+{
2640+ return tag;
2641+}
2642+
2643+function _VirtualDom_noOnOrFormAction(key)
2644+{
2645+ return key;
2646+}
2647+
2648+function _VirtualDom_noInnerHtmlOrFormAction(key)
2649+{
2650+ return key;
2651+}
2652+
2653+function _VirtualDom_noJavaScriptUri(value)
2654+{
2655+ return value;
2656+}
2657+
2658+function _VirtualDom_noJavaScriptOrHtmlUri(value)
2659+{
2660+ return value;
2661+}
2662+
2663+function _VirtualDom_noJavaScriptOrHtmlJson(value)
2664+{
2665+ return value;
2666+}
2667+
2668+
2669+
2670+// MAP FACTS
2671+
2672+
2673+var _VirtualDom_mapAttribute = F2(function(func, attr)
2674+{
2675+ return (attr.$ === 'a0')
2676+ ? A2(_VirtualDom_on, attr.n, _VirtualDom_mapHandler(func, attr.o))
2677+ : attr;
2678+});
2679+
2680+function _VirtualDom_mapHandler(func, handler)
2681+{
2682+ var tag = $lynxjs_elm$virtual_dom$VirtualDom$toHandlerInt(handler);
2683+
2684+ // 0 = Normal
2685+ // 1 = MayStopPropagation
2686+ // 2 = MayPreventDefault
2687+ // 3 = Custom
2688+
2689+ return {
2690+ $: handler.$,
2691+ a:
2692+ !tag
2693+ ? A2($elm$json$Json$Decode$map, func, handler.a)
2694+ :
2695+ A3($elm$json$Json$Decode$map2,
2696+ tag < 3
2697+ ? _VirtualDom_mapEventTuple
2698+ : _VirtualDom_mapEventRecord,
2699+ $elm$json$Json$Decode$succeed(func),
2700+ handler.a
2701+ )
2702+ };
2703+}
2704+
2705+var _VirtualDom_mapEventTuple = F2(function(func, tuple)
2706+{
2707+ return _Utils_Tuple2(func(tuple.a), tuple.b);
2708+});
2709+
2710+var _VirtualDom_mapEventRecord = F2(function(func, record)
2711+{
2712+ return {
2713+ message: func(record.message),
2714+ stopPropagation: record.stopPropagation,
2715+ preventDefault: record.preventDefault
2716+ }
2717+});
2718+
2719+
2720+
2721+// ORGANIZE FACTS
2722+
2723+
2724+function _VirtualDom_organizeFacts(factList)
2725+{
2726+ for (var facts = {}; factList.b; factList = factList.b) // WHILE_CONS
2727+ {
2728+ var entry = factList.a;
2729+
2730+ var tag = entry.$;
2731+ var key = entry.n;
2732+ var value = entry.o;
2733+
2734+ if (tag === 'a2')
2735+ {
2736+ (key === 'className')
2737+ ? _VirtualDom_addClass(facts, key, _Json_unwrap(value))
2738+ : facts[key] = _Json_unwrap(value);
2739+
2740+ continue;
2741+ }
2742+
2743+ var subFacts = facts[tag] || (facts[tag] = {});
2744+ (tag === 'a3' && key === 'class')
2745+ ? _VirtualDom_addClass(subFacts, key, value)
2746+ : subFacts[key] = value;
2747+ }
2748+
2749+ return facts;
2750+}
2751+
2752+function _VirtualDom_addClass(object, key, newClass)
2753+{
2754+ var classes = object[key];
2755+ object[key] = classes ? classes + ' ' + newClass : newClass;
2756+}
2757+
2758+
2759+
2760+// RENDER
2761+
2762+
2763+function _VirtualDom_render(vNode, eventNode)
2764+{
2765+ var tag = vNode.$;
2766+
2767+ if (tag === 5)
2768+ {
2769+ return _VirtualDom_render(vNode.k || (vNode.k = vNode.m()), eventNode);
2770+ }
2771+
2772+ if (tag === 0)
2773+ {
2774+ return _Lynx_createRawText(vNode.a);
2775+ }
2776+
2777+ if (tag === 4)
2778+ {
2779+ var subNode = vNode.k;
2780+ var tagger = vNode.j;
2781+
2782+ while (subNode.$ === 4)
2783+ {
2784+ typeof tagger !== 'object'
2785+ ? tagger = [tagger, subNode.j]
2786+ : tagger.push(subNode.j);
2787+
2788+ subNode = subNode.k;
2789+ }
2790+
2791+ var subEventRoot = { j: tagger, p: eventNode };
2792+ var domNode = _VirtualDom_render(subNode, subEventRoot);
2793+ _VirtualDom_getMeta(domNode).elm_event_node_ref = subEventRoot;
2794+ return domNode;
2795+ }
2796+
2797+ if (tag === 3)
2798+ {
2799+ var domNode = vNode.h(vNode.g);
2800+ _VirtualDom_applyFacts(domNode, eventNode, vNode.d);
2801+ return domNode;
2802+ }
2803+
2804+ // at this point `tag` must be 1 or 2
2805+
2806+ var domNode = _Lynx_createElement(vNode.c);
2807+
2808+ _VirtualDom_applyFacts(domNode, eventNode, vNode.d);
2809+
2810+ for (var kids = vNode.e, i = 0; i < kids.length; i++)
2811+ {
2812+ var kid = tag === 1 ? kids[i] : kids[i].b;
2813+ if (kid.$ === 0)
2814+ {
2815+ _Lynx_appendChild(domNode, _Lynx_createRawText(kid.a));
2816+ }
2817+ else
2818+ {
2819+ _VirtualDom_appendChild(domNode, _VirtualDom_render(kid, eventNode));
2820+ }
2821+ }
2822+
2823+ return domNode;
2824+}
2825+
2826+
2827+
2828+// APPLY FACTS
2829+
2830+
2831+function _VirtualDom_applyFacts(domNode, eventNode, facts)
2832+{
2833+ for (var key in facts)
2834+ {
2835+ var value = facts[key];
2836+
2837+ key === 'a1'
2838+ ? _VirtualDom_applyStyles(domNode, value)
2839+ :
2840+ key === 'a0'
2841+ ? _VirtualDom_applyEvents(domNode, eventNode, value)
2842+ :
2843+ key === 'a3'
2844+ ? _VirtualDom_applyAttrs(domNode, value)
2845+ :
2846+ key === 'a4'
2847+ ? _VirtualDom_applyAttrsNS(domNode, value)
2848+ :
2849+ (key !== 'value' && key !== 'checked' || domNode[key] !== value) && _Lynx_setAttribute(domNode, key === 'className' ? 'class' : key, String(value));
2850+ }
2851+}
2852+
2853+
2854+
2855+// APPLY STYLES
2856+
2857+
2858+function _VirtualDom_applyStyles(domNode, styles)
2859+{
2860+ _Lynx_setInlineStyles(domNode, styles);
2861+}
2862+
2863+
2864+
2865+// APPLY ATTRS
2866+
2867+
2868+function _VirtualDom_applyAttrs(domNode, attrs)
2869+{
2870+ for (var key in attrs)
2871+ {
2872+ var value = attrs[key];
2873+ if (typeof value !== 'undefined')
2874+ {
2875+ _Lynx_setAttribute(domNode, key, value);
2876+ }
2877+ }
2878+}
2879+
2880+
2881+
2882+// APPLY NAMESPACED ATTRS
2883+
2884+
2885+function _VirtualDom_applyAttrsNS(domNode, nsAttrs)
2886+{
2887+ for (var key in nsAttrs)
2888+ {
2889+ var pair = nsAttrs[key];
2890+ var value = pair.o;
2891+
2892+ if (typeof value !== 'undefined')
2893+ {
2894+ _Lynx_setAttribute(domNode, key, value);
2895+ }
2896+ }
2897+}
2898+
2899+
2900+
2901+// APPLY EVENTS
2902+
2903+
2904+function _VirtualDom_applyEvents(domNode, eventNode, events)
2905+{
2906+ var meta = _VirtualDom_getMeta(domNode);
2907+ var allCallbacks = meta.elmFs || (meta.elmFs = {});
2908+
2909+ for (var key in events)
2910+ {
2911+ var newHandler = events[key];
2912+ var oldCallback = allCallbacks[key];
2913+
2914+ if (!newHandler)
2915+ {
2916+ allCallbacks[key] = undefined;
2917+ continue;
2918+ }
2919+
2920+ if (oldCallback)
2921+ {
2922+ var oldHandler = oldCallback.q;
2923+ if (oldHandler.$ === newHandler.$)
2924+ {
2925+ oldCallback.q = newHandler;
2926+ continue;
2927+ }
2928+ }
2929+
2930+ oldCallback = _VirtualDom_makeCallback(eventNode, newHandler);
2931+ allCallbacks[key] = oldCallback;
2932+
2933+ var lynxEventName = _VirtualDom_mapEventName(key);
2934+ var handlerType = $lynxjs_elm$virtual_dom$VirtualDom$toHandlerInt(newHandler);
2935+ var prefix = (handlerType === 1) ? 'catch' : 'bind';
2936+ _Lynx_addEvent(domNode, 'catchEvent', lynxEventName, { type: 'worklet', value: oldCallback });
2937+ }
2938+}
2939+
2940+function _VirtualDom_mapEventName(name)
2941+{
2942+ switch (name)
2943+ {
2944+ case 'click': return 'tap';
2945+ case 'dblclick': return 'tap';
2946+ case 'mousedown': return 'touchstart';
2947+ case 'mousemove': return 'touchmove';
2948+ case 'mouseup': return 'touchend';
2949+ default: return name;
2950+ }
2951+}
2952+
2953+
2954+
2955+// PASSIVE EVENTS
2956+
2957+
2958+
2959+// EVENT HANDLERS
2960+
2961+
2962+function _VirtualDom_makeCallback(eventNode, initialHandler)
2963+{
2964+ function callback(event)
2965+ {
2966+ var handler = callback.q;
2967+ var result = _Json_runHelp(handler.a, event);
2968+
2969+ if (!$elm$core$Result$isOk(result))
2970+ {
2971+ return;
2972+ }
2973+
2974+ var tag = $lynxjs_elm$virtual_dom$VirtualDom$toHandlerInt(handler);
2975+
2976+ // 0 = Normal
2977+ // 1 = MayStopPropagation
2978+ // 2 = MayPreventDefault
2979+ // 3 = Custom
2980+
2981+ var value = result.a;
2982+ var message = !tag ? value : tag < 3 ? value.a : value.message;
2983+ var stopPropagation = tag == 1 ? value.b : tag == 3 && value.stopPropagation;
2984+ var currentEventNode = eventNode;
2985+ var tagger;
2986+ var i;
2987+ while (tagger = currentEventNode.j)
2988+ {
2989+ if (typeof tagger == 'function')
2990+ {
2991+ message = tagger(message);
2992+ }
2993+ else
2994+ {
2995+ for (var i = tagger.length; i--; )
2996+ {
2997+ message = tagger[i](message);
2998+ }
2999+ }
3000+ currentEventNode = currentEventNode.p;
3001+ }
3002+ currentEventNode(message, stopPropagation); // stopPropagation implies isSync
3003+ }
3004+
3005+ callback.q = initialHandler;
3006+
3007+ return callback;
3008+}
3009+
3010+function _VirtualDom_equalEvents(x, y)
3011+{
3012+ return x.$ == y.$ && _Json_equality(x.a, y.a);
3013+}
3014+
3015+
3016+
3017+// DIFF
3018+
3019+
3020+// TODO: Should we do patches like in iOS?
3021+//
3022+// type Patch
3023+// = At Int Patch
3024+// | Batch (List Patch)
3025+// | Change ...
3026+//
3027+// How could it not be better?
3028+//
3029+function _VirtualDom_diff(x, y)
3030+{
3031+ var patches = [];
3032+ _VirtualDom_diffHelp(x, y, patches, 0);
3033+ return patches;
3034+}
3035+
3036+
3037+function _VirtualDom_pushPatch(patches, type, index, data)
3038+{
3039+ var patch = {
3040+ $: type,
3041+ r: index,
3042+ s: data,
3043+ t: undefined,
3044+ u: undefined
3045+ };
3046+ patches.push(patch);
3047+ return patch;
3048+}
3049+
3050+
3051+function _VirtualDom_diffHelp(x, y, patches, index)
3052+{
3053+ if (x === y)
3054+ {
3055+ return;
3056+ }
3057+
3058+ var xType = x.$;
3059+ var yType = y.$;
3060+
3061+ // Bail if you run into different types of nodes. Implies that the
3062+ // structure has changed significantly and it's not worth a diff.
3063+ if (xType !== yType)
3064+ {
3065+ if (xType === 1 && yType === 2)
3066+ {
3067+ y = _VirtualDom_dekey(y);
3068+ yType = 1;
3069+ }
3070+ else
3071+ {
3072+ _VirtualDom_pushPatch(patches, 0, index, y);
3073+ return;
3074+ }
3075+ }
3076+
3077+ // Now we know that both nodes are the same $.
3078+ switch (yType)
3079+ {
3080+ case 5:
3081+ var xRefs = x.l;
3082+ var yRefs = y.l;
3083+ var i = xRefs.length;
3084+ var same = i === yRefs.length;
3085+ while (same && i--)
3086+ {
3087+ same = xRefs[i] === yRefs[i];
3088+ }
3089+ if (same)
3090+ {
3091+ y.k = x.k;
3092+ return;
3093+ }
3094+ y.k = y.m();
3095+ var subPatches = [];
3096+ _VirtualDom_diffHelp(x.k, y.k, subPatches, 0);
3097+ subPatches.length > 0 && _VirtualDom_pushPatch(patches, 1, index, subPatches);
3098+ return;
3099+
3100+ case 4:
3101+ // gather nested taggers
3102+ var xTaggers = x.j;
3103+ var yTaggers = y.j;
3104+ var nesting = false;
3105+
3106+ var xSubNode = x.k;
3107+ while (xSubNode.$ === 4)
3108+ {
3109+ nesting = true;
3110+
3111+ typeof xTaggers !== 'object'
3112+ ? xTaggers = [xTaggers, xSubNode.j]
3113+ : xTaggers.push(xSubNode.j);
3114+
3115+ xSubNode = xSubNode.k;
3116+ }
3117+
3118+ var ySubNode = y.k;
3119+ while (ySubNode.$ === 4)
3120+ {
3121+ nesting = true;
3122+
3123+ typeof yTaggers !== 'object'
3124+ ? yTaggers = [yTaggers, ySubNode.j]
3125+ : yTaggers.push(ySubNode.j);
3126+
3127+ ySubNode = ySubNode.k;
3128+ }
3129+
3130+ // Just bail if different numbers of taggers. This implies the
3131+ // structure of the virtual DOM has changed.
3132+ if (nesting && xTaggers.length !== yTaggers.length)
3133+ {
3134+ _VirtualDom_pushPatch(patches, 0, index, y);
3135+ return;
3136+ }
3137+
3138+ // check if taggers are "the same"
3139+ if (nesting ? !_VirtualDom_pairwiseRefEqual(xTaggers, yTaggers) : xTaggers !== yTaggers)
3140+ {
3141+ _VirtualDom_pushPatch(patches, 2, index, yTaggers);
3142+ }
3143+
3144+ // diff everything below the taggers
3145+ _VirtualDom_diffHelp(xSubNode, ySubNode, patches, index + 1);
3146+ return;
3147+
3148+ case 0:
3149+ if (x.a !== y.a)
3150+ {
3151+ _VirtualDom_pushPatch(patches, 3, index, y.a);
3152+ }
3153+ return;
3154+
3155+ case 1:
3156+ _VirtualDom_diffNodes(x, y, patches, index, _VirtualDom_diffKids);
3157+ return;
3158+
3159+ case 2:
3160+ _VirtualDom_diffNodes(x, y, patches, index, _VirtualDom_diffKeyedKids);
3161+ return;
3162+
3163+ case 3:
3164+ if (x.h !== y.h)
3165+ {
3166+ _VirtualDom_pushPatch(patches, 0, index, y);
3167+ return;
3168+ }
3169+
3170+ var factsDiff = _VirtualDom_diffFacts(x.d, y.d);
3171+ factsDiff && _VirtualDom_pushPatch(patches, 4, index, factsDiff);
3172+
3173+ var patch = y.i(x.g, y.g);
3174+ patch && _VirtualDom_pushPatch(patches, 5, index, patch);
3175+
3176+ return;
3177+ }
3178+}
3179+
3180+// assumes the incoming arrays are the same length
3181+function _VirtualDom_pairwiseRefEqual(as, bs)
3182+{
3183+ for (var i = 0; i < as.length; i++)
3184+ {
3185+ if (as[i] !== bs[i])
3186+ {
3187+ return false;
3188+ }
3189+ }
3190+
3191+ return true;
3192+}
3193+
3194+function _VirtualDom_diffNodes(x, y, patches, index, diffKids)
3195+{
3196+ // Bail if obvious indicators have changed. Implies more serious
3197+ // structural changes such that it's not worth it to diff.
3198+ if (x.c !== y.c || x.f !== y.f)
3199+ {
3200+ _VirtualDom_pushPatch(patches, 0, index, y);
3201+ return;
3202+ }
3203+
3204+ var factsDiff = _VirtualDom_diffFacts(x.d, y.d);
3205+ factsDiff && _VirtualDom_pushPatch(patches, 4, index, factsDiff);
3206+
3207+ diffKids(x, y, patches, index);
3208+}
3209+
3210+
3211+
3212+// DIFF FACTS
3213+
3214+
3215+// TODO Instead of creating a new diff object, it's possible to just test if
3216+// there *is* a diff. During the actual patch, do the diff again and make the
3217+// modifications directly. This way, there's no new allocations. Worth it?
3218+function _VirtualDom_diffFacts(x, y, category)
3219+{
3220+ var diff;
3221+
3222+ // look for changes and removals
3223+ for (var xKey in x)
3224+ {
3225+ if (xKey === 'a1' || xKey === 'a0' || xKey === 'a3' || xKey === 'a4')
3226+ {
3227+ var subDiff = _VirtualDom_diffFacts(x[xKey], y[xKey] || {}, xKey);
3228+ if (subDiff)
3229+ {
3230+ diff = diff || {};
3231+ diff[xKey] = subDiff;
3232+ }
3233+ continue;
3234+ }
3235+
3236+ // remove if not in the new facts
3237+ if (!(xKey in y))
3238+ {
3239+ diff = diff || {};
3240+ diff[xKey] =
3241+ !category
3242+ ? (typeof x[xKey] === 'string' ? '' : null)
3243+ :
3244+ (category === 'a1')
3245+ ? ''
3246+ :
3247+ (category === 'a0' || category === 'a3')
3248+ ? undefined
3249+ :
3250+ { f: x[xKey].f, o: undefined };
3251+
3252+ continue;
3253+ }
3254+
3255+ var xValue = x[xKey];
3256+ var yValue = y[xKey];
3257+
3258+ // reference equal, so don't worry about it
3259+ if (xValue === yValue && xKey !== 'value' && xKey !== 'checked'
3260+ || category === 'a0' && _VirtualDom_equalEvents(xValue, yValue))
3261+ {
3262+ continue;
3263+ }
3264+
3265+ diff = diff || {};
3266+ diff[xKey] = yValue;
3267+ }
3268+
3269+ // add new stuff
3270+ for (var yKey in y)
3271+ {
3272+ if (!(yKey in x))
3273+ {
3274+ diff = diff || {};
3275+ diff[yKey] = y[yKey];
3276+ }
3277+ }
3278+
3279+ return diff;
3280+}
3281+
3282+
3283+
3284+// DIFF KIDS
3285+
3286+
3287+function _VirtualDom_diffKids(xParent, yParent, patches, index)
3288+{
3289+ var xKids = xParent.e;
3290+ var yKids = yParent.e;
3291+
3292+ var xLen = xKids.length;
3293+ var yLen = yKids.length;
3294+
3295+ // FIGURE OUT IF THERE ARE INSERTS OR REMOVALS
3296+
3297+ if (xLen > yLen)
3298+ {
3299+ _VirtualDom_pushPatch(patches, 6, index, {
3300+ v: yLen,
3301+ i: xLen - yLen
3302+ });
3303+ }
3304+ else if (xLen < yLen)
3305+ {
3306+ _VirtualDom_pushPatch(patches, 7, index, {
3307+ v: xLen,
3308+ e: yKids
3309+ });
3310+ }
3311+
3312+ // PAIRWISE DIFF EVERYTHING ELSE
3313+
3314+ for (var minLen = xLen < yLen ? xLen : yLen, i = 0; i < minLen; i++)
3315+ {
3316+ var xKid = xKids[i];
3317+ _VirtualDom_diffHelp(xKid, yKids[i], patches, ++index);
3318+ index += xKid.b || 0;
3319+ }
3320+}
3321+
3322+
3323+
3324+// KEYED DIFF
3325+
3326+
3327+function _VirtualDom_diffKeyedKids(xParent, yParent, patches, rootIndex)
3328+{
3329+ var localPatches = [];
3330+
3331+ var changes = {}; // Dict String Entry
3332+ var inserts = []; // Array { index : Int, entry : Entry }
3333+ // type Entry = { tag : String, vnode : VNode, index : Int, data : _ }
3334+
3335+ var xKids = xParent.e;
3336+ var yKids = yParent.e;
3337+ var xLen = xKids.length;
3338+ var yLen = yKids.length;
3339+ var xIndex = 0;
3340+ var yIndex = 0;
3341+
3342+ var index = rootIndex;
3343+
3344+ while (xIndex < xLen && yIndex < yLen)
3345+ {
3346+ var x = xKids[xIndex];
3347+ var y = yKids[yIndex];
3348+
3349+ var xKey = x.a;
3350+ var yKey = y.a;
3351+ var xNode = x.b;
3352+ var yNode = y.b;
3353+
3354+ var newMatch = undefined;
3355+ var oldMatch = undefined;
3356+
3357+ // check if keys match
3358+
3359+ if (xKey === yKey)
3360+ {
3361+ index++;
3362+ _VirtualDom_diffHelp(xNode, yNode, localPatches, index);
3363+ index += xNode.b || 0;
3364+
3365+ xIndex++;
3366+ yIndex++;
3367+ continue;
3368+ }
3369+
3370+ // look ahead 1 to detect insertions and removals.
3371+
3372+ var xNext = xKids[xIndex + 1];
3373+ var yNext = yKids[yIndex + 1];
3374+
3375+ if (xNext)
3376+ {
3377+ var xNextKey = xNext.a;
3378+ var xNextNode = xNext.b;
3379+ oldMatch = yKey === xNextKey;
3380+ }
3381+
3382+ if (yNext)
3383+ {
3384+ var yNextKey = yNext.a;
3385+ var yNextNode = yNext.b;
3386+ newMatch = xKey === yNextKey;
3387+ }
3388+
3389+
3390+ // swap x and y
3391+ if (newMatch && oldMatch)
3392+ {
3393+ index++;
3394+ _VirtualDom_diffHelp(xNode, yNextNode, localPatches, index);
3395+ _VirtualDom_insertNode(changes, localPatches, xKey, yNode, yIndex, inserts);
3396+ index += xNode.b || 0;
3397+
3398+ index++;
3399+ _VirtualDom_removeNode(changes, localPatches, xKey, xNextNode, index);
3400+ index += xNextNode.b || 0;
3401+
3402+ xIndex += 2;
3403+ yIndex += 2;
3404+ continue;
3405+ }
3406+
3407+ // insert y
3408+ if (newMatch)
3409+ {
3410+ index++;
3411+ _VirtualDom_insertNode(changes, localPatches, yKey, yNode, yIndex, inserts);
3412+ _VirtualDom_diffHelp(xNode, yNextNode, localPatches, index);
3413+ index += xNode.b || 0;
3414+
3415+ xIndex += 1;
3416+ yIndex += 2;
3417+ continue;
3418+ }
3419+
3420+ // remove x
3421+ if (oldMatch)
3422+ {
3423+ index++;
3424+ _VirtualDom_removeNode(changes, localPatches, xKey, xNode, index);
3425+ index += xNode.b || 0;
3426+
3427+ index++;
3428+ _VirtualDom_diffHelp(xNextNode, yNode, localPatches, index);
3429+ index += xNextNode.b || 0;
3430+
3431+ xIndex += 2;
3432+ yIndex += 1;
3433+ continue;
3434+ }
3435+
3436+ // remove x, insert y
3437+ if (xNext && xNextKey === yNextKey)
3438+ {
3439+ index++;
3440+ _VirtualDom_removeNode(changes, localPatches, xKey, xNode, index);
3441+ _VirtualDom_insertNode(changes, localPatches, yKey, yNode, yIndex, inserts);
3442+ index += xNode.b || 0;
3443+
3444+ index++;
3445+ _VirtualDom_diffHelp(xNextNode, yNextNode, localPatches, index);
3446+ index += xNextNode.b || 0;
3447+
3448+ xIndex += 2;
3449+ yIndex += 2;
3450+ continue;
3451+ }
3452+
3453+ break;
3454+ }
3455+
3456+ // eat up any remaining nodes with removeNode and insertNode
3457+
3458+ while (xIndex < xLen)
3459+ {
3460+ index++;
3461+ var x = xKids[xIndex];
3462+ var xNode = x.b;
3463+ _VirtualDom_removeNode(changes, localPatches, x.a, xNode, index);
3464+ index += xNode.b || 0;
3465+ xIndex++;
3466+ }
3467+
3468+ while (yIndex < yLen)
3469+ {
3470+ var endInserts = endInserts || [];
3471+ var y = yKids[yIndex];
3472+ _VirtualDom_insertNode(changes, localPatches, y.a, y.b, undefined, endInserts);
3473+ yIndex++;
3474+ }
3475+
3476+ if (localPatches.length > 0 || inserts.length > 0 || endInserts)
3477+ {
3478+ _VirtualDom_pushPatch(patches, 8, rootIndex, {
3479+ w: localPatches,
3480+ x: inserts,
3481+ y: endInserts
3482+ });
3483+ }
3484+}
3485+
3486+
3487+
3488+// CHANGES FROM KEYED DIFF
3489+
3490+
3491+var _VirtualDom_POSTFIX = '_elmW6BL';
3492+
3493+
3494+function _VirtualDom_insertNode(changes, localPatches, key, vnode, yIndex, inserts)
3495+{
3496+ var entry = changes[key];
3497+
3498+ // never seen this key before
3499+ if (!entry)
3500+ {
3501+ entry = {
3502+ c: 0,
3503+ z: vnode,
3504+ r: yIndex,
3505+ s: undefined
3506+ };
3507+
3508+ inserts.push({ r: yIndex, A: entry });
3509+ changes[key] = entry;
3510+
3511+ return;
3512+ }
3513+
3514+ // this key was removed earlier, a match!
3515+ if (entry.c === 1)
3516+ {
3517+ inserts.push({ r: yIndex, A: entry });
3518+
3519+ entry.c = 2;
3520+ var subPatches = [];
3521+ _VirtualDom_diffHelp(entry.z, vnode, subPatches, entry.r);
3522+ entry.r = yIndex;
3523+ entry.s.s = {
3524+ w: subPatches,
3525+ A: entry
3526+ };
3527+
3528+ return;
3529+ }
3530+
3531+ // this key has already been inserted or moved, a duplicate!
3532+ _VirtualDom_insertNode(changes, localPatches, key + _VirtualDom_POSTFIX, vnode, yIndex, inserts);
3533+}
3534+
3535+
3536+function _VirtualDom_removeNode(changes, localPatches, key, vnode, index)
3537+{
3538+ var entry = changes[key];
3539+
3540+ // never seen this key before
3541+ if (!entry)
3542+ {
3543+ var patch = _VirtualDom_pushPatch(localPatches, 9, index, undefined);
3544+
3545+ changes[key] = {
3546+ c: 1,
3547+ z: vnode,
3548+ r: index,
3549+ s: patch
3550+ };
3551+
3552+ return;
3553+ }
3554+
3555+ // this key was inserted earlier, a match!
3556+ if (entry.c === 0)
3557+ {
3558+ entry.c = 2;
3559+ var subPatches = [];
3560+ _VirtualDom_diffHelp(vnode, entry.z, subPatches, index);
3561+
3562+ _VirtualDom_pushPatch(localPatches, 9, index, {
3563+ w: subPatches,
3564+ A: entry
3565+ });
3566+
3567+ return;
3568+ }
3569+
3570+ // this key has already been removed or moved, a duplicate!
3571+ _VirtualDom_removeNode(changes, localPatches, key + _VirtualDom_POSTFIX, vnode, index);
3572+}
3573+
3574+
3575+
3576+// ADD DOM NODES
3577+//
3578+// Each DOM node has an "index" assigned in order of traversal. It is important
3579+// to minimize our crawl over the actual DOM, so these indexes (along with the
3580+// descendantsCount of virtual nodes) let us skip touching entire subtrees of
3581+// the DOM if we know there are no patches there.
3582+
3583+
3584+function _VirtualDom_addDomNodes(domNode, vNode, patches, eventNode)
3585+{
3586+ _VirtualDom_addDomNodesHelp(domNode, vNode, patches, 0, 0, vNode.b, eventNode);
3587+}
3588+
3589+
3590+// assumes `patches` is non-empty and indexes increase monotonically.
3591+function _VirtualDom_addDomNodesHelp(domNode, vNode, patches, i, low, high, eventNode)
3592+{
3593+ var patch = patches[i];
3594+ var index = patch.r;
3595+
3596+ while (index === low)
3597+ {
3598+ var patchType = patch.$;
3599+
3600+ if (patchType === 1)
3601+ {
3602+ _VirtualDom_addDomNodes(domNode, vNode.k, patch.s, eventNode);
3603+ }
3604+ else if (patchType === 8)
3605+ {
3606+ patch.t = domNode;
3607+ patch.u = eventNode;
3608+
3609+ var subPatches = patch.s.w;
3610+ if (subPatches.length > 0)
3611+ {
3612+ _VirtualDom_addDomNodesHelp(domNode, vNode, subPatches, 0, low, high, eventNode);
3613+ }
3614+ }
3615+ else if (patchType === 9)
3616+ {
3617+ patch.t = domNode;
3618+ patch.u = eventNode;
3619+
3620+ var data = patch.s;
3621+ if (data)
3622+ {
3623+ data.A.s = domNode;
3624+ var subPatches = data.w;
3625+ if (subPatches.length > 0)
3626+ {
3627+ _VirtualDom_addDomNodesHelp(domNode, vNode, subPatches, 0, low, high, eventNode);
3628+ }
3629+ }
3630+ }
3631+ else
3632+ {
3633+ patch.t = domNode;
3634+ patch.u = eventNode;
3635+ }
3636+
3637+ i++;
3638+
3639+ if (!(patch = patches[i]) || (index = patch.r) > high)
3640+ {
3641+ return i;
3642+ }
3643+ }
3644+
3645+ var tag = vNode.$;
3646+
3647+ if (tag === 4)
3648+ {
3649+ var subNode = vNode.k;
3650+
3651+ while (subNode.$ === 4)
3652+ {
3653+ subNode = subNode.k;
3654+ }
3655+
3656+ return _VirtualDom_addDomNodesHelp(domNode, subNode, patches, i, low + 1, high, _VirtualDom_getMeta(domNode).elm_event_node_ref);
3657+ }
3658+
3659+ // tag must be 1 or 2 at this point
3660+
3661+ var vKids = vNode.e;
3662+ var childNodes = _Lynx_getChildren(domNode);
3663+ for (var j = 0; j < vKids.length; j++)
3664+ {
3665+ low++;
3666+ var vKid = tag === 1 ? vKids[j] : vKids[j].b;
3667+ var nextLow = low + (vKid.b || 0);
3668+ if (low <= index && index <= nextLow)
3669+ {
3670+ i = _VirtualDom_addDomNodesHelp(childNodes[j], vKid, patches, i, low, nextLow, eventNode);
3671+ if (!(patch = patches[i]) || (index = patch.r) > high)
3672+ {
3673+ return i;
3674+ }
3675+ }
3676+ low = nextLow;
3677+ }
3678+ return i;
3679+}
3680+
3681+
3682+
3683+// APPLY PATCHES
3684+
3685+
3686+function _VirtualDom_applyPatches(rootDomNode, oldVirtualNode, patches, eventNode)
3687+{
3688+ if (patches.length === 0)
3689+ {
3690+ return rootDomNode;
3691+ }
3692+
3693+ _VirtualDom_addDomNodes(rootDomNode, oldVirtualNode, patches, eventNode);
3694+ return _VirtualDom_applyPatchesHelp(rootDomNode, patches);
3695+}
3696+
3697+function _VirtualDom_applyPatchesHelp(rootDomNode, patches)
3698+{
3699+ for (var i = 0; i < patches.length; i++)
3700+ {
3701+ var patch = patches[i];
3702+ var localDomNode = patch.t
3703+ var newNode = _VirtualDom_applyPatch(localDomNode, patch);
3704+ if (localDomNode === rootDomNode)
3705+ {
3706+ rootDomNode = newNode;
3707+ }
3708+ }
3709+ return rootDomNode;
3710+}
3711+
3712+function _VirtualDom_applyPatch(domNode, patch)
3713+{
3714+ switch (patch.$)
3715+ {
3716+ case 0:
3717+ return _VirtualDom_applyPatchRedraw(domNode, patch.s, patch.u);
3718+
3719+ case 4:
3720+ _VirtualDom_applyFacts(domNode, patch.u, patch.s);
3721+ return domNode;
3722+
3723+ case 3:
3724+ _Lynx_setAttribute(domNode, 'text', patch.s);
3725+ return domNode;
3726+
3727+ case 1:
3728+ return _VirtualDom_applyPatchesHelp(domNode, patch.s);
3729+
3730+ case 2:
3731+ if (_VirtualDom_getMeta(domNode).elm_event_node_ref)
3732+ {
3733+ _VirtualDom_getMeta(domNode).elm_event_node_ref.j = patch.s;
3734+ }
3735+ else
3736+ {
3737+ _VirtualDom_getMeta(domNode).elm_event_node_ref = { j: patch.s, p: patch.u };
3738+ }
3739+ return domNode;
3740+
3741+ case 6:
3742+ var data = patch.s;
3743+ for (var i = 0; i < data.i; i++)
3744+ {
3745+ var children = _Lynx_getChildren(domNode);
3746+ _Lynx_removeElement(domNode, children[data.v]);
3747+ }
3748+ return domNode;
3749+
3750+ case 7:
3751+ var data = patch.s;
3752+ var kids = data.e;
3753+ for (var i = data.v; i < kids.length; i++)
3754+ {
3755+ _Lynx_appendChild(domNode, _VirtualDom_render(kids[i], patch.u));
3756+ }
3757+ return domNode;
3758+
3759+ case 9:
3760+ var data = patch.s;
3761+ if (!data)
3762+ {
3763+ _Lynx_removeElement(_Lynx_getParent(domNode), domNode);
3764+ return domNode;
3765+ }
3766+ var entry = data.A;
3767+ if (typeof entry.r !== 'undefined')
3768+ {
3769+ _Lynx_removeElement(_Lynx_getParent(domNode), domNode);
3770+ }
3771+ entry.s = _VirtualDom_applyPatchesHelp(domNode, data.w);
3772+ return domNode;
3773+
3774+ case 8:
3775+ return _VirtualDom_applyPatchReorder(domNode, patch);
3776+
3777+ case 5:
3778+ return patch.s(domNode);
3779+
3780+ default:
3781+ throw new Error('VirtualDom: unknown patch type');
3782+ }
3783+}
3784+
3785+
3786+function _VirtualDom_applyPatchRedraw(domNode, vNode, eventNode)
3787+{
3788+ var parentNode = _Lynx_getParent(domNode);
3789+ var newNode = _VirtualDom_render(vNode, eventNode);
3790+
3791+ if (!_VirtualDom_getMeta(newNode).elm_event_node_ref)
3792+ {
3793+ _VirtualDom_getMeta(newNode).elm_event_node_ref = _VirtualDom_getMeta(domNode).elm_event_node_ref;
3794+ }
3795+
3796+ if (parentNode && newNode !== domNode)
3797+ {
3798+ _Lynx_replaceElement(parentNode, newNode, domNode);
3799+ }
3800+ return newNode;
3801+}
3802+
3803+
3804+function _VirtualDom_applyPatchReorder(domNode, patch)
3805+{
3806+ var data = patch.s;
3807+
3808+ // remove end inserts
3809+ var endInsertNodes = _VirtualDom_applyPatchReorderEndInsertsHelp(data.y, patch);
3810+
3811+ // removals
3812+ domNode = _VirtualDom_applyPatchesHelp(domNode, data.w);
3813+
3814+ // inserts
3815+ var inserts = data.x;
3816+ for (var i = 0; i < inserts.length; i++)
3817+ {
3818+ var insert = inserts[i];
3819+ var entry = insert.A;
3820+ var node = entry.c === 2
3821+ ? entry.s
3822+ : _VirtualDom_render(entry.z, patch.u);
3823+ var children = _Lynx_getChildren(domNode);
3824+ _Lynx_insertBefore(domNode, node, children[insert.r]);
3825+ }
3826+
3827+ // add end inserts
3828+ if (endInsertNodes)
3829+ {
3830+ for (var i = 0; i < endInsertNodes.length; i++)
3831+ {
3832+ _Lynx_appendChild(domNode, endInsertNodes[i]);
3833+ }
3834+ }
3835+
3836+ return domNode;
3837+}
3838+
3839+
3840+function _VirtualDom_applyPatchReorderEndInsertsHelp(endInserts, patch)
3841+{
3842+ if (!endInserts)
3843+ {
3844+ return;
3845+ }
3846+
3847+ var nodes = [];
3848+ for (var i = 0; i < endInserts.length; i++)
3849+ {
3850+ var insert = endInserts[i];
3851+ var entry = insert.A;
3852+ nodes.push(entry.c === 2
3853+ ? entry.s
3854+ : _VirtualDom_render(entry.z, patch.u)
3855+ );
3856+ }
3857+ return nodes;
3858+}
3859+
3860+
3861+function _VirtualDom_dekey(keyedNode)
3862+{
3863+ var keyedKids = keyedNode.e;
3864+ var len = keyedKids.length;
3865+ var kids = new Array(len);
3866+ for (var i = 0; i < len; i++)
3867+ {
3868+ kids[i] = keyedKids[i].b;
3869+ }
3870+
3871+ return {
3872+ $: 1,
3873+ c: keyedNode.c,
3874+ d: keyedNode.d,
3875+ e: kids,
3876+ f: keyedNode.f,
3877+ b: keyedNode.b
3878+ };
3879+}
3880+
3881+
3882+
3883+// LYNXJS PAPI WRAPPERS
3884+var _Browser_lynx = (typeof globalThis !== 'undefined' ? globalThis : scope);
3885+function _Browser_newPage() {
3886+ return _Browser_lynx['page'];
3887+}
3888+function _Browser_flush() {
3889+ var fn = _Browser_lynx['_' + '_FlushElementTree'];
3890+ if (typeof fn === 'function') { fn(); }
3891+}
3892+
3893+
3894+
3895+// ELEMENT
3896+
3897+
3898+var _Browser_element = F4(function(impl, flagDecoder, debugMetadata, args)
3899+{
3900+ return _Platform_initialize(
3901+ flagDecoder,
3902+ args,
3903+ impl.init,
3904+ impl.update,
3905+ impl.subscriptions,
3906+ function(sendToApp, initialModel) {
3907+ var view = impl.view;
3908+ var domNode = args['node'] || _Browser_newPage();
3909+ var currNode = view(initialModel);
3910+ var currDomNode = _VirtualDom_render(currNode, sendToApp);
3911+ _VirtualDom_appendChild(domNode, currDomNode);
3912+ _Browser_flush();
3913+
3914+ return _Browser_makeAnimator(initialModel, function(model)
3915+ {
3916+ var nextNode = view(model);
3917+ var patches = _VirtualDom_diff(currNode, nextNode);
3918+ currDomNode = _VirtualDom_applyPatches(currDomNode, currNode, patches, sendToApp);
3919+ currNode = nextNode;
3920+ _Browser_flush();
3921+ });
3922+ }
3923+ );
3924+});
3925+
3926+
3927+
3928+// DOCUMENT
3929+
3930+
3931+var _Browser_document = F4(function(impl, flagDecoder, debugMetadata, args)
3932+{
3933+ return _Platform_initialize(
3934+ flagDecoder,
3935+ args,
3936+ impl.init,
3937+ impl.update,
3938+ impl.subscriptions,
3939+ function(sendToApp, initialModel) {
3940+ var view = impl.view;
3941+ var rootNode = args['node'] || _Browser_newPage();
3942+ var doc = view(initialModel);
3943+ var currNode = _VirtualDom_node('view')(_List_Nil)(doc.body);
3944+ var currDomNode = _VirtualDom_render(currNode, sendToApp);
3945+ _VirtualDom_appendChild(rootNode, currDomNode);
3946+ _Browser_flush();
3947+
3948+ return _Browser_makeAnimator(initialModel, function(model)
3949+ {
3950+ var doc = view(model);
3951+ var nextNode = _VirtualDom_node('view')(_List_Nil)(doc.body);
3952+ var patches = _VirtualDom_diff(currNode, nextNode);
3953+ currDomNode = _VirtualDom_applyPatches(currDomNode, currNode, patches, sendToApp);
3954+ currNode = nextNode;
3955+ _Browser_flush();
3956+ });
3957+ }
3958+ );
3959+});
3960+
3961+
3962+
3963+// ANIMATION
3964+
3965+
3966+var _Browser_cancelAnimationFrame =
3967+ function(id) { clearTimeout(id); };
3968+
3969+var _Browser_requestAnimationFrame =
3970+ function(callback) { return setTimeout(callback, 1000 / 60); };
3971+
3972+
3973+function _Browser_makeAnimator(model, draw)
3974+{
3975+ draw(model);
3976+
3977+ var state = 0;
3978+
3979+ function updateIfNeeded()
3980+ {
3981+ state = state === 1
3982+ ? 0
3983+ : ( _Browser_requestAnimationFrame(updateIfNeeded), draw(model), 1 );
3984+ }
3985+
3986+ return function(nextModel, isSync)
3987+ {
3988+ model = nextModel;
3989+
3990+ isSync
3991+ ? ( draw(model),
3992+ state === 2 && (state = 1)
3993+ )
3994+ : ( state === 0 && _Browser_requestAnimationFrame(updateIfNeeded),
3995+ state = 2
3996+ );
3997+ };
3998+}
3999+
4000+
4001+
4002+// APPLICATION
4003+
4004+
4005+function _Browser_application(impl)
4006+{
4007+ return _Browser_document({
4008+ init: function(flags)
4009+ {
4010+ return A3(impl.init, flags, _Browser_fakeUrl(), {});
4011+ },
4012+ view: impl.view,
4013+ update: impl.update,
4014+ subscriptions: impl.subscriptions
4015+ });
4016+}
4017+
4018+function _Browser_fakeUrl()
4019+{
4020+ return {
4021+ protocol: { $: 0 },
4022+ host: 'localhost',
4023+ port_: { $: 1 },
4024+ path: '/',
4025+ query: { $: 1 },
4026+ fragment: { $: 1 }
4027+ };
4028+}
4029+
4030+
4031+
4032+var _Browser_go = F2(function(key, n)
4033+{
4034+ return A2($elm$core$Task$perform, $elm$core$Basics$never, _Scheduler_binding(function() {
4035+ // no-op in LynxJS
4036+ key();
4037+ }));
4038+});
4039+
4040+var _Browser_pushUrl = F2(function(key, url)
4041+{
4042+ return A2($elm$core$Task$perform, $elm$core$Basics$never, _Scheduler_binding(function() {
4043+ // no-op in LynxJS
4044+ key();
4045+ }));
4046+});
4047+
4048+var _Browser_replaceUrl = F2(function(key, url)
4049+{
4050+ return A2($elm$core$Task$perform, $elm$core$Basics$never, _Scheduler_binding(function() {
4051+ // no-op in LynxJS
4052+ key();
4053+ }));
4054+});
4055+
4056+
4057+
4058+// GLOBAL EVENTS
4059+
4060+
4061+var _Browser_fakeNode = { addEventListener: function() {}, removeEventListener: function() {} };
4062+var _Browser_doc = typeof document !== 'undefined' ? document : _Browser_fakeNode;
4063+var _Browser_window = typeof window !== 'undefined' ? window : _Browser_fakeNode;
4064+
4065+var _Browser_on = F3(function(node, eventName, sendToSelf)
4066+{
4067+ return _Scheduler_spawn(_Scheduler_binding(function(callback)
4068+ {
4069+ return function() {};
4070+ }));
4071+});
4072+
4073+var _Browser_decodeEvent = F2(function(decoder, event)
4074+{
4075+ var result = _Json_runHelp(decoder, event);
4076+ return $elm$core$Result$isOk(result) ? $elm$core$Maybe$Just(result.a) : $elm$core$Maybe$Nothing;
4077+});
4078+
4079+
4080+
4081+// PAGE VISIBILITY
4082+
4083+
4084+function _Browser_visibilityInfo()
4085+{
4086+ return (typeof _VirtualDom_doc.hidden !== 'undefined')
4087+ ? { hidden: 'hidden', change: 'visibilitychange' }
4088+ :
4089+ (typeof _VirtualDom_doc.mozHidden !== 'undefined')
4090+ ? { hidden: 'mozHidden', change: 'mozvisibilitychange' }
4091+ :
4092+ (typeof _VirtualDom_doc.msHidden !== 'undefined')
4093+ ? { hidden: 'msHidden', change: 'msvisibilitychange' }
4094+ :
4095+ (typeof _VirtualDom_doc.webkitHidden !== 'undefined')
4096+ ? { hidden: 'webkitHidden', change: 'webkitvisibilitychange' }
4097+ : { hidden: 'hidden', change: 'visibilitychange' };
4098+}
4099+
4100+
4101+
4102+// ANIMATION FRAMES
4103+
4104+
4105+function _Browser_rAF()
4106+{
4107+ return _Scheduler_binding(function(callback)
4108+ {
4109+ var id = _Browser_requestAnimationFrame(function() {
4110+ callback(_Scheduler_succeed(Date.now()));
4111+ });
4112+
4113+ return function() {
4114+ _Browser_cancelAnimationFrame(id);
4115+ };
4116+ });
4117+}
4118+
4119+
4120+function _Browser_now()
4121+{
4122+ return _Scheduler_binding(function(callback)
4123+ {
4124+ callback(_Scheduler_succeed(Date.now()));
4125+ });
4126+}
4127+
4128+
4129+
4130+// DOM STUFF
4131+
4132+
4133+function _Browser_withNode(id, doStuff)
4134+{
4135+ return _Scheduler_binding(function(callback)
4136+ {
4137+ callback(_Scheduler_fail($lynxjs_elm$browser$Browser$Dom$NotFound(id)));
4138+ });
4139+}
4140+
4141+
4142+function _Browser_withWindow(doStuff)
4143+{
4144+ return _Scheduler_binding(function(callback)
4145+ {
4146+ _Browser_requestAnimationFrame(function() {
4147+ callback(_Scheduler_succeed(doStuff()));
4148+ });
4149+ });
4150+}
4151+
4152+
4153+// FOCUS and BLUR
4154+
4155+
4156+var _Browser_call = F2(function(functionName, id)
4157+{
4158+ return _Browser_withNode(id, function(node) {
4159+ node[functionName]();
4160+ return _Utils_Tuple0;
4161+ });
4162+});
4163+
4164+
4165+
4166+// WINDOW VIEWPORT
4167+
4168+
4169+function _Browser_getViewport()
4170+{
4171+ return {
4172+ scene: _Browser_getScene(),
4173+ viewport: {
4174+ x: _Browser_window.pageXOffset,
4175+ y: _Browser_window.pageYOffset,
4176+ width: _Browser_doc.documentElement.clientWidth,
4177+ height: _Browser_doc.documentElement.clientHeight
4178+ }
4179+ };
4180+}
4181+
4182+function _Browser_getScene()
4183+{
4184+ var body = _Browser_doc.body;
4185+ var elem = _Browser_doc.documentElement;
4186+ return {
4187+ width: Math.max(body.scrollWidth, body.offsetWidth, elem.scrollWidth, elem.offsetWidth, elem.clientWidth),
4188+ height: Math.max(body.scrollHeight, body.offsetHeight, elem.scrollHeight, elem.offsetHeight, elem.clientHeight)
4189+ };
4190+}
4191+
4192+var _Browser_setViewport = F2(function(x, y)
4193+{
4194+ return _Browser_withWindow(function()
4195+ {
4196+ _Browser_window.scroll(x, y);
4197+ return _Utils_Tuple0;
4198+ });
4199+});
4200+
4201+
4202+
4203+// ELEMENT VIEWPORT
4204+
4205+
4206+function _Browser_getViewportOf(id)
4207+{
4208+ return _Browser_withNode(id, function(node)
4209+ {
4210+ return {
4211+ scene: {
4212+ width: node.scrollWidth,
4213+ height: node.scrollHeight
4214+ },
4215+ viewport: {
4216+ x: node.scrollLeft,
4217+ y: node.scrollTop,
4218+ width: node.clientWidth,
4219+ height: node.clientHeight
4220+ }
4221+ };
4222+ });
4223+}
4224+
4225+
4226+var _Browser_setViewportOf = F3(function(id, x, y)
4227+{
4228+ return _Browser_withNode(id, function(node)
4229+ {
4230+ node.scrollLeft = x;
4231+ node.scrollTop = y;
4232+ return _Utils_Tuple0;
4233+ });
4234+});
4235+
4236+
4237+
4238+// ELEMENT
4239+
4240+
4241+function _Browser_getElement(id)
4242+{
4243+ return _Browser_withNode(id, function(node)
4244+ {
4245+ var rect = node.getBoundingClientRect();
4246+ var x = _Browser_window.pageXOffset;
4247+ var y = _Browser_window.pageYOffset;
4248+ return {
4249+ scene: _Browser_getScene(),
4250+ viewport: {
4251+ x: x,
4252+ y: y,
4253+ width: _Browser_doc.documentElement.clientWidth,
4254+ height: _Browser_doc.documentElement.clientHeight
4255+ },
4256+ element: {
4257+ x: x + rect.left,
4258+ y: y + rect.top,
4259+ width: rect.width,
4260+ height: rect.height
4261+ }
4262+ };
4263+ });
4264+}
4265+
4266+
4267+
4268+// LOAD and RELOAD
4269+
4270+
4271+function _Browser_reload(skipCache)
4272+{
4273+ return A2($elm$core$Task$perform, $elm$core$Basics$never, _Scheduler_binding(function(callback)
4274+ {
4275+ // no-op in LynxJS
4276+ }));
4277+}
4278+
4279+function _Browser_load(url)
4280+{
4281+ return A2($elm$core$Task$perform, $elm$core$Basics$never, _Scheduler_binding(function(callback)
4282+ {
4283+ try
4284+ {
4285+ // no-op in LynxJS
4286+ }
4287+ catch(err)
4288+ {
4289+ // Only Firefox can throw a NS_ERROR_MALFORMED_URI exception here.
4290+ // Other browsers reload the page, so let's be consistent about that.
4291+ // no-op in LynxJS
4292+ }
4293+ }));
4294+}
4295+var $elm$core$List$cons = _List_cons;
4296+var $elm$core$Elm$JsArray$foldr = _JsArray_foldr;
4297+var $elm$core$Array$foldr = F3(
4298+ function (func, baseCase, _v0) {
4299+ var tree = _v0.c;
4300+ var tail = _v0.d;
4301+ var helper = F2(
4302+ function (node, acc) {
4303+ if (node.$ === 'SubTree') {
4304+ var subTree = node.a;
4305+ return A3($elm$core$Elm$JsArray$foldr, helper, acc, subTree);
4306+ } else {
4307+ var values = node.a;
4308+ return A3($elm$core$Elm$JsArray$foldr, func, acc, values);
4309+ }
4310+ });
4311+ return A3(
4312+ $elm$core$Elm$JsArray$foldr,
4313+ helper,
4314+ A3($elm$core$Elm$JsArray$foldr, func, baseCase, tail),
4315+ tree);
4316+ });
4317+var $elm$core$Array$toList = function (array) {
4318+ return A3($elm$core$Array$foldr, $elm$core$List$cons, _List_Nil, array);
4319+};
4320+var $elm$core$Dict$foldr = F3(
4321+ function (func, acc, t) {
4322+ foldr:
4323+ while (true) {
4324+ if (t.$ === 'RBEmpty_elm_builtin') {
4325+ return acc;
4326+ } else {
4327+ var key = t.b;
4328+ var value = t.c;
4329+ var left = t.d;
4330+ var right = t.e;
4331+ var $temp$func = func,
4332+ $temp$acc = A3(
4333+ func,
4334+ key,
4335+ value,
4336+ A3($elm$core$Dict$foldr, func, acc, right)),
4337+ $temp$t = left;
4338+ func = $temp$func;
4339+ acc = $temp$acc;
4340+ t = $temp$t;
4341+ continue foldr;
4342+ }
4343+ }
4344+ });
4345+var $elm$core$Dict$toList = function (dict) {
4346+ return A3(
4347+ $elm$core$Dict$foldr,
4348+ F3(
4349+ function (key, value, list) {
4350+ return A2(
4351+ $elm$core$List$cons,
4352+ _Utils_Tuple2(key, value),
4353+ list);
4354+ }),
4355+ _List_Nil,
4356+ dict);
4357+};
4358+var $elm$core$Dict$keys = function (dict) {
4359+ return A3(
4360+ $elm$core$Dict$foldr,
4361+ F3(
4362+ function (key, value, keyList) {
4363+ return A2($elm$core$List$cons, key, keyList);
4364+ }),
4365+ _List_Nil,
4366+ dict);
4367+};
4368+var $elm$core$Set$toList = function (_v0) {
4369+ var dict = _v0.a;
4370+ return $elm$core$Dict$keys(dict);
4371+};
4372+var $elm$core$Basics$EQ = {$: 'EQ'};
4373+var $elm$core$Basics$GT = {$: 'GT'};
4374+var $elm$core$Basics$LT = {$: 'LT'};
4375+var $elm$core$Basics$False = {$: 'False'};
4376+var $elm$core$Basics$True = {$: 'True'};
4377+var $author$project$Main$init = {
4378+ draft: '',
4379+ items: _List_fromArray(
4380+ [
4381+ {done: true, id: 1, text: 'Learn Elm'},
4382+ {done: false, id: 2, text: 'Build a LynxJS app'},
4383+ {done: false, id: 3, text: 'Ship to production'}
4384+ ]),
4385+ nextId: 4
4386+};
4387+var $elm$core$Result$Err = function (a) {
4388+ return {$: 'Err', a: a};
4389+};
4390+var $elm$json$Json$Decode$Failure = F2(
4391+ function (a, b) {
4392+ return {$: 'Failure', a: a, b: b};
4393+ });
4394+var $elm$json$Json$Decode$Field = F2(
4395+ function (a, b) {
4396+ return {$: 'Field', a: a, b: b};
4397+ });
4398+var $elm$json$Json$Decode$Index = F2(
4399+ function (a, b) {
4400+ return {$: 'Index', a: a, b: b};
4401+ });
4402+var $elm$core$Result$Ok = function (a) {
4403+ return {$: 'Ok', a: a};
4404+};
4405+var $elm$json$Json$Decode$OneOf = function (a) {
4406+ return {$: 'OneOf', a: a};
4407+};
4408+var $elm$core$Basics$add = _Basics_add;
4409+var $elm$core$Maybe$Just = function (a) {
4410+ return {$: 'Just', a: a};
4411+};
4412+var $elm$core$Maybe$Nothing = {$: 'Nothing'};
4413+var $elm$core$String$all = _String_all;
4414+var $elm$core$Basics$and = _Basics_and;
4415+var $elm$core$Basics$append = _Utils_append;
4416+var $elm$json$Json$Encode$encode = _Json_encode;
4417+var $elm$core$String$fromInt = _String_fromNumber;
4418+var $elm$core$String$join = F2(
4419+ function (sep, chunks) {
4420+ return A2(
4421+ _String_join,
4422+ sep,
4423+ _List_toArray(chunks));
4424+ });
4425+var $elm$core$String$split = F2(
4426+ function (sep, string) {
4427+ return _List_fromArray(
4428+ A2(_String_split, sep, string));
4429+ });
4430+var $elm$json$Json$Decode$indent = function (str) {
4431+ return A2(
4432+ $elm$core$String$join,
4433+ '\n ',
4434+ A2($elm$core$String$split, '\n', str));
4435+};
4436+var $elm$core$List$foldl = F3(
4437+ function (func, acc, list) {
4438+ foldl:
4439+ while (true) {
4440+ if (!list.b) {
4441+ return acc;
4442+ } else {
4443+ var x = list.a;
4444+ var xs = list.b;
4445+ var $temp$func = func,
4446+ $temp$acc = A2(func, x, acc),
4447+ $temp$list = xs;
4448+ func = $temp$func;
4449+ acc = $temp$acc;
4450+ list = $temp$list;
4451+ continue foldl;
4452+ }
4453+ }
4454+ });
4455+var $elm$core$List$length = function (xs) {
4456+ return A3(
4457+ $elm$core$List$foldl,
4458+ F2(
4459+ function (_v0, i) {
4460+ return i + 1;
4461+ }),
4462+ 0,
4463+ xs);
4464+};
4465+var $elm$core$List$map2 = _List_map2;
4466+var $elm$core$Basics$le = _Utils_le;
4467+var $elm$core$Basics$sub = _Basics_sub;
4468+var $elm$core$List$rangeHelp = F3(
4469+ function (lo, hi, list) {
4470+ rangeHelp:
4471+ while (true) {
4472+ if (_Utils_cmp(lo, hi) < 1) {
4473+ var $temp$lo = lo,
4474+ $temp$hi = hi - 1,
4475+ $temp$list = A2($elm$core$List$cons, hi, list);
4476+ lo = $temp$lo;
4477+ hi = $temp$hi;
4478+ list = $temp$list;
4479+ continue rangeHelp;
4480+ } else {
4481+ return list;
4482+ }
4483+ }
4484+ });
4485+var $elm$core$List$range = F2(
4486+ function (lo, hi) {
4487+ return A3($elm$core$List$rangeHelp, lo, hi, _List_Nil);
4488+ });
4489+var $elm$core$List$indexedMap = F2(
4490+ function (f, xs) {
4491+ return A3(
4492+ $elm$core$List$map2,
4493+ f,
4494+ A2(
4495+ $elm$core$List$range,
4496+ 0,
4497+ $elm$core$List$length(xs) - 1),
4498+ xs);
4499+ });
4500+var $elm$core$Char$toCode = _Char_toCode;
4501+var $elm$core$Char$isLower = function (_char) {
4502+ var code = $elm$core$Char$toCode(_char);
4503+ return (97 <= code) && (code <= 122);
4504+};
4505+var $elm$core$Char$isUpper = function (_char) {
4506+ var code = $elm$core$Char$toCode(_char);
4507+ return (code <= 90) && (65 <= code);
4508+};
4509+var $elm$core$Basics$or = _Basics_or;
4510+var $elm$core$Char$isAlpha = function (_char) {
4511+ return $elm$core$Char$isLower(_char) || $elm$core$Char$isUpper(_char);
4512+};
4513+var $elm$core$Char$isDigit = function (_char) {
4514+ var code = $elm$core$Char$toCode(_char);
4515+ return (code <= 57) && (48 <= code);
4516+};
4517+var $elm$core$Char$isAlphaNum = function (_char) {
4518+ return $elm$core$Char$isLower(_char) || ($elm$core$Char$isUpper(_char) || $elm$core$Char$isDigit(_char));
4519+};
4520+var $elm$core$List$reverse = function (list) {
4521+ return A3($elm$core$List$foldl, $elm$core$List$cons, _List_Nil, list);
4522+};
4523+var $elm$core$String$uncons = _String_uncons;
4524+var $elm$json$Json$Decode$errorOneOf = F2(
4525+ function (i, error) {
4526+ return '\n\n(' + ($elm$core$String$fromInt(i + 1) + (') ' + $elm$json$Json$Decode$indent(
4527+ $elm$json$Json$Decode$errorToString(error))));
4528+ });
4529+var $elm$json$Json$Decode$errorToString = function (error) {
4530+ return A2($elm$json$Json$Decode$errorToStringHelp, error, _List_Nil);
4531+};
4532+var $elm$json$Json$Decode$errorToStringHelp = F2(
4533+ function (error, context) {
4534+ errorToStringHelp:
4535+ while (true) {
4536+ switch (error.$) {
4537+ case 'Field':
4538+ var f = error.a;
4539+ var err = error.b;
4540+ var isSimple = function () {
4541+ var _v1 = $elm$core$String$uncons(f);
4542+ if (_v1.$ === 'Nothing') {
4543+ return false;
4544+ } else {
4545+ var _v2 = _v1.a;
4546+ var _char = _v2.a;
4547+ var rest = _v2.b;
4548+ return $elm$core$Char$isAlpha(_char) && A2($elm$core$String$all, $elm$core$Char$isAlphaNum, rest);
4549+ }
4550+ }();
4551+ var fieldName = isSimple ? ('.' + f) : ('[\'' + (f + '\']'));
4552+ var $temp$error = err,
4553+ $temp$context = A2($elm$core$List$cons, fieldName, context);
4554+ error = $temp$error;
4555+ context = $temp$context;
4556+ continue errorToStringHelp;
4557+ case 'Index':
4558+ var i = error.a;
4559+ var err = error.b;
4560+ var indexName = '[' + ($elm$core$String$fromInt(i) + ']');
4561+ var $temp$error = err,
4562+ $temp$context = A2($elm$core$List$cons, indexName, context);
4563+ error = $temp$error;
4564+ context = $temp$context;
4565+ continue errorToStringHelp;
4566+ case 'OneOf':
4567+ var errors = error.a;
4568+ if (!errors.b) {
4569+ return 'Ran into a Json.Decode.oneOf with no possibilities' + function () {
4570+ if (!context.b) {
4571+ return '!';
4572+ } else {
4573+ return ' at json' + A2(
4574+ $elm$core$String$join,
4575+ '',
4576+ $elm$core$List$reverse(context));
4577+ }
4578+ }();
4579+ } else {
4580+ if (!errors.b.b) {
4581+ var err = errors.a;
4582+ var $temp$error = err,
4583+ $temp$context = context;
4584+ error = $temp$error;
4585+ context = $temp$context;
4586+ continue errorToStringHelp;
4587+ } else {
4588+ var starter = function () {
4589+ if (!context.b) {
4590+ return 'Json.Decode.oneOf';
4591+ } else {
4592+ return 'The Json.Decode.oneOf at json' + A2(
4593+ $elm$core$String$join,
4594+ '',
4595+ $elm$core$List$reverse(context));
4596+ }
4597+ }();
4598+ var introduction = starter + (' failed in the following ' + ($elm$core$String$fromInt(
4599+ $elm$core$List$length(errors)) + ' ways:'));
4600+ return A2(
4601+ $elm$core$String$join,
4602+ '\n\n',
4603+ A2(
4604+ $elm$core$List$cons,
4605+ introduction,
4606+ A2($elm$core$List$indexedMap, $elm$json$Json$Decode$errorOneOf, errors)));
4607+ }
4608+ }
4609+ default:
4610+ var msg = error.a;
4611+ var json = error.b;
4612+ var introduction = function () {
4613+ if (!context.b) {
4614+ return 'Problem with the given value:\n\n';
4615+ } else {
4616+ return 'Problem with the value at json' + (A2(
4617+ $elm$core$String$join,
4618+ '',
4619+ $elm$core$List$reverse(context)) + ':\n\n ');
4620+ }
4621+ }();
4622+ return introduction + ($elm$json$Json$Decode$indent(
4623+ A2($elm$json$Json$Encode$encode, 4, json)) + ('\n\n' + msg));
4624+ }
4625+ }
4626+ });
4627+var $elm$core$Array$branchFactor = 32;
4628+var $elm$core$Array$Array_elm_builtin = F4(
4629+ function (a, b, c, d) {
4630+ return {$: 'Array_elm_builtin', a: a, b: b, c: c, d: d};
4631+ });
4632+var $elm$core$Elm$JsArray$empty = _JsArray_empty;
4633+var $elm$core$Basics$ceiling = _Basics_ceiling;
4634+var $elm$core$Basics$fdiv = _Basics_fdiv;
4635+var $elm$core$Basics$logBase = F2(
4636+ function (base, number) {
4637+ return _Basics_log(number) / _Basics_log(base);
4638+ });
4639+var $elm$core$Basics$toFloat = _Basics_toFloat;
4640+var $elm$core$Array$shiftStep = $elm$core$Basics$ceiling(
4641+ A2($elm$core$Basics$logBase, 2, $elm$core$Array$branchFactor));
4642+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);
4643+var $elm$core$Elm$JsArray$initialize = _JsArray_initialize;
4644+var $elm$core$Array$Leaf = function (a) {
4645+ return {$: 'Leaf', a: a};
4646+};
4647+var $elm$core$Basics$apL = F2(
4648+ function (f, x) {
4649+ return f(x);
4650+ });
4651+var $elm$core$Basics$apR = F2(
4652+ function (x, f) {
4653+ return f(x);
4654+ });
4655+var $elm$core$Basics$eq = _Utils_equal;
4656+var $elm$core$Basics$floor = _Basics_floor;
4657+var $elm$core$Elm$JsArray$length = _JsArray_length;
4658+var $elm$core$Basics$gt = _Utils_gt;
4659+var $elm$core$Basics$max = F2(
4660+ function (x, y) {
4661+ return (_Utils_cmp(x, y) > 0) ? x : y;
4662+ });
4663+var $elm$core$Basics$mul = _Basics_mul;
4664+var $elm$core$Array$SubTree = function (a) {
4665+ return {$: 'SubTree', a: a};
4666+};
4667+var $elm$core$Elm$JsArray$initializeFromList = _JsArray_initializeFromList;
4668+var $elm$core$Array$compressNodes = F2(
4669+ function (nodes, acc) {
4670+ compressNodes:
4671+ while (true) {
4672+ var _v0 = A2($elm$core$Elm$JsArray$initializeFromList, $elm$core$Array$branchFactor, nodes);
4673+ var node = _v0.a;
4674+ var remainingNodes = _v0.b;
4675+ var newAcc = A2(
4676+ $elm$core$List$cons,
4677+ $elm$core$Array$SubTree(node),
4678+ acc);
4679+ if (!remainingNodes.b) {
4680+ return $elm$core$List$reverse(newAcc);
4681+ } else {
4682+ var $temp$nodes = remainingNodes,
4683+ $temp$acc = newAcc;
4684+ nodes = $temp$nodes;
4685+ acc = $temp$acc;
4686+ continue compressNodes;
4687+ }
4688+ }
4689+ });
4690+var $elm$core$Tuple$first = function (_v0) {
4691+ var x = _v0.a;
4692+ return x;
4693+};
4694+var $elm$core$Array$treeFromBuilder = F2(
4695+ function (nodeList, nodeListSize) {
4696+ treeFromBuilder:
4697+ while (true) {
4698+ var newNodeSize = $elm$core$Basics$ceiling(nodeListSize / $elm$core$Array$branchFactor);
4699+ if (newNodeSize === 1) {
4700+ return A2($elm$core$Elm$JsArray$initializeFromList, $elm$core$Array$branchFactor, nodeList).a;
4701+ } else {
4702+ var $temp$nodeList = A2($elm$core$Array$compressNodes, nodeList, _List_Nil),
4703+ $temp$nodeListSize = newNodeSize;
4704+ nodeList = $temp$nodeList;
4705+ nodeListSize = $temp$nodeListSize;
4706+ continue treeFromBuilder;
4707+ }
4708+ }
4709+ });
4710+var $elm$core$Array$builderToArray = F2(
4711+ function (reverseNodeList, builder) {
4712+ if (!builder.nodeListSize) {
4713+ return A4(
4714+ $elm$core$Array$Array_elm_builtin,
4715+ $elm$core$Elm$JsArray$length(builder.tail),
4716+ $elm$core$Array$shiftStep,
4717+ $elm$core$Elm$JsArray$empty,
4718+ builder.tail);
4719+ } else {
4720+ var treeLen = builder.nodeListSize * $elm$core$Array$branchFactor;
4721+ var depth = $elm$core$Basics$floor(
4722+ A2($elm$core$Basics$logBase, $elm$core$Array$branchFactor, treeLen - 1));
4723+ var correctNodeList = reverseNodeList ? $elm$core$List$reverse(builder.nodeList) : builder.nodeList;
4724+ var tree = A2($elm$core$Array$treeFromBuilder, correctNodeList, builder.nodeListSize);
4725+ return A4(
4726+ $elm$core$Array$Array_elm_builtin,
4727+ $elm$core$Elm$JsArray$length(builder.tail) + treeLen,
4728+ A2($elm$core$Basics$max, 5, depth * $elm$core$Array$shiftStep),
4729+ tree,
4730+ builder.tail);
4731+ }
4732+ });
4733+var $elm$core$Basics$idiv = _Basics_idiv;
4734+var $elm$core$Basics$lt = _Utils_lt;
4735+var $elm$core$Array$initializeHelp = F5(
4736+ function (fn, fromIndex, len, nodeList, tail) {
4737+ initializeHelp:
4738+ while (true) {
4739+ if (fromIndex < 0) {
4740+ return A2(
4741+ $elm$core$Array$builderToArray,
4742+ false,
4743+ {nodeList: nodeList, nodeListSize: (len / $elm$core$Array$branchFactor) | 0, tail: tail});
4744+ } else {
4745+ var leaf = $elm$core$Array$Leaf(
4746+ A3($elm$core$Elm$JsArray$initialize, $elm$core$Array$branchFactor, fromIndex, fn));
4747+ var $temp$fn = fn,
4748+ $temp$fromIndex = fromIndex - $elm$core$Array$branchFactor,
4749+ $temp$len = len,
4750+ $temp$nodeList = A2($elm$core$List$cons, leaf, nodeList),
4751+ $temp$tail = tail;
4752+ fn = $temp$fn;
4753+ fromIndex = $temp$fromIndex;
4754+ len = $temp$len;
4755+ nodeList = $temp$nodeList;
4756+ tail = $temp$tail;
4757+ continue initializeHelp;
4758+ }
4759+ }
4760+ });
4761+var $elm$core$Basics$remainderBy = _Basics_remainderBy;
4762+var $elm$core$Array$initialize = F2(
4763+ function (len, fn) {
4764+ if (len <= 0) {
4765+ return $elm$core$Array$empty;
4766+ } else {
4767+ var tailLen = len % $elm$core$Array$branchFactor;
4768+ var tail = A3($elm$core$Elm$JsArray$initialize, tailLen, len - tailLen, fn);
4769+ var initialFromIndex = (len - tailLen) - $elm$core$Array$branchFactor;
4770+ return A5($elm$core$Array$initializeHelp, fn, initialFromIndex, len, _List_Nil, tail);
4771+ }
4772+ });
4773+var $elm$core$Result$isOk = function (result) {
4774+ if (result.$ === 'Ok') {
4775+ return true;
4776+ } else {
4777+ return false;
4778+ }
4779+};
4780+var $elm$json$Json$Decode$map = _Json_map1;
4781+var $elm$json$Json$Decode$map2 = _Json_map2;
4782+var $elm$json$Json$Decode$succeed = _Json_succeed;
4783+var $lynxjs_elm$virtual_dom$VirtualDom$toHandlerInt = function (handler) {
4784+ switch (handler.$) {
4785+ case 'Normal':
4786+ return 0;
4787+ case 'MayStopPropagation':
4788+ return 1;
4789+ case 'MayPreventDefault':
4790+ return 2;
4791+ default:
4792+ return 3;
4793+ }
4794+};
4795+var $elm$core$Basics$identity = function (x) {
4796+ return x;
4797+};
4798+var $lynxjs_elm$browser$Browser$Dom$NotFound = function (a) {
4799+ return {$: 'NotFound', a: a};
4800+};
4801+var $elm$core$Basics$never = function (_v0) {
4802+ never:
4803+ while (true) {
4804+ var nvr = _v0.a;
4805+ var $temp$_v0 = nvr;
4806+ _v0 = $temp$_v0;
4807+ continue never;
4808+ }
4809+};
4810+var $elm$core$Task$Perform = function (a) {
4811+ return {$: 'Perform', a: a};
4812+};
4813+var $elm$core$Task$succeed = _Scheduler_succeed;
4814+var $elm$core$Task$init = $elm$core$Task$succeed(_Utils_Tuple0);
4815+var $elm$core$List$foldrHelper = F4(
4816+ function (fn, acc, ctr, ls) {
4817+ if (!ls.b) {
4818+ return acc;
4819+ } else {
4820+ var a = ls.a;
4821+ var r1 = ls.b;
4822+ if (!r1.b) {
4823+ return A2(fn, a, acc);
4824+ } else {
4825+ var b = r1.a;
4826+ var r2 = r1.b;
4827+ if (!r2.b) {
4828+ return A2(
4829+ fn,
4830+ a,
4831+ A2(fn, b, acc));
4832+ } else {
4833+ var c = r2.a;
4834+ var r3 = r2.b;
4835+ if (!r3.b) {
4836+ return A2(
4837+ fn,
4838+ a,
4839+ A2(
4840+ fn,
4841+ b,
4842+ A2(fn, c, acc)));
4843+ } else {
4844+ var d = r3.a;
4845+ var r4 = r3.b;
4846+ var res = (ctr > 500) ? A3(
4847+ $elm$core$List$foldl,
4848+ fn,
4849+ acc,
4850+ $elm$core$List$reverse(r4)) : A4($elm$core$List$foldrHelper, fn, acc, ctr + 1, r4);
4851+ return A2(
4852+ fn,
4853+ a,
4854+ A2(
4855+ fn,
4856+ b,
4857+ A2(
4858+ fn,
4859+ c,
4860+ A2(fn, d, res))));
4861+ }
4862+ }
4863+ }
4864+ }
4865+ });
4866+var $elm$core$List$foldr = F3(
4867+ function (fn, acc, ls) {
4868+ return A4($elm$core$List$foldrHelper, fn, acc, 0, ls);
4869+ });
4870+var $elm$core$List$map = F2(
4871+ function (f, xs) {
4872+ return A3(
4873+ $elm$core$List$foldr,
4874+ F2(
4875+ function (x, acc) {
4876+ return A2(
4877+ $elm$core$List$cons,
4878+ f(x),
4879+ acc);
4880+ }),
4881+ _List_Nil,
4882+ xs);
4883+ });
4884+var $elm$core$Task$andThen = _Scheduler_andThen;
4885+var $elm$core$Task$map = F2(
4886+ function (func, taskA) {
4887+ return A2(
4888+ $elm$core$Task$andThen,
4889+ function (a) {
4890+ return $elm$core$Task$succeed(
4891+ func(a));
4892+ },
4893+ taskA);
4894+ });
4895+var $elm$core$Task$map2 = F3(
4896+ function (func, taskA, taskB) {
4897+ return A2(
4898+ $elm$core$Task$andThen,
4899+ function (a) {
4900+ return A2(
4901+ $elm$core$Task$andThen,
4902+ function (b) {
4903+ return $elm$core$Task$succeed(
4904+ A2(func, a, b));
4905+ },
4906+ taskB);
4907+ },
4908+ taskA);
4909+ });
4910+var $elm$core$Task$sequence = function (tasks) {
4911+ return A3(
4912+ $elm$core$List$foldr,
4913+ $elm$core$Task$map2($elm$core$List$cons),
4914+ $elm$core$Task$succeed(_List_Nil),
4915+ tasks);
4916+};
4917+var $elm$core$Platform$sendToApp = _Platform_sendToApp;
4918+var $elm$core$Task$spawnCmd = F2(
4919+ function (router, _v0) {
4920+ var task = _v0.a;
4921+ return _Scheduler_spawn(
4922+ A2(
4923+ $elm$core$Task$andThen,
4924+ $elm$core$Platform$sendToApp(router),
4925+ task));
4926+ });
4927+var $elm$core$Task$onEffects = F3(
4928+ function (router, commands, state) {
4929+ return A2(
4930+ $elm$core$Task$map,
4931+ function (_v0) {
4932+ return _Utils_Tuple0;
4933+ },
4934+ $elm$core$Task$sequence(
4935+ A2(
4936+ $elm$core$List$map,
4937+ $elm$core$Task$spawnCmd(router),
4938+ commands)));
4939+ });
4940+var $elm$core$Task$onSelfMsg = F3(
4941+ function (_v0, _v1, _v2) {
4942+ return $elm$core$Task$succeed(_Utils_Tuple0);
4943+ });
4944+var $elm$core$Task$cmdMap = F2(
4945+ function (tagger, _v0) {
4946+ var task = _v0.a;
4947+ return $elm$core$Task$Perform(
4948+ A2($elm$core$Task$map, tagger, task));
4949+ });
4950+_Platform_effectManagers['Task'] = _Platform_createManager($elm$core$Task$init, $elm$core$Task$onEffects, $elm$core$Task$onSelfMsg, $elm$core$Task$cmdMap);
4951+var $elm$core$Task$command = _Platform_leaf('Task');
4952+var $elm$core$Task$perform = F2(
4953+ function (toMessage, task) {
4954+ return $elm$core$Task$command(
4955+ $elm$core$Task$Perform(
4956+ A2($elm$core$Task$map, toMessage, task)));
4957+ });
4958+var $elm$core$Platform$Cmd$batch = _Platform_batch;
4959+var $elm$core$Platform$Cmd$none = $elm$core$Platform$Cmd$batch(_List_Nil);
4960+var $elm$core$Platform$Sub$batch = _Platform_batch;
4961+var $elm$core$Platform$Sub$none = $elm$core$Platform$Sub$batch(_List_Nil);
4962+var $lynxjs_elm$browser$Browser$sandbox = function (impl) {
4963+ return _Browser_element(
4964+ {
4965+ init: function (_v0) {
4966+ return _Utils_Tuple2(impl.init, $elm$core$Platform$Cmd$none);
4967+ },
4968+ subscriptions: function (_v1) {
4969+ return $elm$core$Platform$Sub$none;
4970+ },
4971+ update: F2(
4972+ function (msg, model) {
4973+ return _Utils_Tuple2(
4974+ A2(impl.update, msg, model),
4975+ $elm$core$Platform$Cmd$none);
4976+ }),
4977+ view: impl.view
4978+ });
4979+};
4980+var $elm$core$List$filter = F2(
4981+ function (isGood, list) {
4982+ return A3(
4983+ $elm$core$List$foldr,
4984+ F2(
4985+ function (x, xs) {
4986+ return isGood(x) ? A2($elm$core$List$cons, x, xs) : xs;
4987+ }),
4988+ _List_Nil,
4989+ list);
4990+ });
4991+var $elm$core$String$isEmpty = function (string) {
4992+ return string === '';
4993+};
4994+var $elm$core$Basics$neq = _Utils_notEqual;
4995+var $elm$core$Basics$not = _Basics_not;
4996+var $elm$core$String$trim = _String_trim;
4997+var $author$project$Main$update = F2(
4998+ function (msg, model) {
4999+ switch (msg.$) {
5000+ case 'Toggle':
5001+ var targetId = msg.a;
5002+ return _Utils_update(
5003+ model,
5004+ {
5005+ items: A2(
5006+ $elm$core$List$map,
5007+ function (item) {
5008+ return _Utils_eq(item.id, targetId) ? _Utils_update(
5009+ item,
5010+ {done: !item.done}) : item;
5011+ },
5012+ model.items)
5013+ });
5014+ case 'Remove':
5015+ var targetId = msg.a;
5016+ return _Utils_update(
5017+ model,
5018+ {
5019+ items: A2(
5020+ $elm$core$List$filter,
5021+ function (item) {
5022+ return !_Utils_eq(item.id, targetId);
5023+ },
5024+ model.items)
5025+ });
5026+ case 'UpdateDraft':
5027+ var text = msg.a;
5028+ return _Utils_update(
5029+ model,
5030+ {draft: text});
5031+ default:
5032+ return $elm$core$String$isEmpty(
5033+ $elm$core$String$trim(model.draft)) ? model : _Utils_update(
5034+ model,
5035+ {
5036+ draft: '',
5037+ items: _Utils_ap(
5038+ model.items,
5039+ _List_fromArray(
5040+ [
5041+ {done: false, id: model.nextId, text: model.draft}
5042+ ])),
5043+ nextId: model.nextId + 1
5044+ });
5045+ }
5046+ });
5047+var $author$project$Main$AddItem = {$: 'AddItem'};
5048+var $lynxjs_elm$ui$Lynx$Attributes$Bold = {$: 'Bold'};
5049+var $lynxjs_elm$ui$Lynx$Attributes$Center = {$: 'Center'};
5050+var $lynxjs_elm$ui$Lynx$Attributes$Column = {$: 'Column'};
5051+var $lynxjs_elm$ui$Lynx$Attributes$Row = {$: 'Row'};
5052+var $author$project$Main$UpdateDraft = function (a) {
5053+ return {$: 'UpdateDraft', a: a};
5054+};
5055+var $lynxjs_elm$ui$Lynx$Attributes$Vertical = {$: 'Vertical'};
5056+var $lynxjs_elm$ui$Lynx$Attributes$alignmentToString = function (a) {
5057+ switch (a.$) {
5058+ case 'Start':
5059+ return 'flex-start';
5060+ case 'Center':
5061+ return 'center';
5062+ case 'End':
5063+ return 'flex-end';
5064+ case 'SpaceBetween':
5065+ return 'space-between';
5066+ case 'SpaceAround':
5067+ return 'space-around';
5068+ case 'SpaceEvenly':
5069+ return 'space-evenly';
5070+ case 'Stretch':
5071+ return 'stretch';
5072+ default:
5073+ return 'baseline';
5074+ }
5075+};
5076+var $lynxjs_elm$virtual_dom$VirtualDom$style = _VirtualDom_style;
5077+var $lynxjs_elm$ui$Lynx$Attributes$style = $lynxjs_elm$virtual_dom$VirtualDom$style;
5078+var $lynxjs_elm$ui$Lynx$Attributes$alignItems = function (a) {
5079+ return A2(
5080+ $lynxjs_elm$ui$Lynx$Attributes$style,
5081+ 'alignItems',
5082+ $lynxjs_elm$ui$Lynx$Attributes$alignmentToString(a));
5083+};
5084+var $lynxjs_elm$ui$Lynx$Attributes$backgroundColor = $lynxjs_elm$ui$Lynx$Attributes$style('backgroundColor');
5085+var $lynxjs_elm$ui$Lynx$Attributes$borderColor = $lynxjs_elm$ui$Lynx$Attributes$style('borderColor');
5086+var $lynxjs_elm$ui$Lynx$Attributes$pxStyle = F2(
5087+ function (key, val) {
5088+ return A2(
5089+ $lynxjs_elm$virtual_dom$VirtualDom$style,
5090+ key,
5091+ $elm$core$String$fromInt(val) + 'px');
5092+ });
5093+var $lynxjs_elm$ui$Lynx$Attributes$borderRadius = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('borderRadius');
5094+var $lynxjs_elm$ui$Lynx$Attributes$borderWidth = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('borderWidth');
5095+var $lynxjs_elm$ui$Lynx$Attributes$color = $lynxjs_elm$ui$Lynx$Attributes$style('color');
5096+var $lynxjs_elm$ui$Lynx$Attributes$intStyle = F2(
5097+ function (key, val) {
5098+ return A2(
5099+ $lynxjs_elm$virtual_dom$VirtualDom$style,
5100+ key,
5101+ $elm$core$String$fromInt(val));
5102+ });
5103+var $lynxjs_elm$ui$Lynx$Attributes$flex = $lynxjs_elm$ui$Lynx$Attributes$intStyle('flex');
5104+var $lynxjs_elm$ui$Lynx$Attributes$flexDirection = function (d) {
5105+ return A2(
5106+ $lynxjs_elm$ui$Lynx$Attributes$style,
5107+ 'flexDirection',
5108+ function () {
5109+ switch (d.$) {
5110+ case 'Row':
5111+ return 'row';
5112+ case 'Column':
5113+ return 'column';
5114+ case 'RowReverse':
5115+ return 'row-reverse';
5116+ default:
5117+ return 'column-reverse';
5118+ }
5119+ }());
5120+};
5121+var $lynxjs_elm$ui$Lynx$Attributes$fontSize = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('fontSize');
5122+var $lynxjs_elm$ui$Lynx$Attributes$fontWeight = function (w) {
5123+ return A2(
5124+ $lynxjs_elm$ui$Lynx$Attributes$style,
5125+ 'fontWeight',
5126+ function () {
5127+ if (w.$ === 'Normal') {
5128+ return 'normal';
5129+ } else {
5130+ return 'bold';
5131+ }
5132+ }());
5133+};
5134+var $lynxjs_elm$ui$Lynx$Attributes$height = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('height');
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$input = $lynxjs_elm$virtual_dom$VirtualDom$node('input');
5140+var $lynxjs_elm$ui$Lynx$Attributes$marginBottom = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('marginBottom');
5141+var $lynxjs_elm$ui$Lynx$Attributes$marginLeft = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('marginLeft');
5142+var $lynxjs_elm$virtual_dom$VirtualDom$Normal = function (a) {
5143+ return {$: 'Normal', a: a};
5144+};
5145+var $elm$json$Json$Decode$field = _Json_decodeField;
5146+var $elm$json$Json$Decode$at = F2(
5147+ function (fields, decoder) {
5148+ return A3($elm$core$List$foldr, $elm$json$Json$Decode$field, decoder, fields);
5149+ });
5150+var $lynxjs_elm$virtual_dom$VirtualDom$on = _VirtualDom_on;
5151+var $elm$json$Json$Decode$string = _Json_decodeString;
5152+var $lynxjs_elm$ui$Lynx$Events$onInput = function (tagger) {
5153+ return A2(
5154+ $lynxjs_elm$virtual_dom$VirtualDom$on,
5155+ 'input',
5156+ $lynxjs_elm$virtual_dom$VirtualDom$Normal(
5157+ A2(
5158+ $elm$json$Json$Decode$map,
5159+ tagger,
5160+ A2(
5161+ $elm$json$Json$Decode$at,
5162+ _List_fromArray(
5163+ ['detail', 'value']),
5164+ $elm$json$Json$Decode$string))));
5165+};
5166+var $lynxjs_elm$ui$Lynx$Events$onTap = function (msg) {
5167+ return A2(
5168+ $lynxjs_elm$virtual_dom$VirtualDom$on,
5169+ 'tap',
5170+ $lynxjs_elm$virtual_dom$VirtualDom$Normal(
5171+ $elm$json$Json$Decode$succeed(msg)));
5172+};
5173+var $lynxjs_elm$ui$Lynx$Attributes$padding = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('padding');
5174+var $lynxjs_elm$ui$Lynx$Attributes$paddingBottom = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('paddingBottom');
5175+var $lynxjs_elm$ui$Lynx$Attributes$paddingLeft = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('paddingLeft');
5176+var $lynxjs_elm$ui$Lynx$Attributes$paddingRight = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('paddingRight');
5177+var $lynxjs_elm$ui$Lynx$Attributes$paddingTop = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('paddingTop');
5178+var $lynxjs_elm$virtual_dom$VirtualDom$attribute = F2(
5179+ function (key, value) {
5180+ return A2(
5181+ _VirtualDom_attribute,
5182+ _VirtualDom_noOnOrFormAction(key),
5183+ _VirtualDom_noJavaScriptOrHtmlUri(value));
5184+ });
5185+var $lynxjs_elm$ui$Lynx$Attributes$attr = $lynxjs_elm$virtual_dom$VirtualDom$attribute;
5186+var $lynxjs_elm$ui$Lynx$Attributes$placeholder = $lynxjs_elm$ui$Lynx$Attributes$attr('placeholder');
5187+var $lynxjs_elm$ui$Lynx$Attributes$scrollDirection = function (d) {
5188+ return A2(
5189+ $lynxjs_elm$ui$Lynx$Attributes$attr,
5190+ 'scroll-direction',
5191+ function () {
5192+ if (d.$ === 'Vertical') {
5193+ return 'vertical';
5194+ } else {
5195+ return 'horizontal';
5196+ }
5197+ }());
5198+};
5199+var $lynxjs_elm$ui$Lynx$scrollView = $lynxjs_elm$virtual_dom$VirtualDom$node('scroll-view');
5200+var $author$project$Main$summaryText = function (items) {
5201+ var total = $elm$core$List$length(items);
5202+ var done = $elm$core$List$length(
5203+ A2(
5204+ $elm$core$List$filter,
5205+ function ($) {
5206+ return $.done;
5207+ },
5208+ items));
5209+ return $elm$core$String$fromInt(done) + ('/' + ($elm$core$String$fromInt(total) + ' completed'));
5210+};
5211+var $lynxjs_elm$ui$Lynx$text = $lynxjs_elm$virtual_dom$VirtualDom$node('text');
5212+var $lynxjs_elm$virtual_dom$VirtualDom$text = _VirtualDom_text;
5213+var $lynxjs_elm$ui$Lynx$textContent = $lynxjs_elm$virtual_dom$VirtualDom$text;
5214+var $lynxjs_elm$ui$Lynx$Attributes$value = $lynxjs_elm$ui$Lynx$Attributes$attr('value');
5215+var $lynxjs_elm$ui$Lynx$view = $lynxjs_elm$virtual_dom$VirtualDom$node('view');
5216+var $author$project$Main$Remove = function (a) {
5217+ return {$: 'Remove', a: a};
5218+};
5219+var $author$project$Main$Toggle = function (a) {
5220+ return {$: 'Toggle', a: a};
5221+};
5222+var $lynxjs_elm$ui$Lynx$Attributes$justifyContent = function (a) {
5223+ return A2(
5224+ $lynxjs_elm$ui$Lynx$Attributes$style,
5225+ 'justifyContent',
5226+ $lynxjs_elm$ui$Lynx$Attributes$alignmentToString(a));
5227+};
5228+var $lynxjs_elm$ui$Lynx$Attributes$marginRight = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('marginRight');
5229+var $lynxjs_elm$ui$Lynx$Attributes$width = $lynxjs_elm$ui$Lynx$Attributes$pxStyle('width');
5230+var $author$project$Main$viewItem = function (item) {
5231+ return A2(
5232+ $lynxjs_elm$ui$Lynx$view,
5233+ _List_fromArray(
5234+ [
5235+ $lynxjs_elm$ui$Lynx$Attributes$flexDirection($lynxjs_elm$ui$Lynx$Attributes$Row),
5236+ $lynxjs_elm$ui$Lynx$Attributes$alignItems($lynxjs_elm$ui$Lynx$Attributes$Center),
5237+ $lynxjs_elm$ui$Lynx$Attributes$paddingTop(12),
5238+ $lynxjs_elm$ui$Lynx$Attributes$paddingBottom(12),
5239+ $lynxjs_elm$ui$Lynx$Attributes$borderWidth(1),
5240+ $lynxjs_elm$ui$Lynx$Attributes$borderColor('#eeeeee')
5241+ ]),
5242+ _List_fromArray(
5243+ [
5244+ A2(
5245+ $lynxjs_elm$ui$Lynx$view,
5246+ _List_fromArray(
5247+ [
5248+ $lynxjs_elm$ui$Lynx$Events$onTap(
5249+ $author$project$Main$Toggle(item.id)),
5250+ $lynxjs_elm$ui$Lynx$Attributes$width(28),
5251+ $lynxjs_elm$ui$Lynx$Attributes$height(28),
5252+ $lynxjs_elm$ui$Lynx$Attributes$borderRadius(14),
5253+ $lynxjs_elm$ui$Lynx$Attributes$borderWidth(2),
5254+ $lynxjs_elm$ui$Lynx$Attributes$borderColor(
5255+ item.done ? '#4a90d9' : '#cccccc'),
5256+ $lynxjs_elm$ui$Lynx$Attributes$backgroundColor(
5257+ item.done ? '#4a90d9' : '#ffffff'),
5258+ $lynxjs_elm$ui$Lynx$Attributes$alignItems($lynxjs_elm$ui$Lynx$Attributes$Center),
5259+ $lynxjs_elm$ui$Lynx$Attributes$justifyContent($lynxjs_elm$ui$Lynx$Attributes$Center),
5260+ $lynxjs_elm$ui$Lynx$Attributes$marginRight(12)
5261+ ]),
5262+ _List_fromArray(
5263+ [
5264+ item.done ? A2(
5265+ $lynxjs_elm$ui$Lynx$text,
5266+ _List_fromArray(
5267+ [
5268+ $lynxjs_elm$ui$Lynx$Attributes$color('#ffffff'),
5269+ $lynxjs_elm$ui$Lynx$Attributes$fontSize(14)
5270+ ]),
5271+ _List_fromArray(
5272+ [
5273+ $lynxjs_elm$ui$Lynx$textContent('✓')
5274+ ])) : A2($lynxjs_elm$ui$Lynx$text, _List_Nil, _List_Nil)
5275+ ])),
5276+ A2(
5277+ $lynxjs_elm$ui$Lynx$text,
5278+ _List_fromArray(
5279+ [
5280+ $lynxjs_elm$ui$Lynx$Attributes$fontSize(16),
5281+ $lynxjs_elm$ui$Lynx$Attributes$flex(1),
5282+ $lynxjs_elm$ui$Lynx$Attributes$color(
5283+ item.done ? '#aaaaaa' : '#333333')
5284+ ]),
5285+ _List_fromArray(
5286+ [
5287+ $lynxjs_elm$ui$Lynx$textContent(item.text)
5288+ ])),
5289+ A2(
5290+ $lynxjs_elm$ui$Lynx$view,
5291+ _List_fromArray(
5292+ [
5293+ $lynxjs_elm$ui$Lynx$Events$onTap(
5294+ $author$project$Main$Remove(item.id)),
5295+ $lynxjs_elm$ui$Lynx$Attributes$paddingLeft(8),
5296+ $lynxjs_elm$ui$Lynx$Attributes$paddingRight(8)
5297+ ]),
5298+ _List_fromArray(
5299+ [
5300+ A2(
5301+ $lynxjs_elm$ui$Lynx$text,
5302+ _List_fromArray(
5303+ [
5304+ $lynxjs_elm$ui$Lynx$Attributes$fontSize(18),
5305+ $lynxjs_elm$ui$Lynx$Attributes$color('#cc0000')
5306+ ]),
5307+ _List_fromArray(
5308+ [
5309+ $lynxjs_elm$ui$Lynx$textContent('✕')
5310+ ]))
5311+ ]))
5312+ ]));
5313+};
5314+var $author$project$Main$view = function (model) {
5315+ return A2(
5316+ $lynxjs_elm$ui$Lynx$view,
5317+ _List_fromArray(
5318+ [
5319+ $lynxjs_elm$ui$Lynx$Attributes$flexDirection($lynxjs_elm$ui$Lynx$Attributes$Column),
5320+ $lynxjs_elm$ui$Lynx$Attributes$padding(20),
5321+ $lynxjs_elm$ui$Lynx$Attributes$flex(1)
5322+ ]),
5323+ _List_fromArray(
5324+ [
5325+ A2(
5326+ $lynxjs_elm$ui$Lynx$text,
5327+ _List_fromArray(
5328+ [
5329+ $lynxjs_elm$ui$Lynx$Attributes$fontSize(28),
5330+ $lynxjs_elm$ui$Lynx$Attributes$fontWeight($lynxjs_elm$ui$Lynx$Attributes$Bold),
5331+ $lynxjs_elm$ui$Lynx$Attributes$marginBottom(16)
5332+ ]),
5333+ _List_fromArray(
5334+ [
5335+ $lynxjs_elm$ui$Lynx$textContent('Todo List')
5336+ ])),
5337+ A2(
5338+ $lynxjs_elm$ui$Lynx$view,
5339+ _List_fromArray(
5340+ [
5341+ $lynxjs_elm$ui$Lynx$Attributes$flexDirection($lynxjs_elm$ui$Lynx$Attributes$Row),
5342+ $lynxjs_elm$ui$Lynx$Attributes$marginBottom(16),
5343+ $lynxjs_elm$ui$Lynx$Attributes$alignItems($lynxjs_elm$ui$Lynx$Attributes$Center)
5344+ ]),
5345+ _List_fromArray(
5346+ [
5347+ A2(
5348+ $lynxjs_elm$ui$Lynx$input,
5349+ _List_fromArray(
5350+ [
5351+ $lynxjs_elm$ui$Lynx$Events$onInput($author$project$Main$UpdateDraft),
5352+ $lynxjs_elm$ui$Lynx$Attributes$value(model.draft),
5353+ $lynxjs_elm$ui$Lynx$Attributes$placeholder('What needs to be done?'),
5354+ $lynxjs_elm$ui$Lynx$Attributes$flex(1),
5355+ $lynxjs_elm$ui$Lynx$Attributes$height(44),
5356+ $lynxjs_elm$ui$Lynx$Attributes$fontSize(16),
5357+ $lynxjs_elm$ui$Lynx$Attributes$borderWidth(1),
5358+ $lynxjs_elm$ui$Lynx$Attributes$borderColor('#cccccc'),
5359+ $lynxjs_elm$ui$Lynx$Attributes$borderRadius(8),
5360+ $lynxjs_elm$ui$Lynx$Attributes$paddingLeft(12)
5361+ ]),
5362+ _List_Nil),
5363+ A2(
5364+ $lynxjs_elm$ui$Lynx$view,
5365+ _List_fromArray(
5366+ [
5367+ $lynxjs_elm$ui$Lynx$Events$onTap($author$project$Main$AddItem),
5368+ $lynxjs_elm$ui$Lynx$Attributes$backgroundColor('#4a90d9'),
5369+ $lynxjs_elm$ui$Lynx$Attributes$borderRadius(8),
5370+ $lynxjs_elm$ui$Lynx$Attributes$paddingTop(10),
5371+ $lynxjs_elm$ui$Lynx$Attributes$paddingBottom(10),
5372+ $lynxjs_elm$ui$Lynx$Attributes$paddingLeft(16),
5373+ $lynxjs_elm$ui$Lynx$Attributes$paddingRight(16),
5374+ $lynxjs_elm$ui$Lynx$Attributes$marginLeft(8)
5375+ ]),
5376+ _List_fromArray(
5377+ [
5378+ A2(
5379+ $lynxjs_elm$ui$Lynx$text,
5380+ _List_fromArray(
5381+ [
5382+ $lynxjs_elm$ui$Lynx$Attributes$color('#ffffff'),
5383+ $lynxjs_elm$ui$Lynx$Attributes$fontSize(18)
5384+ ]),
5385+ _List_fromArray(
5386+ [
5387+ $lynxjs_elm$ui$Lynx$textContent('Add')
5388+ ]))
5389+ ]))
5390+ ])),
5391+ A2(
5392+ $lynxjs_elm$ui$Lynx$text,
5393+ _List_fromArray(
5394+ [
5395+ $lynxjs_elm$ui$Lynx$Attributes$fontSize(14),
5396+ $lynxjs_elm$ui$Lynx$Attributes$color('#888888'),
5397+ $lynxjs_elm$ui$Lynx$Attributes$marginBottom(12)
5398+ ]),
5399+ _List_fromArray(
5400+ [
5401+ $lynxjs_elm$ui$Lynx$textContent(
5402+ $author$project$Main$summaryText(model.items))
5403+ ])),
5404+ A2(
5405+ $lynxjs_elm$ui$Lynx$scrollView,
5406+ _List_fromArray(
5407+ [
5408+ $lynxjs_elm$ui$Lynx$Attributes$flex(1),
5409+ $lynxjs_elm$ui$Lynx$Attributes$scrollDirection($lynxjs_elm$ui$Lynx$Attributes$Vertical)
5410+ ]),
5411+ A2($elm$core$List$map, $author$project$Main$viewItem, model.items))
5412+ ]));
5413+};
5414+var $author$project$Main$main = $lynxjs_elm$browser$Browser$sandbox(
5415+ {init: $author$project$Main$init, update: $author$project$Main$update, view: $author$project$Main$view});
5416+_Platform_export({'Main':{'init':$author$project$Main$main(
5417+ $elm$json$Json$Decode$succeed(_Utils_Tuple0))(0)}});}(globalThis));
examples/todo-list/src/Main.elm+10−10
@@ -5,7 +5,7 @@ module Main exposing (main)
55
66import Browser
77import Lynx
8−import Lynx.Attributes as Attr
8+import Lynx.Attributes as Attr exposing (Alignment(..), FlexDirection(..), FontWeight(..), ScrollDirection(..))
99import Lynx.Events exposing (onTap, onInput)
1010import VirtualDom exposing (Node)
1111
@@ -104,23 +104,23 @@ update msg model =
104104view : Model -> Node Msg
105105view model =
106106 Lynx.view
107− [ Attr.flexDirection "column"
107+ [ Attr.flexDirection Column
108108 , Attr.padding 20
109109 , Attr.flex 1
110110 ]
111111 [ -- Header
112112 Lynx.text
113113 [ Attr.fontSize 28
114− , Attr.fontWeight "bold"
114+ , Attr.fontWeight Bold
115115 , Attr.marginBottom 16
116116 ]
117117 [ Lynx.textContent "Todo List" ]
118118
119119 -- Input row
120120 , Lynx.view
121− [ Attr.flexDirection "row"
121+ [ Attr.flexDirection Row
122122 , Attr.marginBottom 16
123− , Attr.alignItems "center"
123+ , Attr.alignItems Center
124124 ]
125125 [ Lynx.input
126126 [ onInput UpdateDraft
@@ -161,7 +161,7 @@ view model =
161161 -- Items
162162 , Lynx.scrollView
163163 [ Attr.flex 1
164− , Attr.scrollDirection "vertical"
164+ , Attr.scrollDirection Vertical
165165 ]
166166 (List.map viewItem model.items)
167167 ]
@@ -179,8 +179,8 @@ summaryText items =
179179viewItem : TodoItem -> Node Msg
180180viewItem item =
181181 Lynx.view
182− [ Attr.flexDirection "row"
183− , Attr.alignItems "center"
182+ [ Attr.flexDirection Row
183+ , Attr.alignItems Center
184184 , Attr.paddingTop 12
185185 , Attr.paddingBottom 12
186186 , Attr.borderWidth 1
@@ -197,8 +197,8 @@ viewItem item =
197197 (if item.done then "#4a90d9" else "#cccccc")
198198 , Attr.backgroundColor
199199 (if item.done then "#4a90d9" else "#ffffff")
200− , Attr.alignItems "center"
201− , Attr.justifyContent "center"
200+ , Attr.alignItems Center
201+ , Attr.justifyContent Center
202202 , Attr.marginRight 12
203203 ]
204204 [ if item.done then
lynxjs-elm.mdnew file+1401
@@ -0,0 +1,1401 @@
1+# LynxJS-Elm Language Reference
2+
3+LynxJS-Elm compiles Elm to native iOS/Android UIs via LynxJS. It is a fork of
4+Elm 0.19.1 that replaces browser DOM rendering with LynxJS native PAPI calls.
5+Elm code is written identically to standard Elm, but the view layer uses native
6+elements (`view`, `text`, `image`, etc.) instead of HTML.
7+
8+---
9+
10+## Quick Start
11+
12+### Install
13+
14+```bash
15+cd compiler && stack build && stack install
16+```
17+
18+This places `lynxjs-elm` in `~/.local/bin`.
19+
20+### Create a Project
21+
22+```bash
23+mkdir my-app && cd my-app
24+lynxjs-elm init
25+```
26+
27+This generates:
28+- `elm.json` with default dependencies
29+- `src/Main.elm` with a counter starter app
30+
31+### Build & Run
32+
33+```bash
34+lynxjs-elm make src/Main.elm # -> main.lynx.bundle
35+lynxjs-elm make src/Main.elm --output=foo.lynx.bundle # custom name
36+lynxjs-elm make src/Main.elm --output=elm.js # raw JS only
37+lynxjs-elm dev src/Main.elm # dev server with watch
38+```
39+
40+### Dev Server
41+
42+```bash
43+lynxjs-elm dev src/Main.elm # default port 3000
44+lynxjs-elm dev src/Main.elm --port 8080
45+```
46+
47+The dev server watches `.elm` files, recompiles on changes, and serves a
48+`.lynx.bundle` over HTTP. It prints a URL and QR code for the LynxJS Explorer
49+app.
50+
51+---
52+
53+## CLI Commands
54+
55+| Command | Description |
56+|---------|-------------|
57+| `lynxjs-elm make <file>` | Compile to `.lynx.bundle` (default) or `.js` |
58+| `lynxjs-elm dev <file>` | Dev server with file watching and hot reload |
59+| `lynxjs-elm init` | Create a new project with starter code |
60+| `lynxjs-elm install <pkg>` | Add a package dependency |
61+| `lynxjs-elm uninstall <pkg>` | Remove a package dependency |
62+| `lynxjs-elm clean` | Remove `elm-stuff/` and bundler cache |
63+| `lynxjs-elm repl` | Interactive REPL |
64+| `lynxjs-elm bump` | Auto-bump package version per semver |
65+| `lynxjs-elm diff` | Show API changes between versions |
66+| `lynxjs-elm publish` | Publish a package |
67+
68+### Make Flags
69+
70+| Flag | Effect |
71+|------|--------|
72+| `--output=<path>` | Output path (`.lynx.bundle`, `.js`, `.html`, `/dev/null`) |
73+| `--optimize` | Production build with minification and DCE |
74+| `--debug` | Debug build with time-travelling debugger |
75+| `--verbose` | Show bundler output |
76+
77+---
78+
79+## Project Structure
80+
81+A typical project:
82+
83+```
84+my-app/
85+ elm.json
86+ src/
87+ Main.elm
88+```
89+
90+### elm.json
91+
92+```json
93+{
94+ "type": "application",
95+ "source-directories": ["src"],
96+ "elm-version": "0.19.1",
97+ "dependencies": {
98+ "direct": {
99+ "elm/core": "1.0.5",
100+ "elm/json": "1.1.3",
101+ "lynxjs-elm/browser": "1.0.0",
102+ "lynxjs-elm/ui": "1.0.0",
103+ "lynxjs-elm/virtual-dom": "1.0.0"
104+ },
105+ "indirect": {
106+ "elm/time": "1.0.0",
107+ "elm/url": "1.0.0"
108+ }
109+ },
110+ "test-dependencies": {
111+ "direct": {},
112+ "indirect": {}
113+ }
114+}
115+```
116+
117+For HTTP support, add `"lynxjs-elm/http": "1.0.0"` to direct dependencies.
118+
119+### Forked Packages
120+
121+These packages are built into the compiler and installed automatically:
122+
123+| Fork | Replaces | Purpose |
124+|------|----------|---------|
125+| `lynxjs-elm/virtual-dom` | `elm/virtual-dom` | LynxJS native rendering kernel |
126+| `lynxjs-elm/browser` | `elm/browser` | LynxJS page lifecycle |
127+| `lynxjs-elm/http` | `elm/http` | fetch-based HTTP (replaces XMLHttpRequest) |
128+| `lynxjs-elm/ui` | *(new)* | Native element constructors and attributes |
129+
130+If you try to install `elm/browser`, `elm/http`, or `elm/virtual-dom`, the
131+compiler will suggest the `lynxjs-elm/*` fork instead.
132+
133+Standard Elm packages (`elm/core`, `elm/json`, `elm/time`, `elm/url`, etc.)
134+work as-is. They are downloaded from package.elm-lang.org on first use.
135+
136+---
137+
138+## The Elm Architecture (TEA)
139+
140+Every LynxJS-Elm app uses The Elm Architecture: Model, Update, View.
141+
142+### Browser.sandbox
143+
144+For apps without commands or subscriptions:
145+
146+```elm
147+main : Program () Model Msg
148+main =
149+ Browser.sandbox
150+ { init = init
151+ , view = view
152+ , update = update
153+ }
154+```
155+
156+- `init : Model` -- initial model
157+- `update : Msg -> Model -> Model` -- pure state transitions
158+- `view : Model -> Node Msg` -- render model to UI
159+
160+### Browser.element
161+
162+For apps with commands (HTTP, random, etc.) and subscriptions (time, etc.):
163+
164+```elm
165+main : Program () Model Msg
166+main =
167+ Browser.element
168+ { init = init
169+ , view = view
170+ , update = update
171+ , subscriptions = subscriptions
172+ }
173+```
174+
175+- `init : () -> ( Model, Cmd Msg )` -- initial model + startup command
176+- `update : Msg -> Model -> ( Model, Cmd Msg )` -- state + side effects
177+- `view : Model -> Node Msg` -- render model to UI
178+- `subscriptions : Model -> Sub Msg` -- active subscriptions
179+
180+`Browser.document` and `Browser.application` also exist but URL management
181+and page title are no-ops in LynxJS. Use `Browser.element` for most apps.
182+
183+---
184+
185+## Elm Language Fundamentals
186+
187+LynxJS-Elm is standard Elm 0.19.1. This section covers the essentials.
188+
189+### Module Declaration
190+
191+```elm
192+module Main exposing (main)
193+```
194+
195+### Imports
196+
197+```elm
198+import Browser
199+import Lynx
200+import Lynx.Attributes as Attr exposing (Alignment(..), FlexDirection(..))
201+import Lynx.Events exposing (onTap, onInput)
202+import VirtualDom exposing (Node)
203+```
204+
205+Use `exposing (..)` on types to bring constructors into scope. Use `as` for
206+shorter qualified names.
207+
208+### Type Aliases
209+
210+```elm
211+type alias Model =
212+ { count : Int
213+ , name : String
214+ , items : List Item
215+ }
216+```
217+
218+### Custom Types (Union Types)
219+
220+```elm
221+type Msg
222+ = Increment
223+ | Decrement
224+ | UpdateName String
225+ | Toggle Int
226+
227+type Status
228+ = Loading
229+ | Success String
230+ | Failure String
231+```
232+
233+### Records
234+
235+```elm
236+-- Create
237+init = { count = 0, name = "" }
238+
239+-- Access
240+model.count
241+
242+-- Update (returns new record)
243+{ model | count = model.count + 1 }
244+{ model | name = "Alice", count = 0 }
245+```
246+
247+### Pattern Matching
248+
249+```elm
250+update msg model =
251+ case msg of
252+ Increment ->
253+ { model | count = model.count + 1 }
254+
255+ Decrement ->
256+ { model | count = model.count - 1 }
257+
258+ UpdateName name ->
259+ { model | name = name }
260+```
261+
262+### Functions
263+
264+```elm
265+-- Named function
266+add : Int -> Int -> Int
267+add a b = a + b
268+
269+-- Anonymous function (lambda)
270+List.map (\item -> item.id) items
271+
272+-- Partial application
273+List.map ((*) 2) [1, 2, 3] -- [2, 4, 6]
274+
275+-- Pipe operator
276+items
277+ |> List.filter .done
278+ |> List.length
279+```
280+
281+### Let Expressions
282+
283+```elm
284+formatTime tenths =
285+ let
286+ totalSeconds = tenths // 10
287+ minutes = totalSeconds // 60
288+ seconds = modBy 60 totalSeconds
289+ in
290+ padZero minutes ++ ":" ++ padZero seconds
291+```
292+
293+### If Expressions
294+
295+```elm
296+-- Always requires both branches, returns a value
297+if model.count > 0 then
298+ "Positive"
299+else
300+ "Non-positive"
301+```
302+
303+### Common Types
304+
305+| Type | Example Values |
306+|------|---------------|
307+| `Int` | `42`, `-1`, `0xFF` |
308+| `Float` | `3.14`, `0.0` |
309+| `String` | `"hello"` |
310+| `Bool` | `True`, `False` |
311+| `List a` | `[1, 2, 3]`, `[]` |
312+| `Maybe a` | `Just 42`, `Nothing` |
313+| `Result err ok` | `Ok "data"`, `Err "fail"` |
314+| `()` | `()` (unit) |
315+| `(a, b)` | `(1, "hello")` (tuple) |
316+
317+---
318+
319+## Standard Library (elm/core)
320+
321+All standard `elm/core` modules are available:
322+
323+### Commonly Used
324+
325+| Module | Key Functions |
326+|--------|--------------|
327+| `String` | `fromInt`, `fromFloat`, `toInt`, `toFloat`, `isEmpty`, `length`, `left`, `right`, `trim`, `split`, `join`, `contains`, `startsWith`, `endsWith`, `toLower`, `toUpper`, `append`, `concat`, `repeat`, `replace` |
328+| `List` | `map`, `filter`, `foldl`, `foldr`, `head`, `tail`, `length`, `reverse`, `append`, `concat`, `indexedMap`, `filterMap`, `isEmpty`, `member`, `sort`, `sortBy`, `take`, `drop`, `range`, `repeat`, `partition` |
329+| `Maybe` | `Just`, `Nothing`, `withDefault`, `map`, `andThen` |
330+| `Result` | `Ok`, `Err`, `withDefault`, `map`, `andThen`, `mapError` |
331+| `Dict` | `empty`, `singleton`, `insert`, `get`, `remove`, `update`, `member`, `keys`, `values`, `toList`, `fromList`, `map`, `filter`, `foldl` |
332+| `Set` | `empty`, `singleton`, `insert`, `remove`, `member`, `toList`, `fromList`, `union`, `intersect`, `diff` |
333+| `Tuple` | `first`, `second`, `mapFirst`, `mapSecond`, `pair` |
334+| `Debug` | `log`, `todo` (dev only, stripped in `--optimize`) |
335+| `Basics` | `+`, `-`, `*`, `/`, `//` (int div), `^`, `modBy`, `remainderBy`, `negate`, `abs`, `sqrt`, `clamp`, `compare`, `min`, `max`, `not`, `&&`, `\|\|`, `++` (append), `<\|`, `\|>`, `>>`, `<<`, `identity`, `always`, `never` |
336+| `Cmd` | `none`, `batch`, `map` |
337+| `Sub` | `none`, `batch`, `map` |
338+
339+### JSON (elm/json)
340+
341+Required for decoding event data and HTTP responses.
342+
343+```elm
344+import Json.Decode as Decode
345+import Json.Encode as Encode
346+
347+-- Decoding
348+Decode.string : Decoder String
349+Decode.int : Decoder Int
350+Decode.float : Decoder Float
351+Decode.bool : Decoder Bool
352+Decode.list : Decoder a -> Decoder (List a)
353+Decode.field : String -> Decoder a -> Decoder a
354+Decode.at : List String -> Decoder a -> Decoder a
355+Decode.map : (a -> b) -> Decoder a -> Decoder b
356+Decode.map2 : (a -> b -> c) -> Decoder a -> Decoder b -> Decoder c
357+-- map3 through map8 also available
358+Decode.andThen : (a -> Decoder b) -> Decoder a -> Decoder b
359+Decode.succeed : a -> Decoder a
360+Decode.fail : String -> Decoder a
361+Decode.nullable : Decoder a -> Decoder (Maybe a)
362+Decode.oneOf : List (Decoder a) -> Decoder a
363+Decode.decodeString : Decoder a -> String -> Result Error a
364+
365+-- Encoding
366+Encode.string : String -> Value
367+Encode.int : Int -> Value
368+Encode.float : Float -> Value
369+Encode.bool : Bool -> Value
370+Encode.null : Value
371+Encode.list : (a -> Value) -> List a -> Value
372+Encode.object : List ( String, Value ) -> Value
373+Encode.encode : Int -> Value -> String
374+```
375+
376+---
377+
378+## UI Elements (lynxjs-elm/ui)
379+
380+### Lynx Module
381+
382+All elements take `List (Attribute msg)` and `List (Node msg)`.
383+
384+```elm
385+import Lynx exposing (Node, Attribute)
386+```
387+
388+| Element | LynxJS Tag | Purpose |
389+|---------|-----------|---------|
390+| `Lynx.view` | `<view>` | Container/layout element (like `<div>`) |
391+| `Lynx.text` | `<text>` | Text container (for styling text) |
392+| `Lynx.textContent` | text node | Plain text string (auto-wrapped in `<text>`) |
393+| `Lynx.image` | `<image>` | Image element |
394+| `Lynx.scrollView` | `<scroll-view>` | Scrollable container |
395+| `Lynx.list` | `<list>` | Efficient long list rendering |
396+| `Lynx.input` | `<input>` | Single-line text input |
397+| `Lynx.textarea` | `<textarea>` | Multi-line text input |
398+
399+**Key distinction:** `Lynx.text` is a styled container; `Lynx.textContent` is
400+the actual string content. You almost always nest `textContent` inside `text`:
401+
402+```elm
403+Lynx.text [ Attr.fontSize 18, Attr.color "#333" ]
404+ [ Lynx.textContent "Hello World" ]
405+```
406+
407+### Lynx.Attributes Module
408+
409+Import convention: `import Lynx.Attributes as Attr exposing (...)`.
410+
411+All dimensions are in pixels (Int). Colors are CSS strings (hex, named, etc.).
412+
413+#### Layout
414+
415+```elm
416+-- Dimensions (pixels)
417+Attr.width : Int -> Attribute msg
418+Attr.height : Int -> Attribute msg
419+Attr.minWidth : Int -> Attribute msg
420+Attr.minHeight : Int -> Attribute msg
421+Attr.maxWidth : Int -> Attribute msg
422+Attr.maxHeight : Int -> Attribute msg
423+
424+-- Display
425+type Display = Flex | DisplayNone
426+Attr.display : Display -> Attribute msg
427+
428+-- Flex direction
429+type FlexDirection = Row | Column | RowReverse | ColumnReverse
430+Attr.flexDirection : FlexDirection -> Attribute msg
431+
432+-- Flex wrap
433+type FlexWrap = Wrap | NoWrap | WrapReverse
434+Attr.flexWrap : FlexWrap -> Attribute msg
435+
436+-- Alignment (used by justifyContent, alignItems, alignSelf)
437+type Alignment
438+ = Start -- flex-start
439+ | Center -- center
440+ | End -- flex-end
441+ | SpaceBetween -- space-between (justifyContent only)
442+ | SpaceAround -- space-around (justifyContent only)
443+ | SpaceEvenly -- space-evenly (justifyContent only)
444+ | Stretch -- stretch (alignItems/alignSelf only)
445+ | Baseline -- baseline (alignItems/alignSelf only)
446+
447+Attr.justifyContent : Alignment -> Attribute msg
448+Attr.alignItems : Alignment -> Attribute msg
449+Attr.alignSelf : Alignment -> Attribute msg
450+
451+-- Flex sizing
452+Attr.flex : Int -> Attribute msg
453+Attr.flexGrow : Int -> Attribute msg
454+Attr.flexShrink : Int -> Attribute msg
455+```
456+
457+#### Spacing
458+
459+```elm
460+-- Padding (pixels)
461+Attr.padding : Int -> Attribute msg -- all sides
462+Attr.paddingTop : Int -> Attribute msg
463+Attr.paddingRight : Int -> Attribute msg
464+Attr.paddingBottom : Int -> Attribute msg
465+Attr.paddingLeft : Int -> Attribute msg
466+
467+-- Margin (pixels)
468+Attr.margin : Int -> Attribute msg -- all sides
469+Attr.marginTop : Int -> Attribute msg
470+Attr.marginRight : Int -> Attribute msg
471+Attr.marginBottom : Int -> Attribute msg
472+Attr.marginLeft : Int -> Attribute msg
473+```
474+
475+#### Positioning
476+
477+```elm
478+type Position = Relative | Absolute
479+Attr.position : Position -> Attribute msg
480+Attr.top : Int -> Attribute msg
481+Attr.right : Int -> Attribute msg
482+Attr.bottom : Int -> Attribute msg
483+Attr.left : Int -> Attribute msg
484+Attr.zIndex : Int -> Attribute msg
485+```
486+
487+#### Appearance
488+
489+```elm
490+Attr.backgroundColor : String -> Attribute msg -- CSS color
491+Attr.opacity : Float -> Attribute msg -- 0.0 to 1.0
492+
493+type Overflow = Visible | Hidden | Scroll
494+Attr.overflow : Overflow -> Attribute msg
495+```
496+
497+#### Borders
498+
499+```elm
500+Attr.borderWidth : Int -> Attribute msg -- pixels
501+Attr.borderColor : String -> Attribute msg -- CSS color
502+Attr.borderRadius : Int -> Attribute msg -- pixels
503+```
504+
505+#### Typography
506+
507+```elm
508+Attr.fontSize : Int -> Attribute msg -- pixels
509+Attr.color : String -> Attribute msg -- CSS color (text color)
510+Attr.fontFamily : String -> Attribute msg
511+Attr.lineHeight : Int -> Attribute msg -- pixels
512+
513+type FontWeight = Normal | Bold
514+Attr.fontWeight : FontWeight -> Attribute msg
515+
516+type TextAlign = Left | Right | TextCenter | Justify
517+Attr.textAlign : TextAlign -> Attribute msg
518+
519+type TextOverflow = Clip | Ellipsis
520+Attr.textOverflow : TextOverflow -> Attribute msg
521+```
522+
523+**Note:** Text alignment is `TextCenter` (not `Center`) to avoid conflicting
524+with `Alignment.Center`.
525+
526+#### Content
527+
528+```elm
529+Attr.src : String -> Attribute msg -- image URL
530+Attr.placeholder : String -> Attribute msg -- input placeholder
531+Attr.value : String -> Attribute msg -- input value
532+```
533+
534+#### Scrolling
535+
536+```elm
537+type ScrollDirection = Vertical | Horizontal
538+Attr.scrollDirection : ScrollDirection -> Attribute msg
539+```
540+
541+#### Identity
542+
543+```elm
544+Attr.id : String -> Attribute msg
545+Attr.class_ : String -> Attribute msg -- note trailing underscore
546+```
547+
548+### Lynx.Events Module
549+
550+```elm
551+import Lynx.Events exposing (onTap, onInput)
552+```
553+
554+#### Tap Events
555+
556+```elm
557+onTap : msg -> Attribute msg -- fires on tap
558+onLongpress : msg -> Attribute msg -- fires on long press
559+```
560+
561+#### Touch Events
562+
563+```elm
564+onTouchStart : msg -> Attribute msg
565+onTouchMove : msg -> Attribute msg
566+onTouchEnd : msg -> Attribute msg
567+onTouchCancel : msg -> Attribute msg
568+```
569+
570+#### Input Events
571+
572+```elm
573+onInput : (String -> msg) -> Attribute msg
574+```
575+
576+`onInput` extracts the new value from `event.detail.value`. Use it with
577+`Attr.value` for controlled inputs:
578+
579+```elm
580+Lynx.input
581+ [ onInput UpdateText
582+ , Attr.value model.text
583+ , Attr.placeholder "Type here..."
584+ ]
585+ []
586+```
587+
588+---
589+
590+## HTTP (lynxjs-elm/http)
591+
592+Add `"lynxjs-elm/http": "1.0.0"` to direct dependencies.
593+
594+```elm
595+import Http
596+```
597+
598+### GET Request
599+
600+```elm
601+fetchData : Cmd Msg
602+fetchData =
603+ Http.get
604+ { url = "https://api.example.com/data"
605+ , expect = Http.expectString GotData
606+ }
607+
608+type Msg = GotData (Result Http.Error String)
609+```
610+
611+### POST Request
612+
613+```elm
614+createItem : String -> Cmd Msg
615+createItem name =
616+ Http.post
617+ { url = "https://api.example.com/items"
618+ , body = Http.jsonBody (Encode.object [ ( "name", Encode.string name ) ])
619+ , expect = Http.expectJson GotItem itemDecoder
620+ }
621+```
622+
623+### Custom Request
624+
625+```elm
626+Http.request
627+ { method = "PUT"
628+ , headers = [ Http.header "Authorization" "Bearer token" ]
629+ , url = "https://api.example.com/items/1"
630+ , body = Http.jsonBody payload
631+ , expect = Http.expectWhatever ItemUpdated
632+ , timeout = Just 10000
633+ , tracker = Nothing
634+ }
635+```
636+
637+### Expect Functions
638+
639+```elm
640+Http.expectString : (Result Http.Error String -> msg) -> Expect msg
641+Http.expectJson : (Result Http.Error a -> msg) -> Decoder a -> Expect msg
642+Http.expectBytes : (Result Http.Error Bytes -> msg) -> Decoder a -> Expect msg
643+Http.expectWhatever : (Result Http.Error () -> msg) -> Expect msg
644+```
645+
646+### Error Handling
647+
648+```elm
649+type Error
650+ = BadUrl String
651+ | Timeout
652+ | NetworkError
653+ | BadStatus Int
654+ | BadBody String
655+
656+errorToString : Http.Error -> String
657+errorToString err =
658+ case err of
659+ Http.BadUrl url -> "Bad URL: " ++ url
660+ Http.Timeout -> "Request timed out"
661+ Http.NetworkError -> "Network error"
662+ Http.BadStatus code -> "Bad status: " ++ String.fromInt code
663+ Http.BadBody msg -> "Bad body: " ++ msg
664+```
665+
666+### Body Types
667+
668+```elm
669+Http.emptyBody : Body
670+Http.stringBody : String -> String -> Body -- MIME type, content
671+Http.jsonBody : Value -> Body
672+Http.bytesBody : String -> Bytes -> Body -- MIME type, bytes
673+```
674+
675+**Note:** HTTP progress tracking (`Http.track`) is not supported -- the LynxJS
676+runtime uses the Fetch API which does not expose progress events.
677+
678+---
679+
680+## Time & Subscriptions (elm/time)
681+
682+```elm
683+import Time
684+```
685+
686+### Periodic Subscriptions
687+
688+```elm
689+subscriptions : Model -> Sub Msg
690+subscriptions model =
691+ if model.running then
692+ Time.every 1000 Tick -- fires every 1000ms
693+ else
694+ Sub.none
695+
696+type Msg = Tick Time.Posix
697+```
698+
699+`Time.every` takes milliseconds and produces a `Time.Posix` value on each tick.
700+
701+### Conditional Subscriptions
702+
703+Return `Sub.none` when you don't need updates:
704+
705+```elm
706+subscriptions model =
707+ Sub.batch
708+ [ if model.timerActive then Time.every 100 TimerTick else Sub.none
709+ , if model.polling then Time.every 5000 PollServer else Sub.none
710+ ]
711+```
712+
713+---
714+
715+## Differences from Standard Elm
716+
717+LynxJS-Elm renders to native mobile UI, not a browser. These features are
718+**stubbed or no-ops**:
719+
720+| Feature | Status |
721+|---------|--------|
722+| `Browser.Navigation` (`pushUrl`, `replaceUrl`, `back`, `forward`) | No-op |
723+| `Browser.Dom` (`focus`, `blur`, `getElement`, `getViewport`) | Returns `NotFound` |
724+| `Browser.Events` keyboard/mouse listeners (`onKeyDown`, `onClick`, etc.) | No-op |
725+| `Browser.Events.onResize`, `onVisibilityChange` | No-op |
726+| Page title (`Browser.document` title field) | Ignored |
727+| URL routing (`Browser.application` URL handling) | Stubbed (dummy localhost URL) |
728+| HTTP progress tracking (`Http.track`) | Stub (Fetch API limitation) |
729+| HTML elements (`Html.*`) | Not available -- use `Lynx.*` |
730+
731+**What works fully:**
732+- The Elm Architecture (sandbox, element)
733+- Commands and subscriptions (Cmd, Sub)
734+- HTTP requests (get, post, custom)
735+- Time subscriptions
736+- JSON encoding/decoding
737+- All elm/core modules (List, Dict, Set, String, etc.)
738+- VirtualDom (lazy, keyed nodes)
739+- Custom events via VirtualDom.on
740+
741+---
742+
743+## Common Patterns
744+
745+### Page Layout
746+
747+```elm
748+view model =
749+ Lynx.view
750+ [ Attr.flexDirection Column
751+ , Attr.flex 1
752+ , Attr.padding 20
753+ ]
754+ [ header
755+ , content model
756+ , footer
757+ ]
758+```
759+
760+### Button
761+
762+There is no built-in button element. Create one with `view` + `onTap`:
763+
764+```elm
765+button : msg -> String -> Node msg
766+button msg label =
767+ Lynx.view
768+ [ onTap msg
769+ , Attr.backgroundColor "#4a90d9"
770+ , Attr.borderRadius 8
771+ , Attr.paddingTop 12
772+ , Attr.paddingBottom 12
773+ , Attr.paddingLeft 24
774+ , Attr.paddingRight 24
775+ ]
776+ [ Lynx.text
777+ [ Attr.color "#ffffff"
778+ , Attr.fontSize 18
779+ ]
780+ [ Lynx.textContent label ]
781+ ]
782+```
783+
784+### Controlled Input
785+
786+```elm
787+Lynx.input
788+ [ onInput UpdateDraft
789+ , Attr.value model.draft
790+ , Attr.placeholder "Type here..."
791+ , Attr.height 44
792+ , Attr.fontSize 16
793+ , Attr.borderWidth 1
794+ , Attr.borderColor "#cccccc"
795+ , Attr.borderRadius 8
796+ , Attr.paddingLeft 12
797+ ]
798+ []
799+```
800+
801+### Scrollable List
802+
803+```elm
804+Lynx.scrollView
805+ [ Attr.flex 1
806+ , Attr.scrollDirection Vertical
807+ ]
808+ (List.map viewItem model.items)
809+```
810+
811+With indexed rendering:
812+
813+```elm
814+Lynx.scrollView [ Attr.flex 1, Attr.scrollDirection Vertical ]
815+ (List.indexedMap viewItem model.items)
816+```
817+
818+### Conditional Rendering
819+
820+```elm
821+-- Show/hide based on condition
822+if model.showDetails then
823+ Lynx.view [...] [...]
824+else
825+ Lynx.view [] []
826+
827+-- Pattern match on status
828+case model.status of
829+ Loading ->
830+ Lynx.text [ Attr.color "#888" ] [ Lynx.textContent "Loading..." ]
831+
832+ Success data ->
833+ Lynx.text [] [ Lynx.textContent data ]
834+
835+ Failure err ->
836+ Lynx.text [ Attr.color "#cc0000" ] [ Lynx.textContent err ]
837+```
838+
839+### Conditional Styling
840+
841+```elm
842+Lynx.view
843+ [ Attr.backgroundColor
844+ (if isSelected then "#4a90d9" else "#ffffff")
845+ , Attr.borderWidth
846+ (if isSelected then 2 else 0)
847+ ]
848+ [ ... ]
849+```
850+
851+### List Manipulation in Update
852+
853+```elm
854+-- Toggle item
855+{ model | items =
856+ List.map
857+ (\item ->
858+ if item.id == targetId then
859+ { item | done = not item.done }
860+ else
861+ item
862+ )
863+ model.items
864+}
865+
866+-- Remove item
867+{ model | items = List.filter (\item -> item.id /= targetId) model.items }
868+
869+-- Add item
870+{ model | items = model.items ++ [ newItem ] }
871+```
872+
873+### Empty Node
874+
875+When you need a placeholder node (e.g., in an else branch):
876+
877+```elm
878+Lynx.view [] []
879+```
880+
881+---
882+
883+## Complete Examples
884+
885+### Counter (Browser.sandbox)
886+
887+```elm
888+module Main exposing (main)
889+
890+import Browser
891+import Lynx
892+import Lynx.Attributes as Attr exposing (Alignment(..), FlexDirection(..))
893+import Lynx.Events exposing (onTap)
894+import VirtualDom exposing (Node)
895+
896+
897+main : Program () Model Msg
898+main =
899+ Browser.sandbox
900+ { init = init
901+ , view = view
902+ , update = update
903+ }
904+
905+
906+type alias Model =
907+ { count : Int
908+ }
909+
910+
911+init : Model
912+init =
913+ { count = 0
914+ }
915+
916+
917+type Msg
918+ = Increment
919+ | Decrement
920+
921+
922+update : Msg -> Model -> Model
923+update msg model =
924+ case msg of
925+ Increment ->
926+ { model | count = model.count + 1 }
927+
928+ Decrement ->
929+ { model | count = model.count - 1 }
930+
931+
932+view : Model -> Node Msg
933+view model =
934+ Lynx.view
935+ [ Attr.flexDirection Column
936+ , Attr.alignItems Center
937+ , Attr.justifyContent Center
938+ , Attr.flex 1
939+ ]
940+ [ Lynx.view
941+ [ Attr.flexDirection Row
942+ , Attr.alignItems Center
943+ ]
944+ [ button Decrement "-"
945+ , Lynx.text
946+ [ Attr.fontSize 32
947+ , Attr.marginLeft 20
948+ , Attr.marginRight 20
949+ ]
950+ [ Lynx.textContent (String.fromInt model.count) ]
951+ , button Increment "+"
952+ ]
953+ ]
954+
955+
956+button : Msg -> String -> Node Msg
957+button msg label =
958+ Lynx.view
959+ [ onTap msg
960+ , Attr.backgroundColor "#4a90d9"
961+ , Attr.borderRadius 8
962+ , Attr.paddingTop 12
963+ , Attr.paddingBottom 12
964+ , Attr.paddingLeft 24
965+ , Attr.paddingRight 24
966+ ]
967+ [ Lynx.text
968+ [ Attr.color "#ffffff"
969+ , Attr.fontSize 24
970+ ]
971+ [ Lynx.textContent label ]
972+ ]
973+```
974+
975+### HTTP Example (Browser.element)
976+
977+```elm
978+module Main exposing (main)
979+
980+import Browser
981+import Http
982+import Lynx exposing (view, text, textContent)
983+import Lynx.Attributes exposing (Alignment(..), FlexDirection(..), fontSize, padding, color, flexDirection, alignItems)
984+import Lynx.Events exposing (onTap)
985+
986+
987+main : Program () Model Msg
988+main =
989+ Browser.element
990+ { init = init
991+ , update = update
992+ , subscriptions = \_ -> Sub.none
993+ , view = view_
994+ }
995+
996+
997+type alias Model =
998+ { status : Status
999+ }
1000+
1001+
1002+type Status
1003+ = Loading
1004+ | Success String
1005+ | Failure String
1006+
1007+
1008+type Msg
1009+ = GotQuote (Result Http.Error String)
1010+ | FetchQuote
1011+
1012+
1013+init : () -> ( Model, Cmd Msg )
1014+init _ =
1015+ ( { status = Loading }
1016+ , fetchQuote
1017+ )
1018+
1019+
1020+fetchQuote : Cmd Msg
1021+fetchQuote =
1022+ Http.get
1023+ { url = "https://api.quotable.io/quotes/random"
1024+ , expect = Http.expectString GotQuote
1025+ }
1026+
1027+
1028+update : Msg -> Model -> ( Model, Cmd Msg )
1029+update msg model =
1030+ case msg of
1031+ GotQuote result ->
1032+ case result of
1033+ Ok body ->
1034+ ( { model | status = Success body }, Cmd.none )
1035+
1036+ Err err ->
1037+ ( { model | status = Failure (errorToString err) }, Cmd.none )
1038+
1039+ FetchQuote ->
1040+ ( { model | status = Loading }, fetchQuote )
1041+
1042+
1043+errorToString : Http.Error -> String
1044+errorToString err =
1045+ case err of
1046+ Http.BadUrl url ->
1047+ "Bad URL: " ++ url
1048+
1049+ Http.Timeout ->
1050+ "Request timed out"
1051+
1052+ Http.NetworkError ->
1053+ "Network error"
1054+
1055+ Http.BadStatus code ->
1056+ "Bad status: " ++ String.fromInt code
1057+
1058+ Http.BadBody msg_ ->
1059+ "Bad body: " ++ msg_
1060+
1061+
1062+view_ : Model -> Lynx.Node Msg
1063+view_ model =
1064+ view [ padding 20, flexDirection Column, alignItems Center ]
1065+ [ text [ fontSize 24, padding 10 ]
1066+ [ textContent "HTTP Example" ]
1067+ , view [ padding 10 ]
1068+ [ text [ fontSize 16, color (statusColor model.status) ]
1069+ [ textContent (statusText model.status) ]
1070+ ]
1071+ , view [ onTap FetchQuote, padding 10 ]
1072+ [ text [ fontSize 18, color "#007AFF" ]
1073+ [ textContent "Fetch New Quote" ]
1074+ ]
1075+ ]
1076+
1077+
1078+statusColor : Status -> String
1079+statusColor status =
1080+ case status of
1081+ Loading -> "#888888"
1082+ Success _ -> "#333333"
1083+ Failure _ -> "#CC0000"
1084+
1085+
1086+statusText : Status -> String
1087+statusText status =
1088+ case status of
1089+ Loading -> "Loading..."
1090+ Success body -> String.left 200 body
1091+ Failure err -> err
1092+```
1093+
1094+### Timer (Subscriptions)
1095+
1096+```elm
1097+module Main exposing (main)
1098+
1099+import Browser
1100+import Lynx
1101+import Lynx.Attributes as Attr exposing (Alignment(..), FlexDirection(..), FontWeight(..))
1102+import Lynx.Events exposing (onTap)
1103+import Time
1104+import VirtualDom exposing (Node)
1105+
1106+
1107+main : Program () Model Msg
1108+main =
1109+ Browser.element
1110+ { init = init
1111+ , view = view
1112+ , update = update
1113+ , subscriptions = subscriptions
1114+ }
1115+
1116+
1117+type alias Model =
1118+ { elapsed : Int -- tenths of a second
1119+ , running : Bool
1120+ , laps : List Int
1121+ }
1122+
1123+
1124+init : () -> ( Model, Cmd Msg )
1125+init _ =
1126+ ( { elapsed = 0, running = False, laps = [] }
1127+ , Cmd.none
1128+ )
1129+
1130+
1131+type Msg
1132+ = Tick Time.Posix
1133+ | ToggleRunning
1134+ | RecordLap
1135+ | Reset
1136+
1137+
1138+update : Msg -> Model -> ( Model, Cmd Msg )
1139+update msg model =
1140+ case msg of
1141+ Tick _ ->
1142+ ( { model | elapsed = model.elapsed + 1 }, Cmd.none )
1143+
1144+ ToggleRunning ->
1145+ ( { model | running = not model.running }, Cmd.none )
1146+
1147+ RecordLap ->
1148+ ( { model | laps = model.elapsed :: model.laps }, Cmd.none )
1149+
1150+ Reset ->
1151+ ( { model | elapsed = 0, running = False, laps = [] }, Cmd.none )
1152+
1153+
1154+subscriptions : Model -> Sub Msg
1155+subscriptions model =
1156+ if model.running then
1157+ Time.every 100 Tick
1158+ else
1159+ Sub.none
1160+
1161+
1162+view : Model -> Node Msg
1163+view model =
1164+ Lynx.view
1165+ [ Attr.flexDirection Column
1166+ , Attr.alignItems Center
1167+ , Attr.flex 1
1168+ , Attr.backgroundColor "#1a1a2e"
1169+ , Attr.paddingTop 40
1170+ ]
1171+ [ Lynx.text
1172+ [ Attr.fontSize 64
1173+ , Attr.fontWeight Bold
1174+ , Attr.color "#e94560"
1175+ ]
1176+ [ Lynx.textContent (formatTime model.elapsed) ]
1177+ , Lynx.view [ Attr.flexDirection Row, Attr.marginTop 30 ]
1178+ [ timerButton
1179+ (if model.running then "#e94560" else "#16c79a")
1180+ ToggleRunning
1181+ (if model.running then "Stop" else "Start")
1182+ , if model.running then
1183+ timerButton "#0f3460" RecordLap "Lap"
1184+ else
1185+ Lynx.view [] []
1186+ , if not model.running && model.elapsed > 0 then
1187+ timerButton "#533483" Reset "Reset"
1188+ else
1189+ Lynx.view [] []
1190+ ]
1191+ ]
1192+
1193+
1194+timerButton : String -> Msg -> String -> Node Msg
1195+timerButton bgColor msg label =
1196+ Lynx.view
1197+ [ onTap msg
1198+ , Attr.backgroundColor bgColor
1199+ , Attr.borderRadius 30
1200+ , Attr.paddingTop 14
1201+ , Attr.paddingBottom 14
1202+ , Attr.paddingLeft 28
1203+ , Attr.paddingRight 28
1204+ , Attr.marginLeft 8
1205+ , Attr.marginRight 8
1206+ ]
1207+ [ Lynx.text
1208+ [ Attr.color "#ffffff"
1209+ , Attr.fontSize 18
1210+ , Attr.fontWeight Bold
1211+ ]
1212+ [ Lynx.textContent label ]
1213+ ]
1214+
1215+
1216+formatTime : Int -> String
1217+formatTime tenths =
1218+ let
1219+ totalSeconds = tenths // 10
1220+ minutes = totalSeconds // 60
1221+ seconds = modBy 60 totalSeconds
1222+ deciseconds = modBy 10 tenths
1223+ in
1224+ padZero minutes ++ ":" ++ padZero seconds ++ "." ++ String.fromInt deciseconds
1225+
1226+
1227+padZero : Int -> String
1228+padZero n =
1229+ if n < 10 then
1230+ "0" ++ String.fromInt n
1231+ else
1232+ String.fromInt n
1233+```
1234+
1235+### Todo List (Input + List Manipulation)
1236+
1237+```elm
1238+module Main exposing (main)
1239+
1240+import Browser
1241+import Lynx
1242+import Lynx.Attributes as Attr exposing (Alignment(..), FlexDirection(..), FontWeight(..), ScrollDirection(..))
1243+import Lynx.Events exposing (onTap, onInput)
1244+import VirtualDom exposing (Node)
1245+
1246+
1247+main : Program () Model Msg
1248+main =
1249+ Browser.sandbox
1250+ { init = init
1251+ , view = view
1252+ , update = update
1253+ }
1254+
1255+
1256+type alias Model =
1257+ { items : List TodoItem
1258+ , nextId : Int
1259+ , draft : String
1260+ }
1261+
1262+
1263+type alias TodoItem =
1264+ { id : Int
1265+ , text : String
1266+ , done : Bool
1267+ }
1268+
1269+
1270+init : Model
1271+init =
1272+ { items =
1273+ [ { id = 1, text = "Learn Elm", done = True }
1274+ , { id = 2, text = "Build a LynxJS app", done = False }
1275+ ]
1276+ , nextId = 3
1277+ , draft = ""
1278+ }
1279+
1280+
1281+type Msg
1282+ = Toggle Int
1283+ | Remove Int
1284+ | UpdateDraft String
1285+ | AddItem
1286+
1287+
1288+update : Msg -> Model -> Model
1289+update msg model =
1290+ case msg of
1291+ Toggle targetId ->
1292+ { model
1293+ | items =
1294+ List.map
1295+ (\item ->
1296+ if item.id == targetId then
1297+ { item | done = not item.done }
1298+ else
1299+ item
1300+ )
1301+ model.items
1302+ }
1303+
1304+ Remove targetId ->
1305+ { model | items = List.filter (\item -> item.id /= targetId) model.items }
1306+
1307+ UpdateDraft text ->
1308+ { model | draft = text }
1309+
1310+ AddItem ->
1311+ if String.isEmpty (String.trim model.draft) then
1312+ model
1313+ else
1314+ { model
1315+ | items = model.items ++ [ { id = model.nextId, text = model.draft, done = False } ]
1316+ , nextId = model.nextId + 1
1317+ , draft = ""
1318+ }
1319+
1320+
1321+view : Model -> Node Msg
1322+view model =
1323+ Lynx.view
1324+ [ Attr.flexDirection Column, Attr.padding 20, Attr.flex 1 ]
1325+ [ Lynx.text [ Attr.fontSize 28, Attr.fontWeight Bold, Attr.marginBottom 16 ]
1326+ [ Lynx.textContent "Todo List" ]
1327+ , Lynx.view [ Attr.flexDirection Row, Attr.marginBottom 16, Attr.alignItems Center ]
1328+ [ Lynx.input
1329+ [ onInput UpdateDraft
1330+ , Attr.value model.draft
1331+ , Attr.placeholder "What needs to be done?"
1332+ , Attr.flex 1
1333+ , Attr.height 44
1334+ , Attr.fontSize 16
1335+ , Attr.borderWidth 1
1336+ , Attr.borderColor "#cccccc"
1337+ , Attr.borderRadius 8
1338+ , Attr.paddingLeft 12
1339+ ]
1340+ []
1341+ , Lynx.view
1342+ [ onTap AddItem
1343+ , Attr.backgroundColor "#4a90d9"
1344+ , Attr.borderRadius 8
1345+ , Attr.paddingTop 10
1346+ , Attr.paddingBottom 10
1347+ , Attr.paddingLeft 16
1348+ , Attr.paddingRight 16
1349+ , Attr.marginLeft 8
1350+ ]
1351+ [ Lynx.text [ Attr.color "#ffffff", Attr.fontSize 18 ]
1352+ [ Lynx.textContent "Add" ]
1353+ ]
1354+ ]
1355+ , Lynx.scrollView [ Attr.flex 1, Attr.scrollDirection Vertical ]
1356+ (List.map viewItem model.items)
1357+ ]
1358+
1359+
1360+viewItem : TodoItem -> Node Msg
1361+viewItem item =
1362+ Lynx.view
1363+ [ Attr.flexDirection Row
1364+ , Attr.alignItems Center
1365+ , Attr.paddingTop 12
1366+ , Attr.paddingBottom 12
1367+ ]
1368+ [ Lynx.view
1369+ [ onTap (Toggle item.id)
1370+ , Attr.width 28
1371+ , Attr.height 28
1372+ , Attr.borderRadius 14
1373+ , Attr.borderWidth 2
1374+ , Attr.borderColor (if item.done then "#4a90d9" else "#cccccc")
1375+ , Attr.backgroundColor (if item.done then "#4a90d9" else "#ffffff")
1376+ , Attr.alignItems Center
1377+ , Attr.justifyContent Center
1378+ , Attr.marginRight 12
1379+ ]
1380+ [ if item.done then
1381+ Lynx.text [ Attr.color "#ffffff", Attr.fontSize 14 ]
1382+ [ Lynx.textContent "✓" ]
1383+ else
1384+ Lynx.text [] []
1385+ ]
1386+ , Lynx.text
1387+ [ Attr.fontSize 16
1388+ , Attr.flex 1
1389+ , Attr.color (if item.done then "#aaaaaa" else "#333333")
1390+ ]
1391+ [ Lynx.textContent item.text ]
1392+ , Lynx.view
1393+ [ onTap (Remove item.id)
1394+ , Attr.paddingLeft 8
1395+ , Attr.paddingRight 8
1396+ ]
1397+ [ Lynx.text [ Attr.fontSize 18, Attr.color "#cc0000" ]
1398+ [ Lynx.textContent "✕" ]
1399+ ]
1400+ ]
1401+```
packages/bytes/elm.jsonnew file+17
@@ -0,0 +1,17 @@
1+{
2+ "type": "package",
3+ "name": "lynxjs-elm/bytes",
4+ "summary": "Work with sequences of bytes (with fixed equality)",
5+ "license": "BSD-3-Clause",
6+ "version": "1.0.0",
7+ "exposed-modules": [
8+ "Bytes",
9+ "Bytes.Encode",
10+ "Bytes.Decode"
11+ ],
12+ "elm-version": "0.19.0 <= v < 0.20.0",
13+ "dependencies": {
14+ "elm/core": "1.0.1 <= v < 2.0.0"
15+ },
16+ "test-dependencies": {}
17+}
packages/bytes/src/Bytes.elmnew file+187
@@ -0,0 +1,187 @@
1+module Bytes exposing
2+ ( Bytes
3+ , width
4+ , toBase64
5+ , fromBase64
6+ , Endianness(..)
7+ , getHostEndianness
8+ )
9+
10+
11+{-|
12+
13+# Bytes
14+@docs Bytes, width
15+
16+# Base64
17+@docs toBase64, fromBase64
18+
19+# Endianness
20+@docs Endianness, getHostEndianness
21+
22+-}
23+
24+
25+import Elm.Kernel.Bytes
26+import Task exposing (Task)
27+
28+
29+-- BYTES
30+
31+
32+{-| A sequence of bytes.
33+
34+A byte is a chunk of eight bits. For example, the letter `j` is usually
35+represented as the byte `01101010`, and the letter `k` is `01101011`.
36+
37+Seeing each byte as a stream of zeros and ones can be quite confusing though,
38+so it is common to use hexidecimal numbers instead:
39+
40+```
41+| Binary | Hex |
42++--------+-----+
43+| 0000 | 0 |
44+| 0001 | 1 |
45+| 0010 | 2 |
46+| 0011 | 3 | j = 01101010
47+| 0100 | 4 | \__/\__/
48+| 0101 | 5 | | |
49+| 0110 | 6 | 6 A
50+| 0111 | 7 |
51+| 1000 | 8 | k = 01101011
52+| 1001 | 9 | \__/\__/
53+| 1010 | A | | |
54+| 1011 | B | 6 B
55+| 1100 | C |
56+| 1101 | D |
57+| 1110 | E |
58+| 1111 | F |
59+```
60+
61+So `j` is `6A` and `k` is `6B` in hexidecimal. This more compact representation
62+is great when you have a sequence of bytes. You can see this even in a short
63+string like `"jazz"`:
64+
65+```
66+binary hexidecimal
67+01101010 01100001 01111010 01111010 => 6A 61 7A 7A
68+```
69+
70+Anyway, the point is that `Bytes` is a sequence of bytes!
71+-}
72+type Bytes = Bytes
73+
74+
75+{-| Get the width of a sequence of bytes.
76+
77+So if a sequence has four-hundred bytes, then `width bytes` would give back
78+`400`. That may be 400 unsigned 8-bit integers, 100 signed 32-bit integers, or
79+even a UTF-8 string. The content does not matter. This is just figuring out
80+how many bytes there are!
81+-}
82+width : Bytes -> Int
83+width =
84+ Elm.Kernel.Bytes.width
85+
86+
87+
88+-- BASE64
89+
90+
91+{-| Encode bytes as a Base64 string. This is useful for embedding binary data
92+in JSON.
93+
94+ import Bytes
95+ import Bytes.Encode
96+ import Json.Encode
97+
98+ encodeBytesAsJson : Bytes.Bytes -> Json.Encode.Value
99+ encodeBytesAsJson bytes =
100+ Json.Encode.string (Bytes.toBase64 bytes)
101+-}
102+toBase64 : Bytes -> String
103+toBase64 =
104+ Elm.Kernel.Bytes.toBase64
105+
106+
107+{-| Decode a Base64 string into bytes. Returns `Nothing` if the string is not
108+valid Base64.
109+
110+ import Bytes
111+ import Json.Decode
112+
113+ bytesDecoder : Json.Decode.Decoder Bytes.Bytes
114+ bytesDecoder =
115+ Json.Decode.string
116+ |> Json.Decode.andThen
117+ (\str ->
118+ case Bytes.fromBase64 str of
119+ Just bytes ->
120+ Json.Decode.succeed bytes
121+
122+ Nothing ->
123+ Json.Decode.fail "Invalid Base64 string"
124+ )
125+-}
126+fromBase64 : String -> Maybe Bytes
127+fromBase64 =
128+ Elm.Kernel.Bytes.fromBase64
129+
130+
131+
132+-- ENDIANNESS
133+
134+
135+{-| Different computers store integers and floats slightly differently in
136+memory. Say we have the integer `0x1A2B3C4D` in our program. It needs four
137+bytes (32 bits) in memory. It may seem reasonable to lay them out in order:
138+
139+```
140+ Big-Endian (BE) (Obvious Order)
141++----+----+----+----+
142+| 1A | 2B | 3C | 4D |
143++----+----+----+----+
144+```
145+
146+But some people thought it would be better to store the bytes in the opposite
147+order:
148+
149+```
150+ Little-Endian (LE) (Shuffled Order)
151++----+----+----+----+
152+| 4D | 3C | 2B | 1A |
153++----+----+----+----+
154+```
155+
156+Notice that **the _bytes_ are shuffled, not the bits.** It is like if you cut a
157+photo into four strips and shuffled the strips. It is not a mirror image.
158+The theory seems to be that an 8-bit `0x1A` and a 32-bit `0x0000001A` both have
159+`1A` as the first byte in this scheme. Maybe this was helpful when processors
160+handled one byte at a time.
161+
162+**Most processors use little-endian (LE) layout.** This seems to be because
163+Intel did it this way, and other chip manufactures followed their convention.
164+**Most network protocols use big-endian (BE) layout.** I suspect this is
165+because if you are trying to debug a network protocol, it is nice if your
166+integers are not all shuffled.
167+
168+**Note:** Endianness is relevant for integers and floats, but not strings.
169+UTF-8 specifies the order of bytes explicitly.
170+
171+**Note:** The terms little-endian and big-endian are a reference to an egg joke
172+in Gulliver's Travels. They first appeared in 1980 in [this essay][essay], and
173+you can decide for yourself if they stood the test of time. I personally find
174+these terms quite unhelpful, so I say "Obvious Order" and "Shuffled Order" in
175+my head. I remember which is more common by asking myself, "if things were
176+obvious, would I have to ask this question?"
177+
178+[essay]: http://www.ietf.org/rfc/ien/ien137.txt
179+-}
180+type Endianness = LE | BE
181+
182+
183+{-| Is this program running on a big-endian or little-endian machine?
184+-}
185+getHostEndianness : Task x Endianness
186+getHostEndianness =
187+ Elm.Kernel.Bytes.getHostEndianness LE BE
packages/bytes/src/Bytes/Decode.elmnew file+428
@@ -0,0 +1,428 @@
1+module Bytes.Decode exposing
2+ ( Decoder, decode
3+ , signedInt8, signedInt16, signedInt32
4+ , unsignedInt8, unsignedInt16, unsignedInt32
5+ , float32, float64
6+ , string
7+ , bytes
8+ , map, map2, map3, map4, map5
9+ , andThen, succeed, fail
10+ , Step(..), loop
11+ )
12+
13+
14+{-|
15+
16+# Decoders
17+@docs Decoder, decode
18+
19+# Integers
20+@docs signedInt8, signedInt16, signedInt32,
21+ unsignedInt8, unsignedInt16, unsignedInt32
22+
23+# Floats
24+@docs float32, float64
25+
26+# Bytes
27+@docs bytes
28+
29+# Strings
30+@docs string
31+
32+# Map
33+@docs map, map2, map3, map4, map5
34+
35+# And Then
36+@docs andThen, succeed, fail
37+
38+# Loop
39+@docs Step, loop
40+-}
41+
42+
43+import Bytes exposing (Bytes, Endianness(..))
44+
45+
46+
47+-- PARSER
48+
49+
50+{-| Describes how to turn a sequence of bytes into a nice Elm value.
51+-}
52+type Decoder a =
53+ Decoder (Bytes -> Int -> (Int, a))
54+
55+
56+{-| Turn a sequence of bytes into a nice Elm value.
57+
58+ -- decode (unsignedInt16 BE) <0007> == Just 7
59+ -- decode (unsignedInt16 LE) <0700> == Just 7
60+ -- decode (unsignedInt16 BE) <0700> == Just 1792
61+ -- decode (unsignedInt32 BE) <0700> == Nothing
62+
63+The `Decoder` specifies exactly how this should happen. This process may fail
64+if the sequence of bytes is corrupted or unexpected somehow. The examples above
65+show a case where there are not enough bytes.
66+-}
67+decode : Decoder a -> Bytes -> Maybe a
68+decode (Decoder decoder) bs =
69+ Elm.Kernel.Bytes.decode decoder bs
70+
71+
72+
73+-- SIGNED INTEGERS
74+
75+
76+{-| Decode one byte into an integer from `-128` to `127`.
77+-}
78+signedInt8 : Decoder Int
79+signedInt8 =
80+ Decoder Elm.Kernel.Bytes.read_i8
81+
82+
83+{-| Decode two bytes into an integer from `-32768` to `32767`.
84+-}
85+signedInt16 : Endianness -> Decoder Int
86+signedInt16 endianness =
87+ Decoder (Elm.Kernel.Bytes.read_i16 (endianness == LE))
88+
89+
90+{-| Decode four bytes into an integer from `-2147483648` to `2147483647`.
91+-}
92+signedInt32 : Endianness -> Decoder Int
93+signedInt32 endianness =
94+ Decoder (Elm.Kernel.Bytes.read_i32 (endianness == LE))
95+
96+
97+
98+-- UNSIGNED INTEGERS
99+
100+
101+{-| Decode one byte into an integer from `0` to `255`.
102+-}
103+unsignedInt8 : Decoder Int
104+unsignedInt8 =
105+ Decoder Elm.Kernel.Bytes.read_u8
106+
107+
108+{-| Decode two bytes into an integer from `0` to `65535`.
109+-}
110+unsignedInt16 : Endianness -> Decoder Int
111+unsignedInt16 endianness =
112+ Decoder (Elm.Kernel.Bytes.read_u16 (endianness == LE))
113+
114+
115+{-| Decode four bytes into an integer from `0` to `4294967295`.
116+-}
117+unsignedInt32 : Endianness -> Decoder Int
118+unsignedInt32 endianness =
119+ Decoder (Elm.Kernel.Bytes.read_u32 (endianness == LE))
120+
121+
122+
123+-- FLOATS
124+
125+
126+{-| Decode four bytes into a floating point number.
127+-}
128+float32 : Endianness -> Decoder Float
129+float32 endianness =
130+ Decoder (Elm.Kernel.Bytes.read_f32 (endianness == LE))
131+
132+
133+{-| Decode eight bytes into a floating point number.
134+-}
135+float64 : Endianness -> Decoder Float
136+float64 endianness =
137+ Decoder (Elm.Kernel.Bytes.read_f64 (endianness == LE))
138+
139+
140+
141+-- BYTES
142+
143+
144+{-| Copy a given number of bytes into a new `Bytes` sequence.
145+-}
146+bytes : Int -> Decoder Bytes
147+bytes n =
148+ Decoder (Elm.Kernel.Bytes.read_bytes n)
149+
150+
151+
152+-- STRINGS
153+
154+
155+{-| Decode a given number of UTF-8 bytes into a `String`.
156+
157+Most protocols store the width of the string right before the content, so you
158+will probably write things like this:
159+
160+ import Bytes exposing (Endianness(..))
161+ import Bytes.Decode as Decode
162+
163+ sizedString : Decode.Decoder String
164+ sizedString =
165+ Decode.unsignedInt32 BE
166+ |> Decode.andThen Decode.string
167+
168+In this case we read the width as a 32-bit unsigned integer, but you have the
169+leeway to read the width as a [Base 128 Varint][pb] for ProtoBuf, a
170+[Variable-Length Integer][sql] for SQLite, or whatever else they dream up.
171+
172+[pb]: https://developers.google.com/protocol-buffers/docs/encoding#varints
173+[sql]: https://www.sqlite.org/src4/doc/trunk/www/varint.wiki
174+-}
175+string : Int -> Decoder String
176+string n =
177+ Decoder (Elm.Kernel.Bytes.read_string n)
178+
179+
180+
181+-- MAP
182+
183+
184+{-| Transform the value produced by a decoder. If you encode negative numbers
185+in a special way, you can say something like this:
186+
187+ negativeInt8 : Decoder Int
188+ negativeInt8 =
189+ map negate unsignedInt8
190+
191+In practice you may see something like ProtoBuf's [ZigZag encoding][zz] which
192+decreases the size of small negative numbers.
193+
194+[zz]: https://developers.google.com/protocol-buffers/docs/encoding#types
195+-}
196+map : (a -> b) -> Decoder a -> Decoder b
197+map func (Decoder decodeA) =
198+ Decoder <|
199+ \bites offset ->
200+ let
201+ (aOffset, a) = decodeA bites offset
202+ in
203+ (aOffset, func a)
204+
205+
206+{-| Combine two decoders.
207+
208+ import Bytes exposing (Endiannness(..))
209+ import Bytes.Decode as Decode
210+
211+ type alias Point = { x : Float, y : Float }
212+
213+ decoder : Decode.Decoder Point
214+ decoder =
215+ Decode.map2 Point
216+ (Decode.float32 BE)
217+ (Decode.float32 BE)
218+-}
219+map2 : (a -> b -> result) -> Decoder a -> Decoder b -> Decoder result
220+map2 func (Decoder decodeA) (Decoder decodeB) =
221+ Decoder <|
222+ \bites offset ->
223+ let
224+ (aOffset, a) = decodeA bites offset
225+ (bOffset, b) = decodeB bites aOffset
226+ in
227+ (bOffset, func a b)
228+
229+
230+{-| Combine three decoders.
231+-}
232+map3 : (a -> b -> c -> result) -> Decoder a -> Decoder b -> Decoder c -> Decoder result
233+map3 func (Decoder decodeA) (Decoder decodeB) (Decoder decodeC) =
234+ Decoder <|
235+ \bites offset ->
236+ let
237+ (aOffset, a) = decodeA bites offset
238+ (bOffset, b) = decodeB bites aOffset
239+ (cOffset, c) = decodeC bites bOffset
240+ in
241+ (cOffset, func a b c)
242+
243+
244+{-| Combine four decoders.
245+-}
246+map4 : (a -> b -> c -> d -> result) -> Decoder a -> Decoder b -> Decoder c -> Decoder d -> Decoder result
247+map4 func (Decoder decodeA) (Decoder decodeB) (Decoder decodeC) (Decoder decodeD) =
248+ Decoder <|
249+ \bites offset ->
250+ let
251+ (aOffset, a) = decodeA bites offset
252+ (bOffset, b) = decodeB bites aOffset
253+ (cOffset, c) = decodeC bites bOffset
254+ (dOffset, d) = decodeD bites cOffset
255+ in
256+ (dOffset, func a b c d)
257+
258+
259+{-| Combine five decoders. If you need to combine more things, it is possible
260+to define more of these with `map2` or `andThen`.
261+-}
262+map5 : (a -> b -> c -> d -> e -> result) -> Decoder a -> Decoder b -> Decoder c -> Decoder d -> Decoder e -> Decoder result
263+map5 func (Decoder decodeA) (Decoder decodeB) (Decoder decodeC) (Decoder decodeD) (Decoder decodeE) =
264+ Decoder <|
265+ \bites offset ->
266+ let
267+ (aOffset, a) = decodeA bites offset
268+ (bOffset, b) = decodeB bites aOffset
269+ (cOffset, c) = decodeC bites bOffset
270+ (dOffset, d) = decodeD bites cOffset
271+ (eOffset, e) = decodeE bites dOffset
272+ in
273+ (eOffset, func a b c d e)
274+
275+
276+
277+-- AND THEN
278+
279+
280+{-| Decode something **and then** use that information to decode something
281+else. This is most common with strings or sequences where you need to read
282+how long the value is going to be:
283+
284+ import Bytes exposing (Endianness(..))
285+ import Bytes.Decode as Decode
286+
287+ string : Decoder String
288+ string =
289+ Decode.unsignedInt32 BE
290+ |> Decode.andThen Decode.string
291+
292+Check out the docs for [`succeed`](#succeed), [`fail`](#fail), and
293+[`loop`](#loop) to see `andThen` used in more ways!
294+-}
295+andThen : (a -> Decoder b) -> Decoder a -> Decoder b
296+andThen callback (Decoder decodeA) =
297+ Decoder <|
298+ \bites offset ->
299+ let
300+ (newOffset, a) = decodeA bites offset
301+ (Decoder decodeB) = callback a
302+ in
303+ decodeB bites newOffset
304+
305+
306+{-| A decoder that always succeeds with a certain value. Maybe we are making
307+a `Maybe` decoder:
308+
309+ import Bytes.Decode as Decode exposing (Decoder)
310+
311+ maybe : Decoder a -> Decoder (Maybe a)
312+ maybe decoder =
313+ let
314+ helper n =
315+ if n == 0 then
316+ Decode.succeed Nothing
317+ else
318+ Decode.map Just decoder
319+ in
320+ Decode.unsignedInt8
321+ |> Decode.andThen helper
322+
323+If the first byte is `00000000` then it is `Nothing`, otherwise we start
324+decoding the value and put it in a `Just`.
325+-}
326+succeed : a -> Decoder a
327+succeed a =
328+ Decoder (\_ offset -> (offset,a))
329+
330+
331+{-| A decoder that always fails. This can be useful when using `andThen` to
332+decode custom types:
333+
334+ import Bytes exposing (Endianness(..))
335+ import Bytes.Encode as Encode
336+ import Bytes.Decode as Decode
337+
338+ type Distance = Yards Float | Meters Float
339+
340+ toEncoder : Distance -> Encode.Encoder
341+ toEncoder distance =
342+ case distance of
343+ Yards n -> Encode.sequence [ Encode.unsignedInt8 0, Encode.float32 BE n ]
344+ Meters n -> Encode.sequence [ Encode.unsignedInt8 1, Encode.float32 BE n ]
345+
346+ decoder : Decode.Decoder Distance
347+ decoder =
348+ Decode.unsignedInt8
349+ |> Decode.andThen pickDecoder
350+
351+ pickDecoder : Int -> Decode.Decoder Distance
352+ pickDecoder tag =
353+ case tag of
354+ 0 -> Decode.map Yards (Decode.float32 BE)
355+ 1 -> Decode.map Meters (Decode.float32 BE)
356+ _ -> Decode.fail
357+
358+The encoding chosen here uses an 8-bit unsigned integer to indicate which
359+variant we are working with. If we are working with yards do this, if we are
360+working with meters do that, and otherwise something went wrong!
361+-}
362+fail : Decoder a
363+fail =
364+ Decoder Elm.Kernel.Bytes.decodeFailure
365+
366+
367+
368+-- LOOP
369+
370+
371+{-| Decide what steps to take next in your [`loop`](#loop).
372+
373+If you are `Done`, you give the result of the whole `loop`. If you decide to
374+`Loop` around again, you give a new state to work from. Maybe you need to add
375+an item to a list? Or maybe you need to track some information about what you
376+just saw?
377+
378+**Note:** It may be helpful to learn about [finite-state machines][fsm] to get
379+a broader intuition about using `state`. I.e. You may want to create a `type`
380+that describes four possible states, and then use `Loop` to transition between
381+them as you consume characters.
382+
383+[fsm]: https://en.wikipedia.org/wiki/Finite-state_machine
384+-}
385+type Step state a
386+ = Loop state
387+ | Done a
388+
389+
390+{-| A decoder that can loop indefinitely. This can be helpful when parsing
391+repeated structures, like a list:
392+
393+ import Bytes exposing (Endianness(..))
394+ import Bytes.Decode as Decode exposing (..)
395+
396+ list : Decoder a -> Decoder (List a)
397+ list decoder =
398+ unsignedInt32 BE
399+ |> andThen (\len -> loop (len, []) (listStep decoder))
400+
401+ listStep : Decoder a -> (Int, List a) -> Decoder (Step (Int, List a) (List a))
402+ listStep decoder (n, xs) =
403+ if n <= 0 then
404+ succeed (Done xs)
405+ else
406+ map (\x -> Loop (n - 1, x :: xs)) decoder
407+
408+The `list` decoder first reads a 32-bit unsigned integer. That determines how
409+many items will be decoded. From there we use [`loop`](#loop) to track all the
410+items we have parsed so far and figure out when to stop.
411+-}
412+loop : state -> (state -> Decoder (Step state a)) -> Decoder a
413+loop state callback =
414+ Decoder (loopHelp state callback)
415+
416+
417+loopHelp : state -> (state -> Decoder (Step state a)) -> Bytes -> Int -> (Int, a)
418+loopHelp state callback bites offset =
419+ let
420+ (Decoder decoder) = callback state
421+ (newOffset, step) = decoder bites offset
422+ in
423+ case step of
424+ Loop newState ->
425+ loopHelp newState callback bites newOffset
426+
427+ Done result ->
428+ ( newOffset, result )
packages/bytes/src/Bytes/Encode.elmnew file+338
@@ -0,0 +1,338 @@
1+module Bytes.Encode exposing
2+ ( encode
3+ , Encoder
4+ , signedInt8, signedInt16, signedInt32
5+ , unsignedInt8, unsignedInt16, unsignedInt32
6+ , float32, float64
7+ , bytes
8+ , string, getStringWidth
9+ , sequence
10+ )
11+
12+
13+{-|
14+
15+# Encoders
16+@docs encode, Encoder, sequence
17+
18+# Integers
19+@docs signedInt8, signedInt16, signedInt32,
20+ unsignedInt8, unsignedInt16, unsignedInt32
21+
22+# Floats
23+@docs float32, float64
24+
25+# Bytes
26+@docs bytes
27+
28+# Strings
29+@docs string, getStringWidth
30+
31+-}
32+
33+
34+import Bytes exposing (Bytes, Endianness(..))
35+
36+
37+
38+-- ENCODER
39+
40+
41+{-| Describes how to generate a sequence of bytes.
42+
43+These encoders snap together with [`sequence`](#sequence) so you can start with
44+small building blocks and put them together into a more complex encoding.
45+-}
46+type Encoder
47+ = I8 Int
48+ | I16 Endianness Int
49+ | I32 Endianness Int
50+ | U8 Int
51+ | U16 Endianness Int
52+ | U32 Endianness Int
53+ | F32 Endianness Float
54+ | F64 Endianness Float
55+ | Seq Int (List Encoder)
56+ | Utf8 Int String
57+ | Bytes Bytes
58+
59+
60+
61+-- ENCODE
62+
63+
64+{-| Turn an `Encoder` into `Bytes`.
65+
66+ encode (unsignedInt8 7) -- <07>
67+ encode (unsignedInt16 BE 7) -- <0007>
68+ encode (unsignedInt16 LE 7) -- <0700>
69+
70+The `encode` function is designed to minimize allocation. It figures out the
71+exact width necessary to fit everything in `Bytes` and then generate that
72+value directly. This is valuable when you are encoding more elaborate data:
73+
74+ import Bytes exposing (Endianness(..))
75+ import Bytes.Encode as Encode
76+
77+ type alias Person =
78+ { age : Int
79+ , name : String
80+ }
81+
82+ toEncoder : Person -> Encode.Encoder
83+ toEncoder person =
84+ Encode.sequence
85+ [ Encode.unsignedInt16 BE person.age
86+ , Encode.unsignedInt16 BE (Encode.getStringWidth person.name)
87+ , Encode.string person.name
88+ ]
89+
90+ -- encode (toEncoder (Person 33 "Tom")) == <00210003546F6D>
91+
92+Did you know it was going to be seven bytes? How about when you have a hundred
93+people to serialize? And when some have Japanese and Norwegian names? Having
94+this intermediate `Encoder` can help reduce allocation quite a lot!
95+-}
96+encode : Encoder -> Bytes
97+encode =
98+ Elm.Kernel.Bytes.encode
99+
100+
101+
102+-- INTEGERS
103+
104+
105+{-| Encode integers from `-128` to `127` in one byte.
106+-}
107+signedInt8 : Int -> Encoder
108+signedInt8 =
109+ I8
110+
111+
112+{-| Encode integers from `-32768` to `32767` in two bytes.
113+-}
114+signedInt16 : Endianness -> Int -> Encoder
115+signedInt16 =
116+ I16
117+
118+
119+{-| Encode integers from `-2147483648` to `2147483647` in four bytes.
120+-}
121+signedInt32 : Endianness -> Int -> Encoder
122+signedInt32 =
123+ I32
124+
125+
126+{-| Encode integers from `0` to `255` in one byte.
127+-}
128+unsignedInt8 : Int -> Encoder
129+unsignedInt8 =
130+ U8
131+
132+
133+{-| Encode integers from `0` to `65535` in two bytes.
134+-}
135+unsignedInt16 : Endianness -> Int -> Encoder
136+unsignedInt16 =
137+ U16
138+
139+
140+{-| Encode integers from `0` to `4294967295` in four bytes.
141+-}
142+unsignedInt32 : Endianness -> Int -> Encoder
143+unsignedInt32 =
144+ U32
145+
146+
147+
148+-- FLOATS
149+
150+
151+{-| Encode 32-bit floating point numbers in four bytes.
152+-}
153+float32 : Endianness -> Float -> Encoder
154+float32 =
155+ F32
156+
157+
158+{-| Encode 64-bit floating point numbers in eight bytes.
159+-}
160+float64 : Endianness -> Float -> Encoder
161+float64 =
162+ F64
163+
164+
165+
166+-- BYTES
167+
168+
169+{-| Copy bytes directly into the new `Bytes` sequence. This does not record the
170+width though! You usually want to say something like this:
171+
172+ import Bytes exposing (Bytes, Endianness(..))
173+ import Bytes.Encode as Encode
174+
175+ png : Bytes -> Encode.Encoder
176+ png imageData =
177+ Encode.sequence
178+ [ Encode.unsignedInt32 BE (Bytes.width imageData)
179+ , Encode.bytes imageData
180+ ]
181+
182+This allows you to represent the width however is necessary for your protocol.
183+For example, you can use [Base 128 Varints][pb] for ProtoBuf,
184+[Variable-Length Integers][sql] for SQLite, or whatever else they dream up.
185+
186+[pb]: https://developers.google.com/protocol-buffers/docs/encoding#varints
187+[sql]: https://www.sqlite.org/src4/doc/trunk/www/varint.wiki
188+-}
189+bytes : Bytes -> Encoder
190+bytes =
191+ Bytes
192+
193+
194+
195+-- STRINGS
196+
197+
198+{-| Encode a `String` as a bunch of UTF-8 bytes.
199+
200+ encode (string "$20") -- <24 32 30>
201+ encode (string "£20") -- <C2A3 32 30>
202+ encode (string "€20") -- <E282AC 32 30>
203+ encode (string "bread") -- <62 72 65 61 64>
204+ encode (string "brød") -- <62 72 C3B8 64>
205+
206+Some characters take one byte, while others can take up to four. Read more
207+about [UTF-8](https://en.wikipedia.org/wiki/UTF-8) to learn the details!
208+
209+But if you just encode UTF-8 directly, how can you know when you get to the end
210+of the string when you are decoding? So most protocols have an integer saying
211+how many bytes follow, like this:
212+
213+ sizedString : String -> Encoder
214+ sizedString str =
215+ sequence
216+ [ unsignedInt32 BE (getStringWidth str)
217+ , string str
218+ ]
219+
220+You can choose whatever representation you want for the width, which is helpful
221+because many protocols use different integer representations to save space. For
222+example:
223+
224+- ProtoBuf uses [Base 128 Varints](https://developers.google.com/protocol-buffers/docs/encoding#varints)
225+- SQLite uses [Variable-Length Integers](https://www.sqlite.org/src4/doc/trunk/www/varint.wiki)
226+
227+In both cases, small numbers can fit just one byte, saving some space. (The
228+SQLite encoding has the benefit that the first byte tells you how long the
229+number is, making it faster to decode.) In both cases, it is sort of tricky
230+to make negative numbers small.
231+-}
232+string : String -> Encoder
233+string str =
234+ Utf8 (Elm.Kernel.Bytes.getStringWidth str) str
235+
236+
237+{-| Get the width of a `String` in UTF-8 bytes.
238+
239+ getStringWidth "$20" == 3
240+ getStringWidth "£20" == 4
241+ getStringWidth "€20" == 5
242+ getStringWidth "bread" == 5
243+ getStringWidth "brød" == 5
244+
245+Most protocols need this number to come directly before a chunk of UTF-8 bytes
246+as a way to know where the string ends!
247+
248+Read more about how UTF-8 works [here](https://en.wikipedia.org/wiki/UTF-8).
249+-}
250+getStringWidth : String -> Int
251+getStringWidth =
252+ Elm.Kernel.Bytes.getStringWidth
253+
254+
255+
256+-- SEQUENCE
257+
258+
259+{-| Put together a bunch of builders. So if you wanted to encode three `Float`
260+values for the position of a ball in 3D space, you could say:
261+
262+ import Bytes exposing (Endianness(..))
263+ import Bytes.Encode as Encode
264+
265+ type alias Ball = { x : Float, y : Float, z : Float }
266+
267+ ball : Ball -> Encode.Encoder
268+ ball {x,y,z} =
269+ Encode.sequence
270+ [ Encode.float32 BE x
271+ , Encode.float32 BE y
272+ , Encode.float32 BE z
273+ ]
274+
275+-}
276+sequence : List Encoder -> Encoder
277+sequence builders =
278+ Seq (getWidths 0 builders) builders
279+
280+
281+
282+-- WRITE
283+
284+
285+write : Encoder -> Bytes -> Int -> Int
286+write builder mb offset =
287+ case builder of
288+ I8 n -> Elm.Kernel.Bytes.write_i8 mb offset n
289+ I16 e n -> Elm.Kernel.Bytes.write_i16 mb offset n (e == LE)
290+ I32 e n -> Elm.Kernel.Bytes.write_i32 mb offset n (e == LE)
291+ U8 n -> Elm.Kernel.Bytes.write_u8 mb offset n
292+ U16 e n -> Elm.Kernel.Bytes.write_u16 mb offset n (e == LE)
293+ U32 e n -> Elm.Kernel.Bytes.write_u32 mb offset n (e == LE)
294+ F32 e n -> Elm.Kernel.Bytes.write_f32 mb offset n (e == LE)
295+ F64 e n -> Elm.Kernel.Bytes.write_f64 mb offset n (e == LE)
296+ Seq _ bs -> writeSequence bs mb offset
297+ Utf8 _ s -> Elm.Kernel.Bytes.write_string mb offset s
298+ Bytes bs -> Elm.Kernel.Bytes.write_bytes mb offset bs
299+
300+
301+writeSequence : List Encoder -> Bytes -> Int -> Int
302+writeSequence builders mb offset =
303+ case builders of
304+ [] ->
305+ offset
306+
307+ b :: bs ->
308+ writeSequence bs mb (write b mb offset)
309+
310+
311+
312+-- WIDTHS
313+
314+
315+getWidth : Encoder -> Int
316+getWidth builder =
317+ case builder of
318+ I8 _ -> 1
319+ I16 _ _ -> 2
320+ I32 _ _ -> 4
321+ U8 _ -> 1
322+ U16 _ _ -> 2
323+ U32 _ _ -> 4
324+ F32 _ _ -> 4
325+ F64 _ _ -> 8
326+ Seq w _ -> w
327+ Utf8 w _ -> w
328+ Bytes bs -> Elm.Kernel.Bytes.width bs
329+
330+
331+getWidths : Int -> List Encoder -> Int
332+getWidths width builders =
333+ case builders of
334+ [] ->
335+ width
336+
337+ b :: bs ->
338+ getWidths (width + getWidth b) bs
packages/bytes/src/Elm/Kernel/Bytes.jsnew file+229
@@ -0,0 +1,229 @@
1+/*
2+
3+import Bytes.Encode as Encode exposing (getWidth, write)
4+import Elm.Kernel.Scheduler exposing (binding, succeed)
5+import Elm.Kernel.Utils exposing (Tuple2, chr)
6+import Maybe exposing (Just, Nothing)
7+
8+*/
9+
10+// BYTES
11+
12+// Add enumerable numeric index properties to a DataView so that
13+// Elm's structural equality (_Utils_eqHelp) can compare byte contents.
14+// Without this, DataView has no enumerable keys and any two Bytes
15+// values are always considered equal by (==).
16+function _Bytes_wrap(dv)
17+{
18+ for (var i = 0, len = dv.byteLength; i < len; i++)
19+ {
20+ dv[i] = dv.getUint8(i);
21+ }
22+ return dv;
23+}
24+
25+function _Bytes_width(bytes)
26+{
27+ return bytes.byteLength;
28+}
29+
30+var _Bytes_getHostEndianness = F2(function(le, be)
31+{
32+ return __Scheduler_binding(function(callback)
33+ {
34+ callback(__Scheduler_succeed(new Uint8Array(new Uint32Array([1]))[0] === 1 ? le : be));
35+ });
36+});
37+
38+
39+// ENCODERS
40+
41+function _Bytes_encode(encoder)
42+{
43+ var mutableBytes = new DataView(new ArrayBuffer(__Encode_getWidth(encoder)));
44+ __Encode_write(encoder)(mutableBytes)(0);
45+ return _Bytes_wrap(mutableBytes);
46+}
47+
48+
49+// SIGNED INTEGERS
50+
51+var _Bytes_write_i8 = F3(function(mb, i, n) { mb.setInt8(i, n); return i + 1; });
52+var _Bytes_write_i16 = F4(function(mb, i, n, isLE) { mb.setInt16(i, n, isLE); return i + 2; });
53+var _Bytes_write_i32 = F4(function(mb, i, n, isLE) { mb.setInt32(i, n, isLE); return i + 4; });
54+
55+
56+// UNSIGNED INTEGERS
57+
58+var _Bytes_write_u8 = F3(function(mb, i, n) { mb.setUint8(i, n); return i + 1 ;});
59+var _Bytes_write_u16 = F4(function(mb, i, n, isLE) { mb.setUint16(i, n, isLE); return i + 2; });
60+var _Bytes_write_u32 = F4(function(mb, i, n, isLE) { mb.setUint32(i, n, isLE); return i + 4; });
61+
62+
63+// FLOATS
64+
65+var _Bytes_write_f32 = F4(function(mb, i, n, isLE) { mb.setFloat32(i, n, isLE); return i + 4; });
66+var _Bytes_write_f64 = F4(function(mb, i, n, isLE) { mb.setFloat64(i, n, isLE); return i + 8; });
67+
68+
69+// BYTES
70+
71+var _Bytes_write_bytes = F3(function(mb, offset, bytes)
72+{
73+ for (var i = 0, len = bytes.byteLength, limit = len - 4; i <= limit; i += 4)
74+ {
75+ mb.setUint32(offset + i, bytes.getUint32(i));
76+ }
77+ for (; i < len; i++)
78+ {
79+ mb.setUint8(offset + i, bytes.getUint8(i));
80+ }
81+ return offset + len;
82+});
83+
84+
85+// STRINGS
86+
87+function _Bytes_getStringWidth(string)
88+{
89+ for (var width = 0, i = 0; i < string.length; i++)
90+ {
91+ var code = string.charCodeAt(i);
92+ width +=
93+ (code < 0x80) ? 1 :
94+ (code < 0x800) ? 2 :
95+ (code < 0xD800 || 0xDBFF < code) ? 3 : (i++, 4);
96+ }
97+ return width;
98+}
99+
100+var _Bytes_write_string = F3(function(mb, offset, string)
101+{
102+ for (var i = 0; i < string.length; i++)
103+ {
104+ var code = string.charCodeAt(i);
105+ offset +=
106+ (code < 0x80)
107+ ? (mb.setUint8(offset, code)
108+ , 1
109+ )
110+ :
111+ (code < 0x800)
112+ ? (mb.setUint16(offset, 0xC080 /* 0b1100000010000000 */
113+ | (code >>> 6 & 0x1F /* 0b00011111 */) << 8
114+ | code & 0x3F /* 0b00111111 */)
115+ , 2
116+ )
117+ :
118+ (code < 0xD800 || 0xDBFF < code)
119+ ? (mb.setUint16(offset, 0xE080 /* 0b1110000010000000 */
120+ | (code >>> 12 & 0xF /* 0b00001111 */) << 8
121+ | code >>> 6 & 0x3F /* 0b00111111 */)
122+ , mb.setUint8(offset + 2, 0x80 /* 0b10000000 */
123+ | code & 0x3F /* 0b00111111 */)
124+ , 3
125+ )
126+ :
127+ (code = (code - 0xD800) * 0x400 + string.charCodeAt(++i) - 0xDC00 + 0x10000
128+ , mb.setUint32(offset, 0xF0808080 /* 0b11110000100000001000000010000000 */
129+ | (code >>> 18 & 0x7 /* 0b00000111 */) << 24
130+ | (code >>> 12 & 0x3F /* 0b00111111 */) << 16
131+ | (code >>> 6 & 0x3F /* 0b00111111 */) << 8
132+ | code & 0x3F /* 0b00111111 */)
133+ , 4
134+ );
135+ }
136+ return offset;
137+});
138+
139+
140+// DECODER
141+
142+var _Bytes_decode = F2(function(decoder, bytes)
143+{
144+ try {
145+ return __Maybe_Just(A2(decoder, bytes, 0).b);
146+ } catch(e) {
147+ return __Maybe_Nothing;
148+ }
149+});
150+
151+var _Bytes_read_i8 = F2(function( bytes, offset) { return __Utils_Tuple2(offset + 1, bytes.getInt8(offset)); });
152+var _Bytes_read_i16 = F3(function(isLE, bytes, offset) { return __Utils_Tuple2(offset + 2, bytes.getInt16(offset, isLE)); });
153+var _Bytes_read_i32 = F3(function(isLE, bytes, offset) { return __Utils_Tuple2(offset + 4, bytes.getInt32(offset, isLE)); });
154+var _Bytes_read_u8 = F2(function( bytes, offset) { return __Utils_Tuple2(offset + 1, bytes.getUint8(offset)); });
155+var _Bytes_read_u16 = F3(function(isLE, bytes, offset) { return __Utils_Tuple2(offset + 2, bytes.getUint16(offset, isLE)); });
156+var _Bytes_read_u32 = F3(function(isLE, bytes, offset) { return __Utils_Tuple2(offset + 4, bytes.getUint32(offset, isLE)); });
157+var _Bytes_read_f32 = F3(function(isLE, bytes, offset) { return __Utils_Tuple2(offset + 4, bytes.getFloat32(offset, isLE)); });
158+var _Bytes_read_f64 = F3(function(isLE, bytes, offset) { return __Utils_Tuple2(offset + 8, bytes.getFloat64(offset, isLE)); });
159+
160+var _Bytes_read_bytes = F3(function(len, bytes, offset)
161+{
162+ return __Utils_Tuple2(offset + len, _Bytes_wrap(new DataView(bytes.buffer, offset, len)));
163+});
164+
165+var _Bytes_read_string = F3(function(len, bytes, offset)
166+{
167+ var string = '';
168+ var end = offset + len;
169+ for (; offset < end;)
170+ {
171+ var byte = bytes.getUint8(offset++);
172+ string +=
173+ (byte < 128)
174+ ? String.fromCharCode(byte)
175+ :
176+ ((byte & 0xE0 /* 0b11100000 */) === 0xC0 /* 0b11000000 */)
177+ ? String.fromCharCode((byte & 0x1F /* 0b00011111 */) << 6 | bytes.getUint8(offset++) & 0x3F /* 0b00111111 */)
178+ :
179+ ((byte & 0xF0 /* 0b11110000 */) === 0xE0 /* 0b11100000 */)
180+ ? String.fromCharCode(
181+ (byte & 0xF /* 0b00001111 */) << 12
182+ | (bytes.getUint8(offset++) & 0x3F /* 0b00111111 */) << 6
183+ | bytes.getUint8(offset++) & 0x3F /* 0b00111111 */
184+ )
185+ :
186+ (byte =
187+ ((byte & 0x7 /* 0b00000111 */) << 18
188+ | (bytes.getUint8(offset++) & 0x3F /* 0b00111111 */) << 12
189+ | (bytes.getUint8(offset++) & 0x3F /* 0b00111111 */) << 6
190+ | bytes.getUint8(offset++) & 0x3F /* 0b00111111 */
191+ ) - 0x10000
192+ , String.fromCharCode(Math.floor(byte / 0x400) + 0xD800, byte % 0x400 + 0xDC00)
193+ );
194+ }
195+ return __Utils_Tuple2(offset, string);
196+});
197+
198+var _Bytes_decodeFailure = F2(function() { throw 0; });
199+
200+
201+// BASE64
202+
203+function _Bytes_toBase64(bytes)
204+{
205+ var u8 = new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.byteLength);
206+ var binary = '';
207+ for (var i = 0; i < u8.length; i++)
208+ {
209+ binary += String.fromCharCode(u8[i]);
210+ }
211+ return btoa(binary);
212+}
213+
214+function _Bytes_fromBase64(str)
215+{
216+ try {
217+ var binary = atob(str);
218+ var len = binary.length;
219+ var buffer = new ArrayBuffer(len);
220+ var u8 = new Uint8Array(buffer);
221+ for (var i = 0; i < len; i++)
222+ {
223+ u8[i] = binary.charCodeAt(i);
224+ }
225+ return __Maybe_Just(_Bytes_wrap(new DataView(buffer)));
226+ } catch(e) {
227+ return __Maybe_Nothing;
228+ }
229+}
packages/crypto/README.md+63
@@ -22,6 +22,7 @@ Add to your `elm.json`:
2222
2323- [`Crypto.Secp256k1`](#cryptosecp256k1) — ECDSA signing, ECDH key exchange (Bitcoin, Ethereum)
2424- [`Crypto.Ed25519`](#cryptoed25519) — EdDSA signing (SSH, Signal)
25+- [`Crypto.X25519`](#cryptox25519) — ECDH key exchange (WireGuard, Signal, Noise)
2526- [`Crypto.P256`](#cryptop256) — ECDSA signing, ECDH key exchange (TLS, WebAuthn)
2627- [`Crypto.Cipher`](#cryptocipher) — AES-256-GCM, ChaCha20-Poly1305, XChaCha20-Poly1305
2728
@@ -214,6 +215,67 @@ case Ed25519.privateKeyFromHex "9d61b19d...cae7f60" of
214215
215216---
216217
218+## Crypto.X25519
219+
220+```elm
221+import Crypto.X25519 as X25519
222+```
223+
224+X25519 Diffie-Hellman key exchange on Curve25519 (Montgomery form). Used in WireGuard, Signal, Noise Protocol, TLS 1.3.
225+
226+### Types
227+
228+```elm
229+type PrivateKey
230+type PublicKey
231+```
232+
233+### Key Conversion
234+
235+```elm
236+privateKeyFromHex : String -> Maybe PrivateKey
237+privateKeyToHex : PrivateKey -> String
238+publicKeyFromHex : String -> Maybe PublicKey
239+publicKeyToHex : PublicKey -> String
240+```
241+
242+Parse hex-encoded keys (32 bytes / 64 hex chars).
243+
244+### Operations
245+
246+```elm
247+getPublicKey : PrivateKey -> PublicKey
248+```
249+
250+Derive the public key from a private key.
251+
252+```elm
253+getSharedSecret : PrivateKey -> PublicKey -> String
254+```
255+
256+ECDH: compute a shared secret from your private key and their public key. Returns the hex-encoded shared point (32 bytes / 64 hex chars). Both parties derive the same secret.
257+
258+### Example
259+
260+```elm
261+import Crypto.X25519 as X25519
262+
263+case ( X25519.privateKeyFromHex alicePrivHex, X25519.privateKeyFromHex bobPrivHex ) of
264+ ( Just alicePriv, Just bobPriv ) ->
265+ let
266+ alicePub = X25519.getPublicKey alicePriv
267+ bobPub = X25519.getPublicKey bobPriv
268+ secret1 = X25519.getSharedSecret alicePriv bobPub
269+ secret2 = X25519.getSharedSecret bobPriv alicePub
270+ in
271+ secret1 == secret2 -- True
272+
273+ _ ->
274+ False
275+```
276+
277+---
278+
217279## Crypto.P256
218280
219281```elm
@@ -405,6 +467,7 @@ All functions accept and return **lowercase hex strings**. One byte = two hex ch
405467| Public key, compressed (33 bytes) | 66 chars |
406468| Public key, uncompressed (65 bytes) | 130 chars |
407469| Ed25519 public key (32 bytes) | 64 chars |
470+| X25519 public key (32 bytes) | 64 chars |
408471| Signature, compact (64 bytes) | 128 chars |
409472| Cipher key (32 bytes) | 64 chars |
410473| Nonce12 (12 bytes) | 24 chars |
packages/crypto/elm.json+2−3
@@ -1,13 +1,12 @@
11{
22 "type": "package",
33 "name": "lynxjs-elm/crypto",
4− "summary": "Elliptic curve cryptography via noble/curves",
4+ "summary": "Curve25519 cryptography via tweetnacl",
55 "license": "BSD-3-Clause",
66 "version": "1.0.0",
77 "exposed-modules": [
8− "Crypto.Secp256k1",
98 "Crypto.Ed25519",
10− "Crypto.P256",
9+ "Crypto.X25519",
1110 "Crypto.Cipher"
1211 ],
1312 "elm-version": "0.19.0 <= v < 0.20.0",
packages/crypto/src/Crypto/Cipher.elm+29−85
@@ -1,58 +1,40 @@
11module Crypto.Cipher exposing
2− ( Key, Nonce12, Nonce24
2+ ( Key, Nonce
33 , keyFromHex, keyToHex
4− , nonce12FromHex, nonce12ToHex
5− , nonce24FromHex, nonce24ToHex
6− , aesGcmEncrypt, aesGcmDecrypt
7− , chacha20Encrypt, chacha20Decrypt
8− , xchacha20Encrypt, xchacha20Decrypt
4+ , nonceFromHex, nonceToHex
5+ , encrypt, decrypt
96 )
107
11−{-| Authenticated encryption (AEAD) using AES-GCM, ChaCha20-Poly1305, and
12−XChaCha20-Poly1305. All data is hex-encoded.
8+{-| Authenticated encryption using XSalsa20-Poly1305 (NaCl secretbox).
9+All data is hex-encoded.
1310
14−Ciphertext includes the 16-byte authentication tag appended automatically.
11+Ciphertext includes the 16-byte authentication tag prepended automatically.
1512Decryption returns `Nothing` if authentication fails (tampered data or wrong key/nonce).
1613
1714# Types
18−@docs Key, Nonce12, Nonce24
15+@docs Key, Nonce
1916
2017# Key & Nonce Construction
2118@docs keyFromHex, keyToHex
22−@docs nonce12FromHex, nonce12ToHex
23−@docs nonce24FromHex, nonce24ToHex
19+@docs nonceFromHex, nonceToHex
2420
25−# AES-256-GCM
26−@docs aesGcmEncrypt, aesGcmDecrypt
27−
28−# ChaCha20-Poly1305
29−@docs chacha20Encrypt, chacha20Decrypt
30−
31−# XChaCha20-Poly1305
32−@docs xchacha20Encrypt, xchacha20Decrypt
21+# Encrypt / Decrypt
22+@docs encrypt, decrypt
3323-}
3424
3525import Elm.Kernel.Crypto
3626
3727
38−{-| A 256-bit (32-byte) symmetric key. Used by all ciphers. -}
28+{-| A 256-bit (32-byte) symmetric key. -}
3929type Key = Key
4030
4131
42−{-| A 96-bit (12-byte) nonce. Used by AES-GCM and ChaCha20-Poly1305.
43−
44−**Important:** Never reuse a nonce with the same key. Each (key, nonce) pair
45−must be unique across all messages.
46−-}
47−type Nonce12 = Nonce12
48−
49−
50−{-| A 192-bit (24-byte) nonce. Used by XChaCha20-Poly1305.
32+{-| A 192-bit (24-byte) nonce. Large enough for safe random generation
33+since collision probability is negligible.
5134
52−Larger nonces are safer for random generation since collision probability
53−is negligible.
35+**Important:** Never reuse a nonce with the same key.
5436-}
55−type Nonce24 = Nonce24
37+type Nonce = Nonce
5638
5739
5840{-| Parse a hex-encoded key (32 bytes / 64 hex chars). -}
@@ -67,65 +49,27 @@ keyToHex =
6749 Elm.Kernel.Crypto.cipherKeyToHex
6850
6951
70−{-| Parse a hex-encoded 12-byte nonce (24 hex chars). -}
71−nonce12FromHex : String -> Maybe Nonce12
72−nonce12FromHex =
73− Elm.Kernel.Crypto.cipherNonce12FromHex
74−
75−
76−{-| Get the hex representation of a 12-byte nonce. -}
77−nonce12ToHex : Nonce12 -> String
78−nonce12ToHex =
79− Elm.Kernel.Crypto.cipherNonce12ToHex
80−
81−
8252{-| Parse a hex-encoded 24-byte nonce (48 hex chars). -}
83−nonce24FromHex : String -> Maybe Nonce24
84−nonce24FromHex =
53+nonceFromHex : String -> Maybe Nonce
54+nonceFromHex =
8555 Elm.Kernel.Crypto.cipherNonce24FromHex
8656
8757
88−{-| Get the hex representation of a 24-byte nonce. -}
89−nonce24ToHex : Nonce24 -> String
90−nonce24ToHex =
58+{-| Get the hex representation of a nonce. -}
59+nonceToHex : Nonce -> String
60+nonceToHex =
9161 Elm.Kernel.Crypto.cipherNonce24ToHex
9262
9363
94−{-| Encrypt with AES-256-GCM. Returns ciphertext with appended 16-byte auth tag.
95−-}
96−aesGcmEncrypt : Key -> Nonce12 -> String -> String
97−aesGcmEncrypt =
98− Elm.Kernel.Crypto.aesGcmEncrypt
99−
100−
101−{-| Decrypt with AES-256-GCM. Returns `Nothing` if authentication fails. -}
102−aesGcmDecrypt : Key -> Nonce12 -> String -> Maybe String
103−aesGcmDecrypt =
104− Elm.Kernel.Crypto.aesGcmDecrypt
105−
106−
107−{-| Encrypt with ChaCha20-Poly1305. Returns ciphertext with appended 16-byte auth tag.
108−-}
109−chacha20Encrypt : Key -> Nonce12 -> String -> String
110−chacha20Encrypt =
111− Elm.Kernel.Crypto.chacha20Encrypt
112−
113−
114−{-| Decrypt with ChaCha20-Poly1305. Returns `Nothing` if authentication fails. -}
115−chacha20Decrypt : Key -> Nonce12 -> String -> Maybe String
116−chacha20Decrypt =
117− Elm.Kernel.Crypto.chacha20Decrypt
118−
119−
120−{-| Encrypt with XChaCha20-Poly1305. Returns ciphertext with appended 16-byte auth tag.
121−Uses a 24-byte nonce which is safer for random nonce generation.
64+{-| Encrypt with XSalsa20-Poly1305. Returns hex-encoded ciphertext
65+with prepended 16-byte authentication tag.
12266-}
123−xchacha20Encrypt : Key -> Nonce24 -> String -> String
124−xchacha20Encrypt =
125− Elm.Kernel.Crypto.xchacha20Encrypt
67+encrypt : Key -> Nonce -> String -> String
68+encrypt =
69+ Elm.Kernel.Crypto.encrypt
12670
12771
128−{-| Decrypt with XChaCha20-Poly1305. Returns `Nothing` if authentication fails. -}
129−xchacha20Decrypt : Key -> Nonce24 -> String -> Maybe String
130−xchacha20Decrypt =
131− Elm.Kernel.Crypto.xchacha20Decrypt
72+{-| Decrypt with XSalsa20-Poly1305. Returns `Nothing` if authentication fails. -}
73+decrypt : Key -> Nonce -> String -> Maybe String
74+decrypt =
75+ Elm.Kernel.Crypto.decrypt
packages/crypto/src/Crypto/P256.elmdeleted−121
@@ -1,121 +0,0 @@
1−module Crypto.P256 exposing
2− ( PrivateKey, PublicKey, Signature
3− , privateKeyFromHex, privateKeyToHex
4− , publicKeyFromHex, publicKeyToHex
5− , signatureFromCompactHex, signatureFromDerHex
6− , signatureToCompactHex, signatureToDerHex
7− , getPublicKey
8− , sign, verify
9− , getSharedSecret
10− )
11−
12−{-| Elliptic curve operations for NIST P-256 (secp256r1, prime256v1).
13−
14−All byte data is represented as hex-encoded strings.
15−
16−# Types
17−@docs PrivateKey, PublicKey, Signature
18−
19−# Key Conversion
20−@docs privateKeyFromHex, privateKeyToHex
21−@docs publicKeyFromHex, publicKeyToHex
22−
23−# Signature Conversion
24−@docs signatureFromCompactHex, signatureFromDerHex
25−@docs signatureToCompactHex, signatureToDerHex
26−
27−# Operations
28−@docs getPublicKey, sign, verify, getSharedSecret
29−-}
30−
31−import Elm.Kernel.Crypto
32−
33−
34−{-| An opaque P-256 private key. -}
35−type PrivateKey = PrivateKey
36−
37−
38−{-| An opaque P-256 public key (compressed). -}
39−type PublicKey = PublicKey
40−
41−
42−{-| An opaque P-256 ECDSA signature. -}
43−type Signature = Signature
44−
45−
46−{-| Parse a hex-encoded private key (32 bytes / 64 hex chars). Returns
47−`Nothing` if the hex is invalid or not a valid scalar.
48−-}
49−privateKeyFromHex : String -> Maybe PrivateKey
50−privateKeyFromHex =
51− Elm.Kernel.Crypto.p256PrivateKeyFromHex
52−
53−
54−{-| Get the hex representation of a private key. -}
55−privateKeyToHex : PrivateKey -> String
56−privateKeyToHex =
57− Elm.Kernel.Crypto.p256PrivateKeyToHex
58−
59−
60−{-| Parse a hex-encoded public key (compressed 33 bytes or uncompressed 65
61−bytes). Returns `Nothing` if the point is not on the curve.
62−-}
63−publicKeyFromHex : String -> Maybe PublicKey
64−publicKeyFromHex =
65− Elm.Kernel.Crypto.p256PublicKeyFromHex
66−
67−
68−{-| Get the hex representation of a public key (compressed). -}
69−publicKeyToHex : PublicKey -> String
70−publicKeyToHex =
71− Elm.Kernel.Crypto.p256PublicKeyToHex
72−
73−
74−{-| Parse a compact signature (64 bytes / 128 hex chars, r||s). -}
75−signatureFromCompactHex : String -> Maybe Signature
76−signatureFromCompactHex =
77− Elm.Kernel.Crypto.p256SignatureFromCompactHex
78−
79−
80−{-| Parse a DER-encoded signature. -}
81−signatureFromDerHex : String -> Maybe Signature
82−signatureFromDerHex =
83− Elm.Kernel.Crypto.p256SignatureFromDerHex
84−
85−
86−{-| Get the compact hex representation (r||s, 128 hex chars). -}
87−signatureToCompactHex : Signature -> String
88−signatureToCompactHex =
89− Elm.Kernel.Crypto.p256SignatureToCompactHex
90−
91−
92−{-| Get the DER-encoded hex representation. -}
93−signatureToDerHex : Signature -> String
94−signatureToDerHex =
95− Elm.Kernel.Crypto.p256SignatureToDerHex
96−
97−
98−{-| Derive the public key from a private key. -}
99−getPublicKey : PrivateKey -> PublicKey
100−getPublicKey =
101− Elm.Kernel.Crypto.p256GetPublicKey
102−
103−
104−{-| Sign a message hash. The first argument should be the hex-encoded hash
105−of the message (e.g., a SHA-256 hash). Uses deterministic RFC 6979 nonces.
106−-}
107−sign : String -> PrivateKey -> Signature
108−sign =
109− Elm.Kernel.Crypto.p256Sign
110−
111−
112−{-| Verify a signature against a message hash and public key. -}
113−verify : Signature -> String -> PublicKey -> Bool
114−verify =
115− Elm.Kernel.Crypto.p256Verify
116−
117−
118−{-| Compute an ECDH shared secret. Returns the hex-encoded shared point. -}
119−getSharedSecret : PrivateKey -> PublicKey -> String
120−getSharedSecret =
121− Elm.Kernel.Crypto.p256GetSharedSecret
packages/crypto/src/Crypto/Secp256k1.elmdeleted−121
@@ -1,121 +0,0 @@
1−module Crypto.Secp256k1 exposing
2− ( PrivateKey, PublicKey, Signature
3− , privateKeyFromHex, privateKeyToHex
4− , publicKeyFromHex, publicKeyToHex
5− , signatureFromCompactHex, signatureFromDerHex
6− , signatureToCompactHex, signatureToDerHex
7− , getPublicKey
8− , sign, verify
9− , getSharedSecret
10− )
11−
12−{-| Elliptic curve operations for secp256k1 (Bitcoin, Ethereum).
13−
14−All byte data is represented as hex-encoded strings.
15−
16−# Types
17−@docs PrivateKey, PublicKey, Signature
18−
19−# Key Conversion
20−@docs privateKeyFromHex, privateKeyToHex
21−@docs publicKeyFromHex, publicKeyToHex
22−
23−# Signature Conversion
24−@docs signatureFromCompactHex, signatureFromDerHex
25−@docs signatureToCompactHex, signatureToDerHex
26−
27−# Operations
28−@docs getPublicKey, sign, verify, getSharedSecret
29−-}
30−
31−import Elm.Kernel.Crypto
32−
33−
34−{-| An opaque secp256k1 private key. -}
35−type PrivateKey = PrivateKey
36−
37−
38−{-| An opaque secp256k1 public key (compressed). -}
39−type PublicKey = PublicKey
40−
41−
42−{-| An opaque secp256k1 ECDSA signature. -}
43−type Signature = Signature
44−
45−
46−{-| Parse a hex-encoded private key (32 bytes / 64 hex chars). Returns
47−`Nothing` if the hex is invalid or not a valid scalar.
48−-}
49−privateKeyFromHex : String -> Maybe PrivateKey
50−privateKeyFromHex =
51− Elm.Kernel.Crypto.secp256k1PrivateKeyFromHex
52−
53−
54−{-| Get the hex representation of a private key. -}
55−privateKeyToHex : PrivateKey -> String
56−privateKeyToHex =
57− Elm.Kernel.Crypto.secp256k1PrivateKeyToHex
58−
59−
60−{-| Parse a hex-encoded public key (compressed 33 bytes or uncompressed 65
61−bytes). Returns `Nothing` if the point is not on the curve.
62−-}
63−publicKeyFromHex : String -> Maybe PublicKey
64−publicKeyFromHex =
65− Elm.Kernel.Crypto.secp256k1PublicKeyFromHex
66−
67−
68−{-| Get the hex representation of a public key (compressed). -}
69−publicKeyToHex : PublicKey -> String
70−publicKeyToHex =
71− Elm.Kernel.Crypto.secp256k1PublicKeyToHex
72−
73−
74−{-| Parse a compact signature (64 bytes / 128 hex chars, r||s). -}
75−signatureFromCompactHex : String -> Maybe Signature
76−signatureFromCompactHex =
77− Elm.Kernel.Crypto.secp256k1SignatureFromCompactHex
78−
79−
80−{-| Parse a DER-encoded signature. -}
81−signatureFromDerHex : String -> Maybe Signature
82−signatureFromDerHex =
83− Elm.Kernel.Crypto.secp256k1SignatureFromDerHex
84−
85−
86−{-| Get the compact hex representation (r||s, 128 hex chars). -}
87−signatureToCompactHex : Signature -> String
88−signatureToCompactHex =
89− Elm.Kernel.Crypto.secp256k1SignatureToCompactHex
90−
91−
92−{-| Get the DER-encoded hex representation. -}
93−signatureToDerHex : Signature -> String
94−signatureToDerHex =
95− Elm.Kernel.Crypto.secp256k1SignatureToDerHex
96−
97−
98−{-| Derive the public key from a private key. -}
99−getPublicKey : PrivateKey -> PublicKey
100−getPublicKey =
101− Elm.Kernel.Crypto.secp256k1GetPublicKey
102−
103−
104−{-| Sign a message hash. The first argument should be the hex-encoded hash
105−of the message (e.g., a SHA-256 hash). Uses deterministic RFC 6979 nonces.
106−-}
107−sign : String -> PrivateKey -> Signature
108−sign =
109− Elm.Kernel.Crypto.secp256k1Sign
110−
111−
112−{-| Verify a signature against a message hash and public key. -}
113−verify : Signature -> String -> PublicKey -> Bool
114−verify =
115− Elm.Kernel.Crypto.secp256k1Verify
116−
117−
118−{-| Compute an ECDH shared secret. Returns the hex-encoded shared point. -}
119−getSharedSecret : PrivateKey -> PublicKey -> String
120−getSharedSecret =
121− Elm.Kernel.Crypto.secp256k1GetSharedSecret
packages/crypto/src/Crypto/X25519.elmnew file+70
@@ -0,0 +1,70 @@
1+module Crypto.X25519 exposing
2+ ( PrivateKey, PublicKey
3+ , privateKeyFromHex, privateKeyToHex
4+ , publicKeyFromHex, publicKeyToHex
5+ , getPublicKey
6+ , getSharedSecret
7+ )
8+
9+{-| X25519 Diffie-Hellman key exchange (Curve25519 Montgomery form).
10+
11+All byte data is represented as hex-encoded strings.
12+
13+# Types
14+@docs PrivateKey, PublicKey
15+
16+# Key Conversion
17+@docs privateKeyFromHex, privateKeyToHex
18+@docs publicKeyFromHex, publicKeyToHex
19+
20+# Operations
21+@docs getPublicKey, getSharedSecret
22+-}
23+
24+import Elm.Kernel.Crypto
25+
26+
27+{-| An opaque X25519 private key. -}
28+type PrivateKey = PrivateKey
29+
30+
31+{-| An opaque X25519 public key. -}
32+type PublicKey = PublicKey
33+
34+
35+{-| Parse a hex-encoded private key (32 bytes / 64 hex chars). -}
36+privateKeyFromHex : String -> Maybe PrivateKey
37+privateKeyFromHex =
38+ Elm.Kernel.Crypto.x25519PrivateKeyFromHex
39+
40+
41+{-| Get the hex representation of a private key. -}
42+privateKeyToHex : PrivateKey -> String
43+privateKeyToHex =
44+ Elm.Kernel.Crypto.x25519PrivateKeyToHex
45+
46+
47+{-| Parse a hex-encoded public key (32 bytes / 64 hex chars). -}
48+publicKeyFromHex : String -> Maybe PublicKey
49+publicKeyFromHex =
50+ Elm.Kernel.Crypto.x25519PublicKeyFromHex
51+
52+
53+{-| Get the hex representation of a public key. -}
54+publicKeyToHex : PublicKey -> String
55+publicKeyToHex =
56+ Elm.Kernel.Crypto.x25519PublicKeyToHex
57+
58+
59+{-| Derive the public key from a private key. -}
60+getPublicKey : PrivateKey -> PublicKey
61+getPublicKey =
62+ Elm.Kernel.Crypto.x25519GetPublicKey
63+
64+
65+{-| Compute an ECDH shared secret. Returns the hex-encoded shared point
66+(32 bytes / 64 hex chars). Both parties derive the same secret.
67+-}
68+getSharedSecret : PrivateKey -> PublicKey -> String
69+getSharedSecret =
70+ Elm.Kernel.Crypto.x25519GetSharedSecret
packages/crypto/src/Elm/Kernel/Crypto.js+68−327
@@ -5,210 +5,57 @@ import Maybe exposing (Just, Nothing)
55*/
66
77
8−// NOBLE/CURVES BUNDLE (https://github.com/paulmillr/noble-curves, MIT License)
9−// Embedded: @noble/curves 2.0.1 - secp256k1, ed25519, P-256
10−
11−var _Crypto_noble =(()=>{var te=Object.defineProperty;var _n=Object.getOwnPropertyDescriptor;var In=Object.getOwnPropertyNames;var An=Object.prototype.hasOwnProperty;var Rn=(e,t)=>{for(var r in t)te(e,r,{get:t[r],enumerable:!0})},On=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of In(t))!An.call(e,o)&&o!==r&&te(e,o,{get:()=>t[o],enumerable:!(n=_n(t,o))||n.enumerable});return e};var Hn=e=>On(te({},"_"+"_esModule",{value:!0}),e);var lr={};Rn(lr,{bytesToHex:()=>et,ed25519:()=>vn,hexToBytes:()=>nt,p256:()=>Sn,secp256k1:()=>gn});function pt(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function ot(e,t=""){if(!Number.isSafeInteger(e)||e<0){let r=t&&`"${t}" `;throw new Error(`${r}expected integer >= 0, got ${e}`)}}function N(e,t,r=""){let n=pt(e),o=e?.length,f=t!==void 0;if(!n||f&&o!==t){let i=r&&`"${r}" `,c=f?` of length ${t}`:"",s=n?`length=${o}`:`type=${typeof e}`;throw new Error(i+"expected Uint8Array"+c+", got "+s)}return e}function Yt(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash must wrapped by utils.createHasher");ot(e.outputLen),ot(e.blockLen)}function St(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function qe(e,t){N(e,void 0,"digestInto() output");let r=t.outputLen;if(e.length<r)throw new Error('"digestInto() output" expected to be of length >='+r)}function it(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function kt(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function tt(e,t){return e<<32-t|e>>>t}var Ue=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Tn=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function et(e){if(N(e),Ue)return e.toHex();let t="";for(let r=0;r<e.length;r++)t+=Tn[e[r]];return t}var st={_0:48,_9:57,A:65,F:70,a:97,f:102};function Le(e){if(e>=st._0&&e<=st._9)return e-st._0;if(e>=st.A&&e<=st.F)return e-(st.A-10);if(e>=st.a&&e<=st.f)return e-(st.a-10)}function nt(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(Ue)return Uint8Array.fromHex(e);let t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(r);for(let o=0,f=0;o<r;o++,f+=2){let i=Le(e.charCodeAt(f)),c=Le(e.charCodeAt(f+1));if(i===void 0||c===void 0){let s=e[f]+e[f+1];throw new Error('hex string expected, got non-hex character "'+s+'" at index '+f)}n[o]=i*16+c}return n}function F(...e){let t=0;for(let n=0;n<e.length;n++){let o=e[n];N(o),t+=o.length}let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let f=e[n];r.set(f,o),o+=f.length}return r}function ee(e,t={}){let r=(o,f)=>e(f).update(o).digest(),n=e(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.create=o=>e(o),Object.assign(r,t),Object.freeze(r)}function _t(e=32){let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");return t.getRandomValues(new Uint8Array(e))}var ne=e=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,e])});function Ne(e,t,r){return e&t^~e&r}function De(e,t,r){return e&t^e&r^t&r}var Lt=class{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(t,r,n,o){this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(t),this.view=kt(this.buffer)}update(t){St(this),N(t);let{view:r,buffer:n,blockLen:o}=this,f=t.length;for(let i=0;i<f;){let c=Math.min(o-this.pos,f-i);if(c===o){let s=kt(t);for(;o<=f-i;i+=o)this.process(s,i);continue}n.set(t.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){St(this),qe(t,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:f}=this,{pos:i}=this;r[i++]=128,it(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(n,0),i=0);for(let h=i;h<o;h++)r[h]=0;n.setBigUint64(o-8,BigInt(this.length*8),f),this.process(n,0);let c=kt(t),s=this.outputLen;if(s%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let l=s/4,m=this.get();if(l>m.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<l;h++)c.setUint32(4*h,m[h],f)}digest(){let{buffer:t,outputLen:r}=this;this.digestInto(t);let n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||=new this.constructor,t.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:f,destroyed:i,pos:c}=this;return t.destroyed=i,t.finished=f,t.length=o,t.pos=c,o%r&&t.buffer.set(n),t}clone(){return this._cloneInto()}},ct=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var P=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]);var Xt=BigInt(4294967295),Ze=BigInt(32);function Ln(e,t=!1){return t?{h:Number(e&Xt),l:Number(e>>Ze&Xt)}:{h:Number(e>>Ze&Xt)|0,l:Number(e&Xt)|0}}function Ce(e,t=!1){let r=e.length,n=new Uint32Array(r),o=new Uint32Array(r);for(let f=0;f<r;f++){let{h:i,l:c}=Ln(e[f],t);[n[f],o[f]]=[i,c]}return[n,o]}var re=(e,t,r)=>e>>>r,oe=(e,t,r)=>e<<32-r|t>>>r,gt=(e,t,r)=>e>>>r|t<<32-r,yt=(e,t,r)=>e<<32-r|t>>>r,qt=(e,t,r)=>e<<64-r|t>>>r-32,Ut=(e,t,r)=>e>>>r-32|t<<64-r;function ft(e,t,r,n){let o=(t>>>0)+(n>>>0);return{h:e+r+(o/2**32|0)|0,l:o|0}}var Ve=(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),Me=(e,t,r,n)=>t+r+n+(e/2**32|0)|0,Ye=(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),ke=(e,t,r,n,o)=>t+r+n+o+(e/2**32|0)|0,Xe=(e,t,r,n,o)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(o>>>0),Ge=(e,t,r,n,o,f)=>t+r+n+o+f+(e/2**32|0)|0;var Un=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ut=new Uint32Array(64),fe=class extends Lt{constructor(t){super(64,t,8,!1)}get(){let{A:t,B:r,C:n,D:o,E:f,F:i,G:c,H:s}=this;return[t,r,n,o,f,i,c,s]}set(t,r,n,o,f,i,c,s){this.A=t|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=f|0,this.F=i|0,this.G=c|0,this.H=s|0}process(t,r){for(let h=0;h<16;h++,r+=4)ut[h]=t.getUint32(r,!1);for(let h=16;h<64;h++){let B=ut[h-15],E=ut[h-2],g=tt(B,7)^tt(B,18)^B>>>3,L=tt(E,17)^tt(E,19)^E>>>10;ut[h]=L+ut[h-7]+g+ut[h-16]|0}let{A:n,B:o,C:f,D:i,E:c,F:s,G:l,H:m}=this;for(let h=0;h<64;h++){let B=tt(c,6)^tt(c,11)^tt(c,25),E=m+B+Ne(c,s,l)+Un[h]+ut[h]|0,L=(tt(n,2)^tt(n,13)^tt(n,22))+De(n,o,f)|0;m=l,l=s,s=c,c=i+E|0,i=f,f=o,o=n,n=E+L|0}n=n+this.A|0,o=o+this.B|0,f=f+this.C|0,i=i+this.D|0,c=c+this.E|0,s=s+this.F|0,l=l+this.G|0,m=m+this.H|0,this.set(n,o,f,i,c,s,l,m)}roundClean(){it(ut)}destroy(){this.set(0,0,0,0,0,0,0,0),it(this.buffer)}},se=class extends fe{A=ct[0]|0;B=ct[1]|0;C=ct[2]|0;D=ct[3]|0;E=ct[4]|0;F=ct[5]|0;G=ct[6]|0;H=ct[7]|0;constructor(){super(32)}};var Ke=Ce(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),Nn=Ke[0],Dn=Ke[1],lt=new Uint32Array(80),ht=new Uint32Array(80),ie=class extends Lt{constructor(t){super(128,t,16,!1)}get(){let{Ah:t,Al:r,Bh:n,Bl:o,Ch:f,Cl:i,Dh:c,Dl:s,Eh:l,El:m,Fh:h,Fl:B,Gh:E,Gl:g,Hh:L,Hl:v}=this;return[t,r,n,o,f,i,c,s,l,m,h,B,E,g,L,v]}set(t,r,n,o,f,i,c,s,l,m,h,B,E,g,L,v){this.Ah=t|0,this.Al=r|0,this.Bh=n|0,this.Bl=o|0,this.Ch=f|0,this.Cl=i|0,this.Dh=c|0,this.Dl=s|0,this.Eh=l|0,this.El=m|0,this.Fh=h|0,this.Fl=B|0,this.Gh=E|0,this.Gl=g|0,this.Hh=L|0,this.Hl=v|0}process(t,r){for(let p=0;p<16;p++,r+=4)lt[p]=t.getUint32(r),ht[p]=t.getUint32(r+=4);for(let p=16;p<80;p++){let T=lt[p-15]|0,Z=ht[p-15]|0,V=gt(T,Z,1)^gt(T,Z,8)^re(T,Z,7),M=yt(T,Z,1)^yt(T,Z,8)^oe(T,Z,7),w=lt[p-2]|0,b=ht[p-2]|0,q=gt(w,b,19)^qt(w,b,61)^re(w,b,6),D=yt(w,b,19)^Ut(w,b,61)^oe(w,b,6),R=Ye(M,D,ht[p-7],ht[p-16]),d=ke(R,V,q,lt[p-7],lt[p-16]);lt[p]=d|0,ht[p]=R|0}let{Ah:n,Al:o,Bh:f,Bl:i,Ch:c,Cl:s,Dh:l,Dl:m,Eh:h,El:B,Fh:E,Fl:g,Gh:L,Gl:v,Hh:x,Hl:I}=this;for(let p=0;p<80;p++){let T=gt(h,B,14)^gt(h,B,18)^qt(h,B,41),Z=yt(h,B,14)^yt(h,B,18)^Ut(h,B,41),V=h&E^~h&L,M=B&g^~B&v,w=Xe(I,Z,M,Dn[p],ht[p]),b=Ge(w,x,T,V,Nn[p],lt[p]),q=w|0,D=gt(n,o,28)^qt(n,o,34)^qt(n,o,39),R=yt(n,o,28)^Ut(n,o,34)^Ut(n,o,39),d=n&f^n&c^f&c,u=o&i^o&s^i&s;x=L|0,I=v|0,L=E|0,v=g|0,E=h|0,g=B|0,{h,l:B}=ft(l|0,m|0,b|0,q|0),l=c|0,m=s|0,c=f|0,s=i|0,f=n|0,i=o|0;let a=Ve(q,R,u);n=Me(a,b,D,d),o=a|0}({h:n,l:o}=ft(this.Ah|0,this.Al|0,n|0,o|0)),{h:f,l:i}=ft(this.Bh|0,this.Bl|0,f|0,i|0),{h:c,l:s}=ft(this.Ch|0,this.Cl|0,c|0,s|0),{h:l,l:m}=ft(this.Dh|0,this.Dl|0,l|0,m|0),{h,l:B}=ft(this.Eh|0,this.El|0,h|0,B|0),{h:E,l:g}=ft(this.Fh|0,this.Fl|0,E|0,g|0),{h:L,l:v}=ft(this.Gh|0,this.Gl|0,L|0,v|0),{h:x,l:I}=ft(this.Hh|0,this.Hl|0,x|0,I|0),this.set(n,o,f,i,c,s,l,m,h,B,E,g,L,v,x,I)}roundClean(){it(lt,ht)}destroy(){it(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}},ce=class extends ie{Ah=P[0]|0;Al=P[1]|0;Bh=P[2]|0;Bl=P[3]|0;Ch=P[4]|0;Cl=P[5]|0;Dh=P[6]|0;Dl=P[7]|0;Eh=P[8]|0;El=P[9]|0;Fh=P[10]|0;Fl=P[11]|0;Gh=P[12]|0;Gl=P[13]|0;Hh=P[14]|0;Hl=P[15]|0;constructor(){super(64)}};var Gt=ee(()=>new se,ne(1));var ae=ee(()=>new ce,ne(3));var ue=BigInt(0),de=BigInt(1);function at(e,t=""){if(typeof e!="boolean"){let r=t&&`"${t}" `;throw new Error(r+"expected boolean, got type="+typeof e)}return e}function je(e){if(typeof e=="bigint"){if(!Kt(e))throw new Error("positive bigint expected, got "+e)}else ot(e);return e}function Nt(e){let t=je(e).toString(16);return t.length&1?"0"+t:t}function We(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?ue:BigInt("0x"+e)}function It(e){return We(et(e))}function wt(e){return We(et(Wt(N(e)).reverse()))}function jt(e,t){ot(t),e=je(e);let r=nt(e.toString(16).padStart(t*2,"0"));if(r.length!==t)throw new Error("number too large");return r}function le(e,t){return jt(e,t).reverse()}function Wt(e){return Uint8Array.from(e)}var Kt=e=>typeof e=="bigint"&&ue<=e;function Zn(e,t,r){return Kt(e)&&Kt(t)&&Kt(r)&&t<=e&&e<r}function Dt(e,t,r,n){if(!Zn(t,r,n))throw new Error("expected valid "+e+": "+r+" <= n < "+n+", got "+t)}function he(e){let t;for(t=0;e>ue;e>>=de,t+=1);return t}var Zt=e=>(de<<BigInt(e))-de;function ze(e,t,r){if(ot(e,"hashLen"),ot(t,"qByteLen"),typeof r!="function")throw new Error("hmacFn must be a function");let n=v=>new Uint8Array(v),o=Uint8Array.of(),f=Uint8Array.of(0),i=Uint8Array.of(1),c=1e3,s=n(e),l=n(e),m=0,h=()=>{s.fill(1),l.fill(0),m=0},B=(...v)=>r(l,F(s,...v)),E=(v=o)=>{l=B(f,v),s=B(),v.length!==0&&(l=B(i,v),s=B())},g=()=>{if(m++>=c)throw new Error("drbg: tried max amount of iterations");let v=0,x=[];for(;v<t;){s=B();let I=s.slice();x.push(I),v+=s.length}return F(...x)};return(v,x)=>{h(),E(v);let I;for(;!(I=x(g()));)E();return h(),I}}function bt(e,t={},r={}){if(!e||typeof e!="object")throw new Error("expected valid options object");function n(f,i,c){let s=e[f];if(c&&s===void 0)return;let l=typeof s;if(l!==i||s===null)throw new Error(`param "${f}" is invalid: expected ${i}, got ${l}`)}let o=(f,i)=>Object.entries(f).forEach(([c,s])=>n(c,s,i));o(t,!1),o(r,!0)}function At(e){let t=new WeakMap;return(r,...n)=>{let o=t.get(r);if(o!==void 0)return o;let f=e(r,...n);return t.set(r,f),f}}var J=BigInt(0),W=BigInt(1),Et=BigInt(2),Qe=BigInt(3),Je=BigInt(4),Fe=BigInt(5),Cn=BigInt(7),tn=BigInt(8),Vn=BigInt(9),en=BigInt(16);function j(e,t){let r=e%t;return r>=J?r:t+r}function k(e,t,r){let n=e;for(;t-- >J;)n*=n,n%=r;return n}function $e(e,t){if(e===J)throw new Error("invert: expected non-zero number");if(t<=J)throw new Error("invert: expected positive modulus, got "+t);let r=j(e,t),n=t,o=J,f=W,i=W,c=J;for(;r!==J;){let l=n/r,m=n%r,h=o-i*l,B=f-c*l;n=r,r=m,o=i,f=c,i=h,c=B}if(n!==W)throw new Error("invert: does not exist");return j(o,t)}function xe(e,t,r){if(!e.eql(e.sqr(t),r))throw new Error("Cannot find square root")}function nn(e,t){let r=(e.ORDER+W)/Je,n=e.pow(t,r);return xe(e,n,t),n}function Mn(e,t){let r=(e.ORDER-Fe)/tn,n=e.mul(t,Et),o=e.pow(n,r),f=e.mul(t,o),i=e.mul(e.mul(f,Et),o),c=e.mul(f,e.sub(i,e.ONE));return xe(e,c,t),c}function Yn(e){let t=Rt(e),r=rn(e),n=r(t,t.neg(t.ONE)),o=r(t,n),f=r(t,t.neg(n)),i=(e+Cn)/en;return(c,s)=>{let l=c.pow(s,i),m=c.mul(l,n),h=c.mul(l,o),B=c.mul(l,f),E=c.eql(c.sqr(m),s),g=c.eql(c.sqr(h),s);l=c.cmov(l,m,E),m=c.cmov(B,h,g);let L=c.eql(c.sqr(m),s),v=c.cmov(l,m,L);return xe(c,v,s),v}}function rn(e){if(e<Qe)throw new Error("sqrt is not defined for small field");let t=e-W,r=0;for(;t%Et===J;)t/=Et,r++;let n=Et,o=Rt(e);for(;Pe(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return nn;let f=o.pow(n,t),i=(t+W)/Et;return function(s,l){if(s.is0(l))return l;if(Pe(s,l)!==1)throw new Error("Cannot find square root");let m=r,h=s.mul(s.ONE,f),B=s.pow(l,t),E=s.pow(l,i);for(;!s.eql(B,s.ONE);){if(s.is0(B))return s.ZERO;let g=1,L=s.sqr(B);for(;!s.eql(L,s.ONE);)if(g++,L=s.sqr(L),g===m)throw new Error("Cannot find square root");let v=W<<BigInt(m-g-1),x=s.pow(h,v);m=g,h=s.sqr(x),B=s.mul(B,h),E=s.mul(E,x)}return E}}function kn(e){return e%Je===Qe?nn:e%tn===Fe?Mn:e%en===Vn?Yn(e):rn(e)}var on=(e,t)=>(j(e,t)&W)===W,Xn=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function me(e){let t={ORDER:"bigint",BYTES:"number",BITS:"number"},r=Xn.reduce((n,o)=>(n[o]="function",n),t);return bt(e,r),e}function Gn(e,t,r){if(r<J)throw new Error("invalid exponent, negatives unsupported");if(r===J)return e.ONE;if(r===W)return t;let n=e.ONE,o=t;for(;r>J;)r&W&&(n=e.mul(n,o)),o=e.sqr(o),r>>=W;return n}function Ct(e,t,r=!1){let n=new Array(t.length).fill(r?e.ZERO:void 0),o=t.reduce((i,c,s)=>e.is0(c)?i:(n[s]=i,e.mul(i,c)),e.ONE),f=e.inv(o);return t.reduceRight((i,c,s)=>e.is0(c)?i:(n[s]=e.mul(i,n[s]),e.mul(i,c)),f),n}function Pe(e,t){let r=(e.ORDER-W)/Et,n=e.pow(t,r),o=e.eql(n,e.ONE),f=e.eql(n,e.ZERO),i=e.eql(n,e.neg(e.ONE));if(!o&&!f&&!i)throw new Error("invalid Legendre symbol result");return o?1:f?0:-1}function Kn(e,t){t!==void 0&&ot(t);let r=t!==void 0?t:e.toString(2).length,n=Math.ceil(r/8);return{nBitLength:r,nByteLength:n}}var be=class{ORDER;BITS;BYTES;isLE;ZERO=J;ONE=W;_lengths;_sqrt;_mod;constructor(t,r={}){if(t<=J)throw new Error("invalid field: expected ORDER > 0, got "+t);let n;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(n=r.BITS),typeof r.sqrt=="function"&&(this.sqrt=r.sqrt),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=r.allowedLengths?.slice()),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:o,nByteLength:f}=Kn(t,n);if(f>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=t,this.BITS=o,this.BYTES=f,this._sqrt=void 0,Object.preventExtensions(this)}create(t){return j(t,this.ORDER)}isValid(t){if(typeof t!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof t);return J<=t&&t<this.ORDER}is0(t){return t===J}isValidNot0(t){return!this.is0(t)&&this.isValid(t)}isOdd(t){return(t&W)===W}neg(t){return j(-t,this.ORDER)}eql(t,r){return t===r}sqr(t){return j(t*t,this.ORDER)}add(t,r){return j(t+r,this.ORDER)}sub(t,r){return j(t-r,this.ORDER)}mul(t,r){return j(t*r,this.ORDER)}pow(t,r){return Gn(this,t,r)}div(t,r){return j(t*$e(r,this.ORDER),this.ORDER)}sqrN(t){return t*t}addN(t,r){return t+r}subN(t,r){return t-r}mulN(t,r){return t*r}inv(t){return $e(t,this.ORDER)}sqrt(t){return this._sqrt||(this._sqrt=kn(this.ORDER)),this._sqrt(this,t)}toBytes(t){return this.isLE?le(t,this.BYTES):jt(t,this.BYTES)}fromBytes(t,r=!1){N(t);let{_lengths:n,BYTES:o,isLE:f,ORDER:i,_mod:c}=this;if(n){if(!n.includes(t.length)||t.length>o)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+t.length);let l=new Uint8Array(o);l.set(t,f?0:l.length-t.length),t=l}if(t.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+t.length);let s=f?wt(t):It(t);if(c&&(s=j(s,i)),!r&&!this.isValid(s))throw new Error("invalid field element: outside of range 0..ORDER");return s}invertBatch(t){return Ct(this,t)}cmov(t,r,n){return n?r:t}};function Rt(e,t={}){return new be(e,t)}function fn(e){if(typeof e!="bigint")throw new Error("field order must be bigint");let t=e.toString(2).length;return Math.ceil(t/8)}function pe(e){let t=fn(e);return t+Math.ceil(t/2)}function ge(e,t,r=!1){N(e);let n=e.length,o=fn(t),f=pe(t);if(n<16||n<f||n>1024)throw new Error("expected "+f+"-1024 bytes of input, got "+n);let i=r?wt(e):It(e),c=j(i,t-W)+W;return r?le(c,o):jt(c,o)}var Ot=BigInt(0),Bt=BigInt(1);function Vt(e,t){let r=t.negate();return e?r:t}function vt(e,t){let r=Ct(e.Fp,t.map(n=>n.Z));return t.map((n,o)=>e.fromAffine(n.toAffine(r[o])))}function dn(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function ye(e,t){dn(e,t);let r=Math.ceil(t/e)+1,n=2**(e-1),o=2**e,f=Zt(e),i=BigInt(e);return{windows:r,windowSize:n,mask:f,maxNumber:o,shiftBy:i}}function sn(e,t,r){let{windowSize:n,mask:o,maxNumber:f,shiftBy:i}=r,c=Number(e&o),s=e>>i;c>n&&(c-=f,s+=Bt);let l=t*n,m=l+Math.abs(c)-1,h=c===0,B=c<0,E=t%2!==0;return{nextN:s,offset:m,isZero:h,isNeg:B,isNegF:E,offsetF:l}}var we=new WeakMap,un=new WeakMap;function Ee(e){return un.get(e)||1}function cn(e){if(e!==Ot)throw new Error("invalid wNAF")}var Ht=class{BASE;ZERO;Fn;bits;constructor(t,r){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=r}_unsafeLadder(t,r,n=this.ZERO){let o=t;for(;r>Ot;)r&Bt&&(n=n.add(o)),o=o.double(),r>>=Bt;return n}precomputeWindow(t,r){let{windows:n,windowSize:o}=ye(r,this.bits),f=[],i=t,c=i;for(let s=0;s<n;s++){c=i,f.push(c);for(let l=1;l<o;l++)c=c.add(i),f.push(c);i=c.double()}return f}wNAF(t,r,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let o=this.ZERO,f=this.BASE,i=ye(t,this.bits);for(let c=0;c<i.windows;c++){let{nextN:s,offset:l,isZero:m,isNeg:h,isNegF:B,offsetF:E}=sn(n,c,i);n=s,m?f=f.add(Vt(B,r[E])):o=o.add(Vt(h,r[l]))}return cn(n),{p:o,f}}wNAFUnsafe(t,r,n,o=this.ZERO){let f=ye(t,this.bits);for(let i=0;i<f.windows&&n!==Ot;i++){let{nextN:c,offset:s,isZero:l,isNeg:m}=sn(n,i,f);if(n=c,!l){let h=r[s];o=o.add(m?h.negate():h)}}return cn(n),o}getPrecomputes(t,r,n){let o=we.get(r);return o||(o=this.precomputeWindow(r,t),t!==1&&(typeof n=="function"&&(o=n(o)),we.set(r,o))),o}cached(t,r,n){let o=Ee(t);return this.wNAF(o,this.getPrecomputes(o,t,n),r)}unsafe(t,r,n,o){let f=Ee(t);return f===1?this._unsafeLadder(t,r,o):this.wNAFUnsafe(f,this.getPrecomputes(f,t,n),r,o)}createCache(t,r){dn(r,this.bits),un.set(t,r),we.delete(t)}hasCache(t){return Ee(t)!==1}};function ln(e,t,r,n){let o=t,f=e.ZERO,i=e.ZERO;for(;r>Ot||n>Ot;)r&Bt&&(f=f.add(o)),n&Bt&&(i=i.add(o)),o=o.double(),r>>=Bt,n>>=Bt;return{p1:f,p2:i}}function an(e,t,r){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return me(t),t}else return Rt(e,{isLE:r})}function zt(e,t,r={},n){if(n===void 0&&(n=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(let s of["p","n","h"]){let l=t[s];if(!(typeof l=="bigint"&&l>Ot))throw new Error(`CURVE.${s} must be positive bigint`)}let o=an(t.p,r.Fp,n),f=an(t.n,r.Fn,n),c=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(let s of c)if(!o.isValid(t[s]))throw new Error(`CURVE.${s} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:o,Fn:f}}function $t(e,t){return function(n){let o=e(n);return{secretKey:o,publicKey:t(o)}}}var Pt=class{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(t,r){if(Yt(t),N(r,void 0,"key"),this.iHash=t.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,o=new Uint8Array(n);o.set(r.length>n?t.create().update(r).digest():r);for(let f=0;f<o.length;f++)o[f]^=54;this.iHash.update(o),this.oHash=t.create();for(let f=0;f<o.length;f++)o[f]^=106;this.oHash.update(o),it(o)}update(t){return St(this),this.iHash.update(t),this}digestInto(t){St(this),N(t,this.outputLen,"output"),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||=Object.create(Object.getPrototypeOf(this),{});let{oHash:r,iHash:n,finished:o,destroyed:f,blockLen:i,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=f,t.blockLen=i,t.outputLen=c,t.oHash=r._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Be=(e,t,r)=>new Pt(e,t).update(r).digest();Be.create=(e,t)=>new Pt(e,t);var hn=(e,t)=>(e+(e>=0?t:-t)/bn)/t;function jn(e,t,r){let[[n,o],[f,i]]=t,c=hn(i*e,r),s=hn(-o*e,r),l=e-c*n-s*f,m=-c*o-s*i,h=l<dt,B=m<dt;h&&(l=-l),B&&(m=-m);let E=Zt(Math.ceil(he(r)/2))+Tt;if(l<dt||l>=E||m<dt||m>=E)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:h,k1:l,k2neg:B,k2:m}}function Se(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function ve(e,t){let r={};for(let n of Object.keys(t))r[n]=e[n]===void 0?t[n]:e[n];return at(r.lowS,"lowS"),at(r.prehash,"prehash"),r.format!==void 0&&Se(r.format),r}var _e=class extends Error{constructor(t=""){super(t)}},xt={Err:_e,_tlv:{encode:(e,t)=>{let{Err:r}=xt;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length&1)throw new r("tlv.encode: unpadded data");let n=t.length/2,o=Nt(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let f=n>127?Nt(o.length/2|128):"";return Nt(e)+f+o+t},decode(e,t){let{Err:r}=xt,n=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[n++]!==e)throw new r("tlv.decode: wrong tlv");let o=t[n++],f=!!(o&128),i=0;if(!f)i=o;else{let s=o&127;if(!s)throw new r("tlv.decode(long): indefinite length not supported");if(s>4)throw new r("tlv.decode(long): byte length is too big");let l=t.subarray(n,n+s);if(l.length!==s)throw new r("tlv.decode: length bytes not complete");if(l[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let m of l)i=i<<8|m;if(n+=s,i<128)throw new r("tlv.decode(long): not minimal encoding")}let c=t.subarray(n,n+i);if(c.length!==i)throw new r("tlv.decode: wrong value length");return{v:c,l:t.subarray(n+i)}}},_int:{encode(e){let{Err:t}=xt;if(e<dt)throw new t("integer: negative integers are not allowed");let r=Nt(e);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){let{Err:t}=xt;if(e[0]&128)throw new t("invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return It(e)}},toSig(e){let{Err:t,_int:r,_tlv:n}=xt,o=N(e,void 0,"signature"),{v:f,l:i}=n.decode(48,o);if(i.length)throw new t("invalid signature: left bytes after parsing");let{v:c,l:s}=n.decode(2,f),{v:l,l:m}=n.decode(2,s);if(m.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(c),s:r.decode(l)}},hexFromSig(e){let{_tlv:t,_int:r}=xt,n=t.encode(2,r.encode(e.r)),o=t.encode(2,r.encode(e.s)),f=n+o;return t.encode(48,f)}},dt=BigInt(0),Tt=BigInt(1),bn=BigInt(2),Qt=BigInt(3),Wn=BigInt(4);function Jt(e,t={}){let r=zt("weierstrass",e,t),{Fp:n,Fn:o}=r,f=r.CURVE,{h:i,n:c}=f;bt(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:s}=t;if(s&&(!n.is0(f.a)||typeof s.beta!="bigint"||!Array.isArray(s.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let l=mn(n,o);function m(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function h(R,d,u){let{x:a,y}=d.toAffine(),S=n.toBytes(a);if(at(u,"isCompressed"),u){m();let A=!n.isOdd(y);return F(xn(A),S)}else return F(Uint8Array.of(4),S,n.toBytes(y))}function B(R){N(R,void 0,"Point");let{publicKey:d,publicKeyUncompressed:u}=l,a=R.length,y=R[0],S=R.subarray(1);if(a===d&&(y===2||y===3)){let A=n.fromBytes(S);if(!n.isValid(A))throw new Error("bad point: is not on curve, wrong x");let O=L(A),_;try{_=n.sqrt(O)}catch(X){let Y=X instanceof Error?": "+X.message:"";throw new Error("bad point: is not on curve, sqrt error"+Y)}m();let H=n.isOdd(_);return(y&1)===1!==H&&(_=n.neg(_)),{x:A,y:_}}else if(a===u&&y===4){let A=n.BYTES,O=n.fromBytes(S.subarray(0,A)),_=n.fromBytes(S.subarray(A,A*2));if(!v(O,_))throw new Error("bad point: is not on curve");return{x:O,y:_}}else throw new Error(`bad point: got length ${a}, expected compressed=${d} or uncompressed=${u}`)}let E=t.toBytes||h,g=t.fromBytes||B;function L(R){let d=n.sqr(R),u=n.mul(d,R);return n.add(n.add(u,n.mul(R,f.a)),f.b)}function v(R,d){let u=n.sqr(d),a=L(R);return n.eql(u,a)}if(!v(f.Gx,f.Gy))throw new Error("bad curve params: generator point");let x=n.mul(n.pow(f.a,Qt),Wn),I=n.mul(n.sqr(f.b),BigInt(27));if(n.is0(n.add(x,I)))throw new Error("bad curve params: a or b");function p(R,d,u=!1){if(!n.isValid(d)||u&&n.is0(d))throw new Error(`bad point coordinate ${R}`);return d}function T(R){if(!(R instanceof b))throw new Error("Weierstrass Point expected")}function Z(R){if(!s||!s.basises)throw new Error("no endo");return jn(R,s.basises,o.ORDER)}let V=At((R,d)=>{let{X:u,Y:a,Z:y}=R;if(n.eql(y,n.ONE))return{x:u,y:a};let S=R.is0();d==null&&(d=S?n.ONE:n.inv(y));let A=n.mul(u,d),O=n.mul(a,d),_=n.mul(y,d);if(S)return{x:n.ZERO,y:n.ZERO};if(!n.eql(_,n.ONE))throw new Error("invZ was invalid");return{x:A,y:O}}),M=At(R=>{if(R.is0()){if(t.allowInfinityPoint&&!n.is0(R.Y))return;throw new Error("bad point: ZERO")}let{x:d,y:u}=R.toAffine();if(!n.isValid(d)||!n.isValid(u))throw new Error("bad point: x or y not field elements");if(!v(d,u))throw new Error("bad point: equation left != right");if(!R.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function w(R,d,u,a,y){return u=new b(n.mul(u.X,R),u.Y,u.Z),d=Vt(a,d),u=Vt(y,u),d.add(u)}class b{static BASE=new b(f.Gx,f.Gy,n.ONE);static ZERO=new b(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=o;X;Y;Z;constructor(d,u,a){this.X=p("x",d),this.Y=p("y",u,!0),this.Z=p("z",a),Object.freeze(this)}static CURVE(){return f}static fromAffine(d){let{x:u,y:a}=d||{};if(!d||!n.isValid(u)||!n.isValid(a))throw new Error("invalid affine point");if(d instanceof b)throw new Error("projective point not allowed");return n.is0(u)&&n.is0(a)?b.ZERO:new b(u,a,n.ONE)}static fromBytes(d){let u=b.fromAffine(g(N(d,void 0,"point")));return u.assertValidity(),u}static fromHex(d){return b.fromBytes(nt(d))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(d=8,u=!0){return D.createCache(this,d),u||this.multiply(Qt),this}assertValidity(){M(this)}hasEvenY(){let{y:d}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(d)}equals(d){T(d);let{X:u,Y:a,Z:y}=this,{X:S,Y:A,Z:O}=d,_=n.eql(n.mul(u,O),n.mul(S,y)),H=n.eql(n.mul(a,O),n.mul(A,y));return _&&H}negate(){return new b(this.X,n.neg(this.Y),this.Z)}double(){let{a:d,b:u}=f,a=n.mul(u,Qt),{X:y,Y:S,Z:A}=this,O=n.ZERO,_=n.ZERO,H=n.ZERO,U=n.mul(y,y),X=n.mul(S,S),Y=n.mul(A,A),C=n.mul(y,S);return C=n.add(C,C),H=n.mul(y,A),H=n.add(H,H),O=n.mul(d,H),_=n.mul(a,Y),_=n.add(O,_),O=n.sub(X,_),_=n.add(X,_),_=n.mul(O,_),O=n.mul(C,O),H=n.mul(a,H),Y=n.mul(d,Y),C=n.sub(U,Y),C=n.mul(d,C),C=n.add(C,H),H=n.add(U,U),U=n.add(H,U),U=n.add(U,Y),U=n.mul(U,C),_=n.add(_,U),Y=n.mul(S,A),Y=n.add(Y,Y),U=n.mul(Y,C),O=n.sub(O,U),H=n.mul(Y,X),H=n.add(H,H),H=n.add(H,H),new b(O,_,H)}add(d){T(d);let{X:u,Y:a,Z:y}=this,{X:S,Y:A,Z:O}=d,_=n.ZERO,H=n.ZERO,U=n.ZERO,X=f.a,Y=n.mul(f.b,Qt),C=n.mul(u,S),G=n.mul(a,A),$=n.mul(y,O),rt=n.add(u,a),K=n.add(S,A);rt=n.mul(rt,K),K=n.add(C,G),rt=n.sub(rt,K),K=n.add(u,y);let Q=n.add(S,O);return K=n.mul(K,Q),Q=n.add(C,$),K=n.sub(K,Q),Q=n.add(a,y),_=n.add(A,O),Q=n.mul(Q,_),_=n.add(G,$),Q=n.sub(Q,_),U=n.mul(X,K),_=n.mul(Y,$),U=n.add(_,U),_=n.sub(G,U),U=n.add(G,U),H=n.mul(_,U),G=n.add(C,C),G=n.add(G,C),$=n.mul(X,$),K=n.mul(Y,K),G=n.add(G,$),$=n.sub(C,$),$=n.mul(X,$),K=n.add(K,$),C=n.mul(G,K),H=n.add(H,C),C=n.mul(Q,K),_=n.mul(rt,_),_=n.sub(_,C),C=n.mul(rt,G),U=n.mul(Q,U),U=n.add(U,C),new b(_,H,U)}subtract(d){return this.add(d.negate())}is0(){return this.equals(b.ZERO)}multiply(d){let{endo:u}=t;if(!o.isValidNot0(d))throw new Error("invalid scalar: out of range");let a,y,S=A=>D.cached(this,A,O=>vt(b,O));if(u){let{k1neg:A,k1:O,k2neg:_,k2:H}=Z(d),{p:U,f:X}=S(O),{p:Y,f:C}=S(H);y=X.add(C),a=w(u.beta,U,Y,A,_)}else{let{p:A,f:O}=S(d);a=A,y=O}return vt(b,[a,y])[0]}multiplyUnsafe(d){let{endo:u}=t,a=this;if(!o.isValid(d))throw new Error("invalid scalar: out of range");if(d===dt||a.is0())return b.ZERO;if(d===Tt)return a;if(D.hasCache(this))return this.multiply(d);if(u){let{k1neg:y,k1:S,k2neg:A,k2:O}=Z(d),{p1:_,p2:H}=ln(b,a,S,O);return w(u.beta,_,H,y,A)}else return D.unsafe(a,d)}toAffine(d){return V(this,d)}isTorsionFree(){let{isTorsionFree:d}=t;return i===Tt?!0:d?d(b,this):D.unsafe(this,c).is0()}clearCofactor(){let{clearCofactor:d}=t;return i===Tt?this:d?d(b,this):this.multiplyUnsafe(i)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}toBytes(d=!0){return at(d,"isCompressed"),this.assertValidity(),E(b,this,d)}toHex(d=!0){return et(this.toBytes(d))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let q=o.BITS,D=new Ht(b,t.endo?Math.ceil(q/2):q);return b.BASE.precompute(8),b}function xn(e){return Uint8Array.of(e?2:3)}function mn(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function zn(e,t={}){let{Fn:r}=e,n=t.randomBytes||_t,o=Object.assign(mn(e.Fp,r),{seed:pe(r.ORDER)});function f(E){try{let g=r.fromBytes(E);return r.isValidNot0(g)}catch{return!1}}function i(E,g){let{publicKey:L,publicKeyUncompressed:v}=o;try{let x=E.length;return g===!0&&x!==L||g===!1&&x!==v?!1:!!e.fromBytes(E)}catch{return!1}}function c(E=n(o.seed)){return ge(N(E,o.seed,"seed"),r.ORDER)}function s(E,g=!0){return e.BASE.multiply(r.fromBytes(E)).toBytes(g)}function l(E){let{secretKey:g,publicKey:L,publicKeyUncompressed:v}=o;if(!pt(E)||"_lengths"in r&&r._lengths||g===L)return;let x=N(E,void 0,"key").length;return x===L||x===v}function m(E,g,L=!0){if(l(E)===!0)throw new Error("first arg must be private key");if(l(g)===!1)throw new Error("second arg must be public key");let v=r.fromBytes(E);return e.fromBytes(g).multiply(v).toBytes(L)}let h={isValidSecretKey:f,isValidPublicKey:i,randomSecretKey:c},B=$t(c,s);return Object.freeze({getPublicKey:s,getSharedSecret:m,keygen:B,Point:e,utils:h,lengths:o})}function Ft(e,t,r={}){Yt(t),bt(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let n=r.randomBytes||_t,o=r.hmac||((u,a)=>Be(t,u,a)),{Fp:f,Fn:i}=e,{ORDER:c,BITS:s}=i,{keygen:l,getPublicKey:m,getSharedSecret:h,utils:B,lengths:E}=zn(e,r),g={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},L=c*bn<f.ORDER;function v(u){let a=c>>Tt;return u>a}function x(u,a){if(!i.isValidNot0(a))throw new Error(`invalid signature ${u}: out of range 1..Point.Fn.ORDER`);return a}function I(){if(L)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function p(u,a){Se(a);let y=E.signature,S=a==="compact"?y:a==="recovered"?y+1:void 0;return N(u,S)}class T{r;s;recovery;constructor(a,y,S){if(this.r=x("r",a),this.s=x("s",y),S!=null){if(I(),![0,1,2,3].includes(S))throw new Error("invalid recovery id");this.recovery=S}Object.freeze(this)}static fromBytes(a,y=g.format){p(a,y);let S;if(y==="der"){let{r:H,s:U}=xt.toSig(N(a));return new T(H,U)}y==="recovered"&&(S=a[0],y="compact",a=a.subarray(1));let A=E.signature/2,O=a.subarray(0,A),_=a.subarray(A,A*2);return new T(i.fromBytes(O),i.fromBytes(_),S)}static fromHex(a,y){return this.fromBytes(nt(a),y)}assertRecovery(){let{recovery:a}=this;if(a==null)throw new Error("invalid recovery id: must be present");return a}addRecoveryBit(a){return new T(this.r,this.s,a)}recoverPublicKey(a){let{r:y,s:S}=this,A=this.assertRecovery(),O=A===2||A===3?y+c:y;if(!f.isValid(O))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let _=f.toBytes(O),H=e.fromBytes(F(xn((A&1)===0),_)),U=i.inv(O),X=V(N(a,void 0,"msgHash")),Y=i.create(-X*U),C=i.create(S*U),G=e.BASE.multiplyUnsafe(Y).add(H.multiplyUnsafe(C));if(G.is0())throw new Error("invalid recovery: point at infinify");return G.assertValidity(),G}hasHighS(){return v(this.s)}toBytes(a=g.format){if(Se(a),a==="der")return nt(xt.hexFromSig(this));let{r:y,s:S}=this,A=i.toBytes(y),O=i.toBytes(S);return a==="recovered"?(I(),F(Uint8Array.of(this.assertRecovery()),A,O)):F(A,O)}toHex(a){return et(this.toBytes(a))}}let Z=r.bits2int||function(a){if(a.length>8192)throw new Error("input is too large");let y=It(a),S=a.length*8-s;return S>0?y>>BigInt(S):y},V=r.bits2int_modN||function(a){return i.create(Z(a))},M=Zt(s);function w(u){return Dt("num < 2^"+s,u,dt,M),i.toBytes(u)}function b(u,a){return N(u,void 0,"message"),a?N(t(u),void 0,"prehashed message"):u}function q(u,a,y){let{lowS:S,prehash:A,extraEntropy:O}=ve(y,g);u=b(u,A);let _=V(u),H=i.fromBytes(a);if(!i.isValidNot0(H))throw new Error("invalid private key");let U=[w(H),w(_)];if(O!=null&&O!==!1){let G=O===!0?n(E.secretKey):O;U.push(N(G,void 0,"extraEntropy"))}let X=F(...U),Y=_;function C(G){let $=Z(G);if(!i.isValidNot0($))return;let rt=i.inv($),K=e.BASE.multiply($).toAffine(),Q=i.create(K.x);if(Q===dt)return;let Mt=i.create(rt*i.create(Y+Q*H));if(Mt===dt)return;let He=(K.x===Q?0:2)|Number(K.y&Tt),Te=Mt;return S&&v(Mt)&&(Te=i.neg(Mt),He^=1),new T(Q,Te,L?void 0:He)}return{seed:X,k2sig:C}}function D(u,a,y={}){let{seed:S,k2sig:A}=q(u,a,y);return ze(t.outputLen,i.BYTES,o)(S,A).toBytes(y.format)}function R(u,a,y,S={}){let{lowS:A,prehash:O,format:_}=ve(S,g);if(y=N(y,void 0,"publicKey"),a=b(a,O),!pt(u)){let H=u instanceof T?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+H)}p(u,_);try{let H=T.fromBytes(u,_),U=e.fromBytes(y);if(A&&H.hasHighS())return!1;let{r:X,s:Y}=H,C=V(a),G=i.inv(Y),$=i.create(C*G),rt=i.create(X*G),K=e.BASE.multiplyUnsafe($).add(U.multiplyUnsafe(rt));return K.is0()?!1:i.create(K.x)===X}catch{return!1}}function d(u,a,y={}){let{prehash:S}=ve(y,g);return a=b(a,S),T.fromBytes(u,"recovered").recoverPublicKey(a).toBytes()}return Object.freeze({keygen:l,getPublicKey:m,getSharedSecret:h,utils:B,lengths:E,Point:e,sign:D,verify:R,recoverPublicKey:d,Signature:T,hash:t})}var Ae={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},Pn={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var pn=BigInt(2);function Qn(e){let t=Ae.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),f=BigInt(22),i=BigInt(23),c=BigInt(44),s=BigInt(88),l=e*e*e%t,m=l*l*e%t,h=k(m,r,t)*m%t,B=k(h,r,t)*m%t,E=k(B,pn,t)*l%t,g=k(E,o,t)*E%t,L=k(g,f,t)*g%t,v=k(L,c,t)*L%t,x=k(v,s,t)*v%t,I=k(x,c,t)*L%t,p=k(I,r,t)*m%t,T=k(p,i,t)*g%t,Z=k(T,n,t)*l%t,V=k(Z,pn,t);if(!Ie.eql(Ie.sqr(V),e))throw new Error("Cannot find square root");return V}var Ie=Rt(Ae.p,{sqrt:Qn}),Jn=Jt(Ae,{Fp:Ie,endo:Pn}),gn=Ft(Jn,Gt);var mt=BigInt(0),z=BigInt(1),Re=BigInt(2),Fn=BigInt(8);function tr(e,t,r,n){let o=e.sqr(r),f=e.sqr(n),i=e.add(e.mul(t.a,o),f),c=e.add(e.ONE,e.mul(t.d,e.mul(o,f)));return e.eql(i,c)}function yn(e,t={}){let r=zt("edwards",e,t,t.FpFnLE),{Fp:n,Fn:o}=r,f=r.CURVE,{h:i}=f;bt(t,{},{uvRatio:"function"});let c=Re<<BigInt(o.BYTES*8)-z,s=v=>n.create(v),l=t.uvRatio||((v,x)=>{try{return{isValid:!0,value:n.sqrt(n.div(v,x))}}catch{return{isValid:!1,value:mt}}});if(!tr(n,f,f.Gx,f.Gy))throw new Error("bad curve params: generator point");function m(v,x,I=!1){let p=I?z:mt;return Dt("coordinate "+v,x,p,c),x}function h(v){if(!(v instanceof g))throw new Error("EdwardsPoint expected")}let B=At((v,x)=>{let{X:I,Y:p,Z:T}=v,Z=v.is0();x==null&&(x=Z?Fn:n.inv(T));let V=s(I*x),M=s(p*x),w=n.mul(T,x);if(Z)return{x:mt,y:z};if(w!==z)throw new Error("invZ was invalid");return{x:V,y:M}}),E=At(v=>{let{a:x,d:I}=f;if(v.is0())throw new Error("bad point: ZERO");let{X:p,Y:T,Z,T:V}=v,M=s(p*p),w=s(T*T),b=s(Z*Z),q=s(b*b),D=s(M*x),R=s(b*s(D+w)),d=s(q+s(I*s(M*w)));if(R!==d)throw new Error("bad point: equation left != right (1)");let u=s(p*T),a=s(Z*V);if(u!==a)throw new Error("bad point: equation left != right (2)");return!0});class g{static BASE=new g(f.Gx,f.Gy,z,s(f.Gx*f.Gy));static ZERO=new g(mt,z,z,mt);static Fp=n;static Fn=o;X;Y;Z;T;constructor(x,I,p,T){this.X=m("x",x),this.Y=m("y",I),this.Z=m("z",p,!0),this.T=m("t",T),Object.freeze(this)}static CURVE(){return f}static fromAffine(x){if(x instanceof g)throw new Error("extended point not allowed");let{x:I,y:p}=x||{};return m("x",I),m("y",p),new g(I,p,z,s(I*p))}static fromBytes(x,I=!1){let p=n.BYTES,{a:T,d:Z}=f;x=Wt(N(x,p,"point")),at(I,"zip215");let V=Wt(x),M=x[p-1];V[p-1]=M&-129;let w=wt(V),b=I?c:n.ORDER;Dt("point.y",w,mt,b);let q=s(w*w),D=s(q-z),R=s(Z*q-T),{isValid:d,value:u}=l(D,R);if(!d)throw new Error("bad point: invalid y coordinate");let a=(u&z)===z,y=(M&128)!==0;if(!I&&u===mt&&y)throw new Error("bad point: x=0 and x_0=1");return y!==a&&(u=s(-u)),g.fromAffine({x:u,y:w})}static fromHex(x,I=!1){return g.fromBytes(nt(x),I)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(x=8,I=!0){return L.createCache(this,x),I||this.multiply(Re),this}assertValidity(){E(this)}equals(x){h(x);let{X:I,Y:p,Z:T}=this,{X:Z,Y:V,Z:M}=x,w=s(I*M),b=s(Z*T),q=s(p*M),D=s(V*T);return w===b&&q===D}is0(){return this.equals(g.ZERO)}negate(){return new g(s(-this.X),this.Y,this.Z,s(-this.T))}double(){let{a:x}=f,{X:I,Y:p,Z:T}=this,Z=s(I*I),V=s(p*p),M=s(Re*s(T*T)),w=s(x*Z),b=I+p,q=s(s(b*b)-Z-V),D=w+V,R=D-M,d=w-V,u=s(q*R),a=s(D*d),y=s(q*d),S=s(R*D);return new g(u,a,S,y)}add(x){h(x);let{a:I,d:p}=f,{X:T,Y:Z,Z:V,T:M}=this,{X:w,Y:b,Z:q,T:D}=x,R=s(T*w),d=s(Z*b),u=s(M*p*D),a=s(V*q),y=s((T+Z)*(w+b)-R-d),S=a-u,A=a+u,O=s(d-I*R),_=s(y*S),H=s(A*O),U=s(y*O),X=s(S*A);return new g(_,H,X,U)}subtract(x){return this.add(x.negate())}multiply(x){if(!o.isValidNot0(x))throw new Error("invalid scalar: expected 1 <= sc < curve.n");let{p:I,f:p}=L.cached(this,x,T=>vt(g,T));return vt(g,[I,p])[0]}multiplyUnsafe(x,I=g.ZERO){if(!o.isValid(x))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return x===mt?g.ZERO:this.is0()||x===z?this:L.unsafe(this,x,p=>vt(g,p),I)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}isTorsionFree(){return L.unsafe(this,f.n).is0()}toAffine(x){return B(this,x)}clearCofactor(){return i===z?this:this.multiplyUnsafe(i)}toBytes(){let{x,y:I}=this.toAffine(),p=n.toBytes(I);return p[p.length-1]|=x&z?128:0,p}toHex(){return et(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let L=new Ht(g,o.BITS);return g.BASE.precompute(8),g}function wn(e,t,r={}){if(typeof t!="function")throw new Error('"hash" function param is required');bt(r,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});let{prehash:n}=r,{BASE:o,Fp:f,Fn:i}=e,c=r.randomBytes||_t,s=r.adjustScalarBytes||(w=>w),l=r.domain||((w,b,q)=>{if(at(q,"phflag"),b.length||q)throw new Error("Contexts/pre-hash are not supported");return w});function m(w){return i.create(wt(w))}function h(w){let b=p.secretKey;N(w,p.secretKey,"secretKey");let q=N(t(w),2*b,"hashedSecretKey"),D=s(q.slice(0,b)),R=q.slice(b,2*b),d=m(D);return{head:D,prefix:R,scalar:d}}function B(w){let{head:b,prefix:q,scalar:D}=h(w),R=o.multiply(D),d=R.toBytes();return{head:b,prefix:q,scalar:D,point:R,pointBytes:d}}function E(w){return B(w).pointBytes}function g(w=Uint8Array.of(),...b){let q=F(...b);return m(t(l(q,N(w,void 0,"context"),!!n)))}function L(w,b,q={}){w=N(w,void 0,"message"),n&&(w=n(w));let{prefix:D,scalar:R,pointBytes:d}=B(b),u=g(q.context,D,w),a=o.multiply(u).toBytes(),y=g(q.context,a,d,w),S=i.create(u+y*R);if(!i.isValid(S))throw new Error("sign failed: invalid s");let A=F(a,i.toBytes(S));return N(A,p.signature,"result")}let v={zip215:!0};function x(w,b,q,D=v){let{context:R,zip215:d}=D,u=p.signature;w=N(w,u,"signature"),b=N(b,void 0,"message"),q=N(q,p.publicKey,"publicKey"),d!==void 0&&at(d,"zip215"),n&&(b=n(b));let a=u/2,y=w.subarray(0,a),S=wt(w.subarray(a,u)),A,O,_;try{A=e.fromBytes(q,d),O=e.fromBytes(y,d),_=o.multiplyUnsafe(S)}catch{return!1}if(!d&&A.isSmallOrder())return!1;let H=g(R,O.toBytes(),A.toBytes(),b);return O.add(A.multiplyUnsafe(H)).subtract(_).clearCofactor().is0()}let I=f.BYTES,p={secretKey:I,publicKey:I,signature:2*I,seed:I};function T(w=c(p.seed)){return N(w,p.seed,"seed")}function Z(w){return pt(w)&&w.length===i.BYTES}function V(w,b){try{return!!e.fromBytes(w,b)}catch{return!1}}let M={getExtendedPublicKey:B,randomSecretKey:T,isValidSecretKey:Z,isValidPublicKey:V,toMontgomery(w){let{y:b}=e.fromBytes(w),q=p.publicKey,D=q===32;if(!D&&q!==57)throw new Error("only defined for 25519 and 448");let R=D?f.div(z+b,z-b):f.div(b-z,b+z);return f.toBytes(R)},toMontgomerySecret(w){let b=p.secretKey;N(w,b);let q=t(w.subarray(0,b));return s(q).subarray(0,b)}};return Object.freeze({keygen:$t(T,E),getPublicKey:E,sign:L,verify:x,utils:M,Point:e,lengths:p})}var er=BigInt(1),En=BigInt(2);var nr=BigInt(5),rr=BigInt(8),Oe=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),or={p:Oe,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:rr,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function fr(e){let t=BigInt(10),r=BigInt(20),n=BigInt(40),o=BigInt(80),f=Oe,c=e*e%f*e%f,s=k(c,En,f)*c%f,l=k(s,er,f)*e%f,m=k(l,nr,f)*l%f,h=k(m,t,f)*m%f,B=k(h,r,f)*h%f,E=k(B,n,f)*B%f,g=k(E,o,f)*E%f,L=k(g,o,f)*E%f,v=k(L,t,f)*m%f;return{pow_p_5_8:k(v,En,f)*e%f,b2:c}}function sr(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}var Bn=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function ir(e,t){let r=Oe,n=j(t*t*t,r),o=j(n*n*t,r),f=fr(e*o).pow_p_5_8,i=j(e*n*f,r),c=j(t*i*i,r),s=i,l=j(i*Bn,r),m=c===e,h=c===j(-e,r),B=c===j(-e*Bn,r);return m&&(i=s),(h||B)&&(i=l),on(i,r)&&(i=j(-i,r)),{isValid:m||h,value:i}}var cr=yn(or,{uvRatio:ir});function ar(e){return wn(cr,ae,Object.assign({adjustScalarBytes:sr},e))}var vn=ar({});var dr={p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")};var ur=Jt(dr),Sn=Ft(ur,Gt);return Hn(lr);})();
12−/*! Bundled license information:
13−
14−@noble/hashes/utils.js:
15− (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
16−
17−@noble/curves/utils.js:
18−@noble/curves/abstract/modular.js:
19−@noble/curves/abstract/curve.js:
20−@noble/curves/abstract/weierstrass.js:
21−@noble/curves/secp256k1.js:
22−@noble/curves/abstract/edwards.js:
23−@noble/curves/ed25519.js:
24−@noble/curves/nist.js:
25− (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
26−*/
27−
28−
29−// UTILS
8+// TWEETNACL BUNDLE (https://github.com/nicolo-ribaudo/tweetnacl-js, Unlicense)
9+// Embedded: tweetnacl 1.0.3 - Ed25519, X25519, XSalsa20-Poly1305
3010
31−var _Crypto_toHex = _Crypto_noble.bytesToHex;
32−var _Crypto_fromHex = _Crypto_noble.hexToBytes;
11+var _Crypto_nacl={};(function(i){"use strict";var v=function(r){var t,n=new Float64Array(16);if(r)for(t=0;t<r.length;t++)n[t]=r[t];return n},h=function(){throw new Error("no PRNG")},o=new Uint8Array(16),n=new Uint8Array(32);n[0]=9;var s=v(),u=v([1]),p=v([56129,1]),c=v([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),y=v([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),e=v([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),a=v([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),l=v([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function f(r,t,n,e){r[t]=n>>24&255,r[t+1]=n>>16&255,r[t+2]=n>>8&255,r[t+3]=255&n,r[t+4]=e>>24&255,r[t+5]=e>>16&255,r[t+6]=e>>8&255,r[t+7]=255&e}function w(r,t,n,e,o){var i,h=0;for(i=0;i<o;i++)h|=r[t+i]^n[e+i];return(1&h-1>>>8)-1}function b(r,t,n,e){return w(r,t,n,e,16)}function g(r,t,n,e){return w(r,t,n,e,32)}function A(r,t,n,e){!function(r,t,n,e){for(var o,i=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,h=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,f=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,s=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,c=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,y=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,l=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,w=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,v=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,p=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,b=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,g=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,A=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,_=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,U=i,d=h,E=a,x=f,M=s,m=u,B=c,S=y,k=l,K=w,Y=v,L=p,T=b,z=g,R=A,P=_,N=0;N<20;N+=2)U^=(o=(T^=(o=(k^=(o=(M^=(o=U+T|0)<<7|o>>>25)+U|0)<<9|o>>>23)+M|0)<<13|o>>>19)+k|0)<<18|o>>>14,m^=(o=(d^=(o=(z^=(o=(K^=(o=m+d|0)<<7|o>>>25)+m|0)<<9|o>>>23)+K|0)<<13|o>>>19)+z|0)<<18|o>>>14,Y^=(o=(B^=(o=(E^=(o=(R^=(o=Y+B|0)<<7|o>>>25)+Y|0)<<9|o>>>23)+R|0)<<13|o>>>19)+E|0)<<18|o>>>14,P^=(o=(L^=(o=(S^=(o=(x^=(o=P+L|0)<<7|o>>>25)+P|0)<<9|o>>>23)+x|0)<<13|o>>>19)+S|0)<<18|o>>>14,U^=(o=(x^=(o=(E^=(o=(d^=(o=U+x|0)<<7|o>>>25)+U|0)<<9|o>>>23)+d|0)<<13|o>>>19)+E|0)<<18|o>>>14,m^=(o=(M^=(o=(S^=(o=(B^=(o=m+M|0)<<7|o>>>25)+m|0)<<9|o>>>23)+B|0)<<13|o>>>19)+S|0)<<18|o>>>14,Y^=(o=(K^=(o=(k^=(o=(L^=(o=Y+K|0)<<7|o>>>25)+Y|0)<<9|o>>>23)+L|0)<<13|o>>>19)+k|0)<<18|o>>>14,P^=(o=(R^=(o=(z^=(o=(T^=(o=P+R|0)<<7|o>>>25)+P|0)<<9|o>>>23)+T|0)<<13|o>>>19)+z|0)<<18|o>>>14;U=U+i|0,d=d+h|0,E=E+a|0,x=x+f|0,M=M+s|0,m=m+u|0,B=B+c|0,S=S+y|0,k=k+l|0,K=K+w|0,Y=Y+v|0,L=L+p|0,T=T+b|0,z=z+g|0,R=R+A|0,P=P+_|0,r[0]=U>>>0&255,r[1]=U>>>8&255,r[2]=U>>>16&255,r[3]=U>>>24&255,r[4]=d>>>0&255,r[5]=d>>>8&255,r[6]=d>>>16&255,r[7]=d>>>24&255,r[8]=E>>>0&255,r[9]=E>>>8&255,r[10]=E>>>16&255,r[11]=E>>>24&255,r[12]=x>>>0&255,r[13]=x>>>8&255,r[14]=x>>>16&255,r[15]=x>>>24&255,r[16]=M>>>0&255,r[17]=M>>>8&255,r[18]=M>>>16&255,r[19]=M>>>24&255,r[20]=m>>>0&255,r[21]=m>>>8&255,r[22]=m>>>16&255,r[23]=m>>>24&255,r[24]=B>>>0&255,r[25]=B>>>8&255,r[26]=B>>>16&255,r[27]=B>>>24&255,r[28]=S>>>0&255,r[29]=S>>>8&255,r[30]=S>>>16&255,r[31]=S>>>24&255,r[32]=k>>>0&255,r[33]=k>>>8&255,r[34]=k>>>16&255,r[35]=k>>>24&255,r[36]=K>>>0&255,r[37]=K>>>8&255,r[38]=K>>>16&255,r[39]=K>>>24&255,r[40]=Y>>>0&255,r[41]=Y>>>8&255,r[42]=Y>>>16&255,r[43]=Y>>>24&255,r[44]=L>>>0&255,r[45]=L>>>8&255,r[46]=L>>>16&255,r[47]=L>>>24&255,r[48]=T>>>0&255,r[49]=T>>>8&255,r[50]=T>>>16&255,r[51]=T>>>24&255,r[52]=z>>>0&255,r[53]=z>>>8&255,r[54]=z>>>16&255,r[55]=z>>>24&255,r[56]=R>>>0&255,r[57]=R>>>8&255,r[58]=R>>>16&255,r[59]=R>>>24&255,r[60]=P>>>0&255,r[61]=P>>>8&255,r[62]=P>>>16&255,r[63]=P>>>24&255}(r,t,n,e)}function _(r,t,n,e){!function(r,t,n,e){for(var o,i=255&e[0]|(255&e[1])<<8|(255&e[2])<<16|(255&e[3])<<24,h=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,a=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,f=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,s=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,u=255&e[4]|(255&e[5])<<8|(255&e[6])<<16|(255&e[7])<<24,c=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,y=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,l=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,w=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,v=255&e[8]|(255&e[9])<<8|(255&e[10])<<16|(255&e[11])<<24,p=255&n[16]|(255&n[17])<<8|(255&n[18])<<16|(255&n[19])<<24,b=255&n[20]|(255&n[21])<<8|(255&n[22])<<16|(255&n[23])<<24,g=255&n[24]|(255&n[25])<<8|(255&n[26])<<16|(255&n[27])<<24,A=255&n[28]|(255&n[29])<<8|(255&n[30])<<16|(255&n[31])<<24,_=255&e[12]|(255&e[13])<<8|(255&e[14])<<16|(255&e[15])<<24,U=0;U<20;U+=2)i^=(o=(b^=(o=(l^=(o=(s^=(o=i+b|0)<<7|o>>>25)+i|0)<<9|o>>>23)+s|0)<<13|o>>>19)+l|0)<<18|o>>>14,u^=(o=(h^=(o=(g^=(o=(w^=(o=u+h|0)<<7|o>>>25)+u|0)<<9|o>>>23)+w|0)<<13|o>>>19)+g|0)<<18|o>>>14,v^=(o=(c^=(o=(a^=(o=(A^=(o=v+c|0)<<7|o>>>25)+v|0)<<9|o>>>23)+A|0)<<13|o>>>19)+a|0)<<18|o>>>14,_^=(o=(p^=(o=(y^=(o=(f^=(o=_+p|0)<<7|o>>>25)+_|0)<<9|o>>>23)+f|0)<<13|o>>>19)+y|0)<<18|o>>>14,i^=(o=(f^=(o=(a^=(o=(h^=(o=i+f|0)<<7|o>>>25)+i|0)<<9|o>>>23)+h|0)<<13|o>>>19)+a|0)<<18|o>>>14,u^=(o=(s^=(o=(y^=(o=(c^=(o=u+s|0)<<7|o>>>25)+u|0)<<9|o>>>23)+c|0)<<13|o>>>19)+y|0)<<18|o>>>14,v^=(o=(w^=(o=(l^=(o=(p^=(o=v+w|0)<<7|o>>>25)+v|0)<<9|o>>>23)+p|0)<<13|o>>>19)+l|0)<<18|o>>>14,_^=(o=(A^=(o=(g^=(o=(b^=(o=_+A|0)<<7|o>>>25)+_|0)<<9|o>>>23)+b|0)<<13|o>>>19)+g|0)<<18|o>>>14;r[0]=i>>>0&255,r[1]=i>>>8&255,r[2]=i>>>16&255,r[3]=i>>>24&255,r[4]=u>>>0&255,r[5]=u>>>8&255,r[6]=u>>>16&255,r[7]=u>>>24&255,r[8]=v>>>0&255,r[9]=v>>>8&255,r[10]=v>>>16&255,r[11]=v>>>24&255,r[12]=_>>>0&255,r[13]=_>>>8&255,r[14]=_>>>16&255,r[15]=_>>>24&255,r[16]=c>>>0&255,r[17]=c>>>8&255,r[18]=c>>>16&255,r[19]=c>>>24&255,r[20]=y>>>0&255,r[21]=y>>>8&255,r[22]=y>>>16&255,r[23]=y>>>24&255,r[24]=l>>>0&255,r[25]=l>>>8&255,r[26]=l>>>16&255,r[27]=l>>>24&255,r[28]=w>>>0&255,r[29]=w>>>8&255,r[30]=w>>>16&255,r[31]=w>>>24&255}(r,t,n,e)}var U=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function d(r,t,n,e,o,i,h){var a,f,s=new Uint8Array(16),u=new Uint8Array(64);for(f=0;f<16;f++)s[f]=0;for(f=0;f<8;f++)s[f]=i[f];for(;64<=o;){for(A(u,s,h,U),f=0;f<64;f++)r[t+f]=n[e+f]^u[f];for(a=1,f=8;f<16;f++)a=a+(255&s[f])|0,s[f]=255&a,a>>>=8;o-=64,t+=64,e+=64}if(0<o)for(A(u,s,h,U),f=0;f<o;f++)r[t+f]=n[e+f]^u[f];return 0}function E(r,t,n,e,o){var i,h,a=new Uint8Array(16),f=new Uint8Array(64);for(h=0;h<16;h++)a[h]=0;for(h=0;h<8;h++)a[h]=e[h];for(;64<=n;){for(A(f,a,o,U),h=0;h<64;h++)r[t+h]=f[h];for(i=1,h=8;h<16;h++)i=i+(255&a[h])|0,a[h]=255&i,i>>>=8;n-=64,t+=64}if(0<n)for(A(f,a,o,U),h=0;h<n;h++)r[t+h]=f[h];return 0}function x(r,t,n,e,o){var i=new Uint8Array(32);_(i,e,o,U);for(var h=new Uint8Array(8),a=0;a<8;a++)h[a]=e[a+16];return E(r,t,n,h,i)}function M(r,t,n,e,o,i,h){var a=new Uint8Array(32);_(a,i,h,U);for(var f=new Uint8Array(8),s=0;s<8;s++)f[s]=i[s+16];return d(r,t,n,e,o,f,a)}var m=function(r){var t,n,e,o,i,h,a,f;this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,t=255&r[this.fin=0]|(255&r[1])<<8,this.r[0]=8191&t,n=255&r[2]|(255&r[3])<<8,this.r[1]=8191&(t>>>13|n<<3),e=255&r[4]|(255&r[5])<<8,this.r[2]=7939&(n>>>10|e<<6),o=255&r[6]|(255&r[7])<<8,this.r[3]=8191&(e>>>7|o<<9),i=255&r[8]|(255&r[9])<<8,this.r[4]=255&(o>>>4|i<<12),this.r[5]=i>>>1&8190,h=255&r[10]|(255&r[11])<<8,this.r[6]=8191&(i>>>14|h<<2),a=255&r[12]|(255&r[13])<<8,this.r[7]=8065&(h>>>11|a<<5),f=255&r[14]|(255&r[15])<<8,this.r[8]=8191&(a>>>8|f<<8),this.r[9]=f>>>5&127,this.pad[0]=255&r[16]|(255&r[17])<<8,this.pad[1]=255&r[18]|(255&r[19])<<8,this.pad[2]=255&r[20]|(255&r[21])<<8,this.pad[3]=255&r[22]|(255&r[23])<<8,this.pad[4]=255&r[24]|(255&r[25])<<8,this.pad[5]=255&r[26]|(255&r[27])<<8,this.pad[6]=255&r[28]|(255&r[29])<<8,this.pad[7]=255&r[30]|(255&r[31])<<8};function B(r,t,n,e,o,i){var h=new m(i);return h.update(n,e,o),h.finish(r,t),0}function S(r,t,n,e,o,i){var h=new Uint8Array(16);return B(h,0,n,e,o,i),b(r,t,h,0)}function k(r,t,n,e,o){var i;if(n<32)return-1;for(M(r,0,t,0,n,e,o),B(r,16,r,32,n-32,r),i=0;i<16;i++)r[i]=0;return 0}function K(r,t,n,e,o){var i,h=new Uint8Array(32);if(n<32)return-1;if(x(h,0,32,e,o),0!==S(t,16,t,32,n-32,h))return-1;for(M(r,0,t,0,n,e,o),i=0;i<32;i++)r[i]=0;return 0}function Y(r,t){var n;for(n=0;n<16;n++)r[n]=0|t[n]}function L(r){var t,n,e=1;for(t=0;t<16;t++)n=r[t]+e+65535,e=Math.floor(n/65536),r[t]=n-65536*e;r[0]+=e-1+37*(e-1)}function T(r,t,n){for(var e,o=~(n-1),i=0;i<16;i++)e=o&(r[i]^t[i]),r[i]^=e,t[i]^=e}function z(r,t){var n,e,o,i=v(),h=v();for(n=0;n<16;n++)h[n]=t[n];for(L(h),L(h),L(h),e=0;e<2;e++){for(i[0]=h[0]-65517,n=1;n<15;n++)i[n]=h[n]-65535-(i[n-1]>>16&1),i[n-1]&=65535;i[15]=h[15]-32767-(i[14]>>16&1),o=i[15]>>16&1,i[14]&=65535,T(h,i,1-o)}for(n=0;n<16;n++)r[2*n]=255&h[n],r[2*n+1]=h[n]>>8}function R(r,t){var n=new Uint8Array(32),e=new Uint8Array(32);return z(n,r),z(e,t),g(n,0,e,0)}function P(r){var t=new Uint8Array(32);return z(t,r),1&t[0]}function N(r,t){var n;for(n=0;n<16;n++)r[n]=t[2*n]+(t[2*n+1]<<8);r[15]&=32767}function O(r,t,n){for(var e=0;e<16;e++)r[e]=t[e]+n[e]}function C(r,t,n){for(var e=0;e<16;e++)r[e]=t[e]-n[e]}function F(r,t,n){var e,o,i=0,h=0,a=0,f=0,s=0,u=0,c=0,y=0,l=0,w=0,v=0,p=0,b=0,g=0,A=0,_=0,U=0,d=0,E=0,x=0,M=0,m=0,B=0,S=0,k=0,K=0,Y=0,L=0,T=0,z=0,R=0,P=n[0],N=n[1],O=n[2],C=n[3],F=n[4],I=n[5],Z=n[6],G=n[7],q=n[8],D=n[9],V=n[10],X=n[11],j=n[12],H=n[13],J=n[14],Q=n[15];i+=(e=t[0])*P,h+=e*N,a+=e*O,f+=e*C,s+=e*F,u+=e*I,c+=e*Z,y+=e*G,l+=e*q,w+=e*D,v+=e*V,p+=e*X,b+=e*j,g+=e*H,A+=e*J,_+=e*Q,h+=(e=t[1])*P,a+=e*N,f+=e*O,s+=e*C,u+=e*F,c+=e*I,y+=e*Z,l+=e*G,w+=e*q,v+=e*D,p+=e*V,b+=e*X,g+=e*j,A+=e*H,_+=e*J,U+=e*Q,a+=(e=t[2])*P,f+=e*N,s+=e*O,u+=e*C,c+=e*F,y+=e*I,l+=e*Z,w+=e*G,v+=e*q,p+=e*D,b+=e*V,g+=e*X,A+=e*j,_+=e*H,U+=e*J,d+=e*Q,f+=(e=t[3])*P,s+=e*N,u+=e*O,c+=e*C,y+=e*F,l+=e*I,w+=e*Z,v+=e*G,p+=e*q,b+=e*D,g+=e*V,A+=e*X,_+=e*j,U+=e*H,d+=e*J,E+=e*Q,s+=(e=t[4])*P,u+=e*N,c+=e*O,y+=e*C,l+=e*F,w+=e*I,v+=e*Z,p+=e*G,b+=e*q,g+=e*D,A+=e*V,_+=e*X,U+=e*j,d+=e*H,E+=e*J,x+=e*Q,u+=(e=t[5])*P,c+=e*N,y+=e*O,l+=e*C,w+=e*F,v+=e*I,p+=e*Z,b+=e*G,g+=e*q,A+=e*D,_+=e*V,U+=e*X,d+=e*j,E+=e*H,x+=e*J,M+=e*Q,c+=(e=t[6])*P,y+=e*N,l+=e*O,w+=e*C,v+=e*F,p+=e*I,b+=e*Z,g+=e*G,A+=e*q,_+=e*D,U+=e*V,d+=e*X,E+=e*j,x+=e*H,M+=e*J,m+=e*Q,y+=(e=t[7])*P,l+=e*N,w+=e*O,v+=e*C,p+=e*F,b+=e*I,g+=e*Z,A+=e*G,_+=e*q,U+=e*D,d+=e*V,E+=e*X,x+=e*j,M+=e*H,m+=e*J,B+=e*Q,l+=(e=t[8])*P,w+=e*N,v+=e*O,p+=e*C,b+=e*F,g+=e*I,A+=e*Z,_+=e*G,U+=e*q,d+=e*D,E+=e*V,x+=e*X,M+=e*j,m+=e*H,B+=e*J,S+=e*Q,w+=(e=t[9])*P,v+=e*N,p+=e*O,b+=e*C,g+=e*F,A+=e*I,_+=e*Z,U+=e*G,d+=e*q,E+=e*D,x+=e*V,M+=e*X,m+=e*j,B+=e*H,S+=e*J,k+=e*Q,v+=(e=t[10])*P,p+=e*N,b+=e*O,g+=e*C,A+=e*F,_+=e*I,U+=e*Z,d+=e*G,E+=e*q,x+=e*D,M+=e*V,m+=e*X,B+=e*j,S+=e*H,k+=e*J,K+=e*Q,p+=(e=t[11])*P,b+=e*N,g+=e*O,A+=e*C,_+=e*F,U+=e*I,d+=e*Z,E+=e*G,x+=e*q,M+=e*D,m+=e*V,B+=e*X,S+=e*j,k+=e*H,K+=e*J,Y+=e*Q,b+=(e=t[12])*P,g+=e*N,A+=e*O,_+=e*C,U+=e*F,d+=e*I,E+=e*Z,x+=e*G,M+=e*q,m+=e*D,B+=e*V,S+=e*X,k+=e*j,K+=e*H,Y+=e*J,L+=e*Q,g+=(e=t[13])*P,A+=e*N,_+=e*O,U+=e*C,d+=e*F,E+=e*I,x+=e*Z,M+=e*G,m+=e*q,B+=e*D,S+=e*V,k+=e*X,K+=e*j,Y+=e*H,L+=e*J,T+=e*Q,A+=(e=t[14])*P,_+=e*N,U+=e*O,d+=e*C,E+=e*F,x+=e*I,M+=e*Z,m+=e*G,B+=e*q,S+=e*D,k+=e*V,K+=e*X,Y+=e*j,L+=e*H,T+=e*J,z+=e*Q,_+=(e=t[15])*P,h+=38*(d+=e*O),a+=38*(E+=e*C),f+=38*(x+=e*F),s+=38*(M+=e*I),u+=38*(m+=e*Z),c+=38*(B+=e*G),y+=38*(S+=e*q),l+=38*(k+=e*D),w+=38*(K+=e*V),v+=38*(Y+=e*X),p+=38*(L+=e*j),b+=38*(T+=e*H),g+=38*(z+=e*J),A+=38*(R+=e*Q),i=(e=(i+=38*(U+=e*N))+(o=1)+65535)-65536*(o=Math.floor(e/65536)),h=(e=h+o+65535)-65536*(o=Math.floor(e/65536)),a=(e=a+o+65535)-65536*(o=Math.floor(e/65536)),f=(e=f+o+65535)-65536*(o=Math.floor(e/65536)),s=(e=s+o+65535)-65536*(o=Math.floor(e/65536)),u=(e=u+o+65535)-65536*(o=Math.floor(e/65536)),c=(e=c+o+65535)-65536*(o=Math.floor(e/65536)),y=(e=y+o+65535)-65536*(o=Math.floor(e/65536)),l=(e=l+o+65535)-65536*(o=Math.floor(e/65536)),w=(e=w+o+65535)-65536*(o=Math.floor(e/65536)),v=(e=v+o+65535)-65536*(o=Math.floor(e/65536)),p=(e=p+o+65535)-65536*(o=Math.floor(e/65536)),b=(e=b+o+65535)-65536*(o=Math.floor(e/65536)),g=(e=g+o+65535)-65536*(o=Math.floor(e/65536)),A=(e=A+o+65535)-65536*(o=Math.floor(e/65536)),_=(e=_+o+65535)-65536*(o=Math.floor(e/65536)),i=(e=(i+=o-1+37*(o-1))+(o=1)+65535)-65536*(o=Math.floor(e/65536)),h=(e=h+o+65535)-65536*(o=Math.floor(e/65536)),a=(e=a+o+65535)-65536*(o=Math.floor(e/65536)),f=(e=f+o+65535)-65536*(o=Math.floor(e/65536)),s=(e=s+o+65535)-65536*(o=Math.floor(e/65536)),u=(e=u+o+65535)-65536*(o=Math.floor(e/65536)),c=(e=c+o+65535)-65536*(o=Math.floor(e/65536)),y=(e=y+o+65535)-65536*(o=Math.floor(e/65536)),l=(e=l+o+65535)-65536*(o=Math.floor(e/65536)),w=(e=w+o+65535)-65536*(o=Math.floor(e/65536)),v=(e=v+o+65535)-65536*(o=Math.floor(e/65536)),p=(e=p+o+65535)-65536*(o=Math.floor(e/65536)),b=(e=b+o+65535)-65536*(o=Math.floor(e/65536)),g=(e=g+o+65535)-65536*(o=Math.floor(e/65536)),A=(e=A+o+65535)-65536*(o=Math.floor(e/65536)),_=(e=_+o+65535)-65536*(o=Math.floor(e/65536)),i+=o-1+37*(o-1),r[0]=i,r[1]=h,r[2]=a,r[3]=f,r[4]=s,r[5]=u,r[6]=c,r[7]=y,r[8]=l,r[9]=w,r[10]=v,r[11]=p,r[12]=b,r[13]=g,r[14]=A,r[15]=_}function I(r,t){F(r,t,t)}function Z(r,t){var n,e=v();for(n=0;n<16;n++)e[n]=t[n];for(n=253;0<=n;n--)I(e,e),2!==n&&4!==n&&F(e,e,t);for(n=0;n<16;n++)r[n]=e[n]}function G(r,t){var n,e=v();for(n=0;n<16;n++)e[n]=t[n];for(n=250;0<=n;n--)I(e,e),1!==n&&F(e,e,t);for(n=0;n<16;n++)r[n]=e[n]}function q(r,t,n){var e,o,i=new Uint8Array(32),h=new Float64Array(80),a=v(),f=v(),s=v(),u=v(),c=v(),y=v();for(o=0;o<31;o++)i[o]=t[o];for(i[31]=127&t[31]|64,i[0]&=248,N(h,n),o=0;o<16;o++)f[o]=h[o],u[o]=a[o]=s[o]=0;for(a[0]=u[0]=1,o=254;0<=o;--o)T(a,f,e=i[o>>>3]>>>(7&o)&1),T(s,u,e),O(c,a,s),C(a,a,s),O(s,f,u),C(f,f,u),I(u,c),I(y,a),F(a,s,a),F(s,f,c),O(c,a,s),C(a,a,s),I(f,a),C(s,u,y),F(a,s,p),O(a,a,u),F(s,s,a),F(a,u,y),F(u,f,h),I(f,c),T(a,f,e),T(s,u,e);for(o=0;o<16;o++)h[o+16]=a[o],h[o+32]=s[o],h[o+48]=f[o],h[o+64]=u[o];var l=h.subarray(32),w=h.subarray(16);return Z(l,l),F(w,w,l),z(r,w),0}function D(r,t){return q(r,t,n)}function V(r,t){return h(t,32),D(r,t)}function X(r,t,n){var e=new Uint8Array(32);return q(e,n,t),_(r,o,e,U)}m.prototype.blocks=function(r,t,n){for(var e,o,i,h,a,f,s,u,c,y,l,w,v,p,b,g,A,_,U,d=this.fin?0:2048,E=this.h[0],x=this.h[1],M=this.h[2],m=this.h[3],B=this.h[4],S=this.h[5],k=this.h[6],K=this.h[7],Y=this.h[8],L=this.h[9],T=this.r[0],z=this.r[1],R=this.r[2],P=this.r[3],N=this.r[4],O=this.r[5],C=this.r[6],F=this.r[7],I=this.r[8],Z=this.r[9];16<=n;)y=c=0,y+=(E+=8191&(e=255&r[t+0]|(255&r[t+1])<<8))*T,y+=(x+=8191&(e>>>13|(o=255&r[t+2]|(255&r[t+3])<<8)<<3))*(5*Z),y+=(M+=8191&(o>>>10|(i=255&r[t+4]|(255&r[t+5])<<8)<<6))*(5*I),y+=(m+=8191&(i>>>7|(h=255&r[t+6]|(255&r[t+7])<<8)<<9))*(5*F),c=(y+=(B+=8191&(h>>>4|(a=255&r[t+8]|(255&r[t+9])<<8)<<12))*(5*C))>>>13,y&=8191,y+=(S+=a>>>1&8191)*(5*O),y+=(k+=8191&(a>>>14|(f=255&r[t+10]|(255&r[t+11])<<8)<<2))*(5*N),y+=(K+=8191&(f>>>11|(s=255&r[t+12]|(255&r[t+13])<<8)<<5))*(5*P),y+=(Y+=8191&(s>>>8|(u=255&r[t+14]|(255&r[t+15])<<8)<<8))*(5*R),l=c+=(y+=(L+=u>>>5|d)*(5*z))>>>13,l+=E*z,l+=x*T,l+=M*(5*Z),l+=m*(5*I),c=(l+=B*(5*F))>>>13,l&=8191,l+=S*(5*C),l+=k*(5*O),l+=K*(5*N),l+=Y*(5*P),c+=(l+=L*(5*R))>>>13,l&=8191,w=c,w+=E*R,w+=x*z,w+=M*T,w+=m*(5*Z),c=(w+=B*(5*I))>>>13,w&=8191,w+=S*(5*F),w+=k*(5*C),w+=K*(5*O),w+=Y*(5*N),v=c+=(w+=L*(5*P))>>>13,v+=E*P,v+=x*R,v+=M*z,v+=m*T,c=(v+=B*(5*Z))>>>13,v&=8191,v+=S*(5*I),v+=k*(5*F),v+=K*(5*C),v+=Y*(5*O),p=c+=(v+=L*(5*N))>>>13,p+=E*N,p+=x*P,p+=M*R,p+=m*z,c=(p+=B*T)>>>13,p&=8191,p+=S*(5*Z),p+=k*(5*I),p+=K*(5*F),p+=Y*(5*C),b=c+=(p+=L*(5*O))>>>13,b+=E*O,b+=x*N,b+=M*P,b+=m*R,c=(b+=B*z)>>>13,b&=8191,b+=S*T,b+=k*(5*Z),b+=K*(5*I),b+=Y*(5*F),g=c+=(b+=L*(5*C))>>>13,g+=E*C,g+=x*O,g+=M*N,g+=m*P,c=(g+=B*R)>>>13,g&=8191,g+=S*z,g+=k*T,g+=K*(5*Z),g+=Y*(5*I),A=c+=(g+=L*(5*F))>>>13,A+=E*F,A+=x*C,A+=M*O,A+=m*N,c=(A+=B*P)>>>13,A&=8191,A+=S*R,A+=k*z,A+=K*T,A+=Y*(5*Z),_=c+=(A+=L*(5*I))>>>13,_+=E*I,_+=x*F,_+=M*C,_+=m*O,c=(_+=B*N)>>>13,_&=8191,_+=S*P,_+=k*R,_+=K*z,_+=Y*T,U=c+=(_+=L*(5*Z))>>>13,U+=E*Z,U+=x*I,U+=M*F,U+=m*C,c=(U+=B*O)>>>13,U&=8191,U+=S*N,U+=k*P,U+=K*R,U+=Y*z,E=y=8191&(c=(c=((c+=(U+=L*T)>>>13)<<2)+c|0)+(y&=8191)|0),x=l+=c>>>=13,M=w&=8191,m=v&=8191,B=p&=8191,S=b&=8191,k=g&=8191,K=A&=8191,Y=_&=8191,L=U&=8191,t+=16,n-=16;this.h[0]=E,this.h[1]=x,this.h[2]=M,this.h[3]=m,this.h[4]=B,this.h[5]=S,this.h[6]=k,this.h[7]=K,this.h[8]=Y,this.h[9]=L},m.prototype.finish=function(r,t){var n,e,o,i,h=new Uint16Array(10);if(this.leftover){for(i=this.leftover,this.buffer[i++]=1;i<16;i++)this.buffer[i]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(n=this.h[1]>>>13,this.h[1]&=8191,i=2;i<10;i++)this.h[i]+=n,n=this.h[i]>>>13,this.h[i]&=8191;for(this.h[0]+=5*n,n=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=n,n=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=n,h[0]=this.h[0]+5,n=h[0]>>>13,h[0]&=8191,i=1;i<10;i++)h[i]=this.h[i]+n,n=h[i]>>>13,h[i]&=8191;for(h[9]-=8192,e=(1^n)-1,i=0;i<10;i++)h[i]&=e;for(e=~e,i=0;i<10;i++)this.h[i]=this.h[i]&e|h[i];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),o=this.h[0]+this.pad[0],this.h[0]=65535&o,i=1;i<8;i++)o=(this.h[i]+this.pad[i]|0)+(o>>>16)|0,this.h[i]=65535&o;r[t+0]=this.h[0]>>>0&255,r[t+1]=this.h[0]>>>8&255,r[t+2]=this.h[1]>>>0&255,r[t+3]=this.h[1]>>>8&255,r[t+4]=this.h[2]>>>0&255,r[t+5]=this.h[2]>>>8&255,r[t+6]=this.h[3]>>>0&255,r[t+7]=this.h[3]>>>8&255,r[t+8]=this.h[4]>>>0&255,r[t+9]=this.h[4]>>>8&255,r[t+10]=this.h[5]>>>0&255,r[t+11]=this.h[5]>>>8&255,r[t+12]=this.h[6]>>>0&255,r[t+13]=this.h[6]>>>8&255,r[t+14]=this.h[7]>>>0&255,r[t+15]=this.h[7]>>>8&255},m.prototype.update=function(r,t,n){var e,o;if(this.leftover){for(n<(o=16-this.leftover)&&(o=n),e=0;e<o;e++)this.buffer[this.leftover+e]=r[t+e];if(n-=o,t+=o,this.leftover+=o,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(16<=n&&(o=n-n%16,this.blocks(r,t,o),t+=o,n-=o),n){for(e=0;e<n;e++)this.buffer[this.leftover+e]=r[t+e];this.leftover+=n}};var j=k,H=K;var J=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function Q(r,t,n,e){for(var o,i,h,a,f,s,u,c,y,l,w,v,p,b,g,A,_,U,d,E,x,M,m,B,S=new Int32Array(16),k=new Int32Array(16),K=r[0],Y=r[1],L=r[2],T=r[3],z=r[4],R=r[5],P=r[6],N=r[7],O=t[0],C=t[1],F=t[2],I=t[3],Z=t[4],G=t[5],q=t[6],D=t[7],V=0;128<=e;){for(_=0;_<16;_++)U=8*_+V,S[_]=n[U+0]<<24|n[U+1]<<16|n[U+2]<<8|n[U+3],k[_]=n[U+4]<<24|n[U+5]<<16|n[U+6]<<8|n[U+7];for(_=0;_<80;_++)if(o=Y,i=L,h=T,c=C,y=F,l=I,x=65535&(E=D),M=E>>>16,m=65535&(d=N),B=d>>>16,x+=65535&(E=((w=Z)>>>14|(a=z)<<18)^(Z>>>18|z<<14)^(z>>>9|Z<<23)),M+=E>>>16,m+=65535&(d=(z>>>14|Z<<18)^(z>>>18|Z<<14)^(Z>>>9|z<<23)),B+=d>>>16,x+=65535&(E=Z&(v=G)^~Z&(p=q)),M+=E>>>16,m+=65535&(d=z&(f=R)^~z&(s=P)),B+=d>>>16,d=J[2*_],x+=65535&(E=J[2*_+1]),M+=E>>>16,m+=65535&d,B+=d>>>16,d=S[_%16],M+=(E=k[_%16])>>>16,m+=65535&d,B+=d>>>16,m+=(M+=(x+=65535&E)>>>16)>>>16,x=65535&(E=A=65535&x|M<<16),M=E>>>16,m=65535&(d=g=65535&m|(B+=m>>>16)<<16),B=d>>>16,x+=65535&(E=(O>>>28|K<<4)^(K>>>2|O<<30)^(K>>>7|O<<25)),M+=E>>>16,m+=65535&(d=(K>>>28|O<<4)^(O>>>2|K<<30)^(O>>>7|K<<25)),B+=d>>>16,M+=(E=O&C^O&F^C&F)>>>16,m+=65535&(d=K&Y^K&L^Y&L),B+=d>>>16,u=65535&(m+=(M+=(x+=65535&E)>>>16)>>>16)|(B+=m>>>16)<<16,b=65535&x|M<<16,x=65535&(E=l),M=E>>>16,m=65535&(d=h),B=d>>>16,M+=(E=A)>>>16,m+=65535&(d=g),B+=d>>>16,Y=K,L=o,T=i,z=h=65535&(m+=(M+=(x+=65535&E)>>>16)>>>16)|(B+=m>>>16)<<16,R=a,P=f,N=s,K=u,C=O,F=c,I=y,Z=l=65535&x|M<<16,G=w,q=v,D=p,O=b,_%16==15)for(U=0;U<16;U++)d=S[U],x=65535&(E=k[U]),M=E>>>16,m=65535&d,B=d>>>16,d=S[(U+9)%16],x+=65535&(E=k[(U+9)%16]),M+=E>>>16,m+=65535&d,B+=d>>>16,g=S[(U+1)%16],x+=65535&(E=((A=k[(U+1)%16])>>>1|g<<31)^(A>>>8|g<<24)^(A>>>7|g<<25)),M+=E>>>16,m+=65535&(d=(g>>>1|A<<31)^(g>>>8|A<<24)^g>>>7),B+=d>>>16,g=S[(U+14)%16],M+=(E=((A=k[(U+14)%16])>>>19|g<<13)^(g>>>29|A<<3)^(A>>>6|g<<26))>>>16,m+=65535&(d=(g>>>19|A<<13)^(A>>>29|g<<3)^g>>>6),B+=d>>>16,B+=(m+=(M+=(x+=65535&E)>>>16)>>>16)>>>16,S[U]=65535&m|B<<16,k[U]=65535&x|M<<16;x=65535&(E=O),M=E>>>16,m=65535&(d=K),B=d>>>16,d=r[0],M+=(E=t[0])>>>16,m+=65535&d,B+=d>>>16,B+=(m+=(M+=(x+=65535&E)>>>16)>>>16)>>>16,r[0]=K=65535&m|B<<16,t[0]=O=65535&x|M<<16,x=65535&(E=C),M=E>>>16,m=65535&(d=Y),B=d>>>16,d=r[1],M+=(E=t[1])>>>16,m+=65535&d,B+=d>>>16,B+=(m+=(M+=(x+=65535&E)>>>16)>>>16)>>>16,r[1]=Y=65535&m|B<<16,t[1]=C=65535&x|M<<16,x=65535&(E=F),M=E>>>16,m=65535&(d=L),B=d>>>16,d=r[2],M+=(E=t[2])>>>16,m+=65535&d,B+=d>>>16,B+=(m+=(M+=(x+=65535&E)>>>16)>>>16)>>>16,r[2]=L=65535&m|B<<16,t[2]=F=65535&x|M<<16,x=65535&(E=I),M=E>>>16,m=65535&(d=T),B=d>>>16,d=r[3],M+=(E=t[3])>>>16,m+=65535&d,B+=d>>>16,B+=(m+=(M+=(x+=65535&E)>>>16)>>>16)>>>16,r[3]=T=65535&m|B<<16,t[3]=I=65535&x|M<<16,x=65535&(E=Z),M=E>>>16,m=65535&(d=z),B=d>>>16,d=r[4],M+=(E=t[4])>>>16,m+=65535&d,B+=d>>>16,B+=(m+=(M+=(x+=65535&E)>>>16)>>>16)>>>16,r[4]=z=65535&m|B<<16,t[4]=Z=65535&x|M<<16,x=65535&(E=G),M=E>>>16,m=65535&(d=R),B=d>>>16,d=r[5],M+=(E=t[5])>>>16,m+=65535&d,B+=d>>>16,B+=(m+=(M+=(x+=65535&E)>>>16)>>>16)>>>16,r[5]=R=65535&m|B<<16,t[5]=G=65535&x|M<<16,x=65535&(E=q),M=E>>>16,m=65535&(d=P),B=d>>>16,d=r[6],M+=(E=t[6])>>>16,m+=65535&d,B+=d>>>16,B+=(m+=(M+=(x+=65535&E)>>>16)>>>16)>>>16,r[6]=P=65535&m|B<<16,t[6]=q=65535&x|M<<16,x=65535&(E=D),M=E>>>16,m=65535&(d=N),B=d>>>16,d=r[7],M+=(E=t[7])>>>16,m+=65535&d,B+=d>>>16,B+=(m+=(M+=(x+=65535&E)>>>16)>>>16)>>>16,r[7]=N=65535&m|B<<16,t[7]=D=65535&x|M<<16,V+=128,e-=128}return e}function W(r,t,n){var e,o=new Int32Array(8),i=new Int32Array(8),h=new Uint8Array(256),a=n;for(o[0]=1779033703,o[1]=3144134277,o[2]=1013904242,o[3]=2773480762,o[4]=1359893119,o[5]=2600822924,o[6]=528734635,o[7]=1541459225,i[0]=4089235720,i[1]=2227873595,i[2]=4271175723,i[3]=1595750129,i[4]=2917565137,i[5]=725511199,i[6]=4215389547,i[7]=327033209,Q(o,i,t,n),n%=128,e=0;e<n;e++)h[e]=t[a-n+e];for(h[n]=128,h[(n=256-128*(n<112?1:0))-9]=0,f(h,n-8,a/536870912|0,a<<3),Q(o,i,h,n),e=0;e<8;e++)f(r,8*e,o[e],i[e]);return 0}function $(r,t){var n=v(),e=v(),o=v(),i=v(),h=v(),a=v(),f=v(),s=v(),u=v();C(n,r[1],r[0]),C(u,t[1],t[0]),F(n,n,u),O(e,r[0],r[1]),O(u,t[0],t[1]),F(e,e,u),F(o,r[3],t[3]),F(o,o,y),F(i,r[2],t[2]),O(i,i,i),C(h,e,n),C(a,i,o),O(f,i,o),O(s,e,n),F(r[0],h,a),F(r[1],s,f),F(r[2],f,a),F(r[3],h,s)}function rr(r,t,n){var e;for(e=0;e<4;e++)T(r[e],t[e],n)}function tr(r,t){var n=v(),e=v(),o=v();Z(o,t[2]),F(n,t[0],o),F(e,t[1],o),z(r,e),r[31]^=P(n)<<7}function nr(r,t,n){var e,o;for(Y(r[0],s),Y(r[1],u),Y(r[2],u),Y(r[3],s),o=255;0<=o;--o)rr(r,t,e=n[o/8|0]>>(7&o)&1),$(t,r),$(r,r),rr(r,t,e)}function er(r,t){var n=[v(),v(),v(),v()];Y(n[0],e),Y(n[1],a),Y(n[2],u),F(n[3],e,a),nr(r,n,t)}function or(r,t,n){var e,o=new Uint8Array(64),i=[v(),v(),v(),v()];for(n||h(t,32),W(o,t,32),o[0]&=248,o[31]&=127,o[31]|=64,er(i,o),tr(r,i),e=0;e<32;e++)t[e+32]=r[e];return 0}var ir=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function hr(r,t){var n,e,o,i;for(e=63;32<=e;--e){for(n=0,o=e-32,i=e-12;o<i;++o)t[o]+=n-16*t[e]*ir[o-(e-32)],n=Math.floor((t[o]+128)/256),t[o]-=256*n;t[o]+=n,t[e]=0}for(o=n=0;o<32;o++)t[o]+=n-(t[31]>>4)*ir[o],n=t[o]>>8,t[o]&=255;for(o=0;o<32;o++)t[o]-=n*ir[o];for(e=0;e<32;e++)t[e+1]+=t[e]>>8,r[e]=255&t[e]}function ar(r){var t,n=new Float64Array(64);for(t=0;t<64;t++)n[t]=r[t];for(t=0;t<64;t++)r[t]=0;hr(r,n)}function fr(r,t,n,e){var o,i,h=new Uint8Array(64),a=new Uint8Array(64),f=new Uint8Array(64),s=new Float64Array(64),u=[v(),v(),v(),v()];W(h,e,32),h[0]&=248,h[31]&=127,h[31]|=64;var c=n+64;for(o=0;o<n;o++)r[64+o]=t[o];for(o=0;o<32;o++)r[32+o]=h[32+o];for(W(f,r.subarray(32),n+32),ar(f),er(u,f),tr(r,u),o=32;o<64;o++)r[o]=e[o];for(W(a,r,n+64),ar(a),o=0;o<64;o++)s[o]=0;for(o=0;o<32;o++)s[o]=f[o];for(o=0;o<32;o++)for(i=0;i<32;i++)s[o+i]+=a[o]*h[i];return hr(r.subarray(32),s),c}function sr(r,t,n,e){var o,i=new Uint8Array(32),h=new Uint8Array(64),a=[v(),v(),v(),v()],f=[v(),v(),v(),v()];if(n<64)return-1;if(function(r,t){var n=v(),e=v(),o=v(),i=v(),h=v(),a=v(),f=v();if(Y(r[2],u),N(r[1],t),I(o,r[1]),F(i,o,c),C(o,o,r[2]),O(i,r[2],i),I(h,i),I(a,h),F(f,a,h),F(n,f,o),F(n,n,i),G(n,n),F(n,n,o),F(n,n,i),F(n,n,i),F(r[0],n,i),I(e,r[0]),F(e,e,i),R(e,o)&&F(r[0],r[0],l),I(e,r[0]),F(e,e,i),R(e,o))return 1;P(r[0])===t[31]>>7&&C(r[0],s,r[0]),F(r[3],r[0],r[1])}(f,e))return-1;for(o=0;o<n;o++)r[o]=t[o];for(o=0;o<32;o++)r[o+32]=e[o];if(W(h,r,n),ar(h),nr(a,f,h),er(f,t.subarray(32)),$(a,f),tr(i,a),n-=64,g(t,0,i,0)){for(o=0;o<n;o++)r[o]=0;return-1}for(o=0;o<n;o++)r[o]=t[o+64];return n}function ur(r,t){if(32!==r.length)throw new Error("bad key size");if(24!==t.length)throw new Error("bad nonce size")}function cr(){for(var r=0;r<arguments.length;r++)if(!(arguments[r]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function yr(r){for(var t=0;t<r.length;t++)r[t]=0}i.lowlevel={crypto_core_hsalsa20:_,crypto_stream_xor:M,crypto_stream:x,crypto_stream_salsa20_xor:d,crypto_stream_salsa20:E,crypto_onetimeauth:B,crypto_onetimeauth_verify:S,crypto_verify_16:b,crypto_verify_32:g,crypto_secretbox:k,crypto_secretbox_open:K,crypto_scalarmult:q,crypto_scalarmult_base:D,crypto_box_beforenm:X,crypto_box_afternm:j,crypto_box:function(r,t,n,e,o,i){var h=new Uint8Array(32);return X(h,o,i),j(r,t,n,e,h)},crypto_box_open:function(r,t,n,e,o,i){var h=new Uint8Array(32);return X(h,o,i),H(r,t,n,e,h)},crypto_box_keypair:V,crypto_hash:W,crypto_sign:fr,crypto_sign_keypair:or,crypto_sign_open:sr,crypto_secretbox_KEYBYTES:32,crypto_secretbox_NONCEBYTES:24,crypto_secretbox_ZEROBYTES:32,crypto_secretbox_BOXZEROBYTES:16,crypto_scalarmult_BYTES:32,crypto_scalarmult_SCALARBYTES:32,crypto_box_PUBLICKEYBYTES:32,crypto_box_SECRETKEYBYTES:32,crypto_box_BEFORENMBYTES:32,crypto_box_NONCEBYTES:24,crypto_box_ZEROBYTES:32,crypto_box_BOXZEROBYTES:16,crypto_sign_BYTES:64,crypto_sign_PUBLICKEYBYTES:32,crypto_sign_SECRETKEYBYTES:64,crypto_sign_SEEDBYTES:32,crypto_hash_BYTES:64,gf:v,D:c,L:ir,pack25519:z,unpack25519:N,M:F,A:O,S:I,Z:C,pow2523:G,add:$,set25519:Y,modL:hr,scalarmult:nr,scalarbase:er},i.randomBytes=function(r){var t=new Uint8Array(r);return h(t,r),t},i.secretbox=function(r,t,n){cr(r,t,n),ur(n,t);for(var e=new Uint8Array(32+r.length),o=new Uint8Array(e.length),i=0;i<r.length;i++)e[i+32]=r[i];return k(o,e,e.length,t,n),o.subarray(16)},i.secretbox.open=function(r,t,n){cr(r,t,n),ur(n,t);for(var e=new Uint8Array(16+r.length),o=new Uint8Array(e.length),i=0;i<r.length;i++)e[i+16]=r[i];return e.length<32||0!==K(o,e,e.length,t,n)?null:o.subarray(32)},i.secretbox.keyLength=32,i.secretbox.nonceLength=24,i.secretbox.overheadLength=16,i.scalarMult=function(r,t){if(cr(r,t),32!==r.length)throw new Error("bad n size");if(32!==t.length)throw new Error("bad p size");var n=new Uint8Array(32);return q(n,r,t),n},i.scalarMult.base=function(r){if(cr(r),32!==r.length)throw new Error("bad n size");var t=new Uint8Array(32);return D(t,r),t},i.scalarMult.scalarLength=32,i.scalarMult.groupElementLength=32,i.box=function(r,t,n,e){var o=i.box.before(n,e);return i.secretbox(r,t,o)},i.box.before=function(r,t){cr(r,t),function(r,t){if(32!==r.length)throw new Error("bad public key size");if(32!==t.length)throw new Error("bad secret key size")}(r,t);var n=new Uint8Array(32);return X(n,r,t),n},i.box.after=i.secretbox,i.box.open=function(r,t,n,e){var o=i.box.before(n,e);return i.secretbox.open(r,t,o)},i.box.open.after=i.secretbox.open,i.box.keyPair=function(){var r=new Uint8Array(32),t=new Uint8Array(32);return V(r,t),{publicKey:r,secretKey:t}},i.box.keyPair.fromSecretKey=function(r){if(cr(r),32!==r.length)throw new Error("bad secret key size");var t=new Uint8Array(32);return D(t,r),{publicKey:t,secretKey:new Uint8Array(r)}},i.box.publicKeyLength=32,i.box.secretKeyLength=32,i.box.sharedKeyLength=32,i.box.nonceLength=24,i.box.overheadLength=i.secretbox.overheadLength,i.sign=function(r,t){if(cr(r,t),64!==t.length)throw new Error("bad secret key size");var n=new Uint8Array(64+r.length);return fr(n,r,r.length,t),n},i.sign.open=function(r,t){if(cr(r,t),32!==t.length)throw new Error("bad public key size");var n=new Uint8Array(r.length),e=sr(n,r,r.length,t);if(e<0)return null;for(var o=new Uint8Array(e),i=0;i<o.length;i++)o[i]=n[i];return o},i.sign.detached=function(r,t){for(var n=i.sign(r,t),e=new Uint8Array(64),o=0;o<e.length;o++)e[o]=n[o];return e},i.sign.detached.verify=function(r,t,n){if(cr(r,t,n),64!==t.length)throw new Error("bad signature size");if(32!==n.length)throw new Error("bad public key size");var e,o=new Uint8Array(64+r.length),i=new Uint8Array(64+r.length);for(e=0;e<64;e++)o[e]=t[e];for(e=0;e<r.length;e++)o[e+64]=r[e];return 0<=sr(i,o,o.length,n)},i.sign.keyPair=function(){var r=new Uint8Array(32),t=new Uint8Array(64);return or(r,t),{publicKey:r,secretKey:t}},i.sign.keyPair.fromSecretKey=function(r){if(cr(r),64!==r.length)throw new Error("bad secret key size");for(var t=new Uint8Array(32),n=0;n<t.length;n++)t[n]=r[32+n];return{publicKey:t,secretKey:new Uint8Array(r)}},i.sign.keyPair.fromSeed=function(r){if(cr(r),32!==r.length)throw new Error("bad seed size");for(var t=new Uint8Array(32),n=new Uint8Array(64),e=0;e<32;e++)n[e]=r[e];return or(t,n,!0),{publicKey:t,secretKey:n}},i.sign.publicKeyLength=32,i.sign.secretKeyLength=64,i.sign.seedLength=32,i.sign.signatureLength=64,i.hash=function(r){cr(r);var t=new Uint8Array(64);return W(t,r,r.length),t},i.hash.hashLength=64,i.verify=function(r,t){return cr(r,t),0!==r.length&&0!==t.length&&(r.length===t.length&&0===w(r,0,t,0,r.length))},i.setPRNG=function(r){h=r},function(){var o="undefined"!=typeof self?self.crypto||self.msCrypto:null;if(o&&o.getRandomValues){i.setPRNG(function(r,t){var n,e=new Uint8Array(t);for(n=0;n<t;n+=65536)o.getRandomValues(e.subarray(n,n+Math.min(t-n,65536)));for(n=0;n<t;n++)r[n]=e[n];yr(e)})}else"undefined"!=typeof require&&(o=require("crypto"))&&o.randomBytes&&i.setPRNG(function(r,t){var n,e=o.randomBytes(t);for(n=0;n<t;n++)r[n]=e[n];yr(e)})}()})(_Crypto_nacl);
3312
13+// HEX UTILITIES
3414
35−// DER CODEC (for ECDSA signatures: secp256k1, P-256)
36−
37−function _Crypto_bigintToBytes(n, len)
38−{
39− var hex = n.toString(16);
40− if (hex.length % 2) { hex = '0' + hex; }
41− while (hex.length < len * 2) { hex = '00' + hex; }
42− return _Crypto_fromHex(hex);
43−}
15+var _Crypto_hexChars = '0123456789abcdef';
4416
45−function _Crypto_bytesToBigint(bytes)
17+function _Crypto_toHex(bytes)
4618{
47− return BigInt('0x' + _Crypto_toHex(bytes));
48−}
49−
50−function _Crypto_compactToDer(compactHex, byteLen)
51−{
52− var bytes = _Crypto_fromHex(compactHex);
53− var r = bytes.slice(0, byteLen);
54− var s = bytes.slice(byteLen);
55− function encodeInt(b) {
56− // Strip leading zeros, then add back if high bit set
57− var i = 0;
58− while (i < b.length - 1 && b[i] === 0) { i++; }
59− b = b.slice(i);
60− if (b[0] & 0x80) {
61− var padded = new Uint8Array(b.length + 1);
62− padded[0] = 0;
63− padded.set(b, 1);
64− b = padded;
65− }
66− return b;
67− }
68− var rEnc = encodeInt(r);
69− var sEnc = encodeInt(s);
70− var totalLen = 2 + rEnc.length + 2 + sEnc.length;
71− var der = new Uint8Array(2 + totalLen);
72− var pos = 0;
73− der[pos++] = 0x30;
74− der[pos++] = totalLen;
75− der[pos++] = 0x02;
76− der[pos++] = rEnc.length;
77− der.set(rEnc, pos); pos += rEnc.length;
78− der[pos++] = 0x02;
79− der[pos++] = sEnc.length;
80− der.set(sEnc, pos);
81− return _Crypto_toHex(der);
82−}
83−
84−function _Crypto_derToCompact(derHex, byteLen)
85−{
86− var der = _Crypto_fromHex(derHex);
87− if (der[0] !== 0x30) { return null; }
88− var pos = 2;
89− if (der[pos] !== 0x02) { return null; }
90− var rLen = der[pos + 1]; pos += 2;
91− var rBytes = der.slice(pos, pos + rLen); pos += rLen;
92− if (der[pos] !== 0x02) { return null; }
93− var sLen = der[pos + 1]; pos += 2;
94− var sBytes = der.slice(pos, pos + sLen);
95− // Remove leading zero padding
96− while (rBytes.length > byteLen) { rBytes = rBytes.slice(1); }
97− while (sBytes.length > byteLen) { sBytes = sBytes.slice(1); }
98− // Pad to fixed width
99− var r = new Uint8Array(byteLen);
100− var s = new Uint8Array(byteLen);
101− r.set(rBytes, byteLen - rBytes.length);
102− s.set(sBytes, byteLen - sBytes.length);
103− var compact = new Uint8Array(byteLen * 2);
104− compact.set(r, 0);
105− compact.set(s, byteLen);
106− return _Crypto_toHex(compact);
107−}
108−
109−
110−// SECP256K1
111−
112−function _Crypto_secp256k1PrivateKeyFromHex(hex)
113−{
114− try {
115− _Crypto_noble.secp256k1.getPublicKey(_Crypto_fromHex(hex));
116− return __Maybe_Just(hex);
117− } catch (e) {
118− return __Maybe_Nothing;
19+ var hex = '';
20+ for (var i = 0; i < bytes.length; i++)
21+ {
22+ hex += _Crypto_hexChars[bytes[i] >> 4];
23+ hex += _Crypto_hexChars[bytes[i] & 15];
11924 }
25+ return hex;
12026}
12127
122−function _Crypto_secp256k1PrivateKeyToHex(key)
123−{
124− return key;
125−}
126−
127−function _Crypto_secp256k1PublicKeyFromHex(hex)
28+function _Crypto_fromHex(hex)
12829{
129− try {
130− _Crypto_noble.secp256k1.Point.fromHex(hex);
131− return __Maybe_Just(hex);
132− } catch (e) {
133− return __Maybe_Nothing;
30+ if (hex.length % 2 !== 0) { return new Uint8Array(0); }
31+ var bytes = new Uint8Array(hex.length / 2);
32+ for (var i = 0; i < bytes.length; i++)
33+ {
34+ var hi = _Crypto_hexVal(hex.charCodeAt(i * 2));
35+ var lo = _Crypto_hexVal(hex.charCodeAt(i * 2 + 1));
36+ if (hi < 0 || lo < 0) { return new Uint8Array(0); }
37+ bytes[i] = (hi << 4) | lo;
13438 }
39+ return bytes;
13540}
13641
137−function _Crypto_secp256k1PublicKeyToHex(key)
42+function _Crypto_hexVal(charCode)
13843{
139− return key;
44+ if (charCode >= 48 && charCode <= 57) { return charCode - 48; }
45+ if (charCode >= 97 && charCode <= 102) { return charCode - 87; }
46+ if (charCode >= 65 && charCode <= 70) { return charCode - 55; }
47+ return -1;
14048}
14149
142−function _Crypto_secp256k1SignatureFromCompactHex(hex)
143−{
144− try {
145− var bytes = _Crypto_fromHex(hex);
146− if (bytes.length !== 64) { return __Maybe_Nothing; }
147− _Crypto_noble.secp256k1.Signature.fromHex(hex);
148− return __Maybe_Just(hex);
149− } catch (e) {
150− return __Maybe_Nothing;
151− }
152−}
153−
154−function _Crypto_secp256k1SignatureFromDerHex(hex)
155−{
156− try {
157− var compact = _Crypto_derToCompact(hex, 32);
158− if (!compact) { return __Maybe_Nothing; }
159− _Crypto_noble.secp256k1.Signature.fromHex(compact);
160− return __Maybe_Just(compact);
161− } catch (e) {
162− return __Maybe_Nothing;
163− }
164−}
165−
166−function _Crypto_secp256k1SignatureToCompactHex(sig)
167−{
168− return sig;
169−}
170−
171−function _Crypto_secp256k1SignatureToDerHex(compactHex)
172−{
173− return _Crypto_compactToDer(compactHex, 32);
174−}
175−
176−function _Crypto_secp256k1GetPublicKey(privKey)
177−{
178− return _Crypto_toHex(_Crypto_noble.secp256k1.getPublicKey(_Crypto_fromHex(privKey)));
179−}
180−
181−var _Crypto_secp256k1Sign = F2(function(msgHash, privKey)
182−{
183− var sig = _Crypto_noble.secp256k1.sign(_Crypto_fromHex(msgHash), _Crypto_fromHex(privKey));
184− return _Crypto_toHex(sig);
185−});
186−
187−var _Crypto_secp256k1Verify = F3(function(sig, msgHash, pubKey)
188−{
189− try {
190− return _Crypto_noble.secp256k1.verify(
191− _Crypto_fromHex(sig),
192− _Crypto_fromHex(msgHash),
193− _Crypto_fromHex(pubKey)
194− );
195− } catch (e) {
196− return false;
197− }
198−});
199−
200−var _Crypto_secp256k1GetSharedSecret = F2(function(privKey, pubKey)
201−{
202− return _Crypto_toHex(_Crypto_noble.secp256k1.getSharedSecret(_Crypto_fromHex(privKey), _Crypto_fromHex(pubKey)));
203−});
204−
20550
20651// ED25519
20752
20853function _Crypto_ed25519PrivateKeyFromHex(hex)
20954{
21055 try {
211− _Crypto_noble.ed25519.getPublicKey(_Crypto_fromHex(hex));
56+ var bytes = _Crypto_fromHex(hex);
57+ if (bytes.length !== 32) { return __Maybe_Nothing; }
58+ _Crypto_nacl.sign.keyPair.fromSeed(bytes);
21259 return __Maybe_Just(hex);
21360 } catch (e) {
21461 return __Maybe_Nothing;
@@ -223,7 +70,8 @@ function _Crypto_ed25519PrivateKeyToHex(key)
22370function _Crypto_ed25519PublicKeyFromHex(hex)
22471{
22572 try {
226− _Crypto_noble.ed25519.Point.fromHex(hex);
73+ var bytes = _Crypto_fromHex(hex);
74+ if (bytes.length !== 32) { return __Maybe_Nothing; }
22775 return __Maybe_Just(hex);
22876 } catch (e) {
22977 return __Maybe_Nothing;
@@ -253,20 +101,22 @@ function _Crypto_ed25519SignatureToHex(sig)
253101
254102function _Crypto_ed25519GetPublicKey(privKey)
255103{
256− return _Crypto_toHex(_Crypto_noble.ed25519.getPublicKey(_Crypto_fromHex(privKey)));
104+ var kp = _Crypto_nacl.sign.keyPair.fromSeed(_Crypto_fromHex(privKey));
105+ return _Crypto_toHex(kp.publicKey);
257106}
258107
259108var _Crypto_ed25519Sign = F2(function(msg, privKey)
260109{
261− return _Crypto_toHex(_Crypto_noble.ed25519.sign(_Crypto_fromHex(msg), _Crypto_fromHex(privKey)));
110+ var kp = _Crypto_nacl.sign.keyPair.fromSeed(_Crypto_fromHex(privKey));
111+ return _Crypto_toHex(_Crypto_nacl.sign.detached(_Crypto_fromHex(msg), kp.secretKey));
262112});
263113
264114var _Crypto_ed25519Verify = F3(function(sig, msg, pubKey)
265115{
266116 try {
267− return _Crypto_noble.ed25519.verify(
268− _Crypto_fromHex(sig),
117+ return _Crypto_nacl.sign.detached.verify(
269118 _Crypto_fromHex(msg),
119+ _Crypto_fromHex(sig),
270120 _Crypto_fromHex(pubKey)
271121 );
272122 } catch (e) {
@@ -275,114 +125,53 @@ var _Crypto_ed25519Verify = F3(function(sig, msg, pubKey)
275125});
276126
277127
278−// P-256 (secp256r1)
279−
280−function _Crypto_p256PrivateKeyFromHex(hex)
281−{
282− try {
283− _Crypto_noble.p256.getPublicKey(_Crypto_fromHex(hex));
284− return __Maybe_Just(hex);
285− } catch (e) {
286− return __Maybe_Nothing;
287− }
288−}
289−
290−function _Crypto_p256PrivateKeyToHex(key)
291−{
292− return key;
293−}
128+// X25519 (Diffie-Hellman)
294129
295−function _Crypto_p256PublicKeyFromHex(hex)
130+function _Crypto_x25519PrivateKeyFromHex(hex)
296131{
297132 try {
298− _Crypto_noble.p256.Point.fromHex(hex);
133+ var bytes = _Crypto_fromHex(hex);
134+ if (bytes.length !== 32) { return __Maybe_Nothing; }
135+ _Crypto_nacl.scalarMult.base(bytes);
299136 return __Maybe_Just(hex);
300137 } catch (e) {
301138 return __Maybe_Nothing;
302139 }
303140}
304141
305−function _Crypto_p256PublicKeyToHex(key)
142+function _Crypto_x25519PrivateKeyToHex(key)
306143{
307144 return key;
308145}
309146
310−function _Crypto_p256SignatureFromCompactHex(hex)
147+function _Crypto_x25519PublicKeyFromHex(hex)
311148{
312149 try {
313150 var bytes = _Crypto_fromHex(hex);
314− if (bytes.length !== 64) { return __Maybe_Nothing; }
315− _Crypto_noble.p256.Signature.fromHex(hex);
151+ if (bytes.length !== 32) { return __Maybe_Nothing; }
316152 return __Maybe_Just(hex);
317153 } catch (e) {
318154 return __Maybe_Nothing;
319155 }
320156}
321157
322−function _Crypto_p256SignatureFromDerHex(hex)
323−{
324− try {
325− var compact = _Crypto_derToCompact(hex, 32);
326− if (!compact) { return __Maybe_Nothing; }
327− _Crypto_noble.p256.Signature.fromHex(compact);
328− return __Maybe_Just(compact);
329− } catch (e) {
330− return __Maybe_Nothing;
331− }
332−}
333−
334−function _Crypto_p256SignatureToCompactHex(sig)
335−{
336− return sig;
337−}
338−
339−function _Crypto_p256SignatureToDerHex(compactHex)
158+function _Crypto_x25519PublicKeyToHex(key)
340159{
341− return _Crypto_compactToDer(compactHex, 32);
160+ return key;
342161}
343162
344−function _Crypto_p256GetPublicKey(privKey)
163+function _Crypto_x25519GetPublicKey(privKey)
345164{
346− return _Crypto_toHex(_Crypto_noble.p256.getPublicKey(_Crypto_fromHex(privKey)));
165+ return _Crypto_toHex(_Crypto_nacl.scalarMult.base(_Crypto_fromHex(privKey)));
347166}
348167
349−var _Crypto_p256Sign = F2(function(msgHash, privKey)
168+var _Crypto_x25519GetSharedSecret = F2(function(privKey, pubKey)
350169{
351− var sig = _Crypto_noble.p256.sign(_Crypto_fromHex(msgHash), _Crypto_fromHex(privKey));
352− return _Crypto_toHex(sig);
170+ return _Crypto_toHex(_Crypto_nacl.scalarMult(_Crypto_fromHex(privKey), _Crypto_fromHex(pubKey)));
353171});
354172
355−var _Crypto_p256Verify = F3(function(sig, msgHash, pubKey)
356−{
357− try {
358− return _Crypto_noble.p256.verify(
359− _Crypto_fromHex(sig),
360− _Crypto_fromHex(msgHash),
361− _Crypto_fromHex(pubKey)
362− );
363− } catch (e) {
364− return false;
365− }
366−});
367−
368−var _Crypto_p256GetSharedSecret = F2(function(privKey, pubKey)
369−{
370− return _Crypto_toHex(_Crypto_noble.p256.getSharedSecret(_Crypto_fromHex(privKey), _Crypto_fromHex(pubKey)));
371−});
372−
373−
374−// NOBLE/CIPHERS BUNDLE (https://github.com/paulmillr/noble-ciphers, MIT License)
375−// Embedded: @noble/ciphers - AES-GCM, ChaCha20-Poly1305, XChaCha20-Poly1305
376−
377−var _Crypto_ciphers =(()=>{var _t=Object.defineProperty;var de=Object.getOwnPropertyDescriptor;var we=Object.getOwnPropertyNames;var be=Object.prototype.hasOwnProperty;var xe=(e,t)=>{for(var n in t)_t(e,n,{get:t[n],enumerable:!0})},me=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of we(t))!be.call(e,o)&&o!==n&&_t(e,o,{get:()=>t[o],enumerable:!(r=de(t,o))||r.enumerable});return e};var Le=e=>me(_t({},"_"+"_esModule",{value:!0}),e);var Ge={};xe(Ge,{cbc:()=>ne,cfb:()=>re,chacha20poly1305:()=>pe,ctr:()=>Gt,ecb:()=>ee,gcm:()=>oe,managedNonce:()=>Vt,randomBytes:()=>xt,siv:()=>se,xchacha20poly1305:()=>ye});function Ee(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function yt(e){if(typeof e!="boolean")throw new Error(`boolean expected, not ${e}`)}function ht(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function E(e,t,n=""){let r=Ee(e),o=e?.length,s=t!==void 0;if(!r||s&&o!==t){let i=n&&`"${n}" `,c=s?` of length ${t}`:"",f=r?`length=${o}`:`type=${typeof e}`;throw new Error(i+"expected Uint8Array"+c+", got "+f)}return e}function et(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function gt(e,t){E(e,void 0,"output");let n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function dt(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function A(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function B(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function at(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}var Ue=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function vt(e,t){return e.buffer===t.buffer&&e.byteOffset<t.byteOffset+t.byteLength&&t.byteOffset<e.byteOffset+e.byteLength}function pt(e,t){if(vt(e,t)&&e.byteOffset<t.byteOffset)throw new Error("complex overlap of input and output is not supported")}function Ct(...e){let t=0;for(let r=0;r<e.length;r++){let o=e[r];E(o),t+=o.length}let n=new Uint8Array(t);for(let r=0,o=0;r<e.length;r++){let s=e[r];n.set(s,o),o+=s.length}return n}function jt(e,t){if(t==null||typeof t!="object")throw new Error("options must be defined");return Object.assign(e,t)}function wt(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}var D=(e,t)=>{function n(r,...o){if(E(r,void 0,"key"),!Ue)throw new Error("Non little-endian hardware is not yet supported");if(e.nonceLength!==void 0){let h=o[0];E(h,e.varSizeNonce?void 0:e.nonceLength,"nonce")}let s=e.tagLength;s&&o[1]!==void 0&&E(o[1],void 0,"AAD");let i=t(r,...o),c=(h,a)=>{if(a!==void 0){if(h!==2)throw new Error("cipher output not supported");E(a,void 0,"output")}},f=!1;return{encrypt(h,a){if(f)throw new Error("cannot encrypt() twice with same key + nonce");return f=!0,E(h),c(i.encrypt.length,a),i.encrypt(h,a)},decrypt(h,a){if(E(h),s&&h.length<s)throw new Error('"ciphertext" expected length bigger than tagLength='+s);return c(i.decrypt.length,a),i.decrypt(h,a)}}}return Object.assign(n,e),n};function Q(e,t,n=!0){if(t===void 0)return new Uint8Array(e);if(t.length!==e)throw new Error('"output" expected Uint8Array of length '+e+", got: "+t.length);if(n&&!Z(t))throw new Error("invalid output, must be aligned");return t}function bt(e,t,n){yt(n);let r=new Uint8Array(16),o=at(r);return o.setBigUint64(0,BigInt(t),n),o.setBigUint64(8,BigInt(e),n),r}function Z(e){return e.byteOffset%4===0}function z(e){return Uint8Array.from(e)}function xt(e=32){let t=typeof globalThis=="object"?globalThis.crypto:null;if(typeof t?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");return t.getRandomValues(new Uint8Array(e))}function Vt(e,t=xt){let{nonceLength:n}=e;ht(n);let r=(o,s)=>{let i=Ct(o,s);return s.fill(0),i};return((o,...s)=>({encrypt(i){E(i);let c=t(n),f=e(o,c,...s).encrypt(i);return f instanceof Promise?f.then(l=>r(c,l)):r(c,f)},decrypt(i){E(i);let c=i.subarray(0,n),f=i.subarray(n);return e(o,c,...s).decrypt(f)}}))}var tt=16,Tt=new Uint8Array(16),G=A(Tt),Ae=225,Be=(e,t,n,r)=>{let o=r&1;return{s3:n<<31|r>>>1,s2:t<<31|n>>>1,s1:e<<31|t>>>1,s0:e>>>1^Ae<<24&-(o&1)}},F=e=>(e>>>0&255)<<24|(e>>>8&255)<<16|(e>>>16&255)<<8|e>>>24&255|0;function _e(e){e.reverse();let t=e[15]&1,n=0;for(let r=0;r<e.length;r++){let o=e[r];e[r]=o>>>1|n,n=(o&1)<<7}return e[0]^=-t&225,e}var ve=e=>e>64*1024?8:e>1024?4:2,mt=class{blockLen=tt;outputLen=tt;s0=0;s1=0;s2=0;s3=0;finished=!1;t;W;windowSize;constructor(t,n){E(t,16,"key"),t=z(t);let r=at(t),o=r.getUint32(0,!1),s=r.getUint32(4,!1),i=r.getUint32(8,!1),c=r.getUint32(12,!1),f=[];for(let u=0;u<128;u++)f.push({s0:F(o),s1:F(s),s2:F(i),s3:F(c)}),{s0:o,s1:s,s2:i,s3:c}=Be(o,s,i,c);let l=ve(n||1024);if(![1,2,4,8].includes(l))throw new Error("ghash: invalid window size, expected 2, 4 or 8");this.W=l;let a=128/l,p=this.windowSize=2**l,g=[];for(let u=0;u<a;u++)for(let y=0;y<p;y++){let d=0,w=0,b=0,U=0;for(let L=0;L<l;L++){if(!(y>>>l-L-1&1))continue;let{s0:v,s1:j,s2:V,s3:_}=f[l*u+L];d^=v,w^=j,b^=V,U^=_}g.push({s0:d,s1:w,s2:b,s3:U})}this.t=g}_updateBlock(t,n,r,o){t^=this.s0,n^=this.s1,r^=this.s2,o^=this.s3;let{W:s,t:i,windowSize:c}=this,f=0,l=0,h=0,a=0,p=(1<<s)-1,g=0;for(let u of[t,n,r,o])for(let y=0;y<4;y++){let d=u>>>8*y&255;for(let w=8/s-1;w>=0;w--){let b=d>>>s*w&p,{s0:U,s1:L,s2:C,s3:v}=i[g*c+b];f^=U,l^=L,h^=C,a^=v,g+=1}}this.s0=f,this.s1=l,this.s2=h,this.s3=a}update(t){et(this),E(t),t=z(t);let n=A(t),r=Math.floor(t.length/tt),o=t.length%tt;for(let s=0;s<r;s++)this._updateBlock(n[s*4+0],n[s*4+1],n[s*4+2],n[s*4+3]);return o&&(Tt.set(t.subarray(r*tt)),this._updateBlock(G[0],G[1],G[2],G[3]),B(G)),this}destroy(){let{t}=this;for(let n of t)n.s0=0,n.s1=0,n.s2=0,n.s3=0}digestInto(t){et(this),gt(t,this),this.finished=!0;let{s0:n,s1:r,s2:o,s3:s}=this,i=A(t);return i[0]=n,i[1]=r,i[2]=o,i[3]=s,t}digest(){let t=new Uint8Array(tt);return this.digestInto(t),this.destroy(),t}},St=class extends mt{constructor(t,n){E(t);let r=_e(z(t));super(r,n),B(r)}update(t){et(this),E(t),t=z(t);let n=A(t),r=t.length%tt,o=Math.floor(t.length/tt);for(let s=0;s<o;s++)this._updateBlock(F(n[s*4+3]),F(n[s*4+2]),F(n[s*4+1]),F(n[s*4+0]));return r&&(Tt.set(t.subarray(o*tt)),this._updateBlock(F(G[3]),F(G[2]),F(G[1]),F(G[0])),B(G)),this}digestInto(t){et(this),gt(t,this),this.finished=!0;let{s0:n,s1:r,s2:o,s3:s}=this,i=A(t);return i[0]=n,i[1]=r,i[2]=o,i[3]=s,t.reverse()}};function Ht(e){let t=(r,o)=>e(o,r.length).update(r).digest(),n=e(new Uint8Array(16),0);return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=(r,o)=>e(r,o),t}var It=Ht((e,t)=>new mt(e,t)),Ce=Ht((e,t)=>new St(e,t));var R=16,Nt=4,Lt=new Uint8Array(R);var Se=283;function $t(e){if(![16,24,32].includes(e.length))throw new Error('"aes key" expected Uint8Array of length 16/24/32, got length='+e.length)}function Mt(e){return e<<1^Se&-(e>>7)}function ut(e,t){let n=0;for(;t>0;t>>=1)n^=e&-(t&1),e=Mt(e);return n}var Te=(e,t,n=1)=>{if(!Number.isSafeInteger(n))throw new Error("incBytes: wrong carry "+n);E(e);for(let r=0;r<e.length;r++){let o=t?r:e.length-1-r;n=n+(e[o]&255)|0,e[o]=n&255,n>>>=8}},kt=(()=>{let e=new Uint8Array(256);for(let n=0,r=1;n<256;n++,r^=Mt(r))e[n]=r;let t=new Uint8Array(256);t[0]=99;for(let n=0;n<255;n++){let r=e[255-n];r|=r<<8,t[e[n]]=(r^r>>4^r>>5^r>>6^r>>7^99)&255}return B(e),t})(),Ie=kt.map((e,t)=>kt.indexOf(t)),Ke=e=>e<<24|e>>>8,Kt=e=>e<<8|e>>>24;function Zt(e,t){if(e.length!==256)throw new Error("Wrong sbox length");let n=new Uint32Array(256).map((l,h)=>t(e[h])),r=n.map(Kt),o=r.map(Kt),s=o.map(Kt),i=new Uint32Array(256*256),c=new Uint32Array(256*256),f=new Uint16Array(256*256);for(let l=0;l<256;l++)for(let h=0;h<256;h++){let a=l*256+h;i[a]=n[l]^r[h],c[a]=o[l]^s[h],f[a]=e[l]<<8|e[h]}return{sbox:e,sbox2:f,T0:n,T1:r,T2:o,T3:s,T01:i,T23:c}}var Pt=Zt(kt,e=>ut(e,3)<<24|e<<16|e<<8|ut(e,2)),Ft=Zt(Ie,e=>ut(e,11)<<24|ut(e,13)<<16|ut(e,9)<<8|ut(e,14)),Oe=(()=>{let e=new Uint8Array(16);for(let t=0,n=1;t<16;t++,n=Mt(n))e[t]=n;return e})();function rt(e){E(e);let t=e.length;$t(e);let{sbox2:n}=Pt,r=[];Z(e)||r.push(e=z(e));let o=A(e),s=o.length,i=f=>J(n,f,f,f,f),c=new Uint32Array(t+28);c.set(o);for(let f=s;f<c.length;f++){let l=c[f-1];f%s===0?l=i(Ke(l))^Oe[f/s-1]:s>6&&f%s===4&&(l=i(l)),c[f]=c[f-s]^l}return B(...r),c}function Yt(e){let t=rt(e),n=t.slice(),r=t.length,{sbox2:o}=Pt,{T0:s,T1:i,T2:c,T3:f}=Ft;for(let l=0;l<r;l+=4)for(let h=0;h<4;h++)n[l+h]=t[r-l-4+h];B(t);for(let l=4;l<r-4;l++){let h=n[l],a=J(o,h,h,h,h);n[l]=s[a&255]^i[a>>>8&255]^c[a>>>16&255]^f[a>>>24]}return n}function nt(e,t,n,r,o,s){return e[n<<8&65280|r>>>8&255]^t[o>>>8&65280|s>>>24&255]}function J(e,t,n,r,o){return e[t&255|n&65280]|e[r>>>16&255|o>>>16&65280]<<16}function Y(e,t,n,r,o){let{sbox2:s,T01:i,T23:c}=Pt,f=0;t^=e[f++],n^=e[f++],r^=e[f++],o^=e[f++];let l=e.length/4-2;for(let u=0;u<l;u++){let y=e[f++]^nt(i,c,t,n,r,o),d=e[f++]^nt(i,c,n,r,o,t),w=e[f++]^nt(i,c,r,o,t,n),b=e[f++]^nt(i,c,o,t,n,r);t=y,n=d,r=w,o=b}let h=e[f++]^J(s,t,n,r,o),a=e[f++]^J(s,n,r,o,t),p=e[f++]^J(s,r,o,t,n),g=e[f++]^J(s,o,t,n,r);return{s0:h,s1:a,s2:p,s3:g}}function Qt(e,t,n,r,o){let{sbox2:s,T01:i,T23:c}=Ft,f=0;t^=e[f++],n^=e[f++],r^=e[f++],o^=e[f++];let l=e.length/4-2;for(let u=0;u<l;u++){let y=e[f++]^nt(i,c,t,o,r,n),d=e[f++]^nt(i,c,n,t,o,r),w=e[f++]^nt(i,c,r,n,t,o),b=e[f++]^nt(i,c,o,r,n,t);t=y,n=d,r=w,o=b}let h=e[f++]^J(s,t,o,r,n),a=e[f++]^J(s,n,t,o,r),p=e[f++]^J(s,r,n,t,o),g=e[f++]^J(s,o,r,n,t);return{s0:h,s1:a,s2:p,s3:g}}function ke(e,t,n,r){E(t,R,"nonce"),E(n);let o=n.length;r=Q(o,r),pt(n,r);let s=t,i=A(s),{s0:c,s1:f,s2:l,s3:h}=Y(e,i[0],i[1],i[2],i[3]),a=A(n),p=A(r);for(let u=0;u+4<=a.length;u+=4)p[u+0]=a[u+0]^c,p[u+1]=a[u+1]^f,p[u+2]=a[u+2]^l,p[u+3]=a[u+3]^h,Te(s,!1,1),{s0:c,s1:f,s2:l,s3:h}=Y(e,i[0],i[1],i[2],i[3]);let g=R*Math.floor(a.length/Nt);if(g<o){let u=new Uint32Array([c,f,l,h]),y=dt(u);for(let d=g,w=0;d<o;d++,w++)r[d]=n[d]^y[w];B(u)}return r}function Et(e,t,n,r,o){E(n,R,"nonce"),E(r),o=Q(r.length,o);let s=n,i=A(s),c=at(s),f=A(r),l=A(o),h=t?0:12,a=r.length,p=c.getUint32(h,t),{s0:g,s1:u,s2:y,s3:d}=Y(e,i[0],i[1],i[2],i[3]);for(let b=0;b+4<=f.length;b+=4)l[b+0]=f[b+0]^g,l[b+1]=f[b+1]^u,l[b+2]=f[b+2]^y,l[b+3]=f[b+3]^d,p=p+1>>>0,c.setUint32(h,p,t),{s0:g,s1:u,s2:y,s3:d}=Y(e,i[0],i[1],i[2],i[3]);let w=R*Math.floor(f.length/Nt);if(w<a){let b=new Uint32Array([g,u,y,d]),U=dt(b);for(let L=w,C=0;L<a;L++,C++)o[L]=r[L]^U[C];B(b)}return o}var Gt=D({blockSize:16,nonceLength:16},function(t,n){function r(o,s){if(E(o),s!==void 0&&(E(s),!Z(s)))throw new Error("unaligned destination");let i=rt(t),c=z(n),f=[i,c];Z(o)||f.push(o=z(o));let l=ke(i,c,o,s);return B(...f),l}return{encrypt:(o,s)=>r(o,s),decrypt:(o,s)=>r(o,s)}});function Jt(e){if(E(e),e.length%R!==0)throw new Error("aes-(cbc/ecb).decrypt ciphertext should consist of blocks with size "+R)}function Xt(e,t,n){E(e);let r=e.length,o=r%R;if(!t&&o!==0)throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");Z(e)||(e=z(e));let s=A(e);if(t){let c=R-o;c||(c=R),r=r+c}n=Q(r,n),pt(e,n);let i=A(n);return{b:s,o:i,out:n}}function Dt(e,t){if(!t)return e;let n=e.length;if(!n)throw new Error("aes/pcks5: empty ciphertext not allowed");let r=e[n-1];if(r<=0||r>16)throw new Error("aes/pcks5: wrong padding");let o=e.subarray(0,-r);for(let s=0;s<r;s++)if(e[n-s-1]!==r)throw new Error("aes/pcks5: wrong padding");return o}function te(e){let t=new Uint8Array(16),n=A(t);t.set(e);let r=R-e.length;for(let o=R-r;o<R;o++)t[o]=r;return n}var ee=D({blockSize:16},function(t,n={}){let r=!n.disablePadding;return{encrypt(o,s){let{b:i,o:c,out:f}=Xt(o,r,s),l=rt(t),h=0;for(;h+4<=i.length;){let{s0:a,s1:p,s2:g,s3:u}=Y(l,i[h+0],i[h+1],i[h+2],i[h+3]);c[h++]=a,c[h++]=p,c[h++]=g,c[h++]=u}if(r){let a=te(o.subarray(h*4)),{s0:p,s1:g,s2:u,s3:y}=Y(l,a[0],a[1],a[2],a[3]);c[h++]=p,c[h++]=g,c[h++]=u,c[h++]=y}return B(l),f},decrypt(o,s){Jt(o);let i=Yt(t);s=Q(o.length,s);let c=[i];Z(o)||c.push(o=z(o)),pt(o,s);let f=A(o),l=A(s);for(let h=0;h+4<=f.length;){let{s0:a,s1:p,s2:g,s3:u}=Qt(i,f[h+0],f[h+1],f[h+2],f[h+3]);l[h++]=a,l[h++]=p,l[h++]=g,l[h++]=u}return B(...c),Dt(s,r)}}}),ne=D({blockSize:16,nonceLength:16},function(t,n,r={}){let o=!r.disablePadding;return{encrypt(s,i){let c=rt(t),{b:f,o:l,out:h}=Xt(s,o,i),a=n,p=[c];Z(a)||p.push(a=z(a));let g=A(a),u=g[0],y=g[1],d=g[2],w=g[3],b=0;for(;b+4<=f.length;)u^=f[b+0],y^=f[b+1],d^=f[b+2],w^=f[b+3],{s0:u,s1:y,s2:d,s3:w}=Y(c,u,y,d,w),l[b++]=u,l[b++]=y,l[b++]=d,l[b++]=w;if(o){let U=te(s.subarray(b*4));u^=U[0],y^=U[1],d^=U[2],w^=U[3],{s0:u,s1:y,s2:d,s3:w}=Y(c,u,y,d,w),l[b++]=u,l[b++]=y,l[b++]=d,l[b++]=w}return B(...p),h},decrypt(s,i){Jt(s);let c=Yt(t),f=n,l=[c];Z(f)||l.push(f=z(f));let h=A(f);i=Q(s.length,i),Z(s)||l.push(s=z(s)),pt(s,i);let a=A(s),p=A(i),g=h[0],u=h[1],y=h[2],d=h[3];for(let w=0;w+4<=a.length;){let b=g,U=u,L=y,C=d;g=a[w+0],u=a[w+1],y=a[w+2],d=a[w+3];let{s0:v,s1:j,s2:V,s3:_}=Qt(c,g,u,y,d);p[w++]=v^b,p[w++]=j^U,p[w++]=V^L,p[w++]=_^C}return B(...l),Dt(i,o)}}}),re=D({blockSize:16,nonceLength:16},function(t,n){function r(o,s,i){E(o);let c=o.length;if(i=Q(c,i),vt(o,i))throw new Error("overlapping src and dst not supported.");let f=rt(t),l=n,h=[f];Z(l)||h.push(l=z(l)),Z(o)||h.push(o=z(o));let a=A(o),p=A(i),g=s?p:a,u=A(l),y=u[0],d=u[1],w=u[2],b=u[3];for(let L=0;L+4<=a.length;){let{s0:C,s1:v,s2:j,s3:V}=Y(f,y,d,w,b);p[L+0]=a[L+0]^C,p[L+1]=a[L+1]^v,p[L+2]=a[L+2]^j,p[L+3]=a[L+3]^V,y=g[L++],d=g[L++],w=g[L++],b=g[L++]}let U=R*Math.floor(a.length/Nt);if(U<c){({s0:y,s1:d,s2:w,s3:b}=Y(f,y,d,w,b));let L=dt(new Uint32Array([y,d,w,b]));for(let C=U,v=0;C<c;C++,v++)i[C]=o[C]^L[v];B(L)}return B(...h),i}return{encrypt:(o,s)=>r(o,!0,s),decrypt:(o,s)=>r(o,!1,s)}});function Ne(e,t,n,r,o){let s=o?o.length:0,i=e.create(n,r.length+s);o&&i.update(o);let c=bt(8*r.length,8*s,t);i.update(r),i.update(c);let f=i.digest();return B(c),f}var oe=D({blockSize:16,nonceLength:12,tagLength:16,varSizeNonce:!0},function(t,n,r){if(n.length<8)throw new Error("aes/gcm: invalid nonce length");let o=16;function s(c,f,l){let h=Ne(It,!1,c,l,r);for(let a=0;a<f.length;a++)h[a]^=f[a];return h}function i(){let c=rt(t),f=Lt.slice(),l=Lt.slice();if(Et(c,!1,l,l,f),n.length===12)l.set(n);else{let a=Lt.slice();at(a).setBigUint64(8,BigInt(n.length*8),!1);let g=It.create(f).update(n).update(a);g.digestInto(l),g.destroy()}let h=Et(c,!1,l,Lt);return{xk:c,authKey:f,counter:l,tagMask:h}}return{encrypt(c){let{xk:f,authKey:l,counter:h,tagMask:a}=i(),p=new Uint8Array(c.length+o),g=[f,l,h,a];Z(c)||g.push(c=z(c)),Et(f,!1,h,c,p.subarray(0,c.length));let u=s(l,a,p.subarray(0,p.length-o));return g.push(u),p.set(u,c.length),B(...g),p},decrypt(c){let{xk:f,authKey:l,counter:h,tagMask:a}=i(),p=[f,l,a,h];Z(c)||p.push(c=z(c));let g=c.subarray(0,-o),u=c.subarray(-o),y=s(l,a,g);if(p.push(y),!wt(y,u))throw new Error("aes/gcm: invalid ghash tag");let d=Et(f,!1,h,g);return B(...p),d}}});function Me(e){return e instanceof Uint32Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint32Array"}function Ot(e,t){if(E(t,16,"block"),!Me(e))throw new Error("_encryptBlock accepts result of expandKeyLE");let n=A(t),{s0:r,s1:o,s2:s,s3:i}=Y(e,n[0],n[1],n[2],n[3]);return n[0]=r,n[1]=o,n[2]=s,n[3]=i,t}function qt(e){let t=0;for(let n=R-1;n>=0;n--){let r=(e[n]&128)>>>7;e[n]=e[n]<<1|t,t=r}return t&&(e[R-1]^=135),e}function Ut(e,t){if(e.length!==t.length)throw new Error("xorBlock: blocks must have same length");for(let n=0;n<e.length;n++)e[n]=e[n]^t[n];return e}var At=class{buffer;destroyed;k1;k2;xk;constructor(t){E(t),$t(t),this.xk=rt(t),this.buffer=new Uint8Array(0),this.destroyed=!1;let n=new Uint8Array(R);Ot(this.xk,n),this.k1=qt(n),this.k2=qt(new Uint8Array(this.k1))}update(t){let{destroyed:n,buffer:r}=this;if(n)throw new Error("CMAC instance was destroyed");E(t);let o=new Uint8Array(r.length+t.length);return o.set(r),o.set(t,r.length),this.buffer=o,this}digest(){if(this.destroyed)throw new Error("CMAC instance was destroyed");let{buffer:t}=this,n=t.length,r=Math.ceil(n/R),o;r===0?(r=1,o=!1):o=n%R===0;let s=(r-1)*R,i=t.subarray(s),c;if(o)c=Ut(new Uint8Array(i),this.k1);else{let l=new Uint8Array(R);l.set(i),l[i.length]=128,c=Ut(l,this.k2)}let f=new Uint8Array(R);for(let l=0;l<r-1;l++){let h=t.subarray(l*R,(l+1)*R);Ut(f,h),Ot(this.xk,f)}return Ut(f,c),Ot(this.xk,f),B(c),f}destroy(){let{buffer:t,destroyed:n,xk:r,k1:o,k2:s}=this;n||(this.destroyed=!0,B(t,r,o,s))}},Pe=(e,t)=>new At(e).update(t).digest();Pe.create=e=>new At(e);var se=()=>{throw new Error('"siv" from v1 is now "gcmsiv"')};var ie=e=>Uint8Array.from(e.split(""),t=>t.charCodeAt(0)),ze=ie("expand 16-byte k"),Re=ie("expand 32-byte k"),We=A(ze),je=A(Re);function x(e,t){return e<<t|e>>>32-t}function zt(e){return e.byteOffset%4===0}var Bt=64,Ve=16,fe=2**32-1,ce=Uint32Array.of();function He(e,t,n,r,o,s,i,c){let f=o.length,l=new Uint8Array(Bt),h=A(l),a=zt(o)&&zt(s),p=a?A(o):ce,g=a?A(s):ce;for(let u=0;u<f;i++){if(e(t,n,r,h,i,c),i>=fe)throw new Error("arx: counter overflow");let y=Math.min(Bt,f-u);if(a&&y===Bt){let d=u/4;if(u%4!==0)throw new Error("arx: invalid block position");for(let w=0,b;w<Ve;w++)b=d+w,g[b]=p[b]^h[w];u+=Bt;continue}for(let d=0,w;d<y;d++)w=u+d,s[w]=o[w]^l[d];u+=y}}function Rt(e,t){let{allowShortKeys:n,extendNonceFn:r,counterLength:o,counterRight:s,rounds:i}=jt({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if(typeof e!="function")throw new Error("core must be a function");return ht(o),ht(i),yt(s),yt(n),(c,f,l,h,a=0)=>{E(c,void 0,"key"),E(f,void 0,"nonce"),E(l,void 0,"data");let p=l.length;if(h===void 0&&(h=new Uint8Array(p)),E(h,void 0,"output"),ht(a),a<0||a>=fe)throw new Error("arx: counter overflow");if(h.length<p)throw new Error(`arx: output (${h.length}) is shorter than data (${p})`);let g=[],u=c.length,y,d;if(u===32)g.push(y=z(c)),d=je;else if(u===16&&n)y=new Uint8Array(32),y.set(c),y.set(c,16),d=We,g.push(y);else throw E(c,32,"arx key"),new Error("invalid key size");zt(f)||g.push(f=z(f));let w=A(y);if(r){if(f.length!==24)throw new Error("arx: extended nonce must be 24 bytes");r(d,w,A(f.subarray(0,16)),w),f=f.subarray(16)}let b=16-o;if(b!==f.length)throw new Error(`arx: nonce must be ${b} or 16 bytes`);if(b!==12){let L=new Uint8Array(12);L.set(f,s?0:12-f.length),f=L,g.push(f)}let U=A(f);return He(e,d,w,U,l,h,a,i),B(...g),h}}function $(e,t){return e[t++]&255|(e[t++]&255)<<8}var Wt=class{blockLen=16;outputLen=16;buffer=new Uint8Array(16);r=new Uint16Array(10);h=new Uint16Array(10);pad=new Uint16Array(8);pos=0;finished=!1;constructor(t){t=z(E(t,32,"key"));let n=$(t,0),r=$(t,2),o=$(t,4),s=$(t,6),i=$(t,8),c=$(t,10),f=$(t,12),l=$(t,14);this.r[0]=n&8191,this.r[1]=(n>>>13|r<<3)&8191,this.r[2]=(r>>>10|o<<6)&7939,this.r[3]=(o>>>7|s<<9)&8191,this.r[4]=(s>>>4|i<<12)&255,this.r[5]=i>>>1&8190,this.r[6]=(i>>>14|c<<2)&8191,this.r[7]=(c>>>11|f<<5)&8065,this.r[8]=(f>>>8|l<<8)&8191,this.r[9]=l>>>5&127;for(let h=0;h<8;h++)this.pad[h]=$(t,16+2*h)}process(t,n,r=!1){let o=r?0:2048,{h:s,r:i}=this,c=i[0],f=i[1],l=i[2],h=i[3],a=i[4],p=i[5],g=i[6],u=i[7],y=i[8],d=i[9],w=$(t,n+0),b=$(t,n+2),U=$(t,n+4),L=$(t,n+6),C=$(t,n+8),v=$(t,n+10),j=$(t,n+12),V=$(t,n+14),_=s[0]+(w&8191),S=s[1]+((w>>>13|b<<3)&8191),T=s[2]+((b>>>10|U<<6)&8191),I=s[3]+((U>>>7|L<<9)&8191),K=s[4]+((L>>>4|C<<12)&8191),O=s[5]+(C>>>1&8191),k=s[6]+((C>>>14|v<<2)&8191),N=s[7]+((v>>>11|j<<5)&8191),M=s[8]+((j>>>8|V<<8)&8191),P=s[9]+(V>>>5|o),m=0,H=m+_*c+S*(5*d)+T*(5*y)+I*(5*u)+K*(5*g);m=H>>>13,H&=8191,H+=O*(5*p)+k*(5*a)+N*(5*h)+M*(5*l)+P*(5*f),m+=H>>>13,H&=8191;let q=m+_*f+S*c+T*(5*d)+I*(5*y)+K*(5*u);m=q>>>13,q&=8191,q+=O*(5*g)+k*(5*p)+N*(5*a)+M*(5*h)+P*(5*l),m+=q>>>13,q&=8191;let W=m+_*l+S*f+T*c+I*(5*d)+K*(5*y);m=W>>>13,W&=8191,W+=O*(5*u)+k*(5*g)+N*(5*p)+M*(5*a)+P*(5*h),m+=W>>>13,W&=8191;let X=m+_*h+S*l+T*f+I*c+K*(5*d);m=X>>>13,X&=8191,X+=O*(5*y)+k*(5*u)+N*(5*g)+M*(5*p)+P*(5*a),m+=X>>>13,X&=8191;let ot=m+_*a+S*h+T*l+I*f+K*c;m=ot>>>13,ot&=8191,ot+=O*(5*d)+k*(5*y)+N*(5*u)+M*(5*g)+P*(5*p),m+=ot>>>13,ot&=8191;let st=m+_*p+S*a+T*h+I*l+K*f;m=st>>>13,st&=8191,st+=O*c+k*(5*d)+N*(5*y)+M*(5*u)+P*(5*g),m+=st>>>13,st&=8191;let ct=m+_*g+S*p+T*a+I*h+K*l;m=ct>>>13,ct&=8191,ct+=O*f+k*c+N*(5*d)+M*(5*y)+P*(5*u),m+=ct>>>13,ct&=8191;let it=m+_*u+S*g+T*p+I*a+K*h;m=it>>>13,it&=8191,it+=O*l+k*f+N*c+M*(5*d)+P*(5*y),m+=it>>>13,it&=8191;let ft=m+_*y+S*u+T*g+I*p+K*a;m=ft>>>13,ft&=8191,ft+=O*h+k*l+N*f+M*c+P*(5*d),m+=ft>>>13,ft&=8191;let lt=m+_*d+S*y+T*u+I*g+K*p;m=lt>>>13,lt&=8191,lt+=O*a+k*h+N*l+M*f+P*c,m+=lt>>>13,lt&=8191,m=(m<<2)+m|0,m=m+H|0,H=m&8191,m=m>>>13,q+=m,s[0]=H,s[1]=q,s[2]=W,s[3]=X,s[4]=ot,s[5]=st,s[6]=ct,s[7]=it,s[8]=ft,s[9]=lt}finalize(){let{h:t,pad:n}=this,r=new Uint16Array(10),o=t[1]>>>13;t[1]&=8191;for(let c=2;c<10;c++)t[c]+=o,o=t[c]>>>13,t[c]&=8191;t[0]+=o*5,o=t[0]>>>13,t[0]&=8191,t[1]+=o,o=t[1]>>>13,t[1]&=8191,t[2]+=o,r[0]=t[0]+5,o=r[0]>>>13,r[0]&=8191;for(let c=1;c<10;c++)r[c]=t[c]+o,o=r[c]>>>13,r[c]&=8191;r[9]-=8192;let s=(o^1)-1;for(let c=0;c<10;c++)r[c]&=s;s=~s;for(let c=0;c<10;c++)t[c]=t[c]&s|r[c];t[0]=(t[0]|t[1]<<13)&65535,t[1]=(t[1]>>>3|t[2]<<10)&65535,t[2]=(t[2]>>>6|t[3]<<7)&65535,t[3]=(t[3]>>>9|t[4]<<4)&65535,t[4]=(t[4]>>>12|t[5]<<1|t[6]<<14)&65535,t[5]=(t[6]>>>2|t[7]<<11)&65535,t[6]=(t[7]>>>5|t[8]<<8)&65535,t[7]=(t[8]>>>8|t[9]<<5)&65535;let i=t[0]+n[0];t[0]=i&65535;for(let c=1;c<8;c++)i=(t[c]+n[c]|0)+(i>>>16)|0,t[c]=i&65535;B(r)}update(t){et(this),E(t),t=z(t);let{buffer:n,blockLen:r}=this,o=t.length;for(let s=0;s<o;){let i=Math.min(r-this.pos,o-s);if(i===r){for(;r<=o-s;s+=r)this.process(t,s);continue}n.set(t.subarray(s,s+i),this.pos),this.pos+=i,s+=i,this.pos===r&&(this.process(n,0,!1),this.pos=0)}return this}destroy(){B(this.h,this.r,this.buffer,this.pad)}digestInto(t){et(this),gt(t,this),this.finished=!0;let{buffer:n,h:r}=this,{pos:o}=this;if(o){for(n[o++]=1;o<16;o++)n[o]=0;this.process(n,0,!0)}this.finalize();let s=0;for(let i=0;i<8;i++)t[s++]=r[i]>>>0,t[s++]=r[i]>>>8;return t}digest(){let{buffer:t,outputLen:n}=this;this.digestInto(t);let r=t.slice(0,n);return this.destroy(),r}};function qe(e){let t=(r,o)=>e(o).update(r).digest(),n=e(new Uint8Array(32));return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=r=>e(r),t}var le=qe(e=>new Wt(e));function ue(e,t,n,r,o,s=20){let i=e[0],c=e[1],f=e[2],l=e[3],h=t[0],a=t[1],p=t[2],g=t[3],u=t[4],y=t[5],d=t[6],w=t[7],b=o,U=n[0],L=n[1],C=n[2],v=i,j=c,V=f,_=l,S=h,T=a,I=p,K=g,O=u,k=y,N=d,M=w,P=b,m=U,H=L,q=C;for(let X=0;X<s;X+=2)v=v+S|0,P=x(P^v,16),O=O+P|0,S=x(S^O,12),v=v+S|0,P=x(P^v,8),O=O+P|0,S=x(S^O,7),j=j+T|0,m=x(m^j,16),k=k+m|0,T=x(T^k,12),j=j+T|0,m=x(m^j,8),k=k+m|0,T=x(T^k,7),V=V+I|0,H=x(H^V,16),N=N+H|0,I=x(I^N,12),V=V+I|0,H=x(H^V,8),N=N+H|0,I=x(I^N,7),_=_+K|0,q=x(q^_,16),M=M+q|0,K=x(K^M,12),_=_+K|0,q=x(q^_,8),M=M+q|0,K=x(K^M,7),v=v+T|0,q=x(q^v,16),N=N+q|0,T=x(T^N,12),v=v+T|0,q=x(q^v,8),N=N+q|0,T=x(T^N,7),j=j+I|0,P=x(P^j,16),M=M+P|0,I=x(I^M,12),j=j+I|0,P=x(P^j,8),M=M+P|0,I=x(I^M,7),V=V+K|0,m=x(m^V,16),O=O+m|0,K=x(K^O,12),V=V+K|0,m=x(m^V,8),O=O+m|0,K=x(K^O,7),_=_+S|0,H=x(H^_,16),k=k+H|0,S=x(S^k,12),_=_+S|0,H=x(H^_,8),k=k+H|0,S=x(S^k,7);let W=0;r[W++]=i+v|0,r[W++]=c+j|0,r[W++]=f+V|0,r[W++]=l+_|0,r[W++]=h+S|0,r[W++]=a+T|0,r[W++]=p+I|0,r[W++]=g+K|0,r[W++]=u+O|0,r[W++]=y+k|0,r[W++]=d+N|0,r[W++]=w+M|0,r[W++]=b+P|0,r[W++]=U+m|0,r[W++]=L+H|0,r[W++]=C+q|0}function $e(e,t,n,r){let o=e[0],s=e[1],i=e[2],c=e[3],f=t[0],l=t[1],h=t[2],a=t[3],p=t[4],g=t[5],u=t[6],y=t[7],d=n[0],w=n[1],b=n[2],U=n[3];for(let C=0;C<20;C+=2)o=o+f|0,d=x(d^o,16),p=p+d|0,f=x(f^p,12),o=o+f|0,d=x(d^o,8),p=p+d|0,f=x(f^p,7),s=s+l|0,w=x(w^s,16),g=g+w|0,l=x(l^g,12),s=s+l|0,w=x(w^s,8),g=g+w|0,l=x(l^g,7),i=i+h|0,b=x(b^i,16),u=u+b|0,h=x(h^u,12),i=i+h|0,b=x(b^i,8),u=u+b|0,h=x(h^u,7),c=c+a|0,U=x(U^c,16),y=y+U|0,a=x(a^y,12),c=c+a|0,U=x(U^c,8),y=y+U|0,a=x(a^y,7),o=o+l|0,U=x(U^o,16),u=u+U|0,l=x(l^u,12),o=o+l|0,U=x(U^o,8),u=u+U|0,l=x(l^u,7),s=s+h|0,d=x(d^s,16),y=y+d|0,h=x(h^y,12),s=s+h|0,d=x(d^s,8),y=y+d|0,h=x(h^y,7),i=i+a|0,w=x(w^i,16),p=p+w|0,a=x(a^p,12),i=i+a|0,w=x(w^i,8),p=p+w|0,a=x(a^p,7),c=c+f|0,b=x(b^c,16),g=g+b|0,f=x(f^g,12),c=c+f|0,b=x(b^c,8),g=g+b|0,f=x(f^g,7);let L=0;r[L++]=o,r[L++]=s,r[L++]=i,r[L++]=c,r[L++]=d,r[L++]=w,r[L++]=b,r[L++]=U}var Ze=Rt(ue,{counterRight:!1,counterLength:4,allowShortKeys:!1}),Fe=Rt(ue,{counterRight:!1,counterLength:8,extendNonceFn:$e,allowShortKeys:!1});var Ye=new Uint8Array(16),he=(e,t)=>{e.update(t);let n=t.length%16;n&&e.update(Ye.subarray(n))},Qe=new Uint8Array(32);function ae(e,t,n,r,o){o!==void 0&&E(o,void 0,"AAD");let s=e(t,n,Qe),i=bt(r.length,o?o.length:0,!0),c=le.create(s);o&&he(c,o),he(c,r),c.update(i);let f=c.digest();return B(s,i),f}var ge=e=>(t,n,r)=>({encrypt(s,i){let c=s.length;i=Q(c+16,i,!1),i.set(s);let f=i.subarray(0,-16);e(t,n,f,f,1);let l=ae(e,t,n,f,r);return i.set(l,c),B(l),i},decrypt(s,i){i=Q(s.length-16,i,!1);let c=s.subarray(0,-16),f=s.subarray(-16),l=ae(e,t,n,c,r);if(!wt(f,l))throw new Error("invalid tag");return i.set(s.subarray(0,-16)),e(t,n,i,i,1),B(l),i}}),pe=D({blockSize:64,nonceLength:12,tagLength:16},ge(Ze)),ye=D({blockSize:64,nonceLength:24,tagLength:16},ge(Fe));return Le(Ge);})();
378−/*! Bundled license information:
379−
380−@noble/ciphers/utils.js:
381− (*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) *)
382−*/
383173
384−
385−// CIPHER FUNCTIONS
174+// CIPHER (XSalsa20-Poly1305 via secretbox)
386175
387176function _Crypto_cipherKeyFromHex(hex)
388177{
@@ -400,22 +189,6 @@ function _Crypto_cipherKeyToHex(key)
400189 return key;
401190}
402191
403−function _Crypto_cipherNonce12FromHex(hex)
404−{
405− try {
406− var bytes = _Crypto_fromHex(hex);
407− if (bytes.length !== 12) { return __Maybe_Nothing; }
408− return __Maybe_Just(hex);
409− } catch (e) {
410− return __Maybe_Nothing;
411− }
412−}
413−
414−function _Crypto_cipherNonce12ToHex(nonce)
415−{
416− return nonce;
417−}
418−
419192function _Crypto_cipherNonce24FromHex(hex)
420193{
421194 try {
@@ -432,58 +205,26 @@ function _Crypto_cipherNonce24ToHex(nonce)
432205 return nonce;
433206}
434207
435−
436−// AES-256-GCM
437−
438−var _Crypto_aesGcmEncrypt = F3(function(key, nonce, plaintext)
208+var _Crypto_encrypt = F3(function(key, nonce, plaintext)
439209{
440− var cipher = _Crypto_ciphers.gcm(_Crypto_fromHex(key), _Crypto_fromHex(nonce));
441− return _Crypto_toHex(cipher.encrypt(_Crypto_fromHex(plaintext)));
210+ var result = _Crypto_nacl.secretbox(
211+ _Crypto_fromHex(plaintext),
212+ _Crypto_fromHex(nonce),
213+ _Crypto_fromHex(key)
214+ );
215+ return _Crypto_toHex(result);
442216});
443217
444−var _Crypto_aesGcmDecrypt = F3(function(key, nonce, ciphertext)
218+var _Crypto_decrypt = F3(function(key, nonce, ciphertext)
445219{
446220 try {
447− var cipher = _Crypto_ciphers.gcm(_Crypto_fromHex(key), _Crypto_fromHex(nonce));
448− return __Maybe_Just(_Crypto_toHex(cipher.decrypt(_Crypto_fromHex(ciphertext))));
449− } catch (e) {
450− return __Maybe_Nothing;
451− }
452−});
453−
454−
455−// CHACHA20-POLY1305
456−
457−var _Crypto_chacha20Encrypt = F3(function(key, nonce, plaintext)
458−{
459− var cipher = _Crypto_ciphers.chacha20poly1305(_Crypto_fromHex(key), _Crypto_fromHex(nonce));
460− return _Crypto_toHex(cipher.encrypt(_Crypto_fromHex(plaintext)));
461−});
462−
463−var _Crypto_chacha20Decrypt = F3(function(key, nonce, ciphertext)
464−{
465− try {
466− var cipher = _Crypto_ciphers.chacha20poly1305(_Crypto_fromHex(key), _Crypto_fromHex(nonce));
467− return __Maybe_Just(_Crypto_toHex(cipher.decrypt(_Crypto_fromHex(ciphertext))));
468− } catch (e) {
469− return __Maybe_Nothing;
470− }
471−});
472−
473−
474−// XCHACHA20-POLY1305
475−
476−var _Crypto_xchacha20Encrypt = F3(function(key, nonce, plaintext)
477−{
478− var cipher = _Crypto_ciphers.xchacha20poly1305(_Crypto_fromHex(key), _Crypto_fromHex(nonce));
479− return _Crypto_toHex(cipher.encrypt(_Crypto_fromHex(plaintext)));
480−});
481−
482−var _Crypto_xchacha20Decrypt = F3(function(key, nonce, ciphertext)
483−{
484− try {
485− var cipher = _Crypto_ciphers.xchacha20poly1305(_Crypto_fromHex(key), _Crypto_fromHex(nonce));
486− return __Maybe_Just(_Crypto_toHex(cipher.decrypt(_Crypto_fromHex(ciphertext))));
221+ var result = _Crypto_nacl.secretbox.open(
222+ _Crypto_fromHex(ciphertext),
223+ _Crypto_fromHex(nonce),
224+ _Crypto_fromHex(key)
225+ );
226+ if (result === null) { return __Maybe_Nothing; }
227+ return __Maybe_Just(_Crypto_toHex(result));
487228 } catch (e) {
488229 return __Maybe_Nothing;
489230 }
packages/http/elm.json+1−1
@@ -9,7 +9,7 @@
99 ],
1010 "elm-version": "0.19.0 <= v < 0.20.0",
1111 "dependencies": {
12− "elm/bytes": "1.0.0 <= v < 2.0.0",
12+ "lynxjs-elm/bytes": "1.0.0 <= v < 2.0.0",
1313 "elm/core": "1.0.1 <= v < 2.0.0",
1414 "elm/file": "1.0.0 <= v < 2.0.0",
1515 "elm/json": "1.1.0 <= v < 2.0.0"
packages/http/src/Elm/Kernel/Http.js+2−1
@@ -1,6 +1,7 @@
11/*
22
33import Dict exposing (empty, update)
4+import Elm.Kernel.Bytes exposing (wrap)
45import Elm.Kernel.Scheduler exposing (binding, fail, rawSpawn, succeed)
56import Elm.Kernel.Utils exposing (Tuple2)
67import Http exposing (BadUrl_, Timeout_, NetworkError_, BadStatus_, GoodStatus_, Sending, Receiving)
@@ -147,7 +148,7 @@ var _Http_mapExpect = F2(function(func, expect)
147148
148149function _Http_toDataView(arrayBuffer)
149150{
150− return new DataView(arrayBuffer);
151+ return __Bytes_wrap(new DataView(arrayBuffer));
151152}
152153
153154
packages/ui/src/Lynx.elm+3−3
@@ -31,7 +31,7 @@ type alias Attribute msg =
3131{-| A generic container element, equivalent to `<view>` in LynxJS.
3232This is the primary layout building block.
3333
34− view [ Lynx.Attributes.flexDirection "row" ]
34+ view [ Lynx.Attributes.flexDirection Row ]
3535 [ text [] [ textContent "Hello" ]
3636 ]
3737-}
@@ -43,7 +43,7 @@ view =
4343{-| A text container element, equivalent to `<text>` in LynxJS.
4444Use this when you need to apply styles or attributes to text.
4545
46− text [ Lynx.Attributes.fontSize "18px" ]
46+ text [ Lynx.Attributes.fontSize 18 ]
4747 [ textContent "Styled text" ]
4848-}
4949text : List (Attribute msg) -> List (Node msg) -> Node msg
@@ -72,7 +72,7 @@ image =
7272
7373{-| A scrollable container, equivalent to `<scroll-view>` in LynxJS.
7474
75− scrollView [ Lynx.Attributes.scrollDirection "vertical" ]
75+ scrollView [ Lynx.Attributes.scrollDirection Vertical ]
7676 [ view [] [ textContent "Item 1" ]
7777 , view [] [ textContent "Item 2" ]
7878 ]
packages/ui/src/Lynx/Attributes.elm+190−47
@@ -1,14 +1,24 @@
11module Lynx.Attributes exposing
22 ( width, height, minWidth, minHeight, maxWidth, maxHeight
3− , display, flexDirection, flexWrap, justifyContent, alignItems, alignSelf, flex, flexGrow, flexShrink
3+ , Display(..), display
4+ , FlexDirection(..), flexDirection
5+ , FlexWrap(..), flexWrap
6+ , Alignment(..), justifyContent, alignItems, alignSelf
7+ , flex, flexGrow, flexShrink
48 , padding, paddingTop, paddingRight, paddingBottom, paddingLeft
59 , margin, marginTop, marginRight, marginBottom, marginLeft
6− , position, top, right, bottom, left, zIndex
7− , backgroundColor, opacity, overflow
10+ , Position(..), position, top, right, bottom, left, zIndex
11+ , backgroundColor, opacity
12+ , Overflow(..), overflow
813 , borderWidth, borderColor, borderRadius
9− , fontSize, fontWeight, fontFamily, color, textAlign, lineHeight, textOverflow
14+ , fontSize
15+ , FontWeight(..), fontWeight
16+ , fontFamily, color
17+ , TextAlign(..), textAlign
18+ , lineHeight
19+ , TextOverflow(..), textOverflow
1020 , src, placeholder, value
11− , scrollDirection
21+ , ScrollDirection(..), scrollDirection
1222 , id, class_
1323 )
1424
@@ -16,29 +26,39 @@ module Lynx.Attributes exposing
1626
1727# Layout
1828@docs width, height, minWidth, minHeight, maxWidth, maxHeight
19−@docs display, flexDirection, flexWrap, justifyContent, alignItems, alignSelf, flex, flexGrow, flexShrink
29+@docs Display, display
30+@docs FlexDirection, flexDirection
31+@docs FlexWrap, flexWrap
32+@docs Alignment, justifyContent, alignItems, alignSelf
33+@docs flex, flexGrow, flexShrink
2034
2135# Spacing
2236@docs padding, paddingTop, paddingRight, paddingBottom, paddingLeft
2337@docs margin, marginTop, marginRight, marginBottom, marginLeft
2438
2539# Positioning
26−@docs position, top, right, bottom, left, zIndex
40+@docs Position, position, top, right, bottom, left, zIndex
2741
2842# Appearance
29−@docs backgroundColor, opacity, overflow
43+@docs backgroundColor, opacity
44+@docs Overflow, overflow
3045
3146# Borders
3247@docs borderWidth, borderColor, borderRadius
3348
3449# Typography
35−@docs fontSize, fontWeight, fontFamily, color, textAlign, lineHeight, textOverflow
50+@docs fontSize
51+@docs FontWeight, fontWeight
52+@docs fontFamily, color
53+@docs TextAlign, textAlign
54+@docs lineHeight
55+@docs TextOverflow, textOverflow
3656
3757# Content
3858@docs src, placeholder, value
3959
4060# Scrolling
41−@docs scrollDirection
61+@docs ScrollDirection, scrollDirection
4262
4363# Identity
4464@docs id, class_
@@ -124,39 +144,102 @@ maxHeight =
124144
125145
126146{-| -}
127−display : String -> VirtualDom.Attribute msg
128−display =
129− style "display"
147+type Display
148+ = Flex
149+ | DisplayNone
130150
131151
132152{-| -}
133−flexDirection : String -> VirtualDom.Attribute msg
134−flexDirection =
135− style "flexDirection"
153+display : Display -> VirtualDom.Attribute msg
154+display d =
155+ style "display" <|
156+ case d of
157+ Flex -> "flex"
158+ DisplayNone -> "none"
136159
137160
138161{-| -}
139−flexWrap : String -> VirtualDom.Attribute msg
140−flexWrap =
141− style "flexWrap"
162+type FlexDirection
163+ = Row
164+ | Column
165+ | RowReverse
166+ | ColumnReverse
142167
143168
144169{-| -}
145−justifyContent : String -> VirtualDom.Attribute msg
146−justifyContent =
147− style "justifyContent"
170+flexDirection : FlexDirection -> VirtualDom.Attribute msg
171+flexDirection d =
172+ style "flexDirection" <|
173+ case d of
174+ Row -> "row"
175+ Column -> "column"
176+ RowReverse -> "row-reverse"
177+ ColumnReverse -> "column-reverse"
148178
149179
150180{-| -}
151−alignItems : String -> VirtualDom.Attribute msg
152−alignItems =
153− style "alignItems"
181+type FlexWrap
182+ = Wrap
183+ | NoWrap
184+ | WrapReverse
154185
155186
156187{-| -}
157−alignSelf : String -> VirtualDom.Attribute msg
158−alignSelf =
159− style "alignSelf"
188+flexWrap : FlexWrap -> VirtualDom.Attribute msg
189+flexWrap w =
190+ style "flexWrap" <|
191+ case w of
192+ Wrap -> "wrap"
193+ NoWrap -> "nowrap"
194+ WrapReverse -> "wrap-reverse"
195+
196+
197+{-| Alignment values for `justifyContent`, `alignItems`, and `alignSelf`.
198+
199+Not all values are valid for all properties — `SpaceBetween`, `SpaceAround`,
200+and `SpaceEvenly` only apply to `justifyContent`, while `Stretch` and `Baseline`
201+only apply to `alignItems` and `alignSelf`.
202+-}
203+type Alignment
204+ = Start
205+ | Center
206+ | End
207+ | SpaceBetween
208+ | SpaceAround
209+ | SpaceEvenly
210+ | Stretch
211+ | Baseline
212+
213+
214+alignmentToString : Alignment -> String
215+alignmentToString a =
216+ case a of
217+ Start -> "flex-start"
218+ Center -> "center"
219+ End -> "flex-end"
220+ SpaceBetween -> "space-between"
221+ SpaceAround -> "space-around"
222+ SpaceEvenly -> "space-evenly"
223+ Stretch -> "stretch"
224+ Baseline -> "baseline"
225+
226+
227+{-| -}
228+justifyContent : Alignment -> VirtualDom.Attribute msg
229+justifyContent a =
230+ style "justifyContent" (alignmentToString a)
231+
232+
233+{-| -}
234+alignItems : Alignment -> VirtualDom.Attribute msg
235+alignItems a =
236+ style "alignItems" (alignmentToString a)
237+
238+
239+{-| -}
240+alignSelf : Alignment -> VirtualDom.Attribute msg
241+alignSelf a =
242+ style "alignSelf" (alignmentToString a)
160243
161244
162245{-| -}
@@ -246,9 +329,18 @@ marginLeft =
246329
247330
248331{-| -}
249−position : String -> VirtualDom.Attribute msg
250−position =
251− style "position"
332+type Position
333+ = Relative
334+ | Absolute
335+
336+
337+{-| -}
338+position : Position -> VirtualDom.Attribute msg
339+position p =
340+ style "position" <|
341+ case p of
342+ Relative -> "relative"
343+ Absolute -> "absolute"
252344
253345
254346{-| -}
@@ -298,9 +390,20 @@ opacity =
298390
299391
300392{-| -}
301−overflow : String -> VirtualDom.Attribute msg
302−overflow =
303− style "overflow"
393+type Overflow
394+ = Visible
395+ | Hidden
396+ | Scroll
397+
398+
399+{-| -}
400+overflow : Overflow -> VirtualDom.Attribute msg
401+overflow o =
402+ style "overflow" <|
403+ case o of
404+ Visible -> "visible"
405+ Hidden -> "hidden"
406+ Scroll -> "scroll"
304407
305408
306409
@@ -336,9 +439,18 @@ fontSize =
336439
337440
338441{-| -}
339−fontWeight : String -> VirtualDom.Attribute msg
340−fontWeight =
341− style "fontWeight"
442+type FontWeight
443+ = Normal
444+ | Bold
445+
446+
447+{-| -}
448+fontWeight : FontWeight -> VirtualDom.Attribute msg
449+fontWeight w =
450+ style "fontWeight" <|
451+ case w of
452+ Normal -> "normal"
453+ Bold -> "bold"
342454
343455
344456{-| -}
@@ -354,9 +466,22 @@ color =
354466
355467
356468{-| -}
357−textAlign : String -> VirtualDom.Attribute msg
358−textAlign =
359− style "textAlign"
469+type TextAlign
470+ = Left
471+ | Right
472+ | TextCenter
473+ | Justify
474+
475+
476+{-| -}
477+textAlign : TextAlign -> VirtualDom.Attribute msg
478+textAlign a =
479+ style "textAlign" <|
480+ case a of
481+ Left -> "left"
482+ Right -> "right"
483+ TextCenter -> "center"
484+ Justify -> "justify"
360485
361486
362487{-| -}
@@ -366,9 +491,18 @@ lineHeight =
366491
367492
368493{-| -}
369−textOverflow : String -> VirtualDom.Attribute msg
370−textOverflow =
371− style "textOverflow"
494+type TextOverflow
495+ = Clip
496+ | Ellipsis
497+
498+
499+{-| -}
500+textOverflow : TextOverflow -> VirtualDom.Attribute msg
501+textOverflow o =
502+ style "textOverflow" <|
503+ case o of
504+ Clip -> "clip"
505+ Ellipsis -> "ellipsis"
372506
373507
374508
@@ -400,11 +534,20 @@ value =
400534-- SCROLLING
401535
402536
403−{-| Scroll direction for scroll-view: "vertical" or "horizontal".
537+{-| -}
538+type ScrollDirection
539+ = Vertical
540+ | Horizontal
541+
542+
543+{-| Scroll direction for scroll-view.
404544-}
405−scrollDirection : String -> VirtualDom.Attribute msg
406−scrollDirection =
407− attr "scroll-direction"
545+scrollDirection : ScrollDirection -> VirtualDom.Attribute msg
546+scrollDirection d =
547+ attr "scroll-direction" <|
548+ case d of
549+ Vertical -> "vertical"
550+ Horizontal -> "horizontal"
408551
409552
410553
packages/virtual-dom/src/Elm/Kernel/VirtualDom.js+12−20
@@ -1,7 +1,6 @@
11/*
22
33import Basics exposing (identity)
4−import Elm.Kernel.Debug exposing (crash)
54import Elm.Kernel.Json exposing (equality, runHelp, unwrap, wrap)
65import Elm.Kernel.List exposing (Cons, Nil)
76import Elm.Kernel.Utils exposing (Tuple2)
@@ -15,29 +14,26 @@ import VirtualDom exposing (toHandlerInt)
1514
1615var _Lynx_g = (typeof globalThis !== 'undefined' ? globalThis : scope);
1716function _Lynx_papi(name) { return _Lynx_g['_' + '_' + name] || function() {}; }
17+var _Lynx_createViewFn = _Lynx_papi('CreateView');
18+var _Lynx_createTextFn = _Lynx_papi('CreateText');
19+var _Lynx_createImageFn = _Lynx_papi('CreateImage');
1820function _Lynx_createElement(tag) {
1921 var pId = (_Lynx_g['native'] && _Lynx_g['native']['currentPageId']) || 0;
20− var creators = { 'view': 'CreateView', 'text': 'CreateText', 'image': 'CreateImage' };
21− var name = creators[tag] || 'CreateView';
22− var fn = _Lynx_g['_' + '_' + name];
23− if (typeof fn === 'function') { return fn(pId); }
24− return _Lynx_papi('CreateElement')(tag, pId);
25−}
26−function _Lynx_createRawText(text) {
27− var fn = _Lynx_g['_' + '_CreateRawText'];
28− if (typeof fn === 'function') { return fn(text); }
29− return {};
22+ return (tag === 'text' ? _Lynx_createTextFn
23+ : tag === 'image' ? _Lynx_createImageFn
24+ : _Lynx_createViewFn)(pId);
3025}
26+var _Lynx_createRawText = _Lynx_papi('CreateRawText');
3127var _Lynx_appendChild = _Lynx_papi('AppendElement');
3228var _Lynx_removeElement = _Lynx_papi('RemoveElement');
3329var _Lynx_replaceElement = _Lynx_papi('ReplaceElement');
3430var _Lynx_insertBefore = _Lynx_papi('InsertElementBefore');
3531var _Lynx_setAttribute = _Lynx_papi('SetAttribute');
36−var _Lynx_getChildren = _Lynx_g['_' + '_GetChildren'] || function() { return []; };
37−var _Lynx_getParent = _Lynx_g['_' + '_GetParent'] || function() { return null; };
32+var _Lynx_getChildren = _Lynx_papi('GetChildren');
33+var _Lynx_getParent = _Lynx_papi('GetParent');
3834var _Lynx_addEvent = _Lynx_papi('AddEvent');
3935var _Lynx_setInlineStyles = _Lynx_papi('SetInlineStyles');
40−var _VirtualDom_elementMeta = new Map();
36+var _VirtualDom_elementMeta = new WeakMap();
4137function _VirtualDom_getMeta(el) {
4238 var meta = _VirtualDom_elementMeta.get(el);
4339 if (!meta) { meta = {}; _VirtualDom_elementMeta.set(el, meta); }
@@ -529,11 +525,7 @@ function _VirtualDom_applyFacts(domNode, eventNode, facts)
529525
530526function _VirtualDom_applyStyles(domNode, styles)
531527{
532− var _sIS = _Lynx_g['_' + '_SetInlineStyles'];
533− if (typeof _sIS === 'function')
534− {
535− _sIS(domNode, styles);
536− }
528+ _Lynx_setInlineStyles(domNode, styles);
537529}
538530
539531
@@ -1454,7 +1446,7 @@ function _VirtualDom_applyPatch(domNode, patch)
14541446 return patch.__data(domNode);
14551447
14561448 default:
1457− __Debug_crash(10); // 'Ran into an unknown patch!'
1449+ throw new Error('VirtualDom: unknown patch type');
14581450 }
14591451}
14601452
terminal/src/Dev.hs+1−1
@@ -137,7 +137,7 @@ compileAndWrite root path elmOutput =
137137 Task.mapError Exit.MakeBadGenerate (Generate.dev root details artifacts)
138138 case result of
139139 Left e ->
140− do _ <- Reporting.attemptWithStyle Reporting.silent Exit.makeToReport (return (Left e))
140+ do Exit.toStderr (Exit.makeToReport e)
141141 return False
142142
143143 Right javascript ->
terminal/src/Make.hs+14−10
@@ -103,7 +103,8 @@ runHelp root paths style (Flags debug optimize maybeOutput _ maybeDocs verbose)
103103 _ ->
104104 do _name <- hasOneMain artifacts
105105 builder <- toBuilder root details desiredMode artifacts
106− Task.io $ bundle style "main.lynx.bundle" builder (Build.getRootNames artifacts) verbose
106+ let isOptimized = case desiredMode of { Prod -> True; _ -> False }
107+ Task.io $ bundle style "main.lynx.bundle" builder (Build.getRootNames artifacts) verbose isOptimized
107108
108109 Just DevNull ->
109110 return ()
@@ -125,7 +126,8 @@ runHelp root paths style (Flags debug optimize maybeOutput _ maybeDocs verbose)
125126 Just (Bundle target) ->
126127 do _name <- hasOneMain artifacts
127128 builder <- toBuilder root details desiredMode artifacts
128− Task.io $ bundle style target builder (Build.getRootNames artifacts) verbose
129+ let isOptimized = case desiredMode of { Prod -> True; _ -> False }
130+ Task.io $ bundle style target builder (Build.getRootNames artifacts) verbose isOptimized
129131
130132
131133
@@ -339,8 +341,8 @@ isDevNull name =
339341-- BUNDLE
340342
341343
342−bundle :: Reporting.Style -> FilePath -> B.Builder -> NE.List ModuleName.Raw -> Bool -> IO ()
343−bundle style target js names verbose =
344+bundle :: Reporting.Style -> FilePath -> B.Builder -> NE.List ModuleName.Raw -> Bool -> Bool -> IO ()
345+bundle style target js names verbose optimize =
344346 do startTime <- Time.getPOSIXTime
345347 home <- Stuff.getElmHome
346348 let bundlerDir = home </> "bundler"
@@ -350,7 +352,7 @@ bundle style target js names verbose =
350352
351353 -- Set up bundler project
352354 Dir.createDirectoryIfMissing True srcDir
353− setupBundlerProject bundlerDir
355+ setupBundlerProject bundlerDir optimize
354356
355357 -- Write compiled Elm JS
356358 File.writeBuilder elmFile js
@@ -389,14 +391,14 @@ assembleAndBuild bundlerDir verbose =
389391 callIn bundlerDir "npx" ["rspack", "build"] verbose
390392
391393
392−setupBundlerProject :: FilePath -> IO ()
393−setupBundlerProject dir =
394+setupBundlerProject :: FilePath -> Bool -> IO ()
395+setupBundlerProject dir optimize =
394396 do let pkgFile = dir </> "package.json"
395397 let cfgFile = dir </> "rspack.config.js"
396398 let stubsFile = dir </> "src" </> "stubs.js"
397399 let initFile = dir </> "src" </> "init.js"
398400 writeFile pkgFile packageJson
399− writeFile cfgFile rspackConfig
401+ writeFile cfgFile (rspackConfig optimize)
400402 writeFile stubsFile stubsJs
401403 writeFile initFile initJs
402404
@@ -473,13 +475,15 @@ packageJson = unlines
473475 ]
474476
475477
476−rspackConfig :: String
477−rspackConfig = unlines
478+rspackConfig :: Bool -> String
479+rspackConfig optimize = unlines
478480 [ "import { LynxEncodePlugin, LynxTemplatePlugin } from '@lynx-js/template-webpack-plugin';"
479481 , "import { defineConfig } from '@rspack/cli';"
480482 , ""
481483 , "export default defineConfig({"
482484 , " entry: { main: './src/all.js' },"
485+ , " mode: '" ++ (if optimize then "production" else "development") ++ "',"
486+ , " optimization: { minimize: " ++ (if optimize then "true" else "false") ++ " },"
483487 , " plugins: ["
484488 , " new LynxEncodePlugin(),"
485489 , " new LynxTemplatePlugin({ filename: 'main.lynx.bundle', intermediate: 'main' }),"