apprun 3.33.1 → 3.33.3

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.
package/README.md CHANGED
@@ -3,23 +3,15 @@
3
3
 
4
4
  ## Introduction
5
5
 
6
- AppRun is a sleek and efficient JavaScript library designed to revolutionize statement management in web development. At its core, AppRun harnesses the power of the event PubsSub (Publish-Subscribe) pattern to streamline your application’s state handling.
7
-
8
-
9
- ## Why the Event Pubsub Pattern?
10
-
11
- The event PubSub pattern isn't new; it's a well-established design pattern used widely in software development to handle communication between components or services in a decoupled manner. Web developers are likely already familiar with the PubSub pattern through their use of DOM event handling.
12
-
13
- AppRun takes the familiar PubSub concept and extends it into your application's logic, providing a more structured and powerful approach to state management. The result? Cleaner, more maintainable code and a smoother development experience.
14
-
15
- Here is an example of a simple counter application built with AppRun:
6
+ AppRun is a lightweight alternative to other frameworks and libraries. It has a unique architecture inspired by the Elm architecture that can help you manage states, routing, and other essential aspects of your web application.
16
7
 
8
+ Use a _Counter_ as an example.
17
9
 
18
10
  ```js
19
11
  // define the initial state
20
12
  const state = 0;
21
13
 
22
- // view is a pure function to display the state
14
+ // view is a function to display the state
23
15
  const view = state => `<div>
24
16
  <h1>${state}</h1>
25
17
  <button onclick="app.run('-1')">-1</button>
