UNPKG

@getalby/bitcoin-connect

Version:

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

1 lines 220 kB
import{webln as t,nwc as e,nwa as n}from"@getalby/sdk";import{createStore as r}from"zustand/vanilla";import{fiat as o,Invoice as i}from"@getalby/lightning-tools";import s from"qrcode-generator";function a(){return a=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},a.apply(this,arguments)}function l(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,c(t,e)}function c(t,e){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},c(t,e)}function d(t,e){return e||(e=t.slice(0)),t.raw=e,t}function u(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var h=/*#__PURE__*/function(){function t(t){this._config=t}return t.prototype.unload=function(){return Promise.resolve()},t}(),p=function(t){for(var e=[],n=0,r=atob(t.replace(/[ \r\n]+$/,""));n<r.length;++n){var o=r.charCodeAt(n).toString(16);1===o.length&&(o="0"+o),e[e.length]=o}return e.join("")};function f(t,e){try{var n=t()}catch(t){return e(t)}return n&&n.then?n.then(void 0,e):n}function m(t,e,n){if(!t.s){if(n instanceof g){if(!n.s)return void(n.o=m.bind(null,t,e));1&e&&(e=n.s),n=n.v}if(n&&n.then)return void n.then(m.bind(null,t,e),m.bind(null,t,2));t.s=e,t.v=n;var r=t.o;r&&r(t)}}var g=/*#__PURE__*/function(){function t(){}return t.prototype.then=function(e,n){var r=new t,o=this.s;if(o){var i=1&o?e:n;if(i){try{m(r,1,i(this.v))}catch(t){m(r,2,t)}return r}return this}return this.o=function(t){try{var o=t.v;1&t.s?m(r,1,e?e(o):o):n?m(r,1,n(o)):m(r,2,o)}catch(t){m(r,2,t)}},r},t}();function v(t){return t instanceof g&&1&t.s}var b,C=function(){try{return Promise.resolve(f(function(){return b||Promise.resolve(import("@lightninglabs/lnc-web")).then(function(t){return b=new(0,t.default)})},function(t){throw console.error(t),new Error("LNC is not available")}))}catch(t){return Promise.reject(t)}},y="ONLY CONNECT TO TRUSTED WEBSITES",w=/*#__PURE__*/function(t){function e(e){return t.call(this,e)||this}l(e,t);var n=e.prototype;return n.init=function(){return Promise.resolve(C()).then(function(){var t=new x(b),e=f(function(){var t=!b.credentials.pairingPhrase;return t?(console.log("Pairing phrase does not exist"),b.credentials.password=y):console.log("Pairing phrase set"),Promise.resolve(b.connect()).then(function(){t||(b.credentials.password=y);var e=function(t,e,n){for(var r;;){var o=t();if(v(o)&&(o=o.v),!o)return i;if(o.then){r=0;break}var i=n();if(i&&i.then){if(!v(i)){r=1;break}i=i.s}if(e){var s=e();if(s&&s.then&&!v(s)){r=2;break}}}var a=new g,l=m.bind(null,a,2);return(0===r?o.then(d):1===r?i.then(c):s.then(u)).then(void 0,l),a;function c(r){i=r;do{if(e&&(s=e())&&s.then&&!v(s))return void s.then(u).then(void 0,l);if(!(o=t())||v(o)&&!o.v)return void m(a,1,i);if(o.then)return void o.then(d).then(void 0,l);v(i=n())&&(i=i.v)}while(!i||!i.then);i.then(c).then(void 0,l)}function d(t){t?(i=n())&&i.then?i.then(c).then(void 0,l):c(i):m(a,1,i)}function u(){(o=t())?o.then?o.then(d).then(void 0,l):d(o):m(a,1,i)}}(function(){return!b.isConnected},void 0,function(){return console.log("Waiting to connect..."),Promise.resolve(new Promise(function(t){setTimeout(t,100)})).then(function(){})});if(e&&e.then)return e.then(function(){})})},function(t){throw console.error(t),b.disconnect(),b.credentials.clear(),t});return e&&e.then?e.then(function(e){return t}):t})},n.unload=function(){try{return b.disconnect(),b.credentials.clear(),Promise.resolve(t.prototype.unload.call(this)).then(function(){})}catch(t){return Promise.reject(t)}},e}(h),x=/*#__PURE__*/function(){function t(t){this.lnc=t}var e=t.prototype;return e.enable=function(){return Promise.resolve()},e.getInfo=function(){try{return Promise.resolve(b.lnd.lightning.getInfo()).then(function(t){return{methods:["enable","getBalance","getInfo","sendPayment"],version:"1.0",node:{alias:t.alias,pubkey:t.identityPubkey,color:t.color},supports:["lightning"]}})}catch(t){return Promise.reject(t)}},e.makeInvoice=function(t){throw new Error("Method not implemented.")},e.sendPayment=function(t){try{return Promise.resolve(b.lnd.lightning.sendPaymentSync({paymentRequest:t})).then(function(t){if(t.paymentError)throw new Error(t.paymentError);if(!t.paymentPreimage)throw new Error("No preimage in response");if("string"!=typeof t.paymentPreimage)throw new Error("expected preimage as string");return{preimage:p(t.paymentPreimage)}})}catch(t){return Promise.reject(t)}},e.getBalance=function(){try{return Promise.resolve(b.lnd.lightning.channelBalance()).then(function(t){var e;return{balance:parseInt((null==(e=t.localBalance)?void 0:e.sat)||"0")}})}catch(t){return Promise.reject(t)}},e.keysend=function(t){throw new Error("Method not implemented.")},e.lnurl=function(t){throw new Error("Method not implemented.")},e.lookupInvoice=function(t){throw new Error("Method not implemented.")},e.signMessage=function(t){throw new Error("Method not implemented.")},e.verifyMessage=function(t,e){throw new Error("Method not implemented.")},t}(),_=/*#__PURE__*/function(t){function e(e){return t.call(this,e)||this}return l(e,t),e.prototype.init=function(){try{var t=this;if(!t._config.lnbitsInstanceUrl)throw new Error("no lnbits URL provided");if(!t._config.lnbitsAdminKey)throw new Error("no lnbits admin key provided");return Promise.resolve(new $(t._config.lnbitsInstanceUrl,t._config.lnbitsAdminKey))}catch(t){return Promise.reject(t)}},e}(h),$=/*#__PURE__*/function(){function t(t,e){this._instanceUrl=t,this._adminKey=e}var e=t.prototype;return e.enable=function(){return Promise.resolve()},e.getInfo=function(){try{return Promise.resolve(this.requestLnbits("GET","/api/v1/wallet")).then(function(t){return{node:{alias:t.name,pubkey:""},methods:["getInfo","getBalance","sendPayment"],version:"1.0",supports:["lightning"]}})}catch(t){return Promise.reject(t)}},e.makeInvoice=function(t){try{return Promise.resolve(this.requestLnbits("POST","/api/v1/payments",{amount:t.amount||t.defaultAmount||+t,memo:t.defaultMemo,out:!1})).then(function(t){return{paymentRequest:t.payment_request}})}catch(t){return Promise.reject(t)}},e.sendPayment=function(t){try{var e=this;return Promise.resolve(e.requestLnbits("POST","/api/v1/payments",{bolt11:t,out:!0})).then(function(t){return Promise.resolve(e.requestLnbits("GET","/api/v1/payments/"+t.payment_hash)).then(function(t){if(!t.preimage)throw new Error("No preimage");return{preimage:t.preimage}})})}catch(t){return Promise.reject(t)}},e.getBalance=function(){try{return Promise.resolve(this.requestLnbits("GET","/api/v1/wallet")).then(function(t){return{balance:Math.floor(t.balance/1e3)}})}catch(t){return Promise.reject(t)}},e.keysend=function(t){throw new Error("Method not implemented.")},e.lnurl=function(t){throw new Error("Method not implemented.")},e.lookupInvoice=function(t){throw new Error("Method not implemented.")},e.signMessage=function(t){throw new Error("Method not implemented.")},e.verifyMessage=function(t,e){throw new Error("Method not implemented.")},e.requestLnbits=function(t,e,n){try{var r=null,o=new Headers;if(o.append("Accept","application/json"),o.append("Content-Type","application/json"),o.append("X-Api-Key",this._adminKey),"POST"===t)r=JSON.stringify(n);else if(void 0!==n)throw new Error("TODO: support args in GET");return Promise.resolve(fetch(this._instanceUrl+e+"",{method:t,headers:o,body:r})).then(function(t){function e(e){return Promise.resolve(t.json())}var n=function(){if(!t.ok)return Promise.resolve(t.json()).then(function(t){throw console.error("errBody",t),new Error(t.detail)})}();return n&&n.then?n.then(e):e()})}catch(t){return Promise.reject(t)}},t}(),k=/*#__PURE__*/function(t){function e(e){return t.call(this,e)||this}return l(e,t),e.prototype.init=function(){if(!window.webln)throw new Error("No WebLN provider available");return Promise.resolve(window.webln)},e}(h),S=/*#__PURE__*/function(e){function n(t){return e.call(this,t)||this}return l(n,e),n.prototype.init=function(){try{if(!this._config.nwcUrl)throw new Error("no nwc URL provided");return Promise.resolve(new t.NostrWebLNProvider({nostrWalletConnectUrl:this._config.nwcUrl}))}catch(t){return Promise.reject(t)}},n}(h),A={"extension.generic":k,"nwc.alby":S,"nwc.albyhub":S,"nwc.generic":S,"nwc.lnfi":S,"nwc.coinos":S,"nwc.flash":S,lnbits:_,lnc:w},M={showBalance:!0,appName:"Bitcoin Connect"};function L(t,e){try{var n=t()}catch(t){return e(t)}return n&&n.then?n.then(void 0,e):n}var E=r(function(t,e){return{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:M,info:void 0,connect:function(n,r){void 0===r&&(r={redirectTo:"/connected"});try{return t({connecting:!0,error:void 0}),Promise.resolve(L(function(){var o=new A[n.connectorType](n);return Promise.resolve(o.init()).then(function(i){return Promise.resolve(i.enable()).then(function(){function s(){e().connecting&&(t({connectorConfig:n,connector:o,connected:!0,connecting:!1,info:a,provider:i,connectorName:n.connectorName,route:r.redirectTo}),window.localStorage.setItem("bc:config",JSON.stringify(n)))}var a,l=L(function(){return Promise.resolve(i.getInfo()).then(function(t){a=t})},function(){console.error("Failed to request wallet info")});return l&&l.then?l.then(s):s()})})},function(n){console.error(n),t({error:n.toString(),connecting:!1}),e().disconnect()}))}catch(t){return Promise.reject(t)}},disconnect:function(){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:function(n){e().route!==n&&t({route:n,routeHistory:[].concat(e().routeHistory,[e().route])})},popRoute:function(){var n=e().routeHistory,r=n.pop()||"/start";t({route:r,routeHistory:n})},clearRouteHistory:function(){t({route:"/start",routeHistory:[]})},setModalOpen:function(e){t({modalOpen:e})},setBitcoinConnectConfig:function(e){t({bitcoinConnectConfig:a({},M,e)})},setError:function(e){t({error:e})},setCurrency:function(e){e?window.localStorage.setItem("bc:currency",e):window.localStorage.removeItem("bc:currency"),t({currency:e})},supports:function(t){var n=e(),r=n.info,o=n.provider;return!(null==r||!r.methods)&&r.methods.indexOf(t)>-1&&!(null==o||!o.getBalance)}}});function P(t,e,n,r){var o,i=arguments.length,s=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,n,r);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(i<3?o(s):i>3?o(e,n,s):o(e,n))||s);return i>3&&s&&Object.defineProperty(e,n,s),s}globalThis.window&&(function(){var t=window.localStorage.getItem("bc:config");if(t){var e=JSON.parse(t);E.getState().connect(e,{redirectTo:"/start"})}var n=window.localStorage.getItem("bc:currency");n&&E.getState().setCurrency(n)}(),window.addEventListener("webln:enabled",function(){E.getState().connecting||E.getState().connect({connectorName:"Extension",connectorType:"extension.generic"},{redirectTo:"/start"})})),"function"==typeof SuppressedError&&SuppressedError;const T=globalThis,N=T.ShadowRoot&&(void 0===T.ShadyCSS||T.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,U=Symbol(),O=new WeakMap;class H{constructor(t,e,n){if(this._$cssResult$=!0,n!==U)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(N&&void 0===t){const n=void 0!==e&&1===e.length;n&&(t=O.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),n&&O.set(e,t))}return t}toString(){return this.cssText}}const R=N?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const n of t.cssRules)e+=n.cssText;return(t=>new H("string"==typeof t?t:t+"",void 0,U))(e)})(t):t,{is:j,defineProperty:B,getOwnPropertyDescriptor:D,getOwnPropertyNames:Z,getOwnPropertySymbols:F,getPrototypeOf:z}=Object,W=globalThis,I=W.trustedTypes,V=I?I.emptyScript:"",G=W.reactiveElementPolyfillSupport,q=(t,e)=>t,K={toAttribute(t,e){switch(e){case Boolean:t=t?V: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}},Y=(t,e)=>!j(t,e),J={attribute:!0,type:String,converter:K,reflect:!1,useDefault:!1,hasChanged:Y};Symbol.metadata??=Symbol("metadata"),W.litPropertyMetadata??=new WeakMap;class Q 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=J){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(),r=this.getPropertyDescriptor(t,n,e);void 0!==r&&B(this.prototype,t,r)}}static getPropertyDescriptor(t,e,n){const{get:r,set:o}=D(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get:r,set(e){const i=r?.call(this);o?.call(this,e),this.requestUpdate(t,i,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??J}static _$Ei(){if(this.hasOwnProperty(q("elementProperties")))return;const t=z(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(q("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(q("properties"))){const t=this.properties,e=[...Z(t),...F(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(R(t))}else void 0!==t&&e.push(R(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(N)t.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const n of e){const e=document.createElement("style"),r=T.litNonce;void 0!==r&&e.setAttribute("nonce",r),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),r=this.constructor._$Eu(t,n);if(void 0!==r&&!0===n.reflect){const o=(void 0!==n.converter?.toAttribute?n.converter:K).toAttribute(e,n.type);this._$Em=t,null==o?this.removeAttribute(r):this.setAttribute(r,o),this._$Em=null}}_$AK(t,e){const n=this.constructor,r=n._$Eh.get(t);if(void 0!==r&&this._$Em!==r){const t=n.getPropertyOptions(r),o="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:K;this._$Em=r,this[r]=o.fromAttribute(e,t.type)??this._$Ej?.get(r)??null,this._$Em=null}}requestUpdate(t,e,n){if(void 0!==t){const r=this.constructor,o=this[t];if(n??=r.getPropertyOptions(t),!((n.hasChanged??Y)(o,e)||n.useDefault&&n.reflect&&o===this._$Ej?.get(t)&&!this.hasAttribute(r._$Eu(t,n))))return;this.C(t,e,n)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(t,e,{useDefault:n,reflect:r,wrapped:o},i){n&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,i??e??this[t]),!0!==o||void 0!==i)||(this._$AL.has(t)||(this.hasUpdated||n||(e=void 0),this._$AL.set(t,e)),!0===r&&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,r=this[e];!0!==t||this._$AL.has(e)||void 0===r||this.C(e,void 0,n,r)}}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){}}Q.elementStyles=[],Q.shadowRootOptions={mode:"open"},Q[q("elementProperties")]=new Map,Q[q("finalized")]=new Map,G?.({ReactiveElement:Q}),(W.reactiveElementVersions??=[]).push("2.1.0");const X=globalThis,tt=X.trustedTypes,et=tt?tt.createPolicy("lit-html",{createHTML:t=>t}):void 0,nt="$lit$",rt=`lit$${Math.random().toFixed(9).slice(2)}$`,ot="?"+rt,it=`<${ot}>`,st=document,at=()=>st.createComment(""),lt=t=>null===t||"object"!=typeof t&&"function"!=typeof t,ct=Array.isArray,dt="[ \t\n\f\r]",ut=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ht=/-->/g,pt=/>/g,ft=RegExp(`>|${dt}(?:([^\\s"'>=/]+)(${dt}*=${dt}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),mt=/'/g,gt=/"/g,vt=/^(?:script|style|textarea|title)$/i,bt=Symbol.for("lit-noChange"),Ct=Symbol.for("lit-nothing"),yt=new WeakMap,wt=st.createTreeWalker(st,129);function xt(t,e){if(!ct(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==et?et.createHTML(e):e}class _t{constructor({strings:t,_$litType$:e},n){let r;this.parts=[];let o=0,i=0;const s=t.length-1,a=this.parts,[l,c]=((t,e)=>{const n=t.length-1,r=[];let o,i=2===e?"<svg>":3===e?"<math>":"",s=ut;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===ut?"!--"===l[1]?s=ht:void 0!==l[1]?s=pt:void 0!==l[2]?(vt.test(l[2])&&(o=RegExp("</"+l[2],"g")),s=ft):void 0!==l[3]&&(s=ft):s===ft?">"===l[0]?(s=o??ut,c=-1):void 0===l[1]?c=-2:(c=s.lastIndex-l[2].length,a=l[1],s=void 0===l[3]?ft:'"'===l[3]?gt:mt):s===gt||s===mt?s=ft:s===ht||s===pt?s=ut:(s=ft,o=void 0);const u=s===ft&&t[e+1].startsWith("/>")?" ":"";i+=s===ut?n+it:c>=0?(r.push(a),n.slice(0,c)+nt+n.slice(c)+rt+u):n+rt+(-2===c?e:u)}return[xt(t,i+(t[n]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),r]})(t,e);if(this.el=_t.createElement(l,n),wt.currentNode=this.el.content,2===e||3===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(r=wt.nextNode())&&a.length<s;){if(1===r.nodeType){if(r.hasAttributes())for(const t of r.getAttributeNames())if(t.endsWith(nt)){const e=c[i++],n=r.getAttribute(t).split(rt),s=/([.?@])?(.*)/.exec(e);a.push({type:1,index:o,name:s[2],strings:n,ctor:"."===s[1]?Mt:"?"===s[1]?Lt:"@"===s[1]?Et:At}),r.removeAttribute(t)}else t.startsWith(rt)&&(a.push({type:6,index:o}),r.removeAttribute(t));if(vt.test(r.tagName)){const t=r.textContent.split(rt),e=t.length-1;if(e>0){r.textContent=tt?tt.emptyScript:"";for(let n=0;n<e;n++)r.append(t[n],at()),wt.nextNode(),a.push({type:2,index:++o});r.append(t[e],at())}}}else if(8===r.nodeType)if(r.data===ot)a.push({type:2,index:o});else{let t=-1;for(;-1!==(t=r.data.indexOf(rt,t+1));)a.push({type:7,index:o}),t+=rt.length-1}o++}}static createElement(t,e){const n=st.createElement("template");return n.innerHTML=t,n}}function $t(t,e,n=t,r){if(e===bt)return e;let o=void 0!==r?n._$Co?.[r]:n._$Cl;const i=lt(e)?void 0:e._$litDirective$;return o?.constructor!==i&&(o?._$AO?.(!1),void 0===i?o=void 0:(o=new i(t),o._$AT(t,n,r)),void 0!==r?(n._$Co??=[])[r]=o:n._$Cl=o),void 0!==o&&(e=$t(t,o._$AS(t,e.values),o,r)),e}class kt{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,r=(t?.creationScope??st).importNode(e,!0);wt.currentNode=r;let o=wt.nextNode(),i=0,s=0,a=n[0];for(;void 0!==a;){if(i===a.index){let e;2===a.type?e=new St(o,o.nextSibling,this,t):1===a.type?e=new a.ctor(o,a.name,a.strings,this,t):6===a.type&&(e=new Pt(o,this,t)),this._$AV.push(e),a=n[++s]}i!==a?.index&&(o=wt.nextNode(),i++)}return wt.currentNode=st,r}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 St{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,n,r){this.type=2,this._$AH=Ct,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=n,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=$t(this,t,e),lt(t)?t===Ct||null==t||""===t?(this._$AH!==Ct&&this._$AR(),this._$AH=Ct):t!==this._$AH&&t!==bt&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>ct(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!==Ct&&lt(this._$AH)?this._$AA.nextSibling.data=t:this.T(st.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:n}=t,r="number"==typeof n?this._$AC(t):(void 0===n.el&&(n.el=_t.createElement(xt(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===r)this._$AH.p(e);else{const t=new kt(r,this),n=t.u(this.options);t.p(e),this.T(n),this._$AH=t}}_$AC(t){let e=yt.get(t.strings);return void 0===e&&yt.set(t.strings,e=new _t(t)),e}k(t){ct(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let n,r=0;for(const o of t)r===e.length?e.push(n=new St(this.O(at()),this.O(at()),this,this.options)):n=e[r],n._$AI(o),r++;r<e.length&&(this._$AR(n&&n._$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 At{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,n,r,o){this.type=1,this._$AH=Ct,this._$AN=void 0,this.element=t,this.name=e,this._$AM=r,this.options=o,n.length>2||""!==n[0]||""!==n[1]?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=Ct}_$AI(t,e=this,n,r){const o=this.strings;let i=!1;if(void 0===o)t=$t(this,t,e,0),i=!lt(t)||t!==this._$AH&&t!==bt,i&&(this._$AH=t);else{const r=t;let s,a;for(t=o[0],s=0;s<o.length-1;s++)a=$t(this,r[n+s],e,s),a===bt&&(a=this._$AH[s]),i||=!lt(a)||a!==this._$AH[s],a===Ct?t=Ct:t!==Ct&&(t+=(a??"")+o[s+1]),this._$AH[s]=a}i&&!r&&this.j(t)}j(t){t===Ct?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class Mt extends At{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===Ct?void 0:t}}class Lt extends At{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==Ct)}}class Et extends At{constructor(t,e,n,r,o){super(t,e,n,r,o),this.type=5}_$AI(t,e=this){if((t=$t(this,t,e,0)??Ct)===bt)return;const n=this._$AH,r=t===Ct&&n!==Ct||t.capture!==n.capture||t.once!==n.once||t.passive!==n.passive,o=t!==Ct&&(n===Ct||r);r&&this.element.removeEventListener(this.name,this,n),o&&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 Pt{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){$t(this,t)}}const Tt=X.litHtmlPolyfillSupport;Tt?.(_t,St),(X.litHtmlVersions??=[]).push("3.3.0");const Nt=globalThis,Ut=Nt.ShadowRoot&&(void 0===Nt.ShadyCSS||Nt.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Ot=Symbol(),Ht=new WeakMap;class Rt{constructor(t,e,n){if(this._$cssResult$=!0,n!==Ot)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(Ut&&void 0===t){const n=void 0!==e&&1===e.length;n&&(t=Ht.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),n&&Ht.set(e,t))}return t}toString(){return this.cssText}}const jt=(t,...e)=>{const n=1===t.length?t[0]:e.reduce((e,n,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.")})(n)+t[r+1],t[0]);return new Rt(n,t,Ot)},Bt=Ut?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const n of t.cssRules)e+=n.cssText;return(t=>new Rt("string"==typeof t?t:t+"",void 0,Ot))(e)})(t):t,{is:Dt,defineProperty:Zt,getOwnPropertyDescriptor:Ft,getOwnPropertyNames:zt,getOwnPropertySymbols:Wt,getPrototypeOf:It}=Object,Vt=globalThis,Gt=Vt.trustedTypes,qt=Gt?Gt.emptyScript:"",Kt=Vt.reactiveElementPolyfillSupport,Yt=(t,e)=>t,Jt={toAttribute(t,e){switch(e){case Boolean:t=t?qt: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}},Qt=(t,e)=>!Dt(t,e),Xt={attribute:!0,type:String,converter:Jt,reflect:!1,useDefault:!1,hasChanged:Qt};Symbol.metadata??=Symbol("metadata"),Vt.litPropertyMetadata??=new WeakMap;class te 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=Xt){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(),r=this.getPropertyDescriptor(t,n,e);void 0!==r&&Zt(this.prototype,t,r)}}static getPropertyDescriptor(t,e,n){const{get:r,set:o}=Ft(this.prototype,t)??{get(){return this[e]},set(t){this[e]=t}};return{get:r,set(e){const i=r?.call(this);o?.call(this,e),this.requestUpdate(t,i,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Xt}static _$Ei(){if(this.hasOwnProperty(Yt("elementProperties")))return;const t=It(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(Yt("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Yt("properties"))){const t=this.properties,e=[...zt(t),...Wt(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(Bt(t))}else void 0!==t&&e.push(Bt(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(Ut)t.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const n of e){const e=document.createElement("style"),r=Nt.litNonce;void 0!==r&&e.setAttribute("nonce",r),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),r=this.constructor._$Eu(t,n);if(void 0!==r&&!0===n.reflect){const o=(void 0!==n.converter?.toAttribute?n.converter:Jt).toAttribute(e,n.type);this._$Em=t,null==o?this.removeAttribute(r):this.setAttribute(r,o),this._$Em=null}}_$AK(t,e){const n=this.constructor,r=n._$Eh.get(t);if(void 0!==r&&this._$Em!==r){const t=n.getPropertyOptions(r),o="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:Jt;this._$Em=r,this[r]=o.fromAttribute(e,t.type)??this._$Ej?.get(r)??null,this._$Em=null}}requestUpdate(t,e,n){if(void 0!==t){const r=this.constructor,o=this[t];if(n??=r.getPropertyOptions(t),!((n.hasChanged??Qt)(o,e)||n.useDefault&&n.reflect&&o===this._$Ej?.get(t)&&!this.hasAttribute(r._$Eu(t,n))))return;this.C(t,e,n)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(t,e,{useDefault:n,reflect:r,wrapped:o},i){n&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,i??e??this[t]),!0!==o||void 0!==i)||(this._$AL.has(t)||(this.hasUpdated||n||(e=void 0),this._$AL.set(t,e)),!0===r&&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,r=this[e];!0!==t||this._$AL.has(e)||void 0===r||this.C(e,void 0,n,r)}}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){}}te.elementStyles=[],te.shadowRootOptions={mode:"open"},te[Yt("elementProperties")]=new Map,te[Yt("finalized")]=new Map,Kt?.({ReactiveElement:te}),(Vt.reactiveElementVersions??=[]).push("2.1.0");const ee=globalThis,ne=ee.trustedTypes,re=ne?ne.createPolicy("lit-html",{createHTML:t=>t}):void 0,oe="$lit$",ie=`lit$${Math.random().toFixed(9).slice(2)}$`,se="?"+ie,ae=`<${se}>`,le=document,ce=()=>le.createComment(""),de=t=>null===t||"object"!=typeof t&&"function"!=typeof t,ue=Array.isArray,he="[ \t\n\f\r]",pe=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,fe=/-->/g,me=/>/g,ge=RegExp(`>|${he}(?:([^\\s"'>=/]+)(${he}*=${he}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),ve=/'/g,be=/"/g,Ce=/^(?:script|style|textarea|title)$/i,ye=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),we=ye(1),xe=ye(2),_e=Symbol.for("lit-noChange"),$e=Symbol.for("lit-nothing"),ke=new WeakMap,Se=le.createTreeWalker(le,129);function Ae(t,e){if(!ue(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==re?re.createHTML(e):e}const Me=(t,e)=>{const n=t.length-1,r=[];let o,i=2===e?"<svg>":3===e?"<math>":"",s=pe;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===pe?"!--"===l[1]?s=fe:void 0!==l[1]?s=me:void 0!==l[2]?(Ce.test(l[2])&&(o=RegExp("</"+l[2],"g")),s=ge):void 0!==l[3]&&(s=ge):s===ge?">"===l[0]?(s=o??pe,c=-1):void 0===l[1]?c=-2:(c=s.lastIndex-l[2].length,a=l[1],s=void 0===l[3]?ge:'"'===l[3]?be:ve):s===be||s===ve?s=ge:s===fe||s===me?s=pe:(s=ge,o=void 0);const u=s===ge&&t[e+1].startsWith("/>")?" ":"";i+=s===pe?n+ae:c>=0?(r.push(a),n.slice(0,c)+oe+n.slice(c)+ie+u):n+ie+(-2===c?e:u)}return[Ae(t,i+(t[n]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),r]};class Le{constructor({strings:t,_$litType$:e},n){let r;this.parts=[];let o=0,i=0;const s=t.length-1,a=this.parts,[l,c]=Me(t,e);if(this.el=Le.createElement(l,n),Se.currentNode=this.el.content,2===e||3===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(r=Se.nextNode())&&a.length<s;){if(1===r.nodeType){if(r.hasAttributes())for(const t of r.getAttributeNames())if(t.endsWith(oe)){const e=c[i++],n=r.getAttribute(t).split(ie),s=/([.?@])?(.*)/.exec(e);a.push({type:1,index:o,name:s[2],strings:n,ctor:"."===s[1]?Ue:"?"===s[1]?Oe:"@"===s[1]?He:Ne}),r.removeAttribute(t)}else t.startsWith(ie)&&(a.push({type:6,index:o}),r.removeAttribute(t));if(Ce.test(r.tagName)){const t=r.textContent.split(ie),e=t.length-1;if(e>0){r.textContent=ne?ne.emptyScript:"";for(let n=0;n<e;n++)r.append(t[n],ce()),Se.nextNode(),a.push({type:2,index:++o});r.append(t[e],ce())}}}else if(8===r.nodeType)if(r.data===se)a.push({type:2,index:o});else{let t=-1;for(;-1!==(t=r.data.indexOf(ie,t+1));)a.push({type:7,index:o}),t+=ie.length-1}o++}}static createElement(t,e){const n=le.createElement("template");return n.innerHTML=t,n}}function Ee(t,e,n=t,r){if(e===_e)return e;let o=void 0!==r?n._$Co?.[r]:n._$Cl;const i=de(e)?void 0:e._$litDirective$;return o?.constructor!==i&&(o?._$AO?.(!1),void 0===i?o=void 0:(o=new i(t),o._$AT(t,n,r)),void 0!==r?(n._$Co??=[])[r]=o:n._$Cl=o),void 0!==o&&(e=Ee(t,o._$AS(t,e.values),o,r)),e}class Pe{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,r=(t?.creationScope??le).importNode(e,!0);Se.currentNode=r;let o=Se.nextNode(),i=0,s=0,a=n[0];for(;void 0!==a;){if(i===a.index){let e;2===a.type?e=new Te(o,o.nextSibling,this,t):1===a.type?e=new a.ctor(o,a.name,a.strings,this,t):6===a.type&&(e=new Re(o,this,t)),this._$AV.push(e),a=n[++s]}i!==a?.index&&(o=Se.nextNode(),i++)}return Se.currentNode=le,r}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 Te{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,n,r){this.type=2,this._$AH=$e,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=n,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=Ee(this,t,e),de(t)?t===$e||null==t||""===t?(this._$AH!==$e&&this._$AR(),this._$AH=$e):t!==this._$AH&&t!==_e&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>ue(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!==$e&&de(this._$AH)?this._$AA.nextSibling.data=t:this.T(le.createTextNode(t)),this._$AH=t}$(t){const{values:e,_$litType$:n}=t,r="number"==typeof n?this._$AC(t):(void 0===n.el&&(n.el=Le.createElement(Ae(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===r)this._$AH.p(e);else{const t=new Pe(r,this),n=t.u(this.options);t.p(e),this.T(n),this._$AH=t}}_$AC(t){let e=ke.get(t.strings);return void 0===e&&ke.set(t.strings,e=new Le(t)),e}k(t){ue(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let n,r=0;for(const o of t)r===e.length?e.push(n=new Te(this.O(ce()),this.O(ce()),this,this.options)):n=e[r],n._$AI(o),r++;r<e.length&&(this._$AR(n&&n._$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 Ne{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,n,r,o){this.type=1,this._$AH=$e,this._$AN=void 0,this.element=t,this.name=e,this._$AM=r,this.options=o,n.length>2||""!==n[0]||""!==n[1]?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=$e}_$AI(t,e=this,n,r){const o=this.strings;let i=!1;if(void 0===o)t=Ee(this,t,e,0),i=!de(t)||t!==this._$AH&&t!==_e,i&&(this._$AH=t);else{const r=t;let s,a;for(t=o[0],s=0;s<o.length-1;s++)a=Ee(this,r[n+s],e,s),a===_e&&(a=this._$AH[s]),i||=!de(a)||a!==this._$AH[s],a===$e?t=$e:t!==$e&&(t+=(a??"")+o[s+1]),this._$AH[s]=a}i&&!r&&this.j(t)}j(t){t===$e?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class Ue extends Ne{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===$e?void 0:t}}class Oe extends Ne{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==$e)}}class He extends Ne{constructor(t,e,n,r,o){super(t,e,n,r,o),this.type=5}_$AI(t,e=this){if((t=Ee(this,t,e,0)??$e)===_e)return;const n=this._$AH,r=t===$e&&n!==$e||t.capture!==n.capture||t.once!==n.once||t.passive!==n.passive,o=t!==$e&&(n===$e||r);r&&this.element.removeEventListener(this.name,this,n),o&&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 Re{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){Ee(this,t)}}const je=ee.litHtmlPolyfillSupport;je?.(Le,Te),(ee.litHtmlVersions??=[]).push("3.3.0");const Be=globalThis;class De extends te{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 r=n?.renderBefore??e;let o=r._$litPart$;if(void 0===o){const t=n?.renderBefore??null;r._$litPart$=o=new Te(e.insertBefore(ce(),t),t,void 0,n??{})}return o._$AI(t),o})(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return _e}}De._$litElement$=!0,De.finalized=!0,Be.litElementHydrateSupport?.({LitElement:De});const Ze=Be.litElementPolyfillSupport;Ze?.({LitElement:De}),(Be.litElementVersions??=[]).push("4.2.0");const Fe=t=>(e,n)=>{void 0!==n?n.addInitializer(()=>{customElements.define(t,e)}):customElements.define(t,e)},ze={attribute:!0,type:String,converter:K,reflect:!1,hasChanged:Y},We=(t=ze,e,n)=>{const{kind:r,metadata:o}=n;let i=globalThis.litPropertyMetadata.get(o);if(void 0===i&&globalThis.litPropertyMetadata.set(o,i=new Map),"setter"===r&&((t=Object.create(t)).wrapped=!0),i.set(n.name,t),"accessor"===r){const{name:r}=n;return{set(n){const o=e.get.call(this);e.set.call(this,n),this.requestUpdate(r,o,t)},init(e){return void 0!==e&&this.C(r,void 0,t,e),e}}}if("setter"===r){const{name:r}=n;return function(n){const o=this[r];e.call(this,n),this.requestUpdate(r,o,t)}}throw Error("Unsupported decorator location: "+r)};function Ie(t){return(e,n)=>"object"==typeof n?We(t,e,n):((t,e,n)=>{const r=e.hasOwnProperty(n);return e.constructor.createProperty(n,t),r?Object.getOwnPropertyDescriptor(e,n):void 0})(t,e,n)}function Ve(t){return Ie({...t,state:!0,attribute:!1})}var Ge,qe=/*#__PURE__*/function(t){function e(){return t.apply(this,arguments)||this}l(e,t);var n=e.prototype;return n.updated=function(e){var n;if(t.prototype.updated.call(this,e),globalThis.document&&globalThis.document.documentElement.classList.contains("dark")&&null!=(n=this.shadowRoot)&&null!=(n=n.children)&&n.length)for(var r,o=function(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(n)return(n=n.call(t)).next.bind(n);if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return u(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(t,e):void 0}}(t))){n&&(t=n);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(this.shadowRoot.children);!(r=o()).done;){var i=r.value;i.classList.contains("dark")||i.classList.add("dark")}},n._getBrandColorLuminance=function(){if(!globalThis.window)return 0;var t=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches,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)){var n=document.createElement("div");n.style.color=e,n.style.display="none",document.body.appendChild(n),e=window.getComputedStyle(n).color,n.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")){var 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)},e}(De);qe.styles=[jt(Ge||(Ge=d(["\n :host {\n // global css reset in shadow DOM\n all: initial;\n font-variant-numeric: slashed-zero;\n }\n // TODO: move to individual components - only needed by a couple of icons\n .hover-animation:hover .hover-right-up {\n transform: translateX(2px) translateY(-2px);\n transition: all 0.3s;\n }\n .hover-animation:hover .hover-right {\n transform: translateX(3px);\n transition: all 0.3s;\n }\n "])))];var Ke,Ye=/*#__PURE__*/function(t){function e(){var e;return(e=t.call(this)||this)._modalOpen=!1,e._connected=!1,e._connecting=!1,e._connectorName=void 0,e._appName=void 0,e._appIcon=void 0,e._filters=void 0,e._error=void 0,e._connected=E.getState().connected,e._connecting=E.getState().connecting,e._connectorName=E.getState().connectorName,e._appName=E.getState().bitcoinConnectConfig.appName,e._appIcon=E.getState().bitcoinConnectConfig.appIcon,e._filters=E.getState().bitcoinConnectConfig.filters,e._error=E.getState().error,e._route=E.getState().route,e._modalOpen=E.getState().modalOpen,E.subscribe(function(t){e._connected=t.connected,e._connecting=t.connecting,e._connectorName=t.connectorName,e._appName=t.bitcoinConnectConfig.appName,e._appIcon=t.bitcoinConnectConfig.appIcon,e._filters=t.bitcoinConnectConfig.filters,e._error=t.error,e._route=t.route,e._modalOpen=t.modalOpen}),e}return l(e,t),e}(qe);P([Ve()],Ye.prototype,"_modalOpen",void 0),P([Ve()],Ye.prototype,"_connected",void 0),P([Ve()],Ye.prototype,"_connecting",void 0),P([Ve()],Ye.prototype,"_connectorName",void 0),P([Ve()],Ye.prototype,"_appName",void 0),P([Ve()],Ye.prototype,"_appIcon",void 0),P([Ve()],Ye.prototype,"_filters",void 0),P([Ve()],Ye.prototype,"_error",void 0),P([Ve()],Ye.prototype,"_route",void 0);var Je=xe(Ke||(Ke=d(['\n<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n<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"/>\n</svg>'])));function Qe(t){return[...t.v,(t.i?"!":"")+t.n].join(":")}function Xe(t,e=","){return t.map(Qe).join(e)}let tn="undefined"!=typeof CSS&&CSS.escape||(t=>t.replace(/[!"'`*+.,;:\\/<=>?@#$%&^|~()[\]{}]/g,"\\$&").replace(/^\d/,"\\3$& "));function en(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 nn(t,e="@media "){return e+rn(t).map(t=>("string"==typeof t&&(t={min:t}),t.raw||Object.keys(t).map(e=>`(${e}-width:${t[e]})`).join(" and "))).join(",")}function rn(t=[]){return Array.isArray(t)?t:null==t?[]:[t]}function on(t){return t}function sn(){}let an={d:0,b:134217728,c:268435456,a:671088640,u:805306368,o:939524096};function ln(t){return t.match(/[-=:;]/g)?.length||0}function cn(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(ln(t),15)<<18}let dn=["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 un({n:t,i:e,v:n=[]},r,o,i){t&&(t=Qe({n:t,i:e,v:n})),i=[...rn(i)];for(let t of n){let e=r.theme("screens",t);for(let n of rn(e&&nn(e)||r.v(t)))i.push(n),o|=e?67108864|cn(n):"dark"==t?1073741824:"@"==n[0]?cn(n):1<<~(/:([a-z-]+)/.test(n)&&~dn.indexOf(RegExp.$1.slice(2,7))||-18)}return{n:t,p:o,r:i,i:e}}let hn=new Map;function pn(t){if(t.d){let e=[],n=fn(t.r.reduce((t,n)=>"@"==n[0]?(e.push(n),t):n?fn(t,t=>fn(n,e=>{let n=/(:merge\(.+?\))(:[a-z-]+|\\[.+])/.exec(e);if(n){let r=t.indexOf(n[1]);return~r?t.slice(0,r)+n[0]+t.slice(r+n[1].length):mn(t,e)}return mn(e,t)})):t,"&"),e=>mn(e,t.n?"."+tn(t.n):""));return n&&e.push(n