@microsoft/fast-router 0.4.5 → 0.4.6

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/CHANGELOG.json CHANGED
@@ -2,7 +2,30 @@
2
2
  "name": "@microsoft/fast-router",
3
3
  "entries": [
4
4
  {
5
- "date": "Wed, 17 Aug 2022 16:39:47 GMT",
5
+ "date": "Tue, 25 Oct 2022 02:34:36 GMT",
6
+ "tag": "@microsoft/fast-router_v0.4.6",
7
+ "version": "0.4.6",
8
+ "comments": {
9
+ "none": [
10
+ {
11
+ "author": "chhol@microsoft.com",
12
+ "package": "@microsoft/fast-router",
13
+ "commit": "3fdcb06dceadb8a28d9d4d2a217116ece04e89f4",
14
+ "comment": "fix prettier errors"
15
+ }
16
+ ],
17
+ "patch": [
18
+ {
19
+ "author": "beachball",
20
+ "package": "@microsoft/fast-router",
21
+ "comment": "Bump @microsoft/fast-element to v1.11.0",
22
+ "commit": "3fdcb06dceadb8a28d9d4d2a217116ece04e89f4"
23
+ }
24
+ ]
25
+ }
26
+ },
27
+ {
28
+ "date": "Wed, 17 Aug 2022 16:41:39 GMT",
6
29
  "tag": "@microsoft/fast-router_v0.4.5",
7
30
  "version": "0.4.5",
8
31
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,12 +1,20 @@
1
1
  # Change Log - @microsoft/fast-router
2
2
 
3
- This log was last generated on Wed, 17 Aug 2022 16:39:47 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 25 Oct 2022 02:34:36 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 0.4.6
8
+
9
+ Tue, 25 Oct 2022 02:34:36 GMT
10
+
11
+ ### Patches
12
+
13
+ - Bump @microsoft/fast-element to v1.11.0
14
+
7
15
  ## 0.4.5
8
16
 
9
- Wed, 17 Aug 2022 16:39:47 GMT
17
+ Wed, 17 Aug 2022 16:41:39 GMT
10
18
 
11
19
  ### Patches
12
20
 
@@ -139,6 +139,32 @@ if (FAST.getById === void 0) {
139
139
 
140
140
 
141
141
  const emptyArray = Object.freeze([]);
142
+ /**
143
+ * Creates a function capable of locating metadata associated with a type.
144
+ * @returns A metadata locator function.
145
+ * @internal
146
+ */
147
+
148
+ function createMetadataLocator() {
149
+ const metadataLookup = new WeakMap();
150
+ return function (target) {
151
+ let metadata = metadataLookup.get(target);
152
+
153
+ if (metadata === void 0) {
154
+ let currentTarget = Reflect.getPrototypeOf(target);
155
+
156
+ while (metadata === void 0 && currentTarget !== null) {
157
+ metadata = metadataLookup.get(currentTarget);
158
+ currentTarget = Reflect.getPrototypeOf(currentTarget);
159
+ }
160
+
161
+ metadata = metadata === void 0 ? [] : metadata.slice(0);
162
+ metadataLookup.set(target, metadata);
163
+ }
164
+
165
+ return metadata;
166
+ };
167
+ }
142
168
 
143
169
  const updateQueue = $global.FAST.getById(1
144
170
  /* updateQueue */
@@ -583,7 +609,6 @@ const Observable = FAST.getById(2
583
609
  , () => {
584
610
  const volatileRegex = /(:|&&|\|\||if)/;
585
611
  const notifierLookup = new WeakMap();
586
- const accessorLookup = new WeakMap();
587
612
  const queueUpdate = DOM.queueUpdate;
588
613
  let watcher = void 0;
589
614
 
@@ -605,28 +630,7 @@ const Observable = FAST.getById(2
605
630
  return found;
606
631
  }
607
632
 
608
- function getAccessors(target) {
609
- let accessors = accessorLookup.get(target);
610
-
611
- if (accessors === void 0) {
612
- let currentTarget = Reflect.getPrototypeOf(target);
613
-
614
- while (accessors === void 0 && currentTarget !== null) {
615
- accessors = accessorLookup.get(currentTarget);
616
- currentTarget = Reflect.getPrototypeOf(currentTarget);
617
- }
618
-
619
- if (accessors === void 0) {
620
- accessors = [];
621
- } else {
622
- accessors = accessors.slice(0);
623
- }
624
-
625
- accessorLookup.set(target, accessors);
626
- }
627
-
628
- return accessors;
629
- }
633
+ const getAccessors = createMetadataLocator();
630
634
 
631
635
  class DefaultObservableAccessor {
632
636
  constructor(name) {
@@ -1662,8 +1666,9 @@ class HTMLView {
1662
1666
  if (this.fragment.hasChildNodes()) {
1663
1667
  node.parentNode.insertBefore(this.fragment, node);
1664
1668
  } else {
1665
- const parentNode = node.parentNode;
1666
1669
  const end = this.lastChild;
1670
+ if (node.previousSibling === end) return;
1671
+ const parentNode = node.parentNode;
1667
1672
  let current = this.firstChild;
1668
1673
  let next;
1669
1674
 
@@ -2149,6 +2154,17 @@ class StyleElementStyles extends ElementStyles {
2149
2154
 
2150
2155
  }
2151
2156
 
2157
+ /**
2158
+ * Metadata used to configure a custom attribute's behavior.
2159
+ * @public
2160
+ */
2161
+
2162
+ const AttributeConfiguration = Object.freeze({
2163
+ /**
2164
+ * Locates all attribute configurations associated with a type.
2165
+ */
2166
+ locate: createMetadataLocator()
2167
+ });
2152
2168
  /**
2153
2169
  * A {@link ValueConverter} that converts to and from `boolean` values.
2154
2170
  * @remarks
@@ -2315,7 +2331,7 @@ class AttributeDefinition {
2315
2331
 
2316
2332
  static collect(Owner, ...attributeLists) {
2317
2333
  const attributes = [];
2318
- attributeLists.push(Owner.attributes);
2334
+ attributeLists.push(AttributeConfiguration.locate(Owner));
2319
2335
 
2320
2336
  for (let i = 0, ii = attributeLists.length; i < ii; ++i) {
2321
2337
  const list = attributeLists[i];
@@ -2352,8 +2368,7 @@ function attr(configOrTarget, prop) {
2352
2368
  config.property = $prop;
2353
2369
  }
2354
2370
 
2355
- const attributes = $target.constructor.attributes || ($target.constructor.attributes = []);
2356
- attributes.push(config);
2371
+ AttributeConfiguration.locate($target.constructor).push(config);
2357
2372
  }
2358
2373
 
2359
2374
  if (arguments.length > 1) {
@@ -3942,7 +3957,7 @@ class RepeatBehavior {
3942
3957
  let addIndex = splice.index;
3943
3958
  const end = addIndex + splice.addedCount;
3944
3959
  const removedViews = views.splice(splice.index, removed.length);
3945
- availableViews = leftoverViews.length + removedViews.length;
3960
+ const totalAvailableViews = availableViews = leftoverViews.length + removedViews.length;
3946
3961
 
3947
3962
  for (; addIndex < end; ++addIndex) {
3948
3963
  const neighbor = views[addIndex];
@@ -3950,7 +3965,7 @@ class RepeatBehavior {
3950
3965
  let view;
3951
3966
 
3952
3967
  if (recycle && availableViews > 0) {
3953
- if (removeIndex <= availableViews && removedViews.length > 0) {
3968
+ if (removeIndex <= totalAvailableViews && removedViews.length > 0) {
3954
3969
  view = removedViews[removeIndex];
3955
3970
  removeIndex++;
3956
3971
  } else {
@@ -6790,4 +6805,4 @@ class RouterConfiguration {
6790
6805
  let FASTRouter = class FASTRouter extends Router.from(FASTElement) {};
6791
6806
  FASTRouter = __decorate([customElement("fast-router")], FASTRouter);
6792
6807
 
6793
- export { $global, AttachedBehaviorHTMLDirective, AttributeDefinition, BindingBehavior, CSSDirective, ChildrenBehavior, ConfigurableRoute, Controller, DOM, DefaultLinkHandler, DefaultNavigationProcess, DefaultNavigationQueue, DefaultRouteRecognizer, DefaultRouter, ElementStyles, Endpoint, ExecutionContext, FAST, FASTElement, FASTElementDefinition, FASTElementLayout, FASTRouter, HTMLBindingDirective, HTMLDirective, HTMLView, Ignore, Layout, NavigationHandler, NavigationMessage, Observable, PropertyChangeNotifier, QueryString, RecognizedRoute, Redirect, RefBehavior, Render, RepeatBehavior, RepeatDirective, Route, RouteCollection, Router, RouterConfiguration, RouterExecutionContext, SlottedBehavior, SubscriberSet, TargetedHTMLDirective, Transition, ViewTemplate, attr, booleanConverter$1 as booleanConverter, childRouteParameter, children, compileTemplate, css, cssPartial, customElement, defaultExecutionContext, elements, emptyArray, enableArrayObservation, html, isFASTElementHost, isNavigationPhaseContributor, navigationContributor, nullableNumberConverter, observable, ref, repeat, slotted, volatile, when };
6808
+ export { $global, AttachedBehaviorHTMLDirective, AttributeConfiguration, AttributeDefinition, BindingBehavior, CSSDirective, ChildrenBehavior, ConfigurableRoute, Controller, DOM, DefaultLinkHandler, DefaultNavigationProcess, DefaultNavigationQueue, DefaultRouteRecognizer, DefaultRouter, ElementStyles, Endpoint, ExecutionContext, FAST, FASTElement, FASTElementDefinition, FASTElementLayout, FASTRouter, HTMLBindingDirective, HTMLDirective, HTMLView, Ignore, Layout, NavigationHandler, NavigationMessage, Observable, PropertyChangeNotifier, QueryString, RecognizedRoute, Redirect, RefBehavior, Render, RepeatBehavior, RepeatDirective, Route, RouteCollection, Router, RouterConfiguration, RouterExecutionContext, SlottedBehavior, SubscriberSet, TargetedHTMLDirective, Transition, ViewTemplate, attr, booleanConverter$1 as booleanConverter, childRouteParameter, children, compileTemplate, createMetadataLocator, css, cssPartial, customElement, defaultExecutionContext, elements, emptyArray, enableArrayObservation, html, isFASTElementHost, isNavigationPhaseContributor, navigationContributor, nullableNumberConverter, observable, ref, repeat, slotted, volatile, when };
@@ -1 +1 @@
1
- function t(t,e,i,s){return new(i||(i=Promise))((function(n,r){function o(t){try{a(s.next(t))}catch(t){r(t)}}function l(t){try{a(s.throw(t))}catch(t){r(t)}}function a(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,l)}a((s=s.apply(t,e||[])).next())}))}const e=function(){if("undefined"!=typeof globalThis)return globalThis;if("undefined"!=typeof global)return global;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;try{return new Function("return this")()}catch(t){return{}}}();void 0===e.trustedTypes&&(e.trustedTypes={createPolicy:(t,e)=>e});const i={configurable:!1,enumerable:!1,writable:!1};void 0===e.FAST&&Reflect.defineProperty(e,"FAST",Object.assign({value:Object.create(null)},i));const s=e.FAST;if(void 0===s.getById){const t=Object.create(null);Reflect.defineProperty(s,"getById",Object.assign({value(e,i){let s=t[e];return void 0===s&&(s=i?t[e]=i():null),s}},i))}const n=Object.freeze([]),r=e.FAST.getById(1,()=>{const t=[],i=[];function s(){if(i.length)throw i.shift()}function n(t){try{t.call()}catch(t){i.push(t),setTimeout(s,0)}}function r(){let e=0;for(;e<t.length;)if(n(t[e]),e++,e>1024){for(let i=0,s=t.length-e;i<s;i++)t[i]=t[i+e];t.length-=e,e=0}t.length=0}return Object.freeze({enqueue:function(i){t.length<1&&e.requestAnimationFrame(r),t.push(i)},process:r})}),o=e.trustedTypes.createPolicy("fast-html",{createHTML:t=>t});let l=o;const a="fast-"+Math.random().toString(36).substring(2,8),h=a+"{",c="}"+a,u=Object.freeze({supportsAdoptedStyleSheets:Array.isArray(document.adoptedStyleSheets)&&"replace"in CSSStyleSheet.prototype,setHTMLPolicy(t){if(l!==o)throw new Error("The HTML policy can only be set once.");l=t},createHTML:t=>l.createHTML(t),isMarker:t=>t&&8===t.nodeType&&t.data.startsWith(a),extractDirectiveIndexFromMarker:t=>parseInt(t.data.replace(a+":","")),createInterpolationPlaceholder:t=>`${h}${t}${c}`,createCustomAttributePlaceholder(t,e){return`${t}="${this.createInterpolationPlaceholder(e)}"`},createBlockPlaceholder:t=>`\x3c!--${a}:${t}--\x3e`,queueUpdate:r.enqueue,processUpdates:r.process,nextUpdate:()=>new Promise(r.enqueue),setAttribute(t,e,i){null==i?t.removeAttribute(e):t.setAttribute(e,i)},setBooleanAttribute(t,e,i){i?t.setAttribute(e,""):t.removeAttribute(e)},removeChildNodes(t){for(let e=t.firstChild;null!==e;e=t.firstChild)t.removeChild(e)},createTemplateWalker:t=>document.createTreeWalker(t,133,null,!1)});class d{constructor(t,e){this.sub1=void 0,this.sub2=void 0,this.spillover=void 0,this.source=t,this.sub1=e}has(t){return void 0===this.spillover?this.sub1===t||this.sub2===t:-1!==this.spillover.indexOf(t)}subscribe(t){const e=this.spillover;if(void 0===e){if(this.has(t))return;if(void 0===this.sub1)return void(this.sub1=t);if(void 0===this.sub2)return void(this.sub2=t);this.spillover=[this.sub1,this.sub2,t],this.sub1=void 0,this.sub2=void 0}else{-1===e.indexOf(t)&&e.push(t)}}unsubscribe(t){const e=this.spillover;if(void 0===e)this.sub1===t?this.sub1=void 0:this.sub2===t&&(this.sub2=void 0);else{const i=e.indexOf(t);-1!==i&&e.splice(i,1)}}notify(t){const e=this.spillover,i=this.source;if(void 0===e){const e=this.sub1,s=this.sub2;void 0!==e&&e.handleChange(i,t),void 0!==s&&s.handleChange(i,t)}else for(let s=0,n=e.length;s<n;++s)e[s].handleChange(i,t)}}class f{constructor(t){this.subscribers={},this.sourceSubscribers=null,this.source=t}notify(t){var e;const i=this.subscribers[t];void 0!==i&&i.notify(t),null===(e=this.sourceSubscribers)||void 0===e||e.notify(t)}subscribe(t,e){var i;if(e){let i=this.subscribers[e];void 0===i&&(this.subscribers[e]=i=new d(this.source)),i.subscribe(t)}else this.sourceSubscribers=null!==(i=this.sourceSubscribers)&&void 0!==i?i:new d(this.source),this.sourceSubscribers.subscribe(t)}unsubscribe(t,e){var i;if(e){const i=this.subscribers[e];void 0!==i&&i.unsubscribe(t)}else null===(i=this.sourceSubscribers)||void 0===i||i.unsubscribe(t)}}const p=s.getById(2,()=>{const t=/(:|&&|\|\||if)/,e=new WeakMap,i=new WeakMap,s=u.queueUpdate;let n=void 0,r=t=>{throw new Error("Must call enableArrayObservation before observing arrays.")};function o(t){let i=t.$fastController||e.get(t);return void 0===i&&(Array.isArray(t)?i=r(t):e.set(t,i=new f(t))),i}function l(t){let e=i.get(t);if(void 0===e){let s=Reflect.getPrototypeOf(t);for(;void 0===e&&null!==s;)e=i.get(s),s=Reflect.getPrototypeOf(s);e=void 0===e?[]:e.slice(0),i.set(t,e)}return e}class a{constructor(t){this.name=t,this.field="_"+t,this.callback=t+"Changed"}getValue(t){return void 0!==n&&n.watch(t,this.name),t[this.field]}setValue(t,e){const i=this.field,s=t[i];if(s!==e){t[i]=e;const n=t[this.callback];"function"==typeof n&&n.call(t,s,e),o(t).notify(this.name)}}}class h extends d{constructor(t,e,i=!1){super(t,e),this.binding=t,this.isVolatileBinding=i,this.needsRefresh=!0,this.needsQueue=!0,this.first=this,this.last=null,this.propertySource=void 0,this.propertyName=void 0,this.notifier=void 0,this.next=void 0}observe(t,e){this.needsRefresh&&null!==this.last&&this.disconnect();const i=n;n=this.needsRefresh?this:void 0,this.needsRefresh=this.isVolatileBinding;const s=this.binding(t,e);return n=i,s}disconnect(){if(null!==this.last){let t=this.first;for(;void 0!==t;)t.notifier.unsubscribe(this,t.propertyName),t=t.next;this.last=null,this.needsRefresh=this.needsQueue=!0}}watch(t,e){const i=this.last,s=o(t),r=null===i?this.first:{};if(r.propertySource=t,r.propertyName=e,r.notifier=s,s.subscribe(this,e),null!==i){if(!this.needsRefresh){let e;n=void 0,e=i.propertySource[i.propertyName],n=this,t===e&&(this.needsRefresh=!0)}i.next=r}this.last=r}handleChange(){this.needsQueue&&(this.needsQueue=!1,s(this))}call(){null!==this.last&&(this.needsQueue=!0,this.notify(this))}records(){let t=this.first;return{next:()=>{const e=t;return void 0===e?{value:void 0,done:!0}:(t=t.next,{value:e,done:!1})},[Symbol.iterator]:function(){return this}}}}return Object.freeze({setArrayObserverFactory(t){r=t},getNotifier:o,track(t,e){void 0!==n&&n.watch(t,e)},trackVolatile(){void 0!==n&&(n.needsRefresh=!0)},notify(t,e){o(t).notify(e)},defineProperty(t,e){"string"==typeof e&&(e=new a(e)),l(t).push(e),Reflect.defineProperty(t,e.name,{enumerable:!0,get:function(){return e.getValue(this)},set:function(t){e.setValue(this,t)}})},getAccessors:l,binding(t,e,i=this.isVolatileBinding(t)){return new h(t,e,i)},isVolatileBinding:e=>t.test(e.toString())})});function g(t,e){p.defineProperty(t,e)}function v(t,e,i){return Object.assign({},i,{get:function(){return p.trackVolatile(),i.get.apply(this)}})}const m=s.getById(3,()=>{let t=null;return{get:()=>t,set(e){t=e}}});class b{constructor(){this.index=0,this.length=0,this.parent=null,this.parentContext=null}get event(){return m.get()}get isEven(){return this.index%2==0}get isOdd(){return this.index%2!=0}get isFirst(){return 0===this.index}get isInMiddle(){return!this.isFirst&&!this.isLast}get isLast(){return this.index===this.length-1}static setEvent(t){m.set(t)}}p.defineProperty(b.prototype,"index"),p.defineProperty(b.prototype,"length");const y=Object.seal(new b);class C{constructor(){this.targetIndex=0}}class w extends C{constructor(){super(...arguments),this.createPlaceholder=u.createInterpolationPlaceholder}}class S extends C{constructor(t,e,i){super(),this.name=t,this.behavior=e,this.options=i}createPlaceholder(t){return u.createCustomAttributePlaceholder(this.name,t)}createBehavior(t){return new this.behavior(t,this.options)}}function x(t,e){this.source=t,this.context=e,null===this.bindingObserver&&(this.bindingObserver=p.binding(this.binding,this,this.isBindingVolatile)),this.updateTarget(this.bindingObserver.observe(t,e))}function O(t,e){this.source=t,this.context=e,this.target.addEventListener(this.targetName,this)}function T(){this.bindingObserver.disconnect(),this.source=null,this.context=null}function k(){this.bindingObserver.disconnect(),this.source=null,this.context=null;const t=this.target.$fastView;void 0!==t&&t.isComposed&&(t.unbind(),t.needsBindOnly=!0)}function B(){this.target.removeEventListener(this.targetName,this),this.source=null,this.context=null}function N(t){u.setAttribute(this.target,this.targetName,t)}function A(t){u.setBooleanAttribute(this.target,this.targetName,t)}function $(t){if(null==t&&(t=""),t.create){this.target.textContent="";let e=this.target.$fastView;void 0===e?e=t.create():this.target.$fastTemplate!==t&&(e.isComposed&&(e.remove(),e.unbind()),e=t.create()),e.isComposed?e.needsBindOnly&&(e.needsBindOnly=!1,e.bind(this.source,this.context)):(e.isComposed=!0,e.bind(this.source,this.context),e.insertBefore(this.target),this.target.$fastView=e,this.target.$fastTemplate=t)}else{const e=this.target.$fastView;void 0!==e&&e.isComposed&&(e.isComposed=!1,e.remove(),e.needsBindOnly?e.needsBindOnly=!1:e.unbind()),this.target.textContent=t}}function R(t){this.target[this.targetName]=t}function P(t){const e=this.classVersions||Object.create(null),i=this.target;let s=this.version||0;if(null!=t&&t.length){const n=t.split(/\s+/);for(let t=0,r=n.length;t<r;++t){const r=n[t];""!==r&&(e[r]=s,i.classList.add(r))}}if(this.classVersions=e,this.version=s+1,0!==s){s-=1;for(const t in e)e[t]===s&&i.classList.remove(t)}}class E extends w{constructor(t){super(),this.binding=t,this.bind=x,this.unbind=T,this.updateTarget=N,this.isBindingVolatile=p.isVolatileBinding(this.binding)}get targetName(){return this.originalTargetName}set targetName(t){if(this.originalTargetName=t,void 0!==t)switch(t[0]){case":":if(this.cleanedTargetName=t.substr(1),this.updateTarget=R,"innerHTML"===this.cleanedTargetName){const t=this.binding;this.binding=(e,i)=>u.createHTML(t(e,i))}break;case"?":this.cleanedTargetName=t.substr(1),this.updateTarget=A;break;case"@":this.cleanedTargetName=t.substr(1),this.bind=O,this.unbind=B;break;default:this.cleanedTargetName=t,"class"===t&&(this.updateTarget=P)}}targetAtContent(){this.updateTarget=$,this.unbind=k}createBehavior(t){return new V(t,this.binding,this.isBindingVolatile,this.bind,this.unbind,this.updateTarget,this.cleanedTargetName)}}class V{constructor(t,e,i,s,n,r,o){this.source=null,this.context=null,this.bindingObserver=null,this.target=t,this.binding=e,this.isBindingVolatile=i,this.bind=s,this.unbind=n,this.updateTarget=r,this.targetName=o}handleChange(){this.updateTarget(this.bindingObserver.observe(this.source,this.context))}handleEvent(t){b.setEvent(t);const e=this.binding(this.source,this.context);b.setEvent(null),!0!==e&&t.preventDefault()}}let j=null;class F{addFactory(t){t.targetIndex=this.targetIndex,this.behaviorFactories.push(t)}captureContentBinding(t){t.targetAtContent(),this.addFactory(t)}reset(){this.behaviorFactories=[],this.targetIndex=-1}release(){j=this}static borrow(t){const e=j||new F;return e.directives=t,e.reset(),j=null,e}}function z(t){if(1===t.length)return t[0];let e;const i=t.length,s=t.map(t=>"string"==typeof t?()=>t:(e=t.targetName||e,t.binding)),n=new E((t,e)=>{let n="";for(let r=0;r<i;++r)n+=s[r](t,e);return n});return n.targetName=e,n}const I=c.length;function M(t,e){const i=e.split(h);if(1===i.length)return null;const s=[];for(let e=0,n=i.length;e<n;++e){const n=i[e],r=n.indexOf(c);let o;if(-1===r)o=n;else{const e=parseInt(n.substring(0,r));s.push(t.directives[e]),o=n.substring(r+I)}""!==o&&s.push(o)}return s}function _(t,e,i=!1){const s=e.attributes;for(let n=0,r=s.length;n<r;++n){const o=s[n],l=o.value,a=M(t,l);let h=null;null===a?i&&(h=new E(()=>l),h.targetName=o.name):h=z(a),null!==h&&(e.removeAttributeNode(o),n--,r--,t.addFactory(h))}}function L(t,e,i){const s=M(t,e.textContent);if(null!==s){let n=e;for(let r=0,o=s.length;r<o;++r){const o=s[r],l=0===r?e:n.parentNode.insertBefore(document.createTextNode(""),n.nextSibling);"string"==typeof o?l.textContent=o:(l.textContent=" ",t.captureContentBinding(o)),n=l,t.targetIndex++,l!==e&&i.nextNode()}t.targetIndex--}}function q(t,e){const i=t.content;document.adoptNode(i);const s=F.borrow(e);_(s,t,!0);const n=s.behaviorFactories;s.reset();const r=u.createTemplateWalker(i);let o;for(;o=r.nextNode();)switch(s.targetIndex++,o.nodeType){case 1:_(s,o);break;case 3:L(s,o,r);break;case 8:u.isMarker(o)&&s.addFactory(e[u.extractDirectiveIndexFromMarker(o)])}let l=0;(u.isMarker(i.firstChild)||1===i.childNodes.length&&e.length)&&(i.insertBefore(document.createComment(""),i.firstChild),l=-1);const a=s.behaviorFactories;return s.release(),{fragment:i,viewBehaviorFactories:a,hostBehaviorFactories:n,targetOffset:l}}const H=document.createRange();class D{constructor(t,e){this.fragment=t,this.behaviors=e,this.source=null,this.context=null,this.firstChild=t.firstChild,this.lastChild=t.lastChild}appendTo(t){t.appendChild(this.fragment)}insertBefore(t){if(this.fragment.hasChildNodes())t.parentNode.insertBefore(this.fragment,t);else{const e=t.parentNode,i=this.lastChild;let s,n=this.firstChild;for(;n!==i;)s=n.nextSibling,e.insertBefore(n,t),n=s;e.insertBefore(i,t)}}remove(){const t=this.fragment,e=this.lastChild;let i,s=this.firstChild;for(;s!==e;)i=s.nextSibling,t.appendChild(s),s=i;t.appendChild(e)}dispose(){const t=this.firstChild.parentNode,e=this.lastChild;let i,s=this.firstChild;for(;s!==e;)i=s.nextSibling,t.removeChild(s),s=i;t.removeChild(e);const n=this.behaviors,r=this.source;for(let t=0,e=n.length;t<e;++t)n[t].unbind(r)}bind(t,e){const i=this.behaviors;if(this.source!==t)if(null!==this.source){const s=this.source;this.source=t,this.context=e;for(let n=0,r=i.length;n<r;++n){const r=i[n];r.unbind(s),r.bind(t,e)}}else{this.source=t,this.context=e;for(let s=0,n=i.length;s<n;++s)i[s].bind(t,e)}}unbind(){if(null===this.source)return;const t=this.behaviors,e=this.source;for(let i=0,s=t.length;i<s;++i)t[i].unbind(e);this.source=null}static disposeContiguousBatch(t){if(0!==t.length){H.setStartBefore(t[0].firstChild),H.setEndAfter(t[t.length-1].lastChild),H.deleteContents();for(let e=0,i=t.length;e<i;++e){const i=t[e],s=i.behaviors,n=i.source;for(let t=0,e=s.length;t<e;++t)s[t].unbind(n)}}}}class Q{constructor(t,e){this.behaviorCount=0,this.hasHostBehaviors=!1,this.fragment=null,this.targetOffset=0,this.viewBehaviorFactories=null,this.hostBehaviorFactories=null,this.html=t,this.directives=e}create(t){if(null===this.fragment){let t;const e=this.html;if("string"==typeof e){t=document.createElement("template"),t.innerHTML=u.createHTML(e);const i=t.content.firstElementChild;null!==i&&"TEMPLATE"===i.tagName&&(t=i)}else t=e;const i=q(t,this.directives);this.fragment=i.fragment,this.viewBehaviorFactories=i.viewBehaviorFactories,this.hostBehaviorFactories=i.hostBehaviorFactories,this.targetOffset=i.targetOffset,this.behaviorCount=this.viewBehaviorFactories.length+this.hostBehaviorFactories.length,this.hasHostBehaviors=this.hostBehaviorFactories.length>0}const e=this.fragment.cloneNode(!0),i=this.viewBehaviorFactories,s=new Array(this.behaviorCount),n=u.createTemplateWalker(e);let r=0,o=this.targetOffset,l=n.nextNode();for(let t=i.length;r<t;++r){const t=i[r],e=t.targetIndex;for(;null!==l;){if(o===e){s[r]=t.createBehavior(l);break}l=n.nextNode(),o++}}if(this.hasHostBehaviors){const e=this.hostBehaviorFactories;for(let i=0,n=e.length;i<n;++i,++r)s[r]=e[i].createBehavior(t)}return new D(e,s)}render(t,e,i){"string"==typeof e&&(e=document.getElementById(e)),void 0===i&&(i=e);const s=this.create(i);return s.bind(t,y),s.appendTo(e),s}}const U=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;function W(t,...e){const i=[];let s="";for(let n=0,r=t.length-1;n<r;++n){const r=t[n];let o=e[n];if(s+=r,o instanceof Q){const t=o;o=()=>t}if("function"==typeof o&&(o=new E(o)),o instanceof w){const t=U.exec(r);null!==t&&(o.targetName=t[2])}o instanceof C?(s+=o.createPlaceholder(i.length),i.push(o)):s+=o}return s+=t[t.length-1],new Q(s,i)}class K{constructor(){this.targets=new WeakSet}addStylesTo(t){this.targets.add(t)}removeStylesFrom(t){this.targets.delete(t)}isAttachedTo(t){return this.targets.has(t)}withBehaviors(...t){return this.behaviors=null===this.behaviors?t:this.behaviors.concat(t),this}}function J(t){return t.map(t=>t instanceof K?J(t.styles):[t]).reduce((t,e)=>t.concat(e),[])}function G(t){return t.map(t=>t instanceof K?t.behaviors:null).reduce((t,e)=>null===e?t:(null===t&&(t=[]),t.concat(e)),null)}K.create=(()=>{if(u.supportsAdoptedStyleSheets){const t=new Map;return e=>new X(e,t)}return t=>new Z(t)})();class X extends K{constructor(t,e){super(),this.styles=t,this.styleSheetCache=e,this._styleSheets=void 0,this.behaviors=G(t)}get styleSheets(){if(void 0===this._styleSheets){const t=this.styles,e=this.styleSheetCache;this._styleSheets=J(t).map(t=>{if(t instanceof CSSStyleSheet)return t;let i=e.get(t);return void 0===i&&(i=new CSSStyleSheet,i.replaceSync(t),e.set(t,i)),i})}return this._styleSheets}addStylesTo(t){t.adoptedStyleSheets=[...t.adoptedStyleSheets,...this.styleSheets],super.addStylesTo(t)}removeStylesFrom(t){const e=this.styleSheets;t.adoptedStyleSheets=t.adoptedStyleSheets.filter(t=>-1===e.indexOf(t)),super.removeStylesFrom(t)}}let Y=0;class Z extends K{constructor(t){super(),this.styles=t,this.behaviors=null,this.behaviors=G(t),this.styleSheets=J(t),this.styleClass="fast-style-class-"+ ++Y}addStylesTo(t){const e=this.styleSheets,i=this.styleClass;t=this.normalizeTarget(t);for(let s=0;s<e.length;s++){const n=document.createElement("style");n.innerHTML=e[s],n.className=i,t.append(n)}super.addStylesTo(t)}removeStylesFrom(t){const e=(t=this.normalizeTarget(t)).querySelectorAll("."+this.styleClass);for(let i=0,s=e.length;i<s;++i)t.removeChild(e[i]);super.removeStylesFrom(t)}isAttachedTo(t){return super.isAttachedTo(this.normalizeTarget(t))}normalizeTarget(t){return t===document?document.body:t}}const tt={toView:t=>t?"true":"false",fromView:t=>null!=t&&"false"!==t&&!1!==t&&0!==t},et={toView(t){if(null==t)return null;const e=1*t;return isNaN(e)?null:e.toString()},fromView(t){if(null==t)return null;const e=1*t;return isNaN(e)?null:e}};class it{constructor(t,e,i=e.toLowerCase(),s="reflect",n){this.guards=new Set,this.Owner=t,this.name=e,this.attribute=i,this.mode=s,this.converter=n,this.fieldName="_"+e,this.callbackName=e+"Changed",this.hasCallback=this.callbackName in t.prototype,"boolean"===s&&void 0===n&&(this.converter=tt)}setValue(t,e){const i=t[this.fieldName],s=this.converter;void 0!==s&&(e=s.fromView(e)),i!==e&&(t[this.fieldName]=e,this.tryReflectToAttribute(t),this.hasCallback&&t[this.callbackName](i,e),t.$fastController.notify(this.name))}getValue(t){return p.track(t,this.name),t[this.fieldName]}onAttributeChangedCallback(t,e){this.guards.has(t)||(this.guards.add(t),this.setValue(t,e),this.guards.delete(t))}tryReflectToAttribute(t){const e=this.mode,i=this.guards;i.has(t)||"fromView"===e||u.queueUpdate(()=>{i.add(t);const s=t[this.fieldName];switch(e){case"reflect":const e=this.converter;u.setAttribute(t,this.attribute,void 0!==e?e.toView(s):s);break;case"boolean":u.setBooleanAttribute(t,this.attribute,s)}i.delete(t)})}static collect(t,...e){const i=[];e.push(t.attributes);for(let s=0,n=e.length;s<n;++s){const n=e[s];if(void 0!==n)for(let e=0,s=n.length;e<s;++e){const s=n[e];"string"==typeof s?i.push(new it(t,s)):i.push(new it(t,s.property,s.attribute,s.mode,s.converter))}}return i}}function st(t,e){let i;function s(t,e){arguments.length>1&&(i.property=e);const s=t.constructor.attributes||(t.constructor.attributes=[]);s.push(i)}return arguments.length>1?(i={},void s(t,e)):(i=void 0===t?{}:t,s)}const nt={mode:"open"},rt={},ot=s.getById(4,()=>{const t=new Map;return Object.freeze({register:e=>!t.has(e.type)&&(t.set(e.type,e),!0),getByType:e=>t.get(e)})});class lt{constructor(t,e=t.definition){"string"==typeof e&&(e={name:e}),this.type=t,this.name=e.name,this.template=e.template;const i=it.collect(t,e.attributes),s=new Array(i.length),n={},r={};for(let t=0,e=i.length;t<e;++t){const e=i[t];s[t]=e.attribute,n[e.name]=e,r[e.attribute]=e}this.attributes=i,this.observedAttributes=s,this.propertyLookup=n,this.attributeLookup=r,this.shadowOptions=void 0===e.shadowOptions?nt:null===e.shadowOptions?void 0:Object.assign(Object.assign({},nt),e.shadowOptions),this.elementOptions=void 0===e.elementOptions?rt:Object.assign(Object.assign({},rt),e.elementOptions),this.styles=void 0===e.styles?void 0:Array.isArray(e.styles)?K.create(e.styles):e.styles instanceof K?e.styles:K.create([e.styles])}get isDefined(){return!!ot.getByType(this.type)}define(t=customElements){const e=this.type;if(ot.register(this)){const t=this.attributes,i=e.prototype;for(let e=0,s=t.length;e<s;++e)p.defineProperty(i,t[e]);Reflect.defineProperty(e,"observedAttributes",{value:this.observedAttributes,enumerable:!0})}return t.get(this.name)||t.define(this.name,e,this.elementOptions),this}}lt.forType=ot.getByType;const at=new WeakMap,ht={bubbles:!0,composed:!0,cancelable:!0};function ct(t){return t.shadowRoot||at.get(t)||null}class ut extends f{constructor(t,e){super(t),this.boundObservables=null,this.behaviors=null,this.needsInitialization=!0,this._template=null,this._styles=null,this._isConnected=!1,this.$fastController=this,this.view=null,this.element=t,this.definition=e;const i=e.shadowOptions;if(void 0!==i){const e=t.attachShadow(i);"closed"===i.mode&&at.set(t,e)}const s=p.getAccessors(t);if(s.length>0){const e=this.boundObservables=Object.create(null);for(let i=0,n=s.length;i<n;++i){const n=s[i].name,r=t[n];void 0!==r&&(delete t[n],e[n]=r)}}}get isConnected(){return p.track(this,"isConnected"),this._isConnected}setIsConnected(t){this._isConnected=t,p.notify(this,"isConnected")}get template(){return this._template}set template(t){this._template!==t&&(this._template=t,this.needsInitialization||this.renderTemplate(t))}get styles(){return this._styles}set styles(t){this._styles!==t&&(null!==this._styles&&this.removeStyles(this._styles),this._styles=t,this.needsInitialization||null===t||this.addStyles(t))}addStyles(t){const e=ct(this.element)||this.element.getRootNode();if(t instanceof HTMLStyleElement)e.append(t);else if(!t.isAttachedTo(e)){const i=t.behaviors;t.addStylesTo(e),null!==i&&this.addBehaviors(i)}}removeStyles(t){const e=ct(this.element)||this.element.getRootNode();if(t instanceof HTMLStyleElement)e.removeChild(t);else if(t.isAttachedTo(e)){const i=t.behaviors;t.removeStylesFrom(e),null!==i&&this.removeBehaviors(i)}}addBehaviors(t){const e=this.behaviors||(this.behaviors=new Map),i=t.length,s=[];for(let n=0;n<i;++n){const i=t[n];e.has(i)?e.set(i,e.get(i)+1):(e.set(i,1),s.push(i))}if(this._isConnected){const t=this.element;for(let e=0;e<s.length;++e)s[e].bind(t,y)}}removeBehaviors(t,e=!1){const i=this.behaviors;if(null===i)return;const s=t.length,n=[];for(let r=0;r<s;++r){const s=t[r];if(i.has(s)){const t=i.get(s)-1;0===t||e?i.delete(s)&&n.push(s):i.set(s,t)}}if(this._isConnected){const t=this.element;for(let e=0;e<n.length;++e)n[e].unbind(t)}}onConnectedCallback(){if(this._isConnected)return;const t=this.element;this.needsInitialization?this.finishInitialization():null!==this.view&&this.view.bind(t,y);const e=this.behaviors;if(null!==e)for(const[i]of e)i.bind(t,y);this.setIsConnected(!0)}onDisconnectedCallback(){if(!this._isConnected)return;this.setIsConnected(!1);const t=this.view;null!==t&&t.unbind();const e=this.behaviors;if(null!==e){const t=this.element;for(const[i]of e)i.unbind(t)}}onAttributeChangedCallback(t,e,i){const s=this.definition.attributeLookup[t];void 0!==s&&s.onAttributeChangedCallback(this.element,i)}emit(t,e,i){return!!this._isConnected&&this.element.dispatchEvent(new CustomEvent(t,Object.assign(Object.assign({detail:e},ht),i)))}finishInitialization(){const t=this.element,e=this.boundObservables;if(null!==e){const i=Object.keys(e);for(let s=0,n=i.length;s<n;++s){const n=i[s];t[n]=e[n]}this.boundObservables=null}const i=this.definition;null===this._template&&(this.element.resolveTemplate?this._template=this.element.resolveTemplate():i.template&&(this._template=i.template||null)),null!==this._template&&this.renderTemplate(this._template),null===this._styles&&(this.element.resolveStyles?this._styles=this.element.resolveStyles():i.styles&&(this._styles=i.styles||null)),null!==this._styles&&this.addStyles(this._styles),this.needsInitialization=!1}renderTemplate(t){const e=this.element,i=ct(e)||e;null!==this.view?(this.view.dispose(),this.view=null):this.needsInitialization||u.removeChildNodes(i),t&&(this.view=t.render(e,i,e))}static forCustomElement(t){const e=t.$fastController;if(void 0!==e)return e;const i=lt.forType(t.constructor);if(void 0===i)throw new Error("Missing FASTElement definition.");return t.$fastController=new ut(t,i)}}function dt(t){return class extends t{constructor(){super(),ut.forCustomElement(this)}$emit(t,e,i){return this.$fastController.emit(t,e,i)}connectedCallback(){this.$fastController.onConnectedCallback()}disconnectedCallback(){this.$fastController.onDisconnectedCallback()}attributeChangedCallback(t,e,i){this.$fastController.onAttributeChangedCallback(t,e,i)}}}const ft=Object.assign(dt(HTMLElement),{from:t=>dt(t),define:(t,e)=>new lt(t,e).define().type});function pt(t){return function(e){new lt(e,t).define()}}class gt{createCSS(){return""}createBehavior(){}}function vt(t,e){const i=[];let s="";const n=[];for(let r=0,o=t.length-1;r<o;++r){s+=t[r];let o=e[r];if(o instanceof gt){const t=o.createBehavior();o=o.createCSS(),t&&n.push(t)}o instanceof K||o instanceof CSSStyleSheet?(""!==s.trim()&&(i.push(s),s=""),i.push(o)):s+=o}return s+=t[t.length-1],""!==s.trim()&&i.push(s),{styles:i,behaviors:n}}function mt(t,...e){const{styles:i,behaviors:s}=vt(t,e),n=K.create(i);return s.length&&n.withBehaviors(...s),n}class bt extends gt{constructor(t,e){super(),this.behaviors=e,this.css="";const i=t.reduce((t,e)=>("string"==typeof e?this.css+=e:t.push(e),t),[]);i.length&&(this.styles=K.create(i))}createBehavior(){return this}createCSS(){return this.css}bind(t){this.styles&&t.$fastController.addStyles(this.styles),this.behaviors.length&&t.$fastController.addBehaviors(this.behaviors)}unbind(t){this.styles&&t.$fastController.removeStyles(this.styles),this.behaviors.length&&t.$fastController.removeBehaviors(this.behaviors)}}function yt(t,...e){const{styles:i,behaviors:s}=vt(t,e);return new bt(i,s)}function Ct(t,e,i){return{index:t,removed:e,addedCount:i}}function wt(t,e,i,s,r,o){let l=0,a=0;const h=Math.min(i-e,o-r);if(0===e&&0===r&&(l=function(t,e,i){for(let s=0;s<i;++s)if(t[s]!==e[s])return s;return i}(t,s,h)),i===t.length&&o===s.length&&(a=function(t,e,i){let s=t.length,n=e.length,r=0;for(;r<i&&t[--s]===e[--n];)r++;return r}(t,s,h-l)),r+=l,o-=a,(i-=a)-(e+=l)==0&&o-r==0)return n;if(e===i){const t=Ct(e,[],0);for(;r<o;)t.removed.push(s[r++]);return[t]}if(r===o)return[Ct(e,[],i-e)];const c=function(t){let e=t.length-1,i=t[0].length-1,s=t[e][i];const n=[];for(;e>0||i>0;){if(0===e){n.push(2),i--;continue}if(0===i){n.push(3),e--;continue}const r=t[e-1][i-1],o=t[e-1][i],l=t[e][i-1];let a;a=o<l?o<r?o:r:l<r?l:r,a===r?(r===s?n.push(0):(n.push(1),s=r),e--,i--):a===o?(n.push(3),e--,s=o):(n.push(2),i--,s=l)}return n.reverse(),n}(function(t,e,i,s,n,r){const o=r-n+1,l=i-e+1,a=new Array(o);let h,c;for(let t=0;t<o;++t)a[t]=new Array(l),a[t][0]=t;for(let t=0;t<l;++t)a[0][t]=t;for(let i=1;i<o;++i)for(let r=1;r<l;++r)t[e+r-1]===s[n+i-1]?a[i][r]=a[i-1][r-1]:(h=a[i-1][r]+1,c=a[i][r-1]+1,a[i][r]=h<c?h:c);return a}(t,e,i,s,r,o)),u=[];let d=void 0,f=e,p=r;for(let t=0;t<c.length;++t)switch(c[t]){case 0:void 0!==d&&(u.push(d),d=void 0),f++,p++;break;case 1:void 0===d&&(d=Ct(f,[],0)),d.addedCount++,f++,d.removed.push(s[p]),p++;break;case 2:void 0===d&&(d=Ct(f,[],0)),d.addedCount++,f++;break;case 3:void 0===d&&(d=Ct(f,[],0)),d.removed.push(s[p]),p++}return void 0!==d&&u.push(d),u}const St=Array.prototype.push;function xt(t,e,i,s){const n=Ct(e,i,s);let r=!1,o=0;for(let e=0;e<t.length;e++){const i=t[e];if(i.index+=o,r)continue;const s=(l=n.index,a=n.index+n.removed.length,h=i.index,c=i.index+i.addedCount,a<h||c<l?-1:a===h||c===l?0:l<h?a<c?a-h:c-h:c<a?c-l:a-l);if(s>=0){t.splice(e,1),e--,o-=i.addedCount-i.removed.length,n.addedCount+=i.addedCount-s;const l=n.removed.length+i.removed.length-s;if(n.addedCount||l){let t=i.removed;if(n.index<i.index){const e=n.removed.slice(0,i.index-n.index);St.apply(e,t),t=e}if(n.index+n.removed.length>i.index+i.addedCount){const e=n.removed.slice(i.index+i.addedCount-n.index);St.apply(t,e)}n.removed=t,i.index<n.index&&(n.index=i.index)}else r=!0}else if(n.index<i.index){r=!0,t.splice(e,0,n),e++;const s=n.addedCount-n.removed.length;i.index+=s,o+=s}}var l,a,h,c;r||t.push(n)}function Ot(t,e){let i=[];const s=function(t){const e=[];for(let i=0,s=t.length;i<s;i++){const s=t[i];xt(e,s.index,s.removed,s.addedCount)}return e}(e);for(let e=0,n=s.length;e<n;++e){const n=s[e];1!==n.addedCount||1!==n.removed.length?i=i.concat(wt(t,n.index,n.index+n.addedCount,n.removed,0,n.removed.length)):n.removed[0]!==t[n.index]&&i.push(n)}return i}let Tt=!1;function kt(t,e){let i=t.index;const s=e.length;return i>s?i=s-t.addedCount:i<0&&(i=s+t.removed.length+i-t.addedCount),i<0&&(i=0),t.index=i,t}class Bt extends d{constructor(t){super(t),this.oldCollection=void 0,this.splices=void 0,this.needsQueue=!0,this.call=this.flush,Reflect.defineProperty(t,"$fastController",{value:this,enumerable:!1})}subscribe(t){this.flush(),super.subscribe(t)}addSplice(t){void 0===this.splices?this.splices=[t]:this.splices.push(t),this.needsQueue&&(this.needsQueue=!1,u.queueUpdate(this))}reset(t){this.oldCollection=t,this.needsQueue&&(this.needsQueue=!1,u.queueUpdate(this))}flush(){const t=this.splices,e=this.oldCollection;if(void 0===t&&void 0===e)return;this.needsQueue=!0,this.splices=void 0,this.oldCollection=void 0;const i=void 0===e?Ot(this.source,t):wt(this.source,0,this.source.length,e,0,e.length);this.notify(i)}}function Nt(){if(Tt)return;Tt=!0,p.setArrayObserverFactory(t=>new Bt(t));const t=Array.prototype;if(t.$fastPatch)return;Reflect.defineProperty(t,"$fastPatch",{value:1,enumerable:!1});const e=t.pop,i=t.push,s=t.reverse,n=t.shift,r=t.sort,o=t.splice,l=t.unshift;t.pop=function(){const t=this.length>0,i=e.apply(this,arguments),s=this.$fastController;return void 0!==s&&t&&s.addSplice(Ct(this.length,[i],0)),i},t.push=function(){const t=i.apply(this,arguments),e=this.$fastController;return void 0!==e&&e.addSplice(kt(Ct(this.length-arguments.length,[],arguments.length),this)),t},t.reverse=function(){let t;const e=this.$fastController;void 0!==e&&(e.flush(),t=this.slice());const i=s.apply(this,arguments);return void 0!==e&&e.reset(t),i},t.shift=function(){const t=this.length>0,e=n.apply(this,arguments),i=this.$fastController;return void 0!==i&&t&&i.addSplice(Ct(0,[e],0)),e},t.sort=function(){let t;const e=this.$fastController;void 0!==e&&(e.flush(),t=this.slice());const i=r.apply(this,arguments);return void 0!==e&&e.reset(t),i},t.splice=function(){const t=o.apply(this,arguments),e=this.$fastController;return void 0!==e&&e.addSplice(kt(Ct(+arguments[0],t,arguments.length>2?arguments.length-2:0),this)),t},t.unshift=function(){const t=l.apply(this,arguments),e=this.$fastController;return void 0!==e&&e.addSplice(kt(Ct(0,[],arguments.length),this)),t}}class At{constructor(t,e){this.target=t,this.propertyName=e}bind(t){t[this.propertyName]=this.target}unbind(){}}function $t(t){return new S("fast-ref",At,t)}function Rt(t,e){const i="function"==typeof e?e:()=>e;return(e,s)=>t(e,s)?i(e,s):null}const Pt=Object.freeze({positioning:!1,recycle:!0});function Et(t,e,i,s){t.bind(e[i],s)}function Vt(t,e,i,s){const n=Object.create(s);n.index=i,n.length=e.length,t.bind(e[i],n)}class jt{constructor(t,e,i,s,n,r){this.location=t,this.itemsBinding=e,this.templateBinding=s,this.options=r,this.source=null,this.views=[],this.items=null,this.itemsObserver=null,this.originalContext=void 0,this.childContext=void 0,this.bindView=Et,this.itemsBindingObserver=p.binding(e,this,i),this.templateBindingObserver=p.binding(s,this,n),r.positioning&&(this.bindView=Vt)}bind(t,e){this.source=t,this.originalContext=e,this.childContext=Object.create(e),this.childContext.parent=t,this.childContext.parentContext=this.originalContext,this.items=this.itemsBindingObserver.observe(t,this.originalContext),this.template=this.templateBindingObserver.observe(t,this.originalContext),this.observeItems(!0),this.refreshAllViews()}unbind(){this.source=null,this.items=null,null!==this.itemsObserver&&this.itemsObserver.unsubscribe(this),this.unbindAllViews(),this.itemsBindingObserver.disconnect(),this.templateBindingObserver.disconnect()}handleChange(t,e){t===this.itemsBinding?(this.items=this.itemsBindingObserver.observe(this.source,this.originalContext),this.observeItems(),this.refreshAllViews()):t===this.templateBinding?(this.template=this.templateBindingObserver.observe(this.source,this.originalContext),this.refreshAllViews(!0)):this.updateViews(e)}observeItems(t=!1){if(!this.items)return void(this.items=n);const e=this.itemsObserver,i=this.itemsObserver=p.getNotifier(this.items),s=e!==i;s&&null!==e&&e.unsubscribe(this),(s||t)&&i.subscribe(this)}updateViews(t){const e=this.childContext,i=this.views,s=this.bindView,n=this.items,r=this.template,o=this.options.recycle,l=[];let a=0,h=0;for(let c=0,u=t.length;c<u;++c){const u=t[c],d=u.removed;let f=0,p=u.index;const g=p+u.addedCount,v=i.splice(u.index,d.length);for(h=l.length+v.length;p<g;++p){const t=i[p],c=t?t.firstChild:this.location;let u;o&&h>0?(f<=h&&v.length>0?(u=v[f],f++):(u=l[a],a++),h--):u=r.create(),i.splice(p,0,u),s(u,n,p,e),u.insertBefore(c)}v[f]&&l.push(...v.slice(f))}for(let t=a,e=l.length;t<e;++t)l[t].dispose();if(this.options.positioning)for(let t=0,e=i.length;t<e;++t){const s=i[t].context;s.length=e,s.index=t}}refreshAllViews(t=!1){const e=this.items,i=this.childContext,s=this.template,n=this.location,r=this.bindView;let o=e.length,l=this.views,a=l.length;if(0!==o&&!t&&this.options.recycle||(D.disposeContiguousBatch(l),a=0),0===a){this.views=l=new Array(o);for(let t=0;t<o;++t){const o=s.create();r(o,e,t,i),l[t]=o,o.insertBefore(n)}}else{let t=0;for(;t<o;++t)if(t<a){r(l[t],e,t,i)}else{const o=s.create();r(o,e,t,i),l.push(o),o.insertBefore(n)}const h=l.splice(t,a-t);for(t=0,o=h.length;t<o;++t)h[t].dispose()}}unbindAllViews(){const t=this.views;for(let e=0,i=t.length;e<i;++e)t[e].unbind()}}class Ft extends C{constructor(t,e,i){super(),this.itemsBinding=t,this.templateBinding=e,this.options=i,this.createPlaceholder=u.createBlockPlaceholder,Nt(),this.isItemsBindingVolatile=p.isVolatileBinding(t),this.isTemplateBindingVolatile=p.isVolatileBinding(e)}createBehavior(t){return new jt(t,this.itemsBinding,this.isItemsBindingVolatile,this.templateBinding,this.isTemplateBindingVolatile,this.options)}}function zt(t,e,i=Pt){return new Ft(t,"function"==typeof e?e:()=>e,Object.assign(Object.assign({},Pt),i))}function It(t){return t?function(e,i,s){return 1===e.nodeType&&e.matches(t)}:function(t,e,i){return 1===t.nodeType}}class Mt{constructor(t,e){this.target=t,this.options=e,this.source=null}bind(t){const e=this.options.property;this.shouldUpdate=p.getAccessors(t).some(t=>t.name===e),this.source=t,this.updateTarget(this.computeNodes()),this.shouldUpdate&&this.observe()}unbind(){this.updateTarget(n),this.source=null,this.shouldUpdate&&this.disconnect()}handleEvent(){this.updateTarget(this.computeNodes())}computeNodes(){let t=this.getNodes();return void 0!==this.options.filter&&(t=t.filter(this.options.filter)),t}updateTarget(t){this.source[this.options.property]=t}}class _t extends Mt{constructor(t,e){super(t,e)}observe(){this.target.addEventListener("slotchange",this)}disconnect(){this.target.removeEventListener("slotchange",this)}getNodes(){return this.target.assignedNodes(this.options)}}function Lt(t){return"string"==typeof t&&(t={property:t}),new S("fast-slotted",_t,t)}class qt extends Mt{constructor(t,e){super(t,e),this.observer=null,e.childList=!0}observe(){null===this.observer&&(this.observer=new MutationObserver(this.handleEvent.bind(this))),this.observer.observe(this.target,this.options)}disconnect(){this.observer.disconnect()}getNodes(){return"subtree"in this.options?Array.from(this.target.querySelectorAll(this.options.selector)):Array.from(this.target.childNodes)}}function Ht(t){return"string"==typeof t&&(t={property:t}),new S("fast-children",qt,t)}class Dt{constructor(t){this.path=t}}const Qt=new Set,Ut=Object.freeze({register(t){Qt.add(t)},unregister(t){Qt.delete(t)}}),Wt=/^([a-z][a-z0-9+\-.]*:)?\/\//i,Kt=Object.freeze({path:Object.freeze({get current(){return location.pathname+location.search},generateRoute(e,i,s={}){return t(this,void 0,void 0,(function*(){let t="config"in e?e:xe.find(e);for(;null!==t;){const e=yield t.config.generateRouteFromPath(i,s);if(null!==e)return e;t=t.parent}return null}))},push(t,e=!0){t&&Wt.test(t)?location.href=t:(history.pushState({},document.title,t),e&&Kt.path.trigger(t))},replace(t,e=!0){t&&Wt.test(t)?location.href=t:(history.replaceState({},document.title,t),e&&Kt.path.trigger(t))},trigger(t){const e=new Dt(t);for(const t of Qt)t.enqueue(e)}}),name:Object.freeze({generateRoute(e,i,s={}){return t(this,void 0,void 0,(function*(){let t="config"in e?e:xe.find(e);for(;null!==t;){const e=yield t.config.generateRouteFromName(i,s);if(null!==e)return e;t=t.parent}return null}))},push(e,i,s={},n=!0){return t(this,void 0,void 0,(function*(){const t=yield Kt.name.generateRoute(e,i,s);null!==t&&Kt.path.push(t,n)}))},replace(e,i,s={},n=!0){return t(this,void 0,void 0,(function*(){const t=yield Kt.name.generateRoute(e,i,s);null!==t&&Kt.path.replace(t,n)}))},trigger(e,i,s={}){return t(this,void 0,void 0,(function*(){const t=yield Kt.name.generateRoute(e,i,s);null!==t&&Kt.path.trigger(t)}))}})});class Jt{constructor(){this.queue=[],this.promise=null,this.resolve=null}connect(){this.enqueue(new Dt(Kt.path.current)),window.addEventListener("popstate",this),Ut.register(this)}disconnect(){this.queue=[],this.promise=null,this.resolve=null,window.removeEventListener("popstate",this),Ut.unregister(this)}receive(){return null!==this.promise||(this.promise=new Promise(t=>this.resolve=t),Promise.resolve().then(()=>this.tryDequeue())),this.promise}enqueue(t){this.queue.push(t),this.tryDequeue()}tryDequeue(){if(null===this.resolve||0===this.queue.length)return;const t=this.queue[this.queue.length-1],e=this.resolve;this.queue.length=0,this.promise=null,this.resolve=null,e(t)}handleEvent(t){this.enqueue(new Dt(Kt.path.current))}}const Gt=encodeURIComponent,Xt=t=>Gt(t).replace("%24","$");function Yt(t,e,i){let s=[];if(null==e)return s;if(Array.isArray(e))for(let n=0,r=e.length;n<r;n++)if(i)s.push(`${Xt(t)}=${Gt(e[n])}`);else{const i=t+"["+("object"==typeof e[n]&&null!==e[n]?n:"")+"]";s=s.concat(Yt(i,e[n]))}else if("object"!=typeof e||i)s.push(`${Xt(t)}=${Gt(e)}`);else for(const i in e)s=s.concat(Yt(t+"["+i+"]",e[i]));return s}function Zt(t,e){return Array.isArray(t)?(t.push(e),t):void 0!==t?[t,e]:e}function te(t,e,i){let s=t;const n=e.length-1;for(let t=0;t<=n;t++){const r=""===e[t]?s.length:e[t];if(t<n){const i=s[r]&&"object"!=typeof s[r]?[s[r]]:s[r];s=s[r]=i||(isNaN(e[t+1])?{}:[])}else s=s[r]=i}}const ee=Object.freeze({get current(){return location.search},build(t,e){let i=[];const s=Object.keys(t||{}).sort();for(let n=0,r=s.length;n<r;n++){const r=s[n];i=i.concat(Yt(r,t[r],e))}return 0===i.length?"":i.join("&")},separate(t){const e=t.indexOf("?");let i="";return-1!==e&&(i=t.substr(e+1,t.length),t=t.substr(0,e)),{path:t,queryString:i}},parse(t){const e={};if(!t||"string"!=typeof t)return e;let i=t;"?"===i.charAt(0)&&(i=i.substr(1));const s=i.replace(/\+/g," ").split("&");for(let t=0;t<s.length;t++){const i=s[t].split("="),n=decodeURIComponent(i[0]);if(!n)continue;let r=n.split("]["),o=r.length-1;if(/\[/.test(r[0])&&/\]$/.test(r[o])?(r[o]=r[o].replace(/\]$/,""),r=r.shift().split("[").concat(r),o=r.length-1):o=0,i.length>=2){const t=i[1]?decodeURIComponent(i[1]):"";o?te(e,r,t):e[n]=Zt(e[n],t)}else e[n]=!0}return e}}),ie=t=>t;class se{constructor(t,e,i){this.path=t,this.name=e,this.caseSensitive=i}}class ne{constructor(t,e,i,s){this.route=t,this.paramNames=e,this.paramTypes=i,this.settings=s}get path(){return this.route.path}}class re{constructor(t,e,i,s){this.endpoint=t,this.params=e,this.typedParams=i,this.queryParams=s,this.allParams=Object.assign(Object.assign({},e),s),this.allTypedParams=Object.assign(Object.assign({},i),s)}get settings(){return this.endpoint.settings}}class oe{constructor(t,e,i,s){var n;this.chars=t,this.states=e,this.skippedStates=i,this.result=s,this.head=e[e.length-1],this.endpoint=null===(n=this.head)||void 0===n?void 0:n.endpoint}advance(t){const{chars:e,states:i,skippedStates:s,result:n}=this;let r=null,o=0;const l=i[i.length-1];function a(h,c){if(h.isMatch(t)&&(1==++o?r=h:n.add(new oe(e.concat(t),i.concat(h),null===c?s:s.concat(c),n))),null===l.segment&&h.isOptional&&null!==h.nextStates){if(h.nextStates.length>1)throw new Error(h.nextStates.length+" nextStates");const t=h.nextStates[0];if(!t.isSeparator)throw new Error("Not a separator");if(null!==t.nextStates)for(const e of t.nextStates)a(e,h)}}if(l.isDynamic&&a(l,null),null!==l.nextStates)for(const t of l.nextStates)a(t,null);null!==r&&(i.push(this.head=r),e.push(t),null!==r.endpoint&&(this.endpoint=r.endpoint)),0===o&&n.remove(this)}finalize(){!function t(e,i){const s=i.nextStates;if(null!==s)if(1===s.length&&null===s[0].segment)t(e,s[0]);else for(const i of s)if(i.isOptional&&null!==i.endpoint){if(e.push(i),null!==i.nextStates)for(const s of i.nextStates)t(e,s);break}}(this.skippedStates,this.head)}getParams(){const{states:t,chars:e,endpoint:i}=this,s={};for(const t of i.paramNames)s[t]=void 0;for(let i=0,n=t.length;i<n;++i){const n=t[i];if(n.isDynamic){const t=n.segment.name;void 0===s[t]?s[t]=e[i]:s[t]+=e[i]}}return s}compareTo(t){const e=this.states,i=t.states;for(let t=0,s=0,n=Math.max(e.length,i.length);t<n;++t){let n=e[t];if(void 0===n)return 1;let r=i[s];if(void 0===r)return-1;let o=n.segment,l=r.segment;if(null===o){if(null===l){++s;continue}if(void 0===(n=e[++t]))return 1;o=n.segment}else if(null===l){if(void 0===(r=i[++s]))return-1;l=r.segment}if(o.kind<l.kind)return 1;if(o.kind>l.kind)return-1;++s}const s=this.skippedStates,n=t.skippedStates,r=s.length,o=n.length;if(r<o)return 1;if(r>o)return-1;for(let t=0;t<r;++t){const e=s[t],i=n[t];if(e.length<i.length)return 1;if(e.length>i.length)return-1}return 0}}function le(t){return null!==t.head.endpoint}function ae(t,e){return t.compareTo(e)}class he{constructor(t){this.candidates=[],this.candidates=[new oe([""],[t],[],this)]}get isEmpty(){return 0===this.candidates.length}getSolution(){const t=this.candidates.filter(le);if(0===t.length)return null;for(const e of t)e.finalize();return t.sort(ae),t[0]}add(t){this.candidates.push(t)}remove(t){this.candidates.splice(this.candidates.indexOf(t),1)}advance(t){const e=this.candidates.slice();for(const i of e)i.advance(t)}}class ce{constructor(){this.names=new Map,this.paths=new Map,this.rootState=new ue(null,null,"")}add(t,e){if(t instanceof Array)for(const i of t)this.$add(i,e);else this.$add(t,e)}$add(t,e){const i=t.path,s=new se(t.path,t.name||"",!0===t.caseSensitive),n=""===i?[""]:i.split("/").filter(de),r=[],o=[];let l=this.rootState;const a=[];for(const t of n)switch(l=l.append(null,"/"),t.charAt(0)){case"{":{const e=t.slice(1,-1).split(":").map(t=>t.trim());2===e.length?o.push(e[1]):o.push("string");const i=e[0].endsWith("?"),s=i?e[0].slice(0,-1):e[0];r.push(s);const n=new pe(s,i);a.push(n),l=n.appendTo(l);break}case"*":{const e=t.slice(1);r.push(e),o.push("string");const i=new ge(e);a.push(i),l=i.appendTo(l);break}default:{const e=new fe(t,s.caseSensitive);a.push(e),l=e.appendTo(l);break}}const h=new ne(s,r,o,e||null);l.setEndpoint(h),this.paths.set(i,a),t.name&&this.names.set(t.name,a)}recognize(e,i={}){return t(this,void 0,void 0,(function*(){const t=ee.separate(e),s=ee.parse(t.queryString);(e=decodeURI(t.path)).startsWith("/")||(e="/"+e),e.length>1&&e.endsWith("/")&&(e=e.slice(0,-1));const n=new he(this.rootState);for(let t=0,i=e.length;t<i;++t){const i=e.charAt(t);if(n.advance(i),n.isEmpty)return null}const r=n.getSolution();if(null===r)return null;const{endpoint:o}=r,l=o.paramNames,a=o.paramTypes,h=r.getParams(),c={};for(let t=0,e=l.length;t<e;++t){const e=l[t],s=i[a[t]]||ie,n=h[e],r=yield s(n);c[e]=r}return new re(o,h,c,s)}))}generateFromName(t,e){return this.generate(this.names.get(t),e)}generateFromPath(t,e){return this.generate(this.paths.get(t),e)}generate(t,e){if(!t)return null;const i=Object.assign({},e),s={};let n="";for(let e=0,r=t.length;e<r;e++){const r=t[e],o=r.generate(i,s);if(null==o){if(r instanceof pe&&!r.optional)throw new Error(`A value is required for route parameter '${r.name}'.`)}else n+="/",n+=o}"/"!==n.charAt(0)&&(n="/"+n);for(const t in s)delete i[t];const r=ee.build(i);return n+=r?"?"+r:"",n}}class ue{constructor(t,e,i){switch(this.prevState=t,this.segment=e,this.value=i,this.nextStates=null,this.endpoint=null,null==e?void 0:e.kind){case 2:this.length=t.length+1,this.isSeparator=!1,this.isDynamic=!0,this.isOptional=e.optional;break;case 1:this.length=t.length+1,this.isSeparator=!1,this.isDynamic=!0,this.isOptional=!1;break;case 3:this.length=t.length+1,this.isSeparator=!1,this.isDynamic=!1,this.isOptional=!1;break;case void 0:this.length=null===t?0:t.length,this.isSeparator=!0,this.isDynamic=!1,this.isOptional=!1}}append(t,e){let i,s=this.nextStates;return null===s?(i=void 0,s=this.nextStates=[]):i=null===t?s.find(t=>t.value===e):s.find(e=>{var i;return null===(i=e.segment)||void 0===i?void 0:i.equals(t)}),void 0===i&&s.push(i=new ue(this,t,e)),i}setEndpoint(t){if(null!==this.endpoint)throw new Error(`Cannot add ambiguous route. The pattern '${t.route.path}' clashes with '${this.endpoint.route.path}'`);this.endpoint=t,this.isOptional&&(this.prevState.setEndpoint(t),this.prevState.isSeparator&&null!==this.prevState.prevState&&this.prevState.prevState.setEndpoint(t))}isMatch(t){const e=this.segment;switch(null==e?void 0:e.kind){case 2:return!this.value.includes(t);case 1:return!0;case 3:case void 0:return this.value.includes(t)}}}function de(t){return t.length>0}class fe{constructor(t,e){this.value=t,this.caseSensitive=e}get kind(){return 3}appendTo(t){const{value:e,value:{length:i}}=this;if(this.caseSensitive)for(let s=0;s<i;++s)t=t.append(this,e.charAt(s));else for(let s=0;s<i;++s){const i=e.charAt(s);t=t.append(this,i.toUpperCase()+i.toLowerCase())}return t}generate(){return this.value}equals(t){return 3===t.kind&&t.caseSensitive===this.caseSensitive&&t.value===this.value}}class pe{constructor(t,e){this.name=t,this.optional=e}get kind(){return 2}appendTo(t){return t=t.append(this,"/")}generate(t,e){return e[this.name]=!0,t[this.name]}equals(t){return 2===t.kind&&t.optional===this.optional&&t.name===this.name}}class ge{constructor(t){this.name=t}get kind(){return 1}appendTo(t){return t=t.append(this,"")}generate(t,e){return e[this.name]=!0,t[this.name]}equals(t){return 1===t.kind&&t.name===this.name}}const ve="fast-child-route";function me(t,e){return"command"in e?e.command:"redirect"in e?new Fe(e.redirect):_e.fromDefinition(t,e)}const be=t=>{if(null==t)return!1;switch(t.toLowerCase().trim()){case"true":case"yes":case"1":return!0;default:return!1}},ye={number:t=>void 0===t?NaN:parseFloat(t),float:t=>void 0===t?NaN:parseFloat(t),int:t=>void 0===t?NaN:parseInt(t),integer:t=>void 0===t?NaN:parseInt(t),Date:t=>void 0===t?new Date(Date.now()):new Date(t),boolean:be,bool:be};class Ce{constructor(t){this.owner=t,this._recognizer=null,this.pathToCommand=new Map,this.fallbackCommand=null,this.fallbackSettings=null,this.converters={}}get recognizer(){return null===this._recognizer&&(this._recognizer=this.owner.createRouteRecognizer()),this._recognizer}ignore(t){"string"==typeof t&&(t={path:t}),this.pathToCommand.set(t.path,new je),this.recognizer.add(t,t.settings)}map(...t){for(const e of t){if("children"in e){const t=this.owner.createTitleBuilder(),i=e.children.map(i=>{const s=Object.assign(Object.assign(Object.assign({},e),i),{path:`${e.path}/${i.path}`});if("title"in e||"title"in i){const n=e.title||"",r=i.title||"";s.title=t.joinTitles(n,r)}if("name"in i){const t=e.name?e.name+"/":"";s.name=t+i.name}return s.children===e.children&&delete s.children,s});this.map(...i);continue}let t;if(t="command"in e?e.command:"redirect"in e?new Fe(e.redirect):_e.fromDefinition(this.owner,e),this.pathToCommand.set(e.path,t),this.recognizer.add(e,e.settings),"childRouters"in e&&e.childRouters){const i=Object.assign(Object.assign({},e),{path:e.path+"/*fast-child-route"});this.pathToCommand.set(i.path,t),this.recognizer.add(i,i.settings)}}}fallback(e){const i=this.owner;this.fallbackCommand="function"==typeof e?{createContributor(s,n){return t(this,void 0,void 0,(function*(){const t=yield e();return me(i,t).createContributor(s,n)}))}}:me(i,e)}converter(t,e){let i;i="convert"in e?e.convert.bind(e):e.prototype&&"convert"in e.prototype?t=>this.owner.construct(e).convert(t):e,this.converters[t]=i}recognize(e){return t(this,void 0,void 0,(function*(){const t=yield this.recognizer.recognize(e,this.aggregateConverters());if(null!==t)return{route:t,command:this.pathToCommand.get(t.endpoint.path)};if(null!==this.fallbackCommand){const t=ee.separate(e),i=ee.parse(t.queryString);return{route:new re(new ne(new se("*","",!1),[],[],this.fallbackSettings),{},{},i),command:this.fallbackCommand}}return null}))}generateFromName(t,e){return this.recognizer.generateFromName(t,e)}generateFromPath(t,e){return this.recognizer.generateFromPath(t,e)}aggregateConverters(){return null===this.owner.parent?Object.assign(Object.assign({},ye),this.converters):Object.assign(Object.assign({},this.owner.parent.routes.aggregateConverters()),this.converters)}}function we(t){const e=t.parentElement;if(e)return e;{const e=t.getRootNode();if(e.host instanceof HTMLElement)return e.host}return null}function Se(t){let e=t;for(;e=we(e);)if("$router"in e)return e.$router;return null}const xe=Object.freeze({getOrCreateFor(t){const e=t.$router;return void 0!==e?e:t.$router=new Te(t)},find:t=>t.$router||Se(t),from(t){class e extends t{constructor(){super(),xe.getOrCreateFor(this)}get config(){return this.$router.config}set config(t){this.$router.config=t}}const i=e.prototype;if("connectedCallback"in i){const t=i.connectedCallback;i.connectedCallback=function(){t.call(this),this.$router.connect()}}else i.connectedCallback=function(){this.$router.connect()};if("disconnectedCallback"in i){const t=i.disconnectedCallback;i.disconnectedCallback=function(){t.call(this),this.$router.disconnect()}}else i.disconnectedCallback=function(){this.$router.disconnect()};return e}});function Oe(t){return t instanceof ft}class Te{constructor(e){this.host=e,this.parentRouter=void 0,this.contributors=new Set,this.navigationQueue=null,this.linkHandler=null,this.newView=null,this.newRoute=null,this.childCommandContributor=null,this.childRoute=null,this.isConnected=!1,this.routerConfig=null,this.view=null,this.route=null,this.onNavigationMessage=e=>t(this,void 0,void 0,(function*(){const t=this.config.createNavigationProcess();yield t.run(this,e),this.navigationQueue.receive().then(this.onNavigationMessage)})),e.$router=this}get config(){return this.routerConfig}set config(t){this.routerConfig=t,this.tryConnect()}get parent(){if(void 0===this.parentRouter){if(!this.isConnected)return null;this.parentRouter=Se(this.host)}return this.parentRouter||null}get level(){return null===this.parent?0:this.parent.level+1}shouldRender(t){var e;if(this.route&&this.route.endpoint.path===t.endpoint.path){const i=null==t?void 0:t.allParams,s=null===(e=this.route)||void 0===e?void 0:e.allParams;if(JSON.stringify(s)===JSON.stringify(i))return!1}return!0}beginRender(e,i){return t(this,void 0,void 0,(function*(){return this.newRoute=e,this.newView=yield i.createView(),this.newView.bind(e.allTypedParams,ke.create(this)),this.newView.appendTo(this.host),yield i.transition.begin(this.host,this.view,this.newView),{commit:this.renderOperationCommit.bind(this,i.layout,i.transition),rollback:this.renderOperationRollback.bind(this,i.transition)}}))}connect(){this.isConnected=!0,this.tryConnect()}disconnect(){null===this.parent?(null!==this.navigationQueue&&(this.navigationQueue.disconnect(),this.navigationQueue=null),null!==this.linkHandler&&(this.linkHandler.disconnect(),this.linkHandler=null)):this.parent.removeContributor(this),this.isConnected=!1,this.parentRouter=void 0}addContributor(t){this.contributors.add(t)}removeContributor(t){this.contributors.delete(t)}tryConnect(){null!==this.config&&this.isConnected&&(null===this.parent?(null!==this.navigationQueue&&this.navigationQueue.disconnect(),this.navigationQueue=this.config.createNavigationQueue(),this.navigationQueue.connect(),this.navigationQueue.receive().then(this.onNavigationMessage),null!==this.linkHandler&&this.linkHandler.disconnect(),this.linkHandler=this.config.createLinkHandler(),this.linkHandler.connect()):(this.config.parent=this.parent.config,this.parent.addContributor(this)))}renderOperationCommit(e,i){return t(this,void 0,void 0,(function*(){yield e.beforeCommit(this.host),yield i.commit(this.host,this.view,this.newView),yield e.afterCommit(this.host),null!==this.view&&this.view.dispose(),this.route=this.newRoute,this.view=this.newView,this.newRoute=null,this.newView=null}))}renderOperationRollback(e){return t(this,void 0,void 0,(function*(){null!==this.newView&&(yield e.rollback(this.host,this.view,this.newView),this.newView.dispose(),this.newRoute=null,this.newView=null)}))}navigate(e){return t(this,void 0,void 0,(function*(){yield this.tunnel(e)}))}leave(e){return t(this,void 0,void 0,(function*(){if(yield this.tunnel(e),!e.canceled){const t=this.contributors;this.contributors=new Set,e.onCancel(()=>this.contributors=t)}}))}construct(e){return t(this,void 0,void 0,(function*(){if(null!==this.parent){const t=e.route.allParams["fast-child-route"]||"",i=yield this.config.recognizeRoute(t);if(null===i){return this.config.createEventSink().onUnhandledNavigationMessage(this,new Dt(t)),void e.cancel()}this.childRoute=i.route,this.childCommandContributor=yield i.command.createContributor(this,i.route)}yield this.tunnel(e)}))}enter(e){return t(this,void 0,void 0,(function*(){yield this.tunnel(e)}))}commit(e){return t(this,void 0,void 0,(function*(){yield this.tunnel(e)}))}tunnel(e){return t(this,void 0,void 0,(function*(){const t=this.childRoute,i=this.childCommandContributor;if(t&&i&&(yield e.evaluateContributor(i,t,this)),e.canceled)return;const s=[...this.config.findContributors(e.name),...Array.from(this.contributors)];for(const t of s)if(yield e.evaluateContributor(t,void 0,this),e.canceled)return}))}}const ke=Object.freeze({create:t=>Object.create(y,{router:{value:t}})}),Be=Object.freeze({default:Object.freeze({begin(e,i,s){return t(this,void 0,void 0,(function*(){}))},rollback(e,i,s){return t(this,void 0,void 0,(function*(){}))},commit(e,i,s){return t(this,void 0,void 0,(function*(){}))}})});class Ne{constructor(t=null,e=null,i=!0){this.template=t,this.runBeforeCommit=i,this.styles=null==e?null:Array.isArray(e)?K.create(e):e instanceof K?e:K.create([e])}beforeCommit(e){return t(this,void 0,void 0,(function*(){this.runBeforeCommit&&this.apply(e)}))}afterCommit(e){return t(this,void 0,void 0,(function*(){this.runBeforeCommit||this.apply(e)}))}apply(t){Oe(t)&&(t.$fastController.template!==this.template&&(t.$fastController.template=this.template),t.$fastController.styles!==this.styles&&(t.$fastController.styles=this.styles))}}const Ae=Object.freeze({default:new Ne(W`<slot></slot>`)});function $e(t,e){return e in t}const Re={lifecycle:!0,parameters:!0};class Pe extends C{constructor(t){super(),this.options=t}createPlaceholder(t){return u.createCustomAttributePlaceholder("fast-navigation-contributor",t)}createBehavior(t){return new Ee(t,this.options)}}class Ee{constructor(t,e){this.contributor=t,this.options=e,this.router=null}bind(t,e){if(this.options.lifecycle&&(this.router=e.router||xe.find(this.contributor),this.router.addContributor(this.contributor)),this.options.parameters){const e=this.contributor,i=t;for(const t in i)e[t]=i[t]}}unbind(t){null!==this.router&&this.router.removeContributor(this.contributor)}}function Ve(t){return new Pe(Object.assign({},Re,t))}class je{createContributor(){return t(this,void 0,void 0,(function*(){return{navigate(e){return t(this,void 0,void 0,(function*(){e.cancel()}))}}}))}}class Fe{constructor(t){this.redirect=t}createContributor(){return t(this,void 0,void 0,(function*(){const e=this.redirect;return{navigate(i){return t(this,void 0,void 0,(function*(){const s=i.router.config,n=(yield s.generateRouteFromName(e,i.route.allParams))||(yield s.generateRouteFromPath(e,i.route.allParams));if(null===n)throw new Error("Invalid redirect. Name or path not found: "+e);i.cancel(()=>t(this,void 0,void 0,(function*(){return Kt.path.replace(n)})))}))}}}))}}function ze(t){return W`<${t} ${Ve()}></${t}>`}function Ie(t){const e=document.createDocumentFragment();e.appendChild(t);const i=new D(e,[Ve().createBehavior(t)]);return{create:()=>i}}class Me{constructor(t,e,i){this.router=t,this.route=e,this.command=i}construct(e){return t(this,void 0,void 0,(function*(){this.router.shouldRender(this.route)?(this.operation=yield this.router.beginRender(this.route,this.command),e.onCancel(()=>this.operation.rollback())):e.cancel()}))}commit(e){return t(this,void 0,void 0,(function*(){yield this.operation.commit(),this.command.title&&e.setTitle(this.command.title)}))}}class _e{constructor(t,e){this.owner=t,this.createView=e,this._layout=null,this._transition=null,this.title=""}get transition(){return this._transition||this.owner.defaultTransition}set transition(t){this._transition=t}get layout(){return this._layout||this.owner.defaultLayout}set layout(t){this._layout=t}createContributor(e,i){return t(this,void 0,void 0,(function*(){return new Me(e,i,this)}))}static fromDefinition(e,i){let s;s="template"in i?()=>t(this,void 0,void 0,(function*(){let t=i.template;return"function"==typeof t&&(t=yield t()),t.create()})):()=>t(this,void 0,void 0,(function*(){let t=i.element,e=null;if(i.factory)e=i.factory;else if("function"==typeof t){let i=lt.forType(t);if(i)e=ze(i.name);else if(t=yield t(),"string"==typeof t)e=ze(t);else if(t instanceof HTMLElement)e=Ie(t);else{if(i=lt.forType(t),!i)throw new Error("Invalid value for element in route config.");e=ze(i.name)}}else t instanceof HTMLElement?i.factory=e=Ie(t):i.factory=e=ze(t);return e.create()}));const n=new _e(e,s);return i.layout&&(i.layout instanceof Q?n.layout=new Ne(i.layout):n.layout=i.layout),i.transition&&(n.transition=i.transition),i.title&&(n.title=i.title),n}}class Le{constructor(){this.handler=t=>{const{shouldHandleEvent:e,href:i}=this.getEventInfo(t);e&&(t.preventDefault(),Kt.path.push(i))}}connect(){window.addEventListener("click",this.handler,!0)}disconnect(){window.removeEventListener("click",this.handler)}getEventInfo(t){const e={shouldHandleEvent:!1,href:null,anchor:null},i=this.findClosestAnchor(t);if(!i||!this.targetIsThisWindow(i))return e;if(i.hasAttribute("download")||i.hasAttribute("router-ignore")||i.hasAttribute("data-router-ignore"))return e;if(t.altKey||t.ctrlKey||t.metaKey||t.shiftKey)return e;const s=i.getAttribute("href");e.anchor=i,e.href=s;const n=1===t.which,r=s&&!("#"===s.charAt(0)||/^[a-z]+:/i.test(s));return e.shouldHandleEvent=n&&!!r,e}findClosestAnchor(t){const e=t.composedPath();for(let t=0,i=e.length;t<i;++t){const i=e[t];if("A"===i.tagName)return i}return t.target}targetIsThisWindow(t){const e=t.getAttribute("target");return!e||e===window.name||"_self"===e}}class qe{constructor(t,e,i,s,n){this.name=t,this.commitActions=s,this.cancelActions=n,this.routes=[],this.routers=[],this.canceled=!1,this.titles=[],this.routes.push(e),this.routers.push(i)}get route(){return this.routes[this.routes.length-1]}get router(){return this.routers[this.routers.length-1]}cancel(t){this.canceled=!0,t&&this.cancelActions.push(t)}onCommit(t){this.commitActions.push(t)}onCancel(t){this.cancelActions.push(t)}setTitle(t){const e=this.router.level;for(;this.titles.length<e+1;)this.titles.push([]);this.titles[e].push(t)}evaluateContributor(e,i=this.route,s=this.router){return t(this,void 0,void 0,(function*(){$e(e,this.name)&&(this.routes.push(i),this.routers.push(s),yield e[this.name](this),this.routes.pop(),this.routers.pop())}))}}class He{constructor(){this.phases=["navigate","leave","construct","enter","commit"]}run(e,i){return t(this,void 0,void 0,(function*(){const t=e.config.createEventSink(),s=yield e.config.recognizeRoute(i.path);if(null===s)return void t.onUnhandledNavigationMessage(e,i);const n=s.route,r=s.command;t.onNavigationBegin(e,n,r);const o=[],l=[];let a=o;const h=[yield r.createContributor(e,n),e,this];for(const i of this.phases){const s=new qe(i,n,e,o,l);if(t.onPhaseBegin(s),s.canceled)a=l;else for(const t of h)if(yield s.evaluateContributor(t),s.canceled){a=l;break}if(t.onPhaseEnd(s),s.canceled)break}yield Promise.all(a.map(t=>t())).then(()=>t.onNavigationEnd(e,n,r))}))}commit(t){const e=t.router.config.createTitleBuilder();document.title=e.buildTitle(t.router.config.title,t.titles)}}class De{constructor(t=" - ",e=":"){this.segmentSeparator=t,this.fragmentSeparator=e}joinTitles(t,e){return""===t?e:""===e?t:`${t}${this.segmentSeparator}${e}`}buildTitle(t,e){let i=t;for(const t of e){i&&(i+=this.segmentSeparator);let e="";for(const i of t)e&&(e+=this.fragmentSeparator),e+=i;i+=e}return i}}class Qe{onUnhandledNavigationMessage(t,e){}onNavigationBegin(t,e,i){}onPhaseBegin(t){}onPhaseEnd(t){}onNavigationEnd(t,e,i){}}class Ue{constructor(){this.isConfigured=!1,this.routes=new Ce(this),this.contributors=[],this.defaultLayout=Ae.default,this.defaultTransition=Be.default,this.title="",this.parent=null}createNavigationQueue(){return this.construct(Jt)}createLinkHandler(){return this.construct(Le)}createNavigationProcess(){return new He}createEventSink(){return this.construct(Qe)}createTitleBuilder(){return this.construct(De)}createRouteRecognizer(){return this.construct(ce)}construct(t){return null!==this.parent?this.parent.construct(t):new t}recognizeRoute(e){return t(this,void 0,void 0,(function*(){return yield this.ensureConfigured(),this.routes.recognize(e)}))}generateRouteFromName(e,i){return t(this,void 0,void 0,(function*(){return yield this.ensureConfigured(),this.routes.generateFromName(e,i)}))}generateRouteFromPath(e,i){return t(this,void 0,void 0,(function*(){return yield this.ensureConfigured(),this.routes.generateFromPath(e,i)}))}findContributors(t){return this.contributors.filter(e=>$e(e,t))}cached(e){let i=null;return()=>t(this,void 0,void 0,(function*(){return null===i&&(i=new e),i}))}ensureConfigured(){return t(this,void 0,void 0,(function*(){this.isConfigured||(yield this.configure(),this.isConfigured=!0)}))}}let We=class extends(xe.from(ft)){};We=function(t,e,i,s){var n,r=arguments.length,o=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var l=t.length-1;l>=0;l--)(n=t[l])&&(o=(r<3?n(o):r>3?n(e,i,o):n(e,i))||o);return r>3&&o&&Object.defineProperty(e,i,o),o}([pt("fast-router")],We);export{e as $global,S as AttachedBehaviorHTMLDirective,it as AttributeDefinition,V as BindingBehavior,gt as CSSDirective,qt as ChildrenBehavior,se as ConfigurableRoute,ut as Controller,u as DOM,Le as DefaultLinkHandler,He as DefaultNavigationProcess,Jt as DefaultNavigationQueue,ce as DefaultRouteRecognizer,Te as DefaultRouter,K as ElementStyles,ne as Endpoint,b as ExecutionContext,s as FAST,ft as FASTElement,lt as FASTElementDefinition,Ne as FASTElementLayout,We as FASTRouter,E as HTMLBindingDirective,C as HTMLDirective,D as HTMLView,je as Ignore,Ae as Layout,Ut as NavigationHandler,Dt as NavigationMessage,p as Observable,f as PropertyChangeNotifier,ee as QueryString,re as RecognizedRoute,Fe as Redirect,At as RefBehavior,_e as Render,jt as RepeatBehavior,Ft as RepeatDirective,Kt as Route,Ce as RouteCollection,xe as Router,Ue as RouterConfiguration,ke as RouterExecutionContext,_t as SlottedBehavior,d as SubscriberSet,w as TargetedHTMLDirective,Be as Transition,Q as ViewTemplate,st as attr,tt as booleanConverter,ve as childRouteParameter,Ht as children,q as compileTemplate,mt as css,yt as cssPartial,pt as customElement,y as defaultExecutionContext,It as elements,n as emptyArray,Nt as enableArrayObservation,W as html,Oe as isFASTElementHost,$e as isNavigationPhaseContributor,Ve as navigationContributor,et as nullableNumberConverter,g as observable,$t as ref,zt as repeat,Lt as slotted,v as volatile,Rt as when};
1
+ function t(t,e,i,s){return new(i||(i=Promise))((function(n,r){function o(t){try{a(s.next(t))}catch(t){r(t)}}function l(t){try{a(s.throw(t))}catch(t){r(t)}}function a(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,l)}a((s=s.apply(t,e||[])).next())}))}const e=function(){if("undefined"!=typeof globalThis)return globalThis;if("undefined"!=typeof global)return global;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;try{return new Function("return this")()}catch(t){return{}}}();void 0===e.trustedTypes&&(e.trustedTypes={createPolicy:(t,e)=>e});const i={configurable:!1,enumerable:!1,writable:!1};void 0===e.FAST&&Reflect.defineProperty(e,"FAST",Object.assign({value:Object.create(null)},i));const s=e.FAST;if(void 0===s.getById){const t=Object.create(null);Reflect.defineProperty(s,"getById",Object.assign({value(e,i){let s=t[e];return void 0===s&&(s=i?t[e]=i():null),s}},i))}const n=Object.freeze([]);function r(){const t=new WeakMap;return function(e){let i=t.get(e);if(void 0===i){let s=Reflect.getPrototypeOf(e);for(;void 0===i&&null!==s;)i=t.get(s),s=Reflect.getPrototypeOf(s);i=void 0===i?[]:i.slice(0),t.set(e,i)}return i}}const o=e.FAST.getById(1,()=>{const t=[],i=[];function s(){if(i.length)throw i.shift()}function n(t){try{t.call()}catch(t){i.push(t),setTimeout(s,0)}}function r(){let e=0;for(;e<t.length;)if(n(t[e]),e++,e>1024){for(let i=0,s=t.length-e;i<s;i++)t[i]=t[i+e];t.length-=e,e=0}t.length=0}return Object.freeze({enqueue:function(i){t.length<1&&e.requestAnimationFrame(r),t.push(i)},process:r})}),l=e.trustedTypes.createPolicy("fast-html",{createHTML:t=>t});let a=l;const h="fast-"+Math.random().toString(36).substring(2,8),c=h+"{",u="}"+h,d=Object.freeze({supportsAdoptedStyleSheets:Array.isArray(document.adoptedStyleSheets)&&"replace"in CSSStyleSheet.prototype,setHTMLPolicy(t){if(a!==l)throw new Error("The HTML policy can only be set once.");a=t},createHTML:t=>a.createHTML(t),isMarker:t=>t&&8===t.nodeType&&t.data.startsWith(h),extractDirectiveIndexFromMarker:t=>parseInt(t.data.replace(h+":","")),createInterpolationPlaceholder:t=>`${c}${t}${u}`,createCustomAttributePlaceholder(t,e){return`${t}="${this.createInterpolationPlaceholder(e)}"`},createBlockPlaceholder:t=>`\x3c!--${h}:${t}--\x3e`,queueUpdate:o.enqueue,processUpdates:o.process,nextUpdate:()=>new Promise(o.enqueue),setAttribute(t,e,i){null==i?t.removeAttribute(e):t.setAttribute(e,i)},setBooleanAttribute(t,e,i){i?t.setAttribute(e,""):t.removeAttribute(e)},removeChildNodes(t){for(let e=t.firstChild;null!==e;e=t.firstChild)t.removeChild(e)},createTemplateWalker:t=>document.createTreeWalker(t,133,null,!1)});class f{constructor(t,e){this.sub1=void 0,this.sub2=void 0,this.spillover=void 0,this.source=t,this.sub1=e}has(t){return void 0===this.spillover?this.sub1===t||this.sub2===t:-1!==this.spillover.indexOf(t)}subscribe(t){const e=this.spillover;if(void 0===e){if(this.has(t))return;if(void 0===this.sub1)return void(this.sub1=t);if(void 0===this.sub2)return void(this.sub2=t);this.spillover=[this.sub1,this.sub2,t],this.sub1=void 0,this.sub2=void 0}else{-1===e.indexOf(t)&&e.push(t)}}unsubscribe(t){const e=this.spillover;if(void 0===e)this.sub1===t?this.sub1=void 0:this.sub2===t&&(this.sub2=void 0);else{const i=e.indexOf(t);-1!==i&&e.splice(i,1)}}notify(t){const e=this.spillover,i=this.source;if(void 0===e){const e=this.sub1,s=this.sub2;void 0!==e&&e.handleChange(i,t),void 0!==s&&s.handleChange(i,t)}else for(let s=0,n=e.length;s<n;++s)e[s].handleChange(i,t)}}class p{constructor(t){this.subscribers={},this.sourceSubscribers=null,this.source=t}notify(t){var e;const i=this.subscribers[t];void 0!==i&&i.notify(t),null===(e=this.sourceSubscribers)||void 0===e||e.notify(t)}subscribe(t,e){var i;if(e){let i=this.subscribers[e];void 0===i&&(this.subscribers[e]=i=new f(this.source)),i.subscribe(t)}else this.sourceSubscribers=null!==(i=this.sourceSubscribers)&&void 0!==i?i:new f(this.source),this.sourceSubscribers.subscribe(t)}unsubscribe(t,e){var i;if(e){const i=this.subscribers[e];void 0!==i&&i.unsubscribe(t)}else null===(i=this.sourceSubscribers)||void 0===i||i.unsubscribe(t)}}const g=s.getById(2,()=>{const t=/(:|&&|\|\||if)/,e=new WeakMap,i=d.queueUpdate;let s=void 0,n=t=>{throw new Error("Must call enableArrayObservation before observing arrays.")};function o(t){let i=t.$fastController||e.get(t);return void 0===i&&(Array.isArray(t)?i=n(t):e.set(t,i=new p(t))),i}const l=r();class a{constructor(t){this.name=t,this.field="_"+t,this.callback=t+"Changed"}getValue(t){return void 0!==s&&s.watch(t,this.name),t[this.field]}setValue(t,e){const i=this.field,s=t[i];if(s!==e){t[i]=e;const n=t[this.callback];"function"==typeof n&&n.call(t,s,e),o(t).notify(this.name)}}}class h extends f{constructor(t,e,i=!1){super(t,e),this.binding=t,this.isVolatileBinding=i,this.needsRefresh=!0,this.needsQueue=!0,this.first=this,this.last=null,this.propertySource=void 0,this.propertyName=void 0,this.notifier=void 0,this.next=void 0}observe(t,e){this.needsRefresh&&null!==this.last&&this.disconnect();const i=s;s=this.needsRefresh?this:void 0,this.needsRefresh=this.isVolatileBinding;const n=this.binding(t,e);return s=i,n}disconnect(){if(null!==this.last){let t=this.first;for(;void 0!==t;)t.notifier.unsubscribe(this,t.propertyName),t=t.next;this.last=null,this.needsRefresh=this.needsQueue=!0}}watch(t,e){const i=this.last,n=o(t),r=null===i?this.first:{};if(r.propertySource=t,r.propertyName=e,r.notifier=n,n.subscribe(this,e),null!==i){if(!this.needsRefresh){let e;s=void 0,e=i.propertySource[i.propertyName],s=this,t===e&&(this.needsRefresh=!0)}i.next=r}this.last=r}handleChange(){this.needsQueue&&(this.needsQueue=!1,i(this))}call(){null!==this.last&&(this.needsQueue=!0,this.notify(this))}records(){let t=this.first;return{next:()=>{const e=t;return void 0===e?{value:void 0,done:!0}:(t=t.next,{value:e,done:!1})},[Symbol.iterator]:function(){return this}}}}return Object.freeze({setArrayObserverFactory(t){n=t},getNotifier:o,track(t,e){void 0!==s&&s.watch(t,e)},trackVolatile(){void 0!==s&&(s.needsRefresh=!0)},notify(t,e){o(t).notify(e)},defineProperty(t,e){"string"==typeof e&&(e=new a(e)),l(t).push(e),Reflect.defineProperty(t,e.name,{enumerable:!0,get:function(){return e.getValue(this)},set:function(t){e.setValue(this,t)}})},getAccessors:l,binding(t,e,i=this.isVolatileBinding(t)){return new h(t,e,i)},isVolatileBinding:e=>t.test(e.toString())})});function v(t,e){g.defineProperty(t,e)}function m(t,e,i){return Object.assign({},i,{get:function(){return g.trackVolatile(),i.get.apply(this)}})}const b=s.getById(3,()=>{let t=null;return{get:()=>t,set(e){t=e}}});class y{constructor(){this.index=0,this.length=0,this.parent=null,this.parentContext=null}get event(){return b.get()}get isEven(){return this.index%2==0}get isOdd(){return this.index%2!=0}get isFirst(){return 0===this.index}get isInMiddle(){return!this.isFirst&&!this.isLast}get isLast(){return this.index===this.length-1}static setEvent(t){b.set(t)}}g.defineProperty(y.prototype,"index"),g.defineProperty(y.prototype,"length");const C=Object.seal(new y);class w{constructor(){this.targetIndex=0}}class S extends w{constructor(){super(...arguments),this.createPlaceholder=d.createInterpolationPlaceholder}}class x extends w{constructor(t,e,i){super(),this.name=t,this.behavior=e,this.options=i}createPlaceholder(t){return d.createCustomAttributePlaceholder(this.name,t)}createBehavior(t){return new this.behavior(t,this.options)}}function O(t,e){this.source=t,this.context=e,null===this.bindingObserver&&(this.bindingObserver=g.binding(this.binding,this,this.isBindingVolatile)),this.updateTarget(this.bindingObserver.observe(t,e))}function T(t,e){this.source=t,this.context=e,this.target.addEventListener(this.targetName,this)}function k(){this.bindingObserver.disconnect(),this.source=null,this.context=null}function B(){this.bindingObserver.disconnect(),this.source=null,this.context=null;const t=this.target.$fastView;void 0!==t&&t.isComposed&&(t.unbind(),t.needsBindOnly=!0)}function N(){this.target.removeEventListener(this.targetName,this),this.source=null,this.context=null}function A(t){d.setAttribute(this.target,this.targetName,t)}function $(t){d.setBooleanAttribute(this.target,this.targetName,t)}function R(t){if(null==t&&(t=""),t.create){this.target.textContent="";let e=this.target.$fastView;void 0===e?e=t.create():this.target.$fastTemplate!==t&&(e.isComposed&&(e.remove(),e.unbind()),e=t.create()),e.isComposed?e.needsBindOnly&&(e.needsBindOnly=!1,e.bind(this.source,this.context)):(e.isComposed=!0,e.bind(this.source,this.context),e.insertBefore(this.target),this.target.$fastView=e,this.target.$fastTemplate=t)}else{const e=this.target.$fastView;void 0!==e&&e.isComposed&&(e.isComposed=!1,e.remove(),e.needsBindOnly?e.needsBindOnly=!1:e.unbind()),this.target.textContent=t}}function P(t){this.target[this.targetName]=t}function j(t){const e=this.classVersions||Object.create(null),i=this.target;let s=this.version||0;if(null!=t&&t.length){const n=t.split(/\s+/);for(let t=0,r=n.length;t<r;++t){const r=n[t];""!==r&&(e[r]=s,i.classList.add(r))}}if(this.classVersions=e,this.version=s+1,0!==s){s-=1;for(const t in e)e[t]===s&&i.classList.remove(t)}}class E extends S{constructor(t){super(),this.binding=t,this.bind=O,this.unbind=k,this.updateTarget=A,this.isBindingVolatile=g.isVolatileBinding(this.binding)}get targetName(){return this.originalTargetName}set targetName(t){if(this.originalTargetName=t,void 0!==t)switch(t[0]){case":":if(this.cleanedTargetName=t.substr(1),this.updateTarget=P,"innerHTML"===this.cleanedTargetName){const t=this.binding;this.binding=(e,i)=>d.createHTML(t(e,i))}break;case"?":this.cleanedTargetName=t.substr(1),this.updateTarget=$;break;case"@":this.cleanedTargetName=t.substr(1),this.bind=T,this.unbind=N;break;default:this.cleanedTargetName=t,"class"===t&&(this.updateTarget=j)}}targetAtContent(){this.updateTarget=R,this.unbind=B}createBehavior(t){return new V(t,this.binding,this.isBindingVolatile,this.bind,this.unbind,this.updateTarget,this.cleanedTargetName)}}class V{constructor(t,e,i,s,n,r,o){this.source=null,this.context=null,this.bindingObserver=null,this.target=t,this.binding=e,this.isBindingVolatile=i,this.bind=s,this.unbind=n,this.updateTarget=r,this.targetName=o}handleChange(){this.updateTarget(this.bindingObserver.observe(this.source,this.context))}handleEvent(t){y.setEvent(t);const e=this.binding(this.source,this.context);y.setEvent(null),!0!==e&&t.preventDefault()}}let F=null;class z{addFactory(t){t.targetIndex=this.targetIndex,this.behaviorFactories.push(t)}captureContentBinding(t){t.targetAtContent(),this.addFactory(t)}reset(){this.behaviorFactories=[],this.targetIndex=-1}release(){F=this}static borrow(t){const e=F||new z;return e.directives=t,e.reset(),F=null,e}}function I(t){if(1===t.length)return t[0];let e;const i=t.length,s=t.map(t=>"string"==typeof t?()=>t:(e=t.targetName||e,t.binding)),n=new E((t,e)=>{let n="";for(let r=0;r<i;++r)n+=s[r](t,e);return n});return n.targetName=e,n}const M=u.length;function _(t,e){const i=e.split(c);if(1===i.length)return null;const s=[];for(let e=0,n=i.length;e<n;++e){const n=i[e],r=n.indexOf(u);let o;if(-1===r)o=n;else{const e=parseInt(n.substring(0,r));s.push(t.directives[e]),o=n.substring(r+M)}""!==o&&s.push(o)}return s}function L(t,e,i=!1){const s=e.attributes;for(let n=0,r=s.length;n<r;++n){const o=s[n],l=o.value,a=_(t,l);let h=null;null===a?i&&(h=new E(()=>l),h.targetName=o.name):h=I(a),null!==h&&(e.removeAttributeNode(o),n--,r--,t.addFactory(h))}}function q(t,e,i){const s=_(t,e.textContent);if(null!==s){let n=e;for(let r=0,o=s.length;r<o;++r){const o=s[r],l=0===r?e:n.parentNode.insertBefore(document.createTextNode(""),n.nextSibling);"string"==typeof o?l.textContent=o:(l.textContent=" ",t.captureContentBinding(o)),n=l,t.targetIndex++,l!==e&&i.nextNode()}t.targetIndex--}}function H(t,e){const i=t.content;document.adoptNode(i);const s=z.borrow(e);L(s,t,!0);const n=s.behaviorFactories;s.reset();const r=d.createTemplateWalker(i);let o;for(;o=r.nextNode();)switch(s.targetIndex++,o.nodeType){case 1:L(s,o);break;case 3:q(s,o,r);break;case 8:d.isMarker(o)&&s.addFactory(e[d.extractDirectiveIndexFromMarker(o)])}let l=0;(d.isMarker(i.firstChild)||1===i.childNodes.length&&e.length)&&(i.insertBefore(document.createComment(""),i.firstChild),l=-1);const a=s.behaviorFactories;return s.release(),{fragment:i,viewBehaviorFactories:a,hostBehaviorFactories:n,targetOffset:l}}const D=document.createRange();class Q{constructor(t,e){this.fragment=t,this.behaviors=e,this.source=null,this.context=null,this.firstChild=t.firstChild,this.lastChild=t.lastChild}appendTo(t){t.appendChild(this.fragment)}insertBefore(t){if(this.fragment.hasChildNodes())t.parentNode.insertBefore(this.fragment,t);else{const e=this.lastChild;if(t.previousSibling===e)return;const i=t.parentNode;let s,n=this.firstChild;for(;n!==e;)s=n.nextSibling,i.insertBefore(n,t),n=s;i.insertBefore(e,t)}}remove(){const t=this.fragment,e=this.lastChild;let i,s=this.firstChild;for(;s!==e;)i=s.nextSibling,t.appendChild(s),s=i;t.appendChild(e)}dispose(){const t=this.firstChild.parentNode,e=this.lastChild;let i,s=this.firstChild;for(;s!==e;)i=s.nextSibling,t.removeChild(s),s=i;t.removeChild(e);const n=this.behaviors,r=this.source;for(let t=0,e=n.length;t<e;++t)n[t].unbind(r)}bind(t,e){const i=this.behaviors;if(this.source!==t)if(null!==this.source){const s=this.source;this.source=t,this.context=e;for(let n=0,r=i.length;n<r;++n){const r=i[n];r.unbind(s),r.bind(t,e)}}else{this.source=t,this.context=e;for(let s=0,n=i.length;s<n;++s)i[s].bind(t,e)}}unbind(){if(null===this.source)return;const t=this.behaviors,e=this.source;for(let i=0,s=t.length;i<s;++i)t[i].unbind(e);this.source=null}static disposeContiguousBatch(t){if(0!==t.length){D.setStartBefore(t[0].firstChild),D.setEndAfter(t[t.length-1].lastChild),D.deleteContents();for(let e=0,i=t.length;e<i;++e){const i=t[e],s=i.behaviors,n=i.source;for(let t=0,e=s.length;t<e;++t)s[t].unbind(n)}}}}class U{constructor(t,e){this.behaviorCount=0,this.hasHostBehaviors=!1,this.fragment=null,this.targetOffset=0,this.viewBehaviorFactories=null,this.hostBehaviorFactories=null,this.html=t,this.directives=e}create(t){if(null===this.fragment){let t;const e=this.html;if("string"==typeof e){t=document.createElement("template"),t.innerHTML=d.createHTML(e);const i=t.content.firstElementChild;null!==i&&"TEMPLATE"===i.tagName&&(t=i)}else t=e;const i=H(t,this.directives);this.fragment=i.fragment,this.viewBehaviorFactories=i.viewBehaviorFactories,this.hostBehaviorFactories=i.hostBehaviorFactories,this.targetOffset=i.targetOffset,this.behaviorCount=this.viewBehaviorFactories.length+this.hostBehaviorFactories.length,this.hasHostBehaviors=this.hostBehaviorFactories.length>0}const e=this.fragment.cloneNode(!0),i=this.viewBehaviorFactories,s=new Array(this.behaviorCount),n=d.createTemplateWalker(e);let r=0,o=this.targetOffset,l=n.nextNode();for(let t=i.length;r<t;++r){const t=i[r],e=t.targetIndex;for(;null!==l;){if(o===e){s[r]=t.createBehavior(l);break}l=n.nextNode(),o++}}if(this.hasHostBehaviors){const e=this.hostBehaviorFactories;for(let i=0,n=e.length;i<n;++i,++r)s[r]=e[i].createBehavior(t)}return new Q(e,s)}render(t,e,i){"string"==typeof e&&(e=document.getElementById(e)),void 0===i&&(i=e);const s=this.create(i);return s.bind(t,C),s.appendTo(e),s}}const W=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;function K(t,...e){const i=[];let s="";for(let n=0,r=t.length-1;n<r;++n){const r=t[n];let o=e[n];if(s+=r,o instanceof U){const t=o;o=()=>t}if("function"==typeof o&&(o=new E(o)),o instanceof S){const t=W.exec(r);null!==t&&(o.targetName=t[2])}o instanceof w?(s+=o.createPlaceholder(i.length),i.push(o)):s+=o}return s+=t[t.length-1],new U(s,i)}class J{constructor(){this.targets=new WeakSet}addStylesTo(t){this.targets.add(t)}removeStylesFrom(t){this.targets.delete(t)}isAttachedTo(t){return this.targets.has(t)}withBehaviors(...t){return this.behaviors=null===this.behaviors?t:this.behaviors.concat(t),this}}function G(t){return t.map(t=>t instanceof J?G(t.styles):[t]).reduce((t,e)=>t.concat(e),[])}function X(t){return t.map(t=>t instanceof J?t.behaviors:null).reduce((t,e)=>null===e?t:(null===t&&(t=[]),t.concat(e)),null)}J.create=(()=>{if(d.supportsAdoptedStyleSheets){const t=new Map;return e=>new Y(e,t)}return t=>new tt(t)})();class Y extends J{constructor(t,e){super(),this.styles=t,this.styleSheetCache=e,this._styleSheets=void 0,this.behaviors=X(t)}get styleSheets(){if(void 0===this._styleSheets){const t=this.styles,e=this.styleSheetCache;this._styleSheets=G(t).map(t=>{if(t instanceof CSSStyleSheet)return t;let i=e.get(t);return void 0===i&&(i=new CSSStyleSheet,i.replaceSync(t),e.set(t,i)),i})}return this._styleSheets}addStylesTo(t){t.adoptedStyleSheets=[...t.adoptedStyleSheets,...this.styleSheets],super.addStylesTo(t)}removeStylesFrom(t){const e=this.styleSheets;t.adoptedStyleSheets=t.adoptedStyleSheets.filter(t=>-1===e.indexOf(t)),super.removeStylesFrom(t)}}let Z=0;class tt extends J{constructor(t){super(),this.styles=t,this.behaviors=null,this.behaviors=X(t),this.styleSheets=G(t),this.styleClass="fast-style-class-"+ ++Z}addStylesTo(t){const e=this.styleSheets,i=this.styleClass;t=this.normalizeTarget(t);for(let s=0;s<e.length;s++){const n=document.createElement("style");n.innerHTML=e[s],n.className=i,t.append(n)}super.addStylesTo(t)}removeStylesFrom(t){const e=(t=this.normalizeTarget(t)).querySelectorAll("."+this.styleClass);for(let i=0,s=e.length;i<s;++i)t.removeChild(e[i]);super.removeStylesFrom(t)}isAttachedTo(t){return super.isAttachedTo(this.normalizeTarget(t))}normalizeTarget(t){return t===document?document.body:t}}const et=Object.freeze({locate:r()}),it={toView:t=>t?"true":"false",fromView:t=>null!=t&&"false"!==t&&!1!==t&&0!==t},st={toView(t){if(null==t)return null;const e=1*t;return isNaN(e)?null:e.toString()},fromView(t){if(null==t)return null;const e=1*t;return isNaN(e)?null:e}};class nt{constructor(t,e,i=e.toLowerCase(),s="reflect",n){this.guards=new Set,this.Owner=t,this.name=e,this.attribute=i,this.mode=s,this.converter=n,this.fieldName="_"+e,this.callbackName=e+"Changed",this.hasCallback=this.callbackName in t.prototype,"boolean"===s&&void 0===n&&(this.converter=it)}setValue(t,e){const i=t[this.fieldName],s=this.converter;void 0!==s&&(e=s.fromView(e)),i!==e&&(t[this.fieldName]=e,this.tryReflectToAttribute(t),this.hasCallback&&t[this.callbackName](i,e),t.$fastController.notify(this.name))}getValue(t){return g.track(t,this.name),t[this.fieldName]}onAttributeChangedCallback(t,e){this.guards.has(t)||(this.guards.add(t),this.setValue(t,e),this.guards.delete(t))}tryReflectToAttribute(t){const e=this.mode,i=this.guards;i.has(t)||"fromView"===e||d.queueUpdate(()=>{i.add(t);const s=t[this.fieldName];switch(e){case"reflect":const e=this.converter;d.setAttribute(t,this.attribute,void 0!==e?e.toView(s):s);break;case"boolean":d.setBooleanAttribute(t,this.attribute,s)}i.delete(t)})}static collect(t,...e){const i=[];e.push(et.locate(t));for(let s=0,n=e.length;s<n;++s){const n=e[s];if(void 0!==n)for(let e=0,s=n.length;e<s;++e){const s=n[e];"string"==typeof s?i.push(new nt(t,s)):i.push(new nt(t,s.property,s.attribute,s.mode,s.converter))}}return i}}function rt(t,e){let i;function s(t,e){arguments.length>1&&(i.property=e),et.locate(t.constructor).push(i)}return arguments.length>1?(i={},void s(t,e)):(i=void 0===t?{}:t,s)}const ot={mode:"open"},lt={},at=s.getById(4,()=>{const t=new Map;return Object.freeze({register:e=>!t.has(e.type)&&(t.set(e.type,e),!0),getByType:e=>t.get(e)})});class ht{constructor(t,e=t.definition){"string"==typeof e&&(e={name:e}),this.type=t,this.name=e.name,this.template=e.template;const i=nt.collect(t,e.attributes),s=new Array(i.length),n={},r={};for(let t=0,e=i.length;t<e;++t){const e=i[t];s[t]=e.attribute,n[e.name]=e,r[e.attribute]=e}this.attributes=i,this.observedAttributes=s,this.propertyLookup=n,this.attributeLookup=r,this.shadowOptions=void 0===e.shadowOptions?ot:null===e.shadowOptions?void 0:Object.assign(Object.assign({},ot),e.shadowOptions),this.elementOptions=void 0===e.elementOptions?lt:Object.assign(Object.assign({},lt),e.elementOptions),this.styles=void 0===e.styles?void 0:Array.isArray(e.styles)?J.create(e.styles):e.styles instanceof J?e.styles:J.create([e.styles])}get isDefined(){return!!at.getByType(this.type)}define(t=customElements){const e=this.type;if(at.register(this)){const t=this.attributes,i=e.prototype;for(let e=0,s=t.length;e<s;++e)g.defineProperty(i,t[e]);Reflect.defineProperty(e,"observedAttributes",{value:this.observedAttributes,enumerable:!0})}return t.get(this.name)||t.define(this.name,e,this.elementOptions),this}}ht.forType=at.getByType;const ct=new WeakMap,ut={bubbles:!0,composed:!0,cancelable:!0};function dt(t){return t.shadowRoot||ct.get(t)||null}class ft extends p{constructor(t,e){super(t),this.boundObservables=null,this.behaviors=null,this.needsInitialization=!0,this._template=null,this._styles=null,this._isConnected=!1,this.$fastController=this,this.view=null,this.element=t,this.definition=e;const i=e.shadowOptions;if(void 0!==i){const e=t.attachShadow(i);"closed"===i.mode&&ct.set(t,e)}const s=g.getAccessors(t);if(s.length>0){const e=this.boundObservables=Object.create(null);for(let i=0,n=s.length;i<n;++i){const n=s[i].name,r=t[n];void 0!==r&&(delete t[n],e[n]=r)}}}get isConnected(){return g.track(this,"isConnected"),this._isConnected}setIsConnected(t){this._isConnected=t,g.notify(this,"isConnected")}get template(){return this._template}set template(t){this._template!==t&&(this._template=t,this.needsInitialization||this.renderTemplate(t))}get styles(){return this._styles}set styles(t){this._styles!==t&&(null!==this._styles&&this.removeStyles(this._styles),this._styles=t,this.needsInitialization||null===t||this.addStyles(t))}addStyles(t){const e=dt(this.element)||this.element.getRootNode();if(t instanceof HTMLStyleElement)e.append(t);else if(!t.isAttachedTo(e)){const i=t.behaviors;t.addStylesTo(e),null!==i&&this.addBehaviors(i)}}removeStyles(t){const e=dt(this.element)||this.element.getRootNode();if(t instanceof HTMLStyleElement)e.removeChild(t);else if(t.isAttachedTo(e)){const i=t.behaviors;t.removeStylesFrom(e),null!==i&&this.removeBehaviors(i)}}addBehaviors(t){const e=this.behaviors||(this.behaviors=new Map),i=t.length,s=[];for(let n=0;n<i;++n){const i=t[n];e.has(i)?e.set(i,e.get(i)+1):(e.set(i,1),s.push(i))}if(this._isConnected){const t=this.element;for(let e=0;e<s.length;++e)s[e].bind(t,C)}}removeBehaviors(t,e=!1){const i=this.behaviors;if(null===i)return;const s=t.length,n=[];for(let r=0;r<s;++r){const s=t[r];if(i.has(s)){const t=i.get(s)-1;0===t||e?i.delete(s)&&n.push(s):i.set(s,t)}}if(this._isConnected){const t=this.element;for(let e=0;e<n.length;++e)n[e].unbind(t)}}onConnectedCallback(){if(this._isConnected)return;const t=this.element;this.needsInitialization?this.finishInitialization():null!==this.view&&this.view.bind(t,C);const e=this.behaviors;if(null!==e)for(const[i]of e)i.bind(t,C);this.setIsConnected(!0)}onDisconnectedCallback(){if(!this._isConnected)return;this.setIsConnected(!1);const t=this.view;null!==t&&t.unbind();const e=this.behaviors;if(null!==e){const t=this.element;for(const[i]of e)i.unbind(t)}}onAttributeChangedCallback(t,e,i){const s=this.definition.attributeLookup[t];void 0!==s&&s.onAttributeChangedCallback(this.element,i)}emit(t,e,i){return!!this._isConnected&&this.element.dispatchEvent(new CustomEvent(t,Object.assign(Object.assign({detail:e},ut),i)))}finishInitialization(){const t=this.element,e=this.boundObservables;if(null!==e){const i=Object.keys(e);for(let s=0,n=i.length;s<n;++s){const n=i[s];t[n]=e[n]}this.boundObservables=null}const i=this.definition;null===this._template&&(this.element.resolveTemplate?this._template=this.element.resolveTemplate():i.template&&(this._template=i.template||null)),null!==this._template&&this.renderTemplate(this._template),null===this._styles&&(this.element.resolveStyles?this._styles=this.element.resolveStyles():i.styles&&(this._styles=i.styles||null)),null!==this._styles&&this.addStyles(this._styles),this.needsInitialization=!1}renderTemplate(t){const e=this.element,i=dt(e)||e;null!==this.view?(this.view.dispose(),this.view=null):this.needsInitialization||d.removeChildNodes(i),t&&(this.view=t.render(e,i,e))}static forCustomElement(t){const e=t.$fastController;if(void 0!==e)return e;const i=ht.forType(t.constructor);if(void 0===i)throw new Error("Missing FASTElement definition.");return t.$fastController=new ft(t,i)}}function pt(t){return class extends t{constructor(){super(),ft.forCustomElement(this)}$emit(t,e,i){return this.$fastController.emit(t,e,i)}connectedCallback(){this.$fastController.onConnectedCallback()}disconnectedCallback(){this.$fastController.onDisconnectedCallback()}attributeChangedCallback(t,e,i){this.$fastController.onAttributeChangedCallback(t,e,i)}}}const gt=Object.assign(pt(HTMLElement),{from:t=>pt(t),define:(t,e)=>new ht(t,e).define().type});function vt(t){return function(e){new ht(e,t).define()}}class mt{createCSS(){return""}createBehavior(){}}function bt(t,e){const i=[];let s="";const n=[];for(let r=0,o=t.length-1;r<o;++r){s+=t[r];let o=e[r];if(o instanceof mt){const t=o.createBehavior();o=o.createCSS(),t&&n.push(t)}o instanceof J||o instanceof CSSStyleSheet?(""!==s.trim()&&(i.push(s),s=""),i.push(o)):s+=o}return s+=t[t.length-1],""!==s.trim()&&i.push(s),{styles:i,behaviors:n}}function yt(t,...e){const{styles:i,behaviors:s}=bt(t,e),n=J.create(i);return s.length&&n.withBehaviors(...s),n}class Ct extends mt{constructor(t,e){super(),this.behaviors=e,this.css="";const i=t.reduce((t,e)=>("string"==typeof e?this.css+=e:t.push(e),t),[]);i.length&&(this.styles=J.create(i))}createBehavior(){return this}createCSS(){return this.css}bind(t){this.styles&&t.$fastController.addStyles(this.styles),this.behaviors.length&&t.$fastController.addBehaviors(this.behaviors)}unbind(t){this.styles&&t.$fastController.removeStyles(this.styles),this.behaviors.length&&t.$fastController.removeBehaviors(this.behaviors)}}function wt(t,...e){const{styles:i,behaviors:s}=bt(t,e);return new Ct(i,s)}function St(t,e,i){return{index:t,removed:e,addedCount:i}}function xt(t,e,i,s,r,o){let l=0,a=0;const h=Math.min(i-e,o-r);if(0===e&&0===r&&(l=function(t,e,i){for(let s=0;s<i;++s)if(t[s]!==e[s])return s;return i}(t,s,h)),i===t.length&&o===s.length&&(a=function(t,e,i){let s=t.length,n=e.length,r=0;for(;r<i&&t[--s]===e[--n];)r++;return r}(t,s,h-l)),r+=l,o-=a,(i-=a)-(e+=l)==0&&o-r==0)return n;if(e===i){const t=St(e,[],0);for(;r<o;)t.removed.push(s[r++]);return[t]}if(r===o)return[St(e,[],i-e)];const c=function(t){let e=t.length-1,i=t[0].length-1,s=t[e][i];const n=[];for(;e>0||i>0;){if(0===e){n.push(2),i--;continue}if(0===i){n.push(3),e--;continue}const r=t[e-1][i-1],o=t[e-1][i],l=t[e][i-1];let a;a=o<l?o<r?o:r:l<r?l:r,a===r?(r===s?n.push(0):(n.push(1),s=r),e--,i--):a===o?(n.push(3),e--,s=o):(n.push(2),i--,s=l)}return n.reverse(),n}(function(t,e,i,s,n,r){const o=r-n+1,l=i-e+1,a=new Array(o);let h,c;for(let t=0;t<o;++t)a[t]=new Array(l),a[t][0]=t;for(let t=0;t<l;++t)a[0][t]=t;for(let i=1;i<o;++i)for(let r=1;r<l;++r)t[e+r-1]===s[n+i-1]?a[i][r]=a[i-1][r-1]:(h=a[i-1][r]+1,c=a[i][r-1]+1,a[i][r]=h<c?h:c);return a}(t,e,i,s,r,o)),u=[];let d=void 0,f=e,p=r;for(let t=0;t<c.length;++t)switch(c[t]){case 0:void 0!==d&&(u.push(d),d=void 0),f++,p++;break;case 1:void 0===d&&(d=St(f,[],0)),d.addedCount++,f++,d.removed.push(s[p]),p++;break;case 2:void 0===d&&(d=St(f,[],0)),d.addedCount++,f++;break;case 3:void 0===d&&(d=St(f,[],0)),d.removed.push(s[p]),p++}return void 0!==d&&u.push(d),u}const Ot=Array.prototype.push;function Tt(t,e,i,s){const n=St(e,i,s);let r=!1,o=0;for(let e=0;e<t.length;e++){const i=t[e];if(i.index+=o,r)continue;const s=(l=n.index,a=n.index+n.removed.length,h=i.index,c=i.index+i.addedCount,a<h||c<l?-1:a===h||c===l?0:l<h?a<c?a-h:c-h:c<a?c-l:a-l);if(s>=0){t.splice(e,1),e--,o-=i.addedCount-i.removed.length,n.addedCount+=i.addedCount-s;const l=n.removed.length+i.removed.length-s;if(n.addedCount||l){let t=i.removed;if(n.index<i.index){const e=n.removed.slice(0,i.index-n.index);Ot.apply(e,t),t=e}if(n.index+n.removed.length>i.index+i.addedCount){const e=n.removed.slice(i.index+i.addedCount-n.index);Ot.apply(t,e)}n.removed=t,i.index<n.index&&(n.index=i.index)}else r=!0}else if(n.index<i.index){r=!0,t.splice(e,0,n),e++;const s=n.addedCount-n.removed.length;i.index+=s,o+=s}}var l,a,h,c;r||t.push(n)}function kt(t,e){let i=[];const s=function(t){const e=[];for(let i=0,s=t.length;i<s;i++){const s=t[i];Tt(e,s.index,s.removed,s.addedCount)}return e}(e);for(let e=0,n=s.length;e<n;++e){const n=s[e];1!==n.addedCount||1!==n.removed.length?i=i.concat(xt(t,n.index,n.index+n.addedCount,n.removed,0,n.removed.length)):n.removed[0]!==t[n.index]&&i.push(n)}return i}let Bt=!1;function Nt(t,e){let i=t.index;const s=e.length;return i>s?i=s-t.addedCount:i<0&&(i=s+t.removed.length+i-t.addedCount),i<0&&(i=0),t.index=i,t}class At extends f{constructor(t){super(t),this.oldCollection=void 0,this.splices=void 0,this.needsQueue=!0,this.call=this.flush,Reflect.defineProperty(t,"$fastController",{value:this,enumerable:!1})}subscribe(t){this.flush(),super.subscribe(t)}addSplice(t){void 0===this.splices?this.splices=[t]:this.splices.push(t),this.needsQueue&&(this.needsQueue=!1,d.queueUpdate(this))}reset(t){this.oldCollection=t,this.needsQueue&&(this.needsQueue=!1,d.queueUpdate(this))}flush(){const t=this.splices,e=this.oldCollection;if(void 0===t&&void 0===e)return;this.needsQueue=!0,this.splices=void 0,this.oldCollection=void 0;const i=void 0===e?kt(this.source,t):xt(this.source,0,this.source.length,e,0,e.length);this.notify(i)}}function $t(){if(Bt)return;Bt=!0,g.setArrayObserverFactory(t=>new At(t));const t=Array.prototype;if(t.$fastPatch)return;Reflect.defineProperty(t,"$fastPatch",{value:1,enumerable:!1});const e=t.pop,i=t.push,s=t.reverse,n=t.shift,r=t.sort,o=t.splice,l=t.unshift;t.pop=function(){const t=this.length>0,i=e.apply(this,arguments),s=this.$fastController;return void 0!==s&&t&&s.addSplice(St(this.length,[i],0)),i},t.push=function(){const t=i.apply(this,arguments),e=this.$fastController;return void 0!==e&&e.addSplice(Nt(St(this.length-arguments.length,[],arguments.length),this)),t},t.reverse=function(){let t;const e=this.$fastController;void 0!==e&&(e.flush(),t=this.slice());const i=s.apply(this,arguments);return void 0!==e&&e.reset(t),i},t.shift=function(){const t=this.length>0,e=n.apply(this,arguments),i=this.$fastController;return void 0!==i&&t&&i.addSplice(St(0,[e],0)),e},t.sort=function(){let t;const e=this.$fastController;void 0!==e&&(e.flush(),t=this.slice());const i=r.apply(this,arguments);return void 0!==e&&e.reset(t),i},t.splice=function(){const t=o.apply(this,arguments),e=this.$fastController;return void 0!==e&&e.addSplice(Nt(St(+arguments[0],t,arguments.length>2?arguments.length-2:0),this)),t},t.unshift=function(){const t=l.apply(this,arguments),e=this.$fastController;return void 0!==e&&e.addSplice(Nt(St(0,[],arguments.length),this)),t}}class Rt{constructor(t,e){this.target=t,this.propertyName=e}bind(t){t[this.propertyName]=this.target}unbind(){}}function Pt(t){return new x("fast-ref",Rt,t)}function jt(t,e){const i="function"==typeof e?e:()=>e;return(e,s)=>t(e,s)?i(e,s):null}const Et=Object.freeze({positioning:!1,recycle:!0});function Vt(t,e,i,s){t.bind(e[i],s)}function Ft(t,e,i,s){const n=Object.create(s);n.index=i,n.length=e.length,t.bind(e[i],n)}class zt{constructor(t,e,i,s,n,r){this.location=t,this.itemsBinding=e,this.templateBinding=s,this.options=r,this.source=null,this.views=[],this.items=null,this.itemsObserver=null,this.originalContext=void 0,this.childContext=void 0,this.bindView=Vt,this.itemsBindingObserver=g.binding(e,this,i),this.templateBindingObserver=g.binding(s,this,n),r.positioning&&(this.bindView=Ft)}bind(t,e){this.source=t,this.originalContext=e,this.childContext=Object.create(e),this.childContext.parent=t,this.childContext.parentContext=this.originalContext,this.items=this.itemsBindingObserver.observe(t,this.originalContext),this.template=this.templateBindingObserver.observe(t,this.originalContext),this.observeItems(!0),this.refreshAllViews()}unbind(){this.source=null,this.items=null,null!==this.itemsObserver&&this.itemsObserver.unsubscribe(this),this.unbindAllViews(),this.itemsBindingObserver.disconnect(),this.templateBindingObserver.disconnect()}handleChange(t,e){t===this.itemsBinding?(this.items=this.itemsBindingObserver.observe(this.source,this.originalContext),this.observeItems(),this.refreshAllViews()):t===this.templateBinding?(this.template=this.templateBindingObserver.observe(this.source,this.originalContext),this.refreshAllViews(!0)):this.updateViews(e)}observeItems(t=!1){if(!this.items)return void(this.items=n);const e=this.itemsObserver,i=this.itemsObserver=g.getNotifier(this.items),s=e!==i;s&&null!==e&&e.unsubscribe(this),(s||t)&&i.subscribe(this)}updateViews(t){const e=this.childContext,i=this.views,s=this.bindView,n=this.items,r=this.template,o=this.options.recycle,l=[];let a=0,h=0;for(let c=0,u=t.length;c<u;++c){const u=t[c],d=u.removed;let f=0,p=u.index;const g=p+u.addedCount,v=i.splice(u.index,d.length),m=h=l.length+v.length;for(;p<g;++p){const t=i[p],c=t?t.firstChild:this.location;let u;o&&h>0?(f<=m&&v.length>0?(u=v[f],f++):(u=l[a],a++),h--):u=r.create(),i.splice(p,0,u),s(u,n,p,e),u.insertBefore(c)}v[f]&&l.push(...v.slice(f))}for(let t=a,e=l.length;t<e;++t)l[t].dispose();if(this.options.positioning)for(let t=0,e=i.length;t<e;++t){const s=i[t].context;s.length=e,s.index=t}}refreshAllViews(t=!1){const e=this.items,i=this.childContext,s=this.template,n=this.location,r=this.bindView;let o=e.length,l=this.views,a=l.length;if(0!==o&&!t&&this.options.recycle||(Q.disposeContiguousBatch(l),a=0),0===a){this.views=l=new Array(o);for(let t=0;t<o;++t){const o=s.create();r(o,e,t,i),l[t]=o,o.insertBefore(n)}}else{let t=0;for(;t<o;++t)if(t<a){r(l[t],e,t,i)}else{const o=s.create();r(o,e,t,i),l.push(o),o.insertBefore(n)}const h=l.splice(t,a-t);for(t=0,o=h.length;t<o;++t)h[t].dispose()}}unbindAllViews(){const t=this.views;for(let e=0,i=t.length;e<i;++e)t[e].unbind()}}class It extends w{constructor(t,e,i){super(),this.itemsBinding=t,this.templateBinding=e,this.options=i,this.createPlaceholder=d.createBlockPlaceholder,$t(),this.isItemsBindingVolatile=g.isVolatileBinding(t),this.isTemplateBindingVolatile=g.isVolatileBinding(e)}createBehavior(t){return new zt(t,this.itemsBinding,this.isItemsBindingVolatile,this.templateBinding,this.isTemplateBindingVolatile,this.options)}}function Mt(t,e,i=Et){return new It(t,"function"==typeof e?e:()=>e,Object.assign(Object.assign({},Et),i))}function _t(t){return t?function(e,i,s){return 1===e.nodeType&&e.matches(t)}:function(t,e,i){return 1===t.nodeType}}class Lt{constructor(t,e){this.target=t,this.options=e,this.source=null}bind(t){const e=this.options.property;this.shouldUpdate=g.getAccessors(t).some(t=>t.name===e),this.source=t,this.updateTarget(this.computeNodes()),this.shouldUpdate&&this.observe()}unbind(){this.updateTarget(n),this.source=null,this.shouldUpdate&&this.disconnect()}handleEvent(){this.updateTarget(this.computeNodes())}computeNodes(){let t=this.getNodes();return void 0!==this.options.filter&&(t=t.filter(this.options.filter)),t}updateTarget(t){this.source[this.options.property]=t}}class qt extends Lt{constructor(t,e){super(t,e)}observe(){this.target.addEventListener("slotchange",this)}disconnect(){this.target.removeEventListener("slotchange",this)}getNodes(){return this.target.assignedNodes(this.options)}}function Ht(t){return"string"==typeof t&&(t={property:t}),new x("fast-slotted",qt,t)}class Dt extends Lt{constructor(t,e){super(t,e),this.observer=null,e.childList=!0}observe(){null===this.observer&&(this.observer=new MutationObserver(this.handleEvent.bind(this))),this.observer.observe(this.target,this.options)}disconnect(){this.observer.disconnect()}getNodes(){return"subtree"in this.options?Array.from(this.target.querySelectorAll(this.options.selector)):Array.from(this.target.childNodes)}}function Qt(t){return"string"==typeof t&&(t={property:t}),new x("fast-children",Dt,t)}class Ut{constructor(t){this.path=t}}const Wt=new Set,Kt=Object.freeze({register(t){Wt.add(t)},unregister(t){Wt.delete(t)}}),Jt=/^([a-z][a-z0-9+\-.]*:)?\/\//i,Gt=Object.freeze({path:Object.freeze({get current(){return location.pathname+location.search},generateRoute(e,i,s={}){return t(this,void 0,void 0,(function*(){let t="config"in e?e:Te.find(e);for(;null!==t;){const e=yield t.config.generateRouteFromPath(i,s);if(null!==e)return e;t=t.parent}return null}))},push(t,e=!0){t&&Jt.test(t)?location.href=t:(history.pushState({},document.title,t),e&&Gt.path.trigger(t))},replace(t,e=!0){t&&Jt.test(t)?location.href=t:(history.replaceState({},document.title,t),e&&Gt.path.trigger(t))},trigger(t){const e=new Ut(t);for(const t of Wt)t.enqueue(e)}}),name:Object.freeze({generateRoute(e,i,s={}){return t(this,void 0,void 0,(function*(){let t="config"in e?e:Te.find(e);for(;null!==t;){const e=yield t.config.generateRouteFromName(i,s);if(null!==e)return e;t=t.parent}return null}))},push(e,i,s={},n=!0){return t(this,void 0,void 0,(function*(){const t=yield Gt.name.generateRoute(e,i,s);null!==t&&Gt.path.push(t,n)}))},replace(e,i,s={},n=!0){return t(this,void 0,void 0,(function*(){const t=yield Gt.name.generateRoute(e,i,s);null!==t&&Gt.path.replace(t,n)}))},trigger(e,i,s={}){return t(this,void 0,void 0,(function*(){const t=yield Gt.name.generateRoute(e,i,s);null!==t&&Gt.path.trigger(t)}))}})});class Xt{constructor(){this.queue=[],this.promise=null,this.resolve=null}connect(){this.enqueue(new Ut(Gt.path.current)),window.addEventListener("popstate",this),Kt.register(this)}disconnect(){this.queue=[],this.promise=null,this.resolve=null,window.removeEventListener("popstate",this),Kt.unregister(this)}receive(){return null!==this.promise||(this.promise=new Promise(t=>this.resolve=t),Promise.resolve().then(()=>this.tryDequeue())),this.promise}enqueue(t){this.queue.push(t),this.tryDequeue()}tryDequeue(){if(null===this.resolve||0===this.queue.length)return;const t=this.queue[this.queue.length-1],e=this.resolve;this.queue.length=0,this.promise=null,this.resolve=null,e(t)}handleEvent(t){this.enqueue(new Ut(Gt.path.current))}}const Yt=encodeURIComponent,Zt=t=>Yt(t).replace("%24","$");function te(t,e,i){let s=[];if(null==e)return s;if(Array.isArray(e))for(let n=0,r=e.length;n<r;n++)if(i)s.push(`${Zt(t)}=${Yt(e[n])}`);else{const i=t+"["+("object"==typeof e[n]&&null!==e[n]?n:"")+"]";s=s.concat(te(i,e[n]))}else if("object"!=typeof e||i)s.push(`${Zt(t)}=${Yt(e)}`);else for(const i in e)s=s.concat(te(t+"["+i+"]",e[i]));return s}function ee(t,e){return Array.isArray(t)?(t.push(e),t):void 0!==t?[t,e]:e}function ie(t,e,i){let s=t;const n=e.length-1;for(let t=0;t<=n;t++){const r=""===e[t]?s.length:e[t];if(t<n){const i=s[r]&&"object"!=typeof s[r]?[s[r]]:s[r];s=s[r]=i||(isNaN(e[t+1])?{}:[])}else s=s[r]=i}}const se=Object.freeze({get current(){return location.search},build(t,e){let i=[];const s=Object.keys(t||{}).sort();for(let n=0,r=s.length;n<r;n++){const r=s[n];i=i.concat(te(r,t[r],e))}return 0===i.length?"":i.join("&")},separate(t){const e=t.indexOf("?");let i="";return-1!==e&&(i=t.substr(e+1,t.length),t=t.substr(0,e)),{path:t,queryString:i}},parse(t){const e={};if(!t||"string"!=typeof t)return e;let i=t;"?"===i.charAt(0)&&(i=i.substr(1));const s=i.replace(/\+/g," ").split("&");for(let t=0;t<s.length;t++){const i=s[t].split("="),n=decodeURIComponent(i[0]);if(!n)continue;let r=n.split("]["),o=r.length-1;if(/\[/.test(r[0])&&/\]$/.test(r[o])?(r[o]=r[o].replace(/\]$/,""),r=r.shift().split("[").concat(r),o=r.length-1):o=0,i.length>=2){const t=i[1]?decodeURIComponent(i[1]):"";o?ie(e,r,t):e[n]=ee(e[n],t)}else e[n]=!0}return e}}),ne=t=>t;class re{constructor(t,e,i){this.path=t,this.name=e,this.caseSensitive=i}}class oe{constructor(t,e,i,s){this.route=t,this.paramNames=e,this.paramTypes=i,this.settings=s}get path(){return this.route.path}}class le{constructor(t,e,i,s){this.endpoint=t,this.params=e,this.typedParams=i,this.queryParams=s,this.allParams=Object.assign(Object.assign({},e),s),this.allTypedParams=Object.assign(Object.assign({},i),s)}get settings(){return this.endpoint.settings}}class ae{constructor(t,e,i,s){var n;this.chars=t,this.states=e,this.skippedStates=i,this.result=s,this.head=e[e.length-1],this.endpoint=null===(n=this.head)||void 0===n?void 0:n.endpoint}advance(t){const{chars:e,states:i,skippedStates:s,result:n}=this;let r=null,o=0;const l=i[i.length-1];function a(h,c){if(h.isMatch(t)&&(1==++o?r=h:n.add(new ae(e.concat(t),i.concat(h),null===c?s:s.concat(c),n))),null===l.segment&&h.isOptional&&null!==h.nextStates){if(h.nextStates.length>1)throw new Error(h.nextStates.length+" nextStates");const t=h.nextStates[0];if(!t.isSeparator)throw new Error("Not a separator");if(null!==t.nextStates)for(const e of t.nextStates)a(e,h)}}if(l.isDynamic&&a(l,null),null!==l.nextStates)for(const t of l.nextStates)a(t,null);null!==r&&(i.push(this.head=r),e.push(t),null!==r.endpoint&&(this.endpoint=r.endpoint)),0===o&&n.remove(this)}finalize(){!function t(e,i){const s=i.nextStates;if(null!==s)if(1===s.length&&null===s[0].segment)t(e,s[0]);else for(const i of s)if(i.isOptional&&null!==i.endpoint){if(e.push(i),null!==i.nextStates)for(const s of i.nextStates)t(e,s);break}}(this.skippedStates,this.head)}getParams(){const{states:t,chars:e,endpoint:i}=this,s={};for(const t of i.paramNames)s[t]=void 0;for(let i=0,n=t.length;i<n;++i){const n=t[i];if(n.isDynamic){const t=n.segment.name;void 0===s[t]?s[t]=e[i]:s[t]+=e[i]}}return s}compareTo(t){const e=this.states,i=t.states;for(let t=0,s=0,n=Math.max(e.length,i.length);t<n;++t){let n=e[t];if(void 0===n)return 1;let r=i[s];if(void 0===r)return-1;let o=n.segment,l=r.segment;if(null===o){if(null===l){++s;continue}if(void 0===(n=e[++t]))return 1;o=n.segment}else if(null===l){if(void 0===(r=i[++s]))return-1;l=r.segment}if(o.kind<l.kind)return 1;if(o.kind>l.kind)return-1;++s}const s=this.skippedStates,n=t.skippedStates,r=s.length,o=n.length;if(r<o)return 1;if(r>o)return-1;for(let t=0;t<r;++t){const e=s[t],i=n[t];if(e.length<i.length)return 1;if(e.length>i.length)return-1}return 0}}function he(t){return null!==t.head.endpoint}function ce(t,e){return t.compareTo(e)}class ue{constructor(t){this.candidates=[],this.candidates=[new ae([""],[t],[],this)]}get isEmpty(){return 0===this.candidates.length}getSolution(){const t=this.candidates.filter(he);if(0===t.length)return null;for(const e of t)e.finalize();return t.sort(ce),t[0]}add(t){this.candidates.push(t)}remove(t){this.candidates.splice(this.candidates.indexOf(t),1)}advance(t){const e=this.candidates.slice();for(const i of e)i.advance(t)}}class de{constructor(){this.names=new Map,this.paths=new Map,this.rootState=new fe(null,null,"")}add(t,e){if(t instanceof Array)for(const i of t)this.$add(i,e);else this.$add(t,e)}$add(t,e){const i=t.path,s=new re(t.path,t.name||"",!0===t.caseSensitive),n=""===i?[""]:i.split("/").filter(pe),r=[],o=[];let l=this.rootState;const a=[];for(const t of n)switch(l=l.append(null,"/"),t.charAt(0)){case"{":{const e=t.slice(1,-1).split(":").map(t=>t.trim());2===e.length?o.push(e[1]):o.push("string");const i=e[0].endsWith("?"),s=i?e[0].slice(0,-1):e[0];r.push(s);const n=new ve(s,i);a.push(n),l=n.appendTo(l);break}case"*":{const e=t.slice(1);r.push(e),o.push("string");const i=new me(e);a.push(i),l=i.appendTo(l);break}default:{const e=new ge(t,s.caseSensitive);a.push(e),l=e.appendTo(l);break}}const h=new oe(s,r,o,e||null);l.setEndpoint(h),this.paths.set(i,a),t.name&&this.names.set(t.name,a)}recognize(e,i={}){return t(this,void 0,void 0,(function*(){const t=se.separate(e),s=se.parse(t.queryString);(e=decodeURI(t.path)).startsWith("/")||(e="/"+e),e.length>1&&e.endsWith("/")&&(e=e.slice(0,-1));const n=new ue(this.rootState);for(let t=0,i=e.length;t<i;++t){const i=e.charAt(t);if(n.advance(i),n.isEmpty)return null}const r=n.getSolution();if(null===r)return null;const{endpoint:o}=r,l=o.paramNames,a=o.paramTypes,h=r.getParams(),c={};for(let t=0,e=l.length;t<e;++t){const e=l[t],s=i[a[t]]||ne,n=h[e],r=yield s(n);c[e]=r}return new le(o,h,c,s)}))}generateFromName(t,e){return this.generate(this.names.get(t),e)}generateFromPath(t,e){return this.generate(this.paths.get(t),e)}generate(t,e){if(!t)return null;const i=Object.assign({},e),s={};let n="";for(let e=0,r=t.length;e<r;e++){const r=t[e],o=r.generate(i,s);if(null==o){if(r instanceof ve&&!r.optional)throw new Error(`A value is required for route parameter '${r.name}'.`)}else n+="/",n+=o}"/"!==n.charAt(0)&&(n="/"+n);for(const t in s)delete i[t];const r=se.build(i);return n+=r?"?"+r:"",n}}class fe{constructor(t,e,i){switch(this.prevState=t,this.segment=e,this.value=i,this.nextStates=null,this.endpoint=null,null==e?void 0:e.kind){case 2:this.length=t.length+1,this.isSeparator=!1,this.isDynamic=!0,this.isOptional=e.optional;break;case 1:this.length=t.length+1,this.isSeparator=!1,this.isDynamic=!0,this.isOptional=!1;break;case 3:this.length=t.length+1,this.isSeparator=!1,this.isDynamic=!1,this.isOptional=!1;break;case void 0:this.length=null===t?0:t.length,this.isSeparator=!0,this.isDynamic=!1,this.isOptional=!1}}append(t,e){let i,s=this.nextStates;return null===s?(i=void 0,s=this.nextStates=[]):i=null===t?s.find(t=>t.value===e):s.find(e=>{var i;return null===(i=e.segment)||void 0===i?void 0:i.equals(t)}),void 0===i&&s.push(i=new fe(this,t,e)),i}setEndpoint(t){if(null!==this.endpoint)throw new Error(`Cannot add ambiguous route. The pattern '${t.route.path}' clashes with '${this.endpoint.route.path}'`);this.endpoint=t,this.isOptional&&(this.prevState.setEndpoint(t),this.prevState.isSeparator&&null!==this.prevState.prevState&&this.prevState.prevState.setEndpoint(t))}isMatch(t){const e=this.segment;switch(null==e?void 0:e.kind){case 2:return!this.value.includes(t);case 1:return!0;case 3:case void 0:return this.value.includes(t)}}}function pe(t){return t.length>0}class ge{constructor(t,e){this.value=t,this.caseSensitive=e}get kind(){return 3}appendTo(t){const{value:e,value:{length:i}}=this;if(this.caseSensitive)for(let s=0;s<i;++s)t=t.append(this,e.charAt(s));else for(let s=0;s<i;++s){const i=e.charAt(s);t=t.append(this,i.toUpperCase()+i.toLowerCase())}return t}generate(){return this.value}equals(t){return 3===t.kind&&t.caseSensitive===this.caseSensitive&&t.value===this.value}}class ve{constructor(t,e){this.name=t,this.optional=e}get kind(){return 2}appendTo(t){return t=t.append(this,"/")}generate(t,e){return e[this.name]=!0,t[this.name]}equals(t){return 2===t.kind&&t.optional===this.optional&&t.name===this.name}}class me{constructor(t){this.name=t}get kind(){return 1}appendTo(t){return t=t.append(this,"")}generate(t,e){return e[this.name]=!0,t[this.name]}equals(t){return 1===t.kind&&t.name===this.name}}const be="fast-child-route";function ye(t,e){return"command"in e?e.command:"redirect"in e?new Ie(e.redirect):qe.fromDefinition(t,e)}const Ce=t=>{if(null==t)return!1;switch(t.toLowerCase().trim()){case"true":case"yes":case"1":return!0;default:return!1}},we={number:t=>void 0===t?NaN:parseFloat(t),float:t=>void 0===t?NaN:parseFloat(t),int:t=>void 0===t?NaN:parseInt(t),integer:t=>void 0===t?NaN:parseInt(t),Date:t=>void 0===t?new Date(Date.now()):new Date(t),boolean:Ce,bool:Ce};class Se{constructor(t){this.owner=t,this._recognizer=null,this.pathToCommand=new Map,this.fallbackCommand=null,this.fallbackSettings=null,this.converters={}}get recognizer(){return null===this._recognizer&&(this._recognizer=this.owner.createRouteRecognizer()),this._recognizer}ignore(t){"string"==typeof t&&(t={path:t}),this.pathToCommand.set(t.path,new ze),this.recognizer.add(t,t.settings)}map(...t){for(const e of t){if("children"in e){const t=this.owner.createTitleBuilder(),i=e.children.map(i=>{const s=Object.assign(Object.assign(Object.assign({},e),i),{path:`${e.path}/${i.path}`});if("title"in e||"title"in i){const n=e.title||"",r=i.title||"";s.title=t.joinTitles(n,r)}if("name"in i){const t=e.name?e.name+"/":"";s.name=t+i.name}return s.children===e.children&&delete s.children,s});this.map(...i);continue}let t;if(t="command"in e?e.command:"redirect"in e?new Ie(e.redirect):qe.fromDefinition(this.owner,e),this.pathToCommand.set(e.path,t),this.recognizer.add(e,e.settings),"childRouters"in e&&e.childRouters){const i=Object.assign(Object.assign({},e),{path:e.path+"/*fast-child-route"});this.pathToCommand.set(i.path,t),this.recognizer.add(i,i.settings)}}}fallback(e){const i=this.owner;this.fallbackCommand="function"==typeof e?{createContributor(s,n){return t(this,void 0,void 0,(function*(){const t=yield e();return ye(i,t).createContributor(s,n)}))}}:ye(i,e)}converter(t,e){let i;i="convert"in e?e.convert.bind(e):e.prototype&&"convert"in e.prototype?t=>this.owner.construct(e).convert(t):e,this.converters[t]=i}recognize(e){return t(this,void 0,void 0,(function*(){const t=yield this.recognizer.recognize(e,this.aggregateConverters());if(null!==t)return{route:t,command:this.pathToCommand.get(t.endpoint.path)};if(null!==this.fallbackCommand){const t=se.separate(e),i=se.parse(t.queryString);return{route:new le(new oe(new re("*","",!1),[],[],this.fallbackSettings),{},{},i),command:this.fallbackCommand}}return null}))}generateFromName(t,e){return this.recognizer.generateFromName(t,e)}generateFromPath(t,e){return this.recognizer.generateFromPath(t,e)}aggregateConverters(){return null===this.owner.parent?Object.assign(Object.assign({},we),this.converters):Object.assign(Object.assign({},this.owner.parent.routes.aggregateConverters()),this.converters)}}function xe(t){const e=t.parentElement;if(e)return e;{const e=t.getRootNode();if(e.host instanceof HTMLElement)return e.host}return null}function Oe(t){let e=t;for(;e=xe(e);)if("$router"in e)return e.$router;return null}const Te=Object.freeze({getOrCreateFor(t){const e=t.$router;return void 0!==e?e:t.$router=new Be(t)},find:t=>t.$router||Oe(t),from(t){class e extends t{constructor(){super(),Te.getOrCreateFor(this)}get config(){return this.$router.config}set config(t){this.$router.config=t}}const i=e.prototype;if("connectedCallback"in i){const t=i.connectedCallback;i.connectedCallback=function(){t.call(this),this.$router.connect()}}else i.connectedCallback=function(){this.$router.connect()};if("disconnectedCallback"in i){const t=i.disconnectedCallback;i.disconnectedCallback=function(){t.call(this),this.$router.disconnect()}}else i.disconnectedCallback=function(){this.$router.disconnect()};return e}});function ke(t){return t instanceof gt}class Be{constructor(e){this.host=e,this.parentRouter=void 0,this.contributors=new Set,this.navigationQueue=null,this.linkHandler=null,this.newView=null,this.newRoute=null,this.childCommandContributor=null,this.childRoute=null,this.isConnected=!1,this.routerConfig=null,this.view=null,this.route=null,this.onNavigationMessage=e=>t(this,void 0,void 0,(function*(){const t=this.config.createNavigationProcess();yield t.run(this,e),this.navigationQueue.receive().then(this.onNavigationMessage)})),e.$router=this}get config(){return this.routerConfig}set config(t){this.routerConfig=t,this.tryConnect()}get parent(){if(void 0===this.parentRouter){if(!this.isConnected)return null;this.parentRouter=Oe(this.host)}return this.parentRouter||null}get level(){return null===this.parent?0:this.parent.level+1}shouldRender(t){var e;if(this.route&&this.route.endpoint.path===t.endpoint.path){const i=null==t?void 0:t.allParams,s=null===(e=this.route)||void 0===e?void 0:e.allParams;if(JSON.stringify(s)===JSON.stringify(i))return!1}return!0}beginRender(e,i){return t(this,void 0,void 0,(function*(){return this.newRoute=e,this.newView=yield i.createView(),this.newView.bind(e.allTypedParams,Ne.create(this)),this.newView.appendTo(this.host),yield i.transition.begin(this.host,this.view,this.newView),{commit:this.renderOperationCommit.bind(this,i.layout,i.transition),rollback:this.renderOperationRollback.bind(this,i.transition)}}))}connect(){this.isConnected=!0,this.tryConnect()}disconnect(){null===this.parent?(null!==this.navigationQueue&&(this.navigationQueue.disconnect(),this.navigationQueue=null),null!==this.linkHandler&&(this.linkHandler.disconnect(),this.linkHandler=null)):this.parent.removeContributor(this),this.isConnected=!1,this.parentRouter=void 0}addContributor(t){this.contributors.add(t)}removeContributor(t){this.contributors.delete(t)}tryConnect(){null!==this.config&&this.isConnected&&(null===this.parent?(null!==this.navigationQueue&&this.navigationQueue.disconnect(),this.navigationQueue=this.config.createNavigationQueue(),this.navigationQueue.connect(),this.navigationQueue.receive().then(this.onNavigationMessage),null!==this.linkHandler&&this.linkHandler.disconnect(),this.linkHandler=this.config.createLinkHandler(),this.linkHandler.connect()):(this.config.parent=this.parent.config,this.parent.addContributor(this)))}renderOperationCommit(e,i){return t(this,void 0,void 0,(function*(){yield e.beforeCommit(this.host),yield i.commit(this.host,this.view,this.newView),yield e.afterCommit(this.host),null!==this.view&&this.view.dispose(),this.route=this.newRoute,this.view=this.newView,this.newRoute=null,this.newView=null}))}renderOperationRollback(e){return t(this,void 0,void 0,(function*(){null!==this.newView&&(yield e.rollback(this.host,this.view,this.newView),this.newView.dispose(),this.newRoute=null,this.newView=null)}))}navigate(e){return t(this,void 0,void 0,(function*(){yield this.tunnel(e)}))}leave(e){return t(this,void 0,void 0,(function*(){if(yield this.tunnel(e),!e.canceled){const t=this.contributors;this.contributors=new Set,e.onCancel(()=>this.contributors=t)}}))}construct(e){return t(this,void 0,void 0,(function*(){if(null!==this.parent){const t=e.route.allParams["fast-child-route"]||"",i=yield this.config.recognizeRoute(t);if(null===i){return this.config.createEventSink().onUnhandledNavigationMessage(this,new Ut(t)),void e.cancel()}this.childRoute=i.route,this.childCommandContributor=yield i.command.createContributor(this,i.route)}yield this.tunnel(e)}))}enter(e){return t(this,void 0,void 0,(function*(){yield this.tunnel(e)}))}commit(e){return t(this,void 0,void 0,(function*(){yield this.tunnel(e)}))}tunnel(e){return t(this,void 0,void 0,(function*(){const t=this.childRoute,i=this.childCommandContributor;if(t&&i&&(yield e.evaluateContributor(i,t,this)),e.canceled)return;const s=[...this.config.findContributors(e.name),...Array.from(this.contributors)];for(const t of s)if(yield e.evaluateContributor(t,void 0,this),e.canceled)return}))}}const Ne=Object.freeze({create:t=>Object.create(C,{router:{value:t}})}),Ae=Object.freeze({default:Object.freeze({begin(e,i,s){return t(this,void 0,void 0,(function*(){}))},rollback(e,i,s){return t(this,void 0,void 0,(function*(){}))},commit(e,i,s){return t(this,void 0,void 0,(function*(){}))}})});class $e{constructor(t=null,e=null,i=!0){this.template=t,this.runBeforeCommit=i,this.styles=null==e?null:Array.isArray(e)?J.create(e):e instanceof J?e:J.create([e])}beforeCommit(e){return t(this,void 0,void 0,(function*(){this.runBeforeCommit&&this.apply(e)}))}afterCommit(e){return t(this,void 0,void 0,(function*(){this.runBeforeCommit||this.apply(e)}))}apply(t){ke(t)&&(t.$fastController.template!==this.template&&(t.$fastController.template=this.template),t.$fastController.styles!==this.styles&&(t.$fastController.styles=this.styles))}}const Re=Object.freeze({default:new $e(K`<slot></slot>`)});function Pe(t,e){return e in t}const je={lifecycle:!0,parameters:!0};class Ee extends w{constructor(t){super(),this.options=t}createPlaceholder(t){return d.createCustomAttributePlaceholder("fast-navigation-contributor",t)}createBehavior(t){return new Ve(t,this.options)}}class Ve{constructor(t,e){this.contributor=t,this.options=e,this.router=null}bind(t,e){if(this.options.lifecycle&&(this.router=e.router||Te.find(this.contributor),this.router.addContributor(this.contributor)),this.options.parameters){const e=this.contributor,i=t;for(const t in i)e[t]=i[t]}}unbind(t){null!==this.router&&this.router.removeContributor(this.contributor)}}function Fe(t){return new Ee(Object.assign({},je,t))}class ze{createContributor(){return t(this,void 0,void 0,(function*(){return{navigate(e){return t(this,void 0,void 0,(function*(){e.cancel()}))}}}))}}class Ie{constructor(t){this.redirect=t}createContributor(){return t(this,void 0,void 0,(function*(){const e=this.redirect;return{navigate(i){return t(this,void 0,void 0,(function*(){const s=i.router.config,n=(yield s.generateRouteFromName(e,i.route.allParams))||(yield s.generateRouteFromPath(e,i.route.allParams));if(null===n)throw new Error("Invalid redirect. Name or path not found: "+e);i.cancel(()=>t(this,void 0,void 0,(function*(){return Gt.path.replace(n)})))}))}}}))}}function Me(t){return K`<${t} ${Fe()}></${t}>`}function _e(t){const e=document.createDocumentFragment();e.appendChild(t);const i=new Q(e,[Fe().createBehavior(t)]);return{create:()=>i}}class Le{constructor(t,e,i){this.router=t,this.route=e,this.command=i}construct(e){return t(this,void 0,void 0,(function*(){this.router.shouldRender(this.route)?(this.operation=yield this.router.beginRender(this.route,this.command),e.onCancel(()=>this.operation.rollback())):e.cancel()}))}commit(e){return t(this,void 0,void 0,(function*(){yield this.operation.commit(),this.command.title&&e.setTitle(this.command.title)}))}}class qe{constructor(t,e){this.owner=t,this.createView=e,this._layout=null,this._transition=null,this.title=""}get transition(){return this._transition||this.owner.defaultTransition}set transition(t){this._transition=t}get layout(){return this._layout||this.owner.defaultLayout}set layout(t){this._layout=t}createContributor(e,i){return t(this,void 0,void 0,(function*(){return new Le(e,i,this)}))}static fromDefinition(e,i){let s;s="template"in i?()=>t(this,void 0,void 0,(function*(){let t=i.template;return"function"==typeof t&&(t=yield t()),t.create()})):()=>t(this,void 0,void 0,(function*(){let t=i.element,e=null;if(i.factory)e=i.factory;else if("function"==typeof t){let i=ht.forType(t);if(i)e=Me(i.name);else if(t=yield t(),"string"==typeof t)e=Me(t);else if(t instanceof HTMLElement)e=_e(t);else{if(i=ht.forType(t),!i)throw new Error("Invalid value for element in route config.");e=Me(i.name)}}else t instanceof HTMLElement?i.factory=e=_e(t):i.factory=e=Me(t);return e.create()}));const n=new qe(e,s);return i.layout&&(i.layout instanceof U?n.layout=new $e(i.layout):n.layout=i.layout),i.transition&&(n.transition=i.transition),i.title&&(n.title=i.title),n}}class He{constructor(){this.handler=t=>{const{shouldHandleEvent:e,href:i}=this.getEventInfo(t);e&&(t.preventDefault(),Gt.path.push(i))}}connect(){window.addEventListener("click",this.handler,!0)}disconnect(){window.removeEventListener("click",this.handler)}getEventInfo(t){const e={shouldHandleEvent:!1,href:null,anchor:null},i=this.findClosestAnchor(t);if(!i||!this.targetIsThisWindow(i))return e;if(i.hasAttribute("download")||i.hasAttribute("router-ignore")||i.hasAttribute("data-router-ignore"))return e;if(t.altKey||t.ctrlKey||t.metaKey||t.shiftKey)return e;const s=i.getAttribute("href");e.anchor=i,e.href=s;const n=1===t.which,r=s&&!("#"===s.charAt(0)||/^[a-z]+:/i.test(s));return e.shouldHandleEvent=n&&!!r,e}findClosestAnchor(t){const e=t.composedPath();for(let t=0,i=e.length;t<i;++t){const i=e[t];if("A"===i.tagName)return i}return t.target}targetIsThisWindow(t){const e=t.getAttribute("target");return!e||e===window.name||"_self"===e}}class De{constructor(t,e,i,s,n){this.name=t,this.commitActions=s,this.cancelActions=n,this.routes=[],this.routers=[],this.canceled=!1,this.titles=[],this.routes.push(e),this.routers.push(i)}get route(){return this.routes[this.routes.length-1]}get router(){return this.routers[this.routers.length-1]}cancel(t){this.canceled=!0,t&&this.cancelActions.push(t)}onCommit(t){this.commitActions.push(t)}onCancel(t){this.cancelActions.push(t)}setTitle(t){const e=this.router.level;for(;this.titles.length<e+1;)this.titles.push([]);this.titles[e].push(t)}evaluateContributor(e,i=this.route,s=this.router){return t(this,void 0,void 0,(function*(){Pe(e,this.name)&&(this.routes.push(i),this.routers.push(s),yield e[this.name](this),this.routes.pop(),this.routers.pop())}))}}class Qe{constructor(){this.phases=["navigate","leave","construct","enter","commit"]}run(e,i){return t(this,void 0,void 0,(function*(){const t=e.config.createEventSink(),s=yield e.config.recognizeRoute(i.path);if(null===s)return void t.onUnhandledNavigationMessage(e,i);const n=s.route,r=s.command;t.onNavigationBegin(e,n,r);const o=[],l=[];let a=o;const h=[yield r.createContributor(e,n),e,this];for(const i of this.phases){const s=new De(i,n,e,o,l);if(t.onPhaseBegin(s),s.canceled)a=l;else for(const t of h)if(yield s.evaluateContributor(t),s.canceled){a=l;break}if(t.onPhaseEnd(s),s.canceled)break}yield Promise.all(a.map(t=>t())).then(()=>t.onNavigationEnd(e,n,r))}))}commit(t){const e=t.router.config.createTitleBuilder();document.title=e.buildTitle(t.router.config.title,t.titles)}}class Ue{constructor(t=" - ",e=":"){this.segmentSeparator=t,this.fragmentSeparator=e}joinTitles(t,e){return""===t?e:""===e?t:`${t}${this.segmentSeparator}${e}`}buildTitle(t,e){let i=t;for(const t of e){i&&(i+=this.segmentSeparator);let e="";for(const i of t)e&&(e+=this.fragmentSeparator),e+=i;i+=e}return i}}class We{onUnhandledNavigationMessage(t,e){}onNavigationBegin(t,e,i){}onPhaseBegin(t){}onPhaseEnd(t){}onNavigationEnd(t,e,i){}}class Ke{constructor(){this.isConfigured=!1,this.routes=new Se(this),this.contributors=[],this.defaultLayout=Re.default,this.defaultTransition=Ae.default,this.title="",this.parent=null}createNavigationQueue(){return this.construct(Xt)}createLinkHandler(){return this.construct(He)}createNavigationProcess(){return new Qe}createEventSink(){return this.construct(We)}createTitleBuilder(){return this.construct(Ue)}createRouteRecognizer(){return this.construct(de)}construct(t){return null!==this.parent?this.parent.construct(t):new t}recognizeRoute(e){return t(this,void 0,void 0,(function*(){return yield this.ensureConfigured(),this.routes.recognize(e)}))}generateRouteFromName(e,i){return t(this,void 0,void 0,(function*(){return yield this.ensureConfigured(),this.routes.generateFromName(e,i)}))}generateRouteFromPath(e,i){return t(this,void 0,void 0,(function*(){return yield this.ensureConfigured(),this.routes.generateFromPath(e,i)}))}findContributors(t){return this.contributors.filter(e=>Pe(e,t))}cached(e){let i=null;return()=>t(this,void 0,void 0,(function*(){return null===i&&(i=new e),i}))}ensureConfigured(){return t(this,void 0,void 0,(function*(){this.isConfigured||(yield this.configure(),this.isConfigured=!0)}))}}let Je=class extends(Te.from(gt)){};Je=function(t,e,i,s){var n,r=arguments.length,o=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var l=t.length-1;l>=0;l--)(n=t[l])&&(o=(r<3?n(o):r>3?n(e,i,o):n(e,i))||o);return r>3&&o&&Object.defineProperty(e,i,o),o}([vt("fast-router")],Je);export{e as $global,x as AttachedBehaviorHTMLDirective,et as AttributeConfiguration,nt as AttributeDefinition,V as BindingBehavior,mt as CSSDirective,Dt as ChildrenBehavior,re as ConfigurableRoute,ft as Controller,d as DOM,He as DefaultLinkHandler,Qe as DefaultNavigationProcess,Xt as DefaultNavigationQueue,de as DefaultRouteRecognizer,Be as DefaultRouter,J as ElementStyles,oe as Endpoint,y as ExecutionContext,s as FAST,gt as FASTElement,ht as FASTElementDefinition,$e as FASTElementLayout,Je as FASTRouter,E as HTMLBindingDirective,w as HTMLDirective,Q as HTMLView,ze as Ignore,Re as Layout,Kt as NavigationHandler,Ut as NavigationMessage,g as Observable,p as PropertyChangeNotifier,se as QueryString,le as RecognizedRoute,Ie as Redirect,Rt as RefBehavior,qe as Render,zt as RepeatBehavior,It as RepeatDirective,Gt as Route,Se as RouteCollection,Te as Router,Ke as RouterConfiguration,Ne as RouterExecutionContext,qt as SlottedBehavior,f as SubscriberSet,S as TargetedHTMLDirective,Ae as Transition,U as ViewTemplate,rt as attr,it as booleanConverter,be as childRouteParameter,Qt as children,H as compileTemplate,r as createMetadataLocator,yt as css,wt as cssPartial,vt as customElement,C as defaultExecutionContext,_t as elements,n as emptyArray,$t as enableArrayObservation,K as html,ke as isFASTElementHost,Pe as isNavigationPhaseContributor,Fe as navigationContributor,st as nullableNumberConverter,v as observable,Pt as ref,Mt as repeat,Ht as slotted,m as volatile,jt as when};
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@microsoft/fast-router",
3
3
  "description": "A web-components-based router.",
4
4
  "sideEffects": false,
5
- "version": "0.4.5",
5
+ "version": "0.4.6",
6
6
  "author": {
7
7
  "name": "Microsoft",
8
8
  "url": "https://discord.gg/FcSNfg4"
@@ -84,6 +84,6 @@
84
84
  "webpack": "^4.44.0"
85
85
  },
86
86
  "dependencies": {
87
- "@microsoft/fast-element": "^1.10.5"
87
+ "@microsoft/fast-element": "^1.11.0"
88
88
  }
89
89
  }