@vbotma/sdk 3.3.2 → 3.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- var $c=Object.defineProperty;var Mc=(u,ee,Be)=>ee in u?$c(u,ee,{enumerable:!0,configurable:!0,writable:!0,value:Be}):u[ee]=Be;var s=(u,ee,Be)=>Mc(u,typeof ee!="symbol"?ee+"":ee,Be);this.tmajs=this.tmajs||{};this.tmajs.sdk=(function(u){"use strict";let ee;function Be(t,e){ee?ee.set(t,e):e()}function et(t){if(ee)return t();ee=new Map;try{t()}finally{ee.forEach(e=>e()),ee=void 0}}function D(t,e){e||(e={});const n=e.equals||Object.is;let r=[],i=t;const o=p=>{if(!n(i,p)){const h=i;i=p,Be(l,()=>{[...r].forEach(([f,g])=>{f(p,h),g&&c(f,!0)})})}};function a(p){const h=typeof p!="object"?{once:p}:p;return{once:h.once||!1,signal:h.signal||!1}}const c=(p,h)=>{const f=a(h),g=r.findIndex(([v,F])=>v===p&&F.once===f.once&&F.signal===f.signal);g>=0&&r.splice(g,1)},l=Object.assign(function(){return ni(l),i},{destroy(){r=[]},set:o,reset(){o(t)},sub(p,h){return r.push([p,a(h)]),()=>c(p,h)},unsub:c,unsubAll(){r=r.filter(p=>p[1].signal)}});return l}const je=[];function ni(t){je.length&&je[je.length-1].add(t)}function C(t,e){let n=new Set,r;function i(){return r||(r=D(a(),e))}function o(){i().set(a())}function a(){n.forEach(p=>{p.unsub(o,{signal:!0})});const c=new Set;let l;je.push(c);try{l=t()}finally{je.pop()}return c.forEach(p=>{p.sub(o,{signal:!0})}),n=c,l}return Object.assign(function(){return i()()},{destroy(){i().destroy()},sub(...c){return i().sub(...c)},unsub(...c){i().unsub(...c)},unsubAll(...c){i().unsubAll(...c)}})}var ri=function(t,e,n){if(n||arguments.length===2)for(var r=0,i=e.length,o;r<i;r++)(o||!(r in e))&&(o||(o=Array.prototype.slice.call(e,0,r)),o[r]=e[r]);return t.concat(o||Array.prototype.slice.call(e))};function si(t){return t}function En(t,e,n,r,i,o,a,c,l){switch(arguments.length){case 1:return t;case 2:return function(){return e(t.apply(this,arguments))};case 3:return function(){return n(e(t.apply(this,arguments)))};case 4:return function(){return r(n(e(t.apply(this,arguments))))};case 5:return function(){return i(r(n(e(t.apply(this,arguments)))))};case 6:return function(){return o(i(r(n(e(t.apply(this,arguments))))))};case 7:return function(){return a(o(i(r(n(e(t.apply(this,arguments)))))))};case 8:return function(){return c(a(o(i(r(n(e(t.apply(this,arguments))))))))};case 9:return function(){return l(c(a(o(i(r(n(e(t.apply(this,arguments)))))))))}}}function d(t,e,n,r,i,o,a,c,l){switch(arguments.length){case 1:return t;case 2:return e(t);case 3:return n(e(t));case 4:return r(n(e(t)));case 5:return i(r(n(e(t))));case 6:return o(i(r(n(e(t)))));case 7:return a(o(i(r(n(e(t))))));case 8:return c(a(o(i(r(n(e(t)))))));case 9:return l(c(a(o(i(r(n(e(t))))))));default:{for(var p=arguments[0],h=1;h<arguments.length;h++)p=arguments[h](p);return p}}}var He=function(t,e){var n=typeof t=="number"?function(r){return r.length>=t}:t;return function(){var r=Array.from(arguments);return n(arguments)?e.apply(this,r):function(i){return e.apply(void 0,ri([i],r,!1))}}},ii={_tag:"None"},oi=function(t){return{_tag:"Some",value:t}},ai=function(t){return t._tag==="Left"},qn=function(t){return{_tag:"Left",left:t}},An=function(t){return{_tag:"Right",right:t}},gt={};function ui(t,e){return function(n){return function(r){return t.ap(t.map(r,function(i){return function(o){return e.ap(i,o)}}),n)}}}function ci(t,e){return function(n){return function(r){return t.map(r,function(i){return e.map(i,n)})}}}function wt(t){return function(e,n){return function(r){return t.chain(r,function(i){return t.map(n(i),function(o){var a;return Object.assign({},i,(a={},a[e]=o,a))})})}}}var Fe=ii,$e=oi,li=function(t,e){return d(t,hi(e))},pi=function(t,e){return d(t,_i(e))},di="Option",hi=function(t){return function(e){return De(e)?Fe:$e(t(e.value))}},fi=$e,_i=function(t){return function(e){return De(e)||De(t)?Fe:$e(e.value(t.value))}},bi=He(2,function(t,e){return De(t)?Fe:e(t.value)}),mi={URI:di,map:li,ap:pi,chain:bi},De=function(t){return t._tag==="None"},gi=function(t,e){return function(n){return De(n)?t():e(n.value)}},vt=gi,wi=fi(gt),In=wt(mi),P=qn,E=An,yt=He(2,function(t,e){return me(t)?t:e(t.right)}),St=function(t,e){return d(t,Q(e))},Bn=function(t,e){return d(t,Fi(e))},Ft="Either",Q=function(t){return function(e){return me(e)?e:E(t(e.right))}},vi={URI:Ft,map:St},yi=E,Si=function(t){return function(e){return me(e)?e:me(t)?t:E(e.right(t.right))}},Fi=Si,Ci={URI:Ft,map:St,ap:Bn},ki={URI:Ft,map:St,ap:Bn,chain:yt},Ei=function(t,e){return function(n){return me(n)?P(t(n.left)):E(e(n.right))}},qi=function(t){return function(e){return me(e)?P(t(e.left)):e}},me=ai,Ct=function(t,e){return function(n){return me(n)?t(n.left):e(n.right)}},Ai=Ct,le=Ct,Ii=le,Me=function(t,e){try{return E(t())}catch(n){return P(e(n))}},Bi=yi(gt),$i=wt(ki),$n=$i,Mi=yt,Pi=yt;function Ri(t){return En(E,t.of)}function Ti(t){return En(P,t.of)}function Li(t){return ci(t,vi)}function Vi(t){return ui(t,Ci)}function Oi(t){return function(e,n){return t.chain(e,function(r){return me(r)?t.of(r):n(r.right)})}}function ji(t){return function(e,n,r){return t.map(e,Ei(n,r))}}function Hi(t){return function(e,n){return function(r){return t.map(r,le(e,n))}}}var Di=function(t){return Me(function(){return JSON.parse(t)},si)},kt=function(t,e){return d(t,Ui(e))},Mn=function(t,e){return d(t,Wi(e))},Ui=function(t){return function(e){return function(){return Promise.resolve().then(e).then(t)}}},Wi=function(t){return function(e){return function(){return Promise.all([Promise.resolve().then(e),Promise.resolve().then(t)]).then(function(n){var r=n[0],i=n[1];return r(i)})}}},Et=function(t){return function(){return Promise.resolve(t)}},Ni=He(2,function(t,e){return function(){return Promise.resolve().then(t).then(function(n){return e(n)()})}}),qt="Task",At={URI:qt,map:kt},Pn={of:Et},Gi={URI:qt,map:kt,ap:Mn},zi={URI:qt,map:kt,of:Et,ap:Mn,chain:Ni},Ki=function(t,e,n,r){function i(o){return o instanceof n?o:new n(function(a){a(o)})}return new(n||(n=Promise))(function(o,a){function c(h){try{p(r.next(h))}catch(f){a(f)}}function l(h){try{p(r.throw(h))}catch(f){a(f)}}function p(h){h.done?o(h.value):i(h.value).then(c,l)}p((r=r.apply(t,e||[])).next())})},Qi=function(t,e){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function c(p){return function(h){return l([p,h])}}function l(p){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,p[0]&&(n=0)),n;)try{if(r=1,i&&(o=p[0]&2?i.return:p[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,p[1])).done)return o;switch(i=0,o&&(p=[p[0]&2,o.value]),p[0]){case 0:case 1:o=p;break;case 4:return n.label++,{value:p[1],done:!1};case 5:n.label++,i=p[1],p=[0];continue;case 7:p=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(p[0]===6||p[0]===2)){n=0;continue}if(p[0]===3&&(!o||p[1]>o[0]&&p[1]<o[3])){n.label=p[1];break}if(p[0]===6&&n.label<o[1]){n.label=o[1],o=p;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(p);break}o[2]&&n.ops.pop(),n.trys.pop();continue}p=e.call(t,n)}catch(h){p=[6,h],i=0}finally{r=o=0}if(p[0]&5)throw p[1];return{value:p[0]?p[1]:void 0,done:!0}}},U=Ti(Pn),T=Ri(Pn),Ue=Et,tt=Hi(At),Ji=tt,Rn=function(t,e){return function(){return Ki(void 0,void 0,void 0,function(){var n;return Qi(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,t().then(An)];case 1:return[2,r.sent()];case 2:return n=r.sent(),[2,qn(e(n))];case 3:return[2]}})})}},Zi=function(t,e){return d(t,I(e))},Yi=function(t,e){return d(t,Xi(e))},I=Li(At),We=He(3,ji(At)),Xi=Vi(Gi),It=He(2,Oi(zi)),xi=T,eo="TaskEither",to={URI:eo,map:Zi,ap:Yi,chain:It},no=xi(gt),ro=wt(to),nt=ro,ne=It,pe=It;function te(t){return typeof t=="function"?t():t}class Ne{constructor({onMounted:e,restoreState:n,initialState:r,onUnmounted:i,isPageReload:o}){s(this,"_isMounted",D(!1));s(this,"isMounted",C(this._isMounted));s(this,"mount");s(this,"unmount");this.mount=()=>{if(this.isMounted())return E(void 0);const a=te(o)?n():void 0,c=a?E(a):typeof r=="function"?r():E(r);return d(c,Q(l=>{et(()=>{this._isMounted.set(!0),e==null||e(l)})}))},this.unmount=()=>{this._isMounted()&&et(()=>{this._isMounted.set(!1),i==null||i()})}}}function Bt(t){const e={};for(const n in t){const r=t[n];r!==void 0&&(e[n]=r)}return e}function $t(t,e){const n=Object.keys(t),r=Object.keys(e);return n.length!==r.length?!1:n.every(i=>Object.prototype.hasOwnProperty.call(e,i)&&t[i]===e[i])}class ge{constructor({initialState:e,onChange:n}){s(this,"_state");s(this,"state");s(this,"setState",e=>{const n={...this.state(),...Bt(e)};$t(n,this.state())||this._state.set(n)});this._state=D(e,{equals:$t}),this.state=C(this._state),this.state.sub(n)}getter(e){return C(()=>this._state()[e])}hasDiff(e){return!$t({...this.state(),...Bt(e)},this.state())}}let de;function Mt(t){return{lang:(t==null?void 0:t.lang)??(de==null?void 0:de.lang),message:t==null?void 0:t.message,abortEarly:(t==null?void 0:t.abortEarly)??(de==null?void 0:de.abortEarly),abortPipeEarly:(t==null?void 0:t.abortPipeEarly)??(de==null?void 0:de.abortPipeEarly)}}let Pt;function so(t){return Pt==null?void 0:Pt.get(t)}let Rt;function io(t){return Rt==null?void 0:Rt.get(t)}let Tt;function oo(t,e){var n;return(n=Tt==null?void 0:Tt.get(t))==null?void 0:n.get(e)}function ao(t){var n,r;const e=typeof t;return e==="string"?`"${t}"`:e==="number"||e==="bigint"||e==="boolean"?`${t}`:e==="object"||e==="function"?(t&&((r=(n=Object.getPrototypeOf(t))==null?void 0:n.constructor)==null?void 0:r.name))??"null":e}function Z(t,e,n,r,i){const o=i&&"input"in i?i.input:n.value,a=(i==null?void 0:i.expected)??t.expects??null,c=(i==null?void 0:i.received)??ao(o),l={kind:t.kind,type:t.type,input:o,expected:a,received:c,message:`Invalid ${e}: ${a?`Expected ${a} but r`:"R"}eceived ${c}`,requirement:t.requirement,path:i==null?void 0:i.path,issues:i==null?void 0:i.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},p=t.kind==="schema",h=(i==null?void 0:i.message)??t.message??oo(t.reference,l.lang)??(p?io(l.lang):null)??r.message??so(l.lang);h!==void 0&&(l.message=typeof h=="function"?h(l):h),p&&(n.typed=!1),n.issues?n.issues.push(l):n.issues=[l]}function Y(t){return{version:1,vendor:"valibot",validate(e){return t["~run"]({value:e},Mt())}}}function Tn(t,e){return Object.hasOwn(t,e)&&e!=="__proto__"&&e!=="prototype"&&e!=="constructor"}function uo(t,e){const n=[...new Set(t)];return n.length>1?`(${n.join(` ${e} `)})`:n[0]??"never"}var co=class extends Error{constructor(t){super(t[0].message),this.name="ValiError",this.issues=t}};function rt(t,e){return{kind:"validation",type:"check",reference:rt,async:!1,expects:null,requirement:t,message:e,"~run"(n,r){return n.typed&&!this.requirement(n.value)&&Z(this,"input",n,r),n}}}function Lt(t){return{kind:"validation",type:"integer",reference:Lt,async:!1,expects:null,requirement:Number.isInteger,message:t,"~run"(e,n){return e.typed&&!this.requirement(e.value)&&Z(this,"integer",e,n),e}}}function he(t){return{kind:"transformation",type:"transform",reference:he,async:!1,operation:t,"~run"(e){return e.value=this.operation(e.value),e}}}function lo(t,e,n){return typeof t.fallback=="function"?t.fallback(e,n):t.fallback}function Vt(t,e,n){return typeof t.default=="function"?t.default(e,n):t.default}function Ot(t,e){return!t["~run"]({value:e},{abortEarly:!0}).issues}function Ln(){return{kind:"schema",type:"any",reference:Ln,expects:"any",async:!1,get"~standard"(){return Y(this)},"~run"(t){return t.typed=!0,t}}}function Vn(t,e){return{kind:"schema",type:"array",reference:Vn,expects:"Array",async:!1,item:t,message:e,get"~standard"(){return Y(this)},"~run"(n,r){var o;const i=n.value;if(Array.isArray(i)){n.typed=!0,n.value=[];for(let a=0;a<i.length;a++){const c=i[a],l=this.item["~run"]({value:c},r);if(l.issues){const p={type:"array",origin:"value",input:i,key:a,value:c};for(const h of l.issues)h.path?h.path.unshift(p):h.path=[p],(o=n.issues)==null||o.push(h);if(n.issues||(n.issues=l.issues),r.abortEarly){n.typed=!1;break}}l.typed||(n.typed=!1),n.value.push(l.value)}}else Z(this,"type",n,r);return n}}}function Ce(t){return{kind:"schema",type:"boolean",reference:Ce,expects:"boolean",async:!1,message:t,get"~standard"(){return Y(this)},"~run"(e,n){return typeof e.value=="boolean"?e.typed=!0:Z(this,"type",e,n),e}}}function st(t){return{kind:"schema",type:"date",reference:st,expects:"Date",async:!1,message:t,get"~standard"(){return Y(this)},"~run"(e,n){return e.value instanceof Date?isNaN(e.value)?Z(this,"type",e,n,{received:'"Invalid Date"'}):e.typed=!0:Z(this,"type",e,n),e}}}function jt(t){return{kind:"schema",type:"function",reference:jt,expects:"Function",async:!1,message:t,get"~standard"(){return Y(this)},"~run"(e,n){return typeof e.value=="function"?e.typed=!0:Z(this,"type",e,n),e}}}function Ht(t,e){return{kind:"schema",type:"instance",reference:Ht,expects:t.name,async:!1,class:t,message:e,get"~standard"(){return Y(this)},"~run"(n,r){return n.value instanceof this.class?n.typed=!0:Z(this,"type",n,r),n}}}function N(t,e){return{kind:"schema",type:"loose_object",reference:N,expects:"Object",async:!1,entries:t,message:e,get"~standard"(){return Y(this)},"~run"(n,r){var o;const i=n.value;if(i&&typeof i=="object"){n.typed=!0,n.value={};for(const a in this.entries){const c=this.entries[a];if(a in i||(c.type==="exact_optional"||c.type==="optional"||c.type==="nullish")&&c.default!==void 0){const l=a in i?i[a]:Vt(c),p=c["~run"]({value:l},r);if(p.issues){const h={type:"object",origin:"value",input:i,key:a,value:l};for(const f of p.issues)f.path?f.path.unshift(h):f.path=[h],(o=n.issues)==null||o.push(f);if(n.issues||(n.issues=p.issues),r.abortEarly){n.typed=!1;break}}p.typed||(n.typed=!1),n.value[a]=p.value}else if(c.fallback!==void 0)n.value[a]=lo(c);else if(c.type!=="exact_optional"&&c.type!=="optional"&&c.type!=="nullish"&&(Z(this,"key",n,r,{input:void 0,expected:`"${a}"`,path:[{type:"object",origin:"key",input:i,key:a,value:i[a]}]}),r.abortEarly))break}if(!n.issues||!r.abortEarly)for(const a in i)Tn(i,a)&&!(a in this.entries)&&(n.value[a]=i[a])}else Z(this,"type",n,r);return n}}}function Pe(t,e){return{kind:"schema",type:"nullish",reference:Pe,expects:`(${t.expects} | null | undefined)`,async:!1,wrapped:t,default:e,get"~standard"(){return Y(this)},"~run"(n,r){return(n.value===null||n.value===void 0)&&(this.default!==void 0&&(n.value=Vt(this,n,r)),n.value===null||n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function we(t){return{kind:"schema",type:"number",reference:we,expects:"number",async:!1,message:t,get"~standard"(){return Y(this)},"~run"(e,n){return typeof e.value=="number"&&!isNaN(e.value)?e.typed=!0:Z(this,"type",e,n),e}}}function B(t,e){return{kind:"schema",type:"optional",reference:B,expects:`(${t.expects} | undefined)`,async:!1,wrapped:t,default:e,get"~standard"(){return Y(this)},"~run"(n,r){return n.value===void 0&&(this.default!==void 0&&(n.value=Vt(this,n,r)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function Dt(t,e,n){return{kind:"schema",type:"record",reference:Dt,expects:"Object",async:!1,key:t,value:e,message:n,get"~standard"(){return Y(this)},"~run"(r,i){var a,c;const o=r.value;if(o&&typeof o=="object"){r.typed=!0,r.value={};for(const l in o)if(Tn(o,l)){const p=o[l],h=this.key["~run"]({value:l},i);if(h.issues){const g={type:"object",origin:"key",input:o,key:l,value:p};for(const v of h.issues)v.path=[g],(a=r.issues)==null||a.push(v);if(r.issues||(r.issues=h.issues),i.abortEarly){r.typed=!1;break}}const f=this.value["~run"]({value:p},i);if(f.issues){const g={type:"object",origin:"value",input:o,key:l,value:p};for(const v of f.issues)v.path?v.path.unshift(g):v.path=[g],(c=r.issues)==null||c.push(v);if(r.issues||(r.issues=f.issues),i.abortEarly){r.typed=!1;break}}(!h.typed||!f.typed)&&(r.typed=!1),h.typed&&(r.value[h.value]=f.value)}}else Z(this,"type",r,i);return r}}}function S(t){return{kind:"schema",type:"string",reference:S,expects:"string",async:!1,message:t,get"~standard"(){return Y(this)},"~run"(e,n){return typeof e.value=="string"?e.typed=!0:Z(this,"type",e,n),e}}}function On(t){let e;if(t)for(const n of t)e?e.push(...n.issues):e=n.issues;return e}function it(t,e){return{kind:"schema",type:"union",reference:it,expects:uo(t.map(n=>n.expects),"|"),async:!1,options:t,message:e,get"~standard"(){return Y(this)},"~run"(n,r){let i,o,a;for(const c of this.options){const l=c["~run"]({value:n.value},r);if(l.typed)if(l.issues)o?o.push(l):o=[l];else{i=l;break}else a?a.push(l):a=[l]}if(i)return i;if(o){if(o.length===1)return o[0];Z(this,"type",n,r,{issues:On(o)}),n.typed=!0}else{if((a==null?void 0:a.length)===1)return a[0];Z(this,"type",n,r,{issues:On(a)})}return n}}}function Ut(){return{kind:"schema",type:"unknown",reference:Ut,expects:"unknown",async:!1,get"~standard"(){return Y(this)},"~run"(t){return t.typed=!0,t}}}function fe(t,e,n){const r=t["~run"]({value:e},Mt(n));if(r.issues)throw new co(r.issues);return r.value}function ae(...t){return{...t[0],pipe:t,get"~standard"(){return Y(this)},"~run"(e,n){for(const r of t)if(r.kind!=="metadata"){if(e.issues&&(r.kind==="schema"||r.kind==="transformation")){e.typed=!1;break}(!e.issues||!n.abortEarly&&!n.abortPipeEarly)&&(e=r["~run"](e,n))}return e}}}function Wt(t,e,n){const r=t["~run"]({value:e},Mt(n));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}var po=Object.defineProperty,ho=(t,e,n)=>e in t?po(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,jn=(t,e,n)=>ho(t,typeof e!="symbol"?e+"":e,n),fo=Object.defineProperty,_o=(t,e,n)=>e in t?fo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Nt=(t,e,n)=>_o(t,typeof e!="symbol"?e+"":e,n);function Hn(t){return e=>e instanceof t}function Dn(t,e){const n=class extends Error{constructor(...i){const o=typeof e=="function"?e(...i):typeof e=="string"?[e]:e||[];super(...o),this.name=t}};Nt(n,"is",Hn(n));let r=n;return Object.defineProperty(r,"name",{value:t}),r}function bo(t,e,n){const r=class extends Dn(t,n){constructor(...o){super(...o),Nt(this,"data"),this.data=e(...o)}};Nt(r,"is",Hn(r));let i=r;return Object.defineProperty(i,"name",{value:t}),i}let Un=class extends Dn("CancelledError","Promise was canceled"){},Gt=class extends bo("TimeoutError",e=>({timeout:e}),(e,n)=>[`Timeout reached: ${e}ms`,{cause:n}]){};const mo=Symbol("resolved");function go(t){return{tag:mo,value:t}}function Wn(t,e){return t.reject=e.reject,t.resolve=e.resolve,t}class ve extends Promise{constructor(e,n){let r,i,o,a;typeof e=="function"?(o=e,a=n||{}):a=e||{};let c,l;const p=()=>!!l,h=()=>!!c;let f={};const g=[],v=()=>{g.forEach(w=>w()),g.splice(0,g.length),f={}},F=new AbortController,k=()=>h()||p();super((w,y)=>{const{abortOnResolve:m=!0,abortOnReject:j=!0}=a;i=A=>{var O,L;k()||(w(A),c=[A],(O=f.resolved)==null||O.forEach(G=>G(A)),(L=f.finalized)==null||L.forEach(G=>G({kind:"resolved",result:A})),v(),m&&F.abort(go(A)))},r=A=>{var O,L;k()||(y(A),l=[A],(O=f.rejected)==null||O.forEach(G=>G(A)),(L=f.finalized)==null||L.forEach(G=>G({kind:"rejected",reason:A})),v(),j&&F.abort(A))};const{abortSignal:H}=a;if(H){if(H.aborted)return r(H.reason);const A=()=>{r(H.reason)};H.addEventListener("abort",A,!0),g.push(()=>{H.removeEventListener("abort",A,!0)})}const{timeout:W}=a;if(W){const A=setTimeout(()=>{r(new Gt(W))},W);g.push(()=>{clearTimeout(A)})}try{const A=()=>{},O=o&&o(i,r,{abortSignal:F.signal,get isRejected(){return p()},get isResolved(){return h()},on(L,G){if(c||l){if(L==="finalized"){const Oe=c?{kind:"resolved",result:c[0]}:{kind:"rejected",reason:l[0]};G(Oe)}else L==="resolved"&&c?G(c[0]):L==="rejected"&&l&&G(l[0]);return A}return f[L]||(f[L]=[]),f[L].push(G),()=>{const Oe=f[L]||[],xe=Oe.indexOf(G);xe>=0&&Oe.splice(xe,1)}},get result(){return c==null?void 0:c[0]},get rejectReason(){return l==null?void 0:l[0]},throwIfRejected(){if(l)throw l[0]}});O instanceof Promise&&O.catch(r)}catch(A){r(A)}}),jn(this,"reject"),jn(this,"resolve"),this.reject=r,this.resolve=i}static fn(e,n){return new ve(async(r,i,o)=>{try{r(await e(o))}catch(a){i(a)}},n)}static resolve(e){return this.fn(()=>e)}static reject(e){return new ve((n,r)=>{r(e)})}cancel(){this.reject(new Un)}catch(e){return this.then(void 0,e)}finally(e){return Wn(super.finally(e),this)}then(e,n){return Wn(super.then(e,n),this)}}function Nn(t){return t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function wo(t){return t.replace(/_[a-z]/g,e=>e[1].toUpperCase())}function vo(t){return Object.entries(t).reduce((e,[n,r])=>(e[wo(n)]=r,e),{})}function zt(t){const e=vo(t);for(const n in e){const r=e[n];r&&typeof r=="object"&&!(r instanceof Date)&&(e[n]=Array.isArray(r)?r.map(zt):zt(r))}return e}function yo(t){return t.replace(/_([a-z])/g,(e,n)=>`-${n.toLowerCase()}`)}function Gn(t){return`tapps/${t}`}function ot(t,e){sessionStorage.setItem(Gn(t),JSON.stringify(e))}function zn(t){const e=sessionStorage.getItem(Gn(t));try{return e?JSON.parse(e):void 0}catch{}}function Ge(...t){const e=t.flat(1);return[e.push.bind(e),()=>{e.forEach(n=>{n()})}]}function Kn(t,e){e||(e={});const{textColor:n,bgColor:r,shouldLog:i}=e,o=i===void 0?!0:i,a=typeof o=="boolean"?()=>o:o,c=(l,p,...h)=>{if(p||a()){const f="font-weight:bold;padding:0 5px;border-radius:100px",[g,v,F]={log:["#0089c3","white","INFO"],error:["#ff0000F0","white","ERR"],warn:["#D38E15","white","WARN"]}[l];console[l](`%c${F} ${Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3,timeZone:"UTC"}).format(new Date)}%c %c${t}`,`${f};background-color:${g};color:${v}`,"",`${f};${n?`color:${n};`:""}${r?`background-color:${r}`:""}`,...h)}};return[["log","forceLog"],["warn","forceWarn"],["error","forceError"]].reduce((l,[p,h])=>(l[p]=c.bind(void 0,p,!1),l[h]=c.bind(void 0,p,!0),l),{})}function ze(t){const e=n=>{throw n};return typeof t=="function"?ve.resolve(d(t,tt(e,n=>n))()):d(t,le(e,n=>n))}function re(t){return Object.assign((...e)=>ze(t(...e)),t)}const Re=Object.assign((t,e)=>d(Rn(()=>new ve((n,r,i)=>t(o=>n(E(o)),o=>n(P(o)),i),e),n=>n),pe(le(U,T))),{fn:(t,e)=>Re((n,r,i)=>{const o=t(i);d(typeof o=="function"?o:Ue(o),Ji(r,n))()},e)});var So=Object.defineProperty,Fo=(t,e,n)=>e in t?So(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Kt=(t,e,n)=>Fo(t,typeof e!="symbol"?e+"":e,n);function Qn(t){return e=>e instanceof t}function K(t,e){const n=class extends Error{constructor(...o){const a=typeof e=="function"?e(...o):typeof e=="string"?[e]:e||[];super(...a),this.name=t}};Kt(n,"is",Qn(n));let r=n;return Object.defineProperty(r,"name",{value:t}),r}function at(t,e,n){const r=class extends K(t,n){constructor(...a){super(...a),Kt(this,"data"),this.data=e(...a)}};Kt(r,"is",Qn(r));let i=r;return Object.defineProperty(i,"name",{value:t}),i}function Co(t){const e=n=>{const r={};return new URLSearchParams(n).forEach((i,o)=>{const a=r[o];Array.isArray(a)?a.push(i):a===void 0?r[o]=i:r[o]=[a,i]}),fe(t,r)};return ae(it([S(),Ht(URLSearchParams)]),rt(n=>{try{return e(n),!0}catch{return!1}},"The value doesn't match required schema"),he(e))}function ko(t){return ae(S(),rt(e=>{try{return JSON.parse(e),!0}catch{return!1}},"Input is not a valid JSON value"),he(JSON.parse),t)}function ue(t){return ae(S(),ko(t))}function Qt(t){return ae(it([S(),Ht(URLSearchParams)]),Co(t))}function ut(t){return e=>t.test(e)}const Jn=ut(/^#[\da-f]{3}$/i),Zn=ut(/^#[\da-f]{4}$/i),Ke=ut(/^#[\da-f]{6}$/i),Yn=ut(/^#[\da-f]{8}$/i);function Xn(t){return[Ke,Yn,Jn,Zn].some(e=>e(t))}function xn(t){let e="#";for(let n=0;n<t.length-1;n+=1)e+=t[1+n].repeat(2);return e}function ct(t){const e=t.replace(/\s/g,"").toLowerCase();if(/^#[\da-f]{3}$/i.test(e))return E(xn(e.toLowerCase()+"f"));if(/^#[\da-f]{4}$/i.test(e))return E(xn(e.toLowerCase()));if(/^#[\da-f]{6}$/i.test(e))return E(e.toLowerCase()+"ff");if(/^#[\da-f]{8}$/i.test(e))return E(e.toLowerCase());const n=e.match(/^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/)||e.match(/^rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),(\d{1,3})\)$/);return n?E(n.slice(1).reduce((r,i)=>r+parseInt(i,10).toString(16).padStart(2,"0"),"#").padEnd(9,"f")):P(new Error(`Value "${t}" does not satisfy any of known RGB formats.`))}function er(t){return d(ct(t),Q(e=>e.slice(0,7)))}const Eo=re(er),qo=re(ct);function Ao(){return N({id:we(),photo_url:B(S()),type:S(),title:S(),username:B(S())})}function tr(){return N({added_to_attachment_menu:B(Ce()),allows_write_to_pm:B(Ce()),first_name:S(),id:we(),is_bot:B(Ce()),is_premium:B(Ce()),last_name:B(S()),language_code:B(S()),photo_url:B(S()),username:B(S())})}function Io(){return N({projectCode:S(),uid:S(),sessionId:S(),rootToken:S()})}function Bo(){return N({auth_date:ae(S(),he(t=>new Date(Number(t)*1e3)),st()),can_send_after:B(ae(S(),he(Number),Lt())),chat:B(ue(Ao())),chat_type:B(S()),chat_instance:B(S()),hash:B(S()),query_id:B(S()),receiver:B(ue(tr())),start_param:B(S()),signature:B(S()),user:B(ue(tr())),auth:B(ue(Io()))})}function nr(){return Qt(Bo())}function Jt(){return Dt(S(),ae(it([S(),we()]),he(t=>typeof t=="number"?`#${(t&16777215).toString(16).padStart(6,"0")}`:t),rt(Xn)))}function $o(){const t=B(ae(S(),he(e=>e==="1")));return N({vbWebAppBotInline:t,vbWebAppData:B(nr()),vbWebAppDefaultColors:B(ue(Jt())),vbWebAppFullscreen:t,vbWebAppPlatform:S(),vbWebAppShowSettings:t,vbWebAppStartParam:B(S()),vbWebAppThemeParams:ue(Jt()),vbWebAppVersion:S()})}function Mo(){return Qt($o())}function Zt(){return N({eventType:S(),eventData:B(Ut())})}function rr(t){return Me(()=>fe(nr(),t),e=>e)}function lt(t){return Me(()=>fe(Mo(),t),e=>e)}const Po=re(rr),Yt=re(lt);function sr(t,e){return e||(e=(n,r)=>JSON.stringify(r)),new URLSearchParams(Object.entries(t).reduce((n,[r,i])=>(Array.isArray(i)?n.push(...i.map(o=>[r,String(o)])):i!=null&&n.push([r,i instanceof Date?(i.getTime()/1e3|0).toString():typeof i=="string"||typeof i=="number"?String(i):typeof i=="boolean"?i?"1":"0":e(r,i)]),n),[])).toString()}function ir(t){return sr(t)}function Xt(t){return sr(t,(e,n)=>e==="vbWebAppData"?ir(n):JSON.stringify(n))}function Ro(t){return{all:t=t||new Map,on:function(e,n){var r=t.get(e);r?r.push(n):t.set(e,[n])},off:function(e,n){var r=t.get(e);r&&(n?r.splice(r.indexOf(n)>>>0,1):t.set(e,[]))},emit:function(e,n){var r=t.get(e);r&&r.slice().map(function(i){i(n)}),(r=t.get("*"))&&r.slice().map(function(i){i(e,n)})}}}function or(t){return Ot(N({VBotWebviewProxy:N({postEvent:jt()})}),t)}function xt(){try{return window.self!==window.top}catch{return!0}}class ar extends K("MethodUnsupportedError",(e,n)=>[`Method "${e}" is unsupported in Mini Apps version ${n}`]){}class ur extends K("MethodParameterUnsupportedError",(e,n,r)=>[`Parameter "${n}" of "${e}" method is unsupported in Mini Apps version ${r}`]){}class cr extends at("LaunchParamsRetrieveError",e=>({errors:e}),e=>[["Unable to retrieve launch parameters from any known source. You should pass correct parameters to Mini App","","Collected errors:",...e.map(({source:n,error:r})=>`Source: ${n} / ${r instanceof Error?r.message:String(r)}`)].join(`
2
- `)]){}class en extends K("InvalidLaunchParamsError",(e,n)=>[`Invalid value for launch params: ${e}`,{cause:n}]){}class tn extends K("UnknownEnvError"){}class lr extends K("InvokeCustomMethodError",e=>[`Server returned error: ${e}`]){}const pr="launchParams";function dr(t){return t.replace(/^[^?#]*[?#]/,"").replace(/[?#]/g,"&")}function Te(){return d(Qe(),Mi(lt))}const To=re(Te);function nn(){return d(Qe(),Q(t=>{const e=new URLSearchParams(t).get("vbWebAppData");return e?$e(e):Fe}))}function Lo(){return d(nn(),Ii(t=>{throw t},t=>t),vt(()=>{},t=>t))}function Qe(){const t=[];for(const[e,n]of[[()=>dr(window.location.href),"window.location.href"],[()=>{const r=performance.getEntriesByType("navigation")[0];return r&&dr(r.name)},"performance navigation entries"],[()=>zn(pr),"local storage"]]){const r=e();if(!r){t.push({source:n,error:new Error("Source is empty")});continue}const i=d(lt(r),Ai(o=>o,()=>!0));if(typeof i!="boolean"){t.push({source:n,error:i});continue}return ot(pr,r),E(r)}return P(new cr(t))}const Vo=re(Qe);function hr(t,e){const n=new Map,r=Ro(),i=(o,a,c=!1)=>{const l=n.get(o)||new Map;n.set(o,l);const p=l.get(a)||[];l.set(a,p);const h=p.findIndex(f=>f[1]===c);if(h>=0&&(r.off(o,p[h][0]),p.splice(h,1),!p.length&&(l.delete(a),!l.size))){const f=n.size;n.delete(o),f&&!n.size&&e()}};return{on(o,a,c){!n.size&&t();const l=()=>{i(o,a,c)},p=(...g)=>{c&&l(),o==="*"?a({name:g[0],payload:g[1]}):a(...g)};r.on(o,p);const h=n.get(o)||new Map;n.set(o,h);const f=h.get(a)||[];return h.set(a,f),f.push([p,c||!1]),l},off:i,emit:r.emit,clear(){const o=n.size;r.all.clear(),n.clear(),o&&e()}}}function pt(t,e){window.dispatchEvent(new MessageEvent("message",{data:JSON.stringify({eventType:t,eventData:e}),source:window.parent}))}const rn=D(!1),fr=D("https://web.telegram.org"),Oo=t=>{ce().log("Event received:",t)},_r=C(rn);function jo(t){t!==rn()&&(rn.set(t),(t?X:Ee)("*",Oo))}const br=C(fr);function Ho(t){fr.set(t),ce().log("New target origin set",t)}const ke=D((...t)=>{window.parent.postMessage(...t)}),ce=D(Kn("Bridge",{bgColor:"#9147ff",textColor:"white",shouldLog:_r}));function sn(t,e,n){const r=[n],i=t[e];typeof i=="function"&&r.push(i);const o=(...c)=>{r.forEach(l=>l(...c))},a=Object.assign((...c)=>{o(...c)},{unwrap(){const{length:c}=r;if(c===1){delete t[e];return}if(c===2){wr(t,e,r[1]);return}r.unshift(1),wr(t,e,o)}});gr(t,e,()=>a,c=>r.push(c))}function mr(t,e){const n=t[e];gr(t,e,()=>n,r=>{Object.entries(r).forEach(([i,o])=>{n[i]=o})})}function gr(t,e,n,r){Object.defineProperty(t,e,{enumerable:!0,configurable:!0,get:n,set:r})}function wr(t,e,n){Object.defineProperty(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n})}const Do={clipboard_text_received:N({req_id:S(),data:Pe(S())}),custom_method_invoked:N({req_id:S(),result:B(Ut()),error:B(S())}),popup_closed:Pe(N({button_id:Pe(S(),()=>{})}),{}),viewport_changed:Pe(N({height:we(),width:Pe(we(),()=>window.innerWidth),is_state_stable:Ce(),is_expanded:Ce()}),()=>({height:window.innerHeight,is_state_stable:!0,is_expanded:!0})),theme_changed:N({theme_params:Jt()})};function vr(t){if(t.source!==window.parent)return;let e;try{e=fe(ue(Zt()),t.data)}catch{return}const{eventType:n,eventData:r}=e,i=Do[n];let o;try{o=i?fe(i,r):r}catch(a){return ce().forceError([`An error occurred processing the "${n}" event from the VBot application.`,"Please, file an issue here:","https://github.com/Telegram-Mini-Apps/tma.js/issues/new/choose"].join(`
3
- `),e,a)}Uo(n,o)}const{on:X,off:Ee,emit:Uo,clear:Wo}=hr(()=>{const t=window;!t.TelegramGameProxy&&(t.TelegramGameProxy={}),sn(t.TelegramGameProxy,"receiveEvent",pt),mr(t,"TelegramGameProxy"),!t.VBot&&(t.VBot={}),!t.VBot.WebView&&(t.VBot.WebView={}),sn(t.VBot.WebView,"receiveEvent",pt),mr(t.VBot,"WebView"),sn(t,"TelegramGameProxy_receiveEvent",pt),window.addEventListener("message",vr)},()=>{[["TelegramGameProxy_receiveEvent"],["TelegramGameProxy","receiveEvent"],["VBot","WebView","receiveEvent"]].forEach(t=>{const e=window;let n=[void 0,e];for(const o of t)if(n=[n[1],n[1][o]],!n[1])return;const[r,i]=n;"unwrap"in i&&(i.unwrap(),r&&r!==e&&!Object.keys(r).length&&delete e[t[0]])}),window.removeEventListener("message",vr)}),No=(...t)=>ke()(...t);function Go(t,e){d(Le(t,e),qi(n=>{throw n}))}function Le(t,e){ce().log("Posting event:",e?{eventType:t,eventData:e}:{eventType:t});const n=window,r=JSON.stringify({eventType:t,eventData:e});return xt()?(No(r,br()),E(void 0)):or(n)?(n.VBotWebviewProxy.postEvent(t,JSON.stringify(e)),E(void 0)):Ot(N({external:N({notify:jt()})}),n)?(n.external.notify(r),E(void 0)):P(new tn)}function dt(t,e,n={}){const{capture:r=()=>!0,postEvent:i=Le}=n,o=D(),[a,c]=Ge();(Array.isArray(e)?e:[e]).forEach(p=>{a(X(p,h=>{const f=Array.isArray(e);r(f?{event:p,payload:h}:h)&&o.set([f?{event:p,payload:h}:h])}))});const l=p=>(c(),p);return d(async()=>i(t,n.params),pe(()=>Re((p,h,f)=>{const g=o();if(g)return p(g[0]);const v=k=>{k&&p(k[0])},F=()=>{o.unsub(v)};o.sub(v),f.on("finalized",F)},n)),We(l,l))}function zo(t,e){const n=on(t,e);return typeof n=="function"?ve.fn(()=>ze(n)):n}function on(t,e){const n=or(window);if(!t)return n||d(Qe(),le(()=>!1,()=>!0));if(n)return T(!0);const{timeout:r=100}=e||{};return d(dt("web_app_request_theme","theme_changed",{...e,timeout:r}),tt(i=>Gt.is(i)||tn.is(i)?E(!1):P(i),()=>E(!0)))}function Ko({launchParams:t,onEvent:e,resetPostMessage:n}={}){if(t){const o=typeof t=="string"||t instanceof URLSearchParams?t.toString():Xt({...t,vbWebAppData:void 0})+(t.vbWebAppData?`&vbWebAppData=${encodeURIComponent(t.vbWebAppData.toString())}`:"");try{Yt(o)}catch(a){throw new en(o,a)}ot("launchParams",o)}if(xt()){if(!e)return;n&&ke.reset();const o=ke();ke.set((...a)=>{const[c]=a,l=()=>{o(...a)};try{const p=fe(ue(Zt()),c);e({name:p.eventType,params:p.eventData},l)}catch{l()}});return}const r=window.VBotWebviewProxy||{},i=r.postEvent||(()=>{});window.VBotWebviewProxy={...r,postEvent(o,a){const c=()=>{i(o,a)};e?e({name:o,params:a?JSON.parse(a):void 0},c):c()}},ce().log("Environment was mocked by the mockVBotEnv function")}function Qo({launchParams:t,onEvent:e,resetPostMessage:n}={}){if(t){const o=typeof t=="string"||t instanceof URLSearchParams?t.toString():Xt({...t,vbWebAppData:void 0})+(t.vbWebAppData?`&vbWebAppData=${encodeURIComponent(t.vbWebAppData.toString())}`:"");try{Yt(o)}catch(a){throw new en(o,a)}ot("launchParams",o)}if(xt()){if(!e)return;n&&ke.reset();const o=ke();ke.set((...a)=>{const[c]=a,l=()=>{o(...a)};try{const p=fe(ue(Zt()),c);e({name:p.eventType,params:p.eventData},l)}catch{l()}});return}const r=window.VBotWebviewProxy||{},i=r.postEvent||(()=>{});window.VBotWebviewProxy={...r,postEvent(o,a){const c=()=>{i(o,a)};e?e({name:o,params:a?JSON.parse(a):void 0},c):c()}},ce().log("Launch params are injected by the setLaunchParams function")}function Jo(t,e="*"){const n=o=>{if(o.source===t.contentWindow)try{const a=JSON.parse(o.data),{eventType:c,eventData:l}=a;r.emit(c,l)}catch{}},r=hr(()=>{window.addEventListener("message",n)},()=>{window.removeEventListener("message",n)}),i={...r,send:(o,a)=>{if(t.contentWindow){const c=JSON.stringify({eventType:o,eventData:a});t.contentWindow.postMessage(c,e)}},clear:()=>{r.clear(),Je===i&&(Je=void 0)}};return Je=i,i}let Je;function _(){if(!Je)throw new Error("HostBridge not initialized. Call defineHostBridge() first.");return Je}function yr(t){return({req_id:e})=>e===t}const Sr={"6.0":["iframe_ready","iframe_will_reload","web_app_close","web_app_data_send","web_app_expand","web_app_open_link","web_app_ready","web_app_request_theme","web_app_request_viewport","web_app_setup_main_button","web_app_setup_closing_behavior"],6.1:["web_app_open_tg_link","web_app_open_invoice","web_app_setup_back_button","web_app_set_background_color","web_app_set_header_color","web_app_trigger_haptic_feedback"],6.2:["web_app_open_popup"],6.4:["web_app_close_scan_qr_popup","web_app_open_scan_qr_popup","web_app_read_text_from_clipboard",{method:"web_app_open_link",param:"try_instant_view"}],6.7:["web_app_switch_inline_query"],6.9:["web_app_invoke_custom_method","web_app_request_write_access","web_app_request_phone",{method:"web_app_set_header_color",param:"color"}],"6.10":["web_app_setup_settings_button"],7.2:["web_app_biometry_get_info","web_app_biometry_open_settings","web_app_biometry_request_access","web_app_biometry_request_auth","web_app_biometry_update_token"],7.6:[{method:"web_app_open_link",param:"try_browser"},{method:"web_app_close",param:"return_back"}],7.7:["web_app_setup_swipe_behavior"],7.8:["web_app_share_to_story"],"7.10":["web_app_setup_secondary_button","web_app_set_bottom_bar_color",{method:"web_app_setup_main_button",param:"has_shine_effect"}],"8.0":["web_app_request_safe_area","web_app_request_content_safe_area","web_app_request_fullscreen","web_app_exit_fullscreen","web_app_set_emoji_status","web_app_add_to_home_screen","web_app_check_home_screen","web_app_request_emoji_status_access","web_app_check_location","web_app_open_location_settings","web_app_request_file_download","web_app_request_location","web_app_send_prepared_message","web_app_start_accelerometer","web_app_start_device_orientation","web_app_start_gyroscope","web_app_stop_accelerometer","web_app_stop_device_orientation","web_app_stop_gyroscope","web_app_toggle_orientation_lock"],"9.0":["web_app_device_storage_clear","web_app_device_storage_get_key","web_app_device_storage_save_key","web_app_secure_storage_clear","web_app_secure_storage_get_key","web_app_secure_storage_restore_key","web_app_secure_storage_save_key"],9.1:["web_app_hide_keyboard"],9.2:["web_app_send_notification","web_app_finish_refresh"]};function an(t,e){return Object.keys(Sr).find(n=>Sr[n].some(r=>e?typeof r=="object"&&r.method===t&&r.param===e:r===t))||null}function Fr(t){return t.split(".").map(Number)}function Zo(t,e){const n=Fr(t),r=Fr(e),i=Math.max(n.length,r.length);for(let o=0;o<i;o+=1){const a=n[o]||0,c=r[o]||0;if(a!==c)return a>c?1:-1}return 0}function _e(t,e,n){const r=n?an(t,e):an(t);return r?Zo(r,n||e)<=0:!1}function Yo(t,e="strict"){const n=typeof e=="function"?e:r=>{const{method:i,version:o}=r,a="param"in r?new ur(i,r.param,o):new ar(i,o);if(e==="strict")throw a;return ce().forceWarn(a.message)};return((r,i)=>_e(r,t)?r==="web_app_set_header_color"&&Ot(N({color:Ln()}),i)&&!_e(r,"color",t)?n({version:t,method:r,param:"color"}):Go(r,i):n({version:t,method:r}))}function Xo(t,e,n,r){return d(dt("web_app_invoke_custom_method","custom_method_invoked",{...r||{},params:{method:t,params:e,req_id:n},capture:yr(n)}),ne(({result:i,error:o})=>o?U(new lr(o)):T(i)))}function xo(t,e,n={}){const{capture:r=()=>!0,postEvent:i=Le}=n,o=D(),[a,c]=Ge();(Array.isArray(e)?e:[e]).forEach(p=>{a(X(p,h=>{(Array.isArray(e)?r({event:p,payload:h}):r(h))&&o.set([h])}))});const l=p=>(c(),p);return d(async()=>i(t,n.params),pe(()=>Re((p,h,f)=>{const g=o();if(g)return p(g[0]);const v=k=>{k&&p(k[0])},F=()=>{o.unsub(v)};o.sub(v),f.on("finalized",F)},n)),We(l,l))}function ea(){Object.hasOwn||(Object.hasOwn=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)})}function un(t){return Me(()=>decodeURIComponent(atob(t.replace(/-/g,"+").replace(/_/g,"/")).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join("")),e=>e)}const ta=re(un);function cn(t){return btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,(e,n)=>String.fromCharCode(parseInt(`0x${n}`)))).replace(/\+/g,"-").replace(/\//g,"_")}function Cr(t){const e=cn(typeof t=="string"?t:JSON.stringify(t));return e.length>512?P(new Error("Value is too long for start parameter")):E(e)}const na=re(Cr);function ra(t,e){return ze(kr(t,typeof e=="function"?n=>Me(()=>e(n),r=>r):e))}function kr(t,e){return d(un(t),Pi(n=>e?typeof e=="function"?e(n):Di(n):E(n)))}function sa(t){return cn(t).length<=512}function se(t,e){return C(()=>_e(t,te(e)))}function b(t){return Object.assign(re(t),{ifAvailable(...e){return d(t.ifAvailable(...e),vt(()=>({ok:!1}),n=>({ok:!0,data:ze(n)})))}})}function qe(t){return[t]}class Ze extends at("ValidationError",(e,n)=>({input:e,issues:n}),"Validation error"){}class ht extends K("CSSVarsBoundError","CSS variables are already bound"){}class Er extends at("DeviceStorageMethodError",e=>({error:e}),e=>[e]){}class qr extends at("SecureStorageMethodError",e=>({error:e}),e=>[e]){}class Ar extends K("NotAvailableError",qe){}class ia extends K("InvalidEnvError",qe){}class Ir extends K("FunctionNotAvailableError",qe){}class ie extends K("InvalidArgumentsError",(e,n)=>[e,{cause:n}]){}class ft extends K("ConcurrentCallError",qe){}class Br extends K("SetEmojiStatusError",e=>[`Failed to set emoji status: ${e}`]){}class ln extends K("AccessDeniedError",qe){}class $r extends K("FullscreenFailedError",qe){}class Mr extends K("ShareMessageError",qe){}class Pr extends K("UnknownThemeParamsKeyError",e=>[`Unknown theme params key passed: ${e}`]){}function V(t,e){const n=C(()=>te(e.version)||"100"),r=C(()=>te(e.isVBma)),{requires:i,returns:o}=e,a=i?typeof i=="object"?i:{every:[i]}:void 0,c=w=>{if(!e.supports)return!0;const y=e.supports[w];return _e(y.method,y.param,n())},l=()=>{if(!a)return;const[w,y]="every"in a?["every",a.every]:["some",a.some];for(let m=0;m<y.length;m++){const j=y[m],H=typeof j=="function"?j():_e(j,n())?void 0:`it is unsupported in Mini Apps version ${n()}`;if(H&&(w==="every"||m===y.length-1))return H}},p=(...w)=>{for(const y in e.supports)if(e.supports[y].shouldCheck(...w)&&!c(y))return`option ${y} is not supported in Mini Apps version ${n()}`},h=C(()=>!l()),f=C(()=>n()!=="0.0"),g=C(()=>e.isMounted?e.isMounted():!0),v=C(()=>r()&&f()&&h()&&g()),F=w=>{const y=new Ir(w);return["task","promise"].includes(e.returns)?U(y):P(y)},k=(...w)=>o==="plain"?Me(()=>t(...w),y=>y):o==="promise"?Rn(()=>t(...w),y=>y):t(...w);return Object.assign((...w)=>{var H;const y="Unable to call function:";if(!r())return F(`${y} it can't be called outside Mini Apps`);if(!f())return F(`${y} the SDK was not initialized. Use the SDK init() function`);const m=l();if(m)return F(`${y} ${m}`);const j=p(...w);if(j)return F(`${y} ${j}`);if(!g()){const W=(H=e.isMounting)!=null&&H.call(e)?"mounting. Wait for the mount completion":"unmounted. Use the mount() method";return F(`${y} the component is ${W}`)}return k(...w)},t,{isAvailable:v,ifAvailable(...w){return v()?$e(k(...w)):Fe}},a?{isSupported:h}:{},e.supports?{supports:c}:{})}function M(t){return e=>V(e,t)}class _t{constructor({isVBma:e,storage:n,onClick:r,offClick:i,initialState:o,isPageReload:a,postEvent:c,payload:l,method:p,version:h}){s(this,"isMounted");s(this,"isSupported");s(this,"state");s(this,"stateSetters");s(this,"stateBoolSetters");s(this,"setStateFp");s(this,"setState");s(this,"onClickFp");s(this,"onClick");s(this,"offClickFp");s(this,"offClick");s(this,"mountFp");s(this,"mount");s(this,"unmount");const f=new ge({initialState:o,onChange(w){n.set(w)}}),g=new Ne({initialState:o,isPageReload:a,onMounted:f.setState,restoreState:n.get}),v={version:h,requires:p,isVBma:e},F=M({...v,returns:"plain"}),k=M({...v,returns:"either",isMounted:g.isMounted});this.isMounted=g.isMounted,this.isSupported=se(p,h),this.state=f.state,this.setStateFp=k(w=>{const y={...this.state(),...Bt(w)};return f.hasDiff(y)?d(c(p,l(y)),Q(()=>{f.setState(y)})):E(void 0)}),this.setState=b(this.setStateFp),this.onClickFp=F(r),this.onClick=b(this.onClickFp),this.offClickFp=F(i),this.offClick=b(this.offClickFp),this.mountFp=F(()=>{const w=()=>{};return d(g.mount(),le(w,w))}),this.mount=b(this.mountFp),this.unmount=g.unmount,this.stateSetters=w=>{const y=k(m=>this.setStateFp({[w]:m}));return[b(y),y]},this.stateBoolSetters=w=>{const[,y]=this.stateSetters(w),m=k(()=>y(!1)),j=k(()=>y(!0));return[[b(m),m],[b(j),j]]}}stateGetter(e){return C(()=>this.state()[e])}}class Rr{constructor(e){s(this,"isVisible");s(this,"isMounted");s(this,"isSupported");s(this,"hideFp");s(this,"hide");s(this,"showFp");s(this,"show");s(this,"onClickFp");s(this,"onClick");s(this,"offClickFp");s(this,"offClick");s(this,"mountFp");s(this,"mount");s(this,"unmount");const n=new _t({...e,method:"web_app_setup_back_button",payload:r=>({is_visible:r.isVisible}),initialState:{isVisible:!1}});this.isVisible=n.stateGetter("isVisible"),this.isMounted=n.isMounted,this.isSupported=n.isSupported,[[this.hide,this.hideFp],[this.show,this.showFp]]=n.stateBoolSetters("isVisible"),this.onClick=n.onClick,this.onClickFp=n.onClickFp,this.offClick=n.offClick,this.offClickFp=n.offClickFp,this.mount=n.mount,this.mountFp=n.mountFp,this.unmount=n.unmount}}function q(){return{isVBma:C(()=>on())}}function Ve(t){return e=>({...e,...te(t)})}function Ye(t,e){return D(t,e)}const Tr=Ye(Le),Ae=(...t)=>Tr()(...t),Lr=(...t)=>ze(Ae(...t)),J=Ve({postEvent:Ae});function oa(t){return{get:()=>zn(t),set(e){ot(t,e)}}}function aa(){return performance.getEntriesByType("navigation")[0]}function ua(){const t=aa();return!!t&&t.type==="reload"}function ye(t){return Ve({storage:oa(t),isPageReload:ua})}const pn=Ye("0.0"),$=Ve({version:pn});function dn(t,e){return{...d(q(),J,$,ye(t)),onClick(n,r){return X(e,n,r)},offClick(n,r){Ee(e,n,r)}}}const ca=new Rr(dn("backButton","back_button_pressed"));class hn{constructor({initialState:e,onMounted:n,restoreState:r,onUnmounted:i,isPageReload:o}){s(this,"_isMounted",D(!1));s(this,"isMounted",C(this._isMounted));s(this,"mount");s(this,"unmount");this.mount=a=>{if(this._isMounted())return T(void 0);const c=te(o)?r():void 0;return d(c?T(c):e(a),I(l=>{this._isMounted()||et(()=>{this._isMounted.set(!0),n==null||n(l)})}))},this.unmount=()=>{this._isMounted()&&et(()=>{this._isMounted.set(!1),i==null||i()})}}}function Vr(){return new Ar("Biometry is not available")}function fn(t){let e=!1,n=!1,r="",i=!1,o="",a=!1;return t.available&&(e=!0,n=t.token_saved,r=t.device_id,i=t.access_requested,o=t.type,a=t.access_granted),{available:e,tokenSaved:n,deviceId:r,type:o,accessGranted:a,accessRequested:i}}class Or{constructor({version:e,request:n,postEvent:r,storage:i,onInfoReceived:o,offInfoReceived:a,isVBma:c,isPageReload:l}){s(this,"isAvailable");s(this,"isSupported");s(this,"isMounted");s(this,"state");s(this,"authenticateFp");s(this,"authenticate");s(this,"openSettingsFp");s(this,"openSettings");s(this,"requestAccessFp");s(this,"requestAccess");s(this,"updateTokenFp");s(this,"updateToken");s(this,"mountFp");s(this,"mount");s(this,"unmount");const p=w=>{h.setState(fn(w))},h=new ge({initialState:{available:!1,type:"unknown",accessGranted:!1,accessRequested:!1,deviceId:"",tokenSaved:!1},onChange:i.set}),f=new hn({initialState(w){return d(n("web_app_biometry_get_info","biometry_info_received",w),I(fn))},isPageReload:l,onMounted(w){h.setState(w),o(p)},onUnmounted(){a(p)},restoreState:i.get}),g={version:e,requires:"web_app_biometry_request_auth",isVBma:c},v=M({...g,returns:"either"}),F=M({...g,returns:"task"}),k=M({...g,isMounted:f.isMounted,returns:"task"});this.isAvailable=h.getter("available"),this.isMounted=f.isMounted,this.isSupported=se("web_app_biometry_request_auth",e),this.state=h.state,this.unmount=f.unmount,this.mountFp=F(f.mount),this.authenticateFp=k(w=>this.isAvailable()?d(n("web_app_biometry_request_auth","biometry_auth_requested",{...w,params:{reason:((w||{}).reason||"").trim()}}),I(y=>(h.setState({token:y.token}),y))):U(Vr())),this.openSettingsFp=v(()=>r("web_app_biometry_open_settings")),this.requestAccessFp=k(w=>d(n("web_app_biometry_request_access","biometry_info_received",{...w,params:{reason:((w||{}).reason||"").trim()}}),ne(y=>{const m=fn(y);return m.available?(h.setState(m),T(m.accessRequested)):U(Vr())}))),this.updateTokenFp=k((w={})=>{var y;return d(n("web_app_biometry_update_token","biometry_token_updated",{...w,params:{token:w.token||"",reason:(y=w.reason)==null?void 0:y.trim()}}),I(m=>m.status))}),this.authenticate=b(this.authenticateFp),this.openSettings=b(this.openSettingsFp),this.requestAccess=b(this.requestAccessFp),this.updateToken=b(this.updateTokenFp),this.mount=b(this.mountFp)}}const jr=(t,e,n)=>xo(t,e,{postEvent:Ae,...n}),_n=(t,e,n)=>dt(t,e,{postEvent:Ae,...n}),la=(...t)=>ve.fn(()=>jr(...t)()),pa=(...t)=>ve.fn(()=>_n(...t)()),x=Ve({request:_n});function da(){return new Or({...d(q(),J,$,x,ye("biometry")),offInfoReceived(t){Ee("biometry_info_received",t)},onInfoReceived(t){return X("biometry_info_received",t)}})}const ha=da();class Hr{constructor({postEvent:e,storage:n,isVBma:r,isPageReload:i}){s(this,"isConfirmationEnabled");s(this,"isMounted");s(this,"mountFp");s(this,"mount");s(this,"unmount");s(this,"disableConfirmationFp");s(this,"disableConfirmation");s(this,"enableConfirmationFp");s(this,"enableConfirmation");const o=new ge({initialState:{isConfirmationEnabled:!1},onChange(f){n.set(f)}}),a=new Ne({onMounted:o.setState,restoreState:n.get,initialState:{isConfirmationEnabled:!1},isPageReload:i}),c={requires:"web_app_setup_closing_behavior",isVBma:r},l=M({...c,returns:"plain"}),p=M({...c,returns:"either",isMounted:a.isMounted}),h=f=>f===this.isConfirmationEnabled()?E(void 0):(o.setState({isConfirmationEnabled:f}),e("web_app_setup_closing_behavior",{need_confirmation:f}));this.isConfirmationEnabled=o.getter("isConfirmationEnabled"),this.isMounted=a.isMounted,this.disableConfirmationFp=p(()=>h(!1)),this.enableConfirmationFp=p(()=>h(!0)),this.mountFp=l(()=>{const f=()=>{};return d(a.mount(),le(f,f))}),this.unmount=a.unmount,this.disableConfirmation=b(this.disableConfirmationFp),this.enableConfirmation=b(this.enableConfirmationFp),this.mount=b(this.mountFp)}}function fa(){return new Hr(d(q(),ye("closingBehavior"),J))}const _a=fa();class Dr{constructor({version:e,isVBma:n,invokeCustomMethod:r}){s(this,"isSupported");s(this,"deleteItemFp");s(this,"deleteItem");s(this,"getItemFp");s(this,"getItem");s(this,"getItemsFp");s(this,"getItems");s(this,"getKeysFp");s(this,"getKeys");s(this,"setItemFp");s(this,"setItem");s(this,"clearFp");s(this,"clear");const i=M({version:e,requires:"web_app_invoke_custom_method",isVBma:n,returns:"task"});this.isSupported=se("web_app_invoke_custom_method",e),this.deleteItemFp=i((o,a)=>{const c=Array.isArray(o)?o:[o];return d(c.length?r("deleteStorageValues",{keys:c},a):T(void 0),I(()=>{}))}),this.getItemFp=i((o,a)=>d(this.getItemsFp([o],a),I(c=>c[o]||""))),this.getItemsFp=i((o,a)=>d(o.length?r("getStorageValues",{keys:o},a):T({}),I(c=>({...o.reduce((l,p)=>(l[p]="",l),{}),...fe(Dt(S(),S()),c)})))),this.getKeysFp=i(o=>d(r("getStorageKeys",{},o),I(a=>fe(Vn(S()),a)))),this.setItemFp=i((o,a,c)=>d(r("saveStorageValue",{key:o,value:a},c),I(()=>{}))),this.clearFp=i(o=>d(this.getKeysFp(o),ne(this.deleteItemFp))),this.deleteItem=b(this.deleteItemFp),this.getItem=b(this.getItemFp),this.getItems=b(this.getItemsFp),this.getKeys=b(this.getKeysFp),this.setItem=b(this.setItemFp),this.clear=b(this.clearFp)}}const bn=Ye(0);function bt(){return bn.set(bn()+1),bn().toString()}function Ur(t,e,n){return Xo(t,e,bt(),{...n||{},postEvent:Ae})}const mn=Ve({invokeCustomMethod:Ur});function ba(){return new Dr(d(q(),$,mn))}const ma=ba();class Wr{constructor({isVBma:e,request:n,version:r,createRequestId:i}){s(this,"getItemFp");s(this,"getItem");s(this,"setItemFp");s(this,"setItem");s(this,"deleteItemFp");s(this,"deleteItem");s(this,"clearFp");s(this,"clear");const o=M({version:r,requires:"web_app_device_storage_get_key",isVBma:e,returns:"task"}),a=(c,l,p)=>{const h=i();return d(n(c,["device_storage_failed",l],{params:{...p,req_id:h},capture:(f=>"payload"in f?f.payload.req_id===h:!0)}),ne(f=>f.event==="device_storage_failed"?U(new Er(f.payload.error||"UNKNOWN_ERROR")):T(f.payload)))};this.getItemFp=o(c=>d(a("web_app_device_storage_get_key","device_storage_key_received",{key:c}),I(l=>l.value))),this.setItemFp=o((c,l)=>d(a("web_app_device_storage_save_key","device_storage_key_saved",{key:c,value:l}),I(()=>{}))),this.deleteItemFp=o(c=>this.setItemFp(c,null)),this.clearFp=o(()=>d(a("web_app_device_storage_clear","device_storage_cleared",{}),I(()=>{}))),this.getItem=b(this.getItemFp),this.setItem=b(this.setItemFp),this.deleteItem=b(this.deleteItemFp),this.clear=b(this.clearFp)}}const Nr=Ve({createRequestId:bt});function ga(){return new Wr(d(q(),$,x,Nr))}const wa=ga();function va({request:t,...e}){return V(n=>d(t("web_app_request_emoji_status_access","emoji_status_access_requested",n),I(r=>r.status)),{...e,requires:"web_app_request_emoji_status_access",returns:"task"})}function ya(){return va(d(q(),$,x))}const Gr=ya(),Sa=b(Gr);function Fa({request:t,...e}){return V((n,r)=>d(t("web_app_set_emoji_status",["emoji_status_set","emoji_status_failed"],{params:{custom_emoji_id:n,duration:(r||{}).duration},...r}),pe(i=>i.event==="emoji_status_failed"?U(new Br(i.payload.error)):T(void 0))),{...e,requires:"web_app_set_emoji_status",returns:"task"})}function Ca(){return Fa(d(q(),x,$))}const zr=Ca(),ka=b(zr);class Kr{constructor({postEvent:e,isVBma:n,version:r}){s(this,"isSupported");s(this,"impactOccurredFp");s(this,"impactOccurred");s(this,"notificationOccurredFp");s(this,"notificationOccurred");s(this,"selectionChangedFp");s(this,"selectionChanged");const i="web_app_trigger_haptic_feedback",o=M({requires:i,isVBma:n,version:r,returns:"plain"});this.isSupported=se(i,r),this.impactOccurredFp=o(a=>e(i,{type:"impact",impact_style:a})),this.notificationOccurredFp=o(a=>e(i,{type:"notification",notification_type:a})),this.selectionChangedFp=o(()=>e(i,{type:"selection_change"})),this.impactOccurred=b(this.impactOccurredFp),this.notificationOccurred=b(this.notificationOccurredFp),this.selectionChanged=b(this.selectionChangedFp)}}function Ea(){return new Kr(d(q(),J,$))}const qa=Ea();function Aa({postEvent:t,...e}){return V(()=>t("web_app_add_to_home_screen"),{...e,requires:"web_app_add_to_home_screen",returns:"either"})}function Ia(){return Aa(d(q(),$,J))}const Qr=Ia(),Ba=b(Qr);function $a({request:t,...e}){return V(n=>d(t("web_app_check_home_screen","home_screen_checked",n),I(r=>r.status||"unknown")),{...e,requires:"web_app_check_home_screen",returns:"task"})}function Ma(){return $a(d(q(),$,x))}const Jr=Ma(),Pa=b(Jr);class Zr{constructor({retrieveInitData:e}){s(this,"_state",D());s(this,"_raw",D());s(this,"state",C(this._state));s(this,"authDate",this.fromState("auth_date"));s(this,"canSendAfter",this.fromState("can_send_after"));s(this,"canSendAfterDate",C(()=>{const e=this.authDate(),n=this.canSendAfter();return n&&e?new Date(e.getTime()+n*1e3):void 0}));s(this,"chat",this.fromState("chat"));s(this,"chatType",this.fromState("chat_type"));s(this,"chatInstance",this.fromState("chat_instance"));s(this,"hash",this.fromState("hash"));s(this,"queryId",this.fromState("query_id"));s(this,"raw",C(this._raw));s(this,"receiver",this.fromState("receiver"));s(this,"signature",this.fromState("signature"));s(this,"startParam",this.fromState("start_param"));s(this,"auth",this.fromState("auth"));s(this,"user",this.fromState("user"));s(this,"restoreFp");s(this,"restore");this.restoreFp=()=>d(e(),Q(vt(()=>{},({raw:n,obj:r})=>{this._state.set(r),this._raw.set(n)}))),this.restore=re(this.restoreFp)}fromState(e){return C(()=>{const n=this._state();return n?n[e]:void 0})}}function Ra(){return new Zr({retrieveInitData(){return d(Bi,$n("obj",()=>d(Te(),Q(({vbWebAppData:t})=>t?$e(t):Fe))),$n("raw",nn),Q(({obj:t,raw:e})=>d(wi,In("obj",()=>t),In("raw",()=>e))))}})}const Ta=Ra();class Yr{constructor({version:e,request:n,isVBma:r}){s(this,"isOpened");s(this,"isSupported");s(this,"openSlugFp");s(this,"openSlug");s(this,"openUrlFp");s(this,"openUrl");const i=M({version:e,isVBma:r,requires:"web_app_open_invoice",returns:"task"}),o=D(!1),a=()=>{o.set(!1)};this.isSupported=se("web_app_open_invoice",e),this.isOpened=C(o),this.openSlugFp=i((c,l)=>d(this.isOpened()?U(new ft("Invoice is already opened")):T(void 0),ne(()=>(o.set(!0),n("web_app_open_invoice","invoice_closed",{...l,params:{slug:c},capture:p=>c===p.slug}))),We(p=>(a(),p),p=>(a(),p.status)))),this.openUrlFp=i((c,l)=>{const{hostname:p,pathname:h}=new URL(c,window.location.href);if(p!=="t.me")return U(new ie(`Link has unexpected hostname: ${p}`));const f=h.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);return f?this.openSlugFp(f[2],l):U(new ie('Expected to receive a link with a pathname in format "/invoice/{slug}" or "/${slug}"'))}),this.openUrl=b(this.openUrlFp),this.openSlug=b(this.openSlugFp)}}function La(){return new Yr(d(q(),x,$))}const Va=La();function Oa({postEvent:t,...e}){return V((n,r={})=>{if(typeof n=="string")try{n=new URL(n)}catch(i){return P(new ie(`"${n.toString()}" is invalid URL`,i))}return t("web_app_open_link",{url:n.toString(),try_browser:r.tryBrowser,try_instant_view:r.tryInstantView})},{...e,returns:"either"})}function ja(){return Oa(d(q(),J))}const Xr=ja(),Ha=b(Xr);function Da({postEvent:t,version:e,...n}){return V(r=>{const i=r.toString();return i.match(/^https:\/\/t.me\/.+/)?_e("web_app_open_tg_link",te(e))?(r=new URL(r),t("web_app_open_tg_link",{path_full:r.pathname+r.search})):(window.location.href=i,E(void 0)):P(new ie(`"${i}" is invalid URL`))},{...n,returns:"either"})}function Ua(){return Da(d(q(),J,$))}const gn=Ua(),Wa=b(gn);function Na({openVbotLink:t,...e}){return V((n,r)=>t("https://t.me/share/url?"+new URLSearchParams({url:n,text:r||""}).toString().replace(/\+/g,"%20")),{...e,returns:"either"})}function Ga(){return Na({...q(),openVbotLink:gn})}const xr=Ga(),za=b(xr);function Ka(t){let e=!1,n,r;return t.available&&(e=!0,n=t.access_requested,r=t.access_granted),{available:e,accessGranted:r||!1,accessRequested:n||!1}}class es{constructor({version:e,request:n,postEvent:r,storage:i,isVBma:o,isPageReload:a}){s(this,"state");s(this,"isAvailable");s(this,"isAccessGranted");s(this,"isAccessRequested");s(this,"isMounted");s(this,"isSupported");s(this,"openSettingsFp");s(this,"openSettings");s(this,"requestLocationFp");s(this,"requestLocation");s(this,"mountFp");s(this,"mount");s(this,"unmount");const c=new ge({initialState:{available:!1,accessGranted:!1,accessRequested:!1},onChange:i.set}),l=new hn({isPageReload:a,restoreState:i.get,onMounted:c.setState,initialState(v){return d(n("web_app_check_location","location_checked",v),I(Ka))}}),p={version:e,requires:"web_app_check_location",isVBma:o},h=M({...p,returns:"either"}),f=M({...p,returns:"task"}),g=M({...p,returns:"task",isMounted:l.isMounted});this.isAvailable=c.getter("available"),this.isAccessRequested=c.getter("accessRequested"),this.isAccessGranted=c.getter("accessGranted"),this.isSupported=se("web_app_check_location",e),this.isMounted=l.isMounted,this.state=c.state,this.unmount=l.unmount,this.mountFp=f(l.mount),this.openSettingsFp=h(()=>r("web_app_open_location_settings")),this.requestLocationFp=g(v=>d(n("web_app_request_location","location_requested",v),I(F=>{if(!F.available)return c.setState({available:!1}),null;const{available:k,...w}=F;return w}))),this.mount=b(this.mountFp),this.openSettings=b(this.openSettingsFp),this.requestLocation=b(this.requestLocationFp)}}function Qa(){return new es(d(q(),J,$,x,ye("locationManager")))}const Ja=Qa();class ts{constructor({defaults:e,...n}){s(this,"bgColor");s(this,"hasShineEffect");s(this,"isEnabled");s(this,"isLoaderVisible");s(this,"isVisible");s(this,"isMounted");s(this,"state");s(this,"text");s(this,"textColor");s(this,"showFp");s(this,"show");s(this,"hideFp");s(this,"hide");s(this,"enableFp");s(this,"enable");s(this,"enableShineEffectFp");s(this,"enableShineEffect");s(this,"disableFp");s(this,"disable");s(this,"disableShineEffectFp");s(this,"disableShineEffect");s(this,"setBgColorFp");s(this,"setBgColor");s(this,"setTextColorFp");s(this,"setTextColor");s(this,"setTextFp");s(this,"setText");s(this,"showLoaderFp");s(this,"showLoader");s(this,"hideLoaderFp");s(this,"hideLoader");s(this,"setParamsFp");s(this,"setParams");s(this,"mountFp");s(this,"mount");s(this,"unmount");s(this,"onClickFp");s(this,"onClick");s(this,"offClickFp");s(this,"offClick");const r=new _t({...n,version:"100",initialState:{hasShineEffect:!1,isEnabled:!0,isLoaderVisible:!1,isVisible:!1,text:"Continue"},method:"web_app_setup_main_button",payload:o=>({has_shine_effect:o.hasShineEffect,is_visible:o.isVisible,is_active:o.isEnabled,is_progress_visible:o.isLoaderVisible,text:o.text,color:o.bgColor,text_color:o.textColor})}),i=(o,a)=>{const c=r.stateGetter(o);return C(()=>c()||te(a))};this.bgColor=i("bgColor",e.bgColor),this.textColor=i("textColor",e.textColor),this.hasShineEffect=r.stateGetter("hasShineEffect"),this.isEnabled=r.stateGetter("isEnabled"),this.isLoaderVisible=r.stateGetter("isLoaderVisible"),this.text=r.stateGetter("text"),this.isVisible=r.stateGetter("isVisible"),this.isMounted=r.isMounted,this.state=r.state,[this.setBgColor,this.setBgColorFp]=r.stateSetters("bgColor"),[this.setTextColor,this.setTextColorFp]=r.stateSetters("textColor"),[[this.disableShineEffect,this.disableShineEffectFp],[this.enableShineEffect,this.enableShineEffectFp]]=r.stateBoolSetters("hasShineEffect"),[[this.disable,this.disableFp],[this.enable,this.enableFp]]=r.stateBoolSetters("isEnabled"),[[this.hideLoader,this.hideLoaderFp],[this.showLoader,this.showLoaderFp]]=r.stateBoolSetters("isLoaderVisible"),[this.setText,this.setTextFp]=r.stateSetters("text"),[[this.hide,this.hideFp],[this.show,this.showFp]]=r.stateBoolSetters("isVisible"),this.setParams=r.setState,this.setParamsFp=r.setStateFp,this.onClick=r.onClick,this.onClickFp=r.onClickFp,this.offClick=r.offClick,this.offClickFp=r.offClickFp,this.mount=r.mount,this.mountFp=r.mountFp,this.unmount=r.unmount}}function wn(t,e){document.documentElement.style.setProperty(t,e)}function vn(t){document.documentElement.style.removeProperty(t)}function ns(t){return d(ct(t),Q(e=>Math.sqrt([.299,.587,.114].reduce((n,r,i)=>{const o=parseInt(e.slice(1+i*2,1+(i+1)*2),16);return n+o*o*r},0))<120))}const yn=re(ns);class rs{constructor({initialState:e,onChange:n,offChange:r,isVBma:i,storage:o,isPageReload:a}){s(this,"accentTextColor");s(this,"bgColor");s(this,"buttonColor");s(this,"buttonTextColor");s(this,"bottomBarBgColor");s(this,"destructiveTextColor");s(this,"headerBgColor");s(this,"hintColor");s(this,"linkColor");s(this,"secondaryBgColor");s(this,"sectionBgColor");s(this,"sectionHeaderTextColor");s(this,"sectionSeparatorColor");s(this,"subtitleTextColor");s(this,"textColor");s(this,"_isCssVarsBound",D(!1));s(this,"isCssVarsBound",C(this._isCssVarsBound));s(this,"bindCssVarsFp");s(this,"bindCssVars");s(this,"state");s(this,"isDark",C(()=>{const e=this.bgColor();return!e||yn(e)}));s(this,"isMounted");s(this,"mountFp");s(this,"mount");s(this,"unmount");const c=new ge({initialState:{},onChange:o.set}),l=v=>{c.setState(v.theme_params)},p=new Ne({initialState:()=>E(te(e)),isPageReload:a,onMounted(v){c.setState(v),n(l)},onUnmounted(){r(l)},restoreState:o.get}),h={isVBma:i,returns:"either"},f=M(h),g=M({...h,isMounted:p.isMounted});this.accentTextColor=c.getter("accent_text_color"),this.bgColor=c.getter("bg_color"),this.buttonColor=c.getter("button_color"),this.buttonTextColor=c.getter("button_text_color"),this.bottomBarBgColor=c.getter("bottom_bar_bg_color"),this.destructiveTextColor=c.getter("destructive_text_color"),this.headerBgColor=c.getter("header_bg_color"),this.hintColor=c.getter("hint_color"),this.linkColor=c.getter("link_color"),this.secondaryBgColor=c.getter("secondary_bg_color"),this.sectionBgColor=c.getter("section_bg_color"),this.sectionHeaderTextColor=c.getter("section_header_text_color"),this.sectionSeparatorColor=c.getter("section_separator_color"),this.subtitleTextColor=c.getter("subtitle_text_color"),this.textColor=c.getter("text_color"),this.state=c.state,this.isMounted=p.isMounted,this.bindCssVarsFp=g(v=>{if(this._isCssVarsBound())return P(new ht);v||(v=w=>`--vb-theme-${yo(w)}`);const F=w=>{Object.entries(c.state()).forEach(([y,m])=>{m&&w(y,m)})},k=()=>{F((w,y)=>{wn(v(w),y)})};return k(),c.state.sub(k),this._isCssVarsBound.set(!0),E(()=>{F(vn),c.state.unsub(k),this._isCssVarsBound.set(!1)})}),this.mountFp=f(p.mount),this.unmount=p.unmount,this.bindCssVars=b(this.bindCssVarsFp),this.mount=b(this.mountFp)}}const Sn=Ye({});function Za(){return new rs({...d(q(),ye("themeParams")),offChange(t){Ee("theme_changed",t)},onChange(t){X("theme_changed",t)},initialState:Sn})}const Xe=Za();function ss(t,e,n){return d(dn(t,e),r=>({...r,defaults:n}))}const Ya=new ts(ss("mainButton","main_button_pressed",{bgColor:C(()=>Xe.buttonColor()||"#2481cc"),textColor:C(()=>Xe.buttonTextColor()||"#ffffff")}));class is{constructor({storage:e,isPageReload:n,version:r,postEvent:i,isVBma:o,theme:a,onVisibilityChanged:c,offVisibilityChanged:l}){s(this,"isSupported");s(this,"isDark",C(()=>{const e=this.bgColorRgb();return e?yn(e):!1}));s(this,"isActive");s(this,"state");s(this,"isCssVarsBound");s(this,"bindCssVarsFp");s(this,"bindCssVars");s(this,"isMounted");s(this,"mountFp");s(this,"mount");s(this,"unmount");s(this,"bgColor");s(this,"bgColorRgb");s(this,"setBgColorFp");s(this,"setBgColor");s(this,"headerColor");s(this,"headerColorRgb");s(this,"setHeaderColorFp");s(this,"setHeaderColor");s(this,"bottomBarColor");s(this,"bottomBarColorRgb");s(this,"setBottomBarColorFp");s(this,"setBottomBarColor");s(this,"closeFp");s(this,"close");s(this,"readyFp");s(this,"ready");const p=m=>{g.setState({isActive:m.is_visible})},h=m=>{[[this.headerColor,"web_app_set_header_color"],[this.bgColor,"web_app_set_background_color"],[this.bottomBarColor,"web_app_set_bottom_bar_color"]].forEach(([j,H])=>{const W=j();if(!Ke(W)&&(H!=="web_app_set_header_color"||!["bg_color","secondary_bg_color"].includes(W))){const A=m[W];A&&i(H,{color:A})}})},f=new Ne({initialState(){return E({bgColor:"bg_color",headerColor:"header_bg_color",bottomBarColor:"bottom_bar_bg_color",isActive:!0})},isPageReload:n,onMounted:m=>{c(p),a.sub(h),g.setState(m)},onUnmounted(){l(p),a.unsub(h)},restoreState:e.get});this.isMounted=f.isMounted,this.mountFp=V(()=>{const m=()=>{};return d(f.mount(),le(m,m))},{isVBma:o,returns:"plain"}),this.mount=b(this.mountFp),this.unmount=f.unmount;const g=new ge({initialState:{bgColor:"bg_color",bottomBarColor:"bottom_bar_bg_color",headerColor:"bg_color",isActive:!1},onChange:e.set});this.state=g.state;const v=m=>Ke(m)?m:te(a)[m],F=m=>C(()=>v(m()));this.isActive=g.getter("isActive"),this.isSupported=C(()=>["web_app_set_header_color","web_app_set_background_color","web_app_set_bottom_bar_color"].some(m=>_e(m,te(r))));const k=D(!1);this.isCssVarsBound=C(k),this.bindCssVarsFp=V(m=>{if(k())return P(new ht);const[j,H]=Ge(()=>{k.set(!1)}),W=(A,O)=>{const L=()=>{wn(A,O()||null)};L(),j(O.sub(L),vn.bind(null,A))};return m||(m=A=>`--tg-${Nn(A)}`),W(m("bgColor"),this.bgColorRgb),W(m("bottomBarColor"),this.bottomBarColorRgb),W(m("headerColor"),this.headerColorRgb),k.set(!0),E(H)},{isVBma:o,returns:"either",isMounted:this.isMounted}),this.bindCssVars=b(this.bindCssVarsFp);const w=m=>{const j=g.getter(m),H=F(j),W={headerColor:"web_app_set_header_color",bgColor:"web_app_set_background_color",bottomBarColor:"web_app_set_bottom_bar_color"}[m],A=V(O=>{if(O===j())return E(void 0);if(W==="web_app_set_header_color"&&(O==="bg_color"||O==="secondary_bg_color"))return d(i("web_app_set_header_color",{color_key:O}),Q(()=>{g.setState({[m]:O})}));const L=v(O);return d(L?i(W,{color:L}):P(new Pr(O)),Q(()=>{g.setState({[m]:O})}))},{isVBma:o,version:r,requires:W,isMounted:this.isMounted,returns:"either",supports:m==="headerColor"?{rgb:{method:"web_app_set_header_color",param:"color",shouldCheck:Ke}}:void 0});return[j,H,b(A),A]};[this.bgColor,this.bgColorRgb,this.setBgColor,this.setBgColorFp]=w("bgColor"),[this.headerColor,this.headerColorRgb,this.setHeaderColor,this.setHeaderColorFp]=w("headerColor"),[this.bottomBarColor,this.bottomBarColorRgb,this.setBottomBarColor,this.setBottomBarColorFp]=w("bottomBarColor");const y=M({isVBma:o,returns:"either"});this.closeFp=y(m=>i("web_app_close",{return_back:m})),this.close=b(this.closeFp),this.readyFp=y(()=>i("web_app_ready")),this.ready=b(this.readyFp)}}function Xa(){return new is({...d(q(),J,$,ye("miniApp")),offVisibilityChanged(t){Ee("visibility_changed",t)},onVisibilityChanged(t){X("visibility_changed",t)},theme:Xe.state})}const os=Xa();function xa(){const t=Date.now(),e=Math.random().toString(36).substring(2,9);return`notif_${t}_${e}`}class as{constructor({version:e,isVBma:n}){s(this,"isSupported");s(this,"sendFp");s(this,"send");const r=M({version:e,isVBma:n,requires:"web_app_send_notification",returns:"task"});this.isSupported=se("web_app_send_notification",e),this.sendFp=r(i=>d(Ue(Le("web_app_send_notification",{id:xa(),message:i.message,title:i.title,type:i.type??"default"})),I(()=>{}))),this.send=i=>this.sendFp(i)().then(a=>{if(a._tag==="Left")throw a.left;return a.right})}}function eu(){return new as($(q()))}const tu=eu();function nu(t){const e=t.message.trim(),n=(t.title||"").trim(),r=t.buttons||[];if(n.length>64)return P(new ie(`Invalid title: ${n}`));if(!e||e.length>256)return P(new ie(`Invalid message: ${e}`));if(r.length>3)return P(new ie(`Invalid buttons count: ${r.length}`));const i=[];if(!r.length)i.push({type:"close",id:""});else for(let o=0;o<r.length;o++){const a=r[o],c=a.id||"";if(c.length>64)return P(new ie(`Button with index ${o} has invalid id: ${c}`));if(!a.type||a.type==="default"||a.type==="destructive"){const l=a.text.trim();if(!l||l.length>64)return P(new ie(`Button with index ${o} has invalid text: ${l}`));i.push({type:a.type,text:l,id:c})}else i.push({type:a.type,id:c})}return E({title:n,message:e,buttons:i})}class us{constructor({version:e,isVBma:n,request:r}){s(this,"isOpened");s(this,"isSupported");s(this,"showFp");s(this,"show");const i=D(!1),o=()=>{i.set(!1)},a=M({version:e,isVBma:n,requires:"web_app_open_popup",returns:"task"});this.isSupported=se("web_app_open_popup",e),this.isOpened=C(i),this.showFp=a(c=>d(this.isOpened()?U(new ft("A popup is already opened")):T(void 0),pe(()=>Ue(nu(c))),ne(l=>(i.set(!0),r("web_app_open_popup","popup_closed",{...c,params:l}))),We(l=>(o(),l),l=>(o(),l.button_id)))),this.show=b(this.showFp)}}function ru(){return new us(d(q(),x,$))}const su=ru();function iu({request:t,...e}){return V(n=>d(t("web_app_request_phone","phone_requested",n),I(r=>r.status)),{...e,requires:"web_app_request_phone",returns:"task"})}function ou(){return iu(d(q(),$,x))}const Fn=ou(),au=b(Fn);function uu({invokeCustomMethod:t,requestPhoneAccess:e,...n}){const r=a=>d(t("getRequestedContact",{},{...a,timeout:(a||{}).timeout||5e3}),pe(c=>{const l=Wt(S(),c);if(!l.success)return U(new Ze(c,l.issues));if(!l.output)return T(void 0);const p=Wt(Qt(N({contact:ue(N({user_id:we(),phone_number:S(),first_name:S(),last_name:B(S())})),auth_date:ae(S(),he(h=>new Date(Number(h)*1e3)),st()),hash:S()})),l.output);return p.success?T({raw:l.output,parsed:p.output}):U(new Ze(l.output,p.issues))})),i=a=>d(r(a),tt(c=>Ze.is(c)?P(c):E(void 0),c=>E(c))),o=a=>Re(async(c,l,p)=>{let h=50;for(;!p.isRejected;){const f=await i(p)();if(f._tag==="Left")return l(f.left);if(f.right)return c(f.right);await new Promise(g=>setTimeout(g,h)),h+=50}},a);return V(a=>Re.fn(c=>d(i(c),ne(l=>l?T(l):d(e(c),pe(p=>p==="sent"?o(c):U(new ln("User denied access")))))),a),{...n,returns:"task",requires:"web_app_request_phone"})}function cu(){return uu({...d(q(),mn,$),requestPhoneAccess:Fn})}function lu({requestContact:t,...e}){return V(t,{...e,returns:"task",requires:"web_app_request_phone"})}function pu(){return lu({...d(q(),$),requestContact(t){return d(Cn(t),I(e=>e.parsed))}})}const Cn=cu(),du=b(Cn),cs=pu(),hu=b(cs);function fu({request:t,...e}){return V(n=>d(t("web_app_request_write_access","write_access_requested",n),I(r=>r.status)),{...e,requires:"web_app_request_write_access",returns:"task"})}function _u(){return fu(d(q(),$,x))}const ls=_u(),bu=b(ls);class ps{constructor({version:e,onClosed:n,onTextReceived:r,isVBma:i,postEvent:o}){s(this,"isOpened");s(this,"isSupported");s(this,"captureFp");s(this,"capture");s(this,"closeFp");s(this,"close");s(this,"openFp");s(this,"open");const a={version:e,requires:"web_app_open_scan_qr_popup",isVBma:i},c=M({...a,returns:"either"}),l=M({...a,returns:"task"}),p=D(!1),h=()=>{p.set(!1)};this.isSupported=se("web_app_open_scan_qr_popup",e),this.isOpened=C(p),this.captureFp=l(f=>{let g;return d(this.openFp({...f,onCaptured:v=>{f.capture(v)&&(g=v,this.close())}}),I(()=>g))}),this.closeFp=c(()=>d(o("web_app_close_scan_qr_popup"),Q(h))),this.openFp=l(f=>d(p()?U(new ft("The QR Scanner is already opened")):async()=>o("web_app_open_scan_qr_popup",{text:f.text}),pe(()=>{p.set(!0);const[g,v]=Ge(),F=k=>(v(),p.set(!1),k);return d(Re(k=>{g(n(k),p.sub(w=>{w||k()}),r(f.onCaptured))},f),We(F,F))}))),this.open=b(this.openFp),this.capture=b(this.captureFp),this.close=b(this.closeFp)}}function mu(){return new ps({...d(q(),J,$),onClosed(t){return X("scan_qr_popup_closed",t)},onTextReceived(t){return X("qr_text_received",e=>{t(e.data)})}})}const gu=mu();class ds{constructor({}){s(this,"isRefreshing");s(this,"finishRefreshFp");s(this,"finishRefresh");s(this,"onRefreshRequest");const e=D(!1);X("refresh_requested",()=>{e.set(!0)}),this.isRefreshing=C(e),this.finishRefreshFp=()=>d(Ue(Le("web_app_finish_refresh")),I(()=>{e.set(!1)})),this.finishRefresh=()=>this.finishRefreshFp()().then(r=>{if(r._tag==="Left")throw r.left;return r.right}),this.onRefreshRequest=n=>X("refresh_requested",()=>{n()})}}function wu(){return new ds(d(q()))}const vu=wu();class hs{constructor({defaults:e,...n}){s(this,"isSupported");s(this,"position");s(this,"bgColor");s(this,"hasShineEffect");s(this,"isEnabled");s(this,"isLoaderVisible");s(this,"isVisible");s(this,"isMounted");s(this,"state");s(this,"text");s(this,"textColor");s(this,"showFp");s(this,"show");s(this,"hideFp");s(this,"hide");s(this,"enableFp");s(this,"enable");s(this,"enableShineEffectFp");s(this,"enableShineEffect");s(this,"disableFp");s(this,"disable");s(this,"disableShineEffectFp");s(this,"disableShineEffect");s(this,"setBgColorFp");s(this,"setBgColor");s(this,"setTextColorFp");s(this,"setTextColor");s(this,"setTextFp");s(this,"setText");s(this,"setPositionFp");s(this,"setPosition");s(this,"showLoaderFp");s(this,"showLoader");s(this,"hideLoaderFp");s(this,"hideLoader");s(this,"setParamsFp");s(this,"setParams");s(this,"mountFp");s(this,"mount");s(this,"unmount");s(this,"onClickFp");s(this,"onClick");s(this,"offClickFp");s(this,"offClick");const r=new _t({...n,initialState:{hasShineEffect:!1,isEnabled:!0,isLoaderVisible:!1,isVisible:!1,text:"Cancel",position:"left"},method:"web_app_setup_secondary_button",payload:o=>({has_shine_effect:o.hasShineEffect,is_visible:o.isVisible,is_active:o.isEnabled,is_progress_visible:o.isLoaderVisible,text:o.text,color:o.bgColor,text_color:o.textColor,position:o.position})}),i=(o,a)=>{const c=r.stateGetter(o);return C(()=>c()||te(a))};this.isSupported=se("web_app_setup_secondary_button",n.version),this.bgColor=i("bgColor",e.bgColor),this.textColor=i("textColor",e.textColor),this.position=r.stateGetter("position"),this.hasShineEffect=r.stateGetter("hasShineEffect"),this.isEnabled=r.stateGetter("isEnabled"),this.isLoaderVisible=r.stateGetter("isLoaderVisible"),this.text=r.stateGetter("text"),this.isVisible=r.stateGetter("isVisible"),this.isMounted=r.isMounted,this.state=r.state,[this.setPosition,this.setPositionFp]=r.stateSetters("position"),[this.setBgColor,this.setBgColorFp]=r.stateSetters("bgColor"),[this.setTextColor,this.setTextColorFp]=r.stateSetters("textColor"),[[this.disableShineEffect,this.disableShineEffectFp],[this.enableShineEffect,this.enableShineEffectFp]]=r.stateBoolSetters("hasShineEffect"),[[this.disable,this.disableFp],[this.enable,this.enableFp]]=r.stateBoolSetters("isEnabled"),[[this.hideLoader,this.hideLoaderFp],[this.showLoader,this.showLoaderFp]]=r.stateBoolSetters("isLoaderVisible"),[this.setText,this.setTextFp]=r.stateSetters("text"),[[this.hide,this.hideFp],[this.show,this.showFp]]=r.stateBoolSetters("isVisible"),this.setParams=r.setState,this.setParamsFp=r.setStateFp,this.onClick=r.onClick,this.onClickFp=r.onClickFp,this.offClick=r.offClick,this.offClickFp=r.offClickFp,this.mount=r.mount,this.mountFp=r.mountFp,this.unmount=r.unmount}}function yu(){return new hs(ss("secondaryButton","secondary_button_pressed",{bgColor:C(()=>os.bottomBarColorRgb()||"#000000"),textColor:C(()=>Xe.buttonColor()||"#2481cc")}))}const Su=yu();class fs{constructor({isVBma:e,request:n,version:r,createRequestId:i}){s(this,"getItemFp");s(this,"getItem");s(this,"restoreItemFp");s(this,"restoreItem");s(this,"setItemFp");s(this,"setItem");s(this,"deleteItemFp");s(this,"deleteItem");s(this,"clearFp");s(this,"clear");const o=M({version:r,requires:"web_app_secure_storage_get_key",isVBma:e,returns:"task"}),a=(c,l,p)=>{const h=i();return d(n(c,["secure_storage_failed",l],{params:{...p,req_id:h},capture:(f=>"payload"in f?f.payload.req_id===h:!0)}),ne(f=>f.event==="secure_storage_failed"?U(new qr(f.payload.error||"UNKNOWN_ERROR")):T(f.payload)))};this.getItemFp=o(c=>d(a("web_app_secure_storage_get_key","secure_storage_key_received",{key:c}),I(l=>({value:l.value,canRestore:!!l.can_restore})))),this.setItemFp=o((c,l)=>d(a("web_app_secure_storage_save_key","secure_storage_key_saved",{key:c,value:l}),I(()=>{}))),this.deleteItemFp=o(c=>this.setItemFp(c,null)),this.clearFp=o(()=>d(a("web_app_secure_storage_clear","secure_storage_cleared",{}),I(()=>{}))),this.restoreItemFp=o(c=>d(a("web_app_secure_storage_restore_key","secure_storage_key_restored",{key:c}),I(l=>l.value))),this.getItem=b(this.getItemFp),this.setItem=b(this.setItemFp),this.deleteItem=b(this.deleteItemFp),this.clear=b(this.clearFp),this.restoreItem=b(this.restoreItemFp)}}function Fu(){return new fs(d(q(),$,x,Nr))}const Cu=Fu();class _s{constructor(e){s(this,"isVisible");s(this,"isMounted");s(this,"isSupported");s(this,"hideFp");s(this,"hide");s(this,"showFp");s(this,"show");s(this,"onClickFp");s(this,"onClick");s(this,"offClickFp");s(this,"offClick");s(this,"mountFp");s(this,"mount");s(this,"unmount");const n=new _t({...e,method:"web_app_setup_settings_button",payload:r=>({is_visible:r.isVisible}),initialState:{isVisible:!1}});this.isVisible=n.stateGetter("isVisible"),this.isMounted=n.isMounted,this.isSupported=n.isSupported,[[this.hide,this.hideFp],[this.show,this.showFp]]=n.stateBoolSetters("isVisible"),this.onClick=n.onClick,this.onClickFp=n.onClickFp,this.offClick=n.offClick,this.offClickFp=n.offClickFp,this.mount=n.mount,this.mountFp=n.mountFp,this.unmount=n.unmount}}const ku=new _s(dn("settingsButton","settings_button_pressed"));class bs{constructor({postEvent:e,storage:n,isVBma:r,isPageReload:i,version:o}){s(this,"isSupported");s(this,"isVerticalEnabled");s(this,"isMounted");s(this,"mountFp");s(this,"mount");s(this,"unmount");s(this,"disableVerticalFp");s(this,"disableVertical");s(this,"enableVerticalFp");s(this,"enableVertical");const a={isVerticalEnabled:!0},c=new ge({initialState:a,onChange(v){n.set(v)}}),l=new Ne({initialState:a,isPageReload:i,onMounted:c.setState,restoreState:n.get}),p={requires:"web_app_setup_swipe_behavior",isVBma:r,version:o},h=M({...p,returns:"plain"}),f=M({...p,isMounted:l.isMounted,returns:"either"}),g=v=>{const F={isVerticalEnabled:v};return c.hasDiff(F)?d(e("web_app_setup_swipe_behavior",{allow_vertical_swipe:v}),Q(()=>{c.setState(F)})):E(void 0)};this.isSupported=se("web_app_setup_swipe_behavior",o),this.isVerticalEnabled=c.getter("isVerticalEnabled"),this.isMounted=l.isMounted,this.disableVerticalFp=f(()=>g(!1)),this.enableVerticalFp=f(()=>g(!0)),this.mountFp=h(()=>{const v=()=>{};return d(l.mount(),le(v,v))}),this.unmount=l.unmount,this.disableVertical=b(this.disableVerticalFp),this.enableVertical=b(this.enableVerticalFp),this.mount=b(this.mountFp)}}function Eu(){return new bs(d(q(),J,$,ye("swipeBehavior")))}const qu=Eu();async function Au(t){try{const{clipboard:n}=navigator;if(n)return await n.writeText(t)}catch{}const e=document.createElement("textarea");e.value=t,e.style.top="0",e.style.left="0",e.style.position="fixed",document.body.appendChild(e),e.focus(),e.select();try{document.execCommand("copy")}finally{document.body.removeChild(e)}}function Iu({request:t,...e}){return V((n,r,i)=>d(t("web_app_request_file_download","file_download_requested",{...i,params:{url:n,file_name:r}}),ne(o=>o.status==="downloading"?T(void 0):U(new ln("User denied the action")))),{...e,requires:"web_app_request_file_download",returns:"task"})}function Bu(){return Iu(d(q(),x,$))}const ms=Bu(),$u=b(ms);function Mu({invokeCustomMethod:t,...e}){return V(n=>d(t("getCurrentTime",{},n),ne(r=>{const i=Wt(ae(we(),Lt(),he(o=>new Date(o*1e3)),st()),r);return i.success?T(i.output):U(new Ze(r,i.issues))})),{...e,requires:"web_app_invoke_custom_method",returns:"task"})}function Pu(){return Mu(d(q(),mn,$))}const gs=Pu(),Ru=b(gs);function Tu({postEvent:t,...e}){return V(()=>t("web_app_hide_keyboard"),{...e,returns:"either",requires:"web_app_hide_keyboard"})}function Lu(){return Tu(d(q(),J,$))}const ws=Lu(),Vu=b(ws);function Ou({request:t,createRequestId:e,...n}){return V(r=>{const i=e();return d(t("web_app_read_text_from_clipboard","clipboard_text_received",{...r,params:{req_id:i},capture:yr(i)}),I(({data:o=null})=>o))},{...n,requires:"web_app_read_text_from_clipboard",returns:"task"})}function ju(){return Ou({...d(q(),$,x),createRequestId:bt})}const vs=ju(),Hu=b(vs);function ys(t){const e={},n=t.match(/Telegram-Android(?:\/([^ ]+))?(?: (\([^)]+\))?|$)/);if(n){const[,r,i]=n;r&&(e.appVersion=r),i&&i.slice(1,i.length-1).split(";").forEach(o=>{const[a,c]=o.trim().split(" ");if(a==="Android")e.androidVersion=c;else if(a==="SDK"){const l=parseInt(c,10);l&&(e.sdkVersion=l)}else c?(e.manufacturer=a,e.model=c):e.performanceClass=a})}return e}function Du(){return ys(navigator.userAgent)}function Uu({postEvent:t,...e}){return V(n=>{const{size:r}=new Blob([n]);return!r||r>4096?P(new ie(r?"Maximum size of data to send is 4096 bytes":"Attempted to send empty data")):t("web_app_data_send",{data:n})},{...e,returns:"either"})}function Wu(){return Uu(d(q(),J))}const Ss=Wu(),Nu=b(Ss);function Gu({request:t,...e}){return V((n,r)=>d(t("web_app_send_prepared_message",["prepared_message_failed","prepared_message_sent"],{...r,params:{id:n}}),ne(i=>i.event==="prepared_message_failed"?U(new Mr(i.payload.error)):T(void 0))),{...e,requires:"web_app_send_prepared_message",returns:"task"})}function zu(){return Gu(d(q(),x,$))}const Fs=zu(),Ku=b(Fs);function Qu({postEvent:t,...e}){return V((n,r={})=>t("web_app_share_to_story",{text:r.text,media_url:n,widget_link:r.widgetLink}),{...e,requires:"web_app_share_to_story",returns:"either"})}function Ju(){return Qu(d(q(),J,$))}const Cs=Ju(),Zu=b(Cs),kn=Ye(!1);function Yu({isInlineMode:t,postEvent:e,...n}){return V((r,i)=>e("web_app_switch_inline_query",{query:r,chat_types:i||[]}),{...n,requires:{every:["web_app_switch_inline_query",()=>te(t)?void 0:"The application must be launched in the inline mode"]},returns:"either"})}function Xu(){return Yu({...d(q(),J,$),isInlineMode:kn})}const ks=Xu(),xu=b(ks);class Es{constructor({storage:e,isPageReload:n,onContentSafeAreaInsetsChanged:r,onSafeAreaInsetsChanged:i,onViewportChanged:o,onFullscreenChanged:a,offContentSafeAreaInsetsChanged:c,offFullscreenChanged:l,offSafeAreaInsetsChanged:p,offViewportChanged:h,request:f,isViewportStable:g,isFullscreen:v,isVBma:F,version:k,postEvent:w}){s(this,"state");s(this,"height");s(this,"stableHeight");s(this,"width");s(this,"isExpanded");s(this,"isStable",C(()=>this.height()===this.stableHeight()));s(this,"contentSafeAreaInsets");s(this,"contentSafeAreaInsetTop");s(this,"contentSafeAreaInsetLeft");s(this,"contentSafeAreaInsetRight");s(this,"contentSafeAreaInsetBottom");s(this,"safeAreaInsets");s(this,"safeAreaInsetTop");s(this,"safeAreaInsetLeft");s(this,"safeAreaInsetRight");s(this,"safeAreaInsetBottom");s(this,"isFullscreen");s(this,"requestFullscreenFp");s(this,"requestFullscreen");s(this,"exitFullscreenFp");s(this,"exitFullscreen");s(this,"isCssVarsBound");s(this,"bindCssVarsFp");s(this,"bindCssVars");s(this,"isMounted");s(this,"mountFp");s(this,"mount");s(this,"expandFp");s(this,"expand");const y={top:0,right:0,left:0,bottom:0},m=new ge({initialState:{contentSafeAreaInsets:y,height:0,isExpanded:!1,isFullscreen:!1,safeAreaInsets:y,stableHeight:0,width:0},onChange:e.set}),j=R=>{m.setState({isExpanded:R.is_expanded,height:R.height,width:R.width,stableHeight:R.is_state_stable?R.height:void 0})},H=R=>{m.setState({isFullscreen:R.is_fullscreen})},W=R=>{m.setState({safeAreaInsets:R})},A=R=>{m.setState({contentSafeAreaInsets:R})},O=new hn({initialState(R){const Ie=be=>()=>{const[Se,oe]=be==="safe-area"?["web_app_request_safe_area","safe_area_changed"]:["web_app_request_content_safe_area","content_safe_area_changed"];return _e(Se,te(k))?f(Se,oe,R):T({top:0,left:0,right:0,bottom:0})},z=be=>()=>typeof be=="boolean"?T(be):Ue(be());return d(no,nt("safeAreaInsets",Ie("safe-area")),nt("contentSafeAreaInsets",Ie("content-safe-area")),nt("isFullscreen",z(v)),nt("isViewportStable",z(g)),pe(({isViewportStable:be,...Se})=>be?T({...Se,height:window.innerHeight,isExpanded:!0,stableHeight:window.innerHeight,width:window.innerWidth}):d(f("web_app_request_viewport","viewport_changed",R),I(oe=>({...Se,height:oe.height,isExpanded:oe.is_expanded,stableHeight:oe.is_state_stable?oe.height:0,width:oe.width})))))},isPageReload:n,onMounted(R){o(j),a(H),i(W),r(A),m.setState(R)},onUnmounted(){h(j),l(H),p(W),c(A)},restoreState:e.get}),L=R=>C(()=>this.safeAreaInsets()[R]),G=R=>C(()=>this.contentSafeAreaInsets()[R]);this.state=m.state,this.height=m.getter("height"),this.stableHeight=m.getter("stableHeight"),this.width=m.getter("width"),this.isExpanded=m.getter("isExpanded"),this.safeAreaInsets=m.getter("safeAreaInsets"),this.safeAreaInsetTop=L("top"),this.safeAreaInsetBottom=L("bottom"),this.safeAreaInsetLeft=L("left"),this.safeAreaInsetRight=L("right"),this.contentSafeAreaInsets=m.getter("contentSafeAreaInsets"),this.contentSafeAreaInsetTop=G("top"),this.contentSafeAreaInsetBottom=G("bottom"),this.contentSafeAreaInsetLeft=G("left"),this.contentSafeAreaInsetRight=G("right");const Oe=M({isVBma:F,returns:"task"}),xe=M({isVBma:F,returns:"either"}),Bc=M({isVBma:F,requires:"web_app_request_fullscreen",version:k,returns:"task"}),ei=R=>Bc(Ie=>d(f(R?"web_app_request_fullscreen":"web_app_exit_fullscreen",["fullscreen_changed","fullscreen_failed"],Ie),ne(z=>z.event==="fullscreen_failed"&&z.payload.error!=="ALREADY_FULLSCREEN"?U(new $r(z.payload.error)):(m.setState({isFullscreen:"is_fullscreen"in z.payload?z.payload.is_fullscreen:!0}),T(void 0)))));this.isMounted=O.isMounted,this.mountFp=Oe(O.mount),this.mount=b(this.mountFp),this.isFullscreen=m.getter("isFullscreen"),this.requestFullscreenFp=ei(!0),this.requestFullscreen=b(this.requestFullscreenFp),this.exitFullscreenFp=ei(!1),this.exitFullscreen=b(this.exitFullscreenFp);const mt=D(!1);this.isCssVarsBound=C(mt),this.bindCssVarsFp=xe(R=>{if(mt())return P(new ht);R||(R=z=>`--vb-viewport-${Nn(z)}`);const Ie=[["height",this.height],["stableHeight",this.stableHeight],["width",this.width],["safeAreaInsetTop",this.safeAreaInsetTop],["safeAreaInsetBottom",this.safeAreaInsetBottom],["safeAreaInsetLeft",this.safeAreaInsetLeft],["safeAreaInsetRight",this.safeAreaInsetRight],["contentSafeAreaInsetTop",this.contentSafeAreaInsetTop],["contentSafeAreaInsetBottom",this.contentSafeAreaInsetBottom],["contentSafeAreaInsetLeft",this.contentSafeAreaInsetLeft],["contentSafeAreaInsetRight",this.contentSafeAreaInsetRight]].reduce((z,[be,Se])=>{const oe=R(be);if(oe){const ti=()=>{wn(oe,`${Se()}px`)};z.push({update:ti,removeListener:Se.sub(ti),cssVar:oe})}return z},[]);return Ie.forEach(z=>{z.update()}),mt.set(!0),E(()=>{Ie.forEach(z=>{z.removeListener(),vn(z.cssVar)}),mt.set(!1)})}),this.bindCssVars=b(this.bindCssVarsFp),this.expandFp=xe(()=>w("web_app_expand")),this.expand=b(this.expandFp)}}function ec(){const t=o=>({on:a=>{X(o,a)},off:a=>{Ee(o,a)}}),e=t("viewport_changed"),n=t("fullscreen_changed"),r=t("safe_area_changed"),i=t("content_safe_area_changed");return new Es({...d(q(),ye("viewport"),$,J,x),isFullscreen(){return d(Te(),Q(o=>!!o.vbWebAppFullscreen))},isViewportStable(){return d(Te(),Q(o=>["macos","tdesktop","unigram","webk","weba","web"].includes(o.vbWebAppPlatform)))},offContentSafeAreaInsetsChanged:i.off,offFullscreenChanged:n.off,offSafeAreaInsetsChanged:r.off,offViewportChanged:e.off,onContentSafeAreaInsetsChanged:i.on,onFullscreenChanged:n.on,onSafeAreaInsetsChanged:r.on,onViewportChanged:e.on})}const tc=ec();class qs{constructor({request:e}){s(this,"requestAccessFp");s(this,"requestAccess");s(this,"selectFile");s(this,"selectFiles");s(this,"selectFolder");this.requestAccessFp=n=>d(e("web_app_request_storage_access","storage_access_granted",{params:{access_type:n.accessType,multiple:n.multiple,accept:n.accept,max_file_size:n.maxFileSize,read_content:n.readContent}}),I(r=>({accessType:r.access_type,items:r.items.map(i=>({name:i.name,path:i.path,size:i.size,type:i.type,content:i.content,lastModified:i.last_modified}))}))),this.requestAccess=n=>this.requestAccessFp(n)().then(i=>{if(i._tag==="Left")throw i.left;return i.right}),this.selectFile=n=>this.requestAccess({accessType:"file",multiple:!1,...n}),this.selectFiles=n=>this.requestAccess({accessType:"file",multiple:!0,...n}),this.selectFolder=()=>this.requestAccess({accessType:"folder"})}}function nc(){return new qs({request:dt})}const rc=nc();class As{onSetup(e){return _().on("web_app_setup_back_button",r=>{r&&typeof r.is_visible=="boolean"&&e(r.is_visible)})}press(){_().send("back_button_pressed")}}const sc=new As;class Is{onSetup(e){return _().on("web_app_setup_main_button",r=>{r&&e(r)})}press(){_().send("main_button_pressed")}}const ic=new Is;class Bs{onSetup(e){return _().on("web_app_setup_secondary_button",r=>{r&&e(r)})}press(){_().send("secondary_button_pressed")}}const oc=new Bs;class $s{onSetup(e){return _().on("web_app_setup_settings_button",r=>{r&&e(r)})}press(){_().send("settings_button_pressed")}}const ac=new $s;class Ms{onOpen(e){return _().on("web_app_open_popup",r=>{r&&e(r)})}close(e){_().send("popup_closed",{button_id:e})}}const uc=new Ms;class Ps{onExpand(e){return _().on("web_app_expand",()=>{e()})}onRequestContentSafeArea(e){return _().on("web_app_request_content_safe_area",()=>{e()})}onRequestSafeArea(e){return _().on("web_app_request_safe_area",()=>{e()})}onRequestViewport(e){return _().on("web_app_request_viewport",()=>{e()})}onToggleOrientationLock(e){return _().on("web_app_toggle_orientation_lock",r=>{r&&typeof r.locked=="boolean"&&e(r.locked)})}onRequestFullscreen(e){return _().on("web_app_request_fullscreen",()=>{e()})}setFullscreen(e){_().send("fullscreen_changed",{is_fullscreen:e})}setFullscreenFailed(e){_().send("fullscreen_failed",{error:e})}onExitFullscreen(e){return _().on("web_app_exit_fullscreen",()=>{e()})}setContentSafeArea(e){_().send("content_safe_area_changed",e)}setSafeArea(e){_().send("safe_area_changed",e)}setViewport(e){_().send("viewport_changed",e)}}const cc=new Ps;class Rs{onIframeReady(e){return _().on("iframe_ready",r=>{e(r||{})})}onIframeWillReload(e){return _().on("iframe_will_reload",()=>{e()})}onClose(e){return _().on("web_app_close",()=>{e()})}onHideKeyboard(e){return _().on("web_app_hide_keyboard",()=>{e()})}onReady(e){return _().on("web_app_ready",()=>{e()})}onRequestTheme(e){return _().on("web_app_request_theme",()=>{e()})}onBackgroundColorChange(e){return _().on("web_app_set_background_color",r=>{r&&typeof r.color=="string"&&e(r.color)})}onBottomBarColorChange(e){return _().on("web_app_set_bottom_bar_color",r=>{r&&r.color&&e(r.color)})}onHeaderColorChange(e){return _().on("web_app_set_header_color",r=>{r&&("color_key"in r&&r.color_key?e(r.color_key):"color"in r&&r.color&&e(r.color))})}reloadIframe(){_().send("reload_iframe")}setCustomStyle(e){_().send("set_custom_style",e)}setVisibility(e){_().send("visibility_changed",{is_visible:e})}}const lc=new Rs;class Ts{onHapticFeedback(e){return _().on("web_app_trigger_haptic_feedback",r=>{r&&e(r)})}}const pc=new Ts;class Ls{onGetInfo(e){return _().on("web_app_biometry_get_info",()=>{e()})}onOpenSettings(e){return _().on("web_app_biometry_open_settings",()=>{e()})}onRequestAccess(e){return _().on("web_app_biometry_request_access",r=>{e(r||{})})}onRequestAuth(e){return _().on("web_app_biometry_request_auth",r=>{e(r||{})})}onUpdateToken(e){return _().on("web_app_biometry_update_token",r=>{r&&e(r)})}setInfoReceived(e){_().send("biometry_info_received",e)}setAuthRequested(e){_().send("biometry_auth_requested",e)}setTokenUpdated(e){_().send("biometry_token_updated",e)}}const dc=new Ls;class Vs{onOpenInvoice(e){return _().on("web_app_open_invoice",r=>{r&&e(r)})}setInvoiceClosed(e){_().send("invoice_closed",e)}}const hc=new Vs;class Os{onOpenPopup(e){return _().on("web_app_open_scan_qr_popup",r=>{e(r||{})})}onClosePopup(e){return _().on("web_app_close_scan_qr_popup",()=>{e()})}sendQrTextReceived(e){_().send("qr_text_received",e)}closePopup(){_().send("scan_qr_popup_closed")}}const fc=new Os;class js{onCheckLocation(e){return _().on("web_app_check_location",()=>{e()})}onOpenLocationSettings(e){return _().on("web_app_open_location_settings",()=>{e()})}onRequestLocation(e){return _().on("web_app_request_location",()=>{e()})}setLocationChecked(e){_().send("location_checked",e)}setLocationRequested(e){_().send("location_requested",e)}}const _c=new js;class Hs{onOpenLink(e){return _().on("web_app_open_link",r=>{r&&e(r)})}onOpenTgLink(e){return _().on("web_app_open_tg_link",r=>{r&&e(r)})}}const bc=new Hs;class Ds{onRequestAccess(e){return _().on("web_app_request_emoji_status_access",()=>{e()})}onSetEmojiStatus(e){return _().on("web_app_set_emoji_status",r=>{r&&e(r)})}setAccessRequested(e){_().send("emoji_status_access_requested",e)}setEmojiStatusSet(e){_().send("emoji_status_set",e)}setEmojiStatusFailed(e){_().send("emoji_status_failed",e)}}const mc=new Ds;class Us{onAddToHomeScreen(e){return _().on("web_app_add_to_home_screen",()=>{e()})}onCheckHomeScreen(e){return _().on("web_app_check_home_screen",()=>{e()})}setHomeScreenChecked(e){_().send("home_screen_checked",e)}setHomeScreenAdded(){_().send("home_screen_added")}setHomeScreenFailed(e){_().send("home_screen_failed",e)}}const gc=new Us;class Ws{onRequestPhone(e){return _().on("web_app_request_phone",()=>{e()})}onRequestWriteAccess(e){return _().on("web_app_request_write_access",()=>{e()})}setPhoneRequested(e){_().send("phone_requested",e)}setWriteAccessRequested(e){_().send("write_access_requested",e)}}const wc=new Ws;class Ns{onSetupClosingBehavior(e){return _().on("web_app_setup_closing_behavior",r=>{r&&e(r)})}}const vc=new Ns;class Gs{onSetupSwipeBehavior(e){return _().on("web_app_setup_swipe_behavior",r=>{r&&e(r)})}}const yc=new Gs;class zs{onReadText(e){return _().on("web_app_read_text_from_clipboard",r=>{r&&e(r)})}sendTextReceived(e){_().send("clipboard_text_received",e)}}const Sc=new zs;class Ks{onRequestFileDownload(e){return _().on("web_app_request_file_download",r=>{e(r||{})})}setFileDownloadRequested(e){_().send("file_download_requested",e)}}const Fc=new Ks;class Qs{onSendPreparedMessage(e){return _().on("web_app_send_prepared_message",r=>{r&&e(r)})}onShareToStory(e){return _().on("web_app_share_to_story",r=>{e(r||{})})}setPreparedMessageFailed(e){_().send("prepared_message_failed",e)}setPreparedMessageSent(){_().send("prepared_message_sent")}}const Cc=new Qs;class Js{onDataSend(e){return _().on("web_app_data_send",r=>{r&&e(r)})}onSwitchInlineQuery(e){return _().on("web_app_switch_inline_query",r=>{r&&e(r)})}}const kc=new Js;class Zs{onInvokeCustomMethod(e){return _().on("web_app_invoke_custom_method",r=>{r&&e(r)})}setCustomMethodInvoked(e){_().send("custom_method_invoked",e)}}const Ec=new Zs;class Ys{onSend(e){return _().on("web_app_send_notification",r=>{r&&e(r)})}}const qc=new Ys;class Xs{setTheme(e){_().send("theme_changed",{theme_params:e})}onRequestTheme(e){return _().on("web_app_request_theme",()=>{e()})}}const Ac=new Xs;function xs(t={}){const{version:e,isInlineMode:n,themeParams:r}=t;if(e&&typeof n=="boolean"&&r)pn.set(e),kn.set(n),Sn.set(r);else{const c=d(Te(),Ct(l=>l,l=>{pn.set(e||l.vbWebAppVersion),kn.set(typeof n=="boolean"?n:!!l.vbWebAppBotInline),Sn.set(r||l.vbWebAppThemeParams)}));if(c)return P(c)}t.postEvent&&Tr.set(t.postEvent);const[i,o]=Ge(X("reload_iframe",()=>{ce().log("Received a request to reload the page"),Lr("iframe_will_reload"),window.location.reload()})),{acceptCustomStyles:a=!0}=t;if(a){const c=document.createElement("style");c.id="telegram-custom-styles",document.head.appendChild(c),i(X("set_custom_style",l=>{c.innerHTML=l}),()=>{document.head.removeChild(c)})}return d(Ae("iframe_ready",{reload_supported:!0}),Q(()=>(ce().log("The package was initialized"),o)))}const Ic=re(xs);return u.AccessDeniedError=ln,u.BackButton=Rr,u.Biometry=Or,u.CSSVarsBoundError=ht,u.CancelledError=Un,u.ClosingBehavior=Hr,u.CloudStorage=Dr,u.ConcurrentCallError=ft,u.DeviceStorage=Wr,u.DeviceStorageMethodError=Er,u.FullscreenFailedError=$r,u.FunctionUnavailableError=Ir,u.HapticFeedback=Kr,u.HostBackButton=As,u.HostBiometry=Ls,u.HostChat=Js,u.HostClipboard=zs,u.HostClosingBehavior=Ns,u.HostCustomMethod=Zs,u.HostEmojiStatus=Ds,u.HostFiles=Ks,u.HostHapticFeedback=Ts,u.HostHomeScreen=Us,u.HostInvoice=Vs,u.HostLink=Hs,u.HostLocationManager=js,u.HostMainButton=Is,u.HostMiniApp=Rs,u.HostNotification=Ys,u.HostPopup=Ms,u.HostPrivacy=Ws,u.HostQrScanner=Os,u.HostSecondaryButton=Bs,u.HostSettingsButton=$s,u.HostSharing=Qs,u.HostSwipeBehavior=Gs,u.HostThemeParams=Xs,u.HostViewport=Ps,u.InitData=Zr,u.InvalidArgumentsError=ie,u.InvalidEnvError=ia,u.InvalidLaunchParamsError=en,u.Invoice=Yr,u.InvokeCustomMethodFailedError=lr,u.LaunchParamsRetrieveError=cr,u.LocationManager=es,u.MainButton=ts,u.MethodParameterUnsupportedError=ur,u.MethodUnsupportedError=ar,u.MiniApp=is,u.NotAvailableError=Ar,u.Notification=as,u.Popup=us,u.QrScanner=ps,u.Refresh=ds,u.SecondaryButton=hs,u.SecureStorage=fs,u.SecureStorageMethodError=qr,u.SetEmojiStatusError=Br,u.SettingsButton=_s,u.ShareMessageError=Mr,u.StoragePermission=qs,u.SwipeBehavior=bs,u.ThemeParams=rs,u.TimeoutError=Gt,u.UnknownEnvError=tn,u.UnknownThemeParamsKeyError=Pr,u.ValidationError=Ze,u.Viewport=Es,u.addToHomeScreen=Ba,u.addToHomeScreenFp=Qr,u.applyPolyfills=ea,u.backButton=ca,u.biometry=ha,u.checkHomeScreenStatus=Pa,u.checkHomeScreenStatusFp=Jr,u.closingBehavior=_a,u.cloudStorage=ma,u.copyTextToClipboard=Au,u.createLogger=Kn,u.createPostEvent=Yo,u.createRequestId=bt,u.createStartParam=na,u.createStartParamFp=Cr,u.debug=_r,u.decodeBase64Url=ta,u.decodeBase64UrlFp=un,u.decodeStartParam=ra,u.decodeStartParamFp=kr,u.deepSnakeToCamelObjKeys=zt,u.defineHostBridge=Jo,u.deviceStorage=wa,u.downloadFile=$u,u.downloadFileFp=ms,u.emitEvent=pt,u.encodeBase64Url=cn,u.getCurrentTime=Ru,u.getCurrentTimeFp=gs,u.getHostBridge=_,u.getReleaseVersion=an,u.hapticFeedback=qa,u.hideKeyboard=Vu,u.hideKeyboardFp=ws,u.hostBackButton=sc,u.hostBiometry=dc,u.hostChat=kc,u.hostClipboard=Sc,u.hostClosingBehavior=vc,u.hostCustomMethod=Ec,u.hostEmojiStatus=mc,u.hostFiles=Fc,u.hostHapticFeedback=pc,u.hostHomeScreen=gc,u.hostInvoice=hc,u.hostLink=bc,u.hostLocationManager=_c,u.hostMainButton=ic,u.hostMiniApp=lc,u.hostNotification=qc,u.hostPopup=uc,u.hostPrivacy=wc,u.hostQrScanner=fc,u.hostSecondaryButton=oc,u.hostSettingsButton=ac,u.hostSharing=Cc,u.hostSwipeBehavior=yc,u.hostThemeParams=Ac,u.hostViewport=cc,u.init=Ic,u.initData=Ta,u.initFp=xs,u.invoice=Va,u.invokeCustomMethod=Ur,u.isAnyRGB=Xn,u.isColorDark=yn,u.isColorDarkFp=ns,u.isRGB=Ke,u.isRGBA=Yn,u.isRGBAShort=Zn,u.isRGBShort=Jn,u.isSafeToCreateStartParam=sa,u.isVBma=zo,u.isVBmaFp=on,u.locationManager=Ja,u.logger=ce,u.mainButton=Ya,u.miniApp=os,u.mockVBotEnv=Ko,u.notification=tu,u.off=Ee,u.offAll=Wo,u.on=X,u.openLink=Ha,u.openLinkFp=Xr,u.openVBotLink=Wa,u.openVBotLinkFp=gn,u.parseInitDataQuery=Po,u.parseInitDataQueryFp=rr,u.parseLaunchParamsQuery=Yt,u.parseLaunchParamsQueryFp=lt,u.popup=su,u.postEvent=Lr,u.postEventFp=Ae,u.qrScanner=gu,u.readTextFromClipboard=Hu,u.readTextFromClipboardFp=vs,u.refresh=vu,u.request=la,u.request2=pa,u.request2Fp=_n,u.requestContact=hu,u.requestContactComplete=du,u.requestContactCompleteFp=Cn,u.requestContactFp=cs,u.requestEmojiStatusAccess=Sa,u.requestEmojiStatusAccessFp=Gr,u.requestFp=jr,u.requestPhoneAccess=au,u.requestPhoneAccessFp=Fn,u.requestWriteAccess=bu,u.requestWriteAccessFp=ls,u.retrieveAndroidDeviceData=Du,u.retrieveAndroidDeviceDataFrom=ys,u.retrieveLaunchParams=To,u.retrieveLaunchParamsFp=Te,u.retrieveRawInitData=Lo,u.retrieveRawInitDataFp=nn,u.retrieveRawLaunchParams=Vo,u.retrieveRawLaunchParamsFp=Qe,u.secondaryButton=Su,u.secureStorage=Cu,u.sendData=Nu,u.sendDataFp=Ss,u.serializeInitDataQuery=ir,u.serializeLaunchParamsQuery=Xt,u.setDebug=jo,u.setEmojiStatus=ka,u.setEmojiStatusFp=zr,u.setLaunchParams=Qo,u.setTargetOrigin=Ho,u.settingsButton=ku,u.shareMessage=Ku,u.shareMessageFp=Fs,u.shareStory=Zu,u.shareStoryFp=Cs,u.shareURL=za,u.shareURLFp=xr,u.storagePermission=rc,u.supports=_e,u.swipeBehavior=qu,u.switchInlineQuery=xu,u.switchInlineQueryFp=ks,u.targetOrigin=br,u.themeParams=Xe,u.toRGB=Eo,u.toRGBFp=er,u.toRGBFull=qo,u.toRGBFullFp=ct,u.viewport=tc,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"}),u})({});
1
+ var Mc=Object.defineProperty;var Pc=(u,ee,Ie)=>ee in u?Mc(u,ee,{enumerable:!0,configurable:!0,writable:!0,value:Ie}):u[ee]=Ie;var s=(u,ee,Ie)=>Pc(u,typeof ee!="symbol"?ee+"":ee,Ie);this.tmajs=this.tmajs||{};this.tmajs.sdk=(function(u){"use strict";let ee;function Ie(t,e){ee?ee.set(t,e):e()}function et(t){if(ee)return t();ee=new Map;try{t()}finally{ee.forEach(e=>e()),ee=void 0}}function D(t,e){e||(e={});const n=e.equals||Object.is;let r=[],i=t;const o=p=>{if(!n(i,p)){const h=i;i=p,Ie(l,()=>{[...r].forEach(([f,g])=>{f(p,h),g&&c(f,!0)})})}};function a(p){const h=typeof p!="object"?{once:p}:p;return{once:h.once||!1,signal:h.signal||!1}}const c=(p,h)=>{const f=a(h),g=r.findIndex(([v,F])=>v===p&&F.once===f.once&&F.signal===f.signal);g>=0&&r.splice(g,1)},l=Object.assign(function(){return ri(l),i},{destroy(){r=[]},set:o,reset(){o(t)},sub(p,h){return r.push([p,a(h)]),()=>c(p,h)},unsub:c,unsubAll(){r=r.filter(p=>p[1].signal)}});return l}const Oe=[];function ri(t){Oe.length&&Oe[Oe.length-1].add(t)}function C(t,e){let n=new Set,r;function i(){return r||(r=D(a(),e))}function o(){i().set(a())}function a(){n.forEach(p=>{p.unsub(o,{signal:!0})});const c=new Set;let l;Oe.push(c);try{l=t()}finally{Oe.pop()}return c.forEach(p=>{p.sub(o,{signal:!0})}),n=c,l}return Object.assign(function(){return i()()},{destroy(){i().destroy()},sub(...c){return i().sub(...c)},unsub(...c){i().unsub(...c)},unsubAll(...c){i().unsubAll(...c)}})}var si=function(t,e,n){if(n||arguments.length===2)for(var r=0,i=e.length,o;r<i;r++)(o||!(r in e))&&(o||(o=Array.prototype.slice.call(e,0,r)),o[r]=e[r]);return t.concat(o||Array.prototype.slice.call(e))};function ii(t){return t}function qn(t,e,n,r,i,o,a,c,l){switch(arguments.length){case 1:return t;case 2:return function(){return e(t.apply(this,arguments))};case 3:return function(){return n(e(t.apply(this,arguments)))};case 4:return function(){return r(n(e(t.apply(this,arguments))))};case 5:return function(){return i(r(n(e(t.apply(this,arguments)))))};case 6:return function(){return o(i(r(n(e(t.apply(this,arguments))))))};case 7:return function(){return a(o(i(r(n(e(t.apply(this,arguments)))))))};case 8:return function(){return c(a(o(i(r(n(e(t.apply(this,arguments))))))))};case 9:return function(){return l(c(a(o(i(r(n(e(t.apply(this,arguments)))))))))}}}function d(t,e,n,r,i,o,a,c,l){switch(arguments.length){case 1:return t;case 2:return e(t);case 3:return n(e(t));case 4:return r(n(e(t)));case 5:return i(r(n(e(t))));case 6:return o(i(r(n(e(t)))));case 7:return a(o(i(r(n(e(t))))));case 8:return c(a(o(i(r(n(e(t)))))));case 9:return l(c(a(o(i(r(n(e(t))))))));default:{for(var p=arguments[0],h=1;h<arguments.length;h++)p=arguments[h](p);return p}}}var je=function(t,e){var n=typeof t=="number"?function(r){return r.length>=t}:t;return function(){var r=Array.from(arguments);return n(arguments)?e.apply(this,r):function(i){return e.apply(void 0,si([i],r,!1))}}},oi={_tag:"None"},ai=function(t){return{_tag:"Some",value:t}},ui=function(t){return t._tag==="Left"},An=function(t){return{_tag:"Left",left:t}},In=function(t){return{_tag:"Right",right:t}},gt={};function ci(t,e){return function(n){return function(r){return t.ap(t.map(r,function(i){return function(o){return e.ap(i,o)}}),n)}}}function li(t,e){return function(n){return function(r){return t.map(r,function(i){return e.map(i,n)})}}}function wt(t){return function(e,n){return function(r){return t.chain(r,function(i){return t.map(n(i),function(o){var a;return Object.assign({},i,(a={},a[e]=o,a))})})}}}var Se=oi,Be=ai,pi=function(t,e){return d(t,fi(e))},di=function(t,e){return d(t,bi(e))},hi="Option",fi=function(t){return function(e){return He(e)?Se:Be(t(e.value))}},_i=Be,bi=function(t){return function(e){return He(e)||He(t)?Se:Be(e.value(t.value))}},mi=je(2,function(t,e){return He(t)?Se:e(t.value)}),gi={URI:hi,map:pi,ap:di,chain:mi},He=function(t){return t._tag==="None"},wi=function(t,e){return function(n){return He(n)?t():e(n.value)}},vt=wi,vi=_i(gt),Bn=wt(gi),P=An,E=In,yt=je(2,function(t,e){return me(t)?t:e(t.right)}),St=function(t,e){return d(t,J(e))},$n=function(t,e){return d(t,Ci(e))},Ft="Either",J=function(t){return function(e){return me(e)?e:E(t(e.right))}},yi={URI:Ft,map:St},Si=E,Fi=function(t){return function(e){return me(e)?e:me(t)?t:E(e.right(t.right))}},Ci=Fi,ki={URI:Ft,map:St,ap:$n},Ei={URI:Ft,map:St,ap:$n,chain:yt},qi=function(t,e){return function(n){return me(n)?P(t(n.left)):E(e(n.right))}},Ai=function(t){return function(e){return me(e)?P(t(e.left)):e}},me=ui,Ct=function(t,e){return function(n){return me(n)?t(n.left):e(n.right)}},Ii=Ct,le=Ct,Bi=le,$e=function(t,e){try{return E(t())}catch(n){return P(e(n))}},$i=Si(gt),Mi=wt(Ei),Mn=Mi,Pi=yt,Ri=yt;function Ti(t){return qn(E,t.of)}function Li(t){return qn(P,t.of)}function Vi(t){return li(t,yi)}function Oi(t){return ci(t,ki)}function ji(t){return function(e,n){return t.chain(e,function(r){return me(r)?t.of(r):n(r.right)})}}function Hi(t){return function(e,n,r){return t.map(e,qi(n,r))}}function Di(t){return function(e,n){return function(r){return t.map(r,le(e,n))}}}var Wi=function(t){return $e(function(){return JSON.parse(t)},ii)},kt=function(t,e){return d(t,Ui(e))},Pn=function(t,e){return d(t,Ni(e))},Ui=function(t){return function(e){return function(){return Promise.resolve().then(e).then(t)}}},Ni=function(t){return function(e){return function(){return Promise.all([Promise.resolve().then(e),Promise.resolve().then(t)]).then(function(n){var r=n[0],i=n[1];return r(i)})}}},Et=function(t){return function(){return Promise.resolve(t)}},Gi=je(2,function(t,e){return function(){return Promise.resolve().then(t).then(function(n){return e(n)()})}}),qt="Task",At={URI:qt,map:kt},Rn={of:Et},zi={URI:qt,map:kt,ap:Pn},Ki={URI:qt,map:kt,of:Et,ap:Pn,chain:Gi},Ji=function(t,e,n,r){function i(o){return o instanceof n?o:new n(function(a){a(o)})}return new(n||(n=Promise))(function(o,a){function c(h){try{p(r.next(h))}catch(f){a(f)}}function l(h){try{p(r.throw(h))}catch(f){a(f)}}function p(h){h.done?o(h.value):i(h.value).then(c,l)}p((r=r.apply(t,e||[])).next())})},Qi=function(t,e){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:c(0),throw:c(1),return:c(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function c(p){return function(h){return l([p,h])}}function l(p){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,p[0]&&(n=0)),n;)try{if(r=1,i&&(o=p[0]&2?i.return:p[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,p[1])).done)return o;switch(i=0,o&&(p=[p[0]&2,o.value]),p[0]){case 0:case 1:o=p;break;case 4:return n.label++,{value:p[1],done:!1};case 5:n.label++,i=p[1],p=[0];continue;case 7:p=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(p[0]===6||p[0]===2)){n=0;continue}if(p[0]===3&&(!o||p[1]>o[0]&&p[1]<o[3])){n.label=p[1];break}if(p[0]===6&&n.label<o[1]){n.label=o[1],o=p;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(p);break}o[2]&&n.ops.pop(),n.trys.pop();continue}p=e.call(t,n)}catch(h){p=[6,h],i=0}finally{r=o=0}if(p[0]&5)throw p[1];return{value:p[0]?p[1]:void 0,done:!0}}},W=Li(Rn),T=Ti(Rn),De=Et,tt=Di(At),Zi=tt,Tn=function(t,e){return function(){return Ji(void 0,void 0,void 0,function(){var n;return Qi(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,t().then(In)];case 1:return[2,r.sent()];case 2:return n=r.sent(),[2,An(e(n))];case 3:return[2]}})})}},Yi=function(t,e){return d(t,I(e))},Xi=function(t,e){return d(t,xi(e))},I=Vi(At),We=je(3,Hi(At)),xi=Oi(zi),It=je(2,ji(Ki)),eo=T,to="TaskEither",no={URI:to,map:Yi,ap:Xi,chain:It},ro=eo(gt),so=wt(no),nt=so,ne=It,pe=It;function te(t){return typeof t=="function"?t():t}class Ue{constructor({onMounted:e,restoreState:n,initialState:r,onUnmounted:i,isPageReload:o}){s(this,"_isMounted",D(!1));s(this,"isMounted",C(this._isMounted));s(this,"mount");s(this,"unmount");this.mount=()=>{if(this.isMounted())return E(void 0);const a=te(o)?n():void 0,c=a?E(a):typeof r=="function"?r():E(r);return d(c,J(l=>{et(()=>{this._isMounted.set(!0),e==null||e(l)})}))},this.unmount=()=>{this._isMounted()&&et(()=>{this._isMounted.set(!1),i==null||i()})}}}function Bt(t){const e={};for(const n in t){const r=t[n];r!==void 0&&(e[n]=r)}return e}function $t(t,e){const n=Object.keys(t),r=Object.keys(e);return n.length!==r.length?!1:n.every(i=>Object.prototype.hasOwnProperty.call(e,i)&&t[i]===e[i])}class ge{constructor({initialState:e,onChange:n}){s(this,"_state");s(this,"state");s(this,"setState",e=>{const n={...this.state(),...Bt(e)};$t(n,this.state())||this._state.set(n)});this._state=D(e,{equals:$t}),this.state=C(this._state),this.state.sub(n)}getter(e){return C(()=>this._state()[e])}hasDiff(e){return!$t({...this.state(),...Bt(e)},this.state())}}let de;function Mt(t){return{lang:(t==null?void 0:t.lang)??(de==null?void 0:de.lang),message:t==null?void 0:t.message,abortEarly:(t==null?void 0:t.abortEarly)??(de==null?void 0:de.abortEarly),abortPipeEarly:(t==null?void 0:t.abortPipeEarly)??(de==null?void 0:de.abortPipeEarly)}}let Pt;function io(t){return Pt==null?void 0:Pt.get(t)}let Rt;function oo(t){return Rt==null?void 0:Rt.get(t)}let Tt;function ao(t,e){var n;return(n=Tt==null?void 0:Tt.get(t))==null?void 0:n.get(e)}function uo(t){var n,r;const e=typeof t;return e==="string"?`"${t}"`:e==="number"||e==="bigint"||e==="boolean"?`${t}`:e==="object"||e==="function"?(t&&((r=(n=Object.getPrototypeOf(t))==null?void 0:n.constructor)==null?void 0:r.name))??"null":e}function Z(t,e,n,r,i){const o=i&&"input"in i?i.input:n.value,a=(i==null?void 0:i.expected)??t.expects??null,c=(i==null?void 0:i.received)??uo(o),l={kind:t.kind,type:t.type,input:o,expected:a,received:c,message:`Invalid ${e}: ${a?`Expected ${a} but r`:"R"}eceived ${c}`,requirement:t.requirement,path:i==null?void 0:i.path,issues:i==null?void 0:i.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},p=t.kind==="schema",h=(i==null?void 0:i.message)??t.message??ao(t.reference,l.lang)??(p?oo(l.lang):null)??r.message??io(l.lang);h!==void 0&&(l.message=typeof h=="function"?h(l):h),p&&(n.typed=!1),n.issues?n.issues.push(l):n.issues=[l]}function Y(t){return{version:1,vendor:"valibot",validate(e){return t["~run"]({value:e},Mt())}}}function Ln(t,e){return Object.hasOwn(t,e)&&e!=="__proto__"&&e!=="prototype"&&e!=="constructor"}function co(t,e){const n=[...new Set(t)];return n.length>1?`(${n.join(` ${e} `)})`:n[0]??"never"}var lo=class extends Error{constructor(t){super(t[0].message),this.name="ValiError",this.issues=t}};function rt(t,e){return{kind:"validation",type:"check",reference:rt,async:!1,expects:null,requirement:t,message:e,"~run"(n,r){return n.typed&&!this.requirement(n.value)&&Z(this,"input",n,r),n}}}function Lt(t){return{kind:"validation",type:"integer",reference:Lt,async:!1,expects:null,requirement:Number.isInteger,message:t,"~run"(e,n){return e.typed&&!this.requirement(e.value)&&Z(this,"integer",e,n),e}}}function he(t){return{kind:"transformation",type:"transform",reference:he,async:!1,operation:t,"~run"(e){return e.value=this.operation(e.value),e}}}function po(t,e,n){return typeof t.fallback=="function"?t.fallback(e,n):t.fallback}function Vt(t,e,n){return typeof t.default=="function"?t.default(e,n):t.default}function Ot(t,e){return!t["~run"]({value:e},{abortEarly:!0}).issues}function Vn(){return{kind:"schema",type:"any",reference:Vn,expects:"any",async:!1,get"~standard"(){return Y(this)},"~run"(t){return t.typed=!0,t}}}function On(t,e){return{kind:"schema",type:"array",reference:On,expects:"Array",async:!1,item:t,message:e,get"~standard"(){return Y(this)},"~run"(n,r){var o;const i=n.value;if(Array.isArray(i)){n.typed=!0,n.value=[];for(let a=0;a<i.length;a++){const c=i[a],l=this.item["~run"]({value:c},r);if(l.issues){const p={type:"array",origin:"value",input:i,key:a,value:c};for(const h of l.issues)h.path?h.path.unshift(p):h.path=[p],(o=n.issues)==null||o.push(h);if(n.issues||(n.issues=l.issues),r.abortEarly){n.typed=!1;break}}l.typed||(n.typed=!1),n.value.push(l.value)}}else Z(this,"type",n,r);return n}}}function Fe(t){return{kind:"schema",type:"boolean",reference:Fe,expects:"boolean",async:!1,message:t,get"~standard"(){return Y(this)},"~run"(e,n){return typeof e.value=="boolean"?e.typed=!0:Z(this,"type",e,n),e}}}function st(t){return{kind:"schema",type:"date",reference:st,expects:"Date",async:!1,message:t,get"~standard"(){return Y(this)},"~run"(e,n){return e.value instanceof Date?isNaN(e.value)?Z(this,"type",e,n,{received:'"Invalid Date"'}):e.typed=!0:Z(this,"type",e,n),e}}}function jt(t){return{kind:"schema",type:"function",reference:jt,expects:"Function",async:!1,message:t,get"~standard"(){return Y(this)},"~run"(e,n){return typeof e.value=="function"?e.typed=!0:Z(this,"type",e,n),e}}}function Ht(t,e){return{kind:"schema",type:"instance",reference:Ht,expects:t.name,async:!1,class:t,message:e,get"~standard"(){return Y(this)},"~run"(n,r){return n.value instanceof this.class?n.typed=!0:Z(this,"type",n,r),n}}}function N(t,e){return{kind:"schema",type:"loose_object",reference:N,expects:"Object",async:!1,entries:t,message:e,get"~standard"(){return Y(this)},"~run"(n,r){var o;const i=n.value;if(i&&typeof i=="object"){n.typed=!0,n.value={};for(const a in this.entries){const c=this.entries[a];if(a in i||(c.type==="exact_optional"||c.type==="optional"||c.type==="nullish")&&c.default!==void 0){const l=a in i?i[a]:Vt(c),p=c["~run"]({value:l},r);if(p.issues){const h={type:"object",origin:"value",input:i,key:a,value:l};for(const f of p.issues)f.path?f.path.unshift(h):f.path=[h],(o=n.issues)==null||o.push(f);if(n.issues||(n.issues=p.issues),r.abortEarly){n.typed=!1;break}}p.typed||(n.typed=!1),n.value[a]=p.value}else if(c.fallback!==void 0)n.value[a]=po(c);else if(c.type!=="exact_optional"&&c.type!=="optional"&&c.type!=="nullish"&&(Z(this,"key",n,r,{input:void 0,expected:`"${a}"`,path:[{type:"object",origin:"key",input:i,key:a,value:i[a]}]}),r.abortEarly))break}if(!n.issues||!r.abortEarly)for(const a in i)Ln(i,a)&&!(a in this.entries)&&(n.value[a]=i[a])}else Z(this,"type",n,r);return n}}}function Me(t,e){return{kind:"schema",type:"nullish",reference:Me,expects:`(${t.expects} | null | undefined)`,async:!1,wrapped:t,default:e,get"~standard"(){return Y(this)},"~run"(n,r){return(n.value===null||n.value===void 0)&&(this.default!==void 0&&(n.value=Vt(this,n,r)),n.value===null||n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function we(t){return{kind:"schema",type:"number",reference:we,expects:"number",async:!1,message:t,get"~standard"(){return Y(this)},"~run"(e,n){return typeof e.value=="number"&&!isNaN(e.value)?e.typed=!0:Z(this,"type",e,n),e}}}function B(t,e){return{kind:"schema",type:"optional",reference:B,expects:`(${t.expects} | undefined)`,async:!1,wrapped:t,default:e,get"~standard"(){return Y(this)},"~run"(n,r){return n.value===void 0&&(this.default!==void 0&&(n.value=Vt(this,n,r)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function Dt(t,e,n){return{kind:"schema",type:"record",reference:Dt,expects:"Object",async:!1,key:t,value:e,message:n,get"~standard"(){return Y(this)},"~run"(r,i){var a,c;const o=r.value;if(o&&typeof o=="object"){r.typed=!0,r.value={};for(const l in o)if(Ln(o,l)){const p=o[l],h=this.key["~run"]({value:l},i);if(h.issues){const g={type:"object",origin:"key",input:o,key:l,value:p};for(const v of h.issues)v.path=[g],(a=r.issues)==null||a.push(v);if(r.issues||(r.issues=h.issues),i.abortEarly){r.typed=!1;break}}const f=this.value["~run"]({value:p},i);if(f.issues){const g={type:"object",origin:"value",input:o,key:l,value:p};for(const v of f.issues)v.path?v.path.unshift(g):v.path=[g],(c=r.issues)==null||c.push(v);if(r.issues||(r.issues=f.issues),i.abortEarly){r.typed=!1;break}}(!h.typed||!f.typed)&&(r.typed=!1),h.typed&&(r.value[h.value]=f.value)}}else Z(this,"type",r,i);return r}}}function S(t){return{kind:"schema",type:"string",reference:S,expects:"string",async:!1,message:t,get"~standard"(){return Y(this)},"~run"(e,n){return typeof e.value=="string"?e.typed=!0:Z(this,"type",e,n),e}}}function jn(t){let e;if(t)for(const n of t)e?e.push(...n.issues):e=n.issues;return e}function it(t,e){return{kind:"schema",type:"union",reference:it,expects:co(t.map(n=>n.expects),"|"),async:!1,options:t,message:e,get"~standard"(){return Y(this)},"~run"(n,r){let i,o,a;for(const c of this.options){const l=c["~run"]({value:n.value},r);if(l.typed)if(l.issues)o?o.push(l):o=[l];else{i=l;break}else a?a.push(l):a=[l]}if(i)return i;if(o){if(o.length===1)return o[0];Z(this,"type",n,r,{issues:jn(o)}),n.typed=!0}else{if((a==null?void 0:a.length)===1)return a[0];Z(this,"type",n,r,{issues:jn(a)})}return n}}}function Wt(){return{kind:"schema",type:"unknown",reference:Wt,expects:"unknown",async:!1,get"~standard"(){return Y(this)},"~run"(t){return t.typed=!0,t}}}function fe(t,e,n){const r=t["~run"]({value:e},Mt(n));if(r.issues)throw new lo(r.issues);return r.value}function ae(...t){return{...t[0],pipe:t,get"~standard"(){return Y(this)},"~run"(e,n){for(const r of t)if(r.kind!=="metadata"){if(e.issues&&(r.kind==="schema"||r.kind==="transformation")){e.typed=!1;break}(!e.issues||!n.abortEarly&&!n.abortPipeEarly)&&(e=r["~run"](e,n))}return e}}}function Ut(t,e,n){const r=t["~run"]({value:e},Mt(n));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}var ho=Object.defineProperty,fo=(t,e,n)=>e in t?ho(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Hn=(t,e,n)=>fo(t,typeof e!="symbol"?e+"":e,n),_o=Object.defineProperty,bo=(t,e,n)=>e in t?_o(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Nt=(t,e,n)=>bo(t,typeof e!="symbol"?e+"":e,n);function Dn(t){return e=>e instanceof t}function Wn(t,e){const n=class extends Error{constructor(...i){const o=typeof e=="function"?e(...i):typeof e=="string"?[e]:e||[];super(...o),this.name=t}};Nt(n,"is",Dn(n));let r=n;return Object.defineProperty(r,"name",{value:t}),r}function mo(t,e,n){const r=class extends Wn(t,n){constructor(...o){super(...o),Nt(this,"data"),this.data=e(...o)}};Nt(r,"is",Dn(r));let i=r;return Object.defineProperty(i,"name",{value:t}),i}let Un=class extends Wn("CancelledError","Promise was canceled"){},Gt=class extends mo("TimeoutError",e=>({timeout:e}),(e,n)=>[`Timeout reached: ${e}ms`,{cause:n}]){};const go=Symbol("resolved");function wo(t){return{tag:go,value:t}}function Nn(t,e){return t.reject=e.reject,t.resolve=e.resolve,t}let Ne=class En extends Promise{constructor(e,n){let r,i,o,a;typeof e=="function"?(o=e,a=n||{}):a=e||{};let c,l;const p=()=>!!l,h=()=>!!c;let f={};const g=[],v=()=>{g.forEach(w=>w()),g.splice(0,g.length),f={}},F=new AbortController,k=()=>h()||p();super((w,y)=>{const{abortOnResolve:m=!0,abortOnReject:j=!0}=a;i=A=>{var O,L;k()||(w(A),c=[A],(O=f.resolved)==null||O.forEach(G=>G(A)),(L=f.finalized)==null||L.forEach(G=>G({kind:"resolved",result:A})),v(),m&&F.abort(wo(A)))},r=A=>{var O,L;k()||(y(A),l=[A],(O=f.rejected)==null||O.forEach(G=>G(A)),(L=f.finalized)==null||L.forEach(G=>G({kind:"rejected",reason:A})),v(),j&&F.abort(A))};const{abortSignal:H}=a;if(H){if(H.aborted)return r(H.reason);const A=()=>{r(H.reason)};H.addEventListener("abort",A,!0),g.push(()=>{H.removeEventListener("abort",A,!0)})}const{timeout:U}=a;if(U){const A=setTimeout(()=>{r(new Gt(U))},U);g.push(()=>{clearTimeout(A)})}try{const A=()=>{},O=o&&o(i,r,{abortSignal:F.signal,get isRejected(){return p()},get isResolved(){return h()},on(L,G){if(c||l){if(L==="finalized"){const Ve=c?{kind:"resolved",result:c[0]}:{kind:"rejected",reason:l[0]};G(Ve)}else L==="resolved"&&c?G(c[0]):L==="rejected"&&l&&G(l[0]);return A}return f[L]||(f[L]=[]),f[L].push(G),()=>{const Ve=f[L]||[],xe=Ve.indexOf(G);xe>=0&&Ve.splice(xe,1)}},get result(){return c==null?void 0:c[0]},get rejectReason(){return l==null?void 0:l[0]},throwIfRejected(){if(l)throw l[0]}});O instanceof Promise&&O.catch(r)}catch(A){r(A)}}),Hn(this,"reject"),Hn(this,"resolve"),this.reject=r,this.resolve=i}static fn(e,n){return new En(async(r,i,o)=>{try{r(await e(o))}catch(a){i(a)}},n)}static resolve(e){return this.fn(()=>e)}static reject(e){return new En((n,r)=>{r(e)})}cancel(){this.reject(new Un)}catch(e){return this.then(void 0,e)}finally(e){return Nn(super.finally(e),this)}then(e,n){return Nn(super.then(e,n),this)}};function Gn(t){return t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function vo(t){return t.replace(/_[a-z]/g,e=>e[1].toUpperCase())}function yo(t){return Object.entries(t).reduce((e,[n,r])=>(e[vo(n)]=r,e),{})}function zt(t){const e=yo(t);for(const n in e){const r=e[n];r&&typeof r=="object"&&!(r instanceof Date)&&(e[n]=Array.isArray(r)?r.map(zt):zt(r))}return e}function So(t){return t.replace(/_([a-z])/g,(e,n)=>`-${n.toLowerCase()}`)}function zn(t){return`tapps/${t}`}function ot(t,e){sessionStorage.setItem(zn(t),JSON.stringify(e))}function Kn(t){const e=sessionStorage.getItem(zn(t));try{return e?JSON.parse(e):void 0}catch{}}function Ge(...t){const e=t.flat(1);return[e.push.bind(e),()=>{e.forEach(n=>{n()})}]}function Jn(t,e){e||(e={});const{textColor:n,bgColor:r,shouldLog:i}=e,o=i===void 0?!0:i,a=typeof o=="boolean"?()=>o:o,c=(l,p,...h)=>{if(p||a()){const f="font-weight:bold;padding:0 5px;border-radius:100px",[g,v,F]={log:["#0089c3","white","INFO"],error:["#ff0000F0","white","ERR"],warn:["#D38E15","white","WARN"]}[l];console[l](`%c${F} ${Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3,timeZone:"UTC"}).format(new Date)}%c %c${t}`,`${f};background-color:${g};color:${v}`,"",`${f};${n?`color:${n};`:""}${r?`background-color:${r}`:""}`,...h)}};return[["log","forceLog"],["warn","forceWarn"],["error","forceError"]].reduce((l,[p,h])=>(l[p]=c.bind(void 0,p,!1),l[h]=c.bind(void 0,p,!0),l),{})}function ze(t){const e=n=>{throw n};return typeof t=="function"?Ne.resolve(d(t,tt(e,n=>n))()):d(t,le(e,n=>n))}function re(t){return Object.assign((...e)=>ze(t(...e)),t)}const Pe=Object.assign((t,e)=>d(Tn(()=>new Ne((n,r,i)=>t(o=>n(E(o)),o=>n(P(o)),i),e),n=>n),pe(le(W,T))),{fn:(t,e)=>Pe((n,r,i)=>{const o=t(i);d(typeof o=="function"?o:De(o),Zi(r,n))()},e)});var Fo=Object.defineProperty,Co=(t,e,n)=>e in t?Fo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Kt=(t,e,n)=>Co(t,typeof e!="symbol"?e+"":e,n);function Qn(t){return e=>e instanceof t}function K(t,e){const n=class extends Error{constructor(...o){const a=typeof e=="function"?e(...o):typeof e=="string"?[e]:e||[];super(...a),this.name=t}};Kt(n,"is",Qn(n));let r=n;return Object.defineProperty(r,"name",{value:t}),r}function at(t,e,n){const r=class extends K(t,n){constructor(...a){super(...a),Kt(this,"data"),this.data=e(...a)}};Kt(r,"is",Qn(r));let i=r;return Object.defineProperty(i,"name",{value:t}),i}function ko(t){const e=n=>{const r={};return new URLSearchParams(n).forEach((i,o)=>{const a=r[o];Array.isArray(a)?a.push(i):a===void 0?r[o]=i:r[o]=[a,i]}),fe(t,r)};return ae(it([S(),Ht(URLSearchParams)]),rt(n=>{try{return e(n),!0}catch{return!1}},"The value doesn't match required schema"),he(e))}function Eo(t){return ae(S(),rt(e=>{try{return JSON.parse(e),!0}catch{return!1}},"Input is not a valid JSON value"),he(JSON.parse),t)}function ue(t){return ae(S(),Eo(t))}function Jt(t){return ae(it([S(),Ht(URLSearchParams)]),ko(t))}function ut(t){return e=>t.test(e)}const Zn=ut(/^#[\da-f]{3}$/i),Yn=ut(/^#[\da-f]{4}$/i),Ke=ut(/^#[\da-f]{6}$/i),Xn=ut(/^#[\da-f]{8}$/i);function xn(t){return[Ke,Xn,Zn,Yn].some(e=>e(t))}function er(t){let e="#";for(let n=0;n<t.length-1;n+=1)e+=t[1+n].repeat(2);return e}function ct(t){const e=t.replace(/\s/g,"").toLowerCase();if(/^#[\da-f]{3}$/i.test(e))return E(er(e.toLowerCase()+"f"));if(/^#[\da-f]{4}$/i.test(e))return E(er(e.toLowerCase()));if(/^#[\da-f]{6}$/i.test(e))return E(e.toLowerCase()+"ff");if(/^#[\da-f]{8}$/i.test(e))return E(e.toLowerCase());const n=e.match(/^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/)||e.match(/^rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),(\d{1,3})\)$/);return n?E(n.slice(1).reduce((r,i)=>r+parseInt(i,10).toString(16).padStart(2,"0"),"#").padEnd(9,"f")):P(new Error(`Value "${t}" does not satisfy any of known RGB formats.`))}function tr(t){return d(ct(t),J(e=>e.slice(0,7)))}const qo=re(tr),Ao=re(ct);function Io(){return N({id:we(),photo_url:B(S()),type:S(),title:S(),username:B(S())})}function nr(){return N({added_to_attachment_menu:B(Fe()),allows_write_to_pm:B(Fe()),first_name:S(),id:we(),is_bot:B(Fe()),is_premium:B(Fe()),last_name:B(S()),language_code:B(S()),photo_url:B(S()),username:B(S())})}function Bo(){return N({projectCode:S(),uid:S(),sessionId:S(),rootToken:S()})}function $o(){return N({auth_date:ae(S(),he(t=>new Date(Number(t)*1e3)),st()),can_send_after:B(ae(S(),he(Number),Lt())),chat:B(ue(Io())),chat_type:B(S()),chat_instance:B(S()),hash:B(S()),query_id:B(S()),receiver:B(ue(nr())),start_param:B(S()),signature:B(S()),user:B(ue(nr())),auth:B(ue(Bo()))})}function rr(){return Jt($o())}function Qt(){return Dt(S(),ae(it([S(),we()]),he(t=>typeof t=="number"?`#${(t&16777215).toString(16).padStart(6,"0")}`:t),rt(xn)))}function Mo(){const t=B(ae(S(),he(e=>e==="1")));return N({vbWebAppBotInline:t,vbWebAppData:B(rr()),vbWebAppDefaultColors:B(ue(Qt())),vbWebAppFullscreen:t,vbWebAppPlatform:S(),vbWebAppShowSettings:t,vbWebAppStartParam:B(S()),vbWebAppThemeParams:ue(Qt()),vbWebAppVersion:S()})}function Po(){return Jt(Mo())}function Zt(){return N({eventType:S(),eventData:B(Wt())})}function sr(t){return $e(()=>fe(rr(),t),e=>e)}function lt(t){return $e(()=>fe(Po(),t),e=>e)}const Ro=re(sr),Yt=re(lt);function ir(t,e){return e||(e=(n,r)=>JSON.stringify(r)),new URLSearchParams(Object.entries(t).reduce((n,[r,i])=>(Array.isArray(i)?n.push(...i.map(o=>[r,String(o)])):i!=null&&n.push([r,i instanceof Date?(i.getTime()/1e3|0).toString():typeof i=="string"||typeof i=="number"?String(i):typeof i=="boolean"?i?"1":"0":e(r,i)]),n),[])).toString()}function or(t){return ir(t)}function Xt(t){return ir(t,(e,n)=>e==="vbWebAppData"?or(n):JSON.stringify(n))}function To(t){return{all:t=t||new Map,on:function(e,n){var r=t.get(e);r?r.push(n):t.set(e,[n])},off:function(e,n){var r=t.get(e);r&&(n?r.splice(r.indexOf(n)>>>0,1):t.set(e,[]))},emit:function(e,n){var r=t.get(e);r&&r.slice().map(function(i){i(n)}),(r=t.get("*"))&&r.slice().map(function(i){i(e,n)})}}}function ar(t){return Ot(N({VBotWebviewProxy:N({postEvent:jt()})}),t)}function xt(){try{return window.self!==window.top}catch{return!0}}class ur extends K("MethodUnsupportedError",(e,n)=>[`Method "${e}" is unsupported in Mini Apps version ${n}`]){}class cr extends K("MethodParameterUnsupportedError",(e,n,r)=>[`Parameter "${n}" of "${e}" method is unsupported in Mini Apps version ${r}`]){}class lr extends at("LaunchParamsRetrieveError",e=>({errors:e}),e=>[["Unable to retrieve launch parameters from any known source. You should pass correct parameters to Mini App","","Collected errors:",...e.map(({source:n,error:r})=>`Source: ${n} / ${r instanceof Error?r.message:String(r)}`)].join(`
2
+ `)]){}class en extends K("InvalidLaunchParamsError",(e,n)=>[`Invalid value for launch params: ${e}`,{cause:n}]){}class tn extends K("UnknownEnvError"){}class pr extends K("InvokeCustomMethodError",e=>[`Server returned error: ${e}`]){}const dr="launchParams";function hr(t){return t.replace(/^[^?#]*[?#]/,"").replace(/[?#]/g,"&")}function Re(){return d(Je(),Pi(lt))}const Lo=re(Re);function nn(){return d(Je(),J(t=>{const e=new URLSearchParams(t).get("vbWebAppData");return e?Be(e):Se}))}function Vo(){return d(nn(),Bi(t=>{throw t},t=>t),vt(()=>{},t=>t))}function Je(){const t=[];for(const[e,n]of[[()=>hr(window.location.href),"window.location.href"],[()=>{const r=performance.getEntriesByType("navigation")[0];return r&&hr(r.name)},"performance navigation entries"],[()=>Kn(dr),"local storage"]]){const r=e();if(!r){t.push({source:n,error:new Error("Source is empty")});continue}const i=d(lt(r),Ii(o=>o,()=>!0));if(typeof i!="boolean"){t.push({source:n,error:i});continue}return ot(dr,r),E(r)}return P(new lr(t))}const Oo=re(Je);function fr(t,e){const n=new Map,r=To(),i=(o,a,c=!1)=>{const l=n.get(o)||new Map;n.set(o,l);const p=l.get(a)||[];l.set(a,p);const h=p.findIndex(f=>f[1]===c);if(h>=0&&(r.off(o,p[h][0]),p.splice(h,1),!p.length&&(l.delete(a),!l.size))){const f=n.size;n.delete(o),f&&!n.size&&e()}};return{on(o,a,c){!n.size&&t();const l=()=>{i(o,a,c)},p=(...g)=>{c&&l(),o==="*"?a({name:g[0],payload:g[1]}):a(...g)};r.on(o,p);const h=n.get(o)||new Map;n.set(o,h);const f=h.get(a)||[];return h.set(a,f),f.push([p,c||!1]),l},off:i,emit:r.emit,clear(){const o=n.size;r.all.clear(),n.clear(),o&&e()}}}function pt(t,e){window.dispatchEvent(new MessageEvent("message",{data:JSON.stringify({eventType:t,eventData:e}),source:window.parent}))}const rn=D(!1),_r=D("https://web.telegram.org"),jo=t=>{ce().log("Event received:",t)},br=C(rn);function Ho(t){t!==rn()&&(rn.set(t),(t?X:ke)("*",jo))}const mr=C(_r);function Do(t){_r.set(t),ce().log("New target origin set",t)}const Ce=D((...t)=>{window.parent.postMessage(...t)}),ce=D(Jn("Bridge",{bgColor:"#9147ff",textColor:"white",shouldLog:br}));function sn(t,e,n){const r=[n],i=t[e];typeof i=="function"&&r.push(i);const o=(...c)=>{r.forEach(l=>l(...c))},a=Object.assign((...c)=>{o(...c)},{unwrap(){const{length:c}=r;if(c===1){delete t[e];return}if(c===2){vr(t,e,r[1]);return}r.unshift(1),vr(t,e,o)}});wr(t,e,()=>a,c=>r.push(c))}function gr(t,e){const n=t[e];wr(t,e,()=>n,r=>{Object.entries(r).forEach(([i,o])=>{n[i]=o})})}function wr(t,e,n,r){Object.defineProperty(t,e,{enumerable:!0,configurable:!0,get:n,set:r})}function vr(t,e,n){Object.defineProperty(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n})}const Wo={clipboard_text_received:N({req_id:S(),data:Me(S())}),custom_method_invoked:N({req_id:S(),result:B(Wt()),error:B(S())}),popup_closed:Me(N({button_id:Me(S(),()=>{})}),{}),viewport_changed:Me(N({height:we(),width:Me(we(),()=>window.innerWidth),is_state_stable:Fe(),is_expanded:Fe()}),()=>({height:window.innerHeight,is_state_stable:!0,is_expanded:!0})),theme_changed:N({theme_params:Qt()})};function yr(t){if(t.source!==window.parent)return;let e;try{e=fe(ue(Zt()),t.data)}catch{return}const{eventType:n,eventData:r}=e,i=Wo[n];let o;try{o=i?fe(i,r):r}catch(a){return ce().forceError([`An error occurred processing the "${n}" event from the VBot application.`,"Please, file an issue here:","https://github.com/Telegram-Mini-Apps/tma.js/issues/new/choose"].join(`
3
+ `),e,a)}Uo(n,o)}const{on:X,off:ke,emit:Uo,clear:No}=fr(()=>{const t=window;!t.TelegramGameProxy&&(t.TelegramGameProxy={}),sn(t.TelegramGameProxy,"receiveEvent",pt),gr(t,"TelegramGameProxy"),!t.VBot&&(t.VBot={}),!t.VBot.WebView&&(t.VBot.WebView={}),sn(t.VBot.WebView,"receiveEvent",pt),gr(t.VBot,"WebView"),sn(t,"TelegramGameProxy_receiveEvent",pt),window.addEventListener("message",yr)},()=>{[["TelegramGameProxy_receiveEvent"],["TelegramGameProxy","receiveEvent"],["VBot","WebView","receiveEvent"]].forEach(t=>{const e=window;let n=[void 0,e];for(const o of t)if(n=[n[1],n[1][o]],!n[1])return;const[r,i]=n;"unwrap"in i&&(i.unwrap(),r&&r!==e&&!Object.keys(r).length&&delete e[t[0]])}),window.removeEventListener("message",yr)}),Go=(...t)=>Ce()(...t);function zo(t,e){d(Te(t,e),Ai(n=>{throw n}))}function Te(t,e){ce().log("Posting event:",e?{eventType:t,eventData:e}:{eventType:t});const n=window,r=JSON.stringify({eventType:t,eventData:e});return xt()?(Go(r,mr()),E(void 0)):ar(n)?(n.VBotWebviewProxy.postEvent(t,JSON.stringify(e)),E(void 0)):Ot(N({external:N({notify:jt()})}),n)?(n.external.notify(r),E(void 0)):P(new tn)}function dt(t,e,n={}){const{capture:r=()=>!0,postEvent:i=Te}=n,o=D(),[a,c]=Ge();(Array.isArray(e)?e:[e]).forEach(p=>{a(X(p,h=>{const f=Array.isArray(e);r(f?{event:p,payload:h}:h)&&o.set([f?{event:p,payload:h}:h])}))});const l=p=>(c(),p);return d(async()=>i(t,n.params),pe(()=>Pe((p,h,f)=>{const g=o();if(g)return p(g[0]);const v=k=>{k&&p(k[0])},F=()=>{o.unsub(v)};o.sub(v),f.on("finalized",F)},n)),We(l,l))}function Ko(t,e){const n=on(t,e);return typeof n=="function"?Ne.fn(()=>ze(n)):n}function on(t,e){const n=ar(window);if(!t)return n||d(Je(),le(()=>!1,()=>!0));if(n)return T(!0);const{timeout:r=100}=e||{};return d(dt("web_app_request_theme","theme_changed",{...e,timeout:r}),tt(i=>Gt.is(i)||tn.is(i)?E(!1):P(i),()=>E(!0)))}function Jo({launchParams:t,onEvent:e,resetPostMessage:n}={}){if(t){const o=typeof t=="string"||t instanceof URLSearchParams?t.toString():Xt({...t,vbWebAppData:void 0})+(t.vbWebAppData?`&vbWebAppData=${encodeURIComponent(t.vbWebAppData.toString())}`:"");try{Yt(o)}catch(a){throw new en(o,a)}ot("launchParams",o)}if(xt()){if(!e)return;n&&Ce.reset();const o=Ce();Ce.set((...a)=>{const[c]=a,l=()=>{o(...a)};try{const p=fe(ue(Zt()),c);e({name:p.eventType,params:p.eventData},l)}catch{l()}});return}const r=window.VBotWebviewProxy||{},i=r.postEvent||(()=>{});window.VBotWebviewProxy={...r,postEvent(o,a){const c=()=>{i(o,a)};e?e({name:o,params:a?JSON.parse(a):void 0},c):c()}},ce().log("Environment was mocked by the mockVBotEnv function")}function Qo({launchParams:t,onEvent:e,resetPostMessage:n}={}){if(t){const o=typeof t=="string"||t instanceof URLSearchParams?t.toString():Xt({...t,vbWebAppData:void 0})+(t.vbWebAppData?`&vbWebAppData=${encodeURIComponent(t.vbWebAppData.toString())}`:"");try{Yt(o)}catch(a){throw new en(o,a)}ot("launchParams",o)}if(xt()){if(!e)return;n&&Ce.reset();const o=Ce();Ce.set((...a)=>{const[c]=a,l=()=>{o(...a)};try{const p=fe(ue(Zt()),c);e({name:p.eventType,params:p.eventData},l)}catch{l()}});return}const r=window.VBotWebviewProxy||{},i=r.postEvent||(()=>{});window.VBotWebviewProxy={...r,postEvent(o,a){const c=()=>{i(o,a)};e?e({name:o,params:a?JSON.parse(a):void 0},c):c()}},ce().log("Launch params are injected by the setLaunchParams function")}function Zo(t,e="*"){const n=o=>{if(o.source===t.contentWindow)try{const a=JSON.parse(o.data),{eventType:c,eventData:l}=a;r.emit(c,l)}catch{}},r=fr(()=>{window.addEventListener("message",n)},()=>{window.removeEventListener("message",n)}),i={...r,send:(o,a)=>{if(t.contentWindow){const c=JSON.stringify({eventType:o,eventData:a});t.contentWindow.postMessage(c,e)}},clear:()=>{r.clear(),Qe===i&&(Qe=void 0)}};return Qe=i,i}let Qe;function _(){if(!Qe)throw new Error("HostBridge not initialized. Call defineHostBridge() or defineWebComponentBridge() first.");return Qe}function Sr(t){return({req_id:e})=>e===t}const Fr={"6.0":["iframe_ready","iframe_will_reload","web_app_close","web_app_data_send","web_app_expand","web_app_open_link","web_app_ready","web_app_request_theme","web_app_request_viewport","web_app_setup_main_button","web_app_setup_closing_behavior"],6.1:["web_app_open_tg_link","web_app_open_invoice","web_app_setup_back_button","web_app_set_background_color","web_app_set_header_color","web_app_trigger_haptic_feedback"],6.2:["web_app_open_popup"],6.4:["web_app_close_scan_qr_popup","web_app_open_scan_qr_popup","web_app_read_text_from_clipboard",{method:"web_app_open_link",param:"try_instant_view"}],6.7:["web_app_switch_inline_query"],6.9:["web_app_invoke_custom_method","web_app_request_write_access","web_app_request_phone",{method:"web_app_set_header_color",param:"color"}],"6.10":["web_app_setup_settings_button"],7.2:["web_app_biometry_get_info","web_app_biometry_open_settings","web_app_biometry_request_access","web_app_biometry_request_auth","web_app_biometry_update_token"],7.6:[{method:"web_app_open_link",param:"try_browser"},{method:"web_app_close",param:"return_back"}],7.7:["web_app_setup_swipe_behavior"],7.8:["web_app_share_to_story"],"7.10":["web_app_setup_secondary_button","web_app_set_bottom_bar_color",{method:"web_app_setup_main_button",param:"has_shine_effect"}],"8.0":["web_app_request_safe_area","web_app_request_content_safe_area","web_app_request_fullscreen","web_app_exit_fullscreen","web_app_set_emoji_status","web_app_add_to_home_screen","web_app_check_home_screen","web_app_request_emoji_status_access","web_app_check_location","web_app_open_location_settings","web_app_request_file_download","web_app_request_location","web_app_send_prepared_message","web_app_start_accelerometer","web_app_start_device_orientation","web_app_start_gyroscope","web_app_stop_accelerometer","web_app_stop_device_orientation","web_app_stop_gyroscope","web_app_toggle_orientation_lock"],"9.0":["web_app_device_storage_clear","web_app_device_storage_get_key","web_app_device_storage_save_key","web_app_secure_storage_clear","web_app_secure_storage_get_key","web_app_secure_storage_restore_key","web_app_secure_storage_save_key"],9.1:["web_app_hide_keyboard"],9.2:["web_app_send_notification","web_app_finish_refresh"]};function an(t,e){return Object.keys(Fr).find(n=>Fr[n].some(r=>e?typeof r=="object"&&r.method===t&&r.param===e:r===t))||null}function Cr(t){return t.split(".").map(Number)}function Yo(t,e){const n=Cr(t),r=Cr(e),i=Math.max(n.length,r.length);for(let o=0;o<i;o+=1){const a=n[o]||0,c=r[o]||0;if(a!==c)return a>c?1:-1}return 0}function _e(t,e,n){const r=n?an(t,e):an(t);return r?Yo(r,n||e)<=0:!1}function Xo(t,e="strict"){const n=typeof e=="function"?e:r=>{const{method:i,version:o}=r,a="param"in r?new cr(i,r.param,o):new ur(i,o);if(e==="strict")throw a;return ce().forceWarn(a.message)};return((r,i)=>_e(r,t)?r==="web_app_set_header_color"&&Ot(N({color:Vn()}),i)&&!_e(r,"color",t)?n({version:t,method:r,param:"color"}):zo(r,i):n({version:t,method:r}))}function xo(t,e,n,r){return d(dt("web_app_invoke_custom_method","custom_method_invoked",{...r||{},params:{method:t,params:e,req_id:n},capture:Sr(n)}),ne(({result:i,error:o})=>o?W(new pr(o)):T(i)))}function ea(t,e,n={}){const{capture:r=()=>!0,postEvent:i=Te}=n,o=D(),[a,c]=Ge();(Array.isArray(e)?e:[e]).forEach(p=>{a(X(p,h=>{(Array.isArray(e)?r({event:p,payload:h}):r(h))&&o.set([h])}))});const l=p=>(c(),p);return d(async()=>i(t,n.params),pe(()=>Pe((p,h,f)=>{const g=o();if(g)return p(g[0]);const v=k=>{k&&p(k[0])},F=()=>{o.unsub(v)};o.sub(v),f.on("finalized",F)},n)),We(l,l))}function ta(){Object.hasOwn||(Object.hasOwn=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)})}function un(t){return $e(()=>decodeURIComponent(atob(t.replace(/-/g,"+").replace(/_/g,"/")).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join("")),e=>e)}const na=re(un);function cn(t){return btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,(e,n)=>String.fromCharCode(parseInt(`0x${n}`)))).replace(/\+/g,"-").replace(/\//g,"_")}function kr(t){const e=cn(typeof t=="string"?t:JSON.stringify(t));return e.length>512?P(new Error("Value is too long for start parameter")):E(e)}const ra=re(kr);function sa(t,e){return ze(Er(t,typeof e=="function"?n=>$e(()=>e(n),r=>r):e))}function Er(t,e){return d(un(t),Ri(n=>e?typeof e=="function"?e(n):Wi(n):E(n)))}function ia(t){return cn(t).length<=512}function se(t,e){return C(()=>_e(t,te(e)))}function b(t){return Object.assign(re(t),{ifAvailable(...e){return d(t.ifAvailable(...e),vt(()=>({ok:!1}),n=>({ok:!0,data:ze(n)})))}})}function Ee(t){return[t]}class Ze extends at("ValidationError",(e,n)=>({input:e,issues:n}),"Validation error"){}class ht extends K("CSSVarsBoundError","CSS variables are already bound"){}class qr extends at("DeviceStorageMethodError",e=>({error:e}),e=>[e]){}class Ar extends at("SecureStorageMethodError",e=>({error:e}),e=>[e]){}class Ir extends K("NotAvailableError",Ee){}class oa extends K("InvalidEnvError",Ee){}class Br extends K("FunctionNotAvailableError",Ee){}class ie extends K("InvalidArgumentsError",(e,n)=>[e,{cause:n}]){}class ft extends K("ConcurrentCallError",Ee){}class $r extends K("SetEmojiStatusError",e=>[`Failed to set emoji status: ${e}`]){}class ln extends K("AccessDeniedError",Ee){}class Mr extends K("FullscreenFailedError",Ee){}class Pr extends K("ShareMessageError",Ee){}class Rr extends K("UnknownThemeParamsKeyError",e=>[`Unknown theme params key passed: ${e}`]){}function V(t,e){const n=C(()=>te(e.version)||"100"),r=C(()=>te(e.isVBma)),{requires:i,returns:o}=e,a=i?typeof i=="object"?i:{every:[i]}:void 0,c=w=>{if(!e.supports)return!0;const y=e.supports[w];return _e(y.method,y.param,n())},l=()=>{if(!a)return;const[w,y]="every"in a?["every",a.every]:["some",a.some];for(let m=0;m<y.length;m++){const j=y[m],H=typeof j=="function"?j():_e(j,n())?void 0:`it is unsupported in Mini Apps version ${n()}`;if(H&&(w==="every"||m===y.length-1))return H}},p=(...w)=>{for(const y in e.supports)if(e.supports[y].shouldCheck(...w)&&!c(y))return`option ${y} is not supported in Mini Apps version ${n()}`},h=C(()=>!l()),f=C(()=>n()!=="0.0"),g=C(()=>e.isMounted?e.isMounted():!0),v=C(()=>r()&&f()&&h()&&g()),F=w=>{const y=new Br(w);return["task","promise"].includes(e.returns)?W(y):P(y)},k=(...w)=>o==="plain"?$e(()=>t(...w),y=>y):o==="promise"?Tn(()=>t(...w),y=>y):t(...w);return Object.assign((...w)=>{var H;const y="Unable to call function:";if(!r())return F(`${y} it can't be called outside Mini Apps`);if(!f())return F(`${y} the SDK was not initialized. Use the SDK init() function`);const m=l();if(m)return F(`${y} ${m}`);const j=p(...w);if(j)return F(`${y} ${j}`);if(!g()){const U=(H=e.isMounting)!=null&&H.call(e)?"mounting. Wait for the mount completion":"unmounted. Use the mount() method";return F(`${y} the component is ${U}`)}return k(...w)},t,{isAvailable:v,ifAvailable(...w){return v()?Be(k(...w)):Se}},a?{isSupported:h}:{},e.supports?{supports:c}:{})}function M(t){return e=>V(e,t)}class _t{constructor({isVBma:e,storage:n,onClick:r,offClick:i,initialState:o,isPageReload:a,postEvent:c,payload:l,method:p,version:h}){s(this,"isMounted");s(this,"isSupported");s(this,"state");s(this,"stateSetters");s(this,"stateBoolSetters");s(this,"setStateFp");s(this,"setState");s(this,"onClickFp");s(this,"onClick");s(this,"offClickFp");s(this,"offClick");s(this,"mountFp");s(this,"mount");s(this,"unmount");const f=new ge({initialState:o,onChange(w){n.set(w)}}),g=new Ue({initialState:o,isPageReload:a,onMounted:f.setState,restoreState:n.get}),v={version:h,requires:p,isVBma:e},F=M({...v,returns:"plain"}),k=M({...v,returns:"either",isMounted:g.isMounted});this.isMounted=g.isMounted,this.isSupported=se(p,h),this.state=f.state,this.setStateFp=k(w=>{const y={...this.state(),...Bt(w)};return f.hasDiff(y)?d(c(p,l(y)),J(()=>{f.setState(y)})):E(void 0)}),this.setState=b(this.setStateFp),this.onClickFp=F(r),this.onClick=b(this.onClickFp),this.offClickFp=F(i),this.offClick=b(this.offClickFp),this.mountFp=F(()=>{const w=()=>{};return d(g.mount(),le(w,w))}),this.mount=b(this.mountFp),this.unmount=g.unmount,this.stateSetters=w=>{const y=k(m=>this.setStateFp({[w]:m}));return[b(y),y]},this.stateBoolSetters=w=>{const[,y]=this.stateSetters(w),m=k(()=>y(!1)),j=k(()=>y(!0));return[[b(m),m],[b(j),j]]}}stateGetter(e){return C(()=>this.state()[e])}}class Tr{constructor(e){s(this,"isVisible");s(this,"isMounted");s(this,"isSupported");s(this,"hideFp");s(this,"hide");s(this,"showFp");s(this,"show");s(this,"onClickFp");s(this,"onClick");s(this,"offClickFp");s(this,"offClick");s(this,"mountFp");s(this,"mount");s(this,"unmount");const n=new _t({...e,method:"web_app_setup_back_button",payload:r=>({is_visible:r.isVisible}),initialState:{isVisible:!1}});this.isVisible=n.stateGetter("isVisible"),this.isMounted=n.isMounted,this.isSupported=n.isSupported,[[this.hide,this.hideFp],[this.show,this.showFp]]=n.stateBoolSetters("isVisible"),this.onClick=n.onClick,this.onClickFp=n.onClickFp,this.offClick=n.offClick,this.offClickFp=n.offClickFp,this.mount=n.mount,this.mountFp=n.mountFp,this.unmount=n.unmount}}function q(){return{isVBma:C(()=>on())}}function Le(t){return e=>({...e,...te(t)})}function Ye(t,e){return D(t,e)}const Lr=Ye(Te),qe=(...t)=>Lr()(...t),Vr=(...t)=>ze(qe(...t)),Q=Le({postEvent:qe});function aa(t){return{get:()=>Kn(t),set(e){ot(t,e)}}}function ua(){return performance.getEntriesByType("navigation")[0]}function ca(){const t=ua();return!!t&&t.type==="reload"}function ve(t){return Le({storage:aa(t),isPageReload:ca})}const pn=Ye("0.0"),$=Le({version:pn});function dn(t,e){return{...d(q(),Q,$,ve(t)),onClick(n,r){return X(e,n,r)},offClick(n,r){ke(e,n,r)}}}const la=new Tr(dn("backButton","back_button_pressed"));class hn{constructor({initialState:e,onMounted:n,restoreState:r,onUnmounted:i,isPageReload:o}){s(this,"_isMounted",D(!1));s(this,"isMounted",C(this._isMounted));s(this,"mount");s(this,"unmount");this.mount=a=>{if(this._isMounted())return T(void 0);const c=te(o)?r():void 0;return d(c?T(c):e(a),I(l=>{this._isMounted()||et(()=>{this._isMounted.set(!0),n==null||n(l)})}))},this.unmount=()=>{this._isMounted()&&et(()=>{this._isMounted.set(!1),i==null||i()})}}}function Or(){return new Ir("Biometry is not available")}function fn(t){let e=!1,n=!1,r="",i=!1,o="",a=!1;return t.available&&(e=!0,n=t.token_saved,r=t.device_id,i=t.access_requested,o=t.type,a=t.access_granted),{available:e,tokenSaved:n,deviceId:r,type:o,accessGranted:a,accessRequested:i}}class jr{constructor({version:e,request:n,postEvent:r,storage:i,onInfoReceived:o,offInfoReceived:a,isVBma:c,isPageReload:l}){s(this,"isAvailable");s(this,"isSupported");s(this,"isMounted");s(this,"state");s(this,"authenticateFp");s(this,"authenticate");s(this,"openSettingsFp");s(this,"openSettings");s(this,"requestAccessFp");s(this,"requestAccess");s(this,"updateTokenFp");s(this,"updateToken");s(this,"mountFp");s(this,"mount");s(this,"unmount");const p=w=>{h.setState(fn(w))},h=new ge({initialState:{available:!1,type:"unknown",accessGranted:!1,accessRequested:!1,deviceId:"",tokenSaved:!1},onChange:i.set}),f=new hn({initialState(w){return d(n("web_app_biometry_get_info","biometry_info_received",w),I(fn))},isPageReload:l,onMounted(w){h.setState(w),o(p)},onUnmounted(){a(p)},restoreState:i.get}),g={version:e,requires:"web_app_biometry_request_auth",isVBma:c},v=M({...g,returns:"either"}),F=M({...g,returns:"task"}),k=M({...g,isMounted:f.isMounted,returns:"task"});this.isAvailable=h.getter("available"),this.isMounted=f.isMounted,this.isSupported=se("web_app_biometry_request_auth",e),this.state=h.state,this.unmount=f.unmount,this.mountFp=F(f.mount),this.authenticateFp=k(w=>this.isAvailable()?d(n("web_app_biometry_request_auth","biometry_auth_requested",{...w,params:{reason:((w||{}).reason||"").trim()}}),I(y=>(h.setState({token:y.token}),y))):W(Or())),this.openSettingsFp=v(()=>r("web_app_biometry_open_settings")),this.requestAccessFp=k(w=>d(n("web_app_biometry_request_access","biometry_info_received",{...w,params:{reason:((w||{}).reason||"").trim()}}),ne(y=>{const m=fn(y);return m.available?(h.setState(m),T(m.accessRequested)):W(Or())}))),this.updateTokenFp=k((w={})=>{var y;return d(n("web_app_biometry_update_token","biometry_token_updated",{...w,params:{token:w.token||"",reason:(y=w.reason)==null?void 0:y.trim()}}),I(m=>m.status))}),this.authenticate=b(this.authenticateFp),this.openSettings=b(this.openSettingsFp),this.requestAccess=b(this.requestAccessFp),this.updateToken=b(this.updateTokenFp),this.mount=b(this.mountFp)}}const Hr=(t,e,n)=>ea(t,e,{postEvent:qe,...n}),_n=(t,e,n)=>dt(t,e,{postEvent:qe,...n}),pa=(...t)=>Ne.fn(()=>Hr(...t)()),da=(...t)=>Ne.fn(()=>_n(...t)()),x=Le({request:_n});function ha(){return new jr({...d(q(),Q,$,x,ve("biometry")),offInfoReceived(t){ke("biometry_info_received",t)},onInfoReceived(t){return X("biometry_info_received",t)}})}const fa=ha();class Dr{constructor({postEvent:e,storage:n,isVBma:r,isPageReload:i}){s(this,"isConfirmationEnabled");s(this,"isMounted");s(this,"mountFp");s(this,"mount");s(this,"unmount");s(this,"disableConfirmationFp");s(this,"disableConfirmation");s(this,"enableConfirmationFp");s(this,"enableConfirmation");const o=new ge({initialState:{isConfirmationEnabled:!1},onChange(f){n.set(f)}}),a=new Ue({onMounted:o.setState,restoreState:n.get,initialState:{isConfirmationEnabled:!1},isPageReload:i}),c={requires:"web_app_setup_closing_behavior",isVBma:r},l=M({...c,returns:"plain"}),p=M({...c,returns:"either",isMounted:a.isMounted}),h=f=>f===this.isConfirmationEnabled()?E(void 0):(o.setState({isConfirmationEnabled:f}),e("web_app_setup_closing_behavior",{need_confirmation:f}));this.isConfirmationEnabled=o.getter("isConfirmationEnabled"),this.isMounted=a.isMounted,this.disableConfirmationFp=p(()=>h(!1)),this.enableConfirmationFp=p(()=>h(!0)),this.mountFp=l(()=>{const f=()=>{};return d(a.mount(),le(f,f))}),this.unmount=a.unmount,this.disableConfirmation=b(this.disableConfirmationFp),this.enableConfirmation=b(this.enableConfirmationFp),this.mount=b(this.mountFp)}}function _a(){return new Dr(d(q(),ve("closingBehavior"),Q))}const ba=_a();class Wr{constructor({version:e,isVBma:n,invokeCustomMethod:r}){s(this,"isSupported");s(this,"deleteItemFp");s(this,"deleteItem");s(this,"getItemFp");s(this,"getItem");s(this,"getItemsFp");s(this,"getItems");s(this,"getKeysFp");s(this,"getKeys");s(this,"setItemFp");s(this,"setItem");s(this,"clearFp");s(this,"clear");const i=M({version:e,requires:"web_app_invoke_custom_method",isVBma:n,returns:"task"});this.isSupported=se("web_app_invoke_custom_method",e),this.deleteItemFp=i((o,a)=>{const c=Array.isArray(o)?o:[o];return d(c.length?r("deleteStorageValues",{keys:c},a):T(void 0),I(()=>{}))}),this.getItemFp=i((o,a)=>d(this.getItemsFp([o],a),I(c=>c[o]||""))),this.getItemsFp=i((o,a)=>d(o.length?r("getStorageValues",{keys:o},a):T({}),I(c=>({...o.reduce((l,p)=>(l[p]="",l),{}),...fe(Dt(S(),S()),c)})))),this.getKeysFp=i(o=>d(r("getStorageKeys",{},o),I(a=>fe(On(S()),a)))),this.setItemFp=i((o,a,c)=>d(r("saveStorageValue",{key:o,value:a},c),I(()=>{}))),this.clearFp=i(o=>d(this.getKeysFp(o),ne(this.deleteItemFp))),this.deleteItem=b(this.deleteItemFp),this.getItem=b(this.getItemFp),this.getItems=b(this.getItemsFp),this.getKeys=b(this.getKeysFp),this.setItem=b(this.setItemFp),this.clear=b(this.clearFp)}}const bn=Ye(0);function bt(){return bn.set(bn()+1),bn().toString()}function Ur(t,e,n){return xo(t,e,bt(),{...n||{},postEvent:qe})}const mn=Le({invokeCustomMethod:Ur});function ma(){return new Wr(d(q(),$,mn))}const ga=ma();class Nr{constructor({isVBma:e,request:n,version:r,createRequestId:i}){s(this,"getItemFp");s(this,"getItem");s(this,"setItemFp");s(this,"setItem");s(this,"deleteItemFp");s(this,"deleteItem");s(this,"clearFp");s(this,"clear");const o=M({version:r,requires:"web_app_device_storage_get_key",isVBma:e,returns:"task"}),a=(c,l,p)=>{const h=i();return d(n(c,["device_storage_failed",l],{params:{...p,req_id:h},capture:(f=>"payload"in f?f.payload.req_id===h:!0)}),ne(f=>f.event==="device_storage_failed"?W(new qr(f.payload.error||"UNKNOWN_ERROR")):T(f.payload)))};this.getItemFp=o(c=>d(a("web_app_device_storage_get_key","device_storage_key_received",{key:c}),I(l=>l.value))),this.setItemFp=o((c,l)=>d(a("web_app_device_storage_save_key","device_storage_key_saved",{key:c,value:l}),I(()=>{}))),this.deleteItemFp=o(c=>this.setItemFp(c,null)),this.clearFp=o(()=>d(a("web_app_device_storage_clear","device_storage_cleared",{}),I(()=>{}))),this.getItem=b(this.getItemFp),this.setItem=b(this.setItemFp),this.deleteItem=b(this.deleteItemFp),this.clear=b(this.clearFp)}}const Gr=Le({createRequestId:bt});function wa(){return new Nr(d(q(),$,x,Gr))}const va=wa();function ya({request:t,...e}){return V(n=>d(t("web_app_request_emoji_status_access","emoji_status_access_requested",n),I(r=>r.status)),{...e,requires:"web_app_request_emoji_status_access",returns:"task"})}function Sa(){return ya(d(q(),$,x))}const zr=Sa(),Fa=b(zr);function Ca({request:t,...e}){return V((n,r)=>d(t("web_app_set_emoji_status",["emoji_status_set","emoji_status_failed"],{params:{custom_emoji_id:n,duration:(r||{}).duration},...r}),pe(i=>i.event==="emoji_status_failed"?W(new $r(i.payload.error)):T(void 0))),{...e,requires:"web_app_set_emoji_status",returns:"task"})}function ka(){return Ca(d(q(),x,$))}const Kr=ka(),Ea=b(Kr);class Jr{constructor({postEvent:e,isVBma:n,version:r}){s(this,"isSupported");s(this,"impactOccurredFp");s(this,"impactOccurred");s(this,"notificationOccurredFp");s(this,"notificationOccurred");s(this,"selectionChangedFp");s(this,"selectionChanged");const i="web_app_trigger_haptic_feedback",o=M({requires:i,isVBma:n,version:r,returns:"plain"});this.isSupported=se(i,r),this.impactOccurredFp=o(a=>e(i,{type:"impact",impact_style:a})),this.notificationOccurredFp=o(a=>e(i,{type:"notification",notification_type:a})),this.selectionChangedFp=o(()=>e(i,{type:"selection_change"})),this.impactOccurred=b(this.impactOccurredFp),this.notificationOccurred=b(this.notificationOccurredFp),this.selectionChanged=b(this.selectionChangedFp)}}function qa(){return new Jr(d(q(),Q,$))}const Aa=qa();function Ia({postEvent:t,...e}){return V(()=>t("web_app_add_to_home_screen"),{...e,requires:"web_app_add_to_home_screen",returns:"either"})}function Ba(){return Ia(d(q(),$,Q))}const Qr=Ba(),$a=b(Qr);function Ma({request:t,...e}){return V(n=>d(t("web_app_check_home_screen","home_screen_checked",n),I(r=>r.status||"unknown")),{...e,requires:"web_app_check_home_screen",returns:"task"})}function Pa(){return Ma(d(q(),$,x))}const Zr=Pa(),Ra=b(Zr);class Yr{constructor({retrieveInitData:e}){s(this,"_state",D());s(this,"_raw",D());s(this,"state",C(this._state));s(this,"authDate",this.fromState("auth_date"));s(this,"canSendAfter",this.fromState("can_send_after"));s(this,"canSendAfterDate",C(()=>{const e=this.authDate(),n=this.canSendAfter();return n&&e?new Date(e.getTime()+n*1e3):void 0}));s(this,"chat",this.fromState("chat"));s(this,"chatType",this.fromState("chat_type"));s(this,"chatInstance",this.fromState("chat_instance"));s(this,"hash",this.fromState("hash"));s(this,"queryId",this.fromState("query_id"));s(this,"raw",C(this._raw));s(this,"receiver",this.fromState("receiver"));s(this,"signature",this.fromState("signature"));s(this,"startParam",this.fromState("start_param"));s(this,"auth",this.fromState("auth"));s(this,"user",this.fromState("user"));s(this,"restoreFp");s(this,"restore");this.restoreFp=()=>d(e(),J(vt(()=>{},({raw:n,obj:r})=>{this._state.set(r),this._raw.set(n)}))),this.restore=re(this.restoreFp)}fromState(e){return C(()=>{const n=this._state();return n?n[e]:void 0})}}function Ta(){return new Yr({retrieveInitData(){return d($i,Mn("obj",()=>d(Re(),J(({vbWebAppData:t})=>t?Be(t):Se))),Mn("raw",nn),J(({obj:t,raw:e})=>d(vi,Bn("obj",()=>t),Bn("raw",()=>e))))}})}const La=Ta();class Xr{constructor({version:e,request:n,isVBma:r}){s(this,"isOpened");s(this,"isSupported");s(this,"openSlugFp");s(this,"openSlug");s(this,"openUrlFp");s(this,"openUrl");const i=M({version:e,isVBma:r,requires:"web_app_open_invoice",returns:"task"}),o=D(!1),a=()=>{o.set(!1)};this.isSupported=se("web_app_open_invoice",e),this.isOpened=C(o),this.openSlugFp=i((c,l)=>d(this.isOpened()?W(new ft("Invoice is already opened")):T(void 0),ne(()=>(o.set(!0),n("web_app_open_invoice","invoice_closed",{...l,params:{slug:c},capture:p=>c===p.slug}))),We(p=>(a(),p),p=>(a(),p.status)))),this.openUrlFp=i((c,l)=>{const{hostname:p,pathname:h}=new URL(c,window.location.href);if(p!=="t.me")return W(new ie(`Link has unexpected hostname: ${p}`));const f=h.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);return f?this.openSlugFp(f[2],l):W(new ie('Expected to receive a link with a pathname in format "/invoice/{slug}" or "/${slug}"'))}),this.openUrl=b(this.openUrlFp),this.openSlug=b(this.openSlugFp)}}function Va(){return new Xr(d(q(),x,$))}const Oa=Va();function ja({postEvent:t,...e}){return V((n,r={})=>{if(typeof n=="string")try{n=new URL(n)}catch(i){return P(new ie(`"${n.toString()}" is invalid URL`,i))}return t("web_app_open_link",{url:n.toString(),try_browser:r.tryBrowser,try_instant_view:r.tryInstantView})},{...e,returns:"either"})}function Ha(){return ja(d(q(),Q))}const xr=Ha(),Da=b(xr);function Wa({postEvent:t,version:e,...n}){return V(r=>{const i=r.toString();return i.match(/^https:\/\/t.me\/.+/)?_e("web_app_open_tg_link",te(e))?(r=new URL(r),t("web_app_open_tg_link",{path_full:r.pathname+r.search})):(window.location.href=i,E(void 0)):P(new ie(`"${i}" is invalid URL`))},{...n,returns:"either"})}function Ua(){return Wa(d(q(),Q,$))}const gn=Ua(),Na=b(gn);function Ga({openVbotLink:t,...e}){return V((n,r)=>t("https://t.me/share/url?"+new URLSearchParams({url:n,text:r||""}).toString().replace(/\+/g,"%20")),{...e,returns:"either"})}function za(){return Ga({...q(),openVbotLink:gn})}const es=za(),Ka=b(es);function Ja(t){let e=!1,n,r;return t.available&&(e=!0,n=t.access_requested,r=t.access_granted),{available:e,accessGranted:r||!1,accessRequested:n||!1}}class ts{constructor({version:e,request:n,postEvent:r,storage:i,isVBma:o,isPageReload:a}){s(this,"state");s(this,"isAvailable");s(this,"isAccessGranted");s(this,"isAccessRequested");s(this,"isMounted");s(this,"isSupported");s(this,"openSettingsFp");s(this,"openSettings");s(this,"requestLocationFp");s(this,"requestLocation");s(this,"mountFp");s(this,"mount");s(this,"unmount");const c=new ge({initialState:{available:!1,accessGranted:!1,accessRequested:!1},onChange:i.set}),l=new hn({isPageReload:a,restoreState:i.get,onMounted:c.setState,initialState(v){return d(n("web_app_check_location","location_checked",v),I(Ja))}}),p={version:e,requires:"web_app_check_location",isVBma:o},h=M({...p,returns:"either"}),f=M({...p,returns:"task"}),g=M({...p,returns:"task",isMounted:l.isMounted});this.isAvailable=c.getter("available"),this.isAccessRequested=c.getter("accessRequested"),this.isAccessGranted=c.getter("accessGranted"),this.isSupported=se("web_app_check_location",e),this.isMounted=l.isMounted,this.state=c.state,this.unmount=l.unmount,this.mountFp=f(l.mount),this.openSettingsFp=h(()=>r("web_app_open_location_settings")),this.requestLocationFp=g(v=>d(n("web_app_request_location","location_requested",v),I(F=>{if(!F.available)return c.setState({available:!1}),null;const{available:k,...w}=F;return w}))),this.mount=b(this.mountFp),this.openSettings=b(this.openSettingsFp),this.requestLocation=b(this.requestLocationFp)}}function Qa(){return new ts(d(q(),Q,$,x,ve("locationManager")))}const Za=Qa();class ns{constructor({defaults:e,...n}){s(this,"bgColor");s(this,"hasShineEffect");s(this,"isEnabled");s(this,"isLoaderVisible");s(this,"isVisible");s(this,"isMounted");s(this,"state");s(this,"text");s(this,"textColor");s(this,"showFp");s(this,"show");s(this,"hideFp");s(this,"hide");s(this,"enableFp");s(this,"enable");s(this,"enableShineEffectFp");s(this,"enableShineEffect");s(this,"disableFp");s(this,"disable");s(this,"disableShineEffectFp");s(this,"disableShineEffect");s(this,"setBgColorFp");s(this,"setBgColor");s(this,"setTextColorFp");s(this,"setTextColor");s(this,"setTextFp");s(this,"setText");s(this,"showLoaderFp");s(this,"showLoader");s(this,"hideLoaderFp");s(this,"hideLoader");s(this,"setParamsFp");s(this,"setParams");s(this,"mountFp");s(this,"mount");s(this,"unmount");s(this,"onClickFp");s(this,"onClick");s(this,"offClickFp");s(this,"offClick");const r=new _t({...n,version:"100",initialState:{hasShineEffect:!1,isEnabled:!0,isLoaderVisible:!1,isVisible:!1,text:"Continue"},method:"web_app_setup_main_button",payload:o=>({has_shine_effect:o.hasShineEffect,is_visible:o.isVisible,is_active:o.isEnabled,is_progress_visible:o.isLoaderVisible,text:o.text,color:o.bgColor,text_color:o.textColor})}),i=(o,a)=>{const c=r.stateGetter(o);return C(()=>c()||te(a))};this.bgColor=i("bgColor",e.bgColor),this.textColor=i("textColor",e.textColor),this.hasShineEffect=r.stateGetter("hasShineEffect"),this.isEnabled=r.stateGetter("isEnabled"),this.isLoaderVisible=r.stateGetter("isLoaderVisible"),this.text=r.stateGetter("text"),this.isVisible=r.stateGetter("isVisible"),this.isMounted=r.isMounted,this.state=r.state,[this.setBgColor,this.setBgColorFp]=r.stateSetters("bgColor"),[this.setTextColor,this.setTextColorFp]=r.stateSetters("textColor"),[[this.disableShineEffect,this.disableShineEffectFp],[this.enableShineEffect,this.enableShineEffectFp]]=r.stateBoolSetters("hasShineEffect"),[[this.disable,this.disableFp],[this.enable,this.enableFp]]=r.stateBoolSetters("isEnabled"),[[this.hideLoader,this.hideLoaderFp],[this.showLoader,this.showLoaderFp]]=r.stateBoolSetters("isLoaderVisible"),[this.setText,this.setTextFp]=r.stateSetters("text"),[[this.hide,this.hideFp],[this.show,this.showFp]]=r.stateBoolSetters("isVisible"),this.setParams=r.setState,this.setParamsFp=r.setStateFp,this.onClick=r.onClick,this.onClickFp=r.onClickFp,this.offClick=r.offClick,this.offClickFp=r.offClickFp,this.mount=r.mount,this.mountFp=r.mountFp,this.unmount=r.unmount}}function wn(t,e){document.documentElement.style.setProperty(t,e)}function vn(t){document.documentElement.style.removeProperty(t)}function rs(t){return d(ct(t),J(e=>Math.sqrt([.299,.587,.114].reduce((n,r,i)=>{const o=parseInt(e.slice(1+i*2,1+(i+1)*2),16);return n+o*o*r},0))<120))}const yn=re(rs);class ss{constructor({initialState:e,onChange:n,offChange:r,isVBma:i,storage:o,isPageReload:a}){s(this,"accentTextColor");s(this,"bgColor");s(this,"buttonColor");s(this,"buttonTextColor");s(this,"bottomBarBgColor");s(this,"destructiveTextColor");s(this,"headerBgColor");s(this,"hintColor");s(this,"linkColor");s(this,"secondaryBgColor");s(this,"sectionBgColor");s(this,"sectionHeaderTextColor");s(this,"sectionSeparatorColor");s(this,"subtitleTextColor");s(this,"textColor");s(this,"_isCssVarsBound",D(!1));s(this,"isCssVarsBound",C(this._isCssVarsBound));s(this,"bindCssVarsFp");s(this,"bindCssVars");s(this,"state");s(this,"isDark",C(()=>{const e=this.bgColor();return!e||yn(e)}));s(this,"isMounted");s(this,"mountFp");s(this,"mount");s(this,"unmount");const c=new ge({initialState:{},onChange:o.set}),l=v=>{c.setState(v.theme_params)},p=new Ue({initialState:()=>E(te(e)),isPageReload:a,onMounted(v){c.setState(v),n(l)},onUnmounted(){r(l)},restoreState:o.get}),h={isVBma:i,returns:"either"},f=M(h),g=M({...h,isMounted:p.isMounted});this.accentTextColor=c.getter("accent_text_color"),this.bgColor=c.getter("bg_color"),this.buttonColor=c.getter("button_color"),this.buttonTextColor=c.getter("button_text_color"),this.bottomBarBgColor=c.getter("bottom_bar_bg_color"),this.destructiveTextColor=c.getter("destructive_text_color"),this.headerBgColor=c.getter("header_bg_color"),this.hintColor=c.getter("hint_color"),this.linkColor=c.getter("link_color"),this.secondaryBgColor=c.getter("secondary_bg_color"),this.sectionBgColor=c.getter("section_bg_color"),this.sectionHeaderTextColor=c.getter("section_header_text_color"),this.sectionSeparatorColor=c.getter("section_separator_color"),this.subtitleTextColor=c.getter("subtitle_text_color"),this.textColor=c.getter("text_color"),this.state=c.state,this.isMounted=p.isMounted,this.bindCssVarsFp=g(v=>{if(this._isCssVarsBound())return P(new ht);v||(v=w=>`--vb-theme-${So(w)}`);const F=w=>{Object.entries(c.state()).forEach(([y,m])=>{m&&w(y,m)})},k=()=>{F((w,y)=>{wn(v(w),y)})};return k(),c.state.sub(k),this._isCssVarsBound.set(!0),E(()=>{F(vn),c.state.unsub(k),this._isCssVarsBound.set(!1)})}),this.mountFp=f(p.mount),this.unmount=p.unmount,this.bindCssVars=b(this.bindCssVarsFp),this.mount=b(this.mountFp)}}const Sn=Ye({});function Ya(){return new ss({...d(q(),ve("themeParams")),offChange(t){ke("theme_changed",t)},onChange(t){X("theme_changed",t)},initialState:Sn})}const Xe=Ya();function is(t,e,n){return d(dn(t,e),r=>({...r,defaults:n}))}const Xa=new ns(is("mainButton","main_button_pressed",{bgColor:C(()=>Xe.buttonColor()||"#2481cc"),textColor:C(()=>Xe.buttonTextColor()||"#ffffff")}));class os{constructor({storage:e,isPageReload:n,version:r,postEvent:i,isVBma:o,theme:a,onVisibilityChanged:c,offVisibilityChanged:l}){s(this,"isSupported");s(this,"isDark",C(()=>{const e=this.bgColorRgb();return e?yn(e):!1}));s(this,"isActive");s(this,"state");s(this,"isCssVarsBound");s(this,"bindCssVarsFp");s(this,"bindCssVars");s(this,"isMounted");s(this,"mountFp");s(this,"mount");s(this,"unmount");s(this,"bgColor");s(this,"bgColorRgb");s(this,"setBgColorFp");s(this,"setBgColor");s(this,"headerColor");s(this,"headerColorRgb");s(this,"setHeaderColorFp");s(this,"setHeaderColor");s(this,"bottomBarColor");s(this,"bottomBarColorRgb");s(this,"setBottomBarColorFp");s(this,"setBottomBarColor");s(this,"closeFp");s(this,"close");s(this,"readyFp");s(this,"ready");const p=m=>{g.setState({isActive:m.is_visible})},h=m=>{[[this.headerColor,"web_app_set_header_color"],[this.bgColor,"web_app_set_background_color"],[this.bottomBarColor,"web_app_set_bottom_bar_color"]].forEach(([j,H])=>{const U=j();if(!Ke(U)&&(H!=="web_app_set_header_color"||!["bg_color","secondary_bg_color"].includes(U))){const A=m[U];A&&i(H,{color:A})}})},f=new Ue({initialState(){return E({bgColor:"bg_color",headerColor:"header_bg_color",bottomBarColor:"bottom_bar_bg_color",isActive:!0})},isPageReload:n,onMounted:m=>{c(p),a.sub(h),g.setState(m)},onUnmounted(){l(p),a.unsub(h)},restoreState:e.get});this.isMounted=f.isMounted,this.mountFp=V(()=>{const m=()=>{};return d(f.mount(),le(m,m))},{isVBma:o,returns:"plain"}),this.mount=b(this.mountFp),this.unmount=f.unmount;const g=new ge({initialState:{bgColor:"bg_color",bottomBarColor:"bottom_bar_bg_color",headerColor:"bg_color",isActive:!1},onChange:e.set});this.state=g.state;const v=m=>Ke(m)?m:te(a)[m],F=m=>C(()=>v(m()));this.isActive=g.getter("isActive"),this.isSupported=C(()=>["web_app_set_header_color","web_app_set_background_color","web_app_set_bottom_bar_color"].some(m=>_e(m,te(r))));const k=D(!1);this.isCssVarsBound=C(k),this.bindCssVarsFp=V(m=>{if(k())return P(new ht);const[j,H]=Ge(()=>{k.set(!1)}),U=(A,O)=>{const L=()=>{wn(A,O()||null)};L(),j(O.sub(L),vn.bind(null,A))};return m||(m=A=>`--tg-${Gn(A)}`),U(m("bgColor"),this.bgColorRgb),U(m("bottomBarColor"),this.bottomBarColorRgb),U(m("headerColor"),this.headerColorRgb),k.set(!0),E(H)},{isVBma:o,returns:"either",isMounted:this.isMounted}),this.bindCssVars=b(this.bindCssVarsFp);const w=m=>{const j=g.getter(m),H=F(j),U={headerColor:"web_app_set_header_color",bgColor:"web_app_set_background_color",bottomBarColor:"web_app_set_bottom_bar_color"}[m],A=V(O=>{if(O===j())return E(void 0);if(U==="web_app_set_header_color"&&(O==="bg_color"||O==="secondary_bg_color"))return d(i("web_app_set_header_color",{color_key:O}),J(()=>{g.setState({[m]:O})}));const L=v(O);return d(L?i(U,{color:L}):P(new Rr(O)),J(()=>{g.setState({[m]:O})}))},{isVBma:o,version:r,requires:U,isMounted:this.isMounted,returns:"either",supports:m==="headerColor"?{rgb:{method:"web_app_set_header_color",param:"color",shouldCheck:Ke}}:void 0});return[j,H,b(A),A]};[this.bgColor,this.bgColorRgb,this.setBgColor,this.setBgColorFp]=w("bgColor"),[this.headerColor,this.headerColorRgb,this.setHeaderColor,this.setHeaderColorFp]=w("headerColor"),[this.bottomBarColor,this.bottomBarColorRgb,this.setBottomBarColor,this.setBottomBarColorFp]=w("bottomBarColor");const y=M({isVBma:o,returns:"either"});this.closeFp=y(m=>i("web_app_close",{return_back:m})),this.close=b(this.closeFp),this.readyFp=y(()=>i("web_app_ready")),this.ready=b(this.readyFp)}}function xa(){return new os({...d(q(),Q,$,ve("miniApp")),offVisibilityChanged(t){ke("visibility_changed",t)},onVisibilityChanged(t){X("visibility_changed",t)},theme:Xe.state})}const as=xa();function eu(){const t=Date.now(),e=Math.random().toString(36).substring(2,9);return`notif_${t}_${e}`}class us{constructor({version:e,isVBma:n}){s(this,"isSupported");s(this,"sendFp");s(this,"send");const r=M({version:e,isVBma:n,requires:"web_app_send_notification",returns:"task"});this.isSupported=se("web_app_send_notification",e),this.sendFp=r(i=>d(De(Te("web_app_send_notification",{id:eu(),message:i.message,title:i.title,type:i.type??"default"})),I(()=>{}))),this.send=i=>this.sendFp(i)().then(a=>{if(a._tag==="Left")throw a.left;return a.right})}}function tu(){return new us($(q()))}const nu=tu();function ru(t){const e=t.message.trim(),n=(t.title||"").trim(),r=t.buttons||[];if(n.length>64)return P(new ie(`Invalid title: ${n}`));if(!e||e.length>256)return P(new ie(`Invalid message: ${e}`));if(r.length>3)return P(new ie(`Invalid buttons count: ${r.length}`));const i=[];if(!r.length)i.push({type:"close",id:""});else for(let o=0;o<r.length;o++){const a=r[o],c=a.id||"";if(c.length>64)return P(new ie(`Button with index ${o} has invalid id: ${c}`));if(!a.type||a.type==="default"||a.type==="destructive"){const l=a.text.trim();if(!l||l.length>64)return P(new ie(`Button with index ${o} has invalid text: ${l}`));i.push({type:a.type,text:l,id:c})}else i.push({type:a.type,id:c})}return E({title:n,message:e,buttons:i})}class cs{constructor({version:e,isVBma:n,request:r}){s(this,"isOpened");s(this,"isSupported");s(this,"showFp");s(this,"show");const i=D(!1),o=()=>{i.set(!1)},a=M({version:e,isVBma:n,requires:"web_app_open_popup",returns:"task"});this.isSupported=se("web_app_open_popup",e),this.isOpened=C(i),this.showFp=a(c=>d(this.isOpened()?W(new ft("A popup is already opened")):T(void 0),pe(()=>De(ru(c))),ne(l=>(i.set(!0),r("web_app_open_popup","popup_closed",{...c,params:l}))),We(l=>(o(),l),l=>(o(),l.button_id)))),this.show=b(this.showFp)}}function su(){return new cs(d(q(),x,$))}const iu=su();function ou({request:t,...e}){return V(n=>d(t("web_app_request_phone","phone_requested",n),I(r=>r.status)),{...e,requires:"web_app_request_phone",returns:"task"})}function au(){return ou(d(q(),$,x))}const Fn=au(),uu=b(Fn);function cu({invokeCustomMethod:t,requestPhoneAccess:e,...n}){const r=a=>d(t("getRequestedContact",{},{...a,timeout:(a||{}).timeout||5e3}),pe(c=>{const l=Ut(S(),c);if(!l.success)return W(new Ze(c,l.issues));if(!l.output)return T(void 0);const p=Ut(Jt(N({contact:ue(N({user_id:we(),phone_number:S(),first_name:S(),last_name:B(S())})),auth_date:ae(S(),he(h=>new Date(Number(h)*1e3)),st()),hash:S()})),l.output);return p.success?T({raw:l.output,parsed:p.output}):W(new Ze(l.output,p.issues))})),i=a=>d(r(a),tt(c=>Ze.is(c)?P(c):E(void 0),c=>E(c))),o=a=>Pe(async(c,l,p)=>{let h=50;for(;!p.isRejected;){const f=await i(p)();if(f._tag==="Left")return l(f.left);if(f.right)return c(f.right);await new Promise(g=>setTimeout(g,h)),h+=50}},a);return V(a=>Pe.fn(c=>d(i(c),ne(l=>l?T(l):d(e(c),pe(p=>p==="sent"?o(c):W(new ln("User denied access")))))),a),{...n,returns:"task",requires:"web_app_request_phone"})}function lu(){return cu({...d(q(),mn,$),requestPhoneAccess:Fn})}function pu({requestContact:t,...e}){return V(t,{...e,returns:"task",requires:"web_app_request_phone"})}function du(){return pu({...d(q(),$),requestContact(t){return d(Cn(t),I(e=>e.parsed))}})}const Cn=lu(),hu=b(Cn),ls=du(),fu=b(ls);function _u({request:t,...e}){return V(n=>d(t("web_app_request_write_access","write_access_requested",n),I(r=>r.status)),{...e,requires:"web_app_request_write_access",returns:"task"})}function bu(){return _u(d(q(),$,x))}const ps=bu(),mu=b(ps);class ds{constructor({version:e,onClosed:n,onTextReceived:r,isVBma:i,postEvent:o}){s(this,"isOpened");s(this,"isSupported");s(this,"captureFp");s(this,"capture");s(this,"closeFp");s(this,"close");s(this,"openFp");s(this,"open");const a={version:e,requires:"web_app_open_scan_qr_popup",isVBma:i},c=M({...a,returns:"either"}),l=M({...a,returns:"task"}),p=D(!1),h=()=>{p.set(!1)};this.isSupported=se("web_app_open_scan_qr_popup",e),this.isOpened=C(p),this.captureFp=l(f=>{let g;return d(this.openFp({...f,onCaptured:v=>{f.capture(v)&&(g=v,this.close())}}),I(()=>g))}),this.closeFp=c(()=>d(o("web_app_close_scan_qr_popup"),J(h))),this.openFp=l(f=>d(p()?W(new ft("The QR Scanner is already opened")):async()=>o("web_app_open_scan_qr_popup",{text:f.text}),pe(()=>{p.set(!0);const[g,v]=Ge(),F=k=>(v(),p.set(!1),k);return d(Pe(k=>{g(n(k),p.sub(w=>{w||k()}),r(f.onCaptured))},f),We(F,F))}))),this.open=b(this.openFp),this.capture=b(this.captureFp),this.close=b(this.closeFp)}}function gu(){return new ds({...d(q(),Q,$),onClosed(t){return X("scan_qr_popup_closed",t)},onTextReceived(t){return X("qr_text_received",e=>{t(e.data)})}})}const wu=gu();class hs{constructor({}){s(this,"isRefreshing");s(this,"finishRefreshFp");s(this,"finishRefresh");s(this,"onRefreshRequest");const e=D(!1);X("refresh_requested",()=>{e.set(!0)}),this.isRefreshing=C(e),this.finishRefreshFp=()=>d(De(Te("web_app_finish_refresh")),I(()=>{e.set(!1)})),this.finishRefresh=()=>this.finishRefreshFp()().then(r=>{if(r._tag==="Left")throw r.left;return r.right}),this.onRefreshRequest=n=>X("refresh_requested",()=>{n()})}}function vu(){return new hs(d(q()))}const yu=vu();class fs{constructor({defaults:e,...n}){s(this,"isSupported");s(this,"position");s(this,"bgColor");s(this,"hasShineEffect");s(this,"isEnabled");s(this,"isLoaderVisible");s(this,"isVisible");s(this,"isMounted");s(this,"state");s(this,"text");s(this,"textColor");s(this,"showFp");s(this,"show");s(this,"hideFp");s(this,"hide");s(this,"enableFp");s(this,"enable");s(this,"enableShineEffectFp");s(this,"enableShineEffect");s(this,"disableFp");s(this,"disable");s(this,"disableShineEffectFp");s(this,"disableShineEffect");s(this,"setBgColorFp");s(this,"setBgColor");s(this,"setTextColorFp");s(this,"setTextColor");s(this,"setTextFp");s(this,"setText");s(this,"setPositionFp");s(this,"setPosition");s(this,"showLoaderFp");s(this,"showLoader");s(this,"hideLoaderFp");s(this,"hideLoader");s(this,"setParamsFp");s(this,"setParams");s(this,"mountFp");s(this,"mount");s(this,"unmount");s(this,"onClickFp");s(this,"onClick");s(this,"offClickFp");s(this,"offClick");const r=new _t({...n,initialState:{hasShineEffect:!1,isEnabled:!0,isLoaderVisible:!1,isVisible:!1,text:"Cancel",position:"left"},method:"web_app_setup_secondary_button",payload:o=>({has_shine_effect:o.hasShineEffect,is_visible:o.isVisible,is_active:o.isEnabled,is_progress_visible:o.isLoaderVisible,text:o.text,color:o.bgColor,text_color:o.textColor,position:o.position})}),i=(o,a)=>{const c=r.stateGetter(o);return C(()=>c()||te(a))};this.isSupported=se("web_app_setup_secondary_button",n.version),this.bgColor=i("bgColor",e.bgColor),this.textColor=i("textColor",e.textColor),this.position=r.stateGetter("position"),this.hasShineEffect=r.stateGetter("hasShineEffect"),this.isEnabled=r.stateGetter("isEnabled"),this.isLoaderVisible=r.stateGetter("isLoaderVisible"),this.text=r.stateGetter("text"),this.isVisible=r.stateGetter("isVisible"),this.isMounted=r.isMounted,this.state=r.state,[this.setPosition,this.setPositionFp]=r.stateSetters("position"),[this.setBgColor,this.setBgColorFp]=r.stateSetters("bgColor"),[this.setTextColor,this.setTextColorFp]=r.stateSetters("textColor"),[[this.disableShineEffect,this.disableShineEffectFp],[this.enableShineEffect,this.enableShineEffectFp]]=r.stateBoolSetters("hasShineEffect"),[[this.disable,this.disableFp],[this.enable,this.enableFp]]=r.stateBoolSetters("isEnabled"),[[this.hideLoader,this.hideLoaderFp],[this.showLoader,this.showLoaderFp]]=r.stateBoolSetters("isLoaderVisible"),[this.setText,this.setTextFp]=r.stateSetters("text"),[[this.hide,this.hideFp],[this.show,this.showFp]]=r.stateBoolSetters("isVisible"),this.setParams=r.setState,this.setParamsFp=r.setStateFp,this.onClick=r.onClick,this.onClickFp=r.onClickFp,this.offClick=r.offClick,this.offClickFp=r.offClickFp,this.mount=r.mount,this.mountFp=r.mountFp,this.unmount=r.unmount}}function Su(){return new fs(is("secondaryButton","secondary_button_pressed",{bgColor:C(()=>as.bottomBarColorRgb()||"#000000"),textColor:C(()=>Xe.buttonColor()||"#2481cc")}))}const Fu=Su();class _s{constructor({isVBma:e,request:n,version:r,createRequestId:i}){s(this,"getItemFp");s(this,"getItem");s(this,"restoreItemFp");s(this,"restoreItem");s(this,"setItemFp");s(this,"setItem");s(this,"deleteItemFp");s(this,"deleteItem");s(this,"clearFp");s(this,"clear");const o=M({version:r,requires:"web_app_secure_storage_get_key",isVBma:e,returns:"task"}),a=(c,l,p)=>{const h=i();return d(n(c,["secure_storage_failed",l],{params:{...p,req_id:h},capture:(f=>"payload"in f?f.payload.req_id===h:!0)}),ne(f=>f.event==="secure_storage_failed"?W(new Ar(f.payload.error||"UNKNOWN_ERROR")):T(f.payload)))};this.getItemFp=o(c=>d(a("web_app_secure_storage_get_key","secure_storage_key_received",{key:c}),I(l=>({value:l.value,canRestore:!!l.can_restore})))),this.setItemFp=o((c,l)=>d(a("web_app_secure_storage_save_key","secure_storage_key_saved",{key:c,value:l}),I(()=>{}))),this.deleteItemFp=o(c=>this.setItemFp(c,null)),this.clearFp=o(()=>d(a("web_app_secure_storage_clear","secure_storage_cleared",{}),I(()=>{}))),this.restoreItemFp=o(c=>d(a("web_app_secure_storage_restore_key","secure_storage_key_restored",{key:c}),I(l=>l.value))),this.getItem=b(this.getItemFp),this.setItem=b(this.setItemFp),this.deleteItem=b(this.deleteItemFp),this.clear=b(this.clearFp),this.restoreItem=b(this.restoreItemFp)}}function Cu(){return new _s(d(q(),$,x,Gr))}const ku=Cu();class bs{constructor(e){s(this,"isVisible");s(this,"isMounted");s(this,"isSupported");s(this,"hideFp");s(this,"hide");s(this,"showFp");s(this,"show");s(this,"onClickFp");s(this,"onClick");s(this,"offClickFp");s(this,"offClick");s(this,"mountFp");s(this,"mount");s(this,"unmount");const n=new _t({...e,method:"web_app_setup_settings_button",payload:r=>({is_visible:r.isVisible}),initialState:{isVisible:!1}});this.isVisible=n.stateGetter("isVisible"),this.isMounted=n.isMounted,this.isSupported=n.isSupported,[[this.hide,this.hideFp],[this.show,this.showFp]]=n.stateBoolSetters("isVisible"),this.onClick=n.onClick,this.onClickFp=n.onClickFp,this.offClick=n.offClick,this.offClickFp=n.offClickFp,this.mount=n.mount,this.mountFp=n.mountFp,this.unmount=n.unmount}}const Eu=new bs(dn("settingsButton","settings_button_pressed"));class ms{constructor({postEvent:e,storage:n,isVBma:r,isPageReload:i,version:o}){s(this,"isSupported");s(this,"isVerticalEnabled");s(this,"isMounted");s(this,"mountFp");s(this,"mount");s(this,"unmount");s(this,"disableVerticalFp");s(this,"disableVertical");s(this,"enableVerticalFp");s(this,"enableVertical");const a={isVerticalEnabled:!0},c=new ge({initialState:a,onChange(v){n.set(v)}}),l=new Ue({initialState:a,isPageReload:i,onMounted:c.setState,restoreState:n.get}),p={requires:"web_app_setup_swipe_behavior",isVBma:r,version:o},h=M({...p,returns:"plain"}),f=M({...p,isMounted:l.isMounted,returns:"either"}),g=v=>{const F={isVerticalEnabled:v};return c.hasDiff(F)?d(e("web_app_setup_swipe_behavior",{allow_vertical_swipe:v}),J(()=>{c.setState(F)})):E(void 0)};this.isSupported=se("web_app_setup_swipe_behavior",o),this.isVerticalEnabled=c.getter("isVerticalEnabled"),this.isMounted=l.isMounted,this.disableVerticalFp=f(()=>g(!1)),this.enableVerticalFp=f(()=>g(!0)),this.mountFp=h(()=>{const v=()=>{};return d(l.mount(),le(v,v))}),this.unmount=l.unmount,this.disableVertical=b(this.disableVerticalFp),this.enableVertical=b(this.enableVerticalFp),this.mount=b(this.mountFp)}}function qu(){return new ms(d(q(),Q,$,ve("swipeBehavior")))}const Au=qu();async function Iu(t){try{const{clipboard:n}=navigator;if(n)return await n.writeText(t)}catch{}const e=document.createElement("textarea");e.value=t,e.style.top="0",e.style.left="0",e.style.position="fixed",document.body.appendChild(e),e.focus(),e.select();try{document.execCommand("copy")}finally{document.body.removeChild(e)}}function Bu({request:t,...e}){return V((n,r,i)=>d(t("web_app_request_file_download","file_download_requested",{...i,params:{url:n,file_name:r}}),ne(o=>o.status==="downloading"?T(void 0):W(new ln("User denied the action")))),{...e,requires:"web_app_request_file_download",returns:"task"})}function $u(){return Bu(d(q(),x,$))}const gs=$u(),Mu=b(gs);function Pu({invokeCustomMethod:t,...e}){return V(n=>d(t("getCurrentTime",{},n),ne(r=>{const i=Ut(ae(we(),Lt(),he(o=>new Date(o*1e3)),st()),r);return i.success?T(i.output):W(new Ze(r,i.issues))})),{...e,requires:"web_app_invoke_custom_method",returns:"task"})}function Ru(){return Pu(d(q(),mn,$))}const ws=Ru(),Tu=b(ws);function Lu({postEvent:t,...e}){return V(()=>t("web_app_hide_keyboard"),{...e,returns:"either",requires:"web_app_hide_keyboard"})}function Vu(){return Lu(d(q(),Q,$))}const vs=Vu(),Ou=b(vs);function ju({request:t,createRequestId:e,...n}){return V(r=>{const i=e();return d(t("web_app_read_text_from_clipboard","clipboard_text_received",{...r,params:{req_id:i},capture:Sr(i)}),I(({data:o=null})=>o))},{...n,requires:"web_app_read_text_from_clipboard",returns:"task"})}function Hu(){return ju({...d(q(),$,x),createRequestId:bt})}const ys=Hu(),Du=b(ys);function Ss(t){const e={},n=t.match(/Telegram-Android(?:\/([^ ]+))?(?: (\([^)]+\))?|$)/);if(n){const[,r,i]=n;r&&(e.appVersion=r),i&&i.slice(1,i.length-1).split(";").forEach(o=>{const[a,c]=o.trim().split(" ");if(a==="Android")e.androidVersion=c;else if(a==="SDK"){const l=parseInt(c,10);l&&(e.sdkVersion=l)}else c?(e.manufacturer=a,e.model=c):e.performanceClass=a})}return e}function Wu(){return Ss(navigator.userAgent)}function Uu({postEvent:t,...e}){return V(n=>{const{size:r}=new Blob([n]);return!r||r>4096?P(new ie(r?"Maximum size of data to send is 4096 bytes":"Attempted to send empty data")):t("web_app_data_send",{data:n})},{...e,returns:"either"})}function Nu(){return Uu(d(q(),Q))}const Fs=Nu(),Gu=b(Fs);function zu({request:t,...e}){return V((n,r)=>d(t("web_app_send_prepared_message",["prepared_message_failed","prepared_message_sent"],{...r,params:{id:n}}),ne(i=>i.event==="prepared_message_failed"?W(new Pr(i.payload.error)):T(void 0))),{...e,requires:"web_app_send_prepared_message",returns:"task"})}function Ku(){return zu(d(q(),x,$))}const Cs=Ku(),Ju=b(Cs);function Qu({postEvent:t,...e}){return V((n,r={})=>t("web_app_share_to_story",{text:r.text,media_url:n,widget_link:r.widgetLink}),{...e,requires:"web_app_share_to_story",returns:"either"})}function Zu(){return Qu(d(q(),Q,$))}const ks=Zu(),Yu=b(ks),kn=Ye(!1);function Xu({isInlineMode:t,postEvent:e,...n}){return V((r,i)=>e("web_app_switch_inline_query",{query:r,chat_types:i||[]}),{...n,requires:{every:["web_app_switch_inline_query",()=>te(t)?void 0:"The application must be launched in the inline mode"]},returns:"either"})}function xu(){return Xu({...d(q(),Q,$),isInlineMode:kn})}const Es=xu(),ec=b(Es);class qs{constructor({storage:e,isPageReload:n,onContentSafeAreaInsetsChanged:r,onSafeAreaInsetsChanged:i,onViewportChanged:o,onFullscreenChanged:a,offContentSafeAreaInsetsChanged:c,offFullscreenChanged:l,offSafeAreaInsetsChanged:p,offViewportChanged:h,request:f,isViewportStable:g,isFullscreen:v,isVBma:F,version:k,postEvent:w}){s(this,"state");s(this,"height");s(this,"stableHeight");s(this,"width");s(this,"isExpanded");s(this,"isStable",C(()=>this.height()===this.stableHeight()));s(this,"contentSafeAreaInsets");s(this,"contentSafeAreaInsetTop");s(this,"contentSafeAreaInsetLeft");s(this,"contentSafeAreaInsetRight");s(this,"contentSafeAreaInsetBottom");s(this,"safeAreaInsets");s(this,"safeAreaInsetTop");s(this,"safeAreaInsetLeft");s(this,"safeAreaInsetRight");s(this,"safeAreaInsetBottom");s(this,"isFullscreen");s(this,"requestFullscreenFp");s(this,"requestFullscreen");s(this,"exitFullscreenFp");s(this,"exitFullscreen");s(this,"isCssVarsBound");s(this,"bindCssVarsFp");s(this,"bindCssVars");s(this,"isMounted");s(this,"mountFp");s(this,"mount");s(this,"expandFp");s(this,"expand");const y={top:0,right:0,left:0,bottom:0},m=new ge({initialState:{contentSafeAreaInsets:y,height:0,isExpanded:!1,isFullscreen:!1,safeAreaInsets:y,stableHeight:0,width:0},onChange:e.set}),j=R=>{m.setState({isExpanded:R.is_expanded,height:R.height,width:R.width,stableHeight:R.is_state_stable?R.height:void 0})},H=R=>{m.setState({isFullscreen:R.is_fullscreen})},U=R=>{m.setState({safeAreaInsets:R})},A=R=>{m.setState({contentSafeAreaInsets:R})},O=new hn({initialState(R){const Ae=be=>()=>{const[ye,oe]=be==="safe-area"?["web_app_request_safe_area","safe_area_changed"]:["web_app_request_content_safe_area","content_safe_area_changed"];return _e(ye,te(k))?f(ye,oe,R):T({top:0,left:0,right:0,bottom:0})},z=be=>()=>typeof be=="boolean"?T(be):De(be());return d(ro,nt("safeAreaInsets",Ae("safe-area")),nt("contentSafeAreaInsets",Ae("content-safe-area")),nt("isFullscreen",z(v)),nt("isViewportStable",z(g)),pe(({isViewportStable:be,...ye})=>be?T({...ye,height:window.innerHeight,isExpanded:!0,stableHeight:window.innerHeight,width:window.innerWidth}):d(f("web_app_request_viewport","viewport_changed",R),I(oe=>({...ye,height:oe.height,isExpanded:oe.is_expanded,stableHeight:oe.is_state_stable?oe.height:0,width:oe.width})))))},isPageReload:n,onMounted(R){o(j),a(H),i(U),r(A),m.setState(R)},onUnmounted(){h(j),l(H),p(U),c(A)},restoreState:e.get}),L=R=>C(()=>this.safeAreaInsets()[R]),G=R=>C(()=>this.contentSafeAreaInsets()[R]);this.state=m.state,this.height=m.getter("height"),this.stableHeight=m.getter("stableHeight"),this.width=m.getter("width"),this.isExpanded=m.getter("isExpanded"),this.safeAreaInsets=m.getter("safeAreaInsets"),this.safeAreaInsetTop=L("top"),this.safeAreaInsetBottom=L("bottom"),this.safeAreaInsetLeft=L("left"),this.safeAreaInsetRight=L("right"),this.contentSafeAreaInsets=m.getter("contentSafeAreaInsets"),this.contentSafeAreaInsetTop=G("top"),this.contentSafeAreaInsetBottom=G("bottom"),this.contentSafeAreaInsetLeft=G("left"),this.contentSafeAreaInsetRight=G("right");const Ve=M({isVBma:F,returns:"task"}),xe=M({isVBma:F,returns:"either"}),$c=M({isVBma:F,requires:"web_app_request_fullscreen",version:k,returns:"task"}),ti=R=>$c(Ae=>d(f(R?"web_app_request_fullscreen":"web_app_exit_fullscreen",["fullscreen_changed","fullscreen_failed"],Ae),ne(z=>z.event==="fullscreen_failed"&&z.payload.error!=="ALREADY_FULLSCREEN"?W(new Mr(z.payload.error)):(m.setState({isFullscreen:"is_fullscreen"in z.payload?z.payload.is_fullscreen:!0}),T(void 0)))));this.isMounted=O.isMounted,this.mountFp=Ve(O.mount),this.mount=b(this.mountFp),this.isFullscreen=m.getter("isFullscreen"),this.requestFullscreenFp=ti(!0),this.requestFullscreen=b(this.requestFullscreenFp),this.exitFullscreenFp=ti(!1),this.exitFullscreen=b(this.exitFullscreenFp);const mt=D(!1);this.isCssVarsBound=C(mt),this.bindCssVarsFp=xe(R=>{if(mt())return P(new ht);R||(R=z=>`--vb-viewport-${Gn(z)}`);const Ae=[["height",this.height],["stableHeight",this.stableHeight],["width",this.width],["safeAreaInsetTop",this.safeAreaInsetTop],["safeAreaInsetBottom",this.safeAreaInsetBottom],["safeAreaInsetLeft",this.safeAreaInsetLeft],["safeAreaInsetRight",this.safeAreaInsetRight],["contentSafeAreaInsetTop",this.contentSafeAreaInsetTop],["contentSafeAreaInsetBottom",this.contentSafeAreaInsetBottom],["contentSafeAreaInsetLeft",this.contentSafeAreaInsetLeft],["contentSafeAreaInsetRight",this.contentSafeAreaInsetRight]].reduce((z,[be,ye])=>{const oe=R(be);if(oe){const ni=()=>{wn(oe,`${ye()}px`)};z.push({update:ni,removeListener:ye.sub(ni),cssVar:oe})}return z},[]);return Ae.forEach(z=>{z.update()}),mt.set(!0),E(()=>{Ae.forEach(z=>{z.removeListener(),vn(z.cssVar)}),mt.set(!1)})}),this.bindCssVars=b(this.bindCssVarsFp),this.expandFp=xe(()=>w("web_app_expand")),this.expand=b(this.expandFp)}}function tc(){const t=o=>({on:a=>{X(o,a)},off:a=>{ke(o,a)}}),e=t("viewport_changed"),n=t("fullscreen_changed"),r=t("safe_area_changed"),i=t("content_safe_area_changed");return new qs({...d(q(),ve("viewport"),$,Q,x),isFullscreen(){return d(Re(),J(o=>!!o.vbWebAppFullscreen))},isViewportStable(){return d(Re(),J(o=>["macos","tdesktop","unigram","webk","weba","web"].includes(o.vbWebAppPlatform)))},offContentSafeAreaInsetsChanged:i.off,offFullscreenChanged:n.off,offSafeAreaInsetsChanged:r.off,offViewportChanged:e.off,onContentSafeAreaInsetsChanged:i.on,onFullscreenChanged:n.on,onSafeAreaInsetsChanged:r.on,onViewportChanged:e.on})}const nc=tc();class As{constructor({request:e}){s(this,"requestAccessFp");s(this,"requestAccess");s(this,"selectFile");s(this,"selectFiles");s(this,"selectFolder");this.requestAccessFp=n=>d(e("web_app_request_storage_access","storage_access_granted",{params:{access_type:n.accessType,multiple:n.multiple,accept:n.accept,max_file_size:n.maxFileSize,read_content:n.readContent}}),I(r=>({accessType:r.access_type,items:r.items.map(i=>({name:i.name,path:i.path,size:i.size,type:i.type,content:i.content,lastModified:i.last_modified}))}))),this.requestAccess=n=>this.requestAccessFp(n)().then(i=>{if(i._tag==="Left")throw i.left;return i.right}),this.selectFile=n=>this.requestAccess({accessType:"file",multiple:!1,...n}),this.selectFiles=n=>this.requestAccess({accessType:"file",multiple:!0,...n}),this.selectFolder=()=>this.requestAccess({accessType:"folder"})}}function rc(){return new As({request:dt})}const sc=rc();class Is{onSetup(e){return _().on("web_app_setup_back_button",r=>{r&&typeof r.is_visible=="boolean"&&e(r.is_visible)})}press(){_().send("back_button_pressed")}}const ic=new Is;class Bs{onSetup(e){return _().on("web_app_setup_main_button",r=>{r&&e(r)})}press(){_().send("main_button_pressed")}}const oc=new Bs;class $s{onSetup(e){return _().on("web_app_setup_secondary_button",r=>{r&&e(r)})}press(){_().send("secondary_button_pressed")}}const ac=new $s;class Ms{onSetup(e){return _().on("web_app_setup_settings_button",r=>{r&&e(r)})}press(){_().send("settings_button_pressed")}}const uc=new Ms;class Ps{onOpen(e){return _().on("web_app_open_popup",r=>{r&&e(r)})}close(e){_().send("popup_closed",{button_id:e})}}const cc=new Ps;class Rs{onExpand(e){return _().on("web_app_expand",()=>{e()})}onRequestContentSafeArea(e){return _().on("web_app_request_content_safe_area",()=>{e()})}onRequestSafeArea(e){return _().on("web_app_request_safe_area",()=>{e()})}onRequestViewport(e){return _().on("web_app_request_viewport",()=>{e()})}onToggleOrientationLock(e){return _().on("web_app_toggle_orientation_lock",r=>{r&&typeof r.locked=="boolean"&&e(r.locked)})}onRequestFullscreen(e){return _().on("web_app_request_fullscreen",()=>{e()})}setFullscreen(e){_().send("fullscreen_changed",{is_fullscreen:e})}setFullscreenFailed(e){_().send("fullscreen_failed",{error:e})}onExitFullscreen(e){return _().on("web_app_exit_fullscreen",()=>{e()})}setContentSafeArea(e){_().send("content_safe_area_changed",e)}setSafeArea(e){_().send("safe_area_changed",e)}setViewport(e){_().send("viewport_changed",e)}}const lc=new Rs;class Ts{onIframeReady(e){return _().on("iframe_ready",r=>{e(r||{})})}onIframeWillReload(e){return _().on("iframe_will_reload",()=>{e()})}onClose(e){return _().on("web_app_close",()=>{e()})}onHideKeyboard(e){return _().on("web_app_hide_keyboard",()=>{e()})}onReady(e){return _().on("web_app_ready",()=>{e()})}onRequestTheme(e){return _().on("web_app_request_theme",()=>{e()})}onBackgroundColorChange(e){return _().on("web_app_set_background_color",r=>{r&&typeof r.color=="string"&&e(r.color)})}onBottomBarColorChange(e){return _().on("web_app_set_bottom_bar_color",r=>{r&&r.color&&e(r.color)})}onHeaderColorChange(e){return _().on("web_app_set_header_color",r=>{r&&("color_key"in r&&r.color_key?e(r.color_key):"color"in r&&r.color&&e(r.color))})}reloadIframe(){_().send("reload_iframe")}setCustomStyle(e){_().send("set_custom_style",e)}setVisibility(e){_().send("visibility_changed",{is_visible:e})}}const pc=new Ts;class Ls{onHapticFeedback(e){return _().on("web_app_trigger_haptic_feedback",r=>{r&&e(r)})}}const dc=new Ls;class Vs{onGetInfo(e){return _().on("web_app_biometry_get_info",()=>{e()})}onOpenSettings(e){return _().on("web_app_biometry_open_settings",()=>{e()})}onRequestAccess(e){return _().on("web_app_biometry_request_access",r=>{e(r||{})})}onRequestAuth(e){return _().on("web_app_biometry_request_auth",r=>{e(r||{})})}onUpdateToken(e){return _().on("web_app_biometry_update_token",r=>{r&&e(r)})}setInfoReceived(e){_().send("biometry_info_received",e)}setAuthRequested(e){_().send("biometry_auth_requested",e)}setTokenUpdated(e){_().send("biometry_token_updated",e)}}const hc=new Vs;class Os{onOpenInvoice(e){return _().on("web_app_open_invoice",r=>{r&&e(r)})}setInvoiceClosed(e){_().send("invoice_closed",e)}}const fc=new Os;class js{onOpenPopup(e){return _().on("web_app_open_scan_qr_popup",r=>{e(r||{})})}onClosePopup(e){return _().on("web_app_close_scan_qr_popup",()=>{e()})}sendQrTextReceived(e){_().send("qr_text_received",e)}closePopup(){_().send("scan_qr_popup_closed")}}const _c=new js;class Hs{onCheckLocation(e){return _().on("web_app_check_location",()=>{e()})}onOpenLocationSettings(e){return _().on("web_app_open_location_settings",()=>{e()})}onRequestLocation(e){return _().on("web_app_request_location",()=>{e()})}setLocationChecked(e){_().send("location_checked",e)}setLocationRequested(e){_().send("location_requested",e)}}const bc=new Hs;class Ds{onOpenLink(e){return _().on("web_app_open_link",r=>{r&&e(r)})}onOpenTgLink(e){return _().on("web_app_open_tg_link",r=>{r&&e(r)})}}const mc=new Ds;class Ws{onRequestAccess(e){return _().on("web_app_request_emoji_status_access",()=>{e()})}onSetEmojiStatus(e){return _().on("web_app_set_emoji_status",r=>{r&&e(r)})}setAccessRequested(e){_().send("emoji_status_access_requested",e)}setEmojiStatusSet(e){_().send("emoji_status_set",e)}setEmojiStatusFailed(e){_().send("emoji_status_failed",e)}}const gc=new Ws;class Us{onAddToHomeScreen(e){return _().on("web_app_add_to_home_screen",()=>{e()})}onCheckHomeScreen(e){return _().on("web_app_check_home_screen",()=>{e()})}setHomeScreenChecked(e){_().send("home_screen_checked",e)}setHomeScreenAdded(){_().send("home_screen_added")}setHomeScreenFailed(e){_().send("home_screen_failed",e)}}const wc=new Us;class Ns{onRequestPhone(e){return _().on("web_app_request_phone",()=>{e()})}onRequestWriteAccess(e){return _().on("web_app_request_write_access",()=>{e()})}setPhoneRequested(e){_().send("phone_requested",e)}setWriteAccessRequested(e){_().send("write_access_requested",e)}}const vc=new Ns;class Gs{onSetupClosingBehavior(e){return _().on("web_app_setup_closing_behavior",r=>{r&&e(r)})}}const yc=new Gs;class zs{onSetupSwipeBehavior(e){return _().on("web_app_setup_swipe_behavior",r=>{r&&e(r)})}}const Sc=new zs;class Ks{onReadText(e){return _().on("web_app_read_text_from_clipboard",r=>{r&&e(r)})}sendTextReceived(e){_().send("clipboard_text_received",e)}}const Fc=new Ks;class Js{onRequestFileDownload(e){return _().on("web_app_request_file_download",r=>{e(r||{})})}setFileDownloadRequested(e){_().send("file_download_requested",e)}}const Cc=new Js;class Qs{onSendPreparedMessage(e){return _().on("web_app_send_prepared_message",r=>{r&&e(r)})}onShareToStory(e){return _().on("web_app_share_to_story",r=>{e(r||{})})}setPreparedMessageFailed(e){_().send("prepared_message_failed",e)}setPreparedMessageSent(){_().send("prepared_message_sent")}}const kc=new Qs;class Zs{onDataSend(e){return _().on("web_app_data_send",r=>{r&&e(r)})}onSwitchInlineQuery(e){return _().on("web_app_switch_inline_query",r=>{r&&e(r)})}}const Ec=new Zs;class Ys{onInvokeCustomMethod(e){return _().on("web_app_invoke_custom_method",r=>{r&&e(r)})}setCustomMethodInvoked(e){_().send("custom_method_invoked",e)}}const qc=new Ys;class Xs{onSend(e){return _().on("web_app_send_notification",r=>{r&&e(r)})}}const Ac=new Xs;class xs{setTheme(e){_().send("theme_changed",{theme_params:e})}onRequestTheme(e){return _().on("web_app_request_theme",()=>{e()})}}const Ic=new xs;function ei(t={}){const{version:e,isInlineMode:n,themeParams:r}=t;if(e&&typeof n=="boolean"&&r)pn.set(e),kn.set(n),Sn.set(r);else{const c=d(Re(),Ct(l=>l,l=>{pn.set(e||l.vbWebAppVersion),kn.set(typeof n=="boolean"?n:!!l.vbWebAppBotInline),Sn.set(r||l.vbWebAppThemeParams)}));if(c)return P(c)}t.postEvent&&Lr.set(t.postEvent);const[i,o]=Ge(X("reload_iframe",()=>{ce().log("Received a request to reload the page"),Vr("iframe_will_reload"),window.location.reload()})),{acceptCustomStyles:a=!0}=t;if(a){const c=document.createElement("style");c.id="telegram-custom-styles",document.head.appendChild(c),i(X("set_custom_style",l=>{c.innerHTML=l}),()=>{document.head.removeChild(c)})}return d(qe("iframe_ready",{reload_supported:!0}),J(()=>(ce().log("The package was initialized"),o)))}const Bc=re(ei);return u.AccessDeniedError=ln,u.BackButton=Tr,u.Biometry=jr,u.CSSVarsBoundError=ht,u.CancelledError=Un,u.ClosingBehavior=Dr,u.CloudStorage=Wr,u.ConcurrentCallError=ft,u.DeviceStorage=Nr,u.DeviceStorageMethodError=qr,u.FullscreenFailedError=Mr,u.FunctionUnavailableError=Br,u.HapticFeedback=Jr,u.HostBackButton=Is,u.HostBiometry=Vs,u.HostChat=Zs,u.HostClipboard=Ks,u.HostClosingBehavior=Gs,u.HostCustomMethod=Ys,u.HostEmojiStatus=Ws,u.HostFiles=Js,u.HostHapticFeedback=Ls,u.HostHomeScreen=Us,u.HostInvoice=Os,u.HostLink=Ds,u.HostLocationManager=Hs,u.HostMainButton=Bs,u.HostMiniApp=Ts,u.HostNotification=Xs,u.HostPopup=Ps,u.HostPrivacy=Ns,u.HostQrScanner=js,u.HostSecondaryButton=$s,u.HostSettingsButton=Ms,u.HostSharing=Qs,u.HostSwipeBehavior=zs,u.HostThemeParams=xs,u.HostViewport=Rs,u.InitData=Yr,u.InvalidArgumentsError=ie,u.InvalidEnvError=oa,u.InvalidLaunchParamsError=en,u.Invoice=Xr,u.InvokeCustomMethodFailedError=pr,u.LaunchParamsRetrieveError=lr,u.LocationManager=ts,u.MainButton=ns,u.MethodParameterUnsupportedError=cr,u.MethodUnsupportedError=ur,u.MiniApp=os,u.NotAvailableError=Ir,u.Notification=us,u.Popup=cs,u.QrScanner=ds,u.Refresh=hs,u.SecondaryButton=fs,u.SecureStorage=_s,u.SecureStorageMethodError=Ar,u.SetEmojiStatusError=$r,u.SettingsButton=bs,u.ShareMessageError=Pr,u.StoragePermission=As,u.SwipeBehavior=ms,u.ThemeParams=ss,u.TimeoutError=Gt,u.UnknownEnvError=tn,u.UnknownThemeParamsKeyError=Rr,u.ValidationError=Ze,u.Viewport=qs,u.addToHomeScreen=$a,u.addToHomeScreenFp=Qr,u.applyPolyfills=ta,u.backButton=la,u.biometry=fa,u.checkHomeScreenStatus=Ra,u.checkHomeScreenStatusFp=Zr,u.closingBehavior=ba,u.cloudStorage=ga,u.copyTextToClipboard=Iu,u.createLogger=Jn,u.createPostEvent=Xo,u.createRequestId=bt,u.createStartParam=ra,u.createStartParamFp=kr,u.debug=br,u.decodeBase64Url=na,u.decodeBase64UrlFp=un,u.decodeStartParam=sa,u.decodeStartParamFp=Er,u.deepSnakeToCamelObjKeys=zt,u.defineHostBridge=Zo,u.deviceStorage=va,u.downloadFile=Mu,u.downloadFileFp=gs,u.emitEvent=pt,u.encodeBase64Url=cn,u.getCurrentTime=Tu,u.getCurrentTimeFp=ws,u.getHostBridge=_,u.getReleaseVersion=an,u.hapticFeedback=Aa,u.hideKeyboard=Ou,u.hideKeyboardFp=vs,u.hostBackButton=ic,u.hostBiometry=hc,u.hostChat=Ec,u.hostClipboard=Fc,u.hostClosingBehavior=yc,u.hostCustomMethod=qc,u.hostEmojiStatus=gc,u.hostFiles=Cc,u.hostHapticFeedback=dc,u.hostHomeScreen=wc,u.hostInvoice=fc,u.hostLink=mc,u.hostLocationManager=bc,u.hostMainButton=oc,u.hostMiniApp=pc,u.hostNotification=Ac,u.hostPopup=cc,u.hostPrivacy=vc,u.hostQrScanner=_c,u.hostSecondaryButton=ac,u.hostSettingsButton=uc,u.hostSharing=kc,u.hostSwipeBehavior=Sc,u.hostThemeParams=Ic,u.hostViewport=lc,u.init=Bc,u.initData=La,u.initFp=ei,u.invoice=Oa,u.invokeCustomMethod=Ur,u.isAnyRGB=xn,u.isColorDark=yn,u.isColorDarkFp=rs,u.isRGB=Ke,u.isRGBA=Xn,u.isRGBAShort=Yn,u.isRGBShort=Zn,u.isSafeToCreateStartParam=ia,u.isVBma=Ko,u.isVBmaFp=on,u.locationManager=Za,u.logger=ce,u.mainButton=Xa,u.miniApp=as,u.mockVBotEnv=Jo,u.notification=nu,u.off=ke,u.offAll=No,u.on=X,u.openLink=Da,u.openLinkFp=xr,u.openVBotLink=Na,u.openVBotLinkFp=gn,u.parseInitDataQuery=Ro,u.parseInitDataQueryFp=sr,u.parseLaunchParamsQuery=Yt,u.parseLaunchParamsQueryFp=lt,u.popup=iu,u.postEvent=Vr,u.postEventFp=qe,u.qrScanner=wu,u.readTextFromClipboard=Du,u.readTextFromClipboardFp=ys,u.refresh=yu,u.request=pa,u.request2=da,u.request2Fp=_n,u.requestContact=fu,u.requestContactComplete=hu,u.requestContactCompleteFp=Cn,u.requestContactFp=ls,u.requestEmojiStatusAccess=Fa,u.requestEmojiStatusAccessFp=zr,u.requestFp=Hr,u.requestPhoneAccess=uu,u.requestPhoneAccessFp=Fn,u.requestWriteAccess=mu,u.requestWriteAccessFp=ps,u.retrieveAndroidDeviceData=Wu,u.retrieveAndroidDeviceDataFrom=Ss,u.retrieveLaunchParams=Lo,u.retrieveLaunchParamsFp=Re,u.retrieveRawInitData=Vo,u.retrieveRawInitDataFp=nn,u.retrieveRawLaunchParams=Oo,u.retrieveRawLaunchParamsFp=Je,u.secondaryButton=Fu,u.secureStorage=ku,u.sendData=Gu,u.sendDataFp=Fs,u.serializeInitDataQuery=or,u.serializeLaunchParamsQuery=Xt,u.setDebug=Ho,u.setEmojiStatus=Ea,u.setEmojiStatusFp=Kr,u.setLaunchParams=Qo,u.setTargetOrigin=Do,u.settingsButton=Eu,u.shareMessage=Ju,u.shareMessageFp=Cs,u.shareStory=Yu,u.shareStoryFp=ks,u.shareURL=Ka,u.shareURLFp=es,u.storagePermission=sc,u.supports=_e,u.swipeBehavior=Au,u.switchInlineQuery=ec,u.switchInlineQueryFp=Es,u.targetOrigin=mr,u.themeParams=Xe,u.toRGB=qo,u.toRGBFp=tr,u.toRGBFull=Ao,u.toRGBFullFp=ct,u.viewport=nc,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"}),u})({});
4
4
  //# sourceMappingURL=index.iife.js.map