@benev/slate
Advanced tools
Comparing version 0.0.0-dev.26 to 0.0.0-dev.27
{ | ||
"name": "@benev/slate", | ||
"version": "0.0.0-dev.26", | ||
"version": "0.0.0-dev.27", | ||
"description": "frontend web stuff", | ||
@@ -30,3 +30,3 @@ "license": "MIT", | ||
"cynic": "^0.2.1", | ||
"es-module-shims": "^1.8.1", | ||
"es-module-shims": "^1.8.2", | ||
"http-server": "^14.1.1", | ||
@@ -33,0 +33,0 @@ "importly": "^0.2.3", |
@@ -436,6 +436,6 @@ | ||
```ts | ||
import {signals} from "@benev/slate" | ||
import {signal, signals} from "@benev/slate" | ||
const count = signals.signal(0) | ||
const greeting = signals.signal("hello") | ||
const count = signal(0) | ||
const greeting = signal("hello") | ||
@@ -442,0 +442,0 @@ count.value++ |
@@ -31,5 +31,5 @@ | ||
export * from "./watch/watch_tower.js" | ||
export * from "./watch/tower.js" | ||
export * from "./watch/state_tree.js" | ||
export * from "./watch/zip/action.js" | ||
import {Flat} from "../flatstate/flat.js" | ||
import {SignalTower} from "../signals/tower.js" | ||
import {WatchTower} from "../watch/watch_tower.js" | ||
import {WatchTower} from "../watch/tower.js" | ||
export const flat = new Flat() | ||
export const signals = new SignalTower() | ||
export const watch = new WatchTower() | ||
export const watch = new WatchTower(signals) | ||
@@ -10,0 +10,0 @@ export const flatstate = flat.state.bind(flat) |
import {Slice} from "./slice.js" | ||
export interface WatchBox<V> { | ||
readonly value: V | ||
} | ||
export interface SliceAccessors<S, X> { | ||
@@ -9,0 +5,0 @@ getter: (state: S) => X |
import {Suite, expect} from "cynic" | ||
import {WatchTower} from "./watch_tower.js" | ||
import {WatchTower} from "./tower.js" | ||
import {SignalTower} from "../signals/tower.js" | ||
function setup() { | ||
const watch = new WatchTower() | ||
const signals = new SignalTower() | ||
const watch = new WatchTower(signals) | ||
const tree = watch.stateTree({ | ||
@@ -8,0 +10,0 @@ count: 0, |
@@ -12,2 +12,3 @@ | ||
const blueprint = ZipAction.blueprint<State>() | ||
const testActions = ZipAction.prepBlueprint((state: State) => state.test) | ||
@@ -19,7 +20,7 @@ const tree = new StateTree<State>( | ||
const subgroup = blueprint({ | ||
double: state => () => { | ||
state.test.count *= 2 | ||
}, | ||
}) | ||
const subgroup = testActions(action => ({ | ||
double: action(test => () => { | ||
test.count *= 2 | ||
}), | ||
})) | ||
@@ -26,0 +27,0 @@ const counting_specs = blueprint({ |
@@ -38,6 +38,38 @@ | ||
export function fn<S>() { | ||
return <F extends Fn<S, any[]>>(fn: F) => fn | ||
} | ||
export function blueprint<S>() { | ||
return <B extends Blueprint<S>>(blueprint: B) => blueprint | ||
} | ||
export type Helpers<S, H> = (state: S, setState: ZipAction.SetState<S>) => H | ||
export const prepFn = <S, H>( | ||
helpers: Helpers<S, H> | ||
) => <P extends any[]>( | ||
fun: (helpers: H) => (...params: P) => void | ||
): ZipAction.Fn<S, P> => ( | ||
(state, setState) => (...params) => { | ||
fun(helpers(state, setState))(...params) | ||
return state | ||
} | ||
) | ||
export const prepBlueprint = <S, H>( | ||
helpers: Helpers<S, H> | ||
) => <B extends Blueprint<S>>( | ||
makeBp: (action: <P extends any[]>(f: (helpers: H) => (...params: P) => void) => Fn<S, P>) => B | ||
) => ( | ||
makeBp(prepFn<S, H>(helpers)) | ||
) | ||
export function prep<S, H>(helpers: Helpers<S, H>) { | ||
return { | ||
action: prepFn(helpers), | ||
blueprint: prepBlueprint(helpers), | ||
} | ||
} | ||
} | ||
@@ -597,5 +597,9 @@ | ||
class WatchTower { | ||
#signals; | ||
#computeds = new Set(); | ||
#listeners = new Set(); | ||
#memory = new Map(); | ||
constructor(signals) { | ||
this.#signals = signals; | ||
} | ||
dispatch() { | ||
@@ -608,9 +612,5 @@ for (const computed of this.#computeds) | ||
computed(fun) { | ||
let data = fun(); | ||
this.#computeds.add(() => { data = fun(); }); | ||
return { | ||
get value() { | ||
return data; | ||
} | ||
}; | ||
const box = this.#signals.signal(fun()); | ||
this.#computeds.add(() => { box.value = fun(); }); | ||
return box; | ||
} | ||
@@ -639,3 +639,3 @@ track(collector, responder) { | ||
const signals = new SignalTower(); | ||
const watch = new WatchTower(); | ||
const watch = new WatchTower(signals); | ||
flat.state.bind(flat); | ||
@@ -642,0 +642,0 @@ signals.signal.bind(signals); |
@@ -1,2 +0,2 @@ | ||
Array.prototype.at=function(t){return t>=0?this[t]:this[this.length+t]};const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s=Symbol(),n=new WeakMap;let r=class{constructor(t,e,n){if(this._$cssResult$=!0,n!==s)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const s=this.t;if(e&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=n.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&n.set(s,t))}return t}toString(){return this.cssText}};const i=(t,...e)=>{const n=1===t.length?t[0]:e.reduce(((e,s,n)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+t[n+1]),t[0]);return new r(n,t,s)},o=(s,n)=>{if(e)s.adoptedStyleSheets=n.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of n){const n=document.createElement("style"),r=t.litNonce;void 0!==r&&n.setAttribute("nonce",r),n.textContent=e.cssText,s.appendChild(n)}},a=e?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return(t=>new r("string"==typeof t?t:t+"",void 0,s))(e)})(t):t,{is:c,defineProperty:h,getOwnPropertyDescriptor:l,getOwnPropertyNames:u,getOwnPropertySymbols:d,getPrototypeOf:p}=Object,f=globalThis,_=f.trustedTypes,g=_?_.emptyScript:"",$=f.reactiveElementPolyfillSupport,m=(t,e)=>t,b={toAttribute(t,e){switch(e){case Boolean:t=t?g:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let s=t;switch(e){case Boolean:s=null!==t;break;case Number:s=null===t?null:Number(t);break;case Object:case Array:try{s=JSON.parse(t)}catch(t){s=null}}return s}},y=(t,e)=>!c(t,e),w={attribute:!0,type:String,converter:b,reflect:!1,hasChanged:y};Symbol.metadata??=Symbol("metadata"),f.litPropertyMetadata??=new WeakMap;class v extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=w){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const s=Symbol(),n=this.getPropertyDescriptor(t,s,e);void 0!==n&&h(this.prototype,t,n)}}static getPropertyDescriptor(t,e,s){const{get:n,set:r}=l(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get(){return n?.call(this)},set(e){const i=n?.call(this);r.call(this,e),this.requestUpdate(t,i,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??w}static _$Ei(){if(this.hasOwnProperty(m("elementProperties")))return;const t=p(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(m("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(m("properties"))){const t=this.properties,e=[...u(t),...d(t)];for(const s of e)this.createProperty(s,t[s])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,s]of e)this.elementProperties.set(t,s)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const s=this._$Eu(t,e);void 0!==s&&this._$Eh.set(s,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const t of s)e.unshift(a(t))}else void 0!==t&&e.push(a(t));return e}static _$Eu(t,e){const s=e.attribute;return!1===s?void 0:"string"==typeof s?s:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$Eg=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$ES??=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$ES?.splice(this._$ES.indexOf(t)>>>0,1)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const s of e.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return o(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$ES?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$ES?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,e,s){this._$AK(t,s)}_$EO(t,e){const s=this.constructor.elementProperties.get(t),n=this.constructor._$Eu(t,s);if(void 0!==n&&!0===s.reflect){const r=(void 0!==s.converter?.toAttribute?s.converter:b).toAttribute(e,s.type);this._$Em=t,null==r?this.removeAttribute(n):this.setAttribute(n,r),this._$Em=null}}_$AK(t,e){const s=this.constructor,n=s._$Eh.get(t);if(void 0!==n&&this._$Em!==n){const t=s.getPropertyOptions(n),r="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:b;this._$Em=n,this[n]=r.fromAttribute(e,t.type),this._$Em=null}}requestUpdate(t,e,s,n=!1,r){if(void 0!==t){if(s??=this.constructor.getPropertyOptions(t),!(s.hasChanged??y)(n?r:this[t],e))return;this.C(t,e,s)}!1===this.isUpdatePending&&(this._$Eg=this._$EP())}C(t,e,s){this._$AL.has(t)||this._$AL.set(t,e),!0===s.reflect&&this._$Em!==t&&(this._$Ej??=new Set).add(t)}async _$EP(){this.isUpdatePending=!0;try{await this._$Eg}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,s]of t)!0!==s.wrapped||this._$AL.has(e)||void 0===this[e]||this.C(e,this[e],s)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$ES?.forEach((t=>t.hostUpdate?.())),this.update(e)):this._$ET()}catch(e){throw t=!1,this._$ET(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$ES?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$ET(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Eg}shouldUpdate(t){return!0}update(t){this._$Ej&&=this._$Ej.forEach((t=>this._$EO(t,this[t]))),this._$ET()}updated(t){}firstUpdated(t){}}v.elementStyles=[],v.shadowRootOptions={mode:"open"},v[m("elementProperties")]=new Map,v[m("finalized")]=new Map,$?.({ReactiveElement:v}),(f.reactiveElementVersions??=[]).push("2.0.0");const A=globalThis,x=A.trustedTypes,S=x?x.createPolicy("lit-html",{createHTML:t=>t}):void 0,k="$lit$",C=`lit$${(Math.random()+"").slice(9)}$`,E="?"+C,M=`<${E}>`,P=document,U=()=>P.createComment(""),O=t=>null===t||"object"!=typeof t&&"function"!=typeof t,T=Array.isArray,N="[ \t\n\f\r]",H=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,j=/-->/g,R=/>/g,z=RegExp(`>|${N}(?:([^\\s"'>=/]+)(${N}*=${N}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),q=/'/g,D=/"/g,L=/^(?:script|style|textarea|title)$/i,B=(t=>(e,...s)=>({_$litType$:t,strings:e,values:s}))(1),I=Symbol.for("lit-noChange"),V=Symbol.for("lit-nothing"),W=new WeakMap,Z=P.createTreeWalker(P,129);function J(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==S?S.createHTML(e):e}const K=(t,e)=>{const s=t.length-1,n=[];let r,i=2===e?"<svg>":"",o=H;for(let e=0;e<s;e++){const s=t[e];let a,c,h=-1,l=0;for(;l<s.length&&(o.lastIndex=l,c=o.exec(s),null!==c);)l=o.lastIndex,o===H?"!--"===c[1]?o=j:void 0!==c[1]?o=R:void 0!==c[2]?(L.test(c[2])&&(r=RegExp("</"+c[2],"g")),o=z):void 0!==c[3]&&(o=z):o===z?">"===c[0]?(o=r??H,h=-1):void 0===c[1]?h=-2:(h=o.lastIndex-c[2].length,a=c[1],o=void 0===c[3]?z:'"'===c[3]?D:q):o===D||o===q?o=z:o===j||o===R?o=H:(o=z,r=void 0);const u=o===z&&t[e+1].startsWith("/>")?" ":"";i+=o===H?s+M:h>=0?(n.push(a),s.slice(0,h)+k+s.slice(h)+C+u):s+C+(-2===h?e:u)}return[J(t,i+(t[s]||"<?>")+(2===e?"</svg>":"")),n]};class G{constructor({strings:t,_$litType$:e},s){let n;this.parts=[];let r=0,i=0;const o=t.length-1,a=this.parts,[c,h]=K(t,e);if(this.el=G.createElement(c,s),Z.currentNode=this.el.content,2===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(n=Z.nextNode())&&a.length<o;){if(1===n.nodeType){if(n.hasAttributes())for(const t of n.getAttributeNames())if(t.endsWith(k)){const e=h[i++],s=n.getAttribute(t).split(C),o=/([.?@])?(.*)/.exec(e);a.push({type:1,index:r,name:o[2],strings:s,ctor:"."===o[1]?tt:"?"===o[1]?et:"@"===o[1]?st:Y}),n.removeAttribute(t)}else t.startsWith(C)&&(a.push({type:6,index:r}),n.removeAttribute(t));if(L.test(n.tagName)){const t=n.textContent.split(C),e=t.length-1;if(e>0){n.textContent=x?x.emptyScript:"";for(let s=0;s<e;s++)n.append(t[s],U()),Z.nextNode(),a.push({type:2,index:++r});n.append(t[e],U())}}}else if(8===n.nodeType)if(n.data===E)a.push({type:2,index:r});else{let t=-1;for(;-1!==(t=n.data.indexOf(C,t+1));)a.push({type:7,index:r}),t+=C.length-1}r++}}static createElement(t,e){const s=P.createElement("template");return s.innerHTML=t,s}}function Q(t,e,s=t,n){if(e===I)return e;let r=void 0!==n?s._$Co?.[n]:s._$Cl;const i=O(e)?void 0:e._$litDirective$;return r?.constructor!==i&&(r?._$AO?.(!1),void 0===i?r=void 0:(r=new i(t),r._$AT(t,s,n)),void 0!==n?(s._$Co??=[])[n]=r:s._$Cl=r),void 0!==r&&(e=Q(t,r._$AS(t,e.values),r,n)),e}class F{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:s}=this._$AD,n=(t?.creationScope??P).importNode(e,!0);Z.currentNode=n;let r=Z.nextNode(),i=0,o=0,a=s[0];for(;void 0!==a;){if(i===a.index){let e;2===a.type?e=new X(r,r.nextSibling,this,t):1===a.type?e=new a.ctor(r,a.name,a.strings,this,t):6===a.type&&(e=new nt(r,this,t)),this._$AV.push(e),a=s[++o]}i!==a?.index&&(r=Z.nextNode(),i++)}return Z.currentNode=P,n}p(t){let e=0;for(const s of this._$AV)void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,e),e+=s.strings.length-2):s._$AI(t[e])),e++}}class X{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,s,n){this.type=2,this._$AH=V,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=s,this.options=n,this._$Cv=n?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t?.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=Q(this,t,e),O(t)?t===V||null==t||""===t?(this._$AH!==V&&this._$AR(),this._$AH=V):t!==this._$AH&&t!==I&&this._(t):void 0!==t._$litType$?this.g(t):void 0!==t.nodeType?this.$(t):(t=>T(t)||"function"==typeof t?.[Symbol.iterator])(t)?this.T(t):this._(t)}k(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}$(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}_(t){this._$AH!==V&&O(this._$AH)?this._$AA.nextSibling.data=t:this.$(P.createTextNode(t)),this._$AH=t}g(t){const{values:e,_$litType$:s}=t,n="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=G.createElement(J(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===n)this._$AH.p(e);else{const t=new F(n,this),s=t.u(this.options);t.p(e),this.$(s),this._$AH=t}}_$AC(t){let e=W.get(t.strings);return void 0===e&&W.set(t.strings,e=new G(t)),e}T(t){T(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let s,n=0;for(const r of t)n===e.length?e.push(s=new X(this.k(U()),this.k(U()),this,this.options)):s=e[n],s._$AI(r),n++;n<e.length&&(this._$AR(s&&s._$AB.nextSibling,n),e.length=n)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t&&t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t))}}class Y{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,n,r){this.type=1,this._$AH=V,this._$AN=void 0,this.element=t,this.name=e,this._$AM=n,this.options=r,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=V}_$AI(t,e=this,s,n){const r=this.strings;let i=!1;if(void 0===r)t=Q(this,t,e,0),i=!O(t)||t!==this._$AH&&t!==I,i&&(this._$AH=t);else{const n=t;let o,a;for(t=r[0],o=0;o<r.length-1;o++)a=Q(this,n[s+o],e,o),a===I&&(a=this._$AH[o]),i||=!O(a)||a!==this._$AH[o],a===V?t=V:t!==V&&(t+=(a??"")+r[o+1]),this._$AH[o]=a}i&&!n&&this.j(t)}j(t){t===V?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class tt extends Y{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===V?void 0:t}}class et extends Y{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==V)}}class st extends Y{constructor(t,e,s,n,r){super(t,e,s,n,r),this.type=5}_$AI(t,e=this){if((t=Q(this,t,e,0)??V)===I)return;const s=this._$AH,n=t===V&&s!==V||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,r=t!==V&&(s===V||n);n&&this.element.removeEventListener(this.name,this,s),r&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class nt{constructor(t,e,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){Q(this,t)}}const rt=A.litHtmlPolyfillSupport;rt?.(G,X),(A.litHtmlVersions??=[]).push("3.0.0");const it=(t,e,s)=>{const n=s?.renderBefore??e;let r=n._$litPart$;if(void 0===r){const t=s?.renderBefore??null;n._$litPart$=r=new X(e.insertBefore(U(),t),t,void 0,s??{})}return r._$AI(t),r};let ot=class extends v{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=it(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return I}};ot._$litElement$=!0,ot.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:ot});const at=globalThis.litElementPolyfillSupport;at?.({LitElement:ot}),(globalThis.litElementVersions??=[]).push("4.0.0");class ct{#t=!1;lock(t){this.#t=!0,t(),this.#t=!1}get locked(){return this.#t}}const ht=()=>new Map,lt=()=>new Set;function ut(t){return new dt(t)}class dt{map;constructor(t){this.map=t}grab(t,e){const{map:s}=this;if(s.has(t))return s.get(t);{const n=e();return s.set(t,n),n}}}class pt{#e=new WeakMap;grab_keymap(t){const e=ut(this.#e).grab(t,ht);return{keymap:e,grab_symbolmap:t=>ut(e).grab(t,ht)}}clear(){this.#e=new WeakMap}}class ft{#s=new Map;stop(t){const e=this.#s.get(t);e&&(this.#s.delete(t),e())}add(t,e){this.#s.set(t,e)}}class _t{#n=[];record(t){const e=ht();return this.#n.push(e),t(),this.#n.pop(),e}record_that_key_was_accessed(t,e){const s=this.#n.at(-1);if(s){ut(s).grab(t,lt).add(e)}}}class gt extends Error{name=this.constructor.name}class $t extends gt{constructor(t){super(`forbidden circularity, rejected assignment to "${t}"`)}}class mt extends gt{constructor(t){super(`forbidden assignment to readonly property "${t}"`)}}function bt(t){return new Proxy(t,{get:(t,e)=>t[e],set(t,e){throw new mt(e)}})}function yt(t,e){let s,n,r=[];function i(){s=[],n&&clearTimeout(n),n=void 0,r=[]}return i(),(...o)=>{s=o,n&&clearTimeout(n);const a=new Promise(((t,e)=>{r.push({resolve:t,reject:e})}));return n=setTimeout((()=>{Promise.resolve().then((()=>e(...s))).then((t=>{for(const{resolve:e}of r)e(t);i()})).catch((t=>{for(const{reject:e}of r)e(t);i()}))}),t),a}}class wt{#r=new Map;#i=Promise.resolve();#o=yt(0,(()=>{const t=[...this.#r.values()];this.#r.clear();for(const e of t)e()}));get wait(){return this.#i}add(t,e){this.#r.set(t,e),this.#i=this.#o()}}function vt(t){return function(e){return()=>{const s="function"==typeof t?t():t;return e(s)}}}function At(t,e,s,n){const r=[];for(const[i,o]of e){const{grab_symbolmap:e}=s.grab_keymap(i);for(const s of o){const i=e(s);i.set(t,n),r.push((()=>i.delete(t)))}}return()=>r.forEach((t=>t()))}var xt;!function(t){var e;t.map=(t,e)=>Object.fromEntries(Object.entries(t).map((([t,s])=>[t,e(s,t)]))),t.filter=(t,e)=>Object.fromEntries(Object.entries(t).filter((([t,s])=>e(s,t)))),(e=t.pipe||(t.pipe={})).map=e=>s=>t.map(s,e),e.filter=e=>s=>t.filter(s,e)}(xt||(xt={}));class St extends Error{name=this.constructor.name}class kt{#a;#c=!1;#i;#h=new Set;accessed=!1;constructor(t){this.#a=t,this.#i=Promise.resolve(t)}subscribe(t){return this.#h.add(t),()=>{this.#h.delete(t)}}once(t){const e=s=>{t(s),this.#h.delete(e)};return this.#h.add(e),()=>{this.#h.delete(e)}}clear(){return this.#h.clear()}#l=yt(0,(()=>{const t=this.#a;this.#c=!0;for(const e of this.#h)e(t);return this.#c=!1,t}));async publish(){this.#i=this.#l(),await this.#i}get wait(){return this.#i}get value(){return this.accessed=!0,this.#a}set value(t){if(this.#c)throw new St("you can't set a signal in a signal's subscription listener (infinite loop forbidden)");this.#a=t,this.publish()}}const Ct=Error;var Et;!function(t){function e(t,e){switch(t.mode){case"loading":return e.loading();case"error":return e.error(t.reason);case"ready":return e.ready(t.payload);default:throw console.error("op",t),new Ct("invalid op mode")}}t.loading=()=>({mode:"loading"}),t.error=t=>({mode:"error",reason:t}),t.ready=t=>({mode:"ready",payload:t}),t.is=Object.freeze({loading:t=>"loading"===t.mode,error:t=>"error"===t.mode,ready:t=>"ready"===t.mode}),t.payload=function(t){return"ready"===t.mode?t.payload:void 0},t.select=e,t.run=async function(e,s){e(t.loading());try{const n=await s();return e(t.ready(n)),n}catch(s){const n=s instanceof Ct?s.message:"string"==typeof s?s:"error";e(t.error(n))}},t.morph=function(s,n){return e(s,{loading:()=>t.loading(),error:e=>t.error(e),ready:e=>t.ready(n(e))})}}(Et||(Et={}));class Mt extends kt{constructor(){super(Et.loading())}async run(t){return Et.run((t=>this.value=t),t)}setLoading(){this.value=Et.loading()}setError(t){this.value=Et.error(t)}setReady(t){this.value=Et.ready(t)}get loading(){return Et.is.loading(this.value)}get error(){return Et.is.error(this.value)}get ready(){return Et.is.ready(this.value)}get payload(){return Et.payload(this.value)}select(t){return Et.select(this.value,t)}}class Pt{#u;constructor(t){this.#u=t}get state(){return this.#u.getter(this.#u.parent.state)}transmute(t){this.#u.parent.transmute((e=>{const s=this.#u.getter(e),n=t(s);return this.#u.setter(e,n)}))}slice({getter:t,setter:e}){return new Pt({parent:this,getter:t,setter:e})}}function Ut(t){return null===t||"object"!=typeof t?t:(Object.values(t).forEach((t=>{"object"==typeof t&&null!==t&&Ut(t)})),Object.freeze(t))}class Ot{#d;#p;#f;#_=!1;#g(){return Ut(structuredClone(this.#d))}constructor(t,e=(()=>{})){this.#d=structuredClone(t),this.#p=this.#g(),this.#f=e}get state(){return this.#p}transmute(t){if(this.#_)throw new Error("circular error");this.#_=!0,this.#d=t(structuredClone(this.#d)),this.#p=this.#g(),this.#f(),this.#_=!1}slice({getter:t,setter:e}){return new Pt({parent:this,getter:t,setter:e})}}const Tt=(t,e)=>{if(t===e)return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;const s=Object.keys(t),n=Object.keys(e);if(s.length!==n.length)return!1;for(const r of s){if(!n.includes(r))return!1;if(!Tt(t[r],e[r]))return!1}return!0};const Nt=new class{static readonly=bt;static collectivize=vt;#$=new pt;#m=new _t;#b=new ct;#y=new ft;#w=new wt;#v=function(t,e,s,n,r){function i([r,i]){if(s.lock(i.responder),i.discover){n.stop(r);const o=e.record((()=>s.lock(i.collector)));n.add(r,At(r,o,t,i))}}return{get:(t,s)=>(e.record_that_key_was_accessed(t,s),t[s]),set:(e,n,o)=>{if(s.locked)throw new $t(n);e[n]=o;const a=[...t.grab_keymap(e).grab_symbolmap(n)];for(const t of a){const[e,s]=t;s.debounce?r.add(e,(()=>i(t))):i(t)}return!0}}}(this.#$,this.#m,this.#b,this.#y,this.#w);get wait(){return this.#w.wait}state(t){return new Proxy(t,this.#v)}manual(t){const e=Symbol(),s=this.#m.record((()=>this.#b.lock(t.collector)));return this.#y.add(e,At(e,s,this.#$,t)),()=>this.#y.stop(e)}auto({debounce:t,discover:e,collector:s,responder:n}){return this.manual({debounce:t,discover:e,collector:s,responder:n?()=>n(s()):s})}reaction(t,e){return this.auto({debounce:!0,discover:!1,collector:t,responder:e})}deepReaction(t,e){return this.auto({debounce:!0,discover:!0,collector:t,responder:e})}clear(){this.#$.clear()}},Ht=new class{#A=new Set;#x=new Set;signal(t){const e=new kt(t);return this.#A.add(e),e}computed(t){const e=this.signal(t());return this.track((()=>{e.value=t()})),e}op(){const t=new Mt;return this.#A.add(t),t}many(t){return xt.map(t,(t=>this.signal(t)))}track(t,e=t){const s=yt(0,e),n=[];for(const t of this.#A)t.accessed=!1;t();for(const t of this.#A)t.accessed&&n.push(t);const r=n.map((t=>t.subscribe((()=>{const t=s();this.#x.add(t)}))));return()=>r.forEach((t=>t()))}get wait(){return Promise.all([...this.#A].map((t=>t.wait))).then((()=>Promise.all([...this.#x]))).then((()=>{this.#x.clear()}))}},jt=new class{#S=new Set;#h=new Set;#k=new Map;dispatch(){for(const t of this.#S)t();for(const t of this.#h)t()}computed(t){let e=t();return this.#S.add((()=>{e=t()})),{get value(){return e}}}track(t,e){let s=!0;const n=()=>{const n=t(),r=this.#k.get(t);!s&&Tt(n,r)||(s=!1,this.#k.set(t,n),e(n))};return n(),this.#h.add(n),t()}stateTree(t){return new Ot(t,(()=>this.dispatch()))}};Nt.state.bind(Nt),Ht.signal.bind(Ht);class Rt extends(function(t){return class extends t{#C=(new Set).add((()=>this.setup()));#E=new Set;register_setup(t){this.#C.add(t)}setup(){return()=>{}}connectedCallback(){for(const t of this.#C)this.#E.add(t())}disconnectedCallback(){for(const t of this.#E)t();this.#E.clear()}}}(HTMLElement)){}function zt(){let t,e;return{promise:new Promise(((s,n)=>{t=s,e=n})),resolve:t,reject:e}}function qt(t,e){o(t,function(t){const e=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const t of s)e.unshift(a(t))}else void 0!==t&&e.push(a(t));return e}(e))}class Dt extends Rt{static get styles(){}#M;#P=zt();#i=this.#P.promise;init(){}constructor(){super(),this.#M=this.attachShadow({mode:"open"});const t=this.constructor;qt(this.#M,t.styles),this.init()}get root(){return this.#M}get updateComplete(){return this.#i.then((()=>!0))}render(){}#U=yt(0,(()=>{const t=this.#M,e=this.render();e&&it(e,t,{host:this})}));async requestUpdate(){const t=this.#U();return this.#P&&(t.then(this.#P.resolve),this.#P=void 0),this.#i=t,t}connectedCallback(){super.connectedCallback(),this.requestUpdate()}}class Lt extends Dt{static styles=i`span {color: orange}`;#d=Nt.state({count:0});render(){return B` | ||
Array.prototype.at=function(t){return t>=0?this[t]:this[this.length+t]};const t=globalThis,e=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s=Symbol(),n=new WeakMap;let r=class{constructor(t,e,n){if(this._$cssResult$=!0,n!==s)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const s=this.t;if(e&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=n.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&n.set(s,t))}return t}toString(){return this.cssText}};const i=(t,...e)=>{const n=1===t.length?t[0]:e.reduce(((e,s,n)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+t[n+1]),t[0]);return new r(n,t,s)},o=(s,n)=>{if(e)s.adoptedStyleSheets=n.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of n){const n=document.createElement("style"),r=t.litNonce;void 0!==r&&n.setAttribute("nonce",r),n.textContent=e.cssText,s.appendChild(n)}},a=e?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return(t=>new r("string"==typeof t?t:t+"",void 0,s))(e)})(t):t,{is:c,defineProperty:h,getOwnPropertyDescriptor:l,getOwnPropertyNames:u,getOwnPropertySymbols:d,getPrototypeOf:p}=Object,f=globalThis,_=f.trustedTypes,g=_?_.emptyScript:"",$=f.reactiveElementPolyfillSupport,m=(t,e)=>t,b={toAttribute(t,e){switch(e){case Boolean:t=t?g:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let s=t;switch(e){case Boolean:s=null!==t;break;case Number:s=null===t?null:Number(t);break;case Object:case Array:try{s=JSON.parse(t)}catch(t){s=null}}return s}},y=(t,e)=>!c(t,e),w={attribute:!0,type:String,converter:b,reflect:!1,hasChanged:y};Symbol.metadata??=Symbol("metadata"),f.litPropertyMetadata??=new WeakMap;class v extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=w){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const s=Symbol(),n=this.getPropertyDescriptor(t,s,e);void 0!==n&&h(this.prototype,t,n)}}static getPropertyDescriptor(t,e,s){const{get:n,set:r}=l(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get(){return n?.call(this)},set(e){const i=n?.call(this);r.call(this,e),this.requestUpdate(t,i,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??w}static _$Ei(){if(this.hasOwnProperty(m("elementProperties")))return;const t=p(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(m("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(m("properties"))){const t=this.properties,e=[...u(t),...d(t)];for(const s of e)this.createProperty(s,t[s])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,s]of e)this.elementProperties.set(t,s)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const s=this._$Eu(t,e);void 0!==s&&this._$Eh.set(s,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const t of s)e.unshift(a(t))}else void 0!==t&&e.push(a(t));return e}static _$Eu(t,e){const s=e.attribute;return!1===s?void 0:"string"==typeof s?s:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$Eg=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$ES??=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$ES?.splice(this._$ES.indexOf(t)>>>0,1)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const s of e.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return o(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$ES?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$ES?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,e,s){this._$AK(t,s)}_$EO(t,e){const s=this.constructor.elementProperties.get(t),n=this.constructor._$Eu(t,s);if(void 0!==n&&!0===s.reflect){const r=(void 0!==s.converter?.toAttribute?s.converter:b).toAttribute(e,s.type);this._$Em=t,null==r?this.removeAttribute(n):this.setAttribute(n,r),this._$Em=null}}_$AK(t,e){const s=this.constructor,n=s._$Eh.get(t);if(void 0!==n&&this._$Em!==n){const t=s.getPropertyOptions(n),r="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:b;this._$Em=n,this[n]=r.fromAttribute(e,t.type),this._$Em=null}}requestUpdate(t,e,s,n=!1,r){if(void 0!==t){if(s??=this.constructor.getPropertyOptions(t),!(s.hasChanged??y)(n?r:this[t],e))return;this.C(t,e,s)}!1===this.isUpdatePending&&(this._$Eg=this._$EP())}C(t,e,s){this._$AL.has(t)||this._$AL.set(t,e),!0===s.reflect&&this._$Em!==t&&(this._$Ej??=new Set).add(t)}async _$EP(){this.isUpdatePending=!0;try{await this._$Eg}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this._$Ep){for(const[t,e]of this._$Ep)this[t]=e;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,s]of t)!0!==s.wrapped||this._$AL.has(e)||void 0===this[e]||this.C(e,this[e],s)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$ES?.forEach((t=>t.hostUpdate?.())),this.update(e)):this._$ET()}catch(e){throw t=!1,this._$ET(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$ES?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$ET(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Eg}shouldUpdate(t){return!0}update(t){this._$Ej&&=this._$Ej.forEach((t=>this._$EO(t,this[t]))),this._$ET()}updated(t){}firstUpdated(t){}}v.elementStyles=[],v.shadowRootOptions={mode:"open"},v[m("elementProperties")]=new Map,v[m("finalized")]=new Map,$?.({ReactiveElement:v}),(f.reactiveElementVersions??=[]).push("2.0.0");const A=globalThis,x=A.trustedTypes,S=x?x.createPolicy("lit-html",{createHTML:t=>t}):void 0,k="$lit$",C=`lit$${(Math.random()+"").slice(9)}$`,E="?"+C,M=`<${E}>`,P=document,U=()=>P.createComment(""),O=t=>null===t||"object"!=typeof t&&"function"!=typeof t,T=Array.isArray,N="[ \t\n\f\r]",H=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,j=/-->/g,R=/>/g,z=RegExp(`>|${N}(?:([^\\s"'>=/]+)(${N}*=${N}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),q=/'/g,D=/"/g,L=/^(?:script|style|textarea|title)$/i,B=(t=>(e,...s)=>({_$litType$:t,strings:e,values:s}))(1),I=Symbol.for("lit-noChange"),V=Symbol.for("lit-nothing"),W=new WeakMap,Z=P.createTreeWalker(P,129);function J(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==S?S.createHTML(e):e}const K=(t,e)=>{const s=t.length-1,n=[];let r,i=2===e?"<svg>":"",o=H;for(let e=0;e<s;e++){const s=t[e];let a,c,h=-1,l=0;for(;l<s.length&&(o.lastIndex=l,c=o.exec(s),null!==c);)l=o.lastIndex,o===H?"!--"===c[1]?o=j:void 0!==c[1]?o=R:void 0!==c[2]?(L.test(c[2])&&(r=RegExp("</"+c[2],"g")),o=z):void 0!==c[3]&&(o=z):o===z?">"===c[0]?(o=r??H,h=-1):void 0===c[1]?h=-2:(h=o.lastIndex-c[2].length,a=c[1],o=void 0===c[3]?z:'"'===c[3]?D:q):o===D||o===q?o=z:o===j||o===R?o=H:(o=z,r=void 0);const u=o===z&&t[e+1].startsWith("/>")?" ":"";i+=o===H?s+M:h>=0?(n.push(a),s.slice(0,h)+k+s.slice(h)+C+u):s+C+(-2===h?e:u)}return[J(t,i+(t[s]||"<?>")+(2===e?"</svg>":"")),n]};class G{constructor({strings:t,_$litType$:e},s){let n;this.parts=[];let r=0,i=0;const o=t.length-1,a=this.parts,[c,h]=K(t,e);if(this.el=G.createElement(c,s),Z.currentNode=this.el.content,2===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(n=Z.nextNode())&&a.length<o;){if(1===n.nodeType){if(n.hasAttributes())for(const t of n.getAttributeNames())if(t.endsWith(k)){const e=h[i++],s=n.getAttribute(t).split(C),o=/([.?@])?(.*)/.exec(e);a.push({type:1,index:r,name:o[2],strings:s,ctor:"."===o[1]?tt:"?"===o[1]?et:"@"===o[1]?st:Y}),n.removeAttribute(t)}else t.startsWith(C)&&(a.push({type:6,index:r}),n.removeAttribute(t));if(L.test(n.tagName)){const t=n.textContent.split(C),e=t.length-1;if(e>0){n.textContent=x?x.emptyScript:"";for(let s=0;s<e;s++)n.append(t[s],U()),Z.nextNode(),a.push({type:2,index:++r});n.append(t[e],U())}}}else if(8===n.nodeType)if(n.data===E)a.push({type:2,index:r});else{let t=-1;for(;-1!==(t=n.data.indexOf(C,t+1));)a.push({type:7,index:r}),t+=C.length-1}r++}}static createElement(t,e){const s=P.createElement("template");return s.innerHTML=t,s}}function Q(t,e,s=t,n){if(e===I)return e;let r=void 0!==n?s._$Co?.[n]:s._$Cl;const i=O(e)?void 0:e._$litDirective$;return r?.constructor!==i&&(r?._$AO?.(!1),void 0===i?r=void 0:(r=new i(t),r._$AT(t,s,n)),void 0!==n?(s._$Co??=[])[n]=r:s._$Cl=r),void 0!==r&&(e=Q(t,r._$AS(t,e.values),r,n)),e}class F{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:s}=this._$AD,n=(t?.creationScope??P).importNode(e,!0);Z.currentNode=n;let r=Z.nextNode(),i=0,o=0,a=s[0];for(;void 0!==a;){if(i===a.index){let e;2===a.type?e=new X(r,r.nextSibling,this,t):1===a.type?e=new a.ctor(r,a.name,a.strings,this,t):6===a.type&&(e=new nt(r,this,t)),this._$AV.push(e),a=s[++o]}i!==a?.index&&(r=Z.nextNode(),i++)}return Z.currentNode=P,n}p(t){let e=0;for(const s of this._$AV)void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,e),e+=s.strings.length-2):s._$AI(t[e])),e++}}class X{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,s,n){this.type=2,this._$AH=V,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=s,this.options=n,this._$Cv=n?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t?.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=Q(this,t,e),O(t)?t===V||null==t||""===t?(this._$AH!==V&&this._$AR(),this._$AH=V):t!==this._$AH&&t!==I&&this._(t):void 0!==t._$litType$?this.g(t):void 0!==t.nodeType?this.$(t):(t=>T(t)||"function"==typeof t?.[Symbol.iterator])(t)?this.T(t):this._(t)}k(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}$(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}_(t){this._$AH!==V&&O(this._$AH)?this._$AA.nextSibling.data=t:this.$(P.createTextNode(t)),this._$AH=t}g(t){const{values:e,_$litType$:s}=t,n="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=G.createElement(J(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===n)this._$AH.p(e);else{const t=new F(n,this),s=t.u(this.options);t.p(e),this.$(s),this._$AH=t}}_$AC(t){let e=W.get(t.strings);return void 0===e&&W.set(t.strings,e=new G(t)),e}T(t){T(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let s,n=0;for(const r of t)n===e.length?e.push(s=new X(this.k(U()),this.k(U()),this,this.options)):s=e[n],s._$AI(r),n++;n<e.length&&(this._$AR(s&&s._$AB.nextSibling,n),e.length=n)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t&&t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t))}}class Y{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,n,r){this.type=1,this._$AH=V,this._$AN=void 0,this.element=t,this.name=e,this._$AM=n,this.options=r,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=V}_$AI(t,e=this,s,n){const r=this.strings;let i=!1;if(void 0===r)t=Q(this,t,e,0),i=!O(t)||t!==this._$AH&&t!==I,i&&(this._$AH=t);else{const n=t;let o,a;for(t=r[0],o=0;o<r.length-1;o++)a=Q(this,n[s+o],e,o),a===I&&(a=this._$AH[o]),i||=!O(a)||a!==this._$AH[o],a===V?t=V:t!==V&&(t+=(a??"")+r[o+1]),this._$AH[o]=a}i&&!n&&this.j(t)}j(t){t===V?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class tt extends Y{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===V?void 0:t}}class et extends Y{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==V)}}class st extends Y{constructor(t,e,s,n,r){super(t,e,s,n,r),this.type=5}_$AI(t,e=this){if((t=Q(this,t,e,0)??V)===I)return;const s=this._$AH,n=t===V&&s!==V||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,r=t!==V&&(s===V||n);n&&this.element.removeEventListener(this.name,this,s),r&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}}class nt{constructor(t,e,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){Q(this,t)}}const rt=A.litHtmlPolyfillSupport;rt?.(G,X),(A.litHtmlVersions??=[]).push("3.0.0");const it=(t,e,s)=>{const n=s?.renderBefore??e;let r=n._$litPart$;if(void 0===r){const t=s?.renderBefore??null;n._$litPart$=r=new X(e.insertBefore(U(),t),t,void 0,s??{})}return r._$AI(t),r};let ot=class extends v{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=it(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return I}};ot._$litElement$=!0,ot.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:ot});const at=globalThis.litElementPolyfillSupport;at?.({LitElement:ot}),(globalThis.litElementVersions??=[]).push("4.0.0");class ct{#t=!1;lock(t){this.#t=!0,t(),this.#t=!1}get locked(){return this.#t}}const ht=()=>new Map,lt=()=>new Set;function ut(t){return new dt(t)}class dt{map;constructor(t){this.map=t}grab(t,e){const{map:s}=this;if(s.has(t))return s.get(t);{const n=e();return s.set(t,n),n}}}class pt{#e=new WeakMap;grab_keymap(t){const e=ut(this.#e).grab(t,ht);return{keymap:e,grab_symbolmap:t=>ut(e).grab(t,ht)}}clear(){this.#e=new WeakMap}}class ft{#s=new Map;stop(t){const e=this.#s.get(t);e&&(this.#s.delete(t),e())}add(t,e){this.#s.set(t,e)}}class _t{#n=[];record(t){const e=ht();return this.#n.push(e),t(),this.#n.pop(),e}record_that_key_was_accessed(t,e){const s=this.#n.at(-1);if(s){ut(s).grab(t,lt).add(e)}}}class gt extends Error{name=this.constructor.name}class $t extends gt{constructor(t){super(`forbidden circularity, rejected assignment to "${t}"`)}}class mt extends gt{constructor(t){super(`forbidden assignment to readonly property "${t}"`)}}function bt(t){return new Proxy(t,{get:(t,e)=>t[e],set(t,e){throw new mt(e)}})}function yt(t,e){let s,n,r=[];function i(){s=[],n&&clearTimeout(n),n=void 0,r=[]}return i(),(...o)=>{s=o,n&&clearTimeout(n);const a=new Promise(((t,e)=>{r.push({resolve:t,reject:e})}));return n=setTimeout((()=>{Promise.resolve().then((()=>e(...s))).then((t=>{for(const{resolve:e}of r)e(t);i()})).catch((t=>{for(const{reject:e}of r)e(t);i()}))}),t),a}}class wt{#r=new Map;#i=Promise.resolve();#o=yt(0,(()=>{const t=[...this.#r.values()];this.#r.clear();for(const e of t)e()}));get wait(){return this.#i}add(t,e){this.#r.set(t,e),this.#i=this.#o()}}function vt(t){return function(e){return()=>{const s="function"==typeof t?t():t;return e(s)}}}function At(t,e,s,n){const r=[];for(const[i,o]of e){const{grab_symbolmap:e}=s.grab_keymap(i);for(const s of o){const i=e(s);i.set(t,n),r.push((()=>i.delete(t)))}}return()=>r.forEach((t=>t()))}var xt;!function(t){var e;t.map=(t,e)=>Object.fromEntries(Object.entries(t).map((([t,s])=>[t,e(s,t)]))),t.filter=(t,e)=>Object.fromEntries(Object.entries(t).filter((([t,s])=>e(s,t)))),(e=t.pipe||(t.pipe={})).map=e=>s=>t.map(s,e),e.filter=e=>s=>t.filter(s,e)}(xt||(xt={}));class St extends Error{name=this.constructor.name}class kt{#a;#c=!1;#i;#h=new Set;accessed=!1;constructor(t){this.#a=t,this.#i=Promise.resolve(t)}subscribe(t){return this.#h.add(t),()=>{this.#h.delete(t)}}once(t){const e=s=>{t(s),this.#h.delete(e)};return this.#h.add(e),()=>{this.#h.delete(e)}}clear(){return this.#h.clear()}#l=yt(0,(()=>{const t=this.#a;this.#c=!0;for(const e of this.#h)e(t);return this.#c=!1,t}));async publish(){this.#i=this.#l(),await this.#i}get wait(){return this.#i}get value(){return this.accessed=!0,this.#a}set value(t){if(this.#c)throw new St("you can't set a signal in a signal's subscription listener (infinite loop forbidden)");this.#a=t,this.publish()}}const Ct=Error;var Et;!function(t){function e(t,e){switch(t.mode){case"loading":return e.loading();case"error":return e.error(t.reason);case"ready":return e.ready(t.payload);default:throw console.error("op",t),new Ct("invalid op mode")}}t.loading=()=>({mode:"loading"}),t.error=t=>({mode:"error",reason:t}),t.ready=t=>({mode:"ready",payload:t}),t.is=Object.freeze({loading:t=>"loading"===t.mode,error:t=>"error"===t.mode,ready:t=>"ready"===t.mode}),t.payload=function(t){return"ready"===t.mode?t.payload:void 0},t.select=e,t.run=async function(e,s){e(t.loading());try{const n=await s();return e(t.ready(n)),n}catch(s){const n=s instanceof Ct?s.message:"string"==typeof s?s:"error";e(t.error(n))}},t.morph=function(s,n){return e(s,{loading:()=>t.loading(),error:e=>t.error(e),ready:e=>t.ready(n(e))})}}(Et||(Et={}));class Mt extends kt{constructor(){super(Et.loading())}async run(t){return Et.run((t=>this.value=t),t)}setLoading(){this.value=Et.loading()}setError(t){this.value=Et.error(t)}setReady(t){this.value=Et.ready(t)}get loading(){return Et.is.loading(this.value)}get error(){return Et.is.error(this.value)}get ready(){return Et.is.ready(this.value)}get payload(){return Et.payload(this.value)}select(t){return Et.select(this.value,t)}}class Pt{#u;constructor(t){this.#u=t}get state(){return this.#u.getter(this.#u.parent.state)}transmute(t){this.#u.parent.transmute((e=>{const s=this.#u.getter(e),n=t(s);return this.#u.setter(e,n)}))}slice({getter:t,setter:e}){return new Pt({parent:this,getter:t,setter:e})}}function Ut(t){return null===t||"object"!=typeof t?t:(Object.values(t).forEach((t=>{"object"==typeof t&&null!==t&&Ut(t)})),Object.freeze(t))}class Ot{#d;#p;#f;#_=!1;#g(){return Ut(structuredClone(this.#d))}constructor(t,e=(()=>{})){this.#d=structuredClone(t),this.#p=this.#g(),this.#f=e}get state(){return this.#p}transmute(t){if(this.#_)throw new Error("circular error");this.#_=!0,this.#d=t(structuredClone(this.#d)),this.#p=this.#g(),this.#f(),this.#_=!1}slice({getter:t,setter:e}){return new Pt({parent:this,getter:t,setter:e})}}const Tt=(t,e)=>{if(t===e)return!0;if("object"!=typeof t||null===t||"object"!=typeof e||null===e)return!1;const s=Object.keys(t),n=Object.keys(e);if(s.length!==n.length)return!1;for(const r of s){if(!n.includes(r))return!1;if(!Tt(t[r],e[r]))return!1}return!0};const Nt=new class{static readonly=bt;static collectivize=vt;#$=new pt;#m=new _t;#b=new ct;#y=new ft;#w=new wt;#v=function(t,e,s,n,r){function i([r,i]){if(s.lock(i.responder),i.discover){n.stop(r);const o=e.record((()=>s.lock(i.collector)));n.add(r,At(r,o,t,i))}}return{get:(t,s)=>(e.record_that_key_was_accessed(t,s),t[s]),set:(e,n,o)=>{if(s.locked)throw new $t(n);e[n]=o;const a=[...t.grab_keymap(e).grab_symbolmap(n)];for(const t of a){const[e,s]=t;s.debounce?r.add(e,(()=>i(t))):i(t)}return!0}}}(this.#$,this.#m,this.#b,this.#y,this.#w);get wait(){return this.#w.wait}state(t){return new Proxy(t,this.#v)}manual(t){const e=Symbol(),s=this.#m.record((()=>this.#b.lock(t.collector)));return this.#y.add(e,At(e,s,this.#$,t)),()=>this.#y.stop(e)}auto({debounce:t,discover:e,collector:s,responder:n}){return this.manual({debounce:t,discover:e,collector:s,responder:n?()=>n(s()):s})}reaction(t,e){return this.auto({debounce:!0,discover:!1,collector:t,responder:e})}deepReaction(t,e){return this.auto({debounce:!0,discover:!0,collector:t,responder:e})}clear(){this.#$.clear()}},Ht=new class{#A=new Set;#x=new Set;signal(t){const e=new kt(t);return this.#A.add(e),e}computed(t){const e=this.signal(t());return this.track((()=>{e.value=t()})),e}op(){const t=new Mt;return this.#A.add(t),t}many(t){return xt.map(t,(t=>this.signal(t)))}track(t,e=t){const s=yt(0,e),n=[];for(const t of this.#A)t.accessed=!1;t();for(const t of this.#A)t.accessed&&n.push(t);const r=n.map((t=>t.subscribe((()=>{const t=s();this.#x.add(t)}))));return()=>r.forEach((t=>t()))}get wait(){return Promise.all([...this.#A].map((t=>t.wait))).then((()=>Promise.all([...this.#x]))).then((()=>{this.#x.clear()}))}},jt=new class{#A;#S=new Set;#h=new Set;#k=new Map;constructor(t){this.#A=t}dispatch(){for(const t of this.#S)t();for(const t of this.#h)t()}computed(t){const e=this.#A.signal(t());return this.#S.add((()=>{e.value=t()})),e}track(t,e){let s=!0;const n=()=>{const n=t(),r=this.#k.get(t);!s&&Tt(n,r)||(s=!1,this.#k.set(t,n),e(n))};return n(),this.#h.add(n),t()}stateTree(t){return new Ot(t,(()=>this.dispatch()))}}(Ht);Nt.state.bind(Nt),Ht.signal.bind(Ht);class Rt extends(function(t){return class extends t{#C=(new Set).add((()=>this.setup()));#E=new Set;register_setup(t){this.#C.add(t)}setup(){return()=>{}}connectedCallback(){for(const t of this.#C)this.#E.add(t())}disconnectedCallback(){for(const t of this.#E)t();this.#E.clear()}}}(HTMLElement)){}function zt(){let t,e;return{promise:new Promise(((s,n)=>{t=s,e=n})),resolve:t,reject:e}}function qt(t,e){o(t,function(t){const e=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const t of s)e.unshift(a(t))}else void 0!==t&&e.push(a(t));return e}(e))}class Dt extends Rt{static get styles(){}#M;#P=zt();#i=this.#P.promise;init(){}constructor(){super(),this.#M=this.attachShadow({mode:"open"});const t=this.constructor;qt(this.#M,t.styles),this.init()}get root(){return this.#M}get updateComplete(){return this.#i.then((()=>!0))}render(){}#U=yt(0,(()=>{const t=this.#M,e=this.render();e&&it(e,t,{host:this})}));async requestUpdate(){const t=this.#U();return this.#P&&(t.then(this.#P.resolve),this.#P=void 0),this.#i=t,t}connectedCallback(){super.connectedCallback(),this.requestUpdate()}}class Lt extends Dt{static styles=i`span {color: orange}`;#d=Nt.state({count:0});render(){return B` | ||
<span>${this.#d.count}</span> | ||
@@ -3,0 +3,0 @@ <button @click=${()=>this.#d.count++}>gold</button> |
@@ -25,4 +25,4 @@ export * from "./flatstate/flat.js"; | ||
export * from "./tools/requirement.js"; | ||
export * from "./watch/watch_tower.js"; | ||
export * from "./watch/tower.js"; | ||
export * from "./watch/state_tree.js"; | ||
export * from "./watch/zip/action.js"; |
@@ -25,5 +25,5 @@ export * from "./flatstate/flat.js"; | ||
export * from "./tools/requirement.js"; | ||
export * from "./watch/watch_tower.js"; | ||
export * from "./watch/tower.js"; | ||
export * from "./watch/state_tree.js"; | ||
export * from "./watch/zip/action.js"; | ||
//# sourceMappingURL=pure.js.map |
import { Flat } from "../flatstate/flat.js"; | ||
import { SignalTower } from "../signals/tower.js"; | ||
import { WatchTower } from "../watch/watch_tower.js"; | ||
import { WatchTower } from "../watch/tower.js"; | ||
export declare const flat: Flat; | ||
@@ -5,0 +5,0 @@ export declare const signals: SignalTower; |
import { Flat } from "../flatstate/flat.js"; | ||
import { SignalTower } from "../signals/tower.js"; | ||
import { WatchTower } from "../watch/watch_tower.js"; | ||
import { WatchTower } from "../watch/tower.js"; | ||
export const flat = new Flat(); | ||
export const signals = new SignalTower(); | ||
export const watch = new WatchTower(); | ||
export const watch = new WatchTower(signals); | ||
export const flatstate = flat.state.bind(flat); | ||
export const signal = signals.signal.bind(signals); | ||
//# sourceMappingURL=state.js.map |
import { Slice } from "./slice.js"; | ||
export interface WatchBox<V> { | ||
readonly value: V; | ||
} | ||
export interface SliceAccessors<S, X> { | ||
@@ -6,0 +3,0 @@ getter: (state: S) => X; |
import { expect } from "cynic"; | ||
import { WatchTower } from "./watch_tower.js"; | ||
import { WatchTower } from "./tower.js"; | ||
import { SignalTower } from "../signals/tower.js"; | ||
function setup() { | ||
const watch = new WatchTower(); | ||
const signals = new SignalTower(); | ||
const watch = new WatchTower(signals); | ||
const tree = watch.stateTree({ | ||
@@ -6,0 +8,0 @@ count: 0, |
@@ -12,3 +12,11 @@ import { StateTree } from "../state_tree.js"; | ||
function actualize<S, B extends Blueprint<S>>(tree: StateTree<S>, blueprint: B): Callable<B>; | ||
function fn<S>(): <F extends Fn<S, any[]>>(fn: F) => F; | ||
function blueprint<S>(): <B extends Blueprint<S>>(blueprint: B) => B; | ||
type Helpers<S, H> = (state: S, setState: ZipAction.SetState<S>) => H; | ||
const prepFn: <S, H>(helpers: Helpers<S, H>) => <P extends any[]>(fun: (helpers: H) => (...params: P) => void) => Fn<S, P>; | ||
const prepBlueprint: <S, H>(helpers: Helpers<S, H>) => <B extends Blueprint<S>>(makeBp: (action: <P extends any[]>(f: (helpers: H) => (...params: P) => void) => Fn<S, P>) => B) => B; | ||
function prep<S, H>(helpers: Helpers<S, H>): { | ||
action: <P extends any[]>(fun: (helpers: H) => (...params: P) => void) => Fn<S, P>; | ||
blueprint: <B extends Blueprint<S>>(makeBp: (action: <P_1 extends any[]>(f: (helpers: H) => (...params: P_1) => void) => Fn<S, P_1>) => B) => B; | ||
}; | ||
} |
@@ -21,2 +21,6 @@ import { ob } from "../../tools/ob.js"; | ||
ZipAction.actualize = actualize; | ||
function fn() { | ||
return (fn) => fn; | ||
} | ||
ZipAction.fn = fn; | ||
function blueprint() { | ||
@@ -26,3 +30,15 @@ return (blueprint) => blueprint; | ||
ZipAction.blueprint = blueprint; | ||
ZipAction.prepFn = (helpers) => (fun) => ((state, setState) => (...params) => { | ||
fun(helpers(state, setState))(...params); | ||
return state; | ||
}); | ||
ZipAction.prepBlueprint = (helpers) => (makeBp) => (makeBp(ZipAction.prepFn(helpers))); | ||
function prep(helpers) { | ||
return { | ||
action: ZipAction.prepFn(helpers), | ||
blueprint: ZipAction.prepBlueprint(helpers), | ||
}; | ||
} | ||
ZipAction.prep = prep; | ||
})(ZipAction || (ZipAction = {})); | ||
//# sourceMappingURL=action.js.map |
@@ -8,8 +8,9 @@ import { expect } from "cynic"; | ||
const blueprint = ZipAction.blueprint(); | ||
const testActions = ZipAction.prepBlueprint((state) => state.test); | ||
const tree = new StateTree({ test: { count: 0 } }, () => { memory = tree.state.test.count; }); | ||
const subgroup = blueprint({ | ||
double: state => () => { | ||
state.test.count *= 2; | ||
}, | ||
}); | ||
const subgroup = testActions(action => ({ | ||
double: action(test => () => { | ||
test.count *= 2; | ||
}), | ||
})); | ||
const counting_specs = blueprint({ | ||
@@ -16,0 +17,0 @@ ...subgroup, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
542255
9190