UNPKG

@getalby/bitcoin-connect

Version:

Web components to connect to a lightning wallet and power a website with WebLN

19 lines 208 kB
import{webln as t,nwc as e,nwa as n}from"@getalby/sdk";import{createStore as o}from"zustand/vanilla";import{fiat as i,Invoice as r}from"@getalby/lightning-tools";import s from"qrcode-generator";class a{constructor(t){this._config=t}async unload(){}}const l=t=>{const e=[];for(let n=0,o=atob(t.replace(/[ \r\n]+$/,""));n<o.length;++n){let t=o.charCodeAt(n).toString(16);1===t.length&&(t="0"+t),e[e.length]=t}return e.join("")};let c;async function d(){try{if(c)return c;const t=(await import("@lightninglabs/lnc-web")).default;return c=new t,c}catch(t){throw console.error(t),new Error("LNC is not available")}}const h="ONLY CONNECT TO TRUSTED WEBSITES";class p{constructor(t){this.lnc=t}enable(){return Promise.resolve()}async getInfo(){const t=await c.lnd.lightning.getInfo();return{methods:["enable","getBalance","getInfo","sendPayment"],version:"1.0",node:{alias:t.alias,pubkey:t.identityPubkey,color:t.color},supports:["lightning"]}}makeInvoice(t){throw new Error("Method not implemented.")}async sendPayment(t){const e=await c.lnd.lightning.sendPaymentSync({paymentRequest:t});if(e.paymentError)throw new Error(e.paymentError);if(!e.paymentPreimage)throw new Error("No preimage in response");if("string"!=typeof e.paymentPreimage)throw new Error("expected preimage as string");return{preimage:l(e.paymentPreimage)}}async getBalance(){var t;const e=await c.lnd.lightning.channelBalance();return{balance:parseInt((null==(t=e.localBalance)?void 0:t.sat)||"0")}}keysend(t){throw new Error("Method not implemented.")}lnurl(t){throw new Error("Method not implemented.")}lookupInvoice(t){throw new Error("Method not implemented.")}signMessage(t){throw new Error("Method not implemented.")}verifyMessage(t,e){throw new Error("Method not implemented.")}}class u{constructor(t,e){this._instanceUrl=t,this._adminKey=e}enable(){return Promise.resolve()}async getInfo(){return{node:{alias:(await this.requestLnbits("GET","/api/v1/wallet")).name,pubkey:""},methods:["getInfo","getBalance","sendPayment"],version:"1.0",supports:["lightning"]}}async makeInvoice(t){return{paymentRequest:(await this.requestLnbits("POST","/api/v1/payments",{amount:t.amount||t.defaultAmount||+t,memo:t.defaultMemo,out:!1})).payment_request}}async sendPayment(t){const e=await this.requestLnbits("POST","/api/v1/payments",{bolt11:t,out:!0}),n=await this.requestLnbits("GET",`/api/v1/payments/${e.payment_hash}`);if(!n.preimage)throw new Error("No preimage");return{preimage:n.preimage}}async getBalance(){const t=await this.requestLnbits("GET","/api/v1/wallet");return{balance:Math.floor(t.balance/1e3)}}keysend(t){throw new Error("Method not implemented.")}lnurl(t){throw new Error("Method not implemented.")}lookupInvoice(t){throw new Error("Method not implemented.")}signMessage(t){throw new Error("Method not implemented.")}verifyMessage(t,e){throw new Error("Method not implemented.")}async requestLnbits(t,e,n){let o=null;const i=new Headers;if(i.append("Accept","application/json"),i.append("Content-Type","application/json"),i.append("X-Api-Key",this._adminKey),"POST"===t)o=JSON.stringify(n);else if(void 0!==n)throw new Error("TODO: support args in GET");const r=await fetch(this._instanceUrl+e+"",{method:t,headers:i,body:o});if(!r.ok){const t=await r.json();throw console.error("errBody",t),new Error(t.detail)}return await r.json()}}function f(){return f=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},f.apply(this,arguments)}class g extends a{constructor(t){super(t)}async init(){if(!this._config.nwcUrl)throw new Error("no nwc URL provided");return new t.NostrWebLNProvider({nostrWalletConnectUrl:this._config.nwcUrl})}}const m={"extension.generic":class extends a{constructor(t){super(t)}init(){if(!window.webln)throw new Error("No WebLN provider available");return Promise.resolve(window.webln)}},"nwc.alby":g,"nwc.albyhub":g,"nwc.generic":g,"nwc.lnfi":g,"nwc.coinos":g,"nwc.flash":g,lnbits:class extends a{constructor(t){super(t)}async init(){if(!this._config.lnbitsInstanceUrl)throw new Error("no lnbits URL provided");if(!this._config.lnbitsAdminKey)throw new Error("no lnbits admin key provided");return new u(this._config.lnbitsInstanceUrl,this._config.lnbitsAdminKey)}},lnc:class extends a{constructor(t){super(t)}async init(){await d();const t=new p(c);try{const t=!c.credentials.pairingPhrase;for(t?(console.log("Pairing phrase does not exist"),c.credentials.password=h):console.log("Pairing phrase set"),await c.connect(),t||(c.credentials.password=h);!c.isConnected;)console.log("Waiting to connect..."),await new Promise(t=>{setTimeout(t,100)})}catch(t){throw console.error(t),c.disconnect(),c.credentials.clear(),t}return t}async unload(){c.disconnect(),c.credentials.clear(),await super.unload()}}},b={showBalance:!0,appName:"Bitcoin Connect"},C=o((t,e)=>({route:"/start",routeHistory:[],modalOpen:!1,currency:void 0,connected:!1,connecting:!1,error:void 0,alias:void 0,balance:void 0,connectorName:void 0,invoice:void 0,provider:void 0,connector:void 0,connectorConfig:void 0,bitcoinConnectConfig:b,info:void 0,connect:async(n,o={redirectTo:"/connected"})=>{t({connecting:!0,error:void 0});try{const i=new m[n.connectorType](n),r=await i.init();let s;await r.enable();try{s=await r.getInfo()}catch(t){console.error("Failed to request wallet info")}if(!e().connecting)return;t({connectorConfig:n,connector:i,connected:!0,connecting:!1,info:s,provider:r,connectorName:n.connectorName,route:o.redirectTo}),window.localStorage.setItem("bc:config",JSON.stringify(n))}catch(n){console.error(n),t({error:n.toString(),connecting:!1}),e().disconnect()}},disconnect:()=>{var n;null==(n=e().connector)||n.unload(),t({connectorConfig:void 0,connector:void 0,connected:!1,connecting:!1,connectorName:void 0,provider:void 0,modalOpen:!1}),window.localStorage.removeItem("bc:config")},pushRoute:n=>{e().route!==n&&t({route:n,routeHistory:[...e().routeHistory,e().route]})},popRoute(){const n=e().routeHistory,o=n.pop()||"/start";t({route:o,routeHistory:n})},clearRouteHistory(){t({route:"/start",routeHistory:[]})},setModalOpen:e=>{t({modalOpen:e})},setBitcoinConnectConfig:e=>{t({bitcoinConnectConfig:f({},b,e)})},setError:e=>{t({error:e})},setCurrency:e=>{e?window.localStorage.setItem("bc:currency",e):window.localStorage.removeItem("bc:currency"),t({currency:e})},supports:t=>{const{info:n,provider:o}=e();return!(null==n||!n.methods)&&n.methods.indexOf(t)>-1&&!(null==o||!o.getBalance)}}));function w(t,e,n,o){var i,r=arguments.length,s=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,o);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(r<3?i(s):r>3?i(e,n,s):i(e,n))||s);return r>3&&s&&Object.defineProperty(e,n,s),s}globalThis.window&&(function(){const t=window.localStorage.getItem("bc:config");if(t){const e=JSON.parse(t);C.getState().connect(e,{redirectTo:"/start"})}const e=window.localStorage.getItem("bc:currency");e&&C.getState().setCurrency(e)}(),window.addEventListener("webln:enabled",()=>{C.getState().connecting||C.getState().connect({connectorName:"Extension",connectorType:"extension.generic"},{redirectTo:"/start"})})),"function"==typeof SuppressedError&&SuppressedError;const y=globalThis,v=y.ShadowRoot&&(void 0===y.ShadyCSS||y.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,x=Symbol(),$=new WeakMap;class _{constructor(t,e,n){if(this._$cssResult$=!0,n!==x)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(v&&void 0===t){const n=void 0!==e&&1===e.length;n&&(t=$.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),n&&$.set(e,t))}return t}toString(){return this.cssText}}const k=v?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const n of t.cssRules)e+=n.cssText;return(t=>new _("string"==typeof t?t:t+"",void 0,x))(e)})(t):t,{is:S,defineProperty:A,getOwnPropertyDescriptor:L,getOwnPropertyNames:M,getOwnPropertySymbols:E,getPrototypeOf:T}=Object,N=globalThis,U=N.trustedTypes,P=U?U.emptyScript:"",O=N.reactiveElementPolyfillSupport,H=(t,e)=>t,R={toAttribute(t,e){switch(e){case Boolean:t=t?P:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let n=t;switch(e){case Boolean:n=null!==t;break;case Number:n=null===t?null:Number(t);break;case Object:case Array:try{n=JSON.parse(t)}catch(t){n=null}}return n}},B=(t,e)=>!S(t,e),D={attribute:!0,type:String,converter:R,reflect:!1,useDefault:!1,hasChanged:B};Symbol.metadata??=Symbol("metadata"),N.litPropertyMetadata??=new WeakMap;class Z 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=D){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 n=Symbol(),o=this.getPropertyDescriptor(t,n,e);void 0!==o&&A(this.prototype,t,o)}}static getPropertyDescriptor(t,e,n){const{get:o,set:i}=L(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get:o,set(e){const r=o?.call(this);i?.call(this,e),this.requestUpdate(t,r,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??D}static _$Ei(){if(this.hasOwnProperty(H("elementProperties")))return;const t=T(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(H("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(H("properties"))){const t=this.properties,e=[...M(t),...E(t)];for(const n of e)this.createProperty(n,t[n])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,n]of e)this.elementProperties.set(t,n)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const n=this._$Eu(t,e);void 0!==n&&this._$Eh.set(n,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const n=new Set(t.flat(1/0).reverse());for(const t of n)e.unshift(k(t))}else void 0!==t&&e.push(k(t));return e}static _$Eu(t,e){const n=e.attribute;return!1===n?void 0:"string"==typeof n?n:"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 n of e.keys())this.hasOwnProperty(n)&&(t.set(n,this[n]),delete this[n]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{if(v)t.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const n of e){const e=document.createElement("style"),o=y.litNonce;void 0!==o&&e.setAttribute("nonce",o),e.textContent=n.cssText,t.appendChild(e)}})(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,n){this._$AK(t,n)}_$ET(t,e){const n=this.constructor.elementProperties.get(t),o=this.constructor._$Eu(t,n);if(void 0!==o&&!0===n.reflect){const i=(void 0!==n.converter?.toAttribute?n.converter:R).toAttribute(e,n.type);this._$Em=t,null==i?this.removeAttribute(o):this.setAttribute(o,i),this._$Em=null}}_$AK(t,e){const n=this.constructor,o=n._$Eh.get(t);if(void 0!==o&&this._$Em!==o){const t=n.getPropertyOptions(o),i="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:R;this._$Em=o,this[o]=i.fromAttribute(e,t.type)??this._$Ej?.get(o)??null,this._$Em=null}}requestUpdate(t,e,n){if(void 0!==t){const o=this.constructor,i=this[t];if(n??=o.getPropertyOptions(t),!((n.hasChanged??B)(i,e)||n.useDefault&&n.reflect&&i===this._$Ej?.get(t)&&!this.hasAttribute(o._$Eu(t,n))))return;this.C(t,e,n)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(t,e,{useDefault:n,reflect:o,wrapped:i},r){n&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,r??e??this[t]),!0!==i||void 0!==r)||(this._$AL.has(t)||(this.hasUpdated||n||(e=void 0),this._$AL.set(t,e)),!0===o&&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,n]of t){const{wrapped:t}=n,o=this[e];!0!==t||this._$AL.has(e)||void 0===o||this.C(e,void 0,n,o)}}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){}}Z.elementStyles=[],Z.shadowRootOptions={mode:"open"},Z[H("elementProperties")]=new Map,Z[H("finalized")]=new Map,O?.({ReactiveElement:Z}),(N.reactiveElementVersions??=[]).push("2.1.0");const F=globalThis,z=F.trustedTypes,j=z?z.createPolicy("lit-html",{createHTML:t=>t}):void 0,W="$lit$",I=`lit$${Math.random().toFixed(9).slice(2)}$`,V="?"+I,G=`<${V}>`,q=document,K=()=>q.createComment(""),Y=t=>null===t||"object"!=typeof t&&"function"!=typeof t,J=Array.isArray,Q="[ \t\n\f\r]",X=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,tt=/-->/g,et=/>/g,nt=RegExp(`>|${Q}(?:([^\\s"'>=/]+)(${Q}*=${Q}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),ot=/'/g,it=/"/g,rt=/^(?:script|style|textarea|title)$/i,st=Symbol.for("lit-noChange"),at=Symbol.for("lit-nothing"),lt=new WeakMap,ct=q.createTreeWalker(q,129);function dt(t,e){if(!J(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==j?j.createHTML(e):e}class ht{constructor({strings:t,_$litType$:e},n){let o;this.parts=[];let i=0,r=0;const s=t.length-1,a=this.parts,[l,c]=((t,e)=>{const n=t.length-1,o=[];let i,r=2===e?"<svg>":3===e?"<math>":"",s=X;for(let e=0;e<n;e++){const n=t[e];let a,l,c=-1,d=0;for(;d<n.length&&(s.lastIndex=d,l=s.exec(n),null!==l);)d=s.lastIndex,s===X?"!--"===l[1]?s=tt:void 0!==l[1]?s=et:void 0!==l[2]?(rt.test(l[2])&&(i=RegExp("</"+l[2],"g")),s=nt):void 0!==l[3]&&(s=nt):s===nt?">"===l[0]?(s=i??X,c=-1):void 0===l[1]?c=-2:(c=s.lastIndex-l[2].length,a=l[1],s=void 0===l[3]?nt:'"'===l[3]?it:ot):s===it||s===ot?s=nt:s===tt||s===et?s=X:(s=nt,i=void 0);const h=s===nt&&t[e+1].startsWith("/>")?" ":"";r+=s===X?n+G:c>=0?(o.push(a),n.slice(0,c)+W+n.slice(c)+I+h):n+I+(-2===c?e:h)}return[dt(t,r+(t[n]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),o]})(t,e);if(this.el=ht.createElement(l,n),ct.currentNode=this.el.content,2===e||3===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(o=ct.nextNode())&&a.length<s;){if(1===o.nodeType){if(o.hasAttributes())for(const t of o.getAttributeNames())if(t.endsWith(W)){const e=c[r++],n=o.getAttribute(t).split(I),s=/([.?@])?(.*)/.exec(e);a.push({type:1,index:i,name:s[2],strings:n,ctor:"."===s[1]?mt:"?"===s[1]?bt:"@"===s[1]?Ct:gt}),o.removeAttribute(t)}else t.startsWith(I)&&(a.push({type:6,index:i}),o.removeAttribute(t));if(rt.test(o.tagName)){const t=o.textContent.split(I),e=t.length-1;if(e>0){o.textContent=z?z.emptyScript:"";for(let n=0;n<e;n++)o.append(t[n],K()),ct.nextNode(),a.push({type:2,index:++i});o.append(t[e],K())}}}else if(8===o.nodeType)if(o.data===V)a.push({type:2,index:i});else{let t=-1;for(;-1!==(t=o.data.indexOf(I,t+1));)a.push({type:7,index:i}),t+=I.length-1}i++}}static createElement(t,e){const n=q.createElement("template");return n.innerHTML=t,n}}function pt(t,e,n=t,o){if(e===st)return e;let i=void 0!==o?n._$Co?.[o]:n._$Cl;const r=Y(e)?void 0:e._$litDirective$;return i?.constructor!==r&&(i?._$AO?.(!1),void 0===r?i=void 0:(i=new r(t),i._$AT(t,n,o)),void 0!==o?(n._$Co??=[])[o]=i:n._$Cl=i),void 0!==i&&(e=pt(t,i._$AS(t,e.values),i,o)),e}class ut{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:n}=this._$AD,o=(t?.creationScope??q).importNode(e,!0);ct.currentNode=o;let i=ct.nextNode(),r=0,s=0,a=n[0];for(;void 0!==a;){if(r===a.index){let e;2===a.type?e=new ft(i,i.nextSibling,this,t):1===a.type?e=new a.ctor(i,a.name,a.strings,this,t):6===a.type&&(e=new wt(i,this,t)),this._$AV.push(e),a=n[++s]}r!==a?.index&&(i=ct.nextNode(),r++)}return ct.currentNode=q,o}p(t){let e=0;for(const n of this._$AV)void 0!==n&&(void 0!==n.strings?(n._$AI(t,n,e),e+=n.strings.length-2):n._$AI(t[e])),e++}}class ft{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,n,o){this.type=2,this._$AH=at,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=n,this.options=o,this._$Cv=o?.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=pt(this,t,e),Y(t)?t===at||null==t||""===t?(this._$AH!==at&&this._$AR(),this._$AH=at):t!==this._$AH&&t!==st&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>J(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!==at&&Y(this._$AH)?this._$AA.nextSibling.data=t:this.T(q.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:n}=t,o="number"==typeof n?this._$AC(t):(void 0===n.el&&(n.el=ht.createElement(dt(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===o)this._$AH.p(e);else{const t=new ut(o,this),n=t.u(this.options);t.p(e),this.T(n),this._$AH=t}}_$AC(t){let e=lt.get(t.strings);return void 0===e&&lt.set(t.strings,e=new ht(t)),e}k(t){J(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let n,o=0;for(const i of t)o===e.length?e.push(n=new ft(this.O(K()),this.O(K()),this,this.options)):n=e[o],n._$AI(i),o++;o<e.length&&(this._$AR(n&&n._$AB.nextSibling,o),e.length=o)}_$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 gt{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,n,o,i){this.type=1,this._$AH=at,this._$AN=void 0,this.element=t,this.name=e,this._$AM=o,this.options=i,n.length>2||""!==n[0]||""!==n[1]?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=at}_$AI(t,e=this,n,o){const i=this.strings;let r=!1;if(void 0===i)t=pt(this,t,e,0),r=!Y(t)||t!==this._$AH&&t!==st,r&&(this._$AH=t);else{const o=t;let s,a;for(t=i[0],s=0;s<i.length-1;s++)a=pt(this,o[n+s],e,s),a===st&&(a=this._$AH[s]),r||=!Y(a)||a!==this._$AH[s],a===at?t=at:t!==at&&(t+=(a??"")+i[s+1]),this._$AH[s]=a}r&&!o&&this.j(t)}j(t){t===at?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class mt extends gt{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===at?void 0:t}}class bt extends gt{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==at)}}class Ct extends gt{constructor(t,e,n,o,i){super(t,e,n,o,i),this.type=5}_$AI(t,e=this){if((t=pt(this,t,e,0)??at)===st)return;const n=this._$AH,o=t===at&&n!==at||t.capture!==n.capture||t.once!==n.once||t.passive!==n.passive,i=t!==at&&(n===at||o);o&&this.element.removeEventListener(this.name,this,n),i&&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 wt{constructor(t,e,n){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(t){pt(this,t)}}const yt=F.litHtmlPolyfillSupport;yt?.(ht,ft),(F.litHtmlVersions??=[]).push("3.3.0");const vt=globalThis,xt=vt.ShadowRoot&&(void 0===vt.ShadyCSS||vt.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,$t=Symbol(),_t=new WeakMap;class kt{constructor(t,e,n){if(this._$cssResult$=!0,n!==$t)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(xt&&void 0===t){const n=void 0!==e&&1===e.length;n&&(t=_t.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),n&&_t.set(e,t))}return t}toString(){return this.cssText}}const St=(t,...e)=>{const n=1===t.length?t[0]:e.reduce((e,n,o)=>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.")})(n)+t[o+1],t[0]);return new kt(n,t,$t)},At=xt?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const n of t.cssRules)e+=n.cssText;return(t=>new kt("string"==typeof t?t:t+"",void 0,$t))(e)})(t):t,{is:Lt,defineProperty:Mt,getOwnPropertyDescriptor:Et,getOwnPropertyNames:Tt,getOwnPropertySymbols:Nt,getPrototypeOf:Ut}=Object,Pt=globalThis,Ot=Pt.trustedTypes,Ht=Ot?Ot.emptyScript:"",Rt=Pt.reactiveElementPolyfillSupport,Bt=(t,e)=>t,Dt={toAttribute(t,e){switch(e){case Boolean:t=t?Ht:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let n=t;switch(e){case Boolean:n=null!==t;break;case Number:n=null===t?null:Number(t);break;case Object:case Array:try{n=JSON.parse(t)}catch(t){n=null}}return n}},Zt=(t,e)=>!Lt(t,e),Ft={attribute:!0,type:String,converter:Dt,reflect:!1,useDefault:!1,hasChanged:Zt};Symbol.metadata??=Symbol("metadata"),Pt.litPropertyMetadata??=new WeakMap;class zt 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=Ft){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 n=Symbol(),o=this.getPropertyDescriptor(t,n,e);void 0!==o&&Mt(this.prototype,t,o)}}static getPropertyDescriptor(t,e,n){const{get:o,set:i}=Et(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get:o,set(e){const r=o?.call(this);i?.call(this,e),this.requestUpdate(t,r,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Ft}static _$Ei(){if(this.hasOwnProperty(Bt("elementProperties")))return;const t=Ut(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(Bt("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Bt("properties"))){const t=this.properties,e=[...Tt(t),...Nt(t)];for(const n of e)this.createProperty(n,t[n])}const t=this[Symbol.metadata];if(null!==t){const e=litPropertyMetadata.get(t);if(void 0!==e)for(const[t,n]of e)this.elementProperties.set(t,n)}this._$Eh=new Map;for(const[t,e]of this.elementProperties){const n=this._$Eu(t,e);void 0!==n&&this._$Eh.set(n,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const n=new Set(t.flat(1/0).reverse());for(const t of n)e.unshift(At(t))}else void 0!==t&&e.push(At(t));return e}static _$Eu(t,e){const n=e.attribute;return!1===n?void 0:"string"==typeof n?n:"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 n of e.keys())this.hasOwnProperty(n)&&(t.set(n,this[n]),delete this[n]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{if(xt)t.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const n of e){const e=document.createElement("style"),o=vt.litNonce;void 0!==o&&e.setAttribute("nonce",o),e.textContent=n.cssText,t.appendChild(e)}})(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,n){this._$AK(t,n)}_$ET(t,e){const n=this.constructor.elementProperties.get(t),o=this.constructor._$Eu(t,n);if(void 0!==o&&!0===n.reflect){const i=(void 0!==n.converter?.toAttribute?n.converter:Dt).toAttribute(e,n.type);this._$Em=t,null==i?this.removeAttribute(o):this.setAttribute(o,i),this._$Em=null}}_$AK(t,e){const n=this.constructor,o=n._$Eh.get(t);if(void 0!==o&&this._$Em!==o){const t=n.getPropertyOptions(o),i="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:Dt;this._$Em=o,this[o]=i.fromAttribute(e,t.type)??this._$Ej?.get(o)??null,this._$Em=null}}requestUpdate(t,e,n){if(void 0!==t){const o=this.constructor,i=this[t];if(n??=o.getPropertyOptions(t),!((n.hasChanged??Zt)(i,e)||n.useDefault&&n.reflect&&i===this._$Ej?.get(t)&&!this.hasAttribute(o._$Eu(t,n))))return;this.C(t,e,n)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(t,e,{useDefault:n,reflect:o,wrapped:i},r){n&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,r??e??this[t]),!0!==i||void 0!==r)||(this._$AL.has(t)||(this.hasUpdated||n||(e=void 0),this._$AL.set(t,e)),!0===o&&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,n]of t){const{wrapped:t}=n,o=this[e];!0!==t||this._$AL.has(e)||void 0===o||this.C(e,void 0,n,o)}}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){}}zt.elementStyles=[],zt.shadowRootOptions={mode:"open"},zt[Bt("elementProperties")]=new Map,zt[Bt("finalized")]=new Map,Rt?.({ReactiveElement:zt}),(Pt.reactiveElementVersions??=[]).push("2.1.0");const jt=globalThis,Wt=jt.trustedTypes,It=Wt?Wt.createPolicy("lit-html",{createHTML:t=>t}):void 0,Vt="$lit$",Gt=`lit$${Math.random().toFixed(9).slice(2)}$`,qt="?"+Gt,Kt=`<${qt}>`,Yt=document,Jt=()=>Yt.createComment(""),Qt=t=>null===t||"object"!=typeof t&&"function"!=typeof t,Xt=Array.isArray,te="[ \t\n\f\r]",ee=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ne=/-->/g,oe=/>/g,ie=RegExp(`>|${te}(?:([^\\s"'>=/]+)(${te}*=${te}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),re=/'/g,se=/"/g,ae=/^(?:script|style|textarea|title)$/i,le=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),ce=le(1),de=le(2),he=Symbol.for("lit-noChange"),pe=Symbol.for("lit-nothing"),ue=new WeakMap,fe=Yt.createTreeWalker(Yt,129);function ge(t,e){if(!Xt(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==It?It.createHTML(e):e}const me=(t,e)=>{const n=t.length-1,o=[];let i,r=2===e?"<svg>":3===e?"<math>":"",s=ee;for(let e=0;e<n;e++){const n=t[e];let a,l,c=-1,d=0;for(;d<n.length&&(s.lastIndex=d,l=s.exec(n),null!==l);)d=s.lastIndex,s===ee?"!--"===l[1]?s=ne:void 0!==l[1]?s=oe:void 0!==l[2]?(ae.test(l[2])&&(i=RegExp("</"+l[2],"g")),s=ie):void 0!==l[3]&&(s=ie):s===ie?">"===l[0]?(s=i??ee,c=-1):void 0===l[1]?c=-2:(c=s.lastIndex-l[2].length,a=l[1],s=void 0===l[3]?ie:'"'===l[3]?se:re):s===se||s===re?s=ie:s===ne||s===oe?s=ee:(s=ie,i=void 0);const h=s===ie&&t[e+1].startsWith("/>")?" ":"";r+=s===ee?n+Kt:c>=0?(o.push(a),n.slice(0,c)+Vt+n.slice(c)+Gt+h):n+Gt+(-2===c?e:h)}return[ge(t,r+(t[n]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),o]};class be{constructor({strings:t,_$litType$:e},n){let o;this.parts=[];let i=0,r=0;const s=t.length-1,a=this.parts,[l,c]=me(t,e);if(this.el=be.createElement(l,n),fe.currentNode=this.el.content,2===e||3===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(o=fe.nextNode())&&a.length<s;){if(1===o.nodeType){if(o.hasAttributes())for(const t of o.getAttributeNames())if(t.endsWith(Vt)){const e=c[r++],n=o.getAttribute(t).split(Gt),s=/([.?@])?(.*)/.exec(e);a.push({type:1,index:i,name:s[2],strings:n,ctor:"."===s[1]?xe:"?"===s[1]?$e:"@"===s[1]?_e:ve}),o.removeAttribute(t)}else t.startsWith(Gt)&&(a.push({type:6,index:i}),o.removeAttribute(t));if(ae.test(o.tagName)){const t=o.textContent.split(Gt),e=t.length-1;if(e>0){o.textContent=Wt?Wt.emptyScript:"";for(let n=0;n<e;n++)o.append(t[n],Jt()),fe.nextNode(),a.push({type:2,index:++i});o.append(t[e],Jt())}}}else if(8===o.nodeType)if(o.data===qt)a.push({type:2,index:i});else{let t=-1;for(;-1!==(t=o.data.indexOf(Gt,t+1));)a.push({type:7,index:i}),t+=Gt.length-1}i++}}static createElement(t,e){const n=Yt.createElement("template");return n.innerHTML=t,n}}function Ce(t,e,n=t,o){if(e===he)return e;let i=void 0!==o?n._$Co?.[o]:n._$Cl;const r=Qt(e)?void 0:e._$litDirective$;return i?.constructor!==r&&(i?._$AO?.(!1),void 0===r?i=void 0:(i=new r(t),i._$AT(t,n,o)),void 0!==o?(n._$Co??=[])[o]=i:n._$Cl=i),void 0!==i&&(e=Ce(t,i._$AS(t,e.values),i,o)),e}class we{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:n}=this._$AD,o=(t?.creationScope??Yt).importNode(e,!0);fe.currentNode=o;let i=fe.nextNode(),r=0,s=0,a=n[0];for(;void 0!==a;){if(r===a.index){let e;2===a.type?e=new ye(i,i.nextSibling,this,t):1===a.type?e=new a.ctor(i,a.name,a.strings,this,t):6===a.type&&(e=new ke(i,this,t)),this._$AV.push(e),a=n[++s]}r!==a?.index&&(i=fe.nextNode(),r++)}return fe.currentNode=Yt,o}p(t){let e=0;for(const n of this._$AV)void 0!==n&&(void 0!==n.strings?(n._$AI(t,n,e),e+=n.strings.length-2):n._$AI(t[e])),e++}}class ye{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,n,o){this.type=2,this._$AH=pe,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=n,this.options=o,this._$Cv=o?.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=Ce(this,t,e),Qt(t)?t===pe||null==t||""===t?(this._$AH!==pe&&this._$AR(),this._$AH=pe):t!==this._$AH&&t!==he&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>Xt(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!==pe&&Qt(this._$AH)?this._$AA.nextSibling.data=t:this.T(Yt.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:n}=t,o="number"==typeof n?this._$AC(t):(void 0===n.el&&(n.el=be.createElement(ge(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===o)this._$AH.p(e);else{const t=new we(o,this),n=t.u(this.options);t.p(e),this.T(n),this._$AH=t}}_$AC(t){let e=ue.get(t.strings);return void 0===e&&ue.set(t.strings,e=new be(t)),e}k(t){Xt(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let n,o=0;for(const i of t)o===e.length?e.push(n=new ye(this.O(Jt()),this.O(Jt()),this,this.options)):n=e[o],n._$AI(i),o++;o<e.length&&(this._$AR(n&&n._$AB.nextSibling,o),e.length=o)}_$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 ve{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,n,o,i){this.type=1,this._$AH=pe,this._$AN=void 0,this.element=t,this.name=e,this._$AM=o,this.options=i,n.length>2||""!==n[0]||""!==n[1]?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=pe}_$AI(t,e=this,n,o){const i=this.strings;let r=!1;if(void 0===i)t=Ce(this,t,e,0),r=!Qt(t)||t!==this._$AH&&t!==he,r&&(this._$AH=t);else{const o=t;let s,a;for(t=i[0],s=0;s<i.length-1;s++)a=Ce(this,o[n+s],e,s),a===he&&(a=this._$AH[s]),r||=!Qt(a)||a!==this._$AH[s],a===pe?t=pe:t!==pe&&(t+=(a??"")+i[s+1]),this._$AH[s]=a}r&&!o&&this.j(t)}j(t){t===pe?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class xe extends ve{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===pe?void 0:t}}class $e extends ve{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==pe)}}class _e extends ve{constructor(t,e,n,o,i){super(t,e,n,o,i),this.type=5}_$AI(t,e=this){if((t=Ce(this,t,e,0)??pe)===he)return;const n=this._$AH,o=t===pe&&n!==pe||t.capture!==n.capture||t.once!==n.once||t.passive!==n.passive,i=t!==pe&&(n===pe||o);o&&this.element.removeEventListener(this.name,this,n),i&&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 ke{constructor(t,e,n){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(t){Ce(this,t)}}const Se=jt.litHtmlPolyfillSupport;Se?.(be,ye),(jt.litHtmlVersions??=[]).push("3.3.0");const Ae=globalThis;class Le extends zt{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=((t,e,n)=>{const o=n?.renderBefore??e;let i=o._$litPart$;if(void 0===i){const t=n?.renderBefore??null;o._$litPart$=i=new ye(e.insertBefore(Jt(),t),t,void 0,n??{})}return i._$AI(t),i})(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return he}}Le._$litElement$=!0,Le.finalized=!0,Ae.litElementHydrateSupport?.({LitElement:Le});const Me=Ae.litElementPolyfillSupport;Me?.({LitElement:Le}),(Ae.litElementVersions??=[]).push("4.2.0");const Ee=t=>(e,n)=>{void 0!==n?n.addInitializer(()=>{customElements.define(t,e)}):customElements.define(t,e)},Te={attribute:!0,type:String,converter:R,reflect:!1,hasChanged:B},Ne=(t=Te,e,n)=>{const{kind:o,metadata:i}=n;let r=globalThis.litPropertyMetadata.get(i);if(void 0===r&&globalThis.litPropertyMetadata.set(i,r=new Map),"setter"===o&&((t=Object.create(t)).wrapped=!0),r.set(n.name,t),"accessor"===o){const{name:o}=n;return{set(n){const i=e.get.call(this);e.set.call(this,n),this.requestUpdate(o,i,t)},init(e){return void 0!==e&&this.C(o,void 0,t,e),e}}}if("setter"===o){const{name:o}=n;return function(n){const i=this[o];e.call(this,n),this.requestUpdate(o,i,t)}}throw Error("Unsupported decorator location: "+o)};function Ue(t){return(e,n)=>"object"==typeof n?Ne(t,e,n):((t,e,n)=>{const o=e.hasOwnProperty(n);return e.constructor.createProperty(n,t),o?Object.getOwnPropertyDescriptor(e,n):void 0})(t,e,n)}function Pe(t){return Ue({...t,state:!0,attribute:!1})}let Oe,He;class Re extends Le{updated(t){var e;if(super.updated(t),globalThis.document&&globalThis.document.documentElement.classList.contains("dark")&&null!=(e=this.shadowRoot)&&null!=(e=e.children)&&e.length)for(const t of this.shadowRoot.children)t.classList.contains("dark")||t.classList.add("dark")}_getBrandColorLuminance(){if(!globalThis.window)return 0;const t=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches;let e=window.getComputedStyle(this).getPropertyValue(t?"--bc-color-brand-dark":"--bc-color-brand")||window.getComputedStyle(this).getPropertyValue("--bc-color-brand")||"#196CE7";if(!e.match(/^#[0-9A-F]{6}$/i)){const t=document.createElement("div");t.style.color=e,t.style.display="none",document.body.appendChild(t),e=window.getComputedStyle(t).color,t.remove()}return function(t){if(t.startsWith("#"))return t=t.slice(1),(.299*parseInt(t.slice(0,2),16)+.587*parseInt(t.slice(2,4),16)+.114*parseInt(t.slice(4,6),16))/255;if(t.startsWith("rgb")||t.startsWith("rgba")){const e=t.match(/\d+(\.\d+)?/g);return(.299*parseFloat(e[0])+.587*parseFloat(e[1])+.114*parseFloat(e[2]))/255}throw new Error("Unsupported luminance: "+t)}(e)}}Re.styles=[St(Oe||(Oe=(t=>t)` :host { // global css reset in shadow DOM all: initial; font-variant-numeric: slashed-zero; } // TODO: move to individual components - only needed by a couple of icons .hover-animation:hover .hover-right-up { transform: translateX(2px) translateY(-2px); transition: all 0.3s; } .hover-animation:hover .hover-right { transform: translateX(3px); transition: all 0.3s; } `))];class Be extends Re{constructor(){super(),this._modalOpen=!1,this._connected=!1,this._connecting=!1,this._connectorName=void 0,this._appName=void 0,this._appIcon=void 0,this._filters=void 0,this._error=void 0,this._connected=C.getState().connected,this._connecting=C.getState().connecting,this._connectorName=C.getState().connectorName,this._appName=C.getState().bitcoinConnectConfig.appName,this._appIcon=C.getState().bitcoinConnectConfig.appIcon,this._filters=C.getState().bitcoinConnectConfig.filters,this._error=C.getState().error,this._route=C.getState().route,this._modalOpen=C.getState().modalOpen,C.subscribe(t=>{this._connected=t.connected,this._connecting=t.connecting,this._connectorName=t.connectorName,this._appName=t.bitcoinConnectConfig.appName,this._appIcon=t.bitcoinConnectConfig.appIcon,this._filters=t.bitcoinConnectConfig.filters,this._error=t.error,this._route=t.route,this._modalOpen=t.modalOpen})}}w([Pe()],Be.prototype,"_modalOpen",void 0),w([Pe()],Be.prototype,"_connected",void 0),w([Pe()],Be.prototype,"_connecting",void 0),w([Pe()],Be.prototype,"_connectorName",void 0),w([Pe()],Be.prototype,"_appName",void 0),w([Pe()],Be.prototype,"_appIcon",void 0),w([Pe()],Be.prototype,"_filters",void 0),w([Pe()],Be.prototype,"_error",void 0),w([Pe()],Be.prototype,"_route",void 0);const De=de(He||(He=(t=>t)` <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <path fill-rule="evenodd" clip-rule="evenodd" d="M15.4635 6.0794C17.4325 6.83684 18.8238 7.94315 18.5058 9.88813C18.3285 10.984 17.8283 11.6586 17.1374 12.0334C16.8767 12.1748 16.8191 12.6131 17.0507 12.7984C18.0431 13.592 18.4393 14.7164 17.8152 16.4238C16.9057 18.9138 14.8635 19.177 12.1521 18.6697C11.9858 18.6385 11.8223 18.7396 11.7792 18.9032L11.4563 20.1009C11.3343 20.5633 10.8605 20.8392 10.3981 20.7173C9.93541 20.5953 9.65932 20.1212 9.78149 19.6586L10.0909 18.5121C10.1354 18.3439 10.0349 18.1715 9.86676 18.1266C9.62998 18.0632 9.39019 17.9976 9.14679 17.9294C8.97646 17.8817 8.79964 17.9822 8.75452 18.1532L8.44373 19.3067C8.32182 19.7688 7.8483 20.0446 7.38616 19.9226C6.92422 19.8007 6.64851 19.3274 6.77026 18.8655L7.08988 17.677C7.13458 17.5073 7.03399 17.3333 6.86481 17.2869C6.81003 17.2718 6.75512 17.2567 6.70008 17.2415L6.69828 17.241C6.4604 17.1755 6.22001 17.1094 5.97667 17.0449L5.42127 16.8919C4.80739 16.7299 4.48576 16.0556 4.74625 15.4767C4.95488 15.013 5.47104 14.7734 5.96239 14.9043C5.97132 14.9067 5.98016 14.909 5.98891 14.9113C6.1066 14.9426 6.10094 14.9199 6.21958 14.8924C6.46112 14.8366 6.58893 14.6373 6.65055 14.4901L7.80952 10.0986L7.81254 10.0867L8.63176 6.98069C8.63683 6.96147 8.64021 6.94184 8.64116 6.92198C8.65547 6.62155 8.78957 6.31876 8.35166 6.11178C8.25682 6.06695 8.16354 6.02432 8.06217 5.99736C8.04539 5.9929 8.02808 5.98833 8.01032 5.98367C7.51444 5.85341 7.21198 5.34932 7.34263 4.85356C7.47162 4.36411 7.9731 4.07202 8.46248 4.2013L9.43668 4.47448C9.68634 4.54012 9.94146 4.60362 10.2006 4.66691C10.3681 4.70784 10.5375 4.60681 10.5815 4.44006L10.8668 3.39102C10.9889 2.9288 11.4625 2.65299 11.9247 2.77495C12.3871 2.89693 12.663 3.37062 12.541 3.83294L12.2715 4.82295C12.2273 4.99041 12.3292 5.16145 12.4975 5.20248C12.7444 5.26269 12.9911 5.32354 13.2353 5.38588C13.4 5.42795 13.5684 5.32988 13.6118 5.16547L13.8783 4.18608C14.0003 3.72357 14.4741 3.44751 14.9366 3.56948C15.3992 3.69145 15.6753 4.16533 15.5533 4.62789L15.2637 5.69461C15.2215 5.85461 15.3091 6.01999 15.4635 6.0794ZM11.2479 8.6805L11.4769 7.81121C11.5836 7.40644 11.9982 7.16477 12.403 7.27142C12.8077 7.37807 13.0494 7.79266 12.9428 8.19743L12.7137 9.06672L13.5829 9.29575C13.9877 9.4024 14.2294 9.81699 14.1227 10.2218C14.0161 10.6265 13.6015 10.8682 13.1967 10.7615L12.3275 10.5325L12.0984 11.4018C11.9918 11.8066 11.5772 12.0483 11.1724 11.9416C10.7676 11.835 10.5259 11.4204 10.6326 11.0156L10.8617 10.1463L9.99225 9.91722C9.58747 9.81056 9.34579 9.39598 9.45245 8.99121C9.5591 8.58644 9.9737 8.34477 10.3785 8.45142L11.2479 8.6805ZM13.2927 12.7001L13.0636 13.5693L12.1942 13.3403C11.7895 13.2336 11.3749 13.4753 11.2682 13.8801C11.1615 14.2848 11.4032 14.6994 11.808 14.8061L12.6774 15.0351L12.4484 15.9045C12.3417 16.3092 12.5834 16.7238 12.9882 16.8305C13.3929 16.9371 13.8075 16.6954 13.9142 16.2907L14.1432 15.4214L15.0125 15.6504C15.4172 15.757 15.8318 15.5154 15.9385 15.1106C16.0451 14.7058 15.8035 14.2912 15.3987 14.1846L14.5295 13.9556L14.7585 13.0863C14.8652 12.6815 14.6235 12.2669 14.2187 12.1603C13.8139 12.0536 13.3994 12.2953 13.2927 12.7001Z" fill="currentColor"/> </svg>`));function Ze(t){return[...t.v,(t.i?"!":"")+t.n].join(":")}function Fe(t,e=","){return t.map(Ze).join(e)}let ze="undefined"!=typeof CSS&&CSS.escape||(t=>t.replace(/[!"'`*+.,;:\\/<=>?@#$%&^|~()[\]{}]/g,"\\$&").replace(/^\d/,"\\3$& "));function je(t){for(var e=9,n=t.length;n--;)e=Math.imul(e^t.charCodeAt(n),1597334677);return"#"+((e^e>>>9)>>>0).toString(36)}function We(t,e="@media "){return e+Ie(t).map(t=>("string"==typeof t&&(t={min:t}),t.raw||Object.keys(t).map(e=>`(${e}-width:${t[e]})`).join(" and "))).join(",")}function Ie(t=[]){return Array.isArray(t)?t:null==t?[]:[t]}function Ve(t){return t}function Ge(){}let qe={d:0,b:134217728,c:268435456,a:671088640,u:805306368,o:939524096};function Ke(t){return t.match(/[-=:;]/g)?.length||0}function Ye(t){return Math.min(/(?:^|width[^\d]+)(\d+(?:.\d+)?)(p)?/.test(t)?Math.max(0,29.63*(+RegExp.$1/(RegExp.$2?15:1))**.137-43):0,15)<<22|Math.min(Ke(t),15)<<18}let Je=["rst-c","st-ch","h-chi","y-lin","nk","sited","ecked","pty","ad-on","cus-w","ver","cus","cus-v","tive","sable","tiona","quire"];function Qe({n:t,i:e,v:n=[]},o,i,r){t&&(t=Ze({n:t,i:e,v:n})),r=[...Ie(r)];for(let t of n){let e=o.theme("screens",t);for(let n of Ie(e&&We(e)||o.v(t)))r.push(n),i|=e?67108864|Ye(n):"dark"==t?1073741824:"@"==n[0]?Ye(n):1<<~(/:([a-z-]+)/.test(n)&&~Je.indexOf(RegExp.$1.slice(2,7))||-18)}return{n:t,p:i,r,i:e}}let Xe=new Map;function tn(t){if(t.d){let e=[],n=en(t.r.reduce((t,n)=>"@"==n[0]?(e.push(n),t):n?en(t,t=>en(n,e=>{let n=/(:merge\(.+?\))(:[a-z-]+|\\[.+])/.exec(e);if(n){let o=t.indexOf(n[1]);return~o?t.slice(0,o)+n[0]+t.slice(o+n[1].length):nn(t,e)}return nn(e,t)})):t,"&"),e=>nn(e,t.n?"."+ze(t.n):""));return n&&e.push(n.replace(/:merge\((.+?)\)/g,"$1")),e.reduceRight((t,e)=>e+"{"+t+"}",t.d)}}function en(t,e){return t.replace(/ *((?:\(.+?\)|\[.+?\]|[^,])+) *(,|$)/g,(t,n,o)=>e(n)+o)}function nn(t,e){return t.replace(/&/g,e)}let on=new Intl.Collator("en",{numeric:!0});function rn(t,e){for(var n=0,o=t.length;n<o;){let i=o+n>>1;0>=sn(t[i],e)?n=i+1:o=i}return o}function sn(t,e){let n=t.p&qe.o;return n!=(e.p&qe.o)||n!=qe.b&&n!=qe.o?t.p-e.p||t.o-e.o||on.compare(an(t.n),an(e.n))||on.compare(ln(t.n),ln(e.n)):0}function an(t){return(t||"").split(/:/).pop().split("/").pop()||"\0"}function ln(t){return(t||"").replace(/\W/g,t=>String.fromCharCode(127+t.charCodeAt(0)))+"\0"}function cn(t,e){return Math.round(parseInt(t,16)*e)}function dn(t,e={}){if("function"==typeof t)return t(e);let{opacityValue:n="1",opacityVariable:o}=e,i=o?`var(${o})`:n;if(t.includes("<alpha-value>"))return t.replace("<alpha-value>",i);if("#"==t[0]&&(4==t.length||7==t.length)){let e=(t.length-1)/3,n=[17,1,.062272][e-1];return`rgba(${[cn(t.substr(1,e),n),cn(t.substr(1+e,e),n),cn(t.substr(1+2*e,e),n),i]})`}return"1"==i?t:"0"==i?"#0000":t.replace(/^(rgb|hsl)(\([^)]+)\)$/,`$1a$2,${i})`)}function hn(t,e,n,o,i=[]){return function t(e,{n,p:o,r:i=[],i:r},s){let a=[],l="",c=0,d=0;for(let u in e||{}){var h,p;let f=e[u];if("@"==u[0]){if(!f)continue;if("a"==u[1]){a.push(...gn(n,o,yn(""+f),s,o,i,r,!0));continue}if("l"==u[1]){for(let e of Ie(f))a.push(...t(e,{n,p:(h=qe[u[7]],o&~qe.o|h),r:"d"==u[7]?[]:i,i:r},s));continue}if("i"==u[1]){a.push(...Ie(f).map(t=>({p:-1,o:0,r:[],d:u+" "+t})));continue}if("k"==u[1]){a.push({p:qe.d,o:0,r:[u],d:t(f,{p:qe.d},s).map(tn).join("")});continue}if("f"==u[1]){a.push(...Ie(f).map(e=>({p:qe.d,o:0,r:[u],d:t(e,{p:qe.d},s).map(tn).join("")})));continue}}if("object"!=typeof f||Array.isArray(f))"label"==u&&f?n=f+je(JSON.stringify([o,r,e])):(f||0===f)&&(u=u.replace(/[A-Z]/g,t=>"-"+t.toLowerCase()),d+=1,c=Math.max(c,"-"==(p=u)[0]?0:Ke(p)+(/^(?:(border-(?!w|c|sty)|[tlbr].{2,4}m?$|c.{7,8}$)|([fl].{5}l|g.{8}$|pl))/.test(p)?+!!RegExp.$1||-!!RegExp.$2:0)+1),l+=(l?";":"")+Ie(f).map(t=>s.s(u,pn(""+t,s.theme)+(r?" !important":""))).join(";"));else if("@"==u[0]||u.includes("&")){let e=o;"@"==u[0]&&(u=u.replace(/\bscreen\(([^)]+)\)/g,(t,n)=>{let o=s.theme("screens",n);return o?(e|=67108864,We(o,"")):t}),e|=Ye(u)),a.push(...t(f,{n,p:e,r:[...i,u],i:r},s))}else a.push(...t(f,{p:o,r:[...i,u]},s))}return a.unshift({n,p:o,o:Math.max(0,15-d)+1.5*Math.min(c||15,15),r:i,d:l}),a.sort(sn)}(t,Qe(e,n,o,i),n)}function pn(t,e){return t.replace(/theme\((["'`])?(.+?)\1(?:\s*,\s*(["'`])?(.+?)\3)?\)/g,(t,n,o,i,r="")=>{let s=e(o,r);return"function"==typeof s&&/color|fill|stroke/i.test(o)?dn(s):""+Ie(s).filter(t=>Object(t)!==t)})}function un(t,e){let n,o=[];for(let i of t)i.d&&i.n?n?.p==i.p&&""+n.r==""+i.r?(n.c=[n.c,i.c].filter(Boolean).join(" "),n.d=n.d+";"+i.d):o.push(n={...i,n:i.n&&e}):o.push({...i,n:i.n&&e});return o}function fn(t,e,n=qe.u,o,i){let r=[];for(let s of t)for(let t of function(t,e,n,o,i){let r=function(t,e){let n=Xe.get(t.n);return n?n(t,e):e.r(t.n,"dark"==t.v[0])}(t={...t,i:t.i||i},e);return r?"string"==typeof r?(({r:o,p:n}=Qe(t,e,n,o)),un(fn(yn(r),e,n,o,t.i),t.n)):Array.isArray(r)?r.map(t=>{var e,i;return{o:0,...t,r:[...Ie(o),...Ie(t.r)],p:(e=n,i=t.p??n,e&~qe.o|i)}}):hn(r,t,e,n,o):[{c:Ze(t),p:0,o:0,r:[]}]}(s,e,n,o,i))r.splice(rn(r,t),0,t);return r}function gn(t,e,n,o,i,r,s,a){return un((a?n.flatMap(t=>fn([t],o,i,r,s)):fn(n,o,i,r,s)).map(t=>t.p&qe.o&&(t.n||e==qe.b)?{...t,p:t.p&~qe.o|e,o:0}:t),t)}function mn(t,e,n,o){return Xe.set(t,(t,i)=>{let{n:r,p:s,r:a,i:l}=Qe(t,i,e);return n&&gn(r,e,n,i,s,a,l,o)}),t}function bn(t,e,n){if("("!=t[t.length-1]){let n=[],o=!1,i=!1,r="";for(let e of t)if("("!=e&&!/[~@]$/.test(e)){if("!"==e[0]&&(e=e.slice(1),o=!o),e.endsWith(":")){n["dark:"==e?"unshift":"push"](e.slice(0,-1));continue}"-"==e[0]&&(e=e.slice(1),i=!i),e.endsWith("-")&&(e=e.slice(0,-1)),e&&"&"!=e&&(r+=(r&&"-")+e)}r&&(i&&(r="-"+r),e[0].push({n:r,v:n.filter(Cn),i:o}))}}function Cn(t,e,n){return n.indexOf(t)==e}let wn=new Map;function yn(t){let e=wn.get(t);if(!e){let n=[],o=[[]],i=0,r=0,s=null,a=0,l=(e,r=0)=>{i!=a&&(n.push(t.slice(i,a+r)),e&&bn(n,o)),i=a+1};for(;a<t.length;a++){let e=t[a];if(r)"\\"!=t[a-1]&&(r+=+("["==e)||-("]"==e));else if("["==e)r+=1;else if(s)"\\"!=t[a-1]&&s.test(t.slice(a))&&(s=null,i=a+RegExp.lastMatch.length);else if("/"!=e||"\\"==t[a-1]||"*"!=t[a+1]&&"/"!=t[a+1])if("("==e)l(),n.push(e);else if(":"==e)":"!=t[a+1]&&l(!1,1);else if(/[\s,)]/.test(e)){l(!0);let t=n.lastIndexOf("(");if(")"==e){let e=n[t-1];if(/[~@]$/.test(e)){let i=o.shift();n.length=t,bn([...n,"#"],o);let{v:r}=o[0].pop();for(let t of i)t.v.splice(+("dark"==t.v[0])-+("dark"==r[0]),r.length);bn([...n,mn(e.length>1?e.slice(0,-1)+je(JSON.stringify([e,i])):e+"("+Fe(i)+")",qe.a,i,/@$/.test(e))],o)}t=n.lastIndexOf("(",t-1)}n.length=t+1}else/[~@]/.test(e)&&"("==t[a+1]&&o.unsh