@tma.js/sdk 3.1.0 → 3.1.1
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.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.iife.js +2 -2
- package/dist/index.iife.js.map +1 -1
- package/dist/index.js +87 -87
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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"),W=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,p){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 p(a(u(o(i(n(s(t(r.apply(this,arguments)))))))))}}}function c(r,t,s,n,i,o,u,a,p){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 p(a(u(o(i(n(s(t(r))))))));default:{for(var l=arguments[0],_=1;_<arguments.length;_++)l=arguments[_](l);return l}}}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,G(t))},at=function(r,t){return c(r,Ir(t))},Re="Either",G=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 H(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=H(o)?s():void 0,a=u?q(u):typeof n=="function"?n():q(n);return c(a,G(p=>{g.batch(()=>{this._isMounted.set(!0),t==null||t(p)})}))},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,H(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(_){try{l(n.next(_))}catch(f){u(f)}}function p(_){try{l(n.throw(_))}catch(f){u(f)}}function l(_){_.done?o(_.value):i(_.value).then(a,p)}l((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(l){return function(_){return p([l,_])}}function p(l){if(n)throw new TypeError("Generator is already executing.");for(;u&&(u=0,l[0]&&(s=0)),s;)try{if(n=1,i&&(o=l[0]&2?i.return:l[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,l[1])).done)return o;switch(i=0,o&&(l=[l[0]&2,o.value]),l[0]){case 0:case 1:o=l;break;case 4:return s.label++,{value:l[1],done:!1};case 5:s.label++,i=l[1],l=[0];continue;case 7:l=s.ops.pop(),s.trys.pop();continue;default:if(o=s.trys,!(o=o.length>0&&o[o.length-1])&&(l[0]===6||l[0]===2)){s=0;continue}if(l[0]===3&&(!o||l[1]>o[0]&&l[1]<o[3])){s.label=l[1];break}if(l[0]===6&&s.label<o[1]){s.label=o[1],o=l;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(l);break}o[2]&&s.ops.pop(),s.trys.pop();continue}l=t.call(r,s)}catch(_){l=[6,_],i=0}finally{n=o=0}if(l[0]&5)throw l[1];return{value:l[0]?l[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,Y=De,ue=De;function oe(r){return[r]}class pe extends W.errorClassWithData("ValidationError",(t,s)=>({input:t,issues:s}),"Validation error"){}class Ce extends W.errorClass("CSSVarsBoundError","CSS variables are already bound"){}class dt extends W.errorClassWithData("DeviceStorageMethodError",t=>({error:t}),t=>[t]){}class ft extends W.errorClassWithData("SecureStorageMethodError",t=>({error:t}),t=>[t]){}class mt extends W.errorClass("NotAvailableError",oe){}class fs extends W.errorClass("InvalidEnvError",oe){}class _t extends W.errorClass("FunctionNotAvailableError",oe){}class J extends W.errorClass("InvalidArgumentsError",(t,s)=>[t,{cause:s}]){}class Se extends W.errorClass("ConcurrentCallError",oe){}class bt extends W.errorClass("SetEmojiStatusError",t=>[`Failed to set emoji status: ${t}`]){}class Ue extends W.errorClass("AccessDeniedError",oe){}class gt extends W.errorClass("FullscreenFailedError",oe){}class Ft extends W.errorClass("ShareMessageError",oe){}class wt extends W.errorClass("UnknownThemeParamsKeyError",t=>[`Unknown theme params key passed: ${t}`]){}function P(r,t){const s=g.computed(()=>H(t.version)||"100"),n=g.computed(()=>H(t.isTma)),{requires:i,returns:o}=t,u=i?typeof i=="object"?i:{every:[i]}:void 0,a=b=>{if(!t.supports)return!0;const F=t.supports[b];return d.supports(F.method,F.param,s())},p=()=>{if(!u)return;const[b,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&&(b==="every"||m===F.length-1))return D}},l=(...b)=>{for(const F in t.supports)if(t.supports[F].shouldCheck(...b)&&!a(F))return`option ${F} is not supported in Mini Apps version ${s()}`},_=g.computed(()=>!p()),f=g.computed(()=>s()!=="0.0"),C=g.computed(()=>t.isMounted?t.isMounted():!0),w=g.computed(()=>n()&&f()&&_()&&C()),v=b=>{const F=new _t(b);return["task","promise"].includes(t.returns)?L(F):O(F)},k=(...b)=>o==="plain"?qr(()=>r(...b),F=>F):o==="promise"?os(()=>r(...b),F=>F):r(...b);return Object.assign((...b)=>{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=p();if(m)return v(`${F} ${m}`);const T=l(...b);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 k(...b)},r,{isAvailable:w,ifAvailable(...b){return w()?_e(k(...b)):ae}},u?{isSupported:_}:{},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:p,method:l,version:_}){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(b){s.set(b)}}),C=new me({initialState:o,isPageReload:u,onMounted:f.setState,restoreState:s.get}),w={version:_,requires:l,isTma:t},v=A({...w,returns:"plain"}),k=A({...w,returns:"either",isMounted:C.isMounted});this.isMounted=C.isMounted,this.isSupported=Z(l,_),this.state=f.state,this.setStateFp=k(b=>{const F={...this.state(),...Ae(b)};return f.hasDiff(F)?c(a(l,p(F)),G(()=>{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 b=()=>{};return c(C.mount(),fe(b,b))}),this.mount=h(this.mountFp),this.unmount=C.unmount,this.stateSetters=b=>{const F=k(m=>this.setStateFp({[b]:m}));return[h(F),F]},this.stateBoolSetters=b=>{const[,F]=this.stateSetters(b),m=k(()=>F(!1)),T=k(()=>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,...H(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"),y=ce({version:Be});function Ge(r,t){return{...c(S(),j,y,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=H(o)?n():void 0;return c(a?M(a):t(u),I(p=>{this._isMounted()||g.batch(()=>{this._isMounted.set(!0),s==null||s(p)})}))},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:p}){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 l=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(b){return c(s("web_app_biometry_get_info","biometry_info_received",b),I(Ee))},isPageReload:p,onMounted(b){_.setState(b),o(l)},onUnmounted(){u(l)},restoreState:i.get}),C={version:t,requires:"web_app_biometry_request_auth",isTma:a},w=A({...C,returns:"either"}),v=A({...C,returns:"task"}),k=A({...C,isMounted:f.isMounted,returns:"task"});this.isAvailable=_.getter("available"),this.isMounted=f.isMounted,this.isSupported=Z("web_app_biometry_request_auth",t),this.state=_.state,this.unmount=f.unmount,this.mountFp=v(f.mount),this.authenticateFp=k(b=>this.isAvailable()?c(s("web_app_biometry_request_auth","biometry_auth_requested",{...b,params:{reason:((b||{}).reason||"").trim()}}),I(F=>(_.setState({token:F.token}),F))):L(st)),this.openSettingsFp=w(()=>n("web_app_biometry_open_settings")),this.requestAccessFp=k(b=>c(s("web_app_biometry_request_access","biometry_info_received",{...b,params:{reason:((b||{}).reason||"").trim()}}),Y(F=>{const m=Ee(F);return m.available?(_.setState(m),M(m.accessRequested)):L(st)}))),this.updateTokenFp=k((b={})=>{var F;return c(s("web_app_biometry_update_token","biometry_token_updated",{...b,params:{token:b.token||"",reason:(F=b.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,y,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},p=A({...a,returns:"plain"}),l=A({...a,returns:"either",isMounted:u.isMounted}),_=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=l(()=>_(!1)),this.enableConfirmationFp=l(()=>_(!0)),this.mountFp=p(()=>{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((p,l)=>(p[l]="",p),{}),...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),Y(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(),y,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,p,l)=>{const _=i();return c(s(a,["device_storage_failed",p],{params:{...l,req_id:_},capture:f=>"payload"in f?f.payload.req_id===_:!0}),Y(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(p=>p.value))),this.setItemFp=o((a,p)=>c(u("web_app_device_storage_save_key","device_storage_key_saved",{key:a,value:p}),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(),y,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(),y,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,y)),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,y));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(),y,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(),y,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(),G(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(),G(({tgWebAppData:r})=>r?_e(r):ae))),tt("raw",d.retrieveRawInitDataFp),G(({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,p)=>c(this.isOpened()?L(new Se("Invoice is already opened")):M(void 0),Y(()=>(o.set(!0),s("web_app_open_invoice","invoice_closed",{...p,params:{slug:a},capture:l=>a===l.slug}))),je(l=>(u(),l),l=>(u(),l.status)))),this.openUrlFp=i((a,p)=>{const{hostname:l,pathname:_}=new URL(a,window.location.href);if(l!=="t.me")return L(new J(`Link has unexpected hostname: ${l}`));const f=_.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);return f?this.openSlugFp(f[2],p):L(new J('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,y));function Os({postEvent:r,...t}){return P((s,n={})=>{if(typeof s=="string")try{s=new URL(s)}catch(i){return O(new J(`"${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",H(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 J(`"${i}" is invalid URL`))},{...s,returns:"either"})}const Qe=Vs(c(S(),j,y)),$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}),p=new He({isPageReload:u,restoreState:i.get,onMounted:a.setState,initialState(w){return c(s("web_app_check_location","location_checked",w),I(Us))}}),l={version:t,requires:"web_app_check_location",isTma:o},_=A({...l,returns:"either"}),f=A({...l,returns:"task"}),C=A({...l,returns:"task",isMounted:p.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=p.isMounted,this.state=a.state,this.unmount=p.unmount,this.mountFp=f(p.mount),this.openSettingsFp=_(()=>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:k,...b}=v;return b}))),this.mount=h(this.mountFp),this.openSettings=h(this.openSettingsFp),this.requestLocation=h(this.requestLocationFp)}}const Gs=new jt(c(S(),j,y,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()||H(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),G(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}),p=w=>{a.setState(w.theme_params)},l=new me({initialState:()=>q(H(t)),isPageReload:u,onMounted(w){a.setState(w),s(p)},onUnmounted(){n(p)},restoreState:o.get}),_={isTma:i,returns:"either"},f=A(_),C=A({..._,isMounted:l.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=l.isMounted,this.bindCssVarsFp=C(w=>{if(this._isCssVarsBound())return O(new Ce);w||(w=b=>`--tg-theme-${V.snakeToKebab(b)}`);const v=b=>{Object.entries(a.state()).forEach(([F,m])=>{m&&b(F,m)})},k=()=>{v((b,F)=>{Ke(w(b),F)})};return k(),a.state.sub(k),this._isCssVarsBound.set(!0),q(()=>{v(Ne),a.state.unsub(k),this._isCssVarsBound.set(!1)})}),this.mountFp=f(l.mount),this.unmount=l.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:p}){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 l=m=>{C.setState({isActive:m.is_visible})},_=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 Q=m[$];Q&&i(D,{color:Q})}})},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(l),u.sub(_),C.setState(m)},onUnmounted(){p(l),u.unsub(_)},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:H(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,H(n))));const k=g.signal(!1);this.isCssVarsBound=g.computed(k),this.bindCssVarsFp=P(m=>{if(k())return O(new Ce);const[T,D]=V.createCbCollector(()=>{k.set(!1)}),$=(Q,K)=>{const N=()=>{Ke(Q,K()||null)};N(),T(K.sub(N),Ne.bind(null,Q))};return m||(m=Q=>`--tg-${V.camelToKebab(Q)}`),$(m("bgColor"),this.bgColorRgb),$(m("bottomBarColor"),this.bottomBarColorRgb),$(m("headerColor"),this.headerColorRgb),k.set(!0),q(D)},{isTma:o,returns:"either",isMounted:this.isMounted}),this.bindCssVars=h(this.bindCssVarsFp);const b=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],Q=P(K=>{if(K===T())return q(void 0);if($==="web_app_set_header_color"&&(K==="bg_color"||K==="secondary_bg_color"))return c(i("web_app_set_header_color",{color_key:K}),G(()=>{C.setState({[m]:K})}));const N=w(K);return c(N?i($,{color:N}):O(new wt(K)),G(()=>{C.setState({[m]:N})}))},{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(Q),Q]};[this.bgColor,this.bgColorRgb,this.setBgColor,this.setBgColorFp]=b("bgColor"),[this.headerColor,this.headerColorRgb,this.setHeaderColor,this.setHeaderColorFp]=b("headerColor"),[this.bottomBarColor,this.bottomBarColorRgb,this.setBottomBarColor,this.setBottomBarColorFp]=b("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,y,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 J(`Invalid title: ${s}`));if(!t||t.length>256)return O(new J(`Invalid message: ${t}`));if(n.length>3)return O(new J(`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 J(`Button with index ${o} has invalid id: ${a}`));if(!u.type||u.type==="default"||u.type==="destructive"){const p=u.text.trim();if(!p||p.length>64)return O(new J(`Button with index ${o} has invalid text: ${p}`));i.push({type:u.type,text:p,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))),Y(p=>(i.set(!0),n("web_app_open_popup","popup_closed",{...a,params:p}))),je(p=>(o(),p),p=>(o(),p.button_id)))),this.show=h(this.showFp)}}const Qs=new Kt(c(S(),U,y));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(),y,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 p=E.safeParse(E.string(),a);if(!p.success)return L(new pe(a,p.issues));if(!p.output)return M(void 0);const l=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(_=>new Date(Number(_)*1e3)),E.date()),hash:E.string()})),p.output);return l.success?M({raw:p.output,parsed:l.output}):L(new pe(p.output,l.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,p,l)=>{let _=50;for(;!l.isRejected;){const f=await i(l)();if(f._tag==="Left")return p(f.left);if(f.right)return a(f.right);await new Promise(C=>setTimeout(C,_)),_+=50}},u);return P(u=>V.BetterTaskEither.fn(a=>c(i(a),Y(p=>p?M(p):c(t(a),ue(l=>l==="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,y),requestPhoneAccess:Je}),Ys=h(Ye),Nt=Js({...c(S(),y),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(),y,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"}),p=A({...u,returns:"task"}),l=g.signal(!1),_=()=>{l.set(!1)};this.isSupported=Z("web_app_open_scan_qr_popup",t),this.isOpened=g.computed(l),this.captureFp=p(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"),G(_))),this.openFp=p(f=>c(this.isOpened()?L(new Se("The QR Scanner is already opened")):async()=>o("web_app_open_scan_qr_popup",{text:f.text}),ue(()=>{const[C,w]=V.createCbCollector(),v=k=>(w(),k);return c(V.BetterTaskEither(k=>{C(s(k),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,y),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()||H(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,p,l)=>{const _=i();return c(s(a,["secure_storage_failed",p],{params:{...l,req_id:_},capture:f=>"payload"in f?f.payload.req_id===_:!0}),Y(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(p=>({value:p.value,canRestore:!!p.can_restore})))),this.setItemFp=o((a,p)=>c(u("web_app_secure_storage_save_key","secure_storage_key_saved",{key:a,value:p}),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(p=>p.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(),y,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)}}),p=new me({initialState:u,isPageReload:i,onMounted:a.setState,restoreState:s.get}),l={requires:"web_app_setup_swipe_behavior",isTma:n,version:o},_=A({...l,returns:"plain"}),f=A({...l,isMounted:p.isMounted,returns:"either"}),C=w=>{const v={isVerticalEnabled:w};return a.hasDiff(v)?c(t("web_app_setup_swipe_behavior",{allow_vertical_swipe:w}),G(()=>{a.setState(v)})):q(void 0)};this.isSupported=Z("web_app_setup_swipe_behavior",o),this.isVerticalEnabled=a.getter("isVerticalEnabled"),this.isMounted=p.isMounted,this.disableVerticalFp=f(()=>C(!1)),this.enableVerticalFp=f(()=>C(!0)),this.mountFp=_(()=>{const w=()=>{};return c(p.mount(),fe(w,w))}),this.unmount=p.unmount,this.disableVertical=h(this.disableVerticalFp),this.enableVertical=h(this.enableVerticalFp),this.mount=h(this.mountFp)}}const on=new er(c(S(),j,y,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}}),Y(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,y)),cn=h(tr);function pn({invokeCustomMethod:r,...t}){return P(s=>c(r("getCurrentTime",{},s),Y(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,y)),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,y)),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(),y,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 p=parseInt(a,10);p&&(t.sdkVersion=p)}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 J(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}}),Y(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,y)),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,y)),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",()=>H(r)?void 0:"The application must be launched in the inline mode"]},returns:"either"})}const cr=vn({...c(S(),j,y),isInlineMode:qe}),yn=h(cr);class pr{constructor({storage:t,isPageReload:s,onContentSafeAreaInsetsChanged:n,onSafeAreaInsetsChanged:i,onViewportChanged:o,onFullscreenChanged:u,offContentSafeAreaInsetsChanged:a,offFullscreenChanged:p,offSafeAreaInsetsChanged:l,offViewportChanged:_,request:f,isViewportStable:C,isFullscreen:w,isTma:v,version:k,postEvent:b}){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})},Q=B=>{m.setState({contentSafeAreaInsets:B})},K=new He({initialState(B){const se=X=>()=>{const[ee,z]=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,H(k))?f(ee,z,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(z=>({...ee,height:z.height,isExpanded:z.is_expanded,stableHeight:z.is_state_stable?z.height:0,width:z.width})))))},isPageReload:s,onMounted(B){o(T),u(D),i($),n(Q),m.setState(B)},onUnmounted(){_(T),p(D),l($),a(Q)},restoreState:t.get}),N=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=N("top"),this.safeAreaInsetBottom=N("bottom"),this.safeAreaInsetLeft=N("left"),this.safeAreaInsetRight=N("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:k,returns:"task"}),Xe=B=>dr(se=>c(f(B?"web_app_request_fullscreen":"web_app_exit_fullscreen",["fullscreen_changed","fullscreen_failed"],se),Y(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=K.isMounted,this.mountFp=hr(K.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 z=B(X);if(z){const et=()=>{Ke(z,`${ee()}px`)};R.push({update:et,removeListener:ee.sub(et),cssVar:z})}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(()=>b("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"),y,j,U),isFullscreen(){return c(d.retrieveLaunchParamsFp(),G(o=>!!o.tgWebAppFullscreen))},isViewportStable(){return c(d.retrieveLaunchParamsFp(),G(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(p=>p,p=>{Be.set(t||p.tgWebAppVersion),qe.set(typeof s=="boolean"?s:!!p.tgWebAppBotInline),Pe.set(n||p.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",p=>{a.innerHTML=p}),()=>{document.head.removeChild(a)})}return c(ie("iframe_ready",{reload_supported:!0}),G(()=>(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=J;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 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,p){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 p(a(u(o(i(n(s(t(r.apply(this,arguments)))))))))}}}function c(r,t,s,n,i,o,u,a,p){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 p(a(u(o(i(n(s(t(r))))))));default:{for(var l=arguments[0],_=1;_<arguments.length;_++)l=arguments[_](l);return l}}}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(p=>{g.batch(()=>{this._isMounted.set(!0),t==null||t(p)})}))},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(_){try{l(n.next(_))}catch(f){u(f)}}function p(_){try{l(n.throw(_))}catch(f){u(f)}}function l(_){_.done?o(_.value):i(_.value).then(a,p)}l((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(l){return function(_){return p([l,_])}}function p(l){if(n)throw new TypeError("Generator is already executing.");for(;u&&(u=0,l[0]&&(s=0)),s;)try{if(n=1,i&&(o=l[0]&2?i.return:l[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,l[1])).done)return o;switch(i=0,o&&(l=[l[0]&2,o.value]),l[0]){case 0:case 1:o=l;break;case 4:return s.label++,{value:l[1],done:!1};case 5:s.label++,i=l[1],l=[0];continue;case 7:l=s.ops.pop(),s.trys.pop();continue;default:if(o=s.trys,!(o=o.length>0&&o[o.length-1])&&(l[0]===6||l[0]===2)){s=0;continue}if(l[0]===3&&(!o||l[1]>o[0]&&l[1]<o[3])){s.label=l[1];break}if(l[0]===6&&s.label<o[1]){s.label=o[1],o=l;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(l);break}o[2]&&s.ops.pop(),s.trys.pop();continue}l=t.call(r,s)}catch(_){l=[6,_],i=0}finally{n=o=0}if(l[0]&5)throw l[1];return{value:l[0]?l[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=b=>{if(!t.supports)return!0;const F=t.supports[b];return d.supports(F.method,F.param,s())},p=()=>{if(!u)return;const[b,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&&(b==="every"||m===F.length-1))return D}},l=(...b)=>{for(const F in t.supports)if(t.supports[F].shouldCheck(...b)&&!a(F))return`option ${F} is not supported in Mini Apps version ${s()}`},_=g.computed(()=>!p()),f=g.computed(()=>s()!=="0.0"),C=g.computed(()=>t.isMounted?t.isMounted():!0),w=g.computed(()=>n()&&f()&&_()&&C()),v=b=>{const F=new _t(b);return["task","promise"].includes(t.returns)?L(F):O(F)},k=(...b)=>o==="plain"?qr(()=>r(...b),F=>F):o==="promise"?os(()=>r(...b),F=>F):r(...b);return Object.assign((...b)=>{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=p();if(m)return v(`${F} ${m}`);const T=l(...b);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 k(...b)},r,{isAvailable:w,ifAvailable(...b){return w()?_e(k(...b)):ae}},u?{isSupported:_}:{},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:p,method:l,version:_}){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(b){s.set(b)}}),C=new me({initialState:o,isPageReload:u,onMounted:f.setState,restoreState:s.get}),w={version:_,requires:l,isTma:t},v=A({...w,returns:"plain"}),k=A({...w,returns:"either",isMounted:C.isMounted});this.isMounted=C.isMounted,this.isSupported=Z(l,_),this.state=f.state,this.setStateFp=k(b=>{const F={...this.state(),...Ae(b)};return f.hasDiff(F)?c(a(l,p(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 b=()=>{};return c(C.mount(),fe(b,b))}),this.mount=h(this.mountFp),this.unmount=C.unmount,this.stateSetters=b=>{const F=k(m=>this.setStateFp({[b]:m}));return[h(F),F]},this.stateBoolSetters=b=>{const[,F]=this.stateSetters(b),m=k(()=>F(!1)),T=k(()=>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"),y=ce({version:Be});function Ge(r,t){return{...c(S(),j,y,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(p=>{this._isMounted()||g.batch(()=>{this._isMounted.set(!0),s==null||s(p)})}))},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:p}){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 l=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(b){return c(s("web_app_biometry_get_info","biometry_info_received",b),I(Ee))},isPageReload:p,onMounted(b){_.setState(b),o(l)},onUnmounted(){u(l)},restoreState:i.get}),C={version:t,requires:"web_app_biometry_request_auth",isTma:a},w=A({...C,returns:"either"}),v=A({...C,returns:"task"}),k=A({...C,isMounted:f.isMounted,returns:"task"});this.isAvailable=_.getter("available"),this.isMounted=f.isMounted,this.isSupported=Z("web_app_biometry_request_auth",t),this.state=_.state,this.unmount=f.unmount,this.mountFp=v(f.mount),this.authenticateFp=k(b=>this.isAvailable()?c(s("web_app_biometry_request_auth","biometry_auth_requested",{...b,params:{reason:((b||{}).reason||"").trim()}}),I(F=>(_.setState({token:F.token}),F))):L(st)),this.openSettingsFp=w(()=>n("web_app_biometry_open_settings")),this.requestAccessFp=k(b=>c(s("web_app_biometry_request_access","biometry_info_received",{...b,params:{reason:((b||{}).reason||"").trim()}}),J(F=>{const m=Ee(F);return m.available?(_.setState(m),M(m.accessRequested)):L(st)}))),this.updateTokenFp=k((b={})=>{var F;return c(s("web_app_biometry_update_token","biometry_token_updated",{...b,params:{token:b.token||"",reason:(F=b.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,y,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},p=A({...a,returns:"plain"}),l=A({...a,returns:"either",isMounted:u.isMounted}),_=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=l(()=>_(!1)),this.enableConfirmationFp=l(()=>_(!0)),this.mountFp=p(()=>{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((p,l)=>(p[l]="",p),{}),...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(),y,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,p,l)=>{const _=i();return c(s(a,["device_storage_failed",p],{params:{...l,req_id:_},capture:f=>"payload"in f?f.payload.req_id===_:!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(p=>p.value))),this.setItemFp=o((a,p)=>c(u("web_app_device_storage_save_key","device_storage_key_saved",{key:a,value:p}),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(),y,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(),y,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,y)),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,y));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(),y,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(),y,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,p)=>c(this.isOpened()?L(new Se("Invoice is already opened")):M(void 0),J(()=>(o.set(!0),s("web_app_open_invoice","invoice_closed",{...p,params:{slug:a},capture:l=>a===l.slug}))),je(l=>(u(),l),l=>(u(),l.status)))),this.openUrlFp=i((a,p)=>{const{hostname:l,pathname:_}=new URL(a,window.location.href);if(l!=="t.me")return L(new z(`Link has unexpected hostname: ${l}`));const f=_.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);return f?this.openSlugFp(f[2],p):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,y));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,y)),$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}),p=new He({isPageReload:u,restoreState:i.get,onMounted:a.setState,initialState(w){return c(s("web_app_check_location","location_checked",w),I(Us))}}),l={version:t,requires:"web_app_check_location",isTma:o},_=A({...l,returns:"either"}),f=A({...l,returns:"task"}),C=A({...l,returns:"task",isMounted:p.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=p.isMounted,this.state=a.state,this.unmount=p.unmount,this.mountFp=f(p.mount),this.openSettingsFp=_(()=>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:k,...b}=v;return b}))),this.mount=h(this.mountFp),this.openSettings=h(this.openSettingsFp),this.requestLocation=h(this.requestLocationFp)}}const Gs=new jt(c(S(),j,y,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}),p=w=>{a.setState(w.theme_params)},l=new me({initialState:()=>q(W(t)),isPageReload:u,onMounted(w){a.setState(w),s(p)},onUnmounted(){n(p)},restoreState:o.get}),_={isTma:i,returns:"either"},f=A(_),C=A({..._,isMounted:l.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=l.isMounted,this.bindCssVarsFp=C(w=>{if(this._isCssVarsBound())return O(new Ce);w||(w=b=>`--tg-theme-${V.snakeToKebab(b)}`);const v=b=>{Object.entries(a.state()).forEach(([F,m])=>{m&&b(F,m)})},k=()=>{v((b,F)=>{Ke(w(b),F)})};return k(),a.state.sub(k),this._isCssVarsBound.set(!0),q(()=>{v(Ne),a.state.unsub(k),this._isCssVarsBound.set(!1)})}),this.mountFp=f(l.mount),this.unmount=l.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:p}){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 l=m=>{C.setState({isActive:m.is_visible})},_=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(l),u.sub(_),C.setState(m)},onUnmounted(){p(l),u.unsub(_)},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 k=g.signal(!1);this.isCssVarsBound=g.computed(k),this.bindCssVarsFp=P(m=>{if(k())return O(new Ce);const[T,D]=V.createCbCollector(()=>{k.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),k.set(!0),q(D)},{isTma:o,returns:"either",isMounted:this.isMounted}),this.bindCssVars=h(this.bindCssVarsFp);const b=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]=b("bgColor"),[this.headerColor,this.headerColorRgb,this.setHeaderColor,this.setHeaderColorFp]=b("headerColor"),[this.bottomBarColor,this.bottomBarColorRgb,this.setBottomBarColor,this.setBottomBarColorFp]=b("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,y,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 p=u.text.trim();if(!p||p.length>64)return O(new z(`Button with index ${o} has invalid text: ${p}`));i.push({type:u.type,text:p,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(p=>(i.set(!0),n("web_app_open_popup","popup_closed",{...a,params:p}))),je(p=>(o(),p),p=>(o(),p.button_id)))),this.show=h(this.showFp)}}const Qs=new Kt(c(S(),U,y));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(),y,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 p=E.safeParse(E.string(),a);if(!p.success)return L(new pe(a,p.issues));if(!p.output)return M(void 0);const l=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(_=>new Date(Number(_)*1e3)),E.date()),hash:E.string()})),p.output);return l.success?M({raw:p.output,parsed:l.output}):L(new pe(p.output,l.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,p,l)=>{let _=50;for(;!l.isRejected;){const f=await i(l)();if(f._tag==="Left")return p(f.left);if(f.right)return a(f.right);await new Promise(C=>setTimeout(C,_)),_+=50}},u);return P(u=>V.BetterTaskEither.fn(a=>c(i(a),J(p=>p?M(p):c(t(a),ue(l=>l==="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,y),requestPhoneAccess:Je}),Ys=h(Ye),Nt=Js({...c(S(),y),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(),y,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"}),p=A({...u,returns:"task"}),l=g.signal(!1),_=()=>{l.set(!1)};this.isSupported=Z("web_app_open_scan_qr_popup",t),this.isOpened=g.computed(l),this.captureFp=p(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(_))),this.openFp=p(f=>c(this.isOpened()?L(new Se("The QR Scanner is already opened")):async()=>o("web_app_open_scan_qr_popup",{text:f.text}),ue(()=>{const[C,w]=V.createCbCollector(),v=k=>(w(),k);return c(V.BetterTaskEither(k=>{C(s(k),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,y),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,p,l)=>{const _=i();return c(s(a,["secure_storage_failed",p],{params:{...l,req_id:_},capture:f=>"payload"in f?f.payload.req_id===_:!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(p=>({value:p.value,canRestore:!!p.can_restore})))),this.setItemFp=o((a,p)=>c(u("web_app_secure_storage_save_key","secure_storage_key_saved",{key:a,value:p}),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(p=>p.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(),y,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)}}),p=new me({initialState:u,isPageReload:i,onMounted:a.setState,restoreState:s.get}),l={requires:"web_app_setup_swipe_behavior",isTma:n,version:o},_=A({...l,returns:"plain"}),f=A({...l,isMounted:p.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=p.isMounted,this.disableVerticalFp=f(()=>C(!1)),this.enableVerticalFp=f(()=>C(!0)),this.mountFp=_(()=>{const w=()=>{};return c(p.mount(),fe(w,w))}),this.unmount=p.unmount,this.disableVertical=h(this.disableVerticalFp),this.enableVertical=h(this.enableVerticalFp),this.mount=h(this.mountFp)}}const on=new er(c(S(),j,y,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,y)),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,y)),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,y)),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(),y,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 p=parseInt(a,10);p&&(t.sdkVersion=p)}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,y)),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,y)),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,y),isInlineMode:qe}),yn=h(cr);class pr{constructor({storage:t,isPageReload:s,onContentSafeAreaInsetsChanged:n,onSafeAreaInsetsChanged:i,onViewportChanged:o,onFullscreenChanged:u,offContentSafeAreaInsetsChanged:a,offFullscreenChanged:p,offSafeAreaInsetsChanged:l,offViewportChanged:_,request:f,isViewportStable:C,isFullscreen:w,isTma:v,version:k,postEvent:b}){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(k))?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(){_(T),p(D),l($),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:k,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(()=>b("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"),y,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(p=>p,p=>{Be.set(t||p.tgWebAppVersion),qe.set(typeof s=="boolean"?s:!!p.tgWebAppBotInline),Pe.set(n||p.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",p=>{a.innerHTML=p}),()=>{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;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|