@tma.js/sdk 2.6.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +9 -9
- package/dist/dts/composables/AsyncMountable.d.ts +44 -0
- package/dist/dts/composables/Button.d.ts +140 -0
- package/dist/dts/composables/Mountable.d.ts +43 -0
- package/dist/dts/composables/Stateful.d.ts +35 -0
- package/dist/dts/errors.d.ts +41 -0
- package/dist/dts/features/BackButton/BackButton.d.ts +96 -0
- package/dist/dts/features/BackButton/exports.d.ts +2 -0
- package/dist/dts/features/BackButton/instance.d.ts +2 -0
- package/dist/dts/features/Biometry/Biometry.d.ts +122 -0
- package/dist/dts/features/Biometry/exports.d.ts +3 -0
- package/dist/dts/features/Biometry/instance.d.ts +2 -0
- package/dist/dts/features/Biometry/types.d.ts +84 -0
- package/dist/dts/features/ClosingBehavior/ClosingBehavior.d.ts +51 -0
- package/dist/dts/features/ClosingBehavior/exports.d.ts +2 -0
- package/dist/dts/features/ClosingBehavior/instance.d.ts +2 -0
- package/dist/dts/features/CloudStorage/CloudStorage.d.ts +90 -0
- package/dist/dts/features/CloudStorage/exports.d.ts +2 -0
- package/dist/dts/features/CloudStorage/instance.d.ts +2 -0
- package/dist/dts/features/HapticFeedback/HapticFeedback.d.ts +57 -0
- package/dist/dts/features/HapticFeedback/exports.d.ts +2 -0
- package/dist/dts/features/HapticFeedback/instance.d.ts +2 -0
- package/dist/dts/features/InitData/InitData.d.ts +84 -0
- package/dist/dts/features/InitData/exports.d.ts +2 -0
- package/dist/dts/features/InitData/instance.d.ts +2 -0
- package/dist/dts/features/Invoice/Invoice.d.ts +54 -0
- package/dist/dts/features/Invoice/exports.d.ts +2 -0
- package/dist/dts/features/Invoice/instance.d.ts +2 -0
- package/dist/dts/features/LocationManager/LocationManager.d.ts +74 -0
- package/dist/dts/features/LocationManager/exports.d.ts +3 -0
- package/dist/dts/features/LocationManager/instance.d.ts +2 -0
- package/dist/dts/features/LocationManager/types.d.ts +65 -0
- package/dist/dts/features/MainButton/MainButton.d.ts +214 -0
- package/dist/dts/features/MainButton/exports.d.ts +2 -0
- package/dist/dts/features/MainButton/instance.d.ts +2 -0
- package/dist/dts/features/MiniApp/MiniApp.d.ts +192 -0
- package/dist/dts/features/MiniApp/exports.d.ts +2 -0
- package/dist/dts/features/MiniApp/instance.d.ts +2 -0
- package/dist/dts/features/Popup/Popup.d.ts +56 -0
- package/dist/dts/features/Popup/exports.d.ts +3 -0
- package/dist/dts/features/Popup/instance.d.ts +2 -0
- package/dist/dts/features/Popup/prepareParams.d.ts +9 -0
- package/dist/dts/{components → features}/Popup/types.d.ts +5 -12
- package/dist/dts/features/QrScanner/QrScanner.d.ts +132 -0
- package/dist/dts/features/QrScanner/exports.d.ts +2 -0
- package/dist/dts/features/QrScanner/instance.d.ts +2 -0
- package/dist/dts/features/SecondaryButton/SecondaryButton.d.ts +253 -0
- package/dist/dts/features/SecondaryButton/exports.d.ts +2 -0
- package/dist/dts/features/SecondaryButton/instance.d.ts +2 -0
- package/dist/dts/features/SettingsButton/SettingsButton.d.ts +96 -0
- package/dist/dts/features/SettingsButton/exports.d.ts +2 -0
- package/dist/dts/features/SettingsButton/instance.d.ts +2 -0
- package/dist/dts/features/SwipeBehavior/SwipeBehavior.d.ts +62 -0
- package/dist/dts/features/SwipeBehavior/exports.d.ts +2 -0
- package/dist/dts/features/SwipeBehavior/instance.d.ts +2 -0
- package/dist/dts/features/ThemeParams/ThemeParams.d.ts +127 -0
- package/dist/dts/features/ThemeParams/exports.d.ts +2 -0
- package/dist/dts/features/ThemeParams/instance.d.ts +2 -0
- package/dist/dts/features/Viewport/Viewport.d.ts +220 -0
- package/dist/dts/features/Viewport/exports.d.ts +2 -0
- package/dist/dts/features/Viewport/instance.d.ts +2 -0
- package/dist/dts/features/emoji-status/exports.d.ts +2 -0
- package/dist/dts/features/emoji-status/requestEmojiStatusAccess.d.ts +16 -0
- package/dist/dts/features/emoji-status/setEmojiStatus.d.ts +28 -0
- package/dist/dts/features/home-screen/addToHomeScreen.d.ts +11 -0
- package/dist/dts/features/home-screen/checkHomeScreenStatus.d.ts +14 -0
- package/dist/dts/features/home-screen/exports.d.ts +2 -0
- package/dist/dts/features/links/exports.d.ts +3 -0
- package/dist/dts/features/links/openLink.d.ts +31 -0
- package/dist/dts/features/links/openTelegramLink.d.ts +18 -0
- package/dist/dts/features/links/shareURL.d.ts +18 -0
- package/dist/dts/features/privacy/exports.d.ts +3 -0
- package/dist/dts/features/privacy/requestContact.d.ts +59 -0
- package/dist/dts/features/privacy/requestPhoneAccess.d.ts +19 -0
- package/dist/dts/features/privacy/requestWriteAccess.d.ts +14 -0
- package/dist/dts/features/uncategorized/copyTextToClipboard.d.ts +5 -0
- package/dist/dts/features/uncategorized/downloadFile.d.ts +21 -0
- package/dist/dts/features/uncategorized/exports.d.ts +11 -0
- package/dist/dts/features/uncategorized/getCurrentTime.d.ts +15 -0
- package/dist/dts/features/uncategorized/hideKeyboard.d.ts +13 -0
- package/dist/dts/features/uncategorized/readTextFromClipboard.d.ts +13 -0
- package/dist/dts/features/uncategorized/retrieveAndroidDeviceData.d.ts +6 -0
- package/dist/dts/features/uncategorized/retrieveAndroidDeviceDataFrom.d.ts +14 -0
- package/dist/dts/features/uncategorized/sendData.d.ts +20 -0
- package/dist/dts/features/uncategorized/shareMessage.d.ts +14 -0
- package/dist/dts/features/uncategorized/shareStory.d.ts +50 -0
- package/dist/dts/features/uncategorized/switchInlineQuery.d.ts +28 -0
- package/dist/dts/fn-options/bottomButtonOptions.d.ts +11 -0
- package/dist/dts/fn-options/buttonOptions.d.ts +10 -0
- package/dist/dts/fn-options/createFnOption.d.ts +2 -0
- package/dist/dts/fn-options/sharedFeatureOptions.d.ts +8 -0
- package/dist/dts/fn-options/withInvokeCustomMethod.d.ts +11 -0
- package/dist/dts/fn-options/withPostEvent.d.ts +8 -0
- package/dist/dts/fn-options/withRequest.d.ts +8 -0
- package/dist/dts/fn-options/withStateRestore.d.ts +13 -0
- package/dist/dts/fn-options/withVersion.d.ts +9 -0
- package/dist/dts/globals/createRequestId.d.ts +4 -0
- package/dist/dts/globals/inline-mode.d.ts +4 -0
- package/dist/dts/globals/invokeCustomMethod.d.ts +16 -0
- package/dist/dts/globals/post-event.d.ts +4 -0
- package/dist/dts/globals/request.d.ts +3 -0
- package/dist/dts/globals/resetGlobals.d.ts +4 -0
- package/dist/dts/globals/signals-registry.d.ts +39 -0
- package/dist/dts/globals/themeParams.d.ts +4 -0
- package/dist/dts/globals/version.d.ts +4 -0
- package/dist/dts/helpers/access.d.ts +2 -0
- package/dist/dts/helpers/component-storage.d.ts +9 -0
- package/dist/dts/helpers/createIsSupportedSignal.d.ts +5 -0
- package/dist/dts/helpers/css-vars.d.ts +11 -0
- package/dist/dts/helpers/isColorDark.d.ts +11 -0
- package/dist/dts/{navigation/isPageReload.d.ts → helpers/navigation.d.ts} +1 -1
- package/dist/dts/helpers/removeUndefined.d.ts +10 -0
- package/dist/dts/helpers/shallowEqual.d.ts +1 -0
- package/dist/dts/index.d.ts +33 -168
- package/dist/dts/init.d.ts +42 -0
- package/dist/dts/types.d.ts +6 -0
- package/dist/dts/with-checks/throwifyWithChecksFp.d.ts +3 -0
- package/dist/dts/with-checks/withChecksFp.d.ts +172 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.iife.js +3 -1
- package/dist/index.iife.js.map +1 -1
- package/dist/index.js +3824 -2925
- package/dist/index.js.map +1 -1
- package/package.json +19 -9
- package/dist/dts/bridge/events/event-emitter/createMiniAppsEventEmitter.d.ts +0 -15
- package/dist/dts/bridge/events/event-emitter/singleton.d.ts +0 -8
- package/dist/dts/bridge/events/event-handlers/cleanupEventHandlers.d.ts +0 -4
- package/dist/dts/bridge/events/event-handlers/defineEventHandlers.d.ts +0 -6
- package/dist/dts/bridge/events/event-handlers/emitMiniAppsEvent.d.ts +0 -9
- package/dist/dts/bridge/events/listening/off.d.ts +0 -8
- package/dist/dts/bridge/events/listening/on.d.ts +0 -12
- package/dist/dts/bridge/events/listening/subscribe.d.ts +0 -9
- package/dist/dts/bridge/events/listening/unsubscribe.d.ts +0 -7
- package/dist/dts/bridge/events/types.d.ts +0 -302
- package/dist/dts/bridge/methods/createPostEvent.d.ts +0 -13
- package/dist/dts/bridge/methods/postEvent.d.ts +0 -38
- package/dist/dts/bridge/methods/types/custom-methods.d.ts +0 -57
- package/dist/dts/bridge/methods/types/haptic.d.ts +0 -40
- package/dist/dts/bridge/methods/types/index.d.ts +0 -4
- package/dist/dts/bridge/methods/types/methods.d.ts +0 -392
- package/dist/dts/bridge/methods/types/popup.d.ts +0 -49
- package/dist/dts/bridge/parseMessage.d.ts +0 -18
- package/dist/dts/bridge/target-origin.d.ts +0 -13
- package/dist/dts/bridge/utils/captureSameReq.d.ts +0 -10
- package/dist/dts/bridge/utils/invokeCustomMethod.d.ts +0 -23
- package/dist/dts/bridge/utils/request.d.ts +0 -47
- package/dist/dts/classes/State/State.d.ts +0 -46
- package/dist/dts/classes/State/types.d.ts +0 -29
- package/dist/dts/classes/WithStateUtils.d.ts +0 -18
- package/dist/dts/classes/WithSupports.d.ts +0 -19
- package/dist/dts/classes/WithSupportsAndStateUtils.d.ts +0 -24
- package/dist/dts/classes/WithSupportsAndTrackableState.d.ts +0 -16
- package/dist/dts/classes/WithTrackableState.d.ts +0 -16
- package/dist/dts/classnames/classNames.d.ts +0 -12
- package/dist/dts/classnames/mergeClassNames.d.ts +0 -14
- package/dist/dts/colors/isColorDark.d.ts +0 -6
- package/dist/dts/colors/isRGB.d.ts +0 -7
- package/dist/dts/colors/isRGBShort.d.ts +0 -7
- package/dist/dts/colors/toRGB.d.ts +0 -12
- package/dist/dts/colors/types.d.ts +0 -8
- package/dist/dts/components/BackButton/BackButton.d.ts +0 -41
- package/dist/dts/components/BackButton/initBackButton.d.ts +0 -7
- package/dist/dts/components/BackButton/types.d.ts +0 -25
- package/dist/dts/components/BiometryManager/BiometryManager.d.ts +0 -61
- package/dist/dts/components/BiometryManager/formatEvent.d.ts +0 -34
- package/dist/dts/components/BiometryManager/initBiometryManager.d.ts +0 -7
- package/dist/dts/components/BiometryManager/requestBiometryInfo.d.ts +0 -8
- package/dist/dts/components/BiometryManager/types.d.ts +0 -40
- package/dist/dts/components/ClosingBehavior/ClosingBehavior.d.ts +0 -26
- package/dist/dts/components/ClosingBehavior/initClosingBehavior.d.ts +0 -7
- package/dist/dts/components/ClosingBehavior/types.d.ts +0 -20
- package/dist/dts/components/CloudStorage/CloudStorage.d.ts +0 -47
- package/dist/dts/components/CloudStorage/initCloudStorage.d.ts +0 -7
- package/dist/dts/components/HapticFeedback/HapticFeedback.d.ts +0 -34
- package/dist/dts/components/HapticFeedback/initHapticFeedback.d.ts +0 -7
- package/dist/dts/components/InitData/InitData.d.ts +0 -55
- package/dist/dts/components/InitData/initInitData.d.ts +0 -7
- package/dist/dts/components/InitData/parseInitData.d.ts +0 -7
- package/dist/dts/components/InitData/parsers/chat.d.ts +0 -3
- package/dist/dts/components/InitData/parsers/initData.d.ts +0 -7
- package/dist/dts/components/InitData/parsers/user.d.ts +0 -3
- package/dist/dts/components/InitData/types.d.ts +0 -132
- package/dist/dts/components/Invoice/Invoice.d.ts +0 -31
- package/dist/dts/components/Invoice/initInvoice.d.ts +0 -7
- package/dist/dts/components/Invoice/types.d.ts +0 -20
- package/dist/dts/components/MainButton/MainButton.d.ts +0 -106
- package/dist/dts/components/MainButton/initMainButton.d.ts +0 -7
- package/dist/dts/components/MainButton/types.d.ts +0 -40
- package/dist/dts/components/MiniApp/MiniApp.d.ts +0 -120
- package/dist/dts/components/MiniApp/initMiniApp.d.ts +0 -7
- package/dist/dts/components/MiniApp/parsing/contact.d.ts +0 -7
- package/dist/dts/components/MiniApp/types.d.ts +0 -53
- package/dist/dts/components/Popup/Popup.d.ts +0 -30
- package/dist/dts/components/Popup/initPopup.d.ts +0 -7
- package/dist/dts/components/Popup/preparePopupParams.d.ts +0 -8
- package/dist/dts/components/QRScanner/QRScanner.d.ts +0 -33
- package/dist/dts/components/QRScanner/initQRScanner.d.ts +0 -7
- package/dist/dts/components/QRScanner/types.d.ts +0 -31
- package/dist/dts/components/SettingsButton/SettingsButton.d.ts +0 -37
- package/dist/dts/components/SettingsButton/initSettingsButton.d.ts +0 -7
- package/dist/dts/components/SettingsButton/types.d.ts +0 -25
- package/dist/dts/components/ThemeParams/ThemeParams.d.ts +0 -57
- package/dist/dts/components/ThemeParams/initThemeParams.d.ts +0 -7
- package/dist/dts/components/ThemeParams/keys.d.ts +0 -11
- package/dist/dts/components/ThemeParams/parsing/parseThemeParams.d.ts +0 -7
- package/dist/dts/components/ThemeParams/parsing/serializeThemeParams.d.ts +0 -6
- package/dist/dts/components/ThemeParams/parsing/themeParams.d.ts +0 -4
- package/dist/dts/components/ThemeParams/requestThemeParams.d.ts +0 -8
- package/dist/dts/components/ThemeParams/types.d.ts +0 -29
- package/dist/dts/components/Utils/Utils.d.ts +0 -54
- package/dist/dts/components/Utils/initUtils.d.ts +0 -7
- package/dist/dts/components/Viewport/Viewport.d.ts +0 -77
- package/dist/dts/components/Viewport/initViewport.d.ts +0 -7
- package/dist/dts/components/Viewport/requestViewport.d.ts +0 -13
- package/dist/dts/components/Viewport/types.d.ts +0 -35
- package/dist/dts/css-vars/bindMiniAppCSSVars.d.ts +0 -29
- package/dist/dts/css-vars/bindThemeParamsCSSVars.d.ts +0 -29
- package/dist/dts/css-vars/bindViewportCSSVars.d.ts +0 -32
- package/dist/dts/css-vars/setCSSVar.d.ts +0 -6
- package/dist/dts/debug/debug.d.ts +0 -14
- package/dist/dts/env/hasExternalNotify.d.ts +0 -10
- package/dist/dts/env/hasWebviewProxy.d.ts +0 -10
- package/dist/dts/env/initWeb.d.ts +0 -11
- package/dist/dts/env/isIframe.d.ts +0 -5
- package/dist/dts/env/isSSR.d.ts +0 -4
- package/dist/dts/env/isTMA.d.ts +0 -4
- package/dist/dts/env/mockTelegramEnv.d.ts +0 -7
- package/dist/dts/errors/SDKError.d.ts +0 -9
- package/dist/dts/errors/createError.d.ts +0 -10
- package/dist/dts/errors/errors.d.ts +0 -49
- package/dist/dts/errors/isSDKError.d.ts +0 -7
- package/dist/dts/errors/isSDKErrorOfType.d.ts +0 -8
- package/dist/dts/events/event-emitter/EventEmitter.d.ts +0 -54
- package/dist/dts/events/event-emitter/types.d.ts +0 -45
- package/dist/dts/events/onWindow.d.ts +0 -10
- package/dist/dts/events/types.d.ts +0 -6
- package/dist/dts/index.low-level.d.ts +0 -41
- package/dist/dts/launch-params/parseLaunchParams.d.ts +0 -7
- package/dist/dts/launch-params/retrieveFromLocation.d.ts +0 -7
- package/dist/dts/launch-params/retrieveFromPerformance.d.ts +0 -7
- package/dist/dts/launch-params/retrieveFromStorage.d.ts +0 -7
- package/dist/dts/launch-params/retrieveFromUrl.d.ts +0 -8
- package/dist/dts/launch-params/retrieveLaunchParams.d.ts +0 -7
- package/dist/dts/launch-params/saveToStorage.d.ts +0 -7
- package/dist/dts/launch-params/serializeLaunchParams.d.ts +0 -7
- package/dist/dts/launch-params/types.d.ts +0 -51
- package/dist/dts/logger/Logger.d.ts +0 -29
- package/dist/dts/misc/createCleanup.d.ts +0 -11
- package/dist/dts/misc/createComponentInitFn/createComponentInitFn.d.ts +0 -16
- package/dist/dts/misc/createComponentInitFn/types.d.ts +0 -54
- package/dist/dts/misc/createSingleton.d.ts +0 -15
- package/dist/dts/misc/isRecord.d.ts +0 -5
- package/dist/dts/misc/objectFromKeys.d.ts +0 -6
- package/dist/dts/navigation/BasicNavigator/BasicNavigator.d.ts +0 -118
- package/dist/dts/navigation/BasicNavigator/prepareItem.d.ts +0 -8
- package/dist/dts/navigation/BasicNavigator/types.d.ts +0 -37
- package/dist/dts/navigation/BrowserNavigator/BrowserNavigator.d.ts +0 -198
- package/dist/dts/navigation/BrowserNavigator/basicItemToBrowser.d.ts +0 -7
- package/dist/dts/navigation/BrowserNavigator/createBrowserNavigatorFromLocation.d.ts +0 -4
- package/dist/dts/navigation/BrowserNavigator/prepareItem.d.ts +0 -25
- package/dist/dts/navigation/BrowserNavigator/types.d.ts +0 -64
- package/dist/dts/navigation/createSafeURL.d.ts +0 -7
- package/dist/dts/navigation/drop.d.ts +0 -4
- package/dist/dts/navigation/ensurePrefix.d.ts +0 -7
- package/dist/dts/navigation/getFirstNavigationEntry.d.ts +0 -6
- package/dist/dts/navigation/getHash.d.ts +0 -15
- package/dist/dts/navigation/getPathname.d.ts +0 -7
- package/dist/dts/navigation/go.d.ts +0 -5
- package/dist/dts/navigation/initNavigator.d.ts +0 -9
- package/dist/dts/navigation/urlToPath.d.ts +0 -7
- package/dist/dts/parsing/ArrayParser/ArrayParser.d.ts +0 -17
- package/dist/dts/parsing/ArrayParser/types.d.ts +0 -12
- package/dist/dts/parsing/ValueParser/ValueParser.d.ts +0 -17
- package/dist/dts/parsing/ValueParser/types.d.ts +0 -28
- package/dist/dts/parsing/createTypeError.d.ts +0 -6
- package/dist/dts/parsing/createValueParserGenerator.d.ts +0 -10
- package/dist/dts/parsing/parseBySchema.d.ts +0 -9
- package/dist/dts/parsing/parsers/array.d.ts +0 -7
- package/dist/dts/parsing/parsers/boolean.d.ts +0 -6
- package/dist/dts/parsing/parsers/date.d.ts +0 -6
- package/dist/dts/parsing/parsers/json.d.ts +0 -9
- package/dist/dts/parsing/parsers/number.d.ts +0 -6
- package/dist/dts/parsing/parsers/rgb.d.ts +0 -7
- package/dist/dts/parsing/parsers/searchParams.d.ts +0 -9
- package/dist/dts/parsing/parsers/string.d.ts +0 -6
- package/dist/dts/parsing/toRecord.d.ts +0 -7
- package/dist/dts/parsing/types.d.ts +0 -30
- package/dist/dts/request-id/createRequestIdGenerator.d.ts +0 -6
- package/dist/dts/request-id/types.d.ts +0 -9
- package/dist/dts/storage/storage.d.ts +0 -42
- package/dist/dts/supports/createSupportsFn.d.ts +0 -12
- package/dist/dts/supports/createSupportsParamFn.d.ts +0 -16
- package/dist/dts/supports/supports.d.ts +0 -16
- package/dist/dts/supports/types.d.ts +0 -4
- package/dist/dts/timeout/createTimeoutError.d.ts +0 -7
- package/dist/dts/timeout/sleep.d.ts +0 -5
- package/dist/dts/timeout/withTimeout.d.ts +0 -6
- package/dist/dts/types/index.d.ts +0 -6
- package/dist/dts/types/logical.d.ts +0 -16
- package/dist/dts/types/methods.d.ts +0 -16
- package/dist/dts/types/misc.d.ts +0 -12
- package/dist/dts/types/platform.d.ts +0 -4
- package/dist/dts/types/unions.d.ts +0 -20
- package/dist/dts/types/utils.d.ts +0 -24
- package/dist/dts/version/compareVersions.d.ts +0 -10
- package/dist/dts/version/types.d.ts +0 -5
- package/dist/index.low-level.iife.js +0 -2
- package/dist/index.low-level.iife.js.map +0 -1
package/dist/index.iife.js
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
var Cn=Object.defineProperty;var An=(o,w,v)=>w in o?Cn(o,w,{enumerable:!0,configurable:!0,writable:!0,value:v}):o[w]=v;var h=(o,w,v)=>An(o,typeof w!="symbol"?w+"":w,v);this.tmajs=this.tmajs||{};this.tmajs.sdk=function(o){"use strict";function w(e,t){let n;const s=()=>{n!==void 0&&t&&t(n),n=void 0};return[()=>n===void 0?n=e(s):n,s]}function v(e){const t=W(),{count:n}=t;t.unsubscribe(e),n&&!t.count&&De()}function yt(e){return W().subscribe(e),()=>v(e)}class Se{constructor(t,n={}){this.scope=t,this.options=n}print(t,...n){const s=new Date,i=Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3,timeZone:"UTC"}).format(s),{textColor:r,bgColor:a}=this.options,c="font-weight: bold;padding: 0 5px;border-radius:5px";console[t](`%c${i}%c / %c${this.scope}`,`${c};background-color: lightblue;color:black`,"",`${c};${r?`color:${r};`:""}${a?`background-color:${a}`:""}`,...n)}error(...t){this.print("error",...t)}log(...t){this.print("log",...t)}}const j=new Se("SDK",{bgColor:"forestgreen",textColor:"white"});let z=!1;const Et=({name:e,payload:t})=>{j.log("Event received:",t?{name:e,payload:t}:{name:e})};function Pe(e){z!==e&&(z=e,e?yt(Et):v(Et))}function Re(...e){z&&j.log(...e)}class R{constructor(){h(this,"listeners",new Map);h(this,"listenersCount",0);h(this,"subscribeListeners",[])}clear(){this.listeners.clear(),this.subscribeListeners=[]}get count(){return this.listenersCount+this.subscribeListeners.length}emit(t,...n){this.subscribeListeners.forEach(i=>i({event:t,args:n})),(this.listeners.get(t)||[]).forEach(([i,r])=>{i(...n),r&&this.off(t,i)})}on(t,n,s){let i=this.listeners.get(t);return i||this.listeners.set(t,i=[]),i.push([n,s]),this.listenersCount+=1,()=>this.off(t,n)}off(t,n){const s=this.listeners.get(t)||[];for(let i=0;i<s.length;i+=1)if(n===s[i][0]){s.splice(i,1),this.listenersCount-=1;return}}subscribe(t){return this.subscribeListeners.push(t),()=>this.unsubscribe(t)}unsubscribe(t){for(let n=0;n<this.subscribeListeners.length;n+=1)if(this.subscribeListeners[n]===t){this.subscribeListeners.splice(n,1);return}}}function F(e,t,n){return window.addEventListener(e,t,n),()=>window.removeEventListener(e,t,n)}function J(...e){let t=!1;const n=[...e];return[s=>!t&&n.push(s),()=>{t||(t=!0,n.forEach(s=>s()))},t]}class N extends Error{constructor(t,n,s){super(n,{cause:s}),this.type=t,Object.setPrototypeOf(this,N.prototype)}}function g(e,t,n){return new N(e,t,n)}const vt="ERR_METHOD_UNSUPPORTED",St="ERR_METHOD_PARAMETER_UNSUPPORTED",Pt="ERR_UNKNOWN_ENV",Rt="ERR_INVOKE_CUSTOM_METHOD_RESPONSE",Tt="ERR_TIMED_OUT",Ct="ERR_UNEXPECTED_TYPE",Y="ERR_PARSE",At="ERR_NAVIGATION_LIST_EMPTY",It="ERR_NAVIGATION_CURSOR_INVALID",Te="ERR_NAVIGATION_ITEM_INVALID",Ce="ERR_SSR_INIT",Nt="ERR_INVALID_PATH_BASE";function T(){return g(Ct,"Value has unexpected type")}class U{constructor(t,n,s){this.parser=t,this.isOptional=n,this.type=s}parse(t){if(!(this.isOptional&&t===void 0))try{return this.parser(t)}catch(n){throw g(Y,`Unable to parse value${this.type?` as ${this.type}`:""}`,n)}}optional(){return this.isOptional=!0,this}}function C(e,t){return()=>new U(e,!1,t)}const y=C(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;throw T()},"boolean");function qt(e,t){const n={};for(const s in e){const i=e[s];if(!i)continue;let r,a;if(typeof i=="function"||"parse"in i)r=s,a=typeof i=="function"?i:i.parse.bind(i);else{const{type:c}=i;r=i.from||s,a=typeof c=="function"?c:c.parse.bind(c)}try{const c=a(t(r));c!==void 0&&(n[s]=c)}catch(c){throw g(Y,`Unable to parse field "${s}"`,c)}}return n}function K(e){let t=e;if(typeof t=="string"&&(t=JSON.parse(t)),typeof t!="object"||t===null||Array.isArray(t))throw T();return t}function d(e,t){return new U(n=>{const s=K(n);return qt(e,i=>s[i])},!1,t)}const S=C(e=>{if(typeof e=="number")return e;if(typeof e=="string"){const t=Number(e);if(!Number.isNaN(t))return t}throw T()},"number");function $(e){return/^#[\da-f]{6}$/i.test(e)}function kt(e){return/^#[\da-f]{3}$/i.test(e)}function Q(e){const t=e.replace(/\s/g,"").toLowerCase();if($(t))return t;if(kt(t)){let s="#";for(let i=0;i<3;i+=1)s+=t[1+i].repeat(2);return s}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((s,i)=>{const r=parseInt(i,10).toString(16);return s+(r.length===1?"0":"")+r},"#")}const u=C(e=>{if(typeof e=="string"||typeof e=="number")return e.toString();throw T()},"string"),X=C(e=>Q(u().parse(e)),"rgb");function Dt(e){return d({eventType:u(),eventData:t=>t}).parse(e)}function Ae(){["TelegramGameProxy_receiveEvent","TelegramGameProxy","Telegram"].forEach(e=>{delete window[e]})}function Z(e,t){window.dispatchEvent(new MessageEvent("message",{data:JSON.stringify({eventType:e,eventData:t}),source:window.parent}))}function Ie(){[["TelegramGameProxy_receiveEvent"],["TelegramGameProxy","receiveEvent"],["Telegram","WebView","receiveEvent"]].forEach(e=>{let t=window;e.forEach((n,s,i)=>{if(s===i.length-1){t[n]=Z;return}n in t||(t[n]={}),t=t[n]})})}const Ne={clipboard_text_received:d({req_id:u(),data:e=>e===null?e:u().optional().parse(e)}),custom_method_invoked:d({req_id:u(),result:e=>e,error:u().optional()}),invoice_closed:d({slug:u(),status:u()}),phone_requested:d({status:u()}),popup_closed:{parse(e){return d({button_id:t=>t==null?void 0:u().parse(t)}).parse(e??{})}},qr_text_received:d({data:u().optional()}),theme_changed:d({theme_params:e=>{const t=X().optional();return Object.entries(K(e)).reduce((n,[s,i])=>(n[s]=t.parse(i),n),{})}}),viewport_changed:d({height:S(),width:e=>e==null?window.innerWidth:S().parse(e),is_state_stable:y(),is_expanded:y()}),write_access_requested:d({status:u()})};function qe(){const e=new R,t=new R;t.subscribe(s=>{e.emit("event",{name:s.event,payload:s.args[0]})}),Ie();const[,n]=J(Ae,F("resize",()=>{t.emit("viewport_changed",{width:window.innerWidth,height:window.innerHeight,is_state_stable:!0,is_expanded:!0})}),F("message",s=>{if(s.source!==window.parent)return;let i;try{i=Dt(s.data)}catch{return}const{eventType:r,eventData:a}=i,c=Ne[r];try{const p=c?c.parse(a):a;t.emit(...p?[r,p]:[r])}catch(p){j.error(`An error occurred processing the "${r}" event from the Telegram application. Please, file an issue here: https://github.com/Telegram-Mini-Apps/tma.js/issues/new/choose`,i,p)}}),()=>e.clear(),()=>t.clear());return[{on:t.on.bind(t),off:t.off.bind(t),subscribe(s){return e.on("event",s)},unsubscribe(s){e.off("event",s)},get count(){return t.count+e.count}},n]}const[ke,De]=w(e=>{const[t,n]=qe(),s=t.off.bind(t);return t.off=(i,r)=>{const{count:a}=t;s(i,r),a&&!t.count&&e()},[t,n]},([,e])=>e());function W(){return ke()[0]}function q(e,t){W().off(e,t)}function m(e,t,n){return W().on(e,t,n)}function k(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Mt(e,t){const n=e.split("."),s=t.split("."),i=Math.max(n.length,s.length);for(let r=0;r<i;r+=1){const a=parseInt(n[r]||"0",10),c=parseInt(s[r]||"0",10);if(a!==c)return a>c?1:-1}return 0}function b(e,t){return Mt(e,t)<=0}function P(e,t,n){if(typeof n=="string"){if(e==="web_app_open_link"){if(t==="try_instant_view")return b("6.4",n);if(t==="try_browser")return b("7.6",n)}if(e==="web_app_set_header_color"&&t==="color")return b("6.9",n);if(e==="web_app_close"&&t==="return_back")return b("7.6",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 b("6.1",t);case"web_app_open_popup":return b("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 b("6.4",t);case"web_app_switch_inline_query":return b("6.7",t);case"web_app_invoke_custom_method":case"web_app_request_write_access":case"web_app_request_phone":return b("6.9",t);case"web_app_setup_settings_button":return b("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 b("7.2",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 Vt(e){return"external"in e&&k(e.external)&&"notify"in e.external&&typeof e.external.notify=="function"}function Bt(e){return"TelegramWebviewProxy"in e&&k(e.TelegramWebviewProxy)&&"postEvent"in e.TelegramWebviewProxy&&typeof e.TelegramWebviewProxy.postEvent=="function"}function tt(){try{return window.self!==window.top}catch{return!0}}let Lt="https://web.telegram.org";function Me(e){Lt=e}function Ot(){return Lt}function A(e,t,n){let s={},i;t===void 0&&n===void 0?s={}:t!==void 0&&n!==void 0?(s=n,i=t):t!==void 0&&("targetOrigin"in t?s=t:i=t);const{targetOrigin:r=Ot()}=s;if(Re("Posting event:",i?{event:e,data:i}:{event:e}),tt()){window.parent.postMessage(JSON.stringify({eventType:e,eventData:i}),r);return}if(Vt(window)){window.external.notify(JSON.stringify({eventType:e,eventData:i}));return}if(Bt(window)){window.TelegramWebviewProxy.postEvent(e,JSON.stringify(i));return}throw g(Pt,"Unable to determine current environment and possible way to send event. You are probably trying to use Mini Apps method outside of Telegram application environment.")}function Ut(e){return(t,n)=>{if(!P(t,e))throw g(vt,`Method "${t}" is unsupported in Mini Apps version ${e}`);if(k(n)){let s;if(t==="web_app_open_link"&&"try_instant_view"in n?s="try_instant_view":t==="web_app_set_header_color"&&"color"in n&&(s="color"),s&&!P(t,s,e))throw g(St,`Parameter "${s}" of "${t}" method is unsupported in Mini Apps version ${e}`)}return A(t,n)}}function et(e){return({req_id:t})=>t===e}function $t(e){return g(Tt,`Timeout reached: ${e}ms`)}function nt(e,t){return Promise.race([typeof e=="function"?e():e,new Promise((n,s)=>{setTimeout(()=>{s($t(t))},t)})])}async function _(e){let t;const n=new Promise(c=>{t=c}),{event:s,capture:i,timeout:r}=e,[,a]=J(...(Array.isArray(s)?s:[s]).map(c=>m(c,p=>(!i||i(p))&&t(p))));try{return(e.postEvent||A)(e.method,e.params),await(r?nt(n,r):n)}finally{a()}}async function I(e,t,n,s={}){const{result:i,error:r}=await _({...s,method:"web_app_invoke_custom_method",event:"custom_method_invoked",params:{method:e,params:t,req_id:n},capture:et(n)});if(r)throw g(Rt,r);return i}function H(...e){return e.map(t=>{if(typeof t=="string")return t;if(k(t))return H(Object.entries(t).map(n=>n[1]&&n[0]));if(Array.isArray(t))return H(...t)}).filter(Boolean).join(" ")}function Ve(...e){return e.reduce((t,n)=>(k(n)&&Object.entries(n).forEach(([s,i])=>{const r=H(t[s],i);r.length&&(t[s]=r)}),t),{})}function st(e){const t=Q(e);return Math.sqrt([.299,.587,.114].reduce((n,s,i)=>{const r=parseInt(t.slice(1+i*2,1+(i+1)*2),16);return n+r*r*s},0))<120}class Be{constructor(t){h(this,"ee",new R);h(this,"on",this.ee.on.bind(this.ee));h(this,"off",this.ee.off.bind(this.ee));this.state=t}clone(){return{...this.state}}set(t,n){Object.entries(typeof t=="string"?{[t]:n}:t).reduce((i,[r,a])=>this.state[r]===a||a===void 0?i:(this.state[r]=a,this.ee.emit(`change:${r}`,a),!0),!1)&&this.ee.emit("change",this.state)}get(t){return this.state[t]}}class it{constructor(t){h(this,"state");h(this,"get");h(this,"set");h(this,"clone");this.state=new Be(t),this.set=this.state.set.bind(this.state),this.get=this.state.get.bind(this.state),this.clone=this.state.clone.bind(this.state)}}function Wt(e,t){return n=>P(t[n],e)}class rt extends it{constructor(n,s,i){super(n);h(this,"supports");this.supports=Wt(s,i)}}class Ht extends rt{constructor(n,s,i){super({isVisible:n},s,{show:"web_app_setup_back_button",hide:"web_app_setup_back_button"});h(this,"on",(n,s)=>n==="click"?m("back_button_pressed",s):this.state.on(n,s));h(this,"off",(n,s)=>n==="click"?q("back_button_pressed",s):this.state.off(n,s));this.postEvent=i}set isVisible(n){this.set("isVisible",n),this.postEvent("web_app_setup_back_button",{is_visible:n})}get isVisible(){return this.get("isVisible")}hide(){this.isVisible=!1}show(){this.isVisible=!0}}const ot=C(e=>e instanceof Date?e:new Date(S().parse(e)*1e3),"Date");function x(e,t){return new U(n=>{if(typeof n!="string"&&!(n instanceof URLSearchParams))throw T();const s=typeof n=="string"?new URLSearchParams(n):n;return qt(e,i=>{const r=s.get(i);return r===null?void 0:r})},!1,t)}const Le=d({id:S(),type:u(),title:u(),photoUrl:{type:u().optional(),from:"photo_url"},username:u().optional()},"Chat").optional(),xt=d({addedToAttachmentMenu:{type:y().optional(),from:"added_to_attachment_menu"},allowsWriteToPm:{type:y().optional(),from:"allows_write_to_pm"},firstName:{type:u(),from:"first_name"},id:S(),isBot:{type:y().optional(),from:"is_bot"},isPremium:{type:y().optional(),from:"is_premium"},languageCode:{type:u().optional(),from:"language_code"},lastName:{type:u().optional(),from:"last_name"},photoUrl:{type:u().optional(),from:"photo_url"},username:u().optional()},"User").optional();function Gt(){return x({authDate:{type:ot(),from:"auth_date"},canSendAfter:{type:S().optional(),from:"can_send_after"},chat:Le,chatInstance:{type:u().optional(),from:"chat_instance"},chatType:{type:u().optional(),from:"chat_type"},hash:u(),queryId:{type:u().optional(),from:"query_id"},receiver:xt,startParam:{type:u().optional(),from:"start_param"},user:xt},"InitData")}function Oe(e){return e.replace(/_[a-z]/g,t=>t[1].toUpperCase())}function Ue(e){return e.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`)}const jt=C(e=>{const t=X().optional();return Object.entries(K(e)).reduce((n,[s,i])=>(n[Oe(s)]=t.parse(i),n),{})},"ThemeParams");function G(e){return x({botInline:{type:y().optional(),from:"tgWebAppBotInline"},initData:{type:Gt().optional(),from:"tgWebAppData"},initDataRaw:{type:u().optional(),from:"tgWebAppData"},platform:{type:u(),from:"tgWebAppPlatform"},showSettings:{type:y().optional(),from:"tgWebAppShowSettings"},startParam:{type:u().optional(),from:"tgWebAppStartParam"},themeParams:{type:jt(),from:"tgWebAppThemeParams"},version:{type:u(),from:"tgWebAppVersion"}}).parse(e)}function zt(e){return G(e.replace(/^[^?#]*[?#]/,"").replace(/[?#]/g,"&"))}function $e(){return zt(window.location.href)}function Ft(){return performance.getEntriesByType("navigation")[0]}function We(){const e=Ft();if(!e)throw new Error("Unable to get first navigation entry.");return zt(e.name)}function Jt(e){return`tma.js/${e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}`}function Yt(e,t){sessionStorage.setItem(Jt(e),JSON.stringify(t))}function Kt(e){const t=sessionStorage.getItem(Jt(e));try{return t?JSON.parse(t):void 0}catch{}}function He(){return G(Kt("launchParams")||"")}function at(e){return JSON.stringify(Object.fromEntries(Object.entries(e).map(([t,n])=>[Ue(t),n])))}function Qt(e){const{initDataRaw:t,themeParams:n,platform:s,version:i,showSettings:r,startParam:a,botInline:c}=e,p=new URLSearchParams;return p.set("tgWebAppPlatform",s),p.set("tgWebAppThemeParams",at(n)),p.set("tgWebAppVersion",i),t&&p.set("tgWebAppData",t),a&&p.set("tgWebAppStartParam",a),typeof r=="boolean"&&p.set("tgWebAppShowSettings",r?"1":"0"),typeof c=="boolean"&&p.set("tgWebAppBotInline",c?"1":"0"),p.toString()}function Xt(e){Yt("launchParams",Qt(e))}function Zt(){for(const e of[$e,We,He])try{const t=e();return Xt(t),t}catch{}throw new Error("Unable to retrieve launch parameters from any known source.")}function ct(){const e=Ft();return!!(e&&e.type==="reload")}function xe(){let e=0;return()=>(e+=1).toString()}const[Ge]=w(xe);function f(e,t){return()=>{const n=Zt(),s={...n,postEvent:Ut(n.version),createRequestId:Ge()};if(typeof e=="function")return e(s);const[i,r,a]=J(),c=t({...s,state:ct()?Kt(e):void 0,addCleanup:i}),p=l=>(a||i(l.on("change",Tn=>{Yt(e,Tn)})),l);return[c instanceof Promise?c.then(p):p(c),r]}}const je=f("backButton",({postEvent:e,version:t,state:n={isVisible:!1}})=>new Ht(n.isVisible,t,e));class D extends rt{constructor(){super(...arguments);h(this,"on",this.state.on.bind(this.state));h(this,"off",this.state.off.bind(this.state))}}function te(e){const t=e.available?e:{available:!1,device_id:"",token_saved:!1,access_requested:!1,access_granted:!1,type:""};return{available:!0,type:t.type,deviceId:t.device_id,tokenSaved:t.token_saved,accessRequested:t.access_requested,accessGranted:t.access_granted}}class ee extends D{constructor({postEvent:n,version:s,...i}){super(i,s,{auth:"web_app_biometry_request_auth",openSettings:"web_app_biometry_open_settings",requestAccess:"web_app_biometry_request_access",updateToken:"web_app_biometry_update_token"});h(this,"postEvent");h(this,"authPromise");h(this,"accessPromise");this.postEvent=n}get available(){return this.get("available")}get accessGranted(){return this.get("accessGranted")}get accessRequested(){return this.get("accessRequested")}async authenticate({reason:n,...s}){return this.authPromise||(this.authPromise=_({...s,method:"web_app_biometry_request_auth",event:"biometry_auth_requested",postEvent:this.postEvent,params:{reason:(n||"").trim()}}).then(({token:i})=>i).finally(()=>this.authPromise=void 0)),this.authPromise}get deviceId(){return this.get("deviceId")}openSettings(){this.postEvent("web_app_biometry_open_settings")}requestAccess({reason:n,...s}={}){return this.accessPromise||(this.accessPromise=_({...s,postEvent:this.postEvent,method:"web_app_biometry_request_access",event:"biometry_info_received",params:{reason:n||""}}).then(i=>{const r=te(i);return this.set(r),r.accessGranted}).finally(()=>this.accessPromise=void 0)),this.accessPromise}get biometryType(){return this.get("biometryType")}get tokenSaved(){return this.get("tokenSaved")}async updateToken({token:n,...s}={}){return["removed","updated"].includes((await _({...s,postEvent:this.postEvent,method:"web_app_biometry_update_token",event:"biometry_token_updated",params:{token:n||""}})).status)}}async function ne(e){return te(await _({...e||{},method:"web_app_biometry_get_info",event:"biometry_info_received"}))}const ze=f("biometryManager",async({postEvent:e,version:t,state:n})=>new ee({...n||P("web_app_biometry_get_info",t)?n||await ne({timeout:1e3}):{available:!1,accessGranted:!1,accessRequested:!1,tokenSaved:!1,deviceId:""},version:t,postEvent:e}));class ht extends it{constructor(){super(...arguments);h(this,"on",this.state.on.bind(this.state));h(this,"off",this.state.off.bind(this.state))}}class se extends ht{constructor(t,n){super({isConfirmationNeeded:t}),this.postEvent=n}set isConfirmationNeeded(t){this.set("isConfirmationNeeded",t),this.postEvent("web_app_setup_closing_behavior",{need_confirmation:t})}get isConfirmationNeeded(){return this.get("isConfirmationNeeded")}disableConfirmation(){this.isConfirmationNeeded=!1}enableConfirmation(){this.isConfirmationNeeded=!0}}const Fe=f("closingBehavior",({postEvent:e,state:t={isConfirmationNeeded:!1}})=>new se(t.isConfirmationNeeded,e));class ut{constructor(t,n){h(this,"supports");this.supports=Wt(t,n)}}function Je(e){if(Array.isArray(e))return e;if(typeof e=="string")try{const t=JSON.parse(e);if(Array.isArray(t))return t}catch{}throw T()}class Ye extends U{constructor(n,s,i){super(Je,s,i);h(this,"itemParser");this.itemParser=typeof n=="function"?n:n.parse.bind(n)}parse(n){const s=super.parse(n);return s===void 0?s:s.map(this.itemParser)}of(n){return this.itemParser=typeof n=="function"?n:n.parse.bind(n),this}}function ie(e){return new Ye(t=>t,!1,e)}function re(e,t){return Object.fromEntries(e.map(n=>[n,t]))}class oe extends ut{constructor(t,n,s){super(t,{delete:"web_app_invoke_custom_method",get:"web_app_invoke_custom_method",getKeys:"web_app_invoke_custom_method",set:"web_app_invoke_custom_method"}),this.createRequestId=n,this.postEvent=s}async delete(t,n={}){const s=Array.isArray(t)?t:[t];s.length&&await I("deleteStorageValues",{keys:s},this.createRequestId(),{...n,postEvent:this.postEvent})}async getKeys(t={}){return ie().of(u()).parse(await I("getStorageKeys",{},this.createRequestId(),{...t,postEvent:this.postEvent}))}async get(t,n={}){const s=Array.isArray(t)?t:[t];if(!s.length)return re(s,"");const i=await I("getStorageValues",{keys:s},this.createRequestId(),{...n,postEvent:this.postEvent}),r=d(re(s,u()),"CloudStorageData").parse(i);return Array.isArray(t)?r:r[t]}async set(t,n,s={}){await I("saveStorageValue",{key:t,value:n},this.createRequestId(),{...s,postEvent:this.postEvent})}}const Ke=f(({createRequestId:e,postEvent:t,version:n})=>new oe(n,e,t));class ae extends ut{constructor(t,n){super(t,{impactOccurred:"web_app_trigger_haptic_feedback",notificationOccurred:"web_app_trigger_haptic_feedback",selectionChanged:"web_app_trigger_haptic_feedback"}),this.postEvent=n}impactOccurred(t){this.postEvent("web_app_trigger_haptic_feedback",{type:"impact",impact_style:t})}notificationOccurred(t){this.postEvent("web_app_trigger_haptic_feedback",{type:"notification",notification_type:t})}selectionChanged(){this.postEvent("web_app_trigger_haptic_feedback",{type:"selection_change"})}}const Qe=f(({version:e,postEvent:t})=>new ae(e,t));class ce{constructor(t){this.initData=t}get authDate(){return this.initData.authDate}get canSendAfter(){return this.initData.canSendAfter}get canSendAfterDate(){const{canSendAfter:t}=this;return t?new Date(this.authDate.getTime()+t*1e3):void 0}get chat(){return this.initData.chat}get chatType(){return this.initData.chatType}get chatInstance(){return this.initData.chatInstance}get hash(){return this.initData.hash}get queryId(){return this.initData.queryId}get receiver(){return this.initData.receiver}get startParam(){return this.initData.startParam}get user(){return this.initData.user}}const Xe=f(({initData:e})=>e?new ce(e):void 0);function Ze(e){return Gt().parse(e)}class he extends D{constructor(t,n,s){super({isOpened:t},n,{open:"web_app_open_invoice"}),this.postEvent=s}set isOpened(t){this.set("isOpened",t)}get isOpened(){return this.get("isOpened")}async open(t,n){if(this.isOpened)throw new Error("Invoice is already opened");let s;if(!n)s=t;else{const{hostname:i,pathname:r}=new URL(t,window.location.href);if(i!=="t.me")throw new Error(`Incorrect hostname: ${i}`);const a=r.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);if(!a)throw new Error('Link pathname has incorrect format. Expected to receive "/invoice/{slug}" or "/${slug}"');[,,s]=a}this.isOpened=!0;try{return(await _({method:"web_app_open_invoice",event:"invoice_closed",params:{slug:s},postEvent:this.postEvent,capture(r){return s===r.slug}})).status}finally{this.isOpened=!1}}}const tn=f(({version:e,postEvent:t})=>new he(!1,e,t));class ue extends it{constructor({postEvent:n,...s}){super(s);h(this,"postEvent");h(this,"on",(n,s)=>n==="click"?m("main_button_pressed",s):this.state.on(n,s));h(this,"off",(n,s)=>n==="click"?q("main_button_pressed",s):this.state.off(n,s));this.postEvent=n}get bgColor(){return this.get("bgColor")}commit(){this.text!==""&&this.postEvent("web_app_setup_main_button",{is_visible:this.isVisible,is_active:this.isEnabled,is_progress_visible:this.isLoaderVisible,text:this.text,color:this.bgColor,text_color:this.textColor})}disable(){return this.isEnabled=!1,this}enable(){return this.isEnabled=!0,this}hide(){return this.isVisible=!1,this}hideLoader(){return this.isLoaderVisible=!1,this}set isEnabled(n){this.setParams({isEnabled:n})}get isEnabled(){return this.get("isEnabled")}set isLoaderVisible(n){this.setParams({isLoaderVisible:n})}get isLoaderVisible(){return this.get("isLoaderVisible")}set isVisible(n){this.setParams({isVisible:n})}get isVisible(){return this.get("isVisible")}show(){return this.isVisible=!0,this}showLoader(){return this.isLoaderVisible=!0,this}setText(n){return this.setParams({text:n})}setTextColor(n){return this.setParams({textColor:n})}setBgColor(n){return this.setParams({bgColor:n})}setParams(n){return this.set(n),this.commit(),this}get text(){return this.get("text")}get textColor(){return this.get("textColor")}}const en=f("mainButton",({postEvent:e,themeParams:t,state:n={isVisible:!1,isEnabled:!1,text:"",isLoaderVisible:!1,textColor:t.buttonTextColor||"#ffffff",bgColor:t.buttonColor||"#000000"}})=>new ue({...n,postEvent:e}));function nn(){return x({contact:d({userId:{type:S(),from:"user_id"},phoneNumber:{type:u(),from:"phone_number"},firstName:{type:u(),from:"first_name"},lastName:{type:u().optional(),from:"last_name"}}),authDate:{type:ot(),from:"auth_date"},hash:u()},"RequestedContact")}function pe(e,t){return n=>{const[s,i]=t[n];return P(s,i,e)}}function sn(e){return new Promise(t=>{setTimeout(t,e)})}class le extends D{constructor({postEvent:n,createRequestId:s,version:i,botInline:r,...a}){super(a,i,{requestPhoneAccess:"web_app_request_phone",requestWriteAccess:"web_app_request_write_access",switchInlineQuery:"web_app_switch_inline_query",setHeaderColor:"web_app_set_header_color",setBackgroundColor:"web_app_set_background_color"});h(this,"botInline");h(this,"postEvent");h(this,"createRequestId");h(this,"requestPhoneAccessPromise");h(this,"requestWriteAccessPromise");h(this,"supportsParam");this.createRequestId=s,this.postEvent=n,this.botInline=r;const c=this.supports.bind(this);this.supports=p=>c(p)?p!=="switchInlineQuery"||r:!1,this.supportsParam=pe(i,{"setHeaderColor.color":["web_app_set_header_color","color"]})}async getRequestedContact({timeout:n=1e4}={}){return nn().parse(await I("getRequestedContact",{},this.createRequestId(),{postEvent:this.postEvent,timeout:n}))}get bgColor(){return this.get("bgColor")}close(){this.postEvent("web_app_close")}get headerColor(){return this.get("headerColor")}get isBotInline(){return this.botInline}get isDark(){return st(this.bgColor)}ready(){this.postEvent("web_app_ready")}async requestContact({timeout:n=5e3}={}){try{return await this.getRequestedContact()}catch{}if(await this.requestPhoneAccess()!=="sent")throw new Error("Access denied.");const i=Date.now()+n;let r=50;return nt(async()=>{for(;Date.now()<i;){try{return await this.getRequestedContact()}catch{}await sn(r),r+=50}throw $t(n)},n)}async requestPhoneAccess(n={}){return this.requestPhoneAccessPromise||(this.requestPhoneAccessPromise=_({...n,method:"web_app_request_phone",event:"phone_requested",postEvent:this.postEvent}).then(({status:s})=>s).finally(()=>this.requestPhoneAccessPromise=void 0)),this.requestPhoneAccessPromise}async requestWriteAccess(n={}){return this.requestWriteAccessPromise||(this.requestWriteAccessPromise=_({...n,method:"web_app_request_write_access",event:"write_access_requested",postEvent:this.postEvent}).then(({status:s})=>s).finally(()=>this.requestWriteAccessPromise=void 0)),this.requestWriteAccessPromise}sendData(n){const{size:s}=new Blob([n]);if(!s||s>4096)throw new Error(`Passed data has incorrect size: ${s}`);this.postEvent("web_app_data_send",{data:n})}setHeaderColor(n){this.postEvent("web_app_set_header_color",$(n)?{color:n}:{color_key:n}),this.set("headerColor",n)}setBgColor(n){this.postEvent("web_app_set_background_color",{color:n}),this.set("bgColor",n)}switchInlineQuery(n,s=[]){if(!this.supports("switchInlineQuery")&&!this.isBotInline)throw new Error("Method is unsupported because Mini App should be launched in inline mode.");this.postEvent("web_app_switch_inline_query",{query:n,chat_types:s})}}const rn=f("miniApp",({themeParams:e,botInline:t=!1,state:n={bgColor:e.bgColor||"#ffffff",headerColor:e.headerBgColor||"#000000"},...s})=>new le({...s,...n,botInline:t}));function on(e){const t=e.message.trim(),n=(e.title||"").trim(),s=e.buttons||[];let i;if(n.length>64)throw new Error(`Title has incorrect size: ${n.length}`);if(!t.length||t.length>256)throw new Error(`Message has incorrect size: ${t.length}`);if(s.length>3)throw new Error(`Buttons have incorrect size: ${s.length}`);return s.length?i=s.map(r=>{const{id:a=""}=r;if(a.length>64)throw new Error(`Button ID has incorrect size: ${a}`);if(!r.type||r.type==="default"||r.type==="destructive"){const c=r.text.trim();if(!c.length||c.length>64){const p=r.type||"default";throw new Error(`Button text with type "${p}" has incorrect size: ${r.text.length}`)}return{...r,text:c,id:a}}return{...r,id:a}}):i=[{type:"close",id:""}],{title:n,message:t,buttons:i}}class de extends D{constructor(t,n,s){super({isOpened:t},n,{open:"web_app_open_popup"}),this.postEvent=s}set isOpened(t){this.set("isOpened",t)}get isOpened(){return this.get("isOpened")}async open(t){if(this.isOpened)throw new Error("Popup is already opened.");this.isOpened=!0;try{const{button_id:n=null}=await _({event:"popup_closed",method:"web_app_open_popup",postEvent:this.postEvent,params:on(t)});return n}finally{this.isOpened=!1}}}const an=f(({postEvent:e,version:t})=>new de(!1,t,e));class _e extends D{constructor(t,n,s){super({isOpened:t},n,{close:"web_app_close_scan_qr_popup",open:"web_app_open_scan_qr_popup"}),this.postEvent=s}close(){this.postEvent("web_app_close_scan_qr_popup"),this.isOpened=!1}set isOpened(t){this.set("isOpened",t)}get isOpened(){return this.get("isOpened")}async open(t){if(this.isOpened)throw new Error("The scanner is already opened");const{text:n,capture:s}=(typeof t=="string"?{text:t}:t)||{};this.isOpened=!0;try{const r=(await _({method:"web_app_open_scan_qr_popup",event:["qr_text_received","scan_qr_popup_closed"],postEvent:this.postEvent,params:{text:n},capture(a){return a.event==="scan_qr_popup_closed"||!s||s(a.payload)}})||{}).data||null;return r&&this.close(),r}finally{this.isOpened=!1}}}const cn=f(({version:e,postEvent:t})=>new _e(!1,e,t));class fe extends rt{constructor(n,s,i){super({isVisible:n},s,{show:"web_app_setup_settings_button",hide:"web_app_setup_settings_button"});h(this,"on",(n,s)=>n==="click"?m("settings_button_pressed",s):this.state.on(n,s));h(this,"off",(n,s)=>n==="click"?q("settings_button_pressed",s):this.state.off(n,s));this.postEvent=i}set isVisible(n){this.set("isVisible",n),this.postEvent("web_app_setup_settings_button",{is_visible:n})}get isVisible(){return this.get("isVisible")}hide(){this.isVisible=!1}show(){this.isVisible=!0}}const hn=f("settingsButton",({version:e,postEvent:t,state:n={isVisible:!1}})=>new fe(n.isVisible,e,t));function pt(e){return jt().parse(e)}class ge extends ht{get accentTextColor(){return this.get("accentTextColor")}get bgColor(){return this.get("bgColor")}get buttonColor(){return this.get("buttonColor")}get buttonTextColor(){return this.get("buttonTextColor")}get destructiveTextColor(){return this.get("destructiveTextColor")}getState(){return this.clone()}get headerBgColor(){return this.get("headerBgColor")}get hintColor(){return this.get("hintColor")}get isDark(){return!this.bgColor||st(this.bgColor)}get linkColor(){return this.get("linkColor")}get secondaryBgColor(){return this.get("secondaryBgColor")}get sectionBgColor(){return this.get("sectionBgColor")}get sectionHeaderTextColor(){return this.get("sectionHeaderTextColor")}get sectionSeparatorColor(){return this.get("sectionHeaderTextColor")}listen(){return m("theme_changed",t=>{this.set(pt(t.theme_params))})}get subtitleTextColor(){return this.get("subtitleTextColor")}get textColor(){return this.get("textColor")}}const un=f("themeParams",({themeParams:e,state:t=e,addCleanup:n})=>{const s=new ge(t);return n(s.listen()),s});function pn(e={}){return _({...e,method:"web_app_request_theme",event:"theme_changed"}).then(pt)}class be extends ut{constructor(n,s,i){super(n,{readTextFromClipboard:"web_app_read_text_from_clipboard"});h(this,"supportsParam");this.version=n,this.createRequestId=s,this.postEvent=i,this.supportsParam=pe(n,{"openLink.tryInstantView":["web_app_open_link","try_instant_view"]})}openLink(n,s){const i=new URL(n,window.location.href).toString();if(!P("web_app_open_link",this.version)){window.open(i,"_blank");return}this.postEvent("web_app_open_link",{url:i,...typeof s=="boolean"?{try_instant_view:s}:{}})}openTelegramLink(n){const{hostname:s,pathname:i,search:r}=new URL(n,"https://t.me");if(s!=="t.me")throw new Error(`URL has not allowed hostname: ${s}. Only "t.me" is allowed`);if(!P("web_app_open_tg_link",this.version)){window.location.href=n;return}this.postEvent("web_app_open_tg_link",{path_full:i+r})}async readTextFromClipboard(){const n=this.createRequestId(),{data:s=null}=await _({method:"web_app_read_text_from_clipboard",event:"clipboard_text_received",postEvent:this.postEvent,params:{req_id:n},capture:et(n)});return s}shareURL(n,s){this.openTelegramLink("https://t.me/share/url?"+new URLSearchParams({url:n,text:s||""}).toString())}}const ln=f(({version:e,postEvent:t,createRequestId:n})=>new be(e,n,t));async function lt(e={}){const{is_expanded:t,is_state_stable:n,...s}=await _({...e,method:"web_app_request_viewport",event:"viewport_changed"});return{...s,isExpanded:t,isStateStable:n}}function M(e){return e<0?0:e}class we extends ht{constructor({postEvent:n,stableHeight:s,height:i,width:r,isExpanded:a}){super({height:M(i),isExpanded:a,stableHeight:M(s),width:M(r)});h(this,"postEvent");this.postEvent=n}async sync(n){const{isStateStable:s,...i}=await lt(n);this.set({...i,stableHeight:s?i.height:this.get("stableHeight")})}get height(){return this.get("height")}get stableHeight(){return this.get("stableHeight")}listen(){return m("viewport_changed",n=>{const{height:s,width:i,is_expanded:r,is_state_stable:a}=n,c=M(s);this.set({height:c,isExpanded:r,width:M(i),...a?{stableHeight:c}:{}})})}get isExpanded(){return this.get("isExpanded")}get width(){return this.get("width")}expand(){this.postEvent("web_app_expand"),this.set("isExpanded",!0)}get isStable(){return this.stableHeight===this.height}}const dn=f("viewport",async({state:e,platform:t,postEvent:n,addCleanup:s})=>{let i=!1,r=0,a=0,c=0;if(e)i=e.isExpanded,r=e.height,a=e.width,c=e.stableHeight;else if(["macos","tdesktop","unigram","webk","weba","web"].includes(t))i=!0,r=window.innerHeight,a=window.innerWidth,c=window.innerHeight;else{const l=await lt({timeout:1e3,postEvent:n});i=l.isExpanded,r=l.height,a=l.width,c=l.isStateStable?r:0}const p=new we({postEvent:n,height:r,width:a,stableHeight:c,isExpanded:i});return s(p.listen()),p});function E(e,t){document.documentElement.style.setProperty(e,t)}function _n(e,t,n){n||(n=c=>`--tg-${c}-color`);const s=n("header"),i=n("bg"),r=()=>{const{headerColor:c}=e;if($(c))E(s,c);else{const{bgColor:p,secondaryBgColor:l}=t;c==="bg_color"&&p?E(s,p):c==="secondary_bg_color"&&l&&E(s,l)}E(i,e.bgColor)},a=[t.on("change",r),e.on("change",r)];return r(),()=>a.forEach(c=>c())}function fn(e,t){t||(t=s=>`--tg-theme-${s.replace(/[A-Z]/g,i=>`-${i.toLowerCase()}`)}`);const n=()=>{Object.entries(e.getState()).forEach(([s,i])=>{i&&E(t(s),i)})};return n(),e.on("change",n)}function gn(e,t){t||(t=l=>`--tg-viewport-${l}`);const[n,s,i]=["height","width","stable-height"].map(l=>t(l)),r=()=>E(n,`${e.height}px`),a=()=>E(s,`${e.width}px`),c=()=>E(i,`${e.stableHeight}px`),p=[e.on("change:height",r),e.on("change:width",a),e.on("change:stableHeight",c)];return r(),a(),c(),()=>p.forEach(l=>l())}function bn(e=!0){const t=[m("reload_iframe",()=>{A("iframe_will_reload"),window.location.reload()})],n=()=>t.forEach(s=>s());if(e){const s=document.createElement("style");s.id="telegram-custom-styles",document.head.appendChild(s),t.push(m("set_custom_style",i=>{s.innerHTML=i}),()=>document.head.removeChild(s))}return A("iframe_ready",{reload_supported:!0}),n}function wn(){return typeof window>"u"}async function mn(){if(Bt(window))return!0;try{return await _({method:"web_app_request_theme",event:"theme_changed",timeout:100}),!0}catch{return!1}}function yn(e){const t=typeof e=="string"?G(e):e;Xt(t);function n(i){if(typeof i=="string")try{const{eventType:r}=Dt(i);r==="web_app_request_theme"&&Z("theme_changed",{theme_params:JSON.parse(at(t.themeParams))}),r==="web_app_request_viewport"&&Z("viewport_changed",{width:window.innerWidth,height:window.innerHeight,is_state_stable:!0,is_expanded:!0})}catch{}}if(tt()){const i=window.parent.postMessage.bind(window.parent);window.parent.postMessage=r=>{n(r),i(r)};return}if(Vt(window)){const i=window.external.notify.bind(window.external);window.external.notify=r=>{n(r),i(r)};return}const s=window.TelegramWebviewProxy;window.TelegramWebviewProxy={...s||{},postEvent(...i){n(JSON.stringify({eventType:i[0],eventData:i[1]})),s&&s.postEvent(...i)}}}function me(e){return e instanceof N}function En(e,t){return me(e)&&e.type===t}function dt(e,t){let n,s,i;return typeof e=="string"?n=e:(n=e.pathname===void 0?t:e.pathname,s=e.params,i=e.id),Object.freeze({id:i||(Math.random()*2**14|0).toString(16),pathname:n,params:s})}class ye{constructor(t,n,s=A){h(this,"history");h(this,"ee",new R);h(this,"attached",!1);h(this,"back",()=>this.go(-1));h(this,"on",this.ee.on.bind(this.ee));h(this,"off",this.ee.off.bind(this.ee));if(this._index=n,this.postEvent=s,t.length===0)throw g(At,"History should not be empty.");if(n<0||n>=t.length)throw g(It,"Index should not be zero and higher or equal than history size.");this.history=t.map(i=>dt(i,""))}attach(){this.attached||(this.attached=!0,this.sync(),m("back_button_pressed",this.back))}get current(){return this.history[this.index]}detach(){this.attached=!1,q("back_button_pressed",this.back)}forward(){this.go(1)}go(t,n){const s=this.index+t,i=Math.min(Math.max(0,s),this.history.length-1);(s===i||n)&&this.replaceAndMove(i,this.history[i])}goTo(t,n){this.go(t-this.index,n)}get hasPrev(){return this.index>0}get hasNext(){return this.index!==this.history.length-1}get index(){return this._index}push(t){this.hasNext&&this.history.splice(this.index+1),this.replaceAndMove(this.index+1,dt(t,this.current.pathname))}replace(t){this.replaceAndMove(this.index,dt(t,this.current.pathname))}replaceAndMove(t,n){const s=t-this.index;if(!s&&this.current===n)return;const i=this.current;if(this.index!==t){const r=this._index;this._index=t,this.attached&&r>0!=t>0&&this.sync()}this.history[t]=n,this.ee.emit("change",{navigator:this,from:i,to:this.current,delta:s})}sync(){this.postEvent("web_app_setup_back_button",{is_visible:!!this.index})}}function _t({params:e,...t}){return{...e||{hash:"",search:""},...t}}function V(e,t){return e.startsWith(t)?e:`${t}${e}`}function B(e){return new URL(typeof e=="string"?e:`${e.pathname||""}${V(e.search||"","?")}${V(e.hash||"","#")}`,"http://a")}function L(e){const t=typeof e=="string"?e.startsWith("/"):!!(e.pathname&&e.pathname.startsWith("/")),n=B(e);return`${t?n.pathname:n.pathname.slice(1)}${n.search}${n.hash}`}function ft(e,t,n){let s,i;typeof e=="string"?s=e:(s=L(e),n=e.state,i=e.id);const{pathname:r,search:a,hash:c}=new URL(s,`http://a${V(t,"/")}`);return{id:i,pathname:r,params:{hash:c,search:a,state:n}}}async function O(e){return e===0?!0:Promise.race([new Promise(t=>{const n=F("popstate",()=>{n(),t(!0)});window.history.go(e)}),new Promise(t=>{setTimeout(t,50,!1)})])}async function vn(){if(window.history.length<=1||(window.history.pushState(null,""),await O(1-window.history.length)))return;let t=await O(-1);for(;t;)t=await O(-1)}function gt(e){return B(e).pathname}const Ee=0,bt=1,wt=2;class mt{constructor(t,n,{postEvent:s,hashMode:i="classic",base:r}={}){h(this,"navigator");h(this,"ee",new R);h(this,"hashMode");h(this,"base");h(this,"attached",!1);h(this,"onPopState",({state:t})=>{if(t===null)return this.push(this.parsePath(window.location.href));t===Ee?window.history.forward():t===bt&&this.back(),t===wt&&this.forward()});h(this,"onNavigatorChange",async({to:t,from:n,delta:s})=>{this.attached&&await this.syncHistory(),this.ee.emit("change",{delta:s,from:_t(n),to:_t(t),navigator:this})});h(this,"on",this.ee.on.bind(this.ee));h(this,"off",this.ee.off.bind(this.ee));this.navigator=new ye(t.map(a=>ft(a,"/")),n,s),this.navigator.on("change",a=>{this.onNavigatorChange(a)}),this.hashMode=i,this.base=gt(r||"")}async attach(){this.attached||(this.attached=!0,this.navigator.attach(),window.addEventListener("popstate",this.onPopState),await this.syncHistory())}back(){this.navigator.back()}detach(){this.attached=!1,this.navigator.detach(),window.removeEventListener("popstate",this.onPopState)}forward(){return this.navigator.forward()}get index(){return this.navigator.index}get id(){return this.navigator.current.id}go(t,n){return this.navigator.go(t,n)}goTo(t,n){this.navigator.goTo(t,n)}get hash(){return(this.navigator.current.params||{}).hash||""}get hasPrev(){return this.navigator.hasPrev}get hasNext(){return this.navigator.hasNext}get history(){return this.navigator.history.map(_t)}get path(){return L(this)}get pathname(){return this.navigator.current.pathname}parsePath(t){let n=B(t);return this.hashMode&&(n=B(n.hash.slice(1))),{pathname:n.pathname,search:n.search,hash:n.hash}}push(t,n){const s=ft(t,this.path),{state:i=n}=s.params;this.navigator.push({...s,params:{...s.params,state:i}})}replace(t,n){const s=ft(t,this.path),{state:i=n}=s.params;this.navigator.replace({...s,params:{...s.params,state:i}})}renderPath(t){const n=(this.base.length===1?"":this.base)+V(L(t),"/");return this.hashMode?V(n.slice(1),this.hashMode==="classic"?"#":"#/"):n}async syncHistory(){window.removeEventListener("popstate",this.onPopState);const{state:t}=this,n=this.renderPath(this);await vn(),this.hasPrev&&this.hasNext?(window.history.replaceState(bt,""),window.history.pushState(t,"",n),window.history.pushState(wt,""),await O(-1)):this.hasPrev?(window.history.replaceState(bt,""),window.history.pushState(t,"",n)):this.hasNext?(window.history.replaceState(t,n),window.history.pushState(wt,""),await O(-1)):(window.history.replaceState(Ee,""),window.history.pushState(t,"",n)),window.addEventListener("popstate",this.onPopState)}get search(){return(this.navigator.current.params||{}).search||""}get state(){return(this.navigator.current.params||{}).state}}function ve(e){e||(e={});const{href:t,hash:n}=window.location;let s=L(e.hashMode===null?t:n.includes("?")?n.slice(1):`?${n.slice(1)}`);const i=e.base?gt(e.base):void 0;if(i){if(!s.startsWith(i))throw g(Nt,`Path "${s}" expected to be starting with "${i}"`);s=s.slice(i.length)}return new mt([s],0,e)}function Sn(e){const t=e.match(/#(.+)/);return t?t[1]:null}function Pn(e,t){if(ct()){const n=sessionStorage.getItem(e);if(n)try{const{index:s,history:i}=JSON.parse(n);return new mt(i,s,t)}catch(s){console.error("Unable to restore hash navigator state.",s)}}return ve(t)}function Rn(e,t){const n=Pn(e,t),s=()=>sessionStorage.setItem(e,JSON.stringify({index:n.index,history:n.history}));return n.on("change",s),s(),n}return o.BackButton=Ht,o.BasicNavigator=ye,o.BiometryManager=ee,o.BrowserNavigator=mt,o.ClosingBehavior=se,o.CloudStorage=oe,o.ERR_INVALID_PATH_BASE=Nt,o.ERR_INVOKE_CUSTOM_METHOD_RESPONSE=Rt,o.ERR_METHOD_PARAMETER_UNSUPPORTED=St,o.ERR_METHOD_UNSUPPORTED=vt,o.ERR_NAVIGATION_HISTORY_EMPTY=At,o.ERR_NAVIGATION_INDEX_INVALID=It,o.ERR_NAVIGATION_ITEM_INVALID=Te,o.ERR_PARSE=Y,o.ERR_SSR_INIT=Ce,o.ERR_TIMED_OUT=Tt,o.ERR_UNEXPECTED_TYPE=Ct,o.ERR_UNKNOWN_ENV=Pt,o.EventEmitter=R,o.HapticFeedback=ae,o.InitData=ce,o.Invoice=he,o.MainButton=ue,o.MiniApp=le,o.Popup=de,o.QRScanner=_e,o.SDKError=N,o.SettingsButton=fe,o.ThemeParams=ge,o.Utils=be,o.Viewport=we,o.array=ie,o.bindMiniAppCSSVars=_n,o.bindThemeParamsCSSVars=fn,o.bindViewportCSSVars=gn,o.boolean=y,o.captureSameReq=et,o.classNames=H,o.compareVersions=Mt,o.createBrowserNavigatorFromLocation=ve,o.createPostEvent=Ut,o.createSafeURL=B,o.date=ot,o.getHash=Sn,o.getPathname=gt,o.initBackButton=je,o.initBiometryManager=ze,o.initClosingBehavior=Fe,o.initCloudStorage=Ke,o.initHapticFeedback=Qe,o.initInitData=Xe,o.initInvoice=tn,o.initMainButton=en,o.initMiniApp=rn,o.initNavigator=Rn,o.initPopup=an,o.initQRScanner=cn,o.initSettingsButton=hn,o.initThemeParams=un,o.initUtils=ln,o.initViewport=dn,o.initWeb=bn,o.invokeCustomMethod=I,o.isColorDark=st,o.isIframe=tt,o.isPageReload=ct,o.isRGB=$,o.isRGBShort=kt,o.isSDKError=me,o.isSDKErrorOfType=En,o.isSSR=wn,o.isTMA=mn,o.json=d,o.mergeClassNames=Ve,o.mockTelegramEnv=yn,o.number=S,o.off=q,o.on=m,o.parseInitData=Ze,o.parseLaunchParams=G,o.parseThemeParams=pt,o.postEvent=A,o.request=_,o.requestBiometryInfo=ne,o.requestThemeParams=pn,o.requestViewport=lt,o.retrieveLaunchParams=Zt,o.rgb=X,o.searchParams=x,o.serializeLaunchParams=Qt,o.serializeThemeParams=at,o.setCSSVar=E,o.setDebug=Pe,o.setTargetOrigin=Me,o.string=u,o.subscribe=yt,o.supports=P,o.targetOrigin=Ot,o.toRGB=Q,o.unsubscribe=v,o.urlToPath=L,o.withTimeout=nt,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"}),o}({});
|
|
1
|
+
var cc=Object.defineProperty;var lc=(p,oe,we)=>oe in p?cc(p,oe,{enumerable:!0,configurable:!0,writable:!0,value:we}):p[oe]=we;var o=(p,oe,we)=>lc(p,typeof oe!="symbol"?oe+"":oe,we);this.tmajs=this.tmajs||{};this.tmajs.sdk=function(p){"use strict";var oe=function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,s;r<i;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))};function we(e,t,n,r,i,s,a,u,l){switch(arguments.length){case 1:return e;case 2:return function(){return t(e.apply(this,arguments))};case 3:return function(){return n(t(e.apply(this,arguments)))};case 4:return function(){return r(n(t(e.apply(this,arguments))))};case 5:return function(){return i(r(n(t(e.apply(this,arguments)))))};case 6:return function(){return s(i(r(n(t(e.apply(this,arguments))))))};case 7:return function(){return a(s(i(r(n(t(e.apply(this,arguments)))))))};case 8:return function(){return u(a(s(i(r(n(t(e.apply(this,arguments))))))))};case 9:return function(){return l(u(a(s(i(r(n(t(e.apply(this,arguments)))))))))}}}function d(e,t,n,r,i,s,a,u,l){switch(arguments.length){case 1:return e;case 2:return t(e);case 3:return n(t(e));case 4:return r(n(t(e)));case 5:return i(r(n(t(e))));case 6:return s(i(r(n(t(e)))));case 7:return a(s(i(r(n(t(e))))));case 8:return u(a(s(i(r(n(t(e)))))));case 9:return l(u(a(s(i(r(n(t(e))))))));default:{for(var c=arguments[0],h=1;h<arguments.length;h++)c=arguments[h](c);return c}}}var Ve=function(e,t){var n=typeof e=="number"?function(r){return r.length>=e}:e;return function(){var r=Array.from(arguments);return n(arguments)?t.apply(this,r):function(i){return t.apply(void 0,oe([i],r,!1))}}},Js={_tag:"None"},Qs=function(e){return{_tag:"Some",value:e}},Zs=function(e){return e._tag==="Left"},kn=function(e){return{_tag:"Left",left:e}},En=function(e){return{_tag:"Right",right:e}},dt={};function Ys(e,t){return function(n){return function(r){return e.ap(e.map(r,function(i){return function(s){return t.ap(i,s)}}),n)}}}function Xs(e,t){return function(n){return function(r){return e.map(r,function(i){return t.map(i,n)})}}}function _t(e){return function(t,n){return function(r){return e.chain(r,function(i){return e.map(n(i),function(s){var a;return Object.assign({},i,(a={},a[t]=s,a))})})}}}var O=kn,P=En,ei=Ve(2,function(e,t){return ye(e)?e:t(e.right)}),mt=function(e,t){return d(e,Z(t))},$n=function(e,t){return d(e,si(t))},bt="Either",Z=function(e){return function(t){return ye(t)?t:P(e(t.right))}},ti={URI:bt,map:mt},ni=P,ri=function(e){return function(t){return ye(t)?t:ye(e)?e:P(t.right(e.right))}},si=ri,ii={URI:bt,map:mt,ap:$n},oi={URI:bt,map:mt,ap:$n,chain:ei},ai=function(e,t){return function(n){return ye(n)?O(e(n.left)):P(t(n.right))}},ye=Zs,An=function(e,t){return function(n){return ye(n)?e(n.left):t(n.right)}},Re=An,ui=function(e,t){try{return P(e())}catch(n){return O(t(n))}},ci=ni(dt),li=_t(oi),In=li;let Ae;function pi(e,t){Ae?Ae.set(e,t):t()}function Xe(e){if(Ae)return e();Ae=new Map;try{e()}finally{Ae.forEach(t=>t()),Ae=void 0}}function W(e,t){t||(t={});const n=t.equals||Object.is;let r=[],i=e;const s=c=>{if(!n(i,c)){const h=i;i=c,pi(l,()=>{[...r].forEach(([f,b])=>{f(c,h),b&&u(f,!0)})})}};function a(c){const h=typeof c!="object"?{once:c}:c;return{once:h.once||!1,signal:h.signal||!1}}const u=(c,h)=>{const f=a(h),b=r.findIndex(([v,y])=>v===c&&y.once===f.once&&y.signal===f.signal);b>=0&&r.splice(b,1)},l=Object.assign(function(){return hi(l),i},{destroy(){r=[]},set:s,reset(){s(e)},sub(c,h){return r.push([c,a(h)]),()=>u(c,h)},unsub:u,unsubAll(){r=r.filter(c=>c[1].signal)}});return l}const Oe=[];function hi(e){Oe.length&&Oe[Oe.length-1].add(e)}function F(e,t){let n=new Set,r;function i(){return r||(r=W(a(),t))}function s(){i().set(a())}function a(){n.forEach(c=>{c.unsub(s,{signal:!0})});const u=new Set;let l;Oe.push(u);try{l=e()}finally{Oe.pop()}return u.forEach(c=>{c.sub(s,{signal:!0})}),n=u,l}return Object.assign(function(){return i()()},{destroy(){i().destroy()},sub(...u){return i().sub(...u)},unsub(...u){i().unsub(...u)},unsubAll(...u){i().unsubAll(...u)}})}var ae;function gt(e){return{lang:(e==null?void 0:e.lang)??(ae==null?void 0:ae.lang),message:e==null?void 0:e.message,abortEarly:(e==null?void 0:e.abortEarly)??(ae==null?void 0:ae.abortEarly),abortPipeEarly:(e==null?void 0:e.abortPipeEarly)??(ae==null?void 0:ae.abortPipeEarly)}}var vt;function fi(e){return vt==null?void 0:vt.get(e)}var wt;function di(e){return wt==null?void 0:wt.get(e)}var yt;function _i(e,t){var n;return(n=yt==null?void 0:yt.get(e))==null?void 0:n.get(t)}function mi(e){var n,r;const t=typeof e;return t==="string"?`"${e}"`:t==="number"||t==="bigint"||t==="boolean"?`${e}`:t==="object"||t==="function"?(e&&((r=(n=Object.getPrototypeOf(e))==null?void 0:n.constructor)==null?void 0:r.name))??"null":t}function K(e,t,n,r,i){const s=i&&"input"in i?i.input:n.value,a=(i==null?void 0:i.expected)??e.expects??null,u=(i==null?void 0:i.received)??mi(s),l={kind:e.kind,type:e.type,input:s,expected:a,received:u,message:`Invalid ${t}: ${a?`Expected ${a} but r`:"R"}eceived ${u}`,requirement:e.requirement,path:i==null?void 0:i.path,issues:i==null?void 0:i.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},c=e.kind==="schema",h=(i==null?void 0:i.message)??e.message??_i(e.reference,l.lang)??(c?di(l.lang):null)??r.message??fi(l.lang);h!==void 0&&(l.message=typeof h=="function"?h(l):h),c&&(n.typed=!1),n.issues?n.issues.push(l):n.issues=[l]}function J(e){return{version:1,vendor:"valibot",validate(t){return e["~run"]({value:t},gt())}}}function qn(e,t){return Object.hasOwn(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}function bi(e,t){const n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??"never"}var gi=class extends Error{constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function et(e,t){return{kind:"validation",type:"check",reference:et,async:!1,expects:null,requirement:e,message:t,"~run"(n,r){return n.typed&&!this.requirement(n.value)&&K(this,"input",n,r),n}}}function Ct(e){return{kind:"validation",type:"integer",reference:Ct,async:!1,expects:null,requirement:Number.isInteger,message:e,"~run"(t,n){return t.typed&&!this.requirement(t.value)&&K(this,"integer",t,n),t}}}function ue(e){return{kind:"transformation",type:"transform",reference:ue,async:!1,operation:e,"~run"(t){return t.value=this.operation(t.value),t}}}function vi(e,t,n){return typeof e.fallback=="function"?e.fallback(t,n):e.fallback}function Ft(e,t,n){return typeof e.default=="function"?e.default(t,n):e.default}function St(e,t){return!e["~run"]({value:t},{abortEarly:!0}).issues}function Bn(){return{kind:"schema",type:"any",reference:Bn,expects:"any",async:!1,get"~standard"(){return J(this)},"~run"(e){return e.typed=!0,e}}}function Tn(e,t){return{kind:"schema",type:"array",reference:Tn,expects:"Array",async:!1,item:e,message:t,get"~standard"(){return J(this)},"~run"(n,r){var s;const i=n.value;if(Array.isArray(i)){n.typed=!0,n.value=[];for(let a=0;a<i.length;a++){const u=i[a],l=this.item["~run"]({value:u},r);if(l.issues){const c={type:"array",origin:"value",input:i,key:a,value:u};for(const h of l.issues)h.path?h.path.unshift(c):h.path=[c],(s=n.issues)==null||s.push(h);if(n.issues||(n.issues=l.issues),r.abortEarly){n.typed=!1;break}}l.typed||(n.typed=!1),n.value.push(l.value)}}else K(this,"type",n,r);return n}}}function Ce(e){return{kind:"schema",type:"boolean",reference:Ce,expects:"boolean",async:!1,message:e,get"~standard"(){return J(this)},"~run"(t,n){return typeof t.value=="boolean"?t.typed=!0:K(this,"type",t,n),t}}}function tt(e){return{kind:"schema",type:"date",reference:tt,expects:"Date",async:!1,message:e,get"~standard"(){return J(this)},"~run"(t,n){return t.value instanceof Date?isNaN(t.value)?K(this,"type",t,n,{received:'"Invalid Date"'}):t.typed=!0:K(this,"type",t,n),t}}}function kt(e){return{kind:"schema",type:"function",reference:kt,expects:"Function",async:!1,message:e,get"~standard"(){return J(this)},"~run"(t,n){return typeof t.value=="function"?t.typed=!0:K(this,"type",t,n),t}}}function Et(e,t){return{kind:"schema",type:"instance",reference:Et,expects:e.name,async:!1,class:e,message:t,get"~standard"(){return J(this)},"~run"(n,r){return n.value instanceof this.class?n.typed=!0:K(this,"type",n,r),n}}}function j(e,t){return{kind:"schema",type:"loose_object",reference:j,expects:"Object",async:!1,entries:e,message:t,get"~standard"(){return J(this)},"~run"(n,r){var s;const i=n.value;if(i&&typeof i=="object"){n.typed=!0,n.value={};for(const a in this.entries){const u=this.entries[a];if(a in i||(u.type==="exact_optional"||u.type==="optional"||u.type==="nullish")&&u.default!==void 0){const l=a in i?i[a]:Ft(u),c=u["~run"]({value:l},r);if(c.issues){const h={type:"object",origin:"value",input:i,key:a,value:l};for(const f of c.issues)f.path?f.path.unshift(h):f.path=[h],(s=n.issues)==null||s.push(f);if(n.issues||(n.issues=c.issues),r.abortEarly){n.typed=!1;break}}c.typed||(n.typed=!1),n.value[a]=c.value}else if(u.fallback!==void 0)n.value[a]=vi(u);else if(u.type!=="exact_optional"&&u.type!=="optional"&&u.type!=="nullish"&&(K(this,"key",n,r,{input:void 0,expected:`"${a}"`,path:[{type:"object",origin:"key",input:i,key:a,value:i[a]}]}),r.abortEarly))break}if(!n.issues||!r.abortEarly)for(const a in i)qn(i,a)&&!(a in this.entries)&&(n.value[a]=i[a])}else K(this,"type",n,r);return n}}}function Ie(e,t){return{kind:"schema",type:"nullish",reference:Ie,expects:`(${e.expects} | null | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return J(this)},"~run"(n,r){return(n.value===null||n.value===void 0)&&(this.default!==void 0&&(n.value=Ft(this,n,r)),n.value===null||n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function de(e){return{kind:"schema",type:"number",reference:de,expects:"number",async:!1,message:e,get"~standard"(){return J(this)},"~run"(t,n){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:K(this,"type",t,n),t}}}function $(e,t){return{kind:"schema",type:"optional",reference:$,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return J(this)},"~run"(n,r){return n.value===void 0&&(this.default!==void 0&&(n.value=Ft(this,n,r)),n.value===void 0)?(n.typed=!0,n):this.wrapped["~run"](n,r)}}}function $t(e,t,n){return{kind:"schema",type:"record",reference:$t,expects:"Object",async:!1,key:e,value:t,message:n,get"~standard"(){return J(this)},"~run"(r,i){var a,u;const s=r.value;if(s&&typeof s=="object"){r.typed=!0,r.value={};for(const l in s)if(qn(s,l)){const c=s[l],h=this.key["~run"]({value:l},i);if(h.issues){const b={type:"object",origin:"key",input:s,key:l,value:c};for(const v of h.issues)v.path=[b],(a=r.issues)==null||a.push(v);if(r.issues||(r.issues=h.issues),i.abortEarly){r.typed=!1;break}}const f=this.value["~run"]({value:c},i);if(f.issues){const b={type:"object",origin:"value",input:s,key:l,value:c};for(const v of f.issues)v.path?v.path.unshift(b):v.path=[b],(u=r.issues)==null||u.push(v);if(r.issues||(r.issues=f.issues),i.abortEarly){r.typed=!1;break}}(!h.typed||!f.typed)&&(r.typed=!1),h.typed&&(r.value[h.value]=f.value)}}else K(this,"type",r,i);return r}}}function C(e){return{kind:"schema",type:"string",reference:C,expects:"string",async:!1,message:e,get"~standard"(){return J(this)},"~run"(t,n){return typeof t.value=="string"?t.typed=!0:K(this,"type",t,n),t}}}function Pn(e){let t;if(e)for(const n of e)t?t.push(...n.issues):t=n.issues;return t}function nt(e,t){return{kind:"schema",type:"union",reference:nt,expects:bi(e.map(n=>n.expects),"|"),async:!1,options:e,message:t,get"~standard"(){return J(this)},"~run"(n,r){let i,s,a;for(const u of this.options){const l=u["~run"]({value:n.value},r);if(l.typed)if(l.issues)s?s.push(l):s=[l];else{i=l;break}else a?a.push(l):a=[l]}if(i)return i;if(s){if(s.length===1)return s[0];K(this,"type",n,r,{issues:Pn(s)}),n.typed=!0}else{if((a==null?void 0:a.length)===1)return a[0];K(this,"type",n,r,{issues:Pn(a)})}return n}}}function At(){return{kind:"schema",type:"unknown",reference:At,expects:"unknown",async:!1,get"~standard"(){return J(this)},"~run"(e){return e.typed=!0,e}}}function _e(e,t,n){const r=e["~run"]({value:t},gt(n));if(r.issues)throw new gi(r.issues);return r.value}function se(...e){return{...e[0],pipe:e,get"~standard"(){return J(this)},"~run"(t,n){for(const r of e)if(r.kind!=="metadata"){if(t.issues&&(r.kind==="schema"||r.kind==="transformation")){t.typed=!1;break}(!t.issues||!n.abortEarly&&!n.abortPipeEarly)&&(t=r["~run"](t,n))}return t}}}function It(e,t,n){const r=e["~run"]({value:t},gt(n));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}var wi=Object.defineProperty,yi=(e,t,n)=>t in e?wi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Mn=(e,t,n)=>yi(e,typeof t!="symbol"?t+"":t,n),Ci=Object.defineProperty,Fi=(e,t,n)=>t in e?Ci(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,qt=(e,t,n)=>Fi(e,typeof t!="symbol"?t+"":t,n);function Ln(e){return t=>t instanceof e}function Vn(e,t){const n=class extends Error{constructor(...i){const s=typeof t=="function"?t(...i):typeof t=="string"?[t]:t||[];super(...s),this.name=e}};qt(n,"is",Ln(n));let r=n;return Object.defineProperty(r,"name",{value:e}),r}function Si(e,t,n){const r=class extends Vn(e,n){constructor(...s){super(...s),qt(this,"data"),this.data=t(...s)}};qt(r,"is",Ln(r));let i=r;return Object.defineProperty(i,"name",{value:e}),i}let Rn=class extends Vn("CancelledError","Promise was canceled"){},Bt=class extends Si("TimeoutError",t=>({timeout:t}),(t,n)=>[`Timeout reached: ${t}ms`,{cause:n}]){};const ki=Symbol("resolved");function Ei(e){return{tag:ki,value:e}}function On(e,t){return e.reject=t.reject,e.resolve=t.resolve,e}let rt=class Sn extends Promise{constructor(t,n){let r,i,s,a;typeof t=="function"?(s=t,a=n||{}):a=t||{};let u,l;const c=()=>!!l,h=()=>!!u;let f={};const b=[],v=()=>{b.forEach(g=>g()),b.splice(0,b.length),f={}},y=new AbortController,w=()=>h()||c();super((g,S)=>{const{abortOnResolve:_=!0,abortOnReject:D=!0}=a;i=k=>{var L,I;w()||(g(k),u=[k],(L=f.resolved)==null||L.forEach(x=>x(k)),(I=f.finalized)==null||I.forEach(x=>x({kind:"resolved",result:k})),v(),_&&y.abort(Ei(k)))},r=k=>{var L,I;w()||(S(k),l=[k],(L=f.rejected)==null||L.forEach(x=>x(k)),(I=f.finalized)==null||I.forEach(x=>x({kind:"rejected",reason:k})),v(),D&&y.abort(k))};const{abortSignal:M}=a;if(M){if(M.aborted)return r(M.reason);const k=()=>{r(M.reason)};M.addEventListener("abort",k,!0),b.push(()=>{M.removeEventListener("abort",k,!0)})}const{timeout:U}=a;if(U){const k=setTimeout(()=>{r(new Bt(U))},U);b.push(()=>{clearTimeout(k)})}try{const k=()=>{},L=s&&s(i,r,{abortSignal:y.signal,get isRejected(){return c()},get isResolved(){return h()},on(I,x){if(u||l){if(I==="finalized"){const Le=u?{kind:"resolved",result:u[0]}:{kind:"rejected",reason:l[0]};x(Le)}else I==="resolved"&&u?x(u[0]):I==="rejected"&&l&&x(l[0]);return k}return f[I]||(f[I]=[]),f[I].push(x),()=>{const Le=f[I]||[],Ye=Le.indexOf(x);Ye>=0&&Le.splice(Ye,1)}},get result(){return u==null?void 0:u[0]},get rejectReason(){return l==null?void 0:l[0]},throwIfRejected(){if(l)throw l[0]}});L instanceof Promise&&L.catch(r)}catch(k){r(k)}}),Mn(this,"reject"),Mn(this,"resolve"),this.reject=r,this.resolve=i}static fn(t,n){return new Sn(async(r,i,s)=>{try{r(await t(s))}catch(a){i(a)}},n)}static resolve(t){return this.fn(()=>t)}static reject(t){return new Sn((n,r)=>{r(t)})}cancel(){this.reject(new Rn)}catch(t){return this.then(void 0,t)}finally(t){return On(super.finally(t),this)}then(t,n){return On(super.then(t,n),this)}};function jn(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function $i(e){return e.replace(/_[a-z]/g,t=>t[1].toUpperCase())}function Ai(e){return Object.entries(e).reduce((t,[n,r])=>(t[$i(n)]=r,t),{})}function Tt(e){const t=Ai(e);for(const n in t){const r=t[n];r&&typeof r=="object"&&!(r instanceof Date)&&(t[n]=Array.isArray(r)?r.map(Tt):Tt(r))}return t}function Ii(e){return e.replace(/_([a-z])/g,(t,n)=>`-${n.toLowerCase()}`)}function Dn(e){return`tapps/${e}`}function Pt(e,t){sessionStorage.setItem(Dn(e),JSON.stringify(t))}function Un(e){const t=sessionStorage.getItem(Dn(e));try{return t?JSON.parse(t):void 0}catch{}}function st(...e){const t=e.flat(1);return[t.push.bind(t),()=>{t.forEach(n=>{n()})}]}function xn(e,t){t||(t={});const{textColor:n,bgColor:r,shouldLog:i}=t,s=i===void 0?!0:i,a=typeof s=="boolean"?()=>s:s,u=(l,c,...h)=>{if(c||a()){const f="font-weight:bold;padding:0 5px;border-radius:100px",[b,v,y]={log:["#0089c3","white","INFO"],error:["#ff0000F0","white","ERR"],warn:["#D38E15","white","WARN"]}[l];console[l](`%c${y} ${Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3,timeZone:"UTC"}).format(new Date)}%c %c${e}`,`${f};background-color:${b};color:${v}`,"",`${f};${n?`color:${n};`:""}${r?`background-color:${r}`:""}`,...h)}};return[["log","forceLog"],["warn","forceWarn"],["error","forceError"]].reduce((l,[c,h])=>(l[c]=u.bind(void 0,c,!1),l[h]=u.bind(void 0,c,!0),l),{})}var qi=function(e,t,n){if(arguments.length===2)for(var r=0,i=t.length,s;r<i;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))};function Gn(e,t,n,r,i,s,a,u,l){switch(arguments.length){case 1:return e;case 2:return function(){return t(e.apply(this,arguments))};case 3:return function(){return n(t(e.apply(this,arguments)))};case 4:return function(){return r(n(t(e.apply(this,arguments))))};case 5:return function(){return i(r(n(t(e.apply(this,arguments)))))};case 6:return function(){return s(i(r(n(t(e.apply(this,arguments))))))};case 7:return function(){return a(s(i(r(n(t(e.apply(this,arguments)))))))};case 8:return function(){return u(a(s(i(r(n(t(e.apply(this,arguments))))))))};case 9:return function(){return l(u(a(s(i(r(n(t(e.apply(this,arguments)))))))))}}}function qe(e,t,n,r,i,s,a,u,l){switch(arguments.length){case 1:return e;case 2:return t(e);case 3:return n(t(e));case 4:return r(n(t(e)));case 5:return i(r(n(t(e))));case 6:return s(i(r(n(t(e)))));case 7:return a(s(i(r(n(t(e))))));case 8:return u(a(s(i(r(n(t(e)))))));case 9:return l(u(a(s(i(r(n(t(e))))))));default:{for(var c=arguments[0],h=1;h<arguments.length;h++)c=arguments[h](c);return c}}}var Wn=function(e,t){var n=function(r){return r.length>=e};return function(){var r=Array.from(arguments);return n(arguments)?t.apply(this,r):function(i){return t.apply(void 0,qi([i],r,!1))}}},Bi=function(e){return e._tag==="Left"},Hn=function(e){return{_tag:"Left",left:e}},Nn=function(e){return{_tag:"Right",right:e}},zn=Hn,Kn=Nn,Jn=Bi,Ti=function(e,t){return function(n){return Jn(n)?e(n.left):t(n.right)}},Mt=Ti;function Pi(e){return Gn(Kn,e.of)}function Mi(e){return Gn(zn,e.of)}function Li(e){return function(t,n){return e.chain(t,function(r){return Jn(r)?e.of(r):n(r.right)})}}function Vi(e){return function(t,n){return function(r){return e.map(r,Mt(t,n))}}}var Qn=function(e,t){return qe(e,Oi(t))},Ri=function(e,t){return qe(e,ji(t))},Oi=function(e){return function(t){return function(){return Promise.resolve().then(t).then(e)}}},ji=function(e){return function(t){return function(){return Promise.all([Promise.resolve().then(t),Promise.resolve().then(e)]).then(function(n){var r=n[0],i=n[1];return r(i)})}}},Lt=function(e){return function(){return Promise.resolve(e)}},Di=Wn(2,function(e,t){return function(){return Promise.resolve().then(e).then(function(n){return t(n)()})}}),Zn="Task",Ui={URI:Zn,map:Qn},Yn={of:Lt},xi={URI:Zn,map:Qn,of:Lt,ap:Ri,chain:Di},Gi=function(e,t,n,r){function i(s){return s instanceof n?s:new n(function(a){a(s)})}return new(n||(n=Promise))(function(s,a){function u(h){try{c(r.next(h))}catch(f){a(f)}}function l(h){try{c(r.throw(h))}catch(f){a(f)}}function c(h){h.done?s(h.value):i(h.value).then(u,l)}c((r=r.apply(e,[])).next())})},Wi=function(e,t){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,i,s,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(c){return function(h){return l([c,h])}}function l(c){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(n=0)),n;)try{if(r=1,i&&(s=c[0]&2?i.return:c[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,c[1])).done)return s;switch(i=0,s&&(c=[c[0]&2,s.value]),c[0]){case 0:case 1:s=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,i=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(s=n.trys,!(s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]<s[3])){n.label=c[1];break}if(c[0]===6&&n.label<s[1]){n.label=s[1],s=c;break}if(s&&n.label<s[2]){n.label=s[2],n.ops.push(c);break}s[2]&&n.ops.pop(),n.trys.pop();continue}c=t.call(e,n)}catch(h){c=[6,h],i=0}finally{r=s=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},Hi=Mi(Yn),Ni=Pi(Yn),zi=Lt,Xn=Vi(Ui),Ki=Xn,Ji=function(e,t){return function(){return Gi(void 0,void 0,void 0,function(){var n;return Wi(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,e().then(Nn)];case 1:return[2,r.sent()];case 2:return n=r.sent(),[2,Hn(t(n))];case 3:return[2]}})})}},Qi=Wn(2,Li(xi)),Zi=Qi;function je(e){const t=n=>{throw n};return typeof e=="function"?rt.resolve(qe(e,Xn(t,n=>n))()):qe(e,Mt(t,n=>n))}function X(e){return Object.assign((...t)=>je(e(...t)),e)}const De=Object.assign((e,t)=>qe(Ji(()=>new rt((n,r,i)=>e(s=>n(Kn(s)),s=>n(zn(s)),i),t),n=>n),Zi(Mt(Hi,Ni))),{fn:(e,t)=>De((n,r,i)=>{const s=e(i);qe(typeof s=="function"?s:zi(s),Ki(r,n))()},t)});function Yi(e,t,n,r,i,s,a,u,l){switch(arguments.length){case 1:return e;case 2:return t(e);case 3:return n(t(e));case 4:return r(n(t(e)));case 5:return i(r(n(t(e))));case 6:return s(i(r(n(t(e)))));case 7:return a(s(i(r(n(t(e))))));case 8:return u(a(s(i(r(n(t(e)))))));case 9:return l(u(a(s(i(r(n(t(e))))))));default:{for(var c=arguments[0],h=1;h<arguments.length;h++)c=arguments[h](c);return c}}}var Xi=function(e){return e._tag==="Left"},eo=function(e){return{_tag:"Left",left:e}},to=function(e){return{_tag:"Right",right:e}},er=eo,Fe=to,no=function(e){return function(t){return ro(t)?t:Fe(e(t.right))}},ro=Xi,tr=function(e,t){try{return Fe(e())}catch(n){return er(t(n))}};function so(e){const t=n=>{const r={};return new URLSearchParams(n).forEach((i,s)=>{const a=r[s];Array.isArray(a)?a.push(i):a===void 0?r[s]=i:r[s]=[a,i]}),_e(e,r)};return se(nt([C(),Et(URLSearchParams)]),et(n=>{try{return t(n),!0}catch{return!1}},"The value doesn't match required schema"),ue(t))}function io(e){return se(C(),et(t=>{try{return JSON.parse(t),!0}catch{return!1}},"Input is not a valid JSON value"),ue(JSON.parse),e)}function me(e){return se(C(),io(e))}function Vt(e){return se(nt([C(),Et(URLSearchParams)]),so(e))}function it(e){return t=>e.test(t)}const nr=it(/^#[\da-f]{3}$/i),rr=it(/^#[\da-f]{4}$/i),Ue=it(/^#[\da-f]{6}$/i),sr=it(/^#[\da-f]{8}$/i);function ir(e){return[Ue,sr,nr,rr].some(t=>t(e))}function or(e){let t="#";for(let n=0;n<e.length-1;n+=1)t+=e[1+n].repeat(2);return t}function ot(e){const t=e.replace(/\s/g,"").toLowerCase();if(/^#[\da-f]{3}$/i.test(t))return Fe(or(t.toLowerCase()+"f"));if(/^#[\da-f]{4}$/i.test(t))return Fe(or(t.toLowerCase()));if(/^#[\da-f]{6}$/i.test(t))return Fe(t.toLowerCase()+"ff");if(/^#[\da-f]{8}$/i.test(t))return Fe(t.toLowerCase());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})\)$/);return n?Fe(n.slice(1).reduce((r,i)=>r+parseInt(i,10).toString(16).padStart(2,"0"),"#").padEnd(9,"f")):er(new Error(`Value "${e}" does not satisfy any of known RGB formats.`))}function ar(e){return Yi(ot(e),no(t=>t.slice(0,7)))}const oo=X(ar),ao=X(ot);function uo(){return j({id:de(),photo_url:$(C()),type:C(),title:C(),username:$(C())})}function ur(){return j({added_to_attachment_menu:$(Ce()),allows_write_to_pm:$(Ce()),first_name:C(),id:de(),is_bot:$(Ce()),is_premium:$(Ce()),last_name:$(C()),language_code:$(C()),photo_url:$(C()),username:$(C())})}function co(){return j({auth_date:se(C(),ue(e=>new Date(Number(e)*1e3)),tt()),can_send_after:$(se(C(),ue(Number),Ct())),chat:$(me(uo())),chat_type:$(C()),chat_instance:$(C()),hash:C(),query_id:$(C()),receiver:$(me(ur())),start_param:$(C()),signature:C(),user:$(me(ur()))})}function cr(){return Vt(co())}function Rt(){return $t(C(),se(nt([C(),de()]),ue(e=>typeof e=="number"?`#${(e&16777215).toString(16).padStart(6,"0")}`:e),et(ir)))}function lo(){const e=$(se(C(),ue(t=>t==="1")));return j({tgWebAppBotInline:e,tgWebAppData:$(cr()),tgWebAppDefaultColors:$(me(Rt())),tgWebAppFullscreen:e,tgWebAppPlatform:C(),tgWebAppShowSettings:e,tgWebAppStartParam:$(C()),tgWebAppThemeParams:me(Rt()),tgWebAppVersion:C()})}function po(){return Vt(lo())}function lr(){return j({eventType:C(),eventData:$(At())})}function pr(e){return tr(()=>_e(cr(),e),t=>t)}function at(e){return tr(()=>_e(po(),e),t=>t)}const ho=X(pr),hr=X(at);function fr(e,t){return t||(t=(n,r)=>JSON.stringify(r)),new URLSearchParams(Object.entries(e).reduce((n,[r,i])=>(Array.isArray(i)?n.push(...i.map(s=>[r,String(s)])):i!=null&&n.push([r,i instanceof Date?(i.getTime()/1e3|0).toString():typeof i=="string"||typeof i=="number"?String(i):typeof i=="boolean"?i?"1":"0":t(r,i)]),n),[])).toString()}function dr(e){return fr(e)}function _r(e){return fr(e,(t,n)=>t==="tgWebAppData"?dr(n):JSON.stringify(n))}var fo=Object.defineProperty,_o=(e,t,n)=>t in e?fo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ot=(e,t,n)=>_o(e,typeof t!="symbol"?t+"":t,n);function mr(e){return t=>t instanceof e}function H(e,t){const n=class extends Error{constructor(...s){const a=typeof t=="function"?t(...s):typeof t=="string"?[t]:t||[];super(...a),this.name=e}};Ot(n,"is",mr(n));let r=n;return Object.defineProperty(r,"name",{value:e}),r}function br(e,t,n){const r=class extends H(e,n){constructor(...a){super(...a),Ot(this,"data"),this.data=t(...a)}};Ot(r,"is",mr(r));let i=r;return Object.defineProperty(i,"name",{value:e}),i}function mo(e){return{all:e=e||new Map,on:function(t,n){var r=e.get(t);r?r.push(n):e.set(t,[n])},off:function(t,n){var r=e.get(t);r&&(n?r.splice(r.indexOf(n)>>>0,1):e.set(t,[]))},emit:function(t,n){var r=e.get(t);r&&r.slice().map(function(i){i(n)}),(r=e.get("*"))&&r.slice().map(function(i){i(t,n)})}}}function gr(e){return St(j({TelegramWebviewProxy:j({postEvent:kt()})}),e)}function vr(){try{return window.self!==window.top}catch{return!0}}var bo=function(e,t,n){if(arguments.length===2)for(var r=0,i=t.length,s;r<i;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))};function go(e){return e}function xe(e,t,n,r,i,s,a,u,l){switch(arguments.length){case 1:return e;case 2:return function(){return t(e.apply(this,arguments))};case 3:return function(){return n(t(e.apply(this,arguments)))};case 4:return function(){return r(n(t(e.apply(this,arguments))))};case 5:return function(){return i(r(n(t(e.apply(this,arguments)))))};case 6:return function(){return s(i(r(n(t(e.apply(this,arguments))))))};case 7:return function(){return a(s(i(r(n(t(e.apply(this,arguments)))))))};case 8:return function(){return u(a(s(i(r(n(t(e.apply(this,arguments))))))))};case 9:return function(){return l(u(a(s(i(r(n(t(e.apply(this,arguments)))))))))}}}function ce(e,t,n,r,i,s,a,u,l){switch(arguments.length){case 1:return e;case 2:return t(e);case 3:return n(t(e));case 4:return r(n(t(e)));case 5:return i(r(n(t(e))));case 6:return s(i(r(n(t(e)))));case 7:return a(s(i(r(n(t(e))))));case 8:return u(a(s(i(r(n(t(e)))))));case 9:return l(u(a(s(i(r(n(t(e))))))));default:{for(var c=arguments[0],h=1;h<arguments.length;h++)c=arguments[h](c);return c}}}var jt=function(e,t){var n=function(r){return r.length>=e};return function(){var r=Array.from(arguments);return n(arguments)?t.apply(this,r):function(i){return t.apply(void 0,bo([i],r,!1))}}},vo={_tag:"None"},wo=function(e){return{_tag:"Some",value:e}},yo=function(e){return e._tag==="Left"},Co=function(e){return{_tag:"Left",left:e}},Fo=function(e){return{_tag:"Right",right:e}},Se=Co,te=Fo,wr=jt(2,function(e,t){return Ge(e)?e:t(e.right)}),So=function(e){return function(t){return Ge(t)?t:te(e(t.right))}},ko=function(e){return function(t){return Ge(t)?Se(e(t.left)):t}},Ge=yo,yr=function(e,t){return function(n){return Ge(n)?e(n.left):t(n.right)}},Eo=yr,Dt=yr,$o=Dt,Ut=function(e,t){try{return te(e())}catch(n){return Se(t(n))}},Ao=wr,Io=wr,qo=vo,Bo=wo,To=function(e){return e._tag==="None"},Po=function(e,t){return function(n){return To(n)?e():t(n.value)}},Mo=Po;function Lo(e){return xe(te,e.of)}function Vo(e){return xe(Se,e.of)}function Ro(e){return function(t,n){return e.chain(t,function(r){return Ge(r)?e.of(r):n(r.right)})}}function Oo(e){return function(t,n){return function(r){return e.map(r,Dt(t,n))}}}var Cr=function(e,t){return ce(e,Do(t))},jo=function(e,t){return ce(e,Uo(t))},Do=function(e){return function(t){return function(){return Promise.resolve().then(t).then(e)}}},Uo=function(e){return function(t){return function(){return Promise.all([Promise.resolve().then(t),Promise.resolve().then(e)]).then(function(n){var r=n[0],i=n[1];return r(i)})}}},Fr=function(e){return function(){return Promise.resolve(e)}},xo=jt(2,function(e,t){return function(){return Promise.resolve().then(e).then(function(n){return t(n)()})}}),Sr="Task",Go={URI:Sr,map:Cr},kr={of:Fr},Wo={URI:Sr,map:Cr,of:Fr,ap:jo,chain:xo},Ho=Vo(kr),Er=Lo(kr),No=Oo(Go),$r=jt(2,Ro(Wo)),zo=$r,Ko=$r;class Ar extends H("MethodUnsupportedError",(t,n)=>[`Method "${t}" is unsupported in Mini Apps version ${n}`]){}class Ir extends H("MethodParameterUnsupportedError",(t,n,r)=>[`Parameter "${n}" of "${t}" method is unsupported in Mini Apps version ${r}`]){}class qr extends br("LaunchParamsRetrieveError",t=>({errors:t}),t=>[["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/tma-js-bridge/environment","","Collected errors:",...t.map(({source:n,error:r})=>`Source: ${n} / ${r instanceof Error?r.message:String(r)}`)].join(`
|
|
2
|
+
`)]){}class Br extends H("InvalidLaunchParamsError",(t,n)=>[`Invalid value for launch params: ${t}`,{cause:n}]){}class Tr extends H("UnknownEnvError"){}class Pr extends H("InvokeCustomMethodError",t=>[`Server returned error: ${t}`]){}const Mr="launchParams";function Lr(e){return e.replace(/^[^?#]*[?#]/,"").replace(/[?#]/g,"&")}const Be=xe(We,Ao(at)),Jo=X(Be),xt=xe(We,So(e=>{const t=new URLSearchParams(e).get("tgWebAppData");return t?Bo(t):qo})),Qo=xe(xt,$o(e=>{throw e},e=>e),Mo(()=>{},e=>e));function We(){const e=[];for(const[t,n]of[[()=>Lr(window.location.href),"window.location.href"],[()=>{const r=performance.getEntriesByType("navigation")[0];return r&&Lr(r.name)},"performance navigation entries"],[()=>Un(Mr),"local storage"]]){const r=t();if(!r){e.push({source:n,error:new Error("Source is empty")});continue}const i=ce(at(r),Eo(s=>s,()=>!0));if(typeof i!="boolean"){e.push({source:n,error:i});continue}return Pt(Mr,r),te(r)}return Se(new qr(e))}const Zo=X(We);function Yo(e,t){const n=new Map,r=mo(),i=(s,a,u=!1)=>{const l=n.get(s)||new Map;n.set(s,l);const c=l.get(a)||[];l.set(a,c);const h=c.findIndex(f=>f[1]===u);if(h>=0&&(r.off(s,c[h][0]),c.splice(h,1),!c.length&&(l.delete(a),!l.size))){const f=n.size;n.delete(s),f&&!n.size&&t()}};return{on(s,a,u){!n.size&&e();const l=()=>{i(s,a,u)},c=(...b)=>{u&&l(),s==="*"?a({name:b[0],payload:b[1]}):a(...b)};r.on(s,c);const h=n.get(s)||new Map;n.set(s,h);const f=h.get(a)||[];return h.set(a,f),f.push([c,u||!1]),l},off:i,emit:r.emit,clear(){const s=n.size;r.all.clear(),n.clear(),s&&t()}}}function Gt(e,t){window.dispatchEvent(new MessageEvent("message",{data:JSON.stringify({eventType:e,eventData:t}),source:window.parent}))}function Wt(e,t,n){const r=[n],i=e[t];typeof i=="function"&&r.push(i);const s=(...u)=>{r.forEach(l=>l(...u))},a=Object.assign((...u)=>{s(...u)},{unwrap(){const{length:u}=r;if(u===1){delete e[t];return}if(u===2){Or(e,t,r[1]);return}r.unshift(1),Or(e,t,s)}});Rr(e,t,()=>a,u=>r.push(u))}function Vr(e,t){const n=e[t];Rr(e,t,()=>n,r=>{Object.entries(r).forEach(([i,s])=>{n[i]=s})})}function Rr(e,t,n,r){Object.defineProperty(e,t,{enumerable:!0,configurable:!0,get:n,set:r})}function Or(e,t,n){Object.defineProperty(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n})}const Xo={clipboard_text_received:j({req_id:C(),data:Ie(C())}),custom_method_invoked:j({req_id:C(),result:$(At()),error:$(C())}),popup_closed:Ie(j({button_id:Ie(C(),()=>{})}),{}),viewport_changed:Ie(j({height:de(),width:Ie(de(),()=>window.innerWidth),is_state_stable:Ce(),is_expanded:Ce()}),()=>({height:window.innerHeight,is_state_stable:!0,is_expanded:!0})),theme_changed:j({theme_params:Rt()})};function jr(e){if(e.source!==window.parent)return;let t;try{t=_e(me(lr()),e.data)}catch{return}const{eventType:n,eventData:r}=t,i=Xo[n];let s;try{s=i?_e(i,r):r}catch(a){return le().forceError([`An error occurred processing the "${n}" event from the Telegram application.`,"Please, file an issue here:","https://github.com/Telegram-Mini-Apps/telegram-apps/issues/new/choose"].join(`
|
|
3
|
+
`),t,a)}ea(n,s)}const{on:ee,off:ke,emit:ea,clear:ta}=Yo(()=>{const e=window;!e.TelegramGameProxy&&(e.TelegramGameProxy={}),Wt(e.TelegramGameProxy,"receiveEvent",Gt),Vr(e,"TelegramGameProxy"),!e.Telegram&&(e.Telegram={}),!e.Telegram.WebView&&(e.Telegram.WebView={}),Wt(e.Telegram.WebView,"receiveEvent",Gt),Vr(e.Telegram,"WebView"),Wt(e,"TelegramGameProxy_receiveEvent",Gt),window.addEventListener("message",jr)},()=>{[["TelegramGameProxy_receiveEvent"],["TelegramGameProxy","receiveEvent"],["Telegram","WebView","receiveEvent"]].forEach(e=>{const t=window;let n=[void 0,t];for(const s of e)if(n=[n[1],n[1][s]],!n[1])return;const[r,i]=n;"unwrap"in i&&(i.unwrap(),r&&r!==t&&!Object.keys(r).length&&delete t[e[0]])}),window.removeEventListener("message",jr)}),Ht=W(!1),Dr=W("https://web.telegram.org"),na=e=>{le().log("Event received:",e)},Ur=F(Ht);function ra(e){e!==Ht()&&(Ht.set(e),(e?ee:ke)("*",na))}const xr=F(Dr);function sa(e){Dr.set(e),le().log("New target origin set",e)}const ut=W((...e)=>{window.parent.postMessage(...e)}),le=W(xn("Bridge",{bgColor:"#9147ff",textColor:"white",shouldLog:Ur})),ia=(...e)=>ut()(...e);function oa(e,t){ce(Nt(e,t),ko(n=>{throw n}))}function Nt(e,t){le().log("Posting event:",t?{eventType:e,eventData:t}:{eventType:e});const n=window,r=JSON.stringify({eventType:e,eventData:t});return vr()?(ia(r,xr()),te(void 0)):gr(n)?(n.TelegramWebviewProxy.postEvent(e,JSON.stringify(t)),te(void 0)):St(j({external:j({notify:kt()})}),n)?(n.external.notify(r),te(void 0)):Se(new Tr)}function zt(e,t,n={}){const{capture:r=()=>!0,postEvent:i=Nt}=n;return ce(async()=>i(e,n.params),Ko(()=>De((s,a,u)=>{const[l,c]=st();(Array.isArray(t)?t:[t]).forEach(h=>{l(ee(h,f=>{(Array.isArray(t)?r({event:h,payload:f}):r(f))&&s(f)}))}),u.on("finalized",c)},n)))}function aa(e,t){const n=Kt(e,t);return typeof n=="function"?rt.fn(()=>je(n)):n}function Kt(e,t){const n=gr(window);if(!e)return n||ce(We(),Dt(()=>!1,()=>!0));if(n)return Er(!0);const{timeout:r=100}=t||{};return ce(zt("web_app_request_theme","theme_changed",{...t,timeout:r}),No(i=>Bt.is(i)?te(!1):Se(i),()=>te(!0)))}function ua({launchParams:e,onEvent:t,resetPostMessage:n}={}){if(e){const s=typeof e=="string"||e instanceof URLSearchParams?e.toString():_r({...e,tgWebAppData:void 0})+(e.tgWebAppData?`&tgWebAppData=${encodeURIComponent(e.tgWebAppData.toString())}`:"");try{hr(s)}catch(a){throw new Br(s,a)}Pt("launchParams",s)}if(vr()){if(!t)return;n&&ut.reset();const s=ut();ut.set((...a)=>{const[u]=a,l=()=>{s(...a)};try{const c=_e(me(lr()),u);t([c.eventType,c.eventData],l)}catch{l()}});return}const r=window.TelegramWebviewProxy||{},i=r.postEvent||(()=>{});window.TelegramWebviewProxy={...r,postEvent(s,a){const u=()=>{i(s,a)};t?t([s,a?JSON.parse(a):void 0],u):u()}},le().log("Environment was mocked by the mockTelegramEnv function")}function Gr(e){return({req_id:t})=>t===e}function Wr(e){return e.split(".").map(Number)}function ca(e,t){const n=Wr(e),r=Wr(t),i=Math.max(n.length,r.length);for(let s=0;s<i;s+=1){const a=n[s]||0,u=r[s]||0;if(a!==u)return a>u?1:-1}return 0}const Hr={"6.0":["iframe_ready","iframe_will_reload","web_app_close","web_app_data_send","web_app_expand","web_app_open_link","web_app_ready","web_app_request_theme","web_app_request_viewport","web_app_setup_main_button","web_app_setup_closing_behavior"],6.1:["web_app_open_tg_link","web_app_open_invoice","web_app_setup_back_button","web_app_set_background_color","web_app_set_header_color","web_app_trigger_haptic_feedback"],6.2:["web_app_open_popup"],6.4:["web_app_close_scan_qr_popup","web_app_open_scan_qr_popup","web_app_read_text_from_clipboard",{method:"web_app_open_link",param:"try_instant_view"}],6.7:["web_app_switch_inline_query"],6.9:["web_app_invoke_custom_method","web_app_request_write_access","web_app_request_phone",{method:"web_app_set_header_color",param:"color"}],"6.10":["web_app_setup_settings_button"],7.2:["web_app_biometry_get_info","web_app_biometry_open_settings","web_app_biometry_request_access","web_app_biometry_request_auth","web_app_biometry_update_token"],7.6:[{method:"web_app_open_link",param:"try_browser"},{method:"web_app_close",param:"return_back"}],7.7:["web_app_setup_swipe_behavior"],7.8:["web_app_share_to_story"],"7.10":["web_app_setup_secondary_button","web_app_set_bottom_bar_color",{method:"web_app_setup_main_button",param:"has_shine_effect"}],"8.0":["web_app_request_safe_area","web_app_request_content_safe_area","web_app_request_fullscreen","web_app_exit_fullscreen","web_app_set_emoji_status","web_app_add_to_home_screen","web_app_check_home_screen","web_app_request_emoji_status_access","web_app_check_location","web_app_open_location_settings","web_app_request_file_download","web_app_request_location","web_app_send_prepared_message","web_app_start_accelerometer","web_app_start_device_orientation","web_app_start_gyroscope","web_app_stop_accelerometer","web_app_stop_device_orientation","web_app_stop_gyroscope","web_app_toggle_orientation_lock"],"9.0":["web_app_device_storage_clear","web_app_device_storage_get_key","web_app_device_storage_save_key","web_app_secure_storage_clear","web_app_secure_storage_get_key","web_app_secure_storage_restore_key","web_app_secure_storage_save_key"],9.1:["web_app_hide_keyboard"]};function Jt(e,t){return Object.keys(Hr).find(n=>Hr[n].some(r=>t?typeof r=="object"&&r.method===e&&r.param===t:r===e))||null}function pe(e,t,n){const r=n?Jt(e,t):Jt(e);return r?ca(r,n||t)<=0:!1}function la(e,t="strict"){const n=typeof t=="function"?t:r=>{const{method:i,version:s}=r,a="param"in r?new Ir(i,r.param,s):new Ar(i,s);if(t==="strict")throw a;return le().forceWarn(a.message)};return(r,i)=>pe(r,e)?r==="web_app_set_header_color"&&St(j({color:Bn()}),i)&&!pe(r,"color",e)?n({version:e,method:r,param:"color"}):oa(r,i):n({version:e,method:r})}function pa(e,t,n,r){return ce(zt("web_app_invoke_custom_method","custom_method_invoked",{...r||{},params:{method:e,params:t,req_id:n},capture:Gr(n)}),zo(({result:i,error:s})=>s?Ho(new Pr(s)):Er(i)))}function ha(){Object.hasOwn||(Object.hasOwn=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)})}function Qt(e){return Ut(()=>decodeURIComponent(atob(e).replace(/-/g,"+").replace(/_/g,"/").split("").map(t=>"%"+("00"+t.charCodeAt(0).toString(16)).slice(-2)).join("")),t=>t)}const fa=X(Qt);function Zt(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(t,n)=>String.fromCharCode(parseInt(`0x${n}`)))).replace(/\+/g,"-").replace(/\//g,"_")}var da=function(e){return Ut(function(){return JSON.parse(e)},go)};function Nr(e){const t=Zt(typeof e=="string"?e:JSON.stringify(e));return t.length>512?Se(new Error("Value is too long for start parameter")):te(t)}const _a=X(Nr);function ma(e,t){return je(zr(e,typeof t=="function"?n=>Ut(()=>t(n),r=>r):t))}function zr(e,t){return ce(Qt(e),Io(n=>t?typeof t=="function"?t(n):da(n):te(n)))}function ba(e){return Zt(e).length<=512}function Q(e){return typeof e=="function"?e():e}function ie(e,t){return F(()=>pe(e,Q(t)))}var Te=Js,He=Qs,ga=function(e,t){return d(e,ya(t))},va=function(e,t){return d(e,Fa(t))},wa="Option",ya=function(e){return function(t){return Ne(t)?Te:He(e(t.value))}},Ca=He,Fa=function(e){return function(t){return Ne(t)||Ne(e)?Te:He(t.value(e.value))}},Sa=Ve(2,function(e,t){return Ne(e)?Te:t(e.value)}),ka={URI:wa,map:ga,ap:va,chain:Sa},Ne=function(e){return e._tag==="None"},Ea=function(e,t){return function(n){return Ne(n)?e():t(n.value)}},Kr=Ea,$a=Ca(dt),Jr=_t(ka);function Aa(e){return we(P,e.of)}function Ia(e){return we(O,e.of)}function qa(e){return Xs(e,ti)}function Ba(e){return Ys(e,ii)}function Ta(e){return function(t,n){return e.chain(t,function(r){return ye(r)?e.of(r):n(r.right)})}}function Pa(e){return function(t,n,r){return e.map(t,ai(n,r))}}function Ma(e){return function(t,n){return function(r){return e.map(r,Re(t,n))}}}var Yt=function(e,t){return d(e,La(t))},Qr=function(e,t){return d(e,Va(t))},La=function(e){return function(t){return function(){return Promise.resolve().then(t).then(e)}}},Va=function(e){return function(t){return function(){return Promise.all([Promise.resolve().then(t),Promise.resolve().then(e)]).then(function(n){var r=n[0],i=n[1];return r(i)})}}},Xt=function(e){return function(){return Promise.resolve(e)}},Ra=Ve(2,function(e,t){return function(){return Promise.resolve().then(e).then(function(n){return t(n)()})}}),en="Task",tn={URI:en,map:Yt},Zr={of:Xt},Oa={URI:en,map:Yt,ap:Qr},ja={URI:en,map:Yt,of:Xt,ap:Qr,chain:Ra},Da=function(e,t,n,r){function i(s){return s instanceof n?s:new n(function(a){a(s)})}return new(n||(n=Promise))(function(s,a){function u(h){try{c(r.next(h))}catch(f){a(f)}}function l(h){try{c(r.throw(h))}catch(f){a(f)}}function c(h){h.done?s(h.value):i(h.value).then(u,l)}c((r=r.apply(e,t||[])).next())})},Ua=function(e,t){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,i,s,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(c){return function(h){return l([c,h])}}function l(c){if(r)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(n=0)),n;)try{if(r=1,i&&(s=c[0]&2?i.return:c[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,c[1])).done)return s;switch(i=0,s&&(c=[c[0]&2,s.value]),c[0]){case 0:case 1:s=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,i=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(s=n.trys,!(s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]<s[3])){n.label=c[1];break}if(c[0]===6&&n.label<s[1]){n.label=s[1],s=c;break}if(s&&n.label<s[2]){n.label=s[2],n.ops.push(c);break}s[2]&&n.ops.pop(),n.trys.pop();continue}c=t.call(e,n)}catch(h){c=[6,h],i=0}finally{r=s=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},N=Ia(Zr),R=Aa(Zr),Yr=Xt,xa=Ma(tn),Ga=function(e,t){return function(){return Da(void 0,void 0,void 0,function(){var n;return Ua(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,e().then(En)];case 1:return[2,r.sent()];case 2:return n=r.sent(),[2,kn(t(n))];case 3:return[2]}})})}},Wa=function(e,t){return d(e,V(t))},Ha=function(e,t){return d(e,Na(t))},V=qa(tn),nn=Ve(3,Pa(tn)),Na=Ba(Oa),rn=Ve(2,Ta(ja)),za=R,Ka="TaskEither",Ja={URI:Ka,map:Wa,ap:Ha,chain:rn},Qa=za(dt),Za=_t(Ja),ct=Za,he=rn,Pe=rn;function Ee(e){return[e]}class ze extends br("ValidationError",(t,n)=>({input:t,issues:n}),"Validation error"){}class lt extends H("CSSVarsBoundError","CSS variables are already bound"){}class Xr extends H("NotAvailableError",Ee){}class Ya extends H("InvalidEnvError",Ee){}class es extends H("FunctionNotAvailableError",Ee){}class ne extends H("InvalidArgumentsError",(t,n)=>[t,{cause:n}]){}class pt extends H("ConcurrentCallError",Ee){}class ts extends H("SetEmojiStatusError",t=>[`Failed to set emoji status: ${t}`]){}class sn extends H("AccessDeniedError",Ee){}class ns extends H("FullscreenFailedError",Ee){}class rs extends H("ShareMessageError",Ee){}class ss extends H("UnknownThemeParamsKeyError",t=>[`Unknown theme params key passed: ${t}`]){}function T(e,t){const n=F(()=>Q(t.version)||"100"),r=F(()=>Q(t.isTma)),{requires:i}=t,s=i?typeof i=="object"?i:{every:[i]}:void 0,a=y=>{if(!t.supports)return!0;const w=t.supports[y];return pe(w.method,w.param,n())},u=()=>{if(!s)return;const[y,w]="every"in s?["every",s.every]:["some",s.some];for(let g=0;g<w.length;g++){const S=w[g],_=typeof S=="function"?S():pe(S,n())?void 0:`it is unsupported in Mini Apps version ${n()}`;if(_&&(y==="every"||g===w.length-1))return _}},l=(...y)=>{for(const w in t.supports)if(t.supports[w].shouldCheck(...y)&&!a(w))return`option ${w} is not supported in Mini Apps version ${n()}`},c=F(()=>!u()),h=F(()=>n()!=="0.0"),f=F(()=>t.isMounted?t.isMounted():!0),b=F(()=>r()&&h()&&c()&&f()),v=y=>{const w=new es(y);return["task","promise"].includes(t.returns)?N(w):O(w)};return Object.assign((...y)=>{var D;const w="Unable to call function:";if(!r())return v(`${w} it can't be called outside Mini Apps`);if(!h())return v(`${w} the SDK was not initialized. Use the SDK init() function`);const g=u();if(g)return v(`${w} ${g}`);const S=l(...y);if(S)return v(`${w} ${S}`);if(!f()){const M=(D=t.isMounting)!=null&&D.call(t)?"mounting. Wait for the mount completion":"unmounted. Use the mount() method";return v(`${w} the component is ${M}`)}const{returns:_}=t;return _==="plain"?ui(()=>e(...y),M=>M):_==="promise"?Ga(()=>e(...y),M=>M):e(...y)},e,{isAvailable:b,ifAvailable(...y){return b()?He(e(...y)):Te}},s?{isSupported:c}:{},t.supports?{supports:a}:{})}function B(e){return t=>T(t,e)}function m(e){return Object.assign(X(e),{ifAvailable(...t){return d(e.ifAvailable(...t),Kr(()=>({ok:!1}),n=>({ok:!0,data:je(n)})))}})}function on(e){const t={};for(const n in e){const r=e[n];r!==void 0&&(t[n]=r)}return t}function an(e,t){const n=Object.keys(e),r=Object.keys(t);return n.length!==r.length?!1:n.every(i=>Object.prototype.hasOwnProperty.call(t,i)&&e[i]===t[i])}class be{constructor({initialState:t,onChange:n}){o(this,"_state");o(this,"state");o(this,"setState",t=>{const n={...this.state(),...on(t)};an(n,this.state())||this._state.set(n)});this._state=W(t,{equals:an}),this.state=F(this._state),this.state.sub(n)}getter(t){return F(()=>this._state()[t])}hasDiff(t){return!an({...this.state(),...on(t)},this.state())}}class Ke{constructor({onMounted:t,restoreState:n,initialState:r,onUnmounted:i,isPageReload:s}){o(this,"_isMounted",W(!1));o(this,"isMounted",F(this._isMounted));o(this,"mount");o(this,"unmount");this.mount=()=>{if(this.isMounted())return P(void 0);const a=Q(s)?n():void 0,u=a?P(a):typeof r=="function"?r():P(r);return d(u,Z(l=>{Xe(()=>{this._isMounted.set(!0),t==null||t(l)})}))},this.unmount=()=>{this._isMounted()&&Xe(()=>{this._isMounted.set(!1),i==null||i()})}}}class ht{constructor({isTma:t,storage:n,onClick:r,offClick:i,initialState:s,isPageReload:a,postEvent:u,payload:l,method:c,version:h}){o(this,"isMounted");o(this,"isSupported");o(this,"state");o(this,"stateSetters");o(this,"stateBoolSetters");o(this,"setStateFp");o(this,"setState");o(this,"onClickFp");o(this,"onClick");o(this,"offClickFp");o(this,"offClick");o(this,"mountFp");o(this,"mount");o(this,"unmount");const f=new be({initialState:s,onChange(g){n.set(g)}}),b=new Ke({initialState:s,isPageReload:a,onMounted:f.setState,restoreState:n.get}),v={version:h,requires:c,isTma:t},y=B({...v,returns:"plain"}),w=B({...v,returns:"either",isMounted:b.isMounted});this.isMounted=b.isMounted,this.isSupported=ie(c,h),this.state=f.state,this.setStateFp=w(g=>{const S={...this.state(),...on(g)};return f.hasDiff(S)?d(u(c,l(S)),Z(()=>{f.setState(S)})):P(void 0)}),this.setState=m(this.setStateFp),this.onClickFp=y(r),this.onClick=m(this.onClickFp),this.offClickFp=y(i),this.offClick=m(this.offClickFp),this.mountFp=y(()=>{const g=()=>{};return d(b.mount(),Re(g,g))}),this.mount=m(this.mountFp),this.unmount=b.unmount,this.stateSetters=g=>{const S=w(_=>this.setStateFp({[g]:_}));return[m(S),S]},this.stateBoolSetters=g=>{const[,S]=this.stateSetters(g),_=w(()=>S(!1)),D=w(()=>S(!0));return[[m(_),_],[m(D),D]]}}stateGetter(t){return F(()=>this.state()[t])}}class is{constructor(t){o(this,"isVisible");o(this,"isMounted");o(this,"isSupported");o(this,"hideFp");o(this,"hide");o(this,"showFp");o(this,"show");o(this,"onClickFp");o(this,"onClick");o(this,"offClickFp");o(this,"offClick");o(this,"mountFp");o(this,"mount");o(this,"unmount");const n=new ht({...t,method:"web_app_setup_back_button",payload:r=>({is_visible:r.isVisible}),initialState:{isVisible:!1}});this.isVisible=n.stateGetter("isVisible"),this.isMounted=n.isMounted,this.isSupported=n.isSupported,[[this.hide,this.hideFp],[this.show,this.showFp]]=n.stateBoolSetters("isVisible"),this.onClick=n.onClick,this.onClickFp=n.onClickFp,this.offClick=n.offClick,this.offClickFp=n.offClickFp,this.mount=n.mount,this.mountFp=n.mountFp,this.unmount=n.unmount}}function E(){return{isTma:F(()=>Kt())}}function Xa(e){return{get:()=>Un(e),set(t){Pt(e,t)}}}function eu(){return performance.getEntriesByType("navigation")[0]}function tu(){const e=eu();return!!e&&e.type==="reload"}function Je(e){return t=>({...t,...Q(e)})}function ge(e){return Je({storage:Xa(e),isPageReload:tu})}function Qe(e,t){return W(e,t)}const os=Qe(Nt),Me=(...e)=>os()(...e),as=(...e)=>je(Me(...e)),z=Je({postEvent:Me}),un=Qe("0.0"),A=Je({version:un});function cn(e,t){return{...d(E(),z,A,ge(e)),onClick(n,r){return ee(t,n,r)},offClick(n,r){ke(t,n,r)}}}const nu=new is(cn("backButton","back_button_pressed"));class ln{constructor({initialState:t,onMounted:n,restoreState:r,onUnmounted:i,isPageReload:s}){o(this,"_isMounted",W(!1));o(this,"isMounted",F(this._isMounted));o(this,"mount");o(this,"unmount");this.mount=a=>{if(this._isMounted())return R(void 0);const u=Q(s)?r():void 0;return d(u?R(u):t(a),V(l=>{this._isMounted()||Xe(()=>{this._isMounted.set(!0),n==null||n(l)})}))},this.unmount=()=>{this._isMounted()&&Xe(()=>{this._isMounted.set(!1),i==null||i()})}}}const us=new Xr("Biometry is not available");function pn(e){let t=!1,n=!1,r="",i=!1,s="",a=!1;return e.available&&(t=!0,n=e.token_saved,r=e.device_id,i=e.access_requested,s=e.type,a=e.access_granted),{available:t,tokenSaved:n,deviceId:r,type:s,accessGranted:a,accessRequested:i}}class cs{constructor({version:t,request:n,postEvent:r,storage:i,onInfoReceived:s,offInfoReceived:a,isTma:u,isPageReload:l}){o(this,"isAvailable");o(this,"isSupported");o(this,"isMounted");o(this,"state");o(this,"authenticateFp");o(this,"authenticate");o(this,"openSettingsFp");o(this,"openSettings");o(this,"requestAccessFp");o(this,"requestAccess");o(this,"updateTokenFp");o(this,"updateToken");o(this,"mountFp");o(this,"mount");o(this,"unmount");const c=g=>{h.setState(pn(g))},h=new be({initialState:{available:!1,type:"unknown",accessGranted:!1,accessRequested:!1,deviceId:"",tokenSaved:!1},onChange:i.set}),f=new ln({initialState(g){return d(n("web_app_biometry_get_info","biometry_info_received",g),V(pn))},isPageReload:l,onMounted(g){h.setState(g),s(c)},onUnmounted(){a(c)},restoreState:i.get}),b={version:t,requires:"web_app_biometry_request_auth",isTma:u},v=B({...b,returns:"either"}),y=B({...b,returns:"task"}),w=B({...b,isMounted:f.isMounted,returns:"task"});this.isAvailable=h.getter("available"),this.isMounted=f.isMounted,this.isSupported=ie("web_app_biometry_request_auth",t),this.state=h.state,this.unmount=f.unmount,this.mountFp=y(f.mount),this.authenticateFp=w(g=>this.isAvailable()?d(n("web_app_biometry_request_auth","biometry_auth_requested",{...g,params:{reason:((g||{}).reason||"").trim()}}),V(S=>(h.setState({token:S.token}),S))):N(us)),this.openSettingsFp=v(()=>r("web_app_biometry_open_settings")),this.requestAccessFp=w(g=>d(n("web_app_biometry_request_access","biometry_info_received",{...g,params:{reason:((g||{}).reason||"").trim()}}),he(S=>{const _=pn(S);return _.available?(h.setState(_),R(_.accessRequested)):N(us)}))),this.updateTokenFp=w((g={})=>{var S;return d(n("web_app_biometry_update_token","biometry_token_updated",{...g,params:{token:g.token||"",reason:(S=g.reason)==null?void 0:S.trim()}}),V(_=>_.status))}),this.authenticate=m(this.authenticateFp),this.openSettings=m(this.openSettingsFp),this.requestAccess=m(this.requestAccessFp),this.updateToken=m(this.updateTokenFp),this.mount=m(this.mountFp)}}const hn=(e,t,n)=>zt(e,t,{postEvent:Me,...n}),ru=(...e)=>rt.fn(()=>hn(...e)()),Y=Je({request:hn}),su=new cs({...d(E(),z,A,Y,ge("biometry")),offInfoReceived(e){ke("biometry_info_received",e)},onInfoReceived(e){return ee("biometry_info_received",e)}});class ls{constructor({postEvent:t,storage:n,isTma:r,isPageReload:i}){o(this,"isConfirmationEnabled");o(this,"isMounted");o(this,"mountFp");o(this,"mount");o(this,"unmount");o(this,"disableConfirmationFp");o(this,"disableConfirmation");o(this,"enableConfirmationFp");o(this,"enableConfirmation");const s=new be({initialState:{isConfirmationEnabled:!1},onChange(f){n.set(f)}}),a=new Ke({onMounted:s.setState,restoreState:n.get,initialState:{isConfirmationEnabled:!1},isPageReload:i}),u={requires:"web_app_setup_closing_behavior",isTma:r},l=B({...u,returns:"plain"}),c=B({...u,returns:"either",isMounted:a.isMounted}),h=f=>f===this.isConfirmationEnabled()?P(void 0):(s.setState({isConfirmationEnabled:f}),t("web_app_setup_closing_behavior",{need_confirmation:f}));this.isConfirmationEnabled=s.getter("isConfirmationEnabled"),this.isMounted=a.isMounted,this.disableConfirmationFp=c(()=>h(!1)),this.enableConfirmationFp=c(()=>h(!0)),this.mountFp=l(()=>{const f=()=>{};return d(a.mount(),Re(f,f))}),this.unmount=a.unmount,this.disableConfirmation=m(this.disableConfirmationFp),this.enableConfirmation=m(this.enableConfirmationFp),this.mount=m(this.mountFp)}}const iu=new ls(d(E(),ge("closingBehavior"),z));class ps{constructor({version:t,isTma:n,invokeCustomMethod:r}){o(this,"isSupported");o(this,"deleteItemFp");o(this,"deleteItem");o(this,"getItemFp");o(this,"getItem");o(this,"getItemsFp");o(this,"getItems");o(this,"getKeysFp");o(this,"getKeys");o(this,"setItemFp");o(this,"setItem");o(this,"clearFp");o(this,"clear");const i=B({version:t,requires:"web_app_invoke_custom_method",isTma:n,returns:"task"});this.isSupported=ie("web_app_invoke_custom_method",t),this.deleteItemFp=i((s,a)=>{const u=Array.isArray(s)?s:[s];return d(u.length?r("deleteStorageValues",{keys:u},a):R(void 0),V(()=>{}))}),this.getItemFp=i((s,a)=>d(this.getItemsFp([s],a),V(u=>u[s]||""))),this.getItemsFp=i((s,a)=>d(s.length?r("getStorageValues",{keys:s},a):R({}),V(u=>({...s.reduce((l,c)=>(l[c]="",l),{}),..._e($t(C(),C()),u)})))),this.getKeysFp=i(s=>d(r("getStorageKeys",{},s),V(a=>_e(Tn(C()),a)))),this.setItemFp=i((s,a,u)=>d(r("saveStorageValue",{key:s,value:a},u),V(()=>{}))),this.clearFp=i(s=>d(this.getKeysFp(s),he(this.deleteItemFp))),this.deleteItem=m(this.deleteItemFp),this.getItem=m(this.getItemFp),this.getItems=m(this.getItemsFp),this.getKeys=m(this.getKeysFp),this.setItem=m(this.setItemFp),this.clear=m(this.clearFp)}}const fn=Qe(0);function dn(){return fn.set(fn()+1),fn().toString()}function hs(e,t,n){return pa(e,t,dn(),{...n||{},postEvent:Me})}const _n=Je({invokeCustomMethod:hs}),ou=new ps(d(E(),A,_n));function au({request:e,...t}){return T(n=>d(e("web_app_request_emoji_status_access","emoji_status_access_requested",n),V(r=>r.status)),{...t,requires:"web_app_request_emoji_status_access",returns:"task"})}const fs=au(d(E(),A,Y)),uu=m(fs);function cu({request:e,...t}){return T((n,r)=>d(e("web_app_set_emoji_status",["emoji_status_set","emoji_status_failed"],{params:{custom_emoji_id:n,duration:(r||{}).duration},...r}),Pe(i=>i&&"error"in i?N(new ts(i.error)):R(void 0))),{...t,requires:"web_app_set_emoji_status",returns:"task"})}const ds=cu(d(E(),Y,A)),lu=m(ds);class _s{constructor({postEvent:t,isTma:n,version:r}){o(this,"isSupported");o(this,"impactOccurredFp");o(this,"impactOccurred");o(this,"notificationOccurredFp");o(this,"notificationOccurred");o(this,"selectionChangedFp");o(this,"selectionChanged");const i="web_app_trigger_haptic_feedback",s=B({requires:i,isTma:n,version:r,returns:"plain"});this.isSupported=ie(i,r),this.impactOccurredFp=s(a=>t(i,{type:"impact",impact_style:a})),this.notificationOccurredFp=s(a=>t(i,{type:"notification",notification_type:a})),this.selectionChangedFp=s(()=>t(i,{type:"selection_change"})),this.impactOccurred=m(this.impactOccurredFp),this.notificationOccurred=m(this.notificationOccurredFp),this.selectionChanged=m(this.selectionChangedFp)}}const pu=new _s(d(E(),z,A));function hu({postEvent:e,...t}){return T(()=>e("web_app_add_to_home_screen"),{...t,requires:"web_app_add_to_home_screen",returns:"either"})}const ms=hu(d(E(),A,z)),fu=m(ms);function du({request:e,...t}){return T(n=>d(e("web_app_check_home_screen","home_screen_checked",n),V(r=>r.status||"unknown")),{...t,requires:"web_app_check_home_screen",returns:"task"})}const bs=du(d(E(),A,Y)),_u=m(bs);class gs{constructor({retrieveInitData:t}){o(this,"_state",W());o(this,"_raw",W());o(this,"state",F(this._state));o(this,"authDate",this.fromState("auth_date"));o(this,"canSendAfter",this.fromState("can_send_after"));o(this,"canSendAfterDate",F(()=>{const t=this.authDate(),n=this.canSendAfter();return n&&t?new Date(t.getTime()+n*1e3):void 0}));o(this,"chat",this.fromState("chat"));o(this,"chatType",this.fromState("chat_type"));o(this,"chatInstance",this.fromState("chat_instance"));o(this,"hash",this.fromState("hash"));o(this,"queryId",this.fromState("query_id"));o(this,"raw",F(this._raw));o(this,"receiver",this.fromState("receiver"));o(this,"signature",this.fromState("signature"));o(this,"startParam",this.fromState("start_param"));o(this,"user",this.fromState("user"));o(this,"restoreFp");o(this,"restore");this.restoreFp=()=>d(t(),Z(Kr(()=>{},({raw:n,obj:r})=>{this._state.set(r),this._raw.set(n)}))),this.restore=X(this.restoreFp)}fromState(t){return F(()=>{const n=this._state();return n?n[t]:void 0})}}const mu=new gs({retrieveInitData(){return d(ci,In("obj",()=>d(Be(),Z(({tgWebAppData:e})=>e?He(e):Te))),In("raw",xt),Z(({obj:e,raw:t})=>d($a,Jr("obj",()=>e),Jr("raw",()=>t))))}});class vs{constructor({version:t,request:n,isTma:r}){o(this,"isOpened");o(this,"isSupported");o(this,"openSlugFp");o(this,"openSlug");o(this,"openUrlFp");o(this,"openUrl");const i=B({version:t,isTma:r,requires:"web_app_open_invoice",returns:"task"}),s=W(!1),a=()=>{s.set(!1)};this.isSupported=ie("web_app_open_invoice",t),this.isOpened=F(s),this.openSlugFp=i((u,l)=>d(this.isOpened()?N(new pt("Invoice is already opened")):R(void 0),he(()=>(s.set(!0),n("web_app_open_invoice","invoice_closed",{...l,params:{slug:u},capture:c=>u===c.slug}))),nn(c=>(a(),c),c=>(a(),c.status)))),this.openUrlFp=i((u,l)=>{const{hostname:c,pathname:h}=new URL(u,window.location.href);if(c!=="t.me")return N(new ne(`Link has unexpected hostname: ${c}`));const f=h.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);return f?this.openSlugFp(f[2],l):N(new ne('Expected to receive a link with a pathname in format "/invoice/{slug}" or "/${slug}"'))}),this.openUrl=m(this.openUrlFp),this.openSlug=m(this.openSlugFp)}}const bu=new vs(d(E(),Y,A));function gu({postEvent:e,...t}){return T((n,r={})=>{if(typeof n=="string")try{n=new URL(n)}catch(i){return O(new ne(`"${n.toString()}" is invalid URL`,i))}return e("web_app_open_link",{url:n.toString(),try_browser:r.tryBrowser,try_instant_view:r.tryInstantView})},{...t,returns:"either"})}const ws=gu(d(E(),z)),vu=m(ws);function wu({postEvent:e,version:t,...n}){return T(r=>{const i=r.toString();return i.match(/^https:\/\/t.me\/.+/)?pe("web_app_open_tg_link",Q(t))?(r=new URL(r),e("web_app_open_tg_link",{path_full:r.pathname+r.search})):(window.location.href=i,P(void 0)):O(new ne(`"${i}" is invalid URL`))},{...n,returns:"either"})}const mn=wu(d(E(),z,A)),yu=m(mn);function Cu({openTelegramLink:e,...t}){return T((n,r)=>e("https://t.me/share/url?"+new URLSearchParams({url:n,text:r||""}).toString().replace(/\+/g,"%20")),{...t,returns:"either"})}const ys=Cu({...E(),openTelegramLink:mn}),Fu=m(ys);function Su(e){let t=!1,n,r;return e.available&&(t=!0,n=e.access_requested,r=e.access_granted),{available:t,accessGranted:r||!1,accessRequested:n||!1}}class Cs{constructor({version:t,request:n,postEvent:r,storage:i,isTma:s,isPageReload:a}){o(this,"state");o(this,"isAvailable");o(this,"isAccessGranted");o(this,"isAccessRequested");o(this,"isMounted");o(this,"isSupported");o(this,"openSettingsFp");o(this,"openSettings");o(this,"requestLocationFp");o(this,"requestLocation");o(this,"mountFp");o(this,"mount");o(this,"unmount");const u=new be({initialState:{available:!1,accessGranted:!1,accessRequested:!1},onChange:i.set}),l=new ln({isPageReload:a,restoreState:i.get,onMounted:u.setState,initialState(v){return d(n("web_app_check_location","location_checked",v),V(Su))}}),c={version:t,requires:"web_app_check_location",isTma:s},h=B({...c,returns:"either"}),f=B({...c,returns:"task"}),b=B({...c,returns:"task",isMounted:l.isMounted});this.isAvailable=u.getter("available"),this.isAccessRequested=u.getter("accessRequested"),this.isAccessGranted=u.getter("accessGranted"),this.isSupported=ie("web_app_check_location",t),this.isMounted=l.isMounted,this.state=u.state,this.unmount=l.unmount,this.mountFp=f(l.mount),this.openSettingsFp=h(()=>r("web_app_open_location_settings")),this.requestLocationFp=b(v=>d(n("web_app_request_location","location_requested",v),V(y=>{if(!y.available)return u.setState({available:!1}),null;const{available:w,...g}=y;return g}))),this.mount=m(this.mountFp),this.openSettings=m(this.openSettingsFp),this.requestLocation=m(this.requestLocationFp)}}const ku=new Cs(d(E(),z,A,Y,ge("locationManager")));class Fs{constructor({defaults:t,...n}){o(this,"bgColor");o(this,"hasShineEffect");o(this,"isEnabled");o(this,"isLoaderVisible");o(this,"isVisible");o(this,"isMounted");o(this,"state");o(this,"text");o(this,"textColor");o(this,"showFp");o(this,"show");o(this,"hideFp");o(this,"hide");o(this,"enableFp");o(this,"enable");o(this,"enableShineEffectFp");o(this,"enableShineEffect");o(this,"disableFp");o(this,"disable");o(this,"disableShineEffectFp");o(this,"disableShineEffect");o(this,"setBgColorFp");o(this,"setBgColor");o(this,"setTextColorFp");o(this,"setTextColor");o(this,"setTextFp");o(this,"setText");o(this,"showLoaderFp");o(this,"showLoader");o(this,"hideLoaderFp");o(this,"hideLoader");o(this,"setParamsFp");o(this,"setParams");o(this,"mountFp");o(this,"mount");o(this,"unmount");o(this,"onClickFp");o(this,"onClick");o(this,"offClickFp");o(this,"offClick");const r=new ht({...n,version:"100",initialState:{hasShineEffect:!1,isEnabled:!0,isLoaderVisible:!1,isVisible:!1,text:"Continue"},method:"web_app_setup_main_button",payload:s=>({has_shine_effect:s.hasShineEffect,is_visible:s.isVisible,is_active:s.isEnabled,is_progress_visible:s.isLoaderVisible,text:s.text,color:s.bgColor,text_color:s.textColor})}),i=(s,a)=>{const u=r.stateGetter(s);return F(()=>u()||Q(a))};this.bgColor=i("bgColor",t.bgColor),this.textColor=i("textColor",t.textColor),this.hasShineEffect=r.stateGetter("hasShineEffect"),this.isEnabled=r.stateGetter("isEnabled"),this.isLoaderVisible=r.stateGetter("isLoaderVisible"),this.text=r.stateGetter("text"),this.isVisible=r.stateGetter("isVisible"),this.isMounted=r.isMounted,this.state=r.state,[this.setBgColor,this.setBgColorFp]=r.stateSetters("bgColor"),[this.setTextColor,this.setTextColorFp]=r.stateSetters("textColor"),[[this.disableShineEffect,this.disableShineEffectFp],[this.enableShineEffect,this.enableShineEffectFp]]=r.stateBoolSetters("hasShineEffect"),[[this.disable,this.disableFp],[this.enable,this.enableFp]]=r.stateBoolSetters("isEnabled"),[[this.hideLoader,this.hideLoaderFp],[this.showLoader,this.showLoaderFp]]=r.stateBoolSetters("isLoaderVisible"),[this.setText,this.setTextFp]=r.stateSetters("text"),[[this.hide,this.hideFp],[this.show,this.showFp]]=r.stateBoolSetters("isVisible"),this.setParams=r.setState,this.setParamsFp=r.setStateFp,this.onClick=r.onClick,this.onClickFp=r.onClickFp,this.offClick=r.offClick,this.offClickFp=r.offClickFp,this.mount=r.mount,this.mountFp=r.mountFp,this.unmount=r.unmount}}function Ss(e,t,n){return d(cn(e,t),r=>({...r,defaults:n}))}const bn=Qe({});function gn(e,t){document.documentElement.style.setProperty(e,t)}function vn(e){document.documentElement.style.removeProperty(e)}function ks(e){return d(ot(e),Z(t=>Math.sqrt([.299,.587,.114].reduce((n,r,i)=>{const s=parseInt(t.slice(1+i*2,1+(i+1)*2),16);return n+s*s*r},0))<120))}const wn=X(ks);class Es{constructor({initialState:t,onChange:n,offChange:r,isTma:i,storage:s,isPageReload:a}){o(this,"accentTextColor");o(this,"bgColor");o(this,"buttonColor");o(this,"buttonTextColor");o(this,"bottomBarBgColor");o(this,"destructiveTextColor");o(this,"headerBgColor");o(this,"hintColor");o(this,"linkColor");o(this,"secondaryBgColor");o(this,"sectionBgColor");o(this,"sectionHeaderTextColor");o(this,"sectionSeparatorColor");o(this,"subtitleTextColor");o(this,"textColor");o(this,"_isCssVarsBound",W(!1));o(this,"isCssVarsBound",F(this._isCssVarsBound));o(this,"bindCssVarsFp");o(this,"bindCssVars");o(this,"state");o(this,"isDark",F(()=>{const t=this.bgColor();return!t||wn(t)}));o(this,"isMounted");o(this,"mountFp");o(this,"mount");o(this,"unmount");const u=new be({initialState:{},onChange:s.set}),l=v=>{u.setState(v.theme_params)},c=new Ke({initialState:()=>P(Q(t)),isPageReload:a,onMounted(v){u.setState(v),n(l)},onUnmounted(){r(l)},restoreState:s.get}),h={isTma:i,returns:"either"},f=B(h),b=B({...h,isMounted:c.isMounted});this.accentTextColor=u.getter("accent_text_color"),this.bgColor=u.getter("bg_color"),this.buttonColor=u.getter("button_color"),this.buttonTextColor=u.getter("button_text_color"),this.bottomBarBgColor=u.getter("bottom_bar_bg_color"),this.destructiveTextColor=u.getter("destructive_text_color"),this.headerBgColor=u.getter("header_bg_color"),this.hintColor=u.getter("hint_color"),this.linkColor=u.getter("link_color"),this.secondaryBgColor=u.getter("secondary_bg_color"),this.sectionBgColor=u.getter("section_bg_color"),this.sectionHeaderTextColor=u.getter("section_header_text_color"),this.sectionSeparatorColor=u.getter("section_separator_color"),this.subtitleTextColor=u.getter("subtitle_text_color"),this.textColor=u.getter("text_color"),this.state=u.state,this.isMounted=c.isMounted,this.bindCssVarsFp=b(v=>{if(this._isCssVarsBound())return O(new lt);v||(v=g=>`--tg-theme-${Ii(g)}`);const y=g=>{Object.entries(u.state()).forEach(([S,_])=>{_&&g(S,_)})},w=()=>{y((g,S)=>{gn(v(g),S)})};return w(),u.state.sub(w),this._isCssVarsBound.set(!0),P(()=>{y(vn),u.state.unsub(w),this._isCssVarsBound.set(!1)})}),this.mountFp=f(c.mount),this.unmount=c.unmount,this.bindCssVars=m(this.bindCssVarsFp),this.mount=m(this.mountFp)}}const Ze=new Es({...d(E(),ge("themeParams")),offChange(e){ke("theme_changed",e)},onChange(e){ee("theme_changed",e)},initialState:bn}),Eu=new Fs(Ss("mainButton","main_button_pressed",{bgColor:F(()=>Ze.buttonColor()||"#2481cc"),textColor:F(()=>Ze.buttonTextColor()||"#ffffff")}));class $s{constructor({storage:t,isPageReload:n,version:r,postEvent:i,isTma:s,theme:a,onVisibilityChanged:u,offVisibilityChanged:l}){o(this,"isSupported");o(this,"isDark",F(()=>{const t=this.bgColorRgb();return t?wn(t):!1}));o(this,"isActive");o(this,"state");o(this,"isCssVarsBound");o(this,"bindCssVarsFp");o(this,"bindCssVars");o(this,"isMounted");o(this,"mountFp");o(this,"mount");o(this,"unmount");o(this,"bgColor");o(this,"bgColorRgb");o(this,"setBgColorFp");o(this,"setBgColor");o(this,"headerColor");o(this,"headerColorRgb");o(this,"setHeaderColorFp");o(this,"setHeaderColor");o(this,"bottomBarColor");o(this,"bottomBarColorRgb");o(this,"setBottomBarColorFp");o(this,"setBottomBarColor");o(this,"closeFp");o(this,"close");o(this,"readyFp");o(this,"ready");const c=_=>{b.setState({isActive:_.is_visible})},h=_=>{[[this.headerColor,"web_app_set_header_color"],[this.bgColor,"web_app_set_background_color"],[this.bottomBarColor,"web_app_set_bottom_bar_color"]].forEach(([D,M])=>{const U=D();if(!Ue(U)&&(M==="web_app_set_header_color"||!["bg_color","secondary_bg_color"].includes(U))){const k=_[U];k&&i(M,{color:k})}})},f=new Ke({initialState(){const _=Q(a);return P({bgColor:_.bg_color||"bg_color",headerColor:_.header_bg_color||"header_bg_color",bottomBarColor:_.bottom_bar_bg_color||"bottom_bar_bg_color",isActive:!0})},isPageReload:n,onMounted:_=>{this.setBgColorFp.ifAvailable(_.bgColor),this.setBottomBarColorFp.ifAvailable(_.bottomBarColor),this.setHeaderColorFp.ifAvailable(_.headerColor),u(c),a.sub(h),b.setState(_)},onUnmounted(){l(c),a.unsub(h)},restoreState:t.get});this.isMounted=f.isMounted,this.mountFp=T(()=>{const _=()=>{};return d(f.mount(),Re(_,_))},{isTma:s,returns:"plain"}),this.mount=m(this.mountFp),this.unmount=f.unmount;const b=new be({initialState:{bgColor:"bg_color",bottomBarColor:"bottom_bar_bg_color",headerColor:"bg_color",isActive:!1},onChange:t.set});this.state=b.state;const v=_=>Ue(_)?_:Q(a)[_],y=_=>F(()=>v(_()));this.isActive=b.getter("isActive"),this.isSupported=F(()=>["web_app_set_header_color","web_app_set_background_color","web_app_set_bottom_bar_color"].some(_=>pe(_,Q(r))));const w=W(!1);this.isCssVarsBound=F(w),this.bindCssVarsFp=T(_=>{if(w())return O(new lt);const[D,M]=st(()=>{w.set(!1)}),U=(k,L)=>{const I=()=>{gn(k,L()||null)};I(),D(L.sub(I),vn.bind(null,k))};return _||(_=k=>`--tg-${jn(k)}`),U(_("bgColor"),this.bgColorRgb),U(_("bottomBarColor"),this.bottomBarColorRgb),U(_("headerColor"),this.headerColorRgb),w.set(!0),P(M)},{isTma:s,returns:"either",isMounted:this.isMounted}),this.bindCssVars=m(this.bindCssVarsFp);const g=_=>{const D=b.getter(_),M=y(D),U={headerColor:"web_app_set_header_color",bgColor:"web_app_set_background_color",bottomBarColor:"web_app_set_bottom_bar_color"}[_],k=T(L=>{if(L===D())return P(void 0);if(U==="web_app_set_header_color"&&(L==="bg_color"||L==="secondary_bg_color"))return i("web_app_set_header_color",{color_key:L});const I=v(L);return d(I?i(U,{color:I}):O(new ss(L)),Z(()=>{b.setState({[_]:I})}))},{isTma:s,version:r,requires:U,isMounted:this.isMounted,returns:"either",supports:_==="headerColor"?{rgb:{method:"web_app_set_header_color",param:"color",shouldCheck:Ue}}:void 0});return[D,M,m(k),k]};[this.bgColor,this.bgColorRgb,this.setBgColor,this.setBgColorFp]=g("bgColor"),[this.headerColor,this.headerColorRgb,this.setHeaderColor,this.setHeaderColorFp]=g("headerColor"),[this.bottomBarColor,this.bottomBarColorRgb,this.setBottomBarColor,this.setBottomBarColorFp]=g("bottomBarColor");const S=B({isTma:s,returns:"either"});this.closeFp=S(_=>i("web_app_close",{return_back:_})),this.close=m(this.closeFp),this.readyFp=S(()=>i("web_app_ready")),this.ready=m(this.readyFp)}}const As=new $s({...d(E(),z,A,ge("miniApp")),offVisibilityChanged(e){ke("visibility_changed",e)},onVisibilityChanged(e){ee("visibility_changed",e)},theme:Ze.state});function $u(e){const t=e.message.trim(),n=(e.title||"").trim(),r=e.buttons||[];if(n.length>64)return O(new ne(`Invalid title: ${n}`));if(!t||t.length>256)return O(new ne(`Invalid message: ${t}`));if(r.length>3)return O(new ne(`Invalid buttons count: ${r.length}`));const i=[];if(!r.length)i.push({type:"close",id:""});else for(let s=0;s<r.length;s++){const a=r[s],u=a.id||"";if(u.length>64)return O(new ne(`Button with index ${s} has invalid id: ${u}`));if(!a.type||a.type==="default"||a.type==="destructive"){const l=a.text.trim();if(!l||l.length>64)return O(new ne(`Button with index ${s} has invalid text: ${l}`));i.push({type:a.type,text:l,id:u})}else i.push({type:a.type,id:u})}return P({title:n,message:t,buttons:i})}class Is{constructor({version:t,isTma:n,request:r}){o(this,"isOpened");o(this,"isSupported");o(this,"showFp");o(this,"show");const i=W(!1),s=()=>{i.set(!1)},a=B({version:t,isTma:n,requires:"web_app_open_popup",returns:"task"});this.isSupported=ie("web_app_open_popup",t),this.isOpened=F(i),this.showFp=a(u=>d(this.isOpened()?N(new pt("A popup is already opened")):R(void 0),Pe(()=>Yr($u(u))),he(l=>(i.set(!0),r("web_app_open_popup","popup_closed",{...u,params:l}))),nn(l=>(s(),l),l=>(s(),l.button_id)))),this.show=m(this.showFp)}}const Au=new Is(d(E(),Y,A));function Iu({request:e,...t}){return T(n=>d(e("web_app_request_phone","phone_requested",n),V(r=>r.status)),{...t,requires:"web_app_request_phone",returns:"task"})}const yn=Iu(d(E(),A,Y)),qu=m(yn);function Bu({invokeCustomMethod:e,requestPhoneAccess:t,...n}){const r=a=>d(e("getRequestedContact",{},{...a,timeout:(a||{}).timeout||5e3}),Pe(u=>{const l=It(C(),u);if(!l.success)return N(new ze(u,l.issues));if(!l.output)return R(void 0);const c=It(Vt(j({contact:me(j({user_id:de(),phone_number:C(),first_name:C(),last_name:$(C())})),auth_date:se(C(),ue(h=>new Date(Number(h)*1e3)),tt()),hash:C()})),l.output);return c.success?R({raw:l.output,parsed:c.output}):N(new ze(l.output,c.issues))})),i=a=>d(r(a),xa(u=>ze.is(u)?O(u):P(void 0),u=>P(u))),s=a=>De(async(u,l,c)=>{let h=50;for(;!c.isRejected;){const f=await i(c)();if(f._tag==="Left")return l(f.left);if(f.right)return u(f.right);await new Promise(b=>setTimeout(b,h)),h+=50}},a);return T(a=>De.fn(u=>d(i(u),he(l=>l?R(l):d(t(u),Pe(c=>c==="sent"?s(u):N(new sn("User denied access")))))),a),{...n,returns:"task",requires:"web_app_request_phone"})}function Tu({requestContact:e,...t}){return T(e,{...t,returns:"task",requires:"web_app_request_phone"})}const Cn=Bu({...d(E(),_n,A),requestPhoneAccess:yn}),Pu=m(Cn),qs=Tu({...d(E(),A),requestContact(e){return d(Cn(e),V(t=>t.parsed))}}),Mu=m(qs);function Lu({request:e,...t}){return T(n=>d(e("web_app_request_write_access","write_access_requested",n),V(r=>r.status)),{...t,requires:"web_app_request_write_access",returns:"task"})}const Bs=Lu(d(E(),A,Y)),Vu=m(Bs);class Ts{constructor({version:t,onClosed:n,onTextReceived:r,isTma:i,postEvent:s}){o(this,"isOpened");o(this,"isSupported");o(this,"captureFp");o(this,"capture");o(this,"closeFp");o(this,"close");o(this,"openFp");o(this,"open");const a={version:t,requires:"web_app_open_scan_qr_popup",isTma:i},u=B({...a,returns:"either"}),l=B({...a,returns:"task"}),c=W(!1),h=()=>{c.set(!1)};this.isSupported=ie("web_app_open_scan_qr_popup",t),this.isOpened=F(c),this.captureFp=l(f=>{let b;return d(this.openFp({...f,onCaptured:v=>{f.capture(v)&&(b=v,this.close())}}),V(()=>b))}),this.closeFp=u(()=>d(s("web_app_close_scan_qr_popup"),Z(h))),this.openFp=l(f=>d(this.isOpened()?N(new pt("The QR Scanner is already opened")):async()=>s("web_app_open_scan_qr_popup",{text:f.text}),Pe(()=>{const[b,v]=st(),y=w=>(v(),w);return d(De(w=>{b(n(w),r(f.onCaptured))},f),nn(y,y))}))),this.open=m(this.openFp),this.capture=m(this.captureFp),this.close=m(this.closeFp)}}const Ru=new Ts({...d(E(),z,A),onClosed(e){return ee("scan_qr_popup_closed",e)},onTextReceived(e){return ee("qr_text_received",t=>{e(t.data)})}});class Ps{constructor({defaults:t,...n}){o(this,"isSupported");o(this,"position");o(this,"bgColor");o(this,"hasShineEffect");o(this,"isEnabled");o(this,"isLoaderVisible");o(this,"isVisible");o(this,"isMounted");o(this,"state");o(this,"text");o(this,"textColor");o(this,"showFp");o(this,"show");o(this,"hideFp");o(this,"hide");o(this,"enableFp");o(this,"enable");o(this,"enableShineEffectFp");o(this,"enableShineEffect");o(this,"disableFp");o(this,"disable");o(this,"disableShineEffectFp");o(this,"disableShineEffect");o(this,"setBgColorFp");o(this,"setBgColor");o(this,"setTextColorFp");o(this,"setTextColor");o(this,"setTextFp");o(this,"setText");o(this,"setPositionFp");o(this,"setPosition");o(this,"showLoaderFp");o(this,"showLoader");o(this,"hideLoaderFp");o(this,"hideLoader");o(this,"setParamsFp");o(this,"setParams");o(this,"mountFp");o(this,"mount");o(this,"unmount");o(this,"onClickFp");o(this,"onClick");o(this,"offClickFp");o(this,"offClick");const r=new ht({...n,initialState:{hasShineEffect:!1,isEnabled:!0,isLoaderVisible:!1,isVisible:!1,text:"Cancel",position:"left"},method:"web_app_setup_secondary_button",payload:s=>({has_shine_effect:s.hasShineEffect,is_visible:s.isVisible,is_active:s.isEnabled,is_progress_visible:s.isLoaderVisible,text:s.text,color:s.bgColor,text_color:s.textColor,position:s.position})}),i=(s,a)=>{const u=r.stateGetter(s);return F(()=>u()||Q(a))};this.isSupported=ie("web_app_setup_secondary_button",n.version),this.bgColor=i("bgColor",t.bgColor),this.textColor=i("textColor",t.textColor),this.position=r.stateGetter("position"),this.hasShineEffect=r.stateGetter("hasShineEffect"),this.isEnabled=r.stateGetter("isEnabled"),this.isLoaderVisible=r.stateGetter("isLoaderVisible"),this.text=r.stateGetter("text"),this.isVisible=r.stateGetter("isVisible"),this.isMounted=r.isMounted,this.state=r.state,[this.setPosition,this.setPositionFp]=r.stateSetters("position"),[this.setBgColor,this.setBgColorFp]=r.stateSetters("bgColor"),[this.setTextColor,this.setTextColorFp]=r.stateSetters("textColor"),[[this.disableShineEffect,this.disableShineEffectFp],[this.enableShineEffect,this.enableShineEffectFp]]=r.stateBoolSetters("hasShineEffect"),[[this.disable,this.disableFp],[this.enable,this.enableFp]]=r.stateBoolSetters("isEnabled"),[[this.hideLoader,this.hideLoaderFp],[this.showLoader,this.showLoaderFp]]=r.stateBoolSetters("isLoaderVisible"),[this.setText,this.setTextFp]=r.stateSetters("text"),[[this.hide,this.hideFp],[this.show,this.showFp]]=r.stateBoolSetters("isVisible"),this.setParams=r.setState,this.setParamsFp=r.setStateFp,this.onClick=r.onClick,this.onClickFp=r.onClickFp,this.offClick=r.offClick,this.offClickFp=r.offClickFp,this.mount=r.mount,this.mountFp=r.mountFp,this.unmount=r.unmount}}const Ou=new Ps(Ss("secondaryButton","secondary_button_pressed",{bgColor:F(()=>As.bottomBarColorRgb()||"#000000"),textColor:F(()=>Ze.buttonColor()||"#2481cc")}));class Ms{constructor(t){o(this,"isVisible");o(this,"isMounted");o(this,"isSupported");o(this,"hideFp");o(this,"hide");o(this,"showFp");o(this,"show");o(this,"onClickFp");o(this,"onClick");o(this,"offClickFp");o(this,"offClick");o(this,"mountFp");o(this,"mount");o(this,"unmount");const n=new ht({...t,method:"web_app_setup_settings_button",payload:r=>({is_visible:r.isVisible}),initialState:{isVisible:!1}});this.isVisible=n.stateGetter("isVisible"),this.isMounted=n.isMounted,this.isSupported=n.isSupported,[[this.hide,this.hideFp],[this.show,this.showFp]]=n.stateBoolSetters("isVisible"),this.onClick=n.onClick,this.onClickFp=n.onClickFp,this.offClick=n.offClick,this.offClickFp=n.offClickFp,this.mount=n.mount,this.mountFp=n.mountFp,this.unmount=n.unmount}}const ju=new Ms(cn("settingsButton","settings_button_pressed"));class Ls{constructor({postEvent:t,storage:n,isTma:r,isPageReload:i,version:s}){o(this,"isSupported");o(this,"isVerticalEnabled");o(this,"isMounted");o(this,"mountFp");o(this,"mount");o(this,"unmount");o(this,"disableVerticalFp");o(this,"disableVertical");o(this,"enableVerticalFp");o(this,"enableVertical");const a=new be({initialState:{isVerticalEnabled:!1},onChange(b){n.set(b)}}),u=new Ke({initialState:{isVerticalEnabled:!1},isPageReload:i,onMounted:a.setState,restoreState:n.get}),l={requires:"web_app_setup_swipe_behavior",isTma:r,version:s},c=B({...l,returns:"plain"}),h=B({...l,isMounted:u.isMounted,returns:"either"}),f=b=>{const v={isVerticalEnabled:b};return a.hasDiff(v)?d(t("web_app_setup_swipe_behavior",{allow_vertical_swipe:b}),Z(()=>{a.setState(v)})):P(void 0)};this.isSupported=ie("web_app_setup_swipe_behavior",s),this.isVerticalEnabled=a.getter("isVerticalEnabled"),this.isMounted=u.isMounted,this.disableVerticalFp=h(()=>f(!1)),this.enableVerticalFp=h(()=>f(!0)),this.mountFp=c(()=>{const b=()=>{};return d(u.mount(),Re(b,b))}),this.unmount=u.unmount,this.disableVertical=m(this.disableVerticalFp),this.enableVertical=m(this.enableVerticalFp),this.mount=m(this.mountFp)}}const Du=new Ls(d(E(),z,A,ge("swipeBehavior")));async function Uu(e){try{const{clipboard:n}=navigator;if(n)return await n.writeText(e)}catch{}const t=document.createElement("textarea");t.value=e,t.style.top="0",t.style.left="0",t.style.position="fixed",document.body.appendChild(t),t.focus(),t.select();try{document.execCommand("copy")}finally{document.body.removeChild(t)}}function xu({request:e,...t}){return T((n,r,i)=>d(e("web_app_request_file_download","file_download_requested",{...i,params:{url:n,file_name:r}}),he(s=>s.status==="downloading"?R(void 0):N(new sn("User denied the action")))),{...t,requires:"web_app_request_file_download",returns:"task"})}const Vs=xu(d(E(),Y,A)),Gu=m(Vs);function Wu({invokeCustomMethod:e,...t}){return T(n=>d(e("getCurrentTime",{},n),he(r=>{const i=It(se(de(),Ct(),ue(s=>new Date(s*1e3)),tt()),r);return i.success?R(i.output):N(new ze(r,i.issues))})),{...t,requires:"web_app_invoke_custom_method",returns:"task"})}const Rs=Wu(d(E(),_n,A)),Hu=m(Rs);function Nu({postEvent:e,...t}){return T(()=>e("web_app_hide_keyboard"),{...t,returns:"either",requires:"web_app_hide_keyboard"})}const Os=Nu(d(E(),z,A)),zu=m(Os);function Ku({request:e,createRequestId:t,...n}){return T(r=>{const i=t();return d(e("web_app_read_text_from_clipboard","clipboard_text_received",{...r,params:{req_id:i},capture:Gr(i)}),V(({data:s=null})=>s))},{...n,requires:"web_app_read_text_from_clipboard",returns:"task"})}const js=Ku({...d(E(),A,Y),createRequestId:dn}),Ju=m(js);function Ds(e){const t={},n=e.match(/Telegram-Android(?:\/([^ ]+))?(?: (\([^)]+\))?|$)/);if(n){const[,r,i]=n;r&&(t.appVersion=r),i&&i.slice(1,i.length-1).split(";").forEach(s=>{const[a,u]=s.trim().split(" ");if(a==="Android")t.androidVersion=u;else if(a==="SDK"){const l=parseInt(u,10);l&&(t.sdkVersion=l)}else u?(t.manufacturer=a,t.model=u):t.performanceClass=a})}return t}function Qu(){return Ds(navigator.userAgent)}function Zu({postEvent:e,...t}){return T(n=>{const{size:r}=new Blob([n]);return!r||r>4096?O(new ne(r?"Maximum size of data to send is 4096 bytes":"Attempted to send empty data")):e("web_app_data_send",{data:n})},{...t,returns:"either"})}const Us=Zu(d(E(),z)),Yu=m(Us);function Xu({request:e,...t}){return T((n,r)=>d(e("web_app_send_prepared_message",["prepared_message_failed","prepared_message_sent"],{...r,params:{id:n}}),he(i=>i&&"error"in i?N(new rs(i.error)):R(void 0))),{...t,requires:"web_app_send_prepared_message",returns:"task"})}const xs=Xu(d(E(),Y,A)),ec=m(xs);function tc({postEvent:e,...t}){return T((n,r={})=>e("web_app_share_to_story",{text:r.text,media_url:n,widget_link:r.widgetLink}),{...t,requires:"web_app_share_to_story",returns:"either"})}const Gs=tc(d(E(),z,A)),nc=m(Gs),Fn=Qe(!1);function rc({isInlineMode:e,postEvent:t,...n}){return T((r,i)=>t("web_app_switch_inline_query",{query:r,chat_types:i||[]}),{...n,requires:{every:["web_app_switch_inline_query",()=>Q(e)?void 0:"The application must be launched in the inline mode"]},returns:"either"})}const Ws=rc({...d(E(),z,A),isInlineMode:Fn}),sc=m(Ws);class Hs{constructor({storage:t,isPageReload:n,onContentSafeAreaInsetsChanged:r,onSafeAreaInsetsChanged:i,onViewportChanged:s,onFullscreenChanged:a,offContentSafeAreaInsetsChanged:u,offFullscreenChanged:l,offSafeAreaInsetsChanged:c,offViewportChanged:h,request:f,isViewportStable:b,isFullscreen:v,isTma:y,version:w,postEvent:g}){o(this,"state");o(this,"height");o(this,"stableHeight");o(this,"width");o(this,"isExpanded");o(this,"isStable",F(()=>this.height()===this.stableHeight()));o(this,"contentSafeAreaInsets");o(this,"contentSafeAreaInsetTop");o(this,"contentSafeAreaInsetLeft");o(this,"contentSafeAreaInsetRight");o(this,"contentSafeAreaInsetBottom");o(this,"safeAreaInsets");o(this,"safeAreaInsetTop");o(this,"safeAreaInsetLeft");o(this,"safeAreaInsetRight");o(this,"safeAreaInsetBottom");o(this,"isFullscreen");o(this,"requestFullscreenFp");o(this,"requestFullscreen");o(this,"exitFullscreenFp");o(this,"exitFullscreen");o(this,"isCssVarsBound");o(this,"bindCssVarsFp");o(this,"bindCssVars");o(this,"isMounted");o(this,"mountFp");o(this,"mount");o(this,"expandFp");o(this,"expand");const S={top:0,right:0,left:0,bottom:0},_=new be({initialState:{contentSafeAreaInsets:S,height:0,isExpanded:!1,isFullscreen:!1,safeAreaInsets:S,stableHeight:0,width:0},onChange:t.set}),D=q=>{_.setState({isExpanded:q.is_expanded,height:q.height,width:q.width,stableHeight:q.is_state_stable?q.height:void 0})},M=q=>{_.setState({isFullscreen:q.is_fullscreen})},U=q=>{_.setState({safeAreaInsets:q})},k=q=>{_.setState({contentSafeAreaInsets:q})},L=new ln({initialState(q){const $e=fe=>()=>{const[ve,re]=fe==="safe-area"?["web_app_request_safe_area","safe_area_changed"]:["web_app_request_content_safe_area","content_safe_area_changed"];return pe(ve,Q(w))?f(ve,re,q):R({top:0,left:0,right:0,bottom:0})},G=fe=>()=>typeof fe=="boolean"?R(fe):Yr(fe());return d(Qa,ct("safeAreaInsets",$e("safe-area")),ct("contentSafeAreaInsets",$e("content-safe-area")),ct("isFullscreen",G(v)),ct("isViewportStable",G(b)),Pe(({isViewportStable:fe,...ve})=>fe?R({...ve,height:window.innerHeight,isExpanded:!0,stableHeight:window.innerHeight,width:window.innerWidth}):d(f("web_app_request_viewport","viewport_changed",q),V(re=>({...ve,height:re.height,isExpanded:re.is_expanded,stableHeight:re.is_state_stable?re.height:0,width:re.width})))))},isPageReload:n,onMounted(q){s(D),a(M),i(U),r(k),_.setState(q)},onUnmounted(){h(D),l(M),c(U),u(k)},restoreState:t.get}),I=q=>F(()=>this.safeAreaInsets()[q]),x=q=>F(()=>this.contentSafeAreaInsets()[q]);this.state=_.state,this.height=_.getter("height"),this.stableHeight=_.getter("stableHeight"),this.width=_.getter("width"),this.isExpanded=_.getter("isExpanded"),this.safeAreaInsets=_.getter("safeAreaInsets"),this.safeAreaInsetTop=I("top"),this.safeAreaInsetBottom=I("bottom"),this.safeAreaInsetLeft=I("left"),this.safeAreaInsetRight=I("right"),this.contentSafeAreaInsets=_.getter("contentSafeAreaInsets"),this.contentSafeAreaInsetTop=x("top"),this.contentSafeAreaInsetBottom=x("bottom"),this.contentSafeAreaInsetLeft=x("left"),this.contentSafeAreaInsetRight=x("right");const Le=B({isTma:y,returns:"task"}),Ye=B({isTma:y,returns:"either"}),uc=B({isTma:y,requires:"web_app_request_fullscreen",version:w,returns:"task"}),zs=q=>uc($e=>d(f(q?"web_app_request_fullscreen":"web_app_exit_fullscreen",["fullscreen_changed","fullscreen_failed"],$e),he(G=>"error"in G&&G.error!=="ALREADY_FULLSCREEN"?N(new ns(G.error)):(_.setState({isFullscreen:"is_fullscreen"in G?G.is_fullscreen:!0}),R(void 0)))));this.isMounted=L.isMounted,this.mountFp=Le(L.mount),this.mount=m(this.mountFp),this.isFullscreen=_.getter("isFullscreen"),this.requestFullscreenFp=zs(!0),this.requestFullscreen=m(this.requestFullscreenFp),this.exitFullscreenFp=zs(!1),this.exitFullscreen=m(this.exitFullscreenFp);const ft=W(!1);this.isCssVarsBound=F(ft),this.bindCssVarsFp=Ye(q=>{if(ft())return O(new lt);q||(q=G=>`--tg-viewport-${jn(G)}`);const $e=[["height",this.height],["stableHeight",this.stableHeight],["width",this.width],["safeAreaInsetTop",this.safeAreaInsetTop],["safeAreaInsetBottom",this.safeAreaInsetBottom],["safeAreaInsetLeft",this.safeAreaInsetLeft],["safeAreaInsetRight",this.safeAreaInsetRight],["contentSafeAreaInsetTop",this.contentSafeAreaInsetTop],["contentSafeAreaInsetBottom",this.contentSafeAreaInsetBottom],["contentSafeAreaInsetLeft",this.contentSafeAreaInsetLeft],["contentSafeAreaInsetRight",this.contentSafeAreaInsetRight]].reduce((G,[fe,ve])=>{const re=q(fe);if(re){const Ks=()=>{gn(re,`${ve()}px`)};G.push({update:Ks,removeListener:ve.sub(Ks),cssVar:re})}return G},[]);return $e.forEach(G=>{G.update()}),ft.set(!0),P(()=>{$e.forEach(G=>{G.removeListener(),vn(G.cssVar)}),ft.set(!1)})}),this.bindCssVars=m(this.bindCssVarsFp),this.expandFp=Ye(()=>g("web_app_expand")),this.expand=m(this.expandFp)}}function ic(){const e=s=>({on:a=>{ee(s,a)},off:a=>{ke(s,a)}}),t=e("viewport_changed"),n=e("fullscreen_changed"),r=e("safe_area_changed"),i=e("content_safe_area_changed");return new Hs({...d(E(),ge("viewport"),A,z,Y),isFullscreen(){return d(Be(),Z(s=>!!s.tgWebAppFullscreen))},isViewportStable(){return d(Be(),Z(s=>["macos","tdesktop","unigram","webk","weba","web"].includes(s.tgWebAppPlatform)))},offContentSafeAreaInsetsChanged:i.off,offFullscreenChanged:n.off,offSafeAreaInsetsChanged:r.off,offViewportChanged:t.off,onContentSafeAreaInsetsChanged:i.on,onFullscreenChanged:n.on,onSafeAreaInsetsChanged:r.on,onViewportChanged:t.on})}const oc=ic();function Ns(e={}){const{version:t,isInlineMode:n,themeParams:r}=e;if(t&&typeof n=="boolean"&&r)un.set(t),Fn.set(n),bn.set(r);else{const u=d(Be(),An(l=>l,l=>{un.set(t||l.tgWebAppVersion),Fn.set(typeof n=="boolean"?n:!!l.tgWebAppBotInline),bn.set(r||l.tgWebAppThemeParams)}));if(u)return O(u)}e.postEvent&&os.set(e.postEvent);const[i,s]=st(ee("reload_iframe",()=>{le().log("Received a request to reload the page"),as("iframe_will_reload"),window.location.reload()})),{acceptCustomStyles:a=!0}=e;if(a){const u=document.createElement("style");u.id="telegram-custom-styles",document.head.appendChild(u),i(ee("set_custom_style",l=>{u.innerHTML=l}),()=>{document.head.removeChild(u)})}return d(Me("iframe_ready",{reload_supported:!0}),Z(()=>(le().log("The package was initialized"),s)))}const ac=X(Ns);return p.AccessDeniedError=sn,p.BackButton=is,p.Biometry=cs,p.CSSVarsBoundError=lt,p.CancelledError=Rn,p.ClosingBehavior=ls,p.CloudStorage=ps,p.ConcurrentCallError=pt,p.FullscreenFailedError=ns,p.FunctionUnavailableError=es,p.HapticFeedback=_s,p.InitData=gs,p.InvalidArgumentsError=ne,p.InvalidEnvError=Ya,p.InvalidLaunchParamsError=Br,p.Invoice=vs,p.InvokeCustomMethodFailedError=Pr,p.LaunchParamsRetrieveError=qr,p.LocationManager=Cs,p.MainButton=Fs,p.MethodParameterUnsupportedError=Ir,p.MethodUnsupportedError=Ar,p.MiniApp=$s,p.NotAvailableError=Xr,p.Popup=Is,p.QrScanner=Ts,p.SecondaryButton=Ps,p.SetEmojiStatusError=ts,p.SettingsButton=Ms,p.ShareMessageError=rs,p.SwipeBehavior=Ls,p.ThemeParams=Es,p.TimeoutError=Bt,p.UnknownEnvError=Tr,p.UnknownThemeParamsKeyError=ss,p.ValidationError=ze,p.Viewport=Hs,p.addToHomeScreen=fu,p.addToHomeScreenFp=ms,p.applyPolyfills=ha,p.backButton=nu,p.biometry=su,p.checkHomeScreenStatus=_u,p.checkHomeScreenStatusFp=bs,p.closingBehavior=iu,p.cloudStorage=ou,p.copyTextToClipboard=Uu,p.createLogger=xn,p.createPostEvent=la,p.createRequestId=dn,p.createStartParam=_a,p.createStartParamFp=Nr,p.debug=Ur,p.decodeBase64Url=fa,p.decodeBase64UrlFp=Qt,p.decodeStartParam=ma,p.decodeStartParamFp=zr,p.deepSnakeToCamelObjKeys=Tt,p.downloadFile=Gu,p.downloadFileFp=Vs,p.encodeBase64Url=Zt,p.getCurrentTime=Hu,p.getCurrentTimeFp=Rs,p.getReleaseVersion=Jt,p.hapticFeedback=pu,p.hideKeyboard=zu,p.hideKeyboardFp=Os,p.init=ac,p.initData=mu,p.initFp=Ns,p.invoice=bu,p.invokeCustomMethod=hs,p.isAnyRGB=ir,p.isColorDark=wn,p.isColorDarkFp=ks,p.isRGB=Ue,p.isRGBA=sr,p.isRGBAShort=rr,p.isRGBShort=nr,p.isSafeToCreateStartParam=ba,p.isTMA=aa,p.isTMAFp=Kt,p.locationManager=ku,p.logger=le,p.mainButton=Eu,p.miniApp=As,p.mockTelegramEnv=ua,p.off=ke,p.offAll=ta,p.on=ee,p.openLink=vu,p.openLinkFp=ws,p.openTelegramLink=yu,p.openTelegramLinkFp=mn,p.parseInitDataQuery=ho,p.parseInitDataQueryFp=pr,p.parseLaunchParamsQuery=hr,p.parseLaunchParamsQueryFp=at,p.popup=Au,p.postEvent=as,p.postEventFp=Me,p.qrScanner=Ru,p.readTextFromClipboard=Ju,p.readTextFromClipboardFp=js,p.request=ru,p.requestContact=Mu,p.requestContactComplete=Pu,p.requestContactCompleteFp=Cn,p.requestContactFp=qs,p.requestEmojiStatusAccess=uu,p.requestEmojiStatusAccessFp=fs,p.requestFp=hn,p.requestPhoneAccess=qu,p.requestPhoneAccessFp=yn,p.requestWriteAccess=Vu,p.requestWriteAccessFp=Bs,p.retrieveAndroidDeviceData=Qu,p.retrieveAndroidDeviceDataFrom=Ds,p.retrieveLaunchParams=Jo,p.retrieveLaunchParamsFp=Be,p.retrieveRawInitData=Qo,p.retrieveRawInitDataFp=xt,p.retrieveRawLaunchParams=Zo,p.retrieveRawLaunchParamsFp=We,p.secondaryButton=Ou,p.sendData=Yu,p.sendDataFp=Us,p.serializeInitDataQuery=dr,p.serializeLaunchParamsQuery=_r,p.setDebug=ra,p.setEmojiStatus=lu,p.setEmojiStatusFp=ds,p.setTargetOrigin=sa,p.settingsButton=ju,p.shareMessage=ec,p.shareMessageFp=xs,p.shareStory=nc,p.shareStoryFp=Gs,p.shareURL=Fu,p.shareURLFp=ys,p.supports=pe,p.swipeBehavior=Du,p.switchInlineQuery=sc,p.switchInlineQueryFp=Ws,p.targetOrigin=xr,p.themeParams=Ze,p.toRGB=oo,p.toRGBFp=ar,p.toRGBFull=ao,p.toRGBFullFp=ot,p.viewport=oc,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"}),p}({});
|
|
2
4
|
//# sourceMappingURL=index.iife.js.map
|