@safe-stars/components
Version:
React component library for buying Telegram Stars in Telegram Mini Apps via Safe Stars.
90 lines (83 loc) • 29.6 kB
JavaScript
"use strict";const T=require("./index-CtZaCMo8.cjs"),_=require("./if-defined-MmHKu2JE.cjs");require("./index-BXulAD-4.cjs");var J={},Ft=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},Ct={},I={};let ft;const kt=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];I.getSymbolSize=function(t){if(!t)throw new Error('"version" cannot be null or undefined');if(t<1||t>40)throw new Error('"version" should be in range from 1 to 40');return t*4+17};I.getSymbolTotalCodewords=function(t){return kt[t]};I.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t};I.setToSJISFunction=function(t){if(typeof t!="function")throw new Error('"toSJISFunc" is not a valid function.');ft=t};I.isKanjiModeEnabled=function(){return typeof ft<"u"};I.toSJIS=function(t){return ft(t)};var Q={};(function(e){e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(i){if(typeof i!="string")throw new Error("Param is not a string");switch(i.toLowerCase()){case"l":case"low":return e.L;case"m":case"medium":return e.M;case"q":case"quartile":return e.Q;case"h":case"high":return e.H;default:throw new Error("Unknown EC Level: "+i)}}e.isValid=function(o){return o&&typeof o.bit<"u"&&o.bit>=0&&o.bit<4},e.from=function(o,r){if(e.isValid(o))return o;try{return t(o)}catch{return r}}})(Q);function Bt(){this.buffer=[],this.length=0}Bt.prototype={get:function(e){const t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)===1},put:function(e,t){for(let i=0;i<t;i++)this.putBit((e>>>t-i-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(e){const t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}};var zt=Bt;function Y(e){if(!e||e<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}Y.prototype.set=function(e,t,i,o){const r=e*this.size+t;this.data[r]=i,o&&(this.reservedBit[r]=!0)};Y.prototype.get=function(e,t){return this.data[e*this.size+t]};Y.prototype.xor=function(e,t,i){this.data[e*this.size+t]^=i};Y.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]};var $t=Y,At={};(function(e){const t=I.getSymbolSize;e.getRowColCoords=function(o){if(o===1)return[];const r=Math.floor(o/7)+2,n=t(o),s=n===145?26:Math.ceil((n-13)/(2*r-2))*2,a=[n-7];for(let u=1;u<r-1;u++)a[u]=a[u-1]-s;return a.push(6),a.reverse()},e.getPositions=function(o){const r=[],n=e.getRowColCoords(o),s=n.length;for(let a=0;a<s;a++)for(let u=0;u<s;u++)a===0&&u===0||a===0&&u===s-1||a===s-1&&u===0||r.push([n[a],n[u]]);return r}})(At);var bt={};const Ot=I.getSymbolSize,wt=7;bt.getPositions=function(t){const i=Ot(t);return[[0,0],[i-wt,0],[0,i-wt]]};var It={};(function(e){e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(r){return r!=null&&r!==""&&!isNaN(r)&&r>=0&&r<=7},e.from=function(r){return e.isValid(r)?parseInt(r,10):void 0},e.getPenaltyN1=function(r){const n=r.size;let s=0,a=0,u=0,h=null,g=null;for(let B=0;B<n;B++){a=u=0,h=g=null;for(let p=0;p<n;p++){let w=r.get(B,p);w===h?a++:(a>=5&&(s+=t.N1+(a-5)),h=w,a=1),w=r.get(p,B),w===g?u++:(u>=5&&(s+=t.N1+(u-5)),g=w,u=1)}a>=5&&(s+=t.N1+(a-5)),u>=5&&(s+=t.N1+(u-5))}return s},e.getPenaltyN2=function(r){const n=r.size;let s=0;for(let a=0;a<n-1;a++)for(let u=0;u<n-1;u++){const h=r.get(a,u)+r.get(a,u+1)+r.get(a+1,u)+r.get(a+1,u+1);(h===4||h===0)&&s++}return s*t.N2},e.getPenaltyN3=function(r){const n=r.size;let s=0,a=0,u=0;for(let h=0;h<n;h++){a=u=0;for(let g=0;g<n;g++)a=a<<1&2047|r.get(h,g),g>=10&&(a===1488||a===93)&&s++,u=u<<1&2047|r.get(g,h),g>=10&&(u===1488||u===93)&&s++}return s*t.N3},e.getPenaltyN4=function(r){let n=0;const s=r.data.length;for(let u=0;u<s;u++)n+=r.data[u];return Math.abs(Math.ceil(n*100/s/5)-10)*t.N4};function i(o,r,n){switch(o){case e.Patterns.PATTERN000:return(r+n)%2===0;case e.Patterns.PATTERN001:return r%2===0;case e.Patterns.PATTERN010:return n%3===0;case e.Patterns.PATTERN011:return(r+n)%3===0;case e.Patterns.PATTERN100:return(Math.floor(r/2)+Math.floor(n/3))%2===0;case e.Patterns.PATTERN101:return r*n%2+r*n%3===0;case e.Patterns.PATTERN110:return(r*n%2+r*n%3)%2===0;case e.Patterns.PATTERN111:return(r*n%3+(r+n)%2)%2===0;default:throw new Error("bad maskPattern:"+o)}}e.applyMask=function(r,n){const s=n.size;for(let a=0;a<s;a++)for(let u=0;u<s;u++)n.isReserved(u,a)||n.xor(u,a,i(r,u,a))},e.getBestMask=function(r,n){const s=Object.keys(e.Patterns).length;let a=0,u=1/0;for(let h=0;h<s;h++){n(h),e.applyMask(h,r);const g=e.getPenaltyN1(r)+e.getPenaltyN2(r)+e.getPenaltyN3(r)+e.getPenaltyN4(r);e.applyMask(h,r),g<u&&(u=g,a=h)}return a}})(It);var W={};const U=Q,j=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],q=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];W.getBlocksCount=function(t,i){switch(i){case U.L:return j[(t-1)*4+0];case U.M:return j[(t-1)*4+1];case U.Q:return j[(t-1)*4+2];case U.H:return j[(t-1)*4+3];default:return}};W.getTotalCodewordsCount=function(t,i){switch(i){case U.L:return q[(t-1)*4+0];case U.M:return q[(t-1)*4+1];case U.Q:return q[(t-1)*4+2];case U.H:return q[(t-1)*4+3];default:return}};var Nt={},X={};const H=new Uint8Array(512),x=new Uint8Array(256);(function(){let t=1;for(let i=0;i<255;i++)H[i]=t,x[t]=i,t<<=1,t&256&&(t^=285);for(let i=255;i<512;i++)H[i]=H[i-255]})();X.log=function(t){if(t<1)throw new Error("log("+t+")");return x[t]};X.exp=function(t){return H[t]};X.mul=function(t,i){return t===0||i===0?0:H[x[t]+x[i]]};(function(e){const t=X;e.mul=function(o,r){const n=new Uint8Array(o.length+r.length-1);for(let s=0;s<o.length;s++)for(let a=0;a<r.length;a++)n[s+a]^=t.mul(o[s],r[a]);return n},e.mod=function(o,r){let n=new Uint8Array(o);for(;n.length-r.length>=0;){const s=n[0];for(let u=0;u<r.length;u++)n[u]^=t.mul(r[u],s);let a=0;for(;a<n.length&&n[a]===0;)a++;n=n.slice(a)}return n},e.generateECPolynomial=function(o){let r=new Uint8Array([1]);for(let n=0;n<o;n++)r=e.mul(r,new Uint8Array([1,t.exp(n)]));return r}})(Nt);const Tt=Nt;function dt(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}dt.prototype.initialize=function(t){this.degree=t,this.genPoly=Tt.generateECPolynomial(this.degree)};dt.prototype.encode=function(t){if(!this.genPoly)throw new Error("Encoder not initialized");const i=new Uint8Array(t.length+this.degree);i.set(t);const o=Tt.mod(i,this.genPoly),r=this.degree-o.length;if(r>0){const n=new Uint8Array(this.degree);return n.set(o,r),n}return o};var Vt=dt,St={},F={},ht={};ht.isValid=function(t){return!isNaN(t)&&t>=1&&t<=40};var R={};const Mt="[0-9]+",Ht="[A-Z $%*+\\-./:]+";let K="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";K=K.replace(/u/g,"\\u");const Kt="(?:(?![A-Z0-9 $%*+\\-./:]|"+K+`)(?:.|[\r
]))+`;R.KANJI=new RegExp(K,"g");R.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");R.BYTE=new RegExp(Kt,"g");R.NUMERIC=new RegExp(Mt,"g");R.ALPHANUMERIC=new RegExp(Ht,"g");const Jt=new RegExp("^"+K+"$"),Yt=new RegExp("^"+Mt+"$"),jt=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");R.testKanji=function(t){return Jt.test(t)};R.testNumeric=function(t){return Yt.test(t)};R.testAlphanumeric=function(t){return jt.test(t)};(function(e){const t=ht,i=R;e.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},e.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},e.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(n,s){if(!n.ccBits)throw new Error("Invalid mode: "+n);if(!t.isValid(s))throw new Error("Invalid version: "+s);return s>=1&&s<10?n.ccBits[0]:s<27?n.ccBits[1]:n.ccBits[2]},e.getBestModeForData=function(n){return i.testNumeric(n)?e.NUMERIC:i.testAlphanumeric(n)?e.ALPHANUMERIC:i.testKanji(n)?e.KANJI:e.BYTE},e.toString=function(n){if(n&&n.id)return n.id;throw new Error("Invalid mode")},e.isValid=function(n){return n&&n.bit&&n.ccBits};function o(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"numeric":return e.NUMERIC;case"alphanumeric":return e.ALPHANUMERIC;case"kanji":return e.KANJI;case"byte":return e.BYTE;default:throw new Error("Unknown mode: "+r)}}e.from=function(n,s){if(e.isValid(n))return n;try{return o(n)}catch{return s}}})(F);(function(e){const t=I,i=W,o=Q,r=F,n=ht,s=7973,a=t.getBCHDigit(s);function u(p,w,E){for(let m=1;m<=40;m++)if(w<=e.getCapacity(m,E,p))return m}function h(p,w){return r.getCharCountIndicator(p,w)+4}function g(p,w){let E=0;return p.forEach(function(m){const y=h(m.mode,w);E+=y+m.getBitsLength()}),E}function B(p,w){for(let E=1;E<=40;E++)if(g(p,E)<=e.getCapacity(E,w,r.MIXED))return E}e.from=function(w,E){return n.isValid(w)?parseInt(w,10):E},e.getCapacity=function(w,E,m){if(!n.isValid(w))throw new Error("Invalid QR Code version");typeof m>"u"&&(m=r.BYTE);const y=t.getSymbolTotalCodewords(w),f=i.getTotalCodewordsCount(w,E),l=(y-f)*8;if(m===r.MIXED)return l;const d=l-h(m,w);switch(m){case r.NUMERIC:return Math.floor(d/10*3);case r.ALPHANUMERIC:return Math.floor(d/11*2);case r.KANJI:return Math.floor(d/13);case r.BYTE:default:return Math.floor(d/8)}},e.getBestVersionForData=function(w,E){let m;const y=o.from(E,o.M);if(Array.isArray(w)){if(w.length>1)return B(w,y);if(w.length===0)return 1;m=w[0]}else m=w;return u(m.mode,m.getLength(),y)},e.getEncodedBits=function(w){if(!n.isValid(w)||w<7)throw new Error("Invalid QR Code version");let E=w<<12;for(;t.getBCHDigit(E)-a>=0;)E^=s<<t.getBCHDigit(E)-a;return w<<12|E}})(St);var Rt={};const ut=I,Pt=1335,qt=21522,yt=ut.getBCHDigit(Pt);Rt.getEncodedBits=function(t,i){const o=t.bit<<3|i;let r=o<<10;for(;ut.getBCHDigit(r)-yt>=0;)r^=Pt<<ut.getBCHDigit(r)-yt;return(o<<10|r)^qt};var Lt={};const xt=F;function k(e){this.mode=xt.NUMERIC,this.data=e.toString()}k.getBitsLength=function(t){return 10*Math.floor(t/3)+(t%3?t%3*3+1:0)};k.prototype.getLength=function(){return this.data.length};k.prototype.getBitsLength=function(){return k.getBitsLength(this.data.length)};k.prototype.write=function(t){let i,o,r;for(i=0;i+3<=this.data.length;i+=3)o=this.data.substr(i,3),r=parseInt(o,10),t.put(r,10);const n=this.data.length-i;n>0&&(o=this.data.substr(i),r=parseInt(o,10),t.put(r,n*3+1))};var Gt=k;const Qt=F,et=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function z(e){this.mode=Qt.ALPHANUMERIC,this.data=e}z.getBitsLength=function(t){return 11*Math.floor(t/2)+6*(t%2)};z.prototype.getLength=function(){return this.data.length};z.prototype.getBitsLength=function(){return z.getBitsLength(this.data.length)};z.prototype.write=function(t){let i;for(i=0;i+2<=this.data.length;i+=2){let o=et.indexOf(this.data[i])*45;o+=et.indexOf(this.data[i+1]),t.put(o,11)}this.data.length%2&&t.put(et.indexOf(this.data[i]),6)};var Wt=z,Xt=function(t){for(var i=[],o=t.length,r=0;r<o;r++){var n=t.charCodeAt(r);if(n>=55296&&n<=56319&&o>r+1){var s=t.charCodeAt(r+1);s>=56320&&s<=57343&&(n=(n-55296)*1024+s-56320+65536,r+=1)}if(n<128){i.push(n);continue}if(n<2048){i.push(n>>6|192),i.push(n&63|128);continue}if(n<55296||n>=57344&&n<65536){i.push(n>>12|224),i.push(n>>6&63|128),i.push(n&63|128);continue}if(n>=65536&&n<=1114111){i.push(n>>18|240),i.push(n>>12&63|128),i.push(n>>6&63|128),i.push(n&63|128);continue}i.push(239,191,189)}return new Uint8Array(i).buffer};const Zt=Xt,te=F;function $(e){this.mode=te.BYTE,typeof e=="string"&&(e=Zt(e)),this.data=new Uint8Array(e)}$.getBitsLength=function(t){return t*8};$.prototype.getLength=function(){return this.data.length};$.prototype.getBitsLength=function(){return $.getBitsLength(this.data.length)};$.prototype.write=function(e){for(let t=0,i=this.data.length;t<i;t++)e.put(this.data[t],8)};var ee=$;const ne=F,re=I;function O(e){this.mode=ne.KANJI,this.data=e}O.getBitsLength=function(t){return t*13};O.prototype.getLength=function(){return this.data.length};O.prototype.getBitsLength=function(){return O.getBitsLength(this.data.length)};O.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let i=re.toSJIS(this.data[t]);if(i>=33088&&i<=40956)i-=33088;else if(i>=57408&&i<=60351)i-=49472;else throw new Error("Invalid SJIS character: "+this.data[t]+`
Make sure your charset is UTF-8`);i=(i>>>8&255)*192+(i&255),e.put(i,13)}};var oe=O,_t={exports:{}};(function(e){var t={single_source_shortest_paths:function(i,o,r){var n={},s={};s[o]=0;var a=t.PriorityQueue.make();a.push(o,0);for(var u,h,g,B,p,w,E,m,y;!a.empty();){u=a.pop(),h=u.value,B=u.cost,p=i[h]||{};for(g in p)p.hasOwnProperty(g)&&(w=p[g],E=B+w,m=s[g],y=typeof s[g]>"u",(y||m>E)&&(s[g]=E,a.push(g,E),n[g]=h))}if(typeof r<"u"&&typeof s[r]>"u"){var f=["Could not find a path from ",o," to ",r,"."].join("");throw new Error(f)}return n},extract_shortest_path_from_predecessor_list:function(i,o){for(var r=[],n=o;n;)r.push(n),i[n],n=i[n];return r.reverse(),r},find_path:function(i,o,r){var n=t.single_source_shortest_paths(i,o,r);return t.extract_shortest_path_from_predecessor_list(n,r)},PriorityQueue:{make:function(i){var o=t.PriorityQueue,r={},n;i=i||{};for(n in o)o.hasOwnProperty(n)&&(r[n]=o[n]);return r.queue=[],r.sorter=i.sorter||o.default_sorter,r},default_sorter:function(i,o){return i.cost-o.cost},push:function(i,o){var r={value:i,cost:o};this.queue.push(r),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};e.exports=t})(_t);var ie=_t.exports;(function(e){const t=F,i=Gt,o=Wt,r=ee,n=oe,s=R,a=I,u=ie;function h(f){return unescape(encodeURIComponent(f)).length}function g(f,l,d){const c=[];let C;for(;(C=f.exec(d))!==null;)c.push({data:C[0],index:C.index,mode:l,length:C[0].length});return c}function B(f){const l=g(s.NUMERIC,t.NUMERIC,f),d=g(s.ALPHANUMERIC,t.ALPHANUMERIC,f);let c,C;return a.isKanjiModeEnabled()?(c=g(s.BYTE,t.BYTE,f),C=g(s.KANJI,t.KANJI,f)):(c=g(s.BYTE_KANJI,t.BYTE,f),C=[]),l.concat(d,c,C).sort(function(b,N){return b.index-N.index}).map(function(b){return{data:b.data,mode:b.mode,length:b.length}})}function p(f,l){switch(l){case t.NUMERIC:return i.getBitsLength(f);case t.ALPHANUMERIC:return o.getBitsLength(f);case t.KANJI:return n.getBitsLength(f);case t.BYTE:return r.getBitsLength(f)}}function w(f){return f.reduce(function(l,d){const c=l.length-1>=0?l[l.length-1]:null;return c&&c.mode===d.mode?(l[l.length-1].data+=d.data,l):(l.push(d),l)},[])}function E(f){const l=[];for(let d=0;d<f.length;d++){const c=f[d];switch(c.mode){case t.NUMERIC:l.push([c,{data:c.data,mode:t.ALPHANUMERIC,length:c.length},{data:c.data,mode:t.BYTE,length:c.length}]);break;case t.ALPHANUMERIC:l.push([c,{data:c.data,mode:t.BYTE,length:c.length}]);break;case t.KANJI:l.push([c,{data:c.data,mode:t.BYTE,length:h(c.data)}]);break;case t.BYTE:l.push([{data:c.data,mode:t.BYTE,length:h(c.data)}])}}return l}function m(f,l){const d={},c={start:{}};let C=["start"];for(let A=0;A<f.length;A++){const b=f[A],N=[];for(let v=0;v<b.length;v++){const M=b[v],V=""+A+v;N.push(V),d[V]={node:M,lastCount:0},c[V]={};for(let tt=0;tt<C.length;tt++){const P=C[tt];d[P]&&d[P].node.mode===M.mode?(c[P][V]=p(d[P].lastCount+M.length,M.mode)-p(d[P].lastCount,M.mode),d[P].lastCount+=M.length):(d[P]&&(d[P].lastCount=M.length),c[P][V]=p(M.length,M.mode)+4+t.getCharCountIndicator(M.mode,l))}}C=N}for(let A=0;A<C.length;A++)c[C[A]].end=0;return{map:c,table:d}}function y(f,l){let d;const c=t.getBestModeForData(f);if(d=t.from(l,c),d!==t.BYTE&&d.bit<c.bit)throw new Error('"'+f+'" cannot be encoded with mode '+t.toString(d)+`.
Suggested mode is: `+t.toString(c));switch(d===t.KANJI&&!a.isKanjiModeEnabled()&&(d=t.BYTE),d){case t.NUMERIC:return new i(f);case t.ALPHANUMERIC:return new o(f);case t.KANJI:return new n(f);case t.BYTE:return new r(f)}}e.fromArray=function(l){return l.reduce(function(d,c){return typeof c=="string"?d.push(y(c,null)):c.data&&d.push(y(c.data,c.mode)),d},[])},e.fromString=function(l,d){const c=B(l,a.isKanjiModeEnabled()),C=E(c),A=m(C,d),b=u.find_path(A.map,"start","end"),N=[];for(let v=1;v<b.length-1;v++)N.push(A.table[b[v]].node);return e.fromArray(w(N))},e.rawSplit=function(l){return e.fromArray(B(l,a.isKanjiModeEnabled()))}})(Lt);const Z=I,nt=Q,se=zt,ue=$t,ae=At,ce=bt,at=It,ct=W,le=Vt,G=St,fe=Rt,de=F,rt=Lt;function he(e,t){const i=e.size,o=ce.getPositions(t);for(let r=0;r<o.length;r++){const n=o[r][0],s=o[r][1];for(let a=-1;a<=7;a++)if(!(n+a<=-1||i<=n+a))for(let u=-1;u<=7;u++)s+u<=-1||i<=s+u||(a>=0&&a<=6&&(u===0||u===6)||u>=0&&u<=6&&(a===0||a===6)||a>=2&&a<=4&&u>=2&&u<=4?e.set(n+a,s+u,!0,!0):e.set(n+a,s+u,!1,!0))}}function ge(e){const t=e.size;for(let i=8;i<t-8;i++){const o=i%2===0;e.set(i,6,o,!0),e.set(6,i,o,!0)}}function me(e,t){const i=ae.getPositions(t);for(let o=0;o<i.length;o++){const r=i[o][0],n=i[o][1];for(let s=-2;s<=2;s++)for(let a=-2;a<=2;a++)s===-2||s===2||a===-2||a===2||s===0&&a===0?e.set(r+s,n+a,!0,!0):e.set(r+s,n+a,!1,!0)}}function we(e,t){const i=e.size,o=G.getEncodedBits(t);let r,n,s;for(let a=0;a<18;a++)r=Math.floor(a/3),n=a%3+i-8-3,s=(o>>a&1)===1,e.set(r,n,s,!0),e.set(n,r,s,!0)}function ot(e,t,i){const o=e.size,r=fe.getEncodedBits(t,i);let n,s;for(n=0;n<15;n++)s=(r>>n&1)===1,n<6?e.set(n,8,s,!0):n<8?e.set(n+1,8,s,!0):e.set(o-15+n,8,s,!0),n<8?e.set(8,o-n-1,s,!0):n<9?e.set(8,15-n-1+1,s,!0):e.set(8,15-n-1,s,!0);e.set(o-8,8,1,!0)}function ye(e,t){const i=e.size;let o=-1,r=i-1,n=7,s=0;for(let a=i-1;a>0;a-=2)for(a===6&&a--;;){for(let u=0;u<2;u++)if(!e.isReserved(r,a-u)){let h=!1;s<t.length&&(h=(t[s]>>>n&1)===1),e.set(r,a-u,h),n--,n===-1&&(s++,n=7)}if(r+=o,r<0||i<=r){r-=o,o=-o;break}}}function pe(e,t,i){const o=new se;i.forEach(function(u){o.put(u.mode.bit,4),o.put(u.getLength(),de.getCharCountIndicator(u.mode,e)),u.write(o)});const r=Z.getSymbolTotalCodewords(e),n=ct.getTotalCodewordsCount(e,t),s=(r-n)*8;for(o.getLengthInBits()+4<=s&&o.put(0,4);o.getLengthInBits()%8!==0;)o.putBit(0);const a=(s-o.getLengthInBits())/8;for(let u=0;u<a;u++)o.put(u%2?17:236,8);return Ee(o,e,t)}function Ee(e,t,i){const o=Z.getSymbolTotalCodewords(t),r=ct.getTotalCodewordsCount(t,i),n=o-r,s=ct.getBlocksCount(t,i),a=o%s,u=s-a,h=Math.floor(o/s),g=Math.floor(n/s),B=g+1,p=h-g,w=new le(p);let E=0;const m=new Array(s),y=new Array(s);let f=0;const l=new Uint8Array(e.buffer);for(let b=0;b<s;b++){const N=b<u?g:B;m[b]=l.slice(E,E+N),y[b]=w.encode(m[b]),E+=N,f=Math.max(f,N)}const d=new Uint8Array(o);let c=0,C,A;for(C=0;C<f;C++)for(A=0;A<s;A++)C<m[A].length&&(d[c++]=m[A][C]);for(C=0;C<p;C++)for(A=0;A<s;A++)d[c++]=y[A][C];return d}function Ce(e,t,i,o){let r;if(Array.isArray(e))r=rt.fromArray(e);else if(typeof e=="string"){let h=t;if(!h){const g=rt.rawSplit(e);h=G.getBestVersionForData(g,i)}r=rt.fromString(e,h||40)}else throw new Error("Invalid data");const n=G.getBestVersionForData(r,i);if(!n)throw new Error("The amount of data is too big to be stored in a QR Code");if(!t)t=n;else if(t<n)throw new Error(`
The chosen QR Code version cannot contain this amount of data.
Minimum version required to store current data is: `+n+`.
`);const s=pe(t,i,r),a=Z.getSymbolSize(t),u=new ue(a);return he(u,t),ge(u),me(u,t),ot(u,i,0),t>=7&&we(u,t),ye(u,s),isNaN(o)&&(o=at.getBestMask(u,ot.bind(null,u,i))),at.applyMask(o,u),ot(u,i,o),{modules:u,version:t,errorCorrectionLevel:i,maskPattern:o,segments:r}}Ct.create=function(t,i){if(typeof t>"u"||t==="")throw new Error("No input text");let o=nt.M,r,n;return typeof i<"u"&&(o=nt.from(i.errorCorrectionLevel,nt.M),r=G.from(i.version),n=at.from(i.maskPattern),i.toSJISFunc&&Z.setToSJISFunction(i.toSJISFunc)),Ce(t,r,o,n)};var Dt={},gt={};(function(e){function t(i){if(typeof i=="number"&&(i=i.toString()),typeof i!="string")throw new Error("Color should be defined as hex string");let o=i.slice().replace("#","").split("");if(o.length<3||o.length===5||o.length>8)throw new Error("Invalid hex color: "+i);(o.length===3||o.length===4)&&(o=Array.prototype.concat.apply([],o.map(function(n){return[n,n]}))),o.length===6&&o.push("F","F");const r=parseInt(o.join(""),16);return{r:r>>24&255,g:r>>16&255,b:r>>8&255,a:r&255,hex:"#"+o.slice(0,6).join("")}}e.getOptions=function(o){o||(o={}),o.color||(o.color={});const r=typeof o.margin>"u"||o.margin===null||o.margin<0?4:o.margin,n=o.width&&o.width>=21?o.width:void 0,s=o.scale||4;return{width:n,scale:n?4:s,margin:r,color:{dark:t(o.color.dark||"#000000ff"),light:t(o.color.light||"#ffffffff")},type:o.type,rendererOpts:o.rendererOpts||{}}},e.getScale=function(o,r){return r.width&&r.width>=o+r.margin*2?r.width/(o+r.margin*2):r.scale},e.getImageWidth=function(o,r){const n=e.getScale(o,r);return Math.floor((o+r.margin*2)*n)},e.qrToImageData=function(o,r,n){const s=r.modules.size,a=r.modules.data,u=e.getScale(s,n),h=Math.floor((s+n.margin*2)*u),g=n.margin*u,B=[n.color.light,n.color.dark];for(let p=0;p<h;p++)for(let w=0;w<h;w++){let E=(p*h+w)*4,m=n.color.light;if(p>=g&&w>=g&&p<h-g&&w<h-g){const y=Math.floor((p-g)/u),f=Math.floor((w-g)/u);m=B[a[y*s+f]?1:0]}o[E++]=m.r,o[E++]=m.g,o[E++]=m.b,o[E]=m.a}}})(gt);(function(e){const t=gt;function i(r,n,s){r.clearRect(0,0,n.width,n.height),n.style||(n.style={}),n.height=s,n.width=s,n.style.height=s+"px",n.style.width=s+"px"}function o(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}e.render=function(n,s,a){let u=a,h=s;typeof u>"u"&&(!s||!s.getContext)&&(u=s,s=void 0),s||(h=o()),u=t.getOptions(u);const g=t.getImageWidth(n.modules.size,u),B=h.getContext("2d"),p=B.createImageData(g,g);return t.qrToImageData(p.data,n,u),i(B,h,g),B.putImageData(p,0,0),h},e.renderToDataURL=function(n,s,a){let u=a;typeof u>"u"&&(!s||!s.getContext)&&(u=s,s=void 0),u||(u={});const h=e.render(n,s,u),g=u.type||"image/png",B=u.rendererOpts||{};return h.toDataURL(g,B.quality)}})(Dt);var vt={};const Be=gt;function pt(e,t){const i=e.a/255,o=t+'="'+e.hex+'"';return i<1?o+" "+t+'-opacity="'+i.toFixed(2).slice(1)+'"':o}function it(e,t,i){let o=e+t;return typeof i<"u"&&(o+=" "+i),o}function Ae(e,t,i){let o="",r=0,n=!1,s=0;for(let a=0;a<e.length;a++){const u=Math.floor(a%t),h=Math.floor(a/t);!u&&!n&&(n=!0),e[a]?(s++,a>0&&u>0&&e[a-1]||(o+=n?it("M",u+i,.5+h+i):it("m",r,0),r=0,n=!1),u+1<t&&e[a+1]||(o+=it("h",s),s=0)):r++}return o}vt.render=function(t,i,o){const r=Be.getOptions(i),n=t.modules.size,s=t.modules.data,a=n+r.margin*2,u=r.color.light.a?"<path "+pt(r.color.light,"fill")+' d="M0 0h'+a+"v"+a+'H0z"/>':"",h="<path "+pt(r.color.dark,"stroke")+' d="'+Ae(s,n,r.margin)+'"/>',g='viewBox="0 0 '+a+" "+a+'"',p='<svg xmlns="http://www.w3.org/2000/svg" '+(r.width?'width="'+r.width+'" height="'+r.width+'" ':"")+g+' shape-rendering="crispEdges">'+u+h+`</svg>
`;return typeof o=="function"&&o(null,p),p};const be=Ft,lt=Ct,Ut=Dt,Ie=vt;function mt(e,t,i,o,r){const n=[].slice.call(arguments,1),s=n.length,a=typeof n[s-1]=="function";if(!a&&!be())throw new Error("Callback required as last argument");if(a){if(s<2)throw new Error("Too few arguments provided");s===2?(r=i,i=t,t=o=void 0):s===3&&(t.getContext&&typeof r>"u"?(r=o,o=void 0):(r=o,o=i,i=t,t=void 0))}else{if(s<1)throw new Error("Too few arguments provided");return s===1?(i=t,t=o=void 0):s===2&&!t.getContext&&(o=i,i=t,t=void 0),new Promise(function(u,h){try{const g=lt.create(i,o);u(e(g,t,o))}catch(g){h(g)}})}try{const u=lt.create(i,o);r(null,e(u,t,o))}catch(u){r(u)}}J.create=lt.create;J.toCanvas=mt.bind(null,Ut.render);J.toDataURL=mt.bind(null,Ut.renderToDataURL);J.toString=mt.bind(null,function(e,t,i){return Ie.render(e,i)});const Ne=.1,Et=2.5,L=7;function st(e,t,i){return e===t?!1:(e-t<0?t-e:e-t)<=i+Ne}function Te(e,t){const i=Array.prototype.slice.call(J.create(e,{errorCorrectionLevel:t}).modules.data,0),o=Math.sqrt(i.length);return i.reduce((r,n,s)=>(s%o===0?r.push([n]):r[r.length-1].push(n))&&r,[])}const Se={generate({uri:e,size:t,logoSize:i,dotColor:o="#141414"}){const r="transparent",s=[],a=Te(e,"Q"),u=t/a.length,h=[{x:0,y:0},{x:1,y:0},{x:0,y:1}];h.forEach(({x:m,y})=>{const f=(a.length-L)*u*m,l=(a.length-L)*u*y,d=.45;for(let c=0;c<h.length;c+=1){const C=u*(L-c*2);s.push(T.b`
<rect
fill=${c===2?o:r}
width=${c===0?C-5:C}
rx= ${c===0?(C-5)*d:C*d}
ry= ${c===0?(C-5)*d:C*d}
stroke=${o}
stroke-width=${c===0?5:0}
height=${c===0?C-5:C}
x= ${c===0?l+u*c+5/2:l+u*c}
y= ${c===0?f+u*c+5/2:f+u*c}
/>
`)}});const g=Math.floor((i+25)/u),B=a.length/2-g/2,p=a.length/2+g/2-1,w=[];a.forEach((m,y)=>{m.forEach((f,l)=>{if(a[y][l]&&!(y<L&&l<L||y>a.length-(L+1)&&l<L||y<L&&l>a.length-(L+1))&&!(y>B&&y<p&&l>B&&l<p)){const d=y*u+u/2,c=l*u+u/2;w.push([d,c])}})});const E={};return w.forEach(([m,y])=>{var f;E[m]?(f=E[m])==null||f.push(y):E[m]=[y]}),Object.entries(E).map(([m,y])=>{const f=y.filter(l=>y.every(d=>!st(l,d,u)));return[Number(m),f]}).forEach(([m,y])=>{y.forEach(f=>{s.push(T.b`<circle cx=${m} cy=${f} fill=${o} r=${u/Et} />`)})}),Object.entries(E).filter(([m,y])=>y.length>1).map(([m,y])=>{const f=y.filter(l=>y.some(d=>st(l,d,u)));return[Number(m),f]}).map(([m,y])=>{y.sort((l,d)=>l<d?-1:1);const f=[];for(const l of y){const d=f.find(c=>c.some(C=>st(l,C,u)));d?d.push(l):f.push([l])}return[m,f.map(l=>[l[0],l[l.length-1]])]}).forEach(([m,y])=>{y.forEach(([f,l])=>{s.push(T.b`
<line
x1=${m}
x2=${m}
y1=${f}
y2=${l}
stroke=${o}
stroke-width=${u/(Et/2)}
stroke-linecap="round"
/>
`)})}),s}},Me=T.i`
:host {
position: relative;
user-select: none;
display: block;
overflow: hidden;
aspect-ratio: 1 / 1;
width: var(--local-size);
}
:host([data-theme='dark']) {
border-radius: clamp(0px, var(--wui-border-radius-l), 40px);
background-color: var(--wui-color-inverse-100);
padding: var(--wui-spacing-l);
}
:host([data-theme='light']) {
box-shadow: 0 0 0 1px var(--wui-color-bg-125);
background-color: var(--wui-color-bg-125);
}
:host([data-clear='true']) > wui-icon {
display: none;
}
svg:first-child,
wui-image,
wui-icon {
position: absolute;
top: 50%;
left: 50%;
transform: translateY(-50%) translateX(-50%);
}
wui-image {
width: 25%;
height: 25%;
border-radius: var(--wui-border-radius-xs);
}
wui-icon {
width: 100%;
height: 100%;
color: var(--local-icon-color) !important;
transform: translateY(-50%) translateX(-50%) scale(0.25);
}
`;var D=function(e,t,i,o){var r=arguments.length,n=r<3?t:o===null?o=Object.getOwnPropertyDescriptor(t,i):o,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(e,t,i,o);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(n=(r<3?s(n):r>3?s(t,i,n):s(t,i))||n);return r>3&&n&&Object.defineProperty(t,i,n),n};const Re="#3396ff";let S=class extends T.i$1{constructor(){super(...arguments),this.uri="",this.size=0,this.theme="dark",this.imageSrc=void 0,this.alt=void 0,this.arenaClear=void 0,this.farcaster=void 0}render(){return this.dataset.theme=this.theme,this.dataset.clear=String(this.arenaClear),this.style.cssText=`
--local-size: ${this.size}px;
--local-icon-color: ${this.color??Re}
`,T.x`${this.templateVisual()} ${this.templateSvg()}`}templateSvg(){const t=this.theme==="light"?this.size:this.size-32;return T.b`
<svg height=${t} width=${t}>
${Se.generate({uri:this.uri,size:t,logoSize:this.arenaClear?0:t/4,dotColor:this.color})}
</svg>
`}templateVisual(){return this.imageSrc?T.x`<wui-image src=${this.imageSrc} alt=${this.alt??"logo"}></wui-image>`:this.farcaster?T.x`<wui-icon
class="farcaster"
size="inherit"
color="inherit"
name="farcaster"
></wui-icon>`:T.x`<wui-icon size="inherit" color="inherit" name="walletConnect"></wui-icon>`}};S.styles=[T.resetStyles,Me];D([_.n()],S.prototype,"uri",void 0);D([_.n({type:Number})],S.prototype,"size",void 0);D([_.n()],S.prototype,"theme",void 0);D([_.n()],S.prototype,"imageSrc",void 0);D([_.n()],S.prototype,"alt",void 0);D([_.n()],S.prototype,"color",void 0);D([_.n({type:Boolean})],S.prototype,"arenaClear",void 0);D([_.n({type:Boolean})],S.prototype,"farcaster",void 0);S=D([_.customElement("wui-qr-code")],S);
//# sourceMappingURL=index-Ch6hp36E.cjs.map