@vbotma/sdk 3.1.8
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 +21 -0
- package/README.md +64 -0
- 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 +51 -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 +121 -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/DeviceStorage/DeviceStorage.d.ts +53 -0
- package/dist/dts/features/DeviceStorage/exports.d.ts +2 -0
- package/dist/dts/features/DeviceStorage/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 +87 -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 +73 -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/Notification/Notification.d.ts +21 -0
- package/dist/dts/features/Notification/exports.d.ts +3 -0
- package/dist/dts/features/Notification/instance.d.ts +2 -0
- package/dist/dts/features/Notification/types.d.ts +19 -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/features/Popup/types.d.ts +54 -0
- package/dist/dts/features/QrScanner/QrScanner.d.ts +131 -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/Refresh/Refresh.d.ts +39 -0
- package/dist/dts/features/Refresh/exports.d.ts +3 -0
- package/dist/dts/features/Refresh/instance.d.ts +2 -0
- package/dist/dts/features/Refresh/types.d.ts +7 -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/SecureStorage/SecureStorage.d.ts +68 -0
- package/dist/dts/features/SecureStorage/exports.d.ts +2 -0
- package/dist/dts/features/SecureStorage/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/StoragePermission/StoragePermission.d.ts +45 -0
- package/dist/dts/features/StoragePermission/exports.d.ts +3 -0
- package/dist/dts/features/StoragePermission/instance.d.ts +2 -0
- package/dist/dts/features/StoragePermission/types.d.ts +51 -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 +219 -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/withCreateRequestId.d.ts +7 -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/invokeCustomMethod.d.ts +16 -0
- package/dist/dts/globals/isInlineMode.d.ts +4 -0
- package/dist/dts/globals/postEvent.d.ts +4 -0
- package/dist/dts/globals/request.d.ts +13 -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/helpers/navigation.d.ts +5 -0
- package/dist/dts/helpers/removeUndefined.d.ts +10 -0
- package/dist/dts/helpers/shallowEqual.d.ts +1 -0
- package/dist/dts/index.d.ts +38 -0
- 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 +170 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.iife.js +4 -0
- package/dist/index.iife.js.map +1 -0
- package/dist/index.js +4088 -0
- package/dist/index.js.map +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export * from './features/BackButton/exports.js';
|
|
2
|
+
export * from './features/Biometry/exports.js';
|
|
3
|
+
export * from './features/ClosingBehavior/exports.js';
|
|
4
|
+
export * from './features/CloudStorage/exports.js';
|
|
5
|
+
export * from './features/DeviceStorage/exports.js';
|
|
6
|
+
export * from './features/emoji-status/exports.js';
|
|
7
|
+
export * from './features/HapticFeedback/exports.js';
|
|
8
|
+
export * from './features/home-screen/exports.js';
|
|
9
|
+
export * from './features/InitData/exports.js';
|
|
10
|
+
export * from './features/Invoice/exports.js';
|
|
11
|
+
export * from './features/links/exports.js';
|
|
12
|
+
export * from './features/LocationManager/exports.js';
|
|
13
|
+
export * from './features/MainButton/exports.js';
|
|
14
|
+
export * from './features/MiniApp/exports.js';
|
|
15
|
+
export * from './features/Notification/exports.js';
|
|
16
|
+
export * from './features/Popup/exports.js';
|
|
17
|
+
export * from './features/privacy/exports.js';
|
|
18
|
+
export * from './features/QrScanner/exports.js';
|
|
19
|
+
export * from './features/Refresh/exports.js';
|
|
20
|
+
export * from './features/SecondaryButton/exports.js';
|
|
21
|
+
export * from './features/SecureStorage/exports.js';
|
|
22
|
+
export * from './features/SettingsButton/exports.js';
|
|
23
|
+
export * from './features/SwipeBehavior/exports.js';
|
|
24
|
+
export * from './features/ThemeParams/exports.js';
|
|
25
|
+
export * from './features/uncategorized/exports.js';
|
|
26
|
+
export * from './features/Viewport/exports.js';
|
|
27
|
+
export * from './features/StoragePermission/exports.js';
|
|
28
|
+
export { createRequestId } from './globals/createRequestId.js';
|
|
29
|
+
export { invokeCustomMethod } from './globals/invokeCustomMethod.js';
|
|
30
|
+
export { postEvent, postEventFp } from './globals/postEvent.js';
|
|
31
|
+
export { request, requestFp, request2, request2Fp } from './globals/request.js';
|
|
32
|
+
export { isColorDark, isColorDarkFp } from './helpers/isColorDark.js';
|
|
33
|
+
export * from './errors.js';
|
|
34
|
+
export { init, initFp, type InitOptions } from './init.js';
|
|
35
|
+
export type { AsyncOptions } from './types.js';
|
|
36
|
+
export { isVBMA, isVBMAFp, type isVBMAError, mockVBotEnv, emitEvent, off, offAll, on, type EventListener, type SubscribeListener, type Events, type WriteAccessRequestedStatus, type EmojiStatusAccessRequestedStatus, type BiometryAuthRequestStatus, type BiometryTokenUpdateStatus, type BiometryType, type EmojiStatusFailedError, type EventName, type EventPayload, type EventWithoutPayload, type EventWithPayload, type PhoneRequestedStatus, type FullScreenErrorStatus, type HomeScreenStatus, type InvoiceStatus, type SafeAreaInsets, createPostEvent, type CreatePostEventMode, type OnUnsupportedFn, getReleaseVersion, type PostEventFn, type PostEventFpFn, type PostEventError, supports, type AnyHapticFeedbackParams, type AnyInvokeCustomMethodParams, type CreateMethodParams, type CustomMethodName, type ImpactHapticFeedbackParams, type ImpactHapticFeedbackStyle, type CustomMethodsParams, type CustomMethodParams, type MethodName, type MethodVersionedParams, type NotificationHapticFeedbackParams, type NotificationHapticFeedbackType, type Methods, type SelectionHapticFeedbackParams, type MethodNameWithOptionalParams, type MethodNameWithoutParams, type MethodNameWithRequiredParams, type MethodNameWithVersionedParams, type MethodParams, type PopupParams, type BackgroundColor, type BottomBarColor, type HeaderColorKey, type PopupButton, type OpenLinkBrowser, type SecondaryButtonPosition, type SwitchInlineQueryChatType, type InvokeCustomMethodFn, type InvokeCustomMethodOptions, type InvokeCustomMethodFpFn, type InvokeCustomMethodError, type InvokeCustomMethodFpOptions, type RequestCaptureEventFn, type RequestCaptureEventsFn, type RequestCaptureFn, type RequestCaptureFnEventsPayload, type RequestFn, type RequestOptions, type RequestResult, type RequestError, type RequestFpOptions, type RequestFpFn, applyPolyfills, decodeBase64Url, encodeBase64Url, decodeBase64UrlFp, type DecodeBase64UrlError, LaunchParamsRetrieveError, InvalidLaunchParamsError, InvokeCustomMethodFailedError, MethodParameterUnsupportedError, MethodUnsupportedError, UnknownEnvError, setDebug, debug, logger, setTargetOrigin, targetOrigin, retrieveLaunchParams, retrieveRawInitData, retrieveRawInitDataFp, retrieveRawLaunchParams, retrieveRawLaunchParamsFp, retrieveLaunchParamsFp, type RetrieveLaunchParamsError, type RetrieveLaunchParamsResult, type RetrieveRawInitDataError, type RetrieveRawLaunchParamsError, createStartParam, createStartParamFp, decodeStartParam, decodeStartParamFp, isSafeToCreateStartParam, createLogger, deepSnakeToCamelObjKeys, type DeepConvertSnakeKeysToCamelCase, type Logger, type LoggerFn, type LoggerForceFn, type LoggerOptions, type LogLevel, CancelledError, TimeoutError, } from '@vbotma/bridge';
|
|
37
|
+
export { parseInitDataQuery, parseInitDataQueryFp, type ParseInitDataQueryError, parseLaunchParamsQuery, parseLaunchParamsQueryFp, type ParseLaunchParamsQueryError, isRGBShort, isRGBAShort, isRGB, isRGBA, isAnyRGB, toRGBFullFp, toRGBFp, toRGB, toRGBFull, serializeInitDataQuery, type InitDataLike, serializeLaunchParamsQuery, type LaunchParamsLike, } from '@vbotma/transformers';
|
|
38
|
+
export type { RGB, User, Chat, Auth, InitData as InitDataType, ChatType, Platform, ThemeParams as ThemeParamsType, LaunchParams, KnownThemeParamsKey, Version, } from '@vbotma/types';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { RetrieveLaunchParamsError, PostEventError, PostEventFpFn } from '@vbotma/bridge';
|
|
2
|
+
import { Version, ThemeParams } from '@vbotma/types';
|
|
3
|
+
import { either as E } from 'fp-ts';
|
|
4
|
+
export interface InitOptions {
|
|
5
|
+
/**
|
|
6
|
+
* True if SDK should accept styles sent from the VBot application.
|
|
7
|
+
* @default true
|
|
8
|
+
*/
|
|
9
|
+
acceptCustomStyles?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* True if the application is launched in inline mode.
|
|
12
|
+
* @default Will be calculated based on the launch parameters' vbWebAppBotInline field.
|
|
13
|
+
*/
|
|
14
|
+
isInlineMode?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* A custom `postEvent` function to use across the package.
|
|
17
|
+
* @default tma.js/bridge's postEventFp function will be used.
|
|
18
|
+
*/
|
|
19
|
+
postEvent?: PostEventFpFn;
|
|
20
|
+
/**
|
|
21
|
+
* Mini application theme parameters.
|
|
22
|
+
* @default Will be calculated based on the launch parameters' vbWebAppThemeParams field.
|
|
23
|
+
*/
|
|
24
|
+
themeParams?: ThemeParams;
|
|
25
|
+
/**
|
|
26
|
+
* VBot Mini Apps version supported by the VBot client.
|
|
27
|
+
* @default Will be calculated based on the launch parameters' vbWebAppVersion field.
|
|
28
|
+
*/
|
|
29
|
+
version?: Version;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Initializes the SDK allowing it to properly handle events, sent from the native Telegram
|
|
33
|
+
* application. This function also configure the package's global dependencies (functions,
|
|
34
|
+
* variables used across the package).
|
|
35
|
+
* @param options - function options.
|
|
36
|
+
* @returns A function, to perform a cleanup.
|
|
37
|
+
*/
|
|
38
|
+
export declare function initFp(options?: InitOptions): E.Either<RetrieveLaunchParamsError | PostEventError, VoidFunction>;
|
|
39
|
+
/**
|
|
40
|
+
* @see initFp
|
|
41
|
+
*/
|
|
42
|
+
export declare const init: ((options?: InitOptions | undefined) => VoidFunction) & {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { AnyFn } from '@vbotma/toolkit';
|
|
2
|
+
import { WithChecksFp, WithChecks } from './withChecksFp.js';
|
|
3
|
+
export declare function throwifyWithChecksFp<Fn extends AnyFn, HasSupportCheck extends boolean, SupportsMapKeySchema extends string>(fn_: WithChecksFp<Fn, HasSupportCheck, SupportsMapKeySchema>): WithChecks<Fn, HasSupportCheck, SupportsMapKeySchema>;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { MethodName, MethodNameWithVersionedParams, MethodVersionedParams } from '@vbotma/bridge';
|
|
2
|
+
import { Computed } from '@vbotma/signals';
|
|
3
|
+
import { If, IsNever, AnyFnAnyEither, RightOfReturn, LeftOfReturn, MaybeMonadReturnTypeToCommon, MaybeCommonReturnTypeToMonad, AnyFn } from '@vbotma/toolkit';
|
|
4
|
+
import { Version } from '@vbotma/types';
|
|
5
|
+
import { either as E, option as O, taskEither as TE } from 'fp-ts';
|
|
6
|
+
import { FunctionUnavailableError } from '../errors.js';
|
|
7
|
+
import { MaybeAccessor } from '../types.js';
|
|
8
|
+
type IfReturnsTask<Fn extends AnyFnAnyEither, A, B> = ReturnType<Fn> extends TE.TaskEither<any, any> ? A : B;
|
|
9
|
+
type OptionsBasedRequires<O extends WithChecksOptions<any>> = O extends {
|
|
10
|
+
requires: any;
|
|
11
|
+
} ? true : false;
|
|
12
|
+
type OptionsBasedSupports<O extends WithChecksOptions<any>> = O extends {
|
|
13
|
+
supports: any;
|
|
14
|
+
} ? Extract<keyof O['supports'], string> : never;
|
|
15
|
+
type OptionsBasedFn<Opts extends WithChecksOptions<any>> = (...args: any[]) => (Opts['returns'] extends 'plain' ? any : Opts['returns'] extends 'promise' ? PromiseLike<any> : Opts['returns'] extends 'task' ? TE.TaskEither<any, any> : E.Either<any, any>);
|
|
16
|
+
/**
|
|
17
|
+
* @returns Error text if something is wrong.
|
|
18
|
+
*/
|
|
19
|
+
export type CustomSupportFn = () => string | undefined;
|
|
20
|
+
export type Require = MethodName | CustomSupportFn | {
|
|
21
|
+
every: (MethodName | CustomSupportFn)[];
|
|
22
|
+
} | {
|
|
23
|
+
some: (MethodName | CustomSupportFn)[];
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* A map where the key is a method name with versioned parameters, and the value is a tuple
|
|
27
|
+
* containing the method and parameter names. The third tuple value is a function accepting
|
|
28
|
+
* the wrapped function arguments and returning true if support check must be applied.
|
|
29
|
+
*/
|
|
30
|
+
export type SupportsMap<Args extends any[]> = {
|
|
31
|
+
[OptionName: string]: {
|
|
32
|
+
[M in MethodNameWithVersionedParams]: {
|
|
33
|
+
/**
|
|
34
|
+
* Method name.
|
|
35
|
+
* @example 'web_app_set_header_color'
|
|
36
|
+
*/
|
|
37
|
+
method: M;
|
|
38
|
+
/**
|
|
39
|
+
* Method version-dependent parameter.
|
|
40
|
+
* @example `color`
|
|
41
|
+
*/
|
|
42
|
+
param: MethodVersionedParams<M>;
|
|
43
|
+
/**
|
|
44
|
+
* @returns True if the support function should be called.
|
|
45
|
+
* @param args - function arguments.
|
|
46
|
+
*/
|
|
47
|
+
shouldCheck: (...args: Args) => boolean;
|
|
48
|
+
};
|
|
49
|
+
}[MethodNameWithVersionedParams];
|
|
50
|
+
};
|
|
51
|
+
type WrappedFnReturnType<Fn extends AnyFn> = ReturnType<Fn> extends E.Either<any, any> ? E.Either<FunctionUnavailableError | LeftOfReturn<Fn>, RightOfReturn<Fn>> : ReturnType<Fn> extends TE.TaskEither<any, any> ? TE.TaskEither<FunctionUnavailableError | LeftOfReturn<Fn>, RightOfReturn<Fn>> : ReturnType<Fn> extends PromiseLike<infer U> ? TE.TaskEither<FunctionUnavailableError, U> : E.Either<FunctionUnavailableError, ReturnType<Fn>>;
|
|
52
|
+
export type WrappedFn<Fn extends AnyFn> = (...args: Parameters<Fn>) => WrappedFnReturnType<Fn>;
|
|
53
|
+
export type WithChecksFp<Fn extends AnyFn, HasSupportCheck extends boolean, SupportsMapKeySchema extends string = never> = WrappedFn<Fn> & {
|
|
54
|
+
/**
|
|
55
|
+
* A signal returning `true` if the function is available in the current environment and
|
|
56
|
+
* conditions.
|
|
57
|
+
*
|
|
58
|
+
* To be more accurate, the method checks the following:
|
|
59
|
+
* 1. The current environment is VBot Mini Apps.
|
|
60
|
+
* 2. The SDK package is initialized (if this requirement is specified).
|
|
61
|
+
* 3. If passed, the `isSupported` signal returned true.
|
|
62
|
+
* 4. If passed, the `isMounted` signal returned true.
|
|
63
|
+
*
|
|
64
|
+
* *You should use this function when possible because it provides must-have code security
|
|
65
|
+
* mechanisms and makes a developer sure that he is using the package properly.*
|
|
66
|
+
*
|
|
67
|
+
* @returns True if the function is available in the current environment.
|
|
68
|
+
* @example
|
|
69
|
+
* if (backButton.show.isAvailable()) {
|
|
70
|
+
* backButton.show();
|
|
71
|
+
* }
|
|
72
|
+
*/
|
|
73
|
+
isAvailable: Computed<boolean>;
|
|
74
|
+
/**
|
|
75
|
+
* Calls the function only in case it is available.
|
|
76
|
+
*
|
|
77
|
+
* It uses the `isAvailable` internally to check if the function is available for call.
|
|
78
|
+
* @example
|
|
79
|
+
* backButton.show.ifAvailable();
|
|
80
|
+
*/
|
|
81
|
+
ifAvailable(...args: Parameters<Fn>): O.Option<MaybeCommonReturnTypeToMonad<Fn>>;
|
|
82
|
+
} & If<HasSupportCheck, {
|
|
83
|
+
/**
|
|
84
|
+
* The signal returning `true` if the function is supported by the VBot client,
|
|
85
|
+
* including some possible additional conditions.
|
|
86
|
+
*
|
|
87
|
+
* It is highly recommended to use this signal only in certain narrow cases when only the
|
|
88
|
+
* function support check is required, but not its availability.
|
|
89
|
+
*
|
|
90
|
+
* This signal is not applying additional operations like checking if the current environment
|
|
91
|
+
* is Mini Apps and the SDK is initialized.
|
|
92
|
+
*
|
|
93
|
+
* To check if the function is available for use, use the `isAvailable` signal.
|
|
94
|
+
*
|
|
95
|
+
* @returns True if this function is supported.
|
|
96
|
+
* @see isAvailable
|
|
97
|
+
* @example
|
|
98
|
+
* if (backButton.show.isSupported()) {
|
|
99
|
+
* console.log('The method is supported');
|
|
100
|
+
* }
|
|
101
|
+
*/
|
|
102
|
+
isSupported: Computed<boolean>;
|
|
103
|
+
}, {}> & If<IsNever<SupportsMapKeySchema>, {}, {
|
|
104
|
+
/**
|
|
105
|
+
* A map where the key is the function-specific option name and value is a signal indicating
|
|
106
|
+
* if it is supported by the current environment.
|
|
107
|
+
* @example
|
|
108
|
+
* if (miniApp.setHeaderColor.isAvailable()) {
|
|
109
|
+
* if (miniApp.setHeaderColor.supports('rgb')) {
|
|
110
|
+
* miniApp.setHeaderColor('#ffaabb');
|
|
111
|
+
* } else {
|
|
112
|
+
* miniApp.setHeaderColor('bg_color');
|
|
113
|
+
* }
|
|
114
|
+
* }
|
|
115
|
+
*/
|
|
116
|
+
supports: (key: SupportsMapKeySchema) => boolean;
|
|
117
|
+
}>;
|
|
118
|
+
export type WithChecks<Fn extends AnyFn, HasSupportCheck extends boolean, SupportsMapKeySchema extends string = never> = ((...args: Parameters<Fn>) => MaybeMonadReturnTypeToCommon<Fn>) & Omit<WithChecksFp<Fn, HasSupportCheck, SupportsMapKeySchema>, 'ifAvailable'> & {
|
|
119
|
+
/**
|
|
120
|
+
* Calls the function only in case it is available.
|
|
121
|
+
*
|
|
122
|
+
* It uses the `isAvailable` internally to check if the function is available for call.
|
|
123
|
+
* @example
|
|
124
|
+
* backButton.show.ifAvailable();
|
|
125
|
+
*/
|
|
126
|
+
ifAvailable(...args: Parameters<Fn>): {
|
|
127
|
+
ok: true;
|
|
128
|
+
data: MaybeMonadReturnTypeToCommon<Fn>;
|
|
129
|
+
} | {
|
|
130
|
+
ok: false;
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
export interface WithChecksOptions<Fn extends AnyFn> {
|
|
134
|
+
/**
|
|
135
|
+
* Signal returning true if the owning component is mounted.
|
|
136
|
+
*/
|
|
137
|
+
isMounted?: () => boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Signal returning true if the owning component is mounting.
|
|
140
|
+
*/
|
|
141
|
+
isMounting?: () => boolean;
|
|
142
|
+
/**
|
|
143
|
+
* A value determining the function requirements. This will enable additional checks for
|
|
144
|
+
* the function before being called.
|
|
145
|
+
*/
|
|
146
|
+
requires?: Require;
|
|
147
|
+
/**
|
|
148
|
+
* A signal to retrieve the current VBot Mini Apps version or the value itself.
|
|
149
|
+
*/
|
|
150
|
+
isTma: MaybeAccessor<boolean>;
|
|
151
|
+
/**
|
|
152
|
+
* A map where the key is a method name with versioned parameters, and the value is a tuple
|
|
153
|
+
* containing the method and parameter names. The third tuple value is a function accepting
|
|
154
|
+
* the wrapped function arguments and returning true if support check must be applied.
|
|
155
|
+
*/
|
|
156
|
+
supports?: SupportsMap<Parameters<Fn>>;
|
|
157
|
+
/**
|
|
158
|
+
* A signal to retrieve the current VBot Mini Apps version or the value itself.
|
|
159
|
+
*/
|
|
160
|
+
version?: MaybeAccessor<Version>;
|
|
161
|
+
/**
|
|
162
|
+
* Allows to determine what exactly should be returned from the function - TaskEither or Either.
|
|
163
|
+
* There is no other way to know it until the function itself is called, but we need to perform
|
|
164
|
+
* some checks before calling it and return a valid value based on the function return type.
|
|
165
|
+
*/
|
|
166
|
+
returns: Fn extends AnyFnAnyEither ? IfReturnsTask<Fn, 'task', 'either'> : ReturnType<Fn> extends PromiseLike<any> ? 'promise' : 'plain';
|
|
167
|
+
}
|
|
168
|
+
export declare function withChecksFp<Fn extends AnyFn, O extends WithChecksOptions<Fn>>(fn: Fn, options: O): WithChecksFp<Fn, OptionsBasedRequires<O>, OptionsBasedSupports<O>>;
|
|
169
|
+
export declare function createWithChecksFp<O extends WithChecksOptions<any>>(options: O): <Fn extends OptionsBasedFn<O>>(fn: Fn) => WithChecksFp<Fn, OptionsBasedRequires<O>, OptionsBasedSupports<O>>;
|
|
170
|
+
export {};
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var Ot=Object.defineProperty;var Lt=(n,r,s)=>r in n?Ot(n,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[r]=s;var e=(n,r,s)=>Lt(n,typeof r!="symbol"?r+"":r,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("@vbotma/signals"),h=require("@vbotma/bridge"),x=require("@vbotma/toolkit"),Me=require("better-promises"),A=require("@vbotma/transformers"),t=require("fp-ts"),$=require("error-kid"),v=require("valibot");function j(n){return typeof n=="function"?n():n}class re{constructor({onMounted:r,restoreState:s,initialState:i,onUnmounted:o,isPageReload:u}){e(this,"_isMounted",b.signal(!1));e(this,"isMounted",b.computed(this._isMounted));e(this,"mount");e(this,"unmount");this.mount=()=>{if(this.isMounted())return t.either.right(void 0);const c=j(u)?s():void 0,a=c?t.either.right(c):typeof i=="function"?i():t.either.right(i);return t.function.pipe(a,t.either.map(p=>{b.batch(()=>{this._isMounted.set(!0),r==null||r(p)})}))},this.unmount=()=>{this._isMounted()&&b.batch(()=>{this._isMounted.set(!1),o==null||o()})}}}function de(n){const r={};for(const s in n){const i=n[s];i!==void 0&&(r[s]=i)}return r}function pe(n,r){const s=Object.keys(n),i=Object.keys(r);return s.length!==i.length?!1:s.every(o=>Object.prototype.hasOwnProperty.call(r,o)&&n[o]===r[o])}class z{constructor({initialState:r,onChange:s}){e(this,"_state");e(this,"state");e(this,"setState",r=>{const s={...this.state(),...de(r)};pe(s,this.state())||this._state.set(s)});this._state=b.signal(r,{equals:pe}),this.state=b.computed(this._state),this.state.sub(s)}getter(r){return b.computed(()=>this._state()[r])}hasDiff(r){return!pe({...this.state(),...de(r)},this.state())}}function W(n,r){return b.computed(()=>h.supports(n,j(r)))}function l(n){return Object.assign(x.throwifyFpFn(n),{ifAvailable(...r){return t.function.pipe(n.ifAvailable(...r),t.option.match(()=>({ok:!1}),s=>({ok:!0,data:x.throwifyAnyEither(s)})))}})}function Y(n){return[n]}class ee extends $.errorClassWithData("ValidationError",(r,s)=>({input:r,issues:s}),"Validation error"){}class oe extends $.errorClass("CSSVarsBoundError","CSS variables are already bound"){}class xe extends $.errorClassWithData("DeviceStorageMethodError",r=>({error:r}),r=>[r]){}class Te extends $.errorClassWithData("SecureStorageMethodError",r=>({error:r}),r=>[r]){}class Re extends $.errorClass("NotAvailableError",Y){}class jt extends $.errorClass("InvalidEnvError",Y){}class Ve extends $.errorClass("FunctionNotAvailableError",Y){}class U extends $.errorClass("InvalidArgumentsError",(r,s)=>[r,{cause:s}]){}class ae extends $.errorClass("ConcurrentCallError",Y){}class Oe extends $.errorClass("SetEmojiStatusError",r=>[`Failed to set emoji status: ${r}`]){}class be extends $.errorClass("AccessDeniedError",Y){}class Le extends $.errorClass("FullscreenFailedError",Y){}class je extends $.errorClass("ShareMessageError",Y){}class $e extends $.errorClass("UnknownThemeParamsKeyError",r=>[`Unknown theme params key passed: ${r}`]){}function q(n,r){const s=b.computed(()=>j(r.version)||"100"),i=b.computed(()=>j(r.isTma)),{requires:o,returns:u}=r,c=o?typeof o=="object"?o:{every:[o]}:void 0,a=_=>{if(!r.supports)return!0;const g=r.supports[_];return h.supports(g.method,g.param,s())},p=()=>{if(!c)return;const[_,g]="every"in c?["every",c.every]:["some",c.some];for(let d=0;d<g.length;d++){const P=g[d],V=typeof P=="function"?P():h.supports(P,s())?void 0:`it is unsupported in Mini Apps version ${s()}`;if(V&&(_==="every"||d===g.length-1))return V}},m=(..._)=>{for(const g in r.supports)if(r.supports[g].shouldCheck(..._)&&!a(g))return`option ${g} is not supported in Mini Apps version ${s()}`},F=b.computed(()=>!p()),f=b.computed(()=>s()!=="0.0"),S=b.computed(()=>r.isMounted?r.isMounted():!0),w=b.computed(()=>i()&&f()&&F()&&S()),k=_=>{const g=new Ve(_);return["task","promise"].includes(r.returns)?t.taskEither.left(g):t.either.left(g)},E=(..._)=>u==="plain"?t.either.tryCatch(()=>n(..._),g=>g):u==="promise"?t.taskEither.tryCatch(()=>n(..._),g=>g):n(..._);return Object.assign((..._)=>{var V;const g="Unable to call function:";if(!i())return k(`${g} it can't be called outside Mini Apps`);if(!f())return k(`${g} the SDK was not initialized. Use the SDK init() function`);const d=p();if(d)return k(`${g} ${d}`);const P=m(..._);if(P)return k(`${g} ${P}`);if(!S()){const T=(V=r.isMounting)!=null&&V.call(r)?"mounting. Wait for the mount completion":"unmounted. Use the mount() method";return k(`${g} the component is ${T}`)}return E(..._)},n,{isAvailable:w,ifAvailable(..._){return w()?t.option.some(E(..._)):t.option.none}},c?{isSupported:F}:{},r.supports?{supports:a}:{})}function I(n){return r=>q(r,n)}class ue{constructor({isTma:r,storage:s,onClick:i,offClick:o,initialState:u,isPageReload:c,postEvent:a,payload:p,method:m,version:F}){e(this,"isMounted");e(this,"isSupported");e(this,"state");e(this,"stateSetters");e(this,"stateBoolSetters");e(this,"setStateFp");e(this,"setState");e(this,"onClickFp");e(this,"onClick");e(this,"offClickFp");e(this,"offClick");e(this,"mountFp");e(this,"mount");e(this,"unmount");const f=new z({initialState:u,onChange(_){s.set(_)}}),S=new re({initialState:u,isPageReload:c,onMounted:f.setState,restoreState:s.get}),w={version:F,requires:m,isTma:r},k=I({...w,returns:"plain"}),E=I({...w,returns:"either",isMounted:S.isMounted});this.isMounted=S.isMounted,this.isSupported=W(m,F),this.state=f.state,this.setStateFp=E(_=>{const g={...this.state(),...de(_)};return f.hasDiff(g)?t.function.pipe(a(m,p(g)),t.either.map(()=>{f.setState(g)})):t.either.right(void 0)}),this.setState=l(this.setStateFp),this.onClickFp=k(i),this.onClick=l(this.onClickFp),this.offClickFp=k(o),this.offClick=l(this.offClickFp),this.mountFp=k(()=>{const _=()=>{};return t.function.pipe(S.mount(),t.either.match(_,_))}),this.mount=l(this.mountFp),this.unmount=S.unmount,this.stateSetters=_=>{const g=E(d=>this.setStateFp({[_]:d}));return[l(g),g]},this.stateBoolSetters=_=>{const[,g]=this.stateSetters(_),d=E(()=>g(!1)),P=E(()=>g(!0));return[[l(d),d],[l(P),P]]}}stateGetter(r){return b.computed(()=>this.state()[r])}}class De{constructor(r){e(this,"isVisible");e(this,"isMounted");e(this,"isSupported");e(this,"hideFp");e(this,"hide");e(this,"showFp");e(this,"show");e(this,"onClickFp");e(this,"onClick");e(this,"offClickFp");e(this,"offClick");e(this,"mountFp");e(this,"mount");e(this,"unmount");const s=new ue({...r,method:"web_app_setup_back_button",payload:i=>({is_visible:i.isVisible}),initialState:{isVisible:!1}});this.isVisible=s.stateGetter("isVisible"),this.isMounted=s.isMounted,this.isSupported=s.isSupported,[[this.hide,this.hideFp],[this.show,this.showFp]]=s.stateBoolSetters("isVisible"),this.onClick=s.onClick,this.onClickFp=s.onClickFp,this.offClick=s.offClick,this.offClickFp=s.offClickFp,this.mount=s.mount,this.mountFp=s.mountFp,this.unmount=s.unmount}}function C(){return{isTma:b.computed(()=>h.isVBMAFp())}}function X(n){return r=>({...r,...j(n)})}function se(n,r){return b.signal(n,r)}const Ge=se(h.postEventFp),Z=(...n)=>Ge()(...n),Ue=(...n)=>x.throwifyAnyEither(Z(...n)),R=X({postEvent:Z});function $t(n){return{get:()=>x.getStorageValue(n),set(r){x.setStorageValue(n,r)}}}function Dt(){return performance.getEntriesByType("navigation")[0]}function Gt(){const n=Dt();return!!n&&n.type==="reload"}function N(n){return X({storage:$t(n),isPageReload:Gt})}const fe=se("0.0"),y=X({version:fe});function ge(n,r){return{...t.function.pipe(C(),R,y,N(n)),onClick(s,i){return h.on(r,s,i)},offClick(s,i){h.off(r,s,i)}}}const Ut=new De(ge("backButton","back_button_pressed"));class Fe{constructor({initialState:r,onMounted:s,restoreState:i,onUnmounted:o,isPageReload:u}){e(this,"_isMounted",b.signal(!1));e(this,"isMounted",b.computed(this._isMounted));e(this,"mount");e(this,"unmount");this.mount=c=>{if(this._isMounted())return t.taskEither.right(void 0);const a=j(u)?i():void 0;return t.function.pipe(a?t.taskEither.right(a):r(c),t.taskEither.map(p=>{this._isMounted()||b.batch(()=>{this._isMounted.set(!0),s==null||s(p)})}))},this.unmount=()=>{this._isMounted()&&b.batch(()=>{this._isMounted.set(!1),o==null||o()})}}}function Pe(){return new Re("Biometry is not available")}function he(n){let r=!1,s=!1,i="",o=!1,u="",c=!1;return n.available&&(r=!0,s=n.token_saved,i=n.device_id,o=n.access_requested,u=n.type,c=n.access_granted),{available:r,tokenSaved:s,deviceId:i,type:u,accessGranted:c,accessRequested:o}}class He{constructor({version:r,request:s,postEvent:i,storage:o,onInfoReceived:u,offInfoReceived:c,isTma:a,isPageReload:p}){e(this,"isAvailable");e(this,"isSupported");e(this,"isMounted");e(this,"state");e(this,"authenticateFp");e(this,"authenticate");e(this,"openSettingsFp");e(this,"openSettings");e(this,"requestAccessFp");e(this,"requestAccess");e(this,"updateTokenFp");e(this,"updateToken");e(this,"mountFp");e(this,"mount");e(this,"unmount");const m=_=>{F.setState(he(_))},F=new z({initialState:{available:!1,type:"unknown",accessGranted:!1,accessRequested:!1,deviceId:"",tokenSaved:!1},onChange:o.set}),f=new Fe({initialState(_){return t.function.pipe(s("web_app_biometry_get_info","biometry_info_received",_),t.taskEither.map(he))},isPageReload:p,onMounted(_){F.setState(_),u(m)},onUnmounted(){c(m)},restoreState:o.get}),S={version:r,requires:"web_app_biometry_request_auth",isTma:a},w=I({...S,returns:"either"}),k=I({...S,returns:"task"}),E=I({...S,isMounted:f.isMounted,returns:"task"});this.isAvailable=F.getter("available"),this.isMounted=f.isMounted,this.isSupported=W("web_app_biometry_request_auth",r),this.state=F.state,this.unmount=f.unmount,this.mountFp=k(f.mount),this.authenticateFp=E(_=>this.isAvailable()?t.function.pipe(s("web_app_biometry_request_auth","biometry_auth_requested",{..._,params:{reason:((_||{}).reason||"").trim()}}),t.taskEither.map(g=>(F.setState({token:g.token}),g))):t.taskEither.left(Pe())),this.openSettingsFp=w(()=>i("web_app_biometry_open_settings")),this.requestAccessFp=E(_=>t.function.pipe(s("web_app_biometry_request_access","biometry_info_received",{..._,params:{reason:((_||{}).reason||"").trim()}}),t.taskEither.chain(g=>{const d=he(g);return d.available?(F.setState(d),t.taskEither.right(d.accessRequested)):t.taskEither.left(Pe())}))),this.updateTokenFp=E((_={})=>{var g;return t.function.pipe(s("web_app_biometry_update_token","biometry_token_updated",{..._,params:{token:_.token||"",reason:(g=_.reason)==null?void 0:g.trim()}}),t.taskEither.map(d=>d.status))}),this.authenticate=l(this.authenticateFp),this.openSettings=l(this.openSettingsFp),this.requestAccess=l(this.requestAccessFp),this.updateToken=l(this.updateTokenFp),this.mount=l(this.mountFp)}}const We=(n,r,s)=>h.requestFp(n,r,{postEvent:Z,...s}),we=(n,r,s)=>h.request2Fp(n,r,{postEvent:Z,...s}),Ht=(...n)=>Me.BetterPromise.fn(()=>We(...n)()),Wt=(...n)=>Me.BetterPromise.fn(()=>we(...n)()),O=X({request:we});function Qt(){return new He({...t.function.pipe(C(),R,y,O,N("biometry")),offInfoReceived(n){h.off("biometry_info_received",n)},onInfoReceived(n){return h.on("biometry_info_received",n)}})}const Kt=Qt();class Qe{constructor({postEvent:r,storage:s,isTma:i,isPageReload:o}){e(this,"isConfirmationEnabled");e(this,"isMounted");e(this,"mountFp");e(this,"mount");e(this,"unmount");e(this,"disableConfirmationFp");e(this,"disableConfirmation");e(this,"enableConfirmationFp");e(this,"enableConfirmation");const u=new z({initialState:{isConfirmationEnabled:!1},onChange(f){s.set(f)}}),c=new re({onMounted:u.setState,restoreState:s.get,initialState:{isConfirmationEnabled:!1},isPageReload:o}),a={requires:"web_app_setup_closing_behavior",isTma:i},p=I({...a,returns:"plain"}),m=I({...a,returns:"either",isMounted:c.isMounted}),F=f=>f===this.isConfirmationEnabled()?t.either.right(void 0):(u.setState({isConfirmationEnabled:f}),r("web_app_setup_closing_behavior",{need_confirmation:f}));this.isConfirmationEnabled=u.getter("isConfirmationEnabled"),this.isMounted=c.isMounted,this.disableConfirmationFp=m(()=>F(!1)),this.enableConfirmationFp=m(()=>F(!0)),this.mountFp=p(()=>{const f=()=>{};return t.function.pipe(c.mount(),t.either.match(f,f))}),this.unmount=c.unmount,this.disableConfirmation=l(this.disableConfirmationFp),this.enableConfirmation=l(this.enableConfirmationFp),this.mount=l(this.mountFp)}}function zt(){return new Qe(t.function.pipe(C(),N("closingBehavior"),R))}const Nt=zt();class Ke{constructor({version:r,isTma:s,invokeCustomMethod:i}){e(this,"isSupported");e(this,"deleteItemFp");e(this,"deleteItem");e(this,"getItemFp");e(this,"getItem");e(this,"getItemsFp");e(this,"getItems");e(this,"getKeysFp");e(this,"getKeys");e(this,"setItemFp");e(this,"setItem");e(this,"clearFp");e(this,"clear");const o=I({version:r,requires:"web_app_invoke_custom_method",isTma:s,returns:"task"});this.isSupported=W("web_app_invoke_custom_method",r),this.deleteItemFp=o((u,c)=>{const a=Array.isArray(u)?u:[u];return t.function.pipe(a.length?i("deleteStorageValues",{keys:a},c):t.taskEither.right(void 0),t.taskEither.map(()=>{}))}),this.getItemFp=o((u,c)=>t.function.pipe(this.getItemsFp([u],c),t.taskEither.map(a=>a[u]||""))),this.getItemsFp=o((u,c)=>t.function.pipe(u.length?i("getStorageValues",{keys:u},c):t.taskEither.right({}),t.taskEither.map(a=>({...u.reduce((p,m)=>(p[m]="",p),{}),...v.parse(v.record(v.string(),v.string()),a)})))),this.getKeysFp=o(u=>t.function.pipe(i("getStorageKeys",{},u),t.taskEither.map(c=>v.parse(v.array(v.string()),c)))),this.setItemFp=o((u,c,a)=>t.function.pipe(i("saveStorageValue",{key:u,value:c},a),t.taskEither.map(()=>{}))),this.clearFp=o(u=>t.function.pipe(this.getKeysFp(u),t.taskEither.chain(this.deleteItemFp))),this.deleteItem=l(this.deleteItemFp),this.getItem=l(this.getItemFp),this.getItems=l(this.getItemsFp),this.getKeys=l(this.getKeysFp),this.setItem=l(this.setItemFp),this.clear=l(this.clearFp)}}const le=se(0);function ce(){return le.set(le()+1),le().toString()}function ze(n,r,s){return h.invokeCustomMethodFp(n,r,ce(),{...s||{},postEvent:Z})}const Ce=X({invokeCustomMethod:ze});function Jt(){return new Ke(t.function.pipe(C(),y,Ce))}const Yt=Jt();class Ne{constructor({isTma:r,request:s,version:i,createRequestId:o}){e(this,"getItemFp");e(this,"getItem");e(this,"setItemFp");e(this,"setItem");e(this,"deleteItemFp");e(this,"deleteItem");e(this,"clearFp");e(this,"clear");const u=I({version:i,requires:"web_app_device_storage_get_key",isTma:r,returns:"task"}),c=(a,p,m)=>{const F=o();return t.function.pipe(s(a,["device_storage_failed",p],{params:{...m,req_id:F},capture:(f=>"payload"in f?f.payload.req_id===F:!0)}),t.taskEither.chain(f=>f.event==="device_storage_failed"?t.taskEither.left(new xe(f.payload.error||"UNKNOWN_ERROR")):t.taskEither.right(f.payload)))};this.getItemFp=u(a=>t.function.pipe(c("web_app_device_storage_get_key","device_storage_key_received",{key:a}),t.taskEither.map(p=>p.value))),this.setItemFp=u((a,p)=>t.function.pipe(c("web_app_device_storage_save_key","device_storage_key_saved",{key:a,value:p}),t.taskEither.map(()=>{}))),this.deleteItemFp=u(a=>this.setItemFp(a,null)),this.clearFp=u(()=>t.function.pipe(c("web_app_device_storage_clear","device_storage_cleared",{}),t.taskEither.map(()=>{}))),this.getItem=l(this.getItemFp),this.setItem=l(this.setItemFp),this.deleteItem=l(this.deleteItemFp),this.clear=l(this.clearFp)}}const Je=X({createRequestId:ce});function Zt(){return new Ne(t.function.pipe(C(),y,O,Je))}const Xt=Zt();function er({request:n,...r}){return q(s=>t.function.pipe(n("web_app_request_emoji_status_access","emoji_status_access_requested",s),t.taskEither.map(i=>i.status)),{...r,requires:"web_app_request_emoji_status_access",returns:"task"})}function tr(){return er(t.function.pipe(C(),y,O))}const Ye=tr(),rr=l(Ye);function sr({request:n,...r}){return q((s,i)=>t.function.pipe(n("web_app_set_emoji_status",["emoji_status_set","emoji_status_failed"],{params:{custom_emoji_id:s,duration:(i||{}).duration},...i}),t.taskEither.chainW(o=>o.event==="emoji_status_failed"?t.taskEither.left(new Oe(o.payload.error)):t.taskEither.right(void 0))),{...r,requires:"web_app_set_emoji_status",returns:"task"})}function nr(){return sr(t.function.pipe(C(),O,y))}const Ze=nr(),ir=l(Ze);class Xe{constructor({postEvent:r,isTma:s,version:i}){e(this,"isSupported");e(this,"impactOccurredFp");e(this,"impactOccurred");e(this,"notificationOccurredFp");e(this,"notificationOccurred");e(this,"selectionChangedFp");e(this,"selectionChanged");const o="web_app_trigger_haptic_feedback",u=I({requires:o,isTma:s,version:i,returns:"plain"});this.isSupported=W(o,i),this.impactOccurredFp=u(c=>r(o,{type:"impact",impact_style:c})),this.notificationOccurredFp=u(c=>r(o,{type:"notification",notification_type:c})),this.selectionChangedFp=u(()=>r(o,{type:"selection_change"})),this.impactOccurred=l(this.impactOccurredFp),this.notificationOccurred=l(this.notificationOccurredFp),this.selectionChanged=l(this.selectionChangedFp)}}function or(){return new Xe(t.function.pipe(C(),R,y))}const ar=or();function ur({postEvent:n,...r}){return q(()=>n("web_app_add_to_home_screen"),{...r,requires:"web_app_add_to_home_screen",returns:"either"})}function cr(){return ur(t.function.pipe(C(),y,R))}const et=cr(),pr=l(et);function hr({request:n,...r}){return q(s=>t.function.pipe(n("web_app_check_home_screen","home_screen_checked",s),t.taskEither.map(i=>i.status||"unknown")),{...r,requires:"web_app_check_home_screen",returns:"task"})}function lr(){return hr(t.function.pipe(C(),y,O))}const tt=lr(),dr=l(tt);class rt{constructor({retrieveInitData:r}){e(this,"_state",b.signal());e(this,"_raw",b.signal());e(this,"state",b.computed(this._state));e(this,"authDate",this.fromState("auth_date"));e(this,"canSendAfter",this.fromState("can_send_after"));e(this,"canSendAfterDate",b.computed(()=>{const r=this.authDate(),s=this.canSendAfter();return s&&r?new Date(r.getTime()+s*1e3):void 0}));e(this,"chat",this.fromState("chat"));e(this,"chatType",this.fromState("chat_type"));e(this,"chatInstance",this.fromState("chat_instance"));e(this,"hash",this.fromState("hash"));e(this,"queryId",this.fromState("query_id"));e(this,"raw",b.computed(this._raw));e(this,"receiver",this.fromState("receiver"));e(this,"signature",this.fromState("signature"));e(this,"startParam",this.fromState("start_param"));e(this,"auth",this.fromState("auth"));e(this,"user",this.fromState("user"));e(this,"restoreFp");e(this,"restore");this.restoreFp=()=>t.function.pipe(r(),t.either.map(t.option.match(()=>{},({raw:s,obj:i})=>{this._state.set(i),this._raw.set(s)}))),this.restore=x.throwifyFpFn(this.restoreFp)}fromState(r){return b.computed(()=>{const s=this._state();return s?s[r]:void 0})}}function fr(){return new rt({retrieveInitData(){return t.function.pipe(t.either.Do,t.either.bindW("obj",()=>t.function.pipe(h.retrieveLaunchParamsFp(),t.either.map(({vbWebAppData:n})=>n?t.option.some(n):t.option.none))),t.either.bindW("raw",h.retrieveRawInitDataFp),t.either.map(({obj:n,raw:r})=>t.function.pipe(t.option.Do,t.option.bind("obj",()=>n),t.option.bind("raw",()=>r))))}})}const mr=fr();class st{constructor({version:r,request:s,isTma:i}){e(this,"isOpened");e(this,"isSupported");e(this,"openSlugFp");e(this,"openSlug");e(this,"openUrlFp");e(this,"openUrl");const o=I({version:r,isTma:i,requires:"web_app_open_invoice",returns:"task"}),u=b.signal(!1),c=()=>{u.set(!1)};this.isSupported=W("web_app_open_invoice",r),this.isOpened=b.computed(u),this.openSlugFp=o((a,p)=>t.function.pipe(this.isOpened()?t.taskEither.left(new ae("Invoice is already opened")):t.taskEither.right(void 0),t.taskEither.chain(()=>(u.set(!0),s("web_app_open_invoice","invoice_closed",{...p,params:{slug:a},capture:m=>a===m.slug}))),t.taskEither.mapBoth(m=>(c(),m),m=>(c(),m.status)))),this.openUrlFp=o((a,p)=>{const{hostname:m,pathname:F}=new URL(a,window.location.href);if(m!=="t.me")return t.taskEither.left(new U(`Link has unexpected hostname: ${m}`));const f=F.match(/^\/(\$|invoice\/)([A-Za-z0-9\-_=]+)$/);return f?this.openSlugFp(f[2],p):t.taskEither.left(new U('Expected to receive a link with a pathname in format "/invoice/{slug}" or "/${slug}"'))}),this.openUrl=l(this.openUrlFp),this.openSlug=l(this.openSlugFp)}}function _r(){return new st(t.function.pipe(C(),O,y))}const br=_r();function gr({postEvent:n,...r}){return q((s,i={})=>{if(typeof s=="string")try{s=new URL(s)}catch(o){return t.either.left(new U(`"${s.toString()}" is invalid URL`,o))}return n("web_app_open_link",{url:s.toString(),try_browser:i.tryBrowser,try_instant_view:i.tryInstantView})},{...r,returns:"either"})}function Fr(){return gr(t.function.pipe(C(),R))}const nt=Fr(),wr=l(nt);function Cr({postEvent:n,version:r,...s}){return q(i=>{const o=i.toString();return o.match(/^https:\/\/t.me\/.+/)?h.supports("web_app_open_tg_link",j(r))?(i=new URL(i),n("web_app_open_tg_link",{path_full:i.pathname+i.search})):(window.location.href=o,t.either.right(void 0)):t.either.left(new U(`"${o}" is invalid URL`))},{...s,returns:"either"})}function Sr(){return Cr(t.function.pipe(C(),R,y))}const Se=Sr(),kr=l(Se);function Er({openTelegramLink:n,...r}){return q((s,i)=>n("https://t.me/share/url?"+new URLSearchParams({url:s,text:i||""}).toString().replace(/\+/g,"%20")),{...r,returns:"either"})}function yr(){return Er({...C(),openTelegramLink:Se})}const it=yr(),vr=l(it);function Ir(n){let r=!1,s,i;return n.available&&(r=!0,s=n.access_requested,i=n.access_granted),{available:r,accessGranted:i||!1,accessRequested:s||!1}}class ot{constructor({version:r,request:s,postEvent:i,storage:o,isTma:u,isPageReload:c}){e(this,"state");e(this,"isAvailable");e(this,"isAccessGranted");e(this,"isAccessRequested");e(this,"isMounted");e(this,"isSupported");e(this,"openSettingsFp");e(this,"openSettings");e(this,"requestLocationFp");e(this,"requestLocation");e(this,"mountFp");e(this,"mount");e(this,"unmount");const a=new z({initialState:{available:!1,accessGranted:!1,accessRequested:!1},onChange:o.set}),p=new Fe({isPageReload:c,restoreState:o.get,onMounted:a.setState,initialState(w){return t.function.pipe(s("web_app_check_location","location_checked",w),t.taskEither.map(Ir))}}),m={version:r,requires:"web_app_check_location",isTma:u},F=I({...m,returns:"either"}),f=I({...m,returns:"task"}),S=I({...m,returns:"task",isMounted:p.isMounted});this.isAvailable=a.getter("available"),this.isAccessRequested=a.getter("accessRequested"),this.isAccessGranted=a.getter("accessGranted"),this.isSupported=W("web_app_check_location",r),this.isMounted=p.isMounted,this.state=a.state,this.unmount=p.unmount,this.mountFp=f(p.mount),this.openSettingsFp=F(()=>i("web_app_open_location_settings")),this.requestLocationFp=S(w=>t.function.pipe(s("web_app_request_location","location_requested",w),t.taskEither.map(k=>{if(!k.available)return a.setState({available:!1}),null;const{available:E,..._}=k;return _}))),this.mount=l(this.mountFp),this.openSettings=l(this.openSettingsFp),this.requestLocation=l(this.requestLocationFp)}}function Br(){return new ot(t.function.pipe(C(),R,y,O,N("locationManager")))}const qr=Br();class at{constructor({defaults:r,...s}){e(this,"bgColor");e(this,"hasShineEffect");e(this,"isEnabled");e(this,"isLoaderVisible");e(this,"isVisible");e(this,"isMounted");e(this,"state");e(this,"text");e(this,"textColor");e(this,"showFp");e(this,"show");e(this,"hideFp");e(this,"hide");e(this,"enableFp");e(this,"enable");e(this,"enableShineEffectFp");e(this,"enableShineEffect");e(this,"disableFp");e(this,"disable");e(this,"disableShineEffectFp");e(this,"disableShineEffect");e(this,"setBgColorFp");e(this,"setBgColor");e(this,"setTextColorFp");e(this,"setTextColor");e(this,"setTextFp");e(this,"setText");e(this,"showLoaderFp");e(this,"showLoader");e(this,"hideLoaderFp");e(this,"hideLoader");e(this,"setParamsFp");e(this,"setParams");e(this,"mountFp");e(this,"mount");e(this,"unmount");e(this,"onClickFp");e(this,"onClick");e(this,"offClickFp");e(this,"offClick");const i=new ue({...s,version:"100",initialState:{hasShineEffect:!1,isEnabled:!0,isLoaderVisible:!1,isVisible:!1,text:"Continue"},method:"web_app_setup_main_button",payload:u=>({has_shine_effect:u.hasShineEffect,is_visible:u.isVisible,is_active:u.isEnabled,is_progress_visible:u.isLoaderVisible,text:u.text,color:u.bgColor,text_color:u.textColor})}),o=(u,c)=>{const a=i.stateGetter(u);return b.computed(()=>a()||j(c))};this.bgColor=o("bgColor",r.bgColor),this.textColor=o("textColor",r.textColor),this.hasShineEffect=i.stateGetter("hasShineEffect"),this.isEnabled=i.stateGetter("isEnabled"),this.isLoaderVisible=i.stateGetter("isLoaderVisible"),this.text=i.stateGetter("text"),this.isVisible=i.stateGetter("isVisible"),this.isMounted=i.isMounted,this.state=i.state,[this.setBgColor,this.setBgColorFp]=i.stateSetters("bgColor"),[this.setTextColor,this.setTextColorFp]=i.stateSetters("textColor"),[[this.disableShineEffect,this.disableShineEffectFp],[this.enableShineEffect,this.enableShineEffectFp]]=i.stateBoolSetters("hasShineEffect"),[[this.disable,this.disableFp],[this.enable,this.enableFp]]=i.stateBoolSetters("isEnabled"),[[this.hideLoader,this.hideLoaderFp],[this.showLoader,this.showLoaderFp]]=i.stateBoolSetters("isLoaderVisible"),[this.setText,this.setTextFp]=i.stateSetters("text"),[[this.hide,this.hideFp],[this.show,this.showFp]]=i.stateBoolSetters("isVisible"),this.setParams=i.setState,this.setParamsFp=i.setStateFp,this.onClick=i.onClick,this.onClickFp=i.onClickFp,this.offClick=i.offClick,this.offClickFp=i.offClickFp,this.mount=i.mount,this.mountFp=i.mountFp,this.unmount=i.unmount}}function ke(n,r){document.documentElement.style.setProperty(n,r)}function Ee(n){document.documentElement.style.removeProperty(n)}function ut(n){return t.function.pipe(A.toRGBFullFp(n),t.either.map(r=>Math.sqrt([.299,.587,.114].reduce((s,i,o)=>{const u=parseInt(r.slice(1+o*2,1+(o+1)*2),16);return s+u*u*i},0))<120))}const ye=x.throwifyFpFn(ut);class ct{constructor({initialState:r,onChange:s,offChange:i,isTma:o,storage:u,isPageReload:c}){e(this,"accentTextColor");e(this,"bgColor");e(this,"buttonColor");e(this,"buttonTextColor");e(this,"bottomBarBgColor");e(this,"destructiveTextColor");e(this,"headerBgColor");e(this,"hintColor");e(this,"linkColor");e(this,"secondaryBgColor");e(this,"sectionBgColor");e(this,"sectionHeaderTextColor");e(this,"sectionSeparatorColor");e(this,"subtitleTextColor");e(this,"textColor");e(this,"_isCssVarsBound",b.signal(!1));e(this,"isCssVarsBound",b.computed(this._isCssVarsBound));e(this,"bindCssVarsFp");e(this,"bindCssVars");e(this,"state");e(this,"isDark",b.computed(()=>{const r=this.bgColor();return!r||ye(r)}));e(this,"isMounted");e(this,"mountFp");e(this,"mount");e(this,"unmount");const a=new z({initialState:{},onChange:u.set}),p=w=>{a.setState(w.theme_params)},m=new re({initialState:()=>t.either.right(j(r)),isPageReload:c,onMounted(w){a.setState(w),s(p)},onUnmounted(){i(p)},restoreState:u.get}),F={isTma:o,returns:"either"},f=I(F),S=I({...F,isMounted:m.isMounted});this.accentTextColor=a.getter("accent_text_color"),this.bgColor=a.getter("bg_color"),this.buttonColor=a.getter("button_color"),this.buttonTextColor=a.getter("button_text_color"),this.bottomBarBgColor=a.getter("bottom_bar_bg_color"),this.destructiveTextColor=a.getter("destructive_text_color"),this.headerBgColor=a.getter("header_bg_color"),this.hintColor=a.getter("hint_color"),this.linkColor=a.getter("link_color"),this.secondaryBgColor=a.getter("secondary_bg_color"),this.sectionBgColor=a.getter("section_bg_color"),this.sectionHeaderTextColor=a.getter("section_header_text_color"),this.sectionSeparatorColor=a.getter("section_separator_color"),this.subtitleTextColor=a.getter("subtitle_text_color"),this.textColor=a.getter("text_color"),this.state=a.state,this.isMounted=m.isMounted,this.bindCssVarsFp=S(w=>{if(this._isCssVarsBound())return t.either.left(new oe);w||(w=_=>`--tg-theme-${x.snakeToKebab(_)}`);const k=_=>{Object.entries(a.state()).forEach(([g,d])=>{d&&_(g,d)})},E=()=>{k((_,g)=>{ke(w(_),g)})};return E(),a.state.sub(E),this._isCssVarsBound.set(!0),t.either.right(()=>{k(Ee),a.state.unsub(E),this._isCssVarsBound.set(!1)})}),this.mountFp=f(m.mount),this.unmount=m.unmount,this.bindCssVars=l(this.bindCssVarsFp),this.mount=l(this.mountFp)}}const me=se({});function Ar(){return new ct({...t.function.pipe(C(),N("themeParams")),offChange(n){h.off("theme_changed",n)},onChange(n){h.on("theme_changed",n)},initialState:me})}const te=Ar();function pt(n,r,s){return t.function.pipe(ge(n,r),i=>({...i,defaults:s}))}const Pr=new at(pt("mainButton","main_button_pressed",{bgColor:b.computed(()=>te.buttonColor()||"#2481cc"),textColor:b.computed(()=>te.buttonTextColor()||"#ffffff")}));class ht{constructor({storage:r,isPageReload:s,version:i,postEvent:o,isTma:u,theme:c,onVisibilityChanged:a,offVisibilityChanged:p}){e(this,"isSupported");e(this,"isDark",b.computed(()=>{const r=this.bgColorRgb();return r?ye(r):!1}));e(this,"isActive");e(this,"state");e(this,"isCssVarsBound");e(this,"bindCssVarsFp");e(this,"bindCssVars");e(this,"isMounted");e(this,"mountFp");e(this,"mount");e(this,"unmount");e(this,"bgColor");e(this,"bgColorRgb");e(this,"setBgColorFp");e(this,"setBgColor");e(this,"headerColor");e(this,"headerColorRgb");e(this,"setHeaderColorFp");e(this,"setHeaderColor");e(this,"bottomBarColor");e(this,"bottomBarColorRgb");e(this,"setBottomBarColorFp");e(this,"setBottomBarColor");e(this,"closeFp");e(this,"close");e(this,"readyFp");e(this,"ready");const m=d=>{S.setState({isActive:d.is_visible})},F=d=>{[[this.headerColor,"web_app_set_header_color"],[this.bgColor,"web_app_set_background_color"],[this.bottomBarColor,"web_app_set_bottom_bar_color"]].forEach(([P,V])=>{const T=P();if(!A.isRGB(T)&&(V!=="web_app_set_header_color"||!["bg_color","secondary_bg_color"].includes(T))){const D=d[T];D&&o(V,{color:D})}})},f=new re({initialState(){return t.either.right({bgColor:"bg_color",headerColor:"header_bg_color",bottomBarColor:"bottom_bar_bg_color",isActive:!0})},isPageReload:s,onMounted:d=>{a(m),c.sub(F),S.setState(d)},onUnmounted(){p(m),c.unsub(F)},restoreState:r.get});this.isMounted=f.isMounted,this.mountFp=q(()=>{const d=()=>{};return t.function.pipe(f.mount(),t.either.match(d,d))},{isTma:u,returns:"plain"}),this.mount=l(this.mountFp),this.unmount=f.unmount;const S=new z({initialState:{bgColor:"bg_color",bottomBarColor:"bottom_bar_bg_color",headerColor:"bg_color",isActive:!1},onChange:r.set});this.state=S.state;const w=d=>A.isRGB(d)?d:j(c)[d],k=d=>b.computed(()=>w(d()));this.isActive=S.getter("isActive"),this.isSupported=b.computed(()=>["web_app_set_header_color","web_app_set_background_color","web_app_set_bottom_bar_color"].some(d=>h.supports(d,j(i))));const E=b.signal(!1);this.isCssVarsBound=b.computed(E),this.bindCssVarsFp=q(d=>{if(E())return t.either.left(new oe);const[P,V]=x.createCbCollector(()=>{E.set(!1)}),T=(D,L)=>{const H=()=>{ke(D,L()||null)};H(),P(L.sub(H),Ee.bind(null,D))};return d||(d=D=>`--tg-${x.camelToKebab(D)}`),T(d("bgColor"),this.bgColorRgb),T(d("bottomBarColor"),this.bottomBarColorRgb),T(d("headerColor"),this.headerColorRgb),E.set(!0),t.either.right(V)},{isTma:u,returns:"either",isMounted:this.isMounted}),this.bindCssVars=l(this.bindCssVarsFp);const _=d=>{const P=S.getter(d),V=k(P),T={headerColor:"web_app_set_header_color",bgColor:"web_app_set_background_color",bottomBarColor:"web_app_set_bottom_bar_color"}[d],D=q(L=>{if(L===P())return t.either.right(void 0);if(T==="web_app_set_header_color"&&(L==="bg_color"||L==="secondary_bg_color"))return t.function.pipe(o("web_app_set_header_color",{color_key:L}),t.either.map(()=>{S.setState({[d]:L})}));const H=w(L);return t.function.pipe(H?o(T,{color:H}):t.either.left(new $e(L)),t.either.map(()=>{S.setState({[d]:L})}))},{isTma:u,version:i,requires:T,isMounted:this.isMounted,returns:"either",supports:d==="headerColor"?{rgb:{method:"web_app_set_header_color",param:"color",shouldCheck:A.isRGB}}:void 0});return[P,V,l(D),D]};[this.bgColor,this.bgColorRgb,this.setBgColor,this.setBgColorFp]=_("bgColor"),[this.headerColor,this.headerColorRgb,this.setHeaderColor,this.setHeaderColorFp]=_("headerColor"),[this.bottomBarColor,this.bottomBarColorRgb,this.setBottomBarColor,this.setBottomBarColorFp]=_("bottomBarColor");const g=I({isTma:u,returns:"either"});this.closeFp=g(d=>o("web_app_close",{return_back:d})),this.close=l(this.closeFp),this.readyFp=g(()=>o("web_app_ready")),this.ready=l(this.readyFp)}}function Mr(){return new ht({...t.function.pipe(C(),R,y,N("miniApp")),offVisibilityChanged(n){h.off("visibility_changed",n)},onVisibilityChanged(n){h.on("visibility_changed",n)},theme:te.state})}const lt=Mr();function xr(){const n=Date.now(),r=Math.random().toString(36).substring(2,9);return`notif_${n}_${r}`}class dt{constructor({}){e(this,"sendFp");e(this,"send");this.sendFp=r=>t.function.pipe(t.taskEither.fromEither(h.postEventFp("web_app_send_notification",{id:xr(),message:r.message,title:r.title,type:r.type??"default"})),t.taskEither.map(()=>{})),this.send=r=>this.sendFp(r)().then(i=>{if(i._tag==="Left")throw i.left;return i.right})}}function Tr(){return new dt(t.function.pipe(C()))}const Rr=Tr();function Vr(n){const r=n.message.trim(),s=(n.title||"").trim(),i=n.buttons||[];if(s.length>64)return t.either.left(new U(`Invalid title: ${s}`));if(!r||r.length>256)return t.either.left(new U(`Invalid message: ${r}`));if(i.length>3)return t.either.left(new U(`Invalid buttons count: ${i.length}`));const o=[];if(!i.length)o.push({type:"close",id:""});else for(let u=0;u<i.length;u++){const c=i[u],a=c.id||"";if(a.length>64)return t.either.left(new U(`Button with index ${u} has invalid id: ${a}`));if(!c.type||c.type==="default"||c.type==="destructive"){const p=c.text.trim();if(!p||p.length>64)return t.either.left(new U(`Button with index ${u} has invalid text: ${p}`));o.push({type:c.type,text:p,id:a})}else o.push({type:c.type,id:a})}return t.either.right({title:s,message:r,buttons:o})}class ft{constructor({version:r,isTma:s,request:i}){e(this,"isOpened");e(this,"isSupported");e(this,"showFp");e(this,"show");const o=b.signal(!1),u=()=>{o.set(!1)},c=I({version:r,isTma:s,requires:"web_app_open_popup",returns:"task"});this.isSupported=W("web_app_open_popup",r),this.isOpened=b.computed(o),this.showFp=c(a=>t.function.pipe(this.isOpened()?t.taskEither.left(new ae("A popup is already opened")):t.taskEither.right(void 0),t.taskEither.chainW(()=>t.taskEither.fromEither(Vr(a))),t.taskEither.chain(p=>(o.set(!0),i("web_app_open_popup","popup_closed",{...a,params:p}))),t.taskEither.mapBoth(p=>(u(),p),p=>(u(),p.button_id)))),this.show=l(this.showFp)}}function Or(){return new ft(t.function.pipe(C(),O,y))}const Lr=Or();function jr({request:n,...r}){return q(s=>t.function.pipe(n("web_app_request_phone","phone_requested",s),t.taskEither.map(i=>i.status)),{...r,requires:"web_app_request_phone",returns:"task"})}function $r(){return jr(t.function.pipe(C(),y,O))}const ve=$r(),Dr=l(ve);function Gr({invokeCustomMethod:n,requestPhoneAccess:r,...s}){const i=c=>t.function.pipe(n("getRequestedContact",{},{...c,timeout:(c||{}).timeout||5e3}),t.taskEither.chainW(a=>{const p=v.safeParse(v.string(),a);if(!p.success)return t.taskEither.left(new ee(a,p.issues));if(!p.output)return t.taskEither.right(void 0);const m=v.safeParse(A.pipeQueryToSchema(v.looseObject({contact:A.pipeJsonToSchema(v.looseObject({user_id:v.number(),phone_number:v.string(),first_name:v.string(),last_name:v.optional(v.string())})),auth_date:v.pipe(v.string(),v.transform(F=>new Date(Number(F)*1e3)),v.date()),hash:v.string()})),p.output);return m.success?t.taskEither.right({raw:p.output,parsed:m.output}):t.taskEither.left(new ee(p.output,m.issues))})),o=c=>t.function.pipe(i(c),t.taskEither.match(a=>ee.is(a)?t.either.left(a):t.either.right(void 0),a=>t.either.right(a))),u=c=>x.BetterTaskEither(async(a,p,m)=>{let F=50;for(;!m.isRejected;){const f=await o(m)();if(f._tag==="Left")return p(f.left);if(f.right)return a(f.right);await new Promise(S=>setTimeout(S,F)),F+=50}},c);return q(c=>x.BetterTaskEither.fn(a=>t.function.pipe(o(a),t.taskEither.chain(p=>p?t.taskEither.right(p):t.function.pipe(r(a),t.taskEither.chainW(m=>m==="sent"?u(a):t.taskEither.left(new be("User denied access")))))),c),{...s,returns:"task",requires:"web_app_request_phone"})}function Ur(){return Gr({...t.function.pipe(C(),Ce,y),requestPhoneAccess:ve})}function Hr({requestContact:n,...r}){return q(n,{...r,returns:"task",requires:"web_app_request_phone"})}function Wr(){return Hr({...t.function.pipe(C(),y),requestContact(n){return t.function.pipe(Ie(n),t.taskEither.map(r=>r.parsed))}})}const Ie=Ur(),Qr=l(Ie),mt=Wr(),Kr=l(mt);function zr({request:n,...r}){return q(s=>t.function.pipe(n("web_app_request_write_access","write_access_requested",s),t.taskEither.map(i=>i.status)),{...r,requires:"web_app_request_write_access",returns:"task"})}function Nr(){return zr(t.function.pipe(C(),y,O))}const _t=Nr(),Jr=l(_t);class bt{constructor({version:r,onClosed:s,onTextReceived:i,isTma:o,postEvent:u}){e(this,"isOpened");e(this,"isSupported");e(this,"captureFp");e(this,"capture");e(this,"closeFp");e(this,"close");e(this,"openFp");e(this,"open");const c={version:r,requires:"web_app_open_scan_qr_popup",isTma:o},a=I({...c,returns:"either"}),p=I({...c,returns:"task"}),m=b.signal(!1),F=()=>{m.set(!1)};this.isSupported=W("web_app_open_scan_qr_popup",r),this.isOpened=b.computed(m),this.captureFp=p(f=>{let S;return t.function.pipe(this.openFp({...f,onCaptured:w=>{f.capture(w)&&(S=w,this.close())}}),t.taskEither.map(()=>S))}),this.closeFp=a(()=>t.function.pipe(u("web_app_close_scan_qr_popup"),t.either.map(F))),this.openFp=p(f=>t.function.pipe(m()?t.taskEither.left(new ae("The QR Scanner is already opened")):async()=>u("web_app_open_scan_qr_popup",{text:f.text}),t.taskEither.chainW(()=>{m.set(!0);const[S,w]=x.createCbCollector(),k=E=>(w(),m.set(!1),E);return t.function.pipe(x.BetterTaskEither(E=>{S(s(E),m.sub(_=>{_||E()}),i(f.onCaptured))},f),t.taskEither.mapBoth(k,k))}))),this.open=l(this.openFp),this.capture=l(this.captureFp),this.close=l(this.closeFp)}}function Yr(){return new bt({...t.function.pipe(C(),R,y),onClosed(n){return h.on("scan_qr_popup_closed",n)},onTextReceived(n){return h.on("qr_text_received",r=>{n(r.data)})}})}const Zr=Yr();class gt{constructor({}){e(this,"isRefreshing");e(this,"finishRefreshFp");e(this,"finishRefresh");e(this,"onRefreshRequest");const r=b.signal(!1);h.on("refresh_requested",()=>{r.set(!0)}),this.isRefreshing=b.computed(r),this.finishRefreshFp=()=>t.function.pipe(t.taskEither.fromEither(h.postEventFp("web_app_finish_refresh",{isRefreshed:!0})),t.taskEither.map(()=>{r.set(!1)})),this.finishRefresh=()=>this.finishRefreshFp()().then(i=>{if(i._tag==="Left")throw i.left;return i.right}),this.onRefreshRequest=s=>{const i=()=>{s()};return h.on("refresh_requested",i)}}}function Xr(){return new gt(t.function.pipe(C()))}const es=Xr();class Ft{constructor({defaults:r,...s}){e(this,"isSupported");e(this,"position");e(this,"bgColor");e(this,"hasShineEffect");e(this,"isEnabled");e(this,"isLoaderVisible");e(this,"isVisible");e(this,"isMounted");e(this,"state");e(this,"text");e(this,"textColor");e(this,"showFp");e(this,"show");e(this,"hideFp");e(this,"hide");e(this,"enableFp");e(this,"enable");e(this,"enableShineEffectFp");e(this,"enableShineEffect");e(this,"disableFp");e(this,"disable");e(this,"disableShineEffectFp");e(this,"disableShineEffect");e(this,"setBgColorFp");e(this,"setBgColor");e(this,"setTextColorFp");e(this,"setTextColor");e(this,"setTextFp");e(this,"setText");e(this,"setPositionFp");e(this,"setPosition");e(this,"showLoaderFp");e(this,"showLoader");e(this,"hideLoaderFp");e(this,"hideLoader");e(this,"setParamsFp");e(this,"setParams");e(this,"mountFp");e(this,"mount");e(this,"unmount");e(this,"onClickFp");e(this,"onClick");e(this,"offClickFp");e(this,"offClick");const i=new ue({...s,initialState:{hasShineEffect:!1,isEnabled:!0,isLoaderVisible:!1,isVisible:!1,text:"Cancel",position:"left"},method:"web_app_setup_secondary_button",payload:u=>({has_shine_effect:u.hasShineEffect,is_visible:u.isVisible,is_active:u.isEnabled,is_progress_visible:u.isLoaderVisible,text:u.text,color:u.bgColor,text_color:u.textColor,position:u.position})}),o=(u,c)=>{const a=i.stateGetter(u);return b.computed(()=>a()||j(c))};this.isSupported=W("web_app_setup_secondary_button",s.version),this.bgColor=o("bgColor",r.bgColor),this.textColor=o("textColor",r.textColor),this.position=i.stateGetter("position"),this.hasShineEffect=i.stateGetter("hasShineEffect"),this.isEnabled=i.stateGetter("isEnabled"),this.isLoaderVisible=i.stateGetter("isLoaderVisible"),this.text=i.stateGetter("text"),this.isVisible=i.stateGetter("isVisible"),this.isMounted=i.isMounted,this.state=i.state,[this.setPosition,this.setPositionFp]=i.stateSetters("position"),[this.setBgColor,this.setBgColorFp]=i.stateSetters("bgColor"),[this.setTextColor,this.setTextColorFp]=i.stateSetters("textColor"),[[this.disableShineEffect,this.disableShineEffectFp],[this.enableShineEffect,this.enableShineEffectFp]]=i.stateBoolSetters("hasShineEffect"),[[this.disable,this.disableFp],[this.enable,this.enableFp]]=i.stateBoolSetters("isEnabled"),[[this.hideLoader,this.hideLoaderFp],[this.showLoader,this.showLoaderFp]]=i.stateBoolSetters("isLoaderVisible"),[this.setText,this.setTextFp]=i.stateSetters("text"),[[this.hide,this.hideFp],[this.show,this.showFp]]=i.stateBoolSetters("isVisible"),this.setParams=i.setState,this.setParamsFp=i.setStateFp,this.onClick=i.onClick,this.onClickFp=i.onClickFp,this.offClick=i.offClick,this.offClickFp=i.offClickFp,this.mount=i.mount,this.mountFp=i.mountFp,this.unmount=i.unmount}}function ts(){return new Ft(pt("secondaryButton","secondary_button_pressed",{bgColor:b.computed(()=>lt.bottomBarColorRgb()||"#000000"),textColor:b.computed(()=>te.buttonColor()||"#2481cc")}))}const rs=ts();class wt{constructor({isTma:r,request:s,version:i,createRequestId:o}){e(this,"getItemFp");e(this,"getItem");e(this,"restoreItemFp");e(this,"restoreItem");e(this,"setItemFp");e(this,"setItem");e(this,"deleteItemFp");e(this,"deleteItem");e(this,"clearFp");e(this,"clear");const u=I({version:i,requires:"web_app_secure_storage_get_key",isTma:r,returns:"task"}),c=(a,p,m)=>{const F=o();return t.function.pipe(s(a,["secure_storage_failed",p],{params:{...m,req_id:F},capture:(f=>"payload"in f?f.payload.req_id===F:!0)}),t.taskEither.chain(f=>f.event==="secure_storage_failed"?t.taskEither.left(new Te(f.payload.error||"UNKNOWN_ERROR")):t.taskEither.right(f.payload)))};this.getItemFp=u(a=>t.function.pipe(c("web_app_secure_storage_get_key","secure_storage_key_received",{key:a}),t.taskEither.map(p=>({value:p.value,canRestore:!!p.can_restore})))),this.setItemFp=u((a,p)=>t.function.pipe(c("web_app_secure_storage_save_key","secure_storage_key_saved",{key:a,value:p}),t.taskEither.map(()=>{}))),this.deleteItemFp=u(a=>this.setItemFp(a,null)),this.clearFp=u(()=>t.function.pipe(c("web_app_secure_storage_clear","secure_storage_cleared",{}),t.taskEither.map(()=>{}))),this.restoreItemFp=u(a=>t.function.pipe(c("web_app_secure_storage_restore_key","secure_storage_key_restored",{key:a}),t.taskEither.map(p=>p.value))),this.getItem=l(this.getItemFp),this.setItem=l(this.setItemFp),this.deleteItem=l(this.deleteItemFp),this.clear=l(this.clearFp),this.restoreItem=l(this.restoreItemFp)}}function ss(){return new wt(t.function.pipe(C(),y,O,Je))}const ns=ss();class Ct{constructor(r){e(this,"isVisible");e(this,"isMounted");e(this,"isSupported");e(this,"hideFp");e(this,"hide");e(this,"showFp");e(this,"show");e(this,"onClickFp");e(this,"onClick");e(this,"offClickFp");e(this,"offClick");e(this,"mountFp");e(this,"mount");e(this,"unmount");const s=new ue({...r,method:"web_app_setup_settings_button",payload:i=>({is_visible:i.isVisible}),initialState:{isVisible:!1}});this.isVisible=s.stateGetter("isVisible"),this.isMounted=s.isMounted,this.isSupported=s.isSupported,[[this.hide,this.hideFp],[this.show,this.showFp]]=s.stateBoolSetters("isVisible"),this.onClick=s.onClick,this.onClickFp=s.onClickFp,this.offClick=s.offClick,this.offClickFp=s.offClickFp,this.mount=s.mount,this.mountFp=s.mountFp,this.unmount=s.unmount}}const is=new Ct(ge("settingsButton","settings_button_pressed"));class St{constructor({postEvent:r,storage:s,isTma:i,isPageReload:o,version:u}){e(this,"isSupported");e(this,"isVerticalEnabled");e(this,"isMounted");e(this,"mountFp");e(this,"mount");e(this,"unmount");e(this,"disableVerticalFp");e(this,"disableVertical");e(this,"enableVerticalFp");e(this,"enableVertical");const c={isVerticalEnabled:!0},a=new z({initialState:c,onChange(w){s.set(w)}}),p=new re({initialState:c,isPageReload:o,onMounted:a.setState,restoreState:s.get}),m={requires:"web_app_setup_swipe_behavior",isTma:i,version:u},F=I({...m,returns:"plain"}),f=I({...m,isMounted:p.isMounted,returns:"either"}),S=w=>{const k={isVerticalEnabled:w};return a.hasDiff(k)?t.function.pipe(r("web_app_setup_swipe_behavior",{allow_vertical_swipe:w}),t.either.map(()=>{a.setState(k)})):t.either.right(void 0)};this.isSupported=W("web_app_setup_swipe_behavior",u),this.isVerticalEnabled=a.getter("isVerticalEnabled"),this.isMounted=p.isMounted,this.disableVerticalFp=f(()=>S(!1)),this.enableVerticalFp=f(()=>S(!0)),this.mountFp=F(()=>{const w=()=>{};return t.function.pipe(p.mount(),t.either.match(w,w))}),this.unmount=p.unmount,this.disableVertical=l(this.disableVerticalFp),this.enableVertical=l(this.enableVerticalFp),this.mount=l(this.mountFp)}}function os(){return new St(t.function.pipe(C(),R,y,N("swipeBehavior")))}const as=os();async function us(n){try{const{clipboard:s}=navigator;if(s)return await s.writeText(n)}catch{}const r=document.createElement("textarea");r.value=n,r.style.top="0",r.style.left="0",r.style.position="fixed",document.body.appendChild(r),r.focus(),r.select();try{document.execCommand("copy")}finally{document.body.removeChild(r)}}function cs({request:n,...r}){return q((s,i,o)=>t.function.pipe(n("web_app_request_file_download","file_download_requested",{...o,params:{url:s,file_name:i}}),t.taskEither.chain(u=>u.status==="downloading"?t.taskEither.right(void 0):t.taskEither.left(new be("User denied the action")))),{...r,requires:"web_app_request_file_download",returns:"task"})}function ps(){return cs(t.function.pipe(C(),O,y))}const kt=ps(),hs=l(kt);function ls({invokeCustomMethod:n,...r}){return q(s=>t.function.pipe(n("getCurrentTime",{},s),t.taskEither.chain(i=>{const o=v.safeParse(v.pipe(v.number(),v.integer(),v.transform(u=>new Date(u*1e3)),v.date()),i);return o.success?t.taskEither.right(o.output):t.taskEither.left(new ee(i,o.issues))})),{...r,requires:"web_app_invoke_custom_method",returns:"task"})}function ds(){return ls(t.function.pipe(C(),Ce,y))}const Et=ds(),fs=l(Et);function ms({postEvent:n,...r}){return q(()=>n("web_app_hide_keyboard"),{...r,returns:"either",requires:"web_app_hide_keyboard"})}function _s(){return ms(t.function.pipe(C(),R,y))}const yt=_s(),bs=l(yt);function gs({request:n,createRequestId:r,...s}){return q(i=>{const o=r();return t.function.pipe(n("web_app_read_text_from_clipboard","clipboard_text_received",{...i,params:{req_id:o},capture:h.captureSameReq(o)}),t.taskEither.map(({data:u=null})=>u))},{...s,requires:"web_app_read_text_from_clipboard",returns:"task"})}function Fs(){return gs({...t.function.pipe(C(),y,O),createRequestId:ce})}const vt=Fs(),ws=l(vt);function It(n){const r={},s=n.match(/Telegram-Android(?:\/([^ ]+))?(?: (\([^)]+\))?|$)/);if(s){const[,i,o]=s;i&&(r.appVersion=i),o&&o.slice(1,o.length-1).split(";").forEach(u=>{const[c,a]=u.trim().split(" ");if(c==="Android")r.androidVersion=a;else if(c==="SDK"){const p=parseInt(a,10);p&&(r.sdkVersion=p)}else a?(r.manufacturer=c,r.model=a):r.performanceClass=c})}return r}function Cs(){return It(navigator.userAgent)}function Ss({postEvent:n,...r}){return q(s=>{const{size:i}=new Blob([s]);return!i||i>4096?t.either.left(new U(i?"Maximum size of data to send is 4096 bytes":"Attempted to send empty data")):n("web_app_data_send",{data:s})},{...r,returns:"either"})}function ks(){return Ss(t.function.pipe(C(),R))}const Bt=ks(),Es=l(Bt);function ys({request:n,...r}){return q((s,i)=>t.function.pipe(n("web_app_send_prepared_message",["prepared_message_failed","prepared_message_sent"],{...i,params:{id:s}}),t.taskEither.chain(o=>o.event==="prepared_message_failed"?t.taskEither.left(new je(o.payload.error)):t.taskEither.right(void 0))),{...r,requires:"web_app_send_prepared_message",returns:"task"})}function vs(){return ys(t.function.pipe(C(),O,y))}const qt=vs(),Is=l(qt);function Bs({postEvent:n,...r}){return q((s,i={})=>n("web_app_share_to_story",{text:i.text,media_url:s,widget_link:i.widgetLink}),{...r,requires:"web_app_share_to_story",returns:"either"})}function qs(){return Bs(t.function.pipe(C(),R,y))}const At=qs(),As=l(At),_e=se(!1);function Ps({isInlineMode:n,postEvent:r,...s}){return q((i,o)=>r("web_app_switch_inline_query",{query:i,chat_types:o||[]}),{...s,requires:{every:["web_app_switch_inline_query",()=>j(n)?void 0:"The application must be launched in the inline mode"]},returns:"either"})}function Ms(){return Ps({...t.function.pipe(C(),R,y),isInlineMode:_e})}const Pt=Ms(),xs=l(Pt);class Mt{constructor({storage:r,isPageReload:s,onContentSafeAreaInsetsChanged:i,onSafeAreaInsetsChanged:o,onViewportChanged:u,onFullscreenChanged:c,offContentSafeAreaInsetsChanged:a,offFullscreenChanged:p,offSafeAreaInsetsChanged:m,offViewportChanged:F,request:f,isViewportStable:S,isFullscreen:w,isTma:k,version:E,postEvent:_}){e(this,"state");e(this,"height");e(this,"stableHeight");e(this,"width");e(this,"isExpanded");e(this,"isStable",b.computed(()=>this.height()===this.stableHeight()));e(this,"contentSafeAreaInsets");e(this,"contentSafeAreaInsetTop");e(this,"contentSafeAreaInsetLeft");e(this,"contentSafeAreaInsetRight");e(this,"contentSafeAreaInsetBottom");e(this,"safeAreaInsets");e(this,"safeAreaInsetTop");e(this,"safeAreaInsetLeft");e(this,"safeAreaInsetRight");e(this,"safeAreaInsetBottom");e(this,"isFullscreen");e(this,"requestFullscreenFp");e(this,"requestFullscreen");e(this,"exitFullscreenFp");e(this,"exitFullscreen");e(this,"isCssVarsBound");e(this,"bindCssVarsFp");e(this,"bindCssVars");e(this,"isMounted");e(this,"mountFp");e(this,"mount");e(this,"expandFp");e(this,"expand");const g={top:0,right:0,left:0,bottom:0},d=new z({initialState:{contentSafeAreaInsets:g,height:0,isExpanded:!1,isFullscreen:!1,safeAreaInsets:g,stableHeight:0,width:0},onChange:r.set}),P=B=>{d.setState({isExpanded:B.is_expanded,height:B.height,width:B.width,stableHeight:B.is_state_stable?B.height:void 0})},V=B=>{d.setState({isFullscreen:B.is_fullscreen})},T=B=>{d.setState({safeAreaInsets:B})},D=B=>{d.setState({contentSafeAreaInsets:B})},L=new Fe({initialState(B){const J=Q=>()=>{const[K,G]=Q==="safe-area"?["web_app_request_safe_area","safe_area_changed"]:["web_app_request_content_safe_area","content_safe_area_changed"];return h.supports(K,j(E))?f(K,G,B):t.taskEither.right({top:0,left:0,right:0,bottom:0})},M=Q=>()=>typeof Q=="boolean"?t.taskEither.right(Q):t.taskEither.fromEither(Q());return t.function.pipe(t.taskEither.Do,t.taskEither.bindW("safeAreaInsets",J("safe-area")),t.taskEither.bindW("contentSafeAreaInsets",J("content-safe-area")),t.taskEither.bindW("isFullscreen",M(w)),t.taskEither.bindW("isViewportStable",M(S)),t.taskEither.chainW(({isViewportStable:Q,...K})=>Q?t.taskEither.right({...K,height:window.innerHeight,isExpanded:!0,stableHeight:window.innerHeight,width:window.innerWidth}):t.function.pipe(f("web_app_request_viewport","viewport_changed",B),t.taskEither.map(G=>({...K,height:G.height,isExpanded:G.is_expanded,stableHeight:G.is_state_stable?G.height:0,width:G.width})))))},isPageReload:s,onMounted(B){u(P),c(V),o(T),i(D),d.setState(B)},onUnmounted(){F(P),p(V),m(T),a(D)},restoreState:r.get}),H=B=>b.computed(()=>this.safeAreaInsets()[B]),ne=B=>b.computed(()=>this.contentSafeAreaInsets()[B]);this.state=d.state,this.height=d.getter("height"),this.stableHeight=d.getter("stableHeight"),this.width=d.getter("width"),this.isExpanded=d.getter("isExpanded"),this.safeAreaInsets=d.getter("safeAreaInsets"),this.safeAreaInsetTop=H("top"),this.safeAreaInsetBottom=H("bottom"),this.safeAreaInsetLeft=H("left"),this.safeAreaInsetRight=H("right"),this.contentSafeAreaInsets=d.getter("contentSafeAreaInsets"),this.contentSafeAreaInsetTop=ne("top"),this.contentSafeAreaInsetBottom=ne("bottom"),this.contentSafeAreaInsetLeft=ne("left"),this.contentSafeAreaInsetRight=ne("right");const Rt=I({isTma:k,returns:"task"}),Be=I({isTma:k,returns:"either"}),Vt=I({isTma:k,requires:"web_app_request_fullscreen",version:E,returns:"task"}),qe=B=>Vt(J=>t.function.pipe(f(B?"web_app_request_fullscreen":"web_app_exit_fullscreen",["fullscreen_changed","fullscreen_failed"],J),t.taskEither.chain(M=>M.event==="fullscreen_failed"&&M.payload.error!=="ALREADY_FULLSCREEN"?t.taskEither.left(new Le(M.payload.error)):(d.setState({isFullscreen:"is_fullscreen"in M.payload?M.payload.is_fullscreen:!0}),t.taskEither.right(void 0)))));this.isMounted=L.isMounted,this.mountFp=Rt(L.mount),this.mount=l(this.mountFp),this.isFullscreen=d.getter("isFullscreen"),this.requestFullscreenFp=qe(!0),this.requestFullscreen=l(this.requestFullscreenFp),this.exitFullscreenFp=qe(!1),this.exitFullscreen=l(this.exitFullscreenFp);const ie=b.signal(!1);this.isCssVarsBound=b.computed(ie),this.bindCssVarsFp=Be(B=>{if(ie())return t.either.left(new oe);B||(B=M=>`--tg-viewport-${x.camelToKebab(M)}`);const J=[["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((M,[Q,K])=>{const G=B(Q);if(G){const Ae=()=>{ke(G,`${K()}px`)};M.push({update:Ae,removeListener:K.sub(Ae),cssVar:G})}return M},[]);return J.forEach(M=>{M.update()}),ie.set(!0),t.either.right(()=>{J.forEach(M=>{M.removeListener(),Ee(M.cssVar)}),ie.set(!1)})}),this.bindCssVars=l(this.bindCssVarsFp),this.expandFp=Be(()=>_("web_app_expand")),this.expand=l(this.expandFp)}}function Ts(){const n=u=>({on:c=>{h.on(u,c)},off:c=>{h.off(u,c)}}),r=n("viewport_changed"),s=n("fullscreen_changed"),i=n("safe_area_changed"),o=n("content_safe_area_changed");return new Mt({...t.function.pipe(C(),N("viewport"),y,R,O),isFullscreen(){return t.function.pipe(h.retrieveLaunchParamsFp(),t.either.map(u=>!!u.vbWebAppFullscreen))},isViewportStable(){return t.function.pipe(h.retrieveLaunchParamsFp(),t.either.map(u=>["macos","tdesktop","unigram","webk","weba","web"].includes(u.vbWebAppPlatform)))},offContentSafeAreaInsetsChanged:o.off,offFullscreenChanged:s.off,offSafeAreaInsetsChanged:i.off,offViewportChanged:r.off,onContentSafeAreaInsetsChanged:o.on,onFullscreenChanged:s.on,onSafeAreaInsetsChanged:i.on,onViewportChanged:r.on})}const Rs=Ts();class xt{constructor({request:r}){e(this,"requestAccessFp");e(this,"requestAccess");e(this,"selectFile");e(this,"selectFiles");e(this,"selectFolder");this.requestAccessFp=s=>t.function.pipe(r("web_app_request_storage_access","storage_access_granted",{params:{access_type:s.accessType,multiple:s.multiple,accept:s.accept,max_file_size:s.maxFileSize,read_content:s.readContent}}),t.taskEither.map(i=>({accessType:i.access_type,items:i.items.map(o=>({name:o.name,path:o.path,size:o.size,type:o.type,content:o.content,lastModified:o.last_modified}))}))),this.requestAccess=s=>this.requestAccessFp(s)().then(o=>{if(o._tag==="Left")throw o.left;return o.right}),this.selectFile=s=>this.requestAccess({accessType:"file",multiple:!1,...s}),this.selectFiles=s=>this.requestAccess({accessType:"file",multiple:!0,...s}),this.selectFolder=()=>this.requestAccess({accessType:"folder"})}}function Vs(){return new xt({request:h.request2Fp})}const Os=Vs();function Tt(n={}){const{version:r,isInlineMode:s,themeParams:i}=n;if(r&&typeof s=="boolean"&&i)fe.set(r),_e.set(s),me.set(i);else{const a=t.function.pipe(h.retrieveLaunchParamsFp(),t.either.matchW(p=>p,p=>{fe.set(r||p.vbWebAppVersion),_e.set(typeof s=="boolean"?s:!!p.vbWebAppBotInline),me.set(i||p.vbWebAppThemeParams)}));if(a)return t.either.left(a)}n.postEvent&&Ge.set(n.postEvent);const[o,u]=x.createCbCollector(h.on("reload_iframe",()=>{h.logger().log("Received a request to reload the page"),Ue("iframe_will_reload"),window.location.reload()})),{acceptCustomStyles:c=!0}=n;if(c){const a=document.createElement("style");a.id="telegram-custom-styles",document.head.appendChild(a),o(h.on("set_custom_style",p=>{a.innerHTML=p}),()=>{document.head.removeChild(a)})}return t.function.pipe(Z("iframe_ready",{reload_supported:!0}),t.either.map(()=>(h.logger().log("The package was initialized"),u)))}const Ls=x.throwifyFpFn(Tt);Object.defineProperty(exports,"CancelledError",{enumerable:!0,get:()=>h.CancelledError});Object.defineProperty(exports,"InvalidLaunchParamsError",{enumerable:!0,get:()=>h.InvalidLaunchParamsError});Object.defineProperty(exports,"InvokeCustomMethodFailedError",{enumerable:!0,get:()=>h.InvokeCustomMethodFailedError});Object.defineProperty(exports,"LaunchParamsRetrieveError",{enumerable:!0,get:()=>h.LaunchParamsRetrieveError});Object.defineProperty(exports,"MethodParameterUnsupportedError",{enumerable:!0,get:()=>h.MethodParameterUnsupportedError});Object.defineProperty(exports,"MethodUnsupportedError",{enumerable:!0,get:()=>h.MethodUnsupportedError});Object.defineProperty(exports,"TimeoutError",{enumerable:!0,get:()=>h.TimeoutError});Object.defineProperty(exports,"UnknownEnvError",{enumerable:!0,get:()=>h.UnknownEnvError});Object.defineProperty(exports,"applyPolyfills",{enumerable:!0,get:()=>h.applyPolyfills});Object.defineProperty(exports,"createLogger",{enumerable:!0,get:()=>h.createLogger});Object.defineProperty(exports,"createPostEvent",{enumerable:!0,get:()=>h.createPostEvent});Object.defineProperty(exports,"createStartParam",{enumerable:!0,get:()=>h.createStartParam});Object.defineProperty(exports,"createStartParamFp",{enumerable:!0,get:()=>h.createStartParamFp});Object.defineProperty(exports,"debug",{enumerable:!0,get:()=>h.debug});Object.defineProperty(exports,"decodeBase64Url",{enumerable:!0,get:()=>h.decodeBase64Url});Object.defineProperty(exports,"decodeBase64UrlFp",{enumerable:!0,get:()=>h.decodeBase64UrlFp});Object.defineProperty(exports,"decodeStartParam",{enumerable:!0,get:()=>h.decodeStartParam});Object.defineProperty(exports,"decodeStartParamFp",{enumerable:!0,get:()=>h.decodeStartParamFp});Object.defineProperty(exports,"deepSnakeToCamelObjKeys",{enumerable:!0,get:()=>h.deepSnakeToCamelObjKeys});Object.defineProperty(exports,"emitEvent",{enumerable:!0,get:()=>h.emitEvent});Object.defineProperty(exports,"encodeBase64Url",{enumerable:!0,get:()=>h.encodeBase64Url});Object.defineProperty(exports,"getReleaseVersion",{enumerable:!0,get:()=>h.getReleaseVersion});Object.defineProperty(exports,"isSafeToCreateStartParam",{enumerable:!0,get:()=>h.isSafeToCreateStartParam});Object.defineProperty(exports,"isVBMA",{enumerable:!0,get:()=>h.isVBMA});Object.defineProperty(exports,"isVBMAFp",{enumerable:!0,get:()=>h.isVBMAFp});Object.defineProperty(exports,"logger",{enumerable:!0,get:()=>h.logger});Object.defineProperty(exports,"mockVBotEnv",{enumerable:!0,get:()=>h.mockVBotEnv});Object.defineProperty(exports,"off",{enumerable:!0,get:()=>h.off});Object.defineProperty(exports,"offAll",{enumerable:!0,get:()=>h.offAll});Object.defineProperty(exports,"on",{enumerable:!0,get:()=>h.on});Object.defineProperty(exports,"retrieveLaunchParams",{enumerable:!0,get:()=>h.retrieveLaunchParams});Object.defineProperty(exports,"retrieveLaunchParamsFp",{enumerable:!0,get:()=>h.retrieveLaunchParamsFp});Object.defineProperty(exports,"retrieveRawInitData",{enumerable:!0,get:()=>h.retrieveRawInitData});Object.defineProperty(exports,"retrieveRawInitDataFp",{enumerable:!0,get:()=>h.retrieveRawInitDataFp});Object.defineProperty(exports,"retrieveRawLaunchParams",{enumerable:!0,get:()=>h.retrieveRawLaunchParams});Object.defineProperty(exports,"retrieveRawLaunchParamsFp",{enumerable:!0,get:()=>h.retrieveRawLaunchParamsFp});Object.defineProperty(exports,"setDebug",{enumerable:!0,get:()=>h.setDebug});Object.defineProperty(exports,"setTargetOrigin",{enumerable:!0,get:()=>h.setTargetOrigin});Object.defineProperty(exports,"supports",{enumerable:!0,get:()=>h.supports});Object.defineProperty(exports,"targetOrigin",{enumerable:!0,get:()=>h.targetOrigin});Object.defineProperty(exports,"isAnyRGB",{enumerable:!0,get:()=>A.isAnyRGB});Object.defineProperty(exports,"isRGB",{enumerable:!0,get:()=>A.isRGB});Object.defineProperty(exports,"isRGBA",{enumerable:!0,get:()=>A.isRGBA});Object.defineProperty(exports,"isRGBAShort",{enumerable:!0,get:()=>A.isRGBAShort});Object.defineProperty(exports,"isRGBShort",{enumerable:!0,get:()=>A.isRGBShort});Object.defineProperty(exports,"parseInitDataQuery",{enumerable:!0,get:()=>A.parseInitDataQuery});Object.defineProperty(exports,"parseInitDataQueryFp",{enumerable:!0,get:()=>A.parseInitDataQueryFp});Object.defineProperty(exports,"parseLaunchParamsQuery",{enumerable:!0,get:()=>A.parseLaunchParamsQuery});Object.defineProperty(exports,"parseLaunchParamsQueryFp",{enumerable:!0,get:()=>A.parseLaunchParamsQueryFp});Object.defineProperty(exports,"serializeInitDataQuery",{enumerable:!0,get:()=>A.serializeInitDataQuery});Object.defineProperty(exports,"serializeLaunchParamsQuery",{enumerable:!0,get:()=>A.serializeLaunchParamsQuery});Object.defineProperty(exports,"toRGB",{enumerable:!0,get:()=>A.toRGB});Object.defineProperty(exports,"toRGBFp",{enumerable:!0,get:()=>A.toRGBFp});Object.defineProperty(exports,"toRGBFull",{enumerable:!0,get:()=>A.toRGBFull});Object.defineProperty(exports,"toRGBFullFp",{enumerable:!0,get:()=>A.toRGBFullFp});exports.AccessDeniedError=be;exports.BackButton=De;exports.Biometry=He;exports.CSSVarsBoundError=oe;exports.ClosingBehavior=Qe;exports.CloudStorage=Ke;exports.ConcurrentCallError=ae;exports.DeviceStorage=Ne;exports.DeviceStorageMethodError=xe;exports.FullscreenFailedError=Le;exports.FunctionUnavailableError=Ve;exports.HapticFeedback=Xe;exports.InitData=rt;exports.InvalidArgumentsError=U;exports.InvalidEnvError=jt;exports.Invoice=st;exports.LocationManager=ot;exports.MainButton=at;exports.MiniApp=ht;exports.NotAvailableError=Re;exports.Notification=dt;exports.Popup=ft;exports.QrScanner=bt;exports.Refresh=gt;exports.SecondaryButton=Ft;exports.SecureStorage=wt;exports.SecureStorageMethodError=Te;exports.SetEmojiStatusError=Oe;exports.SettingsButton=Ct;exports.ShareMessageError=je;exports.StoragePermission=xt;exports.SwipeBehavior=St;exports.ThemeParams=ct;exports.UnknownThemeParamsKeyError=$e;exports.ValidationError=ee;exports.Viewport=Mt;exports.addToHomeScreen=pr;exports.addToHomeScreenFp=et;exports.backButton=Ut;exports.biometry=Kt;exports.checkHomeScreenStatus=dr;exports.checkHomeScreenStatusFp=tt;exports.closingBehavior=Nt;exports.cloudStorage=Yt;exports.copyTextToClipboard=us;exports.createRequestId=ce;exports.deviceStorage=Xt;exports.downloadFile=hs;exports.downloadFileFp=kt;exports.getCurrentTime=fs;exports.getCurrentTimeFp=Et;exports.hapticFeedback=ar;exports.hideKeyboard=bs;exports.hideKeyboardFp=yt;exports.init=Ls;exports.initData=mr;exports.initFp=Tt;exports.invoice=br;exports.invokeCustomMethod=ze;exports.isColorDark=ye;exports.isColorDarkFp=ut;exports.locationManager=qr;exports.mainButton=Pr;exports.miniApp=lt;exports.notification=Rr;exports.openLink=wr;exports.openLinkFp=nt;exports.openTelegramLink=kr;exports.openTelegramLinkFp=Se;exports.popup=Lr;exports.postEvent=Ue;exports.postEventFp=Z;exports.qrScanner=Zr;exports.readTextFromClipboard=ws;exports.readTextFromClipboardFp=vt;exports.refresh=es;exports.request=Ht;exports.request2=Wt;exports.request2Fp=we;exports.requestContact=Kr;exports.requestContactComplete=Qr;exports.requestContactCompleteFp=Ie;exports.requestContactFp=mt;exports.requestEmojiStatusAccess=rr;exports.requestEmojiStatusAccessFp=Ye;exports.requestFp=We;exports.requestPhoneAccess=Dr;exports.requestPhoneAccessFp=ve;exports.requestWriteAccess=Jr;exports.requestWriteAccessFp=_t;exports.retrieveAndroidDeviceData=Cs;exports.retrieveAndroidDeviceDataFrom=It;exports.secondaryButton=rs;exports.secureStorage=ns;exports.sendData=Es;exports.sendDataFp=Bt;exports.setEmojiStatus=ir;exports.setEmojiStatusFp=Ze;exports.settingsButton=is;exports.shareMessage=Is;exports.shareMessageFp=qt;exports.shareStory=As;exports.shareStoryFp=At;exports.shareURL=vr;exports.shareURLFp=it;exports.storagePermission=Os;exports.swipeBehavior=as;exports.switchInlineQuery=xs;exports.switchInlineQueryFp=Pt;exports.themeParams=te;exports.viewport=Rs;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|