@e280/authlocal
Version:
User-sovereign login system for everybody
67 lines (65 loc) • 81.3 kB
JavaScript
class t{#t=!1;lock(t){this.#t=!0;const e=t();return this.#t=!1,e}get locked(){return this.#t}}const e=()=>new Map,s=()=>new Set;function n(t){return{guarantee:(e,s)=>function(t,e,s){if(t.has(e))return t.get(e);{const n=s();return t.set(e,n),n}}(t,e,s)}}class r{#e=new WeakMap;grab_keymap(t){const s=n(this.#e).guarantee(t,e);return{keymap:s,grab_symbolmap:t=>n(s).guarantee(t,e)}}clear(){this.#e=new WeakMap}}class i{#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 o{#n=[];record(t){const s=e();this.#n.push(s);const n=t();return this.#n.pop(),{payload:n,recording:s}}record_that_key_was_accessed(t,e){const r=this.#n.at(-1);if(r){n(r).guarantee(t,s).add(e)}}}class a extends Error{name=this.constructor.name}class c extends a{constructor(t){super(`forbidden circularity, rejected assignment to "${t}"`)}}class l extends a{constructor(t){super(`forbidden assignment to readonly property "${t}"`)}}function u(t){return new Proxy(t,{get:(t,e)=>t[e],set(t,e){throw new l(e)}})}function h(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 d{#r=new Map;#i=Promise.resolve();#o=h(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 p(t){return function(e){return()=>{const s="function"==typeof t?t():t;return e(s)}}}function f(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()))}function m(t,e){return g.on_change(t,(()=>t.requestUpdate())),g.proxy(t,e)}var g;!function(t){t.proxy=(t,e)=>new Proxy(e,{get:(s,n)=>{const r=e[n],i=t.getAttribute(n);switch(r){case String:return i??void 0;case Number:return null!==i?Number(i):void 0;case Boolean:return null!==i;default:throw new Error(`invalid attribute type for "${n}"`)}},set:(s,n,r)=>{switch(e[n]){case String:return t.setAttribute(n,r),!0;case Number:return t.setAttribute(n,r.toString()),!0;case Boolean:return r?t.setAttribute(n,""):t.removeAttribute(n),!0;default:throw new Error(`invalid attribute type for "${n}"`)}}}),t.on_change=function(t,e){const s=new MutationObserver(e);return s.observe(t,{attributes:!0}),()=>s.disconnect()}}(g||(g={}));class y{#a;constructor(t){this.#a=t}get state(){return this.#a.getter(this.#a.parent.state)}transmute(t){this.#a.parent.transmute((e=>{const s=this.#a.getter(e),n=t(s);return this.#a.setter(e,n)}))}slice({getter:t,setter:e}){return new y({parent:this,getter:t,setter:e})}}const w=t=>"object"==typeof t&&null!==t;const b={clone:function t(e,s=new Set){if(s.has(e))throw new Error("cannot clone circular reference");let n;return"function"==typeof e||null!==e&&"object"==typeof e?(s.add(e),n=Array.isArray(e)?e.map((e=>t(e,new Set(s)))):e.constructor===Object?Object.fromEntries(Object.entries(e).map((([e,n])=>[e,t(n,new Set(s))]))):e instanceof Map?new Map(Array.from(e,(([e,n])=>[e,t(n,new Set(s))]))):e instanceof Set?new Set(Array.from(e,(e=>t(e,new Set(s))))):e instanceof Date?new Date(e.getTime()):e,s.delete(e)):n=e,n},equal:(t,e)=>function t(e,s,n){if(!w(e)||!w(s))return e===s;if(n.includes(e))throw new Error("forbidden circularity detected in deep equal comparison");const r=[...n,e];if(e instanceof Map&&s instanceof Map){if(e.size!==s.size)return!1;for(const[n,i]of e)if(!s.has(n)||!t(i,s.get(n),r))return!1}else if(e instanceof Set&&s instanceof Set){if(e.size!==s.size)return!1;for(const n of e)if(!Array.from(s).some((e=>t(n,e,r))))return!1}else{const n=Object.keys(e),i=Object.keys(s);if(n.length!==i.length)return!1;for(const o of n){if(!i.includes(o))return!1;if(!t(e[o],s[o],r))return!1}}return!0}(t,e,[]),freeze:function(t){return function t(e,s){if(!w(e)||s.includes(e))return e;const n=[...s,e];if(e instanceof Map)for(const s of e.entries())for(const e of s)t(e,n);else if(e instanceof Set)for(const s of e)t(s,n);else if(Array.isArray(e))for(const s of e)t(s,n);else for(const s of Object.values(e))t(s,n);return Object.freeze(e)}(t,[])}};class v{#c;#l;#u;#h=!1;#d(){return b.freeze(structuredClone(this.#c))}constructor(t,e=()=>{}){this.#c=structuredClone(t),this.#l=this.#d(),this.#u=e}get state(){return this.#l}transmute(t){if(this.#h)throw new Error("circular error");this.#h=!0,this.#c=t(structuredClone(this.#c)),this.#l=this.#d(),this.#u(),this.#h=!1}slice({getter:t,setter:e}){return new y({parent:this,getter:t,setter:e})}}const _=Error;var x;function $(t){return{map:e=>A(t,e),filter:e=>k(t,e)}}!function(t){function e(t){return"ready"===t.status?t.payload:void 0}function s(t,e){switch(t.status){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 _("invalid op status")}}t.loading=()=>({status:"loading"}),t.error=t=>({status:"error",reason:t}),t.ready=t=>({status:"ready",payload:t}),t.is=Object.freeze({loading:t=>"loading"===t.status,error:t=>"error"===t.status,ready:t=>"ready"===t.status}),t.payload=e,t.reason=function(t){return"error"===t.status?t.reason:void 0},t.select=s,t.load=async function(e,s){e(t.loading());try{const n=await s();return e(t.ready(n)),n}catch(s){const n=s instanceof _?s.message:"string"==typeof s?s:"error";throw e(t.error(n)),s}},t.morph=function(e,n){return s(e,{loading:()=>t.loading(),error:e=>t.error(e),ready:e=>t.ready(n(e))})},t.all=function(...s){const n=s.find(t.is.error);return n||(s.every(t.is.ready)?t.ready(s.map(e)):t.loading())}}(x||(x={})),$.pipe=Object.freeze({map:t=>e=>A(e,t),filter:t=>e=>k(e,t)});const A=(t,e)=>Object.fromEntries(Object.entries(t).map((([t,s])=>[t,e(s,t)]))),k=(t,e)=>Object.fromEntries(Object.entries(t).filter((([t,s])=>e(s,t)))),S=Symbol();class E extends Error{name=this.constructor.name}class C{static unwrap=t=>t instanceof C?t.value:t;#p;#f=!1;#i;#m=new Set;[S]=!1;constructor(t){this.#p=t,this.#i=Promise.resolve(t)}subscribe(t){return this.on(t)}on(t){return this.#m.add(t),()=>{this.#m.delete(t)}}once(t){const e=s=>{t(s),this.#m.delete(e)};return this.#m.add(e),()=>{this.#m.delete(e)}}clear(){return this.#m.clear()}#g=h(0,(()=>{const t=this.#p;this.#f=!0;for(const e of this.#m)e(t);return this.#f=!1,t}));async publish(){this.#i=this.#g(),await this.#i}get wait(){return this.#i}get value(){return this[S]=!0,this.#p}set value(t){if(this.#f)throw new E("you can't set a signal in a signal's subscription listener (infinite loop forbidden)");this.#p!==t&&(this.#p=t,this.publish())}setDeep(t){if(this.#f)throw new E("you can't set a signal in a signal's subscription listener (infinite loop forbidden)");b.equal(t,this.#p)||(this.#p=t,this.publish())}setAndPublish(t){if(this.#f)throw new E("you can't set a signal in a signal's subscription listener (infinite loop forbidden)");this.#p=t,this.publish()}setWithoutPublish(t){if(this.#f)throw new E("you can't set a signal in a signal's subscription listener (infinite loop forbidden)");this.#p=t}setValueNoPublish(t){return this.setWithoutPublish(t)}}class O extends C{#y=0;constructor(t){super(t)}async load(t){const e=++this.#y;return x.load((t=>{this.#y===e&&(this.value=t)}),t)}setLoading(){this.value=x.loading()}setError(t){this.value=x.error(t)}setReady(t){this.value=x.ready(t)}isLoading(){return x.is.loading(this.value)}isError(){return x.is.error(this.value)}isReady(){return x.is.ready(this.value)}get payload(){return x.payload(this.value)}select(t){return x.select(this.value,t)}}class B{#w=!0;#b;#v;#_=new Set;#x=new Set;constructor({all_signals:t,waiters:e}){this.#b=t,this.#v=e}#o=h(0,(t=>{if(this.#w)if("lean"in t)t.actor();else{const{payload:e,recording:s}=this.observe(t.collector);this.add_listeners(t,s),t.responder&&t.responder(e)}}));#$(){for(const t of this.#b)t[S]=!1}get#A(){return[...this.#b].filter((t=>t[S]&&!this.#_.has(t)))}observe(t){this.#$();return{payload:t(),recording:this.#A}}add_listeners(t,e){for(const s of e)this.#_.add(s),this.#x.add(s.on((()=>this.#v.add(this.#o(t)))))}shutdown(){this.#w=!1,this.#x.forEach((t=>t()))}}const j=new class{static readonly=u;static collectivize=p;#k=new r;#S=new o;#E=new t;#C=new i;#O=new d;#B=function(t,e,s,n,r){function i([s,r]){if("lean"in r)r.actor();else{const{payload:i,recording:o}=e.record(r.collector);n.add(s,f(s,o,t,r)),r.responder&&r.responder(i)}}return{get:(t,s)=>(e.record_that_key_was_accessed(t,s),t[s]),set:(e,n,o)=>{if(s.locked)throw new c(n);e[n]=o;const a=[...t.grab_keymap(e).grab_symbolmap(n)];for(const t of a){const[e]=t;r.add(e,(()=>s.lock((()=>i(t)))))}return!0}}}(this.#k,this.#S,this.#E,this.#C,this.#O);get wait(){return this.#O.wait}state(t){return new Proxy(t,this.#B)}reaction(t,e){const s=Symbol(),{recording:n}=this.#S.record((()=>this.#E.lock(t)));return this.#C.add(s,f(s,n,this.#k,{collector:t,responder:e})),()=>this.#C.stop(s)}lean(t){const e=Symbol();return{stop:()=>this.#C.stop(e),collect:s=>{const{payload:n,recording:r}=this.#S.record((()=>this.#E.lock(s)));return this.#C.add(e,f(e,r,this.#k,{lean:!0,actor:t})),n}}}clear(){this.#k.clear()}},M=new class{#j=new Set;#v=new Set;signal(t){const e=new C(t);return this.#j.add(e),e}computed(t){const e=this.signal(t());return this.reaction((()=>{e.value=t()})),e}async computedAsync(t,e){const s=await e(t()),n=this.signal(s);return this.reaction(t,(async t=>{n.value=await e(t)})),n}op(t=x.loading()){const e=new O(t);return this.#j.add(e),e}load(t){const e=this.op(x.loading());return e.load(t),e}many(t){return $(t).map((t=>this.signal(t)))}reaction(t,e){const s=new B({waiters:this.#v,all_signals:this.#j}),n={collector:t,responder:e},{recording:r}=s.observe(n.collector);return s.add_listeners(n,r),()=>s.shutdown()}lean(t){const e=new B({waiters:this.#v,all_signals:this.#j}),s={lean:!0,actor:t};return{stop:()=>e.shutdown(),collect:t=>{const{payload:n,recording:r}=e.observe(t);return e.add_listeners(s,r),n}}}async#M(){return await Promise.all([...this.#j].map((t=>t.wait))).then((()=>Promise.all([...this.#v]))).then((()=>{this.#v.clear()}))}get wait(){return Promise.resolve().then((()=>this.#M())).then((()=>this.#M()))}},P=new class{#j;#P=new Set;#m=new Set;#T=new Map;#z=Promise.resolve();constructor(t){this.#j=t}get wait(){return this.#z}#R=h(0,(()=>{for(const t of this.#P)t();for(const t of this.#m)t()}));dispatch(){this.#z=this.#R()}computed(t){const e=this.#j.signal(t());return this.#P.add((()=>{e.value=t()})),e}track(t,e){let s=!0;const n=()=>{const n=t(),r=this.#T.get(t);!s&&b.equal(n,r)||(s=!1,this.#T.set(t,n),e(n))};n(),this.#m.add(n);return()=>this.#m.delete(n)}stateTree(t){return new v(t,(()=>this.dispatch()))}}(M);j.state.bind(j);const T=M.signal.bind(M);M.computed.bind(M),M.op.bind(M);const z=new class{flat;signals;#i=Promise.resolve();constructor(t,e){this.flat=t,this.signals=e}get wait(){return Promise.all([this.flat.wait,this.signals.wait]).then((()=>this.#i))}reaction(t,e){const s=e?()=>e(r()):()=>r(),n=this.lean(s),r=()=>n.collect(t);return r(),n.stop}lean(t){const e=this.flat.lean(t),s=this.signals.lean(t);return{stop(){e.stop(),s.stop()},collect:t=>e.collect((()=>s.collect(t)))}}}(j,M);let R=class t{static with(t){return new this(t)}#U;constructor(t){this.#U=t}to(e){return new t(e(this.#U))}done(){return this.#U}};var U;function q(t){return[t].flat().filter((t=>!!t))}!function(t){function e(...t){return function(e){return class extends e{static get styles(){return H(e.styles,t)}}}}function s(t=z){return function(e){return class extends e{#q=null;render(){return this.#q?.collect((()=>super.render()))}connectedCallback(){super.connectedCallback(),this.#q=t.lean((()=>this.requestUpdate()))}disconnectedCallback(){super.disconnectedCallback(),this.#q&&(this.#q.stop(),this.#q=null)}}}}t.css=e,t.css_deferred=function(t){return function(e){return class extends e{static get styles(){return H(e.styles,t())}}}},t.signals=function(t){return function(e){return class extends e{#q=null;render(){return this.#q?.collect((()=>super.render()))}connectedCallback(){super.connectedCallback(),this.#q=t.lean((()=>this.requestUpdate()))}disconnectedCallback(){super.disconnectedCallback(),this.#q&&(this.#q.stop(),this.#q=null)}}}},t.flat=function(t){return function(e){return class extends e{#q=null;render(){return this.#q?.collect((()=>super.render()))}connectedCallback(){super.connectedCallback(),this.#q=t.lean((()=>this.requestUpdate()))}disconnectedCallback(){super.disconnectedCallback(),this.#q&&(this.#q.stop(),this.#q=null)}}}},t.reactive=s,t.reactor=s,t.setup=function(...t){return function(n){return R.with(n).to(e(...t)).to(s()).done()}}}(U||(U={}));const N=t=>void 0!==t;function H(t,e){return[...q(t)??[],...q(e)].flat().filter(N)}var L;function D(t,e={}){const{soft:s=!1,upgrade:n=!0}=e;for(const[e,r]of Object.entries(t)){const t=e.replace(/([a-zA-Z])(?=[A-Z])/g,"$1-").toLowerCase(),i=customElements.get(t);s&&i||(customElements.define(t,r),n&&document.querySelectorAll(t).forEach((t=>{t.constructor===HTMLElement&&customElements.upgrade(t)})))}}!function(t){t.css=t=>e=>$(e).map((e=>U.css(t)(e))),t.flat=t=>e=>$(e).map((e=>U.flat(t)(e))),t.signals=t=>e=>$(e).map((e=>U.signals(t)(e))),t.reactive=(t=z)=>e=>$(e).map((e=>U.reactive(t)(e))),t.reactor=t.reactive,t.context=e=>s=>R.with(s).to(t.css(e.theme)).to(t.reactive()).done(),t.setup=(...t)=>e=>$(e).map((e=>U.setup(...t)(e)))}(L||(L={}));const I=D,V=globalThis,W=V.ShadowRoot&&(void 0===V.ShadyCSS||V.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,J=Symbol(),F=new WeakMap;
/**
* @license
* Copyright 2019 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/let G=class{constructor(t,e,s){if(this._$cssResult$=!0,s!==J)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(W&&void 0===t){const s=void 0!==e&&1===e.length;s&&(t=F.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&F.set(e,t))}return t}toString(){return this.cssText}};const K=(t,...e)=>{const s=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 G(s,t,J)},Z=(t,e)=>{if(W)t.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const s of e){const e=document.createElement("style"),n=V.litNonce;void 0!==n&&e.setAttribute("nonce",n),e.textContent=s.cssText,t.appendChild(e)}},Y=W?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return(t=>new G("string"==typeof t?t:t+"",void 0,J))(e)})(t):t,{is:Q,defineProperty:X,getOwnPropertyDescriptor:tt,getOwnPropertyNames:et,getOwnPropertySymbols:st,getPrototypeOf:nt}=Object,rt=globalThis,it=rt.trustedTypes,ot=it?it.emptyScript:"",at=rt.reactiveElementPolyfillSupport,ct=(t,e)=>t,lt={toAttribute(t,e){switch(e){case Boolean:t=t?ot: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}},ut=(t,e)=>!Q(t,e),ht={attribute:!0,type:String,converter:lt,reflect:!1,useDefault:!1,hasChanged:ut};
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/Symbol.metadata??=Symbol("metadata"),rt.litPropertyMetadata??=new WeakMap;let dt=class 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=ht){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){const s=Symbol(),n=this.getPropertyDescriptor(t,s,e);void 0!==n&&X(this.prototype,t,n)}}static getPropertyDescriptor(t,e,s){const{get:n,set:r}=tt(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get:n,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)??ht}static _$Ei(){if(this.hasOwnProperty(ct("elementProperties")))return;const t=nt(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(ct("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(ct("properties"))){const t=this.properties,e=[...et(t),...st(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(Y(t))}else void 0!==t&&e.push(Y(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._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)))}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$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 Z(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach((t=>t.hostConnected?.()))}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach((t=>t.hostDisconnected?.()))}attributeChangedCallback(t,e,s){this._$AK(t,s)}_$ET(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:lt).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:lt;this._$Em=n,this[n]=r.fromAttribute(e,t.type)??this._$Ej?.get(n)??null,this._$Em=null}}requestUpdate(t,e,s){if(void 0!==t){const n=this.constructor,r=this[t];if(s??=n.getPropertyOptions(t),!((s.hasChanged??ut)(r,e)||s.useDefault&&s.reflect&&r===this._$Ej?.get(t)&&!this.hasAttribute(n._$Eu(t,s))))return;this.C(t,e,s)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(t,e,{useDefault:s,reflect:n,wrapped:r},i){s&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,i??e??this[t]),!0!==r||void 0!==i)||(this._$AL.has(t)||(this.hasUpdated||s||(e=void 0),this._$AL.set(t,e)),!0===n&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}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.renderRoot??=this.createRenderRoot(),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){const{wrapped:t}=s,n=this[e];!0!==t||this._$AL.has(e)||void 0===n||this.C(e,void 0,s,n)}}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach((t=>t.hostUpdate?.())),this.update(e)):this._$EM()}catch(e){throw t=!1,this._$EM(),e}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach((t=>this._$ET(t,this[t]))),this._$EM()}updated(t){}firstUpdated(t){}};dt.elementStyles=[],dt.shadowRootOptions={mode:"open"},dt[ct("elementProperties")]=new Map,dt[ct("finalized")]=new Map,at?.({ReactiveElement:dt}),(rt.reactiveElementVersions??=[]).push("2.1.0");
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const pt=globalThis,ft=pt.trustedTypes,mt=ft?ft.createPolicy("lit-html",{createHTML:t=>t}):void 0,gt="$lit$",yt=`lit$${Math.random().toFixed(9).slice(2)}$`,wt="?"+yt,bt=`<${wt}>`,vt=document,_t=()=>vt.createComment(""),xt=t=>null===t||"object"!=typeof t&&"function"!=typeof t,$t=Array.isArray,At="[ \t\n\f\r]",kt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,St=/-->/g,Et=/>/g,Ct=RegExp(`>|${At}(?:([^\\s"'>=/]+)(${At}*=${At}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),Ot=/'/g,Bt=/"/g,jt=/^(?:script|style|textarea|title)$/i,Mt=t=>(e,...s)=>({_$litType$:t,strings:e,values:s}),Pt=Mt(1),Tt=Mt(2),zt=Symbol.for("lit-noChange"),Rt=Symbol.for("lit-nothing"),Ut=new WeakMap,qt=vt.createTreeWalker(vt,129);function Nt(t,e){if(!$t(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==mt?mt.createHTML(e):e}const Ht=(t,e)=>{const s=t.length-1,n=[];let r,i=2===e?"<svg>":3===e?"<math>":"",o=kt;for(let e=0;e<s;e++){const s=t[e];let a,c,l=-1,u=0;for(;u<s.length&&(o.lastIndex=u,c=o.exec(s),null!==c);)u=o.lastIndex,o===kt?"!--"===c[1]?o=St:void 0!==c[1]?o=Et:void 0!==c[2]?(jt.test(c[2])&&(r=RegExp("</"+c[2],"g")),o=Ct):void 0!==c[3]&&(o=Ct):o===Ct?">"===c[0]?(o=r??kt,l=-1):void 0===c[1]?l=-2:(l=o.lastIndex-c[2].length,a=c[1],o=void 0===c[3]?Ct:'"'===c[3]?Bt:Ot):o===Bt||o===Ot?o=Ct:o===St||o===Et?o=kt:(o=Ct,r=void 0);const h=o===Ct&&t[e+1].startsWith("/>")?" ":"";i+=o===kt?s+bt:l>=0?(n.push(a),s.slice(0,l)+gt+s.slice(l)+yt+h):s+yt+(-2===l?e:h)}return[Nt(t,i+(t[s]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),n]};let Lt=class t{constructor({strings:e,_$litType$:s},n){let r;this.parts=[];let i=0,o=0;const a=e.length-1,c=this.parts,[l,u]=Ht(e,s);if(this.el=t.createElement(l,n),qt.currentNode=this.el.content,2===s||3===s){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(r=qt.nextNode())&&c.length<a;){if(1===r.nodeType){if(r.hasAttributes())for(const t of r.getAttributeNames())if(t.endsWith(gt)){const e=u[o++],s=r.getAttribute(t).split(yt),n=/([.?@])?(.*)/.exec(e);c.push({type:1,index:i,name:n[2],strings:s,ctor:"."===n[1]?Jt:"?"===n[1]?Ft:"@"===n[1]?Gt:Wt}),r.removeAttribute(t)}else t.startsWith(yt)&&(c.push({type:6,index:i}),r.removeAttribute(t));if(jt.test(r.tagName)){const t=r.textContent.split(yt),e=t.length-1;if(e>0){r.textContent=ft?ft.emptyScript:"";for(let s=0;s<e;s++)r.append(t[s],_t()),qt.nextNode(),c.push({type:2,index:++i});r.append(t[e],_t())}}}else if(8===r.nodeType)if(r.data===wt)c.push({type:2,index:i});else{let t=-1;for(;-1!==(t=r.data.indexOf(yt,t+1));)c.push({type:7,index:i}),t+=yt.length-1}i++}}static createElement(t,e){const s=vt.createElement("template");return s.innerHTML=t,s}};function Dt(t,e,s=t,n){if(e===zt)return e;let r=void 0!==n?s._$Co?.[n]:s._$Cl;const i=xt(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=Dt(t,r._$AS(t,e.values),r,n)),e}let It=class{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??vt).importNode(e,!0);qt.currentNode=n;let r=qt.nextNode(),i=0,o=0,a=s[0];for(;void 0!==a;){if(i===a.index){let e;2===a.type?e=new Vt(r,r.nextSibling,this,t):1===a.type?e=new a.ctor(r,a.name,a.strings,this,t):6===a.type&&(e=new Kt(r,this,t)),this._$AV.push(e),a=s[++o]}i!==a?.index&&(r=qt.nextNode(),i++)}return qt.currentNode=vt,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 Vt{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,s,n){this.type=2,this._$AH=Rt,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=Dt(this,t,e),xt(t)?t===Rt||null==t||""===t?(this._$AH!==Rt&&this._$AR(),this._$AH=Rt):t!==this._$AH&&t!==zt&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>$t(t)||"function"==typeof t?.[Symbol.iterator])(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==Rt&&xt(this._$AH)?this._$AA.nextSibling.data=t:this.T(vt.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:s}=t,n="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=Lt.createElement(Nt(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===n)this._$AH.p(e);else{const t=new It(n,this),s=t.u(this.options);t.p(e),this.T(s),this._$AH=t}}_$AC(t){let e=Ut.get(t.strings);return void 0===e&&Ut.set(t.strings,e=new Lt(t)),e}k(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 Vt(this.O(_t()),this.O(_t()),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 Wt{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,n,r){this.type=1,this._$AH=Rt,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=Rt}_$AI(t,e=this,s,n){const r=this.strings;let i=!1;if(void 0===r)t=Dt(this,t,e,0),i=!xt(t)||t!==this._$AH&&t!==zt,i&&(this._$AH=t);else{const n=t;let o,a;for(t=r[0],o=0;o<r.length-1;o++)a=Dt(this,n[s+o],e,o),a===zt&&(a=this._$AH[o]),i||=!xt(a)||a!==this._$AH[o],a===Rt?t=Rt:t!==Rt&&(t+=(a??"")+r[o+1]),this._$AH[o]=a}i&&!n&&this.j(t)}j(t){t===Rt?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class Jt extends Wt{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===Rt?void 0:t}}let Ft=class extends Wt{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==Rt)}},Gt=class extends Wt{constructor(t,e,s,n,r){super(t,e,s,n,r),this.type=5}_$AI(t,e=this){if((t=Dt(this,t,e,0)??Rt)===zt)return;const s=this._$AH,n=t===Rt&&s!==Rt||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,r=t!==Rt&&(s===Rt||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 Kt{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){Dt(this,t)}}const Zt=pt.litHtmlPolyfillSupport;Zt?.(Lt,Vt),(pt.litHtmlVersions??=[]).push("3.3.0");const Yt=(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 Vt(e.insertBefore(_t(),t),t,void 0,s??{})}return r._$AI(t),r
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/},Qt=globalThis;let Xt=class extends dt{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=Yt(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return zt}};Xt._$litElement$=!0,Xt.finalized=!0,Qt.litElementHydrateSupport?.({LitElement:Xt});const te=Qt.litElementPolyfillSupport;te?.({LitElement:Xt}),(Qt.litElementVersions??=[]).push("4.2.0");class ee extends(function(t){return class extends t{#N=(new Set).add((()=>this.setup()));#H=new Set;register_setup(t){this.#N.add(t)}setup(){return()=>{}}connectedCallback(){for(const t of this.#N)this.#H.add(t())}disconnectedCallback(){for(const t of this.#H)t();this.#H.clear()}}}(HTMLElement)){}function se(){let t,e;const s=new Promise(((s,n)=>{t=s,e=n}));return{promise:s,resolve:t,reject:e,entangle:function(n){return n.then(t).catch(e),s}}}function ne(t,e){Z(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(Y(t))}else void 0!==t&&e.push(Y(t));return e}(e))}class re extends ee{static get styles(){}#L;#D=se();#i=this.#D.promise;init(){}constructor(){super(),this.#L=this.attachShadow({mode:"open"});const t=this.constructor;ne(this.#L,t.styles),this.init()}get root(){return this.#L}get updateComplete(){return this.#i.then((()=>!0))}render(){}#I=h(0,(()=>{const t=this.#L,e=this.render();e&&Yt(e,t,{host:this})}));async requestUpdate(){const t=this.#I();return this.#D&&(t.then(this.#D.resolve),this.#D=void 0),this.#i=t,t}connectedCallback(){super.connectedCallback(),this.requestUpdate()}}class ie extends ee{#D=se();#i=this.#D.promise;init(){}constructor(){super(),this.init()}get updateComplete(){return this.#i.then((()=>!0))}render(){}#I=h(0,(()=>{const t=this.render();Yt(t,this,{host:this})}));async requestUpdate(){const t=this.#I();return this.#D&&(t.then(this.#D.resolve),this.#D=void 0),this.#i=t,t}connectedCallback(){super.connectedCallback(),this.requestUpdate()}}const oe=Symbol();class ae{#p=0;pull(){return this.#p++}reset(){this.#p=0}}class ce{[oe]={wrap:t=>(...e)=>(this.#V.reset(),t(...e)),disconnect:()=>{for(const t of this.#W)t();this.#W.clear();for(const t of this.#J)t();this.#J.clear(),this.#F.clear();for(const{untrack:t}of this.#G.values())t();this.#G.clear()},reconnect:()=>{for(const t of this.#K.values())this.#W.add(t());for(const[t,e]of this.#Z.entries()){const[s,n]=e();this.#F.set(t,s),this.#J.add(n)}},afterRender:()=>{for(const t of this.#Y.values())t()}};#Q;#X;#V=new ae;constructor(t,e){this.#X=t,this.#Q=e}get context(){return this.#Q}rerender(){this.#X()}#K=new Map;#W=new Set;mount(t){const e=this.#V.pull();this.#K.has(e)||(this.#K.set(e,t),this.#W.add(t()))}#Z=new Map;#F=new Map;#J=new Set;init(t){const e=this.#V.pull();if(!this.#Z.has(e)){this.#Z.set(e,t);const[s,n]=t();return this.#F.set(e,s),this.#J.add(n),s}return this.#F.get(e)}#tt=new Map;once(t){const e=this.#V.pull();return n(this.#tt).guarantee(e,t)}#Y=new Map;defer(t){const e=this.signal(void 0),s=this.#V.pull();return this.#Y.has(s)||this.#Y.set(s,(()=>{e.value=t()})),e}#et=new Set;deferOnce(t){this.mount((()=>(this.#et.clear(),()=>{})));const e=this.signal(void 0),s=this.#V.pull();return this.#Y.has(s)||this.#Y.set(s,(()=>{this.#et.has(s)||(this.#et.add(s),e.value=t())})),e}#st=new Map;state(t){const e=this.#V.pull();return[n(this.#st).guarantee(e,(()=>"function"==typeof t?t():t)),t=>{this.#st.set(e,t),this.#X()},()=>this.#st.get(e)]}#nt=new Map;flatstate(t){const e=this.#V.pull();return n(this.#nt).guarantee(e,(()=>j.state("function"==typeof t?t():t)))}#j=new Map;signal(t){const e=this.#V.pull();return n(this.#j).guarantee(e,(()=>M.signal("function"==typeof t?t():t)))}computed(t){const e=this.#V.pull();return n(this.#j).guarantee(e,(()=>M.computed(t)))}op(){const t=this.#V.pull();return n(this.#j).guarantee(t,(()=>M.op()))}load(t){const e=this.op();return this.once((()=>e.load(t))),e}#G=new Map;watch(t){const e=this.#V.pull(),{data:s}=n(this.#G).guarantee(e,(()=>{const e={data:t(),untrack:()=>{}};return e.untrack=P.track(t,(t=>{e.data=t,this.#X()})),e}));return s}#rt=new Map;effect(t,e){e=e.map(C.unwrap);const s=this.#V.pull(),n=this.#rt.get(s);if(n){const[r,i]=n;b.equal(e,i)||(r(),this.#rt.set(s,[t(),e]))}else{this.#K.set(s,t);const n=t();this.#W.add(n),this.#rt.set(s,[n,e])}}}class le extends ce{#it;get element(){return this.#it}#ot;get shadow(){return this.#ot}styles(...t){this.once((()=>ne(this.shadow,[this.context.theme,...t])))}css(...t){return this.styles(...t)}constructor(t,e,s,n){super(s,n),this.#it=t,this.#ot=e}}function ue(t){let e;return function(s){return e||(e=m(t,s)),e}}class he extends le{attrs;constructor(t,e,s,n){super(t,e,s,n),this.attrs=ue(t)}}class de extends ce{#it;get element(){return this.#it}attrs;constructor(t,e,s){super(e,s),this.#it=t,this.attrs=ue(t)}}class pe extends he{}class fe extends de{}class me extends ce{element;name(t){this.once((()=>this.element.setAttribute("view",t)))}constructor(t,e,s){super(e,s),this.element=t}}class ge extends le{name(t){this.once((()=>this.element.setAttribute("view",t)))}}class ye{#Q;constructor(t){this.#Q=t}get context(){if(this.#Q)return this.#Q;throw new Error("nexus.context was not set, but it's necessary")}set context(t){this.#Q=t}}function we(t,e){const s=z.lean(e);return{stop:s.stop,render:(...e)=>s.collect((()=>t(...e)))}}const be=t=>e=>class extends re{#at=new pe(this,this.root,(()=>{this.requestUpdate()}),t.context);#ct=this.#at[oe].wrap((()=>e(this.#at)));#lt;render(){return this.updateComplete.then((()=>this.#at[oe].afterRender())),this.#lt?.render()}connectedCallback(){super.connectedCallback(),this.#at[oe].reconnect(),this.#lt=we(this.#ct,(()=>{this.requestUpdate()}))}disconnectedCallback(){super.disconnectedCallback(),this.#at[oe].disconnect(),this.#lt&&(this.#lt.stop(),this.#lt=void 0)}},ve=2;
/**
* @license
* Copyright 2020 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/class _e{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,s){this._$Ct=t,this._$AM=e,this._$Ci=s}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/const xe=(t,e)=>{const s=t._$AN;if(void 0===s)return!1;for(const t of s)t._$AO?.(e,!1),xe(t,e);return!0},$e=t=>{let e,s;do{if(void 0===(e=t._$AM))break;s=e._$AN,s.delete(t),t=e}while(0===s?.size)},Ae=t=>{for(let e;e=t._$AM;t=e){let s=e._$AN;if(void 0===s)e._$AN=s=new Set;else if(s.has(t))break;s.add(t),Ee(e)}};function ke(t){void 0!==this._$AN?($e(this),this._$AM=t,Ae(this)):this._$AM=t}function Se(t,e=!1,s=0){const n=this._$AH,r=this._$AN;if(void 0!==r&&0!==r.size)if(e)if(Array.isArray(n))for(let t=s;t<n.length;t++)xe(n[t],!1),$e(n[t]);else null!=n&&(xe(n,!1),$e(n));else xe(this,t)}const Ee=t=>{t.type==ve&&(t._$AP??=Se,t._$AQ??=ke)};class Ce extends _e{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,s){super._$AT(t,e,s),Ae(this),this.isConnected=t._$AU}_$AO(t,e=!0){t!==this.isConnected&&(this.isConnected=t,t?this.reconnected?.():this.disconnected?.()),e&&(xe(this,t),$e(this))}setValue(t){if((t=>void 0===t.strings)(this._$Ct))this._$Ct._$AI(t,this);else{const e=[...this._$Ct._$AH];e[this._$Ci]=t,this._$Ct._$AI(e,this,0)}}disconnected(){}reconnected(){}}function Oe(){const t=new Set;function e(e){return t.add(e),()=>{t.delete(e)}}return e.publish=e=>{for(const s of t)s(e)},e.clear=()=>t.clear(),e.once=e=>{const s=n=>{e(n),t.delete(s)};return t.add(s),()=>{t.delete(s)}},e}class Be extends HTMLElement{static tag="slate-view";onConnected=Oe();onDisconnected=Oe();connectedCallback(){this.onConnected.publish()}disconnectedCallback(){this.onDisconnected.publish()}}function je(...t){const e=new Set,s=t.map((t=>t??"")).flatMap(Me);for(const t of s)e.add(t);return e}function Me(t){return t.split(/\s+/).map((t=>t.trim())).filter((t=>!!t))}function Pe(t){return t.split(",").map((t=>t.trim())).filter((t=>!!t)).map((t=>t.includes(":")?t.split(":").map((t=>t.trim()))[1]:t))}function Te(t,e){const s=je(t.getAttribute("part")),n=je(t.getAttribute("data-gpart")),r=function(t,e){return Object.fromEntries(Object.entries(e).map((([e,s])=>[e,Array.from(t.querySelectorAll(`[${s}]`)).map((t=>t.getAttribute(s)))])))}(e,{part:"part",gpart:"data-gpart",exportparts:"exportparts",gexportparts:"gexportparts"}),i=new Set([...r.part.flatMap(Me),...r.exportparts.flatMap(Pe)]),o=new Set([...r.gpart.flatMap(Me),...r.gexportparts.flatMap(Me)]);i.size&&t.setAttribute("exportparts",[...s].flatMap(function(t,e){return s=>[...t].flatMap((t=>[`${t}:${s}-${t}`,...e.has(t)?[t]:[]]))}(i,o)).join(", ")),(o.size||t.hasAttribute("data-gpart"))&&t.setAttribute("gexportparts",[...o,...[...n].flatMap((t=>[...i].map((e=>`${t}-${e}`))))].join(" "))}function ze(t,e={},s={}){const{content:n,attrs:r={}}=e,{attrs:i={}}=s;function o(e,s,n,r){e!==s&&(void 0===e?t.removeAttribute(n):t.setAttribute(n,r()))}r&&function(t,e){for(const[s,n]of Object.entries(e))"string"==typeof n?t.setAttribute(s,n):"number"==typeof n?t.setAttribute(s,n.toString()):"boolean"==typeof n?!0===n?t.setAttribute(s,""):t.removeAttribute(s):void 0===n?t.removeAttribute(s):console.warn(`invalid attribute type ${s} is ${typeof n}`)}(t,r),o(r.class,i?.class,"class",(()=>r.class)),o(r.part,i?.part,"part",(()=>r.part)),o(r.gpart,i?.gpart,"data-gpart",(()=>r.gpart)),n&&Yt(n,t,{host:t})}const Re=t=>e=>(t=>(e,s={})=>({_$litDirective$:t,values:[{meta:s,props:e}]}))(class extends Ce{#U;#ut=!0;#L=function({afterRender:t,onConnected:e,onDisconnected:s}){const n=document.createElement(Be.tag);n.onConnected(e),n.onDisconnected(s);const r=n.attachShadow({mode:"open"});let i=!1;return{container:n,shadow:r,set auto_exportparts(t){i=t},render_into_shadow:e=>(Yt(e,r),i&&Te(n,r),t(),n)}}({afterRender:()=>this.#at[oe].afterRender(),onDisconnected:()=>this.disconnected(),onConnected:()=>{this.#ut||this.reconnected(),this.#ut=!1}});#X=h(0,(()=>{this.#U&&this.isConnected&&this.setValue(this.#L.render_into_shadow(this.render(this.#U)))}));#at=new ge(this.#L.container,this.#L.shadow,this.#X,t.context);#ct=this.#at[oe].wrap(e(this.#at));#lt=we(this.#ct,this.#X);update(t,e){return this.#L.render_into_shadow(this.render(...e))}render(t){return ze(this.#L.container,t.meta,this.#U?.meta),this.#U=t,this.#L.auto_exportparts=t.meta.auto_exportparts??!0,this.#lt?.render(...t.props)}reconnected(){this.#at[oe].reconnect(),this.#lt=we(this.#ct,this.#X)}disconnected(){this.#at[oe].disconnect(),this.#lt&&(this.#lt.stop(),this.#lt=void 0)}}),Ue=t=>e=>class extends ie{#at=new fe(this,(()=>{this.requestUpdate()}),t.context);#ct=this.#at[oe].wrap((()=>e(this.#at)));#lt;render(){return this.updateComplete.then((()=>this.#at[oe].afterRender())),this.#lt?.render()}connectedCallback(){super.connectedCallback(),this.#lt=we(this.#ct,(()=>{this.requestUpdate()})),this.#at[oe].reconnect()}disconnectedCallback(){super.disconnectedCallback(),this.#lt&&(this.#lt.stop(),this.#lt=void 0),this.#at[oe].disconnect()}},qe=t=>e=>(t=>(...e)=>({_$litDirective$:t,values:e}))(class extends Ce{#ht;#it=document.createElement(Be.tag);#dt(t){return Yt(t,this.#it),this.#at[oe].afterRender(),this.#it}#X=h(0,(()=>{this.#ht&&this.isConnected&&this.setValue(this.#dt(this.render(...this.#ht)))}));#at=new me(this.#it,this.#X,t.context);#ct=this.#at[oe].wrap(e(this.#at));#lt=we(this.#ct,this.#X);update(t,e){return this.#dt(this.render(...e))}render(...t){return this.#ht=t,this.#lt?.render(...t)}reconnected(){this.#at[oe].reconnect(),this.#lt=we(this.#ct,this.#X)}disconnected(){this.#at[oe].disconnect(),this.#lt&&(this.#lt.stop(),this.#lt=void 0)}});K`
@layer reset {
* {
margin: 0;
padding: 0;
box-sizing: border-box;
scrollbar-width: thin;
scrollbar-color: #888 transparent;
}
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 1em; }
::-webkit-scrollbar-thumb:hover { background: #444; }
}
`;const Ne=(t,...e)=>Pt(t,...e.map(C.unwrap));const He=K`
:host {
display: contents;
}
`;"undefined"!=typeof process&&process.versions&&process.versions.node||"undefined"!=typeof Deno&&void 0!==Deno.version||I({SlateView:Be},{soft:!0});const Le=new class extends ye{lightComponent;shadowComponent;lightView;shadowView;shadowComponentify;constructor(t){super(t),this.lightComponent=Ue(this),this.shadowComponent=be(this),this.lightView=qe(this),this.shadowView=Re(this),this.shadowComponentify=(t=>e=>t.shadowComponent((t=>(t.styles(He),e([])))))(this)}component=t=>U.setup(this.context.theme)(t);components=t=>L.setup(this.context.theme)(t)}(new class{theme=[]}),De=Le;Le.lightView,Le.lightComponent;const Ie=Le.shadowView;function Ve(t,e){const s=setInterval(e,t);return()=>clearInterval(s)}Le.shadowComponent,Le.component,Le.components,Le.shadowComponentify,Ve.hz=(t,e)=>Ve(1e3/t,e);const We=K`
:host {
color: red;
font-family: monospace;
}
`;De.shadowView((t=>e=>(t.name("error-indicator"),t.styles(We),Ne`${e||"unknown error"}`)));const Je=K`
:host {
font-family: monospace;
}
`;De.shadowView((t=>(e,s)=>{t.name("loading-indicator"),t.styles(Je);const n=t.signal(0);return t.mount((()=>Ve.hz(e,(()=>{const t=n.value+1;n.value=t<s.length?t:0})))),Ne`${s[n.value]}`}));const Fe=[..."aeiou"],Ge=[..."bcdfghjklmnprstvwxyz"],Ke=new Set(["fuc","sex","cum","dic","coc","pen","vag","pus","gay","fap","jiz","fag","cun","nig","jew","goy","sem","bal","fat","god","big","dog","cow","pet","vax","sis","rot","zog","ana","uti","cat","bag","cuc","fuk","fak","wet","cux","bug","gey","pig","rat","bat","dik","bed","boy","man","fem","men","nob","rub","fut","jap","tit","gun","job","nip","but","rim","guy","suc","dad","mom","buk","jis","peg","kox","ded","mum","son","nog","hun","wop","cuk"]);function Ze(t,e){const s=e.length-t;if(s<=0)return e;const n=e.length/s,r=[];let i=n;for(let t=0;t<e.length;t++)t>=Math.round(i)?i+=n:r.push(e[t]);return r.slice(0,t)}function Ye(t){return[...new Set(t)]}const Qe=Ye(Ze(256,Ge.map((t=>Fe.map((e=>Ge.map((s=>t+e+s)))))).flat(2).filter((t=>!Ke.has(t))))),Xe=Ye(Ze(256,Fe.map((t=>Ge.map((e=>Fe.map((s=>t+e+s)))))).flat(2).filter((t=>!Ke.has(t))))),ts=Ye([...Ze(192,Qe),...Ze(64,Xe)]);if(256!==Qe.length)throw new Error("xox not 256");if(256!==Xe.length)throw new Error("oxo not 256");if(256!==ts.length)throw new Error("syllables not 256");new Set([..."अआइईउऊऋएऐओऔकखगघङचछजझञटठडढणतथदधनपफबभमयरलवशषसह",..."அஆஇஈஉஊஎஏஐஒஓகஙசஜஞடணதநபமயரலவழளறன",..."অআইঈউঊএঐওকখগঘঙচছজঝঞটঠডঢণতথদধনপফবভমযরলশষসহ",..."ਅਆਇਈਉਊਏਐਓਕਖਗਘਙਚਛਜਝਞਟਠਡਢਣਤਥਦਧਨਪਫਬਭਮਯਰਲਵਸਹ",..."അആഇഈഉഊഎഏഐഒഓകഖഗഘങചഛജഝഞടഠഡഢണതഥദധനപഫബഭമയരലവശസഹളഴറ",..."અઆઇઈઉઊએઐઓકખગઘઙચછજઝઞટઠડઢણતથદધનપફબભમયરલવશષસહ",..."ଅଆଇଈଉଊଏଐଓଔକଖଗଘଙଚଛଜଝଞଟଠଡଢଣତଥଦଧନପଫବଭମଯରଲଶଷସହ"]);var es;!function(t){t.actualize=function t(e,s){return $(s).map((s=>"function"==typeof s?(...t)=>{e.transmute((e=>(s(e,(t=>{e=t}))(...t),e)))}:t(e,s)))},t.fn=function(){return t=>t},t.blueprint=function(){return t=>t},t.prepFn=t=>e=>(s,n)=>(...r)=>(e(t(s,n))(...r),s),t.prepBlueprint=e=>s=>s(t.prepFn(e)),t.prep=function(e){return{action:t.prepFn(e),blueprint:t.prepBlueprint(e)}}}(es||(es={}));
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
class ss extends _e{constructor(t){if(super(t),this.it=Rt,t.type!==ve)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===Rt||null==t)return this._t=void 0,this.it=t;if(t===zt)return t;if("string"!=typeof t)throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;const e=[t];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}}ss.directiveName="unsafeHTML",ss.resultType=1;const ns=Object.freeze({eq(t,e){if(t.length!==e.length)return!1;for(let s=0;s<=t.length;s++)if(t.at(s)!==e.at(s))return!1;return!0},random:t=>crypto.getRandomValues(new Uint8Array(t))}),rs=Object.freeze({fromBytes:t=>[...t].map((t=>t.toString(16).padStart(2,"0"))).join(""),toBytes(t){if(t.length%2!=0)throw new Error("must have even number of hex characters");const e=new Uint8Array(t.length/2);for(let s=0;s<t.length;s+=2)e[s/2]=parseInt(t.slice(s,s+2),16);return e},random(t=32){return this.fromBytes(ns.random(t))},string:t=>rs.fromBytes(t),bytes:t=>rs.toBytes(t)}),is=["doz","mar","bin","wan","sam","lit","sig","hid","fid","lis","sog","dir","wac","sab","wis","sib","rig","sol","dop","mod","fog","lid","hop","dar","dor","lor","hod","fol","rin","tog","sil","mir","hol","pas","lac","rov","liv","dal","sat","lib","tab","han","tic","pid","tor","bol","fos","dot","los","dil","for","pil","ram","tir","win","tad","bic","dif","roc","wid","bis","das","mid","lop","ril","nar","dap","mol","san","loc","nov","sit","nid","tip","sic","rop","wit","nat","pan","min","rit","pod","mot","tam","tol","sav","pos","nap","nop","som","fin","fon","ban","mor","wor","sip","ron","nor","bot","wic","soc","wat","dol","mag","pic","dav","bid","bal","tim","tas","mal","lig","siv","tag","pad","sal","div","dac","tan","sid","fab","tar","mon","ran","nis","wol","mis","pal","las","dis","map","rab","tob","rol","lat","lon","nod","nav","fig","nom","nib","pag","sop","ral","bil","had","doc","rid","moc","pac","rav","rip","fal","tod","til","tin","hap","mic","fan","pat","tac","lab","mog","sim","son","pin","lom","ric","tap","fir","has","bos","bat","poc","hac","tid","hav","sap","lin","dib","hos","dab","bit","bar","rac","par","lod","dos","bor","toc","hil","mac","tom","dig","fil","fas","mit","hob","har","mig","hin","rad","mas","hal","rag","lag","fad","top","mop","hab","nil","nos","mil","fop","fam","dat","nol","din","hat","nac","ris","fot","rib","hoc","nim","lar","fit","wal","rap","sar","nal","mos","lan","don","dan","lad","dov","riv","bac","pol","lap","tal","pit","nam","bon","ros","ton","fod","pon","sov","noc","sor","lav","mat","mip","fip"],os=["zod","nec","bud","wes","sev","per","sut","let","ful","pen","syt","dur","wep","ser","wyl","sun","ryp","syx","dyr","nup","heb","peg","lup","dep","dys","put","lug","hec","ryt","tyv","syd","nex","lun","mep","lut","sep","pes","del","sul","ped","tem","led","tul","met","wen","byn","hex","feb","pyl","dul","het","mev","rut","tyl","wyd","tep","bes","dex","sef","wyc","bur","der","nep","pur","rys","reb","den","nut","sub","pet","rul","syn","reg","tyd","sup","sem","wyn","rec","meg","net","sec","mul","nym","tev","web","sum","mut","nyx","rex","teb","fus","hep","ben","mus","wyx","sym","sel","ruc","dec","wex","syr","wet","dyl","myn","mes","det","bet","bel","tux","tug","myr","pel","syp","ter","meb","set","dut","deg","tex","sur","fel","tud","nux","rux","ren","wyt","nub","med","lyt","dus","neb","rum","tyn","seg","lyx","pun","res","red","fun","rev","ref","mec","ted","rus","bex","leb","dux","ryn","num","pyx","ryg","ryx","fep","tyr","tus","tyc","leg","nem","fer","mer","ten","lus","nus","syl","tec","mex","pub","rym","tuc","fyl","lep","deb","ber","mug","hut","tun","byl","sud","pem","dev","lur","def","bus","bep","run","mel","pex","dyt","byt","typ","lev","myl","wed","duc","fur","fex","nul","luc","len","ner","lex","rup","ned","lec","ryd","lyd","fen","wel","nyd","hus","rel","rud","nes","hes","fet","des","ret","dun","ler","nyr","seb","hul","ryl","lud","rem","lys","fyn","wer","ryc","sug","nys","nyl","lyn","dyn","dem","lux","fed","sed","bec","mun","lyr","tes","mud","nyt","byr","sen","weg","fyr","mur","tel","rep","teg","pec","nel","nev","fes"],as={defaults:{groupSize:4,wordSeparator:".",groupSeparator:" "},random(t,e){const s=ns.random(t);return this.fromBytes(s,e)},fromBytes(t,e={}){const{groupSize:s=as.defaults.groupSize,wordSeparator:n=as.defaults.wordSeparator,groupSeparator:r=as.defaults.groupSeparator}=e,i=[];let o=[];t.forEach(((t,e)=>{const s=e%2==0?is:os;o.push(s[t]),2===o.length&&(i.push(o.join("")),o=[])})),o.length&&i.push(o.join(""));const a=[];for(let t=0;t<i.length;t+=s)a.push(i.slice(t,t+s).join(n));return a.join(r)},toBytes(t){const e=t.toLowerCase().replace(/[^a-z]/g,"");if(e.length/3%1!=0)throw new Error(`invalid triplet count, ${e.length} does not divide into triplets`);const s=[];for(let t=0;t<e.length;t+=3)s.push(e.slice(t,t+3));return new Uint8Array(s.map(((t,e)=>{const s=(e%2==0?is:os).findIndex((e=>e===t));if(-1===s)throw new Error(`unknown triplet ${t}`);return s})))},toHex:t=>rs.fromBytes(as.toBytes(t)),fromHex:(t,e)=>as.fromBytes(rs.toBytes(t),e)},cs="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",ls=Object.freeze({fromBytes(t){let e=BigInt("0x"+rs.fromBytes(t)),s="";for(;e>0;){const t=e%BigInt(58);e/=BigInt(58),s=cs[Number(t)]+s}for(const e of t){if(0!==e)break;s=cs[0]+s}return s},toBytes(t){let e=BigInt(0);for(const s of t){const t=cs.indexOf(s);if(-1===t)throw new Error(`Invalid character '${s}' in base58 string`);e=e*BigInt(58)+BigInt(t)}let s=e.toString(16);s.length%2!=0&&(s="0"+s);const n=rs.toBytes(s);let r=0;for(const e of t){if(e!==cs[0])break;r++}const i=new Uint8Array(r+n.length);return i.set(n,r),i},random(t=32){return this.fromBytes(ns.random(t))},string:t=>ls.fromBytes(t),bytes:t=>ls.toBytes(t)}),us={defaults:{delimiter:".",sigilBytes:4,previewBytes:8},build:{fromBytes(t,e={}){const{delimiter:s,previewBytes:n,sigilBytes:r}={...us.defaults,...e},i=e=>t.length>0?as.fromBytes(t.slice(0,e),{wordSeparator:s,groupSeparator:s}):"",o=i(r),a=i(n),c=t.length>n?l