lightview 1.8.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (264) hide show
  1. package/.agent/workflows/daisyui-component-migration.md +155 -0
  2. package/.codacy/cli.sh +149 -0
  3. package/.codacy/codacy.yaml +15 -0
  4. package/.github/instructions/codacy.instructions.md +72 -0
  5. package/.wranglerignore +21 -0
  6. package/README.md +1330 -19
  7. package/_headers +4 -0
  8. package/build.js +70 -0
  9. package/components/actions/button.js +151 -0
  10. package/components/actions/dropdown.js +120 -0
  11. package/components/actions/modal.js +146 -0
  12. package/components/actions/swap.js +118 -0
  13. package/components/daisyui.js +288 -0
  14. package/components/data-display/accordion.js +128 -0
  15. package/components/data-display/alert.js +112 -0
  16. package/components/data-display/avatar.js +170 -0
  17. package/components/data-display/badge.js +82 -0
  18. package/components/data-display/card.js +151 -0
  19. package/components/data-display/carousel.js +94 -0
  20. package/components/data-display/chart.js +220 -0
  21. package/components/data-display/chat.js +128 -0
  22. package/components/data-display/collapse.js +103 -0
  23. package/components/data-display/countdown.js +69 -0
  24. package/components/data-display/diff.js +111 -0
  25. package/components/data-display/kbd.js +65 -0
  26. package/components/data-display/loading.js +75 -0
  27. package/components/data-display/progress.js +79 -0
  28. package/components/data-display/radial-progress.js +88 -0
  29. package/components/data-display/skeleton.js +66 -0
  30. package/components/data-display/stats.js +159 -0
  31. package/components/data-display/table.js +146 -0
  32. package/components/data-display/timeline.js +146 -0
  33. package/components/data-display/toast.js +72 -0
  34. package/components/data-display/tooltip.js +74 -0
  35. package/components/data-input/checkbox.js +253 -0
  36. package/components/data-input/file-input.js +224 -0
  37. package/components/data-input/input.js +264 -0
  38. package/components/data-input/radio.js +338 -0
  39. package/components/data-input/range.js +204 -0
  40. package/components/data-input/rating.js +219 -0
  41. package/components/data-input/select.js +287 -0
  42. package/components/data-input/textarea.js +287 -0
  43. package/components/data-input/toggle.js +201 -0
  44. package/components/index.js +137 -0
  45. package/components/layout/divider.js +72 -0
  46. package/components/layout/drawer.js +142 -0
  47. package/components/layout/footer.js +100 -0
  48. package/components/layout/hero.js +109 -0
  49. package/components/layout/indicator.js +90 -0
  50. package/components/layout/join.js +78 -0
  51. package/components/layout/navbar.js +110 -0
  52. package/components/navigation/breadcrumbs.js +91 -0
  53. package/components/navigation/dock.js +103 -0
  54. package/components/navigation/menu.js +126 -0
  55. package/components/navigation/pagination.js +105 -0
  56. package/components/navigation/steps.js +89 -0
  57. package/components/navigation/tabs.css +177 -0
  58. package/components/navigation/tabs.js +123 -0
  59. package/components/theme/theme-switch.css +65 -0
  60. package/components/theme/theme-switch.js +177 -0
  61. package/docs/about.html +164 -0
  62. package/docs/api/computed.html +184 -0
  63. package/docs/api/effects.html +173 -0
  64. package/docs/api/elements.html +180 -0
  65. package/docs/api/enhance.html +225 -0
  66. package/docs/api/hypermedia.html +165 -0
  67. package/docs/api/index.html +178 -0
  68. package/docs/api/nav.html +18 -0
  69. package/docs/api/signals.html +136 -0
  70. package/docs/api/state.html +217 -0
  71. package/docs/assets/images/logo-favicon.svg +42 -0
  72. package/docs/assets/images/logo-static.svg +40 -0
  73. package/docs/assets/images/logo.svg +66 -0
  74. package/docs/assets/js/examplify.js +395 -0
  75. package/docs/assets/styles/site.css +1102 -0
  76. package/docs/assets/styles/themes.css +236 -0
  77. package/docs/components/accordion.html +439 -0
  78. package/docs/components/alert.html +528 -0
  79. package/docs/components/avatar.html +586 -0
  80. package/docs/components/badge.html +531 -0
  81. package/docs/components/breadcrumbs.html +278 -0
  82. package/docs/components/button.html +579 -0
  83. package/docs/components/card.html +561 -0
  84. package/docs/components/carousel.html +286 -0
  85. package/docs/components/chart-area.html +702 -0
  86. package/docs/components/chart-bar.html +782 -0
  87. package/docs/components/chart-column.html +735 -0
  88. package/docs/components/chart-line.html +794 -0
  89. package/docs/components/chart-pie.html +823 -0
  90. package/docs/components/chart.html +610 -15
  91. package/docs/components/chat.html +547 -0
  92. package/docs/components/checkbox.html +641 -0
  93. package/docs/components/collapse.html +536 -0
  94. package/docs/components/component-nav.html +53 -0
  95. package/docs/components/countdown.html +470 -0
  96. package/docs/components/diff.html +245 -0
  97. package/docs/components/divider.html +240 -0
  98. package/docs/components/dock.html +277 -0
  99. package/docs/components/drawer.html +515 -0
  100. package/docs/components/dropdown.html +479 -0
  101. package/docs/components/file-input.html +591 -0
  102. package/docs/components/footer.html +301 -0
  103. package/docs/components/gallery.html +504 -0
  104. package/docs/components/hero.html +264 -0
  105. package/docs/components/index.css +840 -0
  106. package/docs/components/index.html +735 -0
  107. package/docs/components/indicator.html +342 -0
  108. package/docs/components/input.html +644 -0
  109. package/docs/components/join.html +285 -0
  110. package/docs/components/kbd.html +322 -0
  111. package/docs/components/loading.html +521 -0
  112. package/docs/components/menu.html +461 -0
  113. package/docs/components/modal.html +639 -0
  114. package/docs/components/navbar.html +321 -0
  115. package/docs/components/pagination.html +279 -0
  116. package/docs/components/progress.html +514 -0
  117. package/docs/components/radial-progress.html +434 -0
  118. package/docs/components/radio.html +655 -0
  119. package/docs/components/range.html +611 -0
  120. package/docs/components/rating.html +642 -0
  121. package/docs/components/select.html +696 -0
  122. package/docs/components/sidebar-setup.js +93 -0
  123. package/docs/components/skeleton.html +447 -0
  124. package/docs/components/spinner.html +68 -0
  125. package/docs/components/stats.html +486 -0
  126. package/docs/components/steps.html +356 -0
  127. package/docs/components/swap.html +517 -0
  128. package/docs/components/switch.html +68 -0
  129. package/docs/components/table.html +668 -0
  130. package/docs/components/tabs.html +506 -0
  131. package/docs/components/text-input.html +68 -0
  132. package/docs/components/textarea.html +603 -0
  133. package/docs/components/timeline.html +485 -42
  134. package/docs/components/toast.html +474 -0
  135. package/docs/components/toggle.html +564 -0
  136. package/docs/components/tooltip.html +423 -0
  137. package/docs/examples/getting-started-example.html +40 -0
  138. package/docs/examples/index.html +93 -0
  139. package/docs/getting-started/index.html +739 -0
  140. package/docs/getting-started/reviews.html +23 -0
  141. package/docs/getting-started/reviews.odom +108 -0
  142. package/docs/getting-started/reviews.vdom +84 -0
  143. package/docs/index.html +132 -42
  144. package/docs/playground.html +416 -0
  145. package/docs/router.html +285 -0
  146. package/docs/styles/index.html +190 -0
  147. package/functions/_middleware.js +32 -0
  148. package/index.html +309 -0
  149. package/lightview-router.js +364 -0
  150. package/lightview-x.js +1577 -0
  151. package/lightview.js +659 -1200
  152. package/lightview.js.backup +793 -0
  153. package/middleware/locale.js +25 -0
  154. package/middleware/markdown.js +44 -0
  155. package/middleware/notFound.js +37 -0
  156. package/package.json +27 -41
  157. package/watch.js +92 -0
  158. package/wrangler.toml +12 -0
  159. package/.idea/lightview.iml +0 -12
  160. package/.idea/modules.xml +0 -8
  161. package/.idea/vcs.xml +0 -6
  162. package/LICENSE +0 -21
  163. package/codepen-no-tabs-embed.css +0 -2
  164. package/docs/CNAME +0 -1
  165. package/docs/api.html +0 -674
  166. package/docs/blank.html +0 -10
  167. package/docs/comparedto.html +0 -89
  168. package/docs/components/chart-repl.html +0 -69
  169. package/docs/components/components.js +0 -113
  170. package/docs/components/contents.html +0 -17
  171. package/docs/components/gantt-repl.html +0 -61
  172. package/docs/components/gantt.html +0 -42
  173. package/docs/components/gauge-repl.html +0 -66
  174. package/docs/components/gauge.html +0 -20
  175. package/docs/components/orgchart-repl.html +0 -64
  176. package/docs/components/orgchart.html +0 -41
  177. package/docs/components/repl-as-src.html +0 -17
  178. package/docs/components/repl-repl.html +0 -95
  179. package/docs/components/repl.html +0 -527
  180. package/docs/components/timeline-repl.html +0 -72
  181. package/docs/components.html +0 -14
  182. package/docs/css/highlightjs.min.css +0 -9
  183. package/docs/css/tutorial.css +0 -35
  184. package/docs/examples/anchor.html +0 -11
  185. package/docs/examples/chart.html +0 -34
  186. package/docs/examples/counter.html +0 -26
  187. package/docs/examples/counter.test.mjs +0 -47
  188. package/docs/examples/counter2.html +0 -26
  189. package/docs/examples/directives.html +0 -79
  190. package/docs/examples/foreign.html +0 -50
  191. package/docs/examples/forgeinform.html +0 -98
  192. package/docs/examples/form.html +0 -61
  193. package/docs/examples/gauge.html +0 -18
  194. package/docs/examples/invalid-template-literals.html +0 -44
  195. package/docs/examples/medium/remote.html +0 -60
  196. package/docs/examples/message.html +0 -18
  197. package/docs/examples/nested.html +0 -11
  198. package/docs/examples/object-bound-form.html +0 -34
  199. package/docs/examples/remote-server.js +0 -51
  200. package/docs/examples/remote.html +0 -34
  201. package/docs/examples/remote.json +0 -1
  202. package/docs/examples/scratch.html +0 -69
  203. package/docs/examples/sensors/index.html +0 -44
  204. package/docs/examples/sensors/sensor-server.js +0 -30
  205. package/docs/examples/shared.html +0 -41
  206. package/docs/examples/template.html +0 -33
  207. package/docs/examples/timeline.html +0 -21
  208. package/docs/examples/todo.html +0 -40
  209. package/docs/examples/top.html +0 -10
  210. package/docs/examples/types.html +0 -94
  211. package/docs/examples/xor.html +0 -62
  212. package/docs/examples.html +0 -25
  213. package/docs/javascript/codejar.min.js +0 -8
  214. package/docs/javascript/highlightjs.min.js +0 -1173
  215. package/docs/javascript/isomorphic-git.js +0 -9
  216. package/docs/javascript/json5.min.js +0 -1
  217. package/docs/javascript/lightning-fs.js +0 -1
  218. package/docs/javascript/lightview.js +0 -1285
  219. package/docs/javascript/marked.min.js +0 -6
  220. package/docs/javascript/peerjs.min.js +0 -70
  221. package/docs/javascript/turndown.js +0 -973
  222. package/docs/javascript/types.js +0 -606
  223. package/docs/javascript/utils.js +0 -45
  224. package/docs/lightview.html +0 -63
  225. package/docs/old_index.html +0 -965
  226. package/docs/old_index.md +0 -1132
  227. package/docs/slidein.html +0 -51
  228. package/docs/tutorial/0-getting-started.html +0 -67
  229. package/docs/tutorial/1-intro-to-variables.html +0 -103
  230. package/docs/tutorial/10-template-components.html +0 -80
  231. package/docs/tutorial/11-linked-components.html +0 -76
  232. package/docs/tutorial/12-imported-components.html +0 -67
  233. package/docs/tutorial/13-input-binding.html +0 -94
  234. package/docs/tutorial/14-automatic-variable-creation.html +0 -74
  235. package/docs/tutorial/15-form-binding.html +0 -110
  236. package/docs/tutorial/16-if-directive.html +0 -60
  237. package/docs/tutorial/17-loop-directives.html +0 -83
  238. package/docs/tutorial/18-sanitizing-and-escaping-input.html +0 -79
  239. package/docs/tutorial/2-imported-and-exported-variables.html +0 -80
  240. package/docs/tutorial/3-data-types.html +0 -89
  241. package/docs/tutorial/4-extended-data-types.html +0 -83
  242. package/docs/tutorial/5-extended-functional-types.html +0 -96
  243. package/docs/tutorial/5.1-extended-functional-types.html +0 -79
  244. package/docs/tutorial/5.2-extended-functional-types.html +0 -70
  245. package/docs/tutorial/6-conventional-javascript.html +0 -75
  246. package/docs/tutorial/7-monitoring-with-observers.html +0 -107
  247. package/docs/tutorial/8-event-listeners.html +0 -65
  248. package/docs/tutorial/9-intro-to-components.html +0 -91
  249. package/docs/tutorial/contents.html +0 -32
  250. package/docs/tutorial/my-component.html +0 -29
  251. package/docs/tutorial/remote-value.json +0 -4
  252. package/docs/websiterepl.html +0 -46
  253. package/jest-puppeteer.config.js +0 -5
  254. package/jest.config.json +0 -12
  255. package/lightview.min.js +0 -1
  256. package/lightview_good.js +0 -1267
  257. package/lightview_optimized.js +0 -1274
  258. package/repl_hold.html +0 -320
  259. package/test/basic.html +0 -104
  260. package/test/basic.test.mjs +0 -315
  261. package/test/extended.html +0 -29
  262. package/test/extended.test.mjs +0 -448
  263. package/types.js +0 -607
  264. package/unsplash.key +0 -1