@@ -35,14 +27,22 @@ const update = {
35
27
  // start the app
36
28
  app.start(document.body, state, view, update);
37
29
  ```
38
- <apprun-play style="height:200px"></apprun-play>
30
+ <apprun-code style="font-size: smaller"></apprun-code>
39
31
 
32
+ At its core, AppRun harnesses the power of the event PubsSub (Publish-Subscribe) pattern to streamline your application’s state handling.
33
+
34
+
35
+ ## Why the Event Pubsub Pattern
36
+
37
+ The event PubSub pattern isn't new; it's a well-established design pattern used widely in software development to handle communication between components or services in a decoupled manner. Web developers are likely already familiar with the PubSub pattern through their use of DOM event handling.
38
+
39
+ AppRun takes the familiar PubSub concept and extends it into your application's logic, providing a more structured and powerful approach to state management. The result? Cleaner, more maintainable code and a smoother development experience.
40
40
 
41
41
  ## AppRun Benefits
42
42
 
43
43
  * Clean architecture that needs less code
44
44
  * State management and routing included
45
- * No proprietary syntax to learn (no hooks)
45
+ * No proprietary syntax to learn (no hooks, no reducers, no signals)
46
46
  * Use directly in the browser or with a compiler/bundler
47
47
  * Advanced features: JSX, Web Components, Dev Tools, SSR, etc.
48
48
 
@@ -58,21 +58,31 @@ npm install apprun
58
58
  You can also load AppRun directly from the unpkg.com CDN:
59
59
 
60
60
  ```js
61
+ <html>
62
+ <body>
61
63
  <script src="https://unpkg.com/apprun/dist/apprun-html.js"></script>
62
64
  <script>
63
65
  const view = state => `<div>${state}</div>`;
64
66
  app.start(document.body, 'hello AppRun', view);
65
67
  </script>
68
+ </body>
69
+ </html>
66
70
  ```
71
+ <apprun-code style="font-size: smaller"></apprun-code>
67
72
 
68
73
  Or, use the ESM version:
69
74
  ```js
75
+ <html>
76
+ <body>
70
77
  <script type="module">
71
78
  import { app } from 'https://unpkg.com/apprun/dist/apprun-html.esm.js';
72
79
  const view = state => `<div>${state}</div>`;
73
80
  app.start(document.body, 'hello ESM', view);
74
81
  </script>
82
+ </body>
83
+ </html>
75
84
  ```
85
+ <apprun-code style="font-size: smaller"></apprun-code>
76
86
 
77
87
  Or, you can create an AppRun app by using the `npm create apprun-app` command.
78
88
 
@@ -0,0 +1,2 @@
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.apprun=e():t.apprun=e()}(this,(()=>(()=>{"use strict";var t={752:(t,e,n)=>{n.d(e,{Z:()=>r,g:()=>s});class s{constructor(){this._events={}}on(t,e,n={}){this._events[t]=this._events[t]||[],this._events[t].push({fn:e,options:n})}off(t,e){const n=this._events[t]||[];this._events[t]=n.filter((t=>t.fn!==e))}find(t){return this._events[t]}run(t,...e){const n=this.getSubscribers(t,this._events);return console.assert(n&&n.length>0,"No subscriber for event: "+t),n.forEach((n=>{const{fn:s,options:o}=n;return o.delay?this.delay(t,s,e,o):Object.keys(o).length>0?s.apply(this,[...e,o]):s.apply(this,e),!n.options.once})),n.length}once(t,e,n={}){this.on(t,e,Object.assign(Object.assign({},n),{once:!0}))}delay(t,e,n,s){s._t&&clearTimeout(s._t),s._t=setTimeout((()=>{clearTimeout(s._t),Object.keys(s).length>0?e.apply(this,[...n,s]):e.apply(this,n)}),s.delay)}runAsync(t,...e){const n=this.getSubscribers(t,this._events);console.assert(n&&n.length>0,"No subscriber for event: "+t);const s=n.map((t=>{const{fn:n,options:s}=t;return Object.keys(s).length>0?n.apply(this,[...e,s]):n.apply(this,e)}));return Promise.all(s)}query(t,...e){return this.query(t,...e)}getSubscribers(t,e){const n=e[t]||[];return e[t]=n.filter((t=>!t.options.once)),Object.keys(e).filter((e=>e.endsWith("*")&&t.startsWith(e.replace("*","")))).sort(((t,e)=>e.length-t.length)).forEach((s=>n.push(...e[s].map((e=>Object.assign(Object.assign({},e),{options:Object.assign(Object.assign({},e.options),{event:t})})))))),n}}let o;const i="object"==typeof self&&self.self===self&&self||"object"==typeof n.g&&n.g.global===n.g&&n.g;i.app&&i._AppRunVersions?o=i.app:(o=new s,i.app=o,i._AppRunVersions="AppRun-3");const r=o},37:(t,e,n)=>{n.d(e,{Component:()=>u,app:()=>s.Z});var s=n(752),o=n(559);const i=(t,e={})=>class extends HTMLElement{constructor(){super()}get component(){return this._component}get state(){return this._component.state}static get observedAttributes(){return(e.observedAttributes||[]).map((t=>t.toLowerCase()))}connectedCallback(){if(this.isConnected&&!this._component){const n=e||{};this._shadowRoot=n.shadow?this.attachShadow({mode:"open"}):this;const s=n.observedAttributes||[],o=s.reduce(((t,e)=>{const n=e.toLowerCase();return n!==e&&(t[n]=e),t}),{});this._attrMap=t=>o[t]||t;const i={};Array.from(this.attributes).forEach((t=>i[this._attrMap(t.name)]=t.value)),s.forEach((t=>{void 0!==this[t]&&(i[t]=this[t]),Object.defineProperty(this,t,{get:()=>i[t],set(e){this.attributeChangedCallback(t,i[t],e)},configurable:!0,enumerable:!0})})),requestAnimationFrame((()=>{const e=this.children?Array.from(this.children):[];if(this._component=new t(Object.assign(Object.assign({},i),{children:e})).mount(this._shadowRoot,n),this._component._props=i,this._component.dispatchEvent=this.dispatchEvent.bind(this),this._component.mounted){const t=this._component.mounted(i,e,this._component.state);void 0!==t&&(this._component.state=t)}this.on=this._component.on.bind(this._component),this.run=this._component.run.bind(this._component),!1!==n.render&&this._component.run(".")}))}}disconnectedCallback(){var t,e,n,s;null===(e=null===(t=this._component)||void 0===t?void 0:t.unload)||void 0===e||e.call(t),null===(s=null===(n=this._component)||void 0===n?void 0:n.unmount)||void 0===s||s.call(n),this._component=null}attributeChangedCallback(t,n,s){if(this._component){const o=this._attrMap(t);this._component._props[o]=s,this._component.run("attributeChanged",o,n,s),s!==n&&!1!==e.render&&window.requestAnimationFrame((()=>{this._component.run(".")}))}}},r=(t,e,n)=>{"undefined"!=typeof customElements&&customElements.define(t,i(e,n))},a={meta:new WeakMap,defineMetadata(t,e,n){this.meta.has(n)||this.meta.set(n,{}),this.meta.get(n)[t]=e},getMetadataKeys(t){return t=Object.getPrototypeOf(t),this.meta.get(t)?Object.keys(this.meta.get(t)):[]},getMetadata(t,e){return e=Object.getPrototypeOf(e),this.meta.get(e)?this.meta.get(e)[t]:null}};var c=n(334);const l=new Map;s.Z.find("get-components")||s.Z.on("get-components",(t=>t.components=l));const h=t=>t;class u{renderState(t,e=null){if(!this.view)return;let n=e||this.view(t);if(s.Z.debug&&s.Z.run("debug",{component:this,_:n?".":"-",state:t,vdom:n,el:this.element}),"object"!=typeof document)return;const o="string"==typeof this.element&&this.element?document.getElementById(this.element)||document.querySelector(this.element):this.element;if(!o)return;const i="_c";this.unload?o._component===this&&o.getAttribute(i)===this.tracking_id||(this.tracking_id=(new Date).valueOf().toString(),o.setAttribute(i,this.tracking_id),"undefined"!=typeof MutationObserver&&(this.observer||(this.observer=new MutationObserver((t=>{t[0].oldValue!==this.tracking_id&&document.body.contains(o)||(this.unload(this.state),this.observer.disconnect(),this.observer=null)}))),this.observer.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeOldValue:!0,attributeFilter:[i]}))):o.removeAttribute&&o.removeAttribute(i),o._component=this,!e&&n&&(n=(0,c.Z)(n,this),this.options.transition&&document&&document.startViewTransition?document.startViewTransition((()=>s.Z.render(o,n,this))):s.Z.render(o,n,this)),this.rendered&&this.rendered(this.state)}setState(t,e={render:!0,history:!1}){if(t instanceof Promise)Promise.resolve(t).then((n=>{this.setState(n,e),this._state=t}));else{if(this._state=t,null==t)return;this.state=t,!1!==e.render&&(e.transition&&document&&document.startViewTransition?document.startViewTransition((()=>this.renderState(t))):this.renderState(t)),!1!==e.history&&this.enable_history&&(this._history=[...this._history,t],this._history_idx=this._history.length-1),"function"==typeof e.callback&&e.callback(this.state)}}constructor(t,e,n,o){this.state=t,this.view=e,this.update=n,this.options=o,this._app=new s.g,this._actions=[],this._global_events=[],this._history=[],this._history_idx=-1,this._history_prev=()=>{this._history_idx--,this._history_idx>=0?this.setState(this._history[this._history_idx],{render:!0,history:!1}):this._history_idx=0},this._history_next=()=>{this._history_idx++,this._history_idx<this._history.length?this.setState(this._history[this._history_idx],{render:!0,history:!1}):this._history_idx=this._history.length-1},this.start=(t=null,e)=>{if(this.mount(t,Object.assign({render:!0},e)),this.mounted&&"function"==typeof this.mounted){const t=this.mounted({},[],this.state);void 0!==t&&this.setState(t)}return this}}mount(t=null,e){var n,o;return console.assert(!this.element,"Component already mounted."),this.options=e=Object.assign(Object.assign({},this.options),e),this.element=t,this.global_event=e.global_event,this.enable_history=!!e.history,this.enable_history&&(this.on(e.history.prev||"history-prev",this._history_prev),this.on(e.history.next||"history-next",this._history_next)),e.route&&(this.update=this.update||{},this.update[e.route]||(this.update[e.route]=h)),this.add_actions(),this.state=null!==(o=null!==(n=this.state)&&void 0!==n?n:this.model)&&void 0!==o?o:{},"function"==typeof this.state&&(this.state=this.state()),this.setState(this.state,{render:!!e.render,history:!0}),s.Z.debug&&(l.get(t)?l.get(t).push(this):l.set(t,[this])),this}is_global_event(t){return t&&(this.global_event||this._global_events.indexOf(t)>=0||t.startsWith("#")||t.startsWith("/")||t.startsWith("@"))}add_action(t,e,n={}){e&&"function"==typeof e&&(n.global&&this._global_events.push(t),this.on(t,((...o)=>{s.Z.debug&&s.Z.run("debug",{component:this,_:">",event:t,p:o,current_state:this.state,options:n});const i=e(this.state,...o);s.Z.debug&&s.Z.run("debug",{component:this,_:"<",event:t,p:o,newState:i,state:this.state,options:n}),this.setState(i,n)}),n))}add_actions(){const t=this.update||{};a.getMetadataKeys(this).forEach((e=>{if(e.startsWith("apprun-update:")){const n=a.getMetadata(e,this);t[n.name]=[this[n.key].bind(this),n.options]}}));const e={};Array.isArray(t)?t.forEach((t=>{const[n,s,o]=t;n.toString().split(",").forEach((t=>e[t.trim()]=[s,o]))})):Object.keys(t).forEach((n=>{const s=t[n];("function"==typeof s||Array.isArray(s))&&n.split(",").forEach((t=>e[t.trim()]=s))})),e["."]||(e["."]=h),Object.keys(e).forEach((t=>{const n=e[t];"function"==typeof n?this.add_action(t,n):Array.isArray(n)&&this.add_action(t,n[0],n[1])}))}run(t,...e){if(this.state instanceof Promise)return Promise.resolve(this.state).then((n=>{this.state=n,this.run(t,...e)}));{const n=t.toString();return this.is_global_event(n)?s.Z.run(n,...e):this._app.run(n,...e)}}on(t,e,n){const o=t.toString();return this._actions.push({name:o,fn:e}),this.is_global_event(o)?s.Z.on(o,e,n):this._app.on(o,e,n)}runAsync(t,...e){const n=t.toString();return this.is_global_event(n)?s.Z.runAsync(n,...e):this._app.runAsync(n,...e)}query(t,...e){return this.runAsync(t,...e)}unmount(){var t;null===(t=this.observer)||void 0===t||t.disconnect(),this._actions.forEach((t=>{const{name:e,fn:n}=t;this.is_global_event(e)?s.Z.off(e,n):this._app.off(e,n)}))}}u.__isAppRunComponent=!0;const p="//",d="///",m=t=>{if(t||(t="#"),t.startsWith("#")){const[e,...n]=t.split("/");s.Z.run(e,...n)||s.Z.run(d,e,...n),s.Z.run(p,e,...n)}else if(t.startsWith("/")){const[e,n,...o]=t.split("/");s.Z.run("/"+n,...o)||s.Z.run(d,"/"+n,...o),s.Z.run(p,"/"+n,...o)}else s.Z.run(t)||s.Z.run(d,t),s.Z.run(p,t)};s.Z.h=s.Z.createElement=o.az,s.Z.render=o.yj,s.Z.Fragment=o.HY,s.Z.webComponent=r,s.Z.safeHTML=o.eV,s.Z.start=(t,e,n,s,o)=>{const i=Object.assign({render:!0,global_event:!0},o),r=new u(e,n,s);return o&&o.rendered&&(r.rendered=o.rendered),o&&o.mounted&&(r.mounted=o.mounted),r.start(t,i),r};const f=t=>{};s.Z.on("$",f),s.Z.on("debug",(t=>f)),s.Z.on(p,f),s.Z.on("#",f),s.Z.route=m,s.Z.on("route",(t=>s.Z.route&&s.Z.route(t))),"object"==typeof document&&document.addEventListener("DOMContentLoaded",(()=>{s.Z.route===m&&(window.onpopstate=()=>m(location.hash),document.body.hasAttribute("apprun-no-init")||s.Z["no-init-route"]||m(location.hash))})),"object"==typeof window&&(window.Component=u,window._React=window.React,window.React=s.Z,window.on=function(t,e={}){return function(n,s){const o=t?t.toString():s;a.defineMetadata(`apprun-update:${o}`,{name:o,key:s,options:e},n)}},window.customElement=function(t,e){return function(n){return r(t,n,e),n}},window.safeHTML=o.eV),s.Z.use_render=(t,e=0)=>s.Z.render=0===e?(e,n)=>t(n,e):(e,n)=>t(e,n),s.Z.use_react=(t,e)=>{s.Z.h=s.Z.createElement=t.createElement,s.Z.Fragment=t.Fragment,s.Z.render=(t,n)=>e.render(n,t),t.version&&t.version.startsWith("18")&&(s.Z.render=(t,n)=>{t&&n&&(t._root||(t._root=e.createRoot(t)),t._root.render(n))})}},334:(t,e,n)=>{n.d(e,{Z:()=>a});var s=n(752);const o=(t,e)=>(e?t.state[e]:t.state)||"",i=(t,e,n)=>{if(e){const s=t.state||{};s[e]=n,t.setState(s)}else t.setState(n)},r=(t,e)=>{if(Array.isArray(t))return t.map((t=>r(t,e)));{let{type:n,tag:a,props:c,children:l}=t;return a=a||n,l=l||(null==c?void 0:c.children),c&&Object.keys(c).forEach((t=>{t.startsWith("$")&&(((t,e,n,r)=>{if(t.startsWith("$on")){const n=e[t];if(t=t.substring(1),"boolean"==typeof n)e[t]=e=>r.run?r.run(t,e):s.Z.run(t,e);else if("string"==typeof n)e[t]=t=>r.run?r.run(n,t):s.Z.run(n,t);else if("function"==typeof n)e[t]=t=>r.setState(n(r.state,t));else if(Array.isArray(n)){const[o,...i]=n;"string"==typeof o?e[t]=t=>r.run?r.run(o,...i,t):s.Z.run(o,...i,t):"function"==typeof o&&(e[t]=t=>r.setState(o(r.state,...i,t)))}}else if("$bind"===t){const s=e.type||"text",a="string"==typeof e[t]?e[t]:e.name;if("input"===n)switch(s){case"checkbox":e.checked=o(r,a),e.onclick=t=>i(r,a||t.target.name,t.target.checked);break;case"radio":e.checked=o(r,a)===e.value,e.onclick=t=>i(r,a||t.target.name,t.target.value);break;case"number":case"range":e.value=o(r,a),e.oninput=t=>i(r,a||t.target.name,Number(t.target.value));break;default:e.value=o(r,a),e.oninput=t=>i(r,a||t.target.name,t.target.value)}else"select"===n?(e.value=o(r,a),e.onchange=t=>{t.target.multiple||i(r,a||t.target.name,t.target.value)}):"option"===n?(e.selected=o(r,a),e.onclick=t=>i(r,a||t.target.name,t.target.selected)):"textarea"===n&&(e.innerHTML=o(r,a),e.oninput=t=>i(r,a||t.target.name,t.target.value))}else s.Z.run("$",{key:t,tag:n,props:e,component:r})})(t,c,a,e),delete c[t])})),l&&r(l,e),t}},a=r},559:(t,e,n)=>{n.d(e,{HY:()=>o,az:()=>a,eV:()=>p,yj:()=>l});var s=n(334);function o(t,...e){return r(e)}const i="_props";function r(t){const e=[],n=t=>{null!=t&&""!==t&&!1!==t&&e.push("function"==typeof t||"object"==typeof t?t:`${t}`)};return t&&t.forEach((t=>{Array.isArray(t)?t.forEach((t=>n(t))):n(t)})),e}function a(t,e,...n){const s=r(n);if("string"==typeof t)return{tag:t,props:e,children:s};if(Array.isArray(t))return t;if(void 0===t&&n)return s;if(Object.getPrototypeOf(t).__isAppRunComponent)return{tag:t,props:e,children:s};if("function"==typeof t)return t(e,s);throw new Error(`Unknown tag in vdom ${t}`)}const c=new WeakMap,l=(t,e,n={})=>{null!=e&&!1!==e&&function(t,e,n={}){if(null==e||!1===e)return;if(e=y(e,n),!t)return;const s="SVG"===t.nodeName;Array.isArray(e)?u(t,e,s):u(t,[e],s)}("string"==typeof t&&t?document.getElementById(t)||document.querySelector(t):t,e=(0,s.Z)(e,n),n)};function h(t,e,n){3!==e._op&&(n=n||"svg"===e.tag,function(t,e){const n=t.nodeName,s=`${e.tag||""}`;return n.toUpperCase()===s.toUpperCase()}(t,e)?(!(2&e._op)&&u(t,e.children,n),!(1&e._op)&&f(t,e.props,n)):t.parentNode.replaceChild(m(e,n),t))}function u(t,e,n){var s,o;const i=(null===(s=t.childNodes)||void 0===s?void 0:s.length)||0,r=(null==e?void 0:e.length)||0,a=Math.min(i,r);for(let s=0;s<a;s++){const o=e[s];if(3===o._op)continue;const i=t.childNodes[s];if("string"==typeof o)i.textContent!==o&&(3===i.nodeType?i.nodeValue=o:t.replaceChild(d(o),i));else if(o instanceof HTMLElement||o instanceof SVGElement)t.insertBefore(o,i);else{const e=o.props&&o.props.key;if(e)if(i.key===e)h(t.childNodes[s],o,n);else{const r=c[e];if(r){const e=r.nextSibling;t.insertBefore(r,i),e?t.insertBefore(i,e):t.appendChild(i),h(t.childNodes[s],o,n)}else t.replaceChild(m(o,n),i)}else h(t.childNodes[s],o,n)}}let l=(null===(o=t.childNodes)||void 0===o?void 0:o.length)||0;for(;l>a;)t.removeChild(t.lastChild),l--;if(r>a){const s=document.createDocumentFragment();for(let t=a;t<e.length;t++)s.appendChild(m(e[t],n));t.appendChild(s)}}const p=t=>{const e=document.createElement("section");return e.insertAdjacentHTML("afterbegin",t),Array.from(e.children)};function d(t){if(0===(null==t?void 0:t.indexOf("_html:"))){const e=document.createElement("div");return e.insertAdjacentHTML("afterbegin",t.substring(6)),e}return document.createTextNode(null!=t?t:"")}function m(t,e){if(t instanceof HTMLElement||t instanceof SVGElement)return t;if("string"==typeof t)return d(t);if(!t.tag||"function"==typeof t.tag)return d(JSON.stringify(t));const n=(e=e||"svg"===t.tag)?document.createElementNS("http://www.w3.org/2000/svg",t.tag):document.createElement(t.tag);return f(n,t.props,e),t.children&&t.children.forEach((t=>n.appendChild(m(t,e)))),n}function f(t,e,n){const s=t[i]||{};e=function(t,e){e.class=e.class||e.className,delete e.className;const n={};return t&&Object.keys(t).forEach((t=>n[t]=null)),e&&Object.keys(e).forEach((t=>n[t]=e[t])),n}(s,e||{}),t[i]=e;for(const s in e){const o=e[s];if(s.startsWith("data-")){const e=s.substring(5).replace(/-(\w)/g,(t=>t[1].toUpperCase()));t.dataset[e]!==o&&(o||""===o?t.dataset[e]=o:delete t.dataset[e])}else if("style"===s)if(t.style.cssText&&(t.style.cssText=""),"string"==typeof o)t.style.cssText=o;else for(const e in o)t.style[e]!==o[e]&&(t.style[e]=o[e]);else if(s.startsWith("xlink")){const e=s.replace("xlink","").toLowerCase();null==o||!1===o?t.removeAttributeNS("http://www.w3.org/1999/xlink",e):t.setAttributeNS("http://www.w3.org/1999/xlink",e,o)}else s.startsWith("on")?o&&"function"!=typeof o?"string"==typeof o&&(o?t.setAttribute(s,o):t.removeAttribute(s)):t[s]=o:/^id$|^class$|^list$|^readonly$|^contenteditable$|^role|-|^for$/g.test(s)||n?t.getAttribute(s)!==o&&(o?t.setAttribute(s,o):t.removeAttribute(s)):t[s]!==o&&(t[s]=o);"key"===s&&o&&(c[o]=t)}e&&"function"==typeof e.ref&&window.requestAnimationFrame((()=>e.ref(t)))}function y(t,e,n=0){var s;if("string"==typeof t)return t;if(Array.isArray(t))return t.map((t=>y(t,e,n++)));let o=t;if(t&&"function"==typeof t.tag&&Object.getPrototypeOf(t.tag).__isAppRunComponent&&(o=function(t,e,n){const{tag:s,props:o,children:i}=t;let r=`_${n}`,a=o&&o.id;a?r=a:a=`_${n}${Date.now()}`;let c="section";o&&o.as&&(c=o.as,delete o.as),e.__componentCache||(e.__componentCache={});let l=e.__componentCache[r];if(l&&l instanceof s&&l.element)l.renderState(l.state);else{const t=document.createElement(c);l=e.__componentCache[r]=new s(Object.assign(Object.assign({},o),{children:i})).mount(t,{render:!0})}if(l.mounted){const t=l.mounted(o,i,l.state);void 0!==t&&l.setState(t)}return f(l.element,o,!1),l.element}(t,e,n)),o&&Array.isArray(o.children)){const t=null===(s=o.props)||void 0===s?void 0:s._component;if(t){let e=0;o.children=o.children.map((n=>y(n,t,e++)))}else o.children=o.children.map((t=>y(t,e,n++)))}return o}}},e={};function n(s){var o=e[s];if(void 0!==o)return o.exports;var i=e[s]={exports:{}};return t[s](i,i.exports,n),i.exports}n.d=(t,e)=>{for(var s in e)n.o(e,s)&&!n.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var s={};return(()=>{n.r(s);var t=n(37);class e extends t.Component{constructor(){super(...arguments),this.view=({code:e,hide_code:n})=>t.app.h(t.app.Fragment,null,t.app.h("style",null,"\n.CodeMirror, .apprun-play iframe {\n height: 100%;\n border: dotted gray 1px;\n}\n\n.apprun-play {\n height: 100%;\n display: flex;\n}\n\n.apprun-play .col {\n margin: 2px;\n}\n\n.apprun-play .editor, .apprun-play .preview {\n width: 100%;\n height: 100%;\n}\n"),n?t.app.h("div",{class:"apprun-play"},t.app.h("iframe",{class:"preview"})):t.app.h("div",{class:"apprun-play"},t.app.h("div",{class:"col",style:"width:75%"},t.app.h("textarea",{class:"editor"},e)),t.app.h("div",{class:"col",style:"flex:1"},t.app.h("iframe",{class:"preview"})))),this.mounted=t=>{const e=this.element,n=t["code-id"],s=t["hide-code"],o=t["code-width"];let i;i=n?document.getElementById(n):e.previousElementSibling||e.parentElement.previousElementSibling;const r=(null==i?void 0:i.innerText)||(null==i?void 0:i.value)||e.textContent;return i&&(i.style.display="none"),{code:r,hide_code:s,code_width:o}},this.rendered=({code:t,hide_code:e,code_width:n})=>{const s=this.element,o=s.querySelector(".apprun-play .editor");let i=s.querySelector(".apprun-play .preview");if(!i||!o)return;const r=t=>{var e,n;const s=i.cloneNode();null===(e=i.parentNode)||void 0===e||e.replaceChild(s,i),i=s;const o=null===(n=i.contentWindow)||void 0===n?void 0:n.document;o&&(o.open(),t.indexOf("<html")>=0?o.write(t):o.write((t=>`<!DOCTYPE html>\n<html lang="en">\n<head>\n <meta charset="UTF-8">\n <meta name="viewport" content="width=device-width, initial-scale=1.0">\n <meta http-equiv="X-UA-Compatible" content="ie=edge">\n <script src="https://cdnjs.cloudflare.com/ajax/libs/custom-elements/1.1.2/custom-elements.min.js"><\/script>\n <title>AppRun Playground</title>\n <style>\n body {\n font-family: "Benton Sans", "Helvetica Neue", helvetica, arial, sans-serif;\n margin: 2em;\n }\n </style>\n <script src="https://unpkg.com/@babel/standalone/babel.min.js"><\/script>\n <script src="https://unpkg.com/apprun/dist/apprun-html.js"><\/script>\n</head>\n<body>\n<script>\n Babel.registerPlugin("d", [Babel.availablePlugins["proposal-decorators"], {legacy: true}]);\n Babel.registerPlugin("c", [Babel.availablePlugins["proposal-class-properties"], {loose: true}]);\n Babel.registerPlugin("b", [Babel.availablePlugins["proposal-private-methods"], {loose: true}]);\n<\/script>\n<script type="text/babel" data-plugins="d, c, b">\n ${t}\n<\/script>\n</body>\n</html>`)(t)),o.close())};if(t&&r(t),!e&&o)if(n&&(o.parentElement.style.width=n),"undefined"==typeof CodeMirror)o.onkeyup=()=>r(o.value);else{const e=CodeMirror.fromTextArea(o,{lineNumbers:!0,mode:"jsx"});e.setValue(t),e.on("change",(t=>r(t.getValue())))}}}}t.app.webComponent("apprun-code",e)})(),s})()));
2
+ //# sourceMappingURL=apprun-code.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dist/apprun-code.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAgB,OAAID,IAEpBD,EAAa,OAAIC,GAClB,CATD,CASGK,MAAM,I,iECRF,MAAMC,EAcX,WAAAC,GACEF,KAAKG,QAAU,CAAC,CAClB,CAEA,EAAAC,CAAGC,EAAcC,EAAuBC,EAAwB,CAAC,GAC/DP,KAAKG,QAAQE,GAAQL,KAAKG,QAAQE,IAAS,GAC3CL,KAAKG,QAAQE,GAAMG,KAAK,CAAEF,KAAIC,WAChC,CAEA,GAAAE,CAAIJ,EAAcC,GAChB,MAAMI,EAAcV,KAAKG,QAAQE,IAAS,GAE1CL,KAAKG,QAAQE,GAAQK,EAAYC,QAAQC,GAAQA,EAAIN,KAAOA,GAC9D,CAEA,IAAAO,CAAKR,GACH,OAAOL,KAAKG,QAAQE,EACtB,CAEA,GAAAS,CAAIT,KAAiBU,GACnB,MAAML,EAAcV,KAAKgB,eAAeX,EAAML,KAAKG,SAYnD,OAXAc,QAAQC,OAAOR,GAAeA,EAAYS,OAAS,EAAG,4BAA8Bd,GACpFK,EAAYU,SAASR,IACnB,MAAM,GAAEN,EAAE,QAAEC,GAAYK,EAMxB,OALIL,EAAQc,MACVrB,KAAKqB,MAAMhB,EAAMC,EAAIS,EAAMR,GAE3Be,OAAOC,KAAKhB,GAASY,OAAS,EAAIb,EAAGkB,MAAMxB,KAAM,IAAIe,EAAMR,IAAYD,EAAGkB,MAAMxB,KAAMe,IAEhFH,EAAIL,QAAQkB,IAAI,IAGnBf,EAAYS,MACrB,CAEA,IAAAM,CAAKpB,EAAcC,EAAIC,EAAwB,C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leDefinition","webpack://apprun/./src/app.ts","webpack://apprun/./src/web-component.ts","webpack://apprun/./src/decorator.ts","webpack://apprun/./src/component.ts","webpack://apprun/./src/router.ts","webpack://apprun/./src/apprun.ts","webpack://apprun/./src/directive.ts","webpack://apprun/./src/vdom-my.ts","webpack://apprun/webpack/bootstrap","webpack://apprun/webpack/runtime/define property getters","webpack://apprun/webpack/runtime/global","webpack://apprun/webpack/runtime/hasOwnProperty shorthand","webpack://apprun/webpack/runtime/make namespace object","webpack://apprun/./src/apprun-code.tsx"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"apprun\"] = factory();\n\telse\n\t\troot[\"apprun\"] = factory();\n})(this, () => {\nreturn ","import { EventOptions} from './types'\nexport class App {\n\n private _events: Object;\n\n public start;\n public h;\n public createElement;\n public render;\n public Fragment;\n public webComponent;\n public safeHTML;\n public use_render;\n public use_react;\n\n constructor() {\n this._events = {};\n }\n\n on(name: string, fn: (...args) => void, options: EventOptions = {}): void {\n this._events[name] = this._events[name] || [];\n this._events[name].push({ fn, options });\n }\n\n off(name: string, fn: (...args) => void): void {\n const subscribers = this._events[name] || [];\n\n this._events[name] = subscribers.filter((sub) => sub.fn !== fn);\n }\n\n find(name: string): any {\n return this._events[name];\n }\n\n run(name: string, ...args): number {\n const subscribers = this.getSubscribers(name, this._events);\n console.assert(subscribers && subscribers.length > 0, 'No subscriber for event: ' + name);\n subscribers.forEach((sub) => {\n const { fn, options } = sub;\n if (options.delay) {\n this.delay(name, fn, args, options);\n } else {\n Object.keys(options).length > 0 ? fn.apply(this, [...args, options]) : fn.apply(this, args);\n }\n return !sub.options.once;\n });\n\n return subscribers.length;\n }\n\n once(name: string, fn, options: EventOptions = {}): void {\n this.on(name, fn, { ...options, once: true });\n }\n\n private delay(name, fn, args, options): void {\n if (options._t) clearTimeout(options._t);\n options._t = setTimeout(() => {\n clearTimeout(options._t);\n Object.keys(options).length > 0 ? fn.apply(this, [...args, options]) : fn.apply(this, args);\n }, options.delay);\n }\n\n runAsync(name: string, ...args): Promise<any[]> {\n const subscribers = this.getSubscribers(name, this._events);\n console.assert(subscribers && subscribers.length > 0, 'No subscriber for event: ' + name);\n const promises = subscribers.map(sub => {\n const { fn, options } = sub;\n return Object.keys(options).length > 0 ? fn.apply(this, [...args, options]) : fn.apply(this, args);\n });\n return Promise.all(promises);\n }\n\n query(name: string, ...args): Promise<any[]> {\n return this.query(name, ...args);\n }\n\n private getSubscribers(name: string, events) {\n const subscribers = events[name] || [];\n\n // Update the list of subscribers by pulling out those which will run once.\n // We must do this update prior to running any of the events in case they\n // cause additional events to be turned off or on.\n events[name] = subscribers.filter((sub) => {\n return !sub.options.once;\n });\n Object.keys(events).filter(evt => evt.endsWith('*') && name.startsWith(evt.replace('*', '')))\n .sort((a, b) => b.length - a.length)\n .forEach(evt => subscribers.push(...events[evt].map(sub => ({\n ...sub,\n options: { ...sub.options, event: name }\n }))));\n return subscribers;\n }\n}\n\nconst AppRunVersions = 'AppRun-3';\nlet app: App;\nconst root = (typeof self === 'object' && self.self === self && self) ||\n (typeof global === 'object' && global.global === global && global)\nif (root['app'] && root['_AppRunVersions']) {\n app = root['app'];\n} else {\n app = new App();\n root['app'] = app;\n root['_AppRunVersions'] = AppRunVersions;\n}\nexport default app;\n","declare var customElements;\n\nexport type CustomElementOptions = {\n render?: boolean;\n shadow?: boolean;\n history?: boolean;\n global_event?: boolean;\n observedAttributes?: string[];\n};\n\nexport const customElement = (componentClass, options: CustomElementOptions = {}) => class CustomElement extends HTMLElement {\n private _shadowRoot;\n private _component;\n private _attrMap: (arg0: string) => string;\n public on;\n public run;\n constructor() {\n super();\n }\n get component() { return this._component; }\n get state() { return this._component.state; }\n\n static get observedAttributes() {\n // attributes need to be set to lowercase in order to get observed\n return (options.observedAttributes || []).map(attr => attr.toLowerCase());\n }\n\n connectedCallback() {\n if (this.isConnected && !this._component) {\n const opts = options || {};\n this._shadowRoot = opts.shadow ? this.attachShadow({ mode: 'open' }) : this;\n const observedAttributes = (opts.observedAttributes || [])\n\n const attrMap = observedAttributes.reduce((map, name) => {\n const lc = name.toLowerCase()\n if (lc !== name) {\n map[lc] = name\n }\n return map\n }, {})\n this._attrMap = (name: string) : string => attrMap[name] || name\n\n const props = {};\n Array.from(this.attributes).forEach(item => props[this._attrMap(item.name)] = item.value);\n\n // add getters/ setters to allow observation on observedAttributes\n observedAttributes.forEach(name => {\n if (this[name] !== undefined) props[name] = this[name];\n Object.defineProperty(this, name, {\n get(): any {\n return props[name];\n },\n set(this: CustomElement, value: unknown) {\n // trigger change event\n this.attributeChangedCallback(name, props[name], value)\n },\n configurable: true,\n enumerable: true\n });\n })\n\n requestAnimationFrame(() => {\n const children = this.children ? Array.from(this.children) : [];\n // children.forEach(el => el.parentElement.removeChild(el));\n this._component = new componentClass({ ...props, children }).mount(this._shadowRoot, opts);\n // attach props to component\n this._component._props = props;\n // expose dispatchEvent\n this._component.dispatchEvent = this.dispatchEvent.bind(this)\n if (this._component.mounted) {\n const new_state = this._component.mounted(props, children, this._component.state);\n if (typeof new_state !== 'undefined') this._component.state = new_state;\n }\n this.on = this._component.on.bind(this._component);\n this.run = this._component.run.bind(this._component);\n if (!(opts.render === false)) this._component.run('.');\n });\n }\n }\n\n disconnectedCallback() {\n this._component?.unload?.();\n this._component?.unmount?.();\n this._component = null;\n }\n\n attributeChangedCallback(name: string, oldValue: unknown, value: unknown) {\n if (this._component) {\n // camelCase attributes arrive only in lowercase\n const mappedName = this._attrMap(name);\n // store the new property/ attribute\n this._component._props[mappedName] = value;\n this._component.run('attributeChanged', mappedName, oldValue, value);\n\n if (value !== oldValue && !(options.render === false)) {\n window.requestAnimationFrame(() => {\n // re-render state with new combined props on next animation frame\n this._component.run('.')\n })\n }\n }\n }\n}\n\nexport default (name: string, componentClass, options?: CustomElementOptions) => {\n (typeof customElements !== 'undefined') && customElements.define(name, customElement(componentClass, options))\n}\n","import webComponent, { CustomElementOptions } from './web-component';\n\n// tslint:disable:no-invalid-this\nexport const Reflect = {\n\n meta: new WeakMap(),\n\n defineMetadata(metadataKey, metadataValue, target) {\n if (!this.meta.has(target)) this.meta.set(target, {});\n this.meta.get(target)[metadataKey] = metadataValue;\n },\n\n getMetadataKeys(target) {\n target = Object.getPrototypeOf(target);\n return this.meta.get(target) ? Object.keys(this.meta.get(target)) : [];\n },\n\n getMetadata(metadataKey, target) {\n target = Object.getPrototypeOf(target);\n return this.meta.get(target) ? this.meta.get(target)[metadataKey] : null;\n }\n}\n\nexport function update<E=string>(events?: E, options: any = {}) {\n return (target: any, key: string, descriptor: any) => {\n const name = events ? events.toString() : key;\n Reflect.defineMetadata(`apprun-update:${name}`,\n { name, key, options }, target);\n return descriptor;\n }\n}\n\nexport function on<E = string>(events?: E, options: any = {}) {\n return function (target: any, key: string) {\n const name = events ? events.toString() : key;\n Reflect.defineMetadata(`apprun-update:${name}`,\n { name, key, options }, target)\n }\n}\n\nexport function customElement(name: string, options?: CustomElementOptions) {\n return function _customElement<T extends { new(...args: any[]): {} }>(constructor: T) {\n webComponent(name, constructor, options);\n return constructor;\n }\n}\n\n","\r\nimport app, { App } from './app';\r\nimport { Reflect } from './decorator'\r\nimport { View, Update, ActionDef, ActionOptions, MountOptions, EventOptions } from './types';\r\nimport directive from './directive';\r\n\r\nconst componentCache = new Map();\r\nif (!app.find('get-components')) app.on('get-components', o => o.components = componentCache);\r\n\r\nconst REFRESH = state => state;\r\n\r\nexport class Component<T = any, E = any> {\r\n static __isAppRunComponent = true;\r\n private _app = new App();\r\n private _actions = [];\r\n private _global_events = [];\r\n private _state;\r\n private _history = [];\r\n private _history_idx = -1;\r\n private enable_history;\r\n private global_event;\r\n public element;\r\n public rendered;\r\n public mounted;\r\n public unload;\r\n private tracking_id;\r\n private observer;\r\n\r\n\r\n private renderState(state: T, vdom = null) {\r\n if (!this.view) return;\r\n let html = vdom || this.view(state);\r\n app['debug'] && app.run('debug', {\r\n component: this,\r\n _: html ? '.' : '-',\r\n state,\r\n vdom: html,\r\n el: this.element\r\n });\r\n\r\n if (typeof document !== 'object') return;\r\n\r\n const el = (typeof this.element === 'string' && this.element) ?\r\n document.getElementById(this.element) || document.querySelector(this.element) : this.element;\r\n\r\n if (!el) return;\r\n const tracking_attr = '_c';\r\n if (!this.unload) {\r\n el.removeAttribute && el.removeAttribute(tracking_attr);\r\n } else if (el['_component'] !== this || el.getAttribute(tracking_attr) !== this.tracking_id) {\r\n this.tracking_id = new Date().valueOf().toString();\r\n el.setAttribute(tracking_attr, this.tracking_id);\r\n if (typeof MutationObserver !== 'undefined') {\r\n if (!this.observer) this.observer = new MutationObserver(changes => {\r\n if (changes[0].oldValue === this.tracking_id || !document.body.contains(el)) {\r\n this.unload(this.state);\r\n this.observer.disconnect();\r\n this.observer = null;\r\n }\r\n });\r\n this.observer.observe(document.body, {\r\n childList: true, subtree: true,\r\n attributes: true, attributeOldValue: true, attributeFilter: [tracking_attr]\r\n });\r\n }\r\n }\r\n el['_component'] = this;\r\n\r\n if (!vdom && html) {\r\n html = directive(html, this);\r\n if (this.options.transition && document && document['startViewTransition']) {\r\n document['startViewTransition'](() => app.render(el, html, this));\r\n } else {\r\n app.render(el, html, this);\r\n }\r\n }\r\n this.rendered && this.rendered(this.state);\r\n }\r\n\r\n public setState(state: T, options: ActionOptions & EventOptions\r\n = { render: true, history: false }) {\r\n if (state instanceof Promise) {\r\n // Promise will not be saved or rendered\r\n // state will be saved and rendered when promise is resolved\r\n Promise.resolve(state).then(v => {\r\n this.setState(v, options);\r\n this._state = state;\r\n });\r\n } else {\r\n this._state = state;\r\n if (state == null) return;\r\n this.state = state;\r\n if (options.render !== false) {\r\n // before render state\r\n if (options.transition && document && document['startViewTransition']) {\r\n document['startViewTransition'](() => this.renderState(state));\r\n } else {\r\n this.renderState(state);\r\n }\r\n }\r\n if (options.history !== false && this.enable_history) {\r\n this._history = [...this._history, state];\r\n this._history_idx = this._history.length - 1;\r\n }\r\n if (typeof options.callback === 'function') options.callback(this.state);\r\n }\r\n }\r\n\r\n private _history_prev = () => {\r\n this._history_idx--;\r\n if (this._history_idx >= 0) {\r\n this.setState(this._history[this._history_idx], { render: true, history: false });\r\n }\r\n else {\r\n this._history_idx = 0;\r\n }\r\n };\r\n\r\n private _history_next = () => {\r\n this._history_idx++;\r\n if (this._history_idx < this._history.length) {\r\n this.setState(this._history[this._history_idx], { render: true, history: false });\r\n }\r\n else {\r\n this._history_idx = this._history.length - 1;\r\n }\r\n };\r\n\r\n constructor(\r\n protected state?: T,\r\n protected view?: View<T>,\r\n protected update?: Update<T, E>,\r\n protected options?) {\r\n }\r\n\r\n start = (element = null, options?: MountOptions): Component<T, E> => {\r\n this.mount(element, { render: true, ...options });\r\n if (this.mounted && typeof this.mounted === 'function') {\r\n const new_state = this.mounted({}, [], this.state);\r\n (typeof new_state !== 'undefined') && this.setState(new_state);\r\n }\r\n return this;\r\n }\r\n\r\n public mount(element = null, options?: MountOptions): Component<T, E> {\r\n console.assert(!this.element, 'Component already mounted.')\r\n this.options = options = { ...this.options, ...options };\r\n this.element = element;\r\n this.global_event = options.global_event;\r\n this.enable_history = !!options.history;\r\n\r\n if (this.enable_history) {\r\n this.on(options.history.prev || 'history-prev', this._history_prev);\r\n this.on(options.history.next || 'history-next', this._history_next);\r\n }\r\n\r\n if (options.route) {\r\n this.update = this.update || {};\r\n if (!this.update[options.route]) this.update[options.route] = REFRESH;\r\n }\r\n\r\n this.add_actions();\r\n this.state = this.state ?? this['model'] ?? {};\r\n if (typeof this.state === 'function') this.state = this.state();\r\n\r\n this.setState(this.state, { render: !!options.render, history: true });\r\n\r\n if (app['debug']) {\r\n if (componentCache.get(element)) { componentCache.get(element).push(this) }\r\n else { componentCache.set(element, [this]) }\r\n }\r\n return this;\r\n }\r\n\r\n is_global_event(name: string): boolean {\r\n return name && (\r\n this.global_event ||\r\n this._global_events.indexOf(name) >= 0 ||\r\n name.startsWith('#') || name.startsWith('/') || name.startsWith('@'));\r\n }\r\n\r\n add_action(name: string, action, options: ActionOptions = {}) {\r\n if (!action || typeof action !== 'function') return;\r\n if (options.global) this._global_events.push(name);\r\n this.on(name as any, (...p) => {\r\n\r\n app['debug'] && app.run('debug', {\r\n component: this,\r\n _: '>',\r\n event: name, p,\r\n current_state: this.state,\r\n options\r\n });\r\n\r\n const newState = action(this.state, ...p);\r\n\r\n app['debug'] && app.run('debug', {\r\n component: this,\r\n _: '<',\r\n event: name, p,\r\n newState,\r\n state: this.state,\r\n options\r\n });\r\n\r\n this.setState(newState, options)\r\n }, options);\r\n }\r\n\r\n add_actions() {\r\n const actions = this.update || {};\r\n Reflect.getMetadataKeys(this).forEach(key => {\r\n if (key.startsWith('apprun-update:')) {\r\n const meta = Reflect.getMetadata(key, this)\r\n actions[meta.name] = [this[meta.key].bind(this), meta.options];\r\n }\r\n })\r\n\r\n const all = {};\r\n if (Array.isArray(actions)) {\r\n actions.forEach(act => {\r\n const [name, action, opts] = act as ActionDef<T, E>;\r\n const names = name.toString();\r\n names.split(',').forEach(n => all[n.trim()] = [action, opts])\r\n })\r\n } else {\r\n Object.keys(actions).forEach(name => {\r\n const action = actions[name];\r\n if (typeof action === 'function' || Array.isArray(action)) {\r\n name.split(',').forEach(n => all[n.trim()] = action)\r\n }\r\n })\r\n }\r\n\r\n if (!all['.']) all['.'] = REFRESH;\r\n Object.keys(all).forEach(name => {\r\n const action = all[name];\r\n if (typeof action === 'function') {\r\n this.add_action(name, action);\r\n } else if (Array.isArray(action)) {\r\n this.add_action(name, action[0], action[1]);\r\n }\r\n });\r\n }\r\n\r\n public run(event: E, ...args) {\r\n if (this.state instanceof Promise) {\r\n return Promise.resolve(this.state).then(state => {\r\n this.state = state;\r\n this.run(event, ...args)\r\n });\r\n } else {\r\n const name = event.toString();\r\n return this.is_global_event(name) ?\r\n app.run(name, ...args) :\r\n this._app.run(name, ...args);\r\n }\r\n }\r\n\r\n public on(event: E, fn: (...args) => void, options?: any) {\r\n const name = event.toString();\r\n this._actions.push({ name, fn });\r\n return this.is_global_event(name) ?\r\n app.on(name, fn, options) :\r\n this._app.on(name, fn, options);\r\n }\r\n\r\n public runAsync(event: E, ...args) {\r\n const name = event.toString();\r\n return this.is_global_event(name) ?\r\n app.runAsync(name, ...args) :\r\n this._app.runAsync(name, ...args);\r\n }\r\n\r\n // obsolete\r\n public query(event: E, ...args) {\r\n return this.runAsync(event, ...args);\r\n }\r\n\r\n public unmount() {\r\n this.observer?.disconnect();\r\n this._actions.forEach(action => {\r\n const { name, fn } = action;\r\n this.is_global_event(name) ?\r\n app.off(name, fn) :\r\n this._app.off(name, fn);\r\n });\r\n }\r\n}\r\n","import app from './app';\n\nexport type Route = (url: string, ...args: any[]) => any;\n\nexport const ROUTER_EVENT: string = '//';\nexport const ROUTER_404_EVENT: string = '///';\n\nexport const route: Route = (url: string) => {\n if (!url) url = '#';\n if (url.startsWith('#')) {\n const [name, ...rest] = url.split('/');\n app.run(name, ...rest) || app.run(ROUTER_404_EVENT, name, ...rest);\n app.run(ROUTER_EVENT, name, ...rest);\n } else if (url.startsWith('/')) {\n const [_, name, ...rest] = url.split('/');\n app.run('/' + name, ...rest) || app.run(ROUTER_404_EVENT, '/' + name, ...rest);\n app.run(ROUTER_EVENT, '/' + name, ...rest);\n } else {\n app.run(url) || app.run(ROUTER_404_EVENT, url);\n app.run(ROUTER_EVENT, url);\n }\n}\nexport default route;","import app, { App } from './app';\nimport { createElement, render, Fragment, safeHTML } from './vdom';\nimport { Component } from './component';\nimport { VNode, View, Action, Update, EventOptions, ActionOptions, MountOptions, AppStartOptions } from './types';\nimport { on, update, customElement } from './decorator';\nimport webComponent, { CustomElementOptions } from './web-component';\nimport { Route, route, ROUTER_EVENT, ROUTER_404_EVENT } from './router';\n\nexport interface IApp {\n start<T, E = any>(element?: Element | string, model?: T, view?: View<T>, update?: Update<T, E>,\n options?: AppStartOptions<T>): Component<T, E>;\n on(name: string, fn: (...args: any[]) => void, options?: any): void;\n off(name: string, fn: (...args: any[]) => void): void;\n run(name: string, ...args: any[]): number;\n find(name: string): any | any[];\n h(tag: string | Function, props, ...children): VNode | VNode[];\n createElement(tag: string | Function, props, ...children): VNode | VNode[];\n render(element: Element | string, node: VNode): void;\n Fragment(props, ...children): any[];\n route?: Route;\n webComponent(name: string, componentClass, options?: CustomElementOptions): void;\n safeHTML(html: string): any[];\n use_render(render, mode?: 0 | 1);\n use_react(createRoot);\n}\n\napp.h = app.createElement = createElement;\napp.render = render;\napp.Fragment = Fragment;\napp.webComponent = webComponent;\napp.safeHTML = safeHTML;\n\napp.start = <T, E = any>(element?: Element | string, model?: T, view?: View<T>, update?: Update<T, E>,\n options?: AppStartOptions<T>): Component<T, E> => {\n const opts = { render: true, global_event: true, ...options };\n const component = new Component<T, E>(model, view, update);\n if (options && options.rendered) component.rendered = options.rendered;\n if (options && options.mounted) component.mounted = options.mounted;\n component.start(element, opts);\n return component;\n};\n\nconst NOOP = _ => {/* Intentionally empty */ }\napp.on('$', NOOP);\napp.on('debug', _ => NOOP);\napp.on(ROUTER_EVENT, NOOP);\napp.on('#', NOOP);\napp['route'] = route;\napp.on('route', url => app['route'] && app['route'](url));\n\nif (typeof document === 'object') {\n document.addEventListener(\"DOMContentLoaded\", () => {\n if (app['route'] === route) {\n window.onpopstate = () => route(location.hash);\n document.body.hasAttribute('apprun-no-init') || app['no-init-route'] || route(location.hash);\n }\n });\n}\nexport type StatelessComponent<T = {}> = (args: T) => string | VNode | void;\nexport { App, app, Component, View, Action, Update, on, update, EventOptions, ActionOptions, MountOptions, Fragment, safeHTML }\nexport { update as event };\nexport { ROUTER_EVENT, ROUTER_404_EVENT };\nexport { customElement, CustomElementOptions, AppStartOptions };\nexport default app as IApp;\n\nif (typeof window === 'object') {\n window['Component'] = Component;\n window['_React'] = window['React'];\n window['React'] = app;\n window['on'] = on;\n window['customElement'] = customElement;\n window['safeHTML'] = safeHTML;\n}\n\napp.use_render = (render, mode = 0) =>\n mode === 0 ?\n app.render = (el, vdom) => render(vdom, el) : // react style\n app.render = (el, vdom) => render(el, vdom); // apprun style\n\napp.use_react = (React, ReactDOM) => {\n app.h = app.createElement = React.createElement;\n app.Fragment = React.Fragment;\n app.render = (el, vdom) => ReactDOM.render(vdom, el);\n if (React.version && React.version.startsWith('18')) {\n app.render = (el, vdom) => {\n if (!el || !vdom) return;\n if (!el._root) el._root = ReactDOM.createRoot(el);\n el._root.render(vdom);\n }\n }\n}\n","import app from './app';\n\nconst getStateValue = (component, name) => {\n return (name ? component['state'][name] : component['state']) || '';\n}\n\nconst setStateValue = (component, name, value) => {\n if (name) {\n const state = component['state'] || {};\n state[name] = value;\n component.setState(state);\n } else {\n component.setState(value);\n }\n}\n\nconst apply_directive = (key: string, props: {}, tag, component) => {\n if (key.startsWith('$on')) {\n const event = props[key];\n key = key.substring(1)\n if (typeof event === 'boolean') {\n props[key] = e => component.run ? component.run(key, e) : app.run(key, e);\n } else if (typeof event === 'string') {\n props[key] = e => component.run ? component.run(event, e) : app.run(event, e);\n } else if (typeof event === 'function') {\n props[key] = e => component.setState(event(component.state, e));\n } else if (Array.isArray(event)) {\n const [handler, ...p] = event;\n if (typeof handler === 'string') {\n props[key] = e => component.run ? component.run(handler, ...p, e) : app.run(handler, ...p, e);\n } else if (typeof handler === 'function') {\n props[key] = e => component.setState(handler(component.state, ...p, e));\n }\n }\n\n } else if (key === '$bind') {\n const type = props['type'] || 'text';\n const name = typeof props[key] === 'string' ? props[key] : props['name'];\n if (tag === 'input') {\n switch (type) {\n case 'checkbox':\n props['checked'] = getStateValue(component, name);\n props['onclick'] = e => setStateValue(component, name || e.target.name, e.target.checked);\n break;\n case 'radio':\n props['checked'] = getStateValue(component, name) === props['value'];\n props['onclick'] = e => setStateValue(component, name || e.target.name, e.target.value);\n break;\n case 'number':\n case 'range':\n props['value'] = getStateValue(component, name);\n props['oninput'] = e => setStateValue(component, name || e.target.name, Number(e.target.value));\n break;\n default:\n props['value'] = getStateValue(component, name);\n props['oninput'] = e => setStateValue(component, name || e.target.name, e.target.value);\n }\n } else if (tag === 'select') {\n props['value'] = getStateValue(component, name);\n props['onchange'] = e => {\n if (!e.target.multiple) { // multiple selection use $bind on option\n setStateValue(component, name || e.target.name, e.target.value);\n }\n }\n } else if (tag === 'option') {\n props['selected'] = getStateValue(component, name);\n props['onclick'] = e => setStateValue(component, name || e.target.name, e.target.selected);\n } else if (tag === 'textarea') {\n props['innerHTML'] = getStateValue(component, name);\n props['oninput'] = e => setStateValue(component, name || e.target.name, e.target.value);\n }\n } else {\n app.run('$', { key, tag, props, component });\n }\n}\n\nconst directive = (vdom, component) => {\n if (Array.isArray(vdom)) {\n return vdom.map(element => directive(element, component));\n } else {\n let { type, tag, props, children } = vdom;\n tag = tag || type;\n children = children || props?.children;\n if (props) Object.keys(props).forEach(key => {\n if (key.startsWith('$')) {\n apply_directive(key, props, tag, component);\n delete props[key];\n }\n });\n if (children) directive(children, component);\n return vdom;\n }\n}\n\nexport default directive;","import { VDOM, VNode } from './types';\nimport directive from './directive';\nexport type Element = any; //HTMLElement | SVGSVGElement | SVGElement;\n\nexport function Fragment(props, ...children): any[] {\n return collect(children);\n}\n\nconst ATTR_PROPS = '_props';\n\nfunction collect(children) {\n const ch = [];\n const push = (c) => {\n if (c !== null && c !== undefined && c !== '' && c !== false) {\n ch.push((typeof c === 'function' || typeof c === 'object') ? c : `${c}`);\n }\n }\n children && children.forEach(c => {\n if (Array.isArray(c)) {\n c.forEach(i => push(i));\n } else {\n push(c);\n }\n });\n return ch;\n}\n\nexport function createElement(tag: string | Function | [], props?: {}, ...children) {\n const ch = collect(children);\n if (typeof tag === 'string') return { tag, props, children: ch };\n else if (Array.isArray(tag)) return tag; // JSX fragments - babel\n else if (tag === undefined && children) return ch; // JSX fragments - typescript\n else if (Object.getPrototypeOf(tag).__isAppRunComponent) return { tag, props, children: ch } // createComponent(tag, { ...props, children });\n else if (typeof tag === 'function') return tag(props, ch);\n else throw new Error(`Unknown tag in vdom ${tag}`);\n};\n\nconst keyCache = new WeakMap();\n\nexport const updateElement = (element: Element | string, nodes: VDOM, component = {}) => {\n // tslint:disable-next-line\n if (nodes == null || nodes === false) return;\n const el = (typeof element === 'string' && element) ?\n document.getElementById(element) || document.querySelector(element) : element;\n nodes = directive(nodes, component);\n render(el, nodes, component);\n}\n\nfunction render(element: Element, nodes: VDOM, parent = {}) {\n // tslint:disable-next-line\n if (nodes == null || nodes === false) return;\n nodes = createComponent(nodes, parent);\n if (!element) return;\n const isSvg = element.nodeName === \"SVG\";\n if (Array.isArray(nodes)) {\n updateChildren(element, nodes, isSvg);\n } else {\n updateChildren(element, [nodes], isSvg);\n }\n}\n\nfunction same(el: Element, node: VNode) {\n // if (!el || !node) return false;\n const key1 = el.nodeName;\n const key2 = `${node.tag || ''}`;\n return key1.toUpperCase() === key2.toUpperCase();\n}\n\nfunction update(element: Element, node: VNode, isSvg: boolean) {\n if (node['_op'] === 3) return;\n // console.assert(!!element);\n isSvg = isSvg || node.tag === \"svg\";\n if (!same(element, node)) {\n element.parentNode.replaceChild(create(node, isSvg), element);\n return;\n }\n !(node['_op'] & 2) && updateChildren(element, node.children, isSvg);\n !(node['_op'] & 1) && updateProps(element, node.props, isSvg);\n}\n\nfunction updateChildren(element, children, isSvg: boolean) {\n const old_len = element.childNodes?.length || 0;\n const new_len = children?.length || 0;\n const len = Math.min(old_len, new_len);\n for (let i = 0; i < len; i++) {\n const child = children[i];\n if (child['_op'] === 3) continue;\n const el = element.childNodes[i];\n if (typeof child === 'string') {\n if (el.textContent !== child) {\n if (el.nodeType === 3) {\n el.nodeValue = child\n } else {\n element.replaceChild(createText(child), el);\n }\n }\n } else if (child instanceof HTMLElement || child instanceof SVGElement) {\n element.insertBefore(child, el);\n } else {\n const key = child.props && child.props['key'];\n if (key) {\n if (el.key === key) {\n update(element.childNodes[i], child, isSvg);\n } else {\n // console.log(el.key, key);\n const old = keyCache[key];\n if (old) {\n const temp = old.nextSibling;\n element.insertBefore(old, el);\n temp ? element.insertBefore(el, temp) : element.appendChild(el);\n update(element.childNodes[i], child, isSvg);\n } else {\n element.replaceChild(create(child, isSvg), el);\n }\n }\n } else {\n update(element.childNodes[i], child, isSvg);\n }\n }\n }\n\n let n = element.childNodes?.length || 0;\n while (n > len) {\n element.removeChild(element.lastChild);\n n--;\n }\n\n if (new_len > len) {\n const d = document.createDocumentFragment();\n for (let i = len; i < children.length; i++) {\n d.appendChild(create(children[i], isSvg));\n }\n element.appendChild(d);\n }\n}\n\nexport const safeHTML = (html: string) => {\n const div = document.createElement('section');\n div.insertAdjacentHTML('afterbegin', html)\n return Array.from(div.children);\n}\n\nfunction createText(node) {\n if (node?.indexOf('_html:') === 0) { // ?\n const div = document.createElement('div');\n div.insertAdjacentHTML('afterbegin', node.substring(6))\n return div;\n } else {\n return document.createTextNode(node??'');\n }\n}\n\nfunction create(node: VNode | string | HTMLElement | SVGElement, isSvg: boolean): Element {\n // console.assert(node !== null && node !== undefined);\n if ((node instanceof HTMLElement) || (node instanceof SVGElement)) return node;\n if (typeof node === \"string\") return createText(node);\n if (!node.tag || (typeof node.tag === 'function')) return createText(JSON.stringify(node));\n isSvg = isSvg || node.tag === \"svg\";\n const element = isSvg\n ? document.createElementNS(\"http://www.w3.org/2000/svg\", node.tag)\n : document.createElement(node.tag);\n\n updateProps(element, node.props, isSvg);\n if (node.children) node.children.forEach(child => element.appendChild(create(child, isSvg)));\n return element\n}\n\nfunction mergeProps(oldProps: {}, newProps: {}): {} {\n newProps['class'] = newProps['class'] || newProps['className'];\n delete newProps['className'];\n const props = {};\n if (oldProps) Object.keys(oldProps).forEach(p => props[p] = null);\n if (newProps) Object.keys(newProps).forEach(p => props[p] = newProps[p]);\n return props;\n}\n\nexport function updateProps(element: Element, props: {}, isSvg) {\n // console.assert(!!element);\n const cached = element[ATTR_PROPS] || {};\n props = mergeProps(cached, props || {});\n element[ATTR_PROPS] = props;\n\n for (const name in props) {\n const value = props[name];\n // if (cached[name] === value) continue;\n // console.log('updateProps', name, value);\n if (name.startsWith('data-')) {\n const dname = name.substring(5);\n const cname = dname.replace(/-(\\w)/g, (match) => match[1].toUpperCase());\n if (element.dataset[cname] !== value) {\n if (value || value === \"\") element.dataset[cname] = value;\n else delete element.dataset[cname];\n }\n } else if (name === 'style') {\n if (element.style.cssText) element.style.cssText = '';\n if (typeof value === 'string') element.style.cssText = value;\n else {\n for (const s in value) {\n if (element.style[s] !== value[s]) element.style[s] = value[s];\n }\n }\n } else if (name.startsWith('xlink')) {\n const xname = name.replace('xlink', '').toLowerCase();\n if (value == null || value === false) {\n element.removeAttributeNS('http://www.w3.org/1999/xlink', xname);\n } else {\n element.setAttributeNS('http://www.w3.org/1999/xlink', xname, value);\n }\n } else if (name.startsWith('on')) {\n if (!value || typeof value === 'function') {\n element[name] = value;\n } else if (typeof value === 'string') {\n if (value) element.setAttribute(name, value);\n else element.removeAttribute(name);\n }\n } else if (/^id$|^class$|^list$|^readonly$|^contenteditable$|^role|-|^for$/g.test(name) || isSvg) {\n if (element.getAttribute(name) !== value) {\n if (value) element.setAttribute(name, value);\n else element.removeAttribute(name);\n }\n } else if (element[name] !== value) {\n element[name] = value;\n }\n if (name === 'key' && value) keyCache[value] = element;\n }\n if (props && typeof props['ref'] === 'function') {\n window.requestAnimationFrame(() => props['ref'](element));\n }\n}\n\nfunction render_component(node, parent, idx) {\n const { tag, props, children } = node;\n let key = `_${idx}`;\n let id = props && props['id'];\n if (!id) id = `_${idx}${Date.now()}`;\n else key = id;\n let asTag = 'section';\n if (props && props['as']) {\n asTag = props['as'];\n delete props['as'];\n }\n if (!parent.__componentCache) parent.__componentCache = {};\n let component = parent.__componentCache[key];\n if (!component || !(component instanceof tag) || !component.element) {\n const element = document.createElement(asTag);\n component = parent.__componentCache[key] = new tag({ ...props, children }).mount(element, { render: true });\n } else {\n component.renderState(component.state);\n }\n if (component.mounted) {\n const new_state = component.mounted(props, children, component.state);\n (typeof new_state !== 'undefined') && component.setState(new_state);\n }\n updateProps(component.element, props, false);\n return component.element;\n}\n\nfunction createComponent(node, parent, idx = 0) {\n if (typeof node === 'string') return node;\n if (Array.isArray(node)) return node.map(child => createComponent(child, parent, idx++));\n let vdom = node;\n if (node && typeof node.tag === 'function' && Object.getPrototypeOf(node.tag).__isAppRunComponent) {\n vdom = render_component(node, parent, idx);\n }\n if (vdom && Array.isArray(vdom.children)) {\n const new_parent = vdom.props?._component;\n if (new_parent) {\n let i = 0;\n vdom.children = vdom.children.map(child => createComponent(child, new_parent, i++));\n } else {\n vdom.children = vdom.children.map(child => createComponent(child, parent, idx++));\n }\n }\n return vdom;\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\n\t}\n})();","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { app, Component } from './apprun';\n\ndeclare var CodeMirror;\n\nconst styles = `\n.CodeMirror, .apprun-play iframe {\n height: 100%;\n border: dotted gray 1px;\n}\n\n.apprun-play {\n height: 100%;\n display: flex;\n}\n\n.apprun-play .col {\n margin: 2px;\n}\n\n.apprun-play .editor, .apprun-play .preview {\n width: 100%;\n height: 100%;\n}\n`;\n\nconst code_html = code => `<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\">\n <script src=\"https://cdnjs.cloudflare.com/ajax/libs/custom-elements/1.1.2/custom-elements.min.js\"></script>\n <title>AppRun Playground</title>\n <style>\n body {\n font-family: \"Benton Sans\", \"Helvetica Neue\", helvetica, arial, sans-serif;\n margin: 2em;\n }\n </style>\n <script src=\"https://unpkg.com/@babel/standalone/babel.min.js\"></script>\n <script src=\"https://unpkg.com/apprun/dist/apprun-html.js\"></script>\n</head>\n<body>\n<script>\n Babel.registerPlugin(\"d\", [Babel.availablePlugins[\"proposal-decorators\"], {legacy: true}]);\n Babel.registerPlugin(\"c\", [Babel.availablePlugins[\"proposal-class-properties\"], {loose: true}]);\n Babel.registerPlugin(\"b\", [Babel.availablePlugins[\"proposal-private-methods\"], {loose: true}]);\n</script>\n<script type=\"text/babel\" data-plugins=\"d, c, b\">\n ${code}\n</script>\n</body>\n</html>`;\n\n\nclass Play extends Component {\n view = ({ code, hide_code }) => {\n return <>\n <style>{styles}</style>\n {hide_code ?\n <div class=\"apprun-play\">\n <iframe class=\"preview\" />\n </div>\n :\n <div class=\"apprun-play\">\n <div class=\"col\" style=\"width:75%\" >\n <textarea class=\"editor\">{code}</textarea>\n </div>\n <div class=\"col\" style=\"flex:1\" >\n <iframe class=\"preview\" />\n </div>\n </div>}\n </>;\n }\n\n mounted = props => {\n const element = this['element'];\n const code_id = props['code-id'];\n const hide_code = props['hide-code'];\n const code_width = props['code-width'];\n\n let code_area;\n if (code_id) {\n code_area = document.getElementById(code_id);\n } else {\n code_area = element.previousElementSibling ||\n element.parentElement.previousElementSibling;\n }\n\n const code = code_area?.innerText // from div\n || code_area?.value // from textarea\n || element.textContent // from child node\n\n if (code_area) code_area.style.display = 'none';\n\n return { code, hide_code, code_width };\n }\n\n\n rendered = ({ code, hide_code, code_width }) => {\n const element = this['element'];\n\n const textarea = element.querySelector(\".apprun-play .editor\") as any;\n let iframe = element.querySelector('.apprun-play .preview');\n if (!iframe || !textarea) return;\n\n const run_code = code => {\n const iframe_clone = iframe.cloneNode();\n iframe.parentNode?.replaceChild(iframe_clone, iframe);\n iframe = iframe_clone;\n const doc = iframe.contentWindow?.document;\n if (!doc) return;\n doc.open();\n if (code.indexOf('<html') >= 0)\n doc.write(code);\n else\n doc.write(code_html(code));\n doc.close();\n }\n\n if (code) run_code(code);\n if (hide_code || !textarea) return;\n\n if (code_width) textarea.parentElement.style.width = code_width;\n\n if (typeof CodeMirror === 'undefined') {\n textarea.onkeyup = () => run_code(textarea.value);\n } else {\n const editor = CodeMirror.fromTextArea(textarea, {\n lineNumbers: true,\n mode: 'jsx'\n });\n editor.setValue(code);\n editor.on('change', (cm) => run_code(cm.getValue()));\n }\n }\n}\n\napp.webComponent('apprun-code', Play);\n"],"names":["root","factory","exports","module","define","amd","this","App","constructor","_events","on","name","fn","options","push","off","subscribers","filter","sub","find","run","args","getSubscribers","console","assert","length","forEach","delay","Object","keys","apply","once","_t","clearTimeout","setTimeout","runAsync","promises","map","Promise","all","query","events","evt","endsWith","startsWith","replace","sort","a","b","event","app","self","g","global","customElement","componentClass","HTMLElement","super","component","_component","state","observedAttributes","attr","toLowerCase","connectedCallback","isConnected","opts","_shadowRoot","shadow","attachShadow","mode","attrMap","reduce","lc","_attrMap","props","Array","from","attributes","item","value","undefined","defineProperty","get","set","attributeChangedCallback","configurable","enumerable","requestAnimationFrame","children","mount","_props","dispatchEvent","bind","mounted","new_state","render","disconnectedCallback","unload","unmount","oldValue","mappedName","window","customElements","Reflect","meta","WeakMap","defineMetadata","metadataKey","metadataValue","target","has","getMetadataKeys","getPrototypeOf","getMetadata","componentCache","Map","o","components","REFRESH","Component","renderState","vdom","view","html","_","el","element","document","getElementById","querySelector","tracking_attr","getAttribute","tracking_id","Date","valueOf","toString","setAttribute","MutationObserver","observer","changes","body","contains","disconnect","observe","childList","subtree","attributeOldValue","attributeFilter","removeAttribute","directive","transition","rendered","setState","history","resolve","then","v","_state","enable_history","_history","_history_idx","callback","update","_app","_actions","_global_events","_history_prev","_history_next","start","global_event","prev","next","route","add_actions","is_global_event","indexOf","add_action","action","p","current_state","newState","actions","key","isArray","act","split","n","trim","__isAppRunComponent","ROUTER_EVENT","ROUTER_404_EVENT","url","rest","h","createElement","Fragment","webComponent","safeHTML","model","NOOP","addEventListener","onpopstate","location","hash","hasAttribute","use_render","use_react","React","ReactDOM","version","_root","createRoot","getStateValue","setStateValue","type","tag","substring","e","handler","checked","Number","multiple","selected","apply_directive","collect","ATTR_PROPS","ch","c","i","Error","keyCache","updateElement","nodes","parent","createComponent","isSvg","nodeName","updateChildren","node","key1","key2","toUpperCase","same","updateProps","parentNode","replaceChild","create","old_len","childNodes","new_len","len","Math","min","child","textContent","nodeType","nodeValue","createText","SVGElement","insertBefore","old","temp","nextSibling","appendChild","removeChild","lastChild","d","createDocumentFragment","div","insertAdjacentHTML","createTextNode","JSON","stringify","createElementNS","cached","oldProps","newProps","mergeProps","cname","match","dataset","style","cssText","s","xname","removeAttributeNS","setAttributeNS","test","idx","id","now","asTag","__componentCache","render_component","new_parent","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","__webpack_modules__","definition","globalThis","Function","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","Play","code","hide_code","class","code_id","code_width","code_area","previousElementSibling","parentElement","innerText","display","textarea","iframe","run_code","iframe_clone","cloneNode","doc","contentWindow","open","write","code_html","close","width","CodeMirror","onkeyup","editor","fromTextArea","lineNumbers","setValue","cm","getValue"],"sourceRoot":""}
@@ -1,19 +1,18 @@
1
- class t{constructor(){this._events={}}on(t,i,s={}){this._events[t]=this._events[t]||[],this._events[t].push({fn:i,options:s})}off(t,i){const s=this._events[t]||[];this._events[t]=s.filter((t=>t.fn!==i))}find(t){return this._events[t]}run(t,...i){const s=this.getSubscribers(t,this._events);return console.assert(s&&s.length>0,"No subscriber for event: "+t),s.forEach((s=>{const{fn:n,options:e}=s;return e.delay?this.delay(t,n,i,e):Object.keys(e).length>0?n.apply(this,[...i,e]):n.apply(this,i),!s.options.once})),s.length}once(t,i,s={}){this.on(t,i,Object.assign(Object.assign({},s),{once:!0}))}delay(t,i,s,n){n._t&&clearTimeout(n._t),n._t=setTimeout((()=>{clearTimeout(n._t),Object.keys(n).length>0?i.apply(this,[...s,n]):i.apply(this,s)}),n.delay)}runAsync(t,...i){const s=this.getSubscribers(t,this._events);console.assert(s&&s.length>0,"No subscriber for event: "+t);const n=s.map((t=>{const{fn:s,options:n}=t;return Object.keys(n).length>0?s.apply(this,[...i,n]):s.apply(this,i)}));return Promise.all(n)}query(t,...i){return this.query(t,...i)}getSubscribers(t,i){const s=i[t]||[];return i[t]=s.filter((t=>!t.options.once)),Object.keys(i).filter((i=>i.endsWith("*")&&t.startsWith(i.replace("*","")))).sort(((t,i)=>i.length-t.length)).forEach((n=>s.push(...i[n].map((i=>Object.assign(Object.assign({},i),{options:Object.assign(Object.assign({},i.options),{event:t})})))))),s}}let i;const s="object"==typeof self&&self.self===self&&self||"object"==typeof global&&global.global===global&&global;s.app&&s._AppRunVersions?i=s.app:(i=new t,s.app=i,s._AppRunVersions="AppRun-3");var n=i;const e=(t,i)=>(i?t.state[i]:t.state)||"",o=(t,i,s)=>{if(i){const n=t.state||{};n[i]=s,t.setState(n)}else t.setState(s)},r=(t,i)=>{if(Array.isArray(t))return t.map((t=>r(t,i)));{let{type:s,tag:h,props:c,children:l}=t;return h=h||s,l=l||(null==c?void 0:c.children),c&&Object.keys(c).forEach((t=>{t.startsWith("$")&&(((t,i,s,r)=>{if(t.startsWith("$on")){const s=i[t];if(t=t.substring(1),"boolean"==typeof s)i[t]=i=>r.run?r.run(t,i):n.run(t,i);else if("string"==typeof s)i[t]=t=>r.run?r.run(s,t):n.run(s,t);else if("function"==typeof s)i[t]=t=>r.setState(s(r.state,t));else if(Array.isArray(s)){const[e,...o]=s;"string"==typeof e?i[t]=t=>r.run?r.run(e,...o,t):n.run(e,...o,t):"function"==typeof e&&(i[t]=t=>r.setState(e(r.state,...o,t)))}}else if("$bind"===t){const n=i.type||"text",h="string"==typeof i[t]?i[t]:i.name;if("input"===s)switch(n){case"checkbox":i.checked=e(r,h),i.onclick=t=>o(r,h||t.target.name,t.target.checked);break;case"radio":i.checked=e(r,h)===i.value,i.onclick=t=>o(r,h||t.target.name,t.target.value);break;case"number":case"range":i.value=e(r,h),i.oninput=t=>o(r,h||t.target.name,Number(t.target.value));break;default:i.value=e(r,h),i.oninput=t=>o(r,h||t.target.name,t.target.value)}else"select"===s?(i.value=e(r,h),i.onchange=t=>{t.target.multiple||o(r,h||t.target.name,t.target.value)}):"option"===s?(i.selected=e(r,h),i.onclick=t=>o(r,h||t.target.name,t.target.selected)):"textarea"===s&&(i.innerHTML=e(r,h),i.oninput=t=>o(r,h||t.target.name,t.target.value))}else n.run("$",{key:t,tag:s,props:i,component:r})})(t,c,h,i),delete c[t])})),l&&r(l,i),t}};function h(t,...i){return l(i)}const c="_props";function l(t){const i=[],s=t=>{null!=t&&""!==t&&!1!==t&&i.push("function"==typeof t||"object"==typeof t?t:`${t}`)};return t&&t.forEach((t=>{Array.isArray(t)?t.forEach((t=>s(t))):s(t)})),i}function u(t,i,...s){const n=l(s);if("string"==typeof t)return{tag:t,props:i,children:n};if(Array.isArray(t))return t;if(void 0===t&&s)return n;if(Object.getPrototypeOf(t).t)return{tag:t,props:i,children:n};if("function"==typeof t)return t(i,n);throw new Error(`Unknown tag in vdom ${t}`)}const d=new WeakMap,f=(t,i,s={})=>{if(null==i||!1===i)return;!function(t,i,s={}){if(null==i||!1===i)return;if(i=m(i,s),!t)return;const n="SVG"===t.nodeName;Array.isArray(i)?v(t,i,n):v(t,[i],n)}("string"==typeof t&&t?document.getElementById(t)||document.querySelector(t):t,i=r(i,s),s)};function a(t,i,s){3!==i._op&&(s=s||"svg"===i.tag,!function(t,i){const s=t.nodeName,n=`${i.tag||""}`;return s.toUpperCase()===n.toUpperCase()}(t,i)?t.parentNode.replaceChild(b(i,s),t):(!(2&i._op)&&v(t,i.children,s),!(1&i._op)&&g(t,i.props,s)))}function v(t,i,s){var n,e;const o=(null===(n=t.childNodes)||void 0===n?void 0:n.length)||0,r=(null==i?void 0:i.length)||0,h=Math.min(o,r);for(let n=0;n<h;n++){const e=i[n];if(3===e._op)continue;const o=t.childNodes[n];if("string"==typeof e)o.textContent!==e&&(3===o.nodeType?o.nodeValue=e:t.replaceChild(y(e),o));else if(e instanceof HTMLElement||e instanceof SVGElement)t.insertBefore(e,o);else{const i=e.props&&e.props.key;if(i)if(o.key===i)a(t.childNodes[n],e,s);else{const r=d[i];if(r){const i=r.nextSibling;t.insertBefore(r,o),i?t.insertBefore(o,i):t.appendChild(o),a(t.childNodes[n],e,s)}else t.replaceChild(b(e,s),o)}else a(t.childNodes[n],e,s)}}let c=(null===(e=t.childNodes)||void 0===e?void 0:e.length)||0;for(;c>h;)t.removeChild(t.lastChild),c--;if(r>h){const n=document.createDocumentFragment();for(let t=h;t<i.length;t++)n.appendChild(b(i[t],s));t.appendChild(n)}}const p=t=>{const i=document.createElement("section");return i.insertAdjacentHTML("afterbegin",t),Array.from(i.children)};function y(t){if(0===(null==t?void 0:t.indexOf("_html:"))){const i=document.createElement("div");return i.insertAdjacentHTML("afterbegin",t.substring(6)),i}return document.createTextNode(null!=t?t:"")}function b(t,i){if(t instanceof HTMLElement||t instanceof SVGElement)return t;if("string"==typeof t)return y(t);if(!t.tag||"function"==typeof t.tag)return y(JSON.stringify(t));const s=(i=i||"svg"===t.tag)?document.createElementNS("http://www.w3.org/2000/svg",t.tag):document.createElement(t.tag);return g(s,t.props,i),t.children&&t.children.forEach((t=>s.appendChild(b(t,i)))),s}function g(t,i,s){const n=t[c]||{};i=function(t,i){i.class=i.class||i.className,delete i.className;const s={};return t&&Object.keys(t).forEach((t=>s[t]=null)),i&&Object.keys(i).forEach((t=>s[t]=i[t])),s}(n,i||{}),t[c]=i;for(const n in i){const e=i[n];if(n.startsWith("data-")){const i=n.substring(5).replace(/-(\w)/g,(t=>t[1].toUpperCase()));t.dataset[i]!==e&&(e||""===e?t.dataset[i]=e:delete t.dataset[i])}else if("style"===n)if(t.style.cssText&&(t.style.cssText=""),"string"==typeof e)t.style.cssText=e;else for(const i in e)t.style[i]!==e[i]&&(t.style[i]=e[i]);else if(n.startsWith("xlink")){const i=n.replace("xlink","").toLowerCase();null==e||!1===e?t.removeAttributeNS("http://www.w3.org/1999/xlink",i):t.setAttributeNS("http://www.w3.org/1999/xlink",i,e)}else n.startsWith("on")?e&&"function"!=typeof e?"string"==typeof e&&(e?t.setAttribute(n,e):t.removeAttribute(n)):t[n]=e:/^id$|^class$|^list$|^readonly$|^contenteditable$|^role|-|^for$/g.test(n)||s?t.getAttribute(n)!==e&&(e?t.setAttribute(n,e):t.removeAttribute(n)):t[n]!==e&&(t[n]=e);"key"===n&&e&&(d[e]=t)}i&&"function"==typeof i.ref&&window.requestAnimationFrame((()=>i.ref(t)))}function m(t,i,s=0){var n;if("string"==typeof t)return t;if(Array.isArray(t))return t.map((t=>m(t,i,s++)));let e=t;if(t&&"function"==typeof t.tag&&Object.getPrototypeOf(t.tag).t&&(e=function(t,i,s){const{tag:n,props:e,children:o}=t;let r=`_${s}`,h=e&&e.id;h?r=h:h=`_${s}${Date.now()}`;let c="section";e&&e.as&&(c=e.as,delete e.as),i.i||(i.i={});let l=i.i[r];if(l&&l instanceof n&&l.element)l.renderState(l.state);else{const t=document.createElement(c);l=i.i[r]=new n(Object.assign(Object.assign({},e),{children:o})).mount(t,{render:!0})}if(l.mounted){const t=l.mounted(e,o,l.state);void 0!==t&&l.setState(t)}return g(l.element,e,!1),l.element}(t,i,s)),e&&Array.isArray(e.children)){const t=null===(n=e.props)||void 0===n?void 0:n._component;if(t){let i=0;e.children=e.children.map((s=>m(s,t,i++)))}else e.children=e.children.map((t=>m(t,i,s++)))}return e}const w=(t,i={})=>class extends HTMLElement{constructor(){super()}get component(){return this._component}get state(){return this._component.state}static get observedAttributes(){return(i.observedAttributes||[]).map((t=>t.toLowerCase()))}connectedCallback(){if(this.isConnected&&!this._component){const s=i||{};this._shadowRoot=s.shadow?this.attachShadow({mode:"open"}):this;const n=s.observedAttributes||[],e=n.reduce(((t,i)=>{const s=i.toLowerCase();return s!==i&&(t[s]=i),t}),{});this._attrMap=t=>e[t]||t;const o={};Array.from(this.attributes).forEach((t=>o[this._attrMap(t.name)]=t.value)),n.forEach((t=>{void 0!==this[t]&&(o[t]=this[t]),Object.defineProperty(this,t,{get:()=>o[t],set(i){this.attributeChangedCallback(t,o[t],i)},configurable:!0,enumerable:!0})})),requestAnimationFrame((()=>{const i=this.children?Array.from(this.children):[];if(i.forEach((t=>t.parentElement.removeChild(t))),this._component=new t(Object.assign(Object.assign({},o),{children:i})).mount(this._shadowRoot,s),this._component._props=o,this._component.dispatchEvent=this.dispatchEvent.bind(this),this._component.mounted){const t=this._component.mounted(o,i,this._component.state);void 0!==t&&(this._component.state=t)}this.on=this._component.on.bind(this._component),this.run=this._component.run.bind(this._component),!1!==s.render&&this._component.run(".")}))}}disconnectedCallback(){var t,i,s,n;null===(i=null===(t=this._component)||void 0===t?void 0:t.unload)||void 0===i||i.call(t),null===(n=null===(s=this._component)||void 0===s?void 0:s.unmount)||void 0===n||n.call(s),this._component=null}attributeChangedCallback(t,s,n){if(this._component){const e=this._attrMap(t);this._component._props[e]=n,this._component.run("attributeChanged",e,s,n),n!==s&&!1!==i.render&&window.requestAnimationFrame((()=>{this._component.run(".")}))}}};var $=(t,i,s)=>{"undefined"!=typeof customElements&&customElements.define(t,w(i,s))};const j={meta:new WeakMap,defineMetadata(t,i,s){this.meta.has(s)||this.meta.set(s,{}),this.meta.get(s)[t]=i},getMetadataKeys(t){return t=Object.getPrototypeOf(t),this.meta.get(t)?Object.keys(this.meta.get(t)):[]},getMetadata(t,i){return i=Object.getPrototypeOf(i),this.meta.get(i)?this.meta.get(i)[t]:null}};function A(t,i={}){return(s,n,e)=>{const o=t?t.toString():n;return j.defineMetadata(`apprun-update:${o}`,{name:o,key:n,options:i},s),e}}function O(t,i={}){return function(s,n){const e=t?t.toString():n;j.defineMetadata(`apprun-update:${e}`,{name:e,key:n,options:i},s)}}function _(t,i){return function(s){return $(t,s,i),s}}const x=new Map;n.find("get-components")||n.on("get-components",(t=>t.components=x));const k=t=>t;class T{renderState(t,i=null){if(!this.view)return;let s=i||this.view(t);if(n.debug&&n.run("debug",{component:this,_:s?".":"-",state:t,vdom:s,el:this.element}),"object"!=typeof document)return;const e="string"==typeof this.element&&this.element?document.getElementById(this.element)||document.querySelector(this.element):this.element;if(!e)return;const o="_c";this.unload?e._component===this&&e.getAttribute(o)===this.tracking_id||(this.tracking_id=(new Date).valueOf().toString(),e.setAttribute(o,this.tracking_id),"undefined"!=typeof MutationObserver&&(this.observer||(this.observer=new MutationObserver((t=>{t[0].oldValue!==this.tracking_id&&document.body.contains(e)||(this.unload(this.state),this.observer.disconnect(),this.observer=null)}))),this.observer.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeOldValue:!0,attributeFilter:[o]}))):e.removeAttribute&&e.removeAttribute(o),e._component=this,!i&&s&&(s=r(s,this),this.options.transition&&document&&document.startViewTransition?document.startViewTransition((()=>n.render(e,s,this))):n.render(e,s,this)),this.rendered&&this.rendered(this.state)}setState(t,i={render:!0,history:!1}){if(t instanceof Promise)Promise.resolve(t).then((s=>{this.setState(s,i),this._state=t}));else{if(this._state=t,null==t)return;this.state=t,!1!==i.render&&(i.transition&&document&&document.startViewTransition?document.startViewTransition((()=>this.renderState(t))):this.renderState(t)),!1!==i.history&&this.enable_history&&(this._history=[...this._history,t],this._history_idx=this._history.length-1),"function"==typeof i.callback&&i.callback(this.state)}}constructor(i,s,n,e){this.state=i,this.view=s,this.update=n,this.options=e,this._app=new t,this._actions=[],this._global_events=[],this._history=[],this._history_idx=-1,this._history_prev=()=>{this._history_idx--,this._history_idx>=0?this.setState(this._history[this._history_idx],{render:!0,history:!1}):this._history_idx=0},this._history_next=()=>{this._history_idx++,this._history_idx<this._history.length?this.setState(this._history[this._history_idx],{render:!0,history:!1}):this._history_idx=this._history.length-1},this.start=(t=null,i)=>{if(this.mount(t,Object.assign({render:!0},i)),this.mounted&&"function"==typeof this.mounted){const t=this.mounted({},[],this.state);void 0!==t&&this.setState(t)}return this}}mount(t=null,i){var s,e;return console.assert(!this.element,"Component already mounted."),this.options=i=Object.assign(Object.assign({},this.options),i),this.element=t,this.global_event=i.global_event,this.enable_history=!!i.history,this.enable_history&&(this.on(i.history.prev||"history-prev",this._history_prev),this.on(i.history.next||"history-next",this._history_next)),i.route&&(this.update=this.update||{},this.update[i.route]||(this.update[i.route]=k)),this.add_actions(),this.state=null!==(e=null!==(s=this.state)&&void 0!==s?s:this.model)&&void 0!==e?e:{},"function"==typeof this.state&&(this.state=this.state()),this.setState(this.state,{render:!!i.render,history:!0}),n.debug&&(x.get(t)?x.get(t).push(this):x.set(t,[this])),this}is_global_event(t){return t&&(this.global_event||this._global_events.indexOf(t)>=0||t.startsWith("#")||t.startsWith("/")||t.startsWith("@"))}add_action(t,i,s={}){i&&"function"==typeof i&&(s.global&&this._global_events.push(t),this.on(t,((...e)=>{n.debug&&n.run("debug",{component:this,_:">",event:t,p:e,current_state:this.state,options:s});const o=i(this.state,...e);n.debug&&n.run("debug",{component:this,_:"<",event:t,p:e,newState:o,state:this.state,options:s}),this.setState(o,s)}),s))}add_actions(){const t=this.update||{};j.getMetadataKeys(this).forEach((i=>{if(i.startsWith("apprun-update:")){const s=j.getMetadata(i,this);t[s.name]=[this[s.key].bind(this),s.options]}}));const i={};Array.isArray(t)?t.forEach((t=>{const[s,n,e]=t;s.toString().split(",").forEach((t=>i[t.trim()]=[n,e]))})):Object.keys(t).forEach((s=>{const n=t[s];("function"==typeof n||Array.isArray(n))&&s.split(",").forEach((t=>i[t.trim()]=n))})),i["."]||(i["."]=k),Object.keys(i).forEach((t=>{const s=i[t];"function"==typeof s?this.add_action(t,s):Array.isArray(s)&&this.add_action(t,s[0],s[1])}))}run(t,...i){if(this.state instanceof Promise)return Promise.resolve(this.state).then((s=>{this.state=s,this.run(t,...i)}));{const s=t.toString();return this.is_global_event(s)?n.run(s,...i):this._app.run(s,...i)}}on(t,i,s){const e=t.toString();return this._actions.push({name:e,fn:i}),this.is_global_event(e)?n.on(e,i,s):this._app.on(e,i,s)}runAsync(t,...i){const s=t.toString();return this.is_global_event(s)?n.runAsync(s,...i):this._app.runAsync(s,...i)}query(t,...i){return this.runAsync(t,...i)}unmount(){var t;null===(t=this.observer)||void 0===t||t.disconnect(),this._actions.forEach((t=>{const{name:i,fn:s}=t;this.is_global_event(i)?n.off(i,s):this._app.off(i,s)}))}}T.t=!0;const M="//",E="///",C=t=>{if(t||(t="#"),t.startsWith("#")){const[i,...s]=t.split("/");n.run(i,...s)||n.run(E,i,...s),n.run(M,i,...s)}else if(t.startsWith("/")){const[i,s,...e]=t.split("/");n.run("/"+s,...e)||n.run(E,"/"+s,...e),n.run(M,"/"+s,...e)}else n.run(t)||n.run(E,t),n.run(M,t)};n.h=n.createElement=u,n.render=f,n.Fragment=h,n.webComponent=$,n.safeHTML=p,n.start=(t,i,s,n,e)=>{const o=Object.assign({render:!0,global_event:!0},e),r=new T(i,s,n);return e&&e.rendered&&(r.rendered=e.rendered),e&&e.mounted&&(r.mounted=e.mounted),r.start(t,o),r};const S=t=>{};
1
+ class t{constructor(){this._events={}}on(t,i,s={}){this._events[t]=this._events[t]||[],this._events[t].push({fn:i,options:s})}off(t,i){const s=this._events[t]||[];this._events[t]=s.filter((t=>t.fn!==i))}find(t){return this._events[t]}run(t,...i){const s=this.getSubscribers(t,this._events);return console.assert(s&&s.length>0,"No subscriber for event: "+t),s.forEach((s=>{const{fn:n,options:e}=s;return e.delay?this.delay(t,n,i,e):Object.keys(e).length>0?n.apply(this,[...i,e]):n.apply(this,i),!s.options.once})),s.length}once(t,i,s={}){this.on(t,i,Object.assign(Object.assign({},s),{once:!0}))}delay(t,i,s,n){n._t&&clearTimeout(n._t),n._t=setTimeout((()=>{clearTimeout(n._t),Object.keys(n).length>0?i.apply(this,[...s,n]):i.apply(this,s)}),n.delay)}runAsync(t,...i){const s=this.getSubscribers(t,this._events);console.assert(s&&s.length>0,"No subscriber for event: "+t);const n=s.map((t=>{const{fn:s,options:n}=t;return Object.keys(n).length>0?s.apply(this,[...i,n]):s.apply(this,i)}));return Promise.all(n)}query(t,...i){return this.query(t,...i)}getSubscribers(t,i){const s=i[t]||[];return i[t]=s.filter((t=>!t.options.once)),Object.keys(i).filter((i=>i.endsWith("*")&&t.startsWith(i.replace("*","")))).sort(((t,i)=>i.length-t.length)).forEach((n=>s.push(...i[n].map((i=>Object.assign(Object.assign({},i),{options:Object.assign(Object.assign({},i.options),{event:t})})))))),s}}let i;const s="object"==typeof self&&self.self===self&&self||"object"==typeof global&&global.global===global&&global;s.app&&s._AppRunVersions?i=s.app:(i=new t,s.app=i,s._AppRunVersions="AppRun-3");var n=i;const e=(t,i)=>(i?t.state[i]:t.state)||"",o=(t,i,s)=>{if(i){const n=t.state||{};n[i]=s,t.setState(n)}else t.setState(s)},r=(t,i)=>{if(Array.isArray(t))return t.map((t=>r(t,i)));{let{type:s,tag:h,props:c,children:l}=t;return h=h||s,l=l||(null==c?void 0:c.children),c&&Object.keys(c).forEach((t=>{t.startsWith("$")&&(((t,i,s,r)=>{if(t.startsWith("$on")){const s=i[t];if(t=t.substring(1),"boolean"==typeof s)i[t]=i=>r.run?r.run(t,i):n.run(t,i);else if("string"==typeof s)i[t]=t=>r.run?r.run(s,t):n.run(s,t);else if("function"==typeof s)i[t]=t=>r.setState(s(r.state,t));else if(Array.isArray(s)){const[e,...o]=s;"string"==typeof e?i[t]=t=>r.run?r.run(e,...o,t):n.run(e,...o,t):"function"==typeof e&&(i[t]=t=>r.setState(e(r.state,...o,t)))}}else if("$bind"===t){const n=i.type||"text",h="string"==typeof i[t]?i[t]:i.name;if("input"===s)switch(n){case"checkbox":i.checked=e(r,h),i.onclick=t=>o(r,h||t.target.name,t.target.checked);break;case"radio":i.checked=e(r,h)===i.value,i.onclick=t=>o(r,h||t.target.name,t.target.value);break;case"number":case"range":i.value=e(r,h),i.oninput=t=>o(r,h||t.target.name,Number(t.target.value));break;default:i.value=e(r,h),i.oninput=t=>o(r,h||t.target.name,t.target.value)}else"select"===s?(i.value=e(r,h),i.onchange=t=>{t.target.multiple||o(r,h||t.target.name,t.target.value)}):"option"===s?(i.selected=e(r,h),i.onclick=t=>o(r,h||t.target.name,t.target.selected)):"textarea"===s&&(i.innerHTML=e(r,h),i.oninput=t=>o(r,h||t.target.name,t.target.value))}else n.run("$",{key:t,tag:s,props:i,component:r})})(t,c,h,i),delete c[t])})),l&&r(l,i),t}};function h(t,...i){return l(i)}const c="_props";function l(t){const i=[],s=t=>{null!=t&&""!==t&&!1!==t&&i.push("function"==typeof t||"object"==typeof t?t:`${t}`)};return t&&t.forEach((t=>{Array.isArray(t)?t.forEach((t=>s(t))):s(t)})),i}function u(t,i,...s){const n=l(s);if("string"==typeof t)return{tag:t,props:i,children:n};if(Array.isArray(t))return t;if(void 0===t&&s)return n;if(Object.getPrototypeOf(t).t)return{tag:t,props:i,children:n};if("function"==typeof t)return t(i,n);throw new Error(`Unknown tag in vdom ${t}`)}const d=new WeakMap,f=(t,i,s={})=>{if(null==i||!1===i)return;!function(t,i,s={}){if(null==i||!1===i)return;if(i=w(i,s),!t)return;const n="SVG"===t.nodeName;Array.isArray(i)?v(t,i,n):v(t,[i],n)}("string"==typeof t&&t?document.getElementById(t)||document.querySelector(t):t,i=r(i,s),s)};function a(t,i,s){3!==i._op&&(s=s||"svg"===i.tag,!function(t,i){const s=t.nodeName,n=`${i.tag||""}`;return s.toUpperCase()===n.toUpperCase()}(t,i)?t.parentNode.replaceChild(g(i,s),t):(!(2&i._op)&&v(t,i.children,s),!(1&i._op)&&b(t,i.props,s)))}function v(t,i,s){var n,e;const o=(null===(n=t.childNodes)||void 0===n?void 0:n.length)||0,r=(null==i?void 0:i.length)||0,h=Math.min(o,r);for(let n=0;n<h;n++){const e=i[n];if(3===e._op)continue;const o=t.childNodes[n];if("string"==typeof e)o.textContent!==e&&(3===o.nodeType?o.nodeValue=e:t.replaceChild(y(e),o));else if(e instanceof HTMLElement||e instanceof SVGElement)t.insertBefore(e,o);else{const i=e.props&&e.props.key;if(i)if(o.key===i)a(t.childNodes[n],e,s);else{const r=d[i];if(r){const i=r.nextSibling;t.insertBefore(r,o),i?t.insertBefore(o,i):t.appendChild(o),a(t.childNodes[n],e,s)}else t.replaceChild(g(e,s),o)}else a(t.childNodes[n],e,s)}}let c=(null===(e=t.childNodes)||void 0===e?void 0:e.length)||0;for(;c>h;)t.removeChild(t.lastChild),c--;if(r>h){const n=document.createDocumentFragment();for(let t=h;t<i.length;t++)n.appendChild(g(i[t],s));t.appendChild(n)}}const p=t=>{const i=document.createElement("section");return i.insertAdjacentHTML("afterbegin",t),Array.from(i.children)};function y(t){if(0===(null==t?void 0:t.indexOf("_html:"))){const i=document.createElement("div");return i.insertAdjacentHTML("afterbegin",t.substring(6)),i}return document.createTextNode(null!=t?t:"")}function g(t,i){if(t instanceof HTMLElement||t instanceof SVGElement)return t;if("string"==typeof t)return y(t);if(!t.tag||"function"==typeof t.tag)return y(JSON.stringify(t));const s=(i=i||"svg"===t.tag)?document.createElementNS("http://www.w3.org/2000/svg",t.tag):document.createElement(t.tag);return b(s,t.props,i),t.children&&t.children.forEach((t=>s.appendChild(g(t,i)))),s}function b(t,i,s){const n=t[c]||{};i=function(t,i){i.class=i.class||i.className,delete i.className;const s={};return t&&Object.keys(t).forEach((t=>s[t]=null)),i&&Object.keys(i).forEach((t=>s[t]=i[t])),s}(n,i||{}),t[c]=i;for(const n in i){const e=i[n];if(n.startsWith("data-")){const i=n.substring(5).replace(/-(\w)/g,(t=>t[1].toUpperCase()));t.dataset[i]!==e&&(e||""===e?t.dataset[i]=e:delete t.dataset[i])}else if("style"===n)if(t.style.cssText&&(t.style.cssText=""),"string"==typeof e)t.style.cssText=e;else for(const i in e)t.style[i]!==e[i]&&(t.style[i]=e[i]);else if(n.startsWith("xlink")){const i=n.replace("xlink","").toLowerCase();null==e||!1===e?t.removeAttributeNS("http://www.w3.org/1999/xlink",i):t.setAttributeNS("http://www.w3.org/1999/xlink",i,e)}else n.startsWith("on")?e&&"function"!=typeof e?"string"==typeof e&&(e?t.setAttribute(n,e):t.removeAttribute(n)):t[n]=e:/^id$|^class$|^list$|^readonly$|^contenteditable$|^role|-|^for$/g.test(n)||s?t.getAttribute(n)!==e&&(e?t.setAttribute(n,e):t.removeAttribute(n)):t[n]!==e&&(t[n]=e);"key"===n&&e&&(d[e]=t)}i&&"function"==typeof i.ref&&window.requestAnimationFrame((()=>i.ref(t)))}function w(t,i,s=0){var n;if("string"==typeof t)return t;if(Array.isArray(t))return t.map((t=>w(t,i,s++)));let e=t;if(t&&"function"==typeof t.tag&&Object.getPrototypeOf(t.tag).t&&(e=function(t,i,s){const{tag:n,props:e,children:o}=t;let r=`_${s}`,h=e&&e.id;h?r=h:h=`_${s}${Date.now()}`;let c="section";e&&e.as&&(c=e.as,delete e.as),i.i||(i.i={});let l=i.i[r];if(l&&l instanceof n&&l.element)l.renderState(l.state);else{const t=document.createElement(c);l=i.i[r]=new n(Object.assign(Object.assign({},e),{children:o})).mount(t,{render:!0})}if(l.mounted){const t=l.mounted(e,o,l.state);void 0!==t&&l.setState(t)}return b(l.element,e,!1),l.element}(t,i,s)),e&&Array.isArray(e.children)){const t=null===(n=e.props)||void 0===n?void 0:n._component;if(t){let i=0;e.children=e.children.map((s=>w(s,t,i++)))}else e.children=e.children.map((t=>w(t,i,s++)))}return e}const m=(t,i={})=>class extends HTMLElement{constructor(){super()}get component(){return this._component}get state(){return this._component.state}static get observedAttributes(){return(i.observedAttributes||[]).map((t=>t.toLowerCase()))}connectedCallback(){if(this.isConnected&&!this._component){const s=i||{};this._shadowRoot=s.shadow?this.attachShadow({mode:"open"}):this;const n=s.observedAttributes||[],e=n.reduce(((t,i)=>{const s=i.toLowerCase();return s!==i&&(t[s]=i),t}),{});this._attrMap=t=>e[t]||t;const o={};Array.from(this.attributes).forEach((t=>o[this._attrMap(t.name)]=t.value)),n.forEach((t=>{void 0!==this[t]&&(o[t]=this[t]),Object.defineProperty(this,t,{get:()=>o[t],set(i){this.attributeChangedCallback(t,o[t],i)},configurable:!0,enumerable:!0})})),requestAnimationFrame((()=>{const i=this.children?Array.from(this.children):[];if(this._component=new t(Object.assign(Object.assign({},o),{children:i})).mount(this._shadowRoot,s),this._component._props=o,this._component.dispatchEvent=this.dispatchEvent.bind(this),this._component.mounted){const t=this._component.mounted(o,i,this._component.state);void 0!==t&&(this._component.state=t)}this.on=this._component.on.bind(this._component),this.run=this._component.run.bind(this._component),!1!==s.render&&this._component.run(".")}))}}disconnectedCallback(){var t,i,s,n;null===(i=null===(t=this._component)||void 0===t?void 0:t.unload)||void 0===i||i.call(t),null===(n=null===(s=this._component)||void 0===s?void 0:s.unmount)||void 0===n||n.call(s),this._component=null}attributeChangedCallback(t,s,n){if(this._component){const e=this._attrMap(t);this._component._props[e]=n,this._component.run("attributeChanged",e,s,n),n!==s&&!1!==i.render&&window.requestAnimationFrame((()=>{this._component.run(".")}))}}};var $=(t,i,s)=>{"undefined"!=typeof customElements&&customElements.define(t,m(i,s))};const j={meta:new WeakMap,defineMetadata(t,i,s){this.meta.has(s)||this.meta.set(s,{}),this.meta.get(s)[t]=i},getMetadataKeys(t){return t=Object.getPrototypeOf(t),this.meta.get(t)?Object.keys(this.meta.get(t)):[]},getMetadata(t,i){return i=Object.getPrototypeOf(i),this.meta.get(i)?this.meta.get(i)[t]:null}};function A(t,i={}){return(s,n,e)=>{const o=t?t.toString():n;return j.defineMetadata(`apprun-update:${o}`,{name:o,key:n,options:i},s),e}}function O(t,i={}){return function(s,n){const e=t?t.toString():n;j.defineMetadata(`apprun-update:${e}`,{name:e,key:n,options:i},s)}}function _(t,i){return function(s){return $(t,s,i),s}}const x=new Map;n.find("get-components")||n.on("get-components",(t=>t.components=x));const k=t=>t;class M{renderState(t,i=null){if(!this.view)return;let s=i||this.view(t);if(n.debug&&n.run("debug",{component:this,_:s?".":"-",state:t,vdom:s,el:this.element}),"object"!=typeof document)return;const e="string"==typeof this.element&&this.element?document.getElementById(this.element)||document.querySelector(this.element):this.element;if(!e)return;const o="_c";this.unload?e._component===this&&e.getAttribute(o)===this.tracking_id||(this.tracking_id=(new Date).valueOf().toString(),e.setAttribute(o,this.tracking_id),"undefined"!=typeof MutationObserver&&(this.observer||(this.observer=new MutationObserver((t=>{t[0].oldValue!==this.tracking_id&&document.body.contains(e)||(this.unload(this.state),this.observer.disconnect(),this.observer=null)}))),this.observer.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeOldValue:!0,attributeFilter:[o]}))):e.removeAttribute&&e.removeAttribute(o),e._component=this,!i&&s&&(s=r(s,this),this.options.transition&&document&&document.startViewTransition?document.startViewTransition((()=>n.render(e,s,this))):n.render(e,s,this)),this.rendered&&this.rendered(this.state)}setState(t,i={render:!0,history:!1}){if(t instanceof Promise)Promise.resolve(t).then((s=>{this.setState(s,i),this._state=t}));else{if(this._state=t,null==t)return;this.state=t,!1!==i.render&&(i.transition&&document&&document.startViewTransition?document.startViewTransition((()=>this.renderState(t))):this.renderState(t)),!1!==i.history&&this.enable_history&&(this._history=[...this._history,t],this._history_idx=this._history.length-1),"function"==typeof i.callback&&i.callback(this.state)}}constructor(i,s,n,e){this.state=i,this.view=s,this.update=n,this.options=e,this._app=new t,this._actions=[],this._global_events=[],this._history=[],this._history_idx=-1,this._history_prev=()=>{this._history_idx--,this._history_idx>=0?this.setState(this._history[this._history_idx],{render:!0,history:!1}):this._history_idx=0},this._history_next=()=>{this._history_idx++,this._history_idx<this._history.length?this.setState(this._history[this._history_idx],{render:!0,history:!1}):this._history_idx=this._history.length-1},this.start=(t=null,i)=>{if(this.mount(t,Object.assign({render:!0},i)),this.mounted&&"function"==typeof this.mounted){const t=this.mounted({},[],this.state);void 0!==t&&this.setState(t)}return this}}mount(t=null,i){var s,e;return console.assert(!this.element,"Component already mounted."),this.options=i=Object.assign(Object.assign({},this.options),i),this.element=t,this.global_event=i.global_event,this.enable_history=!!i.history,this.enable_history&&(this.on(i.history.prev||"history-prev",this._history_prev),this.on(i.history.next||"history-next",this._history_next)),i.route&&(this.update=this.update||{},this.update[i.route]||(this.update[i.route]=k)),this.add_actions(),this.state=null!==(e=null!==(s=this.state)&&void 0!==s?s:this.model)&&void 0!==e?e:{},"function"==typeof this.state&&(this.state=this.state()),this.setState(this.state,{render:!!i.render,history:!0}),n.debug&&(x.get(t)?x.get(t).push(this):x.set(t,[this])),this}is_global_event(t){return t&&(this.global_event||this._global_events.indexOf(t)>=0||t.startsWith("#")||t.startsWith("/")||t.startsWith("@"))}add_action(t,i,s={}){i&&"function"==typeof i&&(s.global&&this._global_events.push(t),this.on(t,((...e)=>{n.debug&&n.run("debug",{component:this,_:">",event:t,p:e,current_state:this.state,options:s});const o=i(this.state,...e);n.debug&&n.run("debug",{component:this,_:"<",event:t,p:e,newState:o,state:this.state,options:s}),this.setState(o,s)}),s))}add_actions(){const t=this.update||{};j.getMetadataKeys(this).forEach((i=>{if(i.startsWith("apprun-update:")){const s=j.getMetadata(i,this);t[s.name]=[this[s.key].bind(this),s.options]}}));const i={};Array.isArray(t)?t.forEach((t=>{const[s,n,e]=t;s.toString().split(",").forEach((t=>i[t.trim()]=[n,e]))})):Object.keys(t).forEach((s=>{const n=t[s];("function"==typeof n||Array.isArray(n))&&s.split(",").forEach((t=>i[t.trim()]=n))})),i["."]||(i["."]=k),Object.keys(i).forEach((t=>{const s=i[t];"function"==typeof s?this.add_action(t,s):Array.isArray(s)&&this.add_action(t,s[0],s[1])}))}run(t,...i){if(this.state instanceof Promise)return Promise.resolve(this.state).then((s=>{this.state=s,this.run(t,...i)}));{const s=t.toString();return this.is_global_event(s)?n.run(s,...i):this._app.run(s,...i)}}on(t,i,s){const e=t.toString();return this._actions.push({name:e,fn:i}),this.is_global_event(e)?n.on(e,i,s):this._app.on(e,i,s)}runAsync(t,...i){const s=t.toString();return this.is_global_event(s)?n.runAsync(s,...i):this._app.runAsync(s,...i)}query(t,...i){return this.runAsync(t,...i)}unmount(){var t;null===(t=this.observer)||void 0===t||t.disconnect(),this._actions.forEach((t=>{const{name:i,fn:s}=t;this.is_global_event(i)?n.off(i,s):this._app.off(i,s)}))}}M.t=!0;const E="//",T="///",S=t=>{if(t||(t="#"),t.startsWith("#")){const[i,...s]=t.split("/");n.run(i,...s)||n.run(T,i,...s),n.run(E,i,...s)}else if(t.startsWith("/")){const[i,s,...e]=t.split("/");n.run("/"+s,...e)||n.run(T,"/"+s,...e),n.run(E,"/"+s,...e)}else n.run(t)||n.run(T,t),n.run(E,t)};n.h=n.createElement=u,n.render=f,n.Fragment=h,n.webComponent=$,n.safeHTML=p,n.start=(t,i,s,n,e)=>{const o=Object.assign({render:!0,global_event:!0},e),r=new M(i,s,n);return e&&e.rendered&&(r.rendered=e.rendered),e&&e.mounted&&(r.mounted=e.mounted),r.start(t,o),r};const C=t=>{};
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2017 Google LLC
5
5
  * SPDX-License-Identifier: BSD-3-Clause
