UNPKG

@getalby/bitcoin-connect

Version:

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

1 lines 270 kB
var t=require("@getalby/sdk"),e=require("zustand/vanilla"),n=require("@getalby/lightning-tools");function r(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}function o(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach(function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}}),e.default=t,e}var i=/*#__PURE__*/r(require("qrcode-generator"));function s(){return s=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},s.apply(this,arguments)}function a(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,l(t,e)}function l(t,e){return l=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},l(t,e)}function c(t,e){return e||(e=t.slice(0)),t.raw=e,t}function d(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 u=/*#__PURE__*/function(){function t(t){this._config=t}return t.prototype.unload=function(){return Promise.resolve()},t}(),h=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 p(t,e){try{var n=t()}catch(t){return e(t)}return n&&n.then?n.then(void 0,e):n}function f(t,e,n){if(!t.s){if(n instanceof g){if(!n.s)return void(n.o=f.bind(null,t,e));1&e&&(e=n.s),n=n.v}if(n&&n.then)return void n.then(f.bind(null,t,e),f.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{f(r,1,i(this.v))}catch(t){f(r,2,t)}return r}return this}return this.o=function(t){try{var o=t.v;1&t.s?f(r,1,e?e(o):o):n?f(r,1,n(o)):f(r,2,o)}catch(t){f(r,2,t)}},r},t}();function m(t){return t instanceof g&&1&t.s}var C,b=function(){try{return Promise.resolve(p(function(){return C||Promise.resolve(Promise.resolve().then(function(){/*#__PURE__*/return o(require("@lightninglabs/lnc-web"))})).then(function(t){return C=new(0,t.default)})},function(t){throw console.error(t),new Error("LNC is not available")}))}catch(t){return Promise.reject(t)}},v="ONLY CONNECT TO TRUSTED WEBSITES",w=/*#__PURE__*/function(t){function e(e){return t.call(this,e)||this}a(e,t);var n=e.prototype;return n.init=function(){return Promise.resolve(b()).then(function(){var t=new y(C),e=p(function(){var t=!C.credentials.pairingPhrase;return t?(console.log("Pairing phrase does not exist"),C.credentials.password=v):console.log("Pairing phrase set"),Promise.resolve(C.connect()).then(function(){t||(C.credentials.password=v);var e=function(t,e,n){for(var r;;){var o=t();if(m(o)&&(o=o.v),!o)return i;if(o.then){r=0;break}var i=n();if(i&&i.then){if(!m(i)){r=1;break}i=i.s}if(e){var s=e();if(s&&s.then&&!m(s)){r=2;break}}}var a=new g,l=f.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&&!m(s))return void s.then(u).then(void 0,l);if(!(o=t())||m(o)&&!o.v)return void f(a,1,i);if(o.then)return void o.then(d).then(void 0,l);m(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):f(a,1,i)}function u(){(o=t())?o.then?o.then(d).then(void 0,l):d(o):f(a,1,i)}}(function(){return!C.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),C.disconnect(),C.credentials.clear(),t});return e&&e.then?e.then(function(e){return t}):t})},n.unload=function(){try{return C.disconnect(),C.credentials.clear(),Promise.resolve(t.prototype.unload.call(this)).then(function(){})}catch(t){return Promise.reject(t)}},e}(u),y=/*#__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(C.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(C.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:h(t.paymentPreimage)}})}catch(t){return Promise.reject(t)}},e.getBalance=function(){try{return Promise.resolve(C.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}(),x=/*#__PURE__*/function(t){function e(e){return t.call(this,e)||this}return a(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 A(t._config.lnbitsInstanceUrl,t._config.lnbitsAdminKey))}catch(t){return Promise.reject(t)}},e}(u),A=/*#__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}(),S=/*#__PURE__*/function(t){function e(e){return t.call(this,e)||this}return a(e,t),e.prototype.init=function(){if(!window.webln)throw new Error("No WebLN provider available");return Promise.resolve(window.webln)},e}(u),k=/*#__PURE__*/function(e){function n(t){return e.call(this,t)||this}return a(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}(u),L={"extension.generic":S,"nwc.alby":k,"nwc.albyhub":k,"nwc.generic":k,"nwc.lnfi":k,"nwc.coinos":k,"nwc.flash":k,"nwc.cashume":k,"nwc.lnbits":k,"nwc.rizful":k,lnbits:x,lnc:w},M={showBalance:!0,appName:"Bitcoin Connect",persistConnection:!0};function E(t,e){try{var n=t()}catch(t){return e(t)}return n&&n.then?n.then(void 0,e):n}var P=e.createStore(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,connectNWC:function(t){return e().connect({connectorName:"NWC",connectorType:"nwc.generic",nwcUrl:t})},connect:function(n,r){void 0===r&&(r={redirectTo:"/connected"});try{return t({connecting:!0,error:void 0}),Promise.resolve(E(function(){var o=new L[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}),!1!==e().bitcoinConnectConfig.persistConnection&&window.localStorage.setItem("bc:config",JSON.stringify(n)))}var a,l=E(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(n){t({bitcoinConnectConfig:s({},M,n)});var r=e();!1===r.bitcoinConnectConfig.autoConnect||r.connected||r.connecting||function(){try{var t=window.location.hash;if(t){var e=t.indexOf("?"),n=t.slice(e>0?e:1),r=new URLSearchParams(n),o=r.get("nwc");if(o&&o.startsWith("nostr+walletconnect://")){var i=new URL(o).searchParams;i.get("relay")&&i.get("secret")&&(r.delete("nwc"),window.location.hash=t.slice(0,e>0?e+1:1)+r.toString(),P.getState().connectNWC(o))}}}catch(t){console.error(t)}}()},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 _(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);P.getState().connect(e,{redirectTo:"/start"})}var n=window.localStorage.getItem("bc:currency");n&&P.getState().setCurrency(n)}(),window.addEventListener("webln:enabled",function(){P.getState().connecting||P.getState().connect({connectorName:"Extension",connectorType:"extension.generic"},{redirectTo:"/start"})})),"function"==typeof SuppressedError&&SuppressedError;const N=globalThis,T=N.ShadowRoot&&(void 0===N.ShadyCSS||N.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,B=Symbol(),Z=new WeakMap;class U{constructor(t,e,n){if(this._$cssResult$=!0,n!==B)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(T&&void 0===t){const n=void 0!==e&&1===e.length;n&&(t=Z.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),n&&Z.set(e,t))}return t}toString(){return this.cssText}}const O=T?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const n of t.cssRules)e+=n.cssText;return(t=>new U("string"==typeof t?t:t+"",void 0,B))(e)})(t):t,{is:R,defineProperty:j,getOwnPropertyDescriptor:H,getOwnPropertyNames:I,getOwnPropertySymbols:W,getPrototypeOf:F}=Object,G=globalThis,D=G.trustedTypes,V=D?D.emptyScript:"",z=G.reactiveElementPolyfillSupport,Q=(t,e)=>t,J={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)=>!R(t,e),$={attribute:!0,type:String,converter:J,reflect:!1,useDefault:!1,hasChanged:Y};Symbol.metadata??=Symbol("metadata"),G.litPropertyMetadata??=new WeakMap;class K 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=$){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&&j(this.prototype,t,r)}}static getPropertyDescriptor(t,e,n){const{get:r,set:o}=H(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)??$}static _$Ei(){if(this.hasOwnProperty(Q("elementProperties")))return;const t=F(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=[...I(t),...W(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(O(t))}else void 0!==t&&e.push(O(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(T)t.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const n of e){const e=document.createElement("style"),r=N.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:J).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:J;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){}}K.elementStyles=[],K.shadowRootOptions={mode:"open"},K[Q("elementProperties")]=new Map,K[Q("finalized")]=new Map,z?.({ReactiveElement:K}),(G.reactiveElementVersions??=[]).push("2.1.0");const q=globalThis,X=q.trustedTypes,tt=X?X.createPolicy("lit-html",{createHTML:t=>t}):void 0,et="$lit$",nt=`lit$${Math.random().toFixed(9).slice(2)}$`,rt="?"+nt,ot=`<${rt}>`,it=document,st=()=>it.createComment(""),at=t=>null===t||"object"!=typeof t&&"function"!=typeof t,lt=Array.isArray,ct="[ \t\n\f\r]",dt=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ut=/-->/g,ht=/>/g,pt=RegExp(`>|${ct}(?:([^\\s"'>=/]+)(${ct}*=${ct}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),ft=/'/g,gt=/"/g,mt=/^(?:script|style|textarea|title)$/i,Ct=Symbol.for("lit-noChange"),bt=Symbol.for("lit-nothing"),vt=new WeakMap,wt=it.createTreeWalker(it,129);function yt(t,e){if(!lt(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==tt?tt.createHTML(e):e}class xt{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=dt;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===dt?"!--"===l[1]?s=ut:void 0!==l[1]?s=ht:void 0!==l[2]?(mt.test(l[2])&&(o=RegExp("</"+l[2],"g")),s=pt):void 0!==l[3]&&(s=pt):s===pt?">"===l[0]?(s=o??dt,c=-1):void 0===l[1]?c=-2:(c=s.lastIndex-l[2].length,a=l[1],s=void 0===l[3]?pt:'"'===l[3]?gt:ft):s===gt||s===ft?s=pt:s===ut||s===ht?s=dt:(s=pt,o=void 0);const u=s===pt&&t[e+1].startsWith("/>")?" ":"";i+=s===dt?n+ot:c>=0?(r.push(a),n.slice(0,c)+et+n.slice(c)+nt+u):n+nt+(-2===c?e:u)}return[yt(t,i+(t[n]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),r]})(t,e);if(this.el=xt.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(et)){const e=c[i++],n=r.getAttribute(t).split(nt),s=/([.?@])?(.*)/.exec(e);a.push({type:1,index:o,name:s[2],strings:n,ctor:"."===s[1]?Mt:"?"===s[1]?Et:"@"===s[1]?Pt:Lt}),r.removeAttribute(t)}else t.startsWith(nt)&&(a.push({type:6,index:o}),r.removeAttribute(t));if(mt.test(r.tagName)){const t=r.textContent.split(nt),e=t.length-1;if(e>0){r.textContent=X?X.emptyScript:"";for(let n=0;n<e;n++)r.append(t[n],st()),wt.nextNode(),a.push({type:2,index:++o});r.append(t[e],st())}}}else if(8===r.nodeType)if(r.data===rt)a.push({type:2,index:o});else{let t=-1;for(;-1!==(t=r.data.indexOf(nt,t+1));)a.push({type:7,index:o}),t+=nt.length-1}o++}}static createElement(t,e){const n=it.createElement("template");return n.innerHTML=t,n}}function At(t,e,n=t,r){if(e===Ct)return e;let o=void 0!==r?n._$Co?.[r]:n._$Cl;const i=at(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=At(t,o._$AS(t,e.values),o,r)),e}class St{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??it).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 kt(o,o.nextSibling,this,t):1===a.type?e=new a.ctor(o,a.name,a.strings,this,t):6===a.type&&(e=new _t(o,this,t)),this._$AV.push(e),a=n[++s]}i!==a?.index&&(o=wt.nextNode(),i++)}return wt.currentNode=it,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 kt{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,n,r){this.type=2,this._$AH=bt,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=At(this,t,e),at(t)?t===bt||null==t||""===t?(this._$AH!==bt&&this._$AR(),this._$AH=bt):t!==this._$AH&&t!==Ct&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>lt(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!==bt&&at(this._$AH)?this._$AA.nextSibling.data=t:this.T(it.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=xt.createElement(yt(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===r)this._$AH.p(e);else{const t=new St(r,this),n=t.u(this.options);t.p(e),this.T(n),this._$AH=t}}_$AC(t){let e=vt.get(t.strings);return void 0===e&&vt.set(t.strings,e=new xt(t)),e}k(t){lt(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 kt(this.O(st()),this.O(st()),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 Lt{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,n,r,o){this.type=1,this._$AH=bt,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=bt}_$AI(t,e=this,n,r){const o=this.strings;let i=!1;if(void 0===o)t=At(this,t,e,0),i=!at(t)||t!==this._$AH&&t!==Ct,i&&(this._$AH=t);else{const r=t;let s,a;for(t=o[0],s=0;s<o.length-1;s++)a=At(this,r[n+s],e,s),a===Ct&&(a=this._$AH[s]),i||=!at(a)||a!==this._$AH[s],a===bt?t=bt:t!==bt&&(t+=(a??"")+o[s+1]),this._$AH[s]=a}i&&!r&&this.j(t)}j(t){t===bt?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class Mt extends Lt{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===bt?void 0:t}}class Et extends Lt{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==bt)}}class Pt extends Lt{constructor(t,e,n,r,o){super(t,e,n,r,o),this.type=5}_$AI(t,e=this){if((t=At(this,t,e,0)??bt)===Ct)return;const n=this._$AH,r=t===bt&&n!==bt||t.capture!==n.capture||t.once!==n.once||t.passive!==n.passive,o=t!==bt&&(n===bt||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 _t{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){At(this,t)}}const Nt=q.litHtmlPolyfillSupport;Nt?.(xt,kt),(q.litHtmlVersions??=[]).push("3.3.0");const Tt=globalThis,Bt=Tt.ShadowRoot&&(void 0===Tt.ShadyCSS||Tt.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,Zt=Symbol(),Ut=new WeakMap;class Ot{constructor(t,e,n){if(this._$cssResult$=!0,n!==Zt)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(Bt&&void 0===t){const n=void 0!==e&&1===e.length;n&&(t=Ut.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),n&&Ut.set(e,t))}return t}toString(){return this.cssText}}const Rt=(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 Ot(n,t,Zt)},jt=Bt?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const n of t.cssRules)e+=n.cssText;return(t=>new Ot("string"==typeof t?t:t+"",void 0,Zt))(e)})(t):t,{is:Ht,defineProperty:It,getOwnPropertyDescriptor:Wt,getOwnPropertyNames:Ft,getOwnPropertySymbols:Gt,getPrototypeOf:Dt}=Object,Vt=globalThis,zt=Vt.trustedTypes,Qt=zt?zt.emptyScript:"",Jt=Vt.reactiveElementPolyfillSupport,Yt=(t,e)=>t,$t={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}},Kt=(t,e)=>!Ht(t,e),qt={attribute:!0,type:String,converter:$t,reflect:!1,useDefault:!1,hasChanged:Kt};Symbol.metadata??=Symbol("metadata"),Vt.litPropertyMetadata??=new WeakMap;class Xt 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=qt){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&&It(this.prototype,t,r)}}static getPropertyDescriptor(t,e,n){const{get:r,set:o}=Wt(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)??qt}static _$Ei(){if(this.hasOwnProperty(Yt("elementProperties")))return;const t=Dt(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=[...Ft(t),...Gt(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(jt(t))}else void 0!==t&&e.push(jt(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(Bt)t.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const n of e){const e=document.createElement("style"),r=Tt.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:$t).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:$t;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??Kt)(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){}}Xt.elementStyles=[],Xt.shadowRootOptions={mode:"open"},Xt[Yt("elementProperties")]=new Map,Xt[Yt("finalized")]=new Map,Jt?.({ReactiveElement:Xt}),(Vt.reactiveElementVersions??=[]).push("2.1.0");const te=globalThis,ee=te.trustedTypes,ne=ee?ee.createPolicy("lit-html",{createHTML:t=>t}):void 0,re="$lit$",oe=`lit$${Math.random().toFixed(9).slice(2)}$`,ie="?"+oe,se=`<${ie}>`,ae=document,le=()=>ae.createComment(""),ce=t=>null===t||"object"!=typeof t&&"function"!=typeof t,de=Array.isArray,ue="[ \t\n\f\r]",he=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,pe=/-->/g,fe=/>/g,ge=RegExp(`>|${ue}(?:([^\\s"'>=/]+)(${ue}*=${ue}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),me=/'/g,Ce=/"/g,be=/^(?:script|style|textarea|title)$/i,ve=t=>(e,...n)=>({_$litType$:t,strings:e,values:n}),we=ve(1),ye=ve(2),xe=Symbol.for("lit-noChange"),Ae=Symbol.for("lit-nothing"),Se=new WeakMap,ke=ae.createTreeWalker(ae,129);function Le(t,e){if(!de(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==ne?ne.createHTML(e):e}const Me=(t,e)=>{const n=t.length-1,r=[];let o,i=2===e?"<svg>":3===e?"<math>":"",s=he;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===he?"!--"===l[1]?s=pe:void 0!==l[1]?s=fe:void 0!==l[2]?(be.test(l[2])&&(o=RegExp("</"+l[2],"g")),s=ge):void 0!==l[3]&&(s=ge):s===ge?">"===l[0]?(s=o??he,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]?Ce:me):s===Ce||s===me?s=ge:s===pe||s===fe?s=he:(s=ge,o=void 0);const u=s===ge&&t[e+1].startsWith("/>")?" ":"";i+=s===he?n+se:c>=0?(r.push(a),n.slice(0,c)+re+n.slice(c)+oe+u):n+oe+(-2===c?e:u)}return[Le(t,i+(t[n]||"<?>")+(2===e?"</svg>":3===e?"</math>":"")),r]};class Ee{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=Ee.createElement(l,n),ke.currentNode=this.el.content,2===e||3===e){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes)}for(;null!==(r=ke.nextNode())&&a.length<s;){if(1===r.nodeType){if(r.hasAttributes())for(const t of r.getAttributeNames())if(t.endsWith(re)){const e=c[i++],n=r.getAttribute(t).split(oe),s=/([.?@])?(.*)/.exec(e);a.push({type:1,index:o,name:s[2],strings:n,ctor:"."===s[1]?Be:"?"===s[1]?Ze:"@"===s[1]?Ue:Te}),r.removeAttribute(t)}else t.startsWith(oe)&&(a.push({type:6,index:o}),r.removeAttribute(t));if(be.test(r.tagName)){const t=r.textContent.split(oe),e=t.length-1;if(e>0){r.textContent=ee?ee.emptyScript:"";for(let n=0;n<e;n++)r.append(t[n],le()),ke.nextNode(),a.push({type:2,index:++o});r.append(t[e],le())}}}else if(8===r.nodeType)if(r.data===ie)a.push({type:2,index:o});else{let t=-1;for(;-1!==(t=r.data.indexOf(oe,t+1));)a.push({type:7,index:o}),t+=oe.length-1}o++}}static createElement(t,e){const n=ae.createElement("template");return n.innerHTML=t,n}}function Pe(t,e,n=t,r){if(e===xe)return e;let o=void 0!==r?n._$Co?.[r]:n._$Cl;const i=ce(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=Pe(t,o._$AS(t,e.values),o,r)),e}class _e{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??ae).importNode(e,!0);ke.currentNode=r;let o=ke.nextNode(),i=0,s=0,a=n[0];for(;void 0!==a;){if(i===a.index){let e;2===a.type?e=new Ne(o,o.nextSibling,this,t):1===a.type?e=new a.ctor(o,a.name,a.strings,this,t):6===a.type&&(e=new Oe(o,this,t)),this._$AV.push(e),a=n[++s]}i!==a?.index&&(o=ke.nextNode(),i++)}return ke.currentNode=ae,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 Ne{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,n,r){this.type=2,this._$AH=Ae,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=Pe(this,t,e),ce(t)?t===Ae||null==t||""===t?(this._$AH!==Ae&&this._$AR(),this._$AH=Ae):t!==this._$AH&&t!==xe&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>de(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!==Ae&&ce(this._$AH)?this._$AA.nextSibling.data=t:this.T(ae.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=Ee.createElement(Le(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===r)this._$AH.p(e);else{const t=new _e(r,this),n=t.u(this.options);t.p(e),this.T(n),this._$AH=t}}_$AC(t){let e=Se.get(t.strings);return void 0===e&&Se.set(t.strings,e=new Ee(t)),e}k(t){de(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 Ne(this.O(le()),this.O(le()),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 Te{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,n,r,o){this.type=1,this._$AH=Ae,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=Ae}_$AI(t,e=this,n,r){const o=this.strings;let i=!1;if(void 0===o)t=Pe(this,t,e,0),i=!ce(t)||t!==this._$AH&&t!==xe,i&&(this._$AH=t);else{const r=t;let s,a;for(t=o[0],s=0;s<o.length-1;s++)a=Pe(this,r[n+s],e,s),a===xe&&(a=this._$AH[s]),i||=!ce(a)||a!==this._$AH[s],a===Ae?t=Ae:t!==Ae&&(t+=(a??"")+o[s+1]),this._$AH[s]=a}i&&!r&&this.j(t)}j(t){t===Ae?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class Be extends Te{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===Ae?void 0:t}}class Ze extends Te{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==Ae)}}class Ue extends Te{constructor(t,e,n,r,o){super(t,e,n,r,o),this.type=5}_$AI(t,e=this){if((t=Pe(this,t,e,0)??Ae)===xe)return;const n=this._$AH,r=t===Ae&&n!==Ae||t.capture!==n.capture||t.once!==n.once||t.passive!==n.passive,o=t!==Ae&&(n===Ae||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 Oe{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){Pe(this,t)}}const Re=te.litHtmlPolyfillSupport;Re?.(Ee,Ne),(te.litHtmlVersions??=[]).push("3.3.0");const je=globalThis;class He extends Xt{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 Ne(e.insertBefore(le(),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 xe}}He._$litElement$=!0,He.finalized=!0,je.litElementHydrateSupport?.({LitElement:He});const Ie=je.litElementPolyfillSupport;Ie?.({LitElement:He}),(je.litElementVersions??=[]).push("4.2.0");const We=t=>(e,n)=>{void 0!==n?n.addInitializer(()=>{customElements.define(t,e)}):customElements.define(t,e)},Fe={attribute:!0,type:String,converter:J,reflect:!1,hasChanged:Y},Ge=(t=Fe,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 De(t){return(e,n)=>"object"==typeof n?Ge(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 De({...t,state:!0,attribute:!1})}var ze,Qe=/*#__PURE__*/function(t){function e(){return t.apply(this,arguments)||this}a(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 d(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)?d(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}(He);Qe.styles=[Rt(ze||(ze=c(["\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 Je,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=P.getState().connected,e._connecting=P.getState().connecting,e._connectorName=P.getState().connectorName,e._appName=P.getState().bitcoinConnectConfig.appName,e._appIcon=P.getState().bitcoinConnectConfig.appIcon,e._filters=P.getState().bitcoinConnectConfig.filters,e._error=P.getState().error,e._route=P.getState().route,e._modalOpen=P.getState().modalOpen,P.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 a(e,t),e}(Qe);_([Ve()],Ye.prototype,"_modalOpen",void 0),_([Ve()],Ye.prototype,"_connected",void 0),_([Ve()],Ye.prototype,"_connecting",void 0),_([Ve()],Ye.prototype,"_connectorName",void 0),_([Ve()],Ye.prototype,"_appName",void 0),_([Ve()],Ye.prototype,"_appIcon",void 0),_([Ve()],Ye.prototype,"_filters",void 0),_([Ve()],Ye.prototype,"_error",void 0),_([Ve()],Ye.prototype,"_route",void 0);var $e=ye(Je||(Je=c(['\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 Ke(t){return[...t.v,(t.i?"!":"")+t.n].join(":")}function qe(t,e=","){return t.map(Ke).join(e)}let Xe="undefined"!=typeof CSS&&CSS.escape||(t=>t.replace(/[!"'`*+.,;:\\/<=>?@#$%&^|~()[\]{}]/g,"\\$&").replace(/^\d/,"\\3$& "));function tn(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 en(t,e="@media "){return e+nn(t).map(t=>("string"==typeof t&&(t={min:t}),t.raw||Object.keys(t).map(e=>`(${e}-width:${t[e]})`).join(" and "))).join(",")}function nn(t=[]){return Array.isArray(t)?t:null==t?[]:[t]}function rn(t){return t}function on(){}let sn={d:0,b:134217728,c:26