@microsoft/fast-element
Advanced tools
Comparing version 1.7.2 to 1.8.0
@@ -5,3 +5,18 @@ { | ||
{ | ||
"date": "Fri, 25 Feb 2022 17:06:57 GMT", | ||
"date": "Tue, 08 Mar 2022 07:10:44 GMT", | ||
"tag": "@microsoft/fast-element_v1.8.0", | ||
"version": "1.8.0", | ||
"comments": { | ||
"minor": [ | ||
{ | ||
"comment": "feat: enable multiple fast-element instances in browser at once", | ||
"author": "roeisenb@microsoft.com", | ||
"commit": "0e506c6c67a8a7d75e4ef9cfbd000f9da810dc14", | ||
"package": "@microsoft/fast-element" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"date": "Fri, 25 Feb 2022 17:09:32 GMT", | ||
"tag": "@microsoft/fast-element_v1.7.2", | ||
@@ -8,0 +23,0 @@ "version": "1.7.2", |
# Change Log - @microsoft/fast-element | ||
This log was last generated on Fri, 25 Feb 2022 17:06:57 GMT and should not be manually modified. | ||
This log was last generated on Tue, 08 Mar 2022 07:10:44 GMT and should not be manually modified. | ||
<!-- Start content --> | ||
## 1.8.0 | ||
Tue, 08 Mar 2022 07:10:44 GMT | ||
### Minor changes | ||
- feat: enable multiple fast-element instances in browser at once (roeisenb@microsoft.com) | ||
## 1.7.2 | ||
Fri, 25 Feb 2022 17:06:57 GMT | ||
Fri, 25 Feb 2022 17:09:32 GMT | ||
@@ -11,0 +19,0 @@ ### Patches |
@@ -47,3 +47,3 @@ import { ComposableStyles, ElementStyles } from "../styles/element-styles"; | ||
*/ | ||
readonly isDefined: boolean; | ||
get isDefined(): boolean; | ||
/** | ||
@@ -97,3 +97,3 @@ * The name of the custom element. | ||
*/ | ||
static forType<TType extends Function>(type: TType): FASTElementDefinition | undefined; | ||
static readonly forType: <TType_1 extends Function>(key: TType_1) => FASTElementDefinition<Function> | undefined; | ||
} |
@@ -70,3 +70,3 @@ import type { Callable } from "./interfaces"; | ||
*/ | ||
queueUpdate(callable: Callable): void; | ||
queueUpdate: (callable: Callable) => void; | ||
/** | ||
@@ -79,3 +79,3 @@ * Immediately processes all work previously scheduled | ||
*/ | ||
processUpdates(): void; | ||
processUpdates: () => void; | ||
/** | ||
@@ -82,0 +82,0 @@ * Resolves with the next DOM update. |
@@ -24,2 +24,44 @@ import type { Notifier, Subscriber } from "./notifier"; | ||
/** | ||
* The signature of an arrow function capable of being evaluated | ||
* as part of a template binding update. | ||
* @public | ||
*/ | ||
export declare type Binding<TSource = any, TReturn = any, TParent = any> = (source: TSource, context: ExecutionContext<TParent>) => TReturn; | ||
/** | ||
* A record of observable property access. | ||
* @public | ||
*/ | ||
export interface ObservationRecord { | ||
/** | ||
* The source object with an observable property that was accessed. | ||
*/ | ||
propertySource: any; | ||
/** | ||
* The name of the observable property on {@link ObservationRecord.propertySource} that was accessed. | ||
*/ | ||
propertyName: string; | ||
} | ||
/** | ||
* Enables evaluation of and subscription to a binding. | ||
* @public | ||
*/ | ||
export interface BindingObserver<TSource = any, TReturn = any, TParent = any> extends Notifier { | ||
/** | ||
* Begins observing the binding for the source and returns the current value. | ||
* @param source - The source that the binding is based on. | ||
* @param context - The execution context to execute the binding within. | ||
* @returns The value of the binding. | ||
*/ | ||
observe(source: TSource, context: ExecutionContext<TParent>): TReturn; | ||
/** | ||
* Unsubscribe from all dependent observables of the binding. | ||
*/ | ||
disconnect(): void; | ||
/** | ||
* Gets {@link ObservationRecord|ObservationRecords} that the {@link BindingObserver} | ||
* is observing. | ||
*/ | ||
records(): IterableIterator<ObservationRecord>; | ||
} | ||
/** | ||
* Common Observable APIs. | ||
@@ -38,3 +80,3 @@ * @public | ||
*/ | ||
getNotifier(source: any): Notifier; | ||
getNotifier: (source: any) => Notifier; | ||
/** | ||
@@ -69,3 +111,3 @@ * Records a property change for a source object. | ||
*/ | ||
getAccessors(target: {}): Accessor[]; | ||
getAccessors: (target: {}) => Accessor[]; | ||
/** | ||
@@ -102,7 +144,2 @@ * Creates a {@link BindingObserver} that can watch the | ||
/** | ||
* @param event - The event to set as current for the context. | ||
* @internal | ||
*/ | ||
export declare function setCurrentEvent(event: Event | null): void; | ||
/** | ||
* Provides additional contextual information available to behaviors and expressions. | ||
@@ -157,2 +194,8 @@ * @public | ||
get isLast(): boolean; | ||
/** | ||
* Sets the event for the current execution context. | ||
* @param event - The event to set. | ||
* @internal | ||
*/ | ||
static setEvent(event: Event | null): void; | ||
} | ||
@@ -164,43 +207,1 @@ /** | ||
export declare const defaultExecutionContext: ExecutionContext<any, any>; | ||
/** | ||
* The signature of an arrow function capable of being evaluated | ||
* as part of a template binding update. | ||
* @public | ||
*/ | ||
export declare type Binding<TSource = any, TReturn = any, TParent = any> = (source: TSource, context: ExecutionContext<TParent>) => TReturn; | ||
/** | ||
* A record of observable property access. | ||
* @public | ||
*/ | ||
export interface ObservationRecord { | ||
/** | ||
* The source object with an observable property that was accessed. | ||
*/ | ||
propertySource: any; | ||
/** | ||
* The name of the observable property on {@link ObservationRecord.propertySource} that was accessed. | ||
*/ | ||
propertyName: string; | ||
} | ||
/** | ||
* Enables evaluation of and subscription to a binding. | ||
* @public | ||
*/ | ||
export interface BindingObserver<TSource = any, TReturn = any, TParent = any> extends Notifier { | ||
/** | ||
* Begins observing the binding for the source and returns the current value. | ||
* @param source - The source that the binding is based on. | ||
* @param context - The execution context to execute the binding within. | ||
* @returns The value of the binding. | ||
*/ | ||
observe(source: TSource, context: ExecutionContext): TReturn; | ||
/** | ||
* Unsubscribe from all dependent observables of the binding. | ||
*/ | ||
disconnect(): void; | ||
/** | ||
* Gets {@link ObservationRecord|ObservationRecords} that the {@link BindingObserver} | ||
* is observing. | ||
*/ | ||
records(): IterableIterator<ObservationRecord>; | ||
} |
@@ -25,2 +25,19 @@ /** | ||
/** | ||
* The FAST global. | ||
* @internal | ||
*/ | ||
export interface FASTGlobal { | ||
/** | ||
* The list of loaded versions. | ||
*/ | ||
readonly versions: string[]; | ||
/** | ||
* Gets a kernel value. | ||
* @param id - The id to get the value for. | ||
* @param initialize - Creates the initial value for the id if not already existing. | ||
*/ | ||
getById<T>(id: string | number): T | null; | ||
getById<T>(id: string | number, initialize: () => T): T; | ||
} | ||
/** | ||
* The platform global type. | ||
@@ -34,2 +51,7 @@ * @public | ||
trustedTypes: TrustedTypes; | ||
/** | ||
* The FAST global. | ||
* @internal | ||
*/ | ||
readonly FAST: FASTGlobal; | ||
}; | ||
@@ -43,2 +65,17 @@ /** | ||
/** | ||
* The FAST global. | ||
* @internal | ||
*/ | ||
export declare const FAST: FASTGlobal; | ||
/** | ||
* Core services shared across FAST instances. | ||
* @internal | ||
*/ | ||
export declare const enum KernelServiceId { | ||
updateQueue = 1, | ||
observable = 2, | ||
contextEvent = 3, | ||
elementRegistry = 4 | ||
} | ||
/** | ||
* A readonly, empty array. | ||
@@ -45,0 +82,0 @@ * @remarks |
@@ -0,1 +1,2 @@ | ||
import { FAST } from "../platform"; | ||
import { Observable } from "../observation/observable"; | ||
@@ -6,3 +7,17 @@ import { ElementStyles } from "../styles/element-styles"; | ||
const defaultElementOptions = {}; | ||
const fastDefinitions = new Map(); | ||
const fastRegistry = FAST.getById(4 /* elementRegistry */, () => { | ||
const typeToDefinition = new Map(); | ||
return Object.freeze({ | ||
register(definition) { | ||
if (typeToDefinition.has(definition.type)) { | ||
return false; | ||
} | ||
typeToDefinition.set(definition.type, definition); | ||
return true; | ||
}, | ||
getByType(key) { | ||
return typeToDefinition.get(key); | ||
}, | ||
}); | ||
}); | ||
/** | ||
@@ -60,2 +75,8 @@ * Defines metadata for a FASTElement. | ||
/** | ||
* Indicates if this element has been defined in at least one registry. | ||
*/ | ||
get isDefined() { | ||
return !!fastRegistry.getByType(this.type); | ||
} | ||
/** | ||
* Defines a custom element based on this definition. | ||
@@ -66,3 +87,3 @@ * @param registry - The element registry to define the element in. | ||
const type = this.type; | ||
if (!this.isDefined) { | ||
if (fastRegistry.register(this)) { | ||
const attributes = this.attributes; | ||
@@ -77,4 +98,2 @@ const proto = type.prototype; | ||
}); | ||
fastDefinitions.set(type, this); | ||
this.isDefined = true; | ||
} | ||
@@ -86,9 +105,7 @@ if (!registry.get(this.name)) { | ||
} | ||
/** | ||
* Gets the element definition associated with the specified type. | ||
* @param type - The custom element type to retrieve the definition for. | ||
*/ | ||
static forType(type) { | ||
return fastDefinitions.get(type); | ||
} | ||
} | ||
/** | ||
* Gets the element definition associated with the specified type. | ||
* @param type - The custom element type to retrieve the definition for. | ||
*/ | ||
FASTElementDefinition.forType = fastRegistry.getByType; |
import { $global } from "./platform"; | ||
const updateQueue = []; | ||
const updateQueue = $global.FAST.getById(1 /* updateQueue */, () => { | ||
const tasks = []; | ||
const pendingErrors = []; | ||
function throwFirstError() { | ||
if (pendingErrors.length) { | ||
throw pendingErrors.shift(); | ||
} | ||
} | ||
function tryRunTask(task) { | ||
try { | ||
task.call(); | ||
} | ||
catch (error) { | ||
pendingErrors.push(error); | ||
setTimeout(throwFirstError, 0); | ||
} | ||
} | ||
function process() { | ||
const capacity = 1024; | ||
let index = 0; | ||
while (index < tasks.length) { | ||
tryRunTask(tasks[index]); | ||
index++; | ||
// Prevent leaking memory for long chains of recursive calls to `DOM.queueUpdate`. | ||
// If we call `DOM.queueUpdate` within a task scheduled by `DOM.queueUpdate`, the queue will | ||
// grow, but to avoid an O(n) walk for every task we execute, we don't | ||
// shift tasks off the queue after they have been executed. | ||
// Instead, we periodically shift 1024 tasks off the queue. | ||
if (index > capacity) { | ||
// Manually shift all values starting at the index back to the | ||
// beginning of the queue. | ||
for (let scan = 0, newLength = tasks.length - index; scan < newLength; scan++) { | ||
tasks[scan] = tasks[scan + index]; | ||
} | ||
tasks.length -= index; | ||
index = 0; | ||
} | ||
} | ||
tasks.length = 0; | ||
} | ||
function enqueue(callable) { | ||
if (tasks.length < 1) { | ||
$global.requestAnimationFrame(process); | ||
} | ||
tasks.push(callable); | ||
} | ||
return Object.freeze({ | ||
enqueue, | ||
process, | ||
}); | ||
}); | ||
/* eslint-disable */ | ||
@@ -9,18 +59,2 @@ const fastHTMLPolicy = $global.trustedTypes.createPolicy("fast-html", { | ||
let htmlPolicy = fastHTMLPolicy; | ||
// We use a queue so we can ensure errors are thrown in order. | ||
const pendingErrors = []; | ||
function throwFirstError() { | ||
if (pendingErrors.length) { | ||
throw pendingErrors.shift(); | ||
} | ||
} | ||
function tryRunTask(task) { | ||
try { | ||
task.call(); | ||
} | ||
catch (error) { | ||
pendingErrors.push(error); | ||
setTimeout(throwFirstError, 0); | ||
} | ||
} | ||
const marker = `fast-${Math.random().toString(36).substring(2, 8)}`; | ||
@@ -112,8 +146,3 @@ /** @internal */ | ||
*/ | ||
queueUpdate(callable) { | ||
if (updateQueue.length < 1) { | ||
window.requestAnimationFrame(DOM.processUpdates); | ||
} | ||
updateQueue.push(callable); | ||
}, | ||
queueUpdate: updateQueue.enqueue, | ||
/** | ||
@@ -126,25 +155,3 @@ * Immediately processes all work previously scheduled | ||
*/ | ||
processUpdates() { | ||
const capacity = 1024; | ||
let index = 0; | ||
while (index < updateQueue.length) { | ||
tryRunTask(updateQueue[index]); | ||
index++; | ||
// Prevent leaking memory for long chains of recursive calls to `DOM.queueUpdate`. | ||
// If we call `DOM.queueUpdate` within a task scheduled by `DOM.queueUpdate`, the queue will | ||
// grow, but to avoid an O(n) walk for every task we execute, we don't | ||
// shift tasks off the queue after they have been executed. | ||
// Instead, we periodically shift 1024 tasks off the queue. | ||
if (index > capacity) { | ||
// Manually shift all values starting at the index back to the | ||
// beginning of the queue. | ||
for (let scan = 0, newLength = updateQueue.length - index; scan < newLength; scan++) { | ||
updateQueue[scan] = updateQueue[scan + index]; | ||
} | ||
updateQueue.length -= index; | ||
index = 0; | ||
} | ||
} | ||
updateQueue.length = 0; | ||
}, | ||
processUpdates: updateQueue.process, | ||
/** | ||
@@ -154,5 +161,3 @@ * Resolves with the next DOM update. | ||
nextUpdate() { | ||
return new Promise((resolve) => { | ||
DOM.queueUpdate(resolve); | ||
}); | ||
return new Promise(updateQueue.enqueue); | ||
}, | ||
@@ -159,0 +164,0 @@ /** |
import { DOM } from "../dom"; | ||
import { PropertyChangeNotifier, SubscriberSet } from "./notifier"; | ||
const volatileRegex = /(:|&&|\|\||if)/; | ||
const notifierLookup = new WeakMap(); | ||
const accessorLookup = new WeakMap(); | ||
let watcher = void 0; | ||
let createArrayObserver = (array) => { | ||
throw new Error("Must call enableArrayObservation before observing arrays."); | ||
}; | ||
class DefaultObservableAccessor { | ||
constructor(name) { | ||
this.name = name; | ||
this.field = `_${name}`; | ||
this.callback = `${name}Changed`; | ||
} | ||
getValue(source) { | ||
if (watcher !== void 0) { | ||
watcher.watch(source, this.name); | ||
} | ||
return source[this.field]; | ||
} | ||
setValue(source, newValue) { | ||
const field = this.field; | ||
const oldValue = source[field]; | ||
if (oldValue !== newValue) { | ||
source[field] = newValue; | ||
const callback = source[this.callback]; | ||
if (typeof callback === "function") { | ||
callback.call(source, oldValue, newValue); | ||
} | ||
/* eslint-disable-next-line @typescript-eslint/no-use-before-define */ | ||
getNotifier(source).notify(this.name); | ||
} | ||
} | ||
} | ||
import { FAST } from "../platform"; | ||
/** | ||
@@ -40,15 +8,12 @@ * Common Observable APIs. | ||
*/ | ||
export const Observable = Object.freeze({ | ||
/** | ||
* @internal | ||
* @param factory - The factory used to create array observers. | ||
*/ | ||
setArrayObserverFactory(factory) { | ||
createArrayObserver = factory; | ||
}, | ||
/** | ||
* Gets a notifier for an object or Array. | ||
* @param source - The object or Array to get the notifier for. | ||
*/ | ||
getNotifier(source) { | ||
export const Observable = FAST.getById(2 /* observable */, () => { | ||
const volatileRegex = /(:|&&|\|\||if)/; | ||
const notifierLookup = new WeakMap(); | ||
const accessorLookup = new WeakMap(); | ||
const queueUpdate = DOM.queueUpdate; | ||
let watcher = void 0; | ||
let createArrayObserver = (array) => { | ||
throw new Error("Must call enableArrayObservation before observing arrays."); | ||
}; | ||
function getNotifier(source) { | ||
let found = source.$fastController || notifierLookup.get(source); | ||
@@ -64,58 +29,4 @@ if (found === void 0) { | ||
return found; | ||
}, | ||
/** | ||
* Records a property change for a source object. | ||
* @param source - The object to record the change against. | ||
* @param propertyName - The property to track as changed. | ||
*/ | ||
track(source, propertyName) { | ||
if (watcher !== void 0) { | ||
watcher.watch(source, propertyName); | ||
} | ||
}, | ||
/** | ||
* Notifies watchers that the currently executing property getter or function is volatile | ||
* with respect to its observable dependencies. | ||
*/ | ||
trackVolatile() { | ||
if (watcher !== void 0) { | ||
watcher.needsRefresh = true; | ||
} | ||
}, | ||
/** | ||
* Notifies subscribers of a source object of changes. | ||
* @param source - the object to notify of changes. | ||
* @param args - The change args to pass to subscribers. | ||
*/ | ||
notify(source, args) { | ||
/* eslint-disable-next-line @typescript-eslint/no-use-before-define */ | ||
getNotifier(source).notify(args); | ||
}, | ||
/** | ||
* Defines an observable property on an object or prototype. | ||
* @param target - The target object to define the observable on. | ||
* @param nameOrAccessor - The name of the property to define as observable; | ||
* or a custom accessor that specifies the property name and accessor implementation. | ||
*/ | ||
defineProperty(target, nameOrAccessor) { | ||
if (typeof nameOrAccessor === "string") { | ||
nameOrAccessor = new DefaultObservableAccessor(nameOrAccessor); | ||
} | ||
this.getAccessors(target).push(nameOrAccessor); | ||
Reflect.defineProperty(target, nameOrAccessor.name, { | ||
enumerable: true, | ||
get: function () { | ||
return nameOrAccessor.getValue(this); | ||
}, | ||
set: function (newValue) { | ||
nameOrAccessor.setValue(this, newValue); | ||
}, | ||
}); | ||
}, | ||
/** | ||
* Finds all the observable accessors defined on the target, | ||
* including its prototype chain. | ||
* @param target - The target object to search for accessor on. | ||
*/ | ||
getAccessors(target) { | ||
} | ||
function getAccessors(target) { | ||
let accessors = accessorLookup.get(target); | ||
@@ -137,26 +48,211 @@ if (accessors === void 0) { | ||
return accessors; | ||
}, | ||
/** | ||
* Creates a {@link BindingObserver} that can watch the | ||
* provided {@link Binding} for changes. | ||
* @param binding - The binding to observe. | ||
* @param initialSubscriber - An initial subscriber to changes in the binding value. | ||
* @param isVolatileBinding - Indicates whether the binding's dependency list must be re-evaluated on every value evaluation. | ||
*/ | ||
binding(binding, initialSubscriber, isVolatileBinding = this.isVolatileBinding(binding)) { | ||
/* eslint-disable-next-line @typescript-eslint/no-use-before-define */ | ||
return new BindingObserverImplementation(binding, initialSubscriber, isVolatileBinding); | ||
}, | ||
/** | ||
* Determines whether a binding expression is volatile and needs to have its dependency list re-evaluated | ||
* on every evaluation of the value. | ||
* @param binding - The binding to inspect. | ||
*/ | ||
isVolatileBinding(binding) { | ||
return volatileRegex.test(binding.toString()); | ||
}, | ||
} | ||
class DefaultObservableAccessor { | ||
constructor(name) { | ||
this.name = name; | ||
this.field = `_${name}`; | ||
this.callback = `${name}Changed`; | ||
} | ||
getValue(source) { | ||
if (watcher !== void 0) { | ||
watcher.watch(source, this.name); | ||
} | ||
return source[this.field]; | ||
} | ||
setValue(source, newValue) { | ||
const field = this.field; | ||
const oldValue = source[field]; | ||
if (oldValue !== newValue) { | ||
source[field] = newValue; | ||
const callback = source[this.callback]; | ||
if (typeof callback === "function") { | ||
callback.call(source, oldValue, newValue); | ||
} | ||
getNotifier(source).notify(this.name); | ||
} | ||
} | ||
} | ||
class BindingObserverImplementation extends SubscriberSet { | ||
constructor(binding, initialSubscriber, isVolatileBinding = false) { | ||
super(binding, initialSubscriber); | ||
this.binding = binding; | ||
this.isVolatileBinding = isVolatileBinding; | ||
this.needsRefresh = true; | ||
this.needsQueue = true; | ||
this.first = this; | ||
this.last = null; | ||
this.propertySource = void 0; | ||
this.propertyName = void 0; | ||
this.notifier = void 0; | ||
this.next = void 0; | ||
} | ||
observe(source, context) { | ||
if (this.needsRefresh && this.last !== null) { | ||
this.disconnect(); | ||
} | ||
const previousWatcher = watcher; | ||
watcher = this.needsRefresh ? this : void 0; | ||
this.needsRefresh = this.isVolatileBinding; | ||
const result = this.binding(source, context); | ||
watcher = previousWatcher; | ||
return result; | ||
} | ||
disconnect() { | ||
if (this.last !== null) { | ||
let current = this.first; | ||
while (current !== void 0) { | ||
current.notifier.unsubscribe(this, current.propertyName); | ||
current = current.next; | ||
} | ||
this.last = null; | ||
this.needsRefresh = this.needsQueue = true; | ||
} | ||
} | ||
watch(propertySource, propertyName) { | ||
const prev = this.last; | ||
const notifier = getNotifier(propertySource); | ||
const current = prev === null ? this.first : {}; | ||
current.propertySource = propertySource; | ||
current.propertyName = propertyName; | ||
current.notifier = notifier; | ||
notifier.subscribe(this, propertyName); | ||
if (prev !== null) { | ||
if (!this.needsRefresh) { | ||
// Declaring the variable prior to assignment below circumvents | ||
// a bug in Angular's optimization process causing infinite recursion | ||
// of this watch() method. Details https://github.com/microsoft/fast/issues/4969 | ||
let prevValue; | ||
watcher = void 0; | ||
/* eslint-disable-next-line */ | ||
prevValue = prev.propertySource[prev.propertyName]; | ||
watcher = this; | ||
if (propertySource === prevValue) { | ||
this.needsRefresh = true; | ||
} | ||
} | ||
prev.next = current; | ||
} | ||
this.last = current; | ||
} | ||
handleChange() { | ||
if (this.needsQueue) { | ||
this.needsQueue = false; | ||
queueUpdate(this); | ||
} | ||
} | ||
call() { | ||
if (this.last !== null) { | ||
this.needsQueue = true; | ||
this.notify(this); | ||
} | ||
} | ||
records() { | ||
let next = this.first; | ||
return { | ||
next: () => { | ||
const current = next; | ||
if (current === undefined) { | ||
return { value: void 0, done: true }; | ||
} | ||
else { | ||
next = next.next; | ||
return { | ||
value: current, | ||
done: false, | ||
}; | ||
} | ||
}, | ||
[Symbol.iterator]: function () { | ||
return this; | ||
}, | ||
}; | ||
} | ||
} | ||
return Object.freeze({ | ||
/** | ||
* @internal | ||
* @param factory - The factory used to create array observers. | ||
*/ | ||
setArrayObserverFactory(factory) { | ||
createArrayObserver = factory; | ||
}, | ||
/** | ||
* Gets a notifier for an object or Array. | ||
* @param source - The object or Array to get the notifier for. | ||
*/ | ||
getNotifier, | ||
/** | ||
* Records a property change for a source object. | ||
* @param source - The object to record the change against. | ||
* @param propertyName - The property to track as changed. | ||
*/ | ||
track(source, propertyName) { | ||
if (watcher !== void 0) { | ||
watcher.watch(source, propertyName); | ||
} | ||
}, | ||
/** | ||
* Notifies watchers that the currently executing property getter or function is volatile | ||
* with respect to its observable dependencies. | ||
*/ | ||
trackVolatile() { | ||
if (watcher !== void 0) { | ||
watcher.needsRefresh = true; | ||
} | ||
}, | ||
/** | ||
* Notifies subscribers of a source object of changes. | ||
* @param source - the object to notify of changes. | ||
* @param args - The change args to pass to subscribers. | ||
*/ | ||
notify(source, args) { | ||
getNotifier(source).notify(args); | ||
}, | ||
/** | ||
* Defines an observable property on an object or prototype. | ||
* @param target - The target object to define the observable on. | ||
* @param nameOrAccessor - The name of the property to define as observable; | ||
* or a custom accessor that specifies the property name and accessor implementation. | ||
*/ | ||
defineProperty(target, nameOrAccessor) { | ||
if (typeof nameOrAccessor === "string") { | ||
nameOrAccessor = new DefaultObservableAccessor(nameOrAccessor); | ||
} | ||
getAccessors(target).push(nameOrAccessor); | ||
Reflect.defineProperty(target, nameOrAccessor.name, { | ||
enumerable: true, | ||
get: function () { | ||
return nameOrAccessor.getValue(this); | ||
}, | ||
set: function (newValue) { | ||
nameOrAccessor.setValue(this, newValue); | ||
}, | ||
}); | ||
}, | ||
/** | ||
* Finds all the observable accessors defined on the target, | ||
* including its prototype chain. | ||
* @param target - The target object to search for accessor on. | ||
*/ | ||
getAccessors, | ||
/** | ||
* Creates a {@link BindingObserver} that can watch the | ||
* provided {@link Binding} for changes. | ||
* @param binding - The binding to observe. | ||
* @param initialSubscriber - An initial subscriber to changes in the binding value. | ||
* @param isVolatileBinding - Indicates whether the binding's dependency list must be re-evaluated on every value evaluation. | ||
*/ | ||
binding(binding, initialSubscriber, isVolatileBinding = this.isVolatileBinding(binding)) { | ||
return new BindingObserverImplementation(binding, initialSubscriber, isVolatileBinding); | ||
}, | ||
/** | ||
* Determines whether a binding expression is volatile and needs to have its dependency list re-evaluated | ||
* on every evaluation of the value. | ||
* @param binding - The binding to inspect. | ||
*/ | ||
isVolatileBinding(binding) { | ||
return volatileRegex.test(binding.toString()); | ||
}, | ||
}); | ||
}); | ||
const getNotifier = Observable.getNotifier; | ||
const trackVolatile = Observable.trackVolatile; | ||
const queueUpdate = DOM.queueUpdate; | ||
/** | ||
@@ -181,3 +277,3 @@ * Decorator: Defines an observable property on the target. | ||
get: function () { | ||
trackVolatile(); | ||
Observable.trackVolatile(); | ||
return descriptor.get.apply(this); | ||
@@ -187,11 +283,14 @@ }, | ||
} | ||
let currentEvent = null; | ||
const contextEvent = FAST.getById(3 /* contextEvent */, () => { | ||
let current = null; | ||
return { | ||
get() { | ||
return current; | ||
}, | ||
set(event) { | ||
current = event; | ||
}, | ||
}; | ||
}); | ||
/** | ||
* @param event - The event to set as current for the context. | ||
* @internal | ||
*/ | ||
export function setCurrentEvent(event) { | ||
currentEvent = event; | ||
} | ||
/** | ||
* Provides additional contextual information available to behaviors and expressions. | ||
@@ -223,3 +322,3 @@ * @public | ||
get event() { | ||
return currentEvent; | ||
return contextEvent.get(); | ||
} | ||
@@ -261,2 +360,10 @@ /** | ||
} | ||
/** | ||
* Sets the event for the current execution context. | ||
* @param event - The event to set. | ||
* @internal | ||
*/ | ||
static setEvent(event) { | ||
contextEvent.set(event); | ||
} | ||
} | ||
@@ -270,100 +377,1 @@ Observable.defineProperty(ExecutionContext.prototype, "index"); | ||
export const defaultExecutionContext = Object.seal(new ExecutionContext()); | ||
class BindingObserverImplementation extends SubscriberSet { | ||
constructor(binding, initialSubscriber, isVolatileBinding = false) { | ||
super(binding, initialSubscriber); | ||
this.binding = binding; | ||
this.isVolatileBinding = isVolatileBinding; | ||
this.needsRefresh = true; | ||
this.needsQueue = true; | ||
this.first = this; | ||
this.last = null; | ||
this.propertySource = void 0; | ||
this.propertyName = void 0; | ||
this.notifier = void 0; | ||
this.next = void 0; | ||
} | ||
observe(source, context) { | ||
if (this.needsRefresh && this.last !== null) { | ||
this.disconnect(); | ||
} | ||
const previousWatcher = watcher; | ||
watcher = this.needsRefresh ? this : void 0; | ||
this.needsRefresh = this.isVolatileBinding; | ||
const result = this.binding(source, context); | ||
watcher = previousWatcher; | ||
return result; | ||
} | ||
disconnect() { | ||
if (this.last !== null) { | ||
let current = this.first; | ||
while (current !== void 0) { | ||
current.notifier.unsubscribe(this, current.propertyName); | ||
current = current.next; | ||
} | ||
this.last = null; | ||
this.needsRefresh = this.needsQueue = true; | ||
} | ||
} | ||
/** @internal */ | ||
watch(propertySource, propertyName) { | ||
const prev = this.last; | ||
const notifier = getNotifier(propertySource); | ||
const current = prev === null ? this.first : {}; | ||
current.propertySource = propertySource; | ||
current.propertyName = propertyName; | ||
current.notifier = notifier; | ||
notifier.subscribe(this, propertyName); | ||
if (prev !== null) { | ||
if (!this.needsRefresh) { | ||
// Declaring the variable prior to assignment below circumvents | ||
// a bug in Angular's optimization process causing infinite recursion | ||
// of this watch() method. Details https://github.com/microsoft/fast/issues/4969 | ||
let prevValue; | ||
watcher = void 0; | ||
/* eslint-disable-next-line */ | ||
prevValue = prev.propertySource[prev.propertyName]; | ||
watcher = this; | ||
if (propertySource === prevValue) { | ||
this.needsRefresh = true; | ||
} | ||
} | ||
prev.next = current; | ||
} | ||
this.last = current; | ||
} | ||
/** @internal */ | ||
handleChange() { | ||
if (this.needsQueue) { | ||
this.needsQueue = false; | ||
queueUpdate(this); | ||
} | ||
} | ||
/** @internal */ | ||
call() { | ||
if (this.last !== null) { | ||
this.needsQueue = true; | ||
this.notify(this); | ||
} | ||
} | ||
records() { | ||
let next = this.first; | ||
return { | ||
next: () => { | ||
const current = next; | ||
if (current === undefined) { | ||
return { value: void 0, done: true }; | ||
} | ||
else { | ||
next = next.next; | ||
return { | ||
value: current, | ||
done: false, | ||
}; | ||
} | ||
}, | ||
[Symbol.iterator]: function () { | ||
return this; | ||
}, | ||
}; | ||
} | ||
} |
@@ -39,3 +39,26 @@ /** | ||
} | ||
const propConfig = { | ||
configurable: false, | ||
enumerable: false, | ||
writable: false, | ||
}; | ||
if ($global.FAST === void 0) { | ||
Reflect.defineProperty($global, "FAST", Object.assign({ value: Object.create(null) }, propConfig)); | ||
} | ||
/** | ||
* The FAST global. | ||
* @internal | ||
*/ | ||
export const FAST = $global.FAST; | ||
if (FAST.getById === void 0) { | ||
const storage = Object.create(null); | ||
Reflect.defineProperty(FAST, "getById", Object.assign({ value(id, initialize) { | ||
let found = storage[id]; | ||
if (found === void 0) { | ||
found = initialize ? (storage[id] = initialize()) : null; | ||
} | ||
return found; | ||
} }, propConfig)); | ||
} | ||
/** | ||
* A readonly, empty array. | ||
@@ -42,0 +65,0 @@ * @remarks |
import { DOM } from "../dom"; | ||
import { Observable, setCurrentEvent, } from "../observation/observable"; | ||
import { ExecutionContext, Observable, } from "../observation/observable"; | ||
import { TargetedHTMLDirective } from "./html-directive"; | ||
@@ -245,5 +245,5 @@ function normalBind(source, context) { | ||
handleEvent(event) { | ||
setCurrentEvent(event); | ||
ExecutionContext.setEvent(event); | ||
const result = this.binding(this.source, this.context); | ||
setCurrentEvent(null); | ||
ExecutionContext.setEvent(null); | ||
if (result !== true) { | ||
@@ -250,0 +250,0 @@ event.preventDefault(); |
@@ -1,1 +0,1 @@ | ||
const t=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===t.trustedTypes&&(t.trustedTypes={createPolicy:(t,e)=>e});const e=Object.freeze([]),s=[],i=t.trustedTypes.createPolicy("fast-html",{createHTML:t=>t});let n=i;const r=[];function o(){if(r.length)throw r.shift()}function l(t){try{t.call()}catch(t){r.push(t),setTimeout(o,0)}}const h="fast-"+Math.random().toString(36).substring(2,8),a=h+"{",c="}"+h,d=Object.freeze({supportsAdoptedStyleSheets:Array.isArray(document.adoptedStyleSheets)&&"replace"in CSSStyleSheet.prototype,setHTMLPolicy(t){if(n!==i)throw new Error("The HTML policy can only be set once.");n=t},createHTML:t=>n.createHTML(t),isMarker:t=>t&&8===t.nodeType&&t.data.startsWith(h),extractDirectiveIndexFromMarker:t=>parseInt(t.data.replace(h+":","")),createInterpolationPlaceholder:t=>`${a}${t}${c}`,createCustomAttributePlaceholder(t,e){return`${t}="${this.createInterpolationPlaceholder(e)}"`},createBlockPlaceholder:t=>`\x3c!--${h}:${t}--\x3e`,queueUpdate(t){s.length<1&&window.requestAnimationFrame(d.processUpdates),s.push(t)},processUpdates(){let t=0;for(;t<s.length;)if(l(s[t]),t++,t>1024){for(let e=0,i=s.length-t;e<i;e++)s[e]=s[e+t];s.length-=t,t=0}s.length=0},nextUpdate:()=>new Promise(t=>{d.queueUpdate(t)}),setAttribute(t,e,s){null==s?t.removeAttribute(e):t.setAttribute(e,s)},setBooleanAttribute(t,e,s){s?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)});function u(t){const e=this.spillover;-1===e.indexOf(t)&&e.push(t)}function f(t){const e=this.spillover,s=e.indexOf(t);-1!==s&&e.splice(s,1)}function p(t){const e=this.spillover,s=this.source;for(let i=0,n=e.length;i<n;++i)e[i].handleChange(s,t)}function g(t){return-1!==this.spillover.indexOf(t)}class b{constructor(t,e){this.sub1=void 0,this.sub2=void 0,this.spillover=void 0,this.source=t,this.sub1=e}has(t){return this.sub1===t||this.sub2===t}subscribe(t){this.has(t)||(void 0!==this.sub1?void 0!==this.sub2?(this.spillover=[this.sub1,this.sub2,t],this.subscribe=u,this.unsubscribe=f,this.notify=p,this.has=g,this.sub1=void 0,this.sub2=void 0):this.sub2=t:this.sub1=t)}unsubscribe(t){this.sub1===t?this.sub1=void 0:this.sub2===t&&(this.sub2=void 0)}notify(t){const e=this.sub1,s=this.sub2,i=this.source;void 0!==e&&e.handleChange(i,t),void 0!==s&&s.handleChange(i,t)}}class v{constructor(t){this.subscribers={},this.sourceSubscribers=null,this.source=t}notify(t){var e;const s=this.subscribers[t];void 0!==s&&s.notify(t),null===(e=this.sourceSubscribers)||void 0===e||e.notify(t)}subscribe(t,e){var s;if(e){let s=this.subscribers[e];void 0===s&&(this.subscribers[e]=s=new b(this.source)),s.subscribe(t)}else this.sourceSubscribers=null!==(s=this.sourceSubscribers)&&void 0!==s?s:new b(this.source),this.sourceSubscribers.subscribe(t)}unsubscribe(t,e){var s;if(e){const s=this.subscribers[e];void 0!==s&&s.unsubscribe(t)}else null===(s=this.sourceSubscribers)||void 0===s||s.unsubscribe(t)}}const m=/(:|&&|\|\||if)/,y=new WeakMap,C=new WeakMap;let x=void 0,w=t=>{throw new Error("Must call enableArrayObservation before observing arrays.")};class S{constructor(t){this.name=t,this.field="_"+t,this.callback=t+"Changed"}getValue(t){return void 0!==x&&x.watch(t,this.name),t[this.field]}setValue(t,e){const s=this.field,i=t[s];if(i!==e){t[s]=e;const n=t[this.callback];"function"==typeof n&&n.call(t,i,e),T(t).notify(this.name)}}}const B=Object.freeze({setArrayObserverFactory(t){w=t},getNotifier(t){let e=t.$fastController||y.get(t);return void 0===e&&(Array.isArray(t)?e=w(t):y.set(t,e=new v(t))),e},track(t,e){void 0!==x&&x.watch(t,e)},trackVolatile(){void 0!==x&&(x.needsRefresh=!0)},notify(t,e){T(t).notify(e)},defineProperty(t,e){"string"==typeof e&&(e=new S(e)),this.getAccessors(t).push(e),Reflect.defineProperty(t,e.name,{enumerable:!0,get:function(){return e.getValue(this)},set:function(t){e.setValue(this,t)}})},getAccessors(t){let e=C.get(t);if(void 0===e){let s=Reflect.getPrototypeOf(t);for(;void 0===e&&null!==s;)e=C.get(s),s=Reflect.getPrototypeOf(s);e=void 0===e?[]:e.slice(0),C.set(t,e)}return e},binding(t,e,s=this.isVolatileBinding(t)){return new I(t,e,s)},isVolatileBinding:t=>m.test(t.toString())}),T=B.getNotifier,O=B.trackVolatile,N=d.queueUpdate;function A(t,e){B.defineProperty(t,e)}function k(t,e,s){return Object.assign({},s,{get:function(){return O(),s.get.apply(this)}})}let V=null;function F(t){V=t}class ${constructor(){this.index=0,this.length=0,this.parent=null,this.parentContext=null}get event(){return V}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}}B.defineProperty($.prototype,"index"),B.defineProperty($.prototype,"length");const _=Object.seal(new $);class I extends b{constructor(t,e,s=!1){super(t,e),this.binding=t,this.isVolatileBinding=s,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 s=x;x=this.needsRefresh?this:void 0,this.needsRefresh=this.isVolatileBinding;const i=this.binding(t,e);return x=s,i}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 s=this.last,i=T(t),n=null===s?this.first:{};if(n.propertySource=t,n.propertyName=e,n.notifier=i,i.subscribe(this,e),null!==s){if(!this.needsRefresh){let e;x=void 0,e=s.propertySource[s.propertyName],x=this,t===e&&(this.needsRefresh=!0)}s.next=n}this.last=n}handleChange(){this.needsQueue&&(this.needsQueue=!1,N(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}}}}class M{constructor(){this.targetIndex=0}}class P extends M{constructor(){super(...arguments),this.createPlaceholder=d.createInterpolationPlaceholder}}class E extends M{constructor(t,e,s){super(),this.name=t,this.behavior=e,this.options=s}createPlaceholder(t){return d.createCustomAttributePlaceholder(this.name,t)}createBehavior(t){return new this.behavior(t,this.options)}}function L(t,e){this.source=t,this.context=e,null===this.bindingObserver&&(this.bindingObserver=B.binding(this.binding,this,this.isBindingVolatile)),this.updateTarget(this.bindingObserver.observe(t,e))}function R(t,e){this.source=t,this.context=e,this.target.addEventListener(this.targetName,this)}function j(){this.bindingObserver.disconnect(),this.source=null,this.context=null}function z(){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 H(){this.target.removeEventListener(this.targetName,this),this.source=null,this.context=null}function U(t){d.setAttribute(this.target,this.targetName,t)}function Q(t){d.setBooleanAttribute(this.target,this.targetName,t)}function q(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 W(t){this.target[this.targetName]=t}function D(t){const e=this.classVersions||Object.create(null),s=this.target;let i=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]=i,s.classList.add(r))}}if(this.classVersions=e,this.version=i+1,0!==i){i-=1;for(const t in e)e[t]===i&&s.classList.remove(t)}}class G extends P{constructor(t){super(),this.binding=t,this.bind=L,this.unbind=j,this.updateTarget=U,this.isBindingVolatile=B.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=W,"innerHTML"===this.cleanedTargetName){const t=this.binding;this.binding=(e,s)=>d.createHTML(t(e,s))}break;case"?":this.cleanedTargetName=t.substr(1),this.updateTarget=Q;break;case"@":this.cleanedTargetName=t.substr(1),this.bind=R,this.unbind=H;break;default:this.cleanedTargetName=t,"class"===t&&(this.updateTarget=D)}}targetAtContent(){this.updateTarget=q,this.unbind=z}createBehavior(t){return new J(t,this.binding,this.isBindingVolatile,this.bind,this.unbind,this.updateTarget,this.cleanedTargetName)}}class J{constructor(t,e,s,i,n,r,o){this.source=null,this.context=null,this.bindingObserver=null,this.target=t,this.binding=e,this.isBindingVolatile=s,this.bind=i,this.unbind=n,this.updateTarget=r,this.targetName=o}handleChange(){this.updateTarget(this.bindingObserver.observe(this.source,this.context))}handleEvent(t){F(t);const e=this.binding(this.source,this.context);F(null),!0!==e&&t.preventDefault()}}let K=null;class X{addFactory(t){t.targetIndex=this.targetIndex,this.behaviorFactories.push(t)}captureContentBinding(t){t.targetAtContent(),this.addFactory(t)}reset(){this.behaviorFactories=[],this.targetIndex=-1}release(){K=this}static borrow(t){const e=K||new X;return e.directives=t,e.reset(),K=null,e}}function Y(t){if(1===t.length)return t[0];let e;const s=t.length,i=t.map(t=>"string"==typeof t?()=>t:(e=t.targetName||e,t.binding)),n=new G((t,e)=>{let n="";for(let r=0;r<s;++r)n+=i[r](t,e);return n});return n.targetName=e,n}const Z=c.length;function tt(t,e){const s=e.split(a);if(1===s.length)return null;const i=[];for(let e=0,n=s.length;e<n;++e){const n=s[e],r=n.indexOf(c);let o;if(-1===r)o=n;else{const e=parseInt(n.substring(0,r));i.push(t.directives[e]),o=n.substring(r+Z)}""!==o&&i.push(o)}return i}function et(t,e,s=!1){const i=e.attributes;for(let n=0,r=i.length;n<r;++n){const o=i[n],l=o.value,h=tt(t,l);let a=null;null===h?s&&(a=new G(()=>l),a.targetName=o.name):a=Y(h),null!==a&&(e.removeAttributeNode(o),n--,r--,t.addFactory(a))}}function st(t,e,s){const i=tt(t,e.textContent);if(null!==i){let n=e;for(let r=0,o=i.length;r<o;++r){const o=i[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&&s.nextNode()}t.targetIndex--}}function it(t,e){const s=t.content;document.adoptNode(s);const i=X.borrow(e);et(i,t,!0);const n=i.behaviorFactories;i.reset();const r=d.createTemplateWalker(s);let o;for(;o=r.nextNode();)switch(i.targetIndex++,o.nodeType){case 1:et(i,o);break;case 3:st(i,o,r);break;case 8:d.isMarker(o)&&i.addFactory(e[d.extractDirectiveIndexFromMarker(o)])}let l=0;(d.isMarker(s.firstChild)||1===s.childNodes.length&&e.length)&&(s.insertBefore(document.createComment(""),s.firstChild),l=-1);const h=i.behaviorFactories;return i.release(),{fragment:s,viewBehaviorFactories:h,hostBehaviorFactories:n,targetOffset:l}}const nt=document.createRange();class rt{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,s=this.lastChild;let i,n=this.firstChild;for(;n!==s;)i=n.nextSibling,e.insertBefore(n,t),n=i;e.insertBefore(s,t)}}remove(){const t=this.fragment,e=this.lastChild;let s,i=this.firstChild;for(;i!==e;)s=i.nextSibling,t.appendChild(i),i=s;t.appendChild(e)}dispose(){const t=this.firstChild.parentNode,e=this.lastChild;let s,i=this.firstChild;for(;i!==e;)s=i.nextSibling,t.removeChild(i),i=s;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 s=this.behaviors;if(this.source!==t)if(null!==this.source){const i=this.source;this.source=t,this.context=e;for(let n=0,r=s.length;n<r;++n){const r=s[n];r.unbind(i),r.bind(t,e)}}else{this.source=t,this.context=e;for(let i=0,n=s.length;i<n;++i)s[i].bind(t,e)}}unbind(){if(null===this.source)return;const t=this.behaviors,e=this.source;for(let s=0,i=t.length;s<i;++s)t[s].unbind(e);this.source=null}static disposeContiguousBatch(t){if(0!==t.length){nt.setStartBefore(t[0].firstChild),nt.setEndAfter(t[t.length-1].lastChild),nt.deleteContents();for(let e=0,s=t.length;e<s;++e){const s=t[e],i=s.behaviors,n=s.source;for(let t=0,e=i.length;t<e;++t)i[t].unbind(n)}}}}class ot{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 s=t.content.firstElementChild;null!==s&&"TEMPLATE"===s.tagName&&(t=s)}else t=e;const s=it(t,this.directives);this.fragment=s.fragment,this.viewBehaviorFactories=s.viewBehaviorFactories,this.hostBehaviorFactories=s.hostBehaviorFactories,this.targetOffset=s.targetOffset,this.behaviorCount=this.viewBehaviorFactories.length+this.hostBehaviorFactories.length,this.hasHostBehaviors=this.hostBehaviorFactories.length>0}const e=this.fragment.cloneNode(!0),s=this.viewBehaviorFactories,i=new Array(this.behaviorCount),n=d.createTemplateWalker(e);let r=0,o=this.targetOffset,l=n.nextNode();for(let t=s.length;r<t;++r){const t=s[r],e=t.targetIndex;for(;null!==l;){if(o===e){i[r]=t.createBehavior(l);break}l=n.nextNode(),o++}}if(this.hasHostBehaviors){const e=this.hostBehaviorFactories;for(let s=0,n=e.length;s<n;++s,++r)i[r]=e[s].createBehavior(t)}return new rt(e,i)}render(t,e,s){"string"==typeof e&&(e=document.getElementById(e)),void 0===s&&(s=e);const i=this.create(s);return i.bind(t,_),i.appendTo(e),i}}const lt=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;function ht(t,...e){const s=[];let i="";for(let n=0,r=t.length-1;n<r;++n){const r=t[n];let o=e[n];if(i+=r,o instanceof ot){const t=o;o=()=>t}if("function"==typeof o&&(o=new G(o)),o instanceof P){const t=lt.exec(r);null!==t&&(o.targetName=t[2])}o instanceof M?(i+=o.createPlaceholder(s.length),s.push(o)):i+=o}return i+=t[t.length-1],new ot(i,s)}class at{constructor(){this.targets=new WeakSet,this.behaviors=null}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 ct(t){return t.map(t=>t instanceof at?ct(t.styles):[t]).reduce((t,e)=>t.concat(e),[])}function dt(t){return t.map(t=>t instanceof at?t.behaviors:null).reduce((t,e)=>null===e?t:(null===t&&(t=[]),t.concat(e)),null)}at.create=(()=>{if(d.supportsAdoptedStyleSheets){const t=new Map;return e=>new ut(e,t)}return t=>new pt(t)})();class ut extends at{constructor(t,e){super(),this.styles=t,this.styleSheetCache=e,this._styleSheets=void 0,this.behaviors=dt(t)}get styleSheets(){if(void 0===this._styleSheets){const t=this.styles,e=this.styleSheetCache;this._styleSheets=ct(t).map(t=>{if(t instanceof CSSStyleSheet)return t;let s=e.get(t);return void 0===s&&(s=new CSSStyleSheet,s.replaceSync(t),e.set(t,s)),s})}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 ft=0;class pt extends at{constructor(t){super(),this.styles=t,this.behaviors=null,this.behaviors=dt(t),this.styleSheets=ct(t),this.styleClass="fast-style-class-"+ ++ft}addStylesTo(t){const e=this.styleSheets,s=this.styleClass;t=this.normalizeTarget(t);for(let i=0;i<e.length;i++){const n=document.createElement("style");n.innerHTML=e[i],n.className=s,t.append(n)}super.addStylesTo(t)}removeStylesFrom(t){const e=(t=this.normalizeTarget(t)).querySelectorAll("."+this.styleClass);for(let s=0,i=e.length;s<i;++s)t.removeChild(e[s]);super.removeStylesFrom(t)}isAttachedTo(t){return super.isAttachedTo(this.normalizeTarget(t))}normalizeTarget(t){return t===document?document.body:t}}const gt={toView:t=>t?"true":"false",fromView:t=>null!=t&&"false"!==t&&!1!==t&&0!==t},bt={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 vt{constructor(t,e,s=e.toLowerCase(),i="reflect",n){this.guards=new Set,this.Owner=t,this.name=e,this.attribute=s,this.mode=i,this.converter=n,this.fieldName="_"+e,this.callbackName=e+"Changed",this.hasCallback=this.callbackName in t.prototype,"boolean"===i&&void 0===n&&(this.converter=gt)}setValue(t,e){const s=t[this.fieldName],i=this.converter;void 0!==i&&(e=i.fromView(e)),s!==e&&(t[this.fieldName]=e,this.tryReflectToAttribute(t),this.hasCallback&&t[this.callbackName](s,e),t.$fastController.notify(this.name))}getValue(t){return B.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,s=this.guards;s.has(t)||"fromView"===e||d.queueUpdate(()=>{s.add(t);const i=t[this.fieldName];switch(e){case"reflect":const e=this.converter;d.setAttribute(t,this.attribute,void 0!==e?e.toView(i):i);break;case"boolean":d.setBooleanAttribute(t,this.attribute,i)}s.delete(t)})}static collect(t,...e){const s=[];e.push(t.attributes);for(let i=0,n=e.length;i<n;++i){const n=e[i];if(void 0!==n)for(let e=0,i=n.length;e<i;++e){const i=n[e];"string"==typeof i?s.push(new vt(t,i)):s.push(new vt(t,i.property,i.attribute,i.mode,i.converter))}}return s}}function mt(t,e){let s;function i(t,e){arguments.length>1&&(s.property=e);const i=t.constructor.attributes||(t.constructor.attributes=[]);i.push(s)}return arguments.length>1?(s={},void i(t,e)):(s=void 0===t?{}:t,i)}const yt={mode:"open"},Ct={},xt=new Map;class wt{constructor(t,e=t.definition){"string"==typeof e&&(e={name:e}),this.type=t,this.name=e.name,this.template=e.template;const s=vt.collect(t,e.attributes),i=new Array(s.length),n={},r={};for(let t=0,e=s.length;t<e;++t){const e=s[t];i[t]=e.attribute,n[e.name]=e,r[e.attribute]=e}this.attributes=s,this.observedAttributes=i,this.propertyLookup=n,this.attributeLookup=r,this.shadowOptions=void 0===e.shadowOptions?yt:null===e.shadowOptions?void 0:Object.assign(Object.assign({},yt),e.shadowOptions),this.elementOptions=void 0===e.elementOptions?Ct:Object.assign(Object.assign({},Ct),e.elementOptions),this.styles=void 0===e.styles?void 0:Array.isArray(e.styles)?at.create(e.styles):e.styles instanceof at?e.styles:at.create([e.styles])}define(t=customElements){const e=this.type;if(!this.isDefined){const t=this.attributes,s=e.prototype;for(let e=0,i=t.length;e<i;++e)B.defineProperty(s,t[e]);Reflect.defineProperty(e,"observedAttributes",{value:this.observedAttributes,enumerable:!0}),xt.set(e,this),this.isDefined=!0}return t.get(this.name)||t.define(this.name,e,this.elementOptions),this}static forType(t){return xt.get(t)}}const St=new WeakMap,Bt={bubbles:!0,composed:!0,cancelable:!0};function Tt(t){return t.shadowRoot||St.get(t)||null}class Ot extends v{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 s=e.shadowOptions;if(void 0!==s){const e=t.attachShadow(s);"closed"===s.mode&&St.set(t,e)}const i=B.getAccessors(t);if(i.length>0){const e=this.boundObservables=Object.create(null);for(let s=0,n=i.length;s<n;++s){const n=i[s].name,r=t[n];void 0!==r&&(delete t[n],e[n]=r)}}}get isConnected(){return B.track(this,"isConnected"),this._isConnected}setIsConnected(t){this._isConnected=t,B.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=Tt(this.element)||this.element.getRootNode();if(t instanceof HTMLStyleElement)e.append(t);else if(!t.isAttachedTo(e)){const s=t.behaviors;t.addStylesTo(e),null!==s&&this.addBehaviors(s)}}removeStyles(t){const e=Tt(this.element)||this.element.getRootNode();if(t instanceof HTMLStyleElement)e.removeChild(t);else if(t.isAttachedTo(e)){const s=t.behaviors;t.removeStylesFrom(e),null!==s&&this.removeBehaviors(s)}}addBehaviors(t){const e=this.behaviors||(this.behaviors=new Map),s=t.length,i=[];for(let n=0;n<s;++n){const s=t[n];e.has(s)?e.set(s,e.get(s)+1):(e.set(s,1),i.push(s))}if(this._isConnected){const t=this.element;for(let e=0;e<i.length;++e)i[e].bind(t,_)}}removeBehaviors(t,e=!1){const s=this.behaviors;if(null===s)return;const i=t.length,n=[];for(let r=0;r<i;++r){const i=t[r];if(s.has(i)){const t=s.get(i)-1;0===t||e?s.delete(i)&&n.push(i):s.set(i,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,_);const e=this.behaviors;if(null!==e)for(const[s]of e)s.bind(t,_);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[s]of e)s.unbind(t)}}onAttributeChangedCallback(t,e,s){const i=this.definition.attributeLookup[t];void 0!==i&&i.onAttributeChangedCallback(this.element,s)}emit(t,e,s){return!!this._isConnected&&this.element.dispatchEvent(new CustomEvent(t,Object.assign(Object.assign({detail:e},Bt),s)))}finishInitialization(){const t=this.element,e=this.boundObservables;if(null!==e){const s=Object.keys(e);for(let i=0,n=s.length;i<n;++i){const n=s[i];t[n]=e[n]}this.boundObservables=null}const s=this.definition;null===this._template&&(this.element.resolveTemplate?this._template=this.element.resolveTemplate():s.template&&(this._template=s.template||null)),null!==this._template&&this.renderTemplate(this._template),null===this._styles&&(this.element.resolveStyles?this._styles=this.element.resolveStyles():s.styles&&(this._styles=s.styles||null)),null!==this._styles&&this.addStyles(this._styles),this.needsInitialization=!1}renderTemplate(t){const e=this.element,s=Tt(e)||e;null!==this.view?(this.view.dispose(),this.view=null):this.needsInitialization||d.removeChildNodes(s),t&&(this.view=t.render(e,s,e))}static forCustomElement(t){const e=t.$fastController;if(void 0!==e)return e;const s=wt.forType(t.constructor);if(void 0===s)throw new Error("Missing FASTElement definition.");return t.$fastController=new Ot(t,s)}}function Nt(t){return class extends t{constructor(){super(),Ot.forCustomElement(this)}$emit(t,e,s){return this.$fastController.emit(t,e,s)}connectedCallback(){this.$fastController.onConnectedCallback()}disconnectedCallback(){this.$fastController.onDisconnectedCallback()}attributeChangedCallback(t,e,s){this.$fastController.onAttributeChangedCallback(t,e,s)}}}const At=Object.assign(Nt(HTMLElement),{from:t=>Nt(t),define:(t,e)=>new wt(t,e).define().type});function kt(t){return function(e){new wt(e,t).define()}}class Vt{createCSS(){return""}createBehavior(){}}function Ft(t,e){const s=[];let i="";const n=[];for(let r=0,o=t.length-1;r<o;++r){i+=t[r];let o=e[r];if(o instanceof Vt){const t=o.createBehavior();o=o.createCSS(),t&&n.push(t)}o instanceof at||o instanceof CSSStyleSheet?(""!==i.trim()&&(s.push(i),i=""),s.push(o)):i+=o}return i+=t[t.length-1],""!==i.trim()&&s.push(i),{styles:s,behaviors:n}}function $t(t,...e){const{styles:s,behaviors:i}=Ft(t,e),n=at.create(s);return i.length&&n.withBehaviors(...i),n}class _t extends Vt{constructor(t,e){super(),this.behaviors=e,this.css="";const s=t.reduce((t,e)=>("string"==typeof e?this.css+=e:t.push(e),t),[]);s.length&&(this.styles=at.create(s))}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 It(t,...e){const{styles:s,behaviors:i}=Ft(t,e);return new _t(s,i)}function Mt(t,e,s){return{index:t,removed:e,addedCount:s}}function Pt(t,s,i,n,r,o){let l=0,h=0;const a=Math.min(i-s,o-r);if(0===s&&0===r&&(l=function(t,e,s){for(let i=0;i<s;++i)if(t[i]!==e[i])return i;return s}(t,n,a)),i===t.length&&o===n.length&&(h=function(t,e,s){let i=t.length,n=e.length,r=0;for(;r<s&&t[--i]===e[--n];)r++;return r}(t,n,a-l)),r+=l,o-=h,(i-=h)-(s+=l)==0&&o-r==0)return e;if(s===i){const t=Mt(s,[],0);for(;r<o;)t.removed.push(n[r++]);return[t]}if(r===o)return[Mt(s,[],i-s)];const c=function(t){let e=t.length-1,s=t[0].length-1,i=t[e][s];const n=[];for(;e>0||s>0;){if(0===e){n.push(2),s--;continue}if(0===s){n.push(3),e--;continue}const r=t[e-1][s-1],o=t[e-1][s],l=t[e][s-1];let h;h=o<l?o<r?o:r:l<r?l:r,h===r?(r===i?n.push(0):(n.push(1),i=r),e--,s--):h===o?(n.push(3),e--,i=o):(n.push(2),s--,i=l)}return n.reverse(),n}(function(t,e,s,i,n,r){const o=r-n+1,l=s-e+1,h=new Array(o);let a,c;for(let t=0;t<o;++t)h[t]=new Array(l),h[t][0]=t;for(let t=0;t<l;++t)h[0][t]=t;for(let s=1;s<o;++s)for(let r=1;r<l;++r)t[e+r-1]===i[n+s-1]?h[s][r]=h[s-1][r-1]:(a=h[s-1][r]+1,c=h[s][r-1]+1,h[s][r]=a<c?a:c);return h}(t,s,i,n,r,o)),d=[];let u=void 0,f=s,p=r;for(let t=0;t<c.length;++t)switch(c[t]){case 0:void 0!==u&&(d.push(u),u=void 0),f++,p++;break;case 1:void 0===u&&(u=Mt(f,[],0)),u.addedCount++,f++,u.removed.push(n[p]),p++;break;case 2:void 0===u&&(u=Mt(f,[],0)),u.addedCount++,f++;break;case 3:void 0===u&&(u=Mt(f,[],0)),u.removed.push(n[p]),p++}return void 0!==u&&d.push(u),d}const Et=Array.prototype.push;function Lt(t,e,s,i){const n=Mt(e,s,i);let r=!1,o=0;for(let e=0;e<t.length;e++){const s=t[e];if(s.index+=o,r)continue;const i=(l=n.index,h=n.index+n.removed.length,a=s.index,c=s.index+s.addedCount,h<a||c<l?-1:h===a||c===l?0:l<a?h<c?h-a:c-a:c<h?c-l:h-l);if(i>=0){t.splice(e,1),e--,o-=s.addedCount-s.removed.length,n.addedCount+=s.addedCount-i;const l=n.removed.length+s.removed.length-i;if(n.addedCount||l){let t=s.removed;if(n.index<s.index){const e=n.removed.slice(0,s.index-n.index);Et.apply(e,t),t=e}if(n.index+n.removed.length>s.index+s.addedCount){const e=n.removed.slice(s.index+s.addedCount-n.index);Et.apply(t,e)}n.removed=t,s.index<n.index&&(n.index=s.index)}else r=!0}else if(n.index<s.index){r=!0,t.splice(e,0,n),e++;const i=n.addedCount-n.removed.length;s.index+=i,o+=i}}var l,h,a,c;r||t.push(n)}function Rt(t,e){let s=[];const i=function(t){const e=[];for(let s=0,i=t.length;s<i;s++){const i=t[s];Lt(e,i.index,i.removed,i.addedCount)}return e}(e);for(let e=0,n=i.length;e<n;++e){const n=i[e];1!==n.addedCount||1!==n.removed.length?s=s.concat(Pt(t,n.index,n.index+n.addedCount,n.removed,0,n.removed.length)):n.removed[0]!==t[n.index]&&s.push(n)}return s}let jt=!1;function zt(t,e){let s=t.index;const i=e.length;return s>i?s=i-t.addedCount:s<0&&(s=i+t.removed.length+s-t.addedCount),s<0&&(s=0),t.index=s,t}class Ht extends b{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})}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 s=void 0===e?Rt(this.source,t):Pt(this.source,0,this.source.length,e,0,e.length);this.notify(s)}}function Ut(){if(jt)return;jt=!0,B.setArrayObserverFactory(t=>new Ht(t));const t=Array.prototype;if(t.$fastPatch)return;Reflect.defineProperty(t,"$fastPatch",{value:1,enumerable:!1});const e=t.pop,s=t.push,i=t.reverse,n=t.shift,r=t.sort,o=t.splice,l=t.unshift;t.pop=function(){const t=this.length>0,s=e.apply(this,arguments),i=this.$fastController;return void 0!==i&&t&&i.addSplice(Mt(this.length,[s],0)),s},t.push=function(){const t=s.apply(this,arguments),e=this.$fastController;return void 0!==e&&e.addSplice(zt(Mt(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 s=i.apply(this,arguments);return void 0!==e&&e.reset(t),s},t.shift=function(){const t=this.length>0,e=n.apply(this,arguments),s=this.$fastController;return void 0!==s&&t&&s.addSplice(Mt(0,[e],0)),e},t.sort=function(){let t;const e=this.$fastController;void 0!==e&&(e.flush(),t=this.slice());const s=r.apply(this,arguments);return void 0!==e&&e.reset(t),s},t.splice=function(){const t=o.apply(this,arguments),e=this.$fastController;return void 0!==e&&e.addSplice(zt(Mt(+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(zt(Mt(0,[],arguments.length),this)),t}}class Qt{constructor(t,e){this.target=t,this.propertyName=e}bind(t){t[this.propertyName]=this.target}unbind(){}}function qt(t){return new E("fast-ref",Qt,t)}function Wt(t,e){const s="function"==typeof e?e:()=>e;return(e,i)=>t(e,i)?s(e,i):null}const Dt=Object.freeze({positioning:!1,recycle:!0});function Gt(t,e,s,i){t.bind(e[s],i)}function Jt(t,e,s,i){const n=Object.create(i);n.index=s,n.length=e.length,t.bind(e[s],n)}class Kt{constructor(t,e,s,i,n,r){this.location=t,this.itemsBinding=e,this.templateBinding=i,this.options=r,this.source=null,this.views=[],this.items=null,this.itemsObserver=null,this.originalContext=void 0,this.childContext=void 0,this.bindView=Gt,this.itemsBindingObserver=B.binding(e,this,s),this.templateBindingObserver=B.binding(i,this,n),r.positioning&&(this.bindView=Jt)}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=e);const s=this.itemsObserver,i=this.itemsObserver=B.getNotifier(this.items),n=s!==i;n&&null!==s&&s.unsubscribe(this),(n||t)&&i.subscribe(this)}updateViews(t){const e=this.childContext,s=this.views,i=[],n=this.bindView;let r=0;for(let e=0,n=t.length;e<n;++e){const n=t[e],o=n.removed;i.push(...s.splice(n.index+r,o.length)),r-=n.addedCount}const o=this.items,l=this.template;for(let r=0,h=t.length;r<h;++r){const h=t[r];let a=h.index;const c=a+h.addedCount;for(;a<c;++a){const t=s[a],r=t?t.firstChild:this.location,h=this.options.recycle&&i.length>0?i.shift():l.create();s.splice(a,0,h),n(h,o,a,e),h.insertBefore(r)}}for(let t=0,e=i.length;t<e;++t)i[t].dispose();if(this.options.positioning)for(let t=0,e=s.length;t<e;++t){const i=s[t].context;i.length=e,i.index=t}}refreshAllViews(t=!1){const e=this.items,s=this.childContext,i=this.template,n=this.location,r=this.bindView;let o=e.length,l=this.views,h=l.length;if((0===o||t)&&(rt.disposeContiguousBatch(l),h=0),0===h){this.views=l=new Array(o);for(let t=0;t<o;++t){const o=i.create();r(o,e,t,s),l[t]=o,o.insertBefore(n)}}else{let t=0;for(;t<o;++t)if(t<h){r(l[t],e,t,s)}else{const o=i.create();r(o,e,t,s),l.push(o),o.insertBefore(n)}const a=l.splice(t,h-t);for(t=0,o=a.length;t<o;++t)a[t].dispose()}}unbindAllViews(){const t=this.views;for(let e=0,s=t.length;e<s;++e)t[e].unbind()}}class Xt extends M{constructor(t,e,s){super(),this.itemsBinding=t,this.templateBinding=e,this.options=s,this.createPlaceholder=d.createBlockPlaceholder,Ut(),this.isItemsBindingVolatile=B.isVolatileBinding(t),this.isTemplateBindingVolatile=B.isVolatileBinding(e)}createBehavior(t){return new Kt(t,this.itemsBinding,this.isItemsBindingVolatile,this.templateBinding,this.isTemplateBindingVolatile,this.options)}}function Yt(t,e,s=Dt){return new Xt(t,"function"==typeof e?e:()=>e,s)}function Zt(t){return t?function(e,s,i){return 1===e.nodeType&&e.matches(t)}:function(t,e,s){return 1===t.nodeType}}class te{constructor(t,e){this.target=t,this.options=e,this.source=null}bind(t){const e=this.options.property;this.shouldUpdate=B.getAccessors(t).some(t=>t.name===e),this.source=t,this.updateTarget(this.computeNodes()),this.shouldUpdate&&this.observe()}unbind(){this.updateTarget(e),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 ee extends te{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 se(t){return"string"==typeof t&&(t={property:t}),new E("fast-slotted",ee,t)}class ie extends te{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 ne(t){return"string"==typeof t&&(t={property:t}),new E("fast-children",ie,t)}export{t as $global,E as AttachedBehaviorHTMLDirective,vt as AttributeDefinition,J as BindingBehavior,Vt as CSSDirective,ie as ChildrenBehavior,Ot as Controller,d as DOM,at as ElementStyles,$ as ExecutionContext,At as FASTElement,wt as FASTElementDefinition,G as HTMLBindingDirective,M as HTMLDirective,rt as HTMLView,B as Observable,v as PropertyChangeNotifier,Qt as RefBehavior,Kt as RepeatBehavior,Xt as RepeatDirective,ee as SlottedBehavior,b as SubscriberSet,P as TargetedHTMLDirective,ot as ViewTemplate,mt as attr,gt as booleanConverter,ne as children,it as compileTemplate,$t as css,It as cssPartial,kt as customElement,_ as defaultExecutionContext,Zt as elements,e as emptyArray,Ut as enableArrayObservation,ht as html,bt as nullableNumberConverter,A as observable,qt as ref,Yt as repeat,F as setCurrentEvent,se as slotted,k as volatile,Wt as when}; | ||
const t=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===t.trustedTypes&&(t.trustedTypes={createPolicy:(t,e)=>e});const e={configurable:!1,enumerable:!1,writable:!1};void 0===t.FAST&&Reflect.defineProperty(t,"FAST",Object.assign({value:Object.create(null)},e));const s=t.FAST;if(void 0===s.getById){const t=Object.create(null);Reflect.defineProperty(s,"getById",Object.assign({value(e,s){let i=t[e];return void 0===i&&(i=s?t[e]=s():null),i}},e))}const i=Object.freeze([]),n=t.FAST.getById(1,()=>{const e=[],s=[];function i(){if(s.length)throw s.shift()}function n(t){try{t.call()}catch(t){s.push(t),setTimeout(i,0)}}function r(){let t=0;for(;t<e.length;)if(n(e[t]),t++,t>1024){for(let s=0,i=e.length-t;s<i;s++)e[s]=e[s+t];e.length-=t,t=0}e.length=0}return Object.freeze({enqueue:function(s){e.length<1&&t.requestAnimationFrame(r),e.push(s)},process:r})}),r=t.trustedTypes.createPolicy("fast-html",{createHTML:t=>t});let o=r;const l="fast-"+Math.random().toString(36).substring(2,8),h=l+"{",a="}"+l,c=Object.freeze({supportsAdoptedStyleSheets:Array.isArray(document.adoptedStyleSheets)&&"replace"in CSSStyleSheet.prototype,setHTMLPolicy(t){if(o!==r)throw new Error("The HTML policy can only be set once.");o=t},createHTML:t=>o.createHTML(t),isMarker:t=>t&&8===t.nodeType&&t.data.startsWith(l),extractDirectiveIndexFromMarker:t=>parseInt(t.data.replace(l+":","")),createInterpolationPlaceholder:t=>`${h}${t}${a}`,createCustomAttributePlaceholder(t,e){return`${t}="${this.createInterpolationPlaceholder(e)}"`},createBlockPlaceholder:t=>`\x3c!--${l}:${t}--\x3e`,queueUpdate:n.enqueue,processUpdates:n.process,nextUpdate:()=>new Promise(n.enqueue),setAttribute(t,e,s){null==s?t.removeAttribute(e):t.setAttribute(e,s)},setBooleanAttribute(t,e,s){s?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)});function d(t){const e=this.spillover;-1===e.indexOf(t)&&e.push(t)}function u(t){const e=this.spillover,s=e.indexOf(t);-1!==s&&e.splice(s,1)}function f(t){const e=this.spillover,s=this.source;for(let i=0,n=e.length;i<n;++i)e[i].handleChange(s,t)}function g(t){return-1!==this.spillover.indexOf(t)}class p{constructor(t,e){this.sub1=void 0,this.sub2=void 0,this.spillover=void 0,this.source=t,this.sub1=e}has(t){return this.sub1===t||this.sub2===t}subscribe(t){this.has(t)||(void 0!==this.sub1?void 0!==this.sub2?(this.spillover=[this.sub1,this.sub2,t],this.subscribe=d,this.unsubscribe=u,this.notify=f,this.has=g,this.sub1=void 0,this.sub2=void 0):this.sub2=t:this.sub1=t)}unsubscribe(t){this.sub1===t?this.sub1=void 0:this.sub2===t&&(this.sub2=void 0)}notify(t){const e=this.sub1,s=this.sub2,i=this.source;void 0!==e&&e.handleChange(i,t),void 0!==s&&s.handleChange(i,t)}}class b{constructor(t){this.subscribers={},this.sourceSubscribers=null,this.source=t}notify(t){var e;const s=this.subscribers[t];void 0!==s&&s.notify(t),null===(e=this.sourceSubscribers)||void 0===e||e.notify(t)}subscribe(t,e){var s;if(e){let s=this.subscribers[e];void 0===s&&(this.subscribers[e]=s=new p(this.source)),s.subscribe(t)}else this.sourceSubscribers=null!==(s=this.sourceSubscribers)&&void 0!==s?s:new p(this.source),this.sourceSubscribers.subscribe(t)}unsubscribe(t,e){var s;if(e){const s=this.subscribers[e];void 0!==s&&s.unsubscribe(t)}else null===(s=this.sourceSubscribers)||void 0===s||s.unsubscribe(t)}}const v=s.getById(2,()=>{const t=/(:|&&|\|\||if)/,e=new WeakMap,s=new WeakMap,i=c.queueUpdate;let n=void 0,r=t=>{throw new Error("Must call enableArrayObservation before observing arrays.")};function o(t){let s=t.$fastController||e.get(t);return void 0===s&&(Array.isArray(t)?s=r(t):e.set(t,s=new b(t))),s}function l(t){let e=s.get(t);if(void 0===e){let i=Reflect.getPrototypeOf(t);for(;void 0===e&&null!==i;)e=s.get(i),i=Reflect.getPrototypeOf(i);e=void 0===e?[]:e.slice(0),s.set(t,e)}return e}class h{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 s=this.field,i=t[s];if(i!==e){t[s]=e;const n=t[this.callback];"function"==typeof n&&n.call(t,i,e),o(t).notify(this.name)}}}class a extends p{constructor(t,e,s=!1){super(t,e),this.binding=t,this.isVolatileBinding=s,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 s=n;n=this.needsRefresh?this:void 0,this.needsRefresh=this.isVolatileBinding;const i=this.binding(t,e);return n=s,i}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 s=this.last,i=o(t),r=null===s?this.first:{};if(r.propertySource=t,r.propertyName=e,r.notifier=i,i.subscribe(this,e),null!==s){if(!this.needsRefresh){let e;n=void 0,e=s.propertySource[s.propertyName],n=this,t===e&&(this.needsRefresh=!0)}s.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){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 h(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,s=this.isVolatileBinding(t)){return new a(t,e,s)},isVolatileBinding:e=>t.test(e.toString())})});function m(t,e){v.defineProperty(t,e)}function y(t,e,s){return Object.assign({},s,{get:function(){return v.trackVolatile(),s.get.apply(this)}})}const C=s.getById(3,()=>{let t=null;return{get:()=>t,set(e){t=e}}});class x{constructor(){this.index=0,this.length=0,this.parent=null,this.parentContext=null}get event(){return C.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){C.set(t)}}v.defineProperty(x.prototype,"index"),v.defineProperty(x.prototype,"length");const w=Object.seal(new x);class S{constructor(){this.targetIndex=0}}class B extends S{constructor(){super(...arguments),this.createPlaceholder=c.createInterpolationPlaceholder}}class T extends S{constructor(t,e,s){super(),this.name=t,this.behavior=e,this.options=s}createPlaceholder(t){return c.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=v.binding(this.binding,this,this.isBindingVolatile)),this.updateTarget(this.bindingObserver.observe(t,e))}function A(t,e){this.source=t,this.context=e,this.target.addEventListener(this.targetName,this)}function N(){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 V(){this.target.removeEventListener(this.targetName,this),this.source=null,this.context=null}function F(t){c.setAttribute(this.target,this.targetName,t)}function I(t){c.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 _(t){this.target[this.targetName]=t}function M(t){const e=this.classVersions||Object.create(null),s=this.target;let i=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]=i,s.classList.add(r))}}if(this.classVersions=e,this.version=i+1,0!==i){i-=1;for(const t in e)e[t]===i&&s.classList.remove(t)}}class P extends B{constructor(t){super(),this.binding=t,this.bind=O,this.unbind=N,this.updateTarget=F,this.isBindingVolatile=v.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=_,"innerHTML"===this.cleanedTargetName){const t=this.binding;this.binding=(e,s)=>c.createHTML(t(e,s))}break;case"?":this.cleanedTargetName=t.substr(1),this.updateTarget=I;break;case"@":this.cleanedTargetName=t.substr(1),this.bind=A,this.unbind=V;break;default:this.cleanedTargetName=t,"class"===t&&(this.updateTarget=M)}}targetAtContent(){this.updateTarget=$,this.unbind=k}createBehavior(t){return new E(t,this.binding,this.isBindingVolatile,this.bind,this.unbind,this.updateTarget,this.cleanedTargetName)}}class E{constructor(t,e,s,i,n,r,o){this.source=null,this.context=null,this.bindingObserver=null,this.target=t,this.binding=e,this.isBindingVolatile=s,this.bind=i,this.unbind=n,this.updateTarget=r,this.targetName=o}handleChange(){this.updateTarget(this.bindingObserver.observe(this.source,this.context))}handleEvent(t){x.setEvent(t);const e=this.binding(this.source,this.context);x.setEvent(null),!0!==e&&t.preventDefault()}}let L=null;class j{addFactory(t){t.targetIndex=this.targetIndex,this.behaviorFactories.push(t)}captureContentBinding(t){t.targetAtContent(),this.addFactory(t)}reset(){this.behaviorFactories=[],this.targetIndex=-1}release(){L=this}static borrow(t){const e=L||new j;return e.directives=t,e.reset(),L=null,e}}function R(t){if(1===t.length)return t[0];let e;const s=t.length,i=t.map(t=>"string"==typeof t?()=>t:(e=t.targetName||e,t.binding)),n=new P((t,e)=>{let n="";for(let r=0;r<s;++r)n+=i[r](t,e);return n});return n.targetName=e,n}const z=a.length;function H(t,e){const s=e.split(h);if(1===s.length)return null;const i=[];for(let e=0,n=s.length;e<n;++e){const n=s[e],r=n.indexOf(a);let o;if(-1===r)o=n;else{const e=parseInt(n.substring(0,r));i.push(t.directives[e]),o=n.substring(r+z)}""!==o&&i.push(o)}return i}function q(t,e,s=!1){const i=e.attributes;for(let n=0,r=i.length;n<r;++n){const o=i[n],l=o.value,h=H(t,l);let a=null;null===h?s&&(a=new P(()=>l),a.targetName=o.name):a=R(h),null!==a&&(e.removeAttributeNode(o),n--,r--,t.addFactory(a))}}function Q(t,e,s){const i=H(t,e.textContent);if(null!==i){let n=e;for(let r=0,o=i.length;r<o;++r){const o=i[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&&s.nextNode()}t.targetIndex--}}function U(t,e){const s=t.content;document.adoptNode(s);const i=j.borrow(e);q(i,t,!0);const n=i.behaviorFactories;i.reset();const r=c.createTemplateWalker(s);let o;for(;o=r.nextNode();)switch(i.targetIndex++,o.nodeType){case 1:q(i,o);break;case 3:Q(i,o,r);break;case 8:c.isMarker(o)&&i.addFactory(e[c.extractDirectiveIndexFromMarker(o)])}let l=0;(c.isMarker(s.firstChild)||1===s.childNodes.length&&e.length)&&(s.insertBefore(document.createComment(""),s.firstChild),l=-1);const h=i.behaviorFactories;return i.release(),{fragment:s,viewBehaviorFactories:h,hostBehaviorFactories:n,targetOffset:l}}const W=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,s=this.lastChild;let i,n=this.firstChild;for(;n!==s;)i=n.nextSibling,e.insertBefore(n,t),n=i;e.insertBefore(s,t)}}remove(){const t=this.fragment,e=this.lastChild;let s,i=this.firstChild;for(;i!==e;)s=i.nextSibling,t.appendChild(i),i=s;t.appendChild(e)}dispose(){const t=this.firstChild.parentNode,e=this.lastChild;let s,i=this.firstChild;for(;i!==e;)s=i.nextSibling,t.removeChild(i),i=s;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 s=this.behaviors;if(this.source!==t)if(null!==this.source){const i=this.source;this.source=t,this.context=e;for(let n=0,r=s.length;n<r;++n){const r=s[n];r.unbind(i),r.bind(t,e)}}else{this.source=t,this.context=e;for(let i=0,n=s.length;i<n;++i)s[i].bind(t,e)}}unbind(){if(null===this.source)return;const t=this.behaviors,e=this.source;for(let s=0,i=t.length;s<i;++s)t[s].unbind(e);this.source=null}static disposeContiguousBatch(t){if(0!==t.length){W.setStartBefore(t[0].firstChild),W.setEndAfter(t[t.length-1].lastChild),W.deleteContents();for(let e=0,s=t.length;e<s;++e){const s=t[e],i=s.behaviors,n=s.source;for(let t=0,e=i.length;t<e;++t)i[t].unbind(n)}}}}class G{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=c.createHTML(e);const s=t.content.firstElementChild;null!==s&&"TEMPLATE"===s.tagName&&(t=s)}else t=e;const s=U(t,this.directives);this.fragment=s.fragment,this.viewBehaviorFactories=s.viewBehaviorFactories,this.hostBehaviorFactories=s.hostBehaviorFactories,this.targetOffset=s.targetOffset,this.behaviorCount=this.viewBehaviorFactories.length+this.hostBehaviorFactories.length,this.hasHostBehaviors=this.hostBehaviorFactories.length>0}const e=this.fragment.cloneNode(!0),s=this.viewBehaviorFactories,i=new Array(this.behaviorCount),n=c.createTemplateWalker(e);let r=0,o=this.targetOffset,l=n.nextNode();for(let t=s.length;r<t;++r){const t=s[r],e=t.targetIndex;for(;null!==l;){if(o===e){i[r]=t.createBehavior(l);break}l=n.nextNode(),o++}}if(this.hasHostBehaviors){const e=this.hostBehaviorFactories;for(let s=0,n=e.length;s<n;++s,++r)i[r]=e[s].createBehavior(t)}return new D(e,i)}render(t,e,s){"string"==typeof e&&(e=document.getElementById(e)),void 0===s&&(s=e);const i=this.create(s);return i.bind(t,w),i.appendTo(e),i}}const J=/([ \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 s=[];let i="";for(let n=0,r=t.length-1;n<r;++n){const r=t[n];let o=e[n];if(i+=r,o instanceof G){const t=o;o=()=>t}if("function"==typeof o&&(o=new P(o)),o instanceof B){const t=J.exec(r);null!==t&&(o.targetName=t[2])}o instanceof S?(i+=o.createPlaceholder(s.length),s.push(o)):i+=o}return i+=t[t.length-1],new G(i,s)}class X{constructor(){this.targets=new WeakSet,this.behaviors=null}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 Y(t){return t.map(t=>t instanceof X?Y(t.styles):[t]).reduce((t,e)=>t.concat(e),[])}function Z(t){return t.map(t=>t instanceof X?t.behaviors:null).reduce((t,e)=>null===e?t:(null===t&&(t=[]),t.concat(e)),null)}X.create=(()=>{if(c.supportsAdoptedStyleSheets){const t=new Map;return e=>new tt(e,t)}return t=>new st(t)})();class tt extends X{constructor(t,e){super(),this.styles=t,this.styleSheetCache=e,this._styleSheets=void 0,this.behaviors=Z(t)}get styleSheets(){if(void 0===this._styleSheets){const t=this.styles,e=this.styleSheetCache;this._styleSheets=Y(t).map(t=>{if(t instanceof CSSStyleSheet)return t;let s=e.get(t);return void 0===s&&(s=new CSSStyleSheet,s.replaceSync(t),e.set(t,s)),s})}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 et=0;class st extends X{constructor(t){super(),this.styles=t,this.behaviors=null,this.behaviors=Z(t),this.styleSheets=Y(t),this.styleClass="fast-style-class-"+ ++et}addStylesTo(t){const e=this.styleSheets,s=this.styleClass;t=this.normalizeTarget(t);for(let i=0;i<e.length;i++){const n=document.createElement("style");n.innerHTML=e[i],n.className=s,t.append(n)}super.addStylesTo(t)}removeStylesFrom(t){const e=(t=this.normalizeTarget(t)).querySelectorAll("."+this.styleClass);for(let s=0,i=e.length;s<i;++s)t.removeChild(e[s]);super.removeStylesFrom(t)}isAttachedTo(t){return super.isAttachedTo(this.normalizeTarget(t))}normalizeTarget(t){return t===document?document.body:t}}const it={toView:t=>t?"true":"false",fromView:t=>null!=t&&"false"!==t&&!1!==t&&0!==t},nt={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 rt{constructor(t,e,s=e.toLowerCase(),i="reflect",n){this.guards=new Set,this.Owner=t,this.name=e,this.attribute=s,this.mode=i,this.converter=n,this.fieldName="_"+e,this.callbackName=e+"Changed",this.hasCallback=this.callbackName in t.prototype,"boolean"===i&&void 0===n&&(this.converter=it)}setValue(t,e){const s=t[this.fieldName],i=this.converter;void 0!==i&&(e=i.fromView(e)),s!==e&&(t[this.fieldName]=e,this.tryReflectToAttribute(t),this.hasCallback&&t[this.callbackName](s,e),t.$fastController.notify(this.name))}getValue(t){return v.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,s=this.guards;s.has(t)||"fromView"===e||c.queueUpdate(()=>{s.add(t);const i=t[this.fieldName];switch(e){case"reflect":const e=this.converter;c.setAttribute(t,this.attribute,void 0!==e?e.toView(i):i);break;case"boolean":c.setBooleanAttribute(t,this.attribute,i)}s.delete(t)})}static collect(t,...e){const s=[];e.push(t.attributes);for(let i=0,n=e.length;i<n;++i){const n=e[i];if(void 0!==n)for(let e=0,i=n.length;e<i;++e){const i=n[e];"string"==typeof i?s.push(new rt(t,i)):s.push(new rt(t,i.property,i.attribute,i.mode,i.converter))}}return s}}function ot(t,e){let s;function i(t,e){arguments.length>1&&(s.property=e);const i=t.constructor.attributes||(t.constructor.attributes=[]);i.push(s)}return arguments.length>1?(s={},void i(t,e)):(s=void 0===t?{}:t,i)}const lt={mode:"open"},ht={},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 ct{constructor(t,e=t.definition){"string"==typeof e&&(e={name:e}),this.type=t,this.name=e.name,this.template=e.template;const s=rt.collect(t,e.attributes),i=new Array(s.length),n={},r={};for(let t=0,e=s.length;t<e;++t){const e=s[t];i[t]=e.attribute,n[e.name]=e,r[e.attribute]=e}this.attributes=s,this.observedAttributes=i,this.propertyLookup=n,this.attributeLookup=r,this.shadowOptions=void 0===e.shadowOptions?lt:null===e.shadowOptions?void 0:Object.assign(Object.assign({},lt),e.shadowOptions),this.elementOptions=void 0===e.elementOptions?ht:Object.assign(Object.assign({},ht),e.elementOptions),this.styles=void 0===e.styles?void 0:Array.isArray(e.styles)?X.create(e.styles):e.styles instanceof X?e.styles:X.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,s=e.prototype;for(let e=0,i=t.length;e<i;++e)v.defineProperty(s,t[e]);Reflect.defineProperty(e,"observedAttributes",{value:this.observedAttributes,enumerable:!0})}return t.get(this.name)||t.define(this.name,e,this.elementOptions),this}}ct.forType=at.getByType;const dt=new WeakMap,ut={bubbles:!0,composed:!0,cancelable:!0};function ft(t){return t.shadowRoot||dt.get(t)||null}class gt extends b{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 s=e.shadowOptions;if(void 0!==s){const e=t.attachShadow(s);"closed"===s.mode&&dt.set(t,e)}const i=v.getAccessors(t);if(i.length>0){const e=this.boundObservables=Object.create(null);for(let s=0,n=i.length;s<n;++s){const n=i[s].name,r=t[n];void 0!==r&&(delete t[n],e[n]=r)}}}get isConnected(){return v.track(this,"isConnected"),this._isConnected}setIsConnected(t){this._isConnected=t,v.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=ft(this.element)||this.element.getRootNode();if(t instanceof HTMLStyleElement)e.append(t);else if(!t.isAttachedTo(e)){const s=t.behaviors;t.addStylesTo(e),null!==s&&this.addBehaviors(s)}}removeStyles(t){const e=ft(this.element)||this.element.getRootNode();if(t instanceof HTMLStyleElement)e.removeChild(t);else if(t.isAttachedTo(e)){const s=t.behaviors;t.removeStylesFrom(e),null!==s&&this.removeBehaviors(s)}}addBehaviors(t){const e=this.behaviors||(this.behaviors=new Map),s=t.length,i=[];for(let n=0;n<s;++n){const s=t[n];e.has(s)?e.set(s,e.get(s)+1):(e.set(s,1),i.push(s))}if(this._isConnected){const t=this.element;for(let e=0;e<i.length;++e)i[e].bind(t,w)}}removeBehaviors(t,e=!1){const s=this.behaviors;if(null===s)return;const i=t.length,n=[];for(let r=0;r<i;++r){const i=t[r];if(s.has(i)){const t=s.get(i)-1;0===t||e?s.delete(i)&&n.push(i):s.set(i,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,w);const e=this.behaviors;if(null!==e)for(const[s]of e)s.bind(t,w);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[s]of e)s.unbind(t)}}onAttributeChangedCallback(t,e,s){const i=this.definition.attributeLookup[t];void 0!==i&&i.onAttributeChangedCallback(this.element,s)}emit(t,e,s){return!!this._isConnected&&this.element.dispatchEvent(new CustomEvent(t,Object.assign(Object.assign({detail:e},ut),s)))}finishInitialization(){const t=this.element,e=this.boundObservables;if(null!==e){const s=Object.keys(e);for(let i=0,n=s.length;i<n;++i){const n=s[i];t[n]=e[n]}this.boundObservables=null}const s=this.definition;null===this._template&&(this.element.resolveTemplate?this._template=this.element.resolveTemplate():s.template&&(this._template=s.template||null)),null!==this._template&&this.renderTemplate(this._template),null===this._styles&&(this.element.resolveStyles?this._styles=this.element.resolveStyles():s.styles&&(this._styles=s.styles||null)),null!==this._styles&&this.addStyles(this._styles),this.needsInitialization=!1}renderTemplate(t){const e=this.element,s=ft(e)||e;null!==this.view?(this.view.dispose(),this.view=null):this.needsInitialization||c.removeChildNodes(s),t&&(this.view=t.render(e,s,e))}static forCustomElement(t){const e=t.$fastController;if(void 0!==e)return e;const s=ct.forType(t.constructor);if(void 0===s)throw new Error("Missing FASTElement definition.");return t.$fastController=new gt(t,s)}}function pt(t){return class extends t{constructor(){super(),gt.forCustomElement(this)}$emit(t,e,s){return this.$fastController.emit(t,e,s)}connectedCallback(){this.$fastController.onConnectedCallback()}disconnectedCallback(){this.$fastController.onDisconnectedCallback()}attributeChangedCallback(t,e,s){this.$fastController.onAttributeChangedCallback(t,e,s)}}}const bt=Object.assign(pt(HTMLElement),{from:t=>pt(t),define:(t,e)=>new ct(t,e).define().type});function vt(t){return function(e){new ct(e,t).define()}}class mt{createCSS(){return""}createBehavior(){}}function yt(t,e){const s=[];let i="";const n=[];for(let r=0,o=t.length-1;r<o;++r){i+=t[r];let o=e[r];if(o instanceof mt){const t=o.createBehavior();o=o.createCSS(),t&&n.push(t)}o instanceof X||o instanceof CSSStyleSheet?(""!==i.trim()&&(s.push(i),i=""),s.push(o)):i+=o}return i+=t[t.length-1],""!==i.trim()&&s.push(i),{styles:s,behaviors:n}}function Ct(t,...e){const{styles:s,behaviors:i}=yt(t,e),n=X.create(s);return i.length&&n.withBehaviors(...i),n}class xt extends mt{constructor(t,e){super(),this.behaviors=e,this.css="";const s=t.reduce((t,e)=>("string"==typeof e?this.css+=e:t.push(e),t),[]);s.length&&(this.styles=X.create(s))}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:s,behaviors:i}=yt(t,e);return new xt(s,i)}function St(t,e,s){return{index:t,removed:e,addedCount:s}}function Bt(t,e,s,n,r,o){let l=0,h=0;const a=Math.min(s-e,o-r);if(0===e&&0===r&&(l=function(t,e,s){for(let i=0;i<s;++i)if(t[i]!==e[i])return i;return s}(t,n,a)),s===t.length&&o===n.length&&(h=function(t,e,s){let i=t.length,n=e.length,r=0;for(;r<s&&t[--i]===e[--n];)r++;return r}(t,n,a-l)),r+=l,o-=h,(s-=h)-(e+=l)==0&&o-r==0)return i;if(e===s){const t=St(e,[],0);for(;r<o;)t.removed.push(n[r++]);return[t]}if(r===o)return[St(e,[],s-e)];const c=function(t){let e=t.length-1,s=t[0].length-1,i=t[e][s];const n=[];for(;e>0||s>0;){if(0===e){n.push(2),s--;continue}if(0===s){n.push(3),e--;continue}const r=t[e-1][s-1],o=t[e-1][s],l=t[e][s-1];let h;h=o<l?o<r?o:r:l<r?l:r,h===r?(r===i?n.push(0):(n.push(1),i=r),e--,s--):h===o?(n.push(3),e--,i=o):(n.push(2),s--,i=l)}return n.reverse(),n}(function(t,e,s,i,n,r){const o=r-n+1,l=s-e+1,h=new Array(o);let a,c;for(let t=0;t<o;++t)h[t]=new Array(l),h[t][0]=t;for(let t=0;t<l;++t)h[0][t]=t;for(let s=1;s<o;++s)for(let r=1;r<l;++r)t[e+r-1]===i[n+s-1]?h[s][r]=h[s-1][r-1]:(a=h[s-1][r]+1,c=h[s][r-1]+1,h[s][r]=a<c?a:c);return h}(t,e,s,n,r,o)),d=[];let u=void 0,f=e,g=r;for(let t=0;t<c.length;++t)switch(c[t]){case 0:void 0!==u&&(d.push(u),u=void 0),f++,g++;break;case 1:void 0===u&&(u=St(f,[],0)),u.addedCount++,f++,u.removed.push(n[g]),g++;break;case 2:void 0===u&&(u=St(f,[],0)),u.addedCount++,f++;break;case 3:void 0===u&&(u=St(f,[],0)),u.removed.push(n[g]),g++}return void 0!==u&&d.push(u),d}const Tt=Array.prototype.push;function Ot(t,e,s,i){const n=St(e,s,i);let r=!1,o=0;for(let e=0;e<t.length;e++){const s=t[e];if(s.index+=o,r)continue;const i=(l=n.index,h=n.index+n.removed.length,a=s.index,c=s.index+s.addedCount,h<a||c<l?-1:h===a||c===l?0:l<a?h<c?h-a:c-a:c<h?c-l:h-l);if(i>=0){t.splice(e,1),e--,o-=s.addedCount-s.removed.length,n.addedCount+=s.addedCount-i;const l=n.removed.length+s.removed.length-i;if(n.addedCount||l){let t=s.removed;if(n.index<s.index){const e=n.removed.slice(0,s.index-n.index);Tt.apply(e,t),t=e}if(n.index+n.removed.length>s.index+s.addedCount){const e=n.removed.slice(s.index+s.addedCount-n.index);Tt.apply(t,e)}n.removed=t,s.index<n.index&&(n.index=s.index)}else r=!0}else if(n.index<s.index){r=!0,t.splice(e,0,n),e++;const i=n.addedCount-n.removed.length;s.index+=i,o+=i}}var l,h,a,c;r||t.push(n)}function At(t,e){let s=[];const i=function(t){const e=[];for(let s=0,i=t.length;s<i;s++){const i=t[s];Ot(e,i.index,i.removed,i.addedCount)}return e}(e);for(let e=0,n=i.length;e<n;++e){const n=i[e];1!==n.addedCount||1!==n.removed.length?s=s.concat(Bt(t,n.index,n.index+n.addedCount,n.removed,0,n.removed.length)):n.removed[0]!==t[n.index]&&s.push(n)}return s}let Nt=!1;function kt(t,e){let s=t.index;const i=e.length;return s>i?s=i-t.addedCount:s<0&&(s=i+t.removed.length+s-t.addedCount),s<0&&(s=0),t.index=s,t}class Vt extends p{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})}addSplice(t){void 0===this.splices?this.splices=[t]:this.splices.push(t),this.needsQueue&&(this.needsQueue=!1,c.queueUpdate(this))}reset(t){this.oldCollection=t,this.needsQueue&&(this.needsQueue=!1,c.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 s=void 0===e?At(this.source,t):Bt(this.source,0,this.source.length,e,0,e.length);this.notify(s)}}function Ft(){if(Nt)return;Nt=!0,v.setArrayObserverFactory(t=>new Vt(t));const t=Array.prototype;if(t.$fastPatch)return;Reflect.defineProperty(t,"$fastPatch",{value:1,enumerable:!1});const e=t.pop,s=t.push,i=t.reverse,n=t.shift,r=t.sort,o=t.splice,l=t.unshift;t.pop=function(){const t=this.length>0,s=e.apply(this,arguments),i=this.$fastController;return void 0!==i&&t&&i.addSplice(St(this.length,[s],0)),s},t.push=function(){const t=s.apply(this,arguments),e=this.$fastController;return void 0!==e&&e.addSplice(kt(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 s=i.apply(this,arguments);return void 0!==e&&e.reset(t),s},t.shift=function(){const t=this.length>0,e=n.apply(this,arguments),s=this.$fastController;return void 0!==s&&t&&s.addSplice(St(0,[e],0)),e},t.sort=function(){let t;const e=this.$fastController;void 0!==e&&(e.flush(),t=this.slice());const s=r.apply(this,arguments);return void 0!==e&&e.reset(t),s},t.splice=function(){const t=o.apply(this,arguments),e=this.$fastController;return void 0!==e&&e.addSplice(kt(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(kt(St(0,[],arguments.length),this)),t}}class It{constructor(t,e){this.target=t,this.propertyName=e}bind(t){t[this.propertyName]=this.target}unbind(){}}function $t(t){return new T("fast-ref",It,t)}function _t(t,e){const s="function"==typeof e?e:()=>e;return(e,i)=>t(e,i)?s(e,i):null}const Mt=Object.freeze({positioning:!1,recycle:!0});function Pt(t,e,s,i){t.bind(e[s],i)}function Et(t,e,s,i){const n=Object.create(i);n.index=s,n.length=e.length,t.bind(e[s],n)}class Lt{constructor(t,e,s,i,n,r){this.location=t,this.itemsBinding=e,this.templateBinding=i,this.options=r,this.source=null,this.views=[],this.items=null,this.itemsObserver=null,this.originalContext=void 0,this.childContext=void 0,this.bindView=Pt,this.itemsBindingObserver=v.binding(e,this,s),this.templateBindingObserver=v.binding(i,this,n),r.positioning&&(this.bindView=Et)}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=i);const e=this.itemsObserver,s=this.itemsObserver=v.getNotifier(this.items),n=e!==s;n&&null!==e&&e.unsubscribe(this),(n||t)&&s.subscribe(this)}updateViews(t){const e=this.childContext,s=this.views,i=[],n=this.bindView;let r=0;for(let e=0,n=t.length;e<n;++e){const n=t[e],o=n.removed;i.push(...s.splice(n.index+r,o.length)),r-=n.addedCount}const o=this.items,l=this.template;for(let r=0,h=t.length;r<h;++r){const h=t[r];let a=h.index;const c=a+h.addedCount;for(;a<c;++a){const t=s[a],r=t?t.firstChild:this.location,h=this.options.recycle&&i.length>0?i.shift():l.create();s.splice(a,0,h),n(h,o,a,e),h.insertBefore(r)}}for(let t=0,e=i.length;t<e;++t)i[t].dispose();if(this.options.positioning)for(let t=0,e=s.length;t<e;++t){const i=s[t].context;i.length=e,i.index=t}}refreshAllViews(t=!1){const e=this.items,s=this.childContext,i=this.template,n=this.location,r=this.bindView;let o=e.length,l=this.views,h=l.length;if((0===o||t)&&(D.disposeContiguousBatch(l),h=0),0===h){this.views=l=new Array(o);for(let t=0;t<o;++t){const o=i.create();r(o,e,t,s),l[t]=o,o.insertBefore(n)}}else{let t=0;for(;t<o;++t)if(t<h){r(l[t],e,t,s)}else{const o=i.create();r(o,e,t,s),l.push(o),o.insertBefore(n)}const a=l.splice(t,h-t);for(t=0,o=a.length;t<o;++t)a[t].dispose()}}unbindAllViews(){const t=this.views;for(let e=0,s=t.length;e<s;++e)t[e].unbind()}}class jt extends S{constructor(t,e,s){super(),this.itemsBinding=t,this.templateBinding=e,this.options=s,this.createPlaceholder=c.createBlockPlaceholder,Ft(),this.isItemsBindingVolatile=v.isVolatileBinding(t),this.isTemplateBindingVolatile=v.isVolatileBinding(e)}createBehavior(t){return new Lt(t,this.itemsBinding,this.isItemsBindingVolatile,this.templateBinding,this.isTemplateBindingVolatile,this.options)}}function Rt(t,e,s=Mt){return new jt(t,"function"==typeof e?e:()=>e,s)}function zt(t){return t?function(e,s,i){return 1===e.nodeType&&e.matches(t)}:function(t,e,s){return 1===t.nodeType}}class Ht{constructor(t,e){this.target=t,this.options=e,this.source=null}bind(t){const e=this.options.property;this.shouldUpdate=v.getAccessors(t).some(t=>t.name===e),this.source=t,this.updateTarget(this.computeNodes()),this.shouldUpdate&&this.observe()}unbind(){this.updateTarget(i),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 Ht{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 Qt(t){return"string"==typeof t&&(t={property:t}),new T("fast-slotted",qt,t)}class Ut extends Ht{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 Wt(t){return"string"==typeof t&&(t={property:t}),new T("fast-children",Ut,t)}export{t as $global,T as AttachedBehaviorHTMLDirective,rt as AttributeDefinition,E as BindingBehavior,mt as CSSDirective,Ut as ChildrenBehavior,gt as Controller,c as DOM,X as ElementStyles,x as ExecutionContext,s as FAST,bt as FASTElement,ct as FASTElementDefinition,P as HTMLBindingDirective,S as HTMLDirective,D as HTMLView,v as Observable,b as PropertyChangeNotifier,It as RefBehavior,Lt as RepeatBehavior,jt as RepeatDirective,qt as SlottedBehavior,p as SubscriberSet,B as TargetedHTMLDirective,G as ViewTemplate,ot as attr,it as booleanConverter,Wt as children,U as compileTemplate,Ct as css,wt as cssPartial,vt as customElement,w as defaultExecutionContext,zt as elements,i as emptyArray,Ft as enableArrayObservation,K as html,nt as nullableNumberConverter,m as observable,$t as ref,Rt as repeat,Qt as slotted,y as volatile,_t as when}; |
@@ -107,3 +107,3 @@ ## API Report File for "@microsoft/fast-element" | ||
disconnect(): void; | ||
observe(source: TSource, context: ExecutionContext): TReturn; | ||
observe(source: TSource, context: ExecutionContext<TParent>): TReturn; | ||
records(): IterableIterator<ObservationRecord>; | ||
@@ -219,4 +219,4 @@ } | ||
createBlockPlaceholder(index: number): string; | ||
queueUpdate(callable: Callable): void; | ||
processUpdates(): void; | ||
queueUpdate: (callable: Callable) => void; | ||
processUpdates: () => void; | ||
nextUpdate(): Promise<void>; | ||
@@ -285,4 +285,11 @@ setAttribute(element: HTMLElement, attributeName: string, value: any): void; | ||
parentContext: ExecutionContext<TGrandparent>; | ||
// @internal | ||
static setEvent(event: Event | null): void; | ||
} | ||
// Warning: (ae-internal-missing-underscore) The name "FAST" should be prefixed with an underscore because the declaration is marked as @internal | ||
// | ||
// @internal | ||
export const FAST: FASTGlobal; | ||
// @public | ||
@@ -313,4 +320,4 @@ export interface FASTElement { | ||
readonly elementOptions?: ElementDefinitionOptions; | ||
static forType<TType extends Function>(type: TType): FASTElementDefinition | undefined; | ||
readonly isDefined: boolean; | ||
static readonly forType: <TType_1 extends Function>(key: TType_1) => FASTElementDefinition<Function> | undefined; | ||
get isDefined(): boolean; | ||
readonly name: string; | ||
@@ -324,5 +331,16 @@ readonly propertyLookup: Record<string, AttributeDefinition>; | ||
// Warning: (ae-internal-missing-underscore) The name "FASTGlobal" should be prefixed with an underscore because the declaration is marked as @internal | ||
// | ||
// @internal | ||
export interface FASTGlobal { | ||
getById<T>(id: string | number): T | null; | ||
// (undocumented) | ||
getById<T>(id: string | number, initialize: () => T): T; | ||
readonly versions: string[]; | ||
} | ||
// @public | ||
export type Global = typeof globalThis & { | ||
trustedTypes: TrustedTypes; | ||
readonly FAST: FASTGlobal; | ||
}; | ||
@@ -367,2 +385,16 @@ | ||
// Warning: (ae-internal-missing-underscore) The name "KernelServiceId" should be prefixed with an underscore because the declaration is marked as @internal | ||
// | ||
// @internal | ||
export const enum KernelServiceId { | ||
// (undocumented) | ||
contextEvent = 3, | ||
// (undocumented) | ||
elementRegistry = 4, | ||
// (undocumented) | ||
observable = 2, | ||
// (undocumented) | ||
updateQueue = 1 | ||
} | ||
// Warning: (ae-internal-missing-underscore) The name "Mutable" should be prefixed with an underscore because the declaration is marked as @internal | ||
@@ -401,3 +433,3 @@ // | ||
setArrayObserverFactory(factory: (collection: any[]) => Notifier): void; | ||
getNotifier(source: any): Notifier; | ||
getNotifier: (source: any) => Notifier; | ||
track(source: unknown, propertyName: string): void; | ||
@@ -407,3 +439,3 @@ trackVolatile(): void; | ||
defineProperty(target: {}, nameOrAccessor: string | Accessor): void; | ||
getAccessors(target: {}): Accessor[]; | ||
getAccessors: (target: {}) => Accessor[]; | ||
binding<TSource = any, TReturn = any, TParent = any>(binding: Binding<TSource, TReturn, TParent>, initialSubscriber?: Subscriber | undefined, isVolatileBinding?: boolean): BindingObserver<TSource, TReturn, TParent>; | ||
@@ -476,7 +508,2 @@ isVolatileBinding<TSource_1 = any, TReturn_1 = any, TParent_1 = any>(binding: Binding<TSource_1, TReturn_1, TParent_1>): boolean; | ||
// Warning: (ae-internal-missing-underscore) The name "setCurrentEvent" should be prefixed with an underscore because the declaration is marked as @internal | ||
// | ||
// @internal (undocumented) | ||
export function setCurrentEvent(event: Event | null): void; | ||
// @public | ||
@@ -483,0 +510,0 @@ export function slotted<T = any>(propertyOrOptions: (keyof T & string) | SlottedBehaviorOptions<keyof T & string>): CaptureType<T>; |
@@ -5,3 +5,3 @@ { | ||
"sideEffects": false, | ||
"version": "1.7.2", | ||
"version": "1.8.0", | ||
"author": { | ||
@@ -8,0 +8,0 @@ "name": "Microsoft", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
932690
22189