@@ -1,46 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <title><!DOCTYPE html>
6
- <html lang="en">
7
- <head>
8
- <meta charset="UTF-8">
9
- <title>Lightview:REPL</title>
10
- <link href="./components/repl.html" rel="module">
11
- <script src="./javascript/highlightjs.min.js"></script>
12
- <script src="./javascript/marked.min.js"></script>
13
- <script src="./javascript/utils.js"></script>
14
- </head>
15
- <body>
16
- <script src="./javascript/lightview.js"></script>
17
- <div class="markdown">
18
-
19
- </div>
20
- <l-repl id="repl" style="min-height:95vh;min-width:600px;" previewpinned previewheight="250px">
21
- <div slot="headhtml"></div>
22
- <div slot="bodyhtml"></div>
23
- <div slot="script"></div>
24
- <div slot="css"></div>
25
- <template slot="src">
26
- <l-head>
27
- <script src="./javascript/lightview.js?as=x-body"></script>
28
- </l-head>
29
- <l-body>
30
- <div class="message">${message}</div>
31
- </l-body>
32
- <script id="lightview">
33
- currentComponent.mount = function() {
34
- this.variables({message:"string"},{set:"Hello world!"});
35
- }
36
- </script>
37
- <style>
38
- .message { font-size: large }
39
- </style>
40
- </template>
41
- </l-repl>
42
- <script>
43
- processMarkdown();
44
- </script>
45
- </body>
46
- </html>
@@ -1,5 +0,0 @@
1
- module.exports = {
2
- server: {
3
- command: 'http-server'
4
- }
5
- }
package/jest.config.json DELETED
@@ -1,12 +0,0 @@
1
- {
2
- "moduleFileExtensions": ["mjs", "js", "jsx", "ts", "tsx", "json", "node"],
3
- "testMatch": [
4
- "**/?(*.)test.?js"
5
- ],
6
- "verbose": true,
7
- "transform": {},
8
- "testEnvironment": "jest-environment-node",
9
- "globalSetup": "jest-environment-puppeteer/setup",
10
- "globalTeardown": "jest-environment-puppeteer/teardown",
11
- "testEnvironment": "jest-environment-puppeteer"
12
- }
package/lightview.min.js DELETED
@@ -1 +0,0 @@
1
- var e=window.currentComponent=null;document.body&&(e=window.currentComponent=document.currentComponent=document.body);var t=window.Lightview={},{observe:r}=(()=>{let r;const n=new DOMParser;t.sanitizeTemplate=e=>e.replace(/function\s+/g,"").replace(/function\(/g,"").replace(/=\s*>/g,"").replace(/(while|do|for|alert)\s*\(/g,"").replace(/console\.[a-zA-Z$]+\s*\(/g,"");const a=document.createElement("textarea");t.escapeHTML=function(e){return a.textContent=e,a.innerHTML};const o=e=>{if(e&&/^\$\{[a-zA-z_0-9.]*\}$/g.test(e))return e.substring(2,e.length-1)},i=(e,t,r=t.length-1,n)=>{for(let a=0;a<=r;a++)if(void 0===(e=null==e[t[a]]&&n?e[t[a]]="function"==typeof n?Object.create(n.prototype):{}:e[t[a]]))return;return e},s=(e,t,r,n)=>{e.addEventListener(t,(e=>{n&&Object.defineProperty(e,"self",{value:n}),r(e)}))},c=async e=>{e.preventDefault();const t=e.target;if(t===e.currentTarget){const{as:e}=await L(t);h(document,t.getAttribute("target")).forEach((t=>{for(;t.lastChild;)t.lastChild.remove();t.appendChild(document.createElement(e))}))}},l=(e,t,n=[])=>{const a=(...o)=>{if(!a.cancelled){r=a;try{e.call(t||this,...n,...o)}catch(e){}r=null}};return a.cancel=()=>a.cancelled=!0,a(),a},u=(e,t)=>{if(["null","undefined"].includes(e+"")||"any"===t)return e;const r=typeof e;if(r===t)return e;if("number"===t){if("NaN"===(e+=""))return NaN;const t=parseFloat(e);if(isNaN(t))throw new TypeError(`Unable to coerce '${e}' to 'number'`);return t}if("boolean"===t){if([1,"on","checked","selected","true"].includes(e))return!0;if(null==e||""===e)return!1}if("string"===t)return e+"";const n="function"==typeof t;if("object"===t||n){if("object"===r&&n&&e instanceof t)return e;if("string"===r){e=e.trim();try{if(n){const r=t===Date?new Date:Object.create(t.prototype);if(r instanceof Array){let t=w(e.startsWith("[")?e:`[${e}]`);if(Array.isArray(t)||(e.includes(",")?t=e.split(","):(t=w(`["${e}"]`),(!Array.isArray(t)||t[0]!==e&&1!==t.length)&&(t=null))),!Array.isArray(t))throw new TypeError(`Expected Array for parsed data ${t}:${typeof t}`);r.push(...t)}else r instanceof Date?r.setTime(Date.parse(e)):Object.assign(r,JSON.parse(e));return r}return JSON.parse(e)}catch(a){throw new TypeError(`Unable to coerce '${e}:${r}' to '${n?t.name:r}'`)}}}throw new TypeError(`Unable to coerce '${e}:${r}' to '${t}'`)},d=e=>{if(e&&"object"==typeof e){if(e.__isReactor__)return e;const t=[],n={};return new Proxy(e,{get(a,o){if("__isReactor__"===o)return!0;if(a instanceof Array){if("toJSON"===o)return function(){return[...a]};if("toString"===o)return function(){return JSON.stringify([...a])}}if(a instanceof Date){const t=e[o];if("function"==typeof t)return t.bind(e)}let i=a[o];const s=typeof i;if(r&&"symbol"!=typeof o&&"function"!==s){(n[o]||=new Set).add(r)}return void 0!==i?t.includes(i)||i&&"object"!==s||"symbol"==typeof o?("function"!==s||![Date].includes(i)&&"then"!==o||(i=i.bind(a)),i):(i&&"object"===s&&(i=d(i),t.push(i)),a[o]=i,i):void 0},async set(e,r,a){e instanceof Promise&&console.warn(`Setting ${r} = ${a} on a Promise in Reactor`);const o=typeof a;return a&&"object"===o&&a instanceof Promise&&(a=await a),e[r]!==a&&(a&&"object"===o&&(a=d(a),t.push(a)),e[r]=a,[...n[r]||[]].forEach((e=>{e.cancelled?n[r].delete(e):e()}))),!0}})}return e},m=(e,t)=>{const r=new MutationObserver((e=>{e.forEach((e=>{const r=e.target;if("attributes"===e.type){const n=e.attributeName,a=r.getAttribute(n);t&&"message"===n&&r instanceof IFrameElement&&(r.removeAttribute(n),r.dispatchEvent(new CustomEvent("message",{detail:JSON.parse(a)}))),r.observedAttributes&&r.observedAttributes.includes(n)&&a!==e.oldValue&&r.setVariableValue(n,a)}else if("childList"===e.type){for(const t of e.removedNodes)t.disconnectedCallback&&t.disconnectedCallback();for(const t of e.addedNodes)t.connectedCallback&&t.connectedCallback()}else"characterData"===e.type&&r.characterDataMutationCallback&&r.characterDataMutationCallback(r,e.oldValue,r.textContent)}))}));return r.observe(e,{subtree:!0,childList:!0}),r},h=(e,t)=>{const r=[...e.querySelectorAll(t)],n=document.createNodeIterator(e,Node.ELEMENT_NODE);let a;for(;a=n.nextNode();)a.shadowRoot&&r.push(...h(a.shadowRoot,t));return r},f=(e,t)=>{const r=new Set;if(e.shadowRoot)r.add(e),f(e.shadowRoot,t).forEach((e=>r.add(e)));else for(const n of e.childNodes)if(n.nodeType===Node.TEXT_NODE&&n.nodeValue?.includes("${"))n.template||=n.nodeValue,r.add(n);else if(n.nodeType===Node.ELEMENT_NODE){let e;[...n.attributes].forEach((t=>{t.value.includes("${")?(t.template||=t.value,r.add(n)):(t.name.includes(":")||t.name.startsWith("l-"))&&(e=t.name.includes("l-for:"),r.add(n))})),"radio"===n.getAttribute("type")&&r.add(n),e||n.shadowRoot||f(n,t).forEach((e=>r.add(e)))}return r},p=(e,...t)=>(t=t.map((e=>{const t=typeof e;try{return e&&"object"===t?JSON.stringify(e):e}catch(e){return e.toString()}})),e.reduce(((e,r,n)=>n<t.length?e+=r+t[n]:e+r),"")),b=(e,r,n,a=e.extras||{})=>{const s=typeof e,c="string"===s?e.trim():e.template;if(a.populateTemplate=p,c){const l=o(c);try{const o=l?l.split("."):null;let u;return u=o?(u=i(a,o))||(u=i(r.varsProxy,o))||(null==u?r[l]:u):Function("context","extras","with(context) { with(extras) { return populateTemplate`"+(n?c:t.sanitizeTemplate(c))+"` } }")(r.varsProxy,a),"function"==typeof u?u:(u=l||e.nodeType===Node.TEXT_NODE||n?u:t.escapeHTML(u),"string"===s?"undefined"===u?void 0:u:(e.nodeValue=l?null==u?"":"string"==typeof u?u:JSON.stringify(u):"null"==u||"undefined"==u?"":u,u))}catch(e){if(!e.message.includes("defined")){if(t.renderErrors)return e.message;throw e}return}}return e?.nodeValue},v=e=>{[...e.querySelectorAll('a[href$=".html"][target^="#"]')].forEach((e=>{e.removeEventListener("click",c),s(e,"click",c)}))};t.enableAnchors=v;const y=new WeakSet,g=(e,r,n,a,o)=>{if(y.has(e))return;y.add(e);const c="SELECT"===e.tagName||"TEXTAREA"===e.tagName?"text":e.getAttribute("type"),l=r.split(".");let d="SELECT"===e.tagName&&e.hasAttribute("multiple")?Array:(m=c)?["text","tel","email","url","search","radio","color","password"].includes(m)?"string":["number","range"].includes(m)?"number":["datetime"].includes(m)?Date:["checkbox"].includes(m)?"boolean":"any":"any";var m;const h=i(n.vars,l)||{type:d};if("any"===d&&(d=h?.type.type||h?.type),"checkbox"===c&&null==a&&(a=e.checked),null==a){const t=e.getAttribute("value");t&&(a=t)}if(o&&l.length>1){const[e,...t]=l;o=i(o,t,t.length-2,!0);const r=t[t.length-1];o[r]=u(a,d)}else{const o=n.vars[r];if(o){if(existingtype=o?.type.type||o?.type,existingtype!==d)throw new TypeError(`Attempt to bind <${e.tagName} name="${r}" type="${d}"> to variable ${r}:${o.type}`);o.reactive=!0}else{if(!t.createInputVariables)throw new TypeError(`Attempt to bind undefined variable ${r} to <${e.tagName} type="${d}>`);n.variables({[r]:d},{reactive:E,set:a})}"radio"!==c&&("string"==typeof a&&a.includes("${")?e.setAttribute("value",""):n.setVariableValue(r,u(a,d)))}let f="change";"FORM"===e.tagName?f="submit":"SELECT"===e.tagName||c&&"TEXTAREA"!==e.tagName&&!["text","number","tel","email","url","search","password"].includes(c)||(f="input");s(e,f,(t=>{t&&t.stopImmediatePropagation();let r=e.value;if("checkbox"===c?r=e.checked:"SELECT"===e.tagName&&e.hasAttribute("multiple")&&(r=[...e.querySelectorAll("option")].filter((e=>e.selected||b(e.attributes.value||e.innerText,n)===r)).map((e=>e.getAttribute("value")||e.innerText))),o){const[e,...t]=l;o=i(o,l,t.length-2,!0)}else o=i(n.varsProxy,l,l.length-2,!0);const a=l[l.length-1];o[a]=u(r,d)}),n)},w=e=>{try{return JSON.parse(e)}catch(t){return e}},E=()=>({init({variable:e,component:t}){e.reactive=!0,t.vars[e.name]=d(e)}}),A=()=>({init({variable:e,component:t}){const r=e.name;e.exported=!0,e.set=n=>{if(e.exported)if(null==n)R(t,r);else{const e=typeof n;n="string"===e?n:"object"===e&&n instanceof Array?JSON.stringify([...n]):JSON.stringify(n),k(t,r,n)}},e.set(e.value)}});let N={observed:{constant:!0,value:()=>({init({variable:e,component:t}){const r=e.name;e.value=t.hasAttribute(r)?u(t.getAttribute(r),e.type):e.value,e.observed=!0,t.observedAttributes.add(r)}})},reactive:{constant:!0,value:E},shared:{constant:!0,value:()=>({init({variable:e,component:t}){e.shared=!0,e.set=function(e){t.vars[this.name]?.shared&&t.siblings.forEach((t=>t.setVariableValue(this.name,e)))}}})},exported:{constant:!0,value:A},imported:{constant:!0,value:()=>({init({variable:e,component:t}){const r=e.name.toLowerCase();let n=t.hasAttribute(r)?t.getAttribute(r):null;"boolean"!==e.type&&"boolean"!==e.type.type||""!==n||(n=!0),e.imported=!0,e.value=null!=n?u(n,e.type):e.value}})}};const T=(e,t,r,n)=>{e&&[...e.querySelectorAll(t)].forEach((e=>{let t=e.getAttribute(r);t&&e.setAttribute(r,new URL(t,n).href)}))},C=e=>{if((e.getAttribute("src")||"").includes("/lightview.js"))return;const t=document.createElement(e.tagName.toLowerCase());[...e.attributes].forEach((e=>t.setAttribute(e.name,e.value))),t.innerHTML=e.innerHTML,e.after(t),e.remove()},x=(r,{observer:n,framed:a,href:i=window.location.href.replace("blob:",""),mount:c})=>{const h=new Set,p=[];let y;p.add=function(e){p.includes(e)||p.push(e)};const w=class r extends HTMLElement{static get instances(){return h}static setTemplateNode(e){y="TEMPLATE"===e.tagName?document.createElement("div"):e.cloneNode(!0),"TEMPLATE"===e.tagName&&(y.innerHTML=e.innerHTML,[...e.attributes].forEach((e=>y.setAttribute(e.name,e.value)))),T(y.head,"link","href",i),T(y.head,"script","src",i),T(y.body||y,"link","href",i),T(y.body||y,"script","src",i),y.mount=e.mount||e.body?.mount}constructor(){super(),this.componentBaseURI=i,e=window.currentComponent=document.currentComponent=this,h.add(this);const n=this.attachShadow({mode:"open"}),o={};var s,c;this.vars={...N,observe:{value:(...e)=>l(...e),type:"function",constant:!0},addEventListener:{value:(e,t)=>{const r=o[e]||=new Set;[...r].forEach((e=>{t+""==e+""&&r.delete(e)})),o[e].add(t)},type:"function",constant:!0},postEvent:{value:(t,r={})=>{r.type=t,r.target=e,o[t]?.forEach((e=>e(r)))},type:"function",constant:!0},self:{value:e,type:r,constant:!0}},this.varsProxy=(s=this.vars,c=this,new Proxy(s,{get(e,t){if("self"===t)return c;if(e instanceof Date)return Reflect.get(e,t);let{value:r,get:n}=e[t]||{};return n?e[t].value=n.call(e[t]):"function"==typeof r?r.bind(e):r},set(e,r,n){const a={variableName:r,value:n};if(void 0===e[r])return e[r]={type:"any",value:n},e.postEvent.value("change",a),a.defaultPrevented&&delete e[r].value,!0;const o=e[r],{value:i,shared:s,exported:c,constant:l,reactive:m,remote:h}=o;let f=o.type;if(l){const e=new TypeError(`${r}:${f} is a constant`);if(t.renderErrors)return o.value=e.toString(),!0;throw e}(null!=n||f.required)&&(n=f.validate?f.validate(n,e[r]):u(n,f));const p=typeof n,b=typeof f;if(null==n&&!f.required||"any"===f||p===f&&"string"===b||"function"===b&&!f.validate&&n&&"object"===p&&n instanceof f||o.validityState?.valid)return i!==n&&(a.oldValue=i,e[r].value=m?d(n):n,e.postEvent.value("change",a),a.defaultPrevented?e[r].value=i:h&&(o.reactive&&!1!==o?.remote?.config.put||h.put)?h.handleRemote({variable:o,config:o?.remote?.config},!0):o.set&&o.set(n)),!0;if("function"===b&&n&&"object"===p){const e=new TypeError(`Can't assign instance of '${n.constructor.name}' to variable '${r}:${f.name.replace("bound ","")}'`);if(t.renderErrors)return o.value=e.toString(),!0;throw e}const v=new TypeError(`Can't assign '${typeof n} ${"string"===p?'"'+n+'"':n}' to variable '${r}:${"function"===b?f.name.replace("bound ",""):f} ${f.required?"required":""}'`);if(t.renderErrors)return o.value=v.toString(),!0;throw v},keys:()=>[...Object.keys(s)]})),(a||r.lightviewFramed)&&this.variables({message:Object},{exported:A}),["getElementById","querySelector"].forEach((e=>{const t=this[e];Object.defineProperty(this,e,{configurable:!0,writable:!0,value:(...r)=>(t?t.call(this,...r):null)||this.shadowRoot[e](...r)})})),["querySelectorAll"].forEach((e=>{const t=this[e];Object.defineProperty(this,e,{configurable:!0,writable:!0,value:(...r)=>[...t.call(this,...r),...this.shadowRoot[e](...r)]})})),[...y.head?.childNodes||[]].forEach((e=>{const t=e.cloneNode(!0);document.head.appendChild(t),["LINK","SCRIPT"].includes(t.tagName)&&C(t)}));[...(y.body||y).childNodes].forEach((e=>{if(e.tagName&&customElements.get(e.tagName.toLowerCase())){const t=document.createElement(e.tagName);[...e.attributes].forEach((e=>t.setAttribute(e.name,e.value))),n.appendChild(t)}else{const t=e.cloneNode(!0);n.appendChild(t),["LINK","SCRIPT"].includes(t.tagName)&&C(t)}})),v(n)}get siblings(){return[...r.instances].filter((e=>e!=this))}adoptedCallback(){this.hasOwnProperty("adoptedCallback")&&this.adoptedCallback()}disconnectedCallback(){h.delete(this)}connectedCallback(){if([...(y.body||y).attributes].forEach((e=>{this.hasAttribute(e.name)||this.setAttribute(e.name,e.value)})),y.mount||c){const e=document.createElement("script");window.currentComponent=document.currentComponent=this,e.innerHTML=`with(document.currentComponent.varsProxy) { \n ${"undefined"!=typeof lightviewDebug&&!0===lightviewDebug?"debugger;":""}\n const component = document.currentComponent; \n (async () => { await (${y.mount||c}).call(self,self); \n component.compile(); })(); \n };`,this.appendChild(e),e.remove(),[...this.querySelectorAll('link[rel="stylesheet"][export]')].forEach((async e=>{e.remove(),this.appendChild(e)})),window.currentComponent=document.currentComponent=null}}compile(){const e=this,t=this.shadowRoot,r=f(e,i),c=(t,r,n)=>{t.forEach((t=>{if(t.nodeType===Node.TEXT_NODE&&t.template.includes("${")){if(l((()=>b(t,this,!0,t.extras))),"TEXTAREA"===t.parentElement?.tagName){const e=o(t.template);if(e){const n=e.split(".");t.extras&&t.extras[n[0]]&&(r=t.extras[n[0]]),(!this.vars[n[0]]||this.vars[n[0]].reactive||r)&&g(t.parentElement,e,this,b(t.template,this,!0,t.extras),r)}}}else if(t.nodeType===Node.ELEMENT_NODE){const a=t.attributes.value,d=a?.template;if(a&&d){const i=t.attributes.type?b(t.attributes.type,e,!1,t.extras):null,s=t.getAttribute("name"),c=a.template||(n&&s?`\${${n}.${name}}`:null);if(c){const n=o(c);if(n){const e=n.split(".");t.extras&&t.extras[e[0]]&&(r=t.extras[e[0]]),(!this.vars[e[0]]||this.vars[e[0]].reactive||r)&&g(t,n,this,b(a,this,!1,t.extras),r)}l((()=>{const r=b(c,e,!1,t.extras);if(void 0!==r)if("checkbox"===i)!0===u(r,"boolean")?t.setAttribute("checked",""):t.removeAttribute("checked");else if("SELECT"===t.tagName){const n=t.hasAttribute("multiple")?u(r,Array):[r];[...t.querySelectorAll("option")].forEach((async r=>{r.hasAttribute("value")?n.includes(b(r.attributes.value,e,!1,t.extras))&&r.setAttribute("selected",""):n.includes(b(r.innerText,e,!1,t.extras))&&r.setAttribute("selected","")}))}else if("radio"!==i){let e="string"==typeof r?r:r.toString?r.toString():JSON.stringify(r);e.startsWith('"')&&(e=e.substring(1)),e.endsWith('"')&&(e=e.substring(0,e.length-1)),a.value=e}}))}}[...t.attributes].forEach((async n=>{if("value"===n.name&&n.template)return;const{name:a,value:o}=n,d=t.attributes.name?.value;o.includes("${")&&(n.template=o),"type"===a&&"radio"==o&&d&&(g(t,d,this,void 0,r),l((()=>{const r=Function("context","with(context) { return `${"+d+"}` }")(e.varsProxy);t.attributes.value.value==r?(t.setAttribute("checked",""),t.checked=!0):(t.removeAttribute("checked"),t.checked=!1)})));const[m,...h]=a.split(":");if(""===m)l((()=>{const r=n.value;if(h[0])"true"===r?t.setAttribute(h[0],""):t.removeAttribute(h[0]);else{const r=t.attributes.value?b(t.attributes.value,e,!1,t.extras):null;"checkbox"!==(t.attributes.type?b(t.attributes.type,e,!1,t.extras):null)&&"OPTION"!==t.tagName||(!0===r?t.setAttribute("checked",""):t.removeAttribute("checked"))}}));else if("l-on"===m){let r;l((()=>{const a=b(n,this,!0,t.extras);if(r&&t.removeEventListener(h[0],r),r=null,"function"==typeof a)r=a;else try{r=Function("return "+a)()}catch(e){}r&&s(t,h[0],r,e)}))}else"l-if"===m?l((()=>{const e=b(n,this,!0,t.extras);t.style.setProperty("display",1==e||"true"===e?"revert":"none")})):"l-for"===m?(t.template||=t.innerHTML,t.clone||=t.cloneNode(!0),l((()=>{const[e="each",r="item",a="index",o="array",s=!1]=h,l=b(n,this,!1,t.extras),d=u(l,"each"===e?Array:"object"),m=("each"===e?d:Object[e](d)).reduce(((e,n,s,l)=>{const u=t.clone.cloneNode(!0),d=t.extras={[r]:n,[a]:s,[o]:l},m=[...f(u,i)].map((e=>(e.extras=d,e)));return c(m),e.push(...u.childNodes),e}),[]);if(!window.lightviewDebug)if(s)t.style.setProperty("display","none");else for(;t.lastElementChild;)t.lastElementChild.remove();m.forEach((e=>{s?t.parentElement.insertBefore(e,t):t.appendChild(e)}))}))):n.template&&l((()=>{b(n,this,!1,t.extras)}))}))}}))};r.forEach((t=>{if("FORM"===t.tagName){const n=t.getAttribute("value"),a=o(n);if(a){const n=[...r].filter((e=>t!==e&&t.contains(e)));n.forEach((e=>r.delete(e)));const o=e.vars[a]||={type:"object",reactive:!0,value:d({})};if("object"!==o.type||!o.reactive||!o.value||"object"!=typeof o.value)throw new TypeError(`Can't bind form ${t.getAttribute("id")} to non-object variable ${a}`);c(n,o.value,a)}}})),c(r),t.normalize(),n||=m(e,a),n.observe(e,{attributeOldValue:!0,subtree:!0,characterData:!0,characterDataOldValue:!0}),this.hasAttribute("l-unhide")&&this.removeAttribute("hidden"),this.dispatchEvent(new Event("mounted"))}adoptedCallback(e){this.dispatchEvent(new Event("adopted"))}disconnectedCallback(){this.dispatchEvent(new Event("disconnected"))}get observedAttributes(){return r.observedAttributes}static get observedAttributes(){return p}getVariableNames(){return Object.keys(this.vars).filter((e=>!(e in N)&&!["self","addEventListener","postEvent","observe"].includes(e)))}getVariableData(){return this.getVariableNames().reduce(((e,t)=>(e[t]=this.getVariableValue(t),e)),{})}getVariable(e){return this.vars[e]?{...this.vars[e]}:void 0}setVariableValue(e,t,{coerceTo:r=typeof t}={}){if(!this.isConnected)return h.delete(this),!1;let{type:n}=this.vars[e]||{};if(n){if(this.varsProxy[e]!==t){const a=this.vars[e];if(a.shared){const o={variableName:e,value:t=n.validate?n.validate(t,a):u(t,r),oldValue:a.value};a.value=t,this.vars.postEvent.value("change",o),o.defaultPrevented&&(a.value=t)}else this.varsProxy[e]=t}return!0}return this.vars[e]={name:name,type:r,value:u(t,r)},!1}getVariableValue(e){return this.vars[e]?.value}variables(e,{remote:t,constant:r,set:n,...a}={}){const o={remote:t,constant:r,...a};return void 0!==e&&Object.entries(e).forEach((([e,i])=>{var s;"function"==typeof(s=i)&&(s+"").match(/\(*.*\)*\s*=>/g)&&(i=i());const c=this.vars[e]||={name:e,type:i};if(void 0!==n&&void 0!==r)throw new TypeError(`${e} has the constant value ${r} and can't be set to ${n}`);if(c.value=n,void 0!==r){if(t||a.imported)throw new TypeError(`${e} can't be a constant and also remote or imported`);c.constant=!0,c.value=r}t&&("function"==typeof t&&(t=t(`./${e}`)),c.remote=t,t.handleRemote({variable:c,config:t.config,component:this})),Object.entries(a).forEach((([t,n])=>{const i=c[t]="function"==typeof n?n():n;if(i.init&&i.init({variable:c,options:o,component:this}),(void 0!==a.get||void 0!==a.set)&&void 0!==r)throw new TypeError(`${e} has the constant value ${r} and can't have a getter or setter`);c.set,i.set,c.get,i.get})),i.validate&&void 0!==c.value&&i.validate(c.value,c)})),Object.entries(this.vars).reduce(((e,[t,r])=>(e[t]={...r},e)),{})}};return w.setTemplateNode(r),w},$=(e,r,{framed:n,observer:a,href:o,mount:i}={})=>{let s=customElements.get(e);return s?(n&&!s.lightviewFramed?s.lightviewFramed=!0:console.warn(new Error(`${e} is already a CustomElement. Not redefining`)),s):(s=x(r,{observer:a,framed:n,href:o,mount:i}),customElements.define(e,s),t.customElements.set(e,s),s)};t.customElements=new Map,t.createComponent=$;const L=async(t,r)=>{const a=new URL(t.getAttribute("href"),document.baseURI),o=t.getAttribute("as")||(e=>{const t=e.split("/").pop().split(".")[0],r=t.split("-");return t.includes("-")&&r[0].length>=1?t:"l-"+t})(a.pathname);if(a.origin!==window.location.origin&&!t.getAttribute("crossorigin"))throw new URIError(`importLink:HTML imports must be from same domain: ${a.hostname}!=${location.hostname} unless 'crossorigin' attribute is set.`);if(!customElements.get(o)){const i=await(await fetch(a.href)).text(),s=n.parseFromString(i,"text/html"),c=!!s.head.querySelector('meta[name="l-unhide"]');for(const e of[...s.head.querySelectorAll("link[href]")])e.setAttribute("href",new URL(e.getAttribute("href"),a.href).href),t.hasAttribute("crossorigin")&&e.setAttribute("crossorigin",t.getAttribute("crossorigin")),e.getAttribute("href").endsWith(".html")&&"module"===e.getAttribute("rel")&&await L(e,r);(e=window.currentComponent=document.currentComponent=s.body).componentBaseURI=a.href;const l=s.getElementById("lightview");if(l){const e=document.createElement("script");e.innerHTML=l.innerHTML,document.body.appendChild(e),e.remove()}e=window.currentComponent=document.currentComponent=null,$(o,s,{observer:r,href:a.href}),c&&s.body.removeAttribute("hidden")}return{as:o}},S=({as:e="x-body",unhide:t,framed:r}={})=>{$(e,document.body,{framed:r});const n=document.createElement(e);document.body.parentElement.replaceChild(n,document.body),Object.defineProperty(document,"body",{enumerable:!0,configurable:!0,get:()=>n}),t&&n.removeAttribute("hidden")};t.bodyAsComponent=S;const O=(e,t=window.parent)=>{O.enabled&&(t instanceof HTMLIFrameElement?(e={...e,href:document.baseURI},t.contentWindow.postMessage(JSON.stringify(e),"*")):(e={...e,iframeId:document.lightviewId,href:document.baseURI},t.postMessage(JSON.stringify(e),"*")))},k=(e,t,r)=>{e.getAttribute(t)!==r&&e.setAttribute(t,r),O({type:"setAttribute",argsList:[t,r]})},R=(e,t,r)=>{e.removeAttribute(t),O({type:"removeAttribute",argsList:[t]})},P=(e,t=[])=>(t.unshift(e),e.parentNode&&e.parentNode!=e.parentNode&&P(e.parentNode,t),t),M=new URL(document.currentScript.getAttribute("src"),document.baseURI);let j,V;j||s(window,"DOMContentLoaded",(e=>j=e));const D=async e=>{await(async()=>{const e=m(document.body);for(const t of[...document.querySelectorAll('link[href$=".html"][rel=module]')])await L(t,e)})();const t=!!document.querySelector('meta[name="l-unhide"]'),r=!!document.querySelector('meta[name="l-isolate"]'),n=!!document.querySelector('meta[name="l-enableFrames"]');if(e){if(e({unhide:t,isolated:r,enableFrames:n,framed:!0}),!r){O.enabled=!0,s(window,"message",(({data:e})=>{const{type:t,argsList:r}=JSON.parse(e);if("framed"===t){const e=()=>{const{width:e,height:t}=document.body.getBoundingClientRect();O({type:"setAttribute",argsList:["width",e]}),O({type:"setAttribute",argsList:["height",t+20]})};return e(),n=document.body,a=()=>e(),void new ResizeObserver((()=>a())).observe(n)}var n,a;if(["setAttribute","removeAttribute"].includes(t)){let[e,n]=[...r];const a=document.body.vars[e];"removeAttribute"===t&&(n=void 0),a&&a.imported&&document.body.setVariableValue(e,n)}}));const e=new URL(document.baseURI);document.lightviewId=e.searchParams.get("id"),O({type:"DOMContentLoaded"})}}else M.searchParams.has("as")&&S({as:M.searchParams.get("as"),unhide:t});if(n&&(O.enabled=!0,s(window,"message",(e=>{const{type:t,iframeId:r,argsList:n,href:a}=JSON.parse(e.data),o=document.getElementById(r);if(o){if("DOMContentLoaded"===t)return O({type:"framed",href:document.baseURI},o),Object.defineProperty(j,"currentTarget",{enumerable:!1,configurable:!0,value:o}),j.href=a,j.srcElement=o,j.bubbles=!1,j.path=P(o),Object.defineProperty(j,"timeStamp",{enumerable:!1,configurable:!0,value:performance.now()}),void o.dispatchEvent(j);if("setAttribute"===t){const[e,t]=[...n];return void(o.getAttribute(e)!==t+""&&o.setAttribute(e,t))}if("removeAttribute"===t)return void o.removeAttribute(...n)}console.warn("iframe posted a message without providing an id",e)})),!V)){const e=V=new MutationObserver((e=>{document.getElementById("console");for(const{target:t,attributeName:r,oldValue:n}of e){const e=t.getAttribute(r);["height","width","message"].includes(r)||(e?e!==n&&O({type:"setAttribute",argsList:[r,e]},iframe):O({type:"removeAttribute",argsList:[r]},iframe)),"message"===r?e&&(t.removeAttribute("message"),t.dispatchEvent(new CustomEvent("message",{target:t,detail:JSON.parse(e)}))):t.dispatchEvent(new CustomEvent("attribute.changed",{target:t,detail:{attributeName:r,value:e,oldValue:n}}))}}));[...document.body.querySelectorAll("iframe")].forEach((t=>{e.observe(t,{attributes:!0,attributeOldValue:!0})}))}};return t.whenFramed=(e,{isolated:t}={})=>{s(document,"DOMContentLoaded",(t=>D(e)))},t.loader=D,window.location!==window.parent.location&&window.parent instanceof Window&&window.parent===window||s(document,"DOMContentLoaded",(()=>D())),{observe:l}})();