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
20
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.3.1 to 2.4.0

dist/dts/scopes/components/back-button/exports.d.ts

52

dist/dts/index.d.ts
export { classNames } from './classnames/classNames.js';
export { mergeClassNames, type MergeClassNames } from './classnames/mergeClassNames.js';
export * as backButton from './scopes/components/back-button/back-button.js';
export { hide as hideBackButton, isVisible as isBackButtonVisible, isMounted as isBackButtonMounted, isSupported as isBackButtonSupported, mount as mountBackButton, onClick as onBackButtonClick, offClick as offBackButtonClick, show as showBackButton, unmount as unmountBackButton, } from './scopes/components/back-button/back-button.js';
export * as biometry from './scopes/components/biometry/instance.js';
export { authenticate as authenticateBiometry, isMounting as isBiometryMounting, isMounted as isBiometryMounted, isSupported as isBiometrySupported, mount as mountBiometry, mountError as biometryMountError, openSettings as openBiometrySettings, requestAccess as requestBiometryAccess, state as biometryState, unmount as unmountBiometry, updateToken as updateBiometryToken, isAuthenticating as isAuthenticatingBiometry, isRequestingAccess as isRequestingBiometryAccess, } from './scopes/components/biometry/instance.js';
export * as Biometry from './scopes/components/biometry/static.js';
export * as closingBehavior from './scopes/components/closing-behavior/closing-behavior.js';
export { disableConfirmation as disableClosingConfirmation, enableConfirmation as enableClosingConfirmation, isMounted as isClosingBehaviorMounted, isConfirmationEnabled as isClosingConfirmationEnabled, mount as mountClosingBehavior, unmount as unmountClosingBehavior, } from './scopes/components/closing-behavior/closing-behavior.js';
export * as cloudStorage from './scopes/components/cloud-storage/cloud-storage.js';
export { isSupported as isCloudStorageSupported, getItem as getCloudStorageItem, setItem as setCloudStorageItem, deleteItem as deleteCloudStorageItem, getKeys as getCloudStorageKeys, } from './scopes/components/cloud-storage/cloud-storage.js';
export * as hapticFeedback from './scopes/components/haptic-feedback/haptic-feedback.js';
export { impactOccurred as hapticFeedbackImpactOccurred, isSupported as isHapticFeedbackSupported, notificationOccurred as hapticFeedbackNotificationOccurred, selectionChanged as hapticFeedbackSelectionChanged, } from './scopes/components/haptic-feedback/haptic-feedback.js';
export * as initData from './scopes/components/init-data/instance.js';
export { state as initDataState, raw as initDataRaw, authDate as initDataAuthDate, chat as initDataChat, chatInstance as initDataChatInstance, chatType as initDataChatType, hash as initDataHash, canSendAfter as initDataCanSendAfter, canSendAfterDate as initDataCanSendAfterDate, queryId as initDataQueryId, restore as restoreInitData, user as initDataUser, receiver as initDataReceiver, startParam as initDataStartParam, } from './scopes/components/init-data/instance.js';
export * as InitData from './scopes/components/init-data/static.js';
export * as invoice from './scopes/components/invoice/invoice.js';
export { isSupported as isInvoiceSupported, isOpened as isInvoiceOpened, open as openInvoice, } from './scopes/components/invoice/invoice.js';
export * from './scopes/components/back-button/exports.js';
export * from './scopes/components/biometry/exports.js';
export * from './scopes/components/closing-behavior/exports.js';
export * from './scopes/components/cloud-storage/exports.js';
export * from './scopes/components/haptic-feedback/exports.js';
export * from './scopes/components/init-data/exports.js';
export * from './scopes/components/invoice/exports.js';
export * from './scopes/components/main-button/exports.js';
export * from './scopes/components/mini-app/exports.js';
export * as popup from './scopes/components/popup/instance.js';
export { isOpened as isPopupOpened, isSupported as isPopupSupported, open as openPopup, } from './scopes/components/popup/instance.js';
export * as Popup from './scopes/components/popup/static.js';
export * as qrScanner from './scopes/components/qr-scanner/qr-scanner.js';
export { close as closeQrScanner, isSupported as isQrScannerSupported, isOpened as isQrScannerOpened, open as openQrScanner, } from './scopes/components/qr-scanner/qr-scanner.js';
export * from './scopes/components/popup/exports.js';
export * from './scopes/components/qr-scanner/exports.js';
export * from './scopes/components/secondary-button/exports.js';
export * as settingsButton from './scopes/components/settings-button/settings-button.js';
export { hide as hideSettingsButton, isVisible as isSettingsButtonVisible, isMounted as isSettingsButtonMounted, isSupported as isSettingsButtonSupported, mount as mountSettingsButton, onClick as onSettingsButtonClick, offClick as offSettingsButtonClick, show as showSettingsButton, unmount as unmountSettingsButton, } from './scopes/components/settings-button/settings-button.js';
export * as swipeBehavior from './scopes/components/swipe-behavior/swipe-behavior.js';
export { disableVertical as disableVerticalSwipes, enableVertical as enableVerticalSwipes, isMounted as isSwipeBehaviorMounted, isVerticalEnabled as isVerticalSwipesEnabled, isSupported as isSwipeBehaviorSupported, mount as mountSwipeBehavior, unmount as unmountSwipeBehavior, } from './scopes/components/swipe-behavior/swipe-behavior.js';
export * as themeParams from './scopes/components/theme-params/instance.js';
export { accentTextColor as themeParamsAccentTextColor, backgroundColor as themeParamsBackgroundColor, bindCssVars as bindThemeParamsCssVars, buttonTextColor as themeParamsButtonTextColor, buttonColor as themeParamsButtonColor, bottomBarBgColor as themeParamsBottomBarBgColor, destructiveTextColor as themeParamsDestructiveTextColor, headerBackgroundColor as themeParamsHeaderBackgroundColor, hintColor as themeParamsHintColor, isMounted as isThemeParamsMounted, isDark as isThemeParamsDark, isCssVarsBound as isThemeParamsCssVarsBound, linkColor as themeParamsLinkColor, mount as mountThemeParams, state as themeParamsState, subtitleTextColor as themeParamsSubtitleTextColor, sectionBackgroundColor as themeParamsSectionBackgroundColor, secondaryBackgroundColor as themeParamsSecondaryBackgroundColor, sectionSeparatorColor as themeParamsSectionSeparatorColor, sectionHeaderTextColor as themeParamsSectionHeaderTextColor, textColor as themeParamsTextColor, unmount as unmountThemeParams, } from './scopes/components/theme-params/instance.js';
export * as ThemeParams from './scopes/components/theme-params/static.js';
export * as viewport from './scopes/components/viewport/instance.js';
export { bindCssVars as bindViewportCssVars, expand as expandViewport, height as viewportHeight, isExpanded as isViewportExpanded, isStable as isViewportStable, isCssVarsBound as isViewportCssVarsBound, isMounting as isViewportMounting, isMounted as isViewportMounted, mount as mountViewport, mountError as viewportMountError, state as viewportState, stableHeight as viewportStableHeight, unmount as unmountViewport, width as viewportWidth, } from './scopes/components/viewport/instance.js';
export * as Viewport from './scopes/components/viewport/static.js';
export { openLink, openTelegramLink, shareURL, type OpenLinkOptions, } from './scopes/utilities/links/links.js';
export { requestPhoneAccess, requestWriteAccess, requestContact, type RequestedContact, } from './scopes/utilities/privacy/privacy.js';
export { readTextFromClipboard, sendData, switchInlineQuery, shareStory, } from './scopes/utilities/uncategorized/uncategorized.js';
export { $postEvent, $version, $createRequestId, } from './scopes/globals.js';
export * from './scopes/components/settings-button/exports.js';
export * from './scopes/components/swipe-behavior/exports.js';
export * from './scopes/components/theme-params/exports.js';
export * from './scopes/components/viewport/exports.js';
export * from './scopes/utilities/links/exports.js';
export * from './scopes/utilities/privacy/exports.js';
export * from './scopes/utilities/uncategorized/exports.js';
export { $postEvent, $version, $createRequestId } from './scopes/globals.js';
export { isColorDark } from './utils/isColorDark.js';

@@ -42,0 +24,0 @@ export { isSSR } from './utils/isSSR.js';

@@ -1,2 +0,2 @@

import { GetCssVarNameFn } from './static.js';
import { GetCssVarNameFn } from './types.js';
/**

@@ -3,0 +3,0 @@ * Creates CSS variables connected with the current theme parameters.

@@ -22,2 +22,5 @@ import { ThemeParams } from '@telegram-apps/bridge';

export declare const buttonTextColor: Computed<`#${string}` | undefined>;
/**
* @since v7.10
*/
export declare const bottomBarBgColor: Computed<`#${string}` | undefined>;

@@ -24,0 +27,0 @@ export declare const destructiveTextColor: Computed<`#${string}` | undefined>;

@@ -16,2 +16,10 @@ import { CancelablePromise, PhoneRequestedStatus, WriteAccessRequestedStatus, ExecuteWithOptions } from '@telegram-apps/bridge';

/**
* True if phone access is currently being requested.
*/
export declare const isRequestingPhoneAccess: import('@telegram-apps/signals').Signal<boolean>;
/**
* True if write access is currently being requested.
*/
export declare const isRequestingWriteAccess: import('@telegram-apps/signals').Signal<boolean>;
/**
* Requests current user contact information. In contrary to requestPhoneAccess, this method

@@ -18,0 +26,0 @@ * returns promise with contact information that rejects in case, user denied access, or request

@@ -1,5 +0,5 @@

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

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

"devDependencies": {
"test-utils": "0.0.1",
"tsconfig": "0.0.2"
"tsconfig": "0.0.2",
"test-utils": "0.0.1"
},

@@ -50,0 +50,0 @@ "publishConfig": {

export { classNames } from '@/classnames/classNames.js';
export { mergeClassNames, type MergeClassNames } from '@/classnames/mergeClassNames.js';
export * as backButton from '@/scopes/components/back-button/back-button.js';
export {
hide as hideBackButton,
isVisible as isBackButtonVisible,
isMounted as isBackButtonMounted,
isSupported as isBackButtonSupported,
mount as mountBackButton,
onClick as onBackButtonClick,
offClick as offBackButtonClick,
show as showBackButton,
unmount as unmountBackButton,
} from '@/scopes/components/back-button/back-button.js';
export * as biometry from '@/scopes/components/biometry/instance.js';
export {
authenticate as authenticateBiometry,
isMounting as isBiometryMounting,
isMounted as isBiometryMounted,
isSupported as isBiometrySupported,
mount as mountBiometry,
mountError as biometryMountError,
openSettings as openBiometrySettings,
requestAccess as requestBiometryAccess,
state as biometryState,
unmount as unmountBiometry,
updateToken as updateBiometryToken,
isAuthenticating as isAuthenticatingBiometry,
isRequestingAccess as isRequestingBiometryAccess,
} from '@/scopes/components/biometry/instance.js';
export * as Biometry from '@/scopes/components/biometry/static.js';
export * as closingBehavior from '@/scopes/components/closing-behavior/closing-behavior.js';
export {
disableConfirmation as disableClosingConfirmation,
enableConfirmation as enableClosingConfirmation,
isMounted as isClosingBehaviorMounted,
isConfirmationEnabled as isClosingConfirmationEnabled,
mount as mountClosingBehavior,
unmount as unmountClosingBehavior,
} from '@/scopes/components/closing-behavior/closing-behavior.js';
export * as cloudStorage from '@/scopes/components/cloud-storage/cloud-storage.js';
export {
isSupported as isCloudStorageSupported,
getItem as getCloudStorageItem,
setItem as setCloudStorageItem,
deleteItem as deleteCloudStorageItem,
getKeys as getCloudStorageKeys,
} from '@/scopes/components/cloud-storage/cloud-storage.js';
export * as hapticFeedback from '@/scopes/components/haptic-feedback/haptic-feedback.js';
export {
impactOccurred as hapticFeedbackImpactOccurred,
isSupported as isHapticFeedbackSupported,
notificationOccurred as hapticFeedbackNotificationOccurred,
selectionChanged as hapticFeedbackSelectionChanged,
} from '@/scopes/components/haptic-feedback/haptic-feedback.js';
export * as initData from '@/scopes/components/init-data/instance.js';
export {
state as initDataState,
raw as initDataRaw,
authDate as initDataAuthDate,
chat as initDataChat,
chatInstance as initDataChatInstance,
chatType as initDataChatType,
hash as initDataHash,
canSendAfter as initDataCanSendAfter,
canSendAfterDate as initDataCanSendAfterDate,
queryId as initDataQueryId,
restore as restoreInitData,
user as initDataUser,
receiver as initDataReceiver,
startParam as initDataStartParam,
} from '@/scopes/components/init-data/instance.js';
export * as InitData from '@/scopes/components/init-data/static.js';
export * as invoice from '@/scopes/components/invoice/invoice.js';
export {
isSupported as isInvoiceSupported,
isOpened as isInvoiceOpened,
open as openInvoice,
} from '@/scopes/components/invoice/invoice.js';
export * from '@/scopes/components/back-button/exports.js';
export * from '@/scopes/components/biometry/exports.js';
export * from '@/scopes/components/closing-behavior/exports.js';
export * from '@/scopes/components/cloud-storage/exports.js';
export * from '@/scopes/components/haptic-feedback/exports.js';
export * from '@/scopes/components/init-data/exports.js';
export * from '@/scopes/components/invoice/exports.js';
export * from '@/scopes/components/main-button/exports.js';
export * from '@/scopes/components/mini-app/exports.js';
export * as popup from '@/scopes/components/popup/instance.js';
export {
isOpened as isPopupOpened,
isSupported as isPopupSupported,
open as openPopup,
} from '@/scopes/components/popup/instance.js';
export * as Popup from '@/scopes/components/popup/static.js';
export * as qrScanner from '@/scopes/components/qr-scanner/qr-scanner.js';
export {
close as closeQrScanner,
isSupported as isQrScannerSupported,
isOpened as isQrScannerOpened,
open as openQrScanner,
} from '@/scopes/components/qr-scanner/qr-scanner.js';
export * from '@/scopes/components/popup/exports.js';
export * from '@/scopes/components/qr-scanner/exports.js';
export * from '@/scopes/components/secondary-button/exports.js';
export * from '@/scopes/components/settings-button/exports.js';
export * from '@/scopes/components/swipe-behavior/exports.js';
export * from '@/scopes/components/theme-params/exports.js';
export * from '@/scopes/components/viewport/exports.js';
export * from '@/scopes/utilities/links/exports.js';
export * from '@/scopes/utilities/privacy/exports.js';
export * from '@/scopes/utilities/uncategorized/exports.js';
export * as settingsButton from '@/scopes/components/settings-button/settings-button.js';
export {
hide as hideSettingsButton,
isVisible as isSettingsButtonVisible,
isMounted as isSettingsButtonMounted,
isSupported as isSettingsButtonSupported,
mount as mountSettingsButton,
onClick as onSettingsButtonClick,
offClick as offSettingsButtonClick,
show as showSettingsButton,
unmount as unmountSettingsButton,
} from '@/scopes/components/settings-button/settings-button.js';
export { $postEvent, $version, $createRequestId } from '@/scopes/globals.js';
export * as swipeBehavior from '@/scopes/components/swipe-behavior/swipe-behavior.js';
export {
disableVertical as disableVerticalSwipes,
enableVertical as enableVerticalSwipes,
isMounted as isSwipeBehaviorMounted,
isVerticalEnabled as isVerticalSwipesEnabled,
isSupported as isSwipeBehaviorSupported,
mount as mountSwipeBehavior,
unmount as unmountSwipeBehavior,
} from '@/scopes/components/swipe-behavior/swipe-behavior.js';
export * as themeParams from '@/scopes/components/theme-params/instance.js';
export {
accentTextColor as themeParamsAccentTextColor,
backgroundColor as themeParamsBackgroundColor,
bindCssVars as bindThemeParamsCssVars,
buttonTextColor as themeParamsButtonTextColor,
buttonColor as themeParamsButtonColor,
bottomBarBgColor as themeParamsBottomBarBgColor,
destructiveTextColor as themeParamsDestructiveTextColor,
headerBackgroundColor as themeParamsHeaderBackgroundColor,
hintColor as themeParamsHintColor,
isMounted as isThemeParamsMounted,
isDark as isThemeParamsDark,
isCssVarsBound as isThemeParamsCssVarsBound,
linkColor as themeParamsLinkColor,
mount as mountThemeParams,
state as themeParamsState,
subtitleTextColor as themeParamsSubtitleTextColor,
sectionBackgroundColor as themeParamsSectionBackgroundColor,
secondaryBackgroundColor as themeParamsSecondaryBackgroundColor,
sectionSeparatorColor as themeParamsSectionSeparatorColor,
sectionHeaderTextColor as themeParamsSectionHeaderTextColor,
textColor as themeParamsTextColor,
unmount as unmountThemeParams,
} from '@/scopes/components/theme-params/instance.js';
export * as ThemeParams from '@/scopes/components/theme-params/static.js';
export * as viewport from '@/scopes/components/viewport/instance.js';
export {
bindCssVars as bindViewportCssVars,
expand as expandViewport,
height as viewportHeight,
isExpanded as isViewportExpanded,
isStable as isViewportStable,
isCssVarsBound as isViewportCssVarsBound,
isMounting as isViewportMounting,
isMounted as isViewportMounted,
mount as mountViewport,
mountError as viewportMountError,
state as viewportState,
stableHeight as viewportStableHeight,
unmount as unmountViewport,
width as viewportWidth,
} from '@/scopes/components/viewport/instance.js';
export * as Viewport from '@/scopes/components/viewport/static.js';
export {
openLink,
openTelegramLink,
shareURL,
type OpenLinkOptions,
} from '@/scopes/utilities/links/links.js';
export {
requestPhoneAccess,
requestWriteAccess,
requestContact,
type RequestedContact,
} from '@/scopes/utilities/privacy/privacy.js';
export {
readTextFromClipboard,
sendData,
switchInlineQuery,
shareStory,
} from '@/scopes/utilities/uncategorized/uncategorized.js';
export {
$postEvent,
$version,
$createRequestId,
} from '@/scopes/globals.js';
export { isColorDark } from '@/utils/isColorDark.js';

@@ -205,0 +27,0 @@ export { isSSR } from '@/utils/isSSR.js';

@@ -9,3 +9,3 @@ import { afterEach, vi, it, expect, beforeEach } from 'vitest';

import { resetPackageState } from '@test-utils/reset.js';
import { resetPackageState } from '@test-utils/reset/reset.js';
import { $postEvent, $version } from '@/scopes/globals.js';

@@ -12,0 +12,0 @@

@@ -6,3 +6,3 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';

import { mockPostEvent } from '@test-utils/mockPostEvent.js';
import { resetPackageState, resetSignal } from '@test-utils/reset.js';
import { resetPackageState } from '@test-utils/reset/reset.js';
import { $version } from '@/scopes/globals.js';

@@ -24,3 +24,2 @@

resetPackageState();
[isVisible, isMounted].forEach(resetSignal);
vi.restoreAllMocks();

@@ -120,3 +119,8 @@ mockPostEvent();

describe('mount', () => {
afterEach(unmount);
it('should call postEvent with "web_app_setup_back_button"', () => {
const spy = mockPostEvent();
mount();
expect(spy).toHaveBeenCalledTimes(1);
expect(spy).toHaveBeenCalledWith('web_app_setup_back_button', { is_visible: false });
});

@@ -123,0 +127,0 @@ it('should set isMounted = true', () => {

@@ -13,2 +13,3 @@ import {

import { $version, postEvent } from '@/scopes/globals.js';
import { subAndCall } from '@/utils/subAndCall.js';

@@ -55,3 +56,3 @@

isVisible.set(isPageReload() && getStorageValue<StorageValue>(STORAGE_KEY) || false);
isVisible.sub(onStateChanged);
subAndCall(isVisible, onStateChanged);
isMounted.set(true);

@@ -61,5 +62,6 @@ }

function onStateChanged(isVisible: boolean): void {
postEvent(MINI_APPS_METHOD, { is_visible: isVisible });
setStorageValue<StorageValue>(STORAGE_KEY, isVisible);
function onStateChanged(): void {
const value = isVisible();
postEvent(MINI_APPS_METHOD, { is_visible: value });
setStorageValue<StorageValue>(STORAGE_KEY, value);
}

@@ -66,0 +68,0 @@

@@ -17,2 +17,3 @@ import {

import { createMountFn } from '@/scopes/createMountFn.js';
import { subAndCall } from '@/utils/subAndCall.js';
import { ERR_ALREADY_CALLED, ERR_NOT_AVAILABLE } from '@/errors.js';

@@ -28,3 +29,3 @@

} from './signals.js';
import { request as requestBiometry } from './static.js';
import { requestBiometry } from './requestBiometry.js';
import { eventToState } from './eventToState.js';

@@ -167,3 +168,3 @@ import type {

on(BIOMETRY_INFO_RECEIVED_EVENT, onBiometryInfoReceived);
state.sub(onStateChanged);
subAndCall(state, onStateChanged);
state.set(result);

@@ -178,3 +179,4 @@ },

function onStateChanged(s: State | undefined): void {
function onStateChanged(): void {
const s = state();
s && setStorageValue<StorageValue>(STORAGE_KEY, s);

@@ -181,0 +183,0 @@ }

@@ -5,3 +5,3 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';

import { mockPostEvent } from '@test-utils/mockPostEvent.js';
import { resetPackageState, resetSignal } from '@test-utils/reset.js';
import { resetPackageState } from '@test-utils/reset/reset.js';

@@ -19,3 +19,2 @@ import {

resetPackageState();
[isConfirmationEnabled, isMounted].forEach(resetSignal);
vi.restoreAllMocks();

@@ -89,3 +88,8 @@ mockPostEvent();

describe('mount', () => {
afterEach(unmount);
it('should call postEvent with "web_app_setup_closing_behavior"', () => {
const spy = mockPostEvent();
mount();
expect(spy).toHaveBeenCalledTimes(1);
expect(spy).toHaveBeenCalledWith('web_app_setup_closing_behavior', { need_confirmation: false });
});

@@ -92,0 +96,0 @@ it('should set isMounted = true', () => {

@@ -6,2 +6,3 @@ import { isPageReload } from '@telegram-apps/navigation';

import { postEvent } from '@/scopes/globals.js';
import { subAndCall } from '@/utils/subAndCall.js';

@@ -45,3 +46,3 @@ type StorageValue = boolean;

isConfirmationEnabled.set(isPageReload() && getStorageValue<StorageValue>(STORAGE_KEY) || false);
isConfirmationEnabled.sub(onStateChanged);
subAndCall(isConfirmationEnabled, onStateChanged);
isMounted.set(true);

@@ -51,3 +52,4 @@ }

function onStateChanged(value: boolean): void {
function onStateChanged(): void {
const value = isConfirmationEnabled();
postEvent('web_app_setup_closing_behavior', { need_confirmation: value });

@@ -54,0 +56,0 @@ setStorageValue<StorageValue>(STORAGE_KEY, value);

import { beforeEach, describe, expect, it } from 'vitest';
import { mockPostEvent } from '@test-utils/mockPostEvent.js';
import { resetPackageState } from '@test-utils/reset.js';
import { resetPackageState } from '@test-utils/reset/reset.js';

@@ -6,0 +6,0 @@ import { $version } from '@/scopes/globals.js';

@@ -6,6 +6,4 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';

import { mockPostEvent } from '@test-utils/mockPostEvent.js';
import { resetSignal, resetPackageState } from '@test-utils/reset.js';
import { resetPackageState } from '@test-utils/reset/reset.js';
import * as themeParams from '@/scopes/components/theme-params/instance.js';
import {

@@ -21,3 +19,2 @@ text,

hasShineEffect,
state,
} from './signals.js';

@@ -42,17 +39,2 @@ import { onClick, offClick, setParams, mount, unmount } from './methods.js';

resetPackageState();
[
themeParams.isCssVarsBound,
themeParams.isMounted,
themeParams.state,
text,
textColor,
isMounted,
isEnabled,
isLoaderVisible,
isVisible,
internalState,
backgroundColor,
hasShineEffect,
state,
].forEach(resetSignal);
mockPostEvent();

@@ -158,2 +140,17 @@ });

describe('mount', () => {
it('should call postEvent with "web_app_setup_main_button"', () => {
const spy = mockPostEvent();
mount();
expect(spy).toHaveBeenCalledTimes(1);
expect(spy).toHaveBeenCalledWith('web_app_setup_main_button', {
color: '#2481cc',
has_shine_effect: false,
is_active: true,
is_progress_visible: false,
is_visible: false,
text: 'Continue',
text_color: '#ffffff',
});
});
it('should set isMounted = true', () => {

@@ -160,0 +157,0 @@ expect(isMounted()).toBe(false);

@@ -11,2 +11,3 @@ import {

import { postEvent } from '@/scopes/globals.js';
import { subAndCall } from '@/utils/subAndCall.js';

@@ -34,3 +35,3 @@ import { internalState, isMounted, state } from './signals.js';

internalState.sub(onInternalStateChanged);
state.sub(onStateChanged);
subAndCall(state, onStateChanged);
isMounted.set(true);

@@ -61,3 +62,5 @@ }

function onStateChanged(s: Required<State>): void {
function onStateChanged(): void {
const s = state();
// We should not commit changes until the payload is correct.

@@ -64,0 +67,0 @@ // Some version of Telegram will crash due to the empty value of the text.

@@ -6,19 +6,8 @@ import { beforeEach, describe, expect, it, MockInstance, vi } from 'vitest';

import { mockPostEvent } from '@test-utils/mockPostEvent.js';
import { resetPackageState, resetSignal } from '@test-utils/reset.js';
import * as themeParams from '@/scopes/components/theme-params/instance.js';
import { resetPackageState } from '@test-utils/reset/reset.js';
import { state as tpState } from '@/scopes/components/theme-params/signals.js';
import { $version } from '@/scopes/globals.js';
import { headerColor, backgroundColor, bottomBarColor } from './signals.js';
import {
headerColor,
backgroundColor,
state,
isMounted,
isDark,
isCssVarsBound,
bottomBarColor,
bottomBarColorRGB,
backgroundColorRGB,
headerColorRGB,
} from './signals.js';
import {
bindCssVars,

@@ -52,18 +41,2 @@ close,

resetPackageState();
[
themeParams.isCssVarsBound,
themeParams.isMounted,
themeParams.state,
headerColor,
backgroundColor,
state,
isMounted,
isDark,
isCssVarsBound,
bottomBarColor,
bottomBarColorRGB,
backgroundColorRGB,
headerColorRGB,
].forEach(resetSignal);
createWindow();

@@ -111,3 +84,3 @@ setPropertySpy = vi

bindCssVars();
themeParams.state.set({ secondaryBgColor: '#ddddaa' });
tpState.set({ secondaryBgColor: '#ddddaa' });
setPropertySpy.mockClear();

@@ -118,3 +91,3 @@ backgroundColor.set('secondary_bg_color');

themeParams.state.set({ bgColor: '#aafedd' });
tpState.set({ bgColor: '#aafedd' });
setPropertySpy.mockClear();

@@ -135,3 +108,3 @@ backgroundColor.set('bg_color');

bindCssVars();
themeParams.state.set({ secondaryBgColor: '#ddddaa' });
tpState.set({ secondaryBgColor: '#ddddaa' });
setPropertySpy.mockClear();

@@ -142,3 +115,3 @@ headerColor.set('secondary_bg_color');

themeParams.state.set({ bgColor: '#aafedd' });
tpState.set({ bgColor: '#aafedd' });
setPropertySpy.mockClear();

@@ -159,3 +132,3 @@ headerColor.set('bg_color');

bindCssVars();
themeParams.state.set({ bgColor: '#aafedd' });
tpState.set({ bgColor: '#aafedd' });
setPropertySpy.mockClear();

@@ -166,3 +139,3 @@ bottomBarColor.set('bg_color');

themeParams.state.set({ secondaryBgColor: '#ddddaa' });
tpState.set({ secondaryBgColor: '#ddddaa' });
setPropertySpy.mockClear();

@@ -173,3 +146,3 @@ bottomBarColor.set('secondary_bg_color');

themeParams.state.set({ bottomBarBgColor: '#ddaacc' });
tpState.set({ bottomBarBgColor: '#ddaacc' });
setPropertySpy.mockClear();

@@ -223,2 +196,25 @@ bottomBarColor.set('bottom_bar_bg_color');

describe('mount', () => {
it('should call postEvent with "web_app_set_background_color"', () => {
const spy = mockPostEvent();
mount();
expect(spy).toHaveBeenCalledTimes(3);
expect(spy).toHaveBeenNthCalledWith(1, 'web_app_set_background_color', { color: 'bg_color' });
});
it('should call postEvent with "web_app_set_bottom_bar_color"', () => {
const spy = mockPostEvent();
mount();
expect(spy).toHaveBeenCalledTimes(3);
expect(spy).toHaveBeenNthCalledWith(2, 'web_app_set_bottom_bar_color', { color: 'bottom_bar_bg_color' });
});
it('should call postEvent with "web_app_set_header_color"', () => {
const spy = mockPostEvent();
mount();
expect(spy).toHaveBeenCalledTimes(3);
expect(spy).toHaveBeenNthCalledWith(3, 'web_app_set_header_color', { color_key: 'bg_color' });
});
});
describe('close', () => {

@@ -225,0 +221,0 @@ it('should call "web_app_close" with "return_back" option', () => {

@@ -10,3 +10,3 @@ import {

type RGB,
type BottomBarColor, BackgroundColor,
type BottomBarColor,
} from '@telegram-apps/bridge';

@@ -21,6 +21,6 @@ import { isRGB } from '@telegram-apps/transformers';

import { ERR_ALREADY_CALLED } from '@/errors.js';
import { mount as tpMount } from '@/scopes/components/theme-params/methods.js';
import {
mount as tpMount,
headerBackgroundColor as tpHeaderBackgroundColor,
} from '@/scopes/components/theme-params/instance.js';
} from '@/scopes/components/theme-params/signals.js';

@@ -39,2 +39,3 @@ import {

import type { GetCssVarNameFn, HeaderColor, State } from './types.js';
import { subAndCall } from '@/utils/subAndCall.js';

@@ -120,8 +121,11 @@ type StorageValue = State;

tpMount();
backgroundColor.set(s ? s.backgroundColor : 'bg_color');
backgroundColor.sub(onBgColorChanged);
bottomBarColor.set(s ? s.bottomBarColor : 'bottom_bar_bg_color');
bottomBarColor.sub(onBottomBarBgColorChanged);
headerColor.set(s ? s.headerColor : tpHeaderBackgroundColor() || 'bg_color');
headerColor.sub(onHeaderColorChanged);
subAndCall(backgroundColor, onBgColorChanged);
subAndCall(bottomBarColor, onBottomBarBgColorChanged);
subAndCall(headerColor, onHeaderColorChanged);
isMounted.set(true);

@@ -131,3 +135,4 @@ }

function onBgColorChanged(color: BackgroundColor): void {
function onBgColorChanged(): void {
const color = backgroundColor();
saveState();

@@ -137,8 +142,9 @@ postEvent(SET_BG_COLOR_METHOD, { color });

function onBottomBarBgColorChanged(color: BottomBarColor): void {
function onBottomBarBgColorChanged(): void {
saveState();
postEvent(SET_BOTTOM_BAR_BG_COLOR_METHOD, { color });
postEvent(SET_BOTTOM_BAR_BG_COLOR_METHOD, { color: bottomBarColor() });
}
function onHeaderColorChanged(color: HeaderColor): void {
function onHeaderColorChanged(): void {
const color = headerColor();
saveState();

@@ -145,0 +151,0 @@ postEvent(SET_HEADER_COLOR_METHOD, isRGB(color) ? { color } : { color_key: color });

import { beforeEach, describe, expect, it, vi } from 'vitest';
import { resetPackageState, resetSignal } from '@test-utils/reset.js';
import { resetPackageState, resetSignal } from '@test-utils/reset/reset.js';

@@ -4,0 +4,0 @@ import { state as tpState } from '@/scopes/components/theme-params/signals.js';

@@ -15,3 +15,3 @@ import { Computed, computed, signal } from '@telegram-apps/signals';

// #__NO_SIDE_EFFECTS__
function colorBasedOn(signal: Computed<'bg_color' | 'secondary_bg_color' | RGB>) {
function rgbBasedOn(signal: Computed<'bg_color' | 'secondary_bg_color' | RGB>) {
return computed<RGB | undefined>(() => {

@@ -37,3 +37,3 @@ const color = signal();

*/
export const backgroundColorRGB = colorBasedOn(backgroundColor);
export const backgroundColorRGB = rgbBasedOn(backgroundColor);

@@ -76,3 +76,3 @@

*/
export const headerColorRGB = colorBasedOn(headerColor);
export const headerColorRGB = rgbBasedOn(headerColor);

@@ -89,4 +89,2 @@ /**

/* COMPUTED */
/**

@@ -93,0 +91,0 @@ * True if the current Mini App background color is recognized as dark.

import { beforeEach, describe, expect, it, vi } from 'vitest';
import { dispatchMiniAppsEvent } from 'test-utils';
import { resetPackageState, resetSignal } from '@test-utils/reset.js';
import { resetPackageState } from '@test-utils/reset/reset.js';
import { mockPostEvent } from '@test-utils/mockPostEvent.js';

@@ -12,3 +12,2 @@ import { $version } from '@/scopes/globals.js';

resetPackageState();
resetSignal(isOpened);
vi.restoreAllMocks();

@@ -15,0 +14,0 @@ mockPostEvent();

@@ -6,5 +6,4 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';

import { mockPostEvent } from '@test-utils/mockPostEvent.js';
import { resetSignal, resetPackageState } from '@test-utils/reset.js';
import { resetPackageState } from '@test-utils/reset/reset.js';
import * as themeParams from '@/scopes/components/theme-params/instance.js';
import { $version } from '@/scopes/globals.js';

@@ -22,3 +21,2 @@

hasShineEffect,
state,
position,

@@ -44,18 +42,2 @@ } from './signals.js';

resetPackageState();
[
themeParams.isCssVarsBound,
themeParams.isMounted,
themeParams.state,
text,
textColor,
isMounted,
isEnabled,
isLoaderVisible,
isVisible,
internalState,
backgroundColor,
hasShineEffect,
state,
position,
].forEach(resetSignal);
mockPostEvent();

@@ -62,0 +44,0 @@ });

@@ -11,2 +11,3 @@ import {

import { $version, postEvent } from '@/scopes/globals.js';
import { subAndCall } from '@/utils/subAndCall.js';

@@ -41,3 +42,3 @@ import { internalState, isMounted, state } from './signals.js';

internalState.sub(onInternalStateChanged);
state.sub(onStateChanged);
subAndCall(state, onStateChanged);
isMounted.set(true);

@@ -68,3 +69,5 @@ }

function onStateChanged(s: Required<State>): void {
function onStateChanged(): void {
const s = state();
// We should not commit changes until the payload is correct. Some version of Telegram will

@@ -71,0 +74,0 @@ // crash due to the empty value of the text.

@@ -6,3 +6,3 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';

import { mockPostEvent } from '@test-utils/mockPostEvent.js';
import { resetPackageState, resetSignal } from '@test-utils/reset.js';
import { resetPackageState } from '@test-utils/reset/reset.js';

@@ -25,3 +25,2 @@ import { $version } from '@/scopes/globals.js';

resetPackageState();
[isVisible, isMounted].forEach(resetSignal);
vi.restoreAllMocks();

@@ -123,3 +122,8 @@ mockPostEvent();

describe('mount', () => {
afterEach(unmount);
it('should call postEvent with "web_app_setup_settings_button"', () => {
const spy = mockPostEvent();
mount();
expect(spy).toHaveBeenCalledTimes(1);
expect(spy).toHaveBeenCalledWith('web_app_setup_settings_button', { is_visible: false });
});

@@ -126,0 +130,0 @@ it('should set isMounted = true', () => {

@@ -13,2 +13,3 @@ import {

import { $version, postEvent } from '@/scopes/globals.js';
import { subAndCall } from '@/utils/subAndCall.js';

@@ -54,3 +55,3 @@ type StorageValue = boolean;

isVisible.set(isPageReload() && getStorageValue<StorageValue>(STORAGE_KEY) || false);
isVisible.sub(onStateChanged);
subAndCall(isVisible, onStateChanged);
isMounted.set(true);

@@ -60,5 +61,6 @@ }

function onStateChanged(isVisible: boolean) {
postEvent(MINI_APPS_METHOD, { is_visible: isVisible });
setStorageValue<StorageValue>(STORAGE_KEY, isVisible);
function onStateChanged() {
const value = isVisible();
postEvent(MINI_APPS_METHOD, { is_visible: value });
setStorageValue<StorageValue>(STORAGE_KEY, value);
}

@@ -65,0 +67,0 @@

@@ -5,3 +5,3 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';

import { mockPostEvent } from '@test-utils/mockPostEvent.js';
import { resetPackageState, resetSignal } from '@test-utils/reset.js';
import { resetPackageState } from '@test-utils/reset/reset.js';
import { $version } from '@/scopes/globals.js';

@@ -21,3 +21,2 @@

resetPackageState();
[isVerticalEnabled, isMounted].forEach(resetSignal);
vi.restoreAllMocks();

@@ -56,3 +55,2 @@ mockPostEvent();

describe('not mounted', () => {

@@ -105,4 +103,2 @@ describe('disableVerticalSwipes', () => {

describe('mount', () => {
afterEach(unmount);
it('should set isMounted = true', () => {

@@ -114,2 +110,9 @@ expect(isMounted()).toBe(false);

it('should call postEvent with "web_app_setup_swipe_behavior"', () => {
const spy = mockPostEvent();
mount();
expect(spy).toHaveBeenCalledTimes(1);
expect(spy).toHaveBeenCalledWith('web_app_setup_swipe_behavior', { allow_vertical_swipe: false });
});
describe('page reload', () => {

@@ -116,0 +119,0 @@ beforeEach(() => {

@@ -6,2 +6,3 @@ import { isPageReload } from '@telegram-apps/navigation';

import { $version, postEvent } from '@/scopes/globals.js';
import { subAndCall } from '@/utils/subAndCall.js';

@@ -53,3 +54,3 @@ type StorageValue = boolean;

isVerticalEnabled.set(isPageReload() && getStorageValue<StorageValue>(STORAGE_KEY) || false);
isVerticalEnabled.sub(onStateChanged);
subAndCall(isVerticalEnabled, onStateChanged);
isMounted.set(true);

@@ -59,3 +60,4 @@ }

function onStateChanged(value: boolean): void {
function onStateChanged(): void {
const value = isVerticalEnabled();
postEvent(MINI_APPS_METHOD, { allow_vertical_swipe: value });

@@ -62,0 +64,0 @@ setStorageValue<StorageValue>(STORAGE_KEY, value);

import { beforeEach, describe, expect, it, MockInstance, vi } from 'vitest';
import { createWindow } from 'test-utils';
import { emitMiniAppsEvent } from '@telegram-apps/bridge';
import { resetSignal, resetPackageState } from '@test-utils/reset.js';
import { resetPackageState } from '@test-utils/reset/reset.js';
import { mockPostEvent } from '@test-utils/mockPostEvent.js';
import { bindCssVars, mount } from './methods.js';
import { isCssVarsBound, isMounted, state } from './signals.js';
import { mockPostEvent } from '@test-utils/mockPostEvent.js';
import { state } from './signals.js';

@@ -26,4 +26,2 @@ type SetPropertyFn = typeof document.documentElement.style.setProperty;

resetPackageState();
[isCssVarsBound, isMounted, state].forEach(resetSignal);
createWindow();

@@ -30,0 +28,0 @@ mockPostEvent();

@@ -20,3 +20,4 @@ import {

import { isCssVarsBound, state, isMounted } from './signals.js';
import { type GetCssVarNameFn, parse } from './static.js';
import { parseThemeParams } from './parseThemeParams.js';
import type { GetCssVarNameFn } from './types.js';

@@ -93,3 +94,3 @@ type StorageValue = ThemeParams;

const onThemeChanged: EventListener<'theme_changed'> = (e) => {
const value = parse(e.theme_params);
const value = parseThemeParams(e.theme_params);
state.set(value);

@@ -96,0 +97,0 @@ setStorageValue<StorageValue>(STORAGE_KEY, value);

@@ -6,4 +6,2 @@ import type { ThemeParams } from '@telegram-apps/bridge';

/* USUAL */
/**

@@ -24,5 +22,3 @@ * True if the component is currently mounted.

/* COMPUTED */
function createStateComputed<K extends keyof ThemeParams>(key: K): Computed<ThemeParams[K] | undefined> {
function fromState<K extends keyof ThemeParams>(key: K): Computed<ThemeParams[K] | undefined> {
return computed(() => state()[key]);

@@ -34,13 +30,16 @@ }

*/
export const accentTextColor = createStateComputed('accentTextColor');
export const accentTextColor = fromState('accentTextColor');
export const backgroundColor = createStateComputed('bgColor');
export const backgroundColor = fromState('bgColor');
export const buttonColor = createStateComputed('buttonColor');
export const buttonColor = fromState('buttonColor');
export const buttonTextColor = createStateComputed('buttonTextColor');
export const buttonTextColor = fromState('buttonTextColor');
export const bottomBarBgColor = createStateComputed('bottomBarBgColor');
/**
* @since v7.10
*/
export const bottomBarBgColor = fromState('bottomBarBgColor');
export const destructiveTextColor = createStateComputed('destructiveTextColor');
export const destructiveTextColor = fromState('destructiveTextColor');

@@ -50,5 +49,5 @@ /**

*/
export const headerBackgroundColor = createStateComputed('headerBgColor');
export const headerBackgroundColor = fromState('headerBgColor');
export const hintColor = createStateComputed('hintColor');
export const hintColor = fromState('hintColor');

@@ -64,5 +63,5 @@ /**

export const linkColor = createStateComputed('linkColor');
export const linkColor = fromState('linkColor');
export const secondaryBackgroundColor = createStateComputed('secondaryBgColor');
export const secondaryBackgroundColor = fromState('secondaryBgColor');

@@ -72,3 +71,3 @@ /**

*/
export const sectionBackgroundColor = createStateComputed('sectionBgColor');
export const sectionBackgroundColor = fromState('sectionBgColor');

@@ -78,3 +77,3 @@ /**

*/
export const sectionHeaderTextColor = createStateComputed('sectionHeaderTextColor');
export const sectionHeaderTextColor = fromState('sectionHeaderTextColor');

@@ -84,3 +83,3 @@ /**

*/
export const sectionSeparatorColor = createStateComputed('sectionSeparatorColor');
export const sectionSeparatorColor = fromState('sectionSeparatorColor');

@@ -90,4 +89,4 @@ /**

*/
export const subtitleTextColor = createStateComputed('subtitleTextColor');
export const subtitleTextColor = fromState('subtitleTextColor');
export const textColor = createStateComputed('textColor');
export const textColor = fromState('textColor');

@@ -18,2 +18,3 @@ import {

import { createMountFn } from '@/scopes/createMountFn.js';
import { subAndCall } from '@/utils/subAndCall.js';

@@ -142,3 +143,3 @@ import { type GetCSSVarNameFn, request } from './static.js';

on('viewport_changed', onViewportChanged);
state.sub(onStateChanged);
subAndCall(state, onStateChanged);
state.set(formatState(result));

@@ -158,4 +159,4 @@ },

function onStateChanged(s: State): void {
setStorageValue<StorageValue>('viewport', s);
function onStateChanged(): void {
setStorageValue<StorageValue>('viewport', state());
}

@@ -162,0 +163,0 @@

@@ -5,3 +5,3 @@ import { describe, vi, expect, it, beforeEach } from 'vitest';

import { mockPostEvent } from '@test-utils/mockPostEvent.js';
import { resetPackageState } from '@test-utils/reset.js';
import { resetPackageState } from '@test-utils/reset/reset.js';
import { $version } from '@/scopes/globals.js';

@@ -8,0 +8,0 @@

@@ -14,2 +14,3 @@ import {

import { ERR_ACCESS_DENIED, ERR_ALREADY_CALLED } from '@/errors.js';
import { signal } from '@telegram-apps/signals';

@@ -33,6 +34,11 @@ /**

// FIXME: Signals
/**
* True if phone access is currently being requested.
*/
export const isRequestingPhoneAccess = signal(false);
let isRequestingPhoneAccess: boolean | undefined;
let isRequestingWriteAccess: boolean | undefined;
/**
* True if write access is currently being requested.
*/
export const isRequestingWriteAccess = signal(false);

@@ -128,6 +134,6 @@ /**

(options?: ExecuteWithOptions): Promise<PhoneRequestedStatus> => {
if (isRequestingPhoneAccess) {
if (isRequestingPhoneAccess()) {
throw new TypedError(ERR_ALREADY_CALLED);
}
isRequestingPhoneAccess = true;
isRequestingPhoneAccess.set(true);

@@ -137,3 +143,3 @@ return request(REQUEST_PHONE_METHOD, 'phone_requested', options)

.finally(() => {
isRequestingPhoneAccess = undefined;
isRequestingPhoneAccess.set(false);
});

@@ -150,6 +156,6 @@ }, REQUEST_PHONE_METHOD,

(options?: ExecuteWithOptions): Promise<WriteAccessRequestedStatus> => {
if (isRequestingWriteAccess) {
if (isRequestingWriteAccess()) {
throw new TypedError(ERR_ALREADY_CALLED);
}
isRequestingWriteAccess = true;
isRequestingWriteAccess.set(true);

@@ -159,5 +165,5 @@ return request(REQUEST_WRITE_ACCESS_METHOD, 'write_access_requested', options)

.finally(() => {
isRequestingWriteAccess = undefined;
isRequestingWriteAccess.set(false);
});
}, REQUEST_WRITE_ACCESS_METHOD,
);
import { describe, vi, expect, it, afterEach, beforeEach } from 'vitest';
import { dispatchMiniAppsEvent } from 'test-utils';
import { resetPackageState } from '@test-utils/reset.js';
import { resetPackageState } from '@test-utils/reset/reset.js';
import { mockPostEvent } from '@test-utils/mockPostEvent.js';

@@ -6,0 +6,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