@tma.js/sdk 3.1.2 → 3.1.4

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.
@@ -3,49 +3,49 @@ declare const ValidationError_base: import('error-kid').ErrorClassWithData<[inpu
3
3
  input: unknown;
4
4
  issues: BaseIssue<any>[];
5
5
  }>;
6
- export declare class ValidationError extends ValidationError_base {
6
+ export declare class ValidationError extends /* #__PURE__ */ ValidationError_base {
7
7
  }
8
8
  declare const CSSVarsBoundError_base: import('error-kid').ErrorClass<[]>;
9
- export declare class CSSVarsBoundError extends CSSVarsBoundError_base {
9
+ export declare class CSSVarsBoundError extends /* #__PURE__ */ CSSVarsBoundError_base {
10
10
  }
11
11
  declare const DeviceStorageMethodError_base: import('error-kid').ErrorClassWithData<[error: string], {
12
12
  error: string;
13
13
  }>;
14
- export declare class DeviceStorageMethodError extends DeviceStorageMethodError_base {
14
+ export declare class DeviceStorageMethodError extends /* #__PURE__ */ DeviceStorageMethodError_base {
15
15
  }
16
16
  declare const SecureStorageMethodError_base: import('error-kid').ErrorClassWithData<[error: string], {
17
17
  error: string;
18
18
  }>;
19
- export declare class SecureStorageMethodError extends SecureStorageMethodError_base {
19
+ export declare class SecureStorageMethodError extends /* #__PURE__ */ SecureStorageMethodError_base {
20
20
  }
21
21
  declare const NotAvailableError_base: import('error-kid').ErrorClass<[message: string]>;
22
- export declare class NotAvailableError extends NotAvailableError_base {
22
+ export declare class NotAvailableError extends /* #__PURE__ */ NotAvailableError_base {
23
23
  }
24
24
  declare const InvalidEnvError_base: import('error-kid').ErrorClass<[message?: string | undefined]>;
25
- export declare class InvalidEnvError extends InvalidEnvError_base {
25
+ export declare class InvalidEnvError extends /* #__PURE__ */ InvalidEnvError_base {
26
26
  }
27
27
  declare const FunctionUnavailableError_base: import('error-kid').ErrorClass<[message?: string | undefined]>;
28
- export declare class FunctionUnavailableError extends FunctionUnavailableError_base {
28
+ export declare class FunctionUnavailableError extends /* #__PURE__ */ FunctionUnavailableError_base {
29
29
  }
30
30
  declare const InvalidArgumentsError_base: import('error-kid').ErrorClass<[message: string, cause?: unknown]>;
31
- export declare class InvalidArgumentsError extends InvalidArgumentsError_base {
31
+ export declare class InvalidArgumentsError extends /* #__PURE__ */ InvalidArgumentsError_base {
32
32
  }
33
33
  declare const ConcurrentCallError_base: import('error-kid').ErrorClass<[message: string]>;
34
- export declare class ConcurrentCallError extends ConcurrentCallError_base {
34
+ export declare class ConcurrentCallError extends /* #__PURE__ */ ConcurrentCallError_base {
35
35
  }
36
36
  declare const SetEmojiStatusError_base: import('error-kid').ErrorClass<[error: string]>;
37
- export declare class SetEmojiStatusError extends SetEmojiStatusError_base {
37
+ export declare class SetEmojiStatusError extends /* #__PURE__ */ SetEmojiStatusError_base {
38
38
  }
39
39
  declare const AccessDeniedError_base: import('error-kid').ErrorClass<[message: string]>;
40
- export declare class AccessDeniedError extends AccessDeniedError_base {
40
+ export declare class AccessDeniedError extends /* #__PURE__ */ AccessDeniedError_base {
41
41
  }
42
42
  declare const FullscreenFailedError_base: import('error-kid').ErrorClass<[message: string]>;
43
- export declare class FullscreenFailedError extends FullscreenFailedError_base {
43
+ export declare class FullscreenFailedError extends /* #__PURE__ */ FullscreenFailedError_base {
44
44
  }
45
45
  declare const ShareMessageError_base: import('error-kid').ErrorClass<[error: string]>;
46
- export declare class ShareMessageError extends ShareMessageError_base {
46
+ export declare class ShareMessageError extends /* #__PURE__ */ ShareMessageError_base {
47
47
  }
48
48
  declare const UnknownThemeParamsKeyError_base: import('error-kid').ErrorClass<[key: string]>;
49
- export declare class UnknownThemeParamsKeyError extends UnknownThemeParamsKeyError_base {
49
+ export declare class UnknownThemeParamsKeyError extends /* #__PURE__ */ UnknownThemeParamsKeyError_base {
50
50
  }
51
51
  export {};
@@ -25,7 +25,7 @@ export * from './features/Viewport/exports.js';
25
25
  export { createRequestId } from './globals/createRequestId.js';
26
26
  export { invokeCustomMethod } from './globals/invokeCustomMethod.js';
27
27
  export { postEvent, postEventFp } from './globals/postEvent.js';
28
- export { request, requestFp } from './globals/request.js';
28
+ export { request, requestFp, request2, request2Fp } from './globals/request.js';
29
29
  export { isColorDark, isColorDarkFp } from './helpers/isColorDark.js';
30
30
  export * from './errors.js';
31
31
  export { init, initFp, type InitOptions } from './init.js';
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var fr=Object.defineProperty;var mr=(r,t,s)=>t in r?fr(r,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[t]=s;var e=(r,t,s)=>mr(r,typeof t!="symbol"?t+"":t,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("@tma.js/signals"),d=require("@tma.js/bridge"),V=require("@tma.js/toolkit"),_r=require("better-promises"),x=require("@tma.js/transformers"),Q=require("error-kid"),E=require("valibot");var br=function(r,t,s){if(s||arguments.length===2)for(var n=0,i=t.length,o;n<i;n++)(o||!(n in t))&&(o||(o=Array.prototype.slice.call(t,0,n)),o[n]=t[n]);return r.concat(o||Array.prototype.slice.call(t))};function nt(r,t,s,n,i,o,u,a,l){switch(arguments.length){case 1:return r;case 2:return function(){return t(r.apply(this,arguments))};case 3:return function(){return s(t(r.apply(this,arguments)))};case 4:return function(){return n(s(t(r.apply(this,arguments))))};case 5:return function(){return i(n(s(t(r.apply(this,arguments)))))};case 6:return function(){return o(i(n(s(t(r.apply(this,arguments))))))};case 7:return function(){return u(o(i(n(s(t(r.apply(this,arguments)))))))};case 8:return function(){return a(u(o(i(n(s(t(r.apply(this,arguments))))))))};case 9:return function(){return l(a(u(o(i(n(s(t(r.apply(this,arguments)))))))))}}}function c(r,t,s,n,i,o,u,a,l){switch(arguments.length){case 1:return r;case 2:return t(r);case 3:return s(t(r));case 4:return n(s(t(r)));case 5:return i(n(s(t(r))));case 6:return o(i(n(s(t(r)))));case 7:return u(o(i(n(s(t(r))))));case 8:return a(u(o(i(n(s(t(r)))))));case 9:return l(a(u(o(i(n(s(t(r))))))));default:{for(var p=arguments[0],b=1;b<arguments.length;b++)p=arguments[b](p);return p}}}var de=function(r,t){var s=typeof r=="number"?function(n){return n.length>=r}:r;return function(){var n=Array.from(arguments);return s(arguments)?t.apply(this,n):function(i){return t.apply(void 0,br([i],n,!1))}}},gr={_tag:"None"},Fr=function(r){return{_tag:"Some",value:r}},wr=function(r){return r._tag==="Left"},ot=function(r){return{_tag:"Left",left:r}},it=function(r){return{_tag:"Right",right:r}},Me={};function Cr(r,t){return function(s){return function(n){return r.ap(r.map(n,function(i){return function(o){return t.ap(i,o)}}),s)}}}function Sr(r,t){return function(s){return function(n){return r.map(n,function(i){return t.map(i,s)})}}}function xe(r){return function(t,s){return function(n){return r.chain(n,function(i){return r.map(s(i),function(o){var u;return Object.assign({},i,(u={},u[t]=o,u))})})}}}var O=ot,q=it,vr=de(2,function(r,t){return ne(r)?r:t(r.right)}),Te=function(r,t){return c(r,H(t))},at=function(r,t){return c(r,Ir(t))},Re="Either",H=function(r){return function(t){return ne(t)?t:q(r(t.right))}},yr={URI:Re,map:Te},kr=q,Er=function(r){return function(t){return ne(t)?t:ne(r)?r:q(t.right(r.right))}},Ir=Er,Ar={URI:Re,map:Te,ap:at},Br={URI:Re,map:Te,ap:at,chain:vr},Pr=function(r,t){return function(s){return ne(s)?O(r(s.left)):q(t(s.right))}},ne=wr,ut=function(r,t){return function(s){return ne(s)?r(s.left):t(s.right)}},fe=ut,qr=function(r,t){try{return q(r())}catch(s){return O(t(s))}},Mr=kr(Me),xr=xe(Br),tt=xr;function W(r){return typeof r=="function"?r():r}class me{constructor({onMounted:t,restoreState:s,initialState:n,onUnmounted:i,isPageReload:o}){e(this,"_isMounted",g.signal(!1));e(this,"isMounted",g.computed(this._isMounted));e(this,"mount");e(this,"unmount");this.mount=()=>{if(this.isMounted())return q(void 0);const u=W(o)?s():void 0,a=u?q(u):typeof n=="function"?n():q(n);return c(a,H(l=>{g.batch(()=>{this._isMounted.set(!0),t==null||t(l)})}))},this.unmount=()=>{this._isMounted()&&g.batch(()=>{this._isMounted.set(!1),i==null||i()})}}}function Ae(r){const t={};for(const s in r){const n=r[s];n!==void 0&&(t[s]=n)}return t}function ke(r,t){const s=Object.keys(r),n=Object.keys(t);return s.length!==n.length?!1:s.every(i=>Object.prototype.hasOwnProperty.call(t,i)&&r[i]===t[i])}class te{constructor({initialState:t,onChange:s}){e(this,"_state");e(this,"state");e(this,"setState",t=>{const s={...this.state(),...Ae(t)};ke(s,this.state())||this._state.set(s)});this._state=g.signal(t,{equals:ke}),this.state=g.computed(this._state),this.state.sub(s)}getter(t){return g.computed(()=>this._state()[t])}hasDiff(t){return!ke({...this.state(),...Ae(t)},this.state())}}function Z(r,t){return g.computed(()=>d.supports(r,W(t)))}var ae=gr,_e=Fr,Tr=function(r,t){return c(r,Lr(t))},Rr=function(r,t){return c(r,$r(t))},Or="Option",Lr=function(r){return function(t){return le(t)?ae:_e(r(t.value))}},Vr=_e,$r=function(r){return function(t){return le(t)||le(r)?ae:_e(t.value(r.value))}},jr=de(2,function(r,t){return le(r)?ae:t(r.value)}),Dr={URI:Or,map:Tr,ap:Rr,chain:jr},le=function(r){return r._tag==="None"},Ur=function(r,t){return function(s){return le(s)?r():t(s.value)}},ct=Ur,Gr=Vr(Me),rt=xe(Dr);function h(r){return Object.assign(V.throwifyFpFn(r),{ifAvailable(...t){return c(r.ifAvailable(...t),ct(()=>({ok:!1}),s=>({ok:!0,data:V.throwifyAnyEither(s)})))}})}function Hr(r){return nt(q,r.of)}function Wr(r){return nt(O,r.of)}function Qr(r){return Sr(r,yr)}function Kr(r){return Cr(r,Ar)}function Nr(r){return function(t,s){return r.chain(t,function(n){return ne(n)?r.of(n):s(n.right)})}}function zr(r){return function(t,s,n){return r.map(t,Pr(s,n))}}function Jr(r){return function(t,s){return function(n){return r.map(n,fe(t,s))}}}var Oe=function(r,t){return c(r,Yr(t))},pt=function(r,t){return c(r,Zr(t))},Yr=function(r){return function(t){return function(){return Promise.resolve().then(t).then(r)}}},Zr=function(r){return function(t){return function(){return Promise.all([Promise.resolve().then(t),Promise.resolve().then(r)]).then(function(s){var n=s[0],i=s[1];return n(i)})}}},Le=function(r){return function(){return Promise.resolve(r)}},Xr=de(2,function(r,t){return function(){return Promise.resolve().then(r).then(function(s){return t(s)()})}}),Ve="Task",$e={URI:Ve,map:Oe},lt={of:Le},es={URI:Ve,map:Oe,ap:pt},ts={URI:Ve,map:Oe,of:Le,ap:pt,chain:Xr},rs=function(r,t,s,n){function i(o){return o instanceof s?o:new s(function(u){u(o)})}return new(s||(s=Promise))(function(o,u){function a(b){try{p(n.next(b))}catch(f){u(f)}}function l(b){try{p(n.throw(b))}catch(f){u(f)}}function p(b){b.done?o(b.value):i(b.value).then(a,l)}p((n=n.apply(r,t||[])).next())})},ss=function(r,t){var s={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,u;return u={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function a(p){return function(b){return l([p,b])}}function l(p){if(n)throw new TypeError("Generator is already executing.");for(;u&&(u=0,p[0]&&(s=0)),s;)try{if(n=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 s.label++,{value:p[1],done:!1};case 5:s.label++,i=p[1],p=[0];continue;case 7:p=s.ops.pop(),s.trys.pop();continue;default:if(o=s.trys,!(o=o.length>0&&o[o.length-1])&&(p[0]===6||p[0]===2)){s=0;continue}if(p[0]===3&&(!o||p[1]>o[0]&&p[1]<o[3])){s.label=p[1];break}if(p[0]===6&&s.label<o[1]){s.label=o[1],o=p;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(p);break}o[2]&&s.ops.pop(),s.trys.pop();continue}p=t.call(r,s)}catch(b){p=[6,b],i=0}finally{n=o=0}if(p[0]&5)throw p[1];return{value:p[0]?p[1]:void 0,done:!0}}},L=Wr(lt),M=Hr(lt),ht=Le,ns=Jr($e),os=function(r,t){return function(){return rs(void 0,void 0,void 0,function(){var s;return ss(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,r().then(it)];case 1:return[2,n.sent()];case 2:return s=n.sent(),[2,ot(t(s))];case 3:return[2]}})})}},is=function(r,t){return c(r,I(t))},as=function(r,t){return c(r,us(t))},I=Qr($e),je=de(3,zr($e)),us=Kr(es),De=de(2,Nr(ts)),cs=M,ps="TaskEither",ls={URI:ps,map:is,ap:as,chain:De},hs=cs(Me),ds=xe(ls),we=ds,J=De,ue=De;function oe(r){return[r]}class pe extends Q.errorClassWithData("ValidationError",(t,s)=>({input:t,issues:s}),"Validation error"){}class Ce extends Q.errorClass("CSSVarsBoundError","CSS variables are already bound"){}class dt extends Q.errorClassWithData("DeviceStorageMethodError",t=>({error:t}),t=>[t]){}class ft extends Q.errorClassWithData("SecureStorageMethodError",t=>({error:t}),t=>[t]){}class mt extends Q.errorClass("NotAvailableError",oe){}class fs extends Q.errorClass("InvalidEnvError",oe){}class _t extends Q.errorClass("FunctionNotAvailableError",oe){}class z extends Q.errorClass("InvalidArgumentsError",(t,s)=>[t,{cause:s}]){}class Se extends Q.errorClass("ConcurrentCallError",oe){}class bt extends Q.errorClass("SetEmojiStatusError",t=>[`Failed to set emoji status: ${t}`]){}class Ue extends Q.errorClass("AccessDeniedError",oe){}class gt extends Q.errorClass("FullscreenFailedError",oe){}class Ft extends Q.errorClass("ShareMessageError",oe){}class wt extends Q.errorClass("UnknownThemeParamsKeyError",t=>[`Unknown theme params key passed: ${t}`]){}function P(r,t){const s=g.computed(()=>W(t.version)||"100"),n=g.computed(()=>W(t.isTma)),{requires:i,returns:o}=t,u=i?typeof i=="object"?i:{every:[i]}:void 0,a=_=>{if(!t.supports)return!0;const F=t.supports[_];return d.supports(F.method,F.param,s())},l=()=>{if(!u)return;const[_,F]="every"in u?["every",u.every]:["some",u.some];for(let m=0;m<F.length;m++){const T=F[m],D=typeof T=="function"?T():d.supports(T,s())?void 0:`it is unsupported in Mini Apps version ${s()}`;if(D&&(_==="every"||m===F.length-1))return D}},p=(..._)=>{for(const F in t.supports)if(t.supports[F].shouldCheck(..._)&&!a(F))return`option ${F} is not supported in Mini Apps version ${s()}`},b=g.computed(()=>!l()),f=g.computed(()=>s()!=="0.0"),C=g.computed(()=>t.isMounted?t.isMounted():!0),w=g.computed(()=>n()&&f()&&b()&&C()),v=_=>{const F=new _t(_);return["task","promise"].includes(t.returns)?L(F):O(F)},y=(..._)=>o==="plain"?qr(()=>r(..._),F=>F):o==="promise"?os(()=>r(..._),F=>F):r(..._);return Object.assign((..._)=>{var D;const F="Unable to call function:";if(!n())return v(`${F} it can't be called outside Mini Apps`);if(!f())return v(`${F} the SDK was not initialized. Use the SDK init() function`);const m=l();if(m)return v(`${F} ${m}`);const T=p(..._);if(T)return v(`${F} ${T}`);if(!C()){const $=(D=t.isMounting)!=null&&D.call(t)?"mounting. Wait for the mount completion":"unmounted. Use the mount() method";return v(`${F} the component is ${$}`)}return y(..._)},r,{isAvailable:w,ifAvailable(..._){return w()?_e(y(..._)):ae}},u?{isSupported:b}:{},t.supports?{supports:a}:{})}function A(r){return t=>P(t,r)}class ve{constructor({isTma:t,storage:s,onClick:n,offClick:i,initialState:o,isPageReload:u,postEvent:a,payload:l,method:p,version:b}){e(this,"isMounted");e(this,"isSupported");e(this,"state");e(this,"stateSetters");e(this,"stateBoolSetters");e(this,"setStateFp");e(this,"setState");e(this,"onClickFp");e(this,"onClick");e(this,"offClickFp");e(this,"offClick");e(this,"mountFp");e(this,"mount");e(this,"unmount");const f=new te({initialState:o,onChange(_){s.set(_)}}),C=new me({initialState:o,isPageReload:u,onMounted:f.setState,restoreState:s.get}),w={version:b,requires:p,isTma:t},v=A({...w,returns:"plain"}),y=A({...w,returns:"either",isMounted:C.isMounted});this.isMounted=C.isMounted,this.isSupported=Z(p,b),this.state=f.state,this.setStateFp=y(_=>{const F={...this.state(),...Ae(_)};return f.hasDiff(F)?c(a(p,l(F)),H(()=>{f.setState(F)})):q(void 0)}),this.setState=h(this.setStateFp),this.onClickFp=v(n),this.onClick=h(this.onClickFp),this.offClickFp=v(i),this.offClick=h(this.offClickFp),this.mountFp=v(()=>{const _=()=>{};return c(C.mount(),fe(_,_))}),this.mount=h(this.mountFp),this.unmount=C.unmount,this.stateSetters=_=>{const F=y(m=>this.setStateFp({[_]:m}));return[h(F),F]},this.stateBoolSetters=_=>{const[,F]=this.stateSetters(_),m=y(()=>F(!1)),T=y(()=>F(!0));return[[h(m),m],[h(T),T]]}}stateGetter(t){return g.computed(()=>this.state()[t])}}class Ct{constructor(t){e(this,"isVisible");e(this,"isMounted");e(this,"isSupported");e(this,"hideFp");e(this,"hide");e(this,"showFp");e(this,"show");e(this,"onClickFp");e(this,"onClick");e(this,"offClickFp");e(this,"offClick");e(this,"mountFp");e(this,"mount");e(this,"unmount");const s=new ve({...t,method:"web_app_setup_back_button",payload:n=>({is_visible:n.isVisible}),initialState:{isVisible:!1}});this.isVisible=s.stateGetter("isVisible"),this.isMounted=s.isMounted,this.isSupported=s.isSupported,[[this.hide,this.hideFp],[this.show,this.showFp]]=s.stateBoolSetters("isVisible"),this.onClick=s.onClick,this.onClickFp=s.onClickFp,this.offClick=s.offClick,this.offClickFp=s.offClickFp,this.mount=s.mount,this.mountFp=s.mountFp,this.unmount=s.unmount}}function S(){return{isTma:g.computed(()=>d.isTMAFp())}}function ce(r){return t=>({...t,...W(r)})}function be(r,t){return g.signal(r,t)}const St=be(d.postEventFp),ie=(...r)=>St()(...r),vt=(...r)=>V.throwifyAnyEither(ie(...r)),j=ce({postEvent:ie});function ms(r){return{get:()=>V.getStorageValue(r),set(t){V.setStorageValue(r,t)}}}function _s(){return performance.getEntriesByType("navigation")[0]}function bs(){const r=_s();return!!r&&r.type==="reload"}function re(r){return ce({storage:ms(r),isPageReload:bs})}const Be=be("0.0"),k=ce({version:Be});function Ge(r,t){return{...c(S(),j,k,re(r)),onClick(s,n){return d.on(t,s,n)},offClick(s,n){d.off(t,s,n)}}}const gs=new Ct(Ge("backButton","back_button_pressed"));class He{constructor({initialState:t,onMounted:s,restoreState:n,onUnmounted:i,isPageReload:o}){e(this,"_isMounted",g.signal(!1));e(this,"isMounted",g.computed(this._isMounted));e(this,"mount");e(this,"unmount");this.mount=u=>{if(this._isMounted())return M(void 0);const a=W(o)?n():void 0;return c(a?M(a):t(u),I(l=>{this._isMounted()||g.batch(()=>{this._isMounted.set(!0),s==null||s(l)})}))},this.unmount=()=>{this._isMounted()&&g.batch(()=>{this._isMounted.set(!1),i==null||i()})}}}const st=new mt("Biometry is not available");function Ee(r){let t=!1,s=!1,n="",i=!1,o="",u=!1;return r.available&&(t=!0,s=r.token_saved,n=r.device_id,i=r.access_requested,o=r.type,u=r.access_granted),{available:t,tokenSaved:s,deviceId:n,type:o,accessGranted:u,accessRequested:i}}class yt{constructor({version:t,request:s,postEvent:n,storage:i,onInfoReceived:o,offInfoReceived:u,isTma:a,isPageReload:l}){e(this,"isAvailable");e(this,"isSupported");e(this,"isMounted");e(this,"state");e(this,"authenticateFp");e(this,"authenticate");e(this,"openSettingsFp");e(this,"openSettings");e(this,"requestAccessFp");e(this,"requestAccess");e(this,"updateTokenFp");e(this,"updateToken");e(this,"mountFp");e(this,"mount");e(this,"unmount");const p=_=>{b.setState(Ee(_))},b=new te({initialState:{available:!1,type:"unknown",accessGranted:!1,accessRequested:!1,deviceId:"",tokenSaved:!1},onChange:i.set}),f=new He({initialState(_){return c(s("web_app_biometry_get_info","biometry_info_received",_),I(Ee))},isPageReload:l,onMounted(_){b.setState(_),o(p)},onUnmounted(){u(p)},restoreState:i.get}),C={version:t,requires:"web_app_biometry_request_auth",isTma:a},w=A({...C,returns:"either"}),v=A({...C,returns:"task"}),y=A({...C,isMounted:f.isMounted,returns:"task"});this.isAvailable=b.getter("available"),this.isMounted=f.isMounted,this.isSupported=Z("web_app_biometry_request_auth",t),this.state=b.state,this.unmount=f.unmount,this.mountFp=v(f.mount),this.authenticateFp=y(_=>this.isAvailable()?c(s("web_app_biometry_request_auth","biometry_auth_requested",{..._,params:{reason:((_||{}).reason||"").trim()}}),I(F=>(b.setState({token:F.token}),F))):L(st)),this.openSettingsFp=w(()=>n("web_app_biometry_open_settings")),this.requestAccessFp=y(_=>c(s("web_app_biometry_request_access","biometry_info_received",{..._,params:{reason:((_||{}).reason||"").trim()}}),J(F=>{const m=Ee(F);return m.available?(b.setState(m),M(m.accessRequested)):L(st)}))),this.updateTokenFp=y((_={})=>{var F;return c(s("web_app_biometry_update_token","biometry_token_updated",{..._,params:{token:_.token||"",reason:(F=_.reason)==null?void 0:F.trim()}}),I(m=>m.status))}),this.authenticate=h(this.authenticateFp),this.openSettings=h(this.openSettingsFp),this.requestAccess=h(this.requestAccessFp),this.updateToken=h(this.updateTokenFp),this.mount=h(this.mountFp)}}const kt=(r,t,s)=>d.requestFp(r,t,{postEvent:ie,...s}),Fs=(r,t,s)=>d.request2Fp(r,t,{postEvent:ie,...s}),ws=(...r)=>_r.BetterPromise.fn(()=>kt(...r)()),U=ce({request:Fs}),Cs=new yt({...c(S(),j,k,U,re("biometry")),offInfoReceived(r){d.off("biometry_info_received",r)},onInfoReceived(r){return d.on("biometry_info_received",r)}});class Et{constructor({postEvent:t,storage:s,isTma:n,isPageReload:i}){e(this,"isConfirmationEnabled");e(this,"isMounted");e(this,"mountFp");e(this,"mount");e(this,"unmount");e(this,"disableConfirmationFp");e(this,"disableConfirmation");e(this,"enableConfirmationFp");e(this,"enableConfirmation");const o=new te({initialState:{isConfirmationEnabled:!1},onChange(f){s.set(f)}}),u=new me({onMounted:o.setState,restoreState:s.get,initialState:{isConfirmationEnabled:!1},isPageReload:i}),a={requires:"web_app_setup_closing_behavior",isTma:n},l=A({...a,returns:"plain"}),p=A({...a,returns:"either",isMounted:u.isMounted}),b=f=>f===this.isConfirmationEnabled()?q(void 0):(o.setState({isConfirmationEnabled:f}),t("web_app_setup_closing_behavior",{need_confirmation:f}));this.isConfirmationEnabled=o.getter("isConfirmationEnabled"),this.isMounted=u.isMounted,this.disableConfirmationFp=p(()=>b(!1)),this.enableConfirmationFp=p(()=>b(!0)),this.mountFp=l(()=>{const f=()=>{};return c(u.mount(),fe(f,f))}),this.unmount=u.unmount,this.disableConfirmation=h(this.disableConfirmationFp),this.enableConfirmation=h(this.enableConfirmationFp),this.mount=h(this.mountFp)}}const Ss=new Et(c(S(),re("closingBehavior"),j));class It{constructor({version:t,isTma:s,invokeCustomMethod:n}){e(this,"isSupported");e(this,"deleteItemFp");e(this,"deleteItem");e(this,"getItemFp");e(this,"getItem");e(this,"getItemsFp");e(this,"getItems");e(this,"getKeysFp");e(this,"getKeys");e(this,"setItemFp");e(this,"setItem");e(this,"clearFp");e(this,"clear");const i=A({version:t,requires:"web_app_invoke_custom_method",isTma:s,returns:"task"});this.isSupported=Z("web_app_invoke_custom_method",t),this.deleteItemFp=i((o,u)=>{const a=Array.isArray(o)?o:[o];return c(a.length?n("deleteStorageValues",{keys:a},u):M(void 0),I(()=>{}))}),this.getItemFp=i((o,u)=>c(this.getItemsFp([o],u),I(a=>a[o]||""))),this.getItemsFp=i((o,u)=>c(o.length?n("getStorageValues",{keys:o},u):M({}),I(a=>({...o.reduce((l,p)=>(l[p]="",l),{}),...E.parse(E.record(E.string(),E.string()),a)})))),this.getKeysFp=i(o=>c(n("getStorageKeys",{},o),I(u=>E.parse(E.array(E.string()),u)))),this.setItemFp=i((o,u,a)=>c(n("saveStorageValue",{key:o,value:u},a),I(()=>{}))),this.clearFp=i(o=>c(this.getKeysFp(o),J(this.deleteItemFp))),this.deleteItem=h(this.deleteItemFp),this.getItem=h(this.getItemFp),this.getItems=h(this.getItemsFp),this.getKeys=h(this.getKeysFp),this.setItem=h(this.setItemFp),this.clear=h(this.clearFp)}}const Ie=be(0);function ye(){return Ie.set(Ie()+1),Ie().toString()}function At(r,t,s){return d.invokeCustomMethodFp(r,t,ye(),{...s||{},postEvent:ie})}const We=ce({invokeCustomMethod:At}),vs=new It(c(S(),k,We));class Bt{constructor({isTma:t,request:s,version:n,createRequestId:i}){e(this,"getItemFp");e(this,"getItem");e(this,"setItemFp");e(this,"setItem");e(this,"deleteItemFp");e(this,"deleteItem");e(this,"clearFp");e(this,"clear");const o=A({version:n,requires:"web_app_device_storage_get_key",isTma:t,returns:"task"}),u=(a,l,p)=>{const b=i();return c(s(a,["device_storage_failed",l],{params:{...p,req_id:b},capture:f=>"payload"in f?f.payload.req_id===b:!0}),J(f=>f.event==="device_storage_failed"?L(new dt(f.payload.error||"UNKNOWN_ERROR")):M(f.payload)))};this.getItemFp=o(a=>c(u("web_app_device_storage_get_key","device_storage_key_received",{key:a}),I(l=>l.value))),this.setItemFp=o((a,l)=>c(u("web_app_device_storage_save_key","device_storage_key_saved",{key:a,value:l}),I(()=>{}))),this.deleteItemFp=o(a=>this.setItemFp(a,null)),this.clearFp=o(()=>c(u("web_app_device_storage_clear","device_storage_cleared",{}),I(()=>{}))),this.getItem=h(this.getItemFp),this.setItem=h(this.setItemFp),this.deleteItem=h(this.deleteItemFp),this.clear=h(this.clearFp)}}const Pt=ce({createRequestId:ye}),ys=new Bt(c(S(),k,U,Pt));function ks({request:r,...t}){return P(s=>c(r("web_app_request_emoji_status_access","emoji_status_access_requested",s),I(n=>n.status)),{...t,requires:"web_app_request_emoji_status_access",returns:"task"})}const qt=ks(c(S(),k,U)),Es=h(qt);function Is({request:r,...t}){return P((s,n)=>c(r("web_app_set_emoji_status",["emoji_status_set","emoji_status_failed"],{params:{custom_emoji_id:s,duration:(n||{}).duration},...n}),ue(i=>i.event==="emoji_status_failed"?L(new bt(i.payload.error)):M(void 0))),{...t,requires:"web_app_set_emoji_status",returns:"task"})}const Mt=Is(c(S(),U,k)),As=h(Mt);class xt{constructor({postEvent:t,isTma:s,version:n}){e(this,"isSupported");e(this,"impactOccurredFp");e(this,"impactOccurred");e(this,"notificationOccurredFp");e(this,"notificationOccurred");e(this,"selectionChangedFp");e(this,"selectionChanged");const i="web_app_trigger_haptic_feedback",o=A({requires:i,isTma:s,version:n,returns:"plain"});this.isSupported=Z(i,n),this.impactOccurredFp=o(u=>t(i,{type:"impact",impact_style:u})),this.notificationOccurredFp=o(u=>t(i,{type:"notification",notification_type:u})),this.selectionChangedFp=o(()=>t(i,{type:"selection_change"})),this.impactOccurred=h(this.impactOccurredFp),this.notificationOccurred=h(this.notificationOccurredFp),this.selectionChanged=h(this.selectionChangedFp)}}const Bs=new xt(c(S(),j,k));function Ps({postEvent:r,...t}){return P(()=>r("web_app_add_to_home_screen"),{...t,requires:"web_app_add_to_home_screen",returns:"either"})}const Tt=Ps(c(S(),k,j)),qs=h(Tt);function Ms({request:r,...t}){return P(s=>c(r("web_app_check_home_screen","home_screen_checked",s),I(n=>n.status||"unknown")),{...t,requires:"web_app_check_home_screen",returns:"task"})}const Rt=Ms(c(S(),k,U)),xs=h(Rt);class Ot{constructor({retrieveInitData:t}){e(this,"_state",g.signal());e(this,"_raw",g.signal());e(this,"state",g.computed(this._state));e(this,"authDate",this.fromState("auth_date"));e(this,"canSendAfter",this.fromState("can_send_after"));e(this,"canSendAfterDate",g.computed(()=>{const t=this.authDate(),s=this.canSendAfter();return s&&t?new Date(t.getTime()+s*1e3):void 0}));e(this,"chat",this.fromState("chat"));e(this,"chatType",this.fromState("chat_type"));e(this,"chatInstance",this.fromState("chat_instance"));e(this,"hash",this.fromState("hash"));e(this,"queryId",this.fromState("query_id"));e(this,"raw",g.computed(this._raw));e(this,"receiver",this.fromState("receiver"));e(this,"signature",this.fromState("signature"));e(this,"startParam",this.fromState("start_param"));e(this,"user",this.fromState("user"));e(this,"restoreFp");e(this,"restore");this.restoreFp=()=>c(t(),H(ct(()=>{},({raw:s,obj:n})=>{this._state.set(n),this._raw.set(s)}))),this.restore=V.throwifyFpFn(this.restoreFp)}fromState(t){return g.computed(()=>{const s=this._state();return s?s[t]:void 0})}}const Ts=new Ot({retrieveInitData(){return c(Mr,tt("obj",()=>c(d.retrieveLaunchParamsFp(),H(({tgWebAppData:r})=>r?_e(r):ae))),tt("raw",d.retrieveRawInitDataFp),H(({obj:r,raw:t})=>c(Gr,rt("obj",()=>r),rt("raw",()=>t))))}});class Lt{constructor({version:t,request:s,isTma:n}){e(this,"isOpened");e(this,"isSupported");e(this,"openSlugFp");e(this,"openSlug");e(this,"openUrlFp");e(this,"openUrl");const i=A({version:t,isTma:n,requires:"web_app_open_invoice",returns:"task"}),o=g.signal(!1),u=()=>{o.set(!1)};this.isSupported=Z("web_app_open_invoice",t),this.isOpened=g.computed(o),this.openSlugFp=i((a,l)=>c(this.isOpened()?L(new Se("Invoice is already opened")):M(void 0),J(()=>(o.set(!0),s("web_app_open_invoice","invoice_closed",{...l,params:{slug:a},capture:p=>a===p.slug}))),je(p=>(u(),p),p=>(u(),p.status)))),this.openUrlFp=i((a,l)=>{const{hostname:p,pathname:b}=new URL(a,window.location.href);if(p!=="t.me")return L(new z(`Link has unexpected hostname: ${p}`));const f=b.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);return f?this.openSlugFp(f[2],l):L(new z('Expected to receive a link with a pathname in format "/invoice/{slug}" or "/${slug}"'))}),this.openUrl=h(this.openUrlFp),this.openSlug=h(this.openSlugFp)}}const Rs=new Lt(c(S(),U,k));function Os({postEvent:r,...t}){return P((s,n={})=>{if(typeof s=="string")try{s=new URL(s)}catch(i){return O(new z(`"${s.toString()}" is invalid URL`,i))}return r("web_app_open_link",{url:s.toString(),try_browser:n.tryBrowser,try_instant_view:n.tryInstantView})},{...t,returns:"either"})}const Vt=Os(c(S(),j)),Ls=h(Vt);function Vs({postEvent:r,version:t,...s}){return P(n=>{const i=n.toString();return i.match(/^https:\/\/t.me\/.+/)?d.supports("web_app_open_tg_link",W(t))?(n=new URL(n),r("web_app_open_tg_link",{path_full:n.pathname+n.search})):(window.location.href=i,q(void 0)):O(new z(`"${i}" is invalid URL`))},{...s,returns:"either"})}const Qe=Vs(c(S(),j,k)),$s=h(Qe);function js({openTelegramLink:r,...t}){return P((s,n)=>r("https://t.me/share/url?"+new URLSearchParams({url:s,text:n||""}).toString().replace(/\+/g,"%20")),{...t,returns:"either"})}const $t=js({...S(),openTelegramLink:Qe}),Ds=h($t);function Us(r){let t=!1,s,n;return r.available&&(t=!0,s=r.access_requested,n=r.access_granted),{available:t,accessGranted:n||!1,accessRequested:s||!1}}class jt{constructor({version:t,request:s,postEvent:n,storage:i,isTma:o,isPageReload:u}){e(this,"state");e(this,"isAvailable");e(this,"isAccessGranted");e(this,"isAccessRequested");e(this,"isMounted");e(this,"isSupported");e(this,"openSettingsFp");e(this,"openSettings");e(this,"requestLocationFp");e(this,"requestLocation");e(this,"mountFp");e(this,"mount");e(this,"unmount");const a=new te({initialState:{available:!1,accessGranted:!1,accessRequested:!1},onChange:i.set}),l=new He({isPageReload:u,restoreState:i.get,onMounted:a.setState,initialState(w){return c(s("web_app_check_location","location_checked",w),I(Us))}}),p={version:t,requires:"web_app_check_location",isTma:o},b=A({...p,returns:"either"}),f=A({...p,returns:"task"}),C=A({...p,returns:"task",isMounted:l.isMounted});this.isAvailable=a.getter("available"),this.isAccessRequested=a.getter("accessRequested"),this.isAccessGranted=a.getter("accessGranted"),this.isSupported=Z("web_app_check_location",t),this.isMounted=l.isMounted,this.state=a.state,this.unmount=l.unmount,this.mountFp=f(l.mount),this.openSettingsFp=b(()=>n("web_app_open_location_settings")),this.requestLocationFp=C(w=>c(s("web_app_request_location","location_requested",w),I(v=>{if(!v.available)return a.setState({available:!1}),null;const{available:y,..._}=v;return _}))),this.mount=h(this.mountFp),this.openSettings=h(this.openSettingsFp),this.requestLocation=h(this.requestLocationFp)}}const Gs=new jt(c(S(),j,k,U,re("locationManager")));class Dt{constructor({defaults:t,...s}){e(this,"bgColor");e(this,"hasShineEffect");e(this,"isEnabled");e(this,"isLoaderVisible");e(this,"isVisible");e(this,"isMounted");e(this,"state");e(this,"text");e(this,"textColor");e(this,"showFp");e(this,"show");e(this,"hideFp");e(this,"hide");e(this,"enableFp");e(this,"enable");e(this,"enableShineEffectFp");e(this,"enableShineEffect");e(this,"disableFp");e(this,"disable");e(this,"disableShineEffectFp");e(this,"disableShineEffect");e(this,"setBgColorFp");e(this,"setBgColor");e(this,"setTextColorFp");e(this,"setTextColor");e(this,"setTextFp");e(this,"setText");e(this,"showLoaderFp");e(this,"showLoader");e(this,"hideLoaderFp");e(this,"hideLoader");e(this,"setParamsFp");e(this,"setParams");e(this,"mountFp");e(this,"mount");e(this,"unmount");e(this,"onClickFp");e(this,"onClick");e(this,"offClickFp");e(this,"offClick");const n=new ve({...s,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,u)=>{const a=n.stateGetter(o);return g.computed(()=>a()||W(u))};this.bgColor=i("bgColor",t.bgColor),this.textColor=i("textColor",t.textColor),this.hasShineEffect=n.stateGetter("hasShineEffect"),this.isEnabled=n.stateGetter("isEnabled"),this.isLoaderVisible=n.stateGetter("isLoaderVisible"),this.text=n.stateGetter("text"),this.isVisible=n.stateGetter("isVisible"),this.isMounted=n.isMounted,this.state=n.state,[this.setBgColor,this.setBgColorFp]=n.stateSetters("bgColor"),[this.setTextColor,this.setTextColorFp]=n.stateSetters("textColor"),[[this.disableShineEffect,this.disableShineEffectFp],[this.enableShineEffect,this.enableShineEffectFp]]=n.stateBoolSetters("hasShineEffect"),[[this.disable,this.disableFp],[this.enable,this.enableFp]]=n.stateBoolSetters("isEnabled"),[[this.hideLoader,this.hideLoaderFp],[this.showLoader,this.showLoaderFp]]=n.stateBoolSetters("isLoaderVisible"),[this.setText,this.setTextFp]=n.stateSetters("text"),[[this.hide,this.hideFp],[this.show,this.showFp]]=n.stateBoolSetters("isVisible"),this.setParams=n.setState,this.setParamsFp=n.setStateFp,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 Ke(r,t){document.documentElement.style.setProperty(r,t)}function Ne(r){document.documentElement.style.removeProperty(r)}function Ut(r){return c(x.toRGBFullFp(r),H(t=>Math.sqrt([.299,.587,.114].reduce((s,n,i)=>{const o=parseInt(t.slice(1+i*2,1+(i+1)*2),16);return s+o*o*n},0))<120))}const ze=V.throwifyFpFn(Ut);class Gt{constructor({initialState:t,onChange:s,offChange:n,isTma:i,storage:o,isPageReload:u}){e(this,"accentTextColor");e(this,"bgColor");e(this,"buttonColor");e(this,"buttonTextColor");e(this,"bottomBarBgColor");e(this,"destructiveTextColor");e(this,"headerBgColor");e(this,"hintColor");e(this,"linkColor");e(this,"secondaryBgColor");e(this,"sectionBgColor");e(this,"sectionHeaderTextColor");e(this,"sectionSeparatorColor");e(this,"subtitleTextColor");e(this,"textColor");e(this,"_isCssVarsBound",g.signal(!1));e(this,"isCssVarsBound",g.computed(this._isCssVarsBound));e(this,"bindCssVarsFp");e(this,"bindCssVars");e(this,"state");e(this,"isDark",g.computed(()=>{const t=this.bgColor();return!t||ze(t)}));e(this,"isMounted");e(this,"mountFp");e(this,"mount");e(this,"unmount");const a=new te({initialState:{},onChange:o.set}),l=w=>{a.setState(w.theme_params)},p=new me({initialState:()=>q(W(t)),isPageReload:u,onMounted(w){a.setState(w),s(l)},onUnmounted(){n(l)},restoreState:o.get}),b={isTma:i,returns:"either"},f=A(b),C=A({...b,isMounted:p.isMounted});this.accentTextColor=a.getter("accent_text_color"),this.bgColor=a.getter("bg_color"),this.buttonColor=a.getter("button_color"),this.buttonTextColor=a.getter("button_text_color"),this.bottomBarBgColor=a.getter("bottom_bar_bg_color"),this.destructiveTextColor=a.getter("destructive_text_color"),this.headerBgColor=a.getter("header_bg_color"),this.hintColor=a.getter("hint_color"),this.linkColor=a.getter("link_color"),this.secondaryBgColor=a.getter("secondary_bg_color"),this.sectionBgColor=a.getter("section_bg_color"),this.sectionHeaderTextColor=a.getter("section_header_text_color"),this.sectionSeparatorColor=a.getter("section_separator_color"),this.subtitleTextColor=a.getter("subtitle_text_color"),this.textColor=a.getter("text_color"),this.state=a.state,this.isMounted=p.isMounted,this.bindCssVarsFp=C(w=>{if(this._isCssVarsBound())return O(new Ce);w||(w=_=>`--tg-theme-${V.snakeToKebab(_)}`);const v=_=>{Object.entries(a.state()).forEach(([F,m])=>{m&&_(F,m)})},y=()=>{v((_,F)=>{Ke(w(_),F)})};return y(),a.state.sub(y),this._isCssVarsBound.set(!0),q(()=>{v(Ne),a.state.unsub(y),this._isCssVarsBound.set(!1)})}),this.mountFp=f(p.mount),this.unmount=p.unmount,this.bindCssVars=h(this.bindCssVarsFp),this.mount=h(this.mountFp)}}const Pe=be({}),he=new Gt({...c(S(),re("themeParams")),offChange(r){d.off("theme_changed",r)},onChange(r){d.on("theme_changed",r)},initialState:Pe});function Ht(r,t,s){return c(Ge(r,t),n=>({...n,defaults:s}))}const Hs=new Dt(Ht("mainButton","main_button_pressed",{bgColor:g.computed(()=>he.buttonColor()||"#2481cc"),textColor:g.computed(()=>he.buttonTextColor()||"#ffffff")}));class Wt{constructor({storage:t,isPageReload:s,version:n,postEvent:i,isTma:o,theme:u,onVisibilityChanged:a,offVisibilityChanged:l}){e(this,"isSupported");e(this,"isDark",g.computed(()=>{const t=this.bgColorRgb();return t?ze(t):!1}));e(this,"isActive");e(this,"state");e(this,"isCssVarsBound");e(this,"bindCssVarsFp");e(this,"bindCssVars");e(this,"isMounted");e(this,"mountFp");e(this,"mount");e(this,"unmount");e(this,"bgColor");e(this,"bgColorRgb");e(this,"setBgColorFp");e(this,"setBgColor");e(this,"headerColor");e(this,"headerColorRgb");e(this,"setHeaderColorFp");e(this,"setHeaderColor");e(this,"bottomBarColor");e(this,"bottomBarColorRgb");e(this,"setBottomBarColorFp");e(this,"setBottomBarColor");e(this,"closeFp");e(this,"close");e(this,"readyFp");e(this,"ready");const p=m=>{C.setState({isActive:m.is_visible})},b=m=>{[[this.headerColor,"web_app_set_header_color"],[this.bgColor,"web_app_set_background_color"],[this.bottomBarColor,"web_app_set_bottom_bar_color"]].forEach(([T,D])=>{const $=T();if(!x.isRGB($)&&(D!=="web_app_set_header_color"||!["bg_color","secondary_bg_color"].includes($))){const K=m[$];K&&i(D,{color:K})}})},f=new me({initialState(){return q({bgColor:"bg_color",headerColor:"header_bg_color",bottomBarColor:"bottom_bar_bg_color",isActive:!0})},isPageReload:s,onMounted:m=>{a(p),u.sub(b),C.setState(m)},onUnmounted(){l(p),u.unsub(b)},restoreState:t.get});this.isMounted=f.isMounted,this.mountFp=P(()=>{const m=()=>{};return c(f.mount(),fe(m,m))},{isTma:o,returns:"plain"}),this.mount=h(this.mountFp),this.unmount=f.unmount;const C=new te({initialState:{bgColor:"bg_color",bottomBarColor:"bottom_bar_bg_color",headerColor:"bg_color",isActive:!1},onChange:t.set});this.state=C.state;const w=m=>x.isRGB(m)?m:W(u)[m],v=m=>g.computed(()=>w(m()));this.isActive=C.getter("isActive"),this.isSupported=g.computed(()=>["web_app_set_header_color","web_app_set_background_color","web_app_set_bottom_bar_color"].some(m=>d.supports(m,W(n))));const y=g.signal(!1);this.isCssVarsBound=g.computed(y),this.bindCssVarsFp=P(m=>{if(y())return O(new Ce);const[T,D]=V.createCbCollector(()=>{y.set(!1)}),$=(K,G)=>{const Y=()=>{Ke(K,G()||null)};Y(),T(G.sub(Y),Ne.bind(null,K))};return m||(m=K=>`--tg-${V.camelToKebab(K)}`),$(m("bgColor"),this.bgColorRgb),$(m("bottomBarColor"),this.bottomBarColorRgb),$(m("headerColor"),this.headerColorRgb),y.set(!0),q(D)},{isTma:o,returns:"either",isMounted:this.isMounted}),this.bindCssVars=h(this.bindCssVarsFp);const _=m=>{const T=C.getter(m),D=v(T),$={headerColor:"web_app_set_header_color",bgColor:"web_app_set_background_color",bottomBarColor:"web_app_set_bottom_bar_color"}[m],K=P(G=>{if(G===T())return q(void 0);if($==="web_app_set_header_color"&&(G==="bg_color"||G==="secondary_bg_color"))return c(i("web_app_set_header_color",{color_key:G}),H(()=>{C.setState({[m]:G})}));const Y=w(G);return c(Y?i($,{color:Y}):O(new wt(G)),H(()=>{C.setState({[m]:G})}))},{isTma:o,version:n,requires:$,isMounted:this.isMounted,returns:"either",supports:m==="headerColor"?{rgb:{method:"web_app_set_header_color",param:"color",shouldCheck:x.isRGB}}:void 0});return[T,D,h(K),K]};[this.bgColor,this.bgColorRgb,this.setBgColor,this.setBgColorFp]=_("bgColor"),[this.headerColor,this.headerColorRgb,this.setHeaderColor,this.setHeaderColorFp]=_("headerColor"),[this.bottomBarColor,this.bottomBarColorRgb,this.setBottomBarColor,this.setBottomBarColorFp]=_("bottomBarColor");const F=A({isTma:o,returns:"either"});this.closeFp=F(m=>i("web_app_close",{return_back:m})),this.close=h(this.closeFp),this.readyFp=F(()=>i("web_app_ready")),this.ready=h(this.readyFp)}}const Qt=new Wt({...c(S(),j,k,re("miniApp")),offVisibilityChanged(r){d.off("visibility_changed",r)},onVisibilityChanged(r){d.on("visibility_changed",r)},theme:he.state});function Ws(r){const t=r.message.trim(),s=(r.title||"").trim(),n=r.buttons||[];if(s.length>64)return O(new z(`Invalid title: ${s}`));if(!t||t.length>256)return O(new z(`Invalid message: ${t}`));if(n.length>3)return O(new z(`Invalid buttons count: ${n.length}`));const i=[];if(!n.length)i.push({type:"close",id:""});else for(let o=0;o<n.length;o++){const u=n[o],a=u.id||"";if(a.length>64)return O(new z(`Button with index ${o} has invalid id: ${a}`));if(!u.type||u.type==="default"||u.type==="destructive"){const l=u.text.trim();if(!l||l.length>64)return O(new z(`Button with index ${o} has invalid text: ${l}`));i.push({type:u.type,text:l,id:a})}else i.push({type:u.type,id:a})}return q({title:s,message:t,buttons:i})}class Kt{constructor({version:t,isTma:s,request:n}){e(this,"isOpened");e(this,"isSupported");e(this,"showFp");e(this,"show");const i=g.signal(!1),o=()=>{i.set(!1)},u=A({version:t,isTma:s,requires:"web_app_open_popup",returns:"task"});this.isSupported=Z("web_app_open_popup",t),this.isOpened=g.computed(i),this.showFp=u(a=>c(this.isOpened()?L(new Se("A popup is already opened")):M(void 0),ue(()=>ht(Ws(a))),J(l=>(i.set(!0),n("web_app_open_popup","popup_closed",{...a,params:l}))),je(l=>(o(),l),l=>(o(),l.button_id)))),this.show=h(this.showFp)}}const Qs=new Kt(c(S(),U,k));function Ks({request:r,...t}){return P(s=>c(r("web_app_request_phone","phone_requested",s),I(n=>n.status)),{...t,requires:"web_app_request_phone",returns:"task"})}const Je=Ks(c(S(),k,U)),Ns=h(Je);function zs({invokeCustomMethod:r,requestPhoneAccess:t,...s}){const n=u=>c(r("getRequestedContact",{},{...u,timeout:(u||{}).timeout||5e3}),ue(a=>{const l=E.safeParse(E.string(),a);if(!l.success)return L(new pe(a,l.issues));if(!l.output)return M(void 0);const p=E.safeParse(x.pipeQueryToSchema(E.looseObject({contact:x.pipeJsonToSchema(E.looseObject({user_id:E.number(),phone_number:E.string(),first_name:E.string(),last_name:E.optional(E.string())})),auth_date:E.pipe(E.string(),E.transform(b=>new Date(Number(b)*1e3)),E.date()),hash:E.string()})),l.output);return p.success?M({raw:l.output,parsed:p.output}):L(new pe(l.output,p.issues))})),i=u=>c(n(u),ns(a=>pe.is(a)?O(a):q(void 0),a=>q(a))),o=u=>V.BetterTaskEither(async(a,l,p)=>{let b=50;for(;!p.isRejected;){const f=await i(p)();if(f._tag==="Left")return l(f.left);if(f.right)return a(f.right);await new Promise(C=>setTimeout(C,b)),b+=50}},u);return P(u=>V.BetterTaskEither.fn(a=>c(i(a),J(l=>l?M(l):c(t(a),ue(p=>p==="sent"?o(a):L(new Ue("User denied access")))))),u),{...s,returns:"task",requires:"web_app_request_phone"})}function Js({requestContact:r,...t}){return P(r,{...t,returns:"task",requires:"web_app_request_phone"})}const Ye=zs({...c(S(),We,k),requestPhoneAccess:Je}),Ys=h(Ye),Nt=Js({...c(S(),k),requestContact(r){return c(Ye(r),I(t=>t.parsed))}}),Zs=h(Nt);function Xs({request:r,...t}){return P(s=>c(r("web_app_request_write_access","write_access_requested",s),I(n=>n.status)),{...t,requires:"web_app_request_write_access",returns:"task"})}const zt=Xs(c(S(),k,U)),en=h(zt);class Jt{constructor({version:t,onClosed:s,onTextReceived:n,isTma:i,postEvent:o}){e(this,"isOpened");e(this,"isSupported");e(this,"captureFp");e(this,"capture");e(this,"closeFp");e(this,"close");e(this,"openFp");e(this,"open");const u={version:t,requires:"web_app_open_scan_qr_popup",isTma:i},a=A({...u,returns:"either"}),l=A({...u,returns:"task"}),p=g.signal(!1),b=()=>{p.set(!1)};this.isSupported=Z("web_app_open_scan_qr_popup",t),this.isOpened=g.computed(p),this.captureFp=l(f=>{let C;return c(this.openFp({...f,onCaptured:w=>{f.capture(w)&&(C=w,this.close())}}),I(()=>C))}),this.closeFp=a(()=>c(o("web_app_close_scan_qr_popup"),H(b))),this.openFp=l(f=>c(p()?L(new Se("The QR Scanner is already opened")):async()=>o("web_app_open_scan_qr_popup",{text:f.text}),ue(()=>{p.set(!0);const[C,w]=V.createCbCollector(),v=y=>(w(),p.set(!1),y);return c(V.BetterTaskEither(y=>{C(s(y),p.sub(_=>{_||y()}),n(f.onCaptured))},f),je(v,v))}))),this.open=h(this.openFp),this.capture=h(this.captureFp),this.close=h(this.closeFp)}}const tn=new Jt({...c(S(),j,k),onClosed(r){return d.on("scan_qr_popup_closed",r)},onTextReceived(r){return d.on("qr_text_received",t=>{r(t.data)})}});class Yt{constructor({defaults:t,...s}){e(this,"isSupported");e(this,"position");e(this,"bgColor");e(this,"hasShineEffect");e(this,"isEnabled");e(this,"isLoaderVisible");e(this,"isVisible");e(this,"isMounted");e(this,"state");e(this,"text");e(this,"textColor");e(this,"showFp");e(this,"show");e(this,"hideFp");e(this,"hide");e(this,"enableFp");e(this,"enable");e(this,"enableShineEffectFp");e(this,"enableShineEffect");e(this,"disableFp");e(this,"disable");e(this,"disableShineEffectFp");e(this,"disableShineEffect");e(this,"setBgColorFp");e(this,"setBgColor");e(this,"setTextColorFp");e(this,"setTextColor");e(this,"setTextFp");e(this,"setText");e(this,"setPositionFp");e(this,"setPosition");e(this,"showLoaderFp");e(this,"showLoader");e(this,"hideLoaderFp");e(this,"hideLoader");e(this,"setParamsFp");e(this,"setParams");e(this,"mountFp");e(this,"mount");e(this,"unmount");e(this,"onClickFp");e(this,"onClick");e(this,"offClickFp");e(this,"offClick");const n=new ve({...s,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,u)=>{const a=n.stateGetter(o);return g.computed(()=>a()||W(u))};this.isSupported=Z("web_app_setup_secondary_button",s.version),this.bgColor=i("bgColor",t.bgColor),this.textColor=i("textColor",t.textColor),this.position=n.stateGetter("position"),this.hasShineEffect=n.stateGetter("hasShineEffect"),this.isEnabled=n.stateGetter("isEnabled"),this.isLoaderVisible=n.stateGetter("isLoaderVisible"),this.text=n.stateGetter("text"),this.isVisible=n.stateGetter("isVisible"),this.isMounted=n.isMounted,this.state=n.state,[this.setPosition,this.setPositionFp]=n.stateSetters("position"),[this.setBgColor,this.setBgColorFp]=n.stateSetters("bgColor"),[this.setTextColor,this.setTextColorFp]=n.stateSetters("textColor"),[[this.disableShineEffect,this.disableShineEffectFp],[this.enableShineEffect,this.enableShineEffectFp]]=n.stateBoolSetters("hasShineEffect"),[[this.disable,this.disableFp],[this.enable,this.enableFp]]=n.stateBoolSetters("isEnabled"),[[this.hideLoader,this.hideLoaderFp],[this.showLoader,this.showLoaderFp]]=n.stateBoolSetters("isLoaderVisible"),[this.setText,this.setTextFp]=n.stateSetters("text"),[[this.hide,this.hideFp],[this.show,this.showFp]]=n.stateBoolSetters("isVisible"),this.setParams=n.setState,this.setParamsFp=n.setStateFp,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 rn=new Yt(Ht("secondaryButton","secondary_button_pressed",{bgColor:g.computed(()=>Qt.bottomBarColorRgb()||"#000000"),textColor:g.computed(()=>he.buttonColor()||"#2481cc")}));class Zt{constructor({isTma:t,request:s,version:n,createRequestId:i}){e(this,"getItemFp");e(this,"getItem");e(this,"restoreItemFp");e(this,"restoreItem");e(this,"setItemFp");e(this,"setItem");e(this,"deleteItemFp");e(this,"deleteItem");e(this,"clearFp");e(this,"clear");const o=A({version:n,requires:"web_app_secure_storage_get_key",isTma:t,returns:"task"}),u=(a,l,p)=>{const b=i();return c(s(a,["secure_storage_failed",l],{params:{...p,req_id:b},capture:f=>"payload"in f?f.payload.req_id===b:!0}),J(f=>f.event==="secure_storage_failed"?L(new ft(f.payload.error||"UNKNOWN_ERROR")):M(f.payload)))};this.getItemFp=o(a=>c(u("web_app_secure_storage_get_key","secure_storage_key_received",{key:a}),I(l=>({value:l.value,canRestore:!!l.can_restore})))),this.setItemFp=o((a,l)=>c(u("web_app_secure_storage_save_key","secure_storage_key_saved",{key:a,value:l}),I(()=>{}))),this.deleteItemFp=o(a=>this.setItemFp(a,null)),this.clearFp=o(()=>c(u("web_app_secure_storage_clear","secure_storage_cleared",{}),I(()=>{}))),this.restoreItemFp=o(a=>c(u("web_app_secure_storage_restore_key","secure_storage_key_restored",{key:a}),I(l=>l.value))),this.getItem=h(this.getItemFp),this.setItem=h(this.setItemFp),this.deleteItem=h(this.deleteItemFp),this.clear=h(this.clearFp),this.restoreItem=h(this.restoreItemFp)}}const sn=new Zt(c(S(),k,U,Pt));class Xt{constructor(t){e(this,"isVisible");e(this,"isMounted");e(this,"isSupported");e(this,"hideFp");e(this,"hide");e(this,"showFp");e(this,"show");e(this,"onClickFp");e(this,"onClick");e(this,"offClickFp");e(this,"offClick");e(this,"mountFp");e(this,"mount");e(this,"unmount");const s=new ve({...t,method:"web_app_setup_settings_button",payload:n=>({is_visible:n.isVisible}),initialState:{isVisible:!1}});this.isVisible=s.stateGetter("isVisible"),this.isMounted=s.isMounted,this.isSupported=s.isSupported,[[this.hide,this.hideFp],[this.show,this.showFp]]=s.stateBoolSetters("isVisible"),this.onClick=s.onClick,this.onClickFp=s.onClickFp,this.offClick=s.offClick,this.offClickFp=s.offClickFp,this.mount=s.mount,this.mountFp=s.mountFp,this.unmount=s.unmount}}const nn=new Xt(Ge("settingsButton","settings_button_pressed"));class er{constructor({postEvent:t,storage:s,isTma:n,isPageReload:i,version:o}){e(this,"isSupported");e(this,"isVerticalEnabled");e(this,"isMounted");e(this,"mountFp");e(this,"mount");e(this,"unmount");e(this,"disableVerticalFp");e(this,"disableVertical");e(this,"enableVerticalFp");e(this,"enableVertical");const u={isVerticalEnabled:!0},a=new te({initialState:u,onChange(w){s.set(w)}}),l=new me({initialState:u,isPageReload:i,onMounted:a.setState,restoreState:s.get}),p={requires:"web_app_setup_swipe_behavior",isTma:n,version:o},b=A({...p,returns:"plain"}),f=A({...p,isMounted:l.isMounted,returns:"either"}),C=w=>{const v={isVerticalEnabled:w};return a.hasDiff(v)?c(t("web_app_setup_swipe_behavior",{allow_vertical_swipe:w}),H(()=>{a.setState(v)})):q(void 0)};this.isSupported=Z("web_app_setup_swipe_behavior",o),this.isVerticalEnabled=a.getter("isVerticalEnabled"),this.isMounted=l.isMounted,this.disableVerticalFp=f(()=>C(!1)),this.enableVerticalFp=f(()=>C(!0)),this.mountFp=b(()=>{const w=()=>{};return c(l.mount(),fe(w,w))}),this.unmount=l.unmount,this.disableVertical=h(this.disableVerticalFp),this.enableVertical=h(this.enableVerticalFp),this.mount=h(this.mountFp)}}const on=new er(c(S(),j,k,re("swipeBehavior")));async function an(r){try{const{clipboard:s}=navigator;if(s)return await s.writeText(r)}catch{}const t=document.createElement("textarea");t.value=r,t.style.top="0",t.style.left="0",t.style.position="fixed",document.body.appendChild(t),t.focus(),t.select();try{document.execCommand("copy")}finally{document.body.removeChild(t)}}function un({request:r,...t}){return P((s,n,i)=>c(r("web_app_request_file_download","file_download_requested",{...i,params:{url:s,file_name:n}}),J(o=>o.status==="downloading"?M(void 0):L(new Ue("User denied the action")))),{...t,requires:"web_app_request_file_download",returns:"task"})}const tr=un(c(S(),U,k)),cn=h(tr);function pn({invokeCustomMethod:r,...t}){return P(s=>c(r("getCurrentTime",{},s),J(n=>{const i=E.safeParse(E.pipe(E.number(),E.integer(),E.transform(o=>new Date(o*1e3)),E.date()),n);return i.success?M(i.output):L(new pe(n,i.issues))})),{...t,requires:"web_app_invoke_custom_method",returns:"task"})}const rr=pn(c(S(),We,k)),ln=h(rr);function hn({postEvent:r,...t}){return P(()=>r("web_app_hide_keyboard"),{...t,returns:"either",requires:"web_app_hide_keyboard"})}const sr=hn(c(S(),j,k)),dn=h(sr);function fn({request:r,createRequestId:t,...s}){return P(n=>{const i=t();return c(r("web_app_read_text_from_clipboard","clipboard_text_received",{...n,params:{req_id:i},capture:d.captureSameReq(i)}),I(({data:o=null})=>o))},{...s,requires:"web_app_read_text_from_clipboard",returns:"task"})}const nr=fn({...c(S(),k,U),createRequestId:ye}),mn=h(nr);function or(r){const t={},s=r.match(/Telegram-Android(?:\/([^ ]+))?(?: (\([^)]+\))?|$)/);if(s){const[,n,i]=s;n&&(t.appVersion=n),i&&i.slice(1,i.length-1).split(";").forEach(o=>{const[u,a]=o.trim().split(" ");if(u==="Android")t.androidVersion=a;else if(u==="SDK"){const l=parseInt(a,10);l&&(t.sdkVersion=l)}else a?(t.manufacturer=u,t.model=a):t.performanceClass=u})}return t}function _n(){return or(navigator.userAgent)}function bn({postEvent:r,...t}){return P(s=>{const{size:n}=new Blob([s]);return!n||n>4096?O(new z(n?"Maximum size of data to send is 4096 bytes":"Attempted to send empty data")):r("web_app_data_send",{data:s})},{...t,returns:"either"})}const ir=bn(c(S(),j)),gn=h(ir);function Fn({request:r,...t}){return P((s,n)=>c(r("web_app_send_prepared_message",["prepared_message_failed","prepared_message_sent"],{...n,params:{id:s}}),J(i=>i.event==="prepared_message_failed"?L(new Ft(i.payload.error)):M(void 0))),{...t,requires:"web_app_send_prepared_message",returns:"task"})}const ar=Fn(c(S(),U,k)),wn=h(ar);function Cn({postEvent:r,...t}){return P((s,n={})=>r("web_app_share_to_story",{text:n.text,media_url:s,widget_link:n.widgetLink}),{...t,requires:"web_app_share_to_story",returns:"either"})}const ur=Cn(c(S(),j,k)),Sn=h(ur),qe=be(!1);function vn({isInlineMode:r,postEvent:t,...s}){return P((n,i)=>t("web_app_switch_inline_query",{query:n,chat_types:i||[]}),{...s,requires:{every:["web_app_switch_inline_query",()=>W(r)?void 0:"The application must be launched in the inline mode"]},returns:"either"})}const cr=vn({...c(S(),j,k),isInlineMode:qe}),yn=h(cr);class pr{constructor({storage:t,isPageReload:s,onContentSafeAreaInsetsChanged:n,onSafeAreaInsetsChanged:i,onViewportChanged:o,onFullscreenChanged:u,offContentSafeAreaInsetsChanged:a,offFullscreenChanged:l,offSafeAreaInsetsChanged:p,offViewportChanged:b,request:f,isViewportStable:C,isFullscreen:w,isTma:v,version:y,postEvent:_}){e(this,"state");e(this,"height");e(this,"stableHeight");e(this,"width");e(this,"isExpanded");e(this,"isStable",g.computed(()=>this.height()===this.stableHeight()));e(this,"contentSafeAreaInsets");e(this,"contentSafeAreaInsetTop");e(this,"contentSafeAreaInsetLeft");e(this,"contentSafeAreaInsetRight");e(this,"contentSafeAreaInsetBottom");e(this,"safeAreaInsets");e(this,"safeAreaInsetTop");e(this,"safeAreaInsetLeft");e(this,"safeAreaInsetRight");e(this,"safeAreaInsetBottom");e(this,"isFullscreen");e(this,"requestFullscreenFp");e(this,"requestFullscreen");e(this,"exitFullscreenFp");e(this,"exitFullscreen");e(this,"isCssVarsBound");e(this,"bindCssVarsFp");e(this,"bindCssVars");e(this,"isMounted");e(this,"mountFp");e(this,"mount");e(this,"expandFp");e(this,"expand");const F={top:0,right:0,left:0,bottom:0},m=new te({initialState:{contentSafeAreaInsets:F,height:0,isExpanded:!1,isFullscreen:!1,safeAreaInsets:F,stableHeight:0,width:0},onChange:t.set}),T=B=>{m.setState({isExpanded:B.is_expanded,height:B.height,width:B.width,stableHeight:B.is_state_stable?B.height:void 0})},D=B=>{m.setState({isFullscreen:B.is_fullscreen})},$=B=>{m.setState({safeAreaInsets:B})},K=B=>{m.setState({contentSafeAreaInsets:B})},G=new He({initialState(B){const se=X=>()=>{const[ee,N]=X==="safe-area"?["web_app_request_safe_area","safe_area_changed"]:["web_app_request_content_safe_area","content_safe_area_changed"];return d.supports(ee,W(y))?f(ee,N,B):M({top:0,left:0,right:0,bottom:0})},R=X=>()=>typeof X=="boolean"?M(X):ht(X());return c(hs,we("safeAreaInsets",se("safe-area")),we("contentSafeAreaInsets",se("content-safe-area")),we("isFullscreen",R(w)),we("isViewportStable",R(C)),ue(({isViewportStable:X,...ee})=>X?M({...ee,height:window.innerHeight,isExpanded:!0,stableHeight:window.innerHeight,width:window.innerWidth}):c(f("web_app_request_viewport","viewport_changed",B),I(N=>({...ee,height:N.height,isExpanded:N.is_expanded,stableHeight:N.is_state_stable?N.height:0,width:N.width})))))},isPageReload:s,onMounted(B){o(T),u(D),i($),n(K),m.setState(B)},onUnmounted(){b(T),l(D),p($),a(K)},restoreState:t.get}),Y=B=>g.computed(()=>this.safeAreaInsets()[B]),ge=B=>g.computed(()=>this.contentSafeAreaInsets()[B]);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=Y("top"),this.safeAreaInsetBottom=Y("bottom"),this.safeAreaInsetLeft=Y("left"),this.safeAreaInsetRight=Y("right"),this.contentSafeAreaInsets=m.getter("contentSafeAreaInsets"),this.contentSafeAreaInsetTop=ge("top"),this.contentSafeAreaInsetBottom=ge("bottom"),this.contentSafeAreaInsetLeft=ge("left"),this.contentSafeAreaInsetRight=ge("right");const hr=A({isTma:v,returns:"task"}),Ze=A({isTma:v,returns:"either"}),dr=A({isTma:v,requires:"web_app_request_fullscreen",version:y,returns:"task"}),Xe=B=>dr(se=>c(f(B?"web_app_request_fullscreen":"web_app_exit_fullscreen",["fullscreen_changed","fullscreen_failed"],se),J(R=>R.event==="fullscreen_failed"&&R.payload.error!=="ALREADY_FULLSCREEN"?L(new gt(R.payload.error)):(m.setState({isFullscreen:"is_fullscreen"in R.payload?R.payload.is_fullscreen:!0}),M(void 0)))));this.isMounted=G.isMounted,this.mountFp=hr(G.mount),this.mount=h(this.mountFp),this.isFullscreen=m.getter("isFullscreen"),this.requestFullscreenFp=Xe(!0),this.requestFullscreen=h(this.requestFullscreenFp),this.exitFullscreenFp=Xe(!1),this.exitFullscreen=h(this.exitFullscreenFp);const Fe=g.signal(!1);this.isCssVarsBound=g.computed(Fe),this.bindCssVarsFp=Ze(B=>{if(Fe())return O(new Ce);B||(B=R=>`--tg-viewport-${V.camelToKebab(R)}`);const se=[["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((R,[X,ee])=>{const N=B(X);if(N){const et=()=>{Ke(N,`${ee()}px`)};R.push({update:et,removeListener:ee.sub(et),cssVar:N})}return R},[]);return se.forEach(R=>{R.update()}),Fe.set(!0),q(()=>{se.forEach(R=>{R.removeListener(),Ne(R.cssVar)}),Fe.set(!1)})}),this.bindCssVars=h(this.bindCssVarsFp),this.expandFp=Ze(()=>_("web_app_expand")),this.expand=h(this.expandFp)}}function kn(){const r=o=>({on:u=>{d.on(o,u)},off:u=>{d.off(o,u)}}),t=r("viewport_changed"),s=r("fullscreen_changed"),n=r("safe_area_changed"),i=r("content_safe_area_changed");return new pr({...c(S(),re("viewport"),k,j,U),isFullscreen(){return c(d.retrieveLaunchParamsFp(),H(o=>!!o.tgWebAppFullscreen))},isViewportStable(){return c(d.retrieveLaunchParamsFp(),H(o=>["macos","tdesktop","unigram","webk","weba","web"].includes(o.tgWebAppPlatform)))},offContentSafeAreaInsetsChanged:i.off,offFullscreenChanged:s.off,offSafeAreaInsetsChanged:n.off,offViewportChanged:t.off,onContentSafeAreaInsetsChanged:i.on,onFullscreenChanged:s.on,onSafeAreaInsetsChanged:n.on,onViewportChanged:t.on})}const En=kn();function lr(r={}){const{version:t,isInlineMode:s,themeParams:n}=r;if(t&&typeof s=="boolean"&&n)Be.set(t),qe.set(s),Pe.set(n);else{const a=c(d.retrieveLaunchParamsFp(),ut(l=>l,l=>{Be.set(t||l.tgWebAppVersion),qe.set(typeof s=="boolean"?s:!!l.tgWebAppBotInline),Pe.set(n||l.tgWebAppThemeParams)}));if(a)return O(a)}r.postEvent&&St.set(r.postEvent);const[i,o]=V.createCbCollector(d.on("reload_iframe",()=>{d.logger().log("Received a request to reload the page"),vt("iframe_will_reload"),window.location.reload()})),{acceptCustomStyles:u=!0}=r;if(u){const a=document.createElement("style");a.id="telegram-custom-styles",document.head.appendChild(a),i(d.on("set_custom_style",l=>{a.innerHTML=l}),()=>{document.head.removeChild(a)})}return c(ie("iframe_ready",{reload_supported:!0}),H(()=>(d.logger().log("The package was initialized"),o)))}const In=V.throwifyFpFn(lr);Object.defineProperty(exports,"CancelledError",{enumerable:!0,get:()=>d.CancelledError});Object.defineProperty(exports,"InvalidLaunchParamsError",{enumerable:!0,get:()=>d.InvalidLaunchParamsError});Object.defineProperty(exports,"InvokeCustomMethodFailedError",{enumerable:!0,get:()=>d.InvokeCustomMethodFailedError});Object.defineProperty(exports,"LaunchParamsRetrieveError",{enumerable:!0,get:()=>d.LaunchParamsRetrieveError});Object.defineProperty(exports,"MethodParameterUnsupportedError",{enumerable:!0,get:()=>d.MethodParameterUnsupportedError});Object.defineProperty(exports,"MethodUnsupportedError",{enumerable:!0,get:()=>d.MethodUnsupportedError});Object.defineProperty(exports,"TimeoutError",{enumerable:!0,get:()=>d.TimeoutError});Object.defineProperty(exports,"UnknownEnvError",{enumerable:!0,get:()=>d.UnknownEnvError});Object.defineProperty(exports,"applyPolyfills",{enumerable:!0,get:()=>d.applyPolyfills});Object.defineProperty(exports,"createLogger",{enumerable:!0,get:()=>d.createLogger});Object.defineProperty(exports,"createPostEvent",{enumerable:!0,get:()=>d.createPostEvent});Object.defineProperty(exports,"createStartParam",{enumerable:!0,get:()=>d.createStartParam});Object.defineProperty(exports,"createStartParamFp",{enumerable:!0,get:()=>d.createStartParamFp});Object.defineProperty(exports,"debug",{enumerable:!0,get:()=>d.debug});Object.defineProperty(exports,"decodeBase64Url",{enumerable:!0,get:()=>d.decodeBase64Url});Object.defineProperty(exports,"decodeBase64UrlFp",{enumerable:!0,get:()=>d.decodeBase64UrlFp});Object.defineProperty(exports,"decodeStartParam",{enumerable:!0,get:()=>d.decodeStartParam});Object.defineProperty(exports,"decodeStartParamFp",{enumerable:!0,get:()=>d.decodeStartParamFp});Object.defineProperty(exports,"deepSnakeToCamelObjKeys",{enumerable:!0,get:()=>d.deepSnakeToCamelObjKeys});Object.defineProperty(exports,"emitEvent",{enumerable:!0,get:()=>d.emitEvent});Object.defineProperty(exports,"encodeBase64Url",{enumerable:!0,get:()=>d.encodeBase64Url});Object.defineProperty(exports,"getReleaseVersion",{enumerable:!0,get:()=>d.getReleaseVersion});Object.defineProperty(exports,"isSafeToCreateStartParam",{enumerable:!0,get:()=>d.isSafeToCreateStartParam});Object.defineProperty(exports,"isTMA",{enumerable:!0,get:()=>d.isTMA});Object.defineProperty(exports,"isTMAFp",{enumerable:!0,get:()=>d.isTMAFp});Object.defineProperty(exports,"logger",{enumerable:!0,get:()=>d.logger});Object.defineProperty(exports,"mockTelegramEnv",{enumerable:!0,get:()=>d.mockTelegramEnv});Object.defineProperty(exports,"off",{enumerable:!0,get:()=>d.off});Object.defineProperty(exports,"offAll",{enumerable:!0,get:()=>d.offAll});Object.defineProperty(exports,"on",{enumerable:!0,get:()=>d.on});Object.defineProperty(exports,"retrieveLaunchParams",{enumerable:!0,get:()=>d.retrieveLaunchParams});Object.defineProperty(exports,"retrieveLaunchParamsFp",{enumerable:!0,get:()=>d.retrieveLaunchParamsFp});Object.defineProperty(exports,"retrieveRawInitData",{enumerable:!0,get:()=>d.retrieveRawInitData});Object.defineProperty(exports,"retrieveRawInitDataFp",{enumerable:!0,get:()=>d.retrieveRawInitDataFp});Object.defineProperty(exports,"retrieveRawLaunchParams",{enumerable:!0,get:()=>d.retrieveRawLaunchParams});Object.defineProperty(exports,"retrieveRawLaunchParamsFp",{enumerable:!0,get:()=>d.retrieveRawLaunchParamsFp});Object.defineProperty(exports,"setDebug",{enumerable:!0,get:()=>d.setDebug});Object.defineProperty(exports,"setTargetOrigin",{enumerable:!0,get:()=>d.setTargetOrigin});Object.defineProperty(exports,"supports",{enumerable:!0,get:()=>d.supports});Object.defineProperty(exports,"targetOrigin",{enumerable:!0,get:()=>d.targetOrigin});Object.defineProperty(exports,"isAnyRGB",{enumerable:!0,get:()=>x.isAnyRGB});Object.defineProperty(exports,"isRGB",{enumerable:!0,get:()=>x.isRGB});Object.defineProperty(exports,"isRGBA",{enumerable:!0,get:()=>x.isRGBA});Object.defineProperty(exports,"isRGBAShort",{enumerable:!0,get:()=>x.isRGBAShort});Object.defineProperty(exports,"isRGBShort",{enumerable:!0,get:()=>x.isRGBShort});Object.defineProperty(exports,"parseInitDataQuery",{enumerable:!0,get:()=>x.parseInitDataQuery});Object.defineProperty(exports,"parseInitDataQueryFp",{enumerable:!0,get:()=>x.parseInitDataQueryFp});Object.defineProperty(exports,"parseLaunchParamsQuery",{enumerable:!0,get:()=>x.parseLaunchParamsQuery});Object.defineProperty(exports,"parseLaunchParamsQueryFp",{enumerable:!0,get:()=>x.parseLaunchParamsQueryFp});Object.defineProperty(exports,"serializeInitDataQuery",{enumerable:!0,get:()=>x.serializeInitDataQuery});Object.defineProperty(exports,"serializeLaunchParamsQuery",{enumerable:!0,get:()=>x.serializeLaunchParamsQuery});Object.defineProperty(exports,"toRGB",{enumerable:!0,get:()=>x.toRGB});Object.defineProperty(exports,"toRGBFp",{enumerable:!0,get:()=>x.toRGBFp});Object.defineProperty(exports,"toRGBFull",{enumerable:!0,get:()=>x.toRGBFull});Object.defineProperty(exports,"toRGBFullFp",{enumerable:!0,get:()=>x.toRGBFullFp});exports.AccessDeniedError=Ue;exports.BackButton=Ct;exports.Biometry=yt;exports.CSSVarsBoundError=Ce;exports.ClosingBehavior=Et;exports.CloudStorage=It;exports.ConcurrentCallError=Se;exports.DeviceStorage=Bt;exports.DeviceStorageMethodError=dt;exports.FullscreenFailedError=gt;exports.FunctionUnavailableError=_t;exports.HapticFeedback=xt;exports.InitData=Ot;exports.InvalidArgumentsError=z;exports.InvalidEnvError=fs;exports.Invoice=Lt;exports.LocationManager=jt;exports.MainButton=Dt;exports.MiniApp=Wt;exports.NotAvailableError=mt;exports.Popup=Kt;exports.QrScanner=Jt;exports.SecondaryButton=Yt;exports.SecureStorage=Zt;exports.SecureStorageMethodError=ft;exports.SetEmojiStatusError=bt;exports.SettingsButton=Xt;exports.ShareMessageError=Ft;exports.SwipeBehavior=er;exports.ThemeParams=Gt;exports.UnknownThemeParamsKeyError=wt;exports.ValidationError=pe;exports.Viewport=pr;exports.addToHomeScreen=qs;exports.addToHomeScreenFp=Tt;exports.backButton=gs;exports.biometry=Cs;exports.checkHomeScreenStatus=xs;exports.checkHomeScreenStatusFp=Rt;exports.closingBehavior=Ss;exports.cloudStorage=vs;exports.copyTextToClipboard=an;exports.createRequestId=ye;exports.deviceStorage=ys;exports.downloadFile=cn;exports.downloadFileFp=tr;exports.getCurrentTime=ln;exports.getCurrentTimeFp=rr;exports.hapticFeedback=Bs;exports.hideKeyboard=dn;exports.hideKeyboardFp=sr;exports.init=In;exports.initData=Ts;exports.initFp=lr;exports.invoice=Rs;exports.invokeCustomMethod=At;exports.isColorDark=ze;exports.isColorDarkFp=Ut;exports.locationManager=Gs;exports.mainButton=Hs;exports.miniApp=Qt;exports.openLink=Ls;exports.openLinkFp=Vt;exports.openTelegramLink=$s;exports.openTelegramLinkFp=Qe;exports.popup=Qs;exports.postEvent=vt;exports.postEventFp=ie;exports.qrScanner=tn;exports.readTextFromClipboard=mn;exports.readTextFromClipboardFp=nr;exports.request=ws;exports.requestContact=Zs;exports.requestContactComplete=Ys;exports.requestContactCompleteFp=Ye;exports.requestContactFp=Nt;exports.requestEmojiStatusAccess=Es;exports.requestEmojiStatusAccessFp=qt;exports.requestFp=kt;exports.requestPhoneAccess=Ns;exports.requestPhoneAccessFp=Je;exports.requestWriteAccess=en;exports.requestWriteAccessFp=zt;exports.retrieveAndroidDeviceData=_n;exports.retrieveAndroidDeviceDataFrom=or;exports.secondaryButton=rn;exports.secureStorage=sn;exports.sendData=gn;exports.sendDataFp=ir;exports.setEmojiStatus=As;exports.setEmojiStatusFp=Mt;exports.settingsButton=nn;exports.shareMessage=wn;exports.shareMessageFp=ar;exports.shareStory=Sn;exports.shareStoryFp=ur;exports.shareURL=Ds;exports.shareURLFp=$t;exports.swipeBehavior=on;exports.switchInlineQuery=yn;exports.switchInlineQueryFp=cr;exports.themeParams=he;exports.viewport=En;
1
+ "use strict";var _r=Object.defineProperty;var br=(r,t,n)=>t in r?_r(r,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[t]=n;var e=(r,t,n)=>br(r,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("@tma.js/signals"),d=require("@tma.js/bridge"),L=require("@tma.js/toolkit"),ot=require("better-promises"),x=require("@tma.js/transformers"),Q=require("error-kid"),E=require("valibot");var gr=function(r,t,n){if(n||arguments.length===2)for(var s=0,i=t.length,o;s<i;s++)(o||!(s in t))&&(o||(o=Array.prototype.slice.call(t,0,s)),o[s]=t[s]);return r.concat(o||Array.prototype.slice.call(t))};function it(r,t,n,s,i,o,u,a,l){switch(arguments.length){case 1:return r;case 2:return function(){return t(r.apply(this,arguments))};case 3:return function(){return n(t(r.apply(this,arguments)))};case 4:return function(){return s(n(t(r.apply(this,arguments))))};case 5:return function(){return i(s(n(t(r.apply(this,arguments)))))};case 6:return function(){return o(i(s(n(t(r.apply(this,arguments))))))};case 7:return function(){return u(o(i(s(n(t(r.apply(this,arguments)))))))};case 8:return function(){return a(u(o(i(s(n(t(r.apply(this,arguments))))))))};case 9:return function(){return l(a(u(o(i(s(n(t(r.apply(this,arguments)))))))))}}}function c(r,t,n,s,i,o,u,a,l){switch(arguments.length){case 1:return r;case 2:return t(r);case 3:return n(t(r));case 4:return s(n(t(r)));case 5:return i(s(n(t(r))));case 6:return o(i(s(n(t(r)))));case 7:return u(o(i(s(n(t(r))))));case 8:return a(u(o(i(s(n(t(r)))))));case 9:return l(a(u(o(i(s(n(t(r))))))));default:{for(var p=arguments[0],b=1;b<arguments.length;b++)p=arguments[b](p);return p}}}var de=function(r,t){var n=typeof r=="number"?function(s){return s.length>=r}:r;return function(){var s=Array.from(arguments);return n(arguments)?t.apply(this,s):function(i){return t.apply(void 0,gr([i],s,!1))}}},Fr={_tag:"None"},wr=function(r){return{_tag:"Some",value:r}},Cr=function(r){return r._tag==="Left"},at=function(r){return{_tag:"Left",left:r}},ut=function(r){return{_tag:"Right",right:r}},Me={};function Sr(r,t){return function(n){return function(s){return r.ap(r.map(s,function(i){return function(o){return t.ap(i,o)}}),n)}}}function vr(r,t){return function(n){return function(s){return r.map(s,function(i){return t.map(i,n)})}}}function xe(r){return function(t,n){return function(s){return r.chain(s,function(i){return r.map(n(i),function(o){var u;return Object.assign({},i,(u={},u[t]=o,u))})})}}}var R=at,q=ut,yr=de(2,function(r,t){return se(r)?r:t(r.right)}),$e=function(r,t){return c(r,H(t))},ct=function(r,t){return c(r,Ar(t))},Te="Either",H=function(r){return function(t){return se(t)?t:q(r(t.right))}},kr={URI:Te,map:$e},Er=q,Ir=function(r){return function(t){return se(t)?t:se(r)?r:q(t.right(r.right))}},Ar=Ir,Br={URI:Te,map:$e,ap:ct},Pr={URI:Te,map:$e,ap:ct,chain:yr},qr=function(r,t){return function(n){return se(n)?R(r(n.left)):q(t(n.right))}},se=Cr,pt=function(r,t){return function(n){return se(n)?r(n.left):t(n.right)}},fe=pt,Mr=function(r,t){try{return q(r())}catch(n){return R(t(n))}},xr=Er(Me),$r=xe(Pr),rt=$r;function W(r){return typeof r=="function"?r():r}class me{constructor({onMounted:t,restoreState:n,initialState:s,onUnmounted:i,isPageReload:o}){e(this,"_isMounted",g.signal(!1));e(this,"isMounted",g.computed(this._isMounted));e(this,"mount");e(this,"unmount");this.mount=()=>{if(this.isMounted())return q(void 0);const u=W(o)?n():void 0,a=u?q(u):typeof s=="function"?s():q(s);return c(a,H(l=>{g.batch(()=>{this._isMounted.set(!0),t==null||t(l)})}))},this.unmount=()=>{this._isMounted()&&g.batch(()=>{this._isMounted.set(!1),i==null||i()})}}}function Ae(r){const t={};for(const n in r){const s=r[n];s!==void 0&&(t[n]=s)}return t}function ke(r,t){const n=Object.keys(r),s=Object.keys(t);return n.length!==s.length?!1:n.every(i=>Object.prototype.hasOwnProperty.call(t,i)&&r[i]===t[i])}class te{constructor({initialState:t,onChange:n}){e(this,"_state");e(this,"state");e(this,"setState",t=>{const n={...this.state(),...Ae(t)};ke(n,this.state())||this._state.set(n)});this._state=g.signal(t,{equals:ke}),this.state=g.computed(this._state),this.state.sub(n)}getter(t){return g.computed(()=>this._state()[t])}hasDiff(t){return!ke({...this.state(),...Ae(t)},this.state())}}function Z(r,t){return g.computed(()=>d.supports(r,W(t)))}var ae=Fr,_e=wr,Tr=function(r,t){return c(r,Lr(t))},Rr=function(r,t){return c(r,jr(t))},Or="Option",Lr=function(r){return function(t){return le(t)?ae:_e(r(t.value))}},Vr=_e,jr=function(r){return function(t){return le(t)||le(r)?ae:_e(t.value(r.value))}},Dr=de(2,function(r,t){return le(r)?ae:t(r.value)}),Ur={URI:Or,map:Tr,ap:Rr,chain:Dr},le=function(r){return r._tag==="None"},Gr=function(r,t){return function(n){return le(n)?r():t(n.value)}},lt=Gr,Hr=Vr(Me),nt=xe(Ur);function h(r){return Object.assign(L.throwifyFpFn(r),{ifAvailable(...t){return c(r.ifAvailable(...t),lt(()=>({ok:!1}),n=>({ok:!0,data:L.throwifyAnyEither(n)})))}})}function Wr(r){return it(q,r.of)}function Qr(r){return it(R,r.of)}function Kr(r){return vr(r,kr)}function Nr(r){return Sr(r,Br)}function zr(r){return function(t,n){return r.chain(t,function(s){return se(s)?r.of(s):n(s.right)})}}function Jr(r){return function(t,n,s){return r.map(t,qr(n,s))}}function Yr(r){return function(t,n){return function(s){return r.map(s,fe(t,n))}}}var Re=function(r,t){return c(r,Zr(t))},ht=function(r,t){return c(r,Xr(t))},Zr=function(r){return function(t){return function(){return Promise.resolve().then(t).then(r)}}},Xr=function(r){return function(t){return function(){return Promise.all([Promise.resolve().then(t),Promise.resolve().then(r)]).then(function(n){var s=n[0],i=n[1];return s(i)})}}},Oe=function(r){return function(){return Promise.resolve(r)}},en=de(2,function(r,t){return function(){return Promise.resolve().then(r).then(function(n){return t(n)()})}}),Le="Task",Ve={URI:Le,map:Re},dt={of:Oe},tn={URI:Le,map:Re,ap:ht},rn={URI:Le,map:Re,of:Oe,ap:ht,chain:en},nn=function(r,t,n,s){function i(o){return o instanceof n?o:new n(function(u){u(o)})}return new(n||(n=Promise))(function(o,u){function a(b){try{p(s.next(b))}catch(f){u(f)}}function l(b){try{p(s.throw(b))}catch(f){u(f)}}function p(b){b.done?o(b.value):i(b.value).then(a,l)}p((s=s.apply(r,t||[])).next())})},sn=function(r,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},s,i,o,u;return u={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function a(p){return function(b){return l([p,b])}}function l(p){if(s)throw new TypeError("Generator is already executing.");for(;u&&(u=0,p[0]&&(n=0)),n;)try{if(s=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=t.call(r,n)}catch(b){p=[6,b],i=0}finally{s=o=0}if(p[0]&5)throw p[1];return{value:p[0]?p[1]:void 0,done:!0}}},O=Qr(dt),M=Wr(dt),ft=Oe,on=Yr(Ve),an=function(r,t){return function(){return nn(void 0,void 0,void 0,function(){var n;return sn(this,function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,r().then(ut)];case 1:return[2,s.sent()];case 2:return n=s.sent(),[2,at(t(n))];case 3:return[2]}})})}},un=function(r,t){return c(r,I(t))},cn=function(r,t){return c(r,pn(t))},I=Kr(Ve),je=de(3,Jr(Ve)),pn=Nr(tn),De=de(2,zr(rn)),ln=M,hn="TaskEither",dn={URI:hn,map:un,ap:cn,chain:De},fn=ln(Me),mn=xe(dn),we=mn,J=De,ue=De;function oe(r){return[r]}class pe extends Q.errorClassWithData("ValidationError",(t,n)=>({input:t,issues:n}),"Validation error"){}class Ce extends Q.errorClass("CSSVarsBoundError","CSS variables are already bound"){}class mt extends Q.errorClassWithData("DeviceStorageMethodError",t=>({error:t}),t=>[t]){}class _t extends Q.errorClassWithData("SecureStorageMethodError",t=>({error:t}),t=>[t]){}class bt extends Q.errorClass("NotAvailableError",oe){}class _n extends Q.errorClass("InvalidEnvError",oe){}class gt extends Q.errorClass("FunctionNotAvailableError",oe){}class z extends Q.errorClass("InvalidArgumentsError",(t,n)=>[t,{cause:n}]){}class Se extends Q.errorClass("ConcurrentCallError",oe){}class Ft extends Q.errorClass("SetEmojiStatusError",t=>[`Failed to set emoji status: ${t}`]){}class Ue extends Q.errorClass("AccessDeniedError",oe){}class wt extends Q.errorClass("FullscreenFailedError",oe){}class Ct extends Q.errorClass("ShareMessageError",oe){}class St extends Q.errorClass("UnknownThemeParamsKeyError",t=>[`Unknown theme params key passed: ${t}`]){}function P(r,t){const n=g.computed(()=>W(t.version)||"100"),s=g.computed(()=>W(t.isTma)),{requires:i,returns:o}=t,u=i?typeof i=="object"?i:{every:[i]}:void 0,a=_=>{if(!t.supports)return!0;const F=t.supports[_];return d.supports(F.method,F.param,n())},l=()=>{if(!u)return;const[_,F]="every"in u?["every",u.every]:["some",u.some];for(let m=0;m<F.length;m++){const $=F[m],D=typeof $=="function"?$():d.supports($,n())?void 0:`it is unsupported in Mini Apps version ${n()}`;if(D&&(_==="every"||m===F.length-1))return D}},p=(..._)=>{for(const F in t.supports)if(t.supports[F].shouldCheck(..._)&&!a(F))return`option ${F} is not supported in Mini Apps version ${n()}`},b=g.computed(()=>!l()),f=g.computed(()=>n()!=="0.0"),C=g.computed(()=>t.isMounted?t.isMounted():!0),w=g.computed(()=>s()&&f()&&b()&&C()),v=_=>{const F=new gt(_);return["task","promise"].includes(t.returns)?O(F):R(F)},y=(..._)=>o==="plain"?Mr(()=>r(..._),F=>F):o==="promise"?an(()=>r(..._),F=>F):r(..._);return Object.assign((..._)=>{var D;const F="Unable to call function:";if(!s())return v(`${F} it can't be called outside Mini Apps`);if(!f())return v(`${F} the SDK was not initialized. Use the SDK init() function`);const m=l();if(m)return v(`${F} ${m}`);const $=p(..._);if($)return v(`${F} ${$}`);if(!C()){const V=(D=t.isMounting)!=null&&D.call(t)?"mounting. Wait for the mount completion":"unmounted. Use the mount() method";return v(`${F} the component is ${V}`)}return y(..._)},r,{isAvailable:w,ifAvailable(..._){return w()?_e(y(..._)):ae}},u?{isSupported:b}:{},t.supports?{supports:a}:{})}function A(r){return t=>P(t,r)}class ve{constructor({isTma:t,storage:n,onClick:s,offClick:i,initialState:o,isPageReload:u,postEvent:a,payload:l,method:p,version:b}){e(this,"isMounted");e(this,"isSupported");e(this,"state");e(this,"stateSetters");e(this,"stateBoolSetters");e(this,"setStateFp");e(this,"setState");e(this,"onClickFp");e(this,"onClick");e(this,"offClickFp");e(this,"offClick");e(this,"mountFp");e(this,"mount");e(this,"unmount");const f=new te({initialState:o,onChange(_){n.set(_)}}),C=new me({initialState:o,isPageReload:u,onMounted:f.setState,restoreState:n.get}),w={version:b,requires:p,isTma:t},v=A({...w,returns:"plain"}),y=A({...w,returns:"either",isMounted:C.isMounted});this.isMounted=C.isMounted,this.isSupported=Z(p,b),this.state=f.state,this.setStateFp=y(_=>{const F={...this.state(),...Ae(_)};return f.hasDiff(F)?c(a(p,l(F)),H(()=>{f.setState(F)})):q(void 0)}),this.setState=h(this.setStateFp),this.onClickFp=v(s),this.onClick=h(this.onClickFp),this.offClickFp=v(i),this.offClick=h(this.offClickFp),this.mountFp=v(()=>{const _=()=>{};return c(C.mount(),fe(_,_))}),this.mount=h(this.mountFp),this.unmount=C.unmount,this.stateSetters=_=>{const F=y(m=>this.setStateFp({[_]:m}));return[h(F),F]},this.stateBoolSetters=_=>{const[,F]=this.stateSetters(_),m=y(()=>F(!1)),$=y(()=>F(!0));return[[h(m),m],[h($),$]]}}stateGetter(t){return g.computed(()=>this.state()[t])}}class vt{constructor(t){e(this,"isVisible");e(this,"isMounted");e(this,"isSupported");e(this,"hideFp");e(this,"hide");e(this,"showFp");e(this,"show");e(this,"onClickFp");e(this,"onClick");e(this,"offClickFp");e(this,"offClick");e(this,"mountFp");e(this,"mount");e(this,"unmount");const n=new ve({...t,method:"web_app_setup_back_button",payload:s=>({is_visible:s.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 S(){return{isTma:g.computed(()=>d.isTMAFp())}}function ce(r){return t=>({...t,...W(r)})}function be(r,t){return g.signal(r,t)}const yt=be(d.postEventFp),ie=(...r)=>yt()(...r),kt=(...r)=>L.throwifyAnyEither(ie(...r)),j=ce({postEvent:ie});function bn(r){return{get:()=>L.getStorageValue(r),set(t){L.setStorageValue(r,t)}}}function gn(){return performance.getEntriesByType("navigation")[0]}function Fn(){const r=gn();return!!r&&r.type==="reload"}function re(r){return ce({storage:bn(r),isPageReload:Fn})}const Be=be("0.0"),k=ce({version:Be});function Ge(r,t){return{...c(S(),j,k,re(r)),onClick(n,s){return d.on(t,n,s)},offClick(n,s){d.off(t,n,s)}}}const wn=new vt(Ge("backButton","back_button_pressed"));class He{constructor({initialState:t,onMounted:n,restoreState:s,onUnmounted:i,isPageReload:o}){e(this,"_isMounted",g.signal(!1));e(this,"isMounted",g.computed(this._isMounted));e(this,"mount");e(this,"unmount");this.mount=u=>{if(this._isMounted())return M(void 0);const a=W(o)?s():void 0;return c(a?M(a):t(u),I(l=>{this._isMounted()||g.batch(()=>{this._isMounted.set(!0),n==null||n(l)})}))},this.unmount=()=>{this._isMounted()&&g.batch(()=>{this._isMounted.set(!1),i==null||i()})}}}function st(){return new bt("Biometry is not available")}function Ee(r){let t=!1,n=!1,s="",i=!1,o="",u=!1;return r.available&&(t=!0,n=r.token_saved,s=r.device_id,i=r.access_requested,o=r.type,u=r.access_granted),{available:t,tokenSaved:n,deviceId:s,type:o,accessGranted:u,accessRequested:i}}class Et{constructor({version:t,request:n,postEvent:s,storage:i,onInfoReceived:o,offInfoReceived:u,isTma:a,isPageReload:l}){e(this,"isAvailable");e(this,"isSupported");e(this,"isMounted");e(this,"state");e(this,"authenticateFp");e(this,"authenticate");e(this,"openSettingsFp");e(this,"openSettings");e(this,"requestAccessFp");e(this,"requestAccess");e(this,"updateTokenFp");e(this,"updateToken");e(this,"mountFp");e(this,"mount");e(this,"unmount");const p=_=>{b.setState(Ee(_))},b=new te({initialState:{available:!1,type:"unknown",accessGranted:!1,accessRequested:!1,deviceId:"",tokenSaved:!1},onChange:i.set}),f=new He({initialState(_){return c(n("web_app_biometry_get_info","biometry_info_received",_),I(Ee))},isPageReload:l,onMounted(_){b.setState(_),o(p)},onUnmounted(){u(p)},restoreState:i.get}),C={version:t,requires:"web_app_biometry_request_auth",isTma:a},w=A({...C,returns:"either"}),v=A({...C,returns:"task"}),y=A({...C,isMounted:f.isMounted,returns:"task"});this.isAvailable=b.getter("available"),this.isMounted=f.isMounted,this.isSupported=Z("web_app_biometry_request_auth",t),this.state=b.state,this.unmount=f.unmount,this.mountFp=v(f.mount),this.authenticateFp=y(_=>this.isAvailable()?c(n("web_app_biometry_request_auth","biometry_auth_requested",{..._,params:{reason:((_||{}).reason||"").trim()}}),I(F=>(b.setState({token:F.token}),F))):O(st())),this.openSettingsFp=w(()=>s("web_app_biometry_open_settings")),this.requestAccessFp=y(_=>c(n("web_app_biometry_request_access","biometry_info_received",{..._,params:{reason:((_||{}).reason||"").trim()}}),J(F=>{const m=Ee(F);return m.available?(b.setState(m),M(m.accessRequested)):O(st())}))),this.updateTokenFp=y((_={})=>{var F;return c(n("web_app_biometry_update_token","biometry_token_updated",{..._,params:{token:_.token||"",reason:(F=_.reason)==null?void 0:F.trim()}}),I(m=>m.status))}),this.authenticate=h(this.authenticateFp),this.openSettings=h(this.openSettingsFp),this.requestAccess=h(this.requestAccessFp),this.updateToken=h(this.updateTokenFp),this.mount=h(this.mountFp)}}const It=(r,t,n)=>d.requestFp(r,t,{postEvent:ie,...n}),We=(r,t,n)=>d.request2Fp(r,t,{postEvent:ie,...n}),Cn=(...r)=>ot.BetterPromise.fn(()=>It(...r)()),Sn=(...r)=>ot.BetterPromise.fn(()=>We(...r)()),U=ce({request:We});function vn(){return new Et({...c(S(),j,k,U,re("biometry")),offInfoReceived(r){d.off("biometry_info_received",r)},onInfoReceived(r){return d.on("biometry_info_received",r)}})}const yn=vn();class At{constructor({postEvent:t,storage:n,isTma:s,isPageReload:i}){e(this,"isConfirmationEnabled");e(this,"isMounted");e(this,"mountFp");e(this,"mount");e(this,"unmount");e(this,"disableConfirmationFp");e(this,"disableConfirmation");e(this,"enableConfirmationFp");e(this,"enableConfirmation");const o=new te({initialState:{isConfirmationEnabled:!1},onChange(f){n.set(f)}}),u=new me({onMounted:o.setState,restoreState:n.get,initialState:{isConfirmationEnabled:!1},isPageReload:i}),a={requires:"web_app_setup_closing_behavior",isTma:s},l=A({...a,returns:"plain"}),p=A({...a,returns:"either",isMounted:u.isMounted}),b=f=>f===this.isConfirmationEnabled()?q(void 0):(o.setState({isConfirmationEnabled:f}),t("web_app_setup_closing_behavior",{need_confirmation:f}));this.isConfirmationEnabled=o.getter("isConfirmationEnabled"),this.isMounted=u.isMounted,this.disableConfirmationFp=p(()=>b(!1)),this.enableConfirmationFp=p(()=>b(!0)),this.mountFp=l(()=>{const f=()=>{};return c(u.mount(),fe(f,f))}),this.unmount=u.unmount,this.disableConfirmation=h(this.disableConfirmationFp),this.enableConfirmation=h(this.enableConfirmationFp),this.mount=h(this.mountFp)}}function kn(){return new At(c(S(),re("closingBehavior"),j))}const En=kn();class Bt{constructor({version:t,isTma:n,invokeCustomMethod:s}){e(this,"isSupported");e(this,"deleteItemFp");e(this,"deleteItem");e(this,"getItemFp");e(this,"getItem");e(this,"getItemsFp");e(this,"getItems");e(this,"getKeysFp");e(this,"getKeys");e(this,"setItemFp");e(this,"setItem");e(this,"clearFp");e(this,"clear");const i=A({version:t,requires:"web_app_invoke_custom_method",isTma:n,returns:"task"});this.isSupported=Z("web_app_invoke_custom_method",t),this.deleteItemFp=i((o,u)=>{const a=Array.isArray(o)?o:[o];return c(a.length?s("deleteStorageValues",{keys:a},u):M(void 0),I(()=>{}))}),this.getItemFp=i((o,u)=>c(this.getItemsFp([o],u),I(a=>a[o]||""))),this.getItemsFp=i((o,u)=>c(o.length?s("getStorageValues",{keys:o},u):M({}),I(a=>({...o.reduce((l,p)=>(l[p]="",l),{}),...E.parse(E.record(E.string(),E.string()),a)})))),this.getKeysFp=i(o=>c(s("getStorageKeys",{},o),I(u=>E.parse(E.array(E.string()),u)))),this.setItemFp=i((o,u,a)=>c(s("saveStorageValue",{key:o,value:u},a),I(()=>{}))),this.clearFp=i(o=>c(this.getKeysFp(o),J(this.deleteItemFp))),this.deleteItem=h(this.deleteItemFp),this.getItem=h(this.getItemFp),this.getItems=h(this.getItemsFp),this.getKeys=h(this.getKeysFp),this.setItem=h(this.setItemFp),this.clear=h(this.clearFp)}}const Ie=be(0);function ye(){return Ie.set(Ie()+1),Ie().toString()}function Pt(r,t,n){return d.invokeCustomMethodFp(r,t,ye(),{...n||{},postEvent:ie})}const Qe=ce({invokeCustomMethod:Pt});function In(){return new Bt(c(S(),k,Qe))}const An=In();class qt{constructor({isTma:t,request:n,version:s,createRequestId:i}){e(this,"getItemFp");e(this,"getItem");e(this,"setItemFp");e(this,"setItem");e(this,"deleteItemFp");e(this,"deleteItem");e(this,"clearFp");e(this,"clear");const o=A({version:s,requires:"web_app_device_storage_get_key",isTma:t,returns:"task"}),u=(a,l,p)=>{const b=i();return c(n(a,["device_storage_failed",l],{params:{...p,req_id:b},capture:f=>"payload"in f?f.payload.req_id===b:!0}),J(f=>f.event==="device_storage_failed"?O(new mt(f.payload.error||"UNKNOWN_ERROR")):M(f.payload)))};this.getItemFp=o(a=>c(u("web_app_device_storage_get_key","device_storage_key_received",{key:a}),I(l=>l.value))),this.setItemFp=o((a,l)=>c(u("web_app_device_storage_save_key","device_storage_key_saved",{key:a,value:l}),I(()=>{}))),this.deleteItemFp=o(a=>this.setItemFp(a,null)),this.clearFp=o(()=>c(u("web_app_device_storage_clear","device_storage_cleared",{}),I(()=>{}))),this.getItem=h(this.getItemFp),this.setItem=h(this.setItemFp),this.deleteItem=h(this.deleteItemFp),this.clear=h(this.clearFp)}}const Mt=ce({createRequestId:ye});function Bn(){return new qt(c(S(),k,U,Mt))}const Pn=Bn();function qn({request:r,...t}){return P(n=>c(r("web_app_request_emoji_status_access","emoji_status_access_requested",n),I(s=>s.status)),{...t,requires:"web_app_request_emoji_status_access",returns:"task"})}function Mn(){return qn(c(S(),k,U))}const xt=Mn(),xn=h(xt);function $n({request:r,...t}){return P((n,s)=>c(r("web_app_set_emoji_status",["emoji_status_set","emoji_status_failed"],{params:{custom_emoji_id:n,duration:(s||{}).duration},...s}),ue(i=>i.event==="emoji_status_failed"?O(new Ft(i.payload.error)):M(void 0))),{...t,requires:"web_app_set_emoji_status",returns:"task"})}function Tn(){return $n(c(S(),U,k))}const $t=Tn(),Rn=h($t);class Tt{constructor({postEvent:t,isTma:n,version:s}){e(this,"isSupported");e(this,"impactOccurredFp");e(this,"impactOccurred");e(this,"notificationOccurredFp");e(this,"notificationOccurred");e(this,"selectionChangedFp");e(this,"selectionChanged");const i="web_app_trigger_haptic_feedback",o=A({requires:i,isTma:n,version:s,returns:"plain"});this.isSupported=Z(i,s),this.impactOccurredFp=o(u=>t(i,{type:"impact",impact_style:u})),this.notificationOccurredFp=o(u=>t(i,{type:"notification",notification_type:u})),this.selectionChangedFp=o(()=>t(i,{type:"selection_change"})),this.impactOccurred=h(this.impactOccurredFp),this.notificationOccurred=h(this.notificationOccurredFp),this.selectionChanged=h(this.selectionChangedFp)}}function On(){return new Tt(c(S(),j,k))}const Ln=On();function Vn({postEvent:r,...t}){return P(()=>r("web_app_add_to_home_screen"),{...t,requires:"web_app_add_to_home_screen",returns:"either"})}function jn(){return Vn(c(S(),k,j))}const Rt=jn(),Dn=h(Rt);function Un({request:r,...t}){return P(n=>c(r("web_app_check_home_screen","home_screen_checked",n),I(s=>s.status||"unknown")),{...t,requires:"web_app_check_home_screen",returns:"task"})}function Gn(){return Un(c(S(),k,U))}const Ot=Gn(),Hn=h(Ot);class Lt{constructor({retrieveInitData:t}){e(this,"_state",g.signal());e(this,"_raw",g.signal());e(this,"state",g.computed(this._state));e(this,"authDate",this.fromState("auth_date"));e(this,"canSendAfter",this.fromState("can_send_after"));e(this,"canSendAfterDate",g.computed(()=>{const t=this.authDate(),n=this.canSendAfter();return n&&t?new Date(t.getTime()+n*1e3):void 0}));e(this,"chat",this.fromState("chat"));e(this,"chatType",this.fromState("chat_type"));e(this,"chatInstance",this.fromState("chat_instance"));e(this,"hash",this.fromState("hash"));e(this,"queryId",this.fromState("query_id"));e(this,"raw",g.computed(this._raw));e(this,"receiver",this.fromState("receiver"));e(this,"signature",this.fromState("signature"));e(this,"startParam",this.fromState("start_param"));e(this,"user",this.fromState("user"));e(this,"restoreFp");e(this,"restore");this.restoreFp=()=>c(t(),H(lt(()=>{},({raw:n,obj:s})=>{this._state.set(s),this._raw.set(n)}))),this.restore=L.throwifyFpFn(this.restoreFp)}fromState(t){return g.computed(()=>{const n=this._state();return n?n[t]:void 0})}}function Wn(){return new Lt({retrieveInitData(){return c(xr,rt("obj",()=>c(d.retrieveLaunchParamsFp(),H(({tgWebAppData:r})=>r?_e(r):ae))),rt("raw",d.retrieveRawInitDataFp),H(({obj:r,raw:t})=>c(Hr,nt("obj",()=>r),nt("raw",()=>t))))}})}const Qn=Wn();class Vt{constructor({version:t,request:n,isTma:s}){e(this,"isOpened");e(this,"isSupported");e(this,"openSlugFp");e(this,"openSlug");e(this,"openUrlFp");e(this,"openUrl");const i=A({version:t,isTma:s,requires:"web_app_open_invoice",returns:"task"}),o=g.signal(!1),u=()=>{o.set(!1)};this.isSupported=Z("web_app_open_invoice",t),this.isOpened=g.computed(o),this.openSlugFp=i((a,l)=>c(this.isOpened()?O(new Se("Invoice is already opened")):M(void 0),J(()=>(o.set(!0),n("web_app_open_invoice","invoice_closed",{...l,params:{slug:a},capture:p=>a===p.slug}))),je(p=>(u(),p),p=>(u(),p.status)))),this.openUrlFp=i((a,l)=>{const{hostname:p,pathname:b}=new URL(a,window.location.href);if(p!=="t.me")return O(new z(`Link has unexpected hostname: ${p}`));const f=b.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);return f?this.openSlugFp(f[2],l):O(new z('Expected to receive a link with a pathname in format "/invoice/{slug}" or "/${slug}"'))}),this.openUrl=h(this.openUrlFp),this.openSlug=h(this.openSlugFp)}}function Kn(){return new Vt(c(S(),U,k))}const Nn=Kn();function zn({postEvent:r,...t}){return P((n,s={})=>{if(typeof n=="string")try{n=new URL(n)}catch(i){return R(new z(`"${n.toString()}" is invalid URL`,i))}return r("web_app_open_link",{url:n.toString(),try_browser:s.tryBrowser,try_instant_view:s.tryInstantView})},{...t,returns:"either"})}function Jn(){return zn(c(S(),j))}const jt=Jn(),Yn=h(jt);function Zn({postEvent:r,version:t,...n}){return P(s=>{const i=s.toString();return i.match(/^https:\/\/t.me\/.+/)?d.supports("web_app_open_tg_link",W(t))?(s=new URL(s),r("web_app_open_tg_link",{path_full:s.pathname+s.search})):(window.location.href=i,q(void 0)):R(new z(`"${i}" is invalid URL`))},{...n,returns:"either"})}function Xn(){return Zn(c(S(),j,k))}const Ke=Xn(),es=h(Ke);function ts({openTelegramLink:r,...t}){return P((n,s)=>r("https://t.me/share/url?"+new URLSearchParams({url:n,text:s||""}).toString().replace(/\+/g,"%20")),{...t,returns:"either"})}function rs(){return ts({...S(),openTelegramLink:Ke})}const Dt=rs(),ns=h(Dt);function ss(r){let t=!1,n,s;return r.available&&(t=!0,n=r.access_requested,s=r.access_granted),{available:t,accessGranted:s||!1,accessRequested:n||!1}}class Ut{constructor({version:t,request:n,postEvent:s,storage:i,isTma:o,isPageReload:u}){e(this,"state");e(this,"isAvailable");e(this,"isAccessGranted");e(this,"isAccessRequested");e(this,"isMounted");e(this,"isSupported");e(this,"openSettingsFp");e(this,"openSettings");e(this,"requestLocationFp");e(this,"requestLocation");e(this,"mountFp");e(this,"mount");e(this,"unmount");const a=new te({initialState:{available:!1,accessGranted:!1,accessRequested:!1},onChange:i.set}),l=new He({isPageReload:u,restoreState:i.get,onMounted:a.setState,initialState(w){return c(n("web_app_check_location","location_checked",w),I(ss))}}),p={version:t,requires:"web_app_check_location",isTma:o},b=A({...p,returns:"either"}),f=A({...p,returns:"task"}),C=A({...p,returns:"task",isMounted:l.isMounted});this.isAvailable=a.getter("available"),this.isAccessRequested=a.getter("accessRequested"),this.isAccessGranted=a.getter("accessGranted"),this.isSupported=Z("web_app_check_location",t),this.isMounted=l.isMounted,this.state=a.state,this.unmount=l.unmount,this.mountFp=f(l.mount),this.openSettingsFp=b(()=>s("web_app_open_location_settings")),this.requestLocationFp=C(w=>c(n("web_app_request_location","location_requested",w),I(v=>{if(!v.available)return a.setState({available:!1}),null;const{available:y,..._}=v;return _}))),this.mount=h(this.mountFp),this.openSettings=h(this.openSettingsFp),this.requestLocation=h(this.requestLocationFp)}}function os(){return new Ut(c(S(),j,k,U,re("locationManager")))}const is=os();class Gt{constructor({defaults:t,...n}){e(this,"bgColor");e(this,"hasShineEffect");e(this,"isEnabled");e(this,"isLoaderVisible");e(this,"isVisible");e(this,"isMounted");e(this,"state");e(this,"text");e(this,"textColor");e(this,"showFp");e(this,"show");e(this,"hideFp");e(this,"hide");e(this,"enableFp");e(this,"enable");e(this,"enableShineEffectFp");e(this,"enableShineEffect");e(this,"disableFp");e(this,"disable");e(this,"disableShineEffectFp");e(this,"disableShineEffect");e(this,"setBgColorFp");e(this,"setBgColor");e(this,"setTextColorFp");e(this,"setTextColor");e(this,"setTextFp");e(this,"setText");e(this,"showLoaderFp");e(this,"showLoader");e(this,"hideLoaderFp");e(this,"hideLoader");e(this,"setParamsFp");e(this,"setParams");e(this,"mountFp");e(this,"mount");e(this,"unmount");e(this,"onClickFp");e(this,"onClick");e(this,"offClickFp");e(this,"offClick");const s=new ve({...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,u)=>{const a=s.stateGetter(o);return g.computed(()=>a()||W(u))};this.bgColor=i("bgColor",t.bgColor),this.textColor=i("textColor",t.textColor),this.hasShineEffect=s.stateGetter("hasShineEffect"),this.isEnabled=s.stateGetter("isEnabled"),this.isLoaderVisible=s.stateGetter("isLoaderVisible"),this.text=s.stateGetter("text"),this.isVisible=s.stateGetter("isVisible"),this.isMounted=s.isMounted,this.state=s.state,[this.setBgColor,this.setBgColorFp]=s.stateSetters("bgColor"),[this.setTextColor,this.setTextColorFp]=s.stateSetters("textColor"),[[this.disableShineEffect,this.disableShineEffectFp],[this.enableShineEffect,this.enableShineEffectFp]]=s.stateBoolSetters("hasShineEffect"),[[this.disable,this.disableFp],[this.enable,this.enableFp]]=s.stateBoolSetters("isEnabled"),[[this.hideLoader,this.hideLoaderFp],[this.showLoader,this.showLoaderFp]]=s.stateBoolSetters("isLoaderVisible"),[this.setText,this.setTextFp]=s.stateSetters("text"),[[this.hide,this.hideFp],[this.show,this.showFp]]=s.stateBoolSetters("isVisible"),this.setParams=s.setState,this.setParamsFp=s.setStateFp,this.onClick=s.onClick,this.onClickFp=s.onClickFp,this.offClick=s.offClick,this.offClickFp=s.offClickFp,this.mount=s.mount,this.mountFp=s.mountFp,this.unmount=s.unmount}}function Ne(r,t){document.documentElement.style.setProperty(r,t)}function ze(r){document.documentElement.style.removeProperty(r)}function Ht(r){return c(x.toRGBFullFp(r),H(t=>Math.sqrt([.299,.587,.114].reduce((n,s,i)=>{const o=parseInt(t.slice(1+i*2,1+(i+1)*2),16);return n+o*o*s},0))<120))}const Je=L.throwifyFpFn(Ht);class Wt{constructor({initialState:t,onChange:n,offChange:s,isTma:i,storage:o,isPageReload:u}){e(this,"accentTextColor");e(this,"bgColor");e(this,"buttonColor");e(this,"buttonTextColor");e(this,"bottomBarBgColor");e(this,"destructiveTextColor");e(this,"headerBgColor");e(this,"hintColor");e(this,"linkColor");e(this,"secondaryBgColor");e(this,"sectionBgColor");e(this,"sectionHeaderTextColor");e(this,"sectionSeparatorColor");e(this,"subtitleTextColor");e(this,"textColor");e(this,"_isCssVarsBound",g.signal(!1));e(this,"isCssVarsBound",g.computed(this._isCssVarsBound));e(this,"bindCssVarsFp");e(this,"bindCssVars");e(this,"state");e(this,"isDark",g.computed(()=>{const t=this.bgColor();return!t||Je(t)}));e(this,"isMounted");e(this,"mountFp");e(this,"mount");e(this,"unmount");const a=new te({initialState:{},onChange:o.set}),l=w=>{a.setState(w.theme_params)},p=new me({initialState:()=>q(W(t)),isPageReload:u,onMounted(w){a.setState(w),n(l)},onUnmounted(){s(l)},restoreState:o.get}),b={isTma:i,returns:"either"},f=A(b),C=A({...b,isMounted:p.isMounted});this.accentTextColor=a.getter("accent_text_color"),this.bgColor=a.getter("bg_color"),this.buttonColor=a.getter("button_color"),this.buttonTextColor=a.getter("button_text_color"),this.bottomBarBgColor=a.getter("bottom_bar_bg_color"),this.destructiveTextColor=a.getter("destructive_text_color"),this.headerBgColor=a.getter("header_bg_color"),this.hintColor=a.getter("hint_color"),this.linkColor=a.getter("link_color"),this.secondaryBgColor=a.getter("secondary_bg_color"),this.sectionBgColor=a.getter("section_bg_color"),this.sectionHeaderTextColor=a.getter("section_header_text_color"),this.sectionSeparatorColor=a.getter("section_separator_color"),this.subtitleTextColor=a.getter("subtitle_text_color"),this.textColor=a.getter("text_color"),this.state=a.state,this.isMounted=p.isMounted,this.bindCssVarsFp=C(w=>{if(this._isCssVarsBound())return R(new Ce);w||(w=_=>`--tg-theme-${L.snakeToKebab(_)}`);const v=_=>{Object.entries(a.state()).forEach(([F,m])=>{m&&_(F,m)})},y=()=>{v((_,F)=>{Ne(w(_),F)})};return y(),a.state.sub(y),this._isCssVarsBound.set(!0),q(()=>{v(ze),a.state.unsub(y),this._isCssVarsBound.set(!1)})}),this.mountFp=f(p.mount),this.unmount=p.unmount,this.bindCssVars=h(this.bindCssVarsFp),this.mount=h(this.mountFp)}}const Pe=be({});function as(){return new Wt({...c(S(),re("themeParams")),offChange(r){d.off("theme_changed",r)},onChange(r){d.on("theme_changed",r)},initialState:Pe})}const he=as();function Qt(r,t,n){return c(Ge(r,t),s=>({...s,defaults:n}))}const us=new Gt(Qt("mainButton","main_button_pressed",{bgColor:g.computed(()=>he.buttonColor()||"#2481cc"),textColor:g.computed(()=>he.buttonTextColor()||"#ffffff")}));class Kt{constructor({storage:t,isPageReload:n,version:s,postEvent:i,isTma:o,theme:u,onVisibilityChanged:a,offVisibilityChanged:l}){e(this,"isSupported");e(this,"isDark",g.computed(()=>{const t=this.bgColorRgb();return t?Je(t):!1}));e(this,"isActive");e(this,"state");e(this,"isCssVarsBound");e(this,"bindCssVarsFp");e(this,"bindCssVars");e(this,"isMounted");e(this,"mountFp");e(this,"mount");e(this,"unmount");e(this,"bgColor");e(this,"bgColorRgb");e(this,"setBgColorFp");e(this,"setBgColor");e(this,"headerColor");e(this,"headerColorRgb");e(this,"setHeaderColorFp");e(this,"setHeaderColor");e(this,"bottomBarColor");e(this,"bottomBarColorRgb");e(this,"setBottomBarColorFp");e(this,"setBottomBarColor");e(this,"closeFp");e(this,"close");e(this,"readyFp");e(this,"ready");const p=m=>{C.setState({isActive:m.is_visible})},b=m=>{[[this.headerColor,"web_app_set_header_color"],[this.bgColor,"web_app_set_background_color"],[this.bottomBarColor,"web_app_set_bottom_bar_color"]].forEach(([$,D])=>{const V=$();if(!x.isRGB(V)&&(D!=="web_app_set_header_color"||!["bg_color","secondary_bg_color"].includes(V))){const K=m[V];K&&i(D,{color:K})}})},f=new me({initialState(){return q({bgColor:"bg_color",headerColor:"header_bg_color",bottomBarColor:"bottom_bar_bg_color",isActive:!0})},isPageReload:n,onMounted:m=>{a(p),u.sub(b),C.setState(m)},onUnmounted(){l(p),u.unsub(b)},restoreState:t.get});this.isMounted=f.isMounted,this.mountFp=P(()=>{const m=()=>{};return c(f.mount(),fe(m,m))},{isTma:o,returns:"plain"}),this.mount=h(this.mountFp),this.unmount=f.unmount;const C=new te({initialState:{bgColor:"bg_color",bottomBarColor:"bottom_bar_bg_color",headerColor:"bg_color",isActive:!1},onChange:t.set});this.state=C.state;const w=m=>x.isRGB(m)?m:W(u)[m],v=m=>g.computed(()=>w(m()));this.isActive=C.getter("isActive"),this.isSupported=g.computed(()=>["web_app_set_header_color","web_app_set_background_color","web_app_set_bottom_bar_color"].some(m=>d.supports(m,W(s))));const y=g.signal(!1);this.isCssVarsBound=g.computed(y),this.bindCssVarsFp=P(m=>{if(y())return R(new Ce);const[$,D]=L.createCbCollector(()=>{y.set(!1)}),V=(K,G)=>{const Y=()=>{Ne(K,G()||null)};Y(),$(G.sub(Y),ze.bind(null,K))};return m||(m=K=>`--tg-${L.camelToKebab(K)}`),V(m("bgColor"),this.bgColorRgb),V(m("bottomBarColor"),this.bottomBarColorRgb),V(m("headerColor"),this.headerColorRgb),y.set(!0),q(D)},{isTma:o,returns:"either",isMounted:this.isMounted}),this.bindCssVars=h(this.bindCssVarsFp);const _=m=>{const $=C.getter(m),D=v($),V={headerColor:"web_app_set_header_color",bgColor:"web_app_set_background_color",bottomBarColor:"web_app_set_bottom_bar_color"}[m],K=P(G=>{if(G===$())return q(void 0);if(V==="web_app_set_header_color"&&(G==="bg_color"||G==="secondary_bg_color"))return c(i("web_app_set_header_color",{color_key:G}),H(()=>{C.setState({[m]:G})}));const Y=w(G);return c(Y?i(V,{color:Y}):R(new St(G)),H(()=>{C.setState({[m]:G})}))},{isTma:o,version:s,requires:V,isMounted:this.isMounted,returns:"either",supports:m==="headerColor"?{rgb:{method:"web_app_set_header_color",param:"color",shouldCheck:x.isRGB}}:void 0});return[$,D,h(K),K]};[this.bgColor,this.bgColorRgb,this.setBgColor,this.setBgColorFp]=_("bgColor"),[this.headerColor,this.headerColorRgb,this.setHeaderColor,this.setHeaderColorFp]=_("headerColor"),[this.bottomBarColor,this.bottomBarColorRgb,this.setBottomBarColor,this.setBottomBarColorFp]=_("bottomBarColor");const F=A({isTma:o,returns:"either"});this.closeFp=F(m=>i("web_app_close",{return_back:m})),this.close=h(this.closeFp),this.readyFp=F(()=>i("web_app_ready")),this.ready=h(this.readyFp)}}function cs(){return new Kt({...c(S(),j,k,re("miniApp")),offVisibilityChanged(r){d.off("visibility_changed",r)},onVisibilityChanged(r){d.on("visibility_changed",r)},theme:he.state})}const Nt=cs();function ps(r){const t=r.message.trim(),n=(r.title||"").trim(),s=r.buttons||[];if(n.length>64)return R(new z(`Invalid title: ${n}`));if(!t||t.length>256)return R(new z(`Invalid message: ${t}`));if(s.length>3)return R(new z(`Invalid buttons count: ${s.length}`));const i=[];if(!s.length)i.push({type:"close",id:""});else for(let o=0;o<s.length;o++){const u=s[o],a=u.id||"";if(a.length>64)return R(new z(`Button with index ${o} has invalid id: ${a}`));if(!u.type||u.type==="default"||u.type==="destructive"){const l=u.text.trim();if(!l||l.length>64)return R(new z(`Button with index ${o} has invalid text: ${l}`));i.push({type:u.type,text:l,id:a})}else i.push({type:u.type,id:a})}return q({title:n,message:t,buttons:i})}class zt{constructor({version:t,isTma:n,request:s}){e(this,"isOpened");e(this,"isSupported");e(this,"showFp");e(this,"show");const i=g.signal(!1),o=()=>{i.set(!1)},u=A({version:t,isTma:n,requires:"web_app_open_popup",returns:"task"});this.isSupported=Z("web_app_open_popup",t),this.isOpened=g.computed(i),this.showFp=u(a=>c(this.isOpened()?O(new Se("A popup is already opened")):M(void 0),ue(()=>ft(ps(a))),J(l=>(i.set(!0),s("web_app_open_popup","popup_closed",{...a,params:l}))),je(l=>(o(),l),l=>(o(),l.button_id)))),this.show=h(this.showFp)}}function ls(){return new zt(c(S(),U,k))}const hs=ls();function ds({request:r,...t}){return P(n=>c(r("web_app_request_phone","phone_requested",n),I(s=>s.status)),{...t,requires:"web_app_request_phone",returns:"task"})}function fs(){return ds(c(S(),k,U))}const Ye=fs(),ms=h(Ye);function _s({invokeCustomMethod:r,requestPhoneAccess:t,...n}){const s=u=>c(r("getRequestedContact",{},{...u,timeout:(u||{}).timeout||5e3}),ue(a=>{const l=E.safeParse(E.string(),a);if(!l.success)return O(new pe(a,l.issues));if(!l.output)return M(void 0);const p=E.safeParse(x.pipeQueryToSchema(E.looseObject({contact:x.pipeJsonToSchema(E.looseObject({user_id:E.number(),phone_number:E.string(),first_name:E.string(),last_name:E.optional(E.string())})),auth_date:E.pipe(E.string(),E.transform(b=>new Date(Number(b)*1e3)),E.date()),hash:E.string()})),l.output);return p.success?M({raw:l.output,parsed:p.output}):O(new pe(l.output,p.issues))})),i=u=>c(s(u),on(a=>pe.is(a)?R(a):q(void 0),a=>q(a))),o=u=>L.BetterTaskEither(async(a,l,p)=>{let b=50;for(;!p.isRejected;){const f=await i(p)();if(f._tag==="Left")return l(f.left);if(f.right)return a(f.right);await new Promise(C=>setTimeout(C,b)),b+=50}},u);return P(u=>L.BetterTaskEither.fn(a=>c(i(a),J(l=>l?M(l):c(t(a),ue(p=>p==="sent"?o(a):O(new Ue("User denied access")))))),u),{...n,returns:"task",requires:"web_app_request_phone"})}function bs(){return _s({...c(S(),Qe,k),requestPhoneAccess:Ye})}function gs({requestContact:r,...t}){return P(r,{...t,returns:"task",requires:"web_app_request_phone"})}function Fs(){return gs({...c(S(),k),requestContact(r){return c(Ze(r),I(t=>t.parsed))}})}const Ze=bs(),ws=h(Ze),Jt=Fs(),Cs=h(Jt);function Ss({request:r,...t}){return P(n=>c(r("web_app_request_write_access","write_access_requested",n),I(s=>s.status)),{...t,requires:"web_app_request_write_access",returns:"task"})}function vs(){return Ss(c(S(),k,U))}const Yt=vs(),ys=h(Yt);class Zt{constructor({version:t,onClosed:n,onTextReceived:s,isTma:i,postEvent:o}){e(this,"isOpened");e(this,"isSupported");e(this,"captureFp");e(this,"capture");e(this,"closeFp");e(this,"close");e(this,"openFp");e(this,"open");const u={version:t,requires:"web_app_open_scan_qr_popup",isTma:i},a=A({...u,returns:"either"}),l=A({...u,returns:"task"}),p=g.signal(!1),b=()=>{p.set(!1)};this.isSupported=Z("web_app_open_scan_qr_popup",t),this.isOpened=g.computed(p),this.captureFp=l(f=>{let C;return c(this.openFp({...f,onCaptured:w=>{f.capture(w)&&(C=w,this.close())}}),I(()=>C))}),this.closeFp=a(()=>c(o("web_app_close_scan_qr_popup"),H(b))),this.openFp=l(f=>c(p()?O(new Se("The QR Scanner is already opened")):async()=>o("web_app_open_scan_qr_popup",{text:f.text}),ue(()=>{p.set(!0);const[C,w]=L.createCbCollector(),v=y=>(w(),p.set(!1),y);return c(L.BetterTaskEither(y=>{C(n(y),p.sub(_=>{_||y()}),s(f.onCaptured))},f),je(v,v))}))),this.open=h(this.openFp),this.capture=h(this.captureFp),this.close=h(this.closeFp)}}function ks(){return new Zt({...c(S(),j,k),onClosed(r){return d.on("scan_qr_popup_closed",r)},onTextReceived(r){return d.on("qr_text_received",t=>{r(t.data)})}})}const Es=ks();class Xt{constructor({defaults:t,...n}){e(this,"isSupported");e(this,"position");e(this,"bgColor");e(this,"hasShineEffect");e(this,"isEnabled");e(this,"isLoaderVisible");e(this,"isVisible");e(this,"isMounted");e(this,"state");e(this,"text");e(this,"textColor");e(this,"showFp");e(this,"show");e(this,"hideFp");e(this,"hide");e(this,"enableFp");e(this,"enable");e(this,"enableShineEffectFp");e(this,"enableShineEffect");e(this,"disableFp");e(this,"disable");e(this,"disableShineEffectFp");e(this,"disableShineEffect");e(this,"setBgColorFp");e(this,"setBgColor");e(this,"setTextColorFp");e(this,"setTextColor");e(this,"setTextFp");e(this,"setText");e(this,"setPositionFp");e(this,"setPosition");e(this,"showLoaderFp");e(this,"showLoader");e(this,"hideLoaderFp");e(this,"hideLoader");e(this,"setParamsFp");e(this,"setParams");e(this,"mountFp");e(this,"mount");e(this,"unmount");e(this,"onClickFp");e(this,"onClick");e(this,"offClickFp");e(this,"offClick");const s=new ve({...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,u)=>{const a=s.stateGetter(o);return g.computed(()=>a()||W(u))};this.isSupported=Z("web_app_setup_secondary_button",n.version),this.bgColor=i("bgColor",t.bgColor),this.textColor=i("textColor",t.textColor),this.position=s.stateGetter("position"),this.hasShineEffect=s.stateGetter("hasShineEffect"),this.isEnabled=s.stateGetter("isEnabled"),this.isLoaderVisible=s.stateGetter("isLoaderVisible"),this.text=s.stateGetter("text"),this.isVisible=s.stateGetter("isVisible"),this.isMounted=s.isMounted,this.state=s.state,[this.setPosition,this.setPositionFp]=s.stateSetters("position"),[this.setBgColor,this.setBgColorFp]=s.stateSetters("bgColor"),[this.setTextColor,this.setTextColorFp]=s.stateSetters("textColor"),[[this.disableShineEffect,this.disableShineEffectFp],[this.enableShineEffect,this.enableShineEffectFp]]=s.stateBoolSetters("hasShineEffect"),[[this.disable,this.disableFp],[this.enable,this.enableFp]]=s.stateBoolSetters("isEnabled"),[[this.hideLoader,this.hideLoaderFp],[this.showLoader,this.showLoaderFp]]=s.stateBoolSetters("isLoaderVisible"),[this.setText,this.setTextFp]=s.stateSetters("text"),[[this.hide,this.hideFp],[this.show,this.showFp]]=s.stateBoolSetters("isVisible"),this.setParams=s.setState,this.setParamsFp=s.setStateFp,this.onClick=s.onClick,this.onClickFp=s.onClickFp,this.offClick=s.offClick,this.offClickFp=s.offClickFp,this.mount=s.mount,this.mountFp=s.mountFp,this.unmount=s.unmount}}function Is(){return new Xt(Qt("secondaryButton","secondary_button_pressed",{bgColor:g.computed(()=>Nt.bottomBarColorRgb()||"#000000"),textColor:g.computed(()=>he.buttonColor()||"#2481cc")}))}const As=Is();class er{constructor({isTma:t,request:n,version:s,createRequestId:i}){e(this,"getItemFp");e(this,"getItem");e(this,"restoreItemFp");e(this,"restoreItem");e(this,"setItemFp");e(this,"setItem");e(this,"deleteItemFp");e(this,"deleteItem");e(this,"clearFp");e(this,"clear");const o=A({version:s,requires:"web_app_secure_storage_get_key",isTma:t,returns:"task"}),u=(a,l,p)=>{const b=i();return c(n(a,["secure_storage_failed",l],{params:{...p,req_id:b},capture:f=>"payload"in f?f.payload.req_id===b:!0}),J(f=>f.event==="secure_storage_failed"?O(new _t(f.payload.error||"UNKNOWN_ERROR")):M(f.payload)))};this.getItemFp=o(a=>c(u("web_app_secure_storage_get_key","secure_storage_key_received",{key:a}),I(l=>({value:l.value,canRestore:!!l.can_restore})))),this.setItemFp=o((a,l)=>c(u("web_app_secure_storage_save_key","secure_storage_key_saved",{key:a,value:l}),I(()=>{}))),this.deleteItemFp=o(a=>this.setItemFp(a,null)),this.clearFp=o(()=>c(u("web_app_secure_storage_clear","secure_storage_cleared",{}),I(()=>{}))),this.restoreItemFp=o(a=>c(u("web_app_secure_storage_restore_key","secure_storage_key_restored",{key:a}),I(l=>l.value))),this.getItem=h(this.getItemFp),this.setItem=h(this.setItemFp),this.deleteItem=h(this.deleteItemFp),this.clear=h(this.clearFp),this.restoreItem=h(this.restoreItemFp)}}function Bs(){return new er(c(S(),k,U,Mt))}const Ps=Bs();class tr{constructor(t){e(this,"isVisible");e(this,"isMounted");e(this,"isSupported");e(this,"hideFp");e(this,"hide");e(this,"showFp");e(this,"show");e(this,"onClickFp");e(this,"onClick");e(this,"offClickFp");e(this,"offClick");e(this,"mountFp");e(this,"mount");e(this,"unmount");const n=new ve({...t,method:"web_app_setup_settings_button",payload:s=>({is_visible:s.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 qs=new tr(Ge("settingsButton","settings_button_pressed"));class rr{constructor({postEvent:t,storage:n,isTma:s,isPageReload:i,version:o}){e(this,"isSupported");e(this,"isVerticalEnabled");e(this,"isMounted");e(this,"mountFp");e(this,"mount");e(this,"unmount");e(this,"disableVerticalFp");e(this,"disableVertical");e(this,"enableVerticalFp");e(this,"enableVertical");const u={isVerticalEnabled:!0},a=new te({initialState:u,onChange(w){n.set(w)}}),l=new me({initialState:u,isPageReload:i,onMounted:a.setState,restoreState:n.get}),p={requires:"web_app_setup_swipe_behavior",isTma:s,version:o},b=A({...p,returns:"plain"}),f=A({...p,isMounted:l.isMounted,returns:"either"}),C=w=>{const v={isVerticalEnabled:w};return a.hasDiff(v)?c(t("web_app_setup_swipe_behavior",{allow_vertical_swipe:w}),H(()=>{a.setState(v)})):q(void 0)};this.isSupported=Z("web_app_setup_swipe_behavior",o),this.isVerticalEnabled=a.getter("isVerticalEnabled"),this.isMounted=l.isMounted,this.disableVerticalFp=f(()=>C(!1)),this.enableVerticalFp=f(()=>C(!0)),this.mountFp=b(()=>{const w=()=>{};return c(l.mount(),fe(w,w))}),this.unmount=l.unmount,this.disableVertical=h(this.disableVerticalFp),this.enableVertical=h(this.enableVerticalFp),this.mount=h(this.mountFp)}}function Ms(){return new rr(c(S(),j,k,re("swipeBehavior")))}const xs=Ms();async function $s(r){try{const{clipboard:n}=navigator;if(n)return await n.writeText(r)}catch{}const t=document.createElement("textarea");t.value=r,t.style.top="0",t.style.left="0",t.style.position="fixed",document.body.appendChild(t),t.focus(),t.select();try{document.execCommand("copy")}finally{document.body.removeChild(t)}}function Ts({request:r,...t}){return P((n,s,i)=>c(r("web_app_request_file_download","file_download_requested",{...i,params:{url:n,file_name:s}}),J(o=>o.status==="downloading"?M(void 0):O(new Ue("User denied the action")))),{...t,requires:"web_app_request_file_download",returns:"task"})}function Rs(){return Ts(c(S(),U,k))}const nr=Rs(),Os=h(nr);function Ls({invokeCustomMethod:r,...t}){return P(n=>c(r("getCurrentTime",{},n),J(s=>{const i=E.safeParse(E.pipe(E.number(),E.integer(),E.transform(o=>new Date(o*1e3)),E.date()),s);return i.success?M(i.output):O(new pe(s,i.issues))})),{...t,requires:"web_app_invoke_custom_method",returns:"task"})}function Vs(){return Ls(c(S(),Qe,k))}const sr=Vs(),js=h(sr);function Ds({postEvent:r,...t}){return P(()=>r("web_app_hide_keyboard"),{...t,returns:"either",requires:"web_app_hide_keyboard"})}function Us(){return Ds(c(S(),j,k))}const or=Us(),Gs=h(or);function Hs({request:r,createRequestId:t,...n}){return P(s=>{const i=t();return c(r("web_app_read_text_from_clipboard","clipboard_text_received",{...s,params:{req_id:i},capture:d.captureSameReq(i)}),I(({data:o=null})=>o))},{...n,requires:"web_app_read_text_from_clipboard",returns:"task"})}function Ws(){return Hs({...c(S(),k,U),createRequestId:ye})}const ir=Ws(),Qs=h(ir);function ar(r){const t={},n=r.match(/Telegram-Android(?:\/([^ ]+))?(?: (\([^)]+\))?|$)/);if(n){const[,s,i]=n;s&&(t.appVersion=s),i&&i.slice(1,i.length-1).split(";").forEach(o=>{const[u,a]=o.trim().split(" ");if(u==="Android")t.androidVersion=a;else if(u==="SDK"){const l=parseInt(a,10);l&&(t.sdkVersion=l)}else a?(t.manufacturer=u,t.model=a):t.performanceClass=u})}return t}function Ks(){return ar(navigator.userAgent)}function Ns({postEvent:r,...t}){return P(n=>{const{size:s}=new Blob([n]);return!s||s>4096?R(new z(s?"Maximum size of data to send is 4096 bytes":"Attempted to send empty data")):r("web_app_data_send",{data:n})},{...t,returns:"either"})}function zs(){return Ns(c(S(),j))}const ur=zs(),Js=h(ur);function Ys({request:r,...t}){return P((n,s)=>c(r("web_app_send_prepared_message",["prepared_message_failed","prepared_message_sent"],{...s,params:{id:n}}),J(i=>i.event==="prepared_message_failed"?O(new Ct(i.payload.error)):M(void 0))),{...t,requires:"web_app_send_prepared_message",returns:"task"})}function Zs(){return Ys(c(S(),U,k))}const cr=Zs(),Xs=h(cr);function eo({postEvent:r,...t}){return P((n,s={})=>r("web_app_share_to_story",{text:s.text,media_url:n,widget_link:s.widgetLink}),{...t,requires:"web_app_share_to_story",returns:"either"})}function to(){return eo(c(S(),j,k))}const pr=to(),ro=h(pr),qe=be(!1);function no({isInlineMode:r,postEvent:t,...n}){return P((s,i)=>t("web_app_switch_inline_query",{query:s,chat_types:i||[]}),{...n,requires:{every:["web_app_switch_inline_query",()=>W(r)?void 0:"The application must be launched in the inline mode"]},returns:"either"})}function so(){return no({...c(S(),j,k),isInlineMode:qe})}const lr=so(),oo=h(lr);class hr{constructor({storage:t,isPageReload:n,onContentSafeAreaInsetsChanged:s,onSafeAreaInsetsChanged:i,onViewportChanged:o,onFullscreenChanged:u,offContentSafeAreaInsetsChanged:a,offFullscreenChanged:l,offSafeAreaInsetsChanged:p,offViewportChanged:b,request:f,isViewportStable:C,isFullscreen:w,isTma:v,version:y,postEvent:_}){e(this,"state");e(this,"height");e(this,"stableHeight");e(this,"width");e(this,"isExpanded");e(this,"isStable",g.computed(()=>this.height()===this.stableHeight()));e(this,"contentSafeAreaInsets");e(this,"contentSafeAreaInsetTop");e(this,"contentSafeAreaInsetLeft");e(this,"contentSafeAreaInsetRight");e(this,"contentSafeAreaInsetBottom");e(this,"safeAreaInsets");e(this,"safeAreaInsetTop");e(this,"safeAreaInsetLeft");e(this,"safeAreaInsetRight");e(this,"safeAreaInsetBottom");e(this,"isFullscreen");e(this,"requestFullscreenFp");e(this,"requestFullscreen");e(this,"exitFullscreenFp");e(this,"exitFullscreen");e(this,"isCssVarsBound");e(this,"bindCssVarsFp");e(this,"bindCssVars");e(this,"isMounted");e(this,"mountFp");e(this,"mount");e(this,"expandFp");e(this,"expand");const F={top:0,right:0,left:0,bottom:0},m=new te({initialState:{contentSafeAreaInsets:F,height:0,isExpanded:!1,isFullscreen:!1,safeAreaInsets:F,stableHeight:0,width:0},onChange:t.set}),$=B=>{m.setState({isExpanded:B.is_expanded,height:B.height,width:B.width,stableHeight:B.is_state_stable?B.height:void 0})},D=B=>{m.setState({isFullscreen:B.is_fullscreen})},V=B=>{m.setState({safeAreaInsets:B})},K=B=>{m.setState({contentSafeAreaInsets:B})},G=new He({initialState(B){const ne=X=>()=>{const[ee,N]=X==="safe-area"?["web_app_request_safe_area","safe_area_changed"]:["web_app_request_content_safe_area","content_safe_area_changed"];return d.supports(ee,W(y))?f(ee,N,B):M({top:0,left:0,right:0,bottom:0})},T=X=>()=>typeof X=="boolean"?M(X):ft(X());return c(fn,we("safeAreaInsets",ne("safe-area")),we("contentSafeAreaInsets",ne("content-safe-area")),we("isFullscreen",T(w)),we("isViewportStable",T(C)),ue(({isViewportStable:X,...ee})=>X?M({...ee,height:window.innerHeight,isExpanded:!0,stableHeight:window.innerHeight,width:window.innerWidth}):c(f("web_app_request_viewport","viewport_changed",B),I(N=>({...ee,height:N.height,isExpanded:N.is_expanded,stableHeight:N.is_state_stable?N.height:0,width:N.width})))))},isPageReload:n,onMounted(B){o($),u(D),i(V),s(K),m.setState(B)},onUnmounted(){b($),l(D),p(V),a(K)},restoreState:t.get}),Y=B=>g.computed(()=>this.safeAreaInsets()[B]),ge=B=>g.computed(()=>this.contentSafeAreaInsets()[B]);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=Y("top"),this.safeAreaInsetBottom=Y("bottom"),this.safeAreaInsetLeft=Y("left"),this.safeAreaInsetRight=Y("right"),this.contentSafeAreaInsets=m.getter("contentSafeAreaInsets"),this.contentSafeAreaInsetTop=ge("top"),this.contentSafeAreaInsetBottom=ge("bottom"),this.contentSafeAreaInsetLeft=ge("left"),this.contentSafeAreaInsetRight=ge("right");const fr=A({isTma:v,returns:"task"}),Xe=A({isTma:v,returns:"either"}),mr=A({isTma:v,requires:"web_app_request_fullscreen",version:y,returns:"task"}),et=B=>mr(ne=>c(f(B?"web_app_request_fullscreen":"web_app_exit_fullscreen",["fullscreen_changed","fullscreen_failed"],ne),J(T=>T.event==="fullscreen_failed"&&T.payload.error!=="ALREADY_FULLSCREEN"?O(new wt(T.payload.error)):(m.setState({isFullscreen:"is_fullscreen"in T.payload?T.payload.is_fullscreen:!0}),M(void 0)))));this.isMounted=G.isMounted,this.mountFp=fr(G.mount),this.mount=h(this.mountFp),this.isFullscreen=m.getter("isFullscreen"),this.requestFullscreenFp=et(!0),this.requestFullscreen=h(this.requestFullscreenFp),this.exitFullscreenFp=et(!1),this.exitFullscreen=h(this.exitFullscreenFp);const Fe=g.signal(!1);this.isCssVarsBound=g.computed(Fe),this.bindCssVarsFp=Xe(B=>{if(Fe())return R(new Ce);B||(B=T=>`--tg-viewport-${L.camelToKebab(T)}`);const ne=[["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((T,[X,ee])=>{const N=B(X);if(N){const tt=()=>{Ne(N,`${ee()}px`)};T.push({update:tt,removeListener:ee.sub(tt),cssVar:N})}return T},[]);return ne.forEach(T=>{T.update()}),Fe.set(!0),q(()=>{ne.forEach(T=>{T.removeListener(),ze(T.cssVar)}),Fe.set(!1)})}),this.bindCssVars=h(this.bindCssVarsFp),this.expandFp=Xe(()=>_("web_app_expand")),this.expand=h(this.expandFp)}}function io(){const r=o=>({on:u=>{d.on(o,u)},off:u=>{d.off(o,u)}}),t=r("viewport_changed"),n=r("fullscreen_changed"),s=r("safe_area_changed"),i=r("content_safe_area_changed");return new hr({...c(S(),re("viewport"),k,j,U),isFullscreen(){return c(d.retrieveLaunchParamsFp(),H(o=>!!o.tgWebAppFullscreen))},isViewportStable(){return c(d.retrieveLaunchParamsFp(),H(o=>["macos","tdesktop","unigram","webk","weba","web"].includes(o.tgWebAppPlatform)))},offContentSafeAreaInsetsChanged:i.off,offFullscreenChanged:n.off,offSafeAreaInsetsChanged:s.off,offViewportChanged:t.off,onContentSafeAreaInsetsChanged:i.on,onFullscreenChanged:n.on,onSafeAreaInsetsChanged:s.on,onViewportChanged:t.on})}const ao=io();function dr(r={}){const{version:t,isInlineMode:n,themeParams:s}=r;if(t&&typeof n=="boolean"&&s)Be.set(t),qe.set(n),Pe.set(s);else{const a=c(d.retrieveLaunchParamsFp(),pt(l=>l,l=>{Be.set(t||l.tgWebAppVersion),qe.set(typeof n=="boolean"?n:!!l.tgWebAppBotInline),Pe.set(s||l.tgWebAppThemeParams)}));if(a)return R(a)}r.postEvent&&yt.set(r.postEvent);const[i,o]=L.createCbCollector(d.on("reload_iframe",()=>{d.logger().log("Received a request to reload the page"),kt("iframe_will_reload"),window.location.reload()})),{acceptCustomStyles:u=!0}=r;if(u){const a=document.createElement("style");a.id="telegram-custom-styles",document.head.appendChild(a),i(d.on("set_custom_style",l=>{a.innerHTML=l}),()=>{document.head.removeChild(a)})}return c(ie("iframe_ready",{reload_supported:!0}),H(()=>(d.logger().log("The package was initialized"),o)))}const uo=L.throwifyFpFn(dr);Object.defineProperty(exports,"CancelledError",{enumerable:!0,get:()=>d.CancelledError});Object.defineProperty(exports,"InvalidLaunchParamsError",{enumerable:!0,get:()=>d.InvalidLaunchParamsError});Object.defineProperty(exports,"InvokeCustomMethodFailedError",{enumerable:!0,get:()=>d.InvokeCustomMethodFailedError});Object.defineProperty(exports,"LaunchParamsRetrieveError",{enumerable:!0,get:()=>d.LaunchParamsRetrieveError});Object.defineProperty(exports,"MethodParameterUnsupportedError",{enumerable:!0,get:()=>d.MethodParameterUnsupportedError});Object.defineProperty(exports,"MethodUnsupportedError",{enumerable:!0,get:()=>d.MethodUnsupportedError});Object.defineProperty(exports,"TimeoutError",{enumerable:!0,get:()=>d.TimeoutError});Object.defineProperty(exports,"UnknownEnvError",{enumerable:!0,get:()=>d.UnknownEnvError});Object.defineProperty(exports,"applyPolyfills",{enumerable:!0,get:()=>d.applyPolyfills});Object.defineProperty(exports,"createLogger",{enumerable:!0,get:()=>d.createLogger});Object.defineProperty(exports,"createPostEvent",{enumerable:!0,get:()=>d.createPostEvent});Object.defineProperty(exports,"createStartParam",{enumerable:!0,get:()=>d.createStartParam});Object.defineProperty(exports,"createStartParamFp",{enumerable:!0,get:()=>d.createStartParamFp});Object.defineProperty(exports,"debug",{enumerable:!0,get:()=>d.debug});Object.defineProperty(exports,"decodeBase64Url",{enumerable:!0,get:()=>d.decodeBase64Url});Object.defineProperty(exports,"decodeBase64UrlFp",{enumerable:!0,get:()=>d.decodeBase64UrlFp});Object.defineProperty(exports,"decodeStartParam",{enumerable:!0,get:()=>d.decodeStartParam});Object.defineProperty(exports,"decodeStartParamFp",{enumerable:!0,get:()=>d.decodeStartParamFp});Object.defineProperty(exports,"deepSnakeToCamelObjKeys",{enumerable:!0,get:()=>d.deepSnakeToCamelObjKeys});Object.defineProperty(exports,"emitEvent",{enumerable:!0,get:()=>d.emitEvent});Object.defineProperty(exports,"encodeBase64Url",{enumerable:!0,get:()=>d.encodeBase64Url});Object.defineProperty(exports,"getReleaseVersion",{enumerable:!0,get:()=>d.getReleaseVersion});Object.defineProperty(exports,"isSafeToCreateStartParam",{enumerable:!0,get:()=>d.isSafeToCreateStartParam});Object.defineProperty(exports,"isTMA",{enumerable:!0,get:()=>d.isTMA});Object.defineProperty(exports,"isTMAFp",{enumerable:!0,get:()=>d.isTMAFp});Object.defineProperty(exports,"logger",{enumerable:!0,get:()=>d.logger});Object.defineProperty(exports,"mockTelegramEnv",{enumerable:!0,get:()=>d.mockTelegramEnv});Object.defineProperty(exports,"off",{enumerable:!0,get:()=>d.off});Object.defineProperty(exports,"offAll",{enumerable:!0,get:()=>d.offAll});Object.defineProperty(exports,"on",{enumerable:!0,get:()=>d.on});Object.defineProperty(exports,"retrieveLaunchParams",{enumerable:!0,get:()=>d.retrieveLaunchParams});Object.defineProperty(exports,"retrieveLaunchParamsFp",{enumerable:!0,get:()=>d.retrieveLaunchParamsFp});Object.defineProperty(exports,"retrieveRawInitData",{enumerable:!0,get:()=>d.retrieveRawInitData});Object.defineProperty(exports,"retrieveRawInitDataFp",{enumerable:!0,get:()=>d.retrieveRawInitDataFp});Object.defineProperty(exports,"retrieveRawLaunchParams",{enumerable:!0,get:()=>d.retrieveRawLaunchParams});Object.defineProperty(exports,"retrieveRawLaunchParamsFp",{enumerable:!0,get:()=>d.retrieveRawLaunchParamsFp});Object.defineProperty(exports,"setDebug",{enumerable:!0,get:()=>d.setDebug});Object.defineProperty(exports,"setTargetOrigin",{enumerable:!0,get:()=>d.setTargetOrigin});Object.defineProperty(exports,"supports",{enumerable:!0,get:()=>d.supports});Object.defineProperty(exports,"targetOrigin",{enumerable:!0,get:()=>d.targetOrigin});Object.defineProperty(exports,"isAnyRGB",{enumerable:!0,get:()=>x.isAnyRGB});Object.defineProperty(exports,"isRGB",{enumerable:!0,get:()=>x.isRGB});Object.defineProperty(exports,"isRGBA",{enumerable:!0,get:()=>x.isRGBA});Object.defineProperty(exports,"isRGBAShort",{enumerable:!0,get:()=>x.isRGBAShort});Object.defineProperty(exports,"isRGBShort",{enumerable:!0,get:()=>x.isRGBShort});Object.defineProperty(exports,"parseInitDataQuery",{enumerable:!0,get:()=>x.parseInitDataQuery});Object.defineProperty(exports,"parseInitDataQueryFp",{enumerable:!0,get:()=>x.parseInitDataQueryFp});Object.defineProperty(exports,"parseLaunchParamsQuery",{enumerable:!0,get:()=>x.parseLaunchParamsQuery});Object.defineProperty(exports,"parseLaunchParamsQueryFp",{enumerable:!0,get:()=>x.parseLaunchParamsQueryFp});Object.defineProperty(exports,"serializeInitDataQuery",{enumerable:!0,get:()=>x.serializeInitDataQuery});Object.defineProperty(exports,"serializeLaunchParamsQuery",{enumerable:!0,get:()=>x.serializeLaunchParamsQuery});Object.defineProperty(exports,"toRGB",{enumerable:!0,get:()=>x.toRGB});Object.defineProperty(exports,"toRGBFp",{enumerable:!0,get:()=>x.toRGBFp});Object.defineProperty(exports,"toRGBFull",{enumerable:!0,get:()=>x.toRGBFull});Object.defineProperty(exports,"toRGBFullFp",{enumerable:!0,get:()=>x.toRGBFullFp});exports.AccessDeniedError=Ue;exports.BackButton=vt;exports.Biometry=Et;exports.CSSVarsBoundError=Ce;exports.ClosingBehavior=At;exports.CloudStorage=Bt;exports.ConcurrentCallError=Se;exports.DeviceStorage=qt;exports.DeviceStorageMethodError=mt;exports.FullscreenFailedError=wt;exports.FunctionUnavailableError=gt;exports.HapticFeedback=Tt;exports.InitData=Lt;exports.InvalidArgumentsError=z;exports.InvalidEnvError=_n;exports.Invoice=Vt;exports.LocationManager=Ut;exports.MainButton=Gt;exports.MiniApp=Kt;exports.NotAvailableError=bt;exports.Popup=zt;exports.QrScanner=Zt;exports.SecondaryButton=Xt;exports.SecureStorage=er;exports.SecureStorageMethodError=_t;exports.SetEmojiStatusError=Ft;exports.SettingsButton=tr;exports.ShareMessageError=Ct;exports.SwipeBehavior=rr;exports.ThemeParams=Wt;exports.UnknownThemeParamsKeyError=St;exports.ValidationError=pe;exports.Viewport=hr;exports.addToHomeScreen=Dn;exports.addToHomeScreenFp=Rt;exports.backButton=wn;exports.biometry=yn;exports.checkHomeScreenStatus=Hn;exports.checkHomeScreenStatusFp=Ot;exports.closingBehavior=En;exports.cloudStorage=An;exports.copyTextToClipboard=$s;exports.createRequestId=ye;exports.deviceStorage=Pn;exports.downloadFile=Os;exports.downloadFileFp=nr;exports.getCurrentTime=js;exports.getCurrentTimeFp=sr;exports.hapticFeedback=Ln;exports.hideKeyboard=Gs;exports.hideKeyboardFp=or;exports.init=uo;exports.initData=Qn;exports.initFp=dr;exports.invoice=Nn;exports.invokeCustomMethod=Pt;exports.isColorDark=Je;exports.isColorDarkFp=Ht;exports.locationManager=is;exports.mainButton=us;exports.miniApp=Nt;exports.openLink=Yn;exports.openLinkFp=jt;exports.openTelegramLink=es;exports.openTelegramLinkFp=Ke;exports.popup=hs;exports.postEvent=kt;exports.postEventFp=ie;exports.qrScanner=Es;exports.readTextFromClipboard=Qs;exports.readTextFromClipboardFp=ir;exports.request=Cn;exports.request2=Sn;exports.request2Fp=We;exports.requestContact=Cs;exports.requestContactComplete=ws;exports.requestContactCompleteFp=Ze;exports.requestContactFp=Jt;exports.requestEmojiStatusAccess=xn;exports.requestEmojiStatusAccessFp=xt;exports.requestFp=It;exports.requestPhoneAccess=ms;exports.requestPhoneAccessFp=Ye;exports.requestWriteAccess=ys;exports.requestWriteAccessFp=Yt;exports.retrieveAndroidDeviceData=Ks;exports.retrieveAndroidDeviceDataFrom=ar;exports.secondaryButton=As;exports.secureStorage=Ps;exports.sendData=Js;exports.sendDataFp=ur;exports.setEmojiStatus=Rn;exports.setEmojiStatusFp=$t;exports.settingsButton=qs;exports.shareMessage=Xs;exports.shareMessageFp=cr;exports.shareStory=ro;exports.shareStoryFp=pr;exports.shareURL=ns;exports.shareURLFp=Dt;exports.swipeBehavior=xs;exports.switchInlineQuery=oo;exports.switchInlineQueryFp=lr;exports.themeParams=he;exports.viewport=ao;
2
2
  //# sourceMappingURL=index.cjs.map