Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@telegram-apps/sdk

Package Overview
Dependencies
Maintainers
0
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@telegram-apps/sdk - npm Package Compare versions

Comparing version 2.6.1 to 2.6.2

2

dist/index.iife.js
this.telegramApps=this.telegramApps||{};this.telegramApps.sdk=function(o){"use strict";let he=class Es extends Error{constructor(t,n,i){super(typeof n=="object"?n.message:n||t,{cause:typeof n=="object"?n.cause:i}),this.type=t,Object.setPrototypeOf(this,Es.prototype)}};function Ln(e){return e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`)}function Ss(e){return e.replace(/_[a-z]/g,t=>t[1].toUpperCase())}const Un="ERR_INVALID_VALUE",jn="ERR_UNEXPECTED_VALUE",qn="ERR_UNEXPECTED_TYPE",Ot="ERR_PARSE";function Hn(e,t){const n={};for(const i in e){const r=e[i];if(!r)continue;let s,a;typeof r=="function"?(s=i,a=r):[s,a]=r;try{const c=a(t(s));c!==void 0&&(n[i]=c)}catch(c){throw new he(Ot,`Parser for "${i}" property failed${s===i?"":`. Source field: "${s}"`}`,c)}}return n}function Bt(e){let t=e;if(typeof t=="string")try{t=JSON.parse(t)}catch(n){throw new he(Un,{cause:n})}if(typeof t!="object"||!t||Array.isArray(t))throw new he(jn);return t}function U(e,t){return n=>{const i=r=>{if(!(n&&r===void 0))try{return t(r)}catch(s){throw new he(Ot,{message:`"${e}" transformer failed to parse the value`,cause:s})}};return Object.assign(i,{isValid(r){try{return i(r),!0}catch{return!1}}})}}function Ue(e,t){return U(t||"object",n=>{const i=Bt(n);return Hn(e,r=>i[r])})}function be(e){throw new he(qn,`Unexpected value received: ${JSON.stringify(e)}`)}const Cs=U("boolean",e=>{if(typeof e=="boolean")return e;const t=String(e);if(t==="1"||t==="true")return!0;if(t==="0"||t==="false")return!1;be(e)}),j=U("string",e=>{if(typeof e=="string"||typeof e=="number")return e.toString();be(e)}),je=U("number",e=>{if(typeof e=="number")return e;if(typeof e=="string"){const t=Number(e);if(!Number.isNaN(t))return t}be(e)}),Mt=U("date",e=>e instanceof Date?e:new Date(je()(e)*1e3));function Wn(e,t){return U(t||"searchParams",n=>{typeof n!="string"&&!(n instanceof URLSearchParams)&&be(n);const i=typeof n=="string"?new URLSearchParams(n):n;return Hn(e,r=>{const s=i.get(r);return s===null?void 0:s})})}function Dt(e){for(const t in e)e[t]=[Ln(t),e[t]];return e}const $s=e=>{const t=je(),n=je(!0),i=j(),r=j(!0),s=Cs(!0),a=Ue(Dt({addedToAttachmentMenu:s,allowsWriteToPm:s,firstName:i,id:t,isBot:s,isPremium:s,languageCode:r,lastName:r,photoUrl:r,username:r}),"User")(!0);return Wn(Dt({authDate:Mt(),canSendAfter:n,chat:Ue(Dt({id:t,type:i,title:i,photoUrl:r,username:r}),"Chat")(!0),chatInstance:r,chatType:r,hash:i,queryId:r,receiver:a,startParam:r,user:a}),"initData")(e)};function K(e){return/^#[\da-f]{6}$/i.test(e)}function Gn(e){return/^#[\da-f]{3}$/i.test(e)}function Nt(e){const t=e.replace(/\s/g,"").toLowerCase();if(K(t))return t;if(Gn(t)){let i="#";for(let r=0;r<3;r+=1)i+=t[1+r].repeat(2);return i}const n=t.match(/^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/)||t.match(/^rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),\d{1,3}\)$/);if(!n)throw new Error(`Value "${e}" does not satisfy any of known RGB formats.`);return n.slice(1).reduce((i,r)=>{const s=parseInt(r,10).toString(16);return i+(s.length===1?"0":"")+s},"#")}const As=U("rgb",e=>Nt(j()(e))),vs=U("themeParams",e=>{const t=As(!0);return Object.entries(Bt(e)).reduce((n,[i,r])=>(n[Ss(i)]=t(r),n),{})});function zn(e){return JSON.stringify(Object.fromEntries(Object.entries(e).map(([t,n])=>[Ln(t),n])))}function Rs(e){const{initDataRaw:t,startParam:n,showSettings:i,botInline:r}=e,s=new URLSearchParams;return s.set("tgWebAppPlatform",e.platform),s.set("tgWebAppThemeParams",zn(e.themeParams)),s.set("tgWebAppVersion",e.version),t&&s.set("tgWebAppData",t),n&&s.set("tgWebAppStartParam",n),typeof i=="boolean"&&s.set("tgWebAppShowSettings",i?"1":"0"),typeof r=="boolean"&&s.set("tgWebAppBotInline",r?"1":"0"),s.toString()}function Ts(e,t){return U("array",n=>{let i;if(Array.isArray(n))i=n;else if(typeof n=="string")try{const r=JSON.parse(n);Array.isArray(r)&&(i=r)}catch{}return i||be(n),i.map(e)})}function It(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function qe(...e){return e.map(t=>{if(typeof t=="string")return t;if(It(t))return qe(Object.entries(t).map(n=>n[1]&&n[0]));if(Array.isArray(t))return qe(...t)}).filter(Boolean).join(" ")}function Ps(...e){return e.reduce((t,n)=>(It(n)&&Object.entries(n).forEach(([i,r])=>{const s=qe(t[i],r);s&&(t[i]=s)}),t),{})}let ge=class ws extends Error{constructor(t,n,i){super(typeof n=="object"?n.message:n||t,{cause:typeof n=="object"?n.cause:i}),this.type=t,Object.setPrototypeOf(this,ws.prototype)}};function Fn(e){return e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`)}function Os(e){return e.replace(/_[a-z]/g,t=>t[1].toUpperCase())}const Bs="ERR_INVALID_VALUE",Ms="ERR_UNEXPECTED_VALUE",Ds="ERR_UNEXPECTED_TYPE",Qn="ERR_PARSE";function Yn(e,t){const n={};for(const i in e){const r=e[i];if(!r)continue;let s,a;typeof r=="function"?(s=i,a=r):[s,a]=r;try{const c=a(t(s));c!==void 0&&(n[i]=c)}catch(c){throw new ge(Qn,`Parser for "${i}" property failed${s===i?"":`. Source field: "${s}"`}`,c)}}return n}function Jn(e){let t=e;if(typeof t=="string")try{t=JSON.parse(t)}catch(n){throw new ge(Bs,{cause:n})}if(typeof t!="object"||!t||Array.isArray(t))throw new ge(Ms);return t}function B(e,t){return n=>{const i=r=>{if(!(n&&r===void 0))try{return t(r)}catch(s){throw new ge(Qn,{message:`"${e}" transformer failed to parse the value`,cause:s})}};return Object.assign(i,{isValid(r){try{return i(r),!0}catch{return!1}}})}}function M(e,t){return B(t||"object",n=>{const i=Jn(n);return Yn(e,r=>i[r])})}function Ee(e){throw new ge(Ds,`Unexpected value received: ${JSON.stringify(e)}`)}const He=B("boolean",e=>{if(typeof e=="boolean")return e;const t=String(e);if(t==="1"||t==="true")return!0;if(t==="0"||t==="false")return!1;Ee(e)}),A=B("string",e=>{if(typeof e=="string"||typeof e=="number")return e.toString();Ee(e)}),we=B("number",e=>{if(typeof e=="number")return e;if(typeof e=="string"){const t=Number(e);if(!Number.isNaN(t))return t}Ee(e)}),Ns=B("date",e=>e instanceof Date?e:new Date(we()(e)*1e3));function Zn(e,t){return B(t||"searchParams",n=>{typeof n!="string"&&!(n instanceof URLSearchParams)&&Ee(n);const i=typeof n=="string"?new URLSearchParams(n):n;return Yn(e,r=>{const s=i.get(r);return s===null?void 0:s})})}function kt(e){for(const t in e)e[t]=[Fn(t),e[t]];return e}const Is=e=>{const t=we(),n=we(!0),i=A(),r=A(!0),s=He(!0),a=M(kt({addedToAttachmentMenu:s,allowsWriteToPm:s,firstName:i,id:t,isBot:s,isPremium:s,languageCode:r,lastName:r,photoUrl:r,username:r}),"User")(!0);return Zn(kt({authDate:Ns(),canSendAfter:n,chat:M(kt({id:t,type:i,title:i,photoUrl:r,username:r}),"Chat")(!0),chatInstance:r,chatType:r,hash:i,queryId:r,receiver:a,startParam:r,user:a}),"initData")(e)};function ks(e){return/^#[\da-f]{6}$/i.test(e)}function Vs(e){return/^#[\da-f]{3}$/i.test(e)}function Ls(e){const t=e.replace(/\s/g,"").toLowerCase();if(ks(t))return t;if(Vs(t)){let i="#";for(let r=0;r<3;r+=1)i+=t[1+r].repeat(2);return i}const n=t.match(/^rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)$/)||t.match(/^rgba\((\d{1,3}),(\d{1,3}),(\d{1,3}),\d{1,3}\)$/);if(!n)throw new Error(`Value "${e}" does not satisfy any of known RGB formats.`);return n.slice(1).reduce((i,r)=>{const s=parseInt(r,10).toString(16);return i+(s.length===1?"0":"")+s},"#")}const Us=B("rgb",e=>Ls(A()(e))),js=B("themeParams",e=>{const t=Us(!0);return Object.entries(Jn(e)).reduce((n,[i,r])=>(n[Os(i)]=t(r),n),{})});function Kn(e){return JSON.stringify(Object.fromEntries(Object.entries(e).map(([t,n])=>[Fn(t),n])))}const qs=e=>{const t=A(),n=A(!0),i=He(!0);return Zn({botInline:["tgWebAppBotInline",i],initData:["tgWebAppData",Is(!0)],initDataRaw:["tgWebAppData",n],platform:["tgWebAppPlatform",t],showSettings:["tgWebAppShowSettings",i],startParam:["tgWebAppStartParam",n],themeParams:["tgWebAppThemeParams",js()],version:["tgWebAppVersion",t]},"launchParams")(e)};function Hs(e){const{initDataRaw:t,startParam:n,showSettings:i,botInline:r}=e,s=new URLSearchParams;return s.set("tgWebAppPlatform",e.platform),s.set("tgWebAppThemeParams",Kn(e.themeParams)),s.set("tgWebAppVersion",e.version),t&&s.set("tgWebAppData",t),n&&s.set("tgWebAppStartParam",n),typeof i=="boolean"&&s.set("tgWebAppShowSettings",i?"1":"0"),typeof r=="boolean"&&s.set("tgWebAppBotInline",r?"1":"0"),s.toString()}const Xn=M({eventType:A(),eventData:e=>e},"miniAppsMessage"),xn=B("fn",e=>{if(typeof e=="function")return e;Ee(e)});function Ws(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}const Gs=M({TelegramWebviewProxy:M({postEvent:xn()})()});function eo(e){return Gs().isValid(e)}function to(){try{return window.self!==window.top}catch{return!0}}var zs=Object.defineProperty,Fs=(e,t,n)=>t in e?zs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,no=(e,t,n)=>Fs(e,typeof t!="symbol"?t+"":t,n);let d=class ys extends Error{constructor(t,n,i){super(typeof n=="object"?n.message:n||t,{cause:typeof n=="object"?n.cause:i}),this.type=t,Object.setPrototypeOf(this,ys.prototype)}};function We(e,t,n){return e.addEventListener(t,n),()=>e.removeEventListener(t,n)}function X(...e){const t=e.flat(1);return[t.push.bind(t),()=>{t.forEach(n=>{n()})}]}function Qs(e,t){return e instanceof d&&e.type===t}function Vt(e){return t=>Qs(t,e)}const Lt="ERR_ABORTED",Ut="ERR_CANCELED",jt="ERR_TIMED_OUT";function oo(e){return new d(Lt,{cause:e})}const Ys=Vt(jt),Js=Vt(Lt),Zs=Vt(Ut);function ro(e,t){return e.reject=t.reject,e}class g extends Promise{constructor(t,n){let i,r;typeof t=="function"?(i=t,r=n):r=t;let s,a;super((c,_)=>{r||(r={});const{abortSignal:u}=r;if(u&&u.aborted)return _(oo(u.reason));const[p,E]=X(),S=h=>(...Z)=>(E(),h(...Z)),W=new AbortController,{signal:$}=W;a=S(h=>{W.abort(h),_(h)}),s=S(c),u&&p(We(u,"abort",()=>{a(oo(u.reason))}));const{timeout:b}=r;if(b){const h=setTimeout(()=>{a(new d(jt,`Timeout reached: ${b}ms`))},b);p(()=>{clearTimeout(h)})}i&&i(s,a,$)}),no(this,"reject"),this.reject=a}static withFn(t,n){return new g((i,r,s)=>{try{const a=t(s);return a instanceof Promise?a.then(i,r):i(a)}catch(a){r(a)}},n)}static resolve(t){return new g(n=>{n(t)})}static reject(t){return new g((n,i)=>{i(t)})}cancel(){this.reject(new d(Ut))}catch(t){return this.then(void 0,t)}finally(t){return ro(super.finally(t),this)}then(t,n){return ro(super.then(t,n),this)}}function io(e,t){return e.resolve=t.resolve,e}class ye extends g{constructor(t,n){let i,r;typeof t=="function"?(i=t,r=n):r=t;let s;super((a,c,_)=>{s=a,i&&i(a,c,_)},r),no(this,"resolve"),this.resolve=s}static withFn(t,n){return new ye((i,r,s)=>g.withFn(t,{abortSignal:s}).then(i,r),n)}static resolve(t){return new ye(n=>{n(t)})}static reject(t){return new ye((n,i)=>{i(t)})}catch(t){return this.then(void 0,t)}finally(t){return io(super.finally(t),this)}then(t,n){return io(super.then(t,n),this)}}function Ks(e,t){return new g(n=>{setTimeout(n,e)},{abortSignal:t})}function so(e){return`tapps/${e}`}function v(e,t){sessionStorage.setItem(so(e),JSON.stringify(t))}function R(e){const t=sessionStorage.getItem(so(e));try{return t?JSON.parse(t):void 0}catch{}}function qt(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function Xs(e,t){t||(t={});const{textColor:n,bgColor:i,shouldLog:r=!0}=t;function s(a,...c){if(!r||typeof r=="function"&&!r())return;const _="font-weight:bold;padding:0 5px;border-radius:5px";console[a](`%c${Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3,timeZone:"UTC"}).format(new Date)}%c / %c${e}`,`${_};background-color: lightblue;color:black`,"",`${_};${n?`color:${n};`:""}${i?`background-color:${i}`:""}`,...c)}return[function(...a){s("log",...a)},function(...a){s("error",...a)}]}function Ge(e,t){document.documentElement.style.setProperty(e,t)}function ze(e){document.documentElement.style.removeProperty(e)}function xs(e,t){t()}function x(e,t){t||(t={});const n=t.equals||Object.is;let i=[],r=e;const s=u=>{if(!n(r,u)){const p=r;r=u,xs(_,()=>{[...i].forEach(([E,S])=>{E(u,p),S&&c(E,!0)})})}};function a(u){const p=typeof u!="object"?{once:u}:u;return{once:p.once||!1,signal:p.signal||!1}}const c=(u,p)=>{const E=a(p),S=i.findIndex(([W,$])=>W===u&&$.once===E.once&&$.signal===E.signal);S>=0&&i.splice(S,1)},_=Object.assign(function(){return ea(_),r},{destroy(){i=[]},set:s,reset(){s(e)},sub(u,p){return i.push([u,a(p)]),()=>c(u,p)},unsub:c,unsubAll(){i=i.filter(u=>u[1].signal)}});return _}const Ht=[];function ea(e){Ht.length&&Ht[Ht.length-1].add(e)}const ao=x(!1),[Wt,ta]=Xs("Bridge",{bgColor:"#9147ff",textColor:"white",shouldLog:ao}),na={clipboard_text_received:M({req_id:A(),data:e=>e===null?e:A(!0)(e)},"clipboard_text_received"),custom_method_invoked:M({req_id:A(),result:e=>e,error:A(!0)},"custom_method_invoked"),popup_closed:B("popup_closed",e=>e?M({button_id:t=>t==null?void 0:A()(t)})()(e):{}),viewport_changed:M({height:we(),width:e=>e==null?window.innerWidth:we()(e),is_state_stable:He(),is_expanded:He()},"viewport_changed")};function oa(e){const t=window,[,n]=X(We(t,"resize",()=>{e(["viewport_changed",{width:window.innerWidth,height:window.innerHeight,is_state_stable:!0,is_expanded:!0}])}),We(t,"message",i=>{if(i.source!==t.parent)return;let r;try{r=Xn()(i.data)}catch{return}const{eventType:s,eventData:a}=r,c=na[s];try{const _=c?c()(a):a;Wt("Event received:",_?{eventType:s,eventData:_}:{eventType:s}),e([s,_])}catch(_){ta([`An error occurred processing the "${s}" event from the Telegram application.`,"Please, file an issue here:","https://github.com/Telegram-Mini-Apps/telegram-apps/issues/new/choose"].join(`
`),r,_)}}));return n}const Gt=x(),co=x();function uo(){return co()||co.set(oa(Gt.set)),Gt}const zt=x({});function lo(e){let t=zt()[e];return t||(t=x(void 0,{equals(){return!1}}),uo().sub(n=>{n&&n[0]===e&&t.set(n[1])}),zt.set({...zt(),[e]:t})),t}function C(e,t,n){return lo(e).sub(t,n)}const _o="ERR_METHOD_UNSUPPORTED",fo="ERR_RETRIEVE_LP_FAILED",po="ERR_METHOD_PARAMETER_UNSUPPORTED",Ft="ERR_UNKNOWN_ENV",mo="ERR_INVOKE_CUSTOM_METHOD_RESPONSE",ho=x("https://web.telegram.org");function Fe(e,t){Wt("Posting event:",t?{eventType:e,eventData:t}:{eventType:e});const n=window;if(eo(n)){n.TelegramWebviewProxy.postEvent(e,JSON.stringify(t));return}const i=JSON.stringify({eventType:e,eventData:t});if(to())return n.parent.postMessage(i,ho());const{external:r}=n;if(M({notify:xn()})().isValid(r)){r.notify(i);return}throw new d(Ft)}function Qe(e,t,n){n||(n={});const{capture:i}=n,[r,s]=X();return new g(a=>{(Array.isArray(t)?t:[t]).forEach(c=>{r(C(c,_=>{(!i||(Array.isArray(t)?i({event:c,payload:_}):i(_)))&&a(_)}))}),(n.postEvent||Fe)(e,n.params)},n).finally(s)}function Qt(e){return qs()(e)}function bo(e){return Qt(e.replace(/^[^?#]*[?#]/,"").replace(/[?#]/g,"&"))}function ra(){return bo(window.location.href)}function ia(){const e=performance.getEntriesByType("navigation")[0];if(!e)throw new Error("Unable to get first navigation entry.");return bo(e.name)}const sa="launchParams";function aa(){return Qt(R(sa)||"")}function go(e){v("launchParams",Hs(e))}function Eo(e){return e instanceof Error?e.message+(e.cause?`
${Eo(e.cause)}`:""):JSON.stringify(e)}function Q(){const e=[];for(const t of[ra,ia,aa])try{const n=t();return go(n),n}catch(n){e.push(n)}throw new d(fo,["Unable to retrieve launch parameters from any known source. Perhaps, you have opened your app outside Telegram?","📖 Refer to docs for more information:","https://docs.telegram-mini-apps.com/packages/telegram-apps-sdk/environment","Collected errors:",...e.map(t=>`— ${Eo(t)}`)].join(`
`))}function Yt(e){if(e==="simple")try{return Q(),!0}catch{return!1}return g.withFn(async()=>{if(eo(window))return!0;try{return await Qe("web_app_request_theme","theme_changed",{timeout:100}),!0}catch{return!1}},e)}function Ye(e,t){window.dispatchEvent(new MessageEvent("message",{data:JSON.stringify({eventType:e,eventData:t}),source:window.parent}))}function ca(e,t){if(typeof t=="string")try{const{eventType:n}=Xn()(t);n==="web_app_request_theme"&&Ye("theme_changed",{theme_params:JSON.parse(Kn(e))}),n==="web_app_request_viewport"&&Ye("viewport_changed",{width:window.innerWidth,height:window.innerHeight,is_state_stable:!0,is_expanded:!0})}catch{}}function ua(e){var t;const n=typeof e=="string"?Qt(e):e;go(n);const i=(t=window.TelegramWebviewProxy)==null?void 0:t.postEvent;window.TelegramWebviewProxy={postEvent(r,s){ca(n.themeParams,JSON.stringify({eventType:r,eventData:s})),i==null||i(r,s)}},Wt("Environment was mocked by the mockTelegramEnv function")}function wo(){[["TelegramGameProxy_receiveEvent"],["TelegramGameProxy","receiveEvent"],["Telegram","WebView","receiveEvent"]].forEach(e=>{let t=window;e.forEach((n,i,r)=>{if(i===r.length-1){t[n]=Ye;return}n in t||(t[n]={}),t=t[n]})})}function yo(){["TelegramGameProxy_receiveEvent","TelegramGameProxy","Telegram"].forEach(e=>{delete window[e]})}function G(e,t,n){lo(e).unsub(t,n)}function la(e,t){return uo().sub(e,t)}function _a(e,t){Gt.unsub(e,t)}function So(e){return({req_id:t})=>t===e}function Co(e){return e.split(".").map(Number)}function $o(e,t){const n=Co(e),i=Co(t),r=Math.max(n.length,i.length);for(let s=0;s<r;s+=1){const a=n[s]||0,c=i[s]||0;if(a!==c)return a>c?1:-1}return 0}function w(e,t){return $o(e,t)<=0}function z(e,t,n){if(typeof n=="string"){if(e==="web_app_open_link"){if(t==="try_instant_view")return w("6.4",n);if(t==="try_browser")return w("7.6",n)}if(e==="web_app_set_header_color"&&t==="color")return w("6.9",n);if(e==="web_app_close"&&t==="return_back")return w("7.6",n);if(e==="web_app_setup_main_button"&&t==="has_shine_effect")return w("7.10",n)}switch(e){case"web_app_open_tg_link":case"web_app_open_invoice":case"web_app_setup_back_button":case"web_app_set_background_color":case"web_app_set_header_color":case"web_app_trigger_haptic_feedback":return w("6.1",t);case"web_app_open_popup":return w("6.2",t);case"web_app_close_scan_qr_popup":case"web_app_open_scan_qr_popup":case"web_app_read_text_from_clipboard":return w("6.4",t);case"web_app_switch_inline_query":return w("6.7",t);case"web_app_invoke_custom_method":case"web_app_request_write_access":case"web_app_request_phone":return w("6.9",t);case"web_app_setup_settings_button":return w("6.10",t);case"web_app_biometry_get_info":case"web_app_biometry_open_settings":case"web_app_biometry_request_access":case"web_app_biometry_request_auth":case"web_app_biometry_update_token":return w("7.2",t);case"web_app_setup_swipe_behavior":return w("7.7",t);case"web_app_share_to_story":return w("7.8",t);case"web_app_setup_secondary_button":case"web_app_set_bottom_bar_color":return w("7.10",t);default:return["iframe_ready","iframe_will_reload","web_app_close","web_app_data_send","web_app_expand","web_app_open_link","web_app_ready","web_app_request_theme","web_app_request_viewport","web_app_setup_main_button","web_app_setup_closing_behavior"].includes(e)}}function Ao(e,t){t||(t="strict");const n=typeof t=="function"?t:i=>{const{method:r,version:s}=i;let a,c;if("param"in i?(a=`Parameter "${i.param}" of "${r}" method is unsupported in Mini Apps version ${s}`,c=po):(a=`Method "${r}" is unsupported in Mini Apps version ${s}`,c=_o),t==="strict")throw new d(c,a);return console.warn(a)};return(i,r)=>z(i,e)?Ws(r)&&i==="web_app_set_header_color"&&"color"in r&&!z(i,"color",e)?n({version:e,method:i,param:"color"}):Fe(i,r):n({version:e,method:i})}function vo(e,t,n,i){return Qe("web_app_invoke_custom_method","custom_method_invoked",{...i||{},params:{method:e,params:t,req_id:n},capture:So(n)}).then(({result:r,error:s})=>{if(s)throw new d(mo,s);return r})}function da(){return performance.getEntriesByType("navigation")[0]}function D(){const e=da();return!!e&&e.type==="reload"}let ee;function fa(e,t){ee&&ee.set(e,t)||t()}function pa(e){if(ee)return e();ee=new Map;try{e()}finally{ee.forEach(t=>t()),ee=void 0}}function l(e,t){t||(t={});const n=t.equals||Object.is;let i=[],r=e;const s=u=>{if(!n(r,u)){const p=r;r=u,fa(_,()=>{[...i].forEach(([E,S])=>{E(u,p),S&&c(E,!0)})})}};function a(u){const p=typeof u!="object"?{once:u}:u;return{once:p.once||!1,signal:p.signal||!1}}const c=(u,p)=>{const E=a(p),S=i.findIndex(([W,$])=>W===u&&$.once===E.once&&$.signal===E.signal);S>=0&&i.splice(S,1)},_=Object.assign(function(){return ma(_),r},{destroy(){i=[]},set:s,reset(){s(e)},sub(u,p){return i.push([u,a(p)]),()=>c(u,p)},unsub:c,unsubAll(){i=i.filter(u=>u[1].signal)}});return _}const Se=[];function ma(e){Se.length&&Se[Se.length-1].add(e)}function m(e,t){let n=new Set,i;function r(){return i||(i=l(a(),t))}function s(){r().set(a())}function a(){n.forEach(u=>{u.unsub(s,{signal:!0})});const c=new Set;let _;Se.push(c);try{_=e()}finally{Se.pop()}return c.forEach(u=>{u.sub(s,{signal:!0})}),n=c,_}return Object.assign(function(){return r()()},{destroy(){r().destroy()},sub(...c){return r().sub(...c)},unsub(...c){r().unsub(...c)},unsubAll(...c){r().unsubAll(...c)}})}const Ro=l((()=>{let e=0;return()=>(e+=1).toString()})()),Jt=l(Fe),N=l("0.0");function ha(e){e||(e={});const{postEvent:t}=e,n=e.version||Q().version;N.set(n),Jt.set(typeof t=="function"?t:Ao(n))}function To(){return Ro()()}function te(e,t,n){return vo(e,t,To(),{...n||{},postEvent:f})}const I=(e,t,n)=>(n||(n={}),n.postEvent||(n.postEvent=f),Qe(e,t,n)),f=(e,t)=>Jt()(e,t);function k(e){return m(()=>z(e,N()))}const ne="ERR_POPUP_INVALID_PARAMS",Je="ERR_INVALID_URL",Po="ERR_INVALID_SLUG",Oo="ERR_DATA_INVALID_SIZE",Bo="ERR_ACCESS_DENIED",Ce="ERR_ALREADY_REQUESTING",Ze="ERR_ALREADY_OPENED",Mo="ERR_ALREADY_MOUNTING",Do="ERR_VARS_ALREADY_BOUND",No="ERR_NOT_AVAILABLE",Io="ERR_NOT_INITIALIZED",Zt="ERR_NOT_SUPPORTED",ko="ERR_NOT_MOUNTED";function Kt(){return typeof window>"u"}function V(e,t,{isSupported:n,isMounted:i,component:r,supports:s}={}){const a=`${r?`${r}.`:""}${e}()`;n=n?Array.isArray(n)||typeof n=="object"&&"any"in n?n:[n]:void 0;function c(b){if(s){const h=s[b];return z(h[0],h[1],N())}return!0}const _=()=>{if(!n)return;const b=`it is unsupported in Mini Apps version ${N()}`;function h(O){return typeof O=="string"?z(O,N())?void 0:b:O.fn()?void 0:O.error}if(Array.isArray(n)){for(const O of n){const gs=h(O);if(gs)return gs}return}let Z;for(const O of n.any)if(Z=h(O),!Z)return;return b},u=(...b)=>{if(s){for(const h in s)if(s[h][2](...b)&&!c(h))return`option ${h} is not supported in Mini Apps version ${N()}`}},p=m(()=>!_()),E=m(()=>N()!=="0.0"),S=m(()=>!i||i()),W=m(()=>Yt("simple")&&!Kt()&&E()&&p()&&S());let $;if(s){$={};for(const b in s)$[b]=m(()=>c(b))}return Object.assign((...b)=>{const h=`Unable to call the ${a} ${r?"method":"function"}:`;if(Kt()||!Yt("simple"))throw new d(Ft,`${h} it can't be called outside Mini Apps`);if(!E())throw new d(Io,`${h} the SDK was not initialized. Use the SDK init() function`);const Z=_();if(Z)throw new d(Zt,`${h} ${Z}`);const O=u(...b);if(O)throw new d(Zt,`${h} ${O}`);if(!S())throw new d(ko,`${h} the component is not mounted. Use the ${r}.mount() method`);return t(...b)},t,{isAvailable:W,ifAvailable(...b){return W()?t(...b):void 0}},n?{isSupported:p}:{},$?{supports:$}:{})}function Ke(e,t){return t||(t={}),(n,i,r,s)=>V(n,i,{...t,isSupported:r||t.isSupported,supports:s,component:e})}function oe(e,t,n){return Ke(e,{isSupported:n,isMounted:t})}function T(e,t){return Ke(e,{isSupported:t})}const Xe="web_app_setup_back_button",Vo="back_button_pressed",xe="backButton",et=l(!1),re=l(!1),Lo=k(Xe),Uo=oe(xe,re,Xe),Xt=T(xe,Xe),jo=Uo("hide",()=>{xt(!1)}),qo=Xt("mount",()=>{re()||(xt(D()&&R(xe)||!1),re.set(!0))});function xt(e){e!==et()&&(f(Xe,{is_visible:e}),v(xe,e),et.set(e))}const Ho=Xt("onClick",e=>C(Vo,e)),Wo=Xt("offClick",e=>{G(Vo,e)}),Go=Uo("show",()=>{xt(!0)});function zo(){re.set(!1)}const ba=Object.freeze(Object.defineProperty({__proto__:null,hide:jo,isMounted:re,isSupported:Lo,isVisible:et,mount:qo,offClick:Wo,onClick:Ho,show:Go,unmount:zo},Symbol.toStringTag,{value:"Module"}));function Fo(e,t,n,{isMounting:i,isMounted:r,mountError:s}){return a=>g.withFn(async c=>{if(r())return;if(i())throw new d(Mo,`The ${e} component is already mounting`);i.set(!0);let _;try{_=[!0,await t({abortSignal:c})]}catch(u){_=[!1,u]}pa(()=>{if(i.set(!1),r.set(!0),_[0])n(_[1]);else{const u=_[1];throw s.set(u),u}})},a)}const q=Ke,$e=l(),Ae=l(!1),ve=l(!1),Re=l(!1),en=l(!1),tn=l(void 0),ga=m(()=>{const e=$e();return e&&e.available});function nn(e){return e.available?{available:!0,tokenSaved:e.token_saved,deviceId:e.device_id,accessRequested:e.access_requested,type:e.type,accessGranted:e.access_granted}:{available:!1}}const Qo="web_app_biometry_get_info",Yo=V("requestBiometry",e=>I(Qo,"biometry_info_received",e).then(nn),{isSupported:Qo}),tt="web_app_biometry_request_auth",Ea="web_app_biometry_request_access",wa="web_app_biometry_open_settings",ya="web_app_biometry_update_token",on="biometry_info_received",ie="biometry",Jo=k(tt),Sa=q(ie),Ca=T(ie,tt),rn=oe(ie,Re,tt);function Zo(){throw new d(No,"Biometry is not available")}const Ko=rn("authenticate",e=>g.withFn(async t=>{if(Ae())throw new d(Ce,"Authentication is already in progress");const n=$e();(!n||!n.available)&&Zo(),Ae.set(!0);try{const i=await I(tt,"biometry_auth_requested",{abortSignal:t,params:{reason:((e||{}).reason||"").trim()}}),{token:r}=i;return typeof r=="string"&&nt({...n,token:r}),i}finally{Ae.set(!1)}},e)),Xo=Ca("openSettings",()=>{f(wa)}),xo=rn("requestAccess",e=>g.withFn(async t=>{if(ve())throw new d(Ce,"Access request is already in progress");ve.set(!0);try{const n=await I(Ea,on,{abortSignal:t,params:{reason:(e||{}).reason||""}}).then(nn);return n.available||Zo(),nt(n),n.accessGranted}finally{ve.set(!1)}},e)),er=Sa("mount",Fo(ie,e=>{const t=D()&&R(ie);return t||Yo(e)},e=>{C(on,tr),nt(e)},{isMounted:Re,mountError:tn,isMounting:en})),tr=e=>{nt(nn(e))};function nt(e){$e.set(e),v(ie,e)}function nr(){G(on,tr),Re.set(!1)}const or=rn("updateToken",e=>(e||(e={}),I(ya,"biometry_token_updated",{...e,params:{token:e.token||"",reason:e.reason}}).then(t=>t.status))),$a=Object.freeze(Object.defineProperty({__proto__:null,authenticate:Ko,isAuthenticating:Ae,isAvailable:ga,isMounted:Re,isMounting:en,isRequestingAccess:ve,isSupported:Jo,mount:er,mountError:tn,openSettings:Xo,requestAccess:xo,state:$e,unmount:nr,updateToken:or},Symbol.toStringTag,{value:"Module"}));function ot(e,t){return Ke(e,{isMounted:t})}const rt="closingBehavior",it=l(!1),se=l(!1),rr=ot(rt,se),Aa=q(rt),ir=rr("disableConfirmation",()=>{sn(!1)}),sr=rr("enableConfirmation",()=>{sn(!0)}),ar=Aa("mount",()=>{se()||(sn(D()&&R(rt)||!1),se.set(!0))});function sn(e){e!==it()&&(f("web_app_setup_closing_behavior",{need_confirmation:e}),v(rt,e),it.set(e))}function cr(){se.set(!1)}const va=Object.freeze(Object.defineProperty({__proto__:null,disableConfirmation:ir,enableConfirmation:sr,isConfirmationEnabled:it,isMounted:se,mount:ar,unmount:cr},Symbol.toStringTag,{value:"Module"})),ur="web_app_invoke_custom_method",st=T("cloudStorage",ur),lr=k(ur),_r=st("deleteItem",(e,t)=>{const n=Array.isArray(e)?e:[e];return n.length?te("deleteStorageValues",{keys:n},t).then():g.resolve()});function Ra(e,t){const n=Array.isArray(e)?e:[e];return n.length?te("getStorageValues",{keys:n},t).then(i=>{const r=Ue(Object.fromEntries(n.map(s=>[s,j()])))()(i);return Array.isArray(e)?r:r[e]}):g.resolve(typeof e=="string"?"":{})}const dr=st("getItem",Ra),fr=st("getKeys",e=>te("getStorageKeys",{},e).then(Ts(j())())),pr=st("setItem",(e,t,n)=>te("saveStorageValue",{key:e,value:t},n).then()),Ta=Object.freeze(Object.defineProperty({__proto__:null,deleteItem:_r,getItem:dr,getKeys:fr,isSupported:lr,setItem:pr},Symbol.toStringTag,{value:"Module"})),Te="web_app_trigger_haptic_feedback",an=T("hapticFeedback",Te),mr=k(Te),hr=an("impactOccurred",e=>{f(Te,{type:"impact",impact_style:e})}),br=an("notificationOccurred",e=>{f(Te,{type:"notification",notification_type:e})}),gr=an("selectionChanged",()=>{f(Te,{type:"selection_change"})}),Pa=Object.freeze(Object.defineProperty({__proto__:null,impactOccurred:hr,isSupported:mr,notificationOccurred:br,selectionChanged:gr},Symbol.toStringTag,{value:"Module"})),at=l(void 0);function L(e){return m(()=>{const t=at();return t?t[e]:void 0})}const cn=L("authDate"),un=L("canSendAfter"),Er=m(()=>{const e=cn(),t=un();return t&&e?new Date(e.getTime()+t*1e3):void 0}),wr=L("chat"),yr=L("chatType"),Sr=L("chatInstance"),Cr=L("hash"),$r=L("queryId"),ln=l(),Ar=L("receiver");function vr(){const e=Q();at.set(e.initData),ln.set(e.initDataRaw)}const Rr=L("startParam"),Tr=L("user"),Oa=Object.freeze(Object.defineProperty({__proto__:null,authDate:cn,canSendAfter:un,canSendAfterDate:Er,chat:wr,chatInstance:Sr,chatType:yr,hash:Cr,queryId:$r,raw:ln,receiver:Ar,restore:vr,startParam:Rr,state:at,user:Tr},Symbol.toStringTag,{value:"Module"}));function Ba(e){return $s()(e)}const _n="web_app_open_invoice",Ma=T("invoice",_n),Pe=l(!1),Pr=k(_n);async function Or(e,t,n){if(Pe())throw new d(Ze,"An invoice is already opened");let i;if(t==="url"){const{hostname:r,pathname:s}=new URL(e,window.location.href);if(r!=="t.me")throw new d(Je,`Link has unexpected hostname: ${r}`);const a=s.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);if(!a)throw new d(Po,'Expected to receive a link with a pathname in format "/invoice/{slug}" or "/${slug}"');[,,i]=a}else i=e,n=t;return Pe.set(!0),I(_n,"invoice_closed",{...n,params:{slug:i},capture:r=>i===r.slug}).then(r=>r.status).finally(()=>{Pe.set(!1)})}const Br=Ma("open",Or),Da=Object.freeze(Object.defineProperty({__proto__:null,_open:Or,isOpened:Pe,isSupported:Pr,open:Br},Symbol.toStringTag,{value:"Module"}));function dn(e){const t=Nt(e);return Math.sqrt([.299,.587,.114].reduce((n,i,r)=>{const s=parseInt(t.slice(1+r*2,1+(r+1)*2),16);return n+s*s*i},0))<120}const ae=l(!1),Oe=l(!1),H=l({});function y(e){return m(()=>H()[e])}const Mr=y("accentTextColor"),ct=y("bgColor"),ut=y("buttonColor"),fn=y("buttonTextColor"),pn=y("bottomBarBgColor"),Dr=y("destructiveTextColor"),Nr=y("headerBgColor"),Ir=y("hintColor"),kr=m(()=>{const{bgColor:e}=H();return!e||dn(e)}),Vr=y("linkColor"),Be=y("secondaryBgColor"),Lr=y("sectionBgColor"),Ur=y("sectionHeaderTextColor"),jr=y("sectionSeparatorColor"),qr=y("subtitleTextColor"),Hr=y("textColor");function Y(e){return m(()=>lt()[e])}const Me=l({hasShineEffect:!1,isEnabled:!0,isLoaderVisible:!1,isVisible:!1,text:"Continue"}),lt=m(()=>{const e=Me();return{...e,backgroundColor:e.backgroundColor||ut()||"#2481cc",textColor:e.textColor||fn()||"#ffffff"}}),ce=l(!1),Wr=Y("backgroundColor"),Gr=Y("hasShineEffect"),zr=Y("isEnabled"),Fr=Y("isLoaderVisible"),Qr=Y("isVisible"),Yr=Y("text"),Jr=Y("textColor"),Na="web_app_setup_main_button",Zr="main_button_pressed",_t="mainButton",mn=q(_t),Ia=ot(_t,ce),Kr=mn("mount",()=>{if(!ce()){const e=D()&&R(_t);e&&Me.set(e),ce.set(!0)}}),Xr=mn("onClick",e=>C(Zr,e)),xr=mn("offClick",e=>{G(Zr,e)}),ei=Ia("setParams",e=>{Me.set({...Me(),...Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0))}),v(_t,Me());const t=lt();t.text&&f(Na,{color:t.backgroundColor,has_shine_effect:t.hasShineEffect,is_active:t.isEnabled,is_progress_visible:t.isLoaderVisible,is_visible:t.isVisible,text:t.text,text_color:t.textColor})});function ti(){ce.set(!1)}const ka=Object.freeze(Object.defineProperty({__proto__:null,backgroundColor:Wr,hasShineEffect:Gr,isEnabled:zr,isLoaderVisible:Fr,isMounted:ce,isVisible:Qr,mount:Kr,offClick:xr,onClick:Xr,setParams:ei,state:lt,text:Yr,textColor:Jr,unmount:ti},Symbol.toStringTag,{value:"Module"}));function hn(){throw new d(Do,"CSS variables are already bound")}function ni(e){return vs()(e)}const dt="themeParams",oi="theme_changed",Va=q(dt),ri=ot(dt,ae)("bindCssVars",e=>{Oe()&&hn(),e||(e=i=>`--tg-theme-${qt(i)}`);function t(i){Object.entries(H()).forEach(([r,s])=>{s&&i(r,s)})}function n(){t((i,r)=>{Ge(e(i),r)})}return n(),H.sub(n),Oe.set(!0),()=>{t(ze),H.unsub(n),Oe.set(!1)}}),bn=Va("mount",()=>{ae()||(C(oi,ii),H.set(D()&&R(dt)||Q().themeParams),ae.set(!0))}),ii=e=>{const t=ni(e.theme_params);H.set(t),v(dt,t)};function si(){G(oi,ii),ae.set(!1)}function ai(e){return m(()=>{const t=e();return K(t)?t:t==="bg_color"?ct():Be()})}const ue=l("bg_color"),gn=ai(ue),le=l("bottom_bar_bg_color"),ft=m(()=>{const e=le();return K(e)?e:e==="bottom_bar_bg_color"?pn()||Be():e==="secondary_bg_color"?Be():ct()}),_e=l("bg_color"),En=ai(_e),de=l(!1),De=l(!1),ci=m(()=>{const e=gn();return e?dn(e):!1}),wn=m(()=>({backgroundColor:ue(),bottomBarColor:le(),headerColor:_e()})),yn="web_app_set_background_color",Sn="web_app_set_bottom_bar_color",pt="web_app_set_header_color",Ne="miniApp",Cn={any:[yn,Sn,pt]},ui=m(()=>Cn.any.some(e=>z(e,N()))),li=q(Ne),La=T(Ne,Cn),mt=oe(Ne,de,Cn),_i=mt("bindCssVars",e=>{De()&&hn();const[t,n]=X();function i(r,s){function a(){Ge(r,s()||null)}a(),t(s.sub(a),ze.bind(null,r))}return e||(e=r=>`--tg-${qt(r)}`),i(e("bgColor"),gn),i(e("bottomBarColor"),ft),i(e("headerColor"),En),t(()=>{De.set(!1)}),De.set(!0),n}),di=li("close",e=>{f("web_app_close",{return_back:e})}),fi=La("mount",()=>{if(!de()){const e=D()&&R(Ne);bn(),An.ifAvailable(e?e.backgroundColor:"bg_color"),vn.ifAvailable(e?e.bottomBarColor:"bottom_bar_bg_color"),Rn.ifAvailable(e?e.headerColor:"bg_color"),de.set(!0)}}),pi=li("ready",()=>{f("web_app_ready")});function $n(){v(Ne,wn())}const An=mt("setBackgroundColor",e=>{e!==ue()&&(f(yn,{color:e}),ue.set(e),$n())},yn),vn=mt("setBottomBarColor",e=>{e!==le()&&(f(Sn,{color:e}),le.set(e),$n())},Sn),Rn=mt("setHeaderColor",e=>{e!==_e()&&(f(pt,K(e)?{color:e}:{color_key:e}),_e.set(e),$n())},pt,{rgb:[pt,"color",K]});function mi(){de.set(!1)}const Ua=Object.freeze(Object.defineProperty({__proto__:null,backgroundColor:ue,backgroundColorRGB:gn,bindCssVars:_i,bottomBarColor:le,bottomBarColorRGB:ft,close:di,headerColor:_e,headerColorRGB:En,isCssVarsBound:De,isDark:ci,isMounted:de,isSupported:ui,mount:fi,ready:pi,setBackgroundColor:An,setBottomBarColor:vn,setHeaderColor:Rn,state:wn,unmount:mi},Symbol.toStringTag,{value:"Module"}));function ja(e){const t=e.message.trim(),n=(e.title||"").trim(),i=e.buttons||[];if(n.length>64)throw new d(ne,`Invalid title: ${n}`);if(!t||t.length>256)throw new d(ne,`Invalid message: ${t}`);if(i.length>3)throw new d(ne,`Invalid buttons count: ${i.length}`);return{title:n,message:t,buttons:i.length?i.map((r,s)=>{const a=r.id||"";if(a.length>64)throw new d(ne,`Button with index ${s} has invalid id: ${a}`);if(!r.type||r.type==="default"||r.type==="destructive"){const c=r.text.trim();if(!c||c.length>64)throw new d(ne,`Button with index ${s} has invalid text: ${c}`);return{type:r.type,text:c,id:a}}return{type:r.type,id:a}}):[{type:"close",id:""}]}}const Tn="web_app_open_popup",qa=T("popup",Tn),Ie=l(!1),hi=k(Tn),bi=qa("open",async e=>{if(Ie())throw new d(Ze,"A popup is already opened");Ie.set(!0);try{const{button_id:t=null}=await I(Tn,"popup_closed",{...e,params:ja(e)});return t}finally{Ie.set(!1)}}),Ha=Object.freeze(Object.defineProperty({__proto__:null,isOpened:Ie,isSupported:hi,open:bi},Symbol.toStringTag,{value:"Module"})),Wa="web_app_close_scan_qr_popup",Pn="web_app_open_scan_qr_popup",Ga="scan_qr_popup_closed",za="qr_text_received",gi=T("qrScanner",Pn),ht=gi("close",()=>{J.set(!1),f(Wa)}),J=l(!1),Ei=k(Pn);function Fa(e){return g.withFn(t=>{if(J())throw new d(Ze,"The QR Scanner is already opened");J.set(!0),e||(e={});const{onCaptured:n,text:i,capture:r}=e,[,s]=X(J.sub(()=>{a.resolve()}),C(Ga,()=>{J.set(!1)}),C(za,c=>{n?n(c.data):(!r||r(c.data))&&(a.resolve(c.data),ht())})),a=new ye({abortSignal:t}).catch(ht).finally(s);return(e.postEvent||f)(Pn,{text:i}),a},e)}const wi=gi("open",Fa),Qa=Object.freeze(Object.defineProperty({__proto__:null,close:ht,isOpened:J,isSupported:Ei,open:wi},Symbol.toStringTag,{value:"Module"}));function F(e){return m(()=>bt()[e])}const ke=l({hasShineEffect:!1,isEnabled:!0,isLoaderVisible:!1,isVisible:!1,position:"left",text:"Cancel"}),bt=m(()=>{const e=ke();return{...e,backgroundColor:e.backgroundColor||ft()||"#000000",textColor:e.textColor||ut()||"#2481cc"}}),fe=l(!1),yi=F("backgroundColor"),Si=F("hasShineEffect"),Ci=F("isEnabled"),$i=F("isLoaderVisible"),Ai=F("isVisible"),vi=F("position"),Ri=F("text"),Ti=F("textColor"),gt="web_app_setup_secondary_button",Pi="secondary_button_pressed",Et="secondaryButton",On=T(Et,gt),Ya=oe(Et,fe,gt),Oi=k(gt),Bi=On("mount",()=>{if(!fe()){const e=D()&&R(Et);e&&ke.set(e),fe.set(!0)}}),Mi=On("onClick",e=>C(Pi,e)),Di=On("offClick",e=>{G(Pi,e)}),Ni=Ya("setParams",e=>{ke.set({...ke(),...Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0))}),v(Et,ke());const t=bt();t.text&&f(gt,{color:t.backgroundColor,has_shine_effect:t.hasShineEffect,is_active:t.isEnabled,is_progress_visible:t.isLoaderVisible,is_visible:t.isVisible,position:t.position,text:t.text,text_color:t.textColor})});function Ii(){fe.set(!1)}const Ja=Object.freeze(Object.defineProperty({__proto__:null,backgroundColor:yi,hasShineEffect:Si,isEnabled:Ci,isLoaderVisible:$i,isMounted:fe,isSupported:Oi,isVisible:Ai,mount:Bi,offClick:Di,onClick:Mi,position:vi,setParams:Ni,state:bt,text:Ri,textColor:Ti,unmount:Ii},Symbol.toStringTag,{value:"Module"})),wt="web_app_setup_settings_button",ki="settings_button_pressed",yt="settingsButton",St=l(!1),pe=l(!1),Vi=k(wt),Bn=T(yt,wt),Li=oe(yt,pe,wt),Ui=Li("hide",()=>{Mn(!1)}),ji=Bn("mount",()=>{pe()||(Mn(D()&&R(yt)||!1),pe.set(!0))});function Mn(e){e!==St()&&(f(wt,{is_visible:e}),v(yt,e),St.set(e))}const qi=Bn("onClick",e=>C(ki,e)),Hi=Bn("offClick",e=>{G(ki,e)}),Wi=Li("show",()=>{Mn(!0)});function Gi(){pe.set(!1)}const Za=Object.freeze(Object.defineProperty({__proto__:null,hide:Ui,isMounted:pe,isSupported:Vi,isVisible:St,mount:ji,offClick:Hi,onClick:qi,show:Wi,unmount:Gi},Symbol.toStringTag,{value:"Module"})),Ct="web_app_setup_swipe_behavior",$t="swipeBehavior",me=l(!1),zi=k(Ct),At=l(!0),Ka=T($t,Ct),Fi=oe($t,me,Ct),Qi=Fi("disableVertical",()=>{Dn(!1)}),Yi=Fi("enableVertical",()=>{Dn(!0)}),Ji=Ka("mount",()=>{me()||(Dn(D()&&R($t)||!1,!0),me.set(!0))});function Dn(e,t){(e!==At()||t)&&(f(Ct,{allow_vertical_swipe:e}),v($t,e),At.set(e))}function Zi(){me.set(!1)}const Xa=Object.freeze(Object.defineProperty({__proto__:null,disableVertical:Qi,enableVertical:Yi,isMounted:me,isSupported:zi,isVerticalEnabled:At,mount:Ji,unmount:Zi},Symbol.toStringTag,{value:"Module"})),xa=Object.freeze(Object.defineProperty({__proto__:null,accentTextColor:Mr,backgroundColor:ct,bindCssVars:ri,bottomBarBgColor:pn,buttonColor:ut,buttonTextColor:fn,destructiveTextColor:Dr,headerBackgroundColor:Nr,hintColor:Ir,isCssVarsBound:Oe,isDark:kr,isMounted:ae,linkColor:Vr,mount:bn,secondaryBackgroundColor:Be,sectionBackgroundColor:Lr,sectionHeaderTextColor:Ur,sectionSeparatorColor:jr,state:H,subtitleTextColor:qr,textColor:Hr,unmount:si},Symbol.toStringTag,{value:"Module"})),P=l({height:0,width:0,isExpanded:!1,stableHeight:0}),Ve=l(!1),Le=l(!1),Nn=l(!1),In=l(void 0);function vt(e){return m(()=>P()[e])}const Ki=vt("height"),Xi=vt("isExpanded"),xi=m(()=>{const e=P();return e.height===e.stableHeight}),es=vt("stableHeight"),ts=vt("width");function ns(e){return I("web_app_request_viewport","viewport_changed",e).then(t=>({height:t.height,width:t.width,isExpanded:t.is_expanded,isStable:t.is_state_stable}))}const Rt="viewport",os=q(Rt),rs=ot(Rt,Ve)("bindCssVars",e=>{Le()&&hn(),e||(e=i=>`--tg-viewport-${qt(i)}`);const t=["height","width","stableHeight"];function n(){t.forEach(i=>{Ge(e(i),`${P()[i]}px`)})}return n(),P.sub(n),Le.set(!0),()=>{t.forEach(ze),P.unsub(n),Le.set(!1)}}),is=os("expand",()=>{f("web_app_expand")}),ss=os("mount",Fo(Rt,e=>{const t=D()&&R(Rt);if(t)return t;if(["macos","tdesktop","unigram","webk","weba","web"].includes(Q().platform)){const n=window;return{isExpanded:!0,height:n.innerHeight,width:n.innerWidth,stableHeight:n.innerHeight}}return e.timeout||(e.timeout=1e3),ns(e).then(n=>({height:n.height,isExpanded:n.isExpanded,stableHeight:n.isStable?n.height:P().stableHeight,width:n.width}))},e=>{C("viewport_changed",as),cs(e)},{isMounted:Ve,isMounting:Nn,mountError:In})),as=e=>{cs({height:e.height,isExpanded:e.is_expanded,stableHeight:e.is_state_stable?e.height:P().stableHeight,width:e.width})};function cs(e){P.set({isExpanded:e.isExpanded,height:kn(e.height),width:kn(e.width),stableHeight:kn(e.stableHeight)}),v("viewport",P())}function kn(e){return Math.max(e,0)}function us(){G("viewport_changed",as),Ve.set(!1)}const ec=Object.freeze(Object.defineProperty({__proto__:null,bindCssVars:rs,expand:is,height:Ki,isCssVarsBound:Le,isExpanded:Xi,isMounted:Ve,isMounting:Nn,isStable:xi,mount:ss,mountError:In,stableHeight:es,state:P,unmount:us,width:ts},Symbol.toStringTag,{value:"Module"})),tc=q()("openLink",(e,t)=>{if(typeof e=="string")try{e=new URL(e)}catch(n){throw new d(Je,`"${e.toString()}" is invalid URL`,n)}t||(t={}),f("web_app_open_link",{url:e.toString(),try_browser:t.tryBrowser,try_instant_view:t.tryInstantView})}),ls="web_app_open_tg_link",_s=q()("openTelegramLink",e=>{const t=e.toString();if(!t.match(/^https:\/\/t.me\/.+/))throw new d(Je,`"${t}" is invalid URL`);if(!z(ls,N())){window.location.href=t;return}e=new URL(e),f(ls,{path_full:e.pathname+e.search})}),nc=q()("shareURL",(e,t)=>{_s("https://t.me/share/url?"+new URLSearchParams({url:e,text:t||""}).toString().replace(/\+/g,"%20"))}),Vn="web_app_request_phone",Tt=l(!1),ds=V("requestPhoneAccess",e=>{if(Tt())throw new d(Ce,"Phone access request is currently in progress");return Tt.set(!0),I(Vn,"phone_requested",e).then(t=>t.status).finally(()=>{Tt.set(!1)})},{isSupported:Vn});function fs(e){return e||(e={}),te("getRequestedContact",{},{...e,timeout:e.timeout||5e3}).then(Wn({contact:Ue({userId:["user_id",je()],phoneNumber:["phone_number",j()],firstName:["first_name",j()],lastName:["last_name",j(!0)]})(),authDate:["auth_date",Mt()],hash:j()})())}const oc=V("requestContact",e=>new g(async(t,n,i)=>{const r={abortSignal:i};try{return t(await fs(r))}catch{}if(await ds(r)!=="sent")throw new d(Bo,"User denied access");let a=50;for(;!i.aborted;){try{return t(await fs(r))}catch{}await Ks(a),a+=50}},e),{isSupported:Vn}),ps="web_app_request_write_access",Pt=l(!1),rc=V("requestWriteAccess",e=>{if(Pt())throw new d(Ce,"Write access request is currently in progress");return Pt.set(!0),I(ps,"write_access_requested",e).then(t=>t.status).finally(()=>{Pt.set(!1)})},{isSupported:ps}),ic=V("getCurrentTime",e=>te("getCurrentTime",{},e).then(Mt()),{isSupported:"web_app_invoke_custom_method"}),ms="web_app_read_text_from_clipboard",sc=V("readTextFromClipboard",e=>{const t=To();return I(ms,"clipboard_text_received",{...e,params:{req_id:t},capture:So(t)}).then(({data:n=null})=>n)},{isSupported:ms}),ac=V("sendData",e=>{const{size:t}=new Blob([e]);if(!t||t>4096)throw new d(Oo,t?"Maximum size of data to send is 4096 bytes":"Attempted to send empty data");f("web_app_data_send",{data:e})}),hs="web_app_share_to_story",cc=V("shareStory",(e,t)=>{t||(t={}),f(hs,{text:t.text,media_url:e,widget_link:t.widgetLink})},{isSupported:hs}),bs="web_app_switch_inline_query",uc=V("switchInlineQuery",(e,t)=>{f(bs,{query:e,chat_types:t||[]})},{isSupported:[bs,{fn:()=>!!Q().botInline,error:"Mini App should be ran in Bot inline mode"}]});function lc(e){try{return{result:e()}}catch(t){return{error:t}}}function _c(e){ha(e),wo();const[t,n]=X(C("reload_iframe",()=>{f("iframe_will_reload"),window.location.reload()}),yo),{acceptCustomStyles:i=!0}=e||{};if(i){const r=document.createElement("style");r.id="telegram-custom-styles",document.head.appendChild(r),t(C("set_custom_style",s=>{r.innerHTML=s}),()=>{document.head.removeChild(r)})}return f("iframe_ready",{reload_supported:!0}),n}return o.$createRequestId=Ro,o.$debug=ao,o.$postEvent=Jt,o.$targetOrigin=ho,o.$version=N,o.CancelablePromise=g,o.ERR_ABORTED=Lt,o.ERR_ACCESS_DENIED=Bo,o.ERR_ALREADY_MOUNTING=Mo,o.ERR_ALREADY_OPENED=Ze,o.ERR_ALREADY_REQUESTING=Ce,o.ERR_CANCELED=Ut,o.ERR_CSS_VARS_ALREADY_BOUND=Do,o.ERR_CUSTOM_METHOD_ERR_RESPONSE=mo,o.ERR_DATA_INVALID_SIZE=Oo,o.ERR_INVALID_SLUG=Po,o.ERR_INVALID_URL=Je,o.ERR_INVALID_VALUE=Un,o.ERR_METHOD_PARAMETER_UNSUPPORTED=po,o.ERR_METHOD_UNSUPPORTED=_o,o.ERR_NOT_AVAILABLE=No,o.ERR_NOT_INITIALIZED=Io,o.ERR_NOT_MOUNTED=ko,o.ERR_NOT_SUPPORTED=Zt,o.ERR_PARSE=Ot,o.ERR_POPUP_INVALID_PARAMS=ne,o.ERR_RETRIEVE_LP_FAILED=fo,o.ERR_TIMED_OUT=jt,o.ERR_UNEXPECTED_TYPE=qn,o.ERR_UNEXPECTED_VALUE=jn,o.ERR_UNKNOWN_ENV=Ft,o.TypedError=d,o.addEventListener=We,o.authenticateBiometry=Ko,o.backButton=ba,o.bindMiniAppCssVars=_i,o.bindThemeParamsCssVars=ri,o.bindViewportCssVars=rs,o.biometry=$a,o.biometryMountError=tn,o.biometryState=$e,o.classNames=qe,o.closeMiniApp=di,o.closeQrScanner=ht,o.closingBehavior=va,o.cloudStorage=Ta,o.compareVersions=$o,o.createPostEvent=Ao,o.defineEventHandlers=wo,o.deleteCloudStorageItem=_r,o.deleteCssVar=ze,o.disableClosingConfirmation=ir,o.disableVerticalSwipes=Qi,o.emitMiniAppsEvent=Ye,o.enableClosingConfirmation=sr,o.enableVerticalSwipes=Yi,o.expandViewport=is,o.getCloudStorageItem=dr,o.getCloudStorageKeys=fr,o.getCurrentTime=ic,o.hapticFeedback=Pa,o.hapticFeedbackImpactOccurred=hr,o.hapticFeedbackNotificationOccurred=br,o.hapticFeedbackSelectionChanged=gr,o.hideBackButton=jo,o.hideSettingsButton=Ui,o.init=_c,o.initData=Oa,o.initDataAuthDate=cn,o.initDataCanSendAfter=un,o.initDataCanSendAfterDate=Er,o.initDataChat=wr,o.initDataChatInstance=Sr,o.initDataChatType=yr,o.initDataHash=Cr,o.initDataQueryId=$r,o.initDataRaw=ln,o.initDataReceiver=Ar,o.initDataStartParam=Rr,o.initDataState=at,o.initDataUser=Tr,o.invoice=Da,o.invokeCustomMethod=vo,o.isAbortError=Js,o.isAuthenticatingBiometry=Ae,o.isBackButtonMounted=re,o.isBackButtonSupported=Lo,o.isBackButtonVisible=et,o.isBiometryMounted=Re,o.isBiometryMounting=en,o.isBiometrySupported=Jo,o.isCanceledError=Zs,o.isClosingBehaviorMounted=se,o.isClosingConfirmationEnabled=it,o.isCloudStorageSupported=lr,o.isColorDark=dn,o.isHapticFeedbackSupported=mr,o.isIframe=to,o.isInvoiceOpened=Pe,o.isInvoiceSupported=Pr,o.isMainButtonEnabled=zr,o.isMainButtonLoaderVisible=Fr,o.isMainButtonMounted=ce,o.isMainButtonVisible=Qr,o.isMiniAppCssVarsBound=De,o.isMiniAppDark=ci,o.isMiniAppMounted=de,o.isMiniAppSupported=ui,o.isPopupOpened=Ie,o.isPopupSupported=hi,o.isQrScannerOpened=J,o.isQrScannerSupported=Ei,o.isRGB=K,o.isRGBShort=Gn,o.isRecord=It,o.isRequestingBiometryAccess=ve,o.isRequestingPhoneAccess=Tt,o.isRequestingWriteAccess=Pt,o.isSSR=Kt,o.isSecondaryButtonEnabled=Ci,o.isSecondaryButtonLoaderVisible=$i,o.isSecondaryButtonMounted=fe,o.isSecondaryButtonSupported=Oi,o.isSecondaryButtonVisible=Ai,o.isSettingsButtonMounted=pe,o.isSettingsButtonSupported=Vi,o.isSettingsButtonVisible=St,o.isSwipeBehaviorMounted=me,o.isSwipeBehaviorSupported=zi,o.isTMA=Yt,o.isThemeParamsCssVarsBound=Oe,o.isThemeParamsDark=kr,o.isThemeParamsMounted=ae,o.isTimeoutError=Ys,o.isVerticalSwipesEnabled=At,o.isViewportCssVarsBound=Le,o.isViewportExpanded=Xi,o.isViewportMounted=Ve,o.isViewportMounting=Nn,o.isViewportStable=xi,o.mainButton=ka,o.mainButtonBackgroundColor=Wr,o.mainButtonHasShineEffect=Gr,o.mainButtonState=lt,o.mainButtonText=Yr,o.mainButtonTextColor=Jr,o.mergeClassNames=Ps,o.miniApp=Ua,o.miniAppBackgroundColor=ue,o.miniAppBottomBarColor=le,o.miniAppBottomBarColorRGB=ft,o.miniAppHeaderColor=_e,o.miniAppHeaderColorRGB=En,o.miniAppReady=pi,o.miniAppState=wn,o.mockTelegramEnv=ua,o.mountBackButton=qo,o.mountBiometry=er,o.mountClosingBehavior=ar,o.mountMainButton=Kr,o.mountMiniApp=fi,o.mountSecondaryButton=Bi,o.mountSettingsButton=ji,o.mountSwipeBehavior=Ji,o.mountThemeParams=bn,o.mountViewport=ss,o.off=G,o.offBackButtonClick=Wo,o.offMainButtonClick=xr,o.offSecondaryButtonClick=Di,o.offSettingsButtonClick=Hi,o.on=C,o.onBackButtonClick=Ho,o.onMainButtonClick=Xr,o.onSecondaryButtonClick=Mi,o.onSettingsButtonClick=qi,o.openBiometrySettings=Xo,o.openInvoice=Br,o.openLink=tc,o.openPopup=bi,o.openQrScanner=wi,o.openTelegramLink=_s,o.parseInitData=Ba,o.parseThemeParams=ni,o.popup=Ha,o.postEvent=Fe,o.qrScanner=Qa,o.readTextFromClipboard=sc,o.removeEventHandlers=yo,o.request=Qe,o.requestBiometry=Yo,o.requestBiometryAccess=xo,o.requestContact=oc,o.requestPhoneAccess=ds,o.requestViewport=ns,o.requestWriteAccess=rc,o.restoreInitData=vr,o.retrieveLaunchParams=Q,o.safeCall=lc,o.secondaryButton=Ja,o.secondaryButtonBackgroundColor=yi,o.secondaryButtonHasShineEffect=Si,o.secondaryButtonPosition=vi,o.secondaryButtonState=bt,o.secondaryButtonText=Ri,o.secondaryButtonTextColor=Ti,o.sendData=ac,o.serializeLaunchParams=Rs,o.serializeThemeParams=zn,o.setCloudStorageItem=pr,o.setCssVar=Ge,o.setMainButtonParams=ei,o.setMiniAppBackgroundColor=An,o.setMiniAppBottomBarColor=vn,o.setMiniAppHeaderColor=Rn,o.setSecondaryButtonParams=Ni,o.settingsButton=Za,o.shareStory=cc,o.shareURL=nc,o.showBackButton=Go,o.showSettingsButton=Wi,o.subscribe=la,o.supports=z,o.swipeBehavior=Xa,o.switchInlineQuery=uc,o.themeParams=xa,o.themeParamsAccentTextColor=Mr,o.themeParamsBackgroundColor=ct,o.themeParamsBottomBarBgColor=pn,o.themeParamsButtonColor=ut,o.themeParamsButtonTextColor=fn,o.themeParamsDestructiveTextColor=Dr,o.themeParamsHeaderBackgroundColor=Nr,o.themeParamsHintColor=Ir,o.themeParamsLinkColor=Vr,o.themeParamsSecondaryBackgroundColor=Be,o.themeParamsSectionBackgroundColor=Lr,o.themeParamsSectionHeaderTextColor=Ur,o.themeParamsSectionSeparatorColor=jr,o.themeParamsState=H,o.themeParamsSubtitleTextColor=qr,o.themeParamsTextColor=Hr,o.toRGB=Nt,o.toRecord=Bt,o.unmountBackButton=zo,o.unmountBiometry=nr,o.unmountClosingBehavior=cr,o.unmountMainButton=ti,o.unmountMiniApp=mi,o.unmountSecondaryButton=Ii,o.unmountSettingsButton=Gi,o.unmountSwipeBehavior=Zi,o.unmountThemeParams=si,o.unmountViewport=us,o.unsubscribe=_a,o.updateBiometryToken=or,o.viewport=ec,o.viewportHeight=Ki,o.viewportMountError=In,o.viewportStableHeight=es,o.viewportState=P,o.viewportWidth=ts,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),o}({});
`))}function Yt(e){if(e==="simple")try{return Q(),!0}catch{return!1}return g.withFn(async()=>{if(eo(window))return!0;try{return await Qe("web_app_request_theme","theme_changed",{timeout:100}),!0}catch{return!1}},e)}function Ye(e,t){window.dispatchEvent(new MessageEvent("message",{data:JSON.stringify({eventType:e,eventData:t}),source:window.parent}))}function ca(e,t){if(typeof t=="string")try{const{eventType:n}=Xn()(t);n==="web_app_request_theme"&&Ye("theme_changed",{theme_params:JSON.parse(Kn(e))}),n==="web_app_request_viewport"&&Ye("viewport_changed",{width:window.innerWidth,height:window.innerHeight,is_state_stable:!0,is_expanded:!0})}catch{}}function ua(e){var t;const n=typeof e=="string"?Qt(e):e;go(n);const i=(t=window.TelegramWebviewProxy)==null?void 0:t.postEvent;window.TelegramWebviewProxy={postEvent(r,s){ca(n.themeParams,JSON.stringify({eventType:r,eventData:s})),i==null||i(r,s)}},Wt("Environment was mocked by the mockTelegramEnv function")}function wo(){[["TelegramGameProxy_receiveEvent"],["TelegramGameProxy","receiveEvent"],["Telegram","WebView","receiveEvent"]].forEach(e=>{let t=window;e.forEach((n,i,r)=>{if(i===r.length-1){t[n]=Ye;return}n in t||(t[n]={}),t=t[n]})})}function yo(){["TelegramGameProxy_receiveEvent","TelegramGameProxy","Telegram"].forEach(e=>{delete window[e]})}function G(e,t,n){lo(e).unsub(t,n)}function la(e,t){return uo().sub(e,t)}function _a(e,t){Gt.unsub(e,t)}function So(e){return({req_id:t})=>t===e}function Co(e){return e.split(".").map(Number)}function $o(e,t){const n=Co(e),i=Co(t),r=Math.max(n.length,i.length);for(let s=0;s<r;s+=1){const a=n[s]||0,c=i[s]||0;if(a!==c)return a>c?1:-1}return 0}function w(e,t){return $o(e,t)<=0}function z(e,t,n){if(typeof n=="string"){if(e==="web_app_open_link"){if(t==="try_instant_view")return w("6.4",n);if(t==="try_browser")return w("7.6",n)}if(e==="web_app_set_header_color"&&t==="color")return w("6.9",n);if(e==="web_app_close"&&t==="return_back")return w("7.6",n);if(e==="web_app_setup_main_button"&&t==="has_shine_effect")return w("7.10",n)}switch(e){case"web_app_open_tg_link":case"web_app_open_invoice":case"web_app_setup_back_button":case"web_app_set_background_color":case"web_app_set_header_color":case"web_app_trigger_haptic_feedback":return w("6.1",t);case"web_app_open_popup":return w("6.2",t);case"web_app_close_scan_qr_popup":case"web_app_open_scan_qr_popup":case"web_app_read_text_from_clipboard":return w("6.4",t);case"web_app_switch_inline_query":return w("6.7",t);case"web_app_invoke_custom_method":case"web_app_request_write_access":case"web_app_request_phone":return w("6.9",t);case"web_app_setup_settings_button":return w("6.10",t);case"web_app_biometry_get_info":case"web_app_biometry_open_settings":case"web_app_biometry_request_access":case"web_app_biometry_request_auth":case"web_app_biometry_update_token":return w("7.2",t);case"web_app_setup_swipe_behavior":return w("7.7",t);case"web_app_share_to_story":return w("7.8",t);case"web_app_setup_secondary_button":case"web_app_set_bottom_bar_color":return w("7.10",t);default:return["iframe_ready","iframe_will_reload","web_app_close","web_app_data_send","web_app_expand","web_app_open_link","web_app_ready","web_app_request_theme","web_app_request_viewport","web_app_setup_main_button","web_app_setup_closing_behavior"].includes(e)}}function Ao(e,t){t||(t="strict");const n=typeof t=="function"?t:i=>{const{method:r,version:s}=i;let a,c;if("param"in i?(a=`Parameter "${i.param}" of "${r}" method is unsupported in Mini Apps version ${s}`,c=po):(a=`Method "${r}" is unsupported in Mini Apps version ${s}`,c=_o),t==="strict")throw new d(c,a);return console.warn(a)};return(i,r)=>z(i,e)?Ws(r)&&i==="web_app_set_header_color"&&"color"in r&&!z(i,"color",e)?n({version:e,method:i,param:"color"}):Fe(i,r):n({version:e,method:i})}function vo(e,t,n,i){return Qe("web_app_invoke_custom_method","custom_method_invoked",{...i||{},params:{method:e,params:t,req_id:n},capture:So(n)}).then(({result:r,error:s})=>{if(s)throw new d(mo,s);return r})}function da(){return performance.getEntriesByType("navigation")[0]}function D(){const e=da();return!!e&&e.type==="reload"}let ee;function fa(e,t){ee&&ee.set(e,t)||t()}function pa(e){if(ee)return e();ee=new Map;try{e()}finally{ee.forEach(t=>t()),ee=void 0}}function l(e,t){t||(t={});const n=t.equals||Object.is;let i=[],r=e;const s=u=>{if(!n(r,u)){const p=r;r=u,fa(_,()=>{[...i].forEach(([E,S])=>{E(u,p),S&&c(E,!0)})})}};function a(u){const p=typeof u!="object"?{once:u}:u;return{once:p.once||!1,signal:p.signal||!1}}const c=(u,p)=>{const E=a(p),S=i.findIndex(([W,$])=>W===u&&$.once===E.once&&$.signal===E.signal);S>=0&&i.splice(S,1)},_=Object.assign(function(){return ma(_),r},{destroy(){i=[]},set:s,reset(){s(e)},sub(u,p){return i.push([u,a(p)]),()=>c(u,p)},unsub:c,unsubAll(){i=i.filter(u=>u[1].signal)}});return _}const Se=[];function ma(e){Se.length&&Se[Se.length-1].add(e)}function m(e,t){let n=new Set,i;function r(){return i||(i=l(a(),t))}function s(){r().set(a())}function a(){n.forEach(u=>{u.unsub(s,{signal:!0})});const c=new Set;let _;Se.push(c);try{_=e()}finally{Se.pop()}return c.forEach(u=>{u.sub(s,{signal:!0})}),n=c,_}return Object.assign(function(){return r()()},{destroy(){r().destroy()},sub(...c){return r().sub(...c)},unsub(...c){r().unsub(...c)},unsubAll(...c){r().unsubAll(...c)}})}const Ro=l((()=>{let e=0;return()=>(e+=1).toString()})()),Jt=l(Fe),N=l("0.0");function ha(e){e||(e={});const{postEvent:t}=e,n=e.version||Q().version;N.set(n),Jt.set(typeof t=="function"?t:Ao(n))}function To(){return Ro()()}function te(e,t,n){return vo(e,t,To(),{...n||{},postEvent:f})}const I=(e,t,n)=>(n||(n={}),n.postEvent||(n.postEvent=f),Qe(e,t,n)),f=(e,t)=>Jt()(e,t);function k(e){return m(()=>z(e,N()))}const ne="ERR_POPUP_INVALID_PARAMS",Je="ERR_INVALID_URL",Po="ERR_INVALID_SLUG",Oo="ERR_DATA_INVALID_SIZE",Bo="ERR_ACCESS_DENIED",Ce="ERR_ALREADY_REQUESTING",Ze="ERR_ALREADY_OPENED",Mo="ERR_ALREADY_MOUNTING",Do="ERR_VARS_ALREADY_BOUND",No="ERR_NOT_AVAILABLE",Io="ERR_NOT_INITIALIZED",Zt="ERR_NOT_SUPPORTED",ko="ERR_NOT_MOUNTED";function Kt(){return typeof window>"u"}function V(e,t,{isSupported:n,isMounted:i,component:r,supports:s}={}){const a=`${r?`${r}.`:""}${e}()`;n=n?Array.isArray(n)||typeof n=="object"&&"any"in n?n:[n]:void 0;function c(b){if(s){const h=s[b];return z(h[0],h[1],N())}return!0}const _=()=>{if(!n)return;const b=`it is unsupported in Mini Apps version ${N()}`;function h(O){return typeof O=="string"?z(O,N())?void 0:b:O.fn()?void 0:O.error}if(Array.isArray(n)){for(const O of n){const gs=h(O);if(gs)return gs}return}let Z;for(const O of n.any)if(Z=h(O),!Z)return;return b},u=(...b)=>{if(s){for(const h in s)if(s[h][2](...b)&&!c(h))return`option ${h} is not supported in Mini Apps version ${N()}`}},p=m(()=>!_()),E=m(()=>N()!=="0.0"),S=m(()=>!i||i()),W=m(()=>Yt("simple")&&!Kt()&&E()&&p()&&S());let $;if(s){$={};for(const b in s)$[b]=m(()=>c(b))}return Object.assign((...b)=>{const h=`Unable to call the ${a} ${r?"method":"function"}:`;if(Kt()||!Yt("simple"))throw new d(Ft,`${h} it can't be called outside Mini Apps`);if(!E())throw new d(Io,`${h} the SDK was not initialized. Use the SDK init() function`);const Z=_();if(Z)throw new d(Zt,`${h} ${Z}`);const O=u(...b);if(O)throw new d(Zt,`${h} ${O}`);if(!S())throw new d(ko,`${h} the component is not mounted. Use the ${r}.mount() method`);return t(...b)},t,{isAvailable:W,ifAvailable(...b){return W()?t(...b):void 0}},n?{isSupported:p}:{},$?{supports:$}:{})}function Ke(e,t){return t||(t={}),(n,i,r,s)=>V(n,i,{...t,isSupported:r||t.isSupported,supports:s,component:e})}function oe(e,t,n){return Ke(e,{isSupported:n,isMounted:t})}function T(e,t){return Ke(e,{isSupported:t})}const Xe="web_app_setup_back_button",Vo="back_button_pressed",xe="backButton",et=l(!1),re=l(!1),Lo=k(Xe),Uo=oe(xe,re,Xe),Xt=T(xe,Xe),jo=Uo("hide",()=>{xt(!1)}),qo=Xt("mount",()=>{re()||(xt(D()&&R(xe)||!1),re.set(!0))});function xt(e){e!==et()&&(f(Xe,{is_visible:e}),v(xe,e),et.set(e))}const Ho=Xt("onClick",e=>C(Vo,e)),Wo=Xt("offClick",e=>{G(Vo,e)}),Go=Uo("show",()=>{xt(!0)});function zo(){re.set(!1)}const ba=Object.freeze(Object.defineProperty({__proto__:null,hide:jo,isMounted:re,isSupported:Lo,isVisible:et,mount:qo,offClick:Wo,onClick:Ho,show:Go,unmount:zo},Symbol.toStringTag,{value:"Module"}));function Fo(e,t,n,{isMounting:i,isMounted:r,mountError:s}){return a=>g.withFn(async c=>{if(r())return;if(i())throw new d(Mo,`The ${e} component is already mounting`);i.set(!0);let _;try{_=[!0,await t({abortSignal:c})]}catch(u){_=[!1,u]}pa(()=>{if(i.set(!1),r.set(!0),_[0])n(_[1]);else{const u=_[1];throw s.set(u),u}})},a)}const q=Ke,$e=l(),Ae=l(!1),ve=l(!1),Re=l(!1),en=l(!1),tn=l(void 0),ga=m(()=>{const e=$e();return e&&e.available});function nn(e){return e.available?{available:!0,tokenSaved:e.token_saved,deviceId:e.device_id,accessRequested:e.access_requested,type:e.type,accessGranted:e.access_granted}:{available:!1}}const Qo="web_app_biometry_get_info",Yo=V("requestBiometry",e=>I(Qo,"biometry_info_received",e).then(nn),{isSupported:Qo}),tt="web_app_biometry_request_auth",Ea="web_app_biometry_request_access",wa="web_app_biometry_open_settings",ya="web_app_biometry_update_token",on="biometry_info_received",ie="biometry",Jo=k(tt),Sa=q(ie),Ca=T(ie,tt),rn=oe(ie,Re,tt);function Zo(){throw new d(No,"Biometry is not available")}const Ko=rn("authenticate",e=>g.withFn(async t=>{if(Ae())throw new d(Ce,"Authentication is already in progress");const n=$e();(!n||!n.available)&&Zo(),Ae.set(!0);try{const i=await I(tt,"biometry_auth_requested",{abortSignal:t,params:{reason:((e||{}).reason||"").trim()}}),{token:r}=i;return typeof r=="string"&&nt({...n,token:r}),i}finally{Ae.set(!1)}},e)),Xo=Ca("openSettings",()=>{f(wa)}),xo=rn("requestAccess",e=>g.withFn(async t=>{if(ve())throw new d(Ce,"Access request is already in progress");ve.set(!0);try{const n=await I(Ea,on,{abortSignal:t,params:{reason:(e||{}).reason||""}}).then(nn);return n.available||Zo(),nt(n),n.accessGranted}finally{ve.set(!1)}},e)),er=Sa("mount",Fo(ie,e=>{const t=D()&&R(ie);return t||Yo(e)},e=>{C(on,tr),nt(e)},{isMounted:Re,mountError:tn,isMounting:en})),tr=e=>{nt(nn(e))};function nt(e){$e.set(e),v(ie,e)}function nr(){G(on,tr),Re.set(!1)}const or=rn("updateToken",e=>(e||(e={}),I(ya,"biometry_token_updated",{...e,params:{token:e.token||"",reason:e.reason}}).then(t=>t.status))),$a=Object.freeze(Object.defineProperty({__proto__:null,authenticate:Ko,isAuthenticating:Ae,isAvailable:ga,isMounted:Re,isMounting:en,isRequestingAccess:ve,isSupported:Jo,mount:er,mountError:tn,openSettings:Xo,requestAccess:xo,state:$e,unmount:nr,updateToken:or},Symbol.toStringTag,{value:"Module"}));function ot(e,t){return Ke(e,{isMounted:t})}const rt="closingBehavior",it=l(!1),se=l(!1),rr=ot(rt,se),Aa=q(rt),ir=rr("disableConfirmation",()=>{sn(!1)}),sr=rr("enableConfirmation",()=>{sn(!0)}),ar=Aa("mount",()=>{se()||(sn(D()&&R(rt)||!1),se.set(!0))});function sn(e){e!==it()&&(f("web_app_setup_closing_behavior",{need_confirmation:e}),v(rt,e),it.set(e))}function cr(){se.set(!1)}const va=Object.freeze(Object.defineProperty({__proto__:null,disableConfirmation:ir,enableConfirmation:sr,isConfirmationEnabled:it,isMounted:se,mount:ar,unmount:cr},Symbol.toStringTag,{value:"Module"})),ur="web_app_invoke_custom_method",st=T("cloudStorage",ur),lr=k(ur),_r=st("deleteItem",(e,t)=>{const n=Array.isArray(e)?e:[e];return n.length?te("deleteStorageValues",{keys:n},t).then():g.resolve()});function Ra(e,t){const n=Array.isArray(e)?e:[e];return n.length?te("getStorageValues",{keys:n},t).then(i=>{const r=Ue(Object.fromEntries(n.map(s=>[s,j()])))()(i);return Array.isArray(e)?r:r[e]}):g.resolve(typeof e=="string"?"":{})}const dr=st("getItem",Ra),fr=st("getKeys",e=>te("getStorageKeys",{},e).then(Ts(j())())),pr=st("setItem",(e,t,n)=>te("saveStorageValue",{key:e,value:t},n).then()),Ta=Object.freeze(Object.defineProperty({__proto__:null,deleteItem:_r,getItem:dr,getKeys:fr,isSupported:lr,setItem:pr},Symbol.toStringTag,{value:"Module"})),Te="web_app_trigger_haptic_feedback",an=T("hapticFeedback",Te),mr=k(Te),hr=an("impactOccurred",e=>{f(Te,{type:"impact",impact_style:e})}),br=an("notificationOccurred",e=>{f(Te,{type:"notification",notification_type:e})}),gr=an("selectionChanged",()=>{f(Te,{type:"selection_change"})}),Pa=Object.freeze(Object.defineProperty({__proto__:null,impactOccurred:hr,isSupported:mr,notificationOccurred:br,selectionChanged:gr},Symbol.toStringTag,{value:"Module"})),at=l(void 0);function L(e){return m(()=>{const t=at();return t?t[e]:void 0})}const cn=L("authDate"),un=L("canSendAfter"),Er=m(()=>{const e=cn(),t=un();return t&&e?new Date(e.getTime()+t*1e3):void 0}),wr=L("chat"),yr=L("chatType"),Sr=L("chatInstance"),Cr=L("hash"),$r=L("queryId"),ln=l(),Ar=L("receiver");function vr(){const e=Q();at.set(e.initData),ln.set(e.initDataRaw)}const Rr=L("startParam"),Tr=L("user"),Oa=Object.freeze(Object.defineProperty({__proto__:null,authDate:cn,canSendAfter:un,canSendAfterDate:Er,chat:wr,chatInstance:Sr,chatType:yr,hash:Cr,queryId:$r,raw:ln,receiver:Ar,restore:vr,startParam:Rr,state:at,user:Tr},Symbol.toStringTag,{value:"Module"}));function Ba(e){return $s()(e)}const _n="web_app_open_invoice",Ma=T("invoice",_n),Pe=l(!1),Pr=k(_n);async function Or(e,t,n){if(Pe())throw new d(Ze,"An invoice is already opened");let i;if(t==="url"){const{hostname:r,pathname:s}=new URL(e,window.location.href);if(r!=="t.me")throw new d(Je,`Link has unexpected hostname: ${r}`);const a=s.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);if(!a)throw new d(Po,'Expected to receive a link with a pathname in format "/invoice/{slug}" or "/${slug}"');[,,i]=a}else i=e,n=t;return Pe.set(!0),I(_n,"invoice_closed",{...n,params:{slug:i},capture:r=>i===r.slug}).then(r=>r.status).finally(()=>{Pe.set(!1)})}const Br=Ma("open",Or),Da=Object.freeze(Object.defineProperty({__proto__:null,_open:Or,isOpened:Pe,isSupported:Pr,open:Br},Symbol.toStringTag,{value:"Module"}));function dn(e){const t=Nt(e);return Math.sqrt([.299,.587,.114].reduce((n,i,r)=>{const s=parseInt(t.slice(1+r*2,1+(r+1)*2),16);return n+s*s*i},0))<120}const ae=l(!1),Oe=l(!1),H=l({});function y(e){return m(()=>H()[e])}const Mr=y("accentTextColor"),ct=y("bgColor"),ut=y("buttonColor"),fn=y("buttonTextColor"),pn=y("bottomBarBgColor"),Dr=y("destructiveTextColor"),Nr=y("headerBgColor"),Ir=y("hintColor"),kr=m(()=>{const{bgColor:e}=H();return!e||dn(e)}),Vr=y("linkColor"),Be=y("secondaryBgColor"),Lr=y("sectionBgColor"),Ur=y("sectionHeaderTextColor"),jr=y("sectionSeparatorColor"),qr=y("subtitleTextColor"),Hr=y("textColor");function Y(e){return m(()=>lt()[e])}const Me=l({hasShineEffect:!1,isEnabled:!0,isLoaderVisible:!1,isVisible:!1,text:"Continue"}),lt=m(()=>{const e=Me();return{...e,backgroundColor:e.backgroundColor||ut()||"#2481cc",textColor:e.textColor||fn()||"#ffffff"}}),ce=l(!1),Wr=Y("backgroundColor"),Gr=Y("hasShineEffect"),zr=Y("isEnabled"),Fr=Y("isLoaderVisible"),Qr=Y("isVisible"),Yr=Y("text"),Jr=Y("textColor"),Na="web_app_setup_main_button",Zr="main_button_pressed",_t="mainButton",mn=q(_t),Ia=ot(_t,ce),Kr=mn("mount",()=>{if(!ce()){const e=D()&&R(_t);e&&Me.set(e),ce.set(!0)}}),Xr=mn("onClick",e=>C(Zr,e)),xr=mn("offClick",e=>{G(Zr,e)}),ei=Ia("setParams",e=>{Me.set({...Me(),...Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0))}),v(_t,Me());const t=lt();t.text&&f(Na,{color:t.backgroundColor,has_shine_effect:t.hasShineEffect,is_active:t.isEnabled,is_progress_visible:t.isLoaderVisible,is_visible:t.isVisible,text:t.text,text_color:t.textColor})});function ti(){ce.set(!1)}const ka=Object.freeze(Object.defineProperty({__proto__:null,backgroundColor:Wr,hasShineEffect:Gr,isEnabled:zr,isLoaderVisible:Fr,isMounted:ce,isVisible:Qr,mount:Kr,offClick:xr,onClick:Xr,setParams:ei,state:lt,text:Yr,textColor:Jr,unmount:ti},Symbol.toStringTag,{value:"Module"}));function hn(){throw new d(Do,"CSS variables are already bound")}function ni(e){return vs()(e)}const dt="themeParams",oi="theme_changed",Va=q(dt),ri=ot(dt,ae)("bindCssVars",e=>{Oe()&&hn(),e||(e=i=>`--tg-theme-${qt(i)}`);function t(i){Object.entries(H()).forEach(([r,s])=>{s&&i(r,s)})}function n(){t((i,r)=>{Ge(e(i),r)})}return n(),H.sub(n),Oe.set(!0),()=>{t(ze),H.unsub(n),Oe.set(!1)}}),bn=Va("mount",()=>{ae()||(C(oi,ii),H.set(D()&&R(dt)||Q().themeParams),ae.set(!0))}),ii=e=>{const t=ni(e.theme_params);H.set(t),v(dt,t)};function si(){G(oi,ii),ae.set(!1)}function ai(e){return m(()=>{const t=e();return K(t)?t:t==="bg_color"?ct():Be()})}const ue=l("bg_color"),gn=ai(ue),le=l("bottom_bar_bg_color"),ft=m(()=>{const e=le();return K(e)?e:e==="bottom_bar_bg_color"?pn()||Be():e==="secondary_bg_color"?Be():ct()}),_e=l("bg_color"),En=ai(_e),de=l(!1),De=l(!1),ci=m(()=>{const e=gn();return e?dn(e):!1}),wn=m(()=>({backgroundColor:ue(),bottomBarColor:le(),headerColor:_e()})),yn="web_app_set_background_color",Sn="web_app_set_bottom_bar_color",pt="web_app_set_header_color",Ne="miniApp",Cn={any:[yn,Sn,pt]},ui=m(()=>Cn.any.some(e=>z(e,N()))),li=q(Ne),La=T(Ne,Cn),mt=oe(Ne,de,Cn),_i=mt("bindCssVars",e=>{De()&&hn();const[t,n]=X();function i(r,s){function a(){Ge(r,s()||null)}a(),t(s.sub(a),ze.bind(null,r))}return e||(e=r=>`--tg-${qt(r)}`),i(e("bgColor"),gn),i(e("bottomBarColor"),ft),i(e("headerColor"),En),t(()=>{De.set(!1)}),De.set(!0),n}),di=li("close",e=>{f("web_app_close",{return_back:e})}),fi=La("mount",()=>{if(!de()){const e=D()&&R(Ne);bn(),An.ifAvailable(e?e.backgroundColor:"bg_color"),vn.ifAvailable(e?e.bottomBarColor:"bottom_bar_bg_color"),Rn.ifAvailable(e?e.headerColor:"bg_color"),de.set(!0)}}),pi=li("ready",()=>{f("web_app_ready")});function $n(){v(Ne,wn())}const An=mt("setBackgroundColor",e=>{e!==ue()&&(f(yn,{color:e}),ue.set(e),$n())},yn),vn=mt("setBottomBarColor",e=>{e!==le()&&(f(Sn,{color:e}),le.set(e),$n())},Sn),Rn=mt("setHeaderColor",e=>{e!==_e()&&(f(pt,K(e)?{color:e}:{color_key:e}),_e.set(e),$n())},pt,{rgb:[pt,"color",K]});function mi(){de.set(!1)}const Ua=Object.freeze(Object.defineProperty({__proto__:null,backgroundColor:ue,backgroundColorRGB:gn,bindCssVars:_i,bottomBarColor:le,bottomBarColorRGB:ft,close:di,headerColor:_e,headerColorRGB:En,isCssVarsBound:De,isDark:ci,isMounted:de,isSupported:ui,mount:fi,ready:pi,setBackgroundColor:An,setBottomBarColor:vn,setHeaderColor:Rn,state:wn,unmount:mi},Symbol.toStringTag,{value:"Module"}));function ja(e){const t=e.message.trim(),n=(e.title||"").trim(),i=e.buttons||[];if(n.length>64)throw new d(ne,`Invalid title: ${n}`);if(!t||t.length>256)throw new d(ne,`Invalid message: ${t}`);if(i.length>3)throw new d(ne,`Invalid buttons count: ${i.length}`);return{title:n,message:t,buttons:i.length?i.map((r,s)=>{const a=r.id||"";if(a.length>64)throw new d(ne,`Button with index ${s} has invalid id: ${a}`);if(!r.type||r.type==="default"||r.type==="destructive"){const c=r.text.trim();if(!c||c.length>64)throw new d(ne,`Button with index ${s} has invalid text: ${c}`);return{type:r.type,text:c,id:a}}return{type:r.type,id:a}}):[{type:"close",id:""}]}}const Tn="web_app_open_popup",qa=T("popup",Tn),Ie=l(!1),hi=k(Tn),bi=qa("open",async e=>{if(Ie())throw new d(Ze,"A popup is already opened");Ie.set(!0);try{const{button_id:t=null}=await I(Tn,"popup_closed",{...e,params:ja(e)});return t}finally{Ie.set(!1)}}),Ha=Object.freeze(Object.defineProperty({__proto__:null,isOpened:Ie,isSupported:hi,open:bi},Symbol.toStringTag,{value:"Module"})),Wa="web_app_close_scan_qr_popup",Pn="web_app_open_scan_qr_popup",Ga="scan_qr_popup_closed",za="qr_text_received",gi=T("qrScanner",Pn),ht=gi("close",()=>{J.set(!1),f(Wa)}),J=l(!1),Ei=k(Pn);function Fa(e){return g.withFn(t=>{if(J())throw new d(Ze,"The QR Scanner is already opened");J.set(!0),e||(e={});const{onCaptured:n,text:i,capture:r}=e,[,s]=X(J.sub(()=>{a.resolve()}),C(Ga,()=>{J.set(!1)}),C(za,c=>{n?n(c.data):(!r||r(c.data))&&(a.resolve(c.data),ht())})),a=new ye({abortSignal:t}).catch(ht).finally(s);return(e.postEvent||f)(Pn,{text:i}),a},e)}const wi=gi("open",Fa),Qa=Object.freeze(Object.defineProperty({__proto__:null,close:ht,isOpened:J,isSupported:Ei,open:wi},Symbol.toStringTag,{value:"Module"}));function F(e){return m(()=>bt()[e])}const ke=l({hasShineEffect:!1,isEnabled:!0,isLoaderVisible:!1,isVisible:!1,position:"left",text:"Cancel"}),bt=m(()=>{const e=ke();return{...e,backgroundColor:e.backgroundColor||ft()||"#000000",textColor:e.textColor||ut()||"#2481cc"}}),fe=l(!1),yi=F("backgroundColor"),Si=F("hasShineEffect"),Ci=F("isEnabled"),$i=F("isLoaderVisible"),Ai=F("isVisible"),vi=F("position"),Ri=F("text"),Ti=F("textColor"),gt="web_app_setup_secondary_button",Pi="secondary_button_pressed",Et="secondaryButton",On=T(Et,gt),Ya=oe(Et,fe,gt),Oi=k(gt),Bi=On("mount",()=>{if(!fe()){const e=D()&&R(Et);e&&ke.set(e),fe.set(!0)}}),Mi=On("onClick",e=>C(Pi,e)),Di=On("offClick",e=>{G(Pi,e)}),Ni=Ya("setParams",e=>{ke.set({...ke(),...Object.fromEntries(Object.entries(e).filter(([,n])=>n!==void 0))}),v(Et,ke());const t=bt();t.text&&f(gt,{color:t.backgroundColor,has_shine_effect:t.hasShineEffect,is_active:t.isEnabled,is_progress_visible:t.isLoaderVisible,is_visible:t.isVisible,position:t.position,text:t.text,text_color:t.textColor})});function Ii(){fe.set(!1)}const Ja=Object.freeze(Object.defineProperty({__proto__:null,backgroundColor:yi,hasShineEffect:Si,isEnabled:Ci,isLoaderVisible:$i,isMounted:fe,isSupported:Oi,isVisible:Ai,mount:Bi,offClick:Di,onClick:Mi,position:vi,setParams:Ni,state:bt,text:Ri,textColor:Ti,unmount:Ii},Symbol.toStringTag,{value:"Module"})),wt="web_app_setup_settings_button",ki="settings_button_pressed",yt="settingsButton",St=l(!1),pe=l(!1),Vi=k(wt),Bn=T(yt,wt),Li=oe(yt,pe,wt),Ui=Li("hide",()=>{Mn(!1)}),ji=Bn("mount",()=>{pe()||(Mn(D()&&R(yt)||!1),pe.set(!0))});function Mn(e){e!==St()&&(f(wt,{is_visible:e}),v(yt,e),St.set(e))}const qi=Bn("onClick",e=>C(ki,e)),Hi=Bn("offClick",e=>{G(ki,e)}),Wi=Li("show",()=>{Mn(!0)});function Gi(){pe.set(!1)}const Za=Object.freeze(Object.defineProperty({__proto__:null,hide:Ui,isMounted:pe,isSupported:Vi,isVisible:St,mount:ji,offClick:Hi,onClick:qi,show:Wi,unmount:Gi},Symbol.toStringTag,{value:"Module"})),Ct="web_app_setup_swipe_behavior",$t="swipeBehavior",me=l(!1),zi=k(Ct),At=l(!0),Ka=T($t,Ct),Fi=oe($t,me,Ct),Qi=Fi("disableVertical",()=>{Dn(!1)}),Yi=Fi("enableVertical",()=>{Dn(!0)}),Ji=Ka("mount",()=>{me()||(Dn(D()&&R($t)||!1,!0),me.set(!0))});function Dn(e,t){(e!==At()||t)&&(f(Ct,{allow_vertical_swipe:e}),v($t,e),At.set(e))}function Zi(){me.set(!1)}const Xa=Object.freeze(Object.defineProperty({__proto__:null,disableVertical:Qi,enableVertical:Yi,isMounted:me,isSupported:zi,isVerticalEnabled:At,mount:Ji,unmount:Zi},Symbol.toStringTag,{value:"Module"})),xa=Object.freeze(Object.defineProperty({__proto__:null,accentTextColor:Mr,backgroundColor:ct,bindCssVars:ri,bottomBarBgColor:pn,buttonColor:ut,buttonTextColor:fn,destructiveTextColor:Dr,headerBackgroundColor:Nr,hintColor:Ir,isCssVarsBound:Oe,isDark:kr,isMounted:ae,linkColor:Vr,mount:bn,secondaryBackgroundColor:Be,sectionBackgroundColor:Lr,sectionHeaderTextColor:Ur,sectionSeparatorColor:jr,state:H,subtitleTextColor:qr,textColor:Hr,unmount:si},Symbol.toStringTag,{value:"Module"})),P=l({height:0,width:0,isExpanded:!1,stableHeight:0}),Ve=l(!1),Le=l(!1),Nn=l(!1),In=l(void 0);function vt(e){return m(()=>P()[e])}const Ki=vt("height"),Xi=vt("isExpanded"),xi=m(()=>{const e=P();return e.height===e.stableHeight}),es=vt("stableHeight"),ts=vt("width");function ns(e){return I("web_app_request_viewport","viewport_changed",e).then(t=>({height:t.height,width:t.width,isExpanded:t.is_expanded,isStable:t.is_state_stable}))}const Rt="viewport",os=q(Rt),rs=ot(Rt,Ve)("bindCssVars",e=>{Le()&&hn(),e||(e=i=>`--tg-viewport-${qt(i)}`);const t=["height","width","stableHeight"];function n(){t.forEach(i=>{Ge(e(i),`${P()[i]}px`)})}return n(),P.sub(n),Le.set(!0),()=>{t.forEach(ze),P.unsub(n),Le.set(!1)}}),is=os("expand",()=>{f("web_app_expand")}),ss=os("mount",Fo(Rt,e=>{const t=D()&&R(Rt);if(t)return t;if(["macos","tdesktop","unigram","webk","weba","web"].includes(Q().platform)){const n=window;return{isExpanded:!0,height:n.innerHeight,width:n.innerWidth,stableHeight:n.innerHeight}}return e.timeout||(e.timeout=1e3),ns(e).then(n=>({height:n.height,isExpanded:n.isExpanded,stableHeight:n.isStable?n.height:P().stableHeight,width:n.width}))},e=>{C("viewport_changed",as),cs(e)},{isMounted:Ve,isMounting:Nn,mountError:In})),as=e=>{cs({height:e.height,isExpanded:e.is_expanded,stableHeight:e.is_state_stable?e.height:P().stableHeight,width:e.width})};function cs(e){P.set({isExpanded:e.isExpanded,height:kn(e.height),width:kn(e.width),stableHeight:kn(e.stableHeight)}),v("viewport",P())}function kn(e){return Math.max(e,0)}function us(){G("viewport_changed",as),Ve.set(!1)}const ec=Object.freeze(Object.defineProperty({__proto__:null,bindCssVars:rs,expand:is,height:Ki,isCssVarsBound:Le,isExpanded:Xi,isMounted:Ve,isMounting:Nn,isStable:xi,mount:ss,mountError:In,stableHeight:es,state:P,unmount:us,width:ts},Symbol.toStringTag,{value:"Module"})),tc=q()("openLink",(e,t)=>{if(typeof e=="string")try{e=new URL(e)}catch(n){throw new d(Je,`"${e.toString()}" is invalid URL`,n)}t||(t={}),f("web_app_open_link",{url:e.toString(),try_browser:t.tryBrowser,try_instant_view:t.tryInstantView})}),ls="web_app_open_tg_link",_s=q()("openTelegramLink",e=>{const t=e.toString();if(!t.match(/^https:\/\/t.me\/.+/))throw new d(Je,`"${t}" is invalid URL`);if(!z(ls,N())){window.location.href=t;return}e=new URL(e),f(ls,{path_full:e.pathname+e.search})}),nc=q()("shareURL",(e,t)=>{_s("https://t.me/share/url?"+new URLSearchParams({url:e,text:t||""}).toString().replace(/\+/g,"%20"))}),Vn="web_app_request_phone",Tt=l(!1),ds=V("requestPhoneAccess",e=>{if(Tt())throw new d(Ce,"Phone access request is currently in progress");return Tt.set(!0),I(Vn,"phone_requested",e).then(t=>t.status).finally(()=>{Tt.set(!1)})},{isSupported:Vn});function fs(e){return e||(e={}),te("getRequestedContact",{},{...e,timeout:e.timeout||5e3}).then(Wn({contact:Ue({userId:["user_id",je()],phoneNumber:["phone_number",j()],firstName:["first_name",j()],lastName:["last_name",j(!0)]})(),authDate:["auth_date",Mt()],hash:j()})())}const oc=V("requestContact",e=>g.withFn(async t=>{const n={abortSignal:t};try{return await fs(n)}catch{}if(await ds(n)!=="sent")throw new d(Bo,"User denied access");let r=50;for(;!t.aborted;){try{return await fs(n)}catch{}await Ks(r),r+=50}return null},e),{isSupported:Vn}),ps="web_app_request_write_access",Pt=l(!1),rc=V("requestWriteAccess",e=>{if(Pt())throw new d(Ce,"Write access request is currently in progress");return Pt.set(!0),I(ps,"write_access_requested",e).then(t=>t.status).finally(()=>{Pt.set(!1)})},{isSupported:ps}),ic=V("getCurrentTime",e=>te("getCurrentTime",{},e).then(Mt()),{isSupported:"web_app_invoke_custom_method"}),ms="web_app_read_text_from_clipboard",sc=V("readTextFromClipboard",e=>{const t=To();return I(ms,"clipboard_text_received",{...e,params:{req_id:t},capture:So(t)}).then(({data:n=null})=>n)},{isSupported:ms}),ac=V("sendData",e=>{const{size:t}=new Blob([e]);if(!t||t>4096)throw new d(Oo,t?"Maximum size of data to send is 4096 bytes":"Attempted to send empty data");f("web_app_data_send",{data:e})}),hs="web_app_share_to_story",cc=V("shareStory",(e,t)=>{t||(t={}),f(hs,{text:t.text,media_url:e,widget_link:t.widgetLink})},{isSupported:hs}),bs="web_app_switch_inline_query",uc=V("switchInlineQuery",(e,t)=>{f(bs,{query:e,chat_types:t||[]})},{isSupported:[bs,{fn:()=>!!Q().botInline,error:"Mini App should be ran in Bot inline mode"}]});function lc(e){try{return{result:e()}}catch(t){return{error:t}}}function _c(e){ha(e),wo();const[t,n]=X(C("reload_iframe",()=>{f("iframe_will_reload"),window.location.reload()}),yo),{acceptCustomStyles:i=!0}=e||{};if(i){const r=document.createElement("style");r.id="telegram-custom-styles",document.head.appendChild(r),t(C("set_custom_style",s=>{r.innerHTML=s}),()=>{document.head.removeChild(r)})}return f("iframe_ready",{reload_supported:!0}),n}return o.$createRequestId=Ro,o.$debug=ao,o.$postEvent=Jt,o.$targetOrigin=ho,o.$version=N,o.CancelablePromise=g,o.ERR_ABORTED=Lt,o.ERR_ACCESS_DENIED=Bo,o.ERR_ALREADY_MOUNTING=Mo,o.ERR_ALREADY_OPENED=Ze,o.ERR_ALREADY_REQUESTING=Ce,o.ERR_CANCELED=Ut,o.ERR_CSS_VARS_ALREADY_BOUND=Do,o.ERR_CUSTOM_METHOD_ERR_RESPONSE=mo,o.ERR_DATA_INVALID_SIZE=Oo,o.ERR_INVALID_SLUG=Po,o.ERR_INVALID_URL=Je,o.ERR_INVALID_VALUE=Un,o.ERR_METHOD_PARAMETER_UNSUPPORTED=po,o.ERR_METHOD_UNSUPPORTED=_o,o.ERR_NOT_AVAILABLE=No,o.ERR_NOT_INITIALIZED=Io,o.ERR_NOT_MOUNTED=ko,o.ERR_NOT_SUPPORTED=Zt,o.ERR_PARSE=Ot,o.ERR_POPUP_INVALID_PARAMS=ne,o.ERR_RETRIEVE_LP_FAILED=fo,o.ERR_TIMED_OUT=jt,o.ERR_UNEXPECTED_TYPE=qn,o.ERR_UNEXPECTED_VALUE=jn,o.ERR_UNKNOWN_ENV=Ft,o.TypedError=d,o.addEventListener=We,o.authenticateBiometry=Ko,o.backButton=ba,o.bindMiniAppCssVars=_i,o.bindThemeParamsCssVars=ri,o.bindViewportCssVars=rs,o.biometry=$a,o.biometryMountError=tn,o.biometryState=$e,o.classNames=qe,o.closeMiniApp=di,o.closeQrScanner=ht,o.closingBehavior=va,o.cloudStorage=Ta,o.compareVersions=$o,o.createPostEvent=Ao,o.defineEventHandlers=wo,o.deleteCloudStorageItem=_r,o.deleteCssVar=ze,o.disableClosingConfirmation=ir,o.disableVerticalSwipes=Qi,o.emitMiniAppsEvent=Ye,o.enableClosingConfirmation=sr,o.enableVerticalSwipes=Yi,o.expandViewport=is,o.getCloudStorageItem=dr,o.getCloudStorageKeys=fr,o.getCurrentTime=ic,o.hapticFeedback=Pa,o.hapticFeedbackImpactOccurred=hr,o.hapticFeedbackNotificationOccurred=br,o.hapticFeedbackSelectionChanged=gr,o.hideBackButton=jo,o.hideSettingsButton=Ui,o.init=_c,o.initData=Oa,o.initDataAuthDate=cn,o.initDataCanSendAfter=un,o.initDataCanSendAfterDate=Er,o.initDataChat=wr,o.initDataChatInstance=Sr,o.initDataChatType=yr,o.initDataHash=Cr,o.initDataQueryId=$r,o.initDataRaw=ln,o.initDataReceiver=Ar,o.initDataStartParam=Rr,o.initDataState=at,o.initDataUser=Tr,o.invoice=Da,o.invokeCustomMethod=vo,o.isAbortError=Js,o.isAuthenticatingBiometry=Ae,o.isBackButtonMounted=re,o.isBackButtonSupported=Lo,o.isBackButtonVisible=et,o.isBiometryMounted=Re,o.isBiometryMounting=en,o.isBiometrySupported=Jo,o.isCanceledError=Zs,o.isClosingBehaviorMounted=se,o.isClosingConfirmationEnabled=it,o.isCloudStorageSupported=lr,o.isColorDark=dn,o.isHapticFeedbackSupported=mr,o.isIframe=to,o.isInvoiceOpened=Pe,o.isInvoiceSupported=Pr,o.isMainButtonEnabled=zr,o.isMainButtonLoaderVisible=Fr,o.isMainButtonMounted=ce,o.isMainButtonVisible=Qr,o.isMiniAppCssVarsBound=De,o.isMiniAppDark=ci,o.isMiniAppMounted=de,o.isMiniAppSupported=ui,o.isPopupOpened=Ie,o.isPopupSupported=hi,o.isQrScannerOpened=J,o.isQrScannerSupported=Ei,o.isRGB=K,o.isRGBShort=Gn,o.isRecord=It,o.isRequestingBiometryAccess=ve,o.isRequestingPhoneAccess=Tt,o.isRequestingWriteAccess=Pt,o.isSSR=Kt,o.isSecondaryButtonEnabled=Ci,o.isSecondaryButtonLoaderVisible=$i,o.isSecondaryButtonMounted=fe,o.isSecondaryButtonSupported=Oi,o.isSecondaryButtonVisible=Ai,o.isSettingsButtonMounted=pe,o.isSettingsButtonSupported=Vi,o.isSettingsButtonVisible=St,o.isSwipeBehaviorMounted=me,o.isSwipeBehaviorSupported=zi,o.isTMA=Yt,o.isThemeParamsCssVarsBound=Oe,o.isThemeParamsDark=kr,o.isThemeParamsMounted=ae,o.isTimeoutError=Ys,o.isVerticalSwipesEnabled=At,o.isViewportCssVarsBound=Le,o.isViewportExpanded=Xi,o.isViewportMounted=Ve,o.isViewportMounting=Nn,o.isViewportStable=xi,o.mainButton=ka,o.mainButtonBackgroundColor=Wr,o.mainButtonHasShineEffect=Gr,o.mainButtonState=lt,o.mainButtonText=Yr,o.mainButtonTextColor=Jr,o.mergeClassNames=Ps,o.miniApp=Ua,o.miniAppBackgroundColor=ue,o.miniAppBottomBarColor=le,o.miniAppBottomBarColorRGB=ft,o.miniAppHeaderColor=_e,o.miniAppHeaderColorRGB=En,o.miniAppReady=pi,o.miniAppState=wn,o.mockTelegramEnv=ua,o.mountBackButton=qo,o.mountBiometry=er,o.mountClosingBehavior=ar,o.mountMainButton=Kr,o.mountMiniApp=fi,o.mountSecondaryButton=Bi,o.mountSettingsButton=ji,o.mountSwipeBehavior=Ji,o.mountThemeParams=bn,o.mountViewport=ss,o.off=G,o.offBackButtonClick=Wo,o.offMainButtonClick=xr,o.offSecondaryButtonClick=Di,o.offSettingsButtonClick=Hi,o.on=C,o.onBackButtonClick=Ho,o.onMainButtonClick=Xr,o.onSecondaryButtonClick=Mi,o.onSettingsButtonClick=qi,o.openBiometrySettings=Xo,o.openInvoice=Br,o.openLink=tc,o.openPopup=bi,o.openQrScanner=wi,o.openTelegramLink=_s,o.parseInitData=Ba,o.parseThemeParams=ni,o.popup=Ha,o.postEvent=Fe,o.qrScanner=Qa,o.readTextFromClipboard=sc,o.removeEventHandlers=yo,o.request=Qe,o.requestBiometry=Yo,o.requestBiometryAccess=xo,o.requestContact=oc,o.requestPhoneAccess=ds,o.requestViewport=ns,o.requestWriteAccess=rc,o.restoreInitData=vr,o.retrieveLaunchParams=Q,o.safeCall=lc,o.secondaryButton=Ja,o.secondaryButtonBackgroundColor=yi,o.secondaryButtonHasShineEffect=Si,o.secondaryButtonPosition=vi,o.secondaryButtonState=bt,o.secondaryButtonText=Ri,o.secondaryButtonTextColor=Ti,o.sendData=ac,o.serializeLaunchParams=Rs,o.serializeThemeParams=zn,o.setCloudStorageItem=pr,o.setCssVar=Ge,o.setMainButtonParams=ei,o.setMiniAppBackgroundColor=An,o.setMiniAppBottomBarColor=vn,o.setMiniAppHeaderColor=Rn,o.setSecondaryButtonParams=Ni,o.settingsButton=Za,o.shareStory=cc,o.shareURL=nc,o.showBackButton=Go,o.showSettingsButton=Wi,o.subscribe=la,o.supports=z,o.swipeBehavior=Xa,o.switchInlineQuery=uc,o.themeParams=xa,o.themeParamsAccentTextColor=Mr,o.themeParamsBackgroundColor=ct,o.themeParamsBottomBarBgColor=pn,o.themeParamsButtonColor=ut,o.themeParamsButtonTextColor=fn,o.themeParamsDestructiveTextColor=Dr,o.themeParamsHeaderBackgroundColor=Nr,o.themeParamsHintColor=Ir,o.themeParamsLinkColor=Vr,o.themeParamsSecondaryBackgroundColor=Be,o.themeParamsSectionBackgroundColor=Lr,o.themeParamsSectionHeaderTextColor=Ur,o.themeParamsSectionSeparatorColor=jr,o.themeParamsState=H,o.themeParamsSubtitleTextColor=qr,o.themeParamsTextColor=Hr,o.toRGB=Nt,o.toRecord=Bt,o.unmountBackButton=zo,o.unmountBiometry=nr,o.unmountClosingBehavior=cr,o.unmountMainButton=ti,o.unmountMiniApp=mi,o.unmountSecondaryButton=Ii,o.unmountSettingsButton=Gi,o.unmountSwipeBehavior=Zi,o.unmountThemeParams=si,o.unmountViewport=us,o.unsubscribe=_a,o.updateBiometryToken=or,o.viewport=ec,o.viewportHeight=Ki,o.viewportMountError=In,o.viewportStableHeight=es,o.viewportState=P,o.viewportWidth=ts,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),o}({});
//# sourceMappingURL=index.iife.js.map
{
"name": "@telegram-apps/sdk",
"version": "2.6.1",
"version": "2.6.2",
"description": "TypeScript Source Development Kit for Telegram Mini Apps client application.",

@@ -5,0 +5,0 @@ "author": "Vladislav Kibenko <wolfram.deus@gmail.com>",

@@ -73,4 +73,4 @@ import {

(options?: AsyncOptions): CancelablePromise<RequestedContact> => {
return new CancelablePromise(
async (res, _, abortSignal) => {
return CancelablePromise.withFn(
async (abortSignal) => {
const asyncOptions = { abortSignal };

@@ -81,3 +81,3 @@

try {
return res(await getRequestedContact(asyncOptions));
return await getRequestedContact(asyncOptions);
} catch {

@@ -98,3 +98,3 @@ }

try {
return res(await getRequestedContact(asyncOptions));
return await getRequestedContact(asyncOptions);
} catch {

@@ -109,2 +109,6 @@ }

}
// Reachable code, but the promise will be rejected and this result will be
// ignored.
return null as any;
}, options,

@@ -111,0 +115,0 @@ );

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc