@authduo/authduo
Version:
Free User-sovereign Authentication for the World
66 lines (64 loc) • 64.7 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 r(t){return{guarantee:(e,s)=>function(t,e,s){if(t.has(e))return t.get(e);{const r=s();return t.set(e,r),r}}(t,e,s)}}class n{#e=new WeakMap;grab_keymap(t){const s=r(this.#e).guarantee(t,e);return{keymap:s,grab_symbolmap:t=>r(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{#r=[];record(t){const s=e();this.#r.push(s);const r=t();return this.#r.pop(),{payload:r,recording:s}}record_that_key_was_accessed(t,e){const n=this.#r.at(-1);if(n){r(n).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 h(t){return new Proxy(t,{get:(t,e)=>t[e],set(t,e){throw new l(e)}})}function u(t,e){let s,r,n=[];function i(){s=[],r&&clearTimeout(r),r=void 0,n=[]}return i(),(...o)=>{s=o,r&&clearTimeout(r);const a=new Promise(((t,e)=>{n.push({resolve:t,reject:e})}));return r=setTimeout((()=>{Promise.resolve().then((()=>e(...s))).then((t=>{for(const{resolve:e}of n)e(t);i()})).catch((t=>{for(const{reject:e}of n)e(t);i()}))}),t),a}}class d{#n=new Map;#i=Promise.resolve();#o=u(0,(()=>{const t=[...this.#n.values()];this.#n.clear();for(const e of t)e()}));get wait(){return this.#i}add(t,e){this.#n.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,r){const n=[];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,r),n.push((()=>i.delete(t)))}}return()=>n.forEach((t=>t()))}function g(t,e){return m.on_change(t,(()=>t.requestUpdate())),m.proxy(t,e)}var m;!function(t){t.proxy=(t,e)=>new Proxy(e,{get:(s,r)=>{const n=e[r],i=t.getAttribute(r);switch(n){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 "${r}"`)}},set:(s,r,n)=>{switch(e[r]){case String:return t.setAttribute(r,n),!0;case Number:return t.setAttribute(r,n.toString()),!0;case Boolean:return n?t.setAttribute(r,""):t.removeAttribute(r),!0;default:throw new Error(`invalid attribute type for "${r}"`)}}}),t.on_change=function(t,e){const s=new MutationObserver(e);return s.observe(t,{attributes:!0}),()=>s.disconnect()}}(m||(m={}));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),r=t(s);return this.#a.setter(e,r)}))}slice({getter:t,setter:e}){return new y({parent:this,getter:t,setter:e})}}const b=t=>"object"==typeof t&&null!==t;const w={clone:function t(e,s=new Set){if(s.has(e))throw new Error("cannot clone circular reference");let r;return"function"==typeof e||null!==e&&"object"==typeof e?(s.add(e),r=Array.isArray(e)?e.map((e=>t(e,new Set(s)))):e.constructor===Object?Object.fromEntries(Object.entries(e).map((([e,r])=>[e,t(r,new Set(s))]))):e instanceof Map?new Map(Array.from(e,(([e,r])=>[e,t(r,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)):r=e,r},equal:(t,e)=>function t(e,s,r){if(!b(e)||!b(s))return e===s;if(r.includes(e))throw new Error("forbidden circularity detected in deep equal comparison");const n=[...r,e];if(e instanceof Map&&s instanceof Map){if(e.size!==s.size)return!1;for(const[r,i]of e)if(!s.has(r)||!t(i,s.get(r),n))return!1}else if(e instanceof Set&&s instanceof Set){if(e.size!==s.size)return!1;for(const r of e)if(!Array.from(s).some((e=>t(r,e,n))))return!1}else{const r=Object.keys(e),i=Object.keys(s);if(r.length!==i.length)return!1;for(const o of r){if(!i.includes(o))return!1;if(!t(e[o],s[o],n))return!1}}return!0}(t,e,[]),freeze:function(t){return function t(e,s){if(!b(e)||s.includes(e))return e;const r=[...s,e];if(e instanceof Map)for(const s of e.entries())for(const e of s)t(e,r);else if(e instanceof Set)for(const s of e)t(s,r);else if(Array.isArray(e))for(const s of e)t(s,r);else for(const s of Object.values(e))t(s,r);return Object.freeze(e)}(t,[])}};class v{#c;#l;#h;#u=!1;#d(){return w.freeze(structuredClone(this.#c))}constructor(t,e=()=>{}){this.#c=structuredClone(t),this.#l=this.#d(),this.#h=e}get state(){return this.#l}transmute(t){if(this.#u)throw new Error("circular error");this.#u=!0,this.#c=t(structuredClone(this.#c)),this.#l=this.#d(),this.#h(),this.#u=!1}slice({getter:t,setter:e}){return new y({parent:this,getter:t,setter:e})}}const _=Error;var $;function A(t){return{map:e=>x(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 r=await s();return e(t.ready(r)),r}catch(s){const r=s instanceof _?s.message:"string"==typeof s?s:"error";throw e(t.error(r)),s}},t.morph=function(e,r){return s(e,{loading:()=>t.loading(),error:e=>t.error(e),ready:e=>t.ready(r(e))})},t.all=function(...s){const r=s.find(t.is.error);return r||(s.every(t.is.ready)?t.ready(s.map(e)):t.loading())}}($||($={})),A.pipe=Object.freeze({map:t=>e=>x(e,t),filter:t=>e=>k(e,t)});const x=(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)))),C=Symbol();class S extends Error{name=this.constructor.name}class E{static unwrap=t=>t instanceof E?t.value:t;#p;#f=!1;#i;#g=new Set;[C]=!1;constructor(t){this.#p=t,this.#i=Promise.resolve(t)}subscribe(t){return this.on(t)}on(t){return this.#g.add(t),()=>{this.#g.delete(t)}}once(t){const e=s=>{t(s),this.#g.delete(e)};return this.#g.add(e),()=>{this.#g.delete(e)}}clear(){return this.#g.clear()}#m=u(0,(()=>{const t=this.#p;this.#f=!0;for(const e of this.#g)e(t);return this.#f=!1,t}));async publish(){this.#i=this.#m(),await this.#i}get wait(){return this.#i}get value(){return this[C]=!0,this.#p}set value(t){if(this.#f)throw new S("you can't set a signal in a signal's subscription listener (infinite loop forbidden)");this.#p=t,this.publish()}setValueNoPublish(t){this.#p=t}}class O extends E{#y=0;constructor(t){super(t)}async load(t){const e=++this.#y;return $.load((t=>{this.#y===e&&(this.value=t)}),t)}setLoading(){this.value=$.loading()}setError(t){this.value=$.error(t)}setReady(t){this.value=$.ready(t)}isLoading(){return $.is.loading(this.value)}isError(){return $.is.error(this.value)}isReady(){return $.is.ready(this.value)}get payload(){return $.payload(this.value)}select(t){return $.select(this.value,t)}}class P{#b=!0;#w;#v;#_=new Set;#$=new Set;constructor({all_signals:t,waiters:e}){this.#w=t,this.#v=e}#o=u(0,(t=>{if(this.#b)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)}}));#A(){for(const t of this.#w)t[C]=!1}get#x(){return[...this.#w].filter((t=>t[C]&&!this.#_.has(t)))}observe(t){this.#A();return{payload:t(),recording:this.#x}}add_listeners(t,e){for(const s of e)this.#_.add(s),this.#$.add(s.subscribe((()=>this.#v.add(this.#o(t)))))}shutdown(){this.#b=!1,this.#$.forEach((t=>t()))}}const U=new class{static readonly=h;static collectivize=p;#k=new n;#C=new o;#S=new t;#E=new i;#O=new d;#P=function(t,e,s,r,n){function i([s,n]){if("lean"in n)n.actor();else{const{payload:i,recording:o}=e.record(n.collector);r.add(s,f(s,o,t,n)),n.responder&&n.responder(i)}}return{get:(t,s)=>(e.record_that_key_was_accessed(t,s),t[s]),set:(e,r,o)=>{if(s.locked)throw new c(r);e[r]=o;const a=[...t.grab_keymap(e).grab_symbolmap(r)];for(const t of a){const[e]=t;n.add(e,(()=>s.lock((()=>i(t)))))}return!0}}}(this.#k,this.#C,this.#S,this.#E,this.#O);get wait(){return this.#O.wait}state(t){return new Proxy(t,this.#P)}reaction(t,e){const s=Symbol(),{recording:r}=this.#C.record((()=>this.#S.lock(t)));return this.#E.add(s,f(s,r,this.#k,{collector:t,responder:e})),()=>this.#E.stop(s)}lean(t){const e=Symbol();return{stop:()=>this.#E.stop(e),collect:s=>{const{payload:r,recording:n}=this.#C.record((()=>this.#S.lock(s)));return this.#E.add(e,f(e,n,this.#k,{lean:!0,actor:t})),r}}}clear(){this.#k.clear()}},M=new class{#U=new Set;#v=new Set;signal(t){const e=new E(t);return this.#U.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()),r=this.signal(s);return this.reaction(t,(async t=>{r.value=await e(t)})),r}op(t=$.loading()){const e=new O(t);return this.#U.add(e),e}load(t){const e=this.op($.loading());return e.load(t),e}many(t){return A(t).map((t=>this.signal(t)))}reaction(t,e){const s=new P({waiters:this.#v,all_signals:this.#U}),r={collector:t,responder:e},{recording:n}=s.observe(r.collector);return s.add_listeners(r,n),()=>s.shutdown()}lean(t){const e=new P({waiters:this.#v,all_signals:this.#U}),s={lean:!0,actor:t};return{stop:()=>e.shutdown(),collect:t=>{const{payload:r,recording:n}=e.observe(t);return e.add_listeners(s,n),r}}}get wait(){return Promise.all([...this.#U].map((t=>t.wait))).then((()=>Promise.all([...this.#v]))).then((()=>{this.#v.clear()}))}},T=new class{#U;#M=new Set;#g=new Set;#T=new Map;#j=Promise.resolve();constructor(t){this.#U=t}get wait(){return this.#j}#R=u(0,(()=>{for(const t of this.#M)t();for(const t of this.#g)t()}));dispatch(){this.#j=this.#R()}computed(t){const e=this.#U.signal(t());return this.#M.add((()=>{e.value=t()})),e}track(t,e){let s=!0;const r=()=>{const r=t(),n=this.#T.get(t);!s&&w.equal(r,n)||(s=!1,this.#T.set(t,r),e(r))};r(),this.#g.add(r);return()=>this.#g.delete(r)}stateTree(t){return new v(t,(()=>this.dispatch()))}}(M);U.state.bind(U);const j=M.signal.bind(M);M.computed.bind(M),M.op.bind(M);const R=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(n()):()=>n(),r=this.lean(s),n=()=>r.collect(t);return n(),r.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)))}}}(U,M);class D{static with(t){return new this(t)}#D;constructor(t){this.#D=t}to(t){return new D(t(this.#D))}done(){return this.#D}}var z;function N(t){return[t].flat().filter((t=>!!t))}!function(t){function e(...t){return function(e){return class extends e{static get styles(){return q(e.styles,t)}}}}function s(t=R){return function(e){return class extends e{#z=null;render(){return this.#z?.collect((()=>super.render()))}connectedCallback(){super.connectedCallback(),this.#z=t.lean((()=>this.requestUpdate()))}disconnectedCallback(){super.disconnectedCallback(),this.#z&&(this.#z.stop(),this.#z=null)}}}}t.css=e,t.css_deferred=function(t){return function(e){return class extends e{static get styles(){return q(e.styles,t())}}}},t.signals=function(t){return function(e){return class extends e{#z=null;render(){return this.#z?.collect((()=>super.render()))}connectedCallback(){super.connectedCallback(),this.#z=t.lean((()=>this.requestUpdate()))}disconnectedCallback(){super.disconnectedCallback(),this.#z&&(this.#z.stop(),this.#z=null)}}}},t.flat=function(t){return function(e){return class extends e{#z=null;render(){return this.#z?.collect((()=>super.render()))}connectedCallback(){super.connectedCallback(),this.#z=t.lean((()=>this.requestUpdate()))}disconnectedCallback(){super.disconnectedCallback(),this.#z&&(this.#z.stop(),this.#z=null)}}}},t.reactive=s,t.reactor=s,t.setup=function(...t){return function(r){return D.with(r).to(e(...t)).to(s()).done()}}}(z||(z={}));const H=t=>void 0!==t;function q(t,e){return[...N(t),...N(e)].flat().filter(H)}var B;function L(t,e={soft:!1}){for(const[s,r]of Object.entries(t)){const t=s.replace(/([a-zA-Z])(?=[A-Z])/g,"$1-").toLowerCase();e.soft&&void 0!==customElements.get(t)||customElements.define(t,r)}}
/**
* @license
* Copyright 2019 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/!function(t){t.css=t=>e=>A(e).map((e=>z.css(t)(e))),t.flat=t=>e=>A(e).map((e=>z.flat(t)(e))),t.signals=t=>e=>A(e).map((e=>z.signals(t)(e))),t.reactive=(t=R)=>e=>A(e).map((e=>z.reactive(t)(e))),t.reactor=t.reactive,t.context=e=>s=>D.with(s).to(t.css(e.theme)).to(t.reactive()).done(),t.setup=(...t)=>e=>A(e).map((e=>z.setup(...t)(e)))}(B||(B={}));const K=globalThis,I=K.ShadowRoot&&(void 0===K.ShadyCSS||K.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,V=Symbol(),J=new WeakMap;let F=class{constructor(t,e,s){if(this._$cssResult$=!0,s!==V)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(I&&void 0===t){const s=void 0!==e&&1===e.length;s&&(t=J.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&J.set(e,t))}return t}toString(){return this.cssText}};const W=(t,...e)=>{const s=1===t.length?t[0]:e.reduce(((e,s,r)=>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[r+1]),t[0]);return new F(s,t,V)},Y=(t,e)=>{if(I)t.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const s of e){const e=document.createElement("style"),r=K.litNonce;void 0!==r&&e.setAttribute("nonce",r),e.textContent=s.cssText,t.appendChild(e)}},Z=I?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return(t=>new F("string"==typeof t?t:t+"",void 0,V))(e)})(t):t
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/,{is:G,defineProperty:Q,getOwnPropertyDescriptor:X,getOwnPropertyNames:tt,getOwnPropertySymbols:et,getPrototypeOf:st}=Object,rt=globalThis,nt=rt.trustedTypes,it=nt?nt.emptyScript:"",ot=rt.reactiveElementPolyfillSupport,at=(t,e)=>t,ct={toAttribute(t,e){switch(e){case Boolean:t=t?it: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}},lt=(t,e)=>!G(t,e),ht={attribute:!0,type:String,converter:ct,reflect:!1,hasChanged:lt};Symbol.metadata??=Symbol("metadata"),rt.litPropertyMetadata??=new WeakMap;class ut 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.elementProperties.set(t,e),!e.noAccessor){const s=Symbol(),r=this.getPropertyDescriptor(t,s,e);void 0!==r&&Q(this.prototype,t,r)}}static getPropertyDescriptor(t,e,s){const{get:r,set:n}=X(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get(){return r?.call(this)},set(e){const i=r?.call(this);n.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(at("elementProperties")))return;const t=st(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(at("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(at("properties"))){const t=this.properties,e=[...tt(t),...et(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(Z(t))}else void 0!==t&&e.push(Z(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 Y(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)}_$EC(t,e){const s=this.constructor.elementProperties.get(t),r=this.constructor._$Eu(t,s);if(void 0!==r&&!0===s.reflect){const n=(void 0!==s.converter?.toAttribute?s.converter:ct).toAttribute(e,s.type);this._$Em=t,null==n?this.removeAttribute(r):this.setAttribute(r,n),this._$Em=null}}_$AK(t,e){const s=this.constructor,r=s._$Eh.get(t);if(void 0!==r&&this._$Em!==r){const t=s.getPropertyOptions(r),n="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:ct;this._$Em=r,this[r]=n.fromAttribute(e,t.type),this._$Em=null}}requestUpdate(t,e,s){if(void 0!==t){if(s??=this.constructor.getPropertyOptions(t),!(s.hasChanged??lt)(this[t],e))return;this.P(t,e,s)}!1===this.isUpdatePending&&(this._$ES=this._$ET())}P(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 _$ET(){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)!0!==s.wrapped||this._$AL.has(e)||void 0===this[e]||this.P(e,this[e],s)}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._$EU()}catch(e){throw t=!1,this._$EU(),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)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Ej&&=this._$Ej.forEach((t=>this._$EC(t,this[t]))),this._$EU()}updated(t){}firstUpdated(t){}}ut.elementStyles=[],ut.shadowRootOptions={mode:"open"},ut[at("elementProperties")]=new Map,ut[at("finalized")]=new Map,ot?.({ReactiveElement:ut}),(rt.reactiveElementVersions??=[]).push("2.0.4");
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/
const dt=globalThis,pt=dt.trustedTypes,ft=pt?pt.createPolicy("lit-html",{createHTML:t=>t}):void 0,gt="$lit$",mt=`lit$${Math.random().toFixed(9).slice(2)}$`,yt="?"+mt,bt=`<${yt}>`,wt=document,vt=()=>wt.createComment(""),_t=t=>null===t||"object"!=typeof t&&"function"!=typeof t,$t=Array.isArray,At="[ \t\n\f\r]",xt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,kt=/-->/g,Ct=/>/g,St=RegExp(`>|${At}(?:([^\\s"'>=/]+)(${At}*=${At}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),Et=/'/g,Ot=/"/g,Pt=/^(?:script|style|textarea|title)$/i,Ut=(t=>(e,...s)=>({_$litType$:t,strings:e,values:s}))(1),Mt=Symbol.for("lit-noChange"),Tt=Symbol.for("lit-nothing"),jt=new WeakMap,Rt=wt.createTreeWalker(wt,129);function Dt(t,e){if(!$t(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==ft?ft.createHTML(e):e}const zt=(t,e)=>{const s=t.length-1,r=[];let n,i=2===e?"<svg>":3===e?"<math>":"",o=xt;for(let e=0;e<s;e++){const s=t[e];let a,c,l=-1,h=0;for(;h<s.length&&(o.lastIndex=h,c=o.exec(s),null!==c);)h=o.lastIndex,o===xt?"!--"===c[1]?o=kt:void 0!==c[1]?o=Ct:void 0!==c[2]?(Pt.test(c[2])&&(n=RegExp("</"+c[2],"g")),o=St):void 0!==c[3]&&(o=St):o===St?">"===c[0]?(o=n??xt,l=-1):void 0===c[1]?l=-2:(l=o.lastIndex-c[2].length,a=c[1],o=void 0===c[3]?St:'"'===c[3]?Ot:Et):o===Ot||o===Et?o=St:o===kt||o===Ct?o=xt:(o=St,n=void 0);const u=o===St&&t[e+1].startsWith("/>")?" ":"";i+=o===xt?s+bt:l>=0?(r.push(a),s.slice(0,l)+gt+s.slice(l)+mt+u):s+mt+(-2===l?e:u)}return[Dt(t,i+(t[s]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),r]};class Nt{constructor({strings:t,_$litType$:e},s){let r;this.parts=[];let n=0,i=0;const o=t.length-1,a=this.parts,[c,l]=zt(t,e);if(this.el=Nt.createElement(c,s),Rt.currentNode=this.el.content,2===e||3===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(r=Rt.nextNode())&&a.length<o;){if(1===r.nodeType){if(r.hasAttributes())for(const t of r.getAttributeNames())if(t.endsWith(gt)){const e=l[i++],s=r.getAttribute(t).split(mt),o=/([.?@])?(.*)/.exec(e);a.push({type:1,index:n,name:o[2],strings:s,ctor:"."===o[1]?Kt:"?"===o[1]?It:"@"===o[1]?Vt:Lt}),r.removeAttribute(t)}else t.startsWith(mt)&&(a.push({type:6,index:n}),r.removeAttribute(t));if(Pt.test(r.tagName)){const t=r.textContent.split(mt),e=t.length-1;if(e>0){r.textContent=pt?pt.emptyScript:"";for(let s=0;s<e;s++)r.append(t[s],vt()),Rt.nextNode(),a.push({type:2,index:++n});r.append(t[e],vt())}}}else if(8===r.nodeType)if(r.data===yt)a.push({type:2,index:n});else{let t=-1;for(;-1!==(t=r.data.indexOf(mt,t+1));)a.push({type:7,index:n}),t+=mt.length-1}n++}}static createElement(t,e){const s=wt.createElement("template");return s.innerHTML=t,s}}function Ht(t,e,s=t,r){if(e===Mt)return e;let n=void 0!==r?s._$Co?.[r]:s._$Cl;const i=_t(e)?void 0:e._$litDirective$;return n?.constructor!==i&&(n?._$AO?.(!1),void 0===i?n=void 0:(n=new i(t),n._$AT(t,s,r)),void 0!==r?(s._$Co??=[])[r]=n:s._$Cl=n),void 0!==n&&(e=Ht(t,n._$AS(t,e.values),n,r)),e}class qt{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,r=(t?.creationScope??wt).importNode(e,!0);Rt.currentNode=r;let n=Rt.nextNode(),i=0,o=0,a=s[0];for(;void 0!==a;){if(i===a.index){let e;2===a.type?e=new Bt(n,n.nextSibling,this,t):1===a.type?e=new a.ctor(n,a.name,a.strings,this,t):6===a.type&&(e=new Jt(n,this,t)),this._$AV.push(e),a=s[++o]}i!==a?.index&&(n=Rt.nextNode(),i++)}return Rt.currentNode=wt,r}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 Bt{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,s,r){this.type=2,this._$AH=Tt,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=s,this.options=r,this._$Cv=r?.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=Ht(this,t,e),_t(t)?t===Tt||null==t||""===t?(this._$AH!==Tt&&this._$AR(),this._$AH=Tt):t!==this._$AH&&t!==Mt&&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!==Tt&&_t(this._$AH)?this._$AA.nextSibling.data=t:this.T(wt.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:s}=t,r="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=Nt.createElement(Dt(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===r)this._$AH.p(e);else{const t=new qt(r,this),s=t.u(this.options);t.p(e),this.T(s),this._$AH=t}}_$AC(t){let e=jt.get(t.strings);return void 0===e&&jt.set(t.strings,e=new Nt(t)),e}k(t){$t(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let s,r=0;for(const n of t)r===e.length?e.push(s=new Bt(this.O(vt()),this.O(vt()),this,this.options)):s=e[r],s._$AI(n),r++;r<e.length&&(this._$AR(s&&s._$AB.nextSibling,r),e.length=r)}_$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 Lt{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,r,n){this.type=1,this._$AH=Tt,this._$AN=void 0,this.element=t,this.name=e,this._$AM=r,this.options=n,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=Tt}_$AI(t,e=this,s,r){const n=this.strings;let i=!1;if(void 0===n)t=Ht(this,t,e,0),i=!_t(t)||t!==this._$AH&&t!==Mt,i&&(this._$AH=t);else{const r=t;let o,a;for(t=n[0],o=0;o<n.length-1;o++)a=Ht(this,r[s+o],e,o),a===Mt&&(a=this._$AH[o]),i||=!_t(a)||a!==this._$AH[o],a===Tt?t=Tt:t!==Tt&&(t+=(a??"")+n[o+1]),this._$AH[o]=a}i&&!r&&this.j(t)}j(t){t===Tt?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class Kt extends Lt{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===Tt?void 0:t}}class It extends Lt{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==Tt)}}class Vt extends Lt{constructor(t,e,s,r,n){super(t,e,s,r,n),this.type=5}_$AI(t,e=this){if((t=Ht(this,t,e,0)??Tt)===Mt)return;const s=this._$AH,r=t===Tt&&s!==Tt||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,n=t!==Tt&&(s===Tt||r);r&&this.element.removeEventListener(this.name,this,s),n&&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 Jt{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){Ht(this,t)}}const Ft=dt.litHtmlPolyfillSupport;Ft?.(Nt,Bt),(dt.litHtmlVersions??=[]).push("3.2.1");const Wt=(t,e,s)=>{const r=s?.renderBefore??e;let n=r._$litPart$;if(void 0===n){const t=s?.renderBefore??null;r._$litPart$=n=new Bt(e.insertBefore(vt(),t),t,void 0,s??{})}return n._$AI(t),n
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/};let Yt=class extends ut{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=Wt(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Mt}};Yt._$litElement$=!0,Yt.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:Yt});const Zt=globalThis.litElementPolyfillSupport;Zt?.({LitElement:Yt}),(globalThis.litElementVersions??=[]).push("4.1.1");class Gt 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 Qt(){let t,e;const s=new Promise(((s,r)=>{t=s,e=r}));return{promise:s,resolve:t,reject:e,entangle:function(r){return r.then(t).catch(e),s}}}function Xt(t,e){Y(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(Z(t))}else void 0!==t&&e.push(Z(t));return e}(e))}class te extends Gt{static get styles(){}#q;#B=Qt();#i=this.#B.promise;init(){}constructor(){super(),this.#q=this.attachShadow({mode:"open"});const t=this.constructor;Xt(this.#q,t.styles),this.init()}get root(){return this.#q}get updateComplete(){return this.#i.then((()=>!0))}render(){}#L=u(0,(()=>{const t=this.#q,e=this.render();e&&Wt(e,t,{host:this})}));async requestUpdate(){const t=this.#L();return this.#B&&(t.then(this.#B.resolve),this.#B=void 0),this.#i=t,t}connectedCallback(){super.connectedCallback(),this.requestUpdate()}}class ee extends Gt{#B=Qt();#i=this.#B.promise;init(){}constructor(){super(),this.init()}get updateComplete(){return this.#i.then((()=>!0))}render(){}#L=u(0,(()=>{const t=this.render();Wt(t,this,{host:this})}));async requestUpdate(){const t=this.#L();return this.#B&&(t.then(this.#B.resolve),this.#B=void 0),this.#i=t,t}connectedCallback(){super.connectedCallback(),this.requestUpdate()}}const se=Symbol();class re{#p=0;pull(){return this.#p++}reset(){this.#p=0}}class ne{[se]={wrap:t=>(...e)=>(this.#K.reset(),t(...e)),disconnect:()=>{for(const t of this.#I)t();this.#I.clear();for(const t of this.#V)t();this.#V.clear(),this.#J.clear();for(const{untrack:t}of this.#F.values())t();this.#F.clear()},reconnect:()=>{for(const t of this.#W.values())this.#I.add(t());for(const[t,e]of this.#Y.entries()){const[s,r]=e();this.#J.set(t,s),this.#V.add(r)}},afterRender:()=>{for(const t of this.#Z.values())t()}};#G;#Q;#K=new re;constructor(t,e){this.#Q=t,this.#G=e}get context(){return this.#G}rerender(){this.#Q()}#W=new Map;#I=new Set;mount(t){const e=this.#K.pull();this.#W.has(e)||(this.#W.set(e,t),this.#I.add(t()))}#Y=new Map;#J=new Map;#V=new Set;init(t){const e=this.#K.pull();if(!this.#Y.has(e)){this.#Y.set(e,t);const[s,r]=t();return this.#J.set(e,s),this.#V.add(r),s}return this.#J.get(e)}#X=new Map;once(t){const e=this.#K.pull();return r(this.#X).guarantee(e,t)}#Z=new Map;defer(t){const e=this.signal(void 0),s=this.#K.pull();return this.#Z.has(s)||this.#Z.set(s,(()=>{e.value=t()})),e}#tt=new Set;deferOnce(t){this.mount((()=>(this.#tt.clear(),()=>{})));const e=this.signal(void 0),s=this.#K.pull();return this.#Z.has(s)||this.#Z.set(s,(()=>{this.#tt.has(s)||(this.#tt.add(s),e.value=t())})),e}#et=new Map;state(t){const e=this.#K.pull();return[r(this.#et).guarantee(e,(()=>"function"==typeof t?t():t)),t=>{this.#et.set(e,t),this.#Q()},()=>this.#et.get(e)]}#st=new Map;flatstate(t){const e=this.#K.pull();return r(this.#st).guarantee(e,(()=>U.state("function"==typeof t?t():t)))}#U=new Map;signal(t){const e=this.#K.pull();return r(this.#U).guarantee(e,(()=>M.signal("function"==typeof t?t():t)))}computed(t){const e=this.#K.pull();return r(this.#U).guarantee(e,(()=>M.computed(t)))}op(){const t=this.#K.pull();return r(this.#U).guarantee(t,(()=>M.op()))}load(t){const e=this.op();return this.once((()=>e.load(t))),e}#F=new Map;watch(t){const e=this.#K.pull(),{data:s}=r(this.#F).guarantee(e,(()=>{const e={data:t(),untrack:()=>{}};return e.untrack=T.track(t,(t=>{e.data=t,this.#Q()})),e}));return s}#rt=new Map;effect(t,e){e=e.map(E.unwrap);const s=this.#K.pull(),r=this.#rt.get(s);if(r){const[n,i]=r;w.equal(e,i)||(n(),this.#rt.set(s,[t(),e]))}else{this.#W.set(s,t);const r=t();this.#I.add(r),this.#rt.set(s,[r,e])}}}class ie extends ne{#nt;get element(){return this.#nt}#it;get shadow(){return this.#it}styles(...t){this.once((()=>Xt(this.shadow,[this.context.theme,...t])))}css(...t){return this.styles(...t)}constructor(t,e,s,r){super(s,r),this.#nt=t,this.#it=e}}function oe(t){let e;return function(s){return e||(e=g(t,s)),e}}class ae extends ie{attrs;constructor(t,e,s,r){super(t,e,s,r),this.attrs=oe(t)}}class ce extends ne{#nt;get element(){return this.#nt}attrs;constructor(t,e,s){super(e,s),this.#nt=t,this.attrs=oe(t)}}class le extends ae{}class he extends ce{}class ue extends ne{element;name(t){this.once((()=>this.element.setAttribute("view",t)))}constructor(t,e,s){super(e,s),this.element=t}}class de extends ie{name(t){this.once((()=>this.element.setAttribute("view",t)))}}class pe{#G;constructor(t){this.#G=t}get context(){if(this.#G)return this.#G;throw new Error("nexus.context was not set, but it's necessary")}set context(t){this.#G=t}}function fe(t,e){const s=R.lean(e);return{stop:s.stop,render:(...e)=>s.collect((()=>t(...e)))}}const ge=t=>e=>class extends te{#ot=new le(this,this.root,(()=>{this.requestUpdate()}),t.context);#at=this.#ot[se].wrap((()=>e(this.#ot)));#ct;render(){return this.updateComplete.then((()=>this.#ot[se].afterRender())),this.#ct?.render()}connectedCallback(){super.connectedCallback(),this.#ot[se].reconnect(),this.#ct=fe(this.#at,(()=>{this.requestUpdate()}))}disconnectedCallback(){super.disconnectedCallback(),this.#ot[se].disconnect(),this.#ct&&(this.#ct.stop(),this.#ct=void 0)}},me=2;
/**
* @license
* Copyright 2020 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/class ye{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 be=(t,e)=>{const s=t._$AN;if(void 0===s)return!1;for(const t of s)t._$AO?.(e,!1),be(t,e);return!0},we=t=>{let e,s;do{if(void 0===(e=t._$AM))break;s=e._$AN,s.delete(t),t=e}while(0===s?.size)},ve=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),Ae(e)}};function _e(t){void 0!==this._$AN?(we(this),this._$AM=t,ve(this)):this._$AM=t}function $e(t,e=!1,s=0){const r=this._$AH,n=this._$AN;if(void 0!==n&&0!==n.size)if(e)if(Array.isArray(r))for(let t=s;t<r.length;t++)be(r[t],!1),we(r[t]);else null!=r&&(be(r,!1),we(r));else be(this,t)}const Ae=t=>{t.type==me&&(t._$AP??=$e,t._$AQ??=_e)};class xe extends ye{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,s){super._$AT(t,e,s),ve(this),this.isConnected=t._$AU}_$AO(t,e=!0){t!==this.isConnected&&(this.isConnected=t,t?this.reconnected?.():this.disconnected?.()),e&&(be(this,t),we(this))}setValue(t){if((t=>void 0===t.strings)
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/(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 ke(){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=r=>{e(r),t.delete(s)};return t.add(s),()=>{t.delete(s)}},e}class Ce extends HTMLElement{static tag="slate-view";onConnected=ke();onDisconnected=ke();connectedCallback(){this.onConnected.publish()}disconnectedCallback(){this.onDisconnected.publish()}}function Se(...t){const e=new Set,s=t.map((t=>t??"")).flatMap(Ee);for(const t of s)e.add(t);return e}function Ee(t){return t.split(/\s+/).map((t=>t.trim())).filter((t=>!!t))}function Oe(t){return t.split(",").map((t=>t.trim())).filter((t=>!!t)).map((t=>t.includes(":")?t.split(":").map((t=>t.trim()))[1]:t))}function Pe(t,e){const s=Se(t.getAttribute("part")),r=Se(t.getAttribute("data-gpart")),n=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([...n.part.flatMap(Ee),...n.exportparts.flatMap(Oe)]),o=new Set([...n.gpart.flatMap(Ee),...n.gexportparts.flatMap(Ee)]);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,...[...r].flatMap((t=>[...i].map((e=>`${t}-${e}`))))].join(" "))}function Ue(t,e={},s={}){const{content:r,attrs:n={}}=e,{attrs:i={}}=s;function o(e,s,r,n){e!==s&&(void 0===e?t.removeAttribute(r):t.setAttribute(r,n()))}n&&function(t,e){for(const[s,r]of Object.entries(e))"string"==typeof r?t.setAttribute(s,r):"number"==typeof r?t.setAttribute(s,r.toString()):"boolean"==typeof r?!0===r?t.setAttribute(s,""):t.removeAttribute(s):void 0===r?t.removeAttribute(s):console.warn(`invalid attribute type ${s} is ${typeof r}`)}(t,n),o(n.class,i?.class,"class",(()=>n.class)),o(n.part,i?.part,"part",(()=>n.part)),o(n.gpart,i?.gpart,"data-gpart",(()=>n.gpart)),r&&Wt(r,t,{host:t})}L({SlateView:Ce},{soft:!0});const Me=t=>e=>(t=>(e,s={})=>({_$litDirective$:t,values:[{meta:s,props:e}]}))(class extends xe{#D;#lt=!0;#q=function({afterRender:t,onConnected:e,onDisconnected:s}){const r=document.createElement(Ce.tag);r.onConnected(e),r.onDisconnected(s);const n=r.attachShadow({mode:"open"});let i=!1;return{container:r,shadow:n,set auto_exportparts(t){i=t},render_into_shadow:e=>(Wt(e,n),i&&Pe(r,n),t(),r)}}({afterRender:()=>this.#ot[se].afterRender(),onDisconnected:()=>this.disconnected(),onConnected:()=>{this.#lt||this.reconnected(),this.#lt=!1}});#Q=u(0,(()=>{this.#D&&this.isConnected&&this.setValue(this.#q.render_into_shadow(this.render(this.#D)))}));#ot=new de(this.#q.container,this.#q.shadow,this.#Q,t.context);#at=this.#ot[se].wrap(e(this.#ot));#ct=fe(this.#at,this.#Q);update(t,e){return this.#q.render_into_shadow(this.render(...e))}render(t){return Ue(this.#q.container,t.meta,this.#D?.meta),this.#D=t,this.#q.auto_exportparts=t.meta.auto_exportparts??!0,this.#ct?.render(...t.props)}reconnected(){this.#ot[se].reconnect(),this.#ct=fe(this.#at,this.#Q)}disconnected(){this.#ot[se].disconnect(),this.#ct&&(this.#ct.stop(),this.#ct=void 0)}}),Te=t=>e=>class extends ee{#ot=new he(this,(()=>{this.requestUpdate()}),t.context);#at=this.#ot[se].wrap((()=>e(this.#ot)));#ct;render(){return this.updateComplete.then((()=>this.#ot[se].afterRender())),this.#ct?.render()}connectedCallback(){super.connectedCallback(),this.#ct=fe(this.#at,(()=>{this.requestUpdate()})),this.#ot[se].reconnect()}disconnectedCallback(){super.disconnectedCallback(),this.#ct&&(this.#ct.stop(),this.#ct=void 0),this.#ot[se].disconnect()}},je=t=>e=>(t=>(...e)=>({_$litDirective$:t,values:e}))(class extends xe{#ht;#nt=document.createElement(Ce.tag);#ut(t){return Wt(t,this.#nt),this.#ot[se].afterRender(),this.#nt}#Q=u(0,(()=>{this.#ht&&this.isConnected&&this.setValue(this.#ut(this.render(...this.#ht)))}));#ot=new ue(this.#nt,this.#Q,t.context);#at=this.#ot[se].wrap(e(this.#ot));#ct=fe(this.#at,this.#Q);update(t,e){return this.#ut(this.render(...e))}render(...t){return this.#ht=t,this.#ct?.render(...t)}reconnected(){this.#ot[se].reconnect(),this.#ct=fe(this.#at,this.#Q)}disconnected(){this.#ot[se].disconnect(),this.#ct&&(this.#ct.stop(),this.#ct=void 0)}});W`
@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 Re=(t,...e)=>Ut(t,...e.map(E.unwrap)),De=W`
:host {
display: contents;
}
`;const ze=new class extends pe{lightComponent;shadowComponent;lightView;shadowView;shadowComponentify;constructor(t){super(t),this.lightComponent=Te(this),this.shadowComponent=ge(this),this.lightView=je(this),this.shadowView=Me(this),this.shadowComponentify=(t=>e=>t.shadowComponent((t=>(t.styles(De),e([])))))(this)}component=t=>z.setup(this.context.theme)(t);components=t=>B.setup(this.context.theme)(t)}(new class{theme=[]}),Ne=ze;ze.lightView,ze.lightComponent;const He=ze.shadowView;function qe(t,e){const s=setInterval(e,t);return()=>clearInterval(s)}ze.shadowComponent,ze.component,ze.components,ze.shadowComponentify,qe.hz=(t,e)=>qe(1e3/t,e);const Be=W`
:host {
color: red;
font-family: monospace;
}
`;Ne.shadowView((t=>e=>(t.name("error-indicator"),t.styles(Be),Re`${e||"unknown error"}`)));const Le=W`
:host {
font-family: monospace;
}
`;Ne.shadowView((t=>(e,s)=>{t.name("loading-indicator"),t.styles(Le);const r=t.signal(0);return t.mount((()=>qe.hz(e,(()=>{const t=r.value+1;r.value=t<s.length?t:0})))),Re`${s[r.value]}`}));const Ke=[..."aeiou"],Ie=[..."bcdfghjklmnprstvwxyz"],Ve=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 Je(t,e){const s=e.length-t;if(s<=0)return e;const r=e.length/s,n=[];let i=r;for(let t=0;t<e.length;t++)t>=Math.round(i)?i+=r:n.push(e[t]);return n.slice(0,t)}function Fe(t){return[...new Set(t)]}const We=Fe(Je(256,Ie.map((t=>Ke.map((e=>Ie.map((s=>t+e+s)))))).flat(2).filter((t=>!Ve.has(t))))),Ye=Fe(Je(256,Ke.map((t=>Ie.map((e=>Ke.map((s=>t+e+s)))))).flat(2).filter((t=>!Ve.has(t))))),Ze=Fe([...Je(192,We),...Je(64,Ye)]);if(256!==We.length)throw new Error("xox not 256");if(256!==Ye.length)throw new Error("oxo not 256");if(256!==Ze.length)throw new Error("syllables not 256");const Ge={random:t=>crypto.getRandomValues(new Uint8Array(t))};new Set([..."अआइईउऊऋएऐओऔकखगघङचछजझञटठडढणतथदधनपफबभमयरलवशषसह",..."அஆஇஈஉஊஎஏஐஒஓகஙசஜஞடணதநபமயரலவழளறன",..."অআইঈউঊএঐওকখগঘঙচছজঝঞটঠডঢণতথদধনপফবভমযরলশষসহ",..."ਅਆਇਈਉਊਏਐਓਕਖਗਘਙਚਛਜਝਞਟਠਡਢਣਤਥਦਧਨਪਫਬਭਮਯਰਲਵਸਹ",..."അആഇഈഉഊഎഏഐഒഓകഖഗഘങചഛജഝഞടഠഡഢണതഥദധനപഫബഭമയരലവശസഹളഴറ",..."અઆઇઈઉઊએઐઓકખગઘઙચછજઝઞટઠડઢણતથદધનપફબભમયરલવશષસહ",..."ଅଆଇଈଉଊଏଐଓଔକଖଗଘଙଚଛଜଝଞଟଠଡଢଣତଥଦଧନପଫବଭମଯରଲଶଷସହ"]);const Qe={string:t=>[...t].map((t=>t.toString(16).padStart(2,"0"))).join(""),bytes(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.string(Ge.random(t))}},Xe={string:t=>"function"==typeof btoa?btoa(String.fromCharCode(...t)):Buffer.from(t).toString("base64"),bytes:t=>"function"==typeof atob?Uint8Array.from(atob(t),(t=>t.charCodeAt(0))):Uint8Array.from(Buffer.from(t,"base64")),random(t=32){return this.string(Ge.random(t))}},ts={string:t=>Xe.string(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,""),bytes(t){let e=t.replace(/-/g,"+").replace(/_/g,"/");return e.length%4!=0&&(e=e.padEnd(e.length+(4-e.length%4)%4,"=")),Xe.bytes(e)},random(t=32){return this.string(Ge.random(t))}},es={string:t=>(new TextDecoder).decode(t),bytes:t=>(new TextEncoder).encode(t)};function ss(t=32){const e=new Uint8Array(t);return[...crypto.getRandomValues(e)].map((t=>t.toString(16).padStart(2,"0"))).join("")}function rs(){const t=new Set;function e(e){return t.add(e),()=>{t.delete(e)}}return e.publish=async(...e)=>{await Promise.all([...t].map((t=>t(...e))))},e.clear=()=>t.clear(),e.once=async()=>{const{promise:t,resolve:s}=Qt(),r=e(((...t)=>{s(t),r()}));return t},e}var ns,is;!function(t){t.actualize=function t(e,s){return A(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,r)=>(...n)=>(e(t(s,r))(...n),s),t.prepBlueprint=e=>s=>s(t.prepFn(e)),t.prep=function(e){return{action:t.prepFn(e),blueprint:t.prepBlueprint(e)}}}(ns||(ns={}));class os{static formats={public:"spki",private:"pkcs8"};static algos={generate:{name:"ECDSA",namedCurve:"P-256"},signing:{name:"ECDSA",hash:{name:"SHA-256"}},thumbprint:"SHA-256"}}class as extends Error{name=this.constructor.name}class cs{static header=Object.freeze({typ:"JWT",alg:"ES256"});static toJsTime=t=>1e3*t;static fromJsTime=t=>t/1e3;static params=t=>({jti:ss(),iat:Date.now(),exp:cs.fromJsTime(t.expiresAt),nbf:t.notBefore,iss:t.issuer,aud:t.audience});static async sign(t,e){const s=es.bytes(JSON.stringify(cs.header)),r=ts.string(s),n=es.bytes(JSON.stringify(e)),i=`${r}.${ts.string(n)}`,o=(new TextEncoder).encode(i);return`${i}.${ts.string(new Uint8Array(await crypto.subtle.sign(os.algos.signing,t,o)))}`}static decode(t){const[e,s,r]=t.split(".");if(!e||!s||!r)throw new Error("invalid jwt structure");const n=ts.bytes(e),i=es.string(n),o=JSON.parse(i),a=ts.bytes(s),c=es.string(a);return{header:o,payload:JSON.parse(c),signature:ts.bytes(r).buffer}}static async verify(t,e,s={}){const[r,n]=e.split("."),{payload:i,signature:o}=cs.decode(e),a=`${r}.${n}`,c=(new TextEncoder).encode(a);if(!await crypto.subtle.verify(os.algos.signing,t,o,c))throw new as("token signature invalid");if(i.exp){const t=cs.toJsTime(i.exp);if(Date.now()>t)throw new as("token expired")}if(i.nbf){const t=cs.toJsTime(i.nbf);if(Date.now()<t)throw new as("token not ready")}if(s.allowedIssuers){if(!i.iss)throw new as("required iss (issuer) is missing");if(!s.allowedIssuers.includes(i.iss))throw new as(`invalid iss (issuer) "${i.iss}"`)}if(s.allowedAudiences){if(!i.aud)throw new as("required aud (audience) is missing");if(!s.allowedAudiences.includes(i.aud))throw new as(`invalid aud (audience) "${i.aud}"`)}if(i.aud&&!s.allowedAudiences)throw new as('allowedAudiences verification option was not provided, but is required because the token included "aud"');return i}}class ls{thumbprint;publicKey;constructor(t,e){this.thumbprint=t,this.publicKey=e}static async fromData(t){const e=Qe.bytes(t.publicKey).buffer,s=Qe.string(new Uint8Array(await crypto.subtle.digest(os.algos.thumbprint,e)));if(t.thumbprint!==s)throw new as("incorrect thumbprint");return new this(s,await crypto.subtle.importKey(os.formats.public,e,os.algos.generate,!0,["verify"]))}async toData(){const t=await crypto.subtle.exportKey(os.formats.public,this.publicKey);return{thumbprint:Qe.string(new Uint8Array(await crypto.subtle.digest(os.algos.thumbprint,t))),publicKey:Qe.string(new Uint8Array(t))}}async verify(t,e={}){return await cs.verify(this.publicKey,t,e)}}class hs extends ls{privateKey;constructor(t,e,s){super(t,e),this.privateKey=s}static async generate(){const t=await crypto.subtle.generateKey(os.algos.generate,!0,["sign","verify"]),e=await crypto.subtle.exportKey(os.formats.public,t.publicKey);return new this(Qe.string(new Uint8Array(await crypto.subtle.digest(os.algos.thumbprint,e))),t.publicKey,t.privateKey)}static async fromData(t){const e=await ls.fromData(t),s=Qe.bytes(t.privateKey).buffer,r=await crypto.subtle.importKey(os.formats.private,s,os.algos.generate,!0,["sign"]);return new this(e.thumbprint,e.publicKey,r)}async toData(){const t=await super.toData(),e=await crypto.subtle.exportKey(os.formats.private,this.privateKey);return{thumbprint:t.thumbprint,publicKey:t.publicKey,privateKey:Qe.string(new Uint8Array(e))}}toPubkey(){return new ls(this.thumbprint,this.publicKey)}async sign(t){return await cs.sign(this.privateKey,t)}}class us{proof;token;payload;constructor(t,e,s){this.proof=t,this.token=e,this.payload=s}get name(){return this.payload.data.name}get thumbprint(){return this.proof.thumbprint}get expiresAt(){return cs.toJsTime(this.payload.exp)}isExpired(){return Date.now()>this.expiresAt}static decode(t){return cs.decode(t)}static async verify(t,e,s){const r=await t.getPassportPubkey();await r.verify(e,s);const{payload:n}=this.decode(e);return new this(t,e,n)}async signClaimToken({data:t,...e}){const s=this.thumbprint,r=await hs.fromData(this.payload.data.loginKeypair);return await r.sign({...cs.params(e),sub:s,data:t})}}class ds{proof;token;payload;constructor(t,e,s){this.proof=t,this.token=e,this.payload=s}get thumbprint(){return this.payload.sub}get expiresAt(){return cs.toJsTime(this.payload.exp)}get data(){return this.payload.data}isExpired(){return Date.now()>this.expiresAt}static decode(t){return cs.decode(t)}static async verify(t,e,s={}){const{payload:r}=this.decode(e),n=new this(t,e,r);if(n.thumbprint!==t.thumbprint)throw new Error("thumbprint mismatch between claim and proof");const i=await t.getLoginPubkey();return await i.verify(e,s),n}}class ps{token;payload;constructor(t,e){this.token=t,this.payload=e}get audience(){return this.payload.aud}get expiresAt(){return cs.toJsTime(this.payload.exp)}get thumbprint(){return this.payload.data.passportPubkey.thumbprint}async getPassportPubkey(){return await ls.fromData(this.payload.data.passportPubkey)}async getLoginPubkey(){return await ls.fromData(this.payload.data.loginPubkey)}isExpired(){return Date.now()>this.expiresAt}async verifyLogin(t){return us.verify(this,t)}async verifyClaim(t){return ds.verify(this,t)}static decode(t){return cs.decode(t)}static async verify(t,e){const{payload:s}=this.decode(t),r=new this(t,s),n=await r.getPassportPubkey();return await n.verify(t,e),r}}class fs{proof;keys;constructor(t,e){this.proof=t,this.keys=e}static async verify(t,e){const s=await ps.verify(t.proofToken,e);return new this(s,await us.verify(s,t.keysToken,e))}isExpired(){return this.proof.isExpired()}get name(){return this.keys.name}get thumbprint(){return this.proof.thumbprint}get expiresAt(){return this.proof.expiresAt}get tokens(){return{keysToken:this.keys.token,proofToken:this.proof.token}}}async function gs(t){try{return await t()}catch{return null}}class ms{key;storage;onChangeFromOutside=rs();dispose;constructor(t,e=window.localStorage){this.key=t,this.storage=e,this.dispose=funct