forked from Blockchair/Blockchair.Support
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp-DzMTE5xn.js.download
1 lines (1 loc) · 32.3 KB
/
app-DzMTE5xn.js.download
1
var e=Object.defineProperty,t=(t,a,i)=>(((t,a,i)=>{a in t?e(t,a,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[a]=i})(t,"symbol"!=typeof a?a+"":a,i),i);import{d as a}from"./debounce-CHFeCx7p.js";import"./footer-DNMKaWaV.js";import{p as i}from"./time-x6AJkf6k.js";class s{constructor(e){t(this,"activeElement",null),t(this,"activeElementPosition",null),this.rootNode=e,this.init()}init(){this.rememberElements(),this.addEventListeners()}rememberElements(){var e;this.rows=Array.from(this.rootNode.querySelectorAll("[role=row]"));var t=[];this.rows.forEach(((a,i)=>{t.push([]);var s=Array.from(a.querySelectorAll("[role=gridcell]"));s.forEach((a=>{var n=a.querySelector("[tabindex]");n||(n=a),n.tabindex="-1",t[i].push(n),n.addEventListener("click",(()=>this.navigateTo(i,s.length))),e=n,void 0===this.firstEl&&(this.firstEl=n)}))})),void 0===this.lastEl&&(this.lastEl=e),this.firstEl&&(this.firstEl.tabindex="0"),this.matrix=t}addEventListeners(){this.matrix.forEach((e=>{e.forEach((e=>{e.addEventListener("keydown",(e=>this.handleKeydown(e))),e.addEventListener("focusin",(e=>this.handleFocusIn(e))),e.addEventListener("focusout",(e=>this.handleFocusOut(e)))}))}))}handleKeydown(e){switch(e.key){case"ArrowLeft":this.goLeft();break;case"ArrowUp":e.preventDefault(),this.goUp();break;case"ArrowRight":this.goRight();break;case"ArrowDown":e.preventDefault(),this.goDown();break;case"Home":this.goFirst();break;case"End":this.goLast()}}handleFocusIn(e){var{currentTarget:t}=e;this.activeElement=t;for(var a=this.matrix.length,i=0;i<a;i++)for(var s=this.matrix[i].length,n=0;n<s;n++)t===this.matrix[i][n]&&(this.activeElementPosition=[i,n])}handleFocusOut(e){var{relatedTarget:t,currentTarget:a}=e;if(t)if(this.rootNode.contains(t))a.tabindex="-1",t.tabindex="0";else{for(var i=this.matrix.length,s=0;s<i;s++)for(var n=this.matrix[s].length,r=0;r<n;r++)this.matrix[s][r].tabindex="-1";this.activeElement=null,this.activeElementPosition=null,this.firstEl.tabindex="0"}}getCurrentPosition(){if(null===this.activeElementPosition)return null;var[e,t]=this.activeElementPosition,a=this.matrix[e];return{curRow:e,curCol:t,row:a,rowLen:a.length}}navigateTo(e,t){this.activeElement.tabindex="-1",this.activeElementPosition=[e,t],this.activeElement=this.matrix[e][t],this.activeElement.tabindex="0",this.activeElement.focus()}goLeft(){var e=this.getCurrentPosition();if(null!==e){var t=e.curCol-1;t<0&&(t=e.rowLen-1),this.navigateTo(e.curRow,t)}}goUp(){var e=this.getCurrentPosition();if(null!==e){var t=e.curRow-1;t<0&&(t=this.matrix.length-1),this.navigateTo(t,e.curCol)}}goRight(){var e=this.getCurrentPosition();if(null!==e){var t=e.curCol+1;t>=e.rowLen&&(t=0),this.navigateTo(e.curRow,t)}}goDown(){var e=this.getCurrentPosition();if(null!==e){var t=e.curRow+1;t>=this.matrix.length&&(t=0),this.navigateTo(t,e.curCol)}}goFirst(){var e=this.getCurrentPosition();null!==e&&this.navigateTo(e.curRow,0)}goLast(){var e=this.getCurrentPosition();null!==e&&this.navigateTo(e.curRow,e.rowLen-1)}}Array.from(document.querySelectorAll("[role=grid]")).forEach((e=>new s(e)));const n=e=>{const t=":disabled, [aria-disabled='true'], [aria-hidden='true'], [tabindex^='-']",a=`:not(${t})`,i=`[href]:not([href=''], ${t})`;return Array.from(e.querySelectorAll(`input${a}, \nselect${a}, \ntextarea${a}, \nbutton${a}, \niframe${a}, \n[contenteditable=true]${a}, \n[tabindex]${a}, \na${i}, \narea${i}`))};class r{constructor(e){this.firstTab=null,this.lastTab=null,this.tabs=Array.from(e.querySelectorAll("[role=tab]")),this.panels=this.tabs.map((e=>document.getElementById(e.getAttribute("aria-controls")))),this.orientation="vertical"===e.getAttribute("aria-orientation")?"vertical":null;for(let i=0;i<this.tabs.length;i++)this.panels[i]?(this.tabs[i].tabIndex=0===i?null:-1,this.tabs[i].setAttribute("aria-selected",0===i?"true":"false"),this.panels[i].setAttribute("aria-current",0===i?"true":"false"),t=this.panels[i],a=void 0,(a=n(t)).length>0&&a[0]&&this.panels[i].removeAttribute("tabindex"),this.tabs[i].addEventListener("keydown",(e=>this.handleTabKeydown(e))),this.tabs[i].addEventListener("click",(e=>this.handleTabClick(e))),this.tabs[i].addEventListener("mousedown",(e=>this.handleTabClick(e))),0===i&&(this.firstTab=this.tabs[i]),i===this.tabs.length-1&&(this.lastTab=this.tabs[i])):(this.tabs[i].remove(),this.tabs.splice(i,1),this.panels.splice(i,1),i--);var t,a}selectTab(e,t=!0){if(1!==this.tabs.length)for(let a=0;a<this.tabs.length;a++){const i=this.tabs[a],s=this.panels[a];e===i?(i.setAttribute("aria-selected","true"),i.tabIndex=null,s.setAttribute("aria-current","true"),t&&i.focus()):(i.setAttribute("aria-selected","false"),i.tabIndex=-1,s.setAttribute("aria-current","false"))}}selectPreviousTab(e){e===this.firstTab?this.selectTab(this.lastTab):this.selectTab(this.tabs[this.tabs.indexOf(e)-1])}selectNextTab(e){e===this.lastTab?this.selectTab(this.firstTab):this.selectTab(this.tabs[this.tabs.indexOf(e)+1])}handleTabKeydown(e){const{currentTarget:t}=e;let a=!0;if("vertical"===this.orientation)switch(e.key){case"ArrowUp":e.stopPropagation(),e.preventDefault(),this.selectPreviousTab(t);break;case"ArrowDown":e.stopPropagation(),e.preventDefault(),this.selectNextTab(t);break;case"Home":this.selectTab(this.firstTab);break;case"End":this.selectTab(this.lastTab);break;default:a=!1}else switch(e.key){case"ArrowLeft":this.selectPreviousTab(t);break;case"ArrowRight":this.selectNextTab(t);break;case"Home":this.selectTab(this.firstTab);break;case"End":this.selectTab(this.lastTab);break;default:a=!1}a&&(e.stopPropagation(),e.preventDefault())}handleTabClick(e){e.preventDefault(),e.stopPropagation(),this.selectTab(e.currentTarget)}}Array.from(document.querySelectorAll("[role=tablist]")).forEach((e=>new r(e)));class o{constructor(e){this.menuNode=e,this.menuItems=Array.from(e.querySelectorAll('[role="menuitem"]')),this.subMenus=this.menuItems.map((e=>e.querySelector('[role="menu"]'))),this.init()}init(){this.menuItems.forEach(((e,t)=>{e.setAttribute("tabindex","-1"),e.addEventListener("keydown",(t=>this.handleMenuItemKeydown(t,e))),e.addEventListener("click",(t=>this.toggleSubMenu(t,e)));const a=this.subMenus[t];a&&(e.setAttribute("aria-haspopup","true"),e.setAttribute("aria-expanded","false"),a.hidden=!0)})),this.menuItems.length>0&&this.menuItems[0].setAttribute("tabindex","0")}handleMenuItemKeydown(e,t){switch(e.key){case"Escape":this.closeMenu(t);break;case"ArrowDown":case"ArrowRight":this.focusNextMenuItem(t);break;case"ArrowUp":case"ArrowLeft":this.focusPreviousMenuItem(t);break;case"Home":this.menuItems[0].focus();break;case"End":this.menuItems[this.menuItems.length-1].focus();break;case"Enter":case" ":this.toggleSubMenu(e,t)}}focusNextMenuItem(e){const t=(this.menuItems.indexOf(e)+1)%this.menuItems.length;this.menuItems[t].focus()}focusPreviousMenuItem(e){const t=(this.menuItems.indexOf(e)-1+this.menuItems.length)%this.menuItems.length;this.menuItems[t].focus()}toggleSubMenu(e,t){const a=t.querySelector('[role="menu"]');if(a){const e="true"===t.getAttribute("aria-expanded");t.setAttribute("aria-expanded",!e),a.hidden=e}}closeMenu(e){const t=e.closest('[role="menu"], [role="menubar"]');if(!t)return;t.querySelectorAll('[role="menu"]').forEach((e=>{e.hidden=!0;const t=e.closest('[role="menuitem"]');t&&t.setAttribute("aria-expanded","false")}));const a=t.closest('[role="menuitem"]');a&&a.focus()}}document.querySelectorAll('[role="menubar"], [role="menu"]').forEach((e=>new o(e))),document.addEventListener("keydown",(e=>{const{code:t}=e;if("Escape"!==t)return;const a=Array.from(document.getElementsByClassName("tooltip-container")),i={};for(const s of a){if("1"===getComputedStyle(s).getPropertyValue("opacity")){s.style.display="none";let e=s.previousElementSibling;if(e){let t="hover";e.contains(document.activeElement)&&(t="focus",e=document.activeElement),i[s.id]={trigger:e,type:t,tooltip:s}}}}for(const s in i){const{trigger:e,type:t,tooltip:a}=i[s];"hover"===t?e.addEventListener("mouseleave",(()=>{a.style.display=null,delete i[s]}),{once:!0}):"focus"===t&&e.addEventListener("blur",(()=>{a.style.display=null,delete i[s]}),{once:!0})}}));let l=document.querySelectorAll("#theme-form button");function c(e){l.forEach((t=>{t.getAttribute("formaction").includes(e)?t.setAttribute("aria-checked","true"):t.setAttribute("aria-checked","false")}))}l.forEach((function(e){e.addEventListener("click",(function(e){e.preventDefault();let t=this.getAttribute("formaction").split("/").pop();document.documentElement.setAttribute("data-theme",t),fetch(`/monkey/theme/${t}`,{method:"POST",headers:{"x-requested-with":"XMLHttpRequest"}}),c(t)}))})),c(document.documentElement.getAttribute("data-theme"));const h=document.querySelector(".menu");h.querySelectorAll("input[type=search]").forEach((e=>{var t=e.getAttribute("aria-controls"),a=document.getElementById(t),i=a.parentNode;a?(a=a.querySelectorAll("li"),e.addEventListener("input",(()=>{var t=e.value.toLowerCase();i.hasAttribute("open")||i.setAttribute("open",""),a.forEach((e=>{e.textContent.toLowerCase().includes(t)?e.removeAttribute("hidden"):e.setAttribute("hidden","")}))}))):e.remove()})),h.querySelectorAll("details").forEach((e=>{var t=e.querySelector("summary"),a=t.querySelector("summary span");t.removeAttribute("hidden"),e.addEventListener("click",(t=>{e.hasAttribute("open")?a.textContent=window.App.menu.locales.showAll:a.textContent=window.App.menu.locales.hide})),window.innerWidth<1280&&e.removeAttribute("open")})),window.addEventListener("resize",(()=>a((()=>{h.querySelectorAll("details").forEach((e=>{const t=e.querySelector("summary span");window.innerWidth<1280?(t.textContent=window.App.menu.locales.showAll,e.removeAttribute("open")):e.setAttribute("open","")}))}),100)()));const u=document.getElementById("menu-toggle"),m=document.getElementById("main-header"),v=document.querySelectorAll("body > *:not([data-overlay])"),g=document.querySelectorAll(".homepage__hero");window.openedStack||(window.openedStack=[]);var p=window.openedStack;function f(e,t){for(var a=e.parentNode.firstElementChild;a;)a===e||a.hasAttribute("data-menu-persist")||a.hasAttribute("data-overlay")||(t?a.setAttribute("hidden",""):a.removeAttribute("hidden")),a=a.nextElementSibling}function y(e=null){e&&e.preventDefault();const t="true"===u.getAttribute("aria-expanded"),a=u.getAttribute("aria-controls"),i=document.getElementById(a);i&&(u.setAttribute("aria-expanded",t?"false":"true"),u.setAttribute("aria-label",t?u.dataset.closedLabel:u.dataset.expandedLabel),t?(i.setAttribute("hidden",""),v.forEach((e=>{e===i||e.contains(m)||e.hasAttribute("data-menu-persist")||e.removeAttribute("hidden")})),f(m,!1),g.forEach((e=>e.style.removeProperty("background"))),p.splice(p.indexOf(u),1)):(v.forEach((e=>{e===i||e.contains(m)||e.hasAttribute("data-menu-persist")||e.setAttribute("hidden","")})),f(m,!0),g.forEach((e=>e.style.background="none")),i.removeAttribute("hidden"),p.push(u)))}function b(e){const t=(e,t,a)=>{const i=(e=>getComputedStyle(e).getPropertyValue("grid-template-columns").split(" ").map((e=>parseFloat(e))).filter((e=>!isNaN(e))).length)(e);i!==this.previousColumns&&(this.previousColumns=i,requestAnimationFrame((()=>{((e,t,a)=>{t.get(a).forEach(((t,a)=>{e.get(a).append(...t.values())})),e.forEach((e=>{0===e.children.length?e.style.display="none":e.style.display=null}))})(t,a,i)})))},i=new Map(Array.from(e.querySelectorAll("[data-mover-node]")).map((e=>{var{moverNode:t}=e.dataset;return delete e.dataset.moverNode,[t,e]})));if(0===i.length)return;const s=new Map([[3,new Map],[2,new Map],[1,new Map]]);s.forEach(((e,t)=>{for(let a=1;a<=3;a++)i.forEach(((e,t)=>{s.set(a,s.get(a).set(t,new Map))}))})),Array.from(document.querySelectorAll("[data-mover-position]")).reduce(((e,t,a)=>{const i=JSON.parse(t.dataset.moverPosition);delete t.dataset.moverPosition;for(let s=1;s<=3;s++){if(!(s.toString()in i))continue;let[a,n]=i[s.toString()].split("-");e.get(s).get(a).set(n,t)}return e}),s),s.forEach(((e,t)=>{for(let a=1;a<=3;a++)i.forEach(((e,t)=>{s.get(a).set(t,new Map([...s.get(a).get(t).entries()].sort()))}))})),this.previousColumns=3,t(e,i,s),window.addEventListener("resize",a((()=>t(e,i,s))))}u.addEventListener("click",y),document.addEventListener("keydown",(e=>{switch(e.key){case"k":0===((null==window?void 0:window.modalOpened)||0)&&(e.metaKey||e.ctrlKey)&&y();break;case"Escape":if(p.length>0){const e=p.pop();e.focus(),e.click()}}}));Array.from(document.querySelectorAll("[data-mover-container]")).forEach((e=>{new b(e),delete e.dataset.moverContainer}));const w=document.querySelectorAll("[data-timer]");w.forEach((e=>(e=>{"timerStart"in e.dataset&&setInterval((()=>{if("updateInProgress"in e.dataset)return;e.dataset.updateInProgress="1";const t=e.dataset.timerStart;var a=(Date.now()-t)/1e3;a<86400&&(e.innerHTML=i(a)),delete e.dataset.updateInProgress}),1e3)})(e)));const E={};class _{constructor(e,t,a,d,i){this._legacyCanvasSize=_.DEFAULT_CANVAS_SIZE,this._preferredCamera="environment",this._maxScansPerSecond=25,this._lastScanTimestamp=-1,this._destroyed=this._flashOn=this._paused=this._active=!1,this.$video=e,this.$canvas=document.createElement("canvas"),a&&"object"==typeof a?this._onDecode=t:(a||d||i?console.warn("You're using a deprecated version of the QrScanner constructor which will be removed in the future"):console.warn("Note that the type of the scan result passed to onDecode will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),this._legacyOnDecode=t),t="object"==typeof a?a:{},this._onDecodeError=t.onDecodeError||("function"==typeof a?a:this._onDecodeError),this._calculateScanRegion=t.calculateScanRegion||("function"==typeof d?d:this._calculateScanRegion),this._preferredCamera=t.preferredCamera||i||this._preferredCamera,this._legacyCanvasSize="number"==typeof a?a:"number"==typeof d?d:this._legacyCanvasSize,this._maxScansPerSecond=t.maxScansPerSecond||this._maxScansPerSecond,this._onPlay=this._onPlay.bind(this),this._onLoadedMetaData=this._onLoadedMetaData.bind(this),this._onVisibilityChange=this._onVisibilityChange.bind(this),this._updateOverlay=this._updateOverlay.bind(this),e.disablePictureInPicture=!0,e.playsInline=!0,e.muted=!0;let s=!1;if(e.hidden&&(e.hidden=!1,s=!0),document.body.contains(e)||(document.body.appendChild(e),s=!0),a=e.parentElement,t.highlightScanRegion||t.highlightCodeOutline){if(d=!!t.overlay,this.$overlay=t.overlay||document.createElement("div"),(i=this.$overlay.style).position="absolute",i.display="none",i.pointerEvents="none",this.$overlay.classList.add("scan-region-highlight"),!d&&t.highlightScanRegion){this.$overlay.innerHTML='<svg class="scan-region-highlight-svg" viewBox="0 0 238 238" preserveAspectRatio="none" style="position:absolute;width:100%;height:100%;left:0;top:0;fill:none;stroke:#e9b213;stroke-width:4;stroke-linecap:round;stroke-linejoin:round"><path d="M31 2H10a8 8 0 0 0-8 8v21M207 2h21a8 8 0 0 1 8 8v21m0 176v21a8 8 0 0 1-8 8h-21m-176 0H10a8 8 0 0 1-8-8v-21"/></svg>';try{this.$overlay.firstElementChild.animate({transform:["scale(.98)","scale(1.01)"]},{duration:400,iterations:1/0,direction:"alternate",easing:"ease-in-out"})}catch(n){}a.insertBefore(this.$overlay,this.$video.nextSibling)}t.highlightCodeOutline&&(this.$overlay.insertAdjacentHTML("beforeend",'<svg class="code-outline-highlight" preserveAspectRatio="none" style="display:none;width:100%;height:100%;fill:none;stroke:#e9b213;stroke-width:5;stroke-dasharray:25;stroke-linecap:round;stroke-linejoin:round"><polygon/></svg>'),this.$codeOutlineHighlight=this.$overlay.lastElementChild)}this._scanRegion=this._calculateScanRegion(e),requestAnimationFrame((()=>{let t=window.getComputedStyle(e);"none"===t.display&&(e.style.setProperty("display","block","important"),s=!0),"visible"!==t.visibility&&(e.style.setProperty("visibility","visible","important"),s=!0),s&&(console.warn("QrScanner has overwritten the video hiding style to avoid Safari stopping the playback."),e.style.opacity="0",e.style.width="0",e.style.height="0",this.$overlay&&this.$overlay.parentElement&&this.$overlay.parentElement.removeChild(this.$overlay),delete this.$overlay,delete this.$codeOutlineHighlight),this.$overlay&&this._updateOverlay()})),e.addEventListener("play",this._onPlay),e.addEventListener("loadedmetadata",this._onLoadedMetaData),document.addEventListener("visibilitychange",this._onVisibilityChange),window.addEventListener("resize",this._updateOverlay),this._qrEnginePromise=_.createQrEngine()}static set WORKER_PATH(e){console.warn("Setting QrScanner.WORKER_PATH is not required and not supported anymore. Have a look at the README for new setup instructions.")}static async hasCamera(){try{return!!(await _.listCameras(!1)).length}catch(e){return!1}}static async listCameras(e=!1){if(!navigator.mediaDevices)return[];let t,a=async()=>(await navigator.mediaDevices.enumerateDevices()).filter((d=>"videoinput"===d.kind));try{e&&(await a()).every((d=>!d.label))&&(t=await navigator.mediaDevices.getUserMedia({audio:!1,video:!0}))}catch(d){}try{return(await a()).map(((d,e)=>({id:d.deviceId,label:d.label||(0===e?"Default Camera":`Camera ${e+1}`)})))}finally{t&&(console.warn("Call listCameras after successfully starting a QR scanner to avoid creating a temporary video stream"),_._stopVideoStream(t))}}async hasFlash(){let e;try{if(this.$video.srcObject){if(!(this.$video.srcObject instanceof MediaStream))return!1;e=this.$video.srcObject}else e=(await this._getCameraStream()).stream;return"torch"in e.getVideoTracks()[0].getSettings()}catch(t){return!1}finally{e&&e!==this.$video.srcObject&&(console.warn("Call hasFlash after successfully starting the scanner to avoid creating a temporary video stream"),_._stopVideoStream(e))}}isFlashOn(){return this._flashOn}async toggleFlash(){this._flashOn?await this.turnFlashOff():await this.turnFlashOn()}async turnFlashOn(){if(!this._flashOn&&!this._destroyed&&(this._flashOn=!0,this._active&&!this._paused))try{if(!(await this.hasFlash()))throw"No flash available";await this.$video.srcObject.getVideoTracks()[0].applyConstraints({advanced:[{torch:!0}]})}catch(e){throw this._flashOn=!1,e}}async turnFlashOff(){this._flashOn&&(this._flashOn=!1,await this._restartVideoStream())}destroy(){this.$video.removeEventListener("loadedmetadata",this._onLoadedMetaData),this.$video.removeEventListener("play",this._onPlay),document.removeEventListener("visibilitychange",this._onVisibilityChange),window.removeEventListener("resize",this._updateOverlay),this._destroyed=!0,this._flashOn=!1,this.stop(),_._postWorkerMessage(this._qrEnginePromise,"close")}async start(){if(this._destroyed)throw Error("The QR scanner can not be started as it had been destroyed.");if((!this._active||this._paused)&&("https:"!==window.location.protocol&&console.warn("The camera stream is only accessible if the page is transferred via https."),this._active=!0,!document.hidden))if(this._paused=!1,this.$video.srcObject)await this.$video.play();else try{let{stream:e,facingMode:t}=await this._getCameraStream();!this._active||this._paused?_._stopVideoStream(e):(this._setVideoMirror(t),this.$video.srcObject=e,await this.$video.play(),this._flashOn&&(this._flashOn=!1,this.turnFlashOn().catch((()=>{}))))}catch(e){if(!this._paused)throw this._active=!1,e}}stop(){this.pause(),this._active=!1}async pause(e=!1){if(this._paused=!0,!this._active)return!0;this.$video.pause(),this.$overlay&&(this.$overlay.style.display="none");let t=()=>{this.$video.srcObject instanceof MediaStream&&(_._stopVideoStream(this.$video.srcObject),this.$video.srcObject=null)};return e?(t(),!0):(await new Promise((e=>setTimeout(e,300))),!!this._paused&&(t(),!0))}async setCamera(e){e!==this._preferredCamera&&(this._preferredCamera=e,await this._restartVideoStream())}static async scanImage(e,t,a,d,i=!1,s=!1){let n,r=!1;t&&("scanRegion"in t||"qrEngine"in t||"canvas"in t||"disallowCanvasResizing"in t||"alsoTryWithoutScanRegion"in t||"returnDetailedScanResult"in t)?(n=t.scanRegion,a=t.qrEngine,d=t.canvas,i=t.disallowCanvasResizing||!1,s=t.alsoTryWithoutScanRegion||!1,r=!0):t||a||d||i||s?console.warn("You're using a deprecated api for scanImage which will be removed in the future."):console.warn("Note that the return type of scanImage will change in the future. To already switch to the new api today, you can pass returnDetailedScanResult: true."),t=!!a;try{let o,l,c;if([a,o]=await Promise.all([a||_.createQrEngine(),_._loadImage(e)]),[d,l]=_._drawToCanvas(o,n,d,i),a instanceof Worker){let e=a;t||_._postWorkerMessageSync(e,"inversionMode","both"),c=await new Promise(((t,a)=>{let i,s,r,o=-1;s=l=>{l.data.id===o&&(e.removeEventListener("message",s),e.removeEventListener("error",r),clearTimeout(i),null!==l.data.data?t({data:l.data.data,cornerPoints:_._convertPoints(l.data.cornerPoints,n)}):a(_.NO_QR_CODE_FOUND))},r=t=>{e.removeEventListener("message",s),e.removeEventListener("error",r),clearTimeout(i),a("Scanner error: "+(t?t.message||t:"Unknown Error"))},e.addEventListener("message",s),e.addEventListener("error",r),i=setTimeout((()=>r("timeout")),1e4);let c=l.getImageData(0,0,d.width,d.height);o=_._postWorkerMessageSync(e,"decode",c,[c.data.buffer])}))}else c=await Promise.race([new Promise(((e,t)=>window.setTimeout((()=>t("Scanner error: timeout")),1e4))),(async()=>{try{var[t]=await a.detect(d);if(!t)throw _.NO_QR_CODE_FOUND;return{data:t.rawValue,cornerPoints:_._convertPoints(t.cornerPoints,n)}}catch(r){if(t=r.message||r,/not implemented|service unavailable/.test(t))return _._disableBarcodeDetector=!0,_.scanImage(e,{scanRegion:n,canvas:d,disallowCanvasResizing:i,alsoTryWithoutScanRegion:s});throw`Scanner error: ${t}`}})()]);return r?c:c.data}catch(o){if(!n||!s)throw o;let t=await _.scanImage(e,{qrEngine:a,canvas:d,disallowCanvasResizing:i});return r?t:t.data}finally{t||_._postWorkerMessage(a,"close")}}setGrayscaleWeights(e,t,a,d=!0){_._postWorkerMessage(this._qrEnginePromise,"grayscaleWeights",{red:e,green:t,blue:a,useIntegerApproximation:d})}setInversionMode(e){_._postWorkerMessage(this._qrEnginePromise,"inversionMode",e)}static async createQrEngine(e){if(e&&console.warn("Specifying a worker path is not required and not supported anymore."),e=()=>function(e,t,a){let i=Promise.resolve();if(t&&t.length>0){document.getElementsByTagName("link");const e=document.querySelector("meta[property=csp-nonce]"),a=(null==e?void 0:e.nonce)||(null==e?void 0:e.getAttribute("nonce"));i=Promise.all(t.map((e=>{if((e=function(e){return"/w4/build/"+e}(e))in E)return;E[e]=!0;const t=e.endsWith(".css"),i=t?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${e}"]${i}`))return;const s=document.createElement("link");return s.rel=t?"stylesheet":"modulepreload",t||(s.as="script",s.crossOrigin=""),s.href=e,a&&s.setAttribute("nonce",a),document.head.appendChild(s),t?new Promise(((t,a)=>{s.addEventListener("load",t),s.addEventListener("error",(()=>a(new Error(`Unable to preload CSS for ${e}`))))})):void 0})))}return i.then((()=>e())).catch((e=>{const t=new Event("vite:preloadError",{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}))}((()=>import("./qr-scanner-worker.min-k9yJ__Ac.js")),[]).then((e=>e.createWorker())),_._disableBarcodeDetector||!("BarcodeDetector"in window)||!BarcodeDetector.getSupportedFormats||!(await BarcodeDetector.getSupportedFormats()).includes("qr_code"))return e();let t=navigator.userAgentData;return t&&t.brands.some((({brand:e})=>/Chromium/i.test(e)))&&/mac ?OS/i.test(t.platform)&&await t.getHighEntropyValues(["architecture","platformVersion"]).then((({architecture:e,platformVersion:d})=>/arm/i.test(e||"arm")&&13<=parseInt(d||"13"))).catch((()=>!0))?e():new BarcodeDetector({formats:["qr_code"]})}_onPlay(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay(),this.$overlay&&(this.$overlay.style.display=""),this._scanFrame()}_onLoadedMetaData(){this._scanRegion=this._calculateScanRegion(this.$video),this._updateOverlay()}_onVisibilityChange(){document.hidden?this.pause():this._active&&this.start()}_calculateScanRegion(e){let t=Math.round(2/3*Math.min(e.videoWidth,e.videoHeight));return{x:Math.round((e.videoWidth-t)/2),y:Math.round((e.videoHeight-t)/2),width:t,height:t,downScaledWidth:this._legacyCanvasSize,downScaledHeight:this._legacyCanvasSize}}_updateOverlay(){requestAnimationFrame((()=>{if(this.$overlay){var e=this.$video,t=e.videoWidth,a=e.videoHeight,d=e.offsetWidth,i=e.offsetHeight,s=e.offsetLeft,n=e.offsetTop,r=window.getComputedStyle(e),o=r.objectFit,l=t/a,c=d/i;switch(o){case"none":var h=t,u=a;break;case"fill":h=d,u=i;break;default:("cover"===o?l>c:l<c)?h=(u=i)*l:u=(h=d)/l,"scale-down"===o&&(h=Math.min(h,t),u=Math.min(u,a))}var[m,v]=r.objectPosition.split(" ").map(((e,t)=>{const a=parseFloat(e);return e.endsWith("%")?(t?i-u:d-h)*a/100:a}));r=this._scanRegion.width||t,c=this._scanRegion.height||a,o=this._scanRegion.x||0;var g=this._scanRegion.y||0;(l=this.$overlay.style).width=r/t*h+"px",l.height=c/a*u+"px",l.top=`${n+v+g/a*u}px`,a=/scaleX\(-1\)/.test(e.style.transform),l.left=`${s+(a?d-m-h:m)+(a?t-o-r:o)/t*h}px`,l.transform=e.style.transform}}))}static _convertPoints(e,t){if(!t)return e;let a=t.x||0,d=t.y||0,i=t.width&&t.downScaledWidth?t.width/t.downScaledWidth:1;t=t.height&&t.downScaledHeight?t.height/t.downScaledHeight:1;for(let s of e)s.x=s.x*i+a,s.y=s.y*t+d;return e}_scanFrame(){!this._active||this.$video.paused||this.$video.ended||("requestVideoFrameCallback"in this.$video?this.$video.requestVideoFrameCallback.bind(this.$video):requestAnimationFrame)((async()=>{if(!(1>=this.$video.readyState)){var e=Date.now()-this._lastScanTimestamp,t=1e3/this._maxScansPerSecond;e<t&&await new Promise((d=>setTimeout(d,t-e))),this._lastScanTimestamp=Date.now();try{var a=await _.scanImage(this.$video,{scanRegion:this._scanRegion,qrEngine:this._qrEnginePromise,canvas:this.$canvas})}catch(d){if(!this._active)return;this._onDecodeError(d)}!_._disableBarcodeDetector||await this._qrEnginePromise instanceof Worker||(this._qrEnginePromise=_.createQrEngine()),a?(this._onDecode?this._onDecode(a):this._legacyOnDecode&&this._legacyOnDecode(a.data),this.$codeOutlineHighlight&&(clearTimeout(this._codeOutlineHighlightRemovalTimeout),this._codeOutlineHighlightRemovalTimeout=void 0,this.$codeOutlineHighlight.setAttribute("viewBox",`${this._scanRegion.x||0} ${this._scanRegion.y||0} ${this._scanRegion.width||this.$video.videoWidth} ${this._scanRegion.height||this.$video.videoHeight}`),this.$codeOutlineHighlight.firstElementChild.setAttribute("points",a.cornerPoints.map((({x:d,y:e})=>`${d},${e}`)).join(" ")),this.$codeOutlineHighlight.style.display="")):this.$codeOutlineHighlight&&!this._codeOutlineHighlightRemovalTimeout&&(this._codeOutlineHighlightRemovalTimeout=setTimeout((()=>this.$codeOutlineHighlight.style.display="none"),100))}this._scanFrame()}))}_onDecodeError(e){e!==_.NO_QR_CODE_FOUND&&console.log(e)}async _getCameraStream(){if(!navigator.mediaDevices)throw"Camera not found.";let e=/^(environment|user)$/.test(this._preferredCamera)?"facingMode":"deviceId",t=[{width:{min:1024}},{width:{min:768}},{}],a=t.map((d=>Object.assign({},d,{[e]:{exact:this._preferredCamera}})));for(let d of[...a,...t])try{let e=await navigator.mediaDevices.getUserMedia({video:d,audio:!1});return{stream:e,facingMode:this._getFacingMode(e)||(d.facingMode?this._preferredCamera:"environment"===this._preferredCamera?"user":"environment")}}catch(i){}throw"Camera not found."}async _restartVideoStream(){let e=this._paused;await this.pause(!0)&&!e&&this._active&&await this.start()}static _stopVideoStream(e){for(let t of e.getTracks())t.stop(),e.removeTrack(t)}_setVideoMirror(e){this.$video.style.transform="scaleX("+("user"===e?-1:1)+")"}_getFacingMode(e){return(e=e.getVideoTracks()[0])?/rear|back|environment/i.test(e.label)?"environment":/front|user|face/i.test(e.label)?"user":null:null}static _drawToCanvas(e,t,a,d=!1){a=a||document.createElement("canvas");let i=t&&t.x?t.x:0,s=t&&t.y?t.y:0,n=t&&t.width?t.width:e.videoWidth||e.width,r=t&&t.height?t.height:e.videoHeight||e.height;return d||(d=t&&t.downScaledWidth?t.downScaledWidth:n,t=t&&t.downScaledHeight?t.downScaledHeight:r,a.width!==d&&(a.width=d),a.height!==t&&(a.height=t)),(t=a.getContext("2d",{alpha:!1})).imageSmoothingEnabled=!1,t.drawImage(e,i,s,n,r,0,0,a.width,a.height),[a,t]}static async _loadImage(e){if(e instanceof Image)return await _._awaitImageLoad(e),e;if(e instanceof HTMLVideoElement||e instanceof HTMLCanvasElement||e instanceof SVGImageElement||"OffscreenCanvas"in window&&e instanceof OffscreenCanvas||"ImageBitmap"in window&&e instanceof ImageBitmap)return e;if(!(e instanceof File||e instanceof Blob||e instanceof URL||"string"==typeof e))throw"Unsupported image type.";{let t=new Image;t.src=e instanceof File||e instanceof Blob?URL.createObjectURL(e):e.toString();try{return await _._awaitImageLoad(t),t}finally{(e instanceof File||e instanceof Blob)&&URL.revokeObjectURL(t.src)}}}static async _awaitImageLoad(e){e.complete&&0!==e.naturalWidth||await new Promise(((t,a)=>{let d=i=>{e.removeEventListener("load",d),e.removeEventListener("error",d),i instanceof ErrorEvent?a("Image load error"):t()};e.addEventListener("load",d),e.addEventListener("error",d)}))}static async _postWorkerMessage(e,t,a,d){return _._postWorkerMessageSync(await e,t,a,d)}static _postWorkerMessageSync(e,t,a,d){if(!(e instanceof Worker))return-1;let i=_._workerMessageId++;return e.postMessage({id:i,type:t,data:a},d),i}}_.DEFAULT_CANVAS_SIZE=400,_.NO_QR_CODE_FOUND="No QR code found",_._disableBarcodeDetector=!1,_._workerMessageId=0;class S extends HTMLElement{constructor(){super(),t(this,"isConnected",!1),t(this,"overlay",null),t(this,"dialog",null),t(this,"firstFocusable",null),t(this,"lastFocusable",null)}get modalOpened(){return"1"===this.getAttribute("modal-opened")}set modalOpened(e){this.setAttribute("modal-opened",e>0?"1":"0")}connectedCallback(){this.isConnected||(this.initTemplate(),this.initListeners(),this.isConnected=!0)}initTemplate(){this.innerHTML=this.querySelector("template").innerHTML,this.overlay=document.getElementById(this.dataset.overlayId),this.dialog=this.overlay.querySelector("[role=dialog]");var e=n(this.overlay);e.length>0?(this.firstFocusable=e[0],this.lastFocusable=e[e.length-1]):this.dialog.tabindex=0}initListeners(){this.overlay.addEventListener("keydown",(e=>this.captureTabbing(e))),this.overlay.querySelector("button").addEventListener("click",(e=>this.closeModal(e))),this.addEventListener("click",this.handleClick),this.addEventListener("keydown",this.handleKeydown)}captureTabbing(e){if("Tab"===e.code){var{target:t}=e;e.shiftKey?t===this.firstFocusable&&(e.preventDefault(),this.lastFocusable.focus()):t===this.lastFocusable&&(e.preventDefault(),this.firstFocusable.focus())}}handleClick(e){this.openModal(e)}handleEscape(e){this.modalOpened&&"Escape"===e.code&&this.closeModal(e)}handleKeydown(e){this.handleEscape(e),"Space"!==e.code&&"Enter"!==e.code||this.openModal(e)}openModal(e){e.preventDefault(),this.modalOpened||(this.overlay.removeAttribute("hidden"),window.modalOpened=1,this.modalOpened=1,this.firstFocusable.focus())}closeModal(e){e&&e.preventDefault(),this.overlay.setAttribute("hidden",""),window.modalOpened=0,this.modalOpened=0,this.focus()}addGlobalKeydownHandler(){document.addEventListener("keydown",(e=>this.handleEscape(e)))}removeGlobalKeydownHandler(){document.removeEventListener("keydown",(e=>this.handleEscape(e)))}attributeChangedCallback(e,t,a){if("modal-opened"===e)null===t?"1"===a&&this.addGlobalKeydownHandler():"1"!==a?this.removeGlobalKeydownHandler():this.addGlobalKeydownHandler()}}t(S,"observedAttributes",["modal-opened"]),customElements.define("modal-trigger",S);customElements.define("blockchair-scan-qr",class extends S{constructor(){super(),t(this,"qrScanner",null),t(this,"scannedResult",null)}connectedCallback(){this.isConnected||_.hasCamera().then((e=>{e?(this.initTemplate(),this.initListeners()):this.remove(),this.isConnected=!0}))}openModal(e){var t;super.openModal(e),this.qrScanner||(this.qrScanner=new _(this.overlay.querySelector("video"),(e=>{var t;null==(t=this.qrScanner)||t.stop(),this.search(e.data)}),{returnDetailedScanResult:!0})),null==(t=this.qrScanner)||t.start().catch((()=>this.closeModal()))}closeModal(e=null){var t;super.closeModal(e),null==(t=this.qrScanner)||t.stop()}search(e){var t=document.getElementById("search-input");if(t){t.value=e;for(var a=t.parentElement;"FORM"!==a.tagName;)a=t.parentElement;a.submit()}}});const A=(e,t,a,i=null)=>{void 0===a&&(a=null),window._paq||(window._paq=[]),window._paq.push(["trackEvent",e,t,a,i])};Array.from(document.querySelectorAll("[data-okane-click]")).forEach((e=>{try{var t=JSON.parse(e.dataset.okaneClick);delete e.dataset.okaneClick,e.addEventListener("click",(()=>A(...t)))}catch(a){}})),Array.from(document.querySelectorAll("[data-okane-hover]")).forEach((e=>{try{var t=JSON.parse(e.dataset.okaneHover);delete e.dataset.okaneHover,e.addEventListener("mouseenter",(e=>{e.stopPropagation(),A(...t)}))}catch(a){}})),Array.from(document.querySelectorAll("[data-okane-view]")).forEach((e=>{try{var t=JSON.parse(e.dataset.okaneView);delete e.dataset.okaneView,A(...t)}catch(a){}}));