6
6
  */
7
- var N;n.on("$",S),n.on("debug",(t=>S)),n.on(M,S),n.on("#",S),n.route=C,n.on("route",(t=>n.route&&n.route(t))),"object"==typeof document&&document.addEventListener("DOMContentLoaded",(()=>{n.route===C&&(window.onpopstate=()=>C(location.hash),document.body.hasAttribute("apprun-no-init")||n["no-init-route"]||C(location.hash))})),"object"==typeof window&&(window.Component=T,window._React=window.React,window.React=n,window.on=O,window.customElement=_,window.safeHTML=p),n.use_render=(t,i=0)=>n.render=0===i?(i,s)=>t(s,i):(i,s)=>t(i,s),n.use_react=t=>{n.render=(i,s)=>{i&&s&&(i._root||(i._root=t(i)),i._root.render(s))}};const L=globalThis.trustedTypes,U=L?L.createPolicy("lit-html",{createHTML:t=>t}):void 0,H=`lit$${(Math.random()+"").slice(9)}$`,P="?"+H,D=`<${P}>`,I=document,V=(t="")=>I.createComment(t),q=t=>null===t||"object"!=typeof t&&"function"!=typeof t,G=Array.isArray,R=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,W=/-->/g,z=/>/g,F=/>|[ \n \r](?:([^\s"'>=/]+)([ \n \r]*=[ \n \r]*(?:[^ \n \r"'`<>=]|("|')|))|$)/g,Z=/'/g,J=/"/g,K=/^(?:script|style|textarea|title)$/i,B=t=>(i,...s)=>({_$litType$:t,strings:i,values:s}),Q=B(1),X=B(2),Y=Symbol.for("lit-noChange"),tt=Symbol.for("lit-nothing"),it=new WeakMap,st=(t,i,s)=>{var n,e;const o=null!==(n=null==s?void 0:s.renderBefore)&&void 0!==n?n:i;let r=o._$litPart$;if(void 0===r){const t=null!==(e=null==s?void 0:s.renderBefore)&&void 0!==e?e:null;o._$litPart$=r=new ct(i.insertBefore(V(),t),t,void 0,null!=s?s:{})}return r._$AI(t),r},nt=I.createTreeWalker(I,129,null,!1),et=(t,i)=>{const s=t.length-1,n=[];let e,o=2===i?"<svg>":"",r=R;for(let i=0;i<s;i++){const s=t[i];let h,c,l=-1,u=0;for(;u<s.length&&(r.lastIndex=u,c=r.exec(s),null!==c);)u=r.lastIndex,r===R?"!--"===c[1]?r=W:void 0!==c[1]?r=z:void 0!==c[2]?(K.test(c[2])&&(e=RegExp("</"+c[2],"g")),r=F):void 0!==c[3]&&(r=F):r===F?">"===c[0]?(r=null!=e?e:R,l=-1):void 0===c[1]?l=-2:(l=r.lastIndex-c[2].length,h=c[1],r=void 0===c[3]?F:'"'===c[3]?J:Z):r===J||r===Z?r=F:r===W||r===z?r=R:(r=F,e=void 0);const d=r===F&&t[i+1].startsWith("/>")?" ":"";o+=r===R?s+D:l>=0?(n.push(h),s.slice(0,l)+"$lit$"+s.slice(l)+H+d):s+H+(-2===l?(n.push(void 0),i):d)}const h=o+(t[s]||"<?>")+(2===i?"</svg>":"");if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==U?U.createHTML(h):h,n]};class ot{constructor({strings:t,_$litType$:i},s){let n;this.parts=[];let e=0,o=0;const r=t.length-1,h=this.parts,[c,l]=et(t,i);if(this.el=ot.createElement(c,s),nt.currentNode=this.el.content,2===i){const t=this.el.content,i=t.firstChild;i.remove(),t.append(...i.childNodes)}for(;null!==(n=nt.nextNode())&&h.length<r;){if(1===n.nodeType){if(n.hasAttributes()){const t=[];for(const i of n.getAttributeNames())if(i.endsWith("$lit$")||i.startsWith(H)){const s=l[o++];if(t.push(i),void 0!==s){const t=n.getAttribute(s.toLowerCase()+"$lit$").split(H),i=/([.?@])?(.*)/.exec(s);h.push({type:1,index:e,name:i[2],strings:t,ctor:"."===i[1]?ut:"?"===i[1]?ft:"@"===i[1]?at:lt})}else h.push({type:6,index:e})}for(const i of t)n.removeAttribute(i)}if(K.test(n.tagName)){const t=n.textContent.split(H),i=t.length-1;if(i>0){n.textContent=L?L.emptyScript:"";for(let s=0;s<i;s++)n.append(t[s],V()),nt.nextNode(),h.push({type:2,index:++e});n.append(t[i],V())}}}else if(8===n.nodeType)if(n.data===P)h.push({type:2,index:e});else{let t=-1;for(;-1!==(t=n.data.indexOf(H,t+1));)h.push({type:7,index:e}),t+=H.length-1}e++}}static createElement(t,i){const s=I.createElement("template");return s.innerHTML=t,s}}function rt(t,i,s=t,n){var e,o,r,h;if(i===Y)return i;let c=void 0!==n?null===(e=s._$Cl)||void 0===e?void 0:e[n]:s._$Cu;const l=q(i)?void 0:i._$litDirective$;return(null==c?void 0:c.constructor)!==l&&(null===(o=null==c?void 0:c._$AO)||void 0===o||o.call(c,!1),void 0===l?c=void 0:(c=new l(t),c._$AT(t,s,n)),void 0!==n?(null!==(r=(h=s)._$Cl)&&void 0!==r?r:h._$Cl=[])[n]=c:s._$Cu=c),void 0!==c&&(i=rt(t,c._$AS(t,i.values),c,n)),i}class ht{constructor(t,i){this.v=[],this._$AN=void 0,this._$AD=t,this._$AM=i}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}p(t){var i;const{el:{content:s},parts:n}=this._$AD,e=(null!==(i=null==t?void 0:t.creationScope)&&void 0!==i?i:I).importNode(s,!0);nt.currentNode=e;let o=nt.nextNode(),r=0,h=0,c=n[0];for(;void 0!==c;){if(r===c.index){let i;2===c.type?i=new ct(o,o.nextSibling,this,t):1===c.type?i=new c.ctor(o,c.name,c.strings,this,t):6===c.type&&(i=new vt(o,this,t)),this.v.push(i),c=n[++h]}r!==(null==c?void 0:c.index)&&(o=nt.nextNode(),r++)}return e}m(t){let i=0;for(const s of this.v)void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,i),i+=s.strings.length-2):s._$AI(t[i])),i++}}class ct{constructor(t,i,s,n){var e;this.type=2,this._$AH=tt,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=s,this.options=n,this._$Cg=null===(e=null==n?void 0:n.isConnected)||void 0===e||e}get _$AU(){var t,i;return null!==(i=null===(t=this._$AM)||void 0===t?void 0:t._$AU)&&void 0!==i?i:this._$Cg}get parentNode(){let t=this._$AA.parentNode;const i=this._$AM;return void 0!==i&&11===t.nodeType&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=rt(this,t,i),q(t)?t===tt||null==t||""===t?(this._$AH!==tt&&this._$AR(),this._$AH=tt):t!==this._$AH&&t!==Y&&this.$(t):void 0!==t._$litType$?this.T(t):void 0!==t.nodeType?this.k(t):(t=>{var i;return G(t)||"function"==typeof(null===(i=t)||void 0===i?void 0:i[Symbol.iterator])})(t)?this.S(t):this.$(t)}A(t,i=this._$AB){return this._$AA.parentNode.insertBefore(t,i)}k(t){this._$AH!==t&&(this._$AR(),this._$AH=this.A(t))}$(t){this._$AH!==tt&&q(this._$AH)?this._$AA.nextSibling.data=t:this.k(I.createTextNode(t)),this._$AH=t}T(t){var i;const{values:s,_$litType$:n}=t,e="number"==typeof n?this._$AC(t):(void 0===n.el&&(n.el=ot.createElement(n.h,this.options)),n);if((null===(i=this._$AH)||void 0===i?void 0:i._$AD)===e)this._$AH.m(s);else{const t=new ht(e,this),i=t.p(this.options);t.m(s),this.k(i),this._$AH=t}}_$AC(t){let i=it.get(t.strings);return void 0===i&&it.set(t.strings,i=new ot(t)),i}S(t){G(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let s,n=0;for(const e of t)n===i.length?i.push(s=new ct(this.A(V()),this.A(V()),this,this.options)):s=i[n],s._$AI(e),n++;n<i.length&&(this._$AR(s&&s._$AB.nextSibling,n),i.length=n)}_$AR(t=this._$AA.nextSibling,i){var s;for(null===(s=this._$AP)||void 0===s||s.call(this,!1,!0,i);t&&t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i}}setConnected(t){var i;void 0===this._$AM&&(this._$Cg=t,null===(i=this._$AP)||void 0===i||i.call(this,t))}}class lt{constructor(t,i,s,n,e){this.type=1,this._$AH=tt,this._$AN=void 0,this.element=t,this.name=i,this._$AM=n,this.options=e,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=tt}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,i=this,s,n){const e=this.strings;let o=!1;if(void 0===e)t=rt(this,t,i,0),o=!q(t)||t!==this._$AH&&t!==Y,o&&(this._$AH=t);else{const n=t;let r,h;for(t=e[0],r=0;r<e.length-1;r++)h=rt(this,n[s+r],i,r),h===Y&&(h=this._$AH[r]),o||(o=!q(h)||h!==this._$AH[r]),h===tt?t=tt:t!==tt&&(t+=(null!=h?h:"")+e[r+1]),this._$AH[r]=h}o&&!n&&this.C(t)}C(t){t===tt?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class ut extends lt{constructor(){super(...arguments),this.type=3}C(t){this.element[this.name]=t===tt?void 0:t}}const dt=L?L.emptyScript:"";class ft extends lt{constructor(){super(...arguments),this.type=4}C(t){t&&t!==tt?this.element.setAttribute(this.name,dt):this.element.removeAttribute(this.name)}}class at extends lt{constructor(t,i,s,n,e){super(t,i,s,n,e),this.type=5}_$AI(t,i=this){var s;if((t=null!==(s=rt(this,t,i,0))&&void 0!==s?s:tt)===Y)return;const n=this._$AH,e=t===tt&&n!==tt||t.capture!==n.capture||t.once!==n.once||t.passive!==n.passive,o=t!==tt&&(n===tt||e);e&&this.element.removeEventListener(this.name,this,n),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var i,s;"function"==typeof this._$AH?this._$AH.call(null!==(s=null===(i=this.options)||void 0===i?void 0:i.host)&&void 0!==s?s:this.element,t):this._$AH.handleEvent(t)}}class vt{constructor(t,i,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){rt(this,t)}}const pt=window.litHtmlPolyfillSupport;null==pt||pt(ot,ct),(null!==(N=globalThis.litHtmlVersions)&&void 0!==N?N:globalThis.litHtmlVersions=[]).push("2.2.1");
7
+ var N;n.on("$",C),n.on("debug",(t=>C)),n.on(E,C),n.on("#",C),n.route=S,n.on("route",(t=>n.route&&n.route(t))),"object"==typeof document&&document.addEventListener("DOMContentLoaded",(()=>{n.route===S&&(window.onpopstate=()=>S(location.hash),document.body.hasAttribute("apprun-no-init")||n["no-init-route"]||S(location.hash))})),"object"==typeof window&&(window.Component=M,window._React=window.React,window.React=n,window.on=O,window.customElement=_,window.safeHTML=p),n.use_render=(t,i=0)=>n.render=0===i?(i,s)=>t(s,i):(i,s)=>t(i,s),n.use_react=(t,i)=>{n.h=n.createElement=t.createElement,n.Fragment=t.Fragment,n.render=(t,s)=>i.render(s,t),t.version&&t.version.startsWith("18")&&(n.render=(t,s)=>{t&&s&&(t._root||(t._root=i.createRoot(t)),t._root.render(s))})};const L=window,U=L.trustedTypes,H=U?U.createPolicy("lit-html",{createHTML:t=>t}):void 0,P="$lit$",D=`lit$${(Math.random()+"").slice(9)}$`,I="?"+D,R=`<${I}>`,V=document,q=()=>V.createComment(""),G=t=>null===t||"object"!=typeof t&&"function"!=typeof t,W=Array.isArray,z="[ \t\n\f\r]",F=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Z=/-->/g,J=/>/g,K=RegExp(`>|${z}(?:([^\\s"'>=/]+)(${z}*=${z}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),B=/'/g,Q=/"/g,X=/^(?:script|style|textarea|title)$/i,Y=t=>(i,...s)=>({_$litType$:t,strings:i,values:s}),tt=Y(1),it=Y(2),st=Symbol.for("lit-noChange"),nt=Symbol.for("lit-nothing"),et=new WeakMap,ot=V.createTreeWalker(V,129,null,!1);function rt(t,i){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==H?H.createHTML(i):i}const ht=(t,i)=>{const s=t.length-1,n=[];let e,o=2===i?"<svg>":"",r=F;for(let i=0;i<s;i++){const s=t[i];let h,c,l=-1,u=0;for(;u<s.length&&(r.lastIndex=u,c=r.exec(s),null!==c);)u=r.lastIndex,r===F?"!--"===c[1]?r=Z:void 0!==c[1]?r=J:void 0!==c[2]?(X.test(c[2])&&(e=RegExp("</"+c[2],"g")),r=K):void 0!==c[3]&&(r=K):r===K?">"===c[0]?(r=null!=e?e:F,l=-1):void 0===c[1]?l=-2:(l=r.lastIndex-c[2].length,h=c[1],r=void 0===c[3]?K:'"'===c[3]?Q:B):r===Q||r===B?r=K:r===Z||r===J?r=F:(r=K,e=void 0);const d=r===K&&t[i+1].startsWith("/>")?" ":"";o+=r===F?s+R:l>=0?(n.push(h),s.slice(0,l)+P+s.slice(l)+D+d):s+D+(-2===l?(n.push(void 0),i):d)}return[rt(t,o+(t[s]||"<?>")+(2===i?"</svg>":"")),n]};class ct{constructor({strings:t,_$litType$:i},s){let n;this.parts=[];let e=0,o=0;const r=t.length-1,h=this.parts,[c,l]=ht(t,i);if(this.el=ct.createElement(c,s),ot.currentNode=this.el.content,2===i){const t=this.el.content,i=t.firstChild;i.remove(),t.append(...i.childNodes)}for(;null!==(n=ot.nextNode())&&h.length<r;){if(1===n.nodeType){if(n.hasAttributes()){const t=[];for(const i of n.getAttributeNames())if(i.endsWith(P)||i.startsWith(D)){const s=l[o++];if(t.push(i),void 0!==s){const t=n.getAttribute(s.toLowerCase()+P).split(D),i=/([.?@])?(.*)/.exec(s);h.push({type:1,index:e,name:i[2],strings:t,ctor:"."===i[1]?at:"?"===i[1]?pt:"@"===i[1]?yt:ft})}else h.push({type:6,index:e})}for(const i of t)n.removeAttribute(i)}if(X.test(n.tagName)){const t=n.textContent.split(D),i=t.length-1;if(i>0){n.textContent=U?U.emptyScript:"";for(let s=0;s<i;s++)n.append(t[s],q()),ot.nextNode(),h.push({type:2,index:++e});n.append(t[i],q())}}}else if(8===n.nodeType)if(n.data===I)h.push({type:2,index:e});else{let t=-1;for(;-1!==(t=n.data.indexOf(D,t+1));)h.push({type:7,index:e}),t+=D.length-1}e++}}static createElement(t,i){const s=V.createElement("template");return s.innerHTML=t,s}}function lt(t,i,s=t,n){var e,o,r,h;if(i===st)return i;let c=void 0!==n?null===(e=s._$Co)||void 0===e?void 0:e[n]:s._$Cl;const l=G(i)?void 0:i._$litDirective$;return(null==c?void 0:c.constructor)!==l&&(null===(o=null==c?void 0:c._$AO)||void 0===o||o.call(c,!1),void 0===l?c=void 0:(c=new l(t),c._$AT(t,s,n)),void 0!==n?(null!==(r=(h=s)._$Co)&&void 0!==r?r:h._$Co=[])[n]=c:s._$Cl=c),void 0!==c&&(i=lt(t,c._$AS(t,i.values),c,n)),i}class ut{constructor(t,i){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=i}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){var i;const{el:{content:s},parts:n}=this._$AD,e=(null!==(i=null==t?void 0:t.creationScope)&&void 0!==i?i:V).importNode(s,!0);ot.currentNode=e;let o=ot.nextNode(),r=0,h=0,c=n[0];for(;void 0!==c;){if(r===c.index){let i;2===c.type?i=new dt(o,o.nextSibling,this,t):1===c.type?i=new c.ctor(o,c.name,c.strings,this,t):6===c.type&&(i=new gt(o,this,t)),this._$AV.push(i),c=n[++h]}r!==(null==c?void 0:c.index)&&(o=ot.nextNode(),r++)}return ot.currentNode=V,e}v(t){let i=0;for(const s of this._$AV)void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,i),i+=s.strings.length-2):s._$AI(t[i])),i++}}class dt{constructor(t,i,s,n){var e;this.type=2,this._$AH=nt,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=s,this.options=n,this._$Cp=null===(e=null==n?void 0:n.isConnected)||void 0===e||e}get _$AU(){var t,i;return null!==(i=null===(t=this._$AM)||void 0===t?void 0:t._$AU)&&void 0!==i?i:this._$Cp}get parentNode(){let t=this._$AA.parentNode;const i=this._$AM;return void 0!==i&&11===(null==t?void 0:t.nodeType)&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=lt(this,t,i),G(t)?t===nt||null==t||""===t?(this._$AH!==nt&&this._$AR(),this._$AH=nt):t!==this._$AH&&t!==st&&this._(t):void 0!==t._$litType$?this.g(t):void 0!==t.nodeType?this.$(t):(t=>W(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.T(t):this._(t)}k(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}$(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}_(t){this._$AH!==nt&&G(this._$AH)?this._$AA.nextSibling.data=t:this.$(V.createTextNode(t)),this._$AH=t}g(t){var i;const{values:s,_$litType$:n}=t,e="number"==typeof n?this._$AC(t):(void 0===n.el&&(n.el=ct.createElement(rt(n.h,n.h[0]),this.options)),n);if((null===(i=this._$AH)||void 0===i?void 0:i._$AD)===e)this._$AH.v(s);else{const t=new ut(e,this),i=t.u(this.options);t.v(s),this.$(i),this._$AH=t}}_$AC(t){let i=et.get(t.strings);return void 0===i&&et.set(t.strings,i=new ct(t)),i}T(t){W(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let s,n=0;for(const e of t)n===i.length?i.push(s=new dt(this.k(q()),this.k(q()),this,this.options)):s=i[n],s._$AI(e),n++;n<i.length&&(this._$AR(s&&s._$AB.nextSibling,n),i.length=n)}_$AR(t=this._$AA.nextSibling,i){var s;for(null===(s=this._$AP)||void 0===s||s.call(this,!1,!0,i);t&&t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i}}setConnected(t){var i;void 0===this._$AM&&(this._$Cp=t,null===(i=this._$AP)||void 0===i||i.call(this,t))}}class ft{constructor(t,i,s,n,e){this.type=1,this._$AH=nt,this._$AN=void 0,this.element=t,this.name=i,this._$AM=n,this.options=e,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=nt}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,i=this,s,n){const e=this.strings;let o=!1;if(void 0===e)t=lt(this,t,i,0),o=!G(t)||t!==this._$AH&&t!==st,o&&(this._$AH=t);else{const n=t;let r,h;for(t=e[0],r=0;r<e.length-1;r++)h=lt(this,n[s+r],i,r),h===st&&(h=this._$AH[r]),o||(o=!G(h)||h!==this._$AH[r]),h===nt?t=nt:t!==nt&&(t+=(null!=h?h:"")+e[r+1]),this._$AH[r]=h}o&&!n&&this.j(t)}j(t){t===nt?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class at extends ft{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===nt?void 0:t}}const vt=U?U.emptyScript:"";class pt extends ft{constructor(){super(...arguments),this.type=4}j(t){t&&t!==nt?this.element.setAttribute(this.name,vt):this.element.removeAttribute(this.name)}}class yt extends ft{constructor(t,i,s,n,e){super(t,i,s,n,e),this.type=5}_$AI(t,i=this){var s;if((t=null!==(s=lt(this,t,i,0))&&void 0!==s?s:nt)===st)return;const n=this._$AH,e=t===nt&&n!==nt||t.capture!==n.capture||t.once!==n.once||t.passive!==n.passive,o=t!==nt&&(n===nt||e);e&&this.element.removeEventListener(this.name,this,n),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var i,s;"function"==typeof this._$AH?this._$AH.call(null!==(s=null===(i=this.options)||void 0===i?void 0:i.host)&&void 0!==s?s:this.element,t):this._$AH.handleEvent(t)}}class gt{constructor(t,i,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){lt(this,t)}}const bt=L.litHtmlPolyfillSupport;null==bt||bt(ct,dt),(null!==(N=L.litHtmlVersions)&&void 0!==N?N:L.litHtmlVersions=[]).push("2.8.0");const wt=(t,i,s)=>{var n,e;const o=null!==(n=null==s?void 0:s.renderBefore)&&void 0!==n?n:i;let r=o._$litPart$;if(void 0===r){const t=null!==(e=null==s?void 0:s.renderBefore)&&void 0!==e?e:null;o._$litPart$=r=new dt(i.insertBefore(q(),t),t,void 0,null!=s?s:{})}return r._$AI(t),r
8
8
  /**
9
9
  * @license
10
10
  * Copyright 2017 Google LLC
11
11
  * SPDX-License-Identifier: BSD-3-Clause
12
- */
13
- const yt=2,bt=5,gt=t=>(...i)=>({_$litDirective$:t,values:i});class mt{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,i,s){this._$Ct=t,this._$AM=i,this._$Ci=s}_$AS(t,i){return this.update(t,i)}update(t,i){return this.render(...i)}}
12
+ */},mt=2,$t=5,jt=t=>(...i)=>({_$litDirective$:t,values:i});class At{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,i,s){this._$Ct=t,this._$AM=i,this._$Ci=s}_$AS(t,i){return this.update(t,i)}update(t,i){return this.render(...i)}}
14
13
  /**
15
14
  * @license
16
15
  * Copyright 2017 Google LLC
17
16
  * SPDX-License-Identifier: BSD-3-Clause
18
- */class wt extends mt{constructor(t){if(super(t),this.it=tt,t.type!==yt)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===tt||null==t)return this.ft=void 0,this.it=t;if(t===Y)return t;if("string"!=typeof t)throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this.ft;this.it=t;const i=[t];return i.raw=i,this.ft={_$litType$:this.constructor.resultType,strings:i,values:[]}}}wt.directiveName="unsafeHTML",wt.resultType=1;const $t=gt(wt);function jt(t,i,s){i&&("string"==typeof i?(t._$litPart$||t.replaceChildren(),st(Q`${$t(i)}`,t)):"_$litType$"in i?(t._$litPart$||t.replaceChildren(),st(i,t)):(f(t,i,s),t._$litPart$=void 0))}const At=gt(class extends mt{constructor(t){if(super(t),t.type!==bt)throw new Error("${run} can only be used in event handlers")}update(t,i){let{element:s,name:e}=t;const o=()=>{let t=s._component;for(;!t&&s;)s=s.parentElement,t=s&&s._component;return console.assert(!!t,"Component not found."),t},[r,...h]=i;return"string"==typeof r?s[`on${e}`]=t=>{const i=o();i?i.run(r,...h,t):n.run(r,...h,t)}:"function"==typeof r&&(s[`on${e}`]=t=>o().setState(r(o().state,...h,t))),this.render()}render(){return Y}});n.createElement=u,n.render=jt,n.Fragment=h,"object"==typeof window&&(window.React=window._React||n,window.html=Q,window.svg=X,window.run=At);export{T as Component,E as ROUTER_404_EVENT,M as ROUTER_EVENT,n as app,_ as customElement,n as default,A as event,Q as html,O as on,jt as render,At as run,p as safeHTML,X as svg,A as update};
17
+ */class Ot extends At{constructor(t){if(super(t),this.et=nt,t.type!==mt)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===nt||null==t)return this.ft=void 0,this.et=t;if(t===st)return t;if("string"!=typeof t)throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.et)return this.ft;this.et=t;const i=[t];return i.raw=i,this.ft={_$litType$:this.constructor.resultType,strings:i,values:[]}}}Ot.directiveName="unsafeHTML",Ot.resultType=1;const _t=jt(Ot);function xt(t,i,s){i&&("string"==typeof i?(t._$litPart$||t.replaceChildren(),wt(tt`${_t(i)}`,t)):"_$litType$"in i?(t._$litPart$||t.replaceChildren(),wt(i,t)):(f(t,i,s),t._$litPart$=void 0))}const kt=jt(class extends At{constructor(t){if(super(t),t.type!==$t)throw new Error("${run} can only be used in event handlers")}update(t,i){let{element:s,name:e}=t;const o=()=>{let t=s._component;for(;!t&&s;)s=s.parentElement,t=s&&s._component;return console.assert(!!t,"Component not found."),t},[r,...h]=i;return"string"==typeof r?s[`on${e}`]=t=>{const i=o();i?i.run(r,...h,t):n.run(r,...h,t)}:"function"==typeof r&&(s[`on${e}`]=t=>o().setState(r(o().state,...h,t))),this.render()}render(){return st}});n.createElement=u,n.render=xt,n.Fragment=h,"object"==typeof window&&(window.React=window._React||n,window.html=tt,window.svg=it,window.run=kt);export{M as Component,T as ROUTER_404_EVENT,E as ROUTER_EVENT,n as app,_ as customElement,n as default,A as event,tt as html,O as on,xt as render,kt as run,p as safeHTML,it as svg,A as update};
19
18
  //# sourceMappingURL=apprun-html.esm.js